]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/omap/archomap.c
Import sources from 2011-03-30 iso image
[plan9front.git] / sys / src / 9 / omap / archomap.c
1 /*
2  * omap3530 SoC (e.g. beagleboard) architecture-specific stuff
3  *
4  * errata: usb port 3 cannot operate in ulpi mode, only serial or
5  * ulpi tll mode
6  */
7
8 #include "u.h"
9 #include "../port/lib.h"
10 #include "mem.h"
11 #include "dat.h"
12 #include "fns.h"
13 #include "../port/error.h"
14 #include "io.h"
15 #include "arm.h"
16
17 #include "../port/netif.h"
18 #include "etherif.h"
19 #include "../port/flashif.h"
20 #include "../port/usb.h"
21 #include "usbehci.h"
22
23 #define FREQSEL(x) ((x) << 4)
24
25 typedef struct Cm Cm;
26 typedef struct Cntrl Cntrl;
27 typedef struct Gen Gen;
28 typedef struct Gpio Gpio;
29 typedef struct L3agent L3agent;
30 typedef struct L3protreg L3protreg;
31 typedef struct L3regs L3regs;
32 typedef struct Prm Prm;
33 typedef struct Usbotg Usbotg;
34 typedef struct Usbtll Usbtll;
35
36 /* omap3 non-standard usb stuff */
37 struct Usbotg {
38         uchar   faddr;
39         uchar   power;
40         ushort  intrtx;
41         ushort  intrrx;
42         ushort  intrtxe;
43         ushort  intrrxe;
44         uchar   intrusb;
45         uchar   intrusbe;
46         ushort  frame;
47         uchar   index;
48         uchar   testmode;
49
50         /* indexed registers follow; ignore for now */
51         uchar   _pad0[0x400 - 0x10];
52
53         ulong   otgrev;
54         ulong   otgsyscfg;
55         ulong   otgsyssts;
56         ulong   otgifcsel;      /* interface selection */
57         uchar   _pad1[0x414 - 0x410];
58         ulong   otgforcestdby;
59 };
60
61 enum {
62         /* power bits */
63         Hsen            = 1<<5,         /* high-speed enable */
64
65         /* testmode bits */
66         Forcehost       = 1<<7,         /* force host (vs peripheral) mode */
67         Forcehs         = 1<<4,         /* force high-speed at reset */
68
69         /* otgsyscfg bits */
70         Midle           = 1<<12,        /* no standby mode */
71         Sidle           = 1<<3,         /* no idle mode */
72 //      Softreset       = 1<<1,
73
74         /* otgsyssts bits, per sysstatus */
75 };
76
77 struct Usbtll {
78         ulong   revision;       /* ro */
79         uchar   _pad0[0x10-0x4];
80         ulong   sysconfig;
81         ulong   sysstatus;      /* ro */
82
83         ulong   irqstatus;
84         ulong   irqenable;
85 };
86
87 enum {
88         /* sysconfig bits */
89         Softreset       = 1<<1,
90
91         /* sysstatus bits */
92         Resetdone       = 1<<0,
93         /* only in uhh->sysstatus */
94         Ehci_resetdone  = 1<<2,
95         Ohci_resetdone  = 1<<1,
96 };
97
98 /*
99  * an array of these structs is preceded by error_log at 0x20, control,
100  * error_clear_single, error_clear_multi.  first struct is at offset 0x48.
101  */
102 struct L3protreg {              /* hw: an L3 protection region */
103         uvlong  req_info_perm;
104         uvlong  read_perm;
105         uvlong  write_perm;
106         uvlong  addr_match;     /* ro? write this one last, then flush */
107 };
108
109 // TODO: set these permission bits (e.g., for usb)?
110 enum {
111         Permusbhost     = 1<<9,
112         Permusbotg      = 1<<4,
113         Permsysdma      = 1<<3,
114         Permmpu         = 1<<1,
115 };
116
117 struct L3agent {                /* hw registers */
118         uchar   _pad0[0x20];
119         uvlong  ctl;
120         uvlong  sts;
121         uchar   _pad1[0x58 - 0x30];
122         uvlong  errlog;
123         uvlong  errlogaddr;
124 };
125
126 struct L3regs {
127         L3protreg *base;                /* base of array */
128         int     upper;                  /* index maximum */
129         char    *name;
130 };
131 L3regs l3regs[] = {
132         (L3protreg *)(PHYSL3GPMCPM+0x48), 7, "gpmc",    /* known to be first */
133         (L3protreg *)(PHYSL3PMRT+0x48), 1, "rt",        /* l3 config */
134         (L3protreg *)(PHYSL3OCTRAM+0x48), 7, "ocm ram",
135         (L3protreg *)(PHYSL3OCTROM+0x48), 1, "ocm rom",
136         (L3protreg *)(PHYSL3MAD2D+0x48), 7, "mad2d",    /* die-to-die */
137         (L3protreg *)(PHYSL3IVA+0x48), 3, "iva2.2",     /* a/v */
138 };
139
140 /*
141  * PRM_CLKSEL (0x48306d40) low 3 bits are system clock speed, assuming
142  *      units of MHz: 0 = 12, 1 = 13, 2 = 19.2, 3 = 26, 4 = 38.4, 5 = 16.8
143  */
144
145 struct Cm {                             /* clock management */
146         ulong   fclken;                 /* ``functional'' clock enable */
147         ulong   fclken2;
148         ulong   fclken3;
149         uchar   _pad0[0x10 - 0xc];
150
151         ulong   iclken;                 /* ``interface'' clock enable */
152         ulong   iclken2;
153         ulong   iclken3;
154         uchar   _pad1[0x20 - 0x1c];
155
156         ulong   idlest;                 /* idle status */
157         ulong   idlest2;
158         ulong   idlest3;
159         uchar   _pad2[0x30 - 0x2c];
160
161         ulong   autoidle;
162         ulong   autoidle2;
163         ulong   autoidle3;
164         uchar   _pad3[0x40 - 0x3c];
165
166         union {
167                 ulong   clksel[5];
168                 struct unused {
169                         ulong   sleepdep;
170                         ulong   clkstctrl;
171                         ulong   clkstst;
172                 };
173                 uchar   _pad4[0x70 - 0x40];
174         };
175         ulong   clkoutctrl;
176 };
177
178 struct Prm {                            /* power & reset management */
179         uchar   _pad[0x50];
180         ulong   rstctrl;
181 };
182
183 struct Gpio {
184         ulong   _pad0[4];
185         ulong   sysconfig;
186         ulong   sysstatus;
187
188         ulong   irqsts1;                /* for mpu */
189         ulong   irqen1;
190         ulong   wkupen;
191         ulong   _pad1;
192         ulong   irqsts2;                /* for iva */
193         ulong   irqen2;
194
195         ulong   ctrl;
196
197         ulong   oe;
198         ulong   datain;
199         ulong   dataout;
200
201         ulong   lvldet0;
202         ulong   lvldet1;
203         ulong   risingdet;
204         ulong   fallingdet;
205
206         /* rest are uninteresting */
207         ulong   deben;                  /* debouncing enable */
208         ulong   debtime;
209         ulong   _pad2[2];
210
211         ulong   clrirqen1;
212         ulong   setirqen1;
213         ulong   _pad3[2];
214
215         ulong   clrirqen2;
216         ulong   setirqen2;
217         ulong   _pad4[2];
218
219         ulong   clrwkupen;
220         ulong   setwkupen;
221         ulong   _pad5[2];
222
223         ulong   clrdataout;
224         ulong   setdataout;
225 };
226
227 enum {
228         /* clock enable & idle status bits */
229         Wkusimocp       = 1 << 9,       /* SIM card: uses 120MHz clock */
230         Wkwdt2          = 1 << 5,       /* wdt2 clock enable bit for wakeup */
231         Wkgpio1         = 1 << 3,       /* gpio1 " */
232         Wkgpt1          = 1 << 0,       /* gpt1 " */
233
234         Dssl3l4         = 1 << 0,       /* dss l3, l4 i clks */
235         Dsstv           = 1 << 2,       /* dss tv f clock */
236         Dss2            = 1 << 1,       /* dss clock 2 */
237         Dss1            = 1 << 0,       /* dss clock 1 */
238
239         Pergpio6        = 1 << 17,
240         Pergpio5        = 1 << 16,
241         Pergpio4        = 1 << 15,
242         Pergpio3        = 1 << 14,
243         Pergpio2        = 1 << 13,
244         Perwdt3         = 1 << 12,      /* wdt3 clock enable bit for periphs */
245         Peruart3        = 1 << 11,      /* console uart */
246         Pergpt9         = 1 << 10,
247         Pergpt8         = 1 << 9,
248         Pergpt7         = 1 << 8,
249         Pergpt6         = 1 << 7,
250         Pergpt5         = 1 << 6,
251         Pergpt4         = 1 << 5,
252         Pergpt3         = 1 << 4,
253         Pergpt2         = 1 << 3,       /* gpt2 clock enable bit for periphs */
254
255         Perenable       = Pergpio6 | Pergpio5 | Perwdt3 | Pergpt2 | Peruart3,
256
257         Usbhost2        = 1 << 1,       /* 120MHz clock enable */
258         Usbhost1        = 1 << 0,       /* 48MHz clock enable */
259         Usbhost         = Usbhost1,     /* iclock enable */
260         Usbhostidle     = 1 << 1,
261         Usbhoststdby    = 1 << 0,
262
263         Coreusbhsotg    = 1 << 4,       /* usb hs otg enable bit */
264         Core3usbtll     = 1 << 2,       /* usb tll enable bit */
265
266         /* core->idlest bits */
267         Coreusbhsotgidle = 1 << 5,
268         Coreusbhsotgstdby= 1 << 4,
269
270         Dplllock        = 7,
271
272         /* mpu->idlest2 bits */
273         Dplllocked      = 1,
274         Dpllbypassed    = 0,
275
276         /* wkup->idlest bits */
277         Gpio1idle       = 1 << 3,
278
279         /* dss->idlest bits */
280         Dssidle         = 1 << 1,
281
282         Gpio1vidmagic   = 1<<24 | 1<<8 | 1<<5,  /* gpio 1 pins for video */
283 };
284 enum {
285         Rstgs           = 1 << 1,       /* global sw. reset */
286
287         /* fp control regs.  most are read-only */
288         Fpsid           = 0,
289         Fpscr,                          /* rw */
290         Mvfr1           = 6,
291         Mvfr0,
292         Fpexc,                          /* rw */
293 };
294
295 /* see ether9221.c for explanation */
296 enum {
297         Ethergpio       = 176,
298         Etherchanbit    = 1 << (Ethergpio % 32),
299 };
300
301 /*
302  * these shift values are for the Cortex-A8 L1 cache (A=2, L=6) and
303  * the Cortex-A8 L2 cache (A=3, L=6).
304  * A = log2(# of ways), L = log2(bytes per cache line).
305  * see armv7 arch ref p. 1403.
306  *
307  * #define L1WAYSH 30
308  * #define L1SETSH 6
309  * #define L2WAYSH 29
310  * #define L2SETSH 6
311  */
312 enum {
313         /*
314          * cache capabilities.  write-back vs write-through is controlled
315          * by the Buffered bit in PTEs.
316          */
317         Cawt    = 1 << 31,
318         Cawb    = 1 << 30,
319         Cara    = 1 << 29,
320         Cawa    = 1 << 28,
321 };
322
323 struct Gen {
324         ulong   padconf_off;
325         ulong   devconf0;
326         uchar   _pad0[0x68 - 8];
327         ulong   devconf1;
328 };
329
330 struct Cntrl {
331         ulong   _pad0;
332         ulong   id;
333         ulong   _pad1;
334         ulong   skuid;
335 };
336
337
338 static char *
339 devidstr(ulong)
340 {
341         return "ARM Cortex-A8";
342 }
343
344 void
345 archomaplink(void)
346 {
347 }
348
349 int
350 ispow2(uvlong ul)
351 {
352         /* see Hacker's Delight if this isn't obvious */
353         return (ul & (ul - 1)) == 0;
354 }
355
356 /*
357  * return exponent of smallest power of 2 โ‰ฅ n
358  */
359 int
360 log2(ulong n)
361 {
362         int i;
363
364         i = 31 - clz(n);
365         if (n == 0 || !ispow2(n))
366                 i++;
367         return i;
368 }
369
370 void
371 archconfinit(void)
372 {
373         char *p;
374         ulong mhz;
375
376         assert(m != nil);
377         m->cpuhz = 500 * Mhz;                   /* beagle speed */
378         p = getconf("*cpumhz");
379         if (p) {
380                 mhz = atoi(p) * Mhz;
381                 if (mhz >= 100*Mhz && mhz <= 3000UL*Mhz)
382                         m->cpuhz = mhz;
383         }
384         m->delayloop = m->cpuhz/2000;           /* initial estimate */
385 }
386
387 static void
388 prperm(uvlong perm)
389 {
390         if (perm == MASK(16))
391                 print("all");
392         else
393                 print("%#llux", perm);
394 }
395
396 static void
397 prl3region(L3protreg *pr, int r)
398 {
399         int level, size, addrspace;
400         uvlong am, base;
401
402         if (r == 0)
403                 am = 0;
404         else
405                 am = pr->addr_match;
406         size = (am >> 3) & MASK(5);
407         if (r > 0 && size == 0)                 /* disabled? */
408                 return;
409
410         print("  %d: perms req ", r);
411         prperm(pr->req_info_perm);
412         if (pr->read_perm == pr->write_perm && pr->read_perm == MASK(16))
413                 print(" rw all");
414         else {
415                 print(" read ");
416                 prperm(pr->read_perm);
417                 print(" write ");
418                 prperm(pr->write_perm);
419         }
420         if (r == 0)
421                 print(", all addrs level 0");
422         else {
423                 size = 1 << size;               /* 2^size */
424                 level = (am >> 9) & 1;
425                 if (r == 1)
426                         level = 3;
427                 else
428                         level++;
429                 addrspace = am & 7;
430                 base = am & ~MASK(10);
431                 print(", base %#llux size %dKB level %d addrspace %d",
432                         base, size, level, addrspace);
433         }
434         print("\n");
435         delay(100);
436 }
437
438
439 /*
440  * dump the l3 interconnect firewall settings by protection region.
441  * mpu, sys dma and both usbs (0x21a) should be set in all read & write
442  * permission registers.
443  */
444 static void
445 dumpl3pr(void)
446 {
447         int r;
448         L3regs *reg;
449         L3protreg *pr;
450
451         for (reg = l3regs; reg < l3regs + nelem(l3regs); reg++) {
452                 print("%#p (%s) enabled l3 regions:\n", reg->base, reg->name);
453                 for (r = 0; r <= reg->upper; r++)
454                         prl3region(reg->base + r, r);
455         }
456 if (0) {                                // TODO
457         /* touch up gpmc perms */
458         reg = l3regs;                   /* first entry is gpmc */
459         for (r = 0; r <= reg->upper; r++) {
460                 pr = reg->base + r;
461                 // TODO
462         }
463         print("%#p (%s) modified l3 regions:\n", reg->base, reg->name);
464         for (r = 0; r <= reg->upper; r++)
465                 prl3region(reg->base + r, r);
466 }
467 }
468
469 static void
470 p16(uchar *p, ulong v)
471 {
472         *p++ = v>>8;
473         *p   = v;
474 }
475
476 static void
477 p32(uchar *p, ulong v)
478 {
479         *p++ = v>>24;
480         *p++ = v>>16;
481         *p++ = v>>8;
482         *p   = v;
483 }
484
485 int
486 archether(unsigned ctlrno, Ether *ether)
487 {
488         switch(ctlrno) {
489         case 0:
490                 /* there's no built-in ether on the beagle but igepv2 has 1 */
491                 ether->type = "9221";
492                 ether->ctlrno = ctlrno;
493                 ether->irq = 34;
494                 ether->nopt = 0;
495                 ether->mbps = 100;
496                 return 1;
497         }
498         return -1;
499 }
500
501 /*
502  * turn on all the necessary clocks on the SoC.
503  *
504  * a ``functional'' clock drives a device; an ``interface'' clock drives
505  * its communication with the rest of the system.  so the interface
506  * clock must be enabled to reach the device's registers.
507  *
508  * dplls: 1 mpu, 2 iva2, 3 core, 4 per, 5 per2.
509  */
510
511 static void
512 configmpu(void)
513 {
514         ulong clk, mhz, nmhz, maxmhz;
515         Cm *mpu = (Cm *)PHYSSCMMPU;
516         Cntrl *id = (Cntrl *)PHYSCNTRL;
517
518         if ((id->skuid & MASK(4)) == 8)
519                 maxmhz = 720;
520         else
521                 maxmhz = 600;
522         iprint("cpu capable of %ldMHz operation", maxmhz);
523
524         clk = mpu->clksel[0];
525         mhz = (clk >> 8) & MASK(11);            /* configured speed */
526 //      iprint("\tfclk src %ld; dpll1 mult %ld (MHz) div %ld",
527 //              (clk >> 19) & MASK(3), mhz, clk & MASK(7));
528         iprint("; at %ldMHz", mhz);
529         nmhz = m->cpuhz / Mhz;                  /* nominal speed */
530         if (mhz == nmhz) {
531                 iprint("\n");
532                 return;
533         }
534
535         mhz = nmhz;
536         if (mhz > maxmhz) {
537                 mhz = maxmhz;
538                 iprint("; limiting operation to %ldMHz", mhz);
539         }
540
541         /* disable dpll1 lock mode; put into low-power bypass mode */
542         mpu->fclken2 = mpu->fclken2 & ~MASK(3) | 5;
543         coherence();
544         while (mpu->idlest2 != Dpllbypassed)
545                 ;
546
547         /*
548          * there's a dance to change processor speed,
549          * prescribed in spruf98d ยง4.7.6.9.
550          */
551
552         /* just change multiplier; leave divider alone at 12 (meaning 13?) */
553         mpu->clksel[0] = clk & ~(MASK(11) << 8) | mhz << 8;
554         coherence();
555
556         /* set output divider (M2) in clksel[1]: leave at 1 */
557
558         /*
559          * u-boot calls us with just freqsel 3 (~1MHz) & dpll1 lock mode.
560          */
561         /* set FREQSEL */
562         mpu->fclken2 = mpu->fclken2 & ~FREQSEL(MASK(4)) | FREQSEL(3);
563         coherence();
564
565         /* set ramp-up delay to `fast' */
566         mpu->fclken2 = mpu->fclken2 & ~(MASK(2) << 8) | 3 << 8;
567         coherence();
568
569         /* set auto-recalibration (off) */
570         mpu->fclken2 &= ~(1 << 3);
571         coherence();
572
573         /* disable auto-idle: ? */
574         /* unmask clock intr: later */
575
576         /* enable dpll lock mode */
577         mpu->fclken2 |= Dplllock;
578         coherence();
579         while (mpu->idlest2 != Dplllocked)
580                 ;
581         delay(200);                     /* allow time for speed to ramp up */
582
583         if (((mpu->clksel[0] >> 8) & MASK(11)) != mhz)
584                 panic("mpu clock speed change didn't stick");
585         iprint("; now at %ldMHz\n", mhz);
586 }
587
588 static void
589 configpll(void)
590 {
591         int i;
592         Cm *pll = (Cm *)PHYSSCMPLL;
593
594         pll->clkoutctrl |= 1 << 7;      /* enable sys_clkout2 */
595         coherence();
596         delay(10);
597
598         /*
599          * u-boot calls us with just freqsel 3 (~1MHz) & lock mode
600          * for both dplls (3 & 4).  ensure that.
601          */
602         if ((pll->idlest & 3) != 3) {
603                 /* put dpll[34] into low-power bypass mode */
604                 pll->fclken = pll->fclken & ~(MASK(3) << 16 | MASK(3)) |
605                         1 << 16 | 5;
606                 coherence();
607                 while (pll->idlest & 3)  /* wait for both to bypass or stop */
608                         ;
609
610                 pll->fclken =  (FREQSEL(3) | Dplllock) << 16 |
611                                 FREQSEL(3) | Dplllock;
612                 coherence();
613                 while ((pll->idlest & 3) != 3)  /* wait for both to lock */
614                         ;
615         }
616
617         /*
618          * u-boot calls us with just freqsel 1 (default but undefined)
619          * & stop mode for dpll5.  try to lock it at 120MHz.
620          */
621         if (!(pll->idlest2 & Dplllocked)) {
622                 /* force dpll5 into low-power bypass mode */
623                 pll->fclken2 = 3 << 8 | FREQSEL(1) | 1;
624                 coherence();
625                 for (i = 0; pll->idlest2 & Dplllocked && i < 20; i++)
626                         delay(50);
627                 if (i >= 20)
628                         iprint(" [dpll5 failed to stop]");
629
630                 /*
631                  * CORE_CLK is 26MHz.
632                  */
633                 pll->clksel[4-1] = 120 << 8 | 12;       /* M=120, N=12+1 */
634                 /* M2 divisor: 120MHz clock is exactly the DPLL5 clock */
635                 pll->clksel[5-1] = 1;
636                 coherence();
637
638                 pll->fclken2 = 3 << 8 | FREQSEL(1) | Dplllock; /* def. freq */
639                 coherence();
640
641                 for (i = 0; !(pll->idlest2 & Dplllocked) && i < 20; i++)
642                         delay(50);
643                 if (i >= 20)
644                         iprint(" [dpll5 failed to lock]");
645         }
646         if (!(pll->idlest2 & (1<<1)))
647                 iprint(" [no 120MHz clock]");
648         if (!(pll->idlest2 & (1<<3)))
649                 iprint(" [no dpll5 120MHz clock output]");
650 }
651
652 static void
653 configper(void)
654 {
655         Cm *per = (Cm *)PHYSSCMPER;
656
657         per->clksel[0] &= ~MASK(8);     /* select 32kHz clock for GPTIMER2-9 */
658
659         per->iclken |= Perenable;
660         coherence();
661         per->fclken |= Perenable;
662         coherence();
663         while (per->idlest & Perenable)
664                 ;
665
666         per->autoidle = 0;
667         coherence();
668 }
669
670 static void
671 configwkup(void)
672 {
673         Cm *wkup = (Cm *)PHYSSCMWKUP;
674
675         /* select 32kHz clock (not system clock) for GPTIMER1 */
676         wkup->clksel[0] &= ~1;
677
678         wkup->iclken |= Wkusimocp | Wkwdt2 | Wkgpt1;
679         coherence();
680         wkup->fclken |= Wkusimocp | Wkwdt2 | Wkgpt1;
681         coherence();
682         while (wkup->idlest & (Wkusimocp | Wkwdt2 | Wkgpt1))
683                 ;
684 }
685
686 static void
687 configusb(void)
688 {
689         int i;
690         Cm *usb = (Cm *)PHYSSCMUSB;
691
692         /*
693          * make the usb registers accessible without address faults,
694          * notably uhh, ochi & ehci.  tll seems to be separate & otg is okay.
695          */
696         usb->iclken |= Usbhost;
697         coherence();
698         usb->fclken |= Usbhost1 | Usbhost2;     /* includes 120MHz clock */
699         coherence();
700         for (i = 0; usb->idlest & Usbhostidle && i < 20; i++)
701                 delay(50);
702         if (i >= 20)
703                 iprint(" [usb inaccessible]");
704 }
705
706 static void
707 configcore(void)
708 {
709         Cm *core = (Cm *)PHYSSCMCORE;
710
711         /*
712          * make the usb tll registers accessible.
713          */
714         core->iclken  |= Coreusbhsotg;
715         core->iclken3 |= Core3usbtll;
716         coherence();
717         core->fclken3 |= Core3usbtll;
718         coherence();
719         delay(100);
720         while (core->idlest & Coreusbhsotgidle)
721                 ;
722         if (core->idlest3 & Core3usbtll)
723                 iprint(" [no usb tll]");
724 }
725
726 static void
727 configclks(void)
728 {
729         int s;
730         Gen *gen = (Gen *)PHYSSCMPCONF;
731
732         delay(20);
733         s = splhi();
734         configmpu();            /* sets cpu clock rate, turns on dplls 1 & 2 */
735
736         /*
737          * the main goal is to get enough clocks running, in the right order,
738          * so that usb has all the necessary clock signals.
739          */
740         iprint("clocks:");
741         iprint(" usb");
742         configusb();            /* starts usb clocks & 120MHz clock */
743         iprint(", pll");
744         configpll();            /* starts dplls 3, 4 & 5 & 120MHz clock */
745         iprint(", wakeup");
746         configwkup();           /* starts timer clocks and usim clock */
747         iprint(", per");
748         configper();            /* starts timer & gpio (ether) clocks */
749         iprint(", core");
750         configcore();           /* starts usb tll */
751         iprint("\n");
752
753         gen->devconf0 |= 1 << 1 | 1 << 0;       /* dmareq[01] edge sensitive */
754         /* make dmareq[2-6] edge sensitive */
755         gen->devconf1 |= 1 << 23 | 1 << 22 | 1 << 21 | 1 << 8 | 1 << 7;
756         coherence();
757         splx(s);
758         delay(20);
759 }
760
761 static void
762 resetwait(ulong *reg)
763 {
764         long bound;
765
766         for (bound = 400*Mhz; !(*reg & Resetdone) && bound > 0; bound--)
767                 ;
768         if (bound <= 0)
769                 iprint("archomap: Resetdone didn't come ready\n");
770 }
771
772 /*
773  * gpio irq 1 goes to the mpu intr ctlr; irq 2 goes to the iva's.
774  * this stuff is magic and without it, we won't get irq 34 interrupts
775  * from the 9221 ethernet controller.
776  */
777 static void
778 configgpio(void)
779 {
780         Gpio *gpio = (Gpio *)PHYSGPIO6;
781
782         gpio->sysconfig = Softreset;
783         coherence();
784         resetwait(&gpio->sysstatus);
785
786         gpio->ctrl = 1<<1 | 0;  /* enable this gpio module, gating ratio 1 */
787         gpio->oe |= Etherchanbit;       /* cfg ether pin as input */
788         coherence();
789
790         gpio->irqen1 = Etherchanbit;    /* channel # == pin # */
791         gpio->irqen2 = 0;
792
793         gpio->lvldet0 = Etherchanbit;   /* enable irq ass'n on low det'n */
794         gpio->lvldet1 = 0;              /* disable irq ass'n on high det'n */
795         gpio->risingdet = 0;            /* enable irq rising edge det'n */
796         gpio->fallingdet = 0;           /* disable irq falling edge det'n */
797
798         gpio->wkupen = 0;
799
800         gpio->deben = 0;                /* no de-bouncing */
801         gpio->debtime = 0;
802         coherence();
803
804         gpio->irqsts1 = ~0;             /* dismiss all outstanding intrs */
805         gpio->irqsts2 = ~0;
806         coherence();
807 }
808
809 void
810 configscreengpio(void)
811 {
812         Cm *wkup = (Cm *)PHYSSCMWKUP;
813         Gpio *gpio = (Gpio *)PHYSGPIO1;
814
815         /* no clocksel needed */
816         wkup->iclken |= Wkgpio1;
817         coherence();
818         wkup->fclken |= Wkgpio1;                /* turn gpio clock on */
819         coherence();
820         // wkup->autoidle |= Wkgpio1;           /* set gpio clock on auto */
821         wkup->autoidle = 0;
822         coherence();
823         while (wkup->idlest & Gpio1idle)
824                 ;
825
826         /*
827          * 0 bits in oe are output signals.
828          * enable output for gpio 1 (first gpio) video magic pins.
829          */
830         gpio->oe &= ~Gpio1vidmagic;
831         coherence();
832         gpio->dataout |= Gpio1vidmagic;         /* set output pins to 1 */
833         coherence();
834         delay(50);
835 }
836
837 void
838 screenclockson(void)
839 {
840         Cm *dss = (Cm *)PHYSSCMDSS;
841
842         dss->iclken |= Dssl3l4;
843         coherence();
844         dss->fclken = Dsstv | Dss2 | Dss1;
845         coherence();
846         /* tv fclk is dpll4 clk; dpll4 m4 divide factor for dss1 fclk is 2 */
847         dss->clksel[0] = 1<<12 | 2;
848         coherence();
849         delay(50);
850         while (dss->idlest & Dssidle)
851                 ;
852 }
853
854 void
855 gpioirqclr(void)
856 {
857         Gpio *gpio = (Gpio *)PHYSGPIO6;
858
859         gpio->irqsts1 = gpio->irqsts1;
860         coherence();
861 }
862
863 static char *
864 l1iptype(uint type)
865 {
866         static char *types[] = {
867                 "reserved",
868                 "asid-tagged VIVT",
869                 "VIPT",
870                 "PIPT",
871         };
872
873         if (type >= nelem(types) || types[type] == nil)
874                 return "GOK";
875         return types[type];
876 }
877
878 void
879 cacheinfo(int level, Memcache *cp)
880 {
881         ulong setsways;
882
883         /* select cache level */
884         cpwrsc(CpIDcssel, CpID, CpIDid, 0, (level - 1) << 1);
885
886         setsways = cprdsc(CpIDcsize, CpID, CpIDid, 0);
887         cp->l1ip = cprdsc(0, CpID, CpIDidct, CpIDct);
888         cp->level = level;
889         cp->nways = ((setsways >> 3)  & MASK(10)) + 1;
890         cp->nsets = ((setsways >> 13) & MASK(15)) + 1;
891         cp->log2linelen = (setsways & MASK(2)) + 2 + 2;
892         cp->linelen = 1 << cp->log2linelen;
893         cp->setsways = setsways;
894
895         cp->setsh = cp->log2linelen;
896         cp->waysh = 32 - log2(cp->nways);
897 }
898
899 static void
900 prcachecfg(void)
901 {
902         int cache;
903         Memcache mc;
904
905         for (cache = 1; cache <= 2; cache++) {
906                 cacheinfo(cache, &mc);
907                 iprint("l%d: %d ways %d sets %d bytes/line",
908                         mc.level, mc.nways, mc.nsets, mc.linelen);
909                 if (mc.linelen != CACHELINESZ)
910                         iprint(" *should* be %d", CACHELINESZ);
911                 if (mc.setsways & Cawt)
912                         iprint("; can WT");
913                 if (mc.setsways & Cawb)
914                         iprint("; can WB");
915 #ifdef COMPULSIVE                       /* both caches can do this */
916                 if (mc.setsways & Cara)
917                         iprint("; can read-allocate");
918 #endif
919                 if (mc.setsways & Cawa)
920                         iprint("; can write-allocate");
921                 if (cache == 1)
922                         iprint("; l1 I policy %s",
923                                 l1iptype((mc.l1ip >> 14) & MASK(2)));
924                 iprint("\n");
925         }
926 }
927
928 static char *
929 subarch(int impl, uint sa)
930 {
931         static char *armarchs[] = {
932                 "VFPv1 (pre-armv7)",
933                 "VFPv2 (pre-armv7)",
934                 "VFPv3+ with common VFP subarch v2",
935                 "VFPv3+ with null subarch",
936                 "VFPv3+ with common VFP subarch v3",
937         };
938
939         if (impl != 'A' || sa >= nelem(armarchs))
940                 return "GOK";
941         else
942                 return armarchs[sa];
943 }
944
945 /*
946  * padconf bits in a short, 2 per long register
947  *      15      wakeupevent
948  *      14      wakeupenable
949  *      13      offpulltypeselect
950  *      12      offpulludenable
951  *      11      offoutvalue
952  *      10      offoutenable
953  *      9       offenable
954  *      8       inputenable
955  *      4       pulltypeselect
956  *      3       pulludenable
957  *      2-0     muxmode
958  *
959  * see table 7-5 in ยง7.4.4.3 of spruf98d
960  */
961
962 enum {
963         /* pad config register bits */
964         Inena   = 1 << 8,               /* input enable */
965         Indis   = 0 << 8,               /* input disable */
966         Ptup    = 1 << 4,               /* pull type up */
967         Ptdown  = 0 << 4,               /* pull type down */
968         Ptena   = 1 << 3,               /* pull type selection is active */
969         Ptdis   = 0 << 3,               /* pull type selection is inactive */
970         Muxmode = MASK(3),
971
972         /* pad config registers relevant to flash */
973         GpmcA1          = 0x4800207A,
974         GpmcA2          = 0x4800207C,
975         GpmcA3          = 0x4800207E,
976         GpmcA4          = 0x48002080,
977         GpmcA5          = 0x48002082,
978         GpmcA6          = 0x48002084,
979         GpmcA7          = 0x48002086,
980         GpmcA8          = 0x48002088,
981         GpmcA9          = 0x4800208A,
982         GpmcA10         = 0x4800208C,
983         GpmcD0          = 0x4800208E,
984         GpmcD1          = 0x48002090,
985         GpmcD2          = 0x48002092,
986         GpmcD3          = 0x48002094,
987         GpmcD4          = 0x48002096,
988         GpmcD5          = 0x48002098,
989         GpmcD6          = 0x4800209A,
990         GpmcD7          = 0x4800209C,
991         GpmcD8          = 0x4800209E,
992         GpmcD9          = 0x480020A0,
993         GpmcD10         = 0x480020A2,
994         GpmcD11         = 0x480020A4,
995         GpmcD12         = 0x480020A6,
996         GpmcD13         = 0x480020A8,
997         GpmcD14         = 0x480020AA,
998         GpmcD15         = 0x480020AC,
999         GpmcNCS0        = 0x480020AE,
1000         GpmcNCS1        = 0x480020B0,
1001         GpmcNCS2        = 0x480020B2,
1002         GpmcNCS3        = 0x480020B4,
1003         GpmcNCS4        = 0x480020B6,
1004         GpmcNCS5        = 0x480020B8,
1005         GpmcNCS6        = 0x480020BA,
1006         GpmcNCS7        = 0x480020BC,
1007         GpmcCLK         = 0x480020BE,
1008         GpmcNADV_ALE    = 0x480020C0,
1009         GpmcNOE         = 0x480020C2,
1010         GpmcNWE         = 0x480020C4,
1011         GpmcNBE0_CLE    = 0x480020C6,
1012         GpmcNBE1        = 0x480020C8,
1013         GpmcNWP         = 0x480020CA,
1014         GpmcWAIT0       = 0x480020CC,
1015         GpmcWAIT1       = 0x480020CE,
1016         GpmcWAIT2       = 0x480020D0,
1017         GpmcWAIT3       = 0x480020D2,
1018 };
1019
1020 /* set SCM pad config mux mode */
1021 void
1022 setmuxmode(ulong addr, int shorts, int mode)
1023 {
1024         int omode;
1025         ushort *ptr;
1026
1027         mode &= Muxmode;
1028         for (ptr = (ushort *)addr; shorts-- > 0; ptr++) {
1029                 omode = *ptr & Muxmode;
1030                 if (omode != mode)
1031                         *ptr = *ptr & ~Muxmode | mode;
1032         }
1033         coherence();
1034 }
1035
1036 static void
1037 setpadmodes(void)
1038 {
1039         int off;
1040
1041         /* set scm pad modes for usb; hasn't made any difference yet */
1042         setmuxmode(0x48002166, 7, 5);   /* hsusb3_tll* in mode 5; is mode 4 */
1043         setmuxmode(0x48002180, 1, 5);   /* hsusb3_tll_clk; is mode 4 */
1044         setmuxmode(0x48002184, 4, 5);   /* hsusb3_tll_data?; is mode 1 */
1045         setmuxmode(0x480021a2, 12, 0);  /* hsusb0 (console) in mode 0 */
1046         setmuxmode(0x480021d4, 6, 2);   /* hsusb2_tll* (ehci port 2) in mode 2 */
1047                                         /* mode 3 is hsusb2_data* */
1048         setmuxmode(0x480025d8, 18, 6);  /* hsusb[12]_tll*; mode 3 is */
1049                                         /* hsusb1_data*, hsusb2* */
1050
1051         setmuxmode(0x480020e4, 2, 5);   /* uart3_rx_* in mode 5 */
1052         setmuxmode(0x4800219a, 4, 0);   /* uart3_* in mode 0 */
1053         /* uart3_* in mode 2; TODO: conflicts with hsusb0 */
1054         setmuxmode(0x480021aa, 4, 2);
1055         setmuxmode(0x48002240, 2, 3);   /* uart3_* in mode 3 */
1056
1057         /*
1058          * igep/gumstix only: mode 4 of 21d2 is gpio_176 (smsc9221 ether irq).
1059          * see ether9221.c for more.
1060          */
1061         *(ushort *)0x480021d2 = Inena | Ptup | Ptena | 4;
1062
1063         /* magic from u-boot for flash */
1064         *(ushort *)GpmcA1       = Indis | Ptup | Ptena | 0;
1065         *(ushort *)GpmcA2       = Indis | Ptup | Ptena | 0;
1066         *(ushort *)GpmcA3       = Indis | Ptup | Ptena | 0;
1067         *(ushort *)GpmcA4       = Indis | Ptup | Ptena | 0;
1068         *(ushort *)GpmcA5       = Indis | Ptup | Ptena | 0;
1069         *(ushort *)GpmcA6       = Indis | Ptup | Ptena | 0;
1070         *(ushort *)GpmcA7       = Indis | Ptup | Ptena | 0;
1071         *(ushort *)GpmcA8       = Indis | Ptup | Ptena | 0;
1072         *(ushort *)GpmcA9       = Indis | Ptup | Ptena | 0;
1073         *(ushort *)GpmcA10      = Indis | Ptup | Ptena | 0;
1074
1075         *(ushort *)GpmcD0       = Inena | Ptup | Ptena | 0;
1076         *(ushort *)GpmcD1       = Inena | Ptup | Ptena | 0;
1077         *(ushort *)GpmcD2       = Inena | Ptup | Ptena | 0;
1078         *(ushort *)GpmcD3       = Inena | Ptup | Ptena | 0;
1079         *(ushort *)GpmcD4       = Inena | Ptup | Ptena | 0;
1080         *(ushort *)GpmcD5       = Inena | Ptup | Ptena | 0;
1081         *(ushort *)GpmcD6       = Inena | Ptup | Ptena | 0;
1082         *(ushort *)GpmcD7       = Inena | Ptup | Ptena | 0;
1083         *(ushort *)GpmcD8       = Inena | Ptup | Ptena | 0;
1084         *(ushort *)GpmcD9       = Inena | Ptup | Ptena | 0;
1085         *(ushort *)GpmcD10      = Inena | Ptup | Ptena | 0;
1086         *(ushort *)GpmcD11      = Inena | Ptup | Ptena | 0;
1087         *(ushort *)GpmcD12      = Inena | Ptup | Ptena | 0;
1088         *(ushort *)GpmcD13      = Inena | Ptup | Ptena | 0;
1089         *(ushort *)GpmcD14      = Inena | Ptup | Ptena | 0;
1090         *(ushort *)GpmcD15      = Inena | Ptup | Ptena | 0;
1091
1092         *(ushort *)GpmcNCS0     = Indis | Ptup | Ptena | 0;
1093         *(ushort *)GpmcNCS1     = Indis | Ptup | Ptena | 0;
1094         *(ushort *)GpmcNCS2     = Indis | Ptup | Ptena | 0;
1095         *(ushort *)GpmcNCS3     = Indis | Ptup | Ptena | 0;
1096         *(ushort *)GpmcNCS4     = Indis | Ptup | Ptena | 0;
1097         *(ushort *)GpmcNCS5     = Indis | Ptup | Ptena | 0;
1098         *(ushort *)GpmcNCS6     = Indis | Ptup | Ptena | 0;
1099
1100         *(ushort *)GpmcNOE      = Indis | Ptdown | Ptdis | 0;
1101         *(ushort *)GpmcNWE      = Indis | Ptdown | Ptdis | 0;
1102
1103         *(ushort *)GpmcWAIT2    = Inena | Ptup | Ptena | 4; /* GPIO_64 -ETH_NRESET */
1104         *(ushort *)GpmcNCS7     = Inena | Ptup | Ptena | 1; /* SYS_nDMA_REQ3 */
1105
1106         *(ushort *)GpmcCLK      = Indis | Ptdown | Ptdis | 0;
1107
1108         *(ushort *)GpmcNBE1     = Inena | Ptdown | Ptdis | 0;
1109
1110         *(ushort *)GpmcNADV_ALE = Indis | Ptdown | Ptdis | 0;
1111         *(ushort *)GpmcNBE0_CLE = Indis | Ptdown | Ptdis | 0;
1112
1113         *(ushort *)GpmcNWP      = Inena | Ptdown | Ptdis | 0;
1114
1115         *(ushort *)GpmcWAIT0    = Inena | Ptup | Ptena | 0;
1116         *(ushort *)GpmcWAIT1    = Inena | Ptup | Ptena | 0;
1117         *(ushort *)GpmcWAIT3    = Inena | Ptup | Ptena | 0;
1118
1119         /*
1120          * magic from u-boot: set 0xe00 bits in gpmc_(nwe|noe|nadv_ale)
1121          * to enable `off' mode for each.
1122          */
1123         for (off = 0xc0; off <= 0xc4; off += sizeof(short))
1124                 *((ushort *)(PHYSSCM + off)) |= 0xe00;
1125         coherence();
1126 }
1127
1128 static char *
1129 implement(uchar impl)
1130 {
1131         if (impl == 'A')
1132                 return "arm";
1133         else
1134                 return "unknown";
1135 }
1136
1137 static void
1138 fpon(void)
1139 {
1140         int gotfp, impl;
1141         ulong acc, scr;
1142
1143         gotfp = 1 << CpFP | 1 << CpDFP;
1144         cpwrsc(0, CpCONTROL, 0, CpCPaccess, MASK(28));
1145         acc = cprdsc(0, CpCONTROL, 0, CpCPaccess);
1146         if ((acc & (MASK(2) << (2*CpFP))) == 0) {
1147                 gotfp &= ~(1 << CpFP);
1148                 print("fpon: no single FP coprocessor\n");
1149         }
1150         if ((acc & (MASK(2) << (2*CpDFP))) == 0) {
1151                 gotfp &= ~(1 << CpDFP);
1152                 print("fpon: no double FP coprocessor\n");
1153         }
1154         if (!gotfp) {
1155                 print("fpon: no FP coprocessors\n");
1156                 return;
1157         }
1158
1159         /* enable fp.  must be first operation on the FPUs. */
1160         fpwr(Fpexc, fprd(Fpexc) | 1 << 30);
1161
1162         scr = fprd(Fpsid);
1163         impl = scr >> 24;
1164         print("fp: %s arch %s", implement(impl),
1165                 subarch(impl, (scr >> 16) & MASK(7)));
1166
1167         scr = fprd(Fpscr);
1168         // TODO configure Fpscr further
1169         scr |= 1 << 9;                                  /* div-by-0 exception */
1170         scr &= ~(MASK(2) << 20 | MASK(3) << 16);        /* all ops are scalar */
1171         fpwr(Fpscr, scr);
1172         print("\n");
1173         /* we should now be able to execute VFP-style FP instr'ns natively */
1174 }
1175
1176 static void
1177 resetusb(void)
1178 {
1179         int bound;
1180         Uhh *uhh;
1181         Usbotg *otg;
1182         Usbtll *tll;
1183
1184         iprint("resetting usb: otg...");
1185         otg = (Usbotg *)PHYSUSBOTG;
1186         otg->otgsyscfg = Softreset;     /* see omap35x errata 3.1.1.144 */
1187         coherence();
1188         resetwait(&otg->otgsyssts);
1189         otg->otgsyscfg |= Sidle | Midle;
1190         coherence();
1191
1192         iprint("uhh...");
1193         uhh = (Uhh *)PHYSUHH;
1194         uhh->sysconfig |= Softreset;
1195         coherence();
1196         resetwait(&uhh->sysstatus);
1197         for (bound = 400*Mhz; !(uhh->sysstatus & Resetdone) && bound > 0;
1198             bound--)
1199                 ;
1200         uhh->sysconfig |= Sidle | Midle;
1201
1202         /*
1203          * using the TLL seems to be an optimisation when talking
1204          * to another identical SoC, thus not very useful, so
1205          * force PHY (ULPI) mode.
1206          */
1207         /* this bit is normally off when we get here */
1208         uhh->hostconfig &= ~P1ulpi_bypass;
1209         coherence();
1210         if (uhh->hostconfig & P1ulpi_bypass)
1211                 iprint("utmi (tll) mode...");   /* via tll */
1212         else
1213                 /* external transceiver (phy), no tll */
1214                 iprint("ulpi (phy) mode...");
1215
1216         tll = (Usbtll *)PHYSUSBTLL;
1217         if (probeaddr(PHYSUSBTLL) >= 0) {
1218                 iprint("tll...");
1219                 tll->sysconfig |= Softreset;
1220                 coherence();
1221                 resetwait(&tll->sysstatus);
1222                 tll->sysconfig |= Sidle;
1223                 coherence();
1224         } else
1225                 iprint("no tll...");
1226         iprint("\n");
1227 }
1228
1229 /*
1230  * there are secure sdrc registers at 0x48002460
1231  * sdrc regs at PHYSSDRC; see spruf98c ยง1.2.8.2.
1232  * set or dump l4 prot regs at PHYSL4?
1233  */
1234 void
1235 archreset(void)
1236 {
1237         static int beenhere;
1238
1239         if (beenhere)
1240                 return;
1241         beenhere = 1;
1242
1243         /* conservative temporary values until archconfinit runs */
1244         m->cpuhz = 500 * Mhz;                   /* beagle speed */
1245         m->delayloop = m->cpuhz/2000;           /* initial estimate */
1246
1247 //      dumpl3pr();
1248         prcachecfg();
1249         /* fight omap35x errata 2.0.1.104 */
1250         memset((void *)PHYSSWBOOTCFG, 0, 240);
1251         coherence();
1252
1253         setpadmodes();
1254         configclks();                   /* may change cpu speed */
1255         configgpio();
1256
1257         archconfinit();
1258
1259         resetusb();
1260         fpon();
1261 }
1262
1263 void
1264 archreboot(void)
1265 {
1266         Prm *prm = (Prm *)PHYSPRMGLBL;
1267
1268         iprint("archreboot: reset!\n");
1269         delay(20);
1270
1271         prm->rstctrl |= Rstgs;
1272         coherence();
1273         delay(500);
1274
1275         /* shouldn't get here */
1276         splhi();
1277         iprint("awaiting reset");
1278         for(;;) {
1279                 delay(1000);
1280                 print(".");
1281         }
1282 }
1283
1284 void
1285 kbdinit(void)
1286 {
1287 }
1288
1289 void
1290 lastresortprint(char *buf, long bp)
1291 {
1292         iprint("%.*s", (int)bp, buf);   /* nothing else seems to work */
1293 }
1294
1295 static void
1296 scmdump(ulong addr, int shorts)
1297 {
1298         ushort reg;
1299         ushort *ptr;
1300
1301         ptr = (ushort *)addr;
1302         print("scm regs:\n");
1303         while (shorts-- > 0) {
1304                 reg = *ptr++;
1305                 print("%#p: %#ux\tinputenable %d pulltypeselect %d "
1306                         "pulludenable %d muxmode %d\n",
1307                         ptr, reg, (reg>>8) & 1, (reg>>4) & 1, (reg>>3) & 1,
1308                         reg & 7);
1309         }
1310 }
1311
1312 char *cputype2name(char *buf, int size);
1313
1314 void
1315 cpuidprint(void)
1316 {
1317         char name[64];
1318
1319         cputype2name(name, sizeof name);
1320         delay(250);                             /* let uart catch up */
1321         iprint("cpu%d: %lldMHz ARM %s\n", m->machno, m->cpuhz / Mhz, name);
1322 }
1323
1324 static void
1325 missing(ulong addr, char *name)
1326 {
1327         static int firstmiss = 1;
1328
1329         if (probeaddr(addr) >= 0)
1330                 return;
1331         if (firstmiss) {
1332                 iprint("missing:");
1333                 firstmiss = 0;
1334         } else
1335                 iprint(",\n\t");
1336         iprint(" %s at %#lux", name, addr);
1337 }
1338
1339 /* verify that all the necessary device registers are accessible */
1340 void
1341 chkmissing(void)
1342 {
1343         delay(20);
1344         missing(PHYSSCM, "scm");
1345         missing(KZERO, "dram");
1346         missing(PHYSL3, "l3 config");
1347         missing(PHYSINTC, "intr ctlr");
1348         missing(PHYSTIMER1, "timer1");
1349         missing(PHYSCONS, "console uart2");
1350         missing(PHYSUART0, "uart0");
1351         missing(PHYSUART1, "uart1");
1352         missing(PHYSETHER, "smc9221");          /* not on beagle */
1353         missing(PHYSUSBOTG, "usb otg");
1354         missing(PHYSUHH, "usb uhh");
1355         missing(PHYSOHCI, "usb ohci");
1356         missing(PHYSEHCI, "usb ehci");
1357         missing(PHYSSDMA, "dma");
1358         missing(PHYSWDOG, "watchdog timer");
1359         missing(PHYSUSBTLL, "usb tll");
1360         iprint("\n");
1361         delay(20);
1362 }
1363
1364 void
1365 archflashwp(Flash*, int)
1366 {
1367 }
1368
1369 /*
1370  * for ../port/devflash.c:/^flashreset
1371  * retrieve flash type, virtual base and length and return 0;
1372  * return -1 on error (no flash)
1373  */
1374 int
1375 archflashreset(int bank, Flash *f)
1376 {
1377         if(bank != 0)
1378                 return -1;
1379         /*
1380          * this is set up for the igepv2 board.
1381          * if the beagleboard ever works, we'll have to sort this out.
1382          */
1383         f->type = "onenand";
1384         f->addr = (void*)PHYSNAND;              /* mapped here by archreset */
1385         f->size = 0;                            /* done by probe */
1386         f->width = 1;
1387         f->interleave = 0;
1388         return 0;
1389 }