2 * omap3530 SoC (e.g. beagleboard) architecture-specific stuff
4 * errata: usb port 3 cannot operate in ulpi mode, only serial or
9 #include "../port/lib.h"
13 #include "../port/error.h"
17 #include "../port/netif.h"
18 #include "../port/etherif.h"
19 #include "../port/flashif.h"
20 #include "../port/usb.h"
21 #include "../port/portusbehci.h"
24 #define FREQSEL(x) ((x) << 4)
27 typedef struct Cntrl Cntrl;
28 typedef struct Gen Gen;
29 typedef struct Gpio Gpio;
30 typedef struct L3agent L3agent;
31 typedef struct L3protreg L3protreg;
32 typedef struct L3regs L3regs;
33 typedef struct Prm Prm;
34 typedef struct Usbotg Usbotg;
35 typedef struct Usbtll Usbtll;
37 /* omap3 non-standard usb stuff */
51 /* indexed registers follow; ignore for now */
52 uchar _pad0[0x400 - 0x10];
57 ulong otgifcsel; /* interface selection */
58 uchar _pad1[0x414 - 0x410];
64 Hsen = 1<<5, /* high-speed enable */
67 Forcehost = 1<<7, /* force host (vs peripheral) mode */
68 Forcehs = 1<<4, /* force high-speed at reset */
71 Midle = 1<<12, /* no standby mode */
72 Sidle = 1<<3, /* no idle mode */
75 /* otgsyssts bits, per sysstatus */
79 ulong revision; /* ro */
80 uchar _pad0[0x10-0x4];
82 ulong sysstatus; /* ro */
94 /* only in uhh->sysstatus */
95 Ehci_resetdone = 1<<2,
96 Ohci_resetdone = 1<<1,
100 * an array of these structs is preceded by error_log at 0x20, control,
101 * error_clear_single, error_clear_multi. first struct is at offset 0x48.
103 struct L3protreg { /* hw: an L3 protection region */
104 uvlong req_info_perm;
107 uvlong addr_match; /* ro? write this one last, then flush */
110 // TODO: set these permission bits (e.g., for usb)?
118 struct L3agent { /* hw registers */
122 uchar _pad1[0x58 - 0x30];
128 L3protreg *base; /* base of array */
129 int upper; /* index maximum */
133 (L3protreg *)(PHYSL3GPMCPM+0x48), 7, "gpmc", /* known to be first */
134 (L3protreg *)(PHYSL3PMRT+0x48), 1, "rt", /* l3 config */
135 (L3protreg *)(PHYSL3OCTRAM+0x48), 7, "ocm ram",
136 (L3protreg *)(PHYSL3OCTROM+0x48), 1, "ocm rom",
137 (L3protreg *)(PHYSL3MAD2D+0x48), 7, "mad2d", /* die-to-die */
138 (L3protreg *)(PHYSL3IVA+0x48), 3, "iva2.2", /* a/v */
142 * PRM_CLKSEL (0x48306d40) low 3 bits are system clock speed, assuming
143 * units of MHz: 0 = 12, 1 = 13, 2 = 19.2, 3 = 26, 4 = 38.4, 5 = 16.8
146 struct Cm { /* clock management */
147 ulong fclken; /* ``functional'' clock enable */
150 uchar _pad0[0x10 - 0xc];
152 ulong iclken; /* ``interface'' clock enable */
155 uchar _pad1[0x20 - 0x1c];
157 ulong idlest; /* idle status */
160 uchar _pad2[0x30 - 0x2c];
165 uchar _pad3[0x40 - 0x3c];
174 uchar _pad4[0x70 - 0x40];
179 struct Prm { /* power & reset management */
189 ulong irqsts1; /* for mpu */
193 ulong irqsts2; /* for iva */
207 /* rest are uninteresting */
208 ulong deben; /* debouncing enable */
229 /* clock enable & idle status bits */
230 Wkusimocp = 1 << 9, /* SIM card: uses 120MHz clock */
231 Wkwdt2 = 1 << 5, /* wdt2 clock enable bit for wakeup */
232 Wkgpio1 = 1 << 3, /* gpio1 " */
233 Wkgpt1 = 1 << 0, /* gpt1 " */
235 Dssl3l4 = 1 << 0, /* dss l3, l4 i clks */
236 Dsstv = 1 << 2, /* dss tv f clock */
237 Dss2 = 1 << 1, /* dss clock 2 */
238 Dss1 = 1 << 0, /* dss clock 1 */
245 Perwdt3 = 1 << 12, /* wdt3 clock enable bit for periphs */
246 Peruart3 = 1 << 11, /* console uart */
254 Pergpt2 = 1 << 3, /* gpt2 clock enable bit for periphs */
256 Perenable = Pergpio6 | Pergpio5 | Perwdt3 | Pergpt2 | Peruart3,
258 Usbhost2 = 1 << 1, /* 120MHz clock enable */
259 Usbhost1 = 1 << 0, /* 48MHz clock enable */
260 Usbhost = Usbhost1, /* iclock enable */
261 Usbhostidle = 1 << 1,
262 Usbhoststdby = 1 << 0,
264 Coreusbhsotg = 1 << 4, /* usb hs otg enable bit */
265 Core3usbtll = 1 << 2, /* usb tll enable bit */
267 /* core->idlest bits */
268 Coreusbhsotgidle = 1 << 5,
269 Coreusbhsotgstdby= 1 << 4,
273 /* mpu->idlest2 bits */
277 /* wkup->idlest bits */
280 /* dss->idlest bits */
283 Gpio1vidmagic = 1<<24 | 1<<8 | 1<<5, /* gpio 1 pins for video */
286 Rstgs = 1 << 1, /* global sw. reset */
288 /* fp control regs. most are read-only */
296 /* see ether9221.c for explanation */
299 Etherchanbit = 1 << (Ethergpio % 32),
303 * these shift values are for the Cortex-A8 L1 cache (A=2, L=6) and
304 * the Cortex-A8 L2 cache (A=3, L=6).
305 * A = log2(# of ways), L = log2(bytes per cache line).
306 * see armv7 arch ref p. 1403.
315 * cache capabilities. write-back vs write-through is controlled
316 * by the Buffered bit in PTEs.
327 uchar _pad0[0x68 - 8];
342 return "ARM Cortex-A8";
353 /* see Hacker's Delight if this isn't obvious */
354 return (ul & (ul - 1)) == 0;
358 * return exponent of smallest power of 2 โฅ n
366 if (n == 0 || !ispow2(n))
378 m->cpuhz = 500 * Mhz; /* beagle speed */
379 p = getconf("*cpumhz");
382 if (mhz >= 100*Mhz && mhz <= 3000UL*Mhz)
385 m->delayloop = m->cpuhz/2000; /* initial estimate */
391 if (perm == MASK(16))
394 print("%#llux", perm);
398 prl3region(L3protreg *pr, int r)
400 int level, size, addrspace;
407 size = (am >> 3) & MASK(5);
408 if (r > 0 && size == 0) /* disabled? */
411 print(" %d: perms req ", r);
412 prperm(pr->req_info_perm);
413 if (pr->read_perm == pr->write_perm && pr->read_perm == MASK(16))
417 prperm(pr->read_perm);
419 prperm(pr->write_perm);
422 print(", all addrs level 0");
424 size = 1 << size; /* 2^size */
425 level = (am >> 9) & 1;
431 base = am & ~MASK(10);
432 print(", base %#llux size %dKB level %d addrspace %d",
433 base, size, level, addrspace);
441 * dump the l3 interconnect firewall settings by protection region.
442 * mpu, sys dma and both usbs (0x21a) should be set in all read & write
443 * permission registers.
452 for (reg = l3regs; reg < l3regs + nelem(l3regs); reg++) {
453 print("%#p (%s) enabled l3 regions:\n", reg->base, reg->name);
454 for (r = 0; r <= reg->upper; r++)
455 prl3region(reg->base + r, r);
458 /* touch up gpmc perms */
459 reg = l3regs; /* first entry is gpmc */
460 for (r = 0; r <= reg->upper; r++) {
464 print("%#p (%s) modified l3 regions:\n", reg->base, reg->name);
465 for (r = 0; r <= reg->upper; r++)
466 prl3region(reg->base + r, r);
471 p16(uchar *p, ulong v)
478 p32(uchar *p, ulong v)
487 archether(unsigned ctlrno, Ether *ether)
491 /* there's no built-in ether on the beagle but igepv2 has 1 */
492 ether->type = "9221";
493 ether->ctlrno = ctlrno;
503 * turn on all the necessary clocks on the SoC.
505 * a ``functional'' clock drives a device; an ``interface'' clock drives
506 * its communication with the rest of the system. so the interface
507 * clock must be enabled to reach the device's registers.
509 * dplls: 1 mpu, 2 iva2, 3 core, 4 per, 5 per2.
515 ulong clk, mhz, nmhz, maxmhz;
516 Cm *mpu = (Cm *)PHYSSCMMPU;
517 Cntrl *id = (Cntrl *)PHYSCNTRL;
519 if ((id->skuid & MASK(4)) == 8)
523 iprint("cpu capable of %ldMHz operation", maxmhz);
525 clk = mpu->clksel[0];
526 mhz = (clk >> 8) & MASK(11); /* configured speed */
527 // iprint("\tfclk src %ld; dpll1 mult %ld (MHz) div %ld",
528 // (clk >> 19) & MASK(3), mhz, clk & MASK(7));
529 iprint("; at %ldMHz", mhz);
530 nmhz = m->cpuhz / Mhz; /* nominal speed */
539 iprint("; limiting operation to %ldMHz", mhz);
542 /* disable dpll1 lock mode; put into low-power bypass mode */
543 mpu->fclken2 = mpu->fclken2 & ~MASK(3) | 5;
545 while (mpu->idlest2 != Dpllbypassed)
549 * there's a dance to change processor speed,
550 * prescribed in spruf98d ยง4.7.6.9.
553 /* just change multiplier; leave divider alone at 12 (meaning 13?) */
554 mpu->clksel[0] = clk & ~(MASK(11) << 8) | mhz << 8;
557 /* set output divider (M2) in clksel[1]: leave at 1 */
560 * u-boot calls us with just freqsel 3 (~1MHz) & dpll1 lock mode.
563 mpu->fclken2 = mpu->fclken2 & ~FREQSEL(MASK(4)) | FREQSEL(3);
566 /* set ramp-up delay to `fast' */
567 mpu->fclken2 = mpu->fclken2 & ~(MASK(2) << 8) | 3 << 8;
570 /* set auto-recalibration (off) */
571 mpu->fclken2 &= ~(1 << 3);
574 /* disable auto-idle: ? */
575 /* unmask clock intr: later */
577 /* enable dpll lock mode */
578 mpu->fclken2 |= Dplllock;
580 while (mpu->idlest2 != Dplllocked)
582 delay(200); /* allow time for speed to ramp up */
584 if (((mpu->clksel[0] >> 8) & MASK(11)) != mhz)
585 panic("mpu clock speed change didn't stick");
586 iprint("; now at %ldMHz\n", mhz);
593 Cm *pll = (Cm *)PHYSSCMPLL;
595 pll->clkoutctrl |= 1 << 7; /* enable sys_clkout2 */
600 * u-boot calls us with just freqsel 3 (~1MHz) & lock mode
601 * for both dplls (3 & 4). ensure that.
603 if ((pll->idlest & 3) != 3) {
604 /* put dpll[34] into low-power bypass mode */
605 pll->fclken = pll->fclken & ~(MASK(3) << 16 | MASK(3)) |
608 while (pll->idlest & 3) /* wait for both to bypass or stop */
611 pll->fclken = (FREQSEL(3) | Dplllock) << 16 |
612 FREQSEL(3) | Dplllock;
614 while ((pll->idlest & 3) != 3) /* wait for both to lock */
619 * u-boot calls us with just freqsel 1 (default but undefined)
620 * & stop mode for dpll5. try to lock it at 120MHz.
622 if (!(pll->idlest2 & Dplllocked)) {
623 /* force dpll5 into low-power bypass mode */
624 pll->fclken2 = 3 << 8 | FREQSEL(1) | 1;
626 for (i = 0; pll->idlest2 & Dplllocked && i < 20; i++)
629 iprint(" [dpll5 failed to stop]");
634 pll->clksel[4-1] = 120 << 8 | 12; /* M=120, N=12+1 */
635 /* M2 divisor: 120MHz clock is exactly the DPLL5 clock */
636 pll->clksel[5-1] = 1;
639 pll->fclken2 = 3 << 8 | FREQSEL(1) | Dplllock; /* def. freq */
642 for (i = 0; !(pll->idlest2 & Dplllocked) && i < 20; i++)
645 iprint(" [dpll5 failed to lock]");
647 if (!(pll->idlest2 & (1<<1)))
648 iprint(" [no 120MHz clock]");
649 if (!(pll->idlest2 & (1<<3)))
650 iprint(" [no dpll5 120MHz clock output]");
656 Cm *per = (Cm *)PHYSSCMPER;
658 per->clksel[0] &= ~MASK(8); /* select 32kHz clock for GPTIMER2-9 */
660 per->iclken |= Perenable;
662 per->fclken |= Perenable;
664 while (per->idlest & Perenable)
674 Cm *wkup = (Cm *)PHYSSCMWKUP;
676 /* select 32kHz clock (not system clock) for GPTIMER1 */
677 wkup->clksel[0] &= ~1;
679 wkup->iclken |= Wkusimocp | Wkwdt2 | Wkgpt1;
681 wkup->fclken |= Wkusimocp | Wkwdt2 | Wkgpt1;
683 while (wkup->idlest & (Wkusimocp | Wkwdt2 | Wkgpt1))
691 Cm *usb = (Cm *)PHYSSCMUSB;
694 * make the usb registers accessible without address faults,
695 * notably uhh, ochi & ehci. tll seems to be separate & otg is okay.
697 usb->iclken |= Usbhost;
699 usb->fclken |= Usbhost1 | Usbhost2; /* includes 120MHz clock */
701 for (i = 0; usb->idlest & Usbhostidle && i < 20; i++)
704 iprint(" [usb inaccessible]");
710 Cm *core = (Cm *)PHYSSCMCORE;
713 * make the usb tll registers accessible.
715 core->iclken |= Coreusbhsotg;
716 core->iclken3 |= Core3usbtll;
718 core->fclken3 |= Core3usbtll;
721 while (core->idlest & Coreusbhsotgidle)
723 if (core->idlest3 & Core3usbtll)
724 iprint(" [no usb tll]");
731 Gen *gen = (Gen *)PHYSSCMPCONF;
735 configmpu(); /* sets cpu clock rate, turns on dplls 1 & 2 */
738 * the main goal is to get enough clocks running, in the right order,
739 * so that usb has all the necessary clock signals.
743 configusb(); /* starts usb clocks & 120MHz clock */
745 configpll(); /* starts dplls 3, 4 & 5 & 120MHz clock */
747 configwkup(); /* starts timer clocks and usim clock */
749 configper(); /* starts timer & gpio (ether) clocks */
751 configcore(); /* starts usb tll */
754 gen->devconf0 |= 1 << 1 | 1 << 0; /* dmareq[01] edge sensitive */
755 /* make dmareq[2-6] edge sensitive */
756 gen->devconf1 |= 1 << 23 | 1 << 22 | 1 << 21 | 1 << 8 | 1 << 7;
763 resetwait(ulong *reg)
767 for (bound = 400*Mhz; !(*reg & Resetdone) && bound > 0; bound--)
770 iprint("archomap: Resetdone didn't come ready\n");
774 * gpio irq 1 goes to the mpu intr ctlr; irq 2 goes to the iva's.
775 * this stuff is magic and without it, we won't get irq 34 interrupts
776 * from the 9221 ethernet controller.
781 Gpio *gpio = (Gpio *)PHYSGPIO6;
783 gpio->sysconfig = Softreset;
785 resetwait(&gpio->sysstatus);
787 gpio->ctrl = 1<<1 | 0; /* enable this gpio module, gating ratio 1 */
788 gpio->oe |= Etherchanbit; /* cfg ether pin as input */
791 gpio->irqen1 = Etherchanbit; /* channel # == pin # */
794 gpio->lvldet0 = Etherchanbit; /* enable irq ass'n on low det'n */
795 gpio->lvldet1 = 0; /* disable irq ass'n on high det'n */
796 gpio->risingdet = 0; /* enable irq rising edge det'n */
797 gpio->fallingdet = 0; /* disable irq falling edge det'n */
801 gpio->deben = 0; /* no de-bouncing */
805 gpio->irqsts1 = ~0; /* dismiss all outstanding intrs */
811 configscreengpio(void)
813 Cm *wkup = (Cm *)PHYSSCMWKUP;
814 Gpio *gpio = (Gpio *)PHYSGPIO1;
816 /* no clocksel needed */
817 wkup->iclken |= Wkgpio1;
819 wkup->fclken |= Wkgpio1; /* turn gpio clock on */
821 // wkup->autoidle |= Wkgpio1; /* set gpio clock on auto */
824 while (wkup->idlest & Gpio1idle)
828 * 0 bits in oe are output signals.
829 * enable output for gpio 1 (first gpio) video magic pins.
831 gpio->oe &= ~Gpio1vidmagic;
833 gpio->dataout |= Gpio1vidmagic; /* set output pins to 1 */
841 Cm *dss = (Cm *)PHYSSCMDSS;
843 dss->iclken |= Dssl3l4;
845 dss->fclken = Dsstv | Dss2 | Dss1;
847 /* tv fclk is dpll4 clk; dpll4 m4 divide factor for dss1 fclk is 2 */
848 dss->clksel[0] = 1<<12 | 2;
851 while (dss->idlest & Dssidle)
858 Gpio *gpio = (Gpio *)PHYSGPIO6;
860 gpio->irqsts1 = gpio->irqsts1;
867 static char *types[] = {
874 if (type >= nelem(types) || types[type] == nil)
880 cacheinfo(int level, Memcache *cp)
884 /* select cache level */
885 cpwrsc(CpIDcssel, CpID, CpIDid, 0, (level - 1) << 1);
887 setsways = cprdsc(CpIDcsize, CpID, CpIDid, 0);
888 cp->l1ip = cprdsc(0, CpID, CpIDidct, CpIDct);
890 cp->nways = ((setsways >> 3) & MASK(10)) + 1;
891 cp->nsets = ((setsways >> 13) & MASK(15)) + 1;
892 cp->log2linelen = (setsways & MASK(2)) + 2 + 2;
893 cp->linelen = 1 << cp->log2linelen;
894 cp->setsways = setsways;
896 cp->setsh = cp->log2linelen;
897 cp->waysh = 32 - log2(cp->nways);
906 for (cache = 1; cache <= 2; cache++) {
907 cacheinfo(cache, &mc);
908 iprint("l%d: %d ways %d sets %d bytes/line",
909 mc.level, mc.nways, mc.nsets, mc.linelen);
910 if (mc.linelen != CACHELINESZ)
911 iprint(" *should* be %d", CACHELINESZ);
912 if (mc.setsways & Cawt)
914 if (mc.setsways & Cawb)
916 #ifdef COMPULSIVE /* both caches can do this */
917 if (mc.setsways & Cara)
918 iprint("; can read-allocate");
920 if (mc.setsways & Cawa)
921 iprint("; can write-allocate");
923 iprint("; l1 I policy %s",
924 l1iptype((mc.l1ip >> 14) & MASK(2)));
930 subarch(int impl, uint sa)
932 static char *armarchs[] = {
935 "VFPv3+ with common VFP subarch v2",
936 "VFPv3+ with null subarch",
937 "VFPv3+ with common VFP subarch v3",
940 if (impl != 'A' || sa >= nelem(armarchs))
947 * padconf bits in a short, 2 per long register
950 * 13 offpulltypeselect
960 * see table 7-5 in ยง7.4.4.3 of spruf98d
964 /* pad config register bits */
965 Inena = 1 << 8, /* input enable */
966 Indis = 0 << 8, /* input disable */
967 Ptup = 1 << 4, /* pull type up */
968 Ptdown = 0 << 4, /* pull type down */
969 Ptena = 1 << 3, /* pull type selection is active */
970 Ptdis = 0 << 3, /* pull type selection is inactive */
973 /* pad config registers relevant to flash */
983 GpmcA10 = 0x4800208C,
994 GpmcD10 = 0x480020A2,
995 GpmcD11 = 0x480020A4,
996 GpmcD12 = 0x480020A6,
997 GpmcD13 = 0x480020A8,
998 GpmcD14 = 0x480020AA,
999 GpmcD15 = 0x480020AC,
1000 GpmcNCS0 = 0x480020AE,
1001 GpmcNCS1 = 0x480020B0,
1002 GpmcNCS2 = 0x480020B2,
1003 GpmcNCS3 = 0x480020B4,
1004 GpmcNCS4 = 0x480020B6,
1005 GpmcNCS5 = 0x480020B8,
1006 GpmcNCS6 = 0x480020BA,
1007 GpmcNCS7 = 0x480020BC,
1008 GpmcCLK = 0x480020BE,
1009 GpmcNADV_ALE = 0x480020C0,
1010 GpmcNOE = 0x480020C2,
1011 GpmcNWE = 0x480020C4,
1012 GpmcNBE0_CLE = 0x480020C6,
1013 GpmcNBE1 = 0x480020C8,
1014 GpmcNWP = 0x480020CA,
1015 GpmcWAIT0 = 0x480020CC,
1016 GpmcWAIT1 = 0x480020CE,
1017 GpmcWAIT2 = 0x480020D0,
1018 GpmcWAIT3 = 0x480020D2,
1021 /* set SCM pad config mux mode */
1023 setmuxmode(ulong addr, int shorts, int mode)
1029 for (ptr = (ushort *)addr; shorts-- > 0; ptr++) {
1030 omode = *ptr & Muxmode;
1032 *ptr = *ptr & ~Muxmode | mode;
1042 /* set scm pad modes for usb; hasn't made any difference yet */
1043 setmuxmode(0x48002166, 7, 5); /* hsusb3_tll* in mode 5; is mode 4 */
1044 setmuxmode(0x48002180, 1, 5); /* hsusb3_tll_clk; is mode 4 */
1045 setmuxmode(0x48002184, 4, 5); /* hsusb3_tll_data?; is mode 1 */
1046 setmuxmode(0x480021a2, 12, 0); /* hsusb0 (console) in mode 0 */
1047 setmuxmode(0x480021d4, 6, 2); /* hsusb2_tll* (ehci port 2) in mode 2 */
1048 /* mode 3 is hsusb2_data* */
1049 setmuxmode(0x480025d8, 18, 6); /* hsusb[12]_tll*; mode 3 is */
1050 /* hsusb1_data*, hsusb2* */
1052 setmuxmode(0x480020e4, 2, 5); /* uart3_rx_* in mode 5 */
1053 setmuxmode(0x4800219a, 4, 0); /* uart3_* in mode 0 */
1054 /* uart3_* in mode 2; TODO: conflicts with hsusb0 */
1055 setmuxmode(0x480021aa, 4, 2);
1056 setmuxmode(0x48002240, 2, 3); /* uart3_* in mode 3 */
1059 * igep/gumstix only: mode 4 of 21d2 is gpio_176 (smsc9221 ether irq).
1060 * see ether9221.c for more.
1062 *(ushort *)0x480021d2 = Inena | Ptup | Ptena | 4;
1064 /* magic from u-boot for flash */
1065 *(ushort *)GpmcA1 = Indis | Ptup | Ptena | 0;
1066 *(ushort *)GpmcA2 = Indis | Ptup | Ptena | 0;
1067 *(ushort *)GpmcA3 = Indis | Ptup | Ptena | 0;
1068 *(ushort *)GpmcA4 = Indis | Ptup | Ptena | 0;
1069 *(ushort *)GpmcA5 = Indis | Ptup | Ptena | 0;
1070 *(ushort *)GpmcA6 = Indis | Ptup | Ptena | 0;
1071 *(ushort *)GpmcA7 = Indis | Ptup | Ptena | 0;
1072 *(ushort *)GpmcA8 = Indis | Ptup | Ptena | 0;
1073 *(ushort *)GpmcA9 = Indis | Ptup | Ptena | 0;
1074 *(ushort *)GpmcA10 = Indis | Ptup | Ptena | 0;
1076 *(ushort *)GpmcD0 = Inena | Ptup | Ptena | 0;
1077 *(ushort *)GpmcD1 = Inena | Ptup | Ptena | 0;
1078 *(ushort *)GpmcD2 = Inena | Ptup | Ptena | 0;
1079 *(ushort *)GpmcD3 = Inena | Ptup | Ptena | 0;
1080 *(ushort *)GpmcD4 = Inena | Ptup | Ptena | 0;
1081 *(ushort *)GpmcD5 = Inena | Ptup | Ptena | 0;
1082 *(ushort *)GpmcD6 = Inena | Ptup | Ptena | 0;
1083 *(ushort *)GpmcD7 = Inena | Ptup | Ptena | 0;
1084 *(ushort *)GpmcD8 = Inena | Ptup | Ptena | 0;
1085 *(ushort *)GpmcD9 = Inena | Ptup | Ptena | 0;
1086 *(ushort *)GpmcD10 = Inena | Ptup | Ptena | 0;
1087 *(ushort *)GpmcD11 = Inena | Ptup | Ptena | 0;
1088 *(ushort *)GpmcD12 = Inena | Ptup | Ptena | 0;
1089 *(ushort *)GpmcD13 = Inena | Ptup | Ptena | 0;
1090 *(ushort *)GpmcD14 = Inena | Ptup | Ptena | 0;
1091 *(ushort *)GpmcD15 = Inena | Ptup | Ptena | 0;
1093 *(ushort *)GpmcNCS0 = Indis | Ptup | Ptena | 0;
1094 *(ushort *)GpmcNCS1 = Indis | Ptup | Ptena | 0;
1095 *(ushort *)GpmcNCS2 = Indis | Ptup | Ptena | 0;
1096 *(ushort *)GpmcNCS3 = Indis | Ptup | Ptena | 0;
1097 *(ushort *)GpmcNCS4 = Indis | Ptup | Ptena | 0;
1098 *(ushort *)GpmcNCS5 = Indis | Ptup | Ptena | 0;
1099 *(ushort *)GpmcNCS6 = Indis | Ptup | Ptena | 0;
1101 *(ushort *)GpmcNOE = Indis | Ptdown | Ptdis | 0;
1102 *(ushort *)GpmcNWE = Indis | Ptdown | Ptdis | 0;
1104 *(ushort *)GpmcWAIT2 = Inena | Ptup | Ptena | 4; /* GPIO_64 -ETH_NRESET */
1105 *(ushort *)GpmcNCS7 = Inena | Ptup | Ptena | 1; /* SYS_nDMA_REQ3 */
1107 *(ushort *)GpmcCLK = Indis | Ptdown | Ptdis | 0;
1109 *(ushort *)GpmcNBE1 = Inena | Ptdown | Ptdis | 0;
1111 *(ushort *)GpmcNADV_ALE = Indis | Ptdown | Ptdis | 0;
1112 *(ushort *)GpmcNBE0_CLE = Indis | Ptdown | Ptdis | 0;
1114 *(ushort *)GpmcNWP = Inena | Ptdown | Ptdis | 0;
1116 *(ushort *)GpmcWAIT0 = Inena | Ptup | Ptena | 0;
1117 *(ushort *)GpmcWAIT1 = Inena | Ptup | Ptena | 0;
1118 *(ushort *)GpmcWAIT3 = Inena | Ptup | Ptena | 0;
1121 * magic from u-boot: set 0xe00 bits in gpmc_(nwe|noe|nadv_ale)
1122 * to enable `off' mode for each.
1124 for (off = 0xc0; off <= 0xc4; off += sizeof(short))
1125 *((ushort *)(PHYSSCM + off)) |= 0xe00;
1130 implement(uchar impl)
1144 gotfp = 1 << CpFP | 1 << CpDFP;
1145 cpwrsc(0, CpCONTROL, 0, CpCPaccess, MASK(28));
1146 acc = cprdsc(0, CpCONTROL, 0, CpCPaccess);
1147 if ((acc & (MASK(2) << (2*CpFP))) == 0) {
1148 gotfp &= ~(1 << CpFP);
1149 print("fpon: no single FP coprocessor\n");
1151 if ((acc & (MASK(2) << (2*CpDFP))) == 0) {
1152 gotfp &= ~(1 << CpDFP);
1153 print("fpon: no double FP coprocessor\n");
1156 print("fpon: no FP coprocessors\n");
1160 /* enable fp. must be first operation on the FPUs. */
1161 fpwr(Fpexc, fprd(Fpexc) | 1 << 30);
1165 print("fp: %s arch %s", implement(impl),
1166 subarch(impl, (scr >> 16) & MASK(7)));
1169 // TODO configure Fpscr further
1170 scr |= 1 << 9; /* div-by-0 exception */
1171 scr &= ~(MASK(2) << 20 | MASK(3) << 16); /* all ops are scalar */
1174 /* we should now be able to execute VFP-style FP instr'ns natively */
1185 iprint("resetting usb: otg...");
1186 otg = (Usbotg *)PHYSUSBOTG;
1187 otg->otgsyscfg = Softreset; /* see omap35x errata 3.1.1.144 */
1189 resetwait(&otg->otgsyssts);
1190 otg->otgsyscfg |= Sidle | Midle;
1194 uhh = (Uhh *)PHYSUHH;
1195 uhh->sysconfig |= Softreset;
1197 resetwait(&uhh->sysstatus);
1198 for (bound = 400*Mhz; !(uhh->sysstatus & Resetdone) && bound > 0;
1201 uhh->sysconfig |= Sidle | Midle;
1204 * using the TLL seems to be an optimisation when talking
1205 * to another identical SoC, thus not very useful, so
1206 * force PHY (ULPI) mode.
1208 /* this bit is normally off when we get here */
1209 uhh->hostconfig &= ~P1ulpi_bypass;
1211 if (uhh->hostconfig & P1ulpi_bypass)
1212 iprint("utmi (tll) mode..."); /* via tll */
1214 /* external transceiver (phy), no tll */
1215 iprint("ulpi (phy) mode...");
1217 tll = (Usbtll *)PHYSUSBTLL;
1218 if (probeaddr(PHYSUSBTLL) >= 0) {
1220 tll->sysconfig |= Softreset;
1222 resetwait(&tll->sysstatus);
1223 tll->sysconfig |= Sidle;
1226 iprint("no tll...");
1231 * there are secure sdrc registers at 0x48002460
1232 * sdrc regs at PHYSSDRC; see spruf98c ยง1.2.8.2.
1233 * set or dump l4 prot regs at PHYSL4?
1238 static int beenhere;
1244 /* conservative temporary values until archconfinit runs */
1245 m->cpuhz = 500 * Mhz; /* beagle speed */
1246 m->delayloop = m->cpuhz/2000; /* initial estimate */
1250 /* fight omap35x errata 2.0.1.104 */
1251 memset((void *)PHYSSWBOOTCFG, 0, 240);
1255 configclks(); /* may change cpu speed */
1267 Prm *prm = (Prm *)PHYSPRMGLBL;
1269 iprint("archreboot: reset!\n");
1272 prm->rstctrl |= Rstgs;
1276 /* shouldn't get here */
1278 iprint("awaiting reset");
1286 lastresortprint(char *buf, long bp)
1288 iprint("%.*s", (int)bp, buf); /* nothing else seems to work */
1292 scmdump(ulong addr, int shorts)
1297 ptr = (ushort *)addr;
1298 print("scm regs:\n");
1299 while (shorts-- > 0) {
1301 print("%#p: %#ux\tinputenable %d pulltypeselect %d "
1302 "pulludenable %d muxmode %d\n",
1303 ptr, reg, (reg>>8) & 1, (reg>>4) & 1, (reg>>3) & 1,
1308 char *cputype2name(char *buf, int size);
1315 cputype2name(name, sizeof name);
1316 delay(250); /* let uart catch up */
1317 iprint("cpu%d: %lldMHz ARM %s\n", m->machno, m->cpuhz / Mhz, name);
1321 missing(ulong addr, char *name)
1323 static int firstmiss = 1;
1325 if (probeaddr(addr) >= 0)
1332 iprint(" %s at %#lux", name, addr);
1335 /* verify that all the necessary device registers are accessible */
1340 missing(PHYSSCM, "scm");
1341 missing(KZERO, "dram");
1342 missing(PHYSL3, "l3 config");
1343 missing(PHYSINTC, "intr ctlr");
1344 missing(PHYSTIMER1, "timer1");
1345 missing(PHYSCONS, "console uart2");
1346 missing(PHYSUART0, "uart0");
1347 missing(PHYSUART1, "uart1");
1348 missing(PHYSETHER, "smc9221"); /* not on beagle */
1349 missing(PHYSUSBOTG, "usb otg");
1350 missing(PHYSUHH, "usb uhh");
1351 missing(PHYSOHCI, "usb ohci");
1352 missing(PHYSEHCI, "usb ehci");
1353 missing(PHYSSDMA, "dma");
1354 missing(PHYSWDOG, "watchdog timer");
1355 missing(PHYSUSBTLL, "usb tll");
1361 archflashwp(Flash*, int)
1366 * for ../port/devflash.c:/^flashreset
1367 * retrieve flash type, virtual base and length and return 0;
1368 * return -1 on error (no flash)
1371 archflashreset(int bank, Flash *f)
1376 * this is set up for the igepv2 board.
1377 * if the beagleboard ever works, we'll have to sort this out.
1379 f->type = "onenand";
1380 f->addr = (void*)PHYSNAND; /* mapped here by archreset */
1381 f->size = 0; /* done by probe */