1 diff -urN linux.old/arch/mips/Kconfig linux.dev/arch/mips/Kconfig
2 --- linux.old/arch/mips/Kconfig 2005-12-15 13:26:49.758027500 +0100
3 +++ linux.dev/arch/mips/Kconfig 2005-12-15 12:57:27.889182500 +0100
5 Members include the Acer PICA, MIPS Magnum 4000, MIPS Millenium and
6 Olivetti M700-10 workstations.
9 + bool "Support for BCM947xx based boards"
10 + select DMA_NONCOHERENT
13 + select SYS_HAS_CPU_MIPS32_R1
14 + select SYS_SUPPORTS_32BIT_KERNEL
15 + select SYS_SUPPORTS_LITTLE_ENDIAN
17 + Support for BCM947xx based boards
20 bool "Support for LASAT Networks platforms"
21 select DMA_NONCOHERENT
22 diff -urN linux.old/arch/mips/Makefile linux.dev/arch/mips/Makefile
23 --- linux.old/arch/mips/Makefile 2005-12-15 13:26:49.766024000 +0100
24 +++ linux.dev/arch/mips/Makefile 2005-12-15 12:57:27.921168500 +0100
26 load-$(CONFIG_SIBYTE_BIGSUR) := 0xffffffff80100000
29 +# Broadcom BCM47XX boards
31 +core-$(CONFIG_BCM947XX) += arch/mips/bcm947xx/ arch/mips/bcm947xx/broadcom/
32 +cflags-$(CONFIG_BCM947XX) += -Iarch/mips/bcm947xx/include
33 +load-$(CONFIG_BCM947XX) := 0xffffffff80001000
38 core-$(CONFIG_SNI_RM200_PCI) += arch/mips/sni/
39 diff -urN linux.old/arch/mips/bcm947xx/Makefile linux.dev/arch/mips/bcm947xx/Makefile
40 --- linux.old/arch/mips/bcm947xx/Makefile 1970-01-01 01:00:00.000000000 +0100
41 +++ linux.dev/arch/mips/bcm947xx/Makefile 2005-12-15 14:32:03.580639500 +0100
44 +# Makefile for the BCM47xx specific kernel interface routines
48 +obj-y := irq.o int-handler.o prom.o setup.o time.o pci.o
49 diff -urN linux.old/arch/mips/bcm947xx/broadcom/Makefile linux.dev/arch/mips/bcm947xx/broadcom/Makefile
50 --- linux.old/arch/mips/bcm947xx/broadcom/Makefile 1970-01-01 01:00:00.000000000 +0100
51 +++ linux.dev/arch/mips/bcm947xx/broadcom/Makefile 2005-12-15 16:59:40.571216500 +0100
54 +# Makefile for the BCM47xx specific kernel interface routines
58 +obj-y := sbutils.o linux_osl.o bcmsrom.o bcmutils.o sbmips.o sbpci.o sflash.o nvram.o
59 diff -urN linux.old/arch/mips/bcm947xx/broadcom/bcmsrom.c linux.dev/arch/mips/bcm947xx/broadcom/bcmsrom.c
60 --- linux.old/arch/mips/bcm947xx/broadcom/bcmsrom.c 1970-01-01 01:00:00.000000000 +0100
61 +++ linux.dev/arch/mips/bcm947xx/broadcom/bcmsrom.c 2005-12-15 17:35:21.719238750 +0100
64 + * Misc useful routines to access NIC SROM/OTP .
66 + * Copyright 2005, Broadcom Corporation
67 + * All Rights Reserved.
69 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
70 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
71 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
72 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
76 +#include <typedefs.h>
78 +#include <bcmutils.h>
81 +#include <bcmendian.h>
85 +#include <proto/ethernet.h> /* for sprom content groking */
87 +#define VARS_MAX 4096 /* should be reduced */
89 +#define WRITE_ENABLE_DELAY 500 /* 500 ms after write enable/disable toggle */
90 +#define WRITE_WORD_DELAY 20 /* 20 ms between each word write */
92 +static int initvars_srom_pci(void *sbh, void *curmap, char **vars, int *count);
93 +static int sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc);
95 +static int initvars_table(osl_t *osh, char *start, char *end, char **vars, uint *count);
98 + * Initialize local vars from the right source for this platform.
99 + * Return 0 on success, nonzero on error.
102 +srom_var_init(void *sbh, uint bustype, void *curmap, osl_t *osh, char **vars, int *count)
104 + ASSERT(bustype == BUSTYPE(bustype));
105 + if (vars == NULL || count == NULL)
108 + switch (BUSTYPE(bustype)) {
111 + ASSERT(curmap); /* can not be NULL */
112 + return initvars_srom_pci(sbh, curmap, vars, count);
120 +/* support only 16-bit word read from srom */
122 +srom_read(uint bustype, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf)
127 + ASSERT(bustype == BUSTYPE(bustype));
129 + /* check input - 16-bit access only */
130 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
136 + if (BUSTYPE(bustype) == PCI_BUS) {
139 + srom = (uchar*)curmap + PCI_BAR0_SPROM_OFFSET;
140 + if (sprom_read_pci(srom, off, buf, nw, FALSE))
149 +/* support only 16-bit word write into srom */
151 +srom_write(uint bustype, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf)
154 + uint i, off, nw, crc_range;
155 + uint16 image[SPROM_SIZE], *p;
157 + volatile uint32 val32;
159 + ASSERT(bustype == BUSTYPE(bustype));
161 + /* check input - 16-bit access only */
162 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
165 + crc_range = (((BUSTYPE(bustype) == SDIO_BUS)) ? SPROM_SIZE : SPROM_CRC_RANGE) * 2;
167 + /* if changes made inside crc cover range */
168 + if (byteoff < crc_range) {
169 + nw = (((byteoff + nbytes) > crc_range) ? byteoff + nbytes : crc_range) / 2;
170 + /* read data including entire first 64 words from srom */
171 + if (srom_read(bustype, curmap, osh, 0, nw * 2, image))
174 + bcopy((void*)buf, (void*)&image[byteoff / 2], nbytes);
175 + /* calculate crc */
176 + htol16_buf(image, crc_range);
177 + crc = ~hndcrc8((uint8 *)image, crc_range - 1, CRC8_INIT_VALUE);
178 + ltoh16_buf(image, crc_range);
179 + image[(crc_range / 2) - 1] = (crc << 8) | (image[(crc_range / 2) - 1] & 0xff);
188 + if (BUSTYPE(bustype) == PCI_BUS) {
189 + srom = (uint16*)((uchar*)curmap + PCI_BAR0_SPROM_OFFSET);
190 + /* enable writes to the SPROM */
191 + val32 = OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32));
192 + val32 |= SPROM_WRITEEN;
193 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32);
194 + bcm_mdelay(WRITE_ENABLE_DELAY);
196 + for (i = 0; i < nw; i++) {
197 + W_REG(&srom[off + i], p[i]);
198 + bcm_mdelay(WRITE_WORD_DELAY);
200 + /* disable writes to the SPROM */
201 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32 & ~SPROM_WRITEEN);
206 + bcm_mdelay(WRITE_ENABLE_DELAY);
212 + * Read in and validate sprom.
213 + * Return 0 on success, nonzero on error.
216 +sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc)
221 + /* read the sprom */
222 + for (i = 0; i < nwords; i++)
223 + buf[i] = R_REG(&sprom[wordoff + i]);
226 + /* fixup the endianness so crc8 will pass */
227 + htol16_buf(buf, nwords * 2);
228 + if (hndcrc8((uint8*)buf, nwords * 2, CRC8_INIT_VALUE) != CRC8_GOOD_VALUE)
230 + /* now correct the endianness of the byte array */
231 + ltoh16_buf(buf, nwords * 2);
238 +* Create variable table from memory.
239 +* Return 0 on success, nonzero on error.
242 +initvars_table(osl_t *osh, char *start, char *end, char **vars, uint *count)
244 + int c = (int)(end - start);
246 + /* do it only when there is more than just the null string */
248 + char *vp = MALLOC(osh, c);
252 + bcopy(start, vp, c);
265 + * Initialize nonvolatile variable table from sprom.
266 + * Return 0 on success, nonzero on error.
269 +initvars_srom_pci(void *sbh, void *curmap, char **vars, int *count)
273 + struct ether_addr ea;
278 + osl_t *osh = sb_osh(sbh);
279 + char name[SB_DEVPATH_BUFSZ+16], *value;
280 + char devpath[SB_DEVPATH_BUFSZ];
284 + * Apply CRC over SROM content regardless SROM is present or not,
285 + * and use variable <devpath>sromrev's existance in flash to decide
286 + * if we should return an error when CRC fails or read SROM variables
289 + sprom_read_pci((void*)((int8*)curmap + PCI_BAR0_SPROM_OFFSET), 0, b, sizeof(b)/sizeof(b[0]), TRUE);
291 + /* top word of sprom contains version and crc8 */
292 + sromrev = b[63] & 0xff;
293 + /* bcm4401 sroms misprogrammed */
294 + if (sromrev == 0x10)
297 + /* srom version check */
304 + base = vp = MALLOC(osh, VARS_MAX);
309 + vp += sprintf(vp, "sromrev=%d", sromrev);
312 + if (sromrev >= 3) {
313 + /* New section takes over the 3th hardware function space */
315 + /* Words 22+23 are 11a (mid) ofdm power offsets */
316 + w32 = ((uint32)b[23] << 16) | b[22];
317 + vp += sprintf(vp, "ofdmapo=%d", w32);
320 + /* Words 24+25 are 11a (low) ofdm power offsets */
321 + w32 = ((uint32)b[25] << 16) | b[24];
322 + vp += sprintf(vp, "ofdmalpo=%d", w32);
325 + /* Words 26+27 are 11a (high) ofdm power offsets */
326 + w32 = ((uint32)b[27] << 16) | b[26];
327 + vp += sprintf(vp, "ofdmahpo=%d", w32);
330 + /*GPIO LED Powersave duty cycle (oncount >> 24) (offcount >> 8)*/
331 + w32 = ((uint32)b[43] << 24) | ((uint32)b[42] << 8);
332 + vp += sprintf(vp, "gpiotimerval=%d", w32);
334 + /*GPIO LED Powersave duty cycle (oncount >> 24) (offcount >> 8)*/
335 + w32 = ((uint32)((unsigned char)(b[21] >> 8) & 0xFF) << 24) | /* oncount*/
336 + ((uint32)((unsigned char)(b[21] & 0xFF)) << 8); /* offcount */
337 + vp += sprintf(vp, "gpiotimerval=%d", w32);
342 + if (sromrev >= 2) {
343 + /* New section takes over the 4th hardware function space */
345 + /* Word 29 is max power 11a high/low */
347 + vp += sprintf(vp, "pa1himaxpwr=%d", w & 0xff);
349 + vp += sprintf(vp, "pa1lomaxpwr=%d", (w >> 8) & 0xff);
352 + /* Words 30-32 set the 11alow pa settings,
353 + * 33-35 are the 11ahigh ones.
355 + for (i = 0; i < 3; i++) {
356 + vp += sprintf(vp, "pa1lob%d=%d", i, b[30 + i]);
358 + vp += sprintf(vp, "pa1hib%d=%d", i, b[33 + i]);
363 + vp += sprintf(vp, "ccode=");
365 + vp += sprintf(vp, "ccode=%c%c", (w >> 8), (w & 0xff));
370 + /* parameter section of sprom starts at byte offset 72 */
373 + /* first 6 bytes are il0macaddr */
374 + ea.octet[0] = (b[woff] >> 8) & 0xff;
375 + ea.octet[1] = b[woff] & 0xff;
376 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
377 + ea.octet[3] = b[woff+1] & 0xff;
378 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
379 + ea.octet[5] = b[woff+2] & 0xff;
380 + woff += ETHER_ADDR_LEN/2 ;
381 + bcm_ether_ntoa((uchar*)&ea, eabuf);
382 + vp += sprintf(vp, "il0macaddr=%s", eabuf);
385 + /* next 6 bytes are et0macaddr */
386 + ea.octet[0] = (b[woff] >> 8) & 0xff;
387 + ea.octet[1] = b[woff] & 0xff;
388 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
389 + ea.octet[3] = b[woff+1] & 0xff;
390 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
391 + ea.octet[5] = b[woff+2] & 0xff;
392 + woff += ETHER_ADDR_LEN/2 ;
393 + bcm_ether_ntoa((uchar*)&ea, eabuf);
394 + vp += sprintf(vp, "et0macaddr=%s", eabuf);
397 + /* next 6 bytes are et1macaddr */
398 + ea.octet[0] = (b[woff] >> 8) & 0xff;
399 + ea.octet[1] = b[woff] & 0xff;
400 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
401 + ea.octet[3] = b[woff+1] & 0xff;
402 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
403 + ea.octet[5] = b[woff+2] & 0xff;
404 + woff += ETHER_ADDR_LEN/2 ;
405 + bcm_ether_ntoa((uchar*)&ea, eabuf);
406 + vp += sprintf(vp, "et1macaddr=%s", eabuf);
410 + * Enet phy settings one or two singles or a dual
411 + * Bits 4-0 : MII address for enet0 (0x1f for not there)
412 + * Bits 9-5 : MII address for enet1 (0x1f for not there)
413 + * Bit 14 : Mdio for enet0
414 + * Bit 15 : Mdio for enet1
417 + vp += sprintf(vp, "et0phyaddr=%d", (w & 0x1f));
419 + vp += sprintf(vp, "et1phyaddr=%d", ((w >> 5) & 0x1f));
421 + vp += sprintf(vp, "et0mdcport=%d", ((w >> 14) & 0x1));
423 + vp += sprintf(vp, "et1mdcport=%d", ((w >> 15) & 0x1));
426 + /* Word 46 has board rev, antennas 0/1 & Country code/control */
428 + vp += sprintf(vp, "boardrev=%d", w & 0xff);
432 + vp += sprintf(vp, "cctl=%d", (w >> 8) & 0xf);
434 + vp += sprintf(vp, "cc=%d", (w >> 8) & 0xf);
437 + vp += sprintf(vp, "aa0=%d", (w >> 12) & 0x3);
440 + vp += sprintf(vp, "aa1=%d", (w >> 14) & 0x3);
443 + /* Words 47-49 set the (wl) pa settings */
446 + for (i = 0; i < 3; i++) {
447 + vp += sprintf(vp, "pa0b%d=%d", i, b[woff+i]);
449 + vp += sprintf(vp, "pa1b%d=%d", i, b[woff+i+6]);
454 + * Words 50-51 set the customer-configured wl led behavior.
455 + * 8 bits/gpio pin. High bit: activehi=0, activelo=1;
456 + * LED behavior values defined in wlioctl.h .
459 + if ((w != 0) && (w != 0xffff)) {
461 + vp += sprintf(vp, "wl0gpio0=%d", (w & 0xff));
465 + vp += sprintf(vp, "wl0gpio1=%d", (w >> 8) & 0xff);
469 + if ((w != 0) && (w != 0xffff)) {
471 + vp += sprintf(vp, "wl0gpio2=%d", w & 0xff);
475 + vp += sprintf(vp, "wl0gpio3=%d", (w >> 8) & 0xff);
479 + /* Word 52 is max power 0/1 */
481 + vp += sprintf(vp, "pa0maxpwr=%d", w & 0xff);
483 + vp += sprintf(vp, "pa1maxpwr=%d", (w >> 8) & 0xff);
486 + /* Word 56 is idle tssi target 0/1 */
488 + vp += sprintf(vp, "pa0itssit=%d", w & 0xff);
490 + vp += sprintf(vp, "pa1itssit=%d", (w >> 8) & 0xff);
493 + /* Word 57 is boardflags, if not programmed make it zero */
494 + w32 = (uint32)b[57];
495 + if (w32 == 0xffff) w32 = 0;
497 + /* Word 28 is the high bits of boardflags */
498 + w32 |= (uint32)b[28] << 16;
500 + vp += sprintf(vp, "boardflags=%d", w32);
503 + /* Word 58 is antenna gain 0/1 */
505 + vp += sprintf(vp, "ag0=%d", w & 0xff);
508 + vp += sprintf(vp, "ag1=%d", (w >> 8) & 0xff);
511 + if (sromrev == 1) {
512 + /* set the oem string */
513 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x",
514 + ((b[59] >> 8) & 0xff), (b[59] & 0xff),
515 + ((b[60] >> 8) & 0xff), (b[60] & 0xff),
516 + ((b[61] >> 8) & 0xff), (b[61] & 0xff),
517 + ((b[62] >> 8) & 0xff), (b[62] & 0xff));
519 + } else if (sromrev == 2) {
520 + /* Word 60 OFDM tx power offset from CCK level */
521 + /* OFDM Power Offset - opo */
522 + vp += sprintf(vp, "opo=%d", b[60] & 0xff);
525 + /* Word 60: cck power offsets */
526 + vp += sprintf(vp, "cckpo=%d", b[60]);
529 + /* Words 61+62: 11g ofdm power offsets */
530 + w32 = ((uint32)b[62] << 16) | b[61];
531 + vp += sprintf(vp, "ofdmgpo=%d", w32);
535 + /* final nullbyte terminator */
538 + ASSERT((vp - base) <= VARS_MAX);
540 + err = initvars_table(osh, base, vp, vars, count);
542 + MFREE(osh, base, VARS_MAX);
546 diff -urN linux.old/arch/mips/bcm947xx/broadcom/bcmutils.c linux.dev/arch/mips/bcm947xx/broadcom/bcmutils.c
547 --- linux.old/arch/mips/bcm947xx/broadcom/bcmutils.c 1970-01-01 01:00:00.000000000 +0100
548 +++ linux.dev/arch/mips/bcm947xx/broadcom/bcmutils.c 2005-12-15 20:14:31.420035750 +0100
551 + * Misc useful OS-independent routines.
553 + * Copyright 2005, Broadcom Corporation
554 + * All Rights Reserved.
556 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
557 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
558 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
559 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
563 +#include <typedefs.h>
565 +#include <sbutils.h>
566 +#include <bcmnvram.h>
567 +#include <bcmutils.h>
568 +#include <bcmendian.h>
569 +#include <bcmdevs.h>
571 +unsigned char bcm_ctype[] = {
572 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 0-7 */
573 + _BCM_C,_BCM_C|_BCM_S,_BCM_C|_BCM_S,_BCM_C|_BCM_S,_BCM_C|_BCM_S,_BCM_C|_BCM_S,_BCM_C,_BCM_C, /* 8-15 */
574 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 16-23 */
575 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 24-31 */
576 + _BCM_S|_BCM_SP,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 32-39 */
577 + _BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 40-47 */
578 + _BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D, /* 48-55 */
579 + _BCM_D,_BCM_D,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 56-63 */
580 + _BCM_P,_BCM_U|_BCM_X,_BCM_U|_BCM_X,_BCM_U|_BCM_X,_BCM_U|_BCM_X,_BCM_U|_BCM_X,_BCM_U|_BCM_X,_BCM_U, /* 64-71 */
581 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 72-79 */
582 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 80-87 */
583 + _BCM_U,_BCM_U,_BCM_U,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 88-95 */
584 + _BCM_P,_BCM_L|_BCM_X,_BCM_L|_BCM_X,_BCM_L|_BCM_X,_BCM_L|_BCM_X,_BCM_L|_BCM_X,_BCM_L|_BCM_X,_BCM_L, /* 96-103 */
585 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 104-111 */
586 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 112-119 */
587 + _BCM_L,_BCM_L,_BCM_L,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_C, /* 120-127 */
588 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
589 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
590 + _BCM_S|_BCM_SP,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 160-175 */
591 + _BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 176-191 */
592 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 192-207 */
593 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_P,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_L, /* 208-223 */
594 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 224-239 */
595 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_P,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L /* 240-255 */
599 +bcm_toupper(uchar c)
601 + if (bcm_islower(c))
607 +bcm_strtoul(char *cp, char **endp, uint base)
609 + ulong result, value;
614 + while (bcm_isspace(*cp))
619 + else if (cp[0] == '-') {
625 + if (cp[0] == '0') {
626 + if ((cp[1] == 'x') || (cp[1] == 'X')) {
635 + } else if (base == 16 && (cp[0] == '0') && ((cp[1] == 'x') || (cp[1] == 'X'))) {
641 + while (bcm_isxdigit(*cp) &&
642 + (value = bcm_isdigit(*cp) ? *cp-'0' : bcm_toupper(*cp)-'A'+10) < base) {
643 + result = result*base + value;
648 + result = (ulong)(result * -1);
651 + *endp = (char *)cp;
663 + while (bcm_isdigit(*s))
664 + n = (n * 10) + *s++ - '0';
668 +/* return pointer to location of substring 'needle' in 'haystack' */
670 +bcmstrstr(char *haystack, char *needle)
675 + if ((haystack == NULL) || (needle == NULL))
678 + nlen = strlen(needle);
679 + len = strlen(haystack) - nlen + 1;
681 + for (i = 0; i < len; i++)
682 + if (bcmp(needle, &haystack[i], nlen) == 0)
683 + return (&haystack[i]);
688 +bcmstrcat(char *dest, const char *src)
690 + strcpy(&dest[strlen(dest)], src);
696 +bcm_ether_ntoa(char *ea, char *buf)
698 + sprintf(buf,"%02x:%02x:%02x:%02x:%02x:%02x",
699 + (uchar)ea[0]&0xff, (uchar)ea[1]&0xff, (uchar)ea[2]&0xff,
700 + (uchar)ea[3]&0xff, (uchar)ea[4]&0xff, (uchar)ea[5]&0xff);
704 +/* parse a xx:xx:xx:xx:xx:xx format ethernet address */
706 +bcm_ether_atoe(char *p, char *ea)
711 + ea[i++] = (char) bcm_strtoul(p, &p, 16);
712 + if (!*p++ || i == 6)
724 + for (i = 0; i < ms; i++) {
730 + * Search the name=value vars for a specific one and return its value.
731 + * Returns NULL if not found.
734 +getvar(char *vars, char *name)
739 + len = strlen(name);
741 + /* first look in vars[] */
742 + for (s = vars; s && *s; ) {
743 + if ((bcmp(s, name, len) == 0) && (s[len] == '='))
744 + return (&s[len+1]);
750 + /* then query nvram */
751 + return (BCMINIT(nvram_get)(name));
755 + * Search the vars for a specific one and return its value as
756 + * an integer. Returns 0 if not found.
759 +getintvar(char *vars, char *name)
763 + if ((val = getvar(vars, name)) == NULL)
766 + return (bcm_strtoul(val, NULL, 0));
770 +/* Search for token in comma separated token-string */
772 +findmatch(char *string, char *name)
777 + len = strlen(name);
778 + while ((c = strchr(string, ',')) != NULL) {
779 + if (len == (uint)(c - string) && !strncmp(string, name, len))
784 + return (!strcmp(string, name));
787 +/* Return gpio pin number assigned to the named pin */
789 +* Variable should be in format:
791 +* gpio<N>=pin_name,pin_name
793 +* This format allows multiple features to share the gpio with mutual
796 +* 'def_pin' is returned if a specific gpio is not defined for the requested functionality
797 +* and if def_pin is not used by others.
800 +getgpiopin(char *vars, char *pin_name, uint def_pin)
802 + char name[] = "gpioXXXX";
806 + /* Go thru all possibilities till a match in pin name */
807 + for (pin = 0; pin < GPIO_NUMPINS; pin ++) {
808 + sprintf(name, "gpio%d", pin);
809 + val = getvar(vars, name);
810 + if (val && findmatch(val, pin_name))
814 + if (def_pin != GPIO_PIN_NOTDEFINED) {
815 + /* make sure the default pin is not used by someone else */
816 + sprintf(name, "gpio%d", def_pin);
817 + if (getvar(vars, name)) {
818 + def_pin = GPIO_PIN_NOTDEFINED;
826 +/*******************************************************************************
829 + * Computes a crc8 over the input data using the polynomial:
831 + * x^8 + x^7 +x^6 + x^4 + x^2 + 1
833 + * The caller provides the initial value (either CRC8_INIT_VALUE
834 + * or the previous returned value) to allow for processing of
835 + * discontiguous blocks of data. When generating the CRC the
836 + * caller is responsible for complementing the final return value
837 + * and inserting it into the byte stream. When checking, a final
838 + * return value of CRC8_GOOD_VALUE indicates a valid CRC.
840 + * Reference: Dallas Semiconductor Application Note 27
841 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
842 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
843 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
845 + ******************************************************************************/
847 +static uint8 crc8_table[256] = {
848 + 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B,
849 + 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21,
850 + 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF,
851 + 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5,
852 + 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14,
853 + 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E,
854 + 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80,
855 + 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA,
856 + 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95,
857 + 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF,
858 + 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01,
859 + 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B,
860 + 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA,
861 + 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0,
862 + 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E,
863 + 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34,
864 + 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0,
865 + 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A,
866 + 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54,
867 + 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E,
868 + 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF,
869 + 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5,
870 + 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B,
871 + 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61,
872 + 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E,
873 + 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74,
874 + 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA,
875 + 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0,
876 + 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41,
877 + 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B,
878 + 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5,
879 + 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F
882 +#define CRC_INNER_LOOP(n, c, x) \
883 + (c) = ((c) >> 8) ^ crc##n##_table[((c) ^ (x)) & 0xff]
887 + uint8 *pdata, /* pointer to array of data to process */
888 + uint nbytes, /* number of input data bytes to process */
889 + uint8 crc /* either CRC8_INIT_VALUE or previous return value */
892 + /* hard code the crc loop instead of using CRC_INNER_LOOP macro
893 + * to avoid the undefined and unnecessary (uint8 >> 8) operation. */
894 + while (nbytes-- > 0)
895 + crc = crc8_table[(crc ^ *pdata++) & 0xff];
902 +#define CBUFSIZ (CLEN+4)
908 diff -urN linux.old/arch/mips/bcm947xx/broadcom/linux_osl.c linux.dev/arch/mips/bcm947xx/broadcom/linux_osl.c
909 --- linux.old/arch/mips/bcm947xx/broadcom/linux_osl.c 1970-01-01 01:00:00.000000000 +0100
910 +++ linux.dev/arch/mips/bcm947xx/broadcom/linux_osl.c 2005-12-15 17:11:05.818041750 +0100
913 + * Linux OS Independent Layer
915 + * Copyright 2005, Broadcom Corporation
916 + * All Rights Reserved.
918 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
919 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
920 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
921 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
928 +#include <typedefs.h>
929 +#include <bcmendian.h>
930 +#include <linux/module.h>
931 +#include <linuxver.h>
933 +#include <bcmutils.h>
934 +#include <linux/delay.h>
936 +#include <asm/paccess.h>
940 +#define PCI_CFG_RETRY 10
942 +#define OS_HANDLE_MAGIC 0x1234abcd
943 +#define BCM_MEM_FILENAME_LEN 24
945 +typedef struct bcm_mem_link {
946 + struct bcm_mem_link *prev;
947 + struct bcm_mem_link *next;
950 + char file[BCM_MEM_FILENAME_LEN];
958 + bcm_mem_link_t *dbgmem_list;
962 +osl_pci_read_config(osl_t *osh, uint offset, uint size)
965 + uint retry=PCI_CFG_RETRY;
967 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
969 + /* only 4byte access supported */
973 + pci_read_config_dword(osh->pdev, offset, &val);
974 + if (val != 0xffffffff)
983 +osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val)
985 + uint retry=PCI_CFG_RETRY;
987 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
989 + /* only 4byte access supported */
993 + pci_write_config_dword(osh->pdev, offset, val);
994 + if (offset!=PCI_BAR0_WIN)
996 + if (osl_pci_read_config(osh,offset,size) == val)
1003 +osl_delay(uint usec)
1007 + while (usec > 0) {
1008 + d = MIN(usec, 1000);
1014 diff -urN linux.old/arch/mips/bcm947xx/broadcom/nvram.c linux.dev/arch/mips/bcm947xx/broadcom/nvram.c
1015 --- linux.old/arch/mips/bcm947xx/broadcom/nvram.c 1970-01-01 01:00:00.000000000 +0100
1016 +++ linux.dev/arch/mips/bcm947xx/broadcom/nvram.c 2005-12-15 17:36:23.151078000 +0100
1019 + * NVRAM variable manipulation (Linux kernel half)
1021 + * Copyright 2005, Broadcom Corporation
1022 + * All Rights Reserved.
1024 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1025 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1026 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1027 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1032 +#include <linux/config.h>
1033 +#include <linux/init.h>
1034 +#include <linux/module.h>
1035 +#include <linux/kernel.h>
1036 +#include <linux/string.h>
1037 +#include <linux/interrupt.h>
1038 +#include <linux/spinlock.h>
1039 +#include <linux/slab.h>
1040 +#include <linux/bootmem.h>
1041 +#include <asm/addrspace.h>
1042 +#include <asm/io.h>
1043 +#include <asm/uaccess.h>
1045 +#include <typedefs.h>
1046 +#include <bcmendian.h>
1047 +#include <bcmnvram.h>
1048 +#include <bcmutils.h>
1049 +#include <sbconfig.h>
1050 +#include <sbchipc.h>
1051 +#include <sbutils.h>
1052 +#include <sbmips.h>
1053 +#include <sflash.h>
1055 +/* In BSS to minimize text size and page aligned so it can be mmap()-ed */
1056 +static char nvram_buf[NVRAM_SPACE] __attribute__((aligned(PAGE_SIZE)));
1058 +/* Global SB handle */
1060 +extern spinlock_t bcm947xx_sbh_lock;
1063 +#define sbh_lock bcm947xx_sbh_lock
1065 +#define MB * 1024 * 1024
1067 +/* Probe for NVRAM header */
1069 +early_nvram_init(void)
1071 + struct nvram_header *header;
1073 + struct sflash *info = NULL;
1075 + uint32 base, off, lim;
1078 + if ((cc = sb_setcore(sbh, SB_CC, 0)) != NULL) {
1079 + base = KSEG1ADDR(SB_FLASH2);
1080 + switch (readl(&cc->capabilities) & CAP_FLASH_MASK) {
1082 + lim = SB_FLASH2_SZ;
1087 + if ((info = sflash_init(cc)) == NULL)
1097 + /* extif assumed, Stop at 4 MB */
1098 + base = KSEG1ADDR(SB_FLASH1);
1099 + lim = SB_FLASH1_SZ;
1103 + while (off <= lim) {
1104 + /* Windowed flash access */
1105 + header = (struct nvram_header *) KSEG1ADDR(base + off - NVRAM_SPACE);
1106 + if (header->magic == NVRAM_MAGIC)
1111 + /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
1112 + header = (struct nvram_header *) KSEG1ADDR(base + 4 KB);
1113 + if (header->magic == NVRAM_MAGIC)
1116 + header = (struct nvram_header *) KSEG1ADDR(base + 1 KB);
1117 + if (header->magic == NVRAM_MAGIC)
1120 + printk("early_nvram_init: NVRAM not found\n");
1124 + src = (u32 *) header;
1125 + dst = (u32 *) nvram_buf;
1126 + for (i = 0; i < sizeof(struct nvram_header); i += 4)
1128 + for (; i < header->len && i < NVRAM_SPACE; i += 4)
1129 + *dst++ = ltoh32(*src++);
1132 +/* Early (before mm or mtd) read-only access to NVRAM */
1133 +char * __init nvram_get(const char *name)
1135 + char *var, *value, *end, *eq;
1144 + if (!nvram_buf[0])
1145 + early_nvram_init();
1147 + /* Look for name=value and return value */
1148 + var = &nvram_buf[sizeof(struct nvram_header)];
1149 + end = nvram_buf + sizeof(nvram_buf) - 2;
1150 + end[0] = end[1] = '\0';
1151 + for (; *var; var = value + strlen(value) + 1) {
1152 + if (!(eq = strchr(var, '=')))
1155 + if ((eq - var) == strlen(name) && strncmp(var, name, (eq - var)) == 0)
1162 +EXPORT_SYMBOL(nvram_get);
1163 diff -urN linux.old/arch/mips/bcm947xx/broadcom/sbmips.c linux.dev/arch/mips/bcm947xx/broadcom/sbmips.c
1164 --- linux.old/arch/mips/bcm947xx/broadcom/sbmips.c 1970-01-01 01:00:00.000000000 +0100
1165 +++ linux.dev/arch/mips/bcm947xx/broadcom/sbmips.c 2005-12-15 16:46:31.122961250 +0100
1168 + * BCM47XX Sonics SiliconBackplane MIPS core routines
1170 + * Copyright 2005, Broadcom Corporation
1171 + * All Rights Reserved.
1173 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1174 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1175 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1176 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1181 +#include <typedefs.h>
1183 +#include <sbutils.h>
1184 +#include <bcmdevs.h>
1185 +#include <bcmnvram.h>
1186 +#include <bcmutils.h>
1187 +#include <hndmips.h>
1188 +#include <sbconfig.h>
1189 +#include <sbextif.h>
1190 +#include <sbchipc.h>
1191 +#include <sbmemc.h>
1192 +#include <mipsinc.h>
1193 +#include <sbutils.h>
1196 + * Returns TRUE if an external UART exists at the given base
1200 +BCMINITFN(serial_exists)(uint8 *regs)
1202 + uint8 save_mcr, status1;
1204 + save_mcr = R_REG(®s[UART_MCR]);
1205 + W_REG(®s[UART_MCR], UART_MCR_LOOP | 0x0a);
1206 + status1 = R_REG(®s[UART_MSR]) & 0xf0;
1207 + W_REG(®s[UART_MCR], save_mcr);
1209 + return (status1 == 0x90);
1213 + * Initializes UART access. The callback function will be called once
1217 +BCMINITFN(sb_serial_init)(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift))
1224 + if ((regs = sb_setcore(sbh, SB_EXTIF, 0))) {
1225 + extifregs_t *eir = (extifregs_t *) regs;
1228 + /* Determine external UART register base */
1229 + sb = (sbconfig_t *)((ulong) eir + SBCONFIGOFF);
1230 + base = EXTIF_CFGIF_BASE(sb_base(R_REG(&sb->sbadmatch1)));
1232 + /* Determine IRQ */
1233 + irq = sb_irq(sbh);
1235 + /* Disable GPIO interrupt initially */
1236 + W_REG(&eir->gpiointpolarity, 0);
1237 + W_REG(&eir->gpiointmask, 0);
1239 + /* Search for external UARTs */
1241 + for (i = 0; i < 2; i++) {
1242 + regs = (void *) REG_MAP(base + (i * 8), 8);
1243 + if (BCMINIT(serial_exists)(regs)) {
1244 + /* Set GPIO 1 to be the external UART IRQ */
1245 + W_REG(&eir->gpiointmask, 2);
1247 + add(regs, irq, 13500000, 0);
1251 + /* Add internal UART if enabled */
1252 + if (R_REG(&eir->corecontrol) & CC_UE)
1254 + add((void *) &eir->uartdata, irq, sb_clock(sbh), 2);
1255 + } else if ((regs = sb_setcore(sbh, SB_CC, 0))) {
1256 + chipcregs_t *cc = (chipcregs_t *) regs;
1257 + uint32 rev, cap, pll, baud_base, div;
1259 + /* Determine core revision and capabilities */
1260 + rev = sb_corerev(sbh);
1261 + cap = R_REG(&cc->capabilities);
1262 + pll = cap & CAP_PLL_MASK;
1264 + /* Determine IRQ */
1265 + irq = sb_irq(sbh);
1267 + if (pll == PLL_TYPE1) {
1269 + baud_base = sb_clock_rate(pll,
1270 + R_REG(&cc->clockcontrol_n),
1271 + R_REG(&cc->clockcontrol_m2));
1275 + /* Fixed ALP clock */
1276 + baud_base = 20000000;
1278 + /* Set the override bit so we don't divide it */
1279 + W_REG(&cc->corecontrol, CC_UARTCLKO);
1280 + } else if (rev >= 3) {
1281 + /* Internal backplane clock */
1282 + baud_base = sb_clock(sbh);
1283 + div = 2; /* Minimum divisor */
1284 + W_REG(&cc->clkdiv,
1285 + ((R_REG(&cc->clkdiv) & ~CLKD_UART) | div));
1287 + /* Fixed internal backplane clock */
1288 + baud_base = 88000000;
1292 + /* Clock source depends on strapping if UartClkOverride is unset */
1294 + ((R_REG(&cc->corecontrol) & CC_UARTCLKO) == 0)) {
1295 + if ((cap & CAP_UCLKSEL) == CAP_UINTCLK) {
1296 + /* Internal divided backplane clock */
1299 + /* Assume external clock of 1.8432 MHz */
1300 + baud_base = 1843200;
1305 + /* Add internal UARTs */
1306 + n = cap & CAP_UARTS_MASK;
1307 + for (i = 0; i < n; i++) {
1308 + /* Register offset changed after revision 0 */
1310 + regs = (void *)((ulong) &cc->uart0data + (i * 256));
1312 + regs = (void *)((ulong) &cc->uart0data + (i * 8));
1315 + add(regs, irq, baud_base, 0);
1321 + * Initialize jtag master and return handle for
1322 + * jtag_rwreg. Returns NULL on failure.
1325 +sb_jtagm_init(sb_t *sbh, uint clkd, bool exttap)
1329 + if ((regs = sb_setcore(sbh, SB_CC, 0)) != NULL) {
1330 + chipcregs_t *cc = (chipcregs_t *) regs;
1334 + * Determine jtagm availability from
1335 + * core revision and capabilities.
1337 + tmp = sb_corerev(sbh);
1339 + * Corerev 10 has jtagm, but the only chip
1340 + * with it does not have a mips, and
1341 + * the layout of the jtagcmd register is
1342 + * different. We'll only accept >= 11.
1347 + tmp = R_REG(&cc->capabilities);
1348 + if ((tmp & CAP_JTAGP) == 0)
1351 + /* Set clock divider if requested */
1353 + tmp = R_REG(&cc->clkdiv);
1354 + tmp = (tmp & ~CLKD_JTAG) |
1355 + ((clkd << CLKD_JTAG_SHIFT) & CLKD_JTAG);
1356 + W_REG(&cc->clkdiv, tmp);
1359 + /* Enable jtagm */
1360 + tmp = JCTRL_EN | (exttap ? JCTRL_EXT_EN : 0);
1361 + W_REG(&cc->jtagctrl, tmp);
1368 +sb_jtagm_disable(void *h)
1370 + chipcregs_t *cc = (chipcregs_t *)h;
1372 + W_REG(&cc->jtagctrl, R_REG(&cc->jtagctrl) & ~JCTRL_EN);
1376 + * Read/write a jtag register. Assumes a target with
1377 + * 8 bit IR and 32 bit DR.
1382 +jtag_rwreg(void *h, uint32 ir, uint32 dr)
1384 + chipcregs_t *cc = (chipcregs_t *) h;
1387 + W_REG(&cc->jtagir, ir);
1388 + W_REG(&cc->jtagdr, dr);
1389 + tmp = JCMD_START | JCMD_ACC_IRDR |
1390 + ((IRWIDTH - 1) << JCMD_IRW_SHIFT) |
1392 + W_REG(&cc->jtagcmd, tmp);
1393 + while (((tmp = R_REG(&cc->jtagcmd)) & JCMD_BUSY) == JCMD_BUSY) {
1394 + /* OSL_DELAY(1); */
1397 + tmp = R_REG(&cc->jtagdr);
1401 +/* Returns the SB interrupt flag of the current core. */
1408 + regs = sb_coreregs(sbh);
1409 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
1411 + return (R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK);
1414 +static const uint32 sbips_int_mask[] = {
1422 +static const uint32 sbips_int_shift[] = {
1431 + * Returns the MIPS IRQ assignment of the current core. If unassigned,
1440 + uint32 flag, sbipsflag;
1443 + flag = sb_flag(sbh);
1445 + idx = sb_coreidx(sbh);
1447 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
1448 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
1449 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
1451 + /* sbipsflag specifies which core is routed to interrupts 1 to 4 */
1452 + sbipsflag = R_REG(&sb->sbipsflag);
1453 + for (irq = 1; irq <= 4; irq++) {
1454 + if (((sbipsflag & sbips_int_mask[irq]) >> sbips_int_shift[irq]) == flag)
1461 + sb_setcoreidx(sbh, idx);
1466 +/* Clears the specified MIPS IRQ. */
1468 +BCMINITFN(sb_clearirq)(sb_t *sbh, uint irq)
1473 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
1474 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
1476 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
1479 + W_REG(&sb->sbintvec, 0);
1481 + OR_REG(&sb->sbipsflag, sbips_int_mask[irq]);
1485 + * Assigns the specified MIPS IRQ to the specified core. Shared MIPS
1486 + * IRQ 0 may be assigned more than once.
1489 +BCMINITFN(sb_setirq)(sb_t *sbh, uint irq, uint coreid, uint coreunit)
1495 + regs = sb_setcore(sbh, coreid, coreunit);
1497 + flag = sb_flag(sbh);
1499 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
1500 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
1502 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
1505 + OR_REG(&sb->sbintvec, 1 << flag);
1507 + flag <<= sbips_int_shift[irq];
1508 + ASSERT(!(flag & ~sbips_int_mask[irq]));
1509 + flag |= R_REG(&sb->sbipsflag) & ~sbips_int_mask[irq];
1510 + W_REG(&sb->sbipsflag, flag);
1515 + * Initializes clocks and interrupts. SB and NVRAM access must be
1516 + * initialized prior to calling.
1519 +BCMINITFN(sb_mips_init)(sb_t *sbh)
1521 + ulong hz, ns, tmp;
1527 + /* Figure out current SB clock speed */
1528 + if ((hz = sb_clock(sbh)) == 0)
1530 + ns = 1000000000 / hz;
1532 + /* Setup external interface timing */
1533 + if ((eir = sb_setcore(sbh, SB_EXTIF, 0))) {
1534 + /* Initialize extif so we can get to the LEDs and external UART */
1535 + W_REG(&eir->prog_config, CF_EN);
1537 + /* Set timing for the flash */
1538 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
1539 + tmp = tmp | (CEIL(40, ns) << FW_W1_SHIFT); /* W1 = 40nS */
1540 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
1541 + W_REG(&eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
1543 + /* Set programmable interface timing for external uart */
1544 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
1545 + tmp = tmp | (CEIL(20, ns) << FW_W2_SHIFT); /* W2 = 20nS */
1546 + tmp = tmp | (CEIL(100, ns) << FW_W1_SHIFT); /* W1 = 100nS */
1547 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
1548 + W_REG(&eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
1549 + } else if ((cc = sb_setcore(sbh, SB_CC, 0))) {
1550 + /* Set timing for the flash */
1551 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
1552 + tmp |= CEIL(10, ns) << FW_W1_SHIFT; /* W1 = 10nS */
1553 + tmp |= CEIL(120, ns); /* W0 = 120nS */
1555 + // Added by Chen-I for 5365
1556 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
1558 + W_REG(&cc->flash_waitcount, tmp);
1559 + W_REG(&cc->pcmcia_memwait, tmp);
1563 + if (sb_corerev(sbh) < 9)
1564 + W_REG(&cc->flash_waitcount, tmp);
1566 + if ((sb_corerev(sbh) < 9) ||
1567 + ((BCMINIT(sb_chip)(sbh) == BCM5350_DEVICE_ID) && BCMINIT(sb_chiprev)(sbh) == 0)) {
1568 + W_REG(&cc->pcmcia_memwait, tmp);
1573 + /* Chip specific initialization */
1574 + switch (BCMINIT(sb_chip)(sbh)) {
1575 + case BCM4710_DEVICE_ID:
1576 + /* Clear interrupt map */
1577 + for (irq = 0; irq <= 4; irq++)
1578 + BCMINIT(sb_clearirq)(sbh, irq);
1579 + BCMINIT(sb_setirq)(sbh, 0, SB_CODEC, 0);
1580 + BCMINIT(sb_setirq)(sbh, 0, SB_EXTIF, 0);
1581 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 1);
1582 + BCMINIT(sb_setirq)(sbh, 3, SB_ILINE20, 0);
1583 + BCMINIT(sb_setirq)(sbh, 4, SB_PCI, 0);
1585 + value = BCMINIT(nvram_get)("et0phyaddr");
1586 + if (value && !strcmp(value, "31")) {
1587 + /* Enable internal UART */
1588 + W_REG(&eir->corecontrol, CC_UE);
1589 + /* Give USB its own interrupt */
1590 + BCMINIT(sb_setirq)(sbh, 1, SB_USB, 0);
1592 + /* Disable internal UART */
1593 + W_REG(&eir->corecontrol, 0);
1594 + /* Give Ethernet its own interrupt */
1595 + BCMINIT(sb_setirq)(sbh, 1, SB_ENET, 0);
1596 + BCMINIT(sb_setirq)(sbh, 0, SB_USB, 0);
1599 + case BCM5350_DEVICE_ID:
1600 + /* Clear interrupt map */
1601 + for (irq = 0; irq <= 4; irq++)
1602 + BCMINIT(sb_clearirq)(sbh, irq);
1603 + BCMINIT(sb_setirq)(sbh, 0, SB_CC, 0);
1604 + BCMINIT(sb_setirq)(sbh, 1, SB_D11, 0);
1605 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 0);
1606 + BCMINIT(sb_setirq)(sbh, 3, SB_PCI, 0);
1607 + BCMINIT(sb_setirq)(sbh, 4, SB_USB, 0);
1613 +BCMINITFN(sb_mips_clock)(sb_t *sbh)
1619 + uint32 pll_type, rate = 0;
1621 + /* get index of the current core */
1622 + idx = sb_coreidx(sbh);
1623 + pll_type = PLL_TYPE1;
1625 + /* switch to extif or chipc core */
1626 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
1627 + n = R_REG(&eir->clockcontrol_n);
1628 + m = R_REG(&eir->clockcontrol_sb);
1629 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
1630 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
1631 + n = R_REG(&cc->clockcontrol_n);
1632 + if ((pll_type == PLL_TYPE2) ||
1633 + (pll_type == PLL_TYPE4) ||
1634 + (pll_type == PLL_TYPE6) ||
1635 + (pll_type == PLL_TYPE7))
1636 + m = R_REG(&cc->clockcontrol_mips);
1637 + else if (pll_type == PLL_TYPE5) {
1641 + else if (pll_type == PLL_TYPE3) {
1642 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID) { /* 5365 is also type3 */
1646 + m = R_REG(&cc->clockcontrol_m2); /* 5350 uses m2 to control mips */
1648 + m = R_REG(&cc->clockcontrol_sb);
1652 + // Added by Chen-I for 5365
1653 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
1656 + /* calculate rate */
1657 + rate = sb_clock_rate(pll_type, n, m);
1659 + if (pll_type == PLL_TYPE6)
1660 + rate = SB2MIPS_T6(rate);
1663 + /* switch back to previous core */
1664 + sb_setcoreidx(sbh, idx);
1669 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4)
1672 +BCMINITFN(handler)(void)
1676 + ".set\tmips32\n\t"
1679 + /* Disable interrupts */
1680 + /* MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) & ~(ALLINTS | STO_IE)); */
1681 + "mfc0 $15, $12\n\t"
1682 + /* Just a Hack to not to use reg 'at' which was causing problems on 4704 A2 */
1683 + "li $14, -31746\n\t"
1684 + "and $15, $15, $14\n\t"
1685 + "mtc0 $15, $12\n\t"
1693 +/* The following MUST come right after handler() */
1695 +BCMINITFN(afterhandler)(void)
1700 + * Set the MIPS, backplane and PCI clocks as closely as possible.
1703 +BCMINITFN(sb_mips_setclock)(sb_t *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock)
1705 + extifregs_t *eir = NULL;
1706 + chipcregs_t *cc = NULL;
1707 + mipsregs_t *mipsr = NULL;
1708 + volatile uint32 *clockcontrol_n, *clockcontrol_sb, *clockcontrol_pci, *clockcontrol_m2;
1709 + uint32 orig_n, orig_sb, orig_pci, orig_m2, orig_mips, orig_ratio_parm, orig_ratio_cfg;
1710 + uint32 pll_type, sync_mode;
1711 + uint ic_size, ic_lsize;
1720 + static n3m_table_t BCMINITDATA(type1_table)[] = {
1721 + { 96000000, 0x0303, 0x04020011, 0x11030011, 0x11050011 }, /* 96.000 32.000 24.000 */
1722 + { 100000000, 0x0009, 0x04020011, 0x11030011, 0x11050011 }, /* 100.000 33.333 25.000 */
1723 + { 104000000, 0x0802, 0x04020011, 0x11050009, 0x11090009 }, /* 104.000 31.200 24.960 */
1724 + { 108000000, 0x0403, 0x04020011, 0x11050009, 0x02000802 }, /* 108.000 32.400 24.923 */
1725 + { 112000000, 0x0205, 0x04020011, 0x11030021, 0x02000403 }, /* 112.000 32.000 24.889 */
1726 + { 115200000, 0x0303, 0x04020009, 0x11030011, 0x11050011 }, /* 115.200 32.000 24.000 */
1727 + { 120000000, 0x0011, 0x04020011, 0x11050011, 0x11090011 }, /* 120.000 30.000 24.000 */
1728 + { 124800000, 0x0802, 0x04020009, 0x11050009, 0x11090009 }, /* 124.800 31.200 24.960 */
1729 + { 128000000, 0x0305, 0x04020011, 0x11050011, 0x02000305 }, /* 128.000 32.000 24.000 */
1730 + { 132000000, 0x0603, 0x04020011, 0x11050011, 0x02000305 }, /* 132.000 33.000 24.750 */
1731 + { 136000000, 0x0c02, 0x04020011, 0x11090009, 0x02000603 }, /* 136.000 32.640 24.727 */
1732 + { 140000000, 0x0021, 0x04020011, 0x11050021, 0x02000c02 }, /* 140.000 30.000 24.706 */
1733 + { 144000000, 0x0405, 0x04020011, 0x01020202, 0x11090021 }, /* 144.000 30.857 24.686 */
1734 + { 150857142, 0x0605, 0x04020021, 0x02000305, 0x02000605 }, /* 150.857 33.000 24.000 */
1735 + { 152000000, 0x0e02, 0x04020011, 0x11050021, 0x02000e02 }, /* 152.000 32.571 24.000 */
1736 + { 156000000, 0x0802, 0x04020005, 0x11050009, 0x11090009 }, /* 156.000 31.200 24.960 */
1737 + { 160000000, 0x0309, 0x04020011, 0x11090011, 0x02000309 }, /* 160.000 32.000 24.000 */
1738 + { 163200000, 0x0c02, 0x04020009, 0x11090009, 0x02000603 }, /* 163.200 32.640 24.727 */
1739 + { 168000000, 0x0205, 0x04020005, 0x11030021, 0x02000403 }, /* 168.000 32.000 24.889 */
1740 + { 176000000, 0x0602, 0x04020003, 0x11050005, 0x02000602 }, /* 176.000 33.000 24.000 */
1745 + uint32 m2; /* that is the clockcontrol_m2 */
1747 + static type3_table_t type3_table[] = { /* for 5350, mips clock is always double sb clock */
1748 + { 150000000, 0x311, 0x4020005 },
1749 + { 200000000, 0x311, 0x4020003 },
1760 + uint32 ratio_parm;
1763 + static n4m_table_t BCMINITDATA(type2_table)[] = {
1764 + { 180000000, 80000000, 0x0403, 0x01010000, 0x01020300, 0x01020600, 0x05000100, 8, 0x012a00a9 },
1765 + { 180000000, 90000000, 0x0403, 0x01000100, 0x01020300, 0x01000100, 0x05000100, 11, 0x0aaa0555 },
1766 + { 200000000, 100000000, 0x0303, 0x02010000, 0x02040001, 0x02010000, 0x06000001, 11, 0x0aaa0555 },
1767 + { 211200000, 105600000, 0x0902, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
1768 + { 220800000, 110400000, 0x1500, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
1769 + { 230400000, 115200000, 0x0604, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
1770 + { 234000000, 104000000, 0x0b01, 0x01010000, 0x01010700, 0x01020600, 0x05000100, 8, 0x012a00a9 },
1771 + { 240000000, 120000000, 0x0803, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
1772 + { 252000000, 126000000, 0x0504, 0x01000100, 0x01020500, 0x01000100, 0x05000100, 11, 0x0aaa0555 },
1773 + { 264000000, 132000000, 0x0903, 0x01000200, 0x01020700, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
1774 + { 270000000, 120000000, 0x0703, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 },
1775 + { 276000000, 122666666, 0x1500, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 },
1776 + { 280000000, 140000000, 0x0503, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 11, 0x0aaa0555 },
1777 + { 288000000, 128000000, 0x0604, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 },
1778 + { 288000000, 144000000, 0x0404, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 11, 0x0aaa0555 },
1779 + { 300000000, 133333333, 0x0803, 0x01010000, 0x01020600, 0x01020600, 0x05000100, 8, 0x012a00a9 },
1780 + { 300000000, 150000000, 0x0803, 0x01000100, 0x01020600, 0x01000100, 0x05000100, 11, 0x0aaa0555 }
1783 + static n4m_table_t BCMINITDATA(type4_table)[] = {
1784 + { 192000000, 96000000, 0x0702, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 },
1785 + { 198000000, 99000000, 0x0603, 0x11020005, 0x11030011, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
1786 + { 200000000, 100000000, 0x0009, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 11, 0x0aaa0555 },
1787 + { 204000000, 102000000, 0x0c02, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
1788 + { 208000000, 104000000, 0x0802, 0x11030002, 0x11090005, 0x11030002, 0x04000003, 11, 0x0aaa0555 },
1789 + { 210000000, 105000000, 0x0209, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
1790 + { 216000000, 108000000, 0x0111, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
1791 + { 224000000, 112000000, 0x0205, 0x11030002, 0x02002103, 0x11030002, 0x04000003, 11, 0x0aaa0555 },
1792 + { 228000000, 101333333, 0x0e02, 0x11030003, 0x11210005, 0x01030305, 0x04000005, 8, 0x012a00a9 },
1793 + { 228000000, 114000000, 0x0e02, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
1794 + { 240000000, 102857143, 0x0109, 0x04000021, 0x01050203, 0x11030021, 0x04000003, 13, 0x254a14a9 },
1795 + { 240000000, 120000000, 0x0109, 0x11030002, 0x01050203, 0x11030002, 0x04000003, 11, 0x0aaa0555 },
1796 + { 252000000, 100800000, 0x0203, 0x04000009, 0x11050005, 0x02000209, 0x04000002, 9, 0x02520129 },
1797 + { 252000000, 126000000, 0x0203, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 11, 0x0aaa0555 },
1798 + { 264000000, 132000000, 0x0602, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 11, 0x0aaa0555 },
1799 + { 272000000, 116571428, 0x0c02, 0x04000021, 0x02000909, 0x02000221, 0x04000003, 13, 0x254a14a9 },
1800 + { 280000000, 120000000, 0x0209, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 13, 0x254a14a9 },
1801 + { 288000000, 123428571, 0x0111, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 13, 0x254a14a9 },
1802 + { 300000000, 120000000, 0x0009, 0x04000009, 0x01030203, 0x02000902, 0x04000002, 9, 0x02520129 },
1803 + { 300000000, 150000000, 0x0009, 0x04000005, 0x01030203, 0x04000005, 0x04000002, 11, 0x0aaa0555 }
1806 + static n4m_table_t BCMINITDATA(type7_table)[] = {
1807 + { 183333333, 91666666, 0x0605, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 },
1808 + { 187500000, 93750000, 0x0a03, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 },
1809 + { 196875000, 98437500, 0x1003, 0x11020005, 0x11050011, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
1810 + { 200000000, 100000000, 0x0311, 0x04000011, 0x11030011, 0x04000009, 0x04000003, 11, 0x0aaa0555 },
1811 + { 200000000, 100000000, 0x0311, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 11, 0x0aaa0555 },
1812 + { 206250000, 103125000, 0x1103, 0x11020005, 0x11050011, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
1813 + { 212500000, 106250000, 0x0c05, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
1814 + { 215625000, 107812500, 0x1203, 0x11090009, 0x11050005, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
1815 + { 216666666, 108333333, 0x0805, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 },
1816 + { 225000000, 112500000, 0x0d03, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 },
1817 + { 233333333, 116666666, 0x0905, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 },
1818 + { 237500000, 118750000, 0x0e05, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
1819 + { 240000000, 120000000, 0x0b11, 0x11020009, 0x11210009, 0x11020009, 0x04000009, 11, 0x0aaa0555 },
1820 + { 250000000, 125000000, 0x0f03, 0x11020003, 0x11210003, 0x11020003, 0x04000003, 11, 0x0aaa0555 }
1823 + ulong start, end, dst;
1826 + /* get index of the current core */
1827 + idx = sb_coreidx(sbh);
1828 + clockcontrol_m2 = NULL;
1830 + /* switch to extif or chipc core */
1831 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
1832 + pll_type = PLL_TYPE1;
1833 + clockcontrol_n = &eir->clockcontrol_n;
1834 + clockcontrol_sb = &eir->clockcontrol_sb;
1835 + clockcontrol_pci = &eir->clockcontrol_pci;
1836 + clockcontrol_m2 = &cc->clockcontrol_m2;
1837 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
1838 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
1839 + if (pll_type == PLL_TYPE6) {
1840 + clockcontrol_n = NULL;
1841 + clockcontrol_sb = NULL;
1842 + clockcontrol_pci = NULL;
1844 + clockcontrol_n = &cc->clockcontrol_n;
1845 + clockcontrol_sb = &cc->clockcontrol_sb;
1846 + clockcontrol_pci = &cc->clockcontrol_pci;
1847 + clockcontrol_m2 = &cc->clockcontrol_m2;
1852 + if (pll_type == PLL_TYPE6) {
1853 + /* Silence compilers */
1854 + orig_n = orig_sb = orig_pci = 0;
1856 + /* Store the current clock register values */
1857 + orig_n = R_REG(clockcontrol_n);
1858 + orig_sb = R_REG(clockcontrol_sb);
1859 + orig_pci = R_REG(clockcontrol_pci);
1862 + if (pll_type == PLL_TYPE1) {
1863 + /* Keep the current PCI clock if not specified */
1864 + if (pciclock == 0) {
1865 + pciclock = sb_clock_rate(pll_type, R_REG(clockcontrol_n), R_REG(clockcontrol_pci));
1866 + pciclock = (pciclock <= 25000000) ? 25000000 : 33000000;
1869 + /* Search for the closest MIPS clock less than or equal to a preferred value */
1870 + for (i = 0; i < ARRAYSIZE(BCMINIT(type1_table)); i++) {
1871 + ASSERT(BCMINIT(type1_table)[i].mipsclock ==
1872 + sb_clock_rate(pll_type, BCMINIT(type1_table)[i].n, BCMINIT(type1_table)[i].sb));
1873 + if (BCMINIT(type1_table)[i].mipsclock > mipsclock)
1883 + ASSERT(BCMINIT(type1_table)[i].mipsclock <= mipsclock);
1885 + /* No PLL change */
1886 + if ((orig_n == BCMINIT(type1_table)[i].n) &&
1887 + (orig_sb == BCMINIT(type1_table)[i].sb) &&
1888 + (orig_pci == BCMINIT(type1_table)[i].pci33))
1891 + /* Set the PLL controls */
1892 + W_REG(clockcontrol_n, BCMINIT(type1_table)[i].n);
1893 + W_REG(clockcontrol_sb, BCMINIT(type1_table)[i].sb);
1894 + if (pciclock == 25000000)
1895 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci25);
1897 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci33);
1900 + sb_watchdog(sbh, 1);
1903 + } else if ((pll_type == PLL_TYPE3) &&
1904 + (BCMINIT(sb_chip)(sbh) != BCM5365_DEVICE_ID)) {
1906 + /* Search for the closest MIPS clock less than or equal to a preferred value */
1908 + for (i = 0; i < ARRAYSIZE(type3_table); i++) {
1909 + if (type3_table[i].mipsclock > mipsclock)
1919 + ASSERT(type3_table[i].mipsclock <= mipsclock);
1921 + /* No PLL change */
1922 + orig_m2 = R_REG(&cc->clockcontrol_m2);
1923 + if ((orig_n == type3_table[i].n) &&
1924 + (orig_m2 == type3_table[i].m2)) {
1928 + /* Set the PLL controls */
1929 + W_REG(clockcontrol_n, type3_table[i].n);
1930 + W_REG(clockcontrol_m2, type3_table[i].m2);
1933 + sb_watchdog(sbh, 1);
1935 + } else if ((pll_type == PLL_TYPE2) ||
1936 + (pll_type == PLL_TYPE4) ||
1937 + (pll_type == PLL_TYPE6) ||
1938 + (pll_type == PLL_TYPE7)) {
1939 + n4m_table_t *table = NULL, *te;
1944 + orig_mips = R_REG(&cc->clockcontrol_mips);
1946 + if (pll_type == PLL_TYPE6) {
1947 + uint32 new_mips = 0;
1950 + if (mipsclock <= SB2MIPS_T6(CC_T6_M1))
1951 + new_mips = CC_T6_MMASK;
1953 + if (orig_mips == new_mips)
1956 + W_REG(&cc->clockcontrol_mips, new_mips);
1960 + if (pll_type == PLL_TYPE2) {
1961 + table = BCMINIT(type2_table);
1962 + tabsz = ARRAYSIZE(BCMINIT(type2_table));
1963 + } else if (pll_type == PLL_TYPE4) {
1964 + table = BCMINIT(type4_table);
1965 + tabsz = ARRAYSIZE(BCMINIT(type4_table));
1966 + } else if (pll_type == PLL_TYPE7) {
1967 + table = BCMINIT(type7_table);
1968 + tabsz = ARRAYSIZE(BCMINIT(type7_table));
1970 + ASSERT("No table for plltype" == NULL);
1972 + /* Store the current clock register values */
1973 + orig_m2 = R_REG(&cc->clockcontrol_m2);
1974 + orig_ratio_parm = 0;
1975 + orig_ratio_cfg = 0;
1977 + /* Look up current ratio */
1978 + for (i = 0; i < tabsz; i++) {
1979 + if ((orig_n == table[i].n) &&
1980 + (orig_sb == table[i].sb) &&
1981 + (orig_pci == table[i].pci33) &&
1982 + (orig_m2 == table[i].m2) &&
1983 + (orig_mips == table[i].m3)) {
1984 + orig_ratio_parm = table[i].ratio_parm;
1985 + orig_ratio_cfg = table[i].ratio_cfg;
1990 + /* Search for the closest MIPS clock greater or equal to a preferred value */
1991 + for (i = 0; i < tabsz; i++) {
1992 + ASSERT(table[i].mipsclock ==
1993 + sb_clock_rate(pll_type, table[i].n, table[i].m3));
1994 + if ((mipsclock <= table[i].mipsclock) &&
1995 + ((sbclock == 0) || (sbclock <= table[i].sbclock)))
2006 + /* No PLL change */
2007 + if ((orig_n == te->n) &&
2008 + (orig_sb == te->sb) &&
2009 + (orig_pci == te->pci33) &&
2010 + (orig_m2 == te->m2) &&
2011 + (orig_mips == te->m3))
2014 + /* Set the PLL controls */
2015 + W_REG(clockcontrol_n, te->n);
2016 + W_REG(clockcontrol_sb, te->sb);
2017 + W_REG(clockcontrol_pci, te->pci33);
2018 + W_REG(&cc->clockcontrol_m2, te->m2);
2019 + W_REG(&cc->clockcontrol_mips, te->m3);
2021 + /* Set the chipcontrol bit to change mipsref to the backplane divider if needed */
2022 + if ((pll_type == PLL_TYPE7) &&
2023 + (te->sb != te->m2) &&
2024 + (sb_clock_rate(pll_type, te->n, te->m2) == 120000000))
2025 + W_REG(&cc->chipcontrol, R_REG(&cc->chipcontrol) | 0x100);
2027 + /* No ratio change */
2028 + if (orig_ratio_parm == te->ratio_parm)
2031 + icache_probe(MFC0(C0_CONFIG, 1), &ic_size, &ic_lsize);
2033 + /* Preload the code into the cache */
2034 + start = ((ulong) &&start_fill) & ~(ic_lsize - 1);
2035 + end = ((ulong) &&end_fill + (ic_lsize - 1)) & ~(ic_lsize - 1);
2036 + while (start < end) {
2037 + cache_op(start, Fill_I);
2038 + start += ic_lsize;
2041 + /* Copy the handler */
2042 + start = (ulong) &BCMINIT(handler);
2043 + end = (ulong) &BCMINIT(afterhandler);
2044 + dst = KSEG1ADDR(0x180);
2045 + for (i = 0; i < (end - start); i += 4)
2046 + *((ulong *)(dst + i)) = *((ulong *)(start + i));
2048 + /* Preload handler into the cache one line at a time */
2049 + for (i = 0; i < (end - start); i += 4)
2050 + cache_op(dst + i, Fill_I);
2052 + /* Clear BEV bit */
2053 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) & ~ST0_BEV);
2055 + /* Enable interrupts */
2056 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) | (ALLINTS | ST0_IE));
2058 + /* Enable MIPS timer interrupt */
2059 + if (!(mipsr = sb_setcore(sbh, SB_MIPS, 0)) &&
2060 + !(mipsr = sb_setcore(sbh, SB_MIPS33, 0)))
2062 + W_REG(&mipsr->intmask, 1);
2065 + /* step 1, set clock ratios */
2066 + MTC0(C0_BROADCOM, 3, te->ratio_parm);
2067 + MTC0(C0_BROADCOM, 1, te->ratio_cfg);
2069 + /* step 2: program timer intr */
2070 + W_REG(&mipsr->timer, 100);
2071 + (void) R_REG(&mipsr->timer);
2073 + /* step 3, switch to async */
2074 + sync_mode = MFC0(C0_BROADCOM, 4);
2075 + MTC0(C0_BROADCOM, 4, 1 << 22);
2077 + /* step 4, set cfg active */
2078 + MTC0(C0_BROADCOM, 2, 0x9);
2082 + __asm__ __volatile__ (
2088 + /* step 7, clear cfg_active */
2089 + MTC0(C0_BROADCOM, 2, 0);
2091 + /* Additional Step: set back to orig sync mode */
2092 + MTC0(C0_BROADCOM, 4, sync_mode);
2094 + /* step 8, fake soft reset */
2095 + MTC0(C0_BROADCOM, 5, MFC0(C0_BROADCOM, 5) | 4);
2098 + /* step 9 set watchdog timer */
2099 + sb_watchdog(sbh, 20);
2100 + (void) R_REG(&cc->chipid);
2103 + __asm__ __volatile__ (
2113 + /* switch back to previous core */
2114 + sb_setcoreidx(sbh, idx);
2120 + * This also must be run from the cache on 47xx
2121 + * so there are no mips core BIU ops in progress
2122 + * when the PFC is enabled.
2126 +BCMINITFN(_enable_pfc)(uint32 mode)
2129 + *(volatile uint32 *)PFC_CR1 = 0xffff0000;
2132 + *(volatile uint32 *)PFC_CR0 = mode;
2136 +BCMINITFN(enable_pfc)(uint32 mode)
2141 + /* If auto then choose the correct mode for this
2142 + platform, currently we only ever select one mode */
2143 + if (mode == PFC_AUTO)
2146 + /* enable prefetch cache if available */
2147 + if (MFC0(C0_BROADCOM, 0) & BRCM_PFC_AVAIL) {
2148 + start = (ulong) &BCMINIT(_enable_pfc);
2149 + end = (ulong) &BCMINIT(enable_pfc);
2151 + /* Preload handler into the cache one line at a time */
2152 + for (i = 0; i < (end - start); i += 4)
2153 + cache_op(start + i, Fill_I);
2155 + BCMINIT(_enable_pfc)(mode);
2159 +/* returns the ncdl value to be programmed into sdram_ncdl for calibration */
2161 +BCMINITFN(sb_memc_get_ncdl)(sb_t *sbh)
2163 + sbmemcregs_t *memc;
2165 + uint32 config, rd, wr, misc, dqsg, cd, sm, sd;
2168 + idx = sb_coreidx(sbh);
2170 + memc = (sbmemcregs_t *)sb_setcore(sbh, SB_MEMC, 0);
2174 + rev = sb_corerev(sbh);
2176 + config = R_REG(&memc->config);
2177 + wr = R_REG(&memc->wrncdlcor);
2178 + rd = R_REG(&memc->rdncdlcor);
2179 + misc = R_REG(&memc->miscdlyctl);
2180 + dqsg = R_REG(&memc->dqsgatencdl);
2182 + rd &= MEMC_RDNCDLCOR_RD_MASK;
2183 + wr &= MEMC_WRNCDLCOR_WR_MASK;
2184 + dqsg &= MEMC_DQSGATENCDL_G_MASK;
2186 + if (config & MEMC_CONFIG_DDR) {
2187 + ret = (wr << 16) | (rd << 8) | dqsg;
2192 + cd = (rd == MEMC_CD_THRESHOLD) ? rd : (wr + MEMC_CD_THRESHOLD);
2193 + sm = (misc & MEMC_MISC_SM_MASK) >> MEMC_MISC_SM_SHIFT;
2194 + sd = (misc & MEMC_MISC_SD_MASK) >> MEMC_MISC_SD_SHIFT;
2195 + ret = (sm << 16) | (sd << 8) | cd;
2199 + /* switch back to previous core */
2200 + sb_setcoreidx(sbh, idx);
2205 diff -urN linux.old/arch/mips/bcm947xx/broadcom/sbpci.c linux.dev/arch/mips/bcm947xx/broadcom/sbpci.c
2206 --- linux.old/arch/mips/bcm947xx/broadcom/sbpci.c 1970-01-01 01:00:00.000000000 +0100
2207 +++ linux.dev/arch/mips/bcm947xx/broadcom/sbpci.c 2005-12-15 20:09:46.562233250 +0100
2210 + * Low-Level PCI and SB support for BCM47xx
2212 + * Copyright 2005, Broadcom Corporation
2213 + * All Rights Reserved.
2215 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2216 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2217 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2218 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2223 +#include <typedefs.h>
2224 +#include <pcicfg.h>
2225 +#include <bcmdevs.h>
2226 +#include <sbconfig.h>
2228 +#include <sbutils.h>
2230 +#include <bcmendian.h>
2231 +#include <bcmutils.h>
2232 +#include <bcmnvram.h>
2233 +#include <hndmips.h>
2235 +/* Can free sbpci_init() memory after boot */
2240 +/* Emulated configuration space */
2241 +static pci_config_regs sb_config_regs[SB_MAXCORES];
2244 +static uint16 pci_ban[32] = { 0 };
2245 +static uint pci_banned = 0;
2248 +static bool cardbus = FALSE;
2250 +/* Disable PCI host core */
2251 +static bool pci_disabled = FALSE;
2254 + * Functions for accessing external PCI configuration space
2257 +/* Assume one-hot slot wiring */
2258 +#define PCI_SLOT_MAX 16
2261 +config_cmd(sb_t *sbh, uint bus, uint dev, uint func, uint off)
2264 + sbpciregs_t *regs;
2267 + /* CardBusMode supports only one device */
2268 + if (cardbus && dev > 1)
2271 + coreidx = sb_coreidx(sbh);
2272 + regs = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0);
2274 + /* Type 0 transaction */
2276 + /* Skip unwired slots */
2277 + if (dev < PCI_SLOT_MAX) {
2278 + /* Slide the PCI window to the appropriate slot */
2279 + W_REG(®s->sbtopci1, SBTOPCI_CFG0 | ((1 << (dev + 16)) & SBTOPCI1_MASK));
2280 + addr = SB_PCI_CFG | ((1 << (dev + 16)) & ~SBTOPCI1_MASK) |
2281 + (func << 8) | (off & ~3);
2285 + /* Type 1 transaction */
2287 + W_REG(®s->sbtopci1, SBTOPCI_CFG1);
2288 + addr = SB_PCI_CFG | (bus << 16) | (dev << 11) | (func << 8) | (off & ~3);
2291 + sb_setcoreidx(sbh, coreidx);
2297 +extpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
2299 + uint32 addr, *reg = NULL, val;
2302 + if (pci_disabled ||
2303 + !(addr = config_cmd(sbh, bus, dev, func, off)) ||
2304 + !(reg = (uint32 *) REG_MAP(addr, len)) ||
2305 + BUSPROBE(val, reg))
2308 + val >>= 8 * (off & 3);
2310 + *((uint32 *) buf) = val;
2311 + else if (len == 2)
2312 + *((uint16 *) buf) = (uint16) val;
2313 + else if (len == 1)
2314 + *((uint8 *) buf) = (uint8) val;
2325 +extpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
2327 + uint32 addr, *reg = NULL, val;
2330 + if (pci_disabled ||
2331 + !(addr = config_cmd(sbh, bus, dev, func, off)) ||
2332 + !(reg = (uint32 *) REG_MAP(addr, len)) ||
2333 + BUSPROBE(val, reg))
2337 + val = *((uint32 *) buf);
2338 + else if (len == 2) {
2339 + val &= ~(0xffff << (8 * (off & 3)));
2340 + val |= *((uint16 *) buf) << (8 * (off & 3));
2341 + } else if (len == 1) {
2342 + val &= ~(0xff << (8 * (off & 3)));
2343 + val |= *((uint8 *) buf) << (8 * (off & 3));
2357 + * Functions for accessing translated SB configuration space
2361 +sb_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
2363 + pci_config_regs *cfg;
2365 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
2367 + cfg = &sb_config_regs[dev];
2369 + ASSERT(ISALIGNED(off, len));
2370 + ASSERT(ISALIGNED((uintptr)buf, len));
2373 + *((uint32 *) buf) = ltoh32(*((uint32 *)((ulong) cfg + off)));
2374 + else if (len == 2)
2375 + *((uint16 *) buf) = ltoh16(*((uint16 *)((ulong) cfg + off)));
2376 + else if (len == 1)
2377 + *((uint8 *) buf) = *((uint8 *)((ulong) cfg + off));
2385 +sb_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
2390 + pci_config_regs *cfg;
2392 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
2394 + cfg = &sb_config_regs[dev];
2396 + ASSERT(ISALIGNED(off, len));
2397 + ASSERT(ISALIGNED((uintptr)buf, len));
2399 + /* Emulate BAR sizing */
2400 + if (off >= OFFSETOF(pci_config_regs, base[0]) && off <= OFFSETOF(pci_config_regs, base[3]) &&
2401 + len == 4 && *((uint32 *) buf) == ~0) {
2402 + coreidx = sb_coreidx(sbh);
2403 + if ((regs = sb_setcoreidx(sbh, dev))) {
2404 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
2405 + /* Highest numbered address match register */
2406 + n = (R_REG(&sb->sbidlow) & SBIDL_AR_MASK) >> SBIDL_AR_SHIFT;
2407 + if (off == OFFSETOF(pci_config_regs, base[0]))
2408 + cfg->base[0] = ~(sb_size(R_REG(&sb->sbadmatch0)) - 1);
2409 + else if (off == OFFSETOF(pci_config_regs, base[1]) && n >= 1)
2410 + cfg->base[1] = ~(sb_size(R_REG(&sb->sbadmatch1)) - 1);
2411 + else if (off == OFFSETOF(pci_config_regs, base[2]) && n >= 2)
2412 + cfg->base[2] = ~(sb_size(R_REG(&sb->sbadmatch2)) - 1);
2413 + else if (off == OFFSETOF(pci_config_regs, base[3]) && n >= 3)
2414 + cfg->base[3] = ~(sb_size(R_REG(&sb->sbadmatch3)) - 1);
2416 + sb_setcoreidx(sbh, coreidx);
2421 + *((uint32 *)((ulong) cfg + off)) = htol32(*((uint32 *) buf));
2422 + else if (len == 2)
2423 + *((uint16 *)((ulong) cfg + off)) = htol16(*((uint16 *) buf));
2424 + else if (len == 1)
2425 + *((uint8 *)((ulong) cfg + off)) = *((uint8 *) buf);
2433 +sbpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
2436 + return sb_read_config(sbh, bus, dev, func, off, buf, len);
2438 + return extpci_read_config(sbh, bus, dev, func, off, buf, len);
2442 +sbpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
2445 + return sb_write_config(sbh, bus, dev, func, off, buf, len);
2447 + return extpci_write_config(sbh, bus, dev, func, off, buf, len);
2451 +sbpci_ban(uint16 core)
2453 + if (pci_banned < ARRAYSIZE(pci_ban))
2454 + pci_ban[pci_banned++] = core;
2458 +sbpci_init_pci(sb_t *sbh)
2460 + uint chip, chiprev, chippkg, host;
2461 + uint32 boardflags;
2466 + chip = sb_chip(sbh);
2467 + chiprev = sb_chiprev(sbh);
2468 + chippkg = sb_chippkg(sbh);
2470 + if (!(pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0))) {
2471 + printf("PCI: no core\n");
2472 + pci_disabled = TRUE;
2475 + sb_core_reset(sbh, 0);
2477 + boardflags = (uint32) getintvar(NULL, "boardflags");
2479 + if ((chip == BCM4310_DEVICE_ID) && (chiprev == 0))
2480 + pci_disabled = TRUE;
2483 + * The 200-pin BCM4712 package does not bond out PCI. Even when
2484 + * PCI is bonded out, some boards may leave the pins
2487 + if (((chip == BCM4712_DEVICE_ID) &&
2488 + ((chippkg == BCM4712SMALL_PKG_ID) ||
2489 + (chippkg == BCM4712MID_PKG_ID))) ||
2490 + (boardflags & BFL_NOPCI))
2491 + pci_disabled = TRUE;
2494 + * If the PCI core should not be touched (disabled, not bonded
2495 + * out, or pins floating), do not even attempt to access core
2496 + * registers. Otherwise, try to determine if it is in host
2502 + host = !BUSPROBE(val, &pci->control);
2505 + /* Disable PCI interrupts in client mode */
2506 + sb = (sbconfig_t *)((ulong) pci + SBCONFIGOFF);
2507 + W_REG(&sb->sbintvec, 0);
2509 + /* Disable the PCI bridge in client mode */
2510 + sbpci_ban(SB_PCI);
2511 + printf("PCI: Disabled\n");
2513 + /* Reset the external PCI bus and enable the clock */
2514 + W_REG(&pci->control, 0x5); /* enable the tristate drivers */
2515 + W_REG(&pci->control, 0xd); /* enable the PCI clock */
2516 + OSL_DELAY(150); /* delay > 100 us */
2517 + W_REG(&pci->control, 0xf); /* deassert PCI reset */
2518 + W_REG(&pci->arbcontrol, PCI_INT_ARB); /* use internal arbiter */
2519 + OSL_DELAY(1); /* delay 1 us */
2521 + /* Enable CardBusMode */
2522 + cardbus = nvram_match("cardbus", "1");
2524 + printf("PCI: Enabling CardBus\n");
2525 + /* GPIO 1 resets the CardBus device on bcm94710ap */
2526 + sb_gpioout(sbh, 1, 1, GPIO_DRV_PRIORITY);
2527 + sb_gpioouten(sbh, 1, 1, GPIO_DRV_PRIORITY);
2528 + W_REG(&pci->sprom[0], R_REG(&pci->sprom[0]) | 0x400);
2531 + /* 64 MB I/O access window */
2532 + W_REG(&pci->sbtopci0, SBTOPCI_IO);
2533 + /* 64 MB configuration access window */
2534 + W_REG(&pci->sbtopci1, SBTOPCI_CFG0);
2535 + /* 1 GB memory access window */
2536 + W_REG(&pci->sbtopci2, SBTOPCI_MEM | SB_PCI_DMA);
2538 + /* Enable PCI bridge BAR0 prefetch and burst */
2540 + sbpci_write_config(sbh, 1, 0, 0, PCI_CFG_CMD, &val, sizeof(val));
2542 + /* Enable PCI interrupts */
2543 + W_REG(&pci->intmask, PCI_INTA);
2550 +sbpci_init_cores(sb_t *sbh)
2552 + uint chip, chiprev, chippkg, coreidx, i;
2554 + pci_config_regs *cfg;
2558 + uint16 vendor, core;
2559 + uint8 class, subclass, progif;
2561 + uint32 sbips_int_mask[] = { 0, SBIPS_INT1_MASK, SBIPS_INT2_MASK, SBIPS_INT3_MASK, SBIPS_INT4_MASK };
2562 + uint32 sbips_int_shift[] = { 0, 0, SBIPS_INT2_SHIFT, SBIPS_INT3_SHIFT, SBIPS_INT4_SHIFT };
2564 + chip = sb_chip(sbh);
2565 + chiprev = sb_chiprev(sbh);
2566 + chippkg = sb_chippkg(sbh);
2567 + coreidx = sb_coreidx(sbh);
2569 + /* Scan the SB bus */
2570 + bzero(sb_config_regs, sizeof(sb_config_regs));
2571 + for (cfg = sb_config_regs; cfg < &sb_config_regs[SB_MAXCORES]; cfg++) {
2572 + cfg->vendor = 0xffff;
2573 + if (!(regs = sb_setcoreidx(sbh, cfg - sb_config_regs)))
2575 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
2577 + /* Read ID register and parse vendor and core */
2578 + val = R_REG(&sb->sbidhigh);
2579 + vendor = (val & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT;
2580 + core = (val & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT;
2583 + /* Check if this core is banned */
2584 + for (i = 0; i < pci_banned; i++)
2585 + if (core == pci_ban[i])
2587 + if (i < pci_banned)
2590 + /* Known vendor translations */
2593 + vendor = VENDOR_BROADCOM;
2597 + /* Determine class based on known core codes */
2600 + class = PCI_CLASS_NET;
2601 + subclass = PCI_NET_ETHER;
2602 + core = BCM47XX_ILINE_ID;
2605 + class = PCI_CLASS_NET;
2606 + subclass = PCI_NET_ETHER;
2607 + core = BCM4610_ILINE_ID;
2610 + class = PCI_CLASS_NET;
2611 + subclass = PCI_NET_ETHER;
2612 + core = BCM47XX_ENET_ID;
2616 + class = PCI_CLASS_MEMORY;
2617 + subclass = PCI_MEMORY_RAM;
2620 + class = PCI_CLASS_BRIDGE;
2621 + subclass = PCI_BRIDGE_PCI;
2625 + class = PCI_CLASS_CPU;
2626 + subclass = PCI_CPU_MIPS;
2629 + class = PCI_CLASS_COMM;
2630 + subclass = PCI_COMM_MODEM;
2631 + core = BCM47XX_V90_ID;
2634 + class = PCI_CLASS_SERIAL;
2635 + subclass = PCI_SERIAL_USB;
2636 + progif = 0x10; /* OHCI */
2637 + core = BCM47XX_USB_ID;
2640 + class = PCI_CLASS_SERIAL;
2641 + subclass = PCI_SERIAL_USB;
2642 + progif = 0x10; /* OHCI */
2643 + core = BCM47XX_USBH_ID;
2646 + class = PCI_CLASS_SERIAL;
2647 + subclass = PCI_SERIAL_USB;
2648 + core = BCM47XX_USBD_ID;
2651 + class = PCI_CLASS_CRYPT;
2652 + subclass = PCI_CRYPT_NETWORK;
2653 + core = BCM47XX_IPSEC_ID;
2656 + class = PCI_CLASS_NET;
2657 + subclass = PCI_NET_OTHER;
2658 + core = BCM47XX_ROBO_ID;
2662 + class = PCI_CLASS_MEMORY;
2663 + subclass = PCI_MEMORY_FLASH;
2666 + class = PCI_CLASS_NET;
2667 + subclass = PCI_NET_OTHER;
2668 + /* Let an nvram variable override this */
2669 + sprintf(varname, "wl%did", wlidx);
2671 + if ((core = getintvar(NULL, varname)) == 0) {
2672 + if (chip == BCM4712_DEVICE_ID) {
2673 + if (chippkg == BCM4712SMALL_PKG_ID)
2674 + core = BCM4306_D11G_ID;
2676 + core = BCM4306_D11DUAL_ID;
2679 + core = BCM4310_D11B_ID;
2685 + class = subclass = progif = 0xff;
2689 + /* Supported translations */
2690 + cfg->vendor = htol16(vendor);
2691 + cfg->device = htol16(core);
2692 + cfg->rev_id = chiprev;
2693 + cfg->prog_if = progif;
2694 + cfg->sub_class = subclass;
2695 + cfg->base_class = class;
2696 + cfg->base[0] = htol32(sb_base(R_REG(&sb->sbadmatch0)));
2697 + cfg->base[1] = htol32(sb_base(R_REG(&sb->sbadmatch1)));
2698 + cfg->base[2] = htol32(sb_base(R_REG(&sb->sbadmatch2)));
2699 + cfg->base[3] = htol32(sb_base(R_REG(&sb->sbadmatch3)));
2702 + if (class == PCI_CLASS_BRIDGE && subclass == PCI_BRIDGE_PCI)
2703 + cfg->header_type = PCI_HEADER_BRIDGE;
2705 + cfg->header_type = PCI_HEADER_NORMAL;
2706 + /* Save core interrupt flag */
2707 + cfg->int_pin = R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK;
2708 + /* Default to MIPS shared interrupt 0 */
2709 + cfg->int_line = 0;
2710 + /* MIPS sbipsflag maps core interrupt flags to interrupts 1 through 4 */
2711 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
2712 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
2713 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
2714 + val = R_REG(&sb->sbipsflag);
2715 + for (cfg->int_line = 1; cfg->int_line <= 4; cfg->int_line++) {
2716 + if (((val & sbips_int_mask[cfg->int_line]) >> sbips_int_shift[cfg->int_line]) == cfg->int_pin)
2719 + if (cfg->int_line > 4)
2720 + cfg->int_line = 0;
2722 + /* Emulated core */
2723 + *((uint32 *) &cfg->sprom_control) = 0xffffffff;
2726 + sb_setcoreidx(sbh, coreidx);
2731 +sbpci_init(sb_t *sbh)
2733 + sbpci_init_pci(sbh);
2734 + sbpci_init_cores(sbh);
2738 diff -urN linux.old/arch/mips/bcm947xx/broadcom/sbutils.c linux.dev/arch/mips/bcm947xx/broadcom/sbutils.c
2739 --- linux.old/arch/mips/bcm947xx/broadcom/sbutils.c 1970-01-01 01:00:00.000000000 +0100
2740 +++ linux.dev/arch/mips/bcm947xx/broadcom/sbutils.c 2005-12-15 17:31:12.211645500 +0100
2743 + * Misc utility routines for accessing chip-specific features
2744 + * of the SiliconBackplane-based Broadcom chips.
2746 + * Copyright 2005, Broadcom Corporation
2747 + * All Rights Reserved.
2749 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2750 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2751 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2752 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2756 +#include <typedefs.h>
2758 +#include <sbutils.h>
2759 +#include <bcmutils.h>
2760 +#include <bcmdevs.h>
2761 +#include <sbconfig.h>
2762 +#include <sbchipc.h>
2764 +#include <pcicfg.h>
2765 +#include <sbextif.h>
2766 +#include <bcmsrom.h>
2769 +#define SB_ERROR(args)
2772 +typedef uint32 (*sb_intrsoff_t)(void *intr_arg);
2773 +typedef void (*sb_intrsrestore_t)(void *intr_arg, uint32 arg);
2774 +typedef bool (*sb_intrsenabled_t)(void *intr_arg);
2776 +/* misc sb info needed by some of the routines */
2777 +typedef struct sb_info {
2779 + struct sb_pub sb; /* back plane public state(must be first field of sb_info */
2781 + void *osh; /* osl os handle */
2782 + void *sdh; /* bcmsdh handle */
2784 + void *curmap; /* current regs va */
2785 + void *regs[SB_MAXCORES]; /* other regs va */
2787 + uint curidx; /* current core index */
2788 + uint dev_coreid; /* the core provides driver functions */
2790 + uint gpioidx; /* gpio control core index */
2791 + uint gpioid; /* gpio control coretype */
2793 + uint numcores; /* # discovered cores */
2794 + uint coreid[SB_MAXCORES]; /* id of each core */
2796 + void *intr_arg; /* interrupt callback function arg */
2797 + sb_intrsoff_t intrsoff_fn; /* function turns chip interrupts off */
2798 + sb_intrsrestore_t intrsrestore_fn; /* function restore chip interrupts */
2799 + sb_intrsenabled_t intrsenabled_fn; /* function to check if chip interrupts are enabled */
2803 +/* local prototypes */
2804 +static sb_info_t * BCMINIT(sb_doattach)(sb_info_t *si, uint devid, osl_t *osh, void *regs,
2805 + uint bustype, void *sdh, char **vars, int *varsz);
2806 +static void BCMINIT(sb_scan)(sb_info_t *si);
2807 +static uint sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val);
2808 +static uint _sb_coreidx(sb_info_t *si);
2809 +static uint sb_findcoreidx(sb_info_t *si, uint coreid, uint coreunit);
2810 +static uint BCMINIT(sb_pcidev2chip)(uint pcidev);
2811 +static uint BCMINIT(sb_chip2numcores)(uint chip);
2812 +static int sb_pci_fixcfg(sb_info_t *si);
2814 +/* delay needed between the mdio control/ mdiodata register data access */
2815 +#define PR28829_DELAY() OSL_DELAY(10)
2818 +/* global variable to indicate reservation/release of gpio's*/
2819 +static uint32 sb_gpioreservation = 0;
2821 +#define SB_INFO(sbh) (sb_info_t*)sbh
2822 +#define SET_SBREG(sbh, r, mask, val) W_SBREG((sbh), (r), ((R_SBREG((sbh), (r)) & ~(mask)) | (val)))
2823 +#define GOODCOREADDR(x) (((x) >= SB_ENUM_BASE) && ((x) <= SB_ENUM_LIM) && ISALIGNED((x), SB_CORE_SIZE))
2824 +#define GOODREGS(regs) ((regs) && ISALIGNED((uintptr)(regs), SB_CORE_SIZE))
2825 +#define REGS2SB(va) (sbconfig_t*) ((int8*)(va) + SBCONFIGOFF)
2826 +#define GOODIDX(idx) (((uint)idx) < SB_MAXCORES)
2827 +#define BADIDX (SB_MAXCORES+1)
2830 +#define PCI(si) ((BUSTYPE(si->sb.bustype) == PCI_BUS) && (si->sb.buscoretype == SB_PCI))
2833 +#define SONICS_2_2 (SBIDL_RV_2_2 >> SBIDL_RV_SHIFT)
2834 +#define SONICS_2_3 (SBIDL_RV_2_3 >> SBIDL_RV_SHIFT)
2836 +#define R_SBREG(sbh, sbr) sb_read_sbreg((sbh), (sbr))
2837 +#define W_SBREG(sbh, sbr, v) sb_write_sbreg((sbh), (sbr), (v))
2838 +#define AND_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) & (v)))
2839 +#define OR_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) | (v)))
2842 + * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts before/
2843 + * after core switching to avoid invalid register accesss inside ISR.
2845 +#define INTR_OFF(si, intr_val) \
2846 + if ((si)->intrsoff_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
2847 + intr_val = (*(si)->intrsoff_fn)((si)->intr_arg); }
2848 +#define INTR_RESTORE(si, intr_val) \
2849 + if ((si)->intrsrestore_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
2850 + (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val); }
2852 +/* dynamic clock control defines */
2853 +#define LPOMINFREQ 25000 /* low power oscillator min */
2854 +#define LPOMAXFREQ 43000 /* low power oscillator max */
2855 +#define XTALMINFREQ 19800000 /* 20 MHz - 1% */
2856 +#define XTALMAXFREQ 20200000 /* 20 MHz + 1% */
2857 +#define PCIMINFREQ 25000000 /* 25 MHz */
2858 +#define PCIMAXFREQ 34000000 /* 33 MHz + fudge */
2860 +#define ILP_DIV_5MHZ 0 /* ILP = 5 MHz */
2861 +#define ILP_DIV_1MHZ 4 /* ILP = 1 MHz */
2863 +#define MIN_DUMPBUFLEN 32 /* debug */
2865 +/* GPIO Based LED powersave defines */
2866 +#define DEFAULT_GPIO_ONTIME 10
2867 +#define DEFAULT_GPIO_OFFTIME 90
2869 +#define DEFAULT_GPIOTIMERVAL ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME)
2872 +sb_read_sbreg(sb_info_t *si, volatile uint32 *sbr)
2874 + uint32 val = R_REG(sbr);
2880 +sb_write_sbreg(sb_info_t *si, volatile uint32 *sbr, uint32 v)
2885 +/* Using sb_kattach depends on SB_BUS support, either implicit */
2886 +/* no limiting BCMBUSTYPE value) or explicit (value is SB_BUS). */
2887 +#if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SB_BUS)
2889 +/* global kernel resource */
2890 +static sb_info_t ksi;
2892 +/* generic kernel variant of sb_attach() */
2894 +BCMINITFN(sb_kattach)()
2898 + if (ksi.curmap == NULL) {
2901 + regs = (uint32 *)REG_MAP(SB_ENUM_BASE, SB_CORE_SIZE);
2902 + cid = R_REG((uint32 *)regs);
2903 + if (((cid & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
2904 + ((cid & CID_PKG_MASK) != BCM4712LARGE_PKG_ID) &&
2905 + ((cid & CID_REV_MASK) <= (3 << CID_REV_SHIFT))) {
2908 + scc = (uint32 *)((uchar*)regs + OFFSETOF(chipcregs_t, slow_clk_ctl));
2910 + SB_ERROR((" initial scc = 0x%x\n", val));
2911 + val |= SCC_SS_XTAL;
2915 + if (BCMINIT(sb_doattach)(&ksi, BCM4710_DEVICE_ID, NULL, (void*)regs,
2916 + SB_BUS, NULL, NULL, NULL) == NULL) {
2921 + return (sb_t *)&ksi;
2926 +BCMINITFN(sb_doattach)(sb_info_t *si, uint devid, osl_t *osh, void *regs,
2927 + uint bustype, void *sdh, char **vars, int *varsz)
2934 + ASSERT(GOODREGS(regs));
2936 + bzero((uchar*)si, sizeof (sb_info_t));
2938 + si->sb.buscoreidx = si->gpioidx = BADIDX;
2941 + si->curmap = regs;
2944 + /* check to see if we are a sb core mimic'ing a pci core */
2945 + if (bustype == PCI_BUS) {
2946 + if (OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof (uint32)) == 0xffffffff)
2949 + bustype = PCI_BUS;
2952 + si->sb.bustype = bustype;
2953 + if (si->sb.bustype != BUSTYPE(si->sb.bustype)) {
2954 + SB_ERROR(("sb_doattach: bus type %d does not match configured bus type %d\n",
2955 + si->sb.bustype, BUSTYPE(si->sb.bustype)));
2959 + /* kludge to enable the clock on the 4306 which lacks a slowclock */
2960 + if (BUSTYPE(si->sb.bustype) == PCI_BUS)
2961 + sb_clkctl_xtal(&si->sb, XTAL|PLL, ON);
2963 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
2964 + w = OSL_PCI_READ_CONFIG(osh, PCI_BAR0_WIN, sizeof (uint32));
2965 + if (!GOODCOREADDR(w))
2966 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32), SB_ENUM_BASE);
2969 + /* initialize current core index value */
2970 + si->curidx = _sb_coreidx(si);
2972 + if (si->curidx == BADIDX) {
2973 + SB_ERROR(("sb_doattach: bad core index\n"));
2977 + /* get sonics backplane revision */
2978 + sb = REGS2SB(si->curmap);
2979 + si->sb.sonicsrev = (R_SBREG(si, &(sb)->sbidlow) & SBIDL_RV_MASK) >> SBIDL_RV_SHIFT;
2981 + /* keep and reuse the initial register mapping */
2982 + origidx = si->curidx;
2983 + if (BUSTYPE(si->sb.bustype) == SB_BUS)
2984 + si->regs[origidx] = regs;
2986 + /* is core-0 a chipcommon core? */
2988 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, 0);
2989 + if (sb_coreid(&si->sb) != SB_CC)
2992 + /* determine chip id and rev */
2994 + /* chip common core found! */
2995 + si->sb.chip = R_REG(&cc->chipid) & CID_ID_MASK;
2996 + si->sb.chiprev = (R_REG(&cc->chipid) & CID_REV_MASK) >> CID_REV_SHIFT;
2997 + si->sb.chippkg = (R_REG(&cc->chipid) & CID_PKG_MASK) >> CID_PKG_SHIFT;
2999 + /* no chip common core -- must convert device id to chip id */
3000 + if ((si->sb.chip = BCMINIT(sb_pcidev2chip)(devid)) == 0) {
3001 + SB_ERROR(("sb_doattach: unrecognized device id 0x%04x\n", devid));
3002 + sb_setcoreidx(&si->sb, origidx);
3007 + /* get chipcommon rev */
3008 + si->sb.ccrev = cc ? (int)sb_corerev(&si->sb) : NOREV;
3010 + /* determine numcores */
3011 + if (cc && ((si->sb.ccrev == 4) || (si->sb.ccrev >= 6)))
3012 + si->numcores = (R_REG(&cc->chipid) & CID_CC_MASK) >> CID_CC_SHIFT;
3014 + si->numcores = BCMINIT(sb_chip2numcores)(si->sb.chip);
3016 + /* return to original core */
3017 + sb_setcoreidx(&si->sb, origidx);
3019 + /* sanity checks */
3020 + ASSERT(si->sb.chip);
3022 + /* scan for cores */
3023 + BCMINIT(sb_scan)(si);
3025 + /* fixup necessary chip/core configurations */
3026 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
3027 + if (sb_pci_fixcfg(si)) {
3028 + SB_ERROR(("sb_doattach: sb_pci_fixcfg failed\n"));
3033 + /* srom_var_init() depends on sb_scan() info */
3034 + if (srom_var_init(si, si->sb.bustype, si->curmap, osh, vars, varsz)) {
3035 + SB_ERROR(("sb_doattach: srom_var_init failed: bad srom\n"));
3041 + * The chip revision number is hardwired into all
3042 + * of the pci function config rev fields and is
3043 + * independent from the individual core revision numbers.
3044 + * For example, the "A0" silicon of each chip is chip rev 0.
3046 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
3047 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_REV, sizeof (uint32));
3048 + si->sb.chiprev = w & 0xff;
3050 + si->sb.chiprev = 0;
3053 + /* gpio control core is required */
3054 + if (!GOODIDX(si->gpioidx)) {
3055 + SB_ERROR(("sb_doattach: gpio control core not found\n"));
3059 + /* get boardtype and boardrev */
3060 + switch (BUSTYPE(si->sb.bustype)) {
3062 + /* do a pci config read to get subsystem id and subvendor id */
3063 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_SVID, sizeof (uint32));
3064 + si->sb.boardvendor = w & 0xffff;
3065 + si->sb.boardtype = (w >> 16) & 0xffff;
3070 + si->sb.boardvendor = VENDOR_BROADCOM;
3071 + if ((si->sb.boardtype = getintvar(NULL, "boardtype")) == 0)
3072 + si->sb.boardtype = 0xffff;
3076 + if (si->sb.boardtype == 0) {
3077 + SB_ERROR(("sb_doattach: unknown board type\n"));
3078 + ASSERT(si->sb.boardtype);
3081 + /* setup the GPIO based LED powersave register */
3082 + if (si->sb.ccrev >= 16) {
3083 + w = getintvar(*vars, "gpiotimerval");
3085 + w = DEFAULT_GPIOTIMERVAL;
3086 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), ~0, w);
3094 +sb_coreid(sb_t *sbh)
3099 + si = SB_INFO(sbh);
3100 + sb = REGS2SB(si->curmap);
3102 + return ((R_SBREG(si, &(sb)->sbidhigh) & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT);
3106 +sb_coreidx(sb_t *sbh)
3110 + si = SB_INFO(sbh);
3111 + return (si->curidx);
3114 +/* return current index of core */
3116 +_sb_coreidx(sb_info_t *si)
3119 + uint32 sbaddr = 0;
3123 + switch (BUSTYPE(si->sb.bustype)) {
3125 + sb = REGS2SB(si->curmap);
3126 + sbaddr = sb_base(R_SBREG(si, &sb->sbadmatch0));
3130 + sbaddr = OSL_PCI_READ_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32));
3135 + sbaddr = (uint32)si->curmap;
3137 +#endif /* BCMJTAG */
3143 + if (!GOODCOREADDR(sbaddr))
3146 + return ((sbaddr - SB_ENUM_BASE) / SB_CORE_SIZE);
3150 +sb_corevendor(sb_t *sbh)
3155 + si = SB_INFO(sbh);
3156 + sb = REGS2SB(si->curmap);
3158 + return ((R_SBREG(si, &(sb)->sbidhigh) & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT);
3162 +sb_corerev(sb_t *sbh)
3168 + si = SB_INFO(sbh);
3169 + sb = REGS2SB(si->curmap);
3170 + sbidh = R_SBREG(si, &(sb)->sbidhigh);
3172 + return (SBCOREREV(sbidh));
3180 + si = SB_INFO(sbh);
3184 +#define SBTML_ALLOW (SBTML_PE | SBTML_FGC | SBTML_FL_MASK)
3186 +/* set/clear sbtmstatelow core-specific flags */
3188 +sb_coreflags(sb_t *sbh, uint32 mask, uint32 val)
3194 + si = SB_INFO(sbh);
3195 + sb = REGS2SB(si->curmap);
3197 + ASSERT((val & ~mask) == 0);
3198 + ASSERT((mask & ~SBTML_ALLOW) == 0);
3200 + /* mask and set */
3201 + if (mask || val) {
3202 + w = (R_SBREG(si, &sb->sbtmstatelow) & ~mask) | val;
3203 + W_SBREG(si, &sb->sbtmstatelow, w);
3206 + /* return the new value */
3207 + return (R_SBREG(si, &sb->sbtmstatelow) & SBTML_ALLOW);
3210 +/* set/clear sbtmstatehigh core-specific flags */
3212 +sb_coreflagshi(sb_t *sbh, uint32 mask, uint32 val)
3218 + si = SB_INFO(sbh);
3219 + sb = REGS2SB(si->curmap);
3221 + ASSERT((val & ~mask) == 0);
3222 + ASSERT((mask & ~SBTMH_FL_MASK) == 0);
3224 + /* mask and set */
3225 + if (mask || val) {
3226 + w = (R_SBREG(si, &sb->sbtmstatehigh) & ~mask) | val;
3227 + W_SBREG(si, &sb->sbtmstatehigh, w);
3230 + /* return the new value */
3231 + return (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_FL_MASK);
3234 +/* caller needs to take care of core-specific bist hazards */
3236 +sb_corebist(sb_t *sbh, uint coreid, uint coreunit)
3243 + si = SB_INFO(sbh);
3245 + coreidx = sb_findcoreidx(si, coreid, coreunit);
3246 + if (!GOODIDX(coreidx))
3247 + result = BCME_ERROR;
3249 + sblo = sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), 0, 0);
3250 + sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), ~0, (sblo | SBTML_FGC | SBTML_BE));
3252 + SPINWAIT(((sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatehigh), 0, 0) & SBTMH_BISTD) == 0), 100000);
3254 + if (sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatehigh), 0, 0) & SBTMH_BISTF)
3255 + result = BCME_ERROR;
3257 + sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), ~0, sblo);
3264 +sb_iscoreup(sb_t *sbh)
3269 + si = SB_INFO(sbh);
3270 + sb = REGS2SB(si->curmap);
3272 + return ((R_SBREG(si, &(sb)->sbtmstatelow) & (SBTML_RESET | SBTML_REJ_MASK | SBTML_CLK)) == SBTML_CLK);
3276 + * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set operation,
3277 + * switch back to the original core, and return the new value.
3280 +sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val)
3285 + uint intr_val = 0;
3287 + ASSERT(GOODIDX(coreidx));
3288 + ASSERT(regoff < SB_CORE_SIZE);
3289 + ASSERT((val & ~mask) == 0);
3291 + INTR_OFF(si, intr_val);
3293 + /* save current core index */
3294 + origidx = sb_coreidx(&si->sb);
3297 + r = (uint32*) ((uchar*) sb_setcoreidx(&si->sb, coreidx) + regoff);
3299 + /* mask and set */
3300 + if (mask || val) {
3301 + if (regoff >= SBCONFIGOFF) {
3302 + w = (R_SBREG(si, r) & ~mask) | val;
3303 + W_SBREG(si, r, w);
3305 + w = (R_REG(r) & ~mask) | val;
3311 + if (regoff >= SBCONFIGOFF)
3312 + w = R_SBREG(si, r);
3316 + /* restore core index */
3317 + if (origidx != coreidx)
3318 + sb_setcoreidx(&si->sb, origidx);
3320 + INTR_RESTORE(si, intr_val);
3324 +#define DWORD_ALIGN(x) (x & ~(0x03))
3325 +#define BYTE_POS(x) (x & 0x3)
3326 +#define WORD_POS(x) (x & 0x1)
3328 +#define BYTE_SHIFT(x) (8 * BYTE_POS(x))
3329 +#define WORD_SHIFT(x) (16 * WORD_POS(x))
3331 +#define BYTE_VAL(a, x) ((a >> BYTE_SHIFT(x)) & 0xFF)
3332 +#define WORD_VAL(a, x) ((a >> WORD_SHIFT(x)) & 0xFFFF)
3334 +#define read_pci_cfg_byte(a) \
3335 + (BYTE_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xff)
3337 +#define read_pci_cfg_write(a) \
3338 + (WORD_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xffff)
3341 +/* scan the sb enumerated space to identify all cores */
3343 +BCMINITFN(sb_scan)(sb_info_t *si)
3353 + /* numcores should already be set */
3354 + ASSERT((si->numcores > 0) && (si->numcores <= SB_MAXCORES));
3356 + /* save current core index */
3357 + origidx = sb_coreidx(&si->sb);
3359 + si->sb.buscorerev = NOREV;
3360 + si->sb.buscoreidx = BADIDX;
3362 + si->gpioidx = BADIDX;
3368 + for (i = 0; i < si->numcores; i++) {
3369 + sb_setcoreidx(&si->sb, i);
3370 + si->coreid[i] = sb_coreid(&si->sb);
3372 + if (si->coreid[i] == SB_PCI) {
3374 + pcirev = sb_corerev(&si->sb);
3379 + si->sb.buscoretype = SB_PCI;
3380 + si->sb.buscorerev = pcirev;
3381 + si->sb.buscoreidx = pciidx;
3385 + * Find the gpio "controlling core" type and index.
3387 + * - if there's a chip common core - use that
3388 + * - else if there's a pci core (rev >= 2) - use that
3389 + * - else there had better be an extif core (4710 only)
3391 + if (GOODIDX(sb_findcoreidx(si, SB_CC, 0))) {
3392 + si->gpioidx = sb_findcoreidx(si, SB_CC, 0);
3393 + si->gpioid = SB_CC;
3394 + } else if (PCI(si) && (si->sb.buscorerev >= 2)) {
3395 + si->gpioidx = si->sb.buscoreidx;
3396 + si->gpioid = SB_PCI;
3397 + } else if (sb_findcoreidx(si, SB_EXTIF, 0)) {
3398 + si->gpioidx = sb_findcoreidx(si, SB_EXTIF, 0);
3399 + si->gpioid = SB_EXTIF;
3401 + ASSERT(si->gpioidx != BADIDX);
3403 + /* return to original core index */
3404 + sb_setcoreidx(&si->sb, origidx);
3407 +/* may be called with core in reset */
3409 +sb_detach(sb_t *sbh)
3414 + si = SB_INFO(sbh);
3419 + if (BUSTYPE(si->sb.bustype) == SB_BUS)
3420 + for (idx = 0; idx < SB_MAXCORES; idx++)
3421 + if (si->regs[idx]) {
3422 + REG_UNMAP(si->regs[idx]);
3423 + si->regs[idx] = NULL;
3427 + MFREE(si->osh, si, sizeof (sb_info_t));
3430 +/* use pci dev id to determine chip id for chips not having a chipcommon core */
3432 +BCMINITFN(sb_pcidev2chip)(uint pcidev)
3434 + if ((pcidev >= BCM4710_DEVICE_ID) && (pcidev <= BCM47XX_USB_ID))
3435 + return (BCM4710_DEVICE_ID);
3436 + if ((pcidev >= BCM4402_DEVICE_ID) && (pcidev <= BCM4402_V90_ID))
3437 + return (BCM4402_DEVICE_ID);
3438 + if (pcidev == BCM4401_ENET_ID)
3439 + return (BCM4402_DEVICE_ID);
3440 + if ((pcidev >= BCM4307_V90_ID) && (pcidev <= BCM4307_D11B_ID))
3441 + return (BCM4307_DEVICE_ID);
3442 + if (pcidev == BCM4301_DEVICE_ID)
3443 + return (BCM4301_DEVICE_ID);
3448 +/* convert chip number to number of i/o cores */
3450 +BCMINITFN(sb_chip2numcores)(uint chip)
3452 + if (chip == BCM4710_DEVICE_ID)
3454 + if (chip == BCM4402_DEVICE_ID)
3456 + if ((chip == BCM4301_DEVICE_ID) || (chip == BCM4307_DEVICE_ID))
3458 + if (chip == BCM4306_DEVICE_ID) /* < 4306c0 */
3460 + if (chip == BCM4704_DEVICE_ID)
3462 + if (chip == BCM5365_DEVICE_ID)
3465 + SB_ERROR(("sb_chip2numcores: unsupported chip 0x%x\n", chip));
3470 +/* return index of coreid or BADIDX if not found */
3472 +sb_findcoreidx( sb_info_t *si, uint coreid, uint coreunit)
3479 + for (i = 0; i < si->numcores; i++)
3480 + if (si->coreid[i] == coreid) {
3481 + if (found == coreunit)
3490 + * this function changes logical "focus" to the indiciated core,
3491 + * must be called with interrupt off.
3492 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
3495 +sb_setcoreidx(sb_t *sbh, uint coreidx)
3500 + si = SB_INFO(sbh);
3502 + if (coreidx >= si->numcores)
3506 + * If the user has provided an interrupt mask enabled function,
3507 + * then assert interrupts are disabled before switching the core.
3509 + ASSERT((si->intrsenabled_fn == NULL) || !(*(si)->intrsenabled_fn)((si)->intr_arg));
3511 + sbaddr = SB_ENUM_BASE + (coreidx * SB_CORE_SIZE);
3513 + switch (BUSTYPE(si->sb.bustype)) {
3516 + if (!si->regs[coreidx]) {
3517 + si->regs[coreidx] = (void*)REG_MAP(sbaddr, SB_CORE_SIZE);
3518 + ASSERT(GOODREGS(si->regs[coreidx]));
3520 + si->curmap = si->regs[coreidx];
3524 + /* point bar0 window */
3525 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, 4, sbaddr);
3531 + if (!si->regs[coreidx]) {
3532 + si->regs[coreidx] = (void *)sbaddr;
3533 + ASSERT(GOODREGS(si->regs[coreidx]));
3535 + si->curmap = si->regs[coreidx];
3537 +#endif /* BCMJTAG */
3540 + si->curidx = coreidx;
3542 + return (si->curmap);
3546 + * this function changes logical "focus" to the indiciated core,
3547 + * must be called with interrupt off.
3548 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
3551 +sb_setcore(sb_t *sbh, uint coreid, uint coreunit)
3556 + si = SB_INFO(sbh);
3557 + idx = sb_findcoreidx(si, coreid, coreunit);
3558 + if (!GOODIDX(idx))
3561 + return (sb_setcoreidx(sbh, idx));
3564 +/* return chip number */
3566 +BCMINITFN(sb_chip)(sb_t *sbh)
3570 + si = SB_INFO(sbh);
3571 + return (si->sb.chip);
3574 +/* return chip revision number */
3576 +BCMINITFN(sb_chiprev)(sb_t *sbh)
3580 + si = SB_INFO(sbh);
3581 + return (si->sb.chiprev);
3584 +/* return chip common revision number */
3586 +BCMINITFN(sb_chipcrev)(sb_t *sbh)
3590 + si = SB_INFO(sbh);
3591 + return (si->sb.ccrev);
3594 +/* return chip package option */
3596 +BCMINITFN(sb_chippkg)(sb_t *sbh)
3600 + si = SB_INFO(sbh);
3601 + return (si->sb.chippkg);
3604 +/* return PCI core rev. */
3606 +BCMINITFN(sb_pcirev)(sb_t *sbh)
3610 + si = SB_INFO(sbh);
3611 + return (si->sb.buscorerev);
3615 +BCMINITFN(sb_war16165)(sb_t *sbh)
3619 + si = SB_INFO(sbh);
3621 + return (PCI(si) && (si->sb.buscorerev <= 10));
3624 +/* return board vendor id */
3626 +BCMINITFN(sb_boardvendor)(sb_t *sbh)
3630 + si = SB_INFO(sbh);
3631 + return (si->sb.boardvendor);
3634 +/* return boardtype */
3636 +BCMINITFN(sb_boardtype)(sb_t *sbh)
3641 + si = SB_INFO(sbh);
3643 + if (BUSTYPE(si->sb.bustype) == SB_BUS && si->sb.boardtype == 0xffff) {
3644 + /* boardtype format is a hex string */
3645 + si->sb.boardtype = getintvar(NULL, "boardtype");
3647 + /* backward compatibility for older boardtype string format */
3648 + if ((si->sb.boardtype == 0) && (var = getvar(NULL, "boardtype"))) {
3649 + if (!strcmp(var, "bcm94710dev"))
3650 + si->sb.boardtype = BCM94710D_BOARD;
3651 + else if (!strcmp(var, "bcm94710ap"))
3652 + si->sb.boardtype = BCM94710AP_BOARD;
3653 + else if (!strcmp(var, "bu4710"))
3654 + si->sb.boardtype = BU4710_BOARD;
3655 + else if (!strcmp(var, "bcm94702mn"))
3656 + si->sb.boardtype = BCM94702MN_BOARD;
3657 + else if (!strcmp(var, "bcm94710r1"))
3658 + si->sb.boardtype = BCM94710R1_BOARD;
3659 + else if (!strcmp(var, "bcm94710r4"))
3660 + si->sb.boardtype = BCM94710R4_BOARD;
3661 + else if (!strcmp(var, "bcm94702cpci"))
3662 + si->sb.boardtype = BCM94702CPCI_BOARD;
3663 + else if (!strcmp(var, "bcm95380_rr"))
3664 + si->sb.boardtype = BCM95380RR_BOARD;
3668 + return (si->sb.boardtype);
3671 +/* return bus type of sbh device */
3677 + si = SB_INFO(sbh);
3678 + return (si->sb.bustype);
3681 +/* return bus core type */
3683 +sb_buscoretype(sb_t *sbh)
3687 + si = SB_INFO(sbh);
3689 + return (si->sb.buscoretype);
3692 +/* return bus core revision */
3694 +sb_buscorerev(sb_t *sbh)
3697 + si = SB_INFO(sbh);
3699 + return (si->sb.buscorerev);
3702 +/* return list of found cores */
3704 +sb_corelist(sb_t *sbh, uint coreid[])
3708 + si = SB_INFO(sbh);
3710 + bcopy((uchar*)si->coreid, (uchar*)coreid, (si->numcores * sizeof (uint)));
3711 + return (si->numcores);
3714 +/* return current register mapping */
3716 +sb_coreregs(sb_t *sbh)
3720 + si = SB_INFO(sbh);
3721 + ASSERT(GOODREGS(si->curmap));
3723 + return (si->curmap);
3727 +/* do buffered registers update */
3729 +sb_commit(sb_t *sbh)
3733 + uint intr_val = 0;
3735 + si = SB_INFO(sbh);
3737 + origidx = si->curidx;
3738 + ASSERT(GOODIDX(origidx));
3740 + INTR_OFF(si, intr_val);
3742 + /* switch over to chipcommon core if there is one, else use pci */
3743 + if (si->sb.ccrev != NOREV) {
3744 + chipcregs_t *ccregs = (chipcregs_t *)sb_setcore(sbh, SB_CC, 0);
3746 + /* do the buffer registers update */
3747 + W_REG(&ccregs->broadcastaddress, SB_COMMIT);
3748 + W_REG(&ccregs->broadcastdata, 0x0);
3749 + } else if (PCI(si)) {
3750 + sbpciregs_t *pciregs = (sbpciregs_t *)sb_setcore(sbh, SB_PCI, 0);
3752 + /* do the buffer registers update */
3753 + W_REG(&pciregs->bcastaddr, SB_COMMIT);
3754 + W_REG(&pciregs->bcastdata, 0x0);
3758 + /* restore core index */
3759 + sb_setcoreidx(sbh, origidx);
3760 + INTR_RESTORE(si, intr_val);
3763 +/* reset and re-enable a core */
3765 +sb_core_reset(sb_t *sbh, uint32 bits)
3769 + volatile uint32 dummy;
3771 + si = SB_INFO(sbh);
3772 + ASSERT(GOODREGS(si->curmap));
3773 + sb = REGS2SB(si->curmap);
3776 + * Must do the disable sequence first to work for arbitrary current core state.
3778 + sb_core_disable(sbh, bits);
3781 + * Now do the initialization sequence.
3784 + /* set reset while enabling the clock and forcing them on throughout the core */
3785 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | SBTML_RESET | bits));
3786 + dummy = R_SBREG(si, &sb->sbtmstatelow);
3789 + if (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_SERR) {
3790 + W_SBREG(si, &sb->sbtmstatehigh, 0);
3792 + if ((dummy = R_SBREG(si, &sb->sbimstate)) & (SBIM_IBE | SBIM_TO)) {
3793 + AND_SBREG(si, &sb->sbimstate, ~(SBIM_IBE | SBIM_TO));
3796 + /* clear reset and allow it to propagate throughout the core */
3797 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | bits));
3798 + dummy = R_SBREG(si, &sb->sbtmstatelow);
3801 + /* leave clock enabled */
3802 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_CLK | bits));
3803 + dummy = R_SBREG(si, &sb->sbtmstatelow);
3808 +sb_core_tofixup(sb_t *sbh)
3813 + si = SB_INFO(sbh);
3815 + if ( (BUSTYPE(si->sb.bustype) != PCI_BUS) || (PCI(si) && (si->sb.buscorerev >= 5)) )
3818 + ASSERT(GOODREGS(si->curmap));
3819 + sb = REGS2SB(si->curmap);
3821 + if (BUSTYPE(si->sb.bustype) == SB_BUS) {
3822 + SET_SBREG(si, &sb->sbimconfiglow,
3823 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
3824 + (0x5 << SBIMCL_RTO_SHIFT) | 0x3);
3826 + if (sb_coreid(sbh) == SB_PCI) {
3827 + SET_SBREG(si, &sb->sbimconfiglow,
3828 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
3829 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
3831 + SET_SBREG(si, &sb->sbimconfiglow, (SBIMCL_RTO_MASK | SBIMCL_STO_MASK), 0);
3839 + * Set the initiator timeout for the "master core".
3840 + * The master core is defined to be the core in control
3841 + * of the chip and so it issues accesses to non-memory
3842 + * locations (Because of dma *any* core can access memeory).
3844 + * The routine uses the bus to decide who is the master:
3846 + * JTAG_BUS => chipc
3849 + * This routine exists so callers can disable initiator
3850 + * timeouts so accesses to very slow devices like otp
3851 + * won't cause an abort. The routine allows arbitrary
3852 + * settings of the service and request timeouts, though.
3854 + * Returns the timeout state before changing it or -1
3858 +#define TO_MASK (SBIMCL_RTO_MASK | SBIMCL_STO_MASK)
3861 +sb_set_initiator_to(sb_t *sbh, uint32 to)
3864 + uint origidx, idx;
3865 + uint intr_val = 0;
3866 + uint32 tmp, ret = 0xffffffff;
3869 + si = SB_INFO(sbh);
3871 + if ((to & ~TO_MASK) != 0)
3874 + /* Figure out the master core */
3876 + switch (BUSTYPE(si->sb.bustype)) {
3878 + idx = si->sb.buscoreidx;
3884 + if ((idx = sb_findcoreidx(si, SB_MIPS33, 0)) == BADIDX)
3885 + idx = sb_findcoreidx(si, SB_MIPS, 0);
3890 + if (idx == BADIDX)
3893 + INTR_OFF(si, intr_val);
3894 + origidx = sb_coreidx(sbh);
3896 + sb = REGS2SB(sb_setcoreidx(sbh, idx));
3898 + tmp = R_SBREG(si, &sb->sbimconfiglow);
3899 + ret = tmp & TO_MASK;
3900 + W_SBREG(si, &sb->sbimconfiglow, (tmp & ~TO_MASK) | to);
3903 + sb_setcoreidx(sbh, origidx);
3904 + INTR_RESTORE(si, intr_val);
3909 +sb_core_disable(sb_t *sbh, uint32 bits)
3912 + volatile uint32 dummy;
3916 + si = SB_INFO(sbh);
3918 + ASSERT(GOODREGS(si->curmap));
3919 + sb = REGS2SB(si->curmap);
3921 + /* if core is already in reset, just return */
3922 + if (R_SBREG(si, &sb->sbtmstatelow) & SBTML_RESET)
3925 + /* reject value changed between sonics 2.2 and 2.3 */
3926 + if (si->sb.sonicsrev == SONICS_2_2)
3927 + rej = (1 << SBTML_REJ_SHIFT);
3929 + rej = (2 << SBTML_REJ_SHIFT);
3931 + /* if clocks are not enabled, put into reset and return */
3932 + if ((R_SBREG(si, &sb->sbtmstatelow) & SBTML_CLK) == 0)
3935 + /* set target reject and spin until busy is clear (preserve core-specific bits) */
3936 + OR_SBREG(si, &sb->sbtmstatelow, rej);
3937 + dummy = R_SBREG(si, &sb->sbtmstatelow);
3939 + SPINWAIT((R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_BUSY), 100000);
3941 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT) {
3942 + OR_SBREG(si, &sb->sbimstate, SBIM_RJ);
3943 + dummy = R_SBREG(si, &sb->sbimstate);
3945 + SPINWAIT((R_SBREG(si, &sb->sbimstate) & SBIM_BY), 100000);
3948 + /* set reset and reject while enabling the clocks */
3949 + W_SBREG(si, &sb->sbtmstatelow, (bits | SBTML_FGC | SBTML_CLK | rej | SBTML_RESET));
3950 + dummy = R_SBREG(si, &sb->sbtmstatelow);
3953 + /* don't forget to clear the initiator reject bit */
3954 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT)
3955 + AND_SBREG(si, &sb->sbimstate, ~SBIM_RJ);
3958 + /* leave reset and reject asserted */
3959 + W_SBREG(si, &sb->sbtmstatelow, (bits | rej | SBTML_RESET));
3963 +/* set chip watchdog reset timer to fire in 'ticks' backplane cycles */
3965 +sb_watchdog(sb_t *sbh, uint ticks)
3967 + sb_info_t *si = SB_INFO(sbh);
3970 + switch (si->gpioid) {
3972 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, watchdog), ~0, ticks);
3975 + sb_corereg(si, si->gpioidx, OFFSETOF(extifregs_t, watchdog), ~0, ticks);
3982 + * Configure the pci core for pci client (NIC) action
3983 + * coremask is the bitvec of cores by index to be enabled.
3986 +sb_pci_setup(sb_t *sbh, uint coremask)
3990 + sbpciregs_t *pciregs;
3995 + si = SB_INFO(sbh);
3997 + /* if not pci bus, we're done */
3998 + if (BUSTYPE(si->sb.bustype) != PCI_BUS)
4002 + ASSERT(si->sb.buscoreidx != BADIDX);
4004 + /* get current core index */
4007 + /* we interrupt on this backplane flag number */
4008 + ASSERT(GOODREGS(si->curmap));
4009 + sb = REGS2SB(si->curmap);
4010 + sbflag = R_SBREG(si, &sb->sbtpsflag) & SBTPS_NUM0_MASK;
4012 + /* switch over to pci core */
4013 + pciregs = (sbpciregs_t*) sb_setcoreidx(sbh, si->sb.buscoreidx);
4014 + sb = REGS2SB(pciregs);
4017 + * Enable sb->pci interrupts. Assume
4018 + * PCI rev 2.3 support was added in pci core rev 6 and things changed..
4020 + if ((PCI(si) && ((si->sb.buscorerev) >= 6))) {
4021 + /* pci config write to set this core bit in PCIIntMask */
4022 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32));
4023 + w |= (coremask << PCI_SBIM_SHIFT);
4024 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32), w);
4026 + /* set sbintvec bit for our flag number */
4027 + OR_SBREG(si, &sb->sbintvec, (1 << sbflag));
4031 + OR_REG(&pciregs->sbtopci2, (SBTOPCI_PREF|SBTOPCI_BURST));
4032 + if (si->sb.buscorerev >= 11)
4033 + OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI);
4034 + if (si->sb.buscorerev < 5) {
4035 + SET_SBREG(si, &sb->sbimconfiglow, SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
4036 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
4041 + /* switch back to previous core */
4042 + sb_setcoreidx(sbh, idx);
4046 +sb_base(uint32 admatch)
4051 + type = admatch & SBAM_TYPE_MASK;
4057 + base = admatch & SBAM_BASE0_MASK;
4058 + } else if (type == 1) {
4059 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
4060 + base = admatch & SBAM_BASE1_MASK;
4061 + } else if (type == 2) {
4062 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
4063 + base = admatch & SBAM_BASE2_MASK;
4070 +sb_size(uint32 admatch)
4075 + type = admatch & SBAM_TYPE_MASK;
4081 + size = 1 << (((admatch & SBAM_ADINT0_MASK) >> SBAM_ADINT0_SHIFT) + 1);
4082 + } else if (type == 1) {
4083 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
4084 + size = 1 << (((admatch & SBAM_ADINT1_MASK) >> SBAM_ADINT1_SHIFT) + 1);
4085 + } else if (type == 2) {
4086 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
4087 + size = 1 << (((admatch & SBAM_ADINT2_MASK) >> SBAM_ADINT2_SHIFT) + 1);
4093 +/* return the core-type instantiation # of the current core */
4095 +sb_coreunit(sb_t *sbh)
4103 + si = SB_INFO(sbh);
4108 + ASSERT(GOODREGS(si->curmap));
4109 + coreid = sb_coreid(sbh);
4111 + /* count the cores of our type */
4112 + for (i = 0; i < idx; i++)
4113 + if (si->coreid[i] == coreid)
4116 + return (coreunit);
4119 +static INLINE uint32
4123 + case CC_F6_2: return 2;
4124 + case CC_F6_3: return 3;
4125 + case CC_F6_4: return 4;
4126 + case CC_F6_5: return 5;
4127 + case CC_F6_6: return 6;
4128 + case CC_F6_7: return 7;
4129 + default: return 0;
4133 +/* calculate the speed the SB would run at given a set of clockcontrol values */
4135 +sb_clock_rate(uint32 pll_type, uint32 n, uint32 m)
4137 + uint32 n1, n2, clock, m1, m2, m3, mc;
4139 + n1 = n & CN_N1_MASK;
4140 + n2 = (n & CN_N2_MASK) >> CN_N2_SHIFT;
4142 + if (pll_type == PLL_TYPE6) {
4143 + if (m & CC_T6_MMASK)
4147 + } else if ((pll_type == PLL_TYPE1) ||
4148 + (pll_type == PLL_TYPE3) ||
4149 + (pll_type == PLL_TYPE4) ||
4150 + (pll_type == PLL_TYPE7)) {
4153 + } else if (pll_type == PLL_TYPE2) {
4156 + ASSERT((n1 >= 2) && (n1 <= 7));
4157 + ASSERT((n2 >= 5) && (n2 <= 23));
4158 + } else if (pll_type == PLL_TYPE5) {
4159 + return (100000000);
4162 + /* PLL types 3 and 7 use BASE2 (25Mhz) */
4163 + if ((pll_type == PLL_TYPE3) ||
4164 + (pll_type == PLL_TYPE7)) {
4165 + clock = CC_CLOCK_BASE2 * n1 * n2;
4168 + clock = CC_CLOCK_BASE1 * n1 * n2;
4173 + m1 = m & CC_M1_MASK;
4174 + m2 = (m & CC_M2_MASK) >> CC_M2_SHIFT;
4175 + m3 = (m & CC_M3_MASK) >> CC_M3_SHIFT;
4176 + mc = (m & CC_MC_MASK) >> CC_MC_SHIFT;
4178 + if ((pll_type == PLL_TYPE1) ||
4179 + (pll_type == PLL_TYPE3) ||
4180 + (pll_type == PLL_TYPE4) ||
4181 + (pll_type == PLL_TYPE7)) {
4183 + if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE3))
4190 + case CC_MC_BYPASS: return (clock);
4191 + case CC_MC_M1: return (clock / m1);
4192 + case CC_MC_M1M2: return (clock / (m1 * m2));
4193 + case CC_MC_M1M2M3: return (clock / (m1 * m2 * m3));
4194 + case CC_MC_M1M3: return (clock / (m1 * m3));
4195 + default: return (0);
4198 + ASSERT(pll_type == PLL_TYPE2);
4201 + m2 += CC_T2M2_BIAS;
4203 + ASSERT((m1 >= 2) && (m1 <= 7));
4204 + ASSERT((m2 >= 3) && (m2 <= 10));
4205 + ASSERT((m3 >= 2) && (m3 <= 7));
4207 + if ((mc & CC_T2MC_M1BYP) == 0)
4209 + if ((mc & CC_T2MC_M2BYP) == 0)
4211 + if ((mc & CC_T2MC_M3BYP) == 0)
4218 +/* returns the current speed the SB is running at */
4220 +sb_clock(sb_t *sbh)
4227 + uint32 pll_type, rate;
4228 + uint intr_val = 0;
4230 + si = SB_INFO(sbh);
4232 + pll_type = PLL_TYPE1;
4234 + INTR_OFF(si, intr_val);
4236 + /* switch to extif or chipc core */
4237 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
4238 + n = R_REG(&eir->clockcontrol_n);
4239 + m = R_REG(&eir->clockcontrol_sb);
4240 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
4241 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
4242 + n = R_REG(&cc->clockcontrol_n);
4243 + if (pll_type == PLL_TYPE6)
4244 + m = R_REG(&cc->clockcontrol_mips);
4245 + else if (pll_type == PLL_TYPE3)
4247 + // Added by Chen-I for 5365
4248 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
4249 + m = R_REG(&cc->clockcontrol_sb);
4251 + m = R_REG(&cc->clockcontrol_m2);
4254 + m = R_REG(&cc->clockcontrol_sb);
4256 + INTR_RESTORE(si, intr_val);
4260 + // Added by Chen-I for 5365
4261 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
4267 + /* calculate rate */
4268 + rate = sb_clock_rate(pll_type, n, m);
4269 + if (pll_type == PLL_TYPE3)
4273 + /* switch back to previous core */
4274 + sb_setcoreidx(sbh, idx);
4276 + INTR_RESTORE(si, intr_val);
4281 +/* change logical "focus" to the gpio core for optimized access */
4283 +sb_gpiosetcore(sb_t *sbh)
4287 + si = SB_INFO(sbh);
4289 + return (sb_setcoreidx(sbh, si->gpioidx));
4292 +/* mask&set gpiocontrol bits */
4294 +sb_gpiocontrol(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4299 + si = SB_INFO(sbh);
4302 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4304 + /* gpios could be shared on router platforms */
4305 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4306 + mask = priority ? (sb_gpioreservation & mask) :
4307 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4311 + switch (si->gpioid) {
4313 + regoff = OFFSETOF(chipcregs_t, gpiocontrol);
4317 + regoff = OFFSETOF(sbpciregs_t, gpiocontrol);
4324 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4327 +/* mask&set gpio output enable bits */
4329 +sb_gpioouten(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4334 + si = SB_INFO(sbh);
4337 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4339 + /* gpios could be shared on router platforms */
4340 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4341 + mask = priority ? (sb_gpioreservation & mask) :
4342 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4346 + switch (si->gpioid) {
4348 + regoff = OFFSETOF(chipcregs_t, gpioouten);
4352 + regoff = OFFSETOF(sbpciregs_t, gpioouten);
4356 + regoff = OFFSETOF(extifregs_t, gpio[0].outen);
4360 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4363 +/* mask&set gpio output bits */
4365 +sb_gpioout(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4370 + si = SB_INFO(sbh);
4373 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4375 + /* gpios could be shared on router platforms */
4376 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4377 + mask = priority ? (sb_gpioreservation & mask) :
4378 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4382 + switch (si->gpioid) {
4384 + regoff = OFFSETOF(chipcregs_t, gpioout);
4388 + regoff = OFFSETOF(sbpciregs_t, gpioout);
4392 + regoff = OFFSETOF(extifregs_t, gpio[0].out);
4396 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4399 +/* reserve one gpio */
4401 +sb_gpioreserve(sb_t *sbh, uint32 gpio_bitmask, uint8 priority)
4405 + si = SB_INFO(sbh);
4407 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4409 + /* only cores on SB_BUS share GPIO's and only applcation users need to reserve/release GPIO */
4410 + if ( (BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) {
4411 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority));
4414 + /* make sure only one bit is set */
4415 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) {
4416 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1)));
4420 + /* already reserved */
4421 + if (sb_gpioreservation & gpio_bitmask)
4423 + /* set reservation */
4424 + sb_gpioreservation |= gpio_bitmask;
4426 + return sb_gpioreservation;
4429 +/* release one gpio */
4431 + * releasing the gpio doesn't change the current value on the GPIO last write value
4432 + * persists till some one overwrites it
4436 +sb_gpiorelease(sb_t *sbh, uint32 gpio_bitmask, uint8 priority)
4440 + si = SB_INFO(sbh);
4442 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4444 + /* only cores on SB_BUS share GPIO's and only applcation users need to reserve/release GPIO */
4445 + if ( (BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) {
4446 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority));
4449 + /* make sure only one bit is set */
4450 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) {
4451 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1)));
4455 + /* already released */
4456 + if (!(sb_gpioreservation & gpio_bitmask))
4459 + /* clear reservation */
4460 + sb_gpioreservation &= ~gpio_bitmask;
4462 + return sb_gpioreservation;
4465 +/* return the current gpioin register value */
4467 +sb_gpioin(sb_t *sbh)
4472 + si = SB_INFO(sbh);
4475 + switch (si->gpioid) {
4477 + regoff = OFFSETOF(chipcregs_t, gpioin);
4481 + regoff = OFFSETOF(sbpciregs_t, gpioin);
4485 + regoff = OFFSETOF(extifregs_t, gpioin);
4489 + return (sb_corereg(si, si->gpioidx, regoff, 0, 0));
4492 +/* mask&set gpio interrupt polarity bits */
4494 +sb_gpiointpolarity(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4499 + si = SB_INFO(sbh);
4502 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4504 + /* gpios could be shared on router platforms */
4505 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4506 + mask = priority ? (sb_gpioreservation & mask) :
4507 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4511 + switch (si->gpioid) {
4513 + regoff = OFFSETOF(chipcregs_t, gpiointpolarity);
4517 + /* pci gpio implementation does not support interrupt polarity */
4522 + regoff = OFFSETOF(extifregs_t, gpiointpolarity);
4526 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4529 +/* mask&set gpio interrupt mask bits */
4531 +sb_gpiointmask(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4536 + si = SB_INFO(sbh);
4539 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4541 + /* gpios could be shared on router platforms */
4542 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4543 + mask = priority ? (sb_gpioreservation & mask) :
4544 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4548 + switch (si->gpioid) {
4550 + regoff = OFFSETOF(chipcregs_t, gpiointmask);
4554 + /* pci gpio implementation does not support interrupt mask */
4559 + regoff = OFFSETOF(extifregs_t, gpiointmask);
4563 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4566 +/* assign the gpio to an led */
4568 +sb_gpioled(sb_t *sbh, uint32 mask, uint32 val)
4572 + si = SB_INFO(sbh);
4573 + if (si->sb.ccrev < 16)
4576 + /* gpio led powersave reg */
4577 + return(sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimeroutmask), mask, val));
4580 +/* mask&set gpio timer val */
4582 +sb_gpiotimerval(sb_t *sbh, uint32 mask, uint32 gpiotimerval)
4585 + si = SB_INFO(sbh);
4587 + if (si->sb.ccrev < 16)
4590 + return(sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), mask, gpiotimerval));
4594 +/* return the slow clock source - LPO, XTAL, or PCI */
4596 +sb_slowclk_src(sb_info_t *si)
4601 + ASSERT(sb_coreid(&si->sb) == SB_CC);
4603 + if (si->sb.ccrev < 6) {
4604 + if ((BUSTYPE(si->sb.bustype) == PCI_BUS)
4605 + && (OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32)) & PCI_CFG_GPIO_SCS))
4606 + return (SCC_SS_PCI);
4608 + return (SCC_SS_XTAL);
4609 + } else if (si->sb.ccrev < 10) {
4610 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx);
4611 + return (R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK);
4612 + } else /* Insta-clock */
4613 + return (SCC_SS_XTAL);
4616 +/* return the ILP (slowclock) min or max frequency */
4618 +sb_slowclk_freq(sb_info_t *si, bool max)
4625 + ASSERT(sb_coreid(&si->sb) == SB_CC);
4627 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx);
4629 + /* shouldn't be here unless we've established the chip has dynamic clk control */
4630 + ASSERT(R_REG(&cc->capabilities) & CAP_PWR_CTL);
4632 + slowclk = sb_slowclk_src(si);
4633 + if (si->sb.ccrev < 6) {
4634 + if (slowclk == SCC_SS_PCI)
4635 + return (max? (PCIMAXFREQ/64) : (PCIMINFREQ/64));
4637 + return (max? (XTALMAXFREQ/32) : (XTALMINFREQ/32));
4638 + } else if (si->sb.ccrev < 10) {
4639 + div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
4640 + if (slowclk == SCC_SS_LPO)
4641 + return (max? LPOMAXFREQ : LPOMINFREQ);
4642 + else if (slowclk == SCC_SS_XTAL)
4643 + return (max? (XTALMAXFREQ/div) : (XTALMINFREQ/div));
4644 + else if (slowclk == SCC_SS_PCI)
4645 + return (max? (PCIMAXFREQ/div) : (PCIMINFREQ/div));
4649 + /* Chipc rev 10 is InstaClock */
4650 + div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHIFT;
4651 + div = 4 * (div + 1);
4652 + return (max ? XTALMAXFREQ : (XTALMINFREQ/div));
4658 +sb_clkctl_setdelay(sb_info_t *si, void *chipcregs)
4661 + uint slowmaxfreq, pll_delay, slowclk;
4662 + uint pll_on_delay, fref_sel_delay;
4664 + pll_delay = PLL_DELAY;
4666 + /* If the slow clock is not sourced by the xtal then add the xtal_on_delay
4667 + * since the xtal will also be powered down by dynamic clk control logic.
4669 + slowclk = sb_slowclk_src(si);
4670 + if (slowclk != SCC_SS_XTAL)
4671 + pll_delay += XTAL_ON_DELAY;
4673 + /* Starting with 4318 it is ILP that is used for the delays */
4674 + slowmaxfreq = sb_slowclk_freq(si, (si->sb.ccrev >= 10) ? FALSE : TRUE);
4676 + pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000;
4677 + fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000;
4679 + cc = (chipcregs_t *)chipcregs;
4680 + W_REG(&cc->pll_on_delay, pll_on_delay);
4681 + W_REG(&cc->fref_sel_delay, fref_sel_delay);
4685 +sb_pwrctl_slowclk(void *sbh, bool set, uint *div)
4690 + uint intr_val = 0;
4693 + si = SB_INFO(sbh);
4695 + /* chipcommon cores prior to rev6 don't support slowclkcontrol */
4696 + if (si->sb.ccrev < 6)
4699 + /* chipcommon cores rev10 are a whole new ball game */
4700 + if (si->sb.ccrev >= 10)
4703 + if (set && ((*div % 4) || (*div < 4)))
4706 + INTR_OFF(si, intr_val);
4707 + origidx = si->curidx;
4708 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
4709 + ASSERT(cc != NULL);
4711 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL)) {
4717 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, ((*div / 4 - 1) << SCC_CD_SHIFT));
4718 + sb_clkctl_setdelay(sbh, (void *)cc);
4720 + *div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
4723 + sb_setcoreidx(sbh, origidx);
4724 + INTR_RESTORE(si, intr_val);
4728 +/* initialize power control delay registers */
4729 +void sb_clkctl_init(sb_t *sbh)
4735 + si = SB_INFO(sbh);
4737 + origidx = si->curidx;
4739 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
4742 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
4745 + /* set all Instaclk chip ILP to 1 MHz */
4746 + if (si->sb.ccrev >= 10)
4747 + SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK, (ILP_DIV_1MHZ << SYCC_CD_SHIFT));
4749 + sb_clkctl_setdelay(si, (void *)cc);
4752 + sb_setcoreidx(sbh, origidx);
4754 +void sb_pwrctl_init(sb_t *sbh)
4756 +sb_clkctl_init(sbh);
4758 +/* return the value suitable for writing to the dot11 core FAST_PWRUP_DELAY register */
4760 +sb_clkctl_fast_pwrup_delay(sb_t *sbh)
4767 + uint intr_val = 0;
4769 + si = SB_INFO(sbh);
4771 + origidx = si->curidx;
4773 + INTR_OFF(si, intr_val);
4775 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
4778 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
4781 + slowminfreq = sb_slowclk_freq(si, FALSE);
4782 + fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + (slowminfreq - 1)) / slowminfreq;
4785 + sb_setcoreidx(sbh, origidx);
4786 + INTR_RESTORE(si, intr_val);
4789 +uint16 sb_pwrctl_fast_pwrup_delay(sb_t *sbh)
4791 +return sb_clkctl_fast_pwrup_delay(sbh);
4793 +/* turn primary xtal and/or pll off/on */
4795 +sb_clkctl_xtal(sb_t *sbh, uint what, bool on)
4798 + uint32 in, out, outen;
4800 + si = SB_INFO(sbh);
4802 + switch (BUSTYPE(si->sb.bustype)) {
4805 + in = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_IN, sizeof (uint32));
4806 + out = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32));
4807 + outen = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32));
4810 + * Avoid glitching the clock if GPRS is already using it.
4811 + * We can't actually read the state of the PLLPD so we infer it
4812 + * by the value of XTAL_PU which *is* readable via gpioin.
4814 + if (on && (in & PCI_CFG_GPIO_XTAL))
4818 + outen |= PCI_CFG_GPIO_XTAL;
4820 + outen |= PCI_CFG_GPIO_PLL;
4823 + /* turn primary xtal on */
4824 + if (what & XTAL) {
4825 + out |= PCI_CFG_GPIO_XTAL;
4827 + out |= PCI_CFG_GPIO_PLL;
4828 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
4829 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
4830 + OSL_DELAY(XTAL_ON_DELAY);
4835 + out &= ~PCI_CFG_GPIO_PLL;
4836 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
4841 + out &= ~PCI_CFG_GPIO_XTAL;
4843 + out |= PCI_CFG_GPIO_PLL;
4844 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
4845 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
4855 +int sb_pwrctl_xtal(sb_t *sbh, uint what, bool on)
4857 +return sb_clkctl_xtal(sbh,what,on);
4860 +/* set dynamic clk control mode (forceslow, forcefast, dynamic) */
4861 +/* returns true if ignore pll off is set and false if it is not */
4863 +sb_clkctl_clk(sb_t *sbh, uint mode)
4869 + bool forcefastclk=FALSE;
4870 + uint intr_val = 0;
4872 + si = SB_INFO(sbh);
4874 + /* chipcommon cores prior to rev6 don't support dynamic clock control */
4875 + if (si->sb.ccrev < 6)
4878 + /* chipcommon cores rev10 are a whole new ball game */
4879 + if (si->sb.ccrev >= 10)
4882 + INTR_OFF(si, intr_val);
4884 + origidx = si->curidx;
4886 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
4887 + ASSERT(cc != NULL);
4889 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
4893 + case CLK_FAST: /* force fast (pll) clock */
4894 + /* don't forget to force xtal back on before we clear SCC_DYN_XTAL.. */
4895 + sb_clkctl_xtal(&si->sb, XTAL, ON);
4897 + SET_REG(&cc->slow_clk_ctl, (SCC_XC | SCC_FS | SCC_IP), SCC_IP);
4900 + case CLK_DYNAMIC: /* enable dynamic clock control */
4901 + scc = R_REG(&cc->slow_clk_ctl);
4902 + scc &= ~(SCC_FS | SCC_IP | SCC_XC);
4903 + if ((scc & SCC_SS_MASK) != SCC_SS_XTAL)
4905 + W_REG(&cc->slow_clk_ctl, scc);
4907 + /* for dynamic control, we have to release our xtal_pu "force on" */
4909 + sb_clkctl_xtal(&si->sb, XTAL, OFF);
4916 + /* Is the h/w forcing the use of the fast clk */
4917 + forcefastclk = (bool)((R_REG(&cc->slow_clk_ctl) & SCC_IP) == SCC_IP);
4920 + sb_setcoreidx(sbh, origidx);
4921 + INTR_RESTORE(si, intr_val);
4922 + return (forcefastclk);
4925 +bool sb_pwrctl_clk(sb_t *sbh, uint mode)
4927 +return sb_clkctl_clk(sbh, mode);
4929 +/* register driver interrupt disabling and restoring callback functions */
4931 +sb_register_intr_callback(sb_t *sbh, void *intrsoff_fn, void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg)
4935 + si = SB_INFO(sbh);
4936 + si->intr_arg = intr_arg;
4937 + si->intrsoff_fn = (sb_intrsoff_t)intrsoff_fn;
4938 + si->intrsrestore_fn = (sb_intrsrestore_t)intrsrestore_fn;
4939 + si->intrsenabled_fn = (sb_intrsenabled_t)intrsenabled_fn;
4940 + /* save current core id. when this function called, the current core
4941 + * must be the core which provides driver functions(il, et, wl, etc.)
4943 + si->dev_coreid = si->coreid[si->curidx];
4948 +sb_corepciid(sb_t *sbh, uint16 *pcivendor, uint16 *pcidevice,
4949 + uint8 *pciclass, uint8 *pcisubclass, uint8 *pciprogif)
4951 + uint vendor, core, unit;
4952 + uint chip, chippkg;
4954 + uint8 class, subclass, progif;
4956 + vendor = sb_corevendor(sbh);
4957 + core = sb_coreid(sbh);
4958 + unit = sb_coreunit(sbh);
4960 + chip = BCMINIT(sb_chip)(sbh);
4961 + chippkg = BCMINIT(sb_chippkg)(sbh);
4965 + /* Known vendor translations */
4968 + vendor = VENDOR_BROADCOM;
4972 + /* Determine class based on known core codes */
4975 + class = PCI_CLASS_NET;
4976 + subclass = PCI_NET_ETHER;
4977 + core = BCM47XX_ILINE_ID;
4980 + class = PCI_CLASS_NET;
4981 + subclass = PCI_NET_ETHER;
4982 + core = BCM47XX_ENET_ID;
4986 + class = PCI_CLASS_MEMORY;
4987 + subclass = PCI_MEMORY_RAM;
4990 + class = PCI_CLASS_BRIDGE;
4991 + subclass = PCI_BRIDGE_PCI;
4995 + class = PCI_CLASS_CPU;
4996 + subclass = PCI_CPU_MIPS;
4999 + class = PCI_CLASS_COMM;
5000 + subclass = PCI_COMM_MODEM;
5001 + core = BCM47XX_V90_ID;
5004 + class = PCI_CLASS_SERIAL;
5005 + subclass = PCI_SERIAL_USB;
5006 + progif = 0x10; /* OHCI */
5007 + core = BCM47XX_USB_ID;
5010 + class = PCI_CLASS_SERIAL;
5011 + subclass = PCI_SERIAL_USB;
5012 + progif = 0x10; /* OHCI */
5013 + core = BCM47XX_USBH_ID;
5016 + class = PCI_CLASS_SERIAL;
5017 + subclass = PCI_SERIAL_USB;
5018 + core = BCM47XX_USBD_ID;
5021 + class = PCI_CLASS_CRYPT;
5022 + subclass = PCI_CRYPT_NETWORK;
5023 + core = BCM47XX_IPSEC_ID;
5026 + class = PCI_CLASS_NET;
5027 + subclass = PCI_NET_OTHER;
5028 + core = BCM47XX_ROBO_ID;
5032 + class = PCI_CLASS_MEMORY;
5033 + subclass = PCI_MEMORY_FLASH;
5036 + class = PCI_CLASS_NET;
5037 + subclass = PCI_NET_OTHER;
5038 + /* Let an nvram variable override this */
5039 + sprintf(varname, "wl%did", unit);
5040 + if ((core = getintvar(NULL, varname)) == 0) {
5041 + if (chip == BCM4712_DEVICE_ID) {
5042 + if (chippkg == BCM4712SMALL_PKG_ID)
5043 + core = BCM4306_D11G_ID;
5045 + core = BCM4306_D11DUAL_ID;
5051 + class = subclass = progif = 0xff;
5055 + *pcivendor = (uint16)vendor;
5056 + *pcidevice = (uint16)core;
5057 + *pciclass = class;
5058 + *pcisubclass = subclass;
5059 + *pciprogif = progif;
5063 +/* Build device path. Support SB, PCI, and JTAG for now. */
5065 +sb_devpath(sb_t *sbh, char *path, int size)
5068 + ASSERT(size >= SB_DEVPATH_BUFSZ);
5070 + switch (BUSTYPE((SB_INFO(sbh))->sb.bustype)) {
5073 + sprintf(path, "sb/%u/", sb_coreidx(sbh));
5076 + ASSERT((SB_INFO(sbh))->osh);
5077 + sprintf(path, "pci/%u/%u/", OSL_PCI_BUS((SB_INFO(sbh))->osh),
5078 + PCI_SLOT(((struct pci_dev *)(SB_INFO(sbh))->osh)->pdev)->devfn);
5081 + SB_ERROR(("sb_devpath: device 0 assumed\n"));
5082 + sprintf(path, "sd/%u/", sb_coreidx(sbh));
5093 +/* Fix chip's configuration. The current core may be changed upon return */
5095 +sb_pci_fixcfg(sb_info_t *si)
5097 + uint origidx, pciidx;
5098 + sbpciregs_t *pciregs;
5099 + uint16 val16, *reg16;
5100 + char name[SB_DEVPATH_BUFSZ+16], *value;
5101 + char devpath[SB_DEVPATH_BUFSZ];
5103 + ASSERT(BUSTYPE(si->sb.bustype) == PCI_BUS);
5105 + /* Fix PCI(e) SROM shadow area */
5106 + /* save the current index */
5107 + origidx = sb_coreidx(&si->sb);
5109 + if (si->sb.buscoretype == SB_PCI) {
5110 + pciregs = (sbpciregs_t *)sb_setcore(&si->sb, SB_PCI, 0);
5112 + reg16 = &pciregs->sprom[SRSH_PI_OFFSET];
5118 + pciidx = sb_coreidx(&si->sb);
5119 + val16 = R_REG(reg16);
5120 + if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (uint16)pciidx) {
5121 + val16 = (uint16)(pciidx << SRSH_PI_SHIFT) | (val16 & ~SRSH_PI_MASK);
5122 + W_REG(reg16, val16);
5125 + /* restore the original index */
5126 + sb_setcoreidx(&si->sb, origidx);
5129 + /* Fix bar0window */
5130 + /* !do it last, it changes the current core! */
5131 + if (sb_devpath(&si->sb, devpath, sizeof(devpath)))
5133 + sprintf(name, "%sb0w", devpath);
5134 + if ((value = getvar(NULL, name))) {
5135 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, sizeof(uint32),
5136 + bcm_strtoul(value, NULL, 16));
5137 + /* update curidx since the current core is changed */
5138 + si->curidx = _sb_coreidx(si);
5139 + if (si->curidx == BADIDX) {
5140 + SB_ERROR(("sb_pci_fixcfg: bad core index\n"));
5149 diff -urN linux.old/arch/mips/bcm947xx/broadcom/sflash.c linux.dev/arch/mips/bcm947xx/broadcom/sflash.c
5150 --- linux.old/arch/mips/bcm947xx/broadcom/sflash.c 1970-01-01 01:00:00.000000000 +0100
5151 +++ linux.dev/arch/mips/bcm947xx/broadcom/sflash.c 2005-12-15 16:59:20.045933750 +0100
5154 + * Broadcom SiliconBackplane chipcommon serial flash interface
5156 + * Copyright 2005, Broadcom Corporation
5157 + * All Rights Reserved.
5159 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5160 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5161 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5162 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5168 +#include <typedefs.h>
5169 +#include <sbconfig.h>
5170 +#include <sbchipc.h>
5171 +#include <mipsinc.h>
5172 +#include <bcmutils.h>
5173 +#include <bcmdevs.h>
5174 +#include <sflash.h>
5176 +/* Private global state */
5177 +static struct sflash sflash;
5179 +/* Issue a serial flash command */
5181 +sflash_cmd(chipcregs_t *cc, uint opcode)
5183 + W_REG(&cc->flashcontrol, SFLASH_START | opcode);
5184 + while (R_REG(&cc->flashcontrol) & SFLASH_BUSY);
5187 +/* Initialize serial flash access */
5189 +sflash_init(chipcregs_t *cc)
5193 + bzero(&sflash, sizeof(sflash));
5195 + sflash.type = R_REG(&cc->capabilities) & CAP_FLASH_MASK;
5197 + switch (sflash.type) {
5199 + /* Probe for ST chips */
5200 + sflash_cmd(cc, SFLASH_ST_DP);
5201 + sflash_cmd(cc, SFLASH_ST_RES);
5202 + id = R_REG(&cc->flashdata);
5205 + /* ST M25P20 2 Mbit Serial Flash */
5206 + sflash.blocksize = 64 * 1024;
5207 + sflash.numblocks = 4;
5210 + /* ST M25P40 4 Mbit Serial Flash */
5211 + sflash.blocksize = 64 * 1024;
5212 + sflash.numblocks = 8;
5215 + /* ST M25P80 8 Mbit Serial Flash */
5216 + sflash.blocksize = 64 * 1024;
5217 + sflash.numblocks = 16;
5220 + /* ST M25P16 16 Mbit Serial Flash */
5221 + sflash.blocksize = 64 * 1024;
5222 + sflash.numblocks = 32;
5225 + /* ST M25P32 32 Mbit Serial Flash */
5226 + sflash.blocksize = 64 * 1024;
5227 + sflash.numblocks = 64;
5230 + W_REG(&cc->flashaddress, 1);
5231 + sflash_cmd(cc, SFLASH_ST_RES);
5232 + id2 = R_REG(&cc->flashdata);
5233 + if (id2 == 0x44) {
5234 + /* SST M25VF80 4 Mbit Serial Flash */
5235 + sflash.blocksize = 64 * 1024;
5236 + sflash.numblocks = 8;
5243 + /* Probe for Atmel chips */
5244 + sflash_cmd(cc, SFLASH_AT_STATUS);
5245 + id = R_REG(&cc->flashdata) & 0x3c;
5248 + /* Atmel AT45DB011 1Mbit Serial Flash */
5249 + sflash.blocksize = 256;
5250 + sflash.numblocks = 512;
5253 + /* Atmel AT45DB021 2Mbit Serial Flash */
5254 + sflash.blocksize = 256;
5255 + sflash.numblocks = 1024;
5258 + /* Atmel AT45DB041 4Mbit Serial Flash */
5259 + sflash.blocksize = 256;
5260 + sflash.numblocks = 2048;
5263 + /* Atmel AT45DB081 8Mbit Serial Flash */
5264 + sflash.blocksize = 256;
5265 + sflash.numblocks = 4096;
5268 + /* Atmel AT45DB161 16Mbit Serial Flash */
5269 + sflash.blocksize = 512;
5270 + sflash.numblocks = 4096;
5273 + /* Atmel AT45DB321 32Mbit Serial Flash */
5274 + sflash.blocksize = 512;
5275 + sflash.numblocks = 8192;
5278 + /* Atmel AT45DB642 64Mbit Serial Flash */
5279 + sflash.blocksize = 1024;
5280 + sflash.numblocks = 8192;
5286 + sflash.size = sflash.blocksize * sflash.numblocks;
5287 + return sflash.size ? &sflash : NULL;
5290 +/* Read len bytes starting at offset into buf. Returns number of bytes read. */
5292 +sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf)
5295 + uint32 *from, *to;
5300 + if ((offset + len) > sflash.size)
5303 + if ((len >= 4) && (offset & 3))
5304 + cnt = 4 - (offset & 3);
5305 + else if ((len >= 4) && ((uint32)buf & 3))
5306 + cnt = 4 - ((uint32)buf & 3);
5310 + from = (uint32 *)KSEG1ADDR(SB_FLASH2 + offset);
5311 + to = (uint32 *)buf;
5314 + bcopy(from, to, cnt);
5318 + while (cnt >= 4) {
5323 + return (len - cnt);
5326 +/* Poll for command completion. Returns zero when complete. */
5328 +sflash_poll(chipcregs_t *cc, uint offset)
5330 + if (offset >= sflash.size)
5333 + switch (sflash.type) {
5335 + /* Check for ST Write In Progress bit */
5336 + sflash_cmd(cc, SFLASH_ST_RDSR);
5337 + return R_REG(&cc->flashdata) & SFLASH_ST_WIP;
5339 + /* Check for Atmel Ready bit */
5340 + sflash_cmd(cc, SFLASH_AT_STATUS);
5341 + return !(R_REG(&cc->flashdata) & SFLASH_AT_READY);
5347 +/* Write len bytes starting at offset into buf. Returns number of bytes
5348 + * written. Caller should poll for completion.
5351 +sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf)
5353 + struct sflash *sfl;
5356 + uint32 page, byte, mask;
5361 + if ((offset + len) > sflash.size)
5365 + switch (sfl->type) {
5367 + mask = R_REG(&cc->chipid);
5368 + is4712b0 = (((mask & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
5369 + ((mask & CID_REV_MASK) == (3 << CID_REV_SHIFT)));
5370 + /* Enable writes */
5371 + sflash_cmd(cc, SFLASH_ST_WREN);
5374 + W_REG(&cc->flashaddress, offset);
5375 + W_REG(&cc->flashdata, *buf++);
5376 + /* Set chip select */
5377 + OR_REG(&cc->gpioout, mask);
5378 + /* Issue a page program with the first byte */
5379 + sflash_cmd(cc, SFLASH_ST_PP);
5384 + if ((offset & 255) == 0) {
5385 + /* Page boundary, drop cs and return */
5386 + AND_REG(&cc->gpioout, ~mask);
5387 + if (!sflash_poll(cc, offset)) {
5388 + /* Flash rejected command */
5393 + /* Write single byte */
5394 + sflash_cmd(cc, *buf++);
5400 + /* All done, drop cs if needed */
5401 + if ((offset & 255) != 1) {
5403 + AND_REG(&cc->gpioout, ~mask);
5404 + if (!sflash_poll(cc, offset)) {
5405 + /* Flash rejected command */
5411 + W_REG(&cc->flashaddress, offset);
5412 + W_REG(&cc->flashdata, *buf);
5413 + /* Page program */
5414 + sflash_cmd(cc, SFLASH_ST_PP);
5418 + mask = sfl->blocksize - 1;
5419 + page = (offset & ~mask) << 1;
5420 + byte = offset & mask;
5421 + /* Read main memory page into buffer 1 */
5422 + if (byte || len < sfl->blocksize) {
5423 + W_REG(&cc->flashaddress, page);
5424 + sflash_cmd(cc, SFLASH_AT_BUF1_LOAD);
5425 + /* 250 us for AT45DB321B */
5426 + SPINWAIT(sflash_poll(cc, offset), 1000);
5427 + ASSERT(!sflash_poll(cc, offset));
5429 + /* Write into buffer 1 */
5430 + for (ret = 0; ret < len && byte < sfl->blocksize; ret++) {
5431 + W_REG(&cc->flashaddress, byte++);
5432 + W_REG(&cc->flashdata, *buf++);
5433 + sflash_cmd(cc, SFLASH_AT_BUF1_WRITE);
5435 + /* Write buffer 1 into main memory page */
5436 + W_REG(&cc->flashaddress, page);
5437 + sflash_cmd(cc, SFLASH_AT_BUF1_PROGRAM);
5444 +/* Erase a region. Returns number of bytes scheduled for erasure.
5445 + * Caller should poll for completion.
5448 +sflash_erase(chipcregs_t *cc, uint offset)
5450 + struct sflash *sfl;
5452 + if (offset >= sflash.size)
5456 + switch (sfl->type) {
5458 + sflash_cmd(cc, SFLASH_ST_WREN);
5459 + W_REG(&cc->flashaddress, offset);
5460 + sflash_cmd(cc, SFLASH_ST_SE);
5461 + return sfl->blocksize;
5463 + W_REG(&cc->flashaddress, offset << 1);
5464 + sflash_cmd(cc, SFLASH_AT_PAGE_ERASE);
5465 + return sfl->blocksize;
5472 + * writes the appropriate range of flash, a NULL buf simply erases
5473 + * the region of flash
5476 +sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf)
5478 + struct sflash *sfl;
5479 + uchar *block = NULL, *cur_ptr, *blk_ptr;
5480 + uint blocksize = 0, mask, cur_offset, cur_length, cur_retlen, remainder;
5481 + uint blk_offset, blk_len, copied;
5482 + int bytes, ret = 0;
5484 + /* Check address range */
5489 + if ((offset + len) > sfl->size)
5492 + blocksize = sfl->blocksize;
5493 + mask = blocksize - 1;
5495 + /* Allocate a block of mem */
5496 + if (!(block = MALLOC(NULL, blocksize)))
5500 + /* Align offset */
5501 + cur_offset = offset & ~mask;
5502 + cur_length = blocksize;
5505 + remainder = blocksize - (offset & mask);
5506 + if (len < remainder)
5509 + cur_retlen = remainder;
5511 + /* buf == NULL means erase only */
5513 + /* Copy existing data into holding block if necessary */
5514 + if ((offset & mask) || (len < blocksize)) {
5515 + blk_offset = cur_offset;
5516 + blk_len = cur_length;
5517 + blk_ptr = cur_ptr;
5519 + /* Copy entire block */
5521 + copied = sflash_read(cc, blk_offset, blk_len, blk_ptr);
5522 + blk_offset += copied;
5523 + blk_len -= copied;
5524 + blk_ptr += copied;
5528 + /* Copy input data into holding block */
5529 + memcpy(cur_ptr + (offset & mask), buf, cur_retlen);
5533 + if ((ret = sflash_erase(cc, (uint) cur_offset)) < 0)
5535 + while (sflash_poll(cc, (uint) cur_offset));
5537 + /* buf == NULL means erase only */
5539 + offset += cur_retlen;
5540 + len -= cur_retlen;
5544 + /* Write holding block */
5545 + while (cur_length > 0) {
5546 + if ((bytes = sflash_write(cc,
5547 + (uint) cur_offset,
5548 + (uint) cur_length,
5549 + (uchar *) cur_ptr)) < 0) {
5553 + while (sflash_poll(cc, (uint) cur_offset));
5554 + cur_offset += bytes;
5555 + cur_length -= bytes;
5559 + offset += cur_retlen;
5560 + len -= cur_retlen;
5561 + buf += cur_retlen;
5567 + MFREE(NULL, block, blocksize);
5571 diff -urN linux.old/arch/mips/bcm947xx/include/bcmdevs.h linux.dev/arch/mips/bcm947xx/include/bcmdevs.h
5572 --- linux.old/arch/mips/bcm947xx/include/bcmdevs.h 1970-01-01 01:00:00.000000000 +0100
5573 +++ linux.dev/arch/mips/bcm947xx/include/bcmdevs.h 2005-12-15 15:25:24.905340500 +0100
5576 + * Broadcom device-specific manifest constants.
5578 + * Copyright 2005, Broadcom Corporation
5579 + * All Rights Reserved.
5581 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5582 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5583 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5584 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5592 +/* Known PCI vendor Id's */
5593 +#define VENDOR_EPIGRAM 0xfeda
5594 +#define VENDOR_BROADCOM 0x14e4
5595 +#define VENDOR_3COM 0x10b7
5596 +#define VENDOR_NETGEAR 0x1385
5597 +#define VENDOR_DIAMOND 0x1092
5598 +#define VENDOR_DELL 0x1028
5599 +#define VENDOR_HP 0x0e11
5600 +#define VENDOR_APPLE 0x106b
5602 +/* PCI Device Id's */
5603 +#define BCM4210_DEVICE_ID 0x1072 /* never used */
5604 +#define BCM4211_DEVICE_ID 0x4211
5605 +#define BCM4230_DEVICE_ID 0x1086 /* never used */
5606 +#define BCM4231_DEVICE_ID 0x4231
5608 +#define BCM4410_DEVICE_ID 0x4410 /* bcm44xx family pci iline */
5609 +#define BCM4430_DEVICE_ID 0x4430 /* bcm44xx family cardbus iline */
5610 +#define BCM4412_DEVICE_ID 0x4412 /* bcm44xx family pci enet */
5611 +#define BCM4432_DEVICE_ID 0x4432 /* bcm44xx family cardbus enet */
5613 +#define BCM3352_DEVICE_ID 0x3352 /* bcm3352 device id */
5614 +#define BCM3360_DEVICE_ID 0x3360 /* bcm3360 device id */
5616 +#define EPI41210_DEVICE_ID 0xa0fa /* bcm4210 */
5617 +#define EPI41230_DEVICE_ID 0xa10e /* bcm4230 */
5619 +#define BCM47XX_ILINE_ID 0x4711 /* 47xx iline20 */
5620 +#define BCM47XX_V90_ID 0x4712 /* 47xx v90 codec */
5621 +#define BCM47XX_ENET_ID 0x4713 /* 47xx enet */
5622 +#define BCM47XX_EXT_ID 0x4714 /* 47xx external i/f */
5623 +#define BCM47XX_USB_ID 0x4715 /* 47xx usb */
5624 +#define BCM47XX_USBH_ID 0x4716 /* 47xx usb host */
5625 +#define BCM47XX_USBD_ID 0x4717 /* 47xx usb device */
5626 +#define BCM47XX_IPSEC_ID 0x4718 /* 47xx ipsec */
5627 +#define BCM47XX_ROBO_ID 0x4719 /* 47xx/53xx roboswitch core */
5628 +#define BCM47XX_USB20H_ID 0x471a /* 47xx usb 2.0 host */
5629 +#define BCM47XX_USB20D_ID 0x471b /* 47xx usb 2.0 device */
5631 +#define BCM4710_DEVICE_ID 0x4710 /* 4710 primary function 0 */
5633 +#define BCM4610_DEVICE_ID 0x4610 /* 4610 primary function 0 */
5634 +#define BCM4610_ILINE_ID 0x4611 /* 4610 iline100 */
5635 +#define BCM4610_V90_ID 0x4612 /* 4610 v90 codec */
5636 +#define BCM4610_ENET_ID 0x4613 /* 4610 enet */
5637 +#define BCM4610_EXT_ID 0x4614 /* 4610 external i/f */
5638 +#define BCM4610_USB_ID 0x4615 /* 4610 usb */
5640 +#define BCM4402_DEVICE_ID 0x4402 /* 4402 primary function 0 */
5641 +#define BCM4402_ENET_ID 0x4402 /* 4402 enet */
5642 +#define BCM4402_V90_ID 0x4403 /* 4402 v90 codec */
5643 +#define BCM4401_ENET_ID 0x170c /* 4401b0 production enet cards */
5645 +#define BCM4301_DEVICE_ID 0x4301 /* 4301 primary function 0 */
5646 +#define BCM4301_D11B_ID 0x4301 /* 4301 802.11b */
5648 +#define BCM4307_DEVICE_ID 0x4307 /* 4307 primary function 0 */
5649 +#define BCM4307_V90_ID 0x4305 /* 4307 v90 codec */
5650 +#define BCM4307_ENET_ID 0x4306 /* 4307 enet */
5651 +#define BCM4307_D11B_ID 0x4307 /* 4307 802.11b */
5653 +#define BCM4306_DEVICE_ID 0x4306 /* 4306 chipcommon chipid */
5654 +#define BCM4306_D11G_ID 0x4320 /* 4306 802.11g */
5655 +#define BCM4306_D11G_ID2 0x4325
5656 +#define BCM4306_D11A_ID 0x4321 /* 4306 802.11a */
5657 +#define BCM4306_UART_ID 0x4322 /* 4306 uart */
5658 +#define BCM4306_V90_ID 0x4323 /* 4306 v90 codec */
5659 +#define BCM4306_D11DUAL_ID 0x4324 /* 4306 dual A+B */
5661 +#define BCM4309_PKG_ID 1 /* 4309 package id */
5663 +#define BCM4303_D11B_ID 0x4303 /* 4303 802.11b */
5664 +#define BCM4303_PKG_ID 2 /* 4303 package id */
5666 +#define BCM4310_DEVICE_ID 0x4310 /* 4310 chipcommon chipid */
5667 +#define BCM4310_D11B_ID 0x4311 /* 4310 802.11b */
5668 +#define BCM4310_UART_ID 0x4312 /* 4310 uart */
5669 +#define BCM4310_ENET_ID 0x4313 /* 4310 enet */
5670 +#define BCM4310_USB_ID 0x4315 /* 4310 usb */
5672 +#define BCMGPRS_UART_ID 0x4333 /* Uart id used by 4306/gprs card */
5673 +#define BCMGPRS2_UART_ID 0x4344 /* Uart id used by 4306/gprs card */
5676 +#define BCM4704_DEVICE_ID 0x4704 /* 4704 chipcommon chipid */
5677 +#define BCM4704_ENET_ID 0x4706 /* 4704 enet (Use 47XX_ENET_ID instead!) */
5679 +#define BCM4317_DEVICE_ID 0x4317 /* 4317 chip common chipid */
5681 +#define BCM4318_DEVICE_ID 0x4318 /* 4318 chip common chipid */
5682 +#define BCM4318_D11G_ID 0x4318 /* 4318 801.11b/g id */
5683 +#define BCM4318_D11DUAL_ID 0x4319 /* 4318 801.11a/b/g id */
5684 +#define BCM4318_JTAGM_ID 0x4331 /* 4318 jtagm device id */
5686 +#define FPGA_JTAGM_ID 0x4330 /* ??? */
5689 +#define BCM4710_SDRAM 0x00000000 /* Physical SDRAM */
5690 +#define BCM4710_PCI_MEM 0x08000000 /* Host Mode PCI memory access space (64 MB) */
5691 +#define BCM4710_PCI_CFG 0x0c000000 /* Host Mode PCI configuration space (64 MB) */
5692 +#define BCM4710_PCI_DMA 0x40000000 /* Client Mode PCI memory access space (1 GB) */
5693 +#define BCM4710_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
5694 +#define BCM4710_ENUM 0x18000000 /* Beginning of core enumeration space */
5696 +/* Core register space */
5697 +#define BCM4710_REG_SDRAM 0x18000000 /* SDRAM core registers */
5698 +#define BCM4710_REG_ILINE20 0x18001000 /* InsideLine20 core registers */
5699 +#define BCM4710_REG_EMAC0 0x18002000 /* Ethernet MAC 0 core registers */
5700 +#define BCM4710_REG_CODEC 0x18003000 /* Codec core registers */
5701 +#define BCM4710_REG_USB 0x18004000 /* USB core registers */
5702 +#define BCM4710_REG_PCI 0x18005000 /* PCI core registers */
5703 +#define BCM4710_REG_MIPS 0x18006000 /* MIPS core registers */
5704 +#define BCM4710_REG_EXTIF 0x18007000 /* External Interface core registers */
5705 +#define BCM4710_REG_EMAC1 0x18008000 /* Ethernet MAC 1 core registers */
5707 +#define BCM4710_EXTIF 0x1f000000 /* External Interface base address */
5708 +#define BCM4710_PCMCIA_MEM 0x1f000000 /* External Interface PCMCIA memory access */
5709 +#define BCM4710_PCMCIA_IO 0x1f100000 /* PCMCIA I/O access */
5710 +#define BCM4710_PCMCIA_CONF 0x1f200000 /* PCMCIA configuration */
5711 +#define BCM4710_PROG 0x1f800000 /* Programable interface */
5712 +#define BCM4710_FLASH 0x1fc00000 /* Flash */
5714 +#define BCM4710_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
5716 +#define BCM4710_UART (BCM4710_REG_EXTIF + 0x00000300)
5718 +#define BCM4710_EUART (BCM4710_EXTIF + 0x00800000)
5719 +#define BCM4710_LED (BCM4710_EXTIF + 0x00900000)
5721 +#define BCM4712_DEVICE_ID 0x4712 /* 4712 chipcommon chipid */
5722 +#define BCM4712_MIPS_ID 0x4720 /* 4712 base devid */
5723 +#define BCM4712LARGE_PKG_ID 0 /* 340pin 4712 package id */
5724 +#define BCM4712SMALL_PKG_ID 1 /* 200pin 4712 package id */
5725 +#define BCM4712MID_PKG_ID 2 /* 225pin 4712 package id */
5727 +#define SDIOH_FPGA_ID 0x4380 /* sdio host fpga */
5729 +#define BCM5365_DEVICE_ID 0x5365 /* 5365 chipcommon chipid */
5730 +#define BCM5350_DEVICE_ID 0x5350 /* bcm5350 chipcommon chipid */
5731 +#define BCM5352_DEVICE_ID 0x5352 /* bcm5352 chipcommon chipid */
5733 +#define BCM4320_DEVICE_ID 0x4320 /* bcm4320 chipcommon chipid */
5735 +/* PCMCIA vendor Id's */
5737 +#define VENDOR_BROADCOM_PCMCIA 0x02d0
5739 +/* SDIO vendor Id's */
5740 +#define VENDOR_BROADCOM_SDIO 0x00BF
5744 +#define BFL_BTCOEXIST 0x0001 /* This board implements Bluetooth coexistance */
5745 +#define BFL_PACTRL 0x0002 /* This board has gpio 9 controlling the PA */
5746 +#define BFL_AIRLINEMODE 0x0004 /* This board implements gpio13 radio disable indication */
5747 +#define BFL_ENETROBO 0x0010 /* This board has robo switch or core */
5748 +#define BFL_CCKHIPWR 0x0040 /* Can do high-power CCK transmission */
5749 +#define BFL_ENETADM 0x0080 /* This board has ADMtek switch */
5750 +#define BFL_ENETVLAN 0x0100 /* This board has vlan capability */
5751 +#define BFL_AFTERBURNER 0x0200 /* This board supports Afterburner mode */
5752 +#define BFL_NOPCI 0x0400 /* This board leaves PCI floating */
5753 +#define BFL_FEM 0x0800 /* This board supports the Front End Module */
5754 +#define BFL_EXTLNA 0x1000 /* This board has an external LNA */
5755 +#define BFL_HGPA 0x2000 /* This board has a high gain PA */
5756 +#define BFL_BTCMOD 0x4000 /* This board' BTCOEXIST is in the alternate gpios */
5757 +#define BFL_ALTIQ 0x8000 /* Alternate I/Q settings */
5759 +/* board specific GPIO assignment, gpio 0-3 are also customer-configurable led */
5760 +#define BOARD_GPIO_HWRAD_B 0x010 /* bit 4 is HWRAD input on 4301 */
5761 +#define BOARD_GPIO_BTCMOD_IN 0x010 /* bit 4 is the alternate BT Coexistance Input */
5762 +#define BOARD_GPIO_BTCMOD_OUT 0x020 /* bit 5 is the alternate BT Coexistance Out */
5763 +#define BOARD_GPIO_BTC_IN 0x080 /* bit 7 is BT Coexistance Input */
5764 +#define BOARD_GPIO_BTC_OUT 0x100 /* bit 8 is BT Coexistance Out */
5765 +#define BOARD_GPIO_PACTRL 0x200 /* bit 9 controls the PA on new 4306 boards */
5766 +#define PCI_CFG_GPIO_SCS 0x10 /* PCI config space bit 4 for 4306c0 slow clock source */
5767 +#define PCI_CFG_GPIO_HWRAD 0x20 /* PCI config space GPIO 13 for hw radio disable */
5768 +#define PCI_CFG_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */
5769 +#define PCI_CFG_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */
5772 +#define SB_BUS 0 /* Silicon Backplane */
5773 +#define PCI_BUS 1 /* PCI target */
5774 +#define PCMCIA_BUS 2 /* PCMCIA target */
5775 +#define SDIO_BUS 3 /* SDIO target */
5776 +#define JTAG_BUS 4 /* JTAG */
5778 +/* Allows optimization for single-bus support */
5780 +#define BUSTYPE(bus) (BCMBUSTYPE)
5782 +#define BUSTYPE(bus) (bus)
5785 +/* power control defines */
5786 +#define PLL_DELAY 150 /* us pll on delay */
5787 +#define FREF_DELAY 200 /* us fref change delay */
5788 +#define MIN_SLOW_CLK 32 /* us Slow clock period */
5789 +#define XTAL_ON_DELAY 1000 /* us crystal power-on delay */
5791 +/* Reference Board Types */
5793 +#define BU4710_BOARD 0x0400
5794 +#define VSIM4710_BOARD 0x0401
5795 +#define QT4710_BOARD 0x0402
5797 +#define BU4610_BOARD 0x0403
5798 +#define VSIM4610_BOARD 0x0404
5800 +#define BU4307_BOARD 0x0405
5801 +#define BCM94301CB_BOARD 0x0406
5802 +#define BCM94301PC_BOARD 0x0406 /* Pcmcia 5v card */
5803 +#define BCM94301MP_BOARD 0x0407
5804 +#define BCM94307MP_BOARD 0x0408
5805 +#define BCMAP4307_BOARD 0x0409
5807 +#define BU4309_BOARD 0x040a
5808 +#define BCM94309CB_BOARD 0x040b
5809 +#define BCM94309MP_BOARD 0x040c
5810 +#define BCM4309AP_BOARD 0x040d
5812 +#define BCM94302MP_BOARD 0x040e
5814 +#define VSIM4310_BOARD 0x040f
5815 +#define BU4711_BOARD 0x0410
5816 +#define BCM94310U_BOARD 0x0411
5817 +#define BCM94310AP_BOARD 0x0412
5818 +#define BCM94310MP_BOARD 0x0414
5820 +#define BU4306_BOARD 0x0416
5821 +#define BCM94306CB_BOARD 0x0417
5822 +#define BCM94306MP_BOARD 0x0418
5824 +#define BCM94710D_BOARD 0x041a
5825 +#define BCM94710R1_BOARD 0x041b
5826 +#define BCM94710R4_BOARD 0x041c
5827 +#define BCM94710AP_BOARD 0x041d
5830 +#define BU2050_BOARD 0x041f
5833 +#define BCM94309G_BOARD 0x0421
5835 +#define BCM94301PC3_BOARD 0x0422 /* Pcmcia 3.3v card */
5837 +#define BU4704_BOARD 0x0423
5838 +#define BU4702_BOARD 0x0424
5840 +#define BCM94306PC_BOARD 0x0425 /* pcmcia 3.3v 4306 card */
5842 +#define BU4317_BOARD 0x0426
5845 +#define BCM94702MN_BOARD 0x0428
5847 +/* BCM4702 1U CompactPCI Board */
5848 +#define BCM94702CPCI_BOARD 0x0429
5850 +/* BCM4702 with BCM95380 VLAN Router */
5851 +#define BCM95380RR_BOARD 0x042a
5853 +/* cb4306 with SiGe PA */
5854 +#define BCM94306CBSG_BOARD 0x042b
5856 +/* mp4301 with 2050 radio */
5857 +#define BCM94301MPL_BOARD 0x042c
5859 +/* cb4306 with SiGe PA */
5860 +#define PCSG94306_BOARD 0x042d
5862 +/* bu4704 with sdram */
5863 +#define BU4704SD_BOARD 0x042e
5865 +/* Dual 11a/11g Router */
5866 +#define BCM94704AGR_BOARD 0x042f
5868 +/* 11a-only minipci */
5869 +#define BCM94308MP_BOARD 0x0430
5873 +/* BCM94317 boards */
5874 +#define BCM94317CB_BOARD 0x0440
5875 +#define BCM94317MP_BOARD 0x0441
5876 +#define BCM94317PCMCIA_BOARD 0x0442
5877 +#define BCM94317SDIO_BOARD 0x0443
5879 +#define BU4712_BOARD 0x0444
5880 +#define BU4712SD_BOARD 0x045d
5881 +#define BU4712L_BOARD 0x045f
5883 +/* BCM4712 boards */
5884 +#define BCM94712AP_BOARD 0x0445
5885 +#define BCM94712P_BOARD 0x0446
5887 +/* BCM4318 boards */
5888 +#define BU4318_BOARD 0x0447
5889 +#define CB4318_BOARD 0x0448
5890 +#define MPG4318_BOARD 0x0449
5891 +#define MP4318_BOARD 0x044a
5892 +#define SD4318_BOARD 0x044b
5894 +/* BCM63XX boards */
5895 +#define BCM96338_BOARD 0x6338
5896 +#define BCM96345_BOARD 0x6345
5897 +#define BCM96348_BOARD 0x6348
5899 +/* Another mp4306 with SiGe */
5900 +#define BCM94306P_BOARD 0x044c
5902 +/* CF-like 4317 modules */
5903 +#define BCM94317CF_BOARD 0x044d
5906 +#define BCM94303MP_BOARD 0x044e
5909 +#define BCM94306MPSGH_BOARD 0x044f
5911 +/* BRCM 4306 w/ Front End Modules */
5912 +#define BCM94306MPM 0x0450
5913 +#define BCM94306MPL 0x0453
5916 +#define BCM94712AGR_BOARD 0x0451
5918 +/* The real CF 4317 board */
5919 +#define CFI4317_BOARD 0x0452
5922 +#define PC4303_BOARD 0x0454
5925 +#define BCM95350K_BOARD 0x0455
5928 +#define BCM95350R_BOARD 0x0456
5931 +#define BCM94306MPLNA_BOARD 0x0457
5934 +#define BU4320_BOARD 0x0458
5935 +#define BU4320S_BOARD 0x0459
5936 +#define BCM94320PH_BOARD 0x045a
5939 +#define BCM94306MPH_BOARD 0x045b
5942 +#define BCM94306PCIV_BOARD 0x045c
5944 +#define BU4712SD_BOARD 0x045d
5946 +#define BCM94320PFLSH_BOARD 0x045e
5948 +#define BU4712L_BOARD 0x045f
5949 +#define BCM94712LGR_BOARD 0x0460
5950 +#define BCM94320R_BOARD 0x0461
5952 +#define BU5352_BOARD 0x0462
5954 +#define BCM94318MPGH_BOARD 0x0463
5957 +#define BCM95352GR_BOARD 0x0467
5960 +#define BCM95351AGR_BOARD 0x0470
5962 +/* # of GPIO pins */
5963 +#define GPIO_NUMPINS 16
5965 +#endif /* _BCMDEVS_H */
5966 diff -urN linux.old/arch/mips/bcm947xx/include/bcmendian.h linux.dev/arch/mips/bcm947xx/include/bcmendian.h
5967 --- linux.old/arch/mips/bcm947xx/include/bcmendian.h 1970-01-01 01:00:00.000000000 +0100
5968 +++ linux.dev/arch/mips/bcm947xx/include/bcmendian.h 2005-12-15 15:25:47.146730500 +0100
5971 + * local version of endian.h - byte order defines
5973 + * Copyright 2005, Broadcom Corporation
5974 + * All Rights Reserved.
5976 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5977 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5978 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5979 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5984 +#ifndef _BCMENDIAN_H_
5985 +#define _BCMENDIAN_H_
5987 +#include <typedefs.h>
5989 +/* Byte swap a 16 bit value */
5990 +#define BCMSWAP16(val) \
5992 + (((uint16)(val) & (uint16)0x00ffU) << 8) | \
5993 + (((uint16)(val) & (uint16)0xff00U) >> 8) ))
5995 +/* Byte swap a 32 bit value */
5996 +#define BCMSWAP32(val) \
5998 + (((uint32)(val) & (uint32)0x000000ffUL) << 24) | \
5999 + (((uint32)(val) & (uint32)0x0000ff00UL) << 8) | \
6000 + (((uint32)(val) & (uint32)0x00ff0000UL) >> 8) | \
6001 + (((uint32)(val) & (uint32)0xff000000UL) >> 24) ))
6003 +/* 2 Byte swap a 32 bit value */
6004 +#define BCMSWAP32BY16(val) \
6006 + (((uint32)(val) & (uint32)0x0000ffffUL) << 16) | \
6007 + (((uint32)(val) & (uint32)0xffff0000UL) >> 16) ))
6010 +static INLINE uint16
6011 +bcmswap16(uint16 val)
6013 + return BCMSWAP16(val);
6016 +static INLINE uint32
6017 +bcmswap32(uint32 val)
6019 + return BCMSWAP32(val);
6022 +static INLINE uint32
6023 +bcmswap32by16(uint32 val)
6025 + return BCMSWAP32BY16(val);
6028 +/* buf - start of buffer of shorts to swap */
6029 +/* len - byte length of buffer */
6031 +bcmswap16_buf(uint16 *buf, uint len)
6036 + *buf = bcmswap16(*buf);
6042 +#ifndef IL_BIGENDIAN
6043 +#define HTON16(i) BCMSWAP16(i)
6044 +#define hton16(i) bcmswap16(i)
6045 +#define hton32(i) bcmswap32(i)
6046 +#define ntoh16(i) bcmswap16(i)
6047 +#define ntoh32(i) bcmswap32(i)
6048 +#define ltoh16(i) (i)
6049 +#define ltoh32(i) (i)
6050 +#define htol16(i) (i)
6051 +#define htol32(i) (i)
6053 +#define HTON16(i) (i)
6054 +#define hton16(i) (i)
6055 +#define hton32(i) (i)
6056 +#define ntoh16(i) (i)
6057 +#define ntoh32(i) (i)
6058 +#define ltoh16(i) bcmswap16(i)
6059 +#define ltoh32(i) bcmswap32(i)
6060 +#define htol16(i) bcmswap16(i)
6061 +#define htol32(i) bcmswap32(i)
6065 +#ifndef IL_BIGENDIAN
6066 +#define ltoh16_buf(buf, i)
6067 +#define htol16_buf(buf, i)
6069 +#define ltoh16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
6070 +#define htol16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
6074 +* load 16-bit value from unaligned little endian byte array.
6076 +static INLINE uint16
6077 +ltoh16_ua(uint8 *bytes)
6079 + return (bytes[1]<<8)+bytes[0];
6083 +* load 32-bit value from unaligned little endian byte array.
6085 +static INLINE uint32
6086 +ltoh32_ua(uint8 *bytes)
6088 + return (bytes[3]<<24)+(bytes[2]<<16)+(bytes[1]<<8)+bytes[0];
6092 +* load 16-bit value from unaligned big(network) endian byte array.
6094 +static INLINE uint16
6095 +ntoh16_ua(uint8 *bytes)
6097 + return (bytes[0]<<8)+bytes[1];
6101 +* load 32-bit value from unaligned big(network) endian byte array.
6103 +static INLINE uint32
6104 +ntoh32_ua(uint8 *bytes)
6106 + return (bytes[0]<<24)+(bytes[1]<<16)+(bytes[2]<<8)+bytes[3];
6109 +#define ltoh_ua(ptr) ( \
6110 + sizeof(*(ptr)) == sizeof(uint8) ? *(uint8 *)ptr : \
6111 + sizeof(*(ptr)) == sizeof(uint16) ? (((uint8 *)ptr)[1]<<8)+((uint8 *)ptr)[0] : \
6112 + (((uint8 *)ptr)[3]<<24)+(((uint8 *)ptr)[2]<<16)+(((uint8 *)ptr)[1]<<8)+((uint8 *)ptr)[0] \
6115 +#define ntoh_ua(ptr) ( \
6116 + sizeof(*(ptr)) == sizeof(uint8) ? *(uint8 *)ptr : \
6117 + sizeof(*(ptr)) == sizeof(uint16) ? (((uint8 *)ptr)[0]<<8)+((uint8 *)ptr)[1] : \
6118 + (((uint8 *)ptr)[0]<<24)+(((uint8 *)ptr)[1]<<16)+(((uint8 *)ptr)[2]<<8)+((uint8 *)ptr)[3] \
6121 +#endif /* _BCMENDIAN_H_ */
6122 diff -urN linux.old/arch/mips/bcm947xx/include/bcmnvram.h linux.dev/arch/mips/bcm947xx/include/bcmnvram.h
6123 --- linux.old/arch/mips/bcm947xx/include/bcmnvram.h 1970-01-01 01:00:00.000000000 +0100
6124 +++ linux.dev/arch/mips/bcm947xx/include/bcmnvram.h 2005-12-15 16:04:35.850827500 +0100
6127 + * NVRAM variable manipulation
6129 + * Copyright 2005, Broadcom Corporation
6130 + * All Rights Reserved.
6132 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6133 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6134 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6135 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6140 +#ifndef _bcmnvram_h_
6141 +#define _bcmnvram_h_
6143 +#ifndef _LANGUAGE_ASSEMBLY
6145 +#include <typedefs.h>
6147 +struct nvram_header {
6150 + uint32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
6151 + uint32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
6152 + uint32 config_ncdl; /* ncdl values for memc */
6155 +struct nvram_tuple {
6158 + struct nvram_tuple *next;
6162 + * Get the value of an NVRAM variable. The pointer returned may be
6163 + * invalid after a set.
6164 + * @param name name of variable to get
6165 + * @return value of variable or NULL if undefined
6167 +extern char * __init nvram_get(const char *name);
6170 + * Get the value of an NVRAM variable.
6171 + * @param name name of variable to get
6172 + * @return value of variable or NUL if undefined
6174 +#define nvram_safe_get(name) (BCMINIT(nvram_get)(name) ? : "")
6177 + * Match an NVRAM variable.
6178 + * @param name name of variable to match
6179 + * @param match value to compare against value of variable
6180 + * @return TRUE if variable is defined and its value is string equal
6181 + * to match or FALSE otherwise
6184 +nvram_match(char *name, char *match) {
6185 + const char *value = BCMINIT(nvram_get)(name);
6186 + return (value && !strcmp(value, match));
6190 + * Inversely match an NVRAM variable.
6191 + * @param name name of variable to match
6192 + * @param match value to compare against value of variable
6193 + * @return TRUE if variable is defined and its value is not string
6194 + * equal to invmatch or FALSE otherwise
6197 +nvram_invmatch(char *name, char *invmatch) {
6198 + const char *value = BCMINIT(nvram_get)(name);
6199 + return (value && strcmp(value, invmatch));
6202 +#endif /* _LANGUAGE_ASSEMBLY */
6204 +#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
6205 +#define NVRAM_VERSION 1
6206 +#define NVRAM_HEADER_SIZE 20
6207 +#define NVRAM_SPACE 0x8000
6209 +#define NVRAM_MAX_VALUE_LEN 255
6210 +#define NVRAM_MAX_PARAM_LEN 64
6212 +#endif /* _bcmnvram_h_ */
6213 diff -urN linux.old/arch/mips/bcm947xx/include/bcmsrom.h linux.dev/arch/mips/bcm947xx/include/bcmsrom.h
6214 --- linux.old/arch/mips/bcm947xx/include/bcmsrom.h 1970-01-01 01:00:00.000000000 +0100
6215 +++ linux.dev/arch/mips/bcm947xx/include/bcmsrom.h 2005-12-15 15:34:32.919589250 +0100
6218 + * Misc useful routines to access NIC local SROM/OTP .
6220 + * Copyright 2005, Broadcom Corporation
6221 + * All Rights Reserved.
6223 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6224 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6225 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6226 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6231 +#ifndef _bcmsrom_h_
6232 +#define _bcmsrom_h_
6234 +extern int srom_var_init(void *sbh, uint bus, void *curmap, osl_t *osh, char **vars, int *count);
6236 +extern int srom_read(uint bus, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf);
6237 +extern int srom_write(uint bus, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf);
6239 +#endif /* _bcmsrom_h_ */
6240 diff -urN linux.old/arch/mips/bcm947xx/include/bcmutils.h linux.dev/arch/mips/bcm947xx/include/bcmutils.h
6241 --- linux.old/arch/mips/bcm947xx/include/bcmutils.h 1970-01-01 01:00:00.000000000 +0100
6242 +++ linux.dev/arch/mips/bcm947xx/include/bcmutils.h 2005-12-15 16:44:25.619117750 +0100
6245 + * Misc useful os-independent macros and functions.
6247 + * Copyright 2005, Broadcom Corporation
6248 + * All Rights Reserved.
6250 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6251 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6252 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6253 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6257 +#ifndef _bcmutils_h_
6258 +#define _bcmutils_h_
6260 +/*** driver-only section ***/
6263 +#define _BCM_U 0x01 /* upper */
6264 +#define _BCM_L 0x02 /* lower */
6265 +#define _BCM_D 0x04 /* digit */
6266 +#define _BCM_C 0x08 /* cntrl */
6267 +#define _BCM_P 0x10 /* punct */
6268 +#define _BCM_S 0x20 /* white space (space/lf/tab) */
6269 +#define _BCM_X 0x40 /* hex digit */
6270 +#define _BCM_SP 0x80 /* hard space (0x20) */
6272 +#define GPIO_PIN_NOTDEFINED 0x20
6274 +extern unsigned char bcm_ctype[];
6275 +#define bcm_ismask(x) (bcm_ctype[(int)(unsigned char)(x)])
6277 +#define bcm_isalnum(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L|_BCM_D)) != 0)
6278 +#define bcm_isalpha(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L)) != 0)
6279 +#define bcm_iscntrl(c) ((bcm_ismask(c)&(_BCM_C)) != 0)
6280 +#define bcm_isdigit(c) ((bcm_ismask(c)&(_BCM_D)) != 0)
6281 +#define bcm_isgraph(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D)) != 0)
6282 +#define bcm_islower(c) ((bcm_ismask(c)&(_BCM_L)) != 0)
6283 +#define bcm_isprint(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D|_BCM_SP)) != 0)
6284 +#define bcm_ispunct(c) ((bcm_ismask(c)&(_BCM_P)) != 0)
6285 +#define bcm_isspace(c) ((bcm_ismask(c)&(_BCM_S)) != 0)
6286 +#define bcm_isupper(c) ((bcm_ismask(c)&(_BCM_U)) != 0)
6287 +#define bcm_isxdigit(c) ((bcm_ismask(c)&(_BCM_D|_BCM_X)) != 0)
6290 + * Spin at most 'us' microseconds while 'exp' is true.
6291 + * Caller should explicitly test 'exp' when this completes
6292 + * and take appropriate error action if 'exp' is still true.
6294 +#define SPINWAIT(exp, us) { \
6295 + uint countdown = (us) + 9; \
6296 + while ((exp) && (countdown >= 10)) {\
6298 + countdown -= 10; \
6302 +/* generic osl packet queue */
6304 + void *head; /* first packet to dequeue */
6305 + void *tail; /* last packet to dequeue */
6306 + uint len; /* number of queued packets */
6307 + uint maxlen; /* maximum number of queued packets */
6308 + bool priority; /* enqueue by packet priority */
6309 + uint8 prio_map[MAXPRIO+1]; /* user priority to packet enqueue policy map */
6311 +#define DEFAULT_QLEN 128
6313 +#define pktq_len(q) ((q)->len)
6314 +#define pktq_avail(q) ((q)->maxlen - (q)->len)
6315 +#define pktq_head(q) ((q)->head)
6316 +#define pktq_full(q) ((q)->len >= (q)->maxlen)
6317 +#define _pktq_pri(q, pri) ((q)->prio_map[pri])
6318 +#define pktq_tailpri(q) ((q)->tail ? _pktq_pri(q, PKTPRIO((q)->tail)) : _pktq_pri(q, 0))
6322 +extern uint pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf);
6323 +extern uint pkttotlen(osl_t *osh, void *);
6324 +extern void pktq_init(struct pktq *q, uint maxlen, const uint8 prio_map[]);
6325 +extern void pktenq(struct pktq *q, void *p, bool lifo);
6326 +extern void *pktdeq(struct pktq *q);
6327 +extern void *pktdeqtail(struct pktq *q);
6329 +extern uint bcm_atoi(char *s);
6330 +extern uchar bcm_toupper(uchar c);
6331 +extern ulong bcm_strtoul(char *cp, char **endp, uint base);
6332 +extern char *bcmstrstr(char *haystack, char *needle);
6333 +extern char *bcmstrcat(char *dest, const char *src);
6334 +extern ulong wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen);
6335 +/* ethernet address */
6336 +extern char *bcm_ether_ntoa(char *ea, char *buf);
6337 +extern int bcm_ether_atoe(char *p, char *ea);
6339 +extern void bcm_mdelay(uint ms);
6340 +/* variable access */
6341 +extern char *getvar(char *vars, char *name);
6342 +extern int getintvar(char *vars, char *name);
6343 +extern uint getgpiopin(char *vars, char *pin_name, uint def_pin);
6344 +#define bcmlog(fmt, a1, a2)
6345 +#define bcmdumplog(buf, size) *buf = '\0'
6346 +#define bcmdumplogent(buf, idx) -1
6348 +/*** driver/apps-shared section ***/
6350 +#define BCME_STRLEN 64
6351 +#define VALID_BCMERROR(e) ((e <= 0) && (e >= BCME_LAST))
6355 + * error codes could be added but the defined ones shouldn't be changed/deleted
6356 + * these error codes are exposed to the user code
6357 + * when ever a new error code is added to this list
6358 + * please update errorstring table with the related error string and
6359 + * update osl files with os specific errorcode map
6362 +#define BCME_ERROR -1 /* Error generic */
6363 +#define BCME_BADARG -2 /* Bad Argument */
6364 +#define BCME_BADOPTION -3 /* Bad option */
6365 +#define BCME_NOTUP -4 /* Not up */
6366 +#define BCME_NOTDOWN -5 /* Not down */
6367 +#define BCME_NOTAP -6 /* Not AP */
6368 +#define BCME_NOTSTA -7 /* Not STA */
6369 +#define BCME_BADKEYIDX -8 /* BAD Key Index */
6370 +#define BCME_RADIOOFF -9 /* Radio Off */
6371 +#define BCME_NOTBANDLOCKED -10 /* Not bandlocked */
6372 +#define BCME_NOCLK -11 /* No Clock*/
6373 +#define BCME_BADRATESET -12 /* BAD RateSet*/
6374 +#define BCME_BADBAND -13 /* BAD Band */
6375 +#define BCME_BUFTOOSHORT -14 /* Buffer too short */
6376 +#define BCME_BUFTOOLONG -15 /* Buffer too Long */
6377 +#define BCME_BUSY -16 /* Busy*/
6378 +#define BCME_NOTASSOCIATED -17 /* Not associated*/
6379 +#define BCME_BADSSIDLEN -18 /* BAD SSID Len */
6380 +#define BCME_OUTOFRANGECHAN -19 /* Out of Range Channel*/
6381 +#define BCME_BADCHAN -20 /* BAD Channel */
6382 +#define BCME_BADADDR -21 /* BAD Address*/
6383 +#define BCME_NORESOURCE -22 /* No resources*/
6384 +#define BCME_UNSUPPORTED -23 /* Unsupported*/
6385 +#define BCME_BADLEN -24 /* Bad Length*/
6386 +#define BCME_NOTREADY -25 /* Not ready Yet*/
6387 +#define BCME_EPERM -26 /* Not Permitted */
6388 +#define BCME_NOMEM -27 /* No Memory */
6389 +#define BCME_ASSOCIATED -28 /* Associated */
6390 +#define BCME_RANGE -29 /* Range Error*/
6391 +#define BCME_NOTFOUND -30 /* Not found */
6392 +#define BCME_LAST BCME_NOTFOUND
6395 +#define ABS(a) (((a)<0)?-(a):(a))
6399 +#define MIN(a, b) (((a)<(b))?(a):(b))
6403 +#define MAX(a, b) (((a)>(b))?(a):(b))
6406 +#define CEIL(x, y) (((x) + ((y)-1)) / (y))
6407 +#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
6408 +#define ISALIGNED(a, x) (((a) & ((x)-1)) == 0)
6409 +#define ISPOWEROF2(x) ((((x)-1)&(x))==0)
6410 +#define VALID_MASK(mask) !((mask) & ((mask) + 1))
6411 +#define OFFSETOF(type, member) ((uint)(uintptr)&((type *)0)->member)
6412 +#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
6414 +/* bit map related macros */
6416 +#define NBBY 8 /* 8 bits per byte */
6417 +#define setbit(a,i) (((uint8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY))
6418 +#define clrbit(a,i) (((uint8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
6419 +#define isset(a,i) (((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY)))
6420 +#define isclr(a,i) ((((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
6423 +#define NBITS(type) (sizeof(type) * 8)
6424 +#define NBITVAL(bits) (1 << (bits))
6425 +#define MAXBITVAL(bits) ((1 << (bits)) - 1)
6428 +#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
6429 +#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */
6430 +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
6431 +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
6432 +#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
6433 +#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
6435 +/* bcm_format_flags() bit description structure */
6436 +typedef struct bcm_bit_desc {
6441 +/* tag_ID/length/value_buffer tuple */
6442 +typedef struct bcm_tlv {
6448 +/* Check that bcm_tlv_t fits into the given buflen */
6449 +#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (int)(buflen) >= (int)(2 + (elt)->len))
6451 +/* buffer length for ethernet address from bcm_ether_ntoa() */
6452 +#define ETHER_ADDR_STR_LEN 18
6454 +/* unaligned load and store macros */
6455 +#ifdef IL_BIGENDIAN
6456 +static INLINE uint32
6457 +load32_ua(uint8 *a)
6459 + return ((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]);
6463 +store32_ua(uint8 *a, uint32 v)
6465 + a[0] = (v >> 24) & 0xff;
6466 + a[1] = (v >> 16) & 0xff;
6467 + a[2] = (v >> 8) & 0xff;
6471 +static INLINE uint16
6472 +load16_ua(uint8 *a)
6474 + return ((a[0] << 8) | a[1]);
6478 +store16_ua(uint8 *a, uint16 v)
6480 + a[0] = (v >> 8) & 0xff;
6486 +static INLINE uint32
6487 +load32_ua(uint8 *a)
6489 + return ((a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]);
6493 +store32_ua(uint8 *a, uint32 v)
6495 + a[3] = (v >> 24) & 0xff;
6496 + a[2] = (v >> 16) & 0xff;
6497 + a[1] = (v >> 8) & 0xff;
6501 +static INLINE uint16
6502 +load16_ua(uint8 *a)
6504 + return ((a[1] << 8) | a[0]);
6508 +store16_ua(uint8 *a, uint16 v)
6510 + a[1] = (v >> 8) & 0xff;
6518 +extern uint8 hndcrc8(uint8 *p, uint nbytes, uint8 crc);
6521 +extern bcm_tlv_t *bcm_next_tlv(bcm_tlv_t *elt, int *buflen);
6522 +extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key);
6523 +extern bcm_tlv_t *bcm_parse_ordered_tlvs(void *buf, int buflen, uint key);
6526 +extern const char *bcmerrorstr(int bcmerror);
6528 +/* multi-bool data type: set of bools, mbool is true if any is set */
6529 +typedef uint32 mbool;
6530 +#define mboolset(mb, bit) (mb |= bit) /* set one bool */
6531 +#define mboolclr(mb, bit) (mb &= ~bit) /* clear one bool */
6532 +#define mboolisset(mb, bit) ((mb & bit) != 0) /* TRUE if one bool is set */
6533 +#define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val)))
6535 +/* power conversion */
6536 +extern uint16 bcm_qdbm_to_mw(uint8 qdbm);
6537 +extern uint8 bcm_mw_to_qdbm(uint16 mw);
6539 +/* generic datastruct to help dump routines */
6546 +typedef uint32 (*readreg_rtn)(void *arg0, void *arg1, uint32 offset);
6547 +extern uint bcmdumpfields(readreg_rtn func_ptr, void *arg0, void *arg1, struct fielddesc *str, char *buf, uint32 bufsize);
6549 +extern uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint len);
6551 +#endif /* _bcmutils_h_ */
6552 diff -urN linux.old/arch/mips/bcm947xx/include/bitfuncs.h linux.dev/arch/mips/bcm947xx/include/bitfuncs.h
6553 --- linux.old/arch/mips/bcm947xx/include/bitfuncs.h 1970-01-01 01:00:00.000000000 +0100
6554 +++ linux.dev/arch/mips/bcm947xx/include/bitfuncs.h 2005-12-15 15:34:40.268048500 +0100
6557 + * bit manipulation utility functions
6559 + * Copyright 2005, Broadcom Corporation
6560 + * All Rights Reserved.
6562 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6563 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6564 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6565 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6569 +#ifndef _BITFUNCS_H
6570 +#define _BITFUNCS_H
6572 +#include <typedefs.h>
6574 +/* local prototypes */
6575 +static INLINE uint32 find_msbit(uint32 x);
6579 + * find_msbit: returns index of most significant set bit in x, with index
6580 + * range defined as 0-31. NOTE: returns zero if input is zero.
6583 +#if defined(USE_PENTIUM_BSR) && defined(__GNUC__)
6586 + * Implementation for Pentium processors and gcc. Note that this
6587 + * instruction is actually very slow on some processors (e.g., family 5,
6588 + * model 2, stepping 12, "Pentium 75 - 200"), so we use the generic
6589 + * implementation instead.
6591 +static INLINE uint32 find_msbit(uint32 x)
6594 + __asm__("bsrl %1,%0"
6603 + * Generic Implementation
6606 +#define DB_POW_MASK16 0xffff0000
6607 +#define DB_POW_MASK8 0x0000ff00
6608 +#define DB_POW_MASK4 0x000000f0
6609 +#define DB_POW_MASK2 0x0000000c
6610 +#define DB_POW_MASK1 0x00000002
6612 +static INLINE uint32 find_msbit(uint32 x)
6614 + uint32 temp_x = x;
6616 + if (temp_x & DB_POW_MASK16) {
6620 + if (temp_x & DB_POW_MASK8) {
6624 + if (temp_x & DB_POW_MASK4) {
6628 + if (temp_x & DB_POW_MASK2) {
6632 + if (temp_x & DB_POW_MASK1) {
6640 +#endif /* _BITFUNCS_H */
6641 diff -urN linux.old/arch/mips/bcm947xx/include/flash.h linux.dev/arch/mips/bcm947xx/include/flash.h
6642 --- linux.old/arch/mips/bcm947xx/include/flash.h 1970-01-01 01:00:00.000000000 +0100
6643 +++ linux.dev/arch/mips/bcm947xx/include/flash.h 2005-12-15 15:34:44.280299250 +0100
6646 + * flash.h: Common definitions for flash access.
6648 + * Copyright 2005, Broadcom Corporation
6649 + * All Rights Reserved.
6651 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6652 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6653 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6654 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6659 +/* Types of flashes we know about */
6660 +typedef enum _flash_type {OLD, BSC, SCS, AMD, SST, SFLASH} flash_type_t;
6662 +/* Commands to write/erase the flases */
6663 +typedef struct _flash_cmds{
6664 + flash_type_t type;
6667 + uint16 erase_block;
6668 + uint16 erase_chip;
6669 + uint16 write_word;
6675 + uint16 read_array;
6678 +#define UNLOCK_CMD_WORDS 2
6680 +typedef struct _unlock_cmd {
6681 + uint addr[UNLOCK_CMD_WORDS];
6682 + uint16 cmd[UNLOCK_CMD_WORDS];
6685 +/* Flash descriptors */
6686 +typedef struct _flash_desc {
6687 + uint16 mfgid; /* Manufacturer Id */
6688 + uint16 devid; /* Device Id */
6689 + uint size; /* Total size in bytes */
6690 + uint width; /* Device width in bytes */
6691 + flash_type_t type; /* Device type old, S, J */
6692 + uint bsize; /* Block size */
6693 + uint nb; /* Number of blocks */
6694 + uint ff; /* First full block */
6695 + uint lf; /* Last full block */
6696 + uint nsub; /* Number of subblocks */
6697 + uint *subblocks; /* Offsets for subblocks */
6698 + char *desc; /* Description */
6702 +#ifdef DECLARE_FLASHES
6703 +flash_cmds_t sflash_cmd_t =
6704 + { SFLASH, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
6706 +flash_cmds_t flash_cmds[] = {
6707 +/* type needu preera eraseb erasech write wbuf clcsr rdcsr rdid confrm read */
6708 + { BSC, 0, 0x00, 0x20, 0x00, 0x40, 0x00, 0x50, 0x70, 0x90, 0xd0, 0xff },
6709 + { SCS, 0, 0x00, 0x20, 0x00, 0x40, 0xe8, 0x50, 0x70, 0x90, 0xd0, 0xff },
6710 + { AMD, 1, 0x80, 0x30, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
6711 + { SST, 1, 0x80, 0x50, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
6715 +unlock_cmd_t unlock_cmd_amd = {
6717 +/* addr: */ { 0x0aa8, 0x0556},
6719 +/* addr: */ { 0x0aaa, 0x0554},
6721 +/* data: */ { 0xaa, 0x55}
6724 +unlock_cmd_t unlock_cmd_sst = {
6726 +/* addr: */ { 0xaaa8, 0x5556},
6728 +/* addr: */ { 0xaaaa, 0x5554},
6730 +/* data: */ { 0xaa, 0x55}
6733 +#define AMD_CMD 0xaaa
6734 +#define SST_CMD 0xaaaa
6736 +/* intel unlock block cmds */
6737 +#define INTEL_UNLOCK1 0x60
6738 +#define INTEL_UNLOCK2 0xD0
6740 +/* Just eight blocks of 8KB byte each */
6742 +uint blk8x8k[] = { 0x00000000,
6753 +/* Funky AMD arrangement for 29xx800's */
6754 +uint amd800[] = { 0x00000000, /* 16KB */
6755 + 0x00004000, /* 32KB */
6756 + 0x0000c000, /* 8KB */
6757 + 0x0000e000, /* 8KB */
6758 + 0x00010000, /* 8KB */
6759 + 0x00012000, /* 8KB */
6760 + 0x00014000, /* 32KB */
6761 + 0x0001c000, /* 16KB */
6765 +/* AMD arrangement for 29xx160's */
6766 +uint amd4112[] = { 0x00000000, /* 32KB */
6767 + 0x00008000, /* 8KB */
6768 + 0x0000a000, /* 8KB */
6769 + 0x0000c000, /* 16KB */
6772 +uint amd2114[] = { 0x00000000, /* 16KB */
6773 + 0x00004000, /* 8KB */
6774 + 0x00006000, /* 8KB */
6775 + 0x00008000, /* 32KB */
6780 +flash_desc_t sflash_desc =
6781 + { 0, 0, 0, 0, SFLASH, 0, 0, 0, 0, 0, NULL, "SFLASH" };
6783 +flash_desc_t flashes[] = {
6784 + { 0x00b0, 0x00d0, 0x0200000, 2, SCS, 0x10000, 32, 0, 31, 0, NULL, "Intel 28F160S3/5 1Mx16" },
6785 + { 0x00b0, 0x00d4, 0x0400000, 2, SCS, 0x10000, 64, 0, 63, 0, NULL, "Intel 28F320S3/5 2Mx16" },
6786 + { 0x0089, 0x8890, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160B3 1Mx16 TopB" },
6787 + { 0x0089, 0x8891, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160B3 1Mx16 BotB" },
6788 + { 0x0089, 0x8896, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320B3 2Mx16 TopB" },
6789 + { 0x0089, 0x8897, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320B3 2Mx16 BotB" },
6790 + { 0x0089, 0x8898, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640B3 4Mx16 TopB" },
6791 + { 0x0089, 0x8899, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640B3 4Mx16 BotB" },
6792 + { 0x0089, 0x88C2, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160C3 1Mx16 TopB" },
6793 + { 0x0089, 0x88C3, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160C3 1Mx16 BotB" },
6794 + { 0x0089, 0x88C4, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320C3 2Mx16 TopB" },
6795 + { 0x0089, 0x88C5, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320C3 2Mx16 BotB" },
6796 + { 0x0089, 0x88CC, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640C3 4Mx16 TopB" },
6797 + { 0x0089, 0x88CD, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640C3 4Mx16 BotB" },
6798 + { 0x0089, 0x0014, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J5 2Mx16" },
6799 + { 0x0089, 0x0015, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J5 4Mx16" },
6800 + { 0x0089, 0x0016, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J3 2Mx16" },
6801 + { 0x0089, 0x0017, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J3 4Mx16" },
6802 + { 0x0089, 0x0018, 0x1000000, 2, SCS, 0x20000, 128, 0, 127, 0, NULL, "Intel 28F128J3 8Mx16" },
6803 + { 0x00b0, 0x00e3, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Sharp 28F320BJE 2Mx16 BotB" },
6804 + { 0x0001, 0x224a, 0x0100000, 2, AMD, 0x10000, 16, 0, 13, 8, amd800, "AMD 29DL800BT 512Kx16 TopB" },
6805 + { 0x0001, 0x22cb, 0x0100000, 2, AMD, 0x10000, 16, 2, 15, 8, amd800, "AMD 29DL800BB 512Kx16 BotB" },
6806 + { 0x0001, 0x22c4, 0x0200000, 2, AMD, 0x10000, 32, 0, 30, 4, amd2114, "AMD 29lv160DT 1Mx16 TopB" },
6807 + { 0x0001, 0x2249, 0x0200000, 2, AMD, 0x10000, 32, 1, 31, 4, amd4112, "AMD 29lv160DB 1Mx16 BotB" },
6808 + { 0x0001, 0x22f6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320DT 2Mx16 TopB" },
6809 + { 0x0001, 0x22f9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320DB 2Mx16 BotB" },
6810 + { 0x0001, 0x227e, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320MT 2Mx16 TopB" },
6811 + { 0x0001, 0x2200, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320MB 2Mx16 BotB" },
6812 + { 0x0020, 0x22CA, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "ST 29w320DT 2Mx16 TopB" },
6813 + { 0x0020, 0x22CB, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "ST 29w320DB 2Mx16 BotB" },
6814 + { 0x00C2, 0x00A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
6815 + { 0x00C2, 0x00A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
6816 + { 0x0004, 0x22F6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MBM29LV320TE 2Mx16 TopB" },
6817 + { 0x0004, 0x22F9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MBM29LV320BE 2Mx16 BotB" },
6818 + { 0x0098, 0x009A, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "TC58FVT321 2Mx16 TopB" },
6819 + { 0x0098, 0x009C, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "TC58FVB321 2Mx16 BotB" },
6820 + { 0x00C2, 0x22A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
6821 + { 0x00C2, 0x22A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
6822 + { 0x00BF, 0x2783, 0x0400000, 2, SST, 0x10000, 64, 0, 63, 0, NULL, "SST39VF320 2Mx16" },
6823 + { 0, 0, 0, 0, OLD, 0, 0, 0, 0, 0, NULL, NULL },
6828 +extern flash_cmds_t flash_cmds[];
6829 +extern unlock_cmd_t unlock_cmd;
6830 +extern flash_desc_t flashes[];
6833 diff -urN linux.old/arch/mips/bcm947xx/include/flashutl.h linux.dev/arch/mips/bcm947xx/include/flashutl.h
6834 --- linux.old/arch/mips/bcm947xx/include/flashutl.h 1970-01-01 01:00:00.000000000 +0100
6835 +++ linux.dev/arch/mips/bcm947xx/include/flashutl.h 2005-12-15 15:34:48.160541750 +0100
6838 + * BCM47XX FLASH driver interface
6840 + * Copyright 2005, Broadcom Corporation
6841 + * All Rights Reserved.
6843 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6844 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6845 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6846 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6850 +#ifndef _flashutl_h_
6851 +#define _flashutl_h_
6854 +#ifndef _LANGUAGE_ASSEMBLY
6856 +int sysFlashInit(char *flash_str);
6857 +int sysFlashRead(uint off, uchar *dst, uint bytes);
6858 +int sysFlashWrite(uint off, uchar *src, uint bytes);
6859 +void nvWrite(unsigned short *data, unsigned int len);
6861 +#endif /* _LANGUAGE_ASSEMBLY */
6863 +#endif /* _flashutl_h_ */
6864 diff -urN linux.old/arch/mips/bcm947xx/include/hndmips.h linux.dev/arch/mips/bcm947xx/include/hndmips.h
6865 --- linux.old/arch/mips/bcm947xx/include/hndmips.h 1970-01-01 01:00:00.000000000 +0100
6866 +++ linux.dev/arch/mips/bcm947xx/include/hndmips.h 2005-12-15 15:34:53.396869000 +0100
6869 + * Alternate include file for HND sbmips.h since CFE also ships with
6872 + * Copyright 2005, Broadcom Corporation
6873 + * All Rights Reserved.
6875 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6876 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6877 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6878 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6883 +#include "sbmips.h"
6884 diff -urN linux.old/arch/mips/bcm947xx/include/linux_osl.h linux.dev/arch/mips/bcm947xx/include/linux_osl.h
6885 --- linux.old/arch/mips/bcm947xx/include/linux_osl.h 1970-01-01 01:00:00.000000000 +0100
6886 +++ linux.dev/arch/mips/bcm947xx/include/linux_osl.h 2005-12-15 17:23:39.225126750 +0100
6889 + * Linux OS Independent Layer
6891 + * Copyright 2005, Broadcom Corporation
6892 + * All Rights Reserved.
6894 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6895 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6896 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6897 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6902 +#ifndef _linux_osl_h_
6903 +#define _linux_osl_h_
6905 +#include <typedefs.h>
6907 +/* use current 2.4.x calling conventions */
6908 +#include <linuxver.h>
6910 +/* assert and panic */
6912 +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
6913 +#if GCC_VERSION > 30100
6914 +#define ASSERT(exp) do {} while (0)
6916 +/* ASSERT could causes segmentation fault on GCC3.1, use empty instead*/
6917 +#define ASSERT(exp)
6921 +/* microsecond delay */
6922 +#define OSL_DELAY(usec) osl_delay(usec)
6923 +extern void osl_delay(uint usec);
6925 +/* PCI configuration space access macros */
6926 +#define OSL_PCI_READ_CONFIG(osh, offset, size) \
6927 + osl_pci_read_config((osh), (offset), (size))
6928 +#define OSL_PCI_WRITE_CONFIG(osh, offset, size, val) \
6929 + osl_pci_write_config((osh), (offset), (size), (val))
6930 +extern uint32 osl_pci_read_config(osl_t *osh, uint size, uint offset);
6931 +extern void osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val);
6933 +/* PCI device bus # and slot # */
6934 +#define OSL_PCI_BUS(osh) osl_pci_bus(osh)
6935 +#define OSL_PCI_SLOT(osh) osl_pci_slot(osh)
6936 +extern uint osl_pci_bus(osl_t *osh);
6937 +extern uint osl_pci_slot(osl_t *osh);
6939 +/* OSL initialization */
6940 +extern osl_t *osl_attach(void *pdev);
6941 +extern void osl_detach(osl_t *osh);
6943 +/* host/bus architecture-specific byte swap */
6944 +#define BUS_SWAP32(v) (v)
6946 +/* general purpose memory allocation */
6948 +#define MALLOC(osh, size) kmalloc(size, GFP_ATOMIC)
6949 +#define MFREE(osh, addr, size) kfree(addr);
6951 +#define MALLOC_FAILED(osh) osl_malloc_failed((osh))
6953 +extern void *osl_malloc(osl_t *osh, uint size);
6954 +extern void osl_mfree(osl_t *osh, void *addr, uint size);
6955 +extern uint osl_malloced(osl_t *osh);
6956 +extern uint osl_malloc_failed(osl_t *osh);
6958 +/* allocate/free shared (dma-able) consistent memory */
6959 +#define DMA_CONSISTENT_ALIGN PAGE_SIZE
6960 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) \
6961 + osl_dma_alloc_consistent((osh), (size), (pap))
6962 +#define DMA_FREE_CONSISTENT(osh, va, size, pa) \
6963 + osl_dma_free_consistent((osh), (void*)(va), (size), (pa))
6964 +extern void *osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap);
6965 +extern void osl_dma_free_consistent(osl_t *osh, void *va, uint size, ulong pa);
6967 +/* map/unmap direction */
6971 +/* register access macros */
6972 +#if defined(BCMJTAG)
6973 +#include <bcmjtag.h>
6974 +#define R_REG(r) bcmjtag_read(NULL, (uint32)(r), sizeof (*(r)))
6975 +#define W_REG(r, v) bcmjtag_write(NULL, (uint32)(r), (uint32)(v), sizeof (*(r)))
6979 + * BINOSL selects the slightly slower function-call-based binary compatible osl.
6980 + * Macros expand to calls to functions defined in linux_osl.c .
6984 +/* string library, kernel mode */
6985 +#define printf(fmt, args...) printk(fmt, ## args)
6986 +#include <linux/kernel.h>
6987 +#include <linux/string.h>
6989 +/* register access macros */
6990 +#if !defined(BCMJTAG)
6991 +#ifndef IL_BIGENDIAN
6992 +#define R_REG(r) ( \
6993 + sizeof(*(r)) == sizeof(uint8) ? readb((volatile uint8*)(r)) : \
6994 + sizeof(*(r)) == sizeof(uint16) ? readw((volatile uint16*)(r)) : \
6995 + readl((volatile uint32*)(r)) \
6997 +#define W_REG(r, v) do { \
6998 + switch (sizeof(*(r))) { \
6999 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)(r)); break; \
7000 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)(r)); break; \
7001 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \
7004 +#else /* IL_BIGENDIAN */
7005 +#define R_REG(r) ({ \
7006 + __typeof(*(r)) __osl_v; \
7007 + switch (sizeof(*(r))) { \
7008 + case sizeof(uint8): __osl_v = readb((volatile uint8*)((uint32)r^3)); break; \
7009 + case sizeof(uint16): __osl_v = readw((volatile uint16*)((uint32)r^2)); break; \
7010 + case sizeof(uint32): __osl_v = readl((volatile uint32*)(r)); break; \
7014 +#define W_REG(r, v) do { \
7015 + switch (sizeof(*(r))) { \
7016 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)((uint32)r^3)); break; \
7017 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)((uint32)r^2)); break; \
7018 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \
7024 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
7025 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
7027 +/* bcopy, bcmp, and bzero */
7028 +#define bcopy(src, dst, len) memcpy((dst), (src), (len))
7029 +#define bcmp(b1, b2, len) memcmp((b1), (b2), (len))
7030 +#define bzero(b, len) memset((b), '\0', (len))
7032 +/* uncached virtual address */
7034 +#define OSL_UNCACHED(va) KSEG1ADDR((va))
7035 +#include <asm/addrspace.h>
7037 +#define OSL_UNCACHED(va) (va)
7040 +/* get processor cycle count */
7042 +#define OSL_GETCYCLES(x) ((x) = read_c0_count() * 2)
7043 +#elif defined(__i386__)
7044 +#define OSL_GETCYCLES(x) rdtscl((x))
7046 +#define OSL_GETCYCLES(x) ((x) = 0)
7049 +/* dereference an address that may cause a bus exception */
7051 +#if defined(MODULE) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,17))
7052 +#define BUSPROBE(val, addr) panic("get_dbe() will not fixup a bus exception when compiled into a module")
7054 +#define BUSPROBE(val, addr) get_dbe((val), (addr))
7055 +#include <asm/paccess.h>
7058 +#define BUSPROBE(val, addr) ({ (val) = R_REG((addr)); 0; })
7061 +/* map/unmap physical to virtual I/O */
7062 +#define REG_MAP(pa, size) ioremap_nocache((unsigned long)(pa), (unsigned long)(size))
7063 +#define REG_UNMAP(va) iounmap((void *)(va))
7065 +/* shared (dma-able) memory access macros */
7066 +#define R_SM(r) *(r)
7067 +#define W_SM(r, v) (*(r) = (v))
7068 +#define BZERO_SM(r, len) memset((r), '\0', (len))
7070 +/* packet primitives */
7071 +#define PKTGET(osh, len, send) osl_pktget((osh), (len), (send))
7072 +#define PKTFREE(osh, skb, send) osl_pktfree((skb))
7073 +#define PKTDATA(osh, skb) (((struct sk_buff*)(skb))->data)
7074 +#define PKTLEN(osh, skb) (((struct sk_buff*)(skb))->len)
7075 +#define PKTHEADROOM(osh, skb) (PKTDATA(osh,skb)-(((struct sk_buff*)(skb))->head))
7076 +#define PKTTAILROOM(osh, skb) ((((struct sk_buff*)(skb))->end)-(((struct sk_buff*)(skb))->tail))
7077 +#define PKTNEXT(osh, skb) (((struct sk_buff*)(skb))->next)
7078 +#define PKTSETNEXT(skb, x) (((struct sk_buff*)(skb))->next = (struct sk_buff*)(x))
7079 +#define PKTSETLEN(osh, skb, len) __skb_trim((struct sk_buff*)(skb), (len))
7080 +#define PKTPUSH(osh, skb, bytes) skb_push((struct sk_buff*)(skb), (bytes))
7081 +#define PKTPULL(osh, skb, bytes) skb_pull((struct sk_buff*)(skb), (bytes))
7082 +#define PKTDUP(osh, skb) skb_clone((struct sk_buff*)(skb), GFP_ATOMIC)
7083 +#define PKTCOOKIE(skb) ((void*)((struct sk_buff*)(skb))->csum)
7084 +#define PKTSETCOOKIE(skb, x) (((struct sk_buff*)(skb))->csum = (uint)(x))
7085 +#define PKTLINK(skb) (((struct sk_buff*)(skb))->prev)
7086 +#define PKTSETLINK(skb, x) (((struct sk_buff*)(skb))->prev = (struct sk_buff*)(x))
7087 +#define PKTPRIO(skb) (((struct sk_buff*)(skb))->priority)
7088 +#define PKTSETPRIO(skb, x) (((struct sk_buff*)(skb))->priority = (x))
7089 +extern void *osl_pktget(osl_t *osh, uint len, bool send);
7090 +extern void osl_pktfree(void *skb);
7094 +/* string library */
7097 +#define printf(fmt, args...) osl_printf((fmt), ## args)
7099 +#define sprintf(buf, fmt, args...) osl_sprintf((buf), (fmt), ## args)
7101 +#define strcmp(s1, s2) osl_strcmp((s1), (s2))
7103 +#define strncmp(s1, s2, n) osl_strncmp((s1), (s2), (n))
7105 +#define strlen(s) osl_strlen((s))
7107 +#define strcpy(d, s) osl_strcpy((d), (s))
7109 +#define strncpy(d, s, n) osl_strncpy((d), (s), (n))
7111 +extern int osl_printf(const char *format, ...);
7112 +extern int osl_sprintf(char *buf, const char *format, ...);
7113 +extern int osl_strcmp(const char *s1, const char *s2);
7114 +extern int osl_strncmp(const char *s1, const char *s2, uint n);
7115 +extern int osl_strlen(const char *s);
7116 +extern char* osl_strcpy(char *d, const char *s);
7117 +extern char* osl_strncpy(char *d, const char *s, uint n);
7119 +/* register access macros */
7120 +#if !defined(BCMJTAG)
7121 +#define R_REG(r) ( \
7122 + sizeof(*(r)) == sizeof(uint8) ? osl_readb((volatile uint8*)(r)) : \
7123 + sizeof(*(r)) == sizeof(uint16) ? osl_readw((volatile uint16*)(r)) : \
7124 + osl_readl((volatile uint32*)(r)) \
7126 +#define W_REG(r, v) do { \
7127 + switch (sizeof(*(r))) { \
7128 + case sizeof(uint8): osl_writeb((uint8)(v), (volatile uint8*)(r)); break; \
7129 + case sizeof(uint16): osl_writew((uint16)(v), (volatile uint16*)(r)); break; \
7130 + case sizeof(uint32): osl_writel((uint32)(v), (volatile uint32*)(r)); break; \
7135 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
7136 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
7137 +extern uint8 osl_readb(volatile uint8 *r);
7138 +extern uint16 osl_readw(volatile uint16 *r);
7139 +extern uint32 osl_readl(volatile uint32 *r);
7140 +extern void osl_writeb(uint8 v, volatile uint8 *r);
7141 +extern void osl_writew(uint16 v, volatile uint16 *r);
7142 +extern void osl_writel(uint32 v, volatile uint32 *r);
7144 +/* bcopy, bcmp, and bzero */
7145 +extern void bcopy(const void *src, void *dst, int len);
7146 +extern int bcmp(const void *b1, const void *b2, int len);
7147 +extern void bzero(void *b, int len);
7149 +/* uncached virtual address */
7150 +#define OSL_UNCACHED(va) osl_uncached((va))
7151 +extern void *osl_uncached(void *va);
7153 +/* get processor cycle count */
7154 +#define OSL_GETCYCLES(x) ((x) = osl_getcycles())
7155 +extern uint osl_getcycles(void);
7157 +/* dereference an address that may target abort */
7158 +#define BUSPROBE(val, addr) osl_busprobe(&(val), (addr))
7159 +extern int osl_busprobe(uint32 *val, uint32 addr);
7161 +/* map/unmap physical to virtual */
7162 +#define REG_MAP(pa, size) osl_reg_map((pa), (size))
7163 +#define REG_UNMAP(va) osl_reg_unmap((va))
7164 +extern void *osl_reg_map(uint32 pa, uint size);
7165 +extern void osl_reg_unmap(void *va);
7167 +/* shared (dma-able) memory access macros */
7168 +#define R_SM(r) *(r)
7169 +#define W_SM(r, v) (*(r) = (v))
7170 +#define BZERO_SM(r, len) bzero((r), (len))
7172 +/* packet primitives */
7173 +#define PKTGET(osh, len, send) osl_pktget((osh), (len), (send))
7174 +#define PKTFREE(osh, skb, send) osl_pktfree((skb))
7175 +#define PKTDATA(osh, skb) osl_pktdata((osh), (skb))
7176 +#define PKTLEN(osh, skb) osl_pktlen((osh), (skb))
7177 +#define PKTHEADROOM(osh, skb) osl_pktheadroom((osh), (skb))
7178 +#define PKTTAILROOM(osh, skb) osl_pkttailroom((osh), (skb))
7179 +#define PKTNEXT(osh, skb) osl_pktnext((osh), (skb))
7180 +#define PKTSETNEXT(skb, x) osl_pktsetnext((skb), (x))
7181 +#define PKTSETLEN(osh, skb, len) osl_pktsetlen((osh), (skb), (len))
7182 +#define PKTPUSH(osh, skb, bytes) osl_pktpush((osh), (skb), (bytes))
7183 +#define PKTPULL(osh, skb, bytes) osl_pktpull((osh), (skb), (bytes))
7184 +#define PKTDUP(osh, skb) osl_pktdup((osh), (skb))
7185 +#define PKTCOOKIE(skb) osl_pktcookie((skb))
7186 +#define PKTSETCOOKIE(skb, x) osl_pktsetcookie((skb), (x))
7187 +#define PKTLINK(skb) osl_pktlink((skb))
7188 +#define PKTSETLINK(skb, x) osl_pktsetlink((skb), (x))
7189 +#define PKTPRIO(skb) osl_pktprio((skb))
7190 +#define PKTSETPRIO(skb, x) osl_pktsetprio((skb), (x))
7191 +extern void *osl_pktget(osl_t *osh, uint len, bool send);
7192 +extern void osl_pktfree(void *skb);
7193 +extern uchar *osl_pktdata(osl_t *osh, void *skb);
7194 +extern uint osl_pktlen(osl_t *osh, void *skb);
7195 +extern uint osl_pktheadroom(osl_t *osh, void *skb);
7196 +extern uint osl_pkttailroom(osl_t *osh, void *skb);
7197 +extern void *osl_pktnext(osl_t *osh, void *skb);
7198 +extern void osl_pktsetnext(void *skb, void *x);
7199 +extern void osl_pktsetlen(osl_t *osh, void *skb, uint len);
7200 +extern uchar *osl_pktpush(osl_t *osh, void *skb, int bytes);
7201 +extern uchar *osl_pktpull(osl_t *osh, void *skb, int bytes);
7202 +extern void *osl_pktdup(osl_t *osh, void *skb);
7203 +extern void *osl_pktcookie(void *skb);
7204 +extern void osl_pktsetcookie(void *skb, void *x);
7205 +extern void *osl_pktlink(void *skb);
7206 +extern void osl_pktsetlink(void *skb, void *x);
7207 +extern uint osl_pktprio(void *skb);
7208 +extern void osl_pktsetprio(void *skb, uint x);
7210 +#endif /* BINOSL */
7212 +#define OSL_ERROR(bcmerror) osl_error(bcmerror)
7213 +extern int osl_error(int bcmerror);
7215 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
7216 +#define PKTBUFSZ 2048
7218 +#endif /* _linux_osl_h_ */
7219 diff -urN linux.old/arch/mips/bcm947xx/include/linuxver.h linux.dev/arch/mips/bcm947xx/include/linuxver.h
7220 --- linux.old/arch/mips/bcm947xx/include/linuxver.h 1970-01-01 01:00:00.000000000 +0100
7221 +++ linux.dev/arch/mips/bcm947xx/include/linuxver.h 2005-12-15 16:02:45.467929000 +0100
7224 + * Linux-specific abstractions to gain some independence from linux kernel versions.
7225 + * Pave over some 2.2 versus 2.4 versus 2.6 kernel differences.
7227 + * Copyright 2005, Broadcom Corporation
7228 + * All Rights Reserved.
7230 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7231 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7232 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7233 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7238 +#ifndef _linuxver_h_
7239 +#define _linuxver_h_
7241 +#include <linux/config.h>
7242 +#include <linux/version.h>
7244 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
7245 +/* __NO_VERSION__ must be defined for all linkables except one in 2.2 */
7246 +#ifdef __UNDEF_NO_VERSION__
7247 +#undef __NO_VERSION__
7249 +#define __NO_VERSION__
7253 +#if defined(MODULE) && defined(MODVERSIONS)
7254 +#include <linux/modversions.h>
7257 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
7258 +#include <linux/moduleparam.h>
7262 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
7263 +#define module_param(_name_, _type_, _perm_) MODULE_PARM(_name_, "i")
7264 +#define module_param_string(_name_, _string_, _size_, _perm_) MODULE_PARM(_string_, "c" __MODULE_STRING(_size_))
7267 +/* linux/malloc.h is deprecated, use linux/slab.h instead. */
7268 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,9))
7269 +#include <linux/malloc.h>
7271 +#include <linux/slab.h>
7274 +#include <linux/types.h>
7275 +#include <linux/init.h>
7276 +#include <linux/mm.h>
7277 +#include <linux/string.h>
7278 +#include <linux/pci.h>
7279 +#include <linux/interrupt.h>
7280 +#include <linux/netdevice.h>
7281 +#include <asm/io.h>
7283 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41))
7284 +#include <linux/workqueue.h>
7286 +#include <linux/tqueue.h>
7287 +#ifndef work_struct
7288 +#define work_struct tq_struct
7291 +#define INIT_WORK(_work, _func, _data) INIT_TQUEUE((_work), (_func), (_data))
7293 +#ifndef schedule_work
7294 +#define schedule_work(_work) schedule_task((_work))
7296 +#ifndef flush_scheduled_work
7297 +#define flush_scheduled_work() flush_scheduled_tasks()
7301 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
7302 +/* Some distributions have their own 2.6.x compatibility layers */
7304 +typedef void irqreturn_t;
7306 +#define IRQ_HANDLED
7307 +#define IRQ_RETVAL(x)
7310 +typedef irqreturn_t (*FN_ISR) (int irq, void *dev_id, struct pt_regs *ptregs);
7320 +#define __devinit __init
7322 +#ifndef __devinitdata
7323 +#define __devinitdata
7325 +#ifndef __devexit_p
7326 +#define __devexit_p(x) x
7329 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
7331 +#define pci_get_drvdata(dev) (dev)->sysdata
7332 +#define pci_set_drvdata(dev, value) (dev)->sysdata=(value)
7335 + * New-style (2.4.x) PCI/hot-pluggable PCI/CardBus registration
7338 +struct pci_device_id {
7339 + unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */
7340 + unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
7341 + unsigned int class, class_mask; /* (class,subclass,prog-if) triplet */
7342 + unsigned long driver_data; /* Data private to the driver */
7345 +struct pci_driver {
7346 + struct list_head node;
7348 + const struct pci_device_id *id_table; /* NULL if wants all devices */
7349 + int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
7350 + void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
7351 + void (*suspend)(struct pci_dev *dev); /* Device suspended */
7352 + void (*resume)(struct pci_dev *dev); /* Device woken up */
7355 +#define MODULE_DEVICE_TABLE(type, name)
7356 +#define PCI_ANY_ID (~0)
7359 +#define pci_module_init pci_register_driver
7360 +extern int pci_register_driver(struct pci_driver *drv);
7361 +extern void pci_unregister_driver(struct pci_driver *drv);
7363 +#endif /* PCI registration */
7365 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
7367 +#define module_init(x) int init_module(void) { return x(); }
7368 +#define module_exit(x) void cleanup_module(void) { x(); }
7370 +#define module_init(x) __initcall(x);
7371 +#define module_exit(x) __exitcall(x);
7375 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,48))
7376 +#define list_for_each(pos, head) \
7377 + for (pos = (head)->next; pos != (head); pos = pos->next)
7380 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,13))
7381 +#define pci_resource_start(dev, bar) ((dev)->base_address[(bar)])
7382 +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,44))
7383 +#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
7386 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,23))
7387 +#define pci_enable_device(dev) do { } while (0)
7390 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,14))
7391 +#define net_device device
7394 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,42))
7399 + * See linux/Documentation/DMA-mapping.txt
7402 +#ifndef PCI_DMA_TODEVICE
7403 +#define PCI_DMA_TODEVICE 1
7404 +#define PCI_DMA_FROMDEVICE 2
7407 +typedef u32 dma_addr_t;
7409 +/* Pure 2^n version of get_order */
7410 +static inline int get_order(unsigned long size)
7414 + size = (size-1) >> (PAGE_SHIFT-1);
7423 +static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
7424 + dma_addr_t *dma_handle)
7427 + int gfp = GFP_ATOMIC | GFP_DMA;
7429 + ret = (void *)__get_free_pages(gfp, get_order(size));
7431 + if (ret != NULL) {
7432 + memset(ret, 0, size);
7433 + *dma_handle = virt_to_bus(ret);
7437 +static inline void pci_free_consistent(struct pci_dev *hwdev, size_t size,
7438 + void *vaddr, dma_addr_t dma_handle)
7440 + free_pages((unsigned long)vaddr, get_order(size));
7443 +extern uint pci_map_single(void *dev, void *va, uint size, int direction);
7444 +extern void pci_unmap_single(void *dev, uint pa, uint size, int direction);
7446 +#define pci_map_single(cookie, address, size, dir) virt_to_bus(address)
7447 +#define pci_unmap_single(cookie, address, size, dir)
7450 +#endif /* DMA mapping */
7452 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,43))
7454 +#define dev_kfree_skb_any(a) dev_kfree_skb(a)
7455 +#define netif_down(dev) do { (dev)->start = 0; } while(0)
7457 +/* pcmcia-cs provides its own netdevice compatibility layer */
7458 +#ifndef _COMPAT_NETDEVICE_H
7463 + * For pre-softnet kernels we need to tell the upper layer not to
7464 + * re-enter start_xmit() while we are in there. However softnet
7465 + * guarantees not to enter while we are in there so there is no need
7466 + * to do the netif_stop_queue() dance unless the transmit queue really
7467 + * gets stuck. This should also improve performance according to tests
7468 + * done by Aman Singla.
7471 +#define dev_kfree_skb_irq(a) dev_kfree_skb(a)
7472 +#define netif_wake_queue(dev) do { clear_bit(0, &(dev)->tbusy); mark_bh(NET_BH); } while(0)
7473 +#define netif_stop_queue(dev) set_bit(0, &(dev)->tbusy)
7475 +static inline void netif_start_queue(struct net_device *dev)
7478 + dev->interrupt = 0;
7482 +#define netif_queue_stopped(dev) (dev)->tbusy
7483 +#define netif_running(dev) (dev)->start
7485 +#endif /* _COMPAT_NETDEVICE_H */
7487 +#define netif_device_attach(dev) netif_start_queue(dev)
7488 +#define netif_device_detach(dev) netif_stop_queue(dev)
7490 +/* 2.4.x renamed bottom halves to tasklets */
7491 +#define tasklet_struct tq_struct
7492 +static inline void tasklet_schedule(struct tasklet_struct *tasklet)
7494 + queue_task(tasklet, &tq_immediate);
7495 + mark_bh(IMMEDIATE_BH);
7498 +static inline void tasklet_init(struct tasklet_struct *tasklet,
7499 + void (*func)(unsigned long),
7500 + unsigned long data)
7502 + tasklet->next = NULL;
7503 + tasklet->sync = 0;
7504 + tasklet->routine = (void (*)(void *))func;
7505 + tasklet->data = (void *)data;
7507 +#define tasklet_kill(tasklet) {do{} while(0);}
7509 +/* 2.4.x introduced del_timer_sync() */
7510 +#define del_timer_sync(timer) del_timer(timer)
7514 +#define netif_down(dev)
7516 +#endif /* SoftNet */
7518 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3))
7521 + * Emit code to initialise a tq_struct's routine and data pointers
7523 +#define PREPARE_TQUEUE(_tq, _routine, _data) \
7525 + (_tq)->routine = _routine; \
7526 + (_tq)->data = _data; \
7530 + * Emit code to initialise all of a tq_struct
7532 +#define INIT_TQUEUE(_tq, _routine, _data) \
7534 + INIT_LIST_HEAD(&(_tq)->list); \
7535 + (_tq)->sync = 0; \
7536 + PREPARE_TQUEUE((_tq), (_routine), (_data)); \
7541 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6))
7543 +/* Power management related routines */
7546 +pci_save_state(struct pci_dev *dev, u32 *buffer)
7550 + for (i = 0; i < 16; i++)
7551 + pci_read_config_dword(dev, i * 4,&buffer[i]);
7557 +pci_restore_state(struct pci_dev *dev, u32 *buffer)
7562 + for (i = 0; i < 16; i++)
7563 + pci_write_config_dword(dev,i * 4, buffer[i]);
7566 + * otherwise, write the context information we know from bootup.
7567 + * This works around a problem where warm-booting from Windows
7568 + * combined with a D3(hot)->D0 transition causes PCI config
7569 + * header data to be forgotten.
7572 + for (i = 0; i < 6; i ++)
7573 + pci_write_config_dword(dev,
7574 + PCI_BASE_ADDRESS_0 + (i * 4),
7575 + pci_resource_start(dev, i));
7576 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
7581 +#endif /* PCI power management */
7583 +/* Old cp0 access macros deprecated in 2.4.19 */
7584 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19))
7585 +#define read_c0_count() read_32bit_cp0_register(CP0_COUNT)
7588 +/* Module refcount handled internally in 2.6.x */
7589 +#ifndef SET_MODULE_OWNER
7590 +#define SET_MODULE_OWNER(dev) do {} while (0)
7591 +#define OLD_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
7592 +#define OLD_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
7594 +#define OLD_MOD_INC_USE_COUNT do {} while (0)
7595 +#define OLD_MOD_DEC_USE_COUNT do {} while (0)
7598 +#ifndef SET_NETDEV_DEV
7599 +#define SET_NETDEV_DEV(net, pdev) do {} while (0)
7602 +#ifndef HAVE_FREE_NETDEV
7603 +#define free_netdev(dev) kfree(dev)
7606 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
7607 +/* struct packet_type redefined in 2.6.x */
7608 +#define af_packet_priv data
7611 +#endif /* _linuxver_h_ */
7612 diff -urN linux.old/arch/mips/bcm947xx/include/mipsinc.h linux.dev/arch/mips/bcm947xx/include/mipsinc.h
7613 --- linux.old/arch/mips/bcm947xx/include/mipsinc.h 1970-01-01 01:00:00.000000000 +0100
7614 +++ linux.dev/arch/mips/bcm947xx/include/mipsinc.h 2005-12-15 16:47:29.886633750 +0100
7617 + * HND Run Time Environment for standalone MIPS programs.
7619 + * Copyright 2005, Broadcom Corporation
7620 + * All Rights Reserved.
7622 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7623 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7624 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7625 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7636 +#ifdef _LANGUAGE_ASSEMBLY
7639 + * Symbolic register names for 32 bit ABI
7641 +#define zero $0 /* wired zero */
7642 +#define AT $1 /* assembler temp - uppercase because of ".set at" */
7643 +#define v0 $2 /* return value */
7645 +#define a0 $4 /* argument registers */
7649 +#define t0 $8 /* caller saved */
7657 +#define s0 $16 /* callee saved */
7665 +#define t8 $24 /* caller saved */
7667 +#define jp $25 /* PIC jump register */
7668 +#define k0 $26 /* kernel scratch */
7670 +#define gp $28 /* global pointer */
7671 +#define sp $29 /* stack pointer */
7672 +#define fp $30 /* frame pointer */
7673 +#define s8 $30 /* same like fp! */
7674 +#define ra $31 /* return address */
7683 +#define C0_TLBLO0 $2
7684 +#define C0_TLBLO C0_TLBLO0
7685 +#define C0_TLBLO1 $3
7686 +#define C0_CTEXT $4
7687 +#define C0_PGMASK $5
7688 +#define C0_WIRED $6
7689 +#define C0_BADVADDR $8
7690 +#define C0_COUNT $9
7691 +#define C0_TLBHI $10
7692 +#define C0_COMPARE $11
7694 +#define C0_STATUS C0_SR
7695 +#define C0_CAUSE $13
7697 +#define C0_PRID $15
7698 +#define C0_CONFIG $16
7699 +#define C0_LLADDR $17
7700 +#define C0_WATCHLO $18
7701 +#define C0_WATCHHI $19
7702 +#define C0_XCTEXT $20
7703 +#define C0_DIAGNOSTIC $22
7704 +#define C0_BROADCOM C0_DIAGNOSTIC
7705 +#define C0_PERFORMANCE $25
7707 +#define C0_CACHEERR $27
7708 +#define C0_TAGLO $28
7709 +#define C0_TAGHI $29
7710 +#define C0_ERREPC $30
7711 +#define C0_DESAVE $31
7714 + * LEAF - declare leaf routine
7716 +#define LEAF(symbol) \
7719 + .type symbol,@function; \
7721 +symbol: .frame sp,0,ra
7724 + * END - mark end of function
7726 +#define END(function) \
7728 + .size function,.-function
7735 + * The following macros are especially useful for __asm__
7736 + * inline assembler.
7739 +#define __STR(x) #x
7742 +#define STR(x) __STR(x)
7745 +#define _ULCAST_ (unsigned long)
7752 +#define C0_INX 0 /* CP0: TLB Index */
7753 +#define C0_RAND 1 /* CP0: TLB Random */
7754 +#define C0_TLBLO0 2 /* CP0: TLB EntryLo0 */
7755 +#define C0_TLBLO C0_TLBLO0 /* CP0: TLB EntryLo0 */
7756 +#define C0_TLBLO1 3 /* CP0: TLB EntryLo1 */
7757 +#define C0_CTEXT 4 /* CP0: Context */
7758 +#define C0_PGMASK 5 /* CP0: TLB PageMask */
7759 +#define C0_WIRED 6 /* CP0: TLB Wired */
7760 +#define C0_BADVADDR 8 /* CP0: Bad Virtual Address */
7761 +#define C0_COUNT 9 /* CP0: Count */
7762 +#define C0_TLBHI 10 /* CP0: TLB EntryHi */
7763 +#define C0_COMPARE 11 /* CP0: Compare */
7764 +#define C0_SR 12 /* CP0: Processor Status */
7765 +#define C0_STATUS C0_SR /* CP0: Processor Status */
7766 +#define C0_CAUSE 13 /* CP0: Exception Cause */
7767 +#define C0_EPC 14 /* CP0: Exception PC */
7768 +#define C0_PRID 15 /* CP0: Processor Revision Indentifier */
7769 +#define C0_CONFIG 16 /* CP0: Config */
7770 +#define C0_LLADDR 17 /* CP0: LLAddr */
7771 +#define C0_WATCHLO 18 /* CP0: WatchpointLo */
7772 +#define C0_WATCHHI 19 /* CP0: WatchpointHi */
7773 +#define C0_XCTEXT 20 /* CP0: XContext */
7774 +#define C0_DIAGNOSTIC 22 /* CP0: Diagnostic */
7775 +#define C0_BROADCOM C0_DIAGNOSTIC /* CP0: Broadcom Register */
7776 +#define C0_PERFORMANCE 25 /* CP0: Performance Counter/Control Registers */
7777 +#define C0_ECC 26 /* CP0: ECC */
7778 +#define C0_CACHEERR 27 /* CP0: CacheErr */
7779 +#define C0_TAGLO 28 /* CP0: TagLo */
7780 +#define C0_TAGHI 29 /* CP0: TagHi */
7781 +#define C0_ERREPC 30 /* CP0: ErrorEPC */
7782 +#define C0_DESAVE 31 /* CP0: DebugSave */
7784 +#endif /* _LANGUAGE_ASSEMBLY */
7787 + * Memory segments (32bit kernel mode addresses)
7794 +#define KUSEG 0x00000000
7795 +#define KSEG0 0x80000000
7796 +#define KSEG1 0xa0000000
7797 +#define KSEG2 0xc0000000
7798 +#define KSEG3 0xe0000000
7799 +#define PHYSADDR_MASK 0x1fffffff
7802 + * Map an address to a certain kernel segment
7810 +#define PHYSADDR(a) (_ULCAST_(a) & PHYSADDR_MASK)
7811 +#define KSEG0ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG0)
7812 +#define KSEG1ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG1)
7813 +#define KSEG2ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG2)
7814 +#define KSEG3ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG3)
7817 +#ifndef Index_Invalidate_I
7819 + * Cache Operations
7821 +#define Index_Invalidate_I 0x00
7822 +#define Index_Writeback_Inv_D 0x01
7823 +#define Index_Invalidate_SI 0x02
7824 +#define Index_Writeback_Inv_SD 0x03
7825 +#define Index_Load_Tag_I 0x04
7826 +#define Index_Load_Tag_D 0x05
7827 +#define Index_Load_Tag_SI 0x06
7828 +#define Index_Load_Tag_SD 0x07
7829 +#define Index_Store_Tag_I 0x08
7830 +#define Index_Store_Tag_D 0x09
7831 +#define Index_Store_Tag_SI 0x0A
7832 +#define Index_Store_Tag_SD 0x0B
7833 +#define Create_Dirty_Excl_D 0x0d
7834 +#define Create_Dirty_Excl_SD 0x0f
7835 +#define Hit_Invalidate_I 0x10
7836 +#define Hit_Invalidate_D 0x11
7837 +#define Hit_Invalidate_SI 0x12
7838 +#define Hit_Invalidate_SD 0x13
7839 +#define Fill_I 0x14
7840 +#define Hit_Writeback_Inv_D 0x15
7841 + /* 0x16 is unused */
7842 +#define Hit_Writeback_Inv_SD 0x17
7843 +#define R5K_Page_Invalidate_S 0x17
7844 +#define Hit_Writeback_I 0x18
7845 +#define Hit_Writeback_D 0x19
7846 + /* 0x1a is unused */
7847 +#define Hit_Writeback_SD 0x1b
7848 + /* 0x1c is unused */
7849 + /* 0x1e is unused */
7850 +#define Hit_Set_Virtual_SI 0x1e
7851 +#define Hit_Set_Virtual_SD 0x1f
7856 + * R4x00 interrupt enable / cause bits
7858 +#define IE_SW0 (_ULCAST_(1) << 8)
7859 +#define IE_SW1 (_ULCAST_(1) << 9)
7860 +#define IE_IRQ0 (_ULCAST_(1) << 10)
7861 +#define IE_IRQ1 (_ULCAST_(1) << 11)
7862 +#define IE_IRQ2 (_ULCAST_(1) << 12)
7863 +#define IE_IRQ3 (_ULCAST_(1) << 13)
7864 +#define IE_IRQ4 (_ULCAST_(1) << 14)
7865 +#define IE_IRQ5 (_ULCAST_(1) << 15)
7869 + * Bitfields in the mips32 cp0 status register
7871 +#define ST0_IE 0x00000001
7872 +#define ST0_EXL 0x00000002
7873 +#define ST0_ERL 0x00000004
7874 +#define ST0_UM 0x00000010
7875 +#define ST0_SWINT0 0x00000100
7876 +#define ST0_SWINT1 0x00000200
7877 +#define ST0_HWINT0 0x00000400
7878 +#define ST0_HWINT1 0x00000800
7879 +#define ST0_HWINT2 0x00001000
7880 +#define ST0_HWINT3 0x00002000
7881 +#define ST0_HWINT4 0x00004000
7882 +#define ST0_HWINT5 0x00008000
7883 +#define ST0_IM 0x0000ff00
7884 +#define ST0_NMI 0x00080000
7885 +#define ST0_SR 0x00100000
7886 +#define ST0_TS 0x00200000
7887 +#define ST0_BEV 0x00400000
7888 +#define ST0_RE 0x02000000
7889 +#define ST0_RP 0x08000000
7890 +#define ST0_CU 0xf0000000
7891 +#define ST0_CU0 0x10000000
7892 +#define ST0_CU1 0x20000000
7893 +#define ST0_CU2 0x40000000
7894 +#define ST0_CU3 0x80000000
7899 + * Bitfields in the mips32 cp0 cause register
7901 +#define C_EXC 0x0000007c
7902 +#define C_EXC_SHIFT 2
7903 +#define C_INT 0x0000ff00
7904 +#define C_INT_SHIFT 8
7905 +#define C_SW0 (_ULCAST_(1) << 8)
7906 +#define C_SW1 (_ULCAST_(1) << 9)
7907 +#define C_IRQ0 (_ULCAST_(1) << 10)
7908 +#define C_IRQ1 (_ULCAST_(1) << 11)
7909 +#define C_IRQ2 (_ULCAST_(1) << 12)
7910 +#define C_IRQ3 (_ULCAST_(1) << 13)
7911 +#define C_IRQ4 (_ULCAST_(1) << 14)
7912 +#define C_IRQ5 (_ULCAST_(1) << 15)
7913 +#define C_WP 0x00400000
7914 +#define C_IV 0x00800000
7915 +#define C_CE 0x30000000
7916 +#define C_CE_SHIFT 28
7917 +#define C_BD 0x80000000
7919 +/* Values in C_EXC */
7934 +#define EXC_WATCH 23
7935 +#define EXC_MCHK 24
7939 + * Bits in the cp0 config register.
7941 +#define CONF_CM_CACHABLE_NO_WA 0
7942 +#define CONF_CM_CACHABLE_WA 1
7943 +#define CONF_CM_UNCACHED 2
7944 +#define CONF_CM_CACHABLE_NONCOHERENT 3
7945 +#define CONF_CM_CACHABLE_CE 4
7946 +#define CONF_CM_CACHABLE_COW 5
7947 +#define CONF_CM_CACHABLE_CUW 6
7948 +#define CONF_CM_CACHABLE_ACCELERATED 7
7949 +#define CONF_CM_CMASK 7
7950 +#define CONF_CU (_ULCAST_(1) << 3)
7951 +#define CONF_DB (_ULCAST_(1) << 4)
7952 +#define CONF_IB (_ULCAST_(1) << 5)
7953 +#define CONF_SE (_ULCAST_(1) << 12)
7954 +#define CONF_SC (_ULCAST_(1) << 17)
7955 +#define CONF_AC (_ULCAST_(1) << 23)
7956 +#define CONF_HALT (_ULCAST_(1) << 25)
7960 + * Bits in the cp0 config register select 1.
7962 +#define CONF1_FP 0x00000001 /* FPU present */
7963 +#define CONF1_EP 0x00000002 /* EJTAG present */
7964 +#define CONF1_CA 0x00000004 /* mips16 implemented */
7965 +#define CONF1_WR 0x00000008 /* Watch registers present */
7966 +#define CONF1_PC 0x00000010 /* Performance counters present */
7967 +#define CONF1_DA_SHIFT 7 /* D$ associativity */
7968 +#define CONF1_DA_MASK 0x00000380
7969 +#define CONF1_DA_BASE 1
7970 +#define CONF1_DL_SHIFT 10 /* D$ line size */
7971 +#define CONF1_DL_MASK 0x00001c00
7972 +#define CONF1_DL_BASE 2
7973 +#define CONF1_DS_SHIFT 13 /* D$ sets/way */
7974 +#define CONF1_DS_MASK 0x0000e000
7975 +#define CONF1_DS_BASE 64
7976 +#define CONF1_IA_SHIFT 16 /* I$ associativity */
7977 +#define CONF1_IA_MASK 0x00070000
7978 +#define CONF1_IA_BASE 1
7979 +#define CONF1_IL_SHIFT 19 /* I$ line size */
7980 +#define CONF1_IL_MASK 0x00380000
7981 +#define CONF1_IL_BASE 2
7982 +#define CONF1_IS_SHIFT 22 /* Instruction cache sets/way */
7983 +#define CONF1_IS_MASK 0x01c00000
7984 +#define CONF1_IS_BASE 64
7985 +#define CONF1_MS_MASK 0x7e000000 /* Number of tlb entries */
7986 +#define CONF1_MS_SHIFT 25
7988 +/* PRID register */
7989 +#define PRID_COPT_MASK 0xff000000
7990 +#define PRID_COMP_MASK 0x00ff0000
7991 +#define PRID_IMP_MASK 0x0000ff00
7992 +#define PRID_REV_MASK 0x000000ff
7994 +#define PRID_COMP_LEGACY 0x000000
7995 +#define PRID_COMP_MIPS 0x010000
7996 +#define PRID_COMP_BROADCOM 0x020000
7997 +#define PRID_COMP_ALCHEMY 0x030000
7998 +#define PRID_COMP_SIBYTE 0x040000
7999 +#define PRID_IMP_BCM4710 0x4000
8000 +#define PRID_IMP_BCM3302 0x9000
8001 +#define PRID_IMP_BCM3303 0x9100
8003 +#define PRID_IMP_UNKNOWN 0xff00
8005 +#define BCM330X(id) \
8006 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) \
8007 + || ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3303)))
8009 +/* Bits in C0_BROADCOM */
8010 +#define BRCM_PFC_AVAIL 0x20000000 /* PFC is available */
8011 +#define BRCM_DC_ENABLE 0x40000000 /* Enable Data $ */
8012 +#define BRCM_IC_ENABLE 0x80000000 /* Enable Instruction $ */
8013 +#define BRCM_PFC_ENABLE 0x00400000 /* Obsolete? Enable PFC (at least on 4310) */
8015 +/* PreFetch Cache aka Read Ahead Cache */
8017 +#define PFC_CR0 0xff400000 /* control reg 0 */
8018 +#define PFC_CR1 0xff400004 /* control reg 1 */
8020 +/* PFC operations */
8021 +#define PFC_I 0x00000001 /* Enable PFC use for instructions */
8022 +#define PFC_D 0x00000002 /* Enable PFC use for data */
8023 +#define PFC_PFI 0x00000004 /* Enable seq. prefetch for instructions */
8024 +#define PFC_PFD 0x00000008 /* Enable seq. prefetch for data */
8025 +#define PFC_CINV 0x00000010 /* Enable selective (i/d) cacheop flushing */
8026 +#define PFC_NCH 0x00000020 /* Disable flushing based on cacheops */
8027 +#define PFC_DPF 0x00000040 /* Enable directional prefetching */
8028 +#define PFC_FLUSH 0x00000100 /* Flush the PFC */
8029 +#define PFC_BRR 0x40000000 /* Bus error indication */
8030 +#define PFC_PWR 0x80000000 /* Disable power saving (clock gating) */
8032 +/* Handy defaults */
8033 +#define PFC_DISABLED 0
8034 +#define PFC_AUTO 0xffffffff /* auto select the default mode */
8035 +#define PFC_INST (PFC_I | PFC_PFI | PFC_CINV)
8036 +#define PFC_INST_NOPF (PFC_I | PFC_CINV)
8037 +#define PFC_DATA (PFC_D | PFC_PFD | PFC_CINV)
8038 +#define PFC_DATA_NOPF (PFC_D | PFC_CINV)
8039 +#define PFC_I_AND_D (PFC_INST | PFC_DATA)
8040 +#define PFC_I_AND_D_NOPF (PFC_INST_NOPF | PFC_DATA_NOPF)
8044 + * These are the UART port assignments, expressed as offsets from the base
8045 + * register. These assignments should hold for any serial port based on
8046 + * a 8250, 16450, or 16550(A).
8049 +#define UART_RX 0 /* In: Receive buffer (DLAB=0) */
8050 +#define UART_TX 0 /* Out: Transmit buffer (DLAB=0) */
8051 +#define UART_DLL 0 /* Out: Divisor Latch Low (DLAB=1) */
8052 +#define UART_DLM 1 /* Out: Divisor Latch High (DLAB=1) */
8053 +#define UART_LCR 3 /* Out: Line Control Register */
8054 +#define UART_MCR 4 /* Out: Modem Control Register */
8055 +#define UART_LSR 5 /* In: Line Status Register */
8056 +#define UART_MSR 6 /* In: Modem Status Register */
8057 +#define UART_SCR 7 /* I/O: Scratch Register */
8058 +#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */
8059 +#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */
8060 +#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */
8061 +#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
8062 +#define UART_LSR_RXRDY 0x01 /* Receiver ready */
8065 +#ifndef _LANGUAGE_ASSEMBLY
8068 + * Macros to access the system control coprocessor
8071 +#define MFC0(source, sel) \
8074 + __asm__ __volatile__( \
8075 + ".set\tnoreorder\n\t" \
8076 + ".set\tnoat\n\t" \
8077 + ".word\t"STR(0x40010000 | ((source)<<11) | (sel))"\n\t" \
8078 + "move\t%0,$1\n\t" \
8087 +#define MTC0(source, sel, value) \
8089 + __asm__ __volatile__( \
8090 + ".set\tnoreorder\n\t" \
8091 + ".set\tnoat\n\t" \
8092 + "move\t$1,%z0\n\t" \
8093 + ".word\t"STR(0x40810000 | ((source)<<11) | (sel))"\n\t" \
8101 +#define get_c0_count() \
8104 + __asm__ __volatile__( \
8105 + ".set\tnoreorder\n\t" \
8106 + ".set\tnoat\n\t" \
8107 + "mfc0\t%0,$9\n\t" \
8114 +static INLINE void icache_probe(uint32 config1, uint *size, uint *lsize)
8116 + uint lsz, sets, ways;
8118 + /* Instruction Cache Size = Associativity * Line Size * Sets Per Way */
8119 + if ((lsz = ((config1 & CONF1_IL_MASK) >> CONF1_IL_SHIFT)))
8120 + lsz = CONF1_IL_BASE << lsz;
8121 + sets = CONF1_IS_BASE << ((config1 & CONF1_IS_MASK) >> CONF1_IS_SHIFT);
8122 + ways = CONF1_IA_BASE + ((config1 & CONF1_IA_MASK) >> CONF1_IA_SHIFT);
8123 + *size = lsz * sets * ways;
8127 +static INLINE void dcache_probe(uint32 config1, uint *size, uint *lsize)
8129 + uint lsz, sets, ways;
8131 + /* Data Cache Size = Associativity * Line Size * Sets Per Way */
8132 + if ((lsz = ((config1 & CONF1_DL_MASK) >> CONF1_DL_SHIFT)))
8133 + lsz = CONF1_DL_BASE << lsz;
8134 + sets = CONF1_DS_BASE << ((config1 & CONF1_DS_MASK) >> CONF1_DS_SHIFT);
8135 + ways = CONF1_DA_BASE + ((config1 & CONF1_DA_MASK) >> CONF1_DA_SHIFT);
8136 + *size = lsz * sets * ways;
8140 +#define cache_op(base, op) \
8141 + __asm__ __volatile__(" \
8151 +#define cache_unroll4(base, delta, op) \
8152 + __asm__ __volatile__(" \
8156 + cache %1,delta(%0); \
8157 + cache %1,(2 * delta)(%0); \
8158 + cache %1,(3 * delta)(%0); \
8165 +#endif /* !_LANGUAGE_ASSEMBLY */
8167 +#endif /* _MISPINC_H */
8168 diff -urN linux.old/arch/mips/bcm947xx/include/osl.h linux.dev/arch/mips/bcm947xx/include/osl.h
8169 --- linux.old/arch/mips/bcm947xx/include/osl.h 1970-01-01 01:00:00.000000000 +0100
8170 +++ linux.dev/arch/mips/bcm947xx/include/osl.h 2005-12-15 15:35:08.321801750 +0100
8173 + * OS Abstraction Layer
8175 + * Copyright 2005, Broadcom Corporation
8176 + * All Rights Reserved.
8178 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8179 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8180 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8181 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8188 +/* osl handle type forward declaration */
8189 +typedef struct os_handle osl_t;
8192 +#include <linux_osl.h>
8193 +#elif defined(NDIS)
8194 +#include <ndis_osl.h>
8195 +#elif defined(_CFE_)
8196 +#include <cfe_osl.h>
8197 +#elif defined(_HNDRTE_)
8198 +#include <hndrte_osl.h>
8199 +#elif defined(_MINOSL_)
8200 +#include <min_osl.h>
8202 +#include <pmon_osl.h>
8203 +#elif defined(MACOSX)
8204 +#include <macosx_osl.h>
8206 +#error "Unsupported OSL requested"
8210 +#define SET_REG(r, mask, val) W_REG((r), ((R_REG(r) & ~(mask)) | (val)))
8211 +#define MAXPRIO 7 /* 0-7 */
8213 +#endif /* _osl_h_ */
8214 diff -urN linux.old/arch/mips/bcm947xx/include/pcicfg.h linux.dev/arch/mips/bcm947xx/include/pcicfg.h
8215 --- linux.old/arch/mips/bcm947xx/include/pcicfg.h 1970-01-01 01:00:00.000000000 +0100
8216 +++ linux.dev/arch/mips/bcm947xx/include/pcicfg.h 2005-12-15 15:36:31.719013750 +0100
8219 + * pcicfg.h: PCI configuration constants and structures.
8221 + * Copyright 2005, Broadcom Corporation
8222 + * All Rights Reserved.
8224 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8225 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8226 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8227 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8235 +/* The following inside ifndef's so we don't collide with NTDDK.H */
8236 +#ifndef PCI_MAX_BUS
8237 +#define PCI_MAX_BUS 0x100
8239 +#ifndef PCI_MAX_DEVICES
8240 +#define PCI_MAX_DEVICES 0x20
8242 +#ifndef PCI_MAX_FUNCTION
8243 +#define PCI_MAX_FUNCTION 0x8
8246 +#ifndef PCI_INVALID_VENDORID
8247 +#define PCI_INVALID_VENDORID 0xffff
8249 +#ifndef PCI_INVALID_DEVICEID
8250 +#define PCI_INVALID_DEVICEID 0xffff
8254 +/* Convert between bus-slot-function-register and config addresses */
8256 +#define PCICFG_BUS_SHIFT 16 /* Bus shift */
8257 +#define PCICFG_SLOT_SHIFT 11 /* Slot shift */
8258 +#define PCICFG_FUN_SHIFT 8 /* Function shift */
8259 +#define PCICFG_OFF_SHIFT 0 /* Register shift */
8261 +#define PCICFG_BUS_MASK 0xff /* Bus mask */
8262 +#define PCICFG_SLOT_MASK 0x1f /* Slot mask */
8263 +#define PCICFG_FUN_MASK 7 /* Function mask */
8264 +#define PCICFG_OFF_MASK 0xff /* Bus mask */
8266 +#define PCI_CONFIG_ADDR(b, s, f, o) \
8267 + ((((b) & PCICFG_BUS_MASK) << PCICFG_BUS_SHIFT) \
8268 + | (((s) & PCICFG_SLOT_MASK) << PCICFG_SLOT_SHIFT) \
8269 + | (((f) & PCICFG_FUN_MASK) << PCICFG_FUN_SHIFT) \
8270 + | (((o) & PCICFG_OFF_MASK) << PCICFG_OFF_SHIFT))
8272 +#define PCI_CONFIG_BUS(a) (((a) >> PCICFG_BUS_SHIFT) & PCICFG_BUS_MASK)
8273 +#define PCI_CONFIG_SLOT(a) (((a) >> PCICFG_SLOT_SHIFT) & PCICFG_SLOT_MASK)
8274 +#define PCI_CONFIG_FUN(a) (((a) >> PCICFG_FUN_SHIFT) & PCICFG_FUN_MASK)
8275 +#define PCI_CONFIG_OFF(a) (((a) >> PCICFG_OFF_SHIFT) & PCICFG_OFF_MASK)
8277 +/* The actual config space */
8279 +#define PCI_BAR_MAX 6
8281 +#define PCI_ROM_BAR 8
8283 +#define PCR_RSVDA_MAX 2
8285 +/* pci config status reg has a bit to indicate that capability ptr is present*/
8287 +#define PCI_CAPPTR_PRESENT 0x0010
8289 +typedef struct _pci_config_regs {
8290 + unsigned short vendor;
8291 + unsigned short device;
8292 + unsigned short command;
8293 + unsigned short status;
8294 + unsigned char rev_id;
8295 + unsigned char prog_if;
8296 + unsigned char sub_class;
8297 + unsigned char base_class;
8298 + unsigned char cache_line_size;
8299 + unsigned char latency_timer;
8300 + unsigned char header_type;
8301 + unsigned char bist;
8302 + unsigned long base[PCI_BAR_MAX];
8303 + unsigned long cardbus_cis;
8304 + unsigned short subsys_vendor;
8305 + unsigned short subsys_id;
8306 + unsigned long baserom;
8307 + unsigned long rsvd_a[PCR_RSVDA_MAX];
8308 + unsigned char int_line;
8309 + unsigned char int_pin;
8310 + unsigned char min_gnt;
8311 + unsigned char max_lat;
8312 + unsigned char dev_dep[192];
8315 +#define SZPCR (sizeof (pci_config_regs))
8316 +#define MINSZPCR 64 /* offsetof (dev_dep[0] */
8318 +/* A structure for the config registers is nice, but in most
8319 + * systems the config space is not memory mapped, so we need
8320 + * filed offsetts. :-(
8322 +#define PCI_CFG_VID 0
8323 +#define PCI_CFG_DID 2
8324 +#define PCI_CFG_CMD 4
8325 +#define PCI_CFG_STAT 6
8326 +#define PCI_CFG_REV 8
8327 +#define PCI_CFG_PROGIF 9
8328 +#define PCI_CFG_SUBCL 0xa
8329 +#define PCI_CFG_BASECL 0xb
8330 +#define PCI_CFG_CLSZ 0xc
8331 +#define PCI_CFG_LATTIM 0xd
8332 +#define PCI_CFG_HDR 0xe
8333 +#define PCI_CFG_BIST 0xf
8334 +#define PCI_CFG_BAR0 0x10
8335 +#define PCI_CFG_BAR1 0x14
8336 +#define PCI_CFG_BAR2 0x18
8337 +#define PCI_CFG_BAR3 0x1c
8338 +#define PCI_CFG_BAR4 0x20
8339 +#define PCI_CFG_BAR5 0x24
8340 +#define PCI_CFG_CIS 0x28
8341 +#define PCI_CFG_SVID 0x2c
8342 +#define PCI_CFG_SSID 0x2e
8343 +#define PCI_CFG_ROMBAR 0x30
8344 +#define PCI_CFG_CAPPTR 0x34
8345 +#define PCI_CFG_INT 0x3c
8346 +#define PCI_CFG_PIN 0x3d
8347 +#define PCI_CFG_MINGNT 0x3e
8348 +#define PCI_CFG_MAXLAT 0x3f
8350 +/* Classes and subclasses */
8353 + PCI_CLASS_OLD = 0,
8356 + PCI_CLASS_DISPLAY,
8366 + PCI_CLASS_INTELLIGENT = 0xe,
8367 + PCI_CLASS_SATELLITE,
8379 + PCI_DASDI_OTHER = 0x80
8380 +} pci_dasdi_subclasses;
8387 + PCI_NET_OTHER = 0x80
8388 +} pci_net_subclasses;
8394 + PCI_DISPLAY_OTHER = 0x80
8395 +} pci_display_subclasses;
8401 + PCI_MEDIA_OTHER = 0x80
8402 +} pci_mmedia_subclasses;
8407 + PCI_MEMORY_OTHER = 0x80
8408 +} pci_memory_subclasses;
8416 + PCI_BRIDGE_PCMCIA,
8418 + PCI_BRIDGE_CARDBUS,
8419 + PCI_BRIDGE_RACEWAY,
8420 + PCI_BRIDGE_OTHER = 0x80
8421 +} pci_bridge_subclasses;
8425 + PCI_COMM_PARALLEL,
8426 + PCI_COMM_MULTIUART,
8428 + PCI_COMM_OTHER = 0x80
8429 +} pci_comm_subclasses;
8436 + PCI_BASE_PCI_HOTPLUG,
8437 + PCI_BASE_OTHER = 0x80
8438 +} pci_base_subclasses;
8444 + PCI_INPUT_SCANNER,
8445 + PCI_INPUT_GAMEPORT,
8446 + PCI_INPUT_OTHER = 0x80
8447 +} pci_input_subclasses;
8451 + PCI_DOCK_OTHER = 0x80
8452 +} pci_dock_subclasses;
8458 + PCI_CPU_ALPHA = 0x10,
8459 + PCI_CPU_POWERPC = 0x20,
8460 + PCI_CPU_MIPS = 0x30,
8461 + PCI_CPU_COPROC = 0x40,
8462 + PCI_CPU_OTHER = 0x80
8463 +} pci_cpu_subclasses;
8466 + PCI_SERIAL_IEEE1394,
8467 + PCI_SERIAL_ACCESS,
8472 + PCI_SERIAL_OTHER = 0x80
8473 +} pci_serial_subclasses;
8476 + PCI_INTELLIGENT_I2O,
8477 +} pci_intelligent_subclasses;
8481 + PCI_SATELLITE_AUDIO,
8482 + PCI_SATELLITE_VOICE,
8483 + PCI_SATELLITE_DATA,
8484 + PCI_SATELLITE_OTHER = 0x80
8485 +} pci_satellite_subclasses;
8488 + PCI_CRYPT_NETWORK,
8489 + PCI_CRYPT_ENTERTAINMENT,
8490 + PCI_CRYPT_OTHER = 0x80
8491 +} pci_crypt_subclasses;
8495 + PCI_DSP_OTHER = 0x80
8496 +} pci_dsp_subclasses;
8500 + PCI_HEADER_NORMAL,
8501 + PCI_HEADER_BRIDGE,
8502 + PCI_HEADER_CARDBUS
8503 +} pci_header_types;
8506 +/* Overlay for a PCI-to-PCI bridge */
8508 +#define PPB_RSVDA_MAX 2
8509 +#define PPB_RSVDD_MAX 8
8511 +typedef struct _ppb_config_regs {
8512 + unsigned short vendor;
8513 + unsigned short device;
8514 + unsigned short command;
8515 + unsigned short status;
8516 + unsigned char rev_id;
8517 + unsigned char prog_if;
8518 + unsigned char sub_class;
8519 + unsigned char base_class;
8520 + unsigned char cache_line_size;
8521 + unsigned char latency_timer;
8522 + unsigned char header_type;
8523 + unsigned char bist;
8524 + unsigned long rsvd_a[PPB_RSVDA_MAX];
8525 + unsigned char prim_bus;
8526 + unsigned char sec_bus;
8527 + unsigned char sub_bus;
8528 + unsigned char sec_lat;
8529 + unsigned char io_base;
8530 + unsigned char io_lim;
8531 + unsigned short sec_status;
8532 + unsigned short mem_base;
8533 + unsigned short mem_lim;
8534 + unsigned short pf_mem_base;
8535 + unsigned short pf_mem_lim;
8536 + unsigned long pf_mem_base_hi;
8537 + unsigned long pf_mem_lim_hi;
8538 + unsigned short io_base_hi;
8539 + unsigned short io_lim_hi;
8540 + unsigned short subsys_vendor;
8541 + unsigned short subsys_id;
8542 + unsigned long rsvd_b;
8543 + unsigned char rsvd_c;
8544 + unsigned char int_pin;
8545 + unsigned short bridge_ctrl;
8546 + unsigned char chip_ctrl;
8547 + unsigned char diag_ctrl;
8548 + unsigned short arb_ctrl;
8549 + unsigned long rsvd_d[PPB_RSVDD_MAX];
8550 + unsigned char dev_dep[192];
8554 +/* PCI CAPABILITY DEFINES */
8555 +#define PCI_CAP_POWERMGMTCAP_ID 0x01
8556 +#define PCI_CAP_MSICAP_ID 0x05
8558 +/* Data structure to define the Message Signalled Interrupt facility
8559 + * Valid for PCI and PCIE configurations */
8560 +typedef struct _pciconfig_cap_msi {
8561 + unsigned char capID;
8562 + unsigned char nextptr;
8563 + unsigned short msgctrl;
8564 + unsigned int msgaddr;
8565 +} pciconfig_cap_msi;
8567 +/* Data structure to define the Power managment facility
8568 + * Valid for PCI and PCIE configurations */
8569 +typedef struct _pciconfig_cap_pwrmgmt {
8570 + unsigned char capID;
8571 + unsigned char nextptr;
8572 + unsigned short pme_cap;
8573 + unsigned short pme_sts_ctrl;
8574 + unsigned char pme_bridge_ext;
8575 + unsigned char data;
8576 +} pciconfig_cap_pwrmgmt;
8578 +/* Everything below is BRCM HND proprietary */
8580 +#define PCI_BAR0_WIN 0x80 /* backplane addres space accessed by BAR0 */
8581 +#define PCI_BAR1_WIN 0x84 /* backplane addres space accessed by BAR1 */
8582 +#define PCI_SPROM_CONTROL 0x88 /* sprom property control */
8583 +#define PCI_BAR1_CONTROL 0x8c /* BAR1 region burst control */
8584 +#define PCI_INT_STATUS 0x90 /* PCI and other cores interrupts */
8585 +#define PCI_INT_MASK 0x94 /* mask of PCI and other cores interrupts */
8586 +#define PCI_TO_SB_MB 0x98 /* signal backplane interrupts */
8587 +#define PCI_BACKPLANE_ADDR 0xA0 /* address an arbitrary location on the system backplane */
8588 +#define PCI_BACKPLANE_DATA 0xA4 /* data at the location specified by above address register */
8589 +#define PCI_GPIO_IN 0xb0 /* pci config space gpio input (>=rev3) */
8590 +#define PCI_GPIO_OUT 0xb4 /* pci config space gpio output (>=rev3) */
8591 +#define PCI_GPIO_OUTEN 0xb8 /* pci config space gpio output enable (>=rev3) */
8593 +#define PCI_BAR0_SPROM_OFFSET (4 * 1024) /* bar0 + 4K accesses external sprom */
8594 +#define PCI_BAR0_PCIREGS_OFFSET (6 * 1024) /* bar0 + 6K accesses pci core registers */
8596 +/* PCI_INT_STATUS */
8597 +#define PCI_SBIM_STATUS_SERR 0x4 /* backplane SBErr interrupt status */
8600 +#define PCI_SBIM_SHIFT 8 /* backplane core interrupt mask bits offset */
8601 +#define PCI_SBIM_MASK 0xff00 /* backplane core interrupt mask */
8602 +#define PCI_SBIM_MASK_SERR 0x4 /* backplane SBErr interrupt mask */
8604 +/* PCI_SPROM_CONTROL */
8605 +#define SPROM_BLANK 0x04 /* indicating a blank sprom */
8606 +#define SPROM_WRITEEN 0x10 /* sprom write enable */
8607 +#define SPROM_BOOTROM_WE 0x20 /* external bootrom write enable */
8609 +#define SPROM_SIZE 256 /* sprom size in 16-bit */
8610 +#define SPROM_CRC_RANGE 64 /* crc cover range in 16-bit */
8612 +/* PCI_CFG_CMD_STAT */
8613 +#define PCI_CFG_CMD_STAT_TA 0x08000000 /* target abort status */
8616 diff -urN linux.old/arch/mips/bcm947xx/include/proto/ethernet.h linux.dev/arch/mips/bcm947xx/include/proto/ethernet.h
8617 --- linux.old/arch/mips/bcm947xx/include/proto/ethernet.h 1970-01-01 01:00:00.000000000 +0100
8618 +++ linux.dev/arch/mips/bcm947xx/include/proto/ethernet.h 2005-12-15 12:57:27.869191250 +0100
8620 +/*******************************************************************************
8622 + * Copyright 2001-2003, Broadcom Corporation
8623 + * All Rights Reserved.
8625 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8626 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8627 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8628 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8629 + * From FreeBSD 2.2.7: Fundamental constants relating to ethernet.
8630 + ******************************************************************************/
8632 +#ifndef _NET_ETHERNET_H_ /* use native BSD ethernet.h when available */
8633 +#define _NET_ETHERNET_H_
8635 +#ifndef _TYPEDEFS_H_
8636 +#include "typedefs.h"
8639 +#if defined(__GNUC__)
8640 +#define PACKED __attribute__((packed))
8646 + * The number of bytes in an ethernet (MAC) address.
8648 +#define ETHER_ADDR_LEN 6
8651 + * The number of bytes in the type field.
8653 +#define ETHER_TYPE_LEN 2
8656 + * The number of bytes in the trailing CRC field.
8658 +#define ETHER_CRC_LEN 4
8661 + * The length of the combined header.
8663 +#define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
8666 + * The minimum packet length.
8668 +#define ETHER_MIN_LEN 64
8671 + * The minimum packet user data length.
8673 +#define ETHER_MIN_DATA 46
8676 + * The maximum packet length.
8678 +#define ETHER_MAX_LEN 1518
8681 + * The maximum packet user data length.
8683 +#define ETHER_MAX_DATA 1500
8686 + * Used to uniquely identify a 802.1q VLAN-tagged header.
8688 +#define VLAN_TAG 0x8100
8691 + * Located after dest & src address in ether header.
8693 +#define VLAN_FIELDS_OFFSET (ETHER_ADDR_LEN * 2)
8696 + * 4 bytes of vlan field info.
8698 +#define VLAN_FIELDS_SIZE 4
8700 +/* location of pri bits in 16-bit vlan fields */
8701 +#define VLAN_PRI_SHIFT 13
8703 +/* 3 bits of priority */
8704 +#define VLAN_PRI_MASK 7
8706 +/* 802.1X ethertype */
8707 +#define ETHER_TYPE_802_1X 0x888e
8710 + * A macro to validate a length with
8712 +#define ETHER_IS_VALID_LEN(foo) \
8713 + ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
8716 +#ifndef __INCif_etherh /* Quick and ugly hack for VxWorks */
8718 + * Structure of a 10Mb/s Ethernet header.
8720 +struct ether_header {
8721 + uint8 ether_dhost[ETHER_ADDR_LEN];
8722 + uint8 ether_shost[ETHER_ADDR_LEN];
8723 + uint16 ether_type;
8727 + * Structure of a 48-bit Ethernet address.
8729 +struct ether_addr {
8730 + uint8 octet[ETHER_ADDR_LEN];
8735 + * Takes a pointer, returns true if a 48-bit multicast address
8736 + * (including broadcast, since it is all ones)
8738 +#define ETHER_ISMULTI(ea) (((uint8 *)(ea))[0] & 1)
8741 + * Takes a pointer, returns true if a 48-bit broadcast (all ones)
8743 +#define ETHER_ISBCAST(ea) ((((uint8 *)(ea))[0] & \
8744 + ((uint8 *)(ea))[1] & \
8745 + ((uint8 *)(ea))[2] & \
8746 + ((uint8 *)(ea))[3] & \
8747 + ((uint8 *)(ea))[4] & \
8748 + ((uint8 *)(ea))[5]) == 0xff)
8750 +static const struct ether_addr ether_bcast = {{255, 255, 255, 255, 255, 255}};
8753 + * Takes a pointer, returns true if a 48-bit null address (all zeros)
8755 +#define ETHER_ISNULLADDR(ea) ((((uint8 *)(ea))[0] | \
8756 + ((uint8 *)(ea))[1] | \
8757 + ((uint8 *)(ea))[2] | \
8758 + ((uint8 *)(ea))[3] | \
8759 + ((uint8 *)(ea))[4] | \
8760 + ((uint8 *)(ea))[5]) == 0)
8764 +#endif /* _NET_ETHERNET_H_ */
8765 diff -urN linux.old/arch/mips/bcm947xx/include/s5.h linux.dev/arch/mips/bcm947xx/include/s5.h
8766 --- linux.old/arch/mips/bcm947xx/include/s5.h 1970-01-01 01:00:00.000000000 +0100
8767 +++ linux.dev/arch/mips/bcm947xx/include/s5.h 2005-12-15 12:57:27.869191250 +0100
8772 + * Copyright 2003, Broadcom Corporation
8773 + * All Rights Reserved.
8775 + * Broadcom Sentry5 (S5) BCM5365, 53xx, BCM58xx SOC Internal Core
8776 + * and MIPS3301 (R4K) System Address Space
8778 + * This program is free software; you can redistribute it and/or
8779 + * modify it under the terms of the GNU General Public License as
8780 + * published by the Free Software Foundation, located in the file
8783 + * $Id: s5.h,v 1.3 2003/06/10 18:54:51 jfd Exp $
8787 +/* BCM5365 Address map */
8788 +#define KSEG1ADDR(x) ( (x) | 0xa0000000)
8789 +#define BCM5365_SDRAM 0x00000000 /* 0-128MB Physical SDRAM */
8790 +#define BCM5365_PCI_MEM 0x08000000 /* Host Mode PCI mem space (64MB) */
8791 +#define BCM5365_PCI_CFG 0x0c000000 /* Host Mode PCI cfg space (64MB) */
8792 +#define BCM5365_PCI_DMA 0x40000000 /* Client Mode PCI mem space (1GB)*/
8793 +#define BCM5365_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
8794 +#define BCM5365_ENUM 0x18000000 /* Beginning of core enum space */
8796 +/* BCM5365 Core register space */
8797 +#define BCM5365_REG_CHIPC 0x18000000 /* Chipcommon registers */
8798 +#define BCM5365_REG_EMAC0 0x18001000 /* Ethernet MAC0 core registers */
8799 +#define BCM5365_REG_IPSEC 0x18002000 /* BCM582x CryptoCore registers */
8800 +#define BCM5365_REG_USB 0x18003000 /* USB core registers */
8801 +#define BCM5365_REG_PCI 0x18004000 /* PCI core registers */
8802 +#define BCM5365_REG_MIPS33 0x18005000 /* MIPS core registers */
8803 +#define BCM5365_REG_MEMC 0x18006000 /* MEMC core registers */
8804 +#define BCM5365_REG_UARTS (BCM5365_REG_CHIPC + 0x300) /* UART regs */
8805 +#define BCM5365_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
8807 +/* COM Ports 1/2 */
8808 +#define BCM5365_UART (BCM5365_REG_UARTS)
8809 +#define BCM5365_UART_COM2 (BCM5365_REG_UARTS + 0x00000100)
8811 +/* Registers common to MIPS33 Core used in 5365 */
8812 +#define MIPS33_FLASH_REGION 0x1fc00000 /* Boot FLASH Region */
8813 +#define MIPS33_EXTIF_REGION 0x1a000000 /* Chipcommon EXTIF region*/
8814 +#define BCM5365_EXTIF 0x1b000000 /* MISC_CS */
8815 +#define MIPS33_FLASH_REGION_AUX 0x1c000000 /* FLASH Region 2*/
8817 +/* Internal Core Sonics Backplane Devices */
8818 +#define INTERNAL_UART_COM1 BCM5365_UART
8819 +#define INTERNAL_UART_COM2 BCM5365_UART_COM2
8820 +#define SB_REG_CHIPC BCM5365_REG_CHIPC
8821 +#define SB_REG_ENET0 BCM5365_REG_EMAC0
8822 +#define SB_REG_IPSEC BCM5365_REG_IPSEC
8823 +#define SB_REG_USB BCM5365_REG_USB
8824 +#define SB_REG_PCI BCM5365_REG_PCI
8825 +#define SB_REG_MIPS BCM5365_REG_MIPS33
8826 +#define SB_REG_MEMC BCM5365_REG_MEMC
8827 +#define SB_REG_MEMC_OFF 0x6000
8828 +#define SB_EXTIF_SPACE MIPS33_EXTIF_REGION
8829 +#define SB_FLASH_SPACE MIPS33_FLASH_REGION
8833 + * 5365-specific backplane interrupt flag numbers. This should be done
8834 + * dynamically instead.
8836 +#define SBFLAG_PCI 0
8837 +#define SBFLAG_ENET0 1
8838 +#define SBFLAG_ILINE20 2
8839 +#define SBFLAG_CODEC 3
8840 +#define SBFLAG_USB 4
8841 +#define SBFLAG_EXTIF 5
8842 +#define SBFLAG_ENET1 6
8844 +/* BCM95365 Local Bus devices */
8845 +#define BCM95365K_RESET_ADDR BCM5365_EXTIF
8846 +#define BCM95365K_BOARDID_ADDR (BCM5365_EXTIF | 0x4000)
8847 +#define BCM95365K_DOC_ADDR (BCM5365_EXTIF | 0x6000)
8848 +#define BCM95365K_LED_ADDR (BCM5365_EXTIF | 0xc000)
8849 +#define BCM95365K_TOD_REG_BASE (BCM95365K_NVRAM_ADDR | 0x1ff0)
8850 +#define BCM95365K_NVRAM_ADDR (BCM5365_EXTIF | 0xe000)
8851 +#define BCM95365K_NVRAM_SIZE 0x1ff0 /* 8K NVRAM : DS1743/STM48txx*/
8853 +/* Write to DLR2416 VFD Display character RAM */
8854 +#define LED_REG(x) \
8855 + (*(volatile unsigned char *) (KSEG1ADDR(BCM95365K_LED_ADDR) + (x)))
8858 +#define BCM5365_TRACE(trval) do { *((int *)0xa0002ff8) = (trval); \
8861 +#define BCM5365_TRACE(trval) do { *((unsigned char *)\
8862 + KSEG1ADDR(BCM5365K_LED_ADDR)) = (trval); \
8863 + *((int *)0xa0002ff8) = (trval); } while (0)
8866 +/* BCM9536R Local Bus devices */
8867 +#define BCM95365R_DOC_ADDR BCM5365_EXTIF
8871 +#endif /*!_S5_H_ */
8872 diff -urN linux.old/arch/mips/bcm947xx/include/sbchipc.h linux.dev/arch/mips/bcm947xx/include/sbchipc.h
8873 --- linux.old/arch/mips/bcm947xx/include/sbchipc.h 1970-01-01 01:00:00.000000000 +0100
8874 +++ linux.dev/arch/mips/bcm947xx/include/sbchipc.h 2005-12-15 15:35:20.458560250 +0100
8877 + * SiliconBackplane Chipcommon core hardware definitions.
8879 + * The chipcommon core provides chip identification, SB control,
8880 + * jtag, 0/1/2 uarts, clock frequency control, a watchdog interrupt timer,
8881 + * gpio interface, extbus, and support for serial and parallel flashes.
8884 + * Copyright 2005, Broadcom Corporation
8885 + * All Rights Reserved.
8887 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8888 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8889 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8890 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8898 +#ifndef _LANGUAGE_ASSEMBLY
8900 +/* cpp contortions to concatenate w/arg prescan */
8902 +#define _PADLINE(line) pad ## line
8903 +#define _XSTR(line) _PADLINE(line)
8904 +#define PAD _XSTR(__LINE__)
8907 +typedef volatile struct {
8908 + uint32 chipid; /* 0x0 */
8909 + uint32 capabilities;
8910 + uint32 corecontrol; /* corerev >= 1 */
8914 + uint32 otpstatus; /* 0x10, corerev >= 10 */
8915 + uint32 otpcontrol;
8919 + /* Interrupt control */
8920 + uint32 intstatus; /* 0x20 */
8922 + uint32 chipcontrol; /* 0x28, rev >= 11 */
8923 + uint32 chipstatus; /* 0x2c, rev >= 11 */
8926 + uint32 jtagcmd; /* 0x30, rev >= 10 */
8931 + /* serial flash interface registers */
8932 + uint32 flashcontrol; /* 0x40 */
8933 + uint32 flashaddress;
8937 + /* Silicon backplane configuration broadcast control */
8938 + uint32 broadcastaddress; /* 0x50 */
8939 + uint32 broadcastdata;
8942 + /* gpio - cleared only by power-on-reset */
8943 + uint32 gpioin; /* 0x60 */
8946 + uint32 gpiocontrol;
8947 + uint32 gpiointpolarity;
8948 + uint32 gpiointmask;
8951 + /* Watchdog timer */
8952 + uint32 watchdog; /* 0x80 */
8955 + /*GPIO based LED powersave registers corerev >= 16*/
8956 + uint32 gpiotimerval; /*0x88 */
8957 + uint32 gpiotimeroutmask;
8959 + /* clock control */
8960 + uint32 clockcontrol_n; /* 0x90 */
8961 + uint32 clockcontrol_sb; /* aka m0 */
8962 + uint32 clockcontrol_pci; /* aka m1 */
8963 + uint32 clockcontrol_m2; /* mii/uart/mipsref */
8964 + uint32 clockcontrol_mips; /* aka m3 */
8965 + uint32 clkdiv; /* corerev >= 3 */
8968 + /* pll delay registers (corerev >= 4) */
8969 + uint32 pll_on_delay; /* 0xb0 */
8970 + uint32 fref_sel_delay;
8971 + uint32 slow_clk_ctl; /* 5 < corerev < 10 */
8974 + /* Instaclock registers (corerev >= 10) */
8975 + uint32 system_clk_ctl; /* 0xc0 */
8976 + uint32 clkstatestretch;
8979 + /* ExtBus control registers (corerev >= 3) */
8980 + uint32 pcmcia_config; /* 0x100 */
8981 + uint32 pcmcia_memwait;
8982 + uint32 pcmcia_attrwait;
8983 + uint32 pcmcia_iowait;
8984 + uint32 ide_config;
8985 + uint32 ide_memwait;
8986 + uint32 ide_attrwait;
8987 + uint32 ide_iowait;
8988 + uint32 prog_config;
8989 + uint32 prog_waitcount;
8990 + uint32 flash_config;
8991 + uint32 flash_waitcount;
8995 + uint8 uart0data; /* 0x300 */
9002 + uint8 uart0scratch;
9003 + uint8 PAD[248]; /* corerev >= 1 */
9005 + uint8 uart1data; /* 0x400 */
9012 + uint8 uart1scratch;
9015 +#endif /* _LANGUAGE_ASSEMBLY */
9017 +#define CC_CHIPID 0
9018 +#define CC_CAPABILITIES 4
9019 +#define CC_JTAGCMD 0x30
9020 +#define CC_JTAGIR 0x34
9021 +#define CC_JTAGDR 0x38
9022 +#define CC_JTAGCTRL 0x3c
9023 +#define CC_WATCHDOG 0x80
9024 +#define CC_CLKC_N 0x90
9025 +#define CC_CLKC_M0 0x94
9026 +#define CC_CLKC_M1 0x98
9027 +#define CC_CLKC_M2 0x9c
9028 +#define CC_CLKC_M3 0xa0
9029 +#define CC_CLKDIV 0xa4
9030 +#define CC_SYS_CLK_CTL 0xc0
9031 +#define CC_OTP 0x800
9034 +#define CID_ID_MASK 0x0000ffff /* Chip Id mask */
9035 +#define CID_REV_MASK 0x000f0000 /* Chip Revision mask */
9036 +#define CID_REV_SHIFT 16 /* Chip Revision shift */
9037 +#define CID_PKG_MASK 0x00f00000 /* Package Option mask */
9038 +#define CID_PKG_SHIFT 20 /* Package Option shift */
9039 +#define CID_CC_MASK 0x0f000000 /* CoreCount (corerev >= 4) */
9040 +#define CID_CC_SHIFT 24
9043 +#define CAP_UARTS_MASK 0x00000003 /* Number of uarts */
9044 +#define CAP_MIPSEB 0x00000004 /* MIPS is in big-endian mode */
9045 +#define CAP_UCLKSEL 0x00000018 /* UARTs clock select */
9046 +#define CAP_UINTCLK 0x00000008 /* UARTs are driven by internal divided clock */
9047 +#define CAP_UARTGPIO 0x00000020 /* UARTs own Gpio's 15:12 */
9048 +#define CAP_EXTBUS 0x00000040 /* External bus present */
9049 +#define CAP_FLASH_MASK 0x00000700 /* Type of flash */
9050 +#define CAP_PLL_MASK 0x00038000 /* Type of PLL */
9051 +#define CAP_PWR_CTL 0x00040000 /* Power control */
9052 +#define CAP_OTPSIZE 0x00380000 /* OTP Size (0 = none) */
9053 +#define CAP_OTPSIZE_SHIFT 19 /* OTP Size shift */
9054 +#define CAP_OTPSIZE_BASE 5 /* OTP Size base */
9055 +#define CAP_JTAGP 0x00400000 /* JTAG Master Present */
9056 +#define CAP_ROM 0x00800000 /* Internal boot rom active */
9059 +#define PLL_NONE 0x00000000
9060 +#define PLL_TYPE1 0x00010000 /* 48Mhz base, 3 dividers */
9061 +#define PLL_TYPE2 0x00020000 /* 48Mhz, 4 dividers */
9062 +#define PLL_TYPE3 0x00030000 /* 25Mhz, 2 dividers */
9063 +#define PLL_TYPE4 0x00008000 /* 48Mhz, 4 dividers */
9064 +#define PLL_TYPE5 0x00018000 /* 25Mhz, 4 dividers */
9065 +#define PLL_TYPE6 0x00028000 /* 100/200 or 120/240 only */
9066 +#define PLL_TYPE7 0x00038000 /* 25Mhz, 4 dividers */
9069 +#define CC_UARTCLKO 0x00000001 /* Drive UART with internal clock */
9070 +#define CC_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
9072 +/* Fields in the otpstatus register */
9073 +#define OTPS_PROGFAIL 0x80000000
9074 +#define OTPS_PROTECT 0x00000007
9075 +#define OTPS_HW_PROTECT 0x00000001
9076 +#define OTPS_SW_PROTECT 0x00000002
9077 +#define OTPS_CID_PROTECT 0x00000004
9079 +/* Fields in the otpcontrol register */
9080 +#define OTPC_RECWAIT 0xff000000
9081 +#define OTPC_PROGWAIT 0x00ffff00
9082 +#define OTPC_PRW_SHIFT 8
9083 +#define OTPC_MAXFAIL 0x00000038
9084 +#define OTPC_VSEL 0x00000006
9085 +#define OTPC_SELVL 0x00000001
9087 +/* Fields in otpprog */
9088 +#define OTPP_COL_MASK 0x000000ff
9089 +#define OTPP_ROW_MASK 0x0000ff00
9090 +#define OTPP_ROW_SHIFT 8
9091 +#define OTPP_READERR 0x10000000
9092 +#define OTPP_VALUE 0x20000000
9093 +#define OTPP_VALUE_SHIFT 29
9094 +#define OTPP_READ 0x40000000
9095 +#define OTPP_START 0x80000000
9096 +#define OTPP_BUSY 0x80000000
9099 +#define JCMD_START 0x80000000
9100 +#define JCMD_BUSY 0x80000000
9101 +#define JCMD_PAUSE 0x40000000
9102 +#define JCMD0_ACC_MASK 0x0000f000
9103 +#define JCMD0_ACC_IRDR 0x00000000
9104 +#define JCMD0_ACC_DR 0x00001000
9105 +#define JCMD0_ACC_IR 0x00002000
9106 +#define JCMD0_ACC_RESET 0x00003000
9107 +#define JCMD0_ACC_IRPDR 0x00004000
9108 +#define JCMD0_ACC_PDR 0x00005000
9109 +#define JCMD0_IRW_MASK 0x00000f00
9110 +#define JCMD_ACC_MASK 0x000f0000 /* Changes for corerev 11 */
9111 +#define JCMD_ACC_IRDR 0x00000000
9112 +#define JCMD_ACC_DR 0x00010000
9113 +#define JCMD_ACC_IR 0x00020000
9114 +#define JCMD_ACC_RESET 0x00030000
9115 +#define JCMD_ACC_IRPDR 0x00040000
9116 +#define JCMD_ACC_PDR 0x00050000
9117 +#define JCMD_IRW_MASK 0x00001f00
9118 +#define JCMD_IRW_SHIFT 8
9119 +#define JCMD_DRW_MASK 0x0000003f
9122 +#define JCTRL_FORCE_CLK 4 /* Force clock */
9123 +#define JCTRL_EXT_EN 2 /* Enable external targets */
9124 +#define JCTRL_EN 1 /* Enable Jtag master */
9126 +/* Fields in clkdiv */
9127 +#define CLKD_SFLASH 0x0f000000
9128 +#define CLKD_SFLASH_SHIFT 24
9129 +#define CLKD_OTP 0x000f0000
9130 +#define CLKD_OTP_SHIFT 16
9131 +#define CLKD_JTAG 0x00000f00
9132 +#define CLKD_JTAG_SHIFT 8
9133 +#define CLKD_UART 0x000000ff
9135 +/* intstatus/intmask */
9136 +#define CI_GPIO 0x00000001 /* gpio intr */
9137 +#define CI_EI 0x00000002 /* ro: ext intr pin (corerev >= 3) */
9138 +#define CI_WDRESET 0x80000000 /* watchdog reset occurred */
9141 +#define SCC_SS_MASK 0x00000007 /* slow clock source mask */
9142 +#define SCC_SS_LPO 0x00000000 /* source of slow clock is LPO */
9143 +#define SCC_SS_XTAL 0x00000001 /* source of slow clock is crystal */
9144 +#define SCC_SS_PCI 0x00000002 /* source of slow clock is PCI */
9145 +#define SCC_LF 0x00000200 /* LPOFreqSel, 1: 160Khz, 0: 32KHz */
9146 +#define SCC_LP 0x00000400 /* LPOPowerDown, 1: LPO is disabled, 0: LPO is enabled */
9147 +#define SCC_FS 0x00000800 /* ForceSlowClk, 1: sb/cores running on slow clock, 0: power logic control */
9148 +#define SCC_IP 0x00001000 /* IgnorePllOffReq, 1/0: power logic ignores/honors PLL clock disable requests from core */
9149 +#define SCC_XC 0x00002000 /* XtalControlEn, 1/0: power logic does/doesn't disable crystal when appropriate */
9150 +#define SCC_XP 0x00004000 /* XtalPU (RO), 1/0: crystal running/disabled */
9151 +#define SCC_CD_MASK 0xffff0000 /* ClockDivider (SlowClk = 1/(4+divisor)) */
9152 +#define SCC_CD_SHIFT 16
9154 +/* system_clk_ctl */
9155 +#define SYCC_IE 0x00000001 /* ILPen: Enable Idle Low Power */
9156 +#define SYCC_AE 0x00000002 /* ALPen: Enable Active Low Power */
9157 +#define SYCC_FP 0x00000004 /* ForcePLLOn */
9158 +#define SYCC_AR 0x00000008 /* Force ALP (or HT if ALPen is not set */
9159 +#define SYCC_HR 0x00000010 /* Force HT */
9160 +#define SYCC_CD_MASK 0xffff0000 /* ClkDiv (ILP = 1/(4+divisor)) */
9161 +#define SYCC_CD_SHIFT 16
9164 +#define GPIO_ONTIME_SHIFT 16
9166 +/* clockcontrol_n */
9167 +#define CN_N1_MASK 0x3f /* n1 control */
9168 +#define CN_N2_MASK 0x3f00 /* n2 control */
9169 +#define CN_N2_SHIFT 8
9170 +#define CN_PLLC_MASK 0xf0000 /* pll control */
9171 +#define CN_PLLC_SHIFT 16
9173 +/* clockcontrol_sb/pci/uart */
9174 +#define CC_M1_MASK 0x3f /* m1 control */
9175 +#define CC_M2_MASK 0x3f00 /* m2 control */
9176 +#define CC_M2_SHIFT 8
9177 +#define CC_M3_MASK 0x3f0000 /* m3 control */
9178 +#define CC_M3_SHIFT 16
9179 +#define CC_MC_MASK 0x1f000000 /* mux control */
9180 +#define CC_MC_SHIFT 24
9182 +/* N3M Clock control magic field values */
9183 +#define CC_F6_2 0x02 /* A factor of 2 in */
9184 +#define CC_F6_3 0x03 /* 6-bit fields like */
9185 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
9186 +#define CC_F6_5 0x09
9187 +#define CC_F6_6 0x11
9188 +#define CC_F6_7 0x21
9190 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
9192 +#define CC_MC_BYPASS 0x08
9193 +#define CC_MC_M1 0x04
9194 +#define CC_MC_M1M2 0x02
9195 +#define CC_MC_M1M2M3 0x01
9196 +#define CC_MC_M1M3 0x11
9198 +/* Type 2 Clock control magic field values */
9199 +#define CC_T2_BIAS 2 /* n1, n2, m1 & m3 bias */
9200 +#define CC_T2M2_BIAS 3 /* m2 bias */
9202 +#define CC_T2MC_M1BYP 1
9203 +#define CC_T2MC_M2BYP 2
9204 +#define CC_T2MC_M3BYP 4
9206 +/* Type 6 Clock control magic field values */
9207 +#define CC_T6_MMASK 1 /* bits of interest in m */
9208 +#define CC_T6_M0 120000000 /* sb clock for m = 0 */
9209 +#define CC_T6_M1 100000000 /* sb clock for m = 1 */
9210 +#define SB2MIPS_T6(sb) (2 * (sb))
9212 +/* Common clock base */
9213 +#define CC_CLOCK_BASE1 24000000 /* Half the clock freq */
9214 +#define CC_CLOCK_BASE2 12500000 /* Alternate crystal on some PLL's */
9216 +/* Clock control values for 200Mhz in 5350 */
9217 +#define CLKC_5350_N 0x0311
9218 +#define CLKC_5350_M 0x04020009
9220 +/* Flash types in the chipcommon capabilities register */
9221 +#define FLASH_NONE 0x000 /* No flash */
9222 +#define SFLASH_ST 0x100 /* ST serial flash */
9223 +#define SFLASH_AT 0x200 /* Atmel serial flash */
9224 +#define PFLASH 0x700 /* Parallel flash */
9226 +/* Bits in the config registers */
9227 +#define CC_CFG_EN 0x0001 /* Enable */
9228 +#define CC_CFG_EM_MASK 0x000e /* Extif Mode */
9229 +#define CC_CFG_EM_ASYNC 0x0002 /* Async/Parallel flash */
9230 +#define CC_CFG_EM_SYNC 0x0004 /* Synchronous */
9231 +#define CC_CFG_EM_PCMCIA 0x0008 /* PCMCIA */
9232 +#define CC_CFG_EM_IDE 0x000a /* IDE */
9233 +#define CC_CFG_DS 0x0010 /* Data size, 0=8bit, 1=16bit */
9234 +#define CC_CFG_CD_MASK 0x0060 /* Sync: Clock divisor */
9235 +#define CC_CFG_CE 0x0080 /* Sync: Clock enable */
9236 +#define CC_CFG_SB 0x0100 /* Sync: Size/Bytestrobe */
9238 +/* Start/busy bit in flashcontrol */
9239 +#define SFLASH_START 0x80000000
9240 +#define SFLASH_BUSY SFLASH_START
9242 +/* flashcontrol opcodes for ST flashes */
9243 +#define SFLASH_ST_WREN 0x0006 /* Write Enable */
9244 +#define SFLASH_ST_WRDIS 0x0004 /* Write Disable */
9245 +#define SFLASH_ST_RDSR 0x0105 /* Read Status Register */
9246 +#define SFLASH_ST_WRSR 0x0101 /* Write Status Register */
9247 +#define SFLASH_ST_READ 0x0303 /* Read Data Bytes */
9248 +#define SFLASH_ST_PP 0x0302 /* Page Program */
9249 +#define SFLASH_ST_SE 0x02d8 /* Sector Erase */
9250 +#define SFLASH_ST_BE 0x00c7 /* Bulk Erase */
9251 +#define SFLASH_ST_DP 0x00b9 /* Deep Power-down */
9252 +#define SFLASH_ST_RES 0x03ab /* Read Electronic Signature */
9254 +/* Status register bits for ST flashes */
9255 +#define SFLASH_ST_WIP 0x01 /* Write In Progress */
9256 +#define SFLASH_ST_WEL 0x02 /* Write Enable Latch */
9257 +#define SFLASH_ST_BP_MASK 0x1c /* Block Protect */
9258 +#define SFLASH_ST_BP_SHIFT 2
9259 +#define SFLASH_ST_SRWD 0x80 /* Status Register Write Disable */
9261 +/* flashcontrol opcodes for Atmel flashes */
9262 +#define SFLASH_AT_READ 0x07e8
9263 +#define SFLASH_AT_PAGE_READ 0x07d2
9264 +#define SFLASH_AT_BUF1_READ
9265 +#define SFLASH_AT_BUF2_READ
9266 +#define SFLASH_AT_STATUS 0x01d7
9267 +#define SFLASH_AT_BUF1_WRITE 0x0384
9268 +#define SFLASH_AT_BUF2_WRITE 0x0387
9269 +#define SFLASH_AT_BUF1_ERASE_PROGRAM 0x0283
9270 +#define SFLASH_AT_BUF2_ERASE_PROGRAM 0x0286
9271 +#define SFLASH_AT_BUF1_PROGRAM 0x0288
9272 +#define SFLASH_AT_BUF2_PROGRAM 0x0289
9273 +#define SFLASH_AT_PAGE_ERASE 0x0281
9274 +#define SFLASH_AT_BLOCK_ERASE 0x0250
9275 +#define SFLASH_AT_BUF1_WRITE_ERASE_PROGRAM 0x0382
9276 +#define SFLASH_AT_BUF2_WRITE_ERASE_PROGRAM 0x0385
9277 +#define SFLASH_AT_BUF1_LOAD 0x0253
9278 +#define SFLASH_AT_BUF2_LOAD 0x0255
9279 +#define SFLASH_AT_BUF1_COMPARE 0x0260
9280 +#define SFLASH_AT_BUF2_COMPARE 0x0261
9281 +#define SFLASH_AT_BUF1_REPROGRAM 0x0258
9282 +#define SFLASH_AT_BUF2_REPROGRAM 0x0259
9284 +/* Status register bits for Atmel flashes */
9285 +#define SFLASH_AT_READY 0x80
9286 +#define SFLASH_AT_MISMATCH 0x40
9287 +#define SFLASH_AT_ID_MASK 0x38
9288 +#define SFLASH_AT_ID_SHIFT 3
9291 +#define OTP_HW_REGION OTPS_HW_PROTECT
9292 +#define OTP_SW_REGION OTPS_SW_PROTECT
9293 +#define OTP_CID_REGION OTPS_CID_PROTECT
9295 +/* OTP regions (Byte offsets from otp size) */
9296 +#define OTP_SWLIM_OFF (-8)
9297 +#define OTP_CIDBASE_OFF 0
9298 +#define OTP_CIDLIM_OFF 8
9300 +/* Predefined OTP words (Word offset from otp size) */
9301 +#define OTP_BOUNDARY_OFF (-4)
9302 +#define OTP_HWSIGN_OFF (-3)
9303 +#define OTP_SWSIGN_OFF (-2)
9304 +#define OTP_CIDSIGN_OFF (-1)
9306 +#define OTP_CID_OFF 0
9307 +#define OTP_PKG_OFF 1
9308 +#define OTP_FID_OFF 2
9309 +#define OTP_RSV_OFF 3
9310 +#define OTP_LIM_OFF 4
9312 +#define OTP_SIGNATURE 0x578a
9313 +#define OTP_MAGIC 0x4e56
9315 +#endif /* _SBCHIPC_H */
9316 diff -urN linux.old/arch/mips/bcm947xx/include/sbconfig.h linux.dev/arch/mips/bcm947xx/include/sbconfig.h
9317 --- linux.old/arch/mips/bcm947xx/include/sbconfig.h 1970-01-01 01:00:00.000000000 +0100
9318 +++ linux.dev/arch/mips/bcm947xx/include/sbconfig.h 2005-12-15 15:35:24.538815250 +0100
9321 + * Broadcom SiliconBackplane hardware register definitions.
9323 + * Copyright 2005, Broadcom Corporation
9324 + * All Rights Reserved.
9326 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9327 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9328 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9329 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9333 +#ifndef _SBCONFIG_H
9334 +#define _SBCONFIG_H
9336 +/* cpp contortions to concatenate w/arg prescan */
9338 +#define _PADLINE(line) pad ## line
9339 +#define _XSTR(line) _PADLINE(line)
9340 +#define PAD _XSTR(__LINE__)
9344 + * SiliconBackplane Address Map.
9345 + * All regions may not exist on all chips.
9347 +#define SB_SDRAM_BASE 0x00000000 /* Physical SDRAM */
9348 +#define SB_PCI_MEM 0x08000000 /* Host Mode sb2pcitranslation0 (64 MB) */
9349 +#define SB_PCI_CFG 0x0c000000 /* Host Mode sb2pcitranslation1 (64 MB) */
9350 +#define SB_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
9351 +#define SB_ENUM_BASE 0x18000000 /* Enumeration space base */
9352 +#define SB_ENUM_LIM 0x18010000 /* Enumeration space limit */
9354 +#define SB_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
9355 +#define SB_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
9357 +#define SB_EXTIF_BASE 0x1f000000 /* External Interface region base address */
9358 +#define SB_FLASH1 0x1fc00000 /* Flash Region 1 */
9359 +#define SB_FLASH1_SZ 0x00400000 /* Size of Flash Region 1 */
9361 +#define SB_PCI_DMA 0x40000000 /* Client Mode sb2pcitranslation2 (1 GB) */
9362 +#define SB_PCI_DMA_SZ 0x40000000 /* Client Mode sb2pcitranslation2 size in bytes */
9363 +#define SB_PCIE_DMA_L32 0x00000000 /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), low 32 bits */
9364 +#define SB_PCIE_DMA_H32 0x80000000 /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */
9365 +#define SB_EUART (SB_EXTIF_BASE + 0x00800000)
9366 +#define SB_LED (SB_EXTIF_BASE + 0x00900000)
9369 +/* enumeration space related defs */
9370 +#define SB_CORE_SIZE 0x1000 /* each core gets 4Kbytes for registers */
9371 +#define SB_MAXCORES ((SB_ENUM_LIM - SB_ENUM_BASE)/SB_CORE_SIZE)
9372 +#define SBCONFIGOFF 0xf00 /* core sbconfig regs are top 256bytes of regs */
9373 +#define SBCONFIGSIZE 256 /* sizeof (sbconfig_t) */
9376 +#define SB_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
9379 + * Sonics Configuration Space Registers.
9381 +#define SBIPSFLAG 0x08
9382 +#define SBTPSFLAG 0x18
9383 +#define SBTMERRLOGA 0x48 /* sonics >= 2.3 */
9384 +#define SBTMERRLOG 0x50 /* sonics >= 2.3 */
9385 +#define SBADMATCH3 0x60
9386 +#define SBADMATCH2 0x68
9387 +#define SBADMATCH1 0x70
9388 +#define SBIMSTATE 0x90
9389 +#define SBINTVEC 0x94
9390 +#define SBTMSTATELOW 0x98
9391 +#define SBTMSTATEHIGH 0x9c
9392 +#define SBBWA0 0xa0
9393 +#define SBIMCONFIGLOW 0xa8
9394 +#define SBIMCONFIGHIGH 0xac
9395 +#define SBADMATCH0 0xb0
9396 +#define SBTMCONFIGLOW 0xb8
9397 +#define SBTMCONFIGHIGH 0xbc
9398 +#define SBBCONFIG 0xc0
9399 +#define SBBSTATE 0xc8
9400 +#define SBACTCNFG 0xd8
9401 +#define SBFLAGST 0xe8
9402 +#define SBIDLOW 0xf8
9403 +#define SBIDHIGH 0xfc
9405 +#ifndef _LANGUAGE_ASSEMBLY
9407 +typedef volatile struct _sbconfig {
9409 + uint32 sbipsflag; /* initiator port ocp slave flag */
9411 + uint32 sbtpsflag; /* target port ocp slave flag */
9413 + uint32 sbtmerrloga; /* (sonics >= 2.3) */
9415 + uint32 sbtmerrlog; /* (sonics >= 2.3) */
9417 + uint32 sbadmatch3; /* address match3 */
9419 + uint32 sbadmatch2; /* address match2 */
9421 + uint32 sbadmatch1; /* address match1 */
9423 + uint32 sbimstate; /* initiator agent state */
9424 + uint32 sbintvec; /* interrupt mask */
9425 + uint32 sbtmstatelow; /* target state */
9426 + uint32 sbtmstatehigh; /* target state */
9427 + uint32 sbbwa0; /* bandwidth allocation table0 */
9429 + uint32 sbimconfiglow; /* initiator configuration */
9430 + uint32 sbimconfighigh; /* initiator configuration */
9431 + uint32 sbadmatch0; /* address match0 */
9433 + uint32 sbtmconfiglow; /* target configuration */
9434 + uint32 sbtmconfighigh; /* target configuration */
9435 + uint32 sbbconfig; /* broadcast configuration */
9437 + uint32 sbbstate; /* broadcast state */
9439 + uint32 sbactcnfg; /* activate configuration */
9441 + uint32 sbflagst; /* current sbflags */
9443 + uint32 sbidlow; /* identification */
9444 + uint32 sbidhigh; /* identification */
9447 +#endif /* _LANGUAGE_ASSEMBLY */
9450 +#define SBIPS_INT1_MASK 0x3f /* which sbflags get routed to mips interrupt 1 */
9451 +#define SBIPS_INT1_SHIFT 0
9452 +#define SBIPS_INT2_MASK 0x3f00 /* which sbflags get routed to mips interrupt 2 */
9453 +#define SBIPS_INT2_SHIFT 8
9454 +#define SBIPS_INT3_MASK 0x3f0000 /* which sbflags get routed to mips interrupt 3 */
9455 +#define SBIPS_INT3_SHIFT 16
9456 +#define SBIPS_INT4_MASK 0x3f000000 /* which sbflags get routed to mips interrupt 4 */
9457 +#define SBIPS_INT4_SHIFT 24
9460 +#define SBTPS_NUM0_MASK 0x3f /* interrupt sbFlag # generated by this core */
9461 +#define SBTPS_F0EN0 0x40 /* interrupt is always sent on the backplane */
9464 +#define SBTMEL_CM 0x00000007 /* command */
9465 +#define SBTMEL_CI 0x0000ff00 /* connection id */
9466 +#define SBTMEL_EC 0x0f000000 /* error code */
9467 +#define SBTMEL_ME 0x80000000 /* multiple error */
9470 +#define SBIM_PC 0xf /* pipecount */
9471 +#define SBIM_AP_MASK 0x30 /* arbitration policy */
9472 +#define SBIM_AP_BOTH 0x00 /* use both timeslaces and token */
9473 +#define SBIM_AP_TS 0x10 /* use timesliaces only */
9474 +#define SBIM_AP_TK 0x20 /* use token only */
9475 +#define SBIM_AP_RSV 0x30 /* reserved */
9476 +#define SBIM_IBE 0x20000 /* inbanderror */
9477 +#define SBIM_TO 0x40000 /* timeout */
9478 +#define SBIM_BY 0x01800000 /* busy (sonics >= 2.3) */
9479 +#define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */
9482 +#define SBTML_RESET 0x1 /* reset */
9483 +#define SBTML_REJ_MASK 0x6 /* reject */
9484 +#define SBTML_REJ_SHIFT 1
9485 +#define SBTML_CLK 0x10000 /* clock enable */
9486 +#define SBTML_FGC 0x20000 /* force gated clocks on */
9487 +#define SBTML_FL_MASK 0x3ffc0000 /* core-specific flags */
9488 +#define SBTML_PE 0x40000000 /* pme enable */
9489 +#define SBTML_BE 0x80000000 /* bist enable */
9491 +/* sbtmstatehigh */
9492 +#define SBTMH_SERR 0x1 /* serror */
9493 +#define SBTMH_INT 0x2 /* interrupt */
9494 +#define SBTMH_BUSY 0x4 /* busy */
9495 +#define SBTMH_TO 0x00000020 /* timeout (sonics >= 2.3) */
9496 +#define SBTMH_FL_MASK 0x1fff0000 /* core-specific flags */
9497 +#define SBTMH_DMA64 0x10000000 /* supports DMA with 64-bit addresses */
9498 +#define SBTMH_GCR 0x20000000 /* gated clock request */
9499 +#define SBTMH_BISTF 0x40000000 /* bist failed */
9500 +#define SBTMH_BISTD 0x80000000 /* bist done */
9504 +#define SBBWA_TAB0_MASK 0xffff /* lookup table 0 */
9505 +#define SBBWA_TAB1_MASK 0xffff /* lookup table 1 */
9506 +#define SBBWA_TAB1_SHIFT 16
9508 +/* sbimconfiglow */
9509 +#define SBIMCL_STO_MASK 0x7 /* service timeout */
9510 +#define SBIMCL_RTO_MASK 0x70 /* request timeout */
9511 +#define SBIMCL_RTO_SHIFT 4
9512 +#define SBIMCL_CID_MASK 0xff0000 /* connection id */
9513 +#define SBIMCL_CID_SHIFT 16
9515 +/* sbimconfighigh */
9516 +#define SBIMCH_IEM_MASK 0xc /* inband error mode */
9517 +#define SBIMCH_TEM_MASK 0x30 /* timeout error mode */
9518 +#define SBIMCH_TEM_SHIFT 4
9519 +#define SBIMCH_BEM_MASK 0xc0 /* bus error mode */
9520 +#define SBIMCH_BEM_SHIFT 6
9523 +#define SBAM_TYPE_MASK 0x3 /* address type */
9524 +#define SBAM_AD64 0x4 /* reserved */
9525 +#define SBAM_ADINT0_MASK 0xf8 /* type0 size */
9526 +#define SBAM_ADINT0_SHIFT 3
9527 +#define SBAM_ADINT1_MASK 0x1f8 /* type1 size */
9528 +#define SBAM_ADINT1_SHIFT 3
9529 +#define SBAM_ADINT2_MASK 0x1f8 /* type2 size */
9530 +#define SBAM_ADINT2_SHIFT 3
9531 +#define SBAM_ADEN 0x400 /* enable */
9532 +#define SBAM_ADNEG 0x800 /* negative decode */
9533 +#define SBAM_BASE0_MASK 0xffffff00 /* type0 base address */
9534 +#define SBAM_BASE0_SHIFT 8
9535 +#define SBAM_BASE1_MASK 0xfffff000 /* type1 base address for the core */
9536 +#define SBAM_BASE1_SHIFT 12
9537 +#define SBAM_BASE2_MASK 0xffff0000 /* type2 base address for the core */
9538 +#define SBAM_BASE2_SHIFT 16
9540 +/* sbtmconfiglow */
9541 +#define SBTMCL_CD_MASK 0xff /* clock divide */
9542 +#define SBTMCL_CO_MASK 0xf800 /* clock offset */
9543 +#define SBTMCL_CO_SHIFT 11
9544 +#define SBTMCL_IF_MASK 0xfc0000 /* interrupt flags */
9545 +#define SBTMCL_IF_SHIFT 18
9546 +#define SBTMCL_IM_MASK 0x3000000 /* interrupt mode */
9547 +#define SBTMCL_IM_SHIFT 24
9549 +/* sbtmconfighigh */
9550 +#define SBTMCH_BM_MASK 0x3 /* busy mode */
9551 +#define SBTMCH_RM_MASK 0x3 /* retry mode */
9552 +#define SBTMCH_RM_SHIFT 2
9553 +#define SBTMCH_SM_MASK 0x30 /* stop mode */
9554 +#define SBTMCH_SM_SHIFT 4
9555 +#define SBTMCH_EM_MASK 0x300 /* sb error mode */
9556 +#define SBTMCH_EM_SHIFT 8
9557 +#define SBTMCH_IM_MASK 0xc00 /* int mode */
9558 +#define SBTMCH_IM_SHIFT 10
9561 +#define SBBC_LAT_MASK 0x3 /* sb latency */
9562 +#define SBBC_MAX0_MASK 0xf0000 /* maxccntr0 */
9563 +#define SBBC_MAX0_SHIFT 16
9564 +#define SBBC_MAX1_MASK 0xf00000 /* maxccntr1 */
9565 +#define SBBC_MAX1_SHIFT 20
9568 +#define SBBS_SRD 0x1 /* st reg disable */
9569 +#define SBBS_HRD 0x2 /* hold reg disable */
9572 +#define SBIDL_CS_MASK 0x3 /* config space */
9573 +#define SBIDL_AR_MASK 0x38 /* # address ranges supported */
9574 +#define SBIDL_AR_SHIFT 3
9575 +#define SBIDL_SYNCH 0x40 /* sync */
9576 +#define SBIDL_INIT 0x80 /* initiator */
9577 +#define SBIDL_MINLAT_MASK 0xf00 /* minimum backplane latency */
9578 +#define SBIDL_MINLAT_SHIFT 8
9579 +#define SBIDL_MAXLAT 0xf000 /* maximum backplane latency */
9580 +#define SBIDL_MAXLAT_SHIFT 12
9581 +#define SBIDL_FIRST 0x10000 /* this initiator is first */
9582 +#define SBIDL_CW_MASK 0xc0000 /* cycle counter width */
9583 +#define SBIDL_CW_SHIFT 18
9584 +#define SBIDL_TP_MASK 0xf00000 /* target ports */
9585 +#define SBIDL_TP_SHIFT 20
9586 +#define SBIDL_IP_MASK 0xf000000 /* initiator ports */
9587 +#define SBIDL_IP_SHIFT 24
9588 +#define SBIDL_RV_MASK 0xf0000000 /* sonics backplane revision code */
9589 +#define SBIDL_RV_SHIFT 28
9590 +#define SBIDL_RV_2_2 0x00000000 /* version 2.2 or earlier */
9591 +#define SBIDL_RV_2_3 0x10000000 /* version 2.3 */
9594 +#define SBIDH_RC_MASK 0x000f /* revision code */
9595 +#define SBIDH_RCE_MASK 0x7000 /* revision code extension field */
9596 +#define SBIDH_RCE_SHIFT 8
9597 +#define SBCOREREV(sbidh) \
9598 + ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | ((sbidh) & SBIDH_RC_MASK))
9599 +#define SBIDH_CC_MASK 0x8ff0 /* core code */
9600 +#define SBIDH_CC_SHIFT 4
9601 +#define SBIDH_VC_MASK 0xffff0000 /* vendor code */
9602 +#define SBIDH_VC_SHIFT 16
9604 +#define SB_COMMIT 0xfd8 /* update buffered registers value */
9607 +#define SB_VEND_BCM 0x4243 /* Broadcom's SB vendor code */
9610 +#define SB_CC 0x800 /* chipcommon core */
9611 +#define SB_ILINE20 0x801 /* iline20 core */
9612 +#define SB_SDRAM 0x803 /* sdram core */
9613 +#define SB_PCI 0x804 /* pci core */
9614 +#define SB_MIPS 0x805 /* mips core */
9615 +#define SB_ENET 0x806 /* enet mac core */
9616 +#define SB_CODEC 0x807 /* v90 codec core */
9617 +#define SB_USB 0x808 /* usb 1.1 host/device core */
9618 +#define SB_ADSL 0x809 /* ADSL core */
9619 +#define SB_ILINE100 0x80a /* iline100 core */
9620 +#define SB_IPSEC 0x80b /* ipsec core */
9621 +#define SB_PCMCIA 0x80d /* pcmcia core */
9622 +#define SB_SOCRAM 0x80e /* internal memory core */
9623 +#define SB_MEMC 0x80f /* memc sdram core */
9624 +#define SB_EXTIF 0x811 /* external interface core */
9625 +#define SB_D11 0x812 /* 802.11 MAC core */
9626 +#define SB_MIPS33 0x816 /* mips3302 core */
9627 +#define SB_USB11H 0x817 /* usb 1.1 host core */
9628 +#define SB_USB11D 0x818 /* usb 1.1 device core */
9629 +#define SB_USB20H 0x819 /* usb 2.0 host core */
9630 +#define SB_USB20D 0x81a /* usb 2.0 device core */
9631 +#define SB_SDIOH 0x81b /* sdio host core */
9632 +#define SB_ROBO 0x81c /* roboswitch core */
9633 +#define SB_ATA100 0x81d /* parallel ATA core */
9634 +#define SB_SATAXOR 0x81e /* serial ATA & XOR DMA core */
9635 +#define SB_GIGETH 0x81f /* gigabit ethernet core */
9636 +#define SB_PCIE 0x820 /* pci express core */
9637 +#define SB_SRAMC 0x822 /* SRAM controller core */
9638 +#define SB_MINIMAC 0x823 /* MINI MAC/phy core */
9640 +#define SB_CC_IDX 0 /* chipc, when present, is always core 0 */
9642 +/* Not really related to Silicon Backplane, but a couple of software
9643 + * conventions for the use the flash space:
9646 +/* Minumum amount of flash we support */
9647 +#define FLASH_MIN 0x00020000 /* Minimum flash size */
9649 +/* A boot/binary may have an embedded block that describes its size */
9650 +#define BISZ_OFFSET 0x3e0 /* At this offset into the binary */
9651 +#define BISZ_MAGIC 0x4249535a /* Marked with this value: 'BISZ' */
9652 +#define BISZ_MAGIC_IDX 0 /* Word 0: magic */
9653 +#define BISZ_TXTST_IDX 1 /* 1: text start */
9654 +#define BISZ_TXTEND_IDX 2 /* 2: text start */
9655 +#define BISZ_DATAST_IDX 3 /* 3: text start */
9656 +#define BISZ_DATAEND_IDX 4 /* 4: text start */
9657 +#define BISZ_BSSST_IDX 5 /* 5: text start */
9658 +#define BISZ_BSSEND_IDX 6 /* 6: text start */
9659 +#define BISZ_SIZE 7 /* descriptor size in 32-bit intergers */
9661 +#endif /* _SBCONFIG_H */
9662 diff -urN linux.old/arch/mips/bcm947xx/include/sbextif.h linux.dev/arch/mips/bcm947xx/include/sbextif.h
9663 --- linux.old/arch/mips/bcm947xx/include/sbextif.h 1970-01-01 01:00:00.000000000 +0100
9664 +++ linux.dev/arch/mips/bcm947xx/include/sbextif.h 2005-12-15 16:48:55.651993750 +0100
9667 + * Hardware-specific External Interface I/O core definitions
9668 + * for the BCM47xx family of SiliconBackplane-based chips.
9670 + * The External Interface core supports a total of three external chip selects
9671 + * supporting external interfaces. One of the external chip selects is
9672 + * used for Flash, one is used for PCMCIA, and the other may be
9673 + * programmed to support either a synchronous interface or an
9674 + * asynchronous interface. The asynchronous interface can be used to
9675 + * support external devices such as UARTs and the BCM2019 Bluetooth
9676 + * baseband processor.
9677 + * The external interface core also contains 2 on-chip 16550 UARTs, clock
9678 + * frequency control, a watchdog interrupt timer, and a GPIO interface.
9680 + * Copyright 2005, Broadcom Corporation
9681 + * All Rights Reserved.
9683 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9684 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9685 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9686 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9693 +/* external interface address space */
9694 +#define EXTIF_PCMCIA_MEMBASE(x) (x)
9695 +#define EXTIF_PCMCIA_IOBASE(x) ((x) + 0x100000)
9696 +#define EXTIF_PCMCIA_CFGBASE(x) ((x) + 0x200000)
9697 +#define EXTIF_CFGIF_BASE(x) ((x) + 0x800000)
9698 +#define EXTIF_FLASH_BASE(x) ((x) + 0xc00000)
9700 +/* cpp contortions to concatenate w/arg prescan */
9702 +#define _PADLINE(line) pad ## line
9703 +#define _XSTR(line) _PADLINE(line)
9704 +#define PAD _XSTR(__LINE__)
9708 + * The multiple instances of output and output enable registers
9709 + * are present to allow driver software for multiple cores to control
9710 + * gpio outputs without needing to share a single register pair.
9716 +#define NGPIOUSER 5
9718 +typedef volatile struct {
9719 + uint32 corecontrol;
9723 + /* pcmcia control registers */
9724 + uint32 pcmcia_config;
9725 + uint32 pcmcia_memwait;
9726 + uint32 pcmcia_attrwait;
9727 + uint32 pcmcia_iowait;
9729 + /* programmable interface control registers */
9730 + uint32 prog_config;
9731 + uint32 prog_waitcount;
9733 + /* flash control registers */
9734 + uint32 flash_config;
9735 + uint32 flash_waitcount;
9740 + /* clock control */
9741 + uint32 clockcontrol_n;
9742 + uint32 clockcontrol_sb;
9743 + uint32 clockcontrol_pci;
9744 + uint32 clockcontrol_mii;
9749 + struct gpiouser gpio[NGPIOUSER];
9751 + uint32 ejtagouten;
9752 + uint32 gpiointpolarity;
9753 + uint32 gpiointmask;
9770 + uint8 uartscratch;
9775 +#define CC_UE (1 << 0) /* uart enable */
9778 +#define ES_EM (1 << 0) /* endian mode (ro) */
9779 +#define ES_EI (1 << 1) /* external interrupt pin (ro) */
9780 +#define ES_GI (1 << 2) /* gpio interrupt pin (ro) */
9782 +/* gpio bit mask */
9783 +#define GPIO_BIT0 (1 << 0)
9784 +#define GPIO_BIT1 (1 << 1)
9785 +#define GPIO_BIT2 (1 << 2)
9786 +#define GPIO_BIT3 (1 << 3)
9787 +#define GPIO_BIT4 (1 << 4)
9788 +#define GPIO_BIT5 (1 << 5)
9789 +#define GPIO_BIT6 (1 << 6)
9790 +#define GPIO_BIT7 (1 << 7)
9793 +/* pcmcia/prog/flash_config */
9794 +#define CF_EN (1 << 0) /* enable */
9795 +#define CF_EM_MASK 0xe /* mode */
9796 +#define CF_EM_SHIFT 1
9797 +#define CF_EM_FLASH 0x0 /* flash/asynchronous mode */
9798 +#define CF_EM_SYNC 0x2 /* synchronous mode */
9799 +#define CF_EM_PCMCIA 0x4 /* pcmcia mode */
9800 +#define CF_DS (1 << 4) /* destsize: 0=8bit, 1=16bit */
9801 +#define CF_BS (1 << 5) /* byteswap */
9802 +#define CF_CD_MASK 0xc0 /* clock divider */
9803 +#define CF_CD_SHIFT 6
9804 +#define CF_CD_DIV2 0x0 /* backplane/2 */
9805 +#define CF_CD_DIV3 0x40 /* backplane/3 */
9806 +#define CF_CD_DIV4 0x80 /* backplane/4 */
9807 +#define CF_CE (1 << 8) /* clock enable */
9808 +#define CF_SB (1 << 9) /* size/bytestrobe (synch only) */
9810 +/* pcmcia_memwait */
9811 +#define PM_W0_MASK 0x3f /* waitcount0 */
9812 +#define PM_W1_MASK 0x1f00 /* waitcount1 */
9813 +#define PM_W1_SHIFT 8
9814 +#define PM_W2_MASK 0x1f0000 /* waitcount2 */
9815 +#define PM_W2_SHIFT 16
9816 +#define PM_W3_MASK 0x1f000000 /* waitcount3 */
9817 +#define PM_W3_SHIFT 24
9819 +/* pcmcia_attrwait */
9820 +#define PA_W0_MASK 0x3f /* waitcount0 */
9821 +#define PA_W1_MASK 0x1f00 /* waitcount1 */
9822 +#define PA_W1_SHIFT 8
9823 +#define PA_W2_MASK 0x1f0000 /* waitcount2 */
9824 +#define PA_W2_SHIFT 16
9825 +#define PA_W3_MASK 0x1f000000 /* waitcount3 */
9826 +#define PA_W3_SHIFT 24
9828 +/* pcmcia_iowait */
9829 +#define PI_W0_MASK 0x3f /* waitcount0 */
9830 +#define PI_W1_MASK 0x1f00 /* waitcount1 */
9831 +#define PI_W1_SHIFT 8
9832 +#define PI_W2_MASK 0x1f0000 /* waitcount2 */
9833 +#define PI_W2_SHIFT 16
9834 +#define PI_W3_MASK 0x1f000000 /* waitcount3 */
9835 +#define PI_W3_SHIFT 24
9837 +/* prog_waitcount */
9838 +#define PW_W0_MASK 0x0000001f /* waitcount0 */
9839 +#define PW_W1_MASK 0x00001f00 /* waitcount1 */
9840 +#define PW_W1_SHIFT 8
9841 +#define PW_W2_MASK 0x001f0000 /* waitcount2 */
9842 +#define PW_W2_SHIFT 16
9843 +#define PW_W3_MASK 0x1f000000 /* waitcount3 */
9844 +#define PW_W3_SHIFT 24
9846 +#define PW_W0 0x0000000c
9847 +#define PW_W1 0x00000a00
9848 +#define PW_W2 0x00020000
9849 +#define PW_W3 0x01000000
9851 +/* flash_waitcount */
9852 +#define FW_W0_MASK 0x1f /* waitcount0 */
9853 +#define FW_W1_MASK 0x1f00 /* waitcount1 */
9854 +#define FW_W1_SHIFT 8
9855 +#define FW_W2_MASK 0x1f0000 /* waitcount2 */
9856 +#define FW_W2_SHIFT 16
9857 +#define FW_W3_MASK 0x1f000000 /* waitcount3 */
9858 +#define FW_W3_SHIFT 24
9861 +#define WATCHDOG_CLOCK 48000000 /* Hz */
9863 +/* clockcontrol_n */
9864 +#define CN_N1_MASK 0x3f /* n1 control */
9865 +#define CN_N2_MASK 0x3f00 /* n2 control */
9866 +#define CN_N2_SHIFT 8
9868 +/* clockcontrol_sb/pci/mii */
9869 +#define CC_M1_MASK 0x3f /* m1 control */
9870 +#define CC_M2_MASK 0x3f00 /* m2 control */
9871 +#define CC_M2_SHIFT 8
9872 +#define CC_M3_MASK 0x3f0000 /* m3 control */
9873 +#define CC_M3_SHIFT 16
9874 +#define CC_MC_MASK 0x1f000000 /* mux control */
9875 +#define CC_MC_SHIFT 24
9877 +/* Clock control default values */
9878 +#define CC_DEF_N 0x0009 /* Default values for bcm4710 */
9879 +#define CC_DEF_100 0x04020011
9880 +#define CC_DEF_33 0x11030011
9881 +#define CC_DEF_25 0x11050011
9883 +/* Clock control values for 125Mhz */
9884 +#define CC_125_N 0x0802
9885 +#define CC_125_M 0x04020009
9886 +#define CC_125_M25 0x11090009
9887 +#define CC_125_M33 0x11090005
9889 +/* Clock control magic field values */
9890 +#define CC_F6_2 0x02 /* A factor of 2 in */
9891 +#define CC_F6_3 0x03 /* 6-bit fields like */
9892 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
9893 +#define CC_F6_5 0x09
9894 +#define CC_F6_6 0x11
9895 +#define CC_F6_7 0x21
9897 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
9899 +#define CC_MC_BYPASS 0x08
9900 +#define CC_MC_M1 0x04
9901 +#define CC_MC_M1M2 0x02
9902 +#define CC_MC_M1M2M3 0x01
9903 +#define CC_MC_M1M3 0x11
9905 +#define CC_CLOCK_BASE 24000000 /* Half the clock freq. in the 4710 */
9907 +#endif /* _SBEXTIF_H */
9908 diff -urN linux.old/arch/mips/bcm947xx/include/sbmemc.h linux.dev/arch/mips/bcm947xx/include/sbmemc.h
9909 --- linux.old/arch/mips/bcm947xx/include/sbmemc.h 1970-01-01 01:00:00.000000000 +0100
9910 +++ linux.dev/arch/mips/bcm947xx/include/sbmemc.h 2005-12-15 15:35:31.567254500 +0100
9913 + * BCM47XX Sonics SiliconBackplane DDR/SDRAM controller core hardware definitions.
9915 + * Copyright 2005, Broadcom Corporation
9916 + * All Rights Reserved.
9918 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9919 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9920 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9921 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9929 +#ifdef _LANGUAGE_ASSEMBLY
9931 +#define MEMC_CONTROL 0x00
9932 +#define MEMC_CONFIG 0x04
9933 +#define MEMC_REFRESH 0x08
9934 +#define MEMC_BISTSTAT 0x0c
9935 +#define MEMC_MODEBUF 0x10
9936 +#define MEMC_BKCLS 0x14
9937 +#define MEMC_PRIORINV 0x18
9938 +#define MEMC_DRAMTIM 0x1c
9939 +#define MEMC_INTSTAT 0x20
9940 +#define MEMC_INTMASK 0x24
9941 +#define MEMC_INTINFO 0x28
9942 +#define MEMC_NCDLCTL 0x30
9943 +#define MEMC_RDNCDLCOR 0x34
9944 +#define MEMC_WRNCDLCOR 0x38
9945 +#define MEMC_MISCDLYCTL 0x3c
9946 +#define MEMC_DQSGATENCDL 0x40
9947 +#define MEMC_SPARE 0x44
9948 +#define MEMC_TPADDR 0x48
9949 +#define MEMC_TPDATA 0x4c
9950 +#define MEMC_BARRIER 0x50
9951 +#define MEMC_CORE 0x54
9956 +/* Sonics side: MEMC core registers */
9957 +typedef volatile struct sbmemcregs {
9973 + uint32 miscdlyctl;
9974 + uint32 dqsgatencdl;
9984 +/* MEMC Core Init values (OCP ID 0x80f) */
9987 +#define MEMC_SD_CONFIG_INIT 0x00048000
9988 +#define MEMC_SD_DRAMTIM2_INIT 0x000754d8
9989 +#define MEMC_SD_DRAMTIM3_INIT 0x000754da
9990 +#define MEMC_SD_RDNCDLCOR_INIT 0x00000000
9991 +#define MEMC_SD_WRNCDLCOR_INIT 0x49351200
9992 +#define MEMC_SD1_WRNCDLCOR_INIT 0x14500200 /* For corerev 1 (4712) */
9993 +#define MEMC_SD_MISCDLYCTL_INIT 0x00061c1b
9994 +#define MEMC_SD1_MISCDLYCTL_INIT 0x00021416 /* For corerev 1 (4712) */
9995 +#define MEMC_SD_CONTROL_INIT0 0x00000002
9996 +#define MEMC_SD_CONTROL_INIT1 0x00000008
9997 +#define MEMC_SD_CONTROL_INIT2 0x00000004
9998 +#define MEMC_SD_CONTROL_INIT3 0x00000010
9999 +#define MEMC_SD_CONTROL_INIT4 0x00000001
10000 +#define MEMC_SD_MODEBUF_INIT 0x00000000
10001 +#define MEMC_SD_REFRESH_INIT 0x0000840f
10004 +/* This is for SDRM8X8X4 */
10005 +#define MEMC_SDR_INIT 0x0008
10006 +#define MEMC_SDR_MODE 0x32
10007 +#define MEMC_SDR_NCDL 0x00020032
10008 +#define MEMC_SDR1_NCDL 0x0002020f /* For corerev 1 (4712) */
10011 +#define MEMC_CONFIG_INIT 0x00048000
10012 +#define MEMC_DRAMTIM2_INIT 0x000754d8
10013 +#define MEMC_DRAMTIM25_INIT 0x000754d9
10014 +#define MEMC_RDNCDLCOR_INIT 0x00000000
10015 +#define MEMC_RDNCDLCOR_SIMINIT 0xf6f6f6f6 /* For hdl sim */
10016 +#define MEMC_WRNCDLCOR_INIT 0x49351200
10017 +#define MEMC_1_WRNCDLCOR_INIT 0x14500200
10018 +#define MEMC_DQSGATENCDL_INIT 0x00030000
10019 +#define MEMC_MISCDLYCTL_INIT 0x21061c1b
10020 +#define MEMC_1_MISCDLYCTL_INIT 0x21021400
10021 +#define MEMC_NCDLCTL_INIT 0x00002001
10022 +#define MEMC_CONTROL_INIT0 0x00000002
10023 +#define MEMC_CONTROL_INIT1 0x00000008
10024 +#define MEMC_MODEBUF_INIT0 0x00004000
10025 +#define MEMC_CONTROL_INIT2 0x00000010
10026 +#define MEMC_MODEBUF_INIT1 0x00000100
10027 +#define MEMC_CONTROL_INIT3 0x00000010
10028 +#define MEMC_CONTROL_INIT4 0x00000008
10029 +#define MEMC_REFRESH_INIT 0x0000840f
10030 +#define MEMC_CONTROL_INIT5 0x00000004
10031 +#define MEMC_MODEBUF_INIT2 0x00000000
10032 +#define MEMC_CONTROL_INIT6 0x00000010
10033 +#define MEMC_CONTROL_INIT7 0x00000001
10036 +/* This is for DDRM16X16X2 */
10037 +#define MEMC_DDR_INIT 0x0009
10038 +#define MEMC_DDR_MODE 0x62
10039 +#define MEMC_DDR_NCDL 0x0005050a
10040 +#define MEMC_DDR1_NCDL 0x00000a0a /* For corerev 1 (4712) */
10042 +/* mask for sdr/ddr calibration registers */
10043 +#define MEMC_RDNCDLCOR_RD_MASK 0x000000ff
10044 +#define MEMC_WRNCDLCOR_WR_MASK 0x000000ff
10045 +#define MEMC_DQSGATENCDL_G_MASK 0x000000ff
10047 +/* masks for miscdlyctl registers */
10048 +#define MEMC_MISC_SM_MASK 0x30000000
10049 +#define MEMC_MISC_SM_SHIFT 28
10050 +#define MEMC_MISC_SD_MASK 0x0f000000
10051 +#define MEMC_MISC_SD_SHIFT 24
10053 +/* hw threshhold for calculating wr/rd for sdr memc */
10054 +#define MEMC_CD_THRESHOLD 128
10056 +/* Low bit of init register says if memc is ddr or sdr */
10057 +#define MEMC_CONFIG_DDR 0x00000001
10059 +#endif /* _SBMEMC_H */
10060 diff -urN linux.old/arch/mips/bcm947xx/include/sbmips.h linux.dev/arch/mips/bcm947xx/include/sbmips.h
10061 --- linux.old/arch/mips/bcm947xx/include/sbmips.h 1970-01-01 01:00:00.000000000 +0100
10062 +++ linux.dev/arch/mips/bcm947xx/include/sbmips.h 2005-12-15 16:46:57.616617000 +0100
10065 + * Broadcom SiliconBackplane MIPS definitions
10067 + * SB MIPS cores are custom MIPS32 processors with SiliconBackplane
10068 + * OCP interfaces. The CP0 processor ID is 0x00024000, where bits
10069 + * 23:16 mean Broadcom and bits 15:8 mean a MIPS core with an OCP
10070 + * interface. The core revision is stored in the SB ID register in SB
10071 + * configuration space.
10073 + * Copyright 2005, Broadcom Corporation
10074 + * All Rights Reserved.
10076 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10077 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10078 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10079 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10087 +#include <mipsinc.h>
10089 +#ifndef _LANGUAGE_ASSEMBLY
10091 +/* cpp contortions to concatenate w/arg prescan */
10093 +#define _PADLINE(line) pad ## line
10094 +#define _XSTR(line) _PADLINE(line)
10095 +#define PAD _XSTR(__LINE__)
10098 +typedef volatile struct {
10099 + uint32 corecontrol;
10101 + uint32 biststatus;
10103 + uint32 intstatus;
10108 +extern uint32 sb_flag(sb_t *sbh);
10109 +extern uint sb_irq(sb_t *sbh);
10111 +extern void BCMINIT(sb_serial_init)(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift));
10113 +extern void *sb_jtagm_init(sb_t *sbh, uint clkd, bool exttap);
10114 +extern void sb_jtagm_disable(void *h);
10115 +extern uint32 jtag_rwreg(void *h, uint32 ir, uint32 dr);
10116 +extern void BCMINIT(sb_mips_init)(sb_t *sbh);
10117 +extern uint32 BCMINIT(sb_mips_clock)(sb_t *sbh);
10118 +extern bool BCMINIT(sb_mips_setclock)(sb_t *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock);
10119 +extern void BCMINIT(enable_pfc)(uint32 mode);
10120 +extern uint32 BCMINIT(sb_memc_get_ncdl)(sb_t *sbh);
10123 +#endif /* _LANGUAGE_ASSEMBLY */
10125 +#endif /* _SBMIPS_H */
10126 diff -urN linux.old/arch/mips/bcm947xx/include/sbpci.h linux.dev/arch/mips/bcm947xx/include/sbpci.h
10127 --- linux.old/arch/mips/bcm947xx/include/sbpci.h 1970-01-01 01:00:00.000000000 +0100
10128 +++ linux.dev/arch/mips/bcm947xx/include/sbpci.h 2005-12-15 15:35:36.795581250 +0100
10131 + * BCM47XX Sonics SiliconBackplane PCI core hardware definitions.
10134 + * Copyright 2005, Broadcom Corporation
10135 + * All Rights Reserved.
10137 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10138 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10139 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10140 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10146 +/* cpp contortions to concatenate w/arg prescan */
10148 +#define _PADLINE(line) pad ## line
10149 +#define _XSTR(line) _PADLINE(line)
10150 +#define PAD _XSTR(__LINE__)
10153 +/* Sonics side: PCI core and host control registers */
10154 +typedef struct sbpciregs {
10155 + uint32 control; /* PCI control */
10157 + uint32 arbcontrol; /* PCI arbiter control */
10159 + uint32 intstatus; /* Interrupt status */
10160 + uint32 intmask; /* Interrupt mask */
10161 + uint32 sbtopcimailbox; /* Sonics to PCI mailbox */
10163 + uint32 bcastaddr; /* Sonics broadcast address */
10164 + uint32 bcastdata; /* Sonics broadcast data */
10166 + uint32 gpioin; /* ro: gpio input (>=rev2) */
10167 + uint32 gpioout; /* rw: gpio output (>=rev2) */
10168 + uint32 gpioouten; /* rw: gpio output enable (>= rev2) */
10169 + uint32 gpiocontrol; /* rw: gpio control (>= rev2) */
10171 + uint32 sbtopci0; /* Sonics to PCI translation 0 */
10172 + uint32 sbtopci1; /* Sonics to PCI translation 1 */
10173 + uint32 sbtopci2; /* Sonics to PCI translation 2 */
10175 + uint16 sprom[36]; /* SPROM shadow Area */
10180 +#define PCI_RST_OE 0x01 /* When set, drives PCI_RESET out to pin */
10181 +#define PCI_RST 0x02 /* Value driven out to pin */
10182 +#define PCI_CLK_OE 0x04 /* When set, drives clock as gated by PCI_CLK out to pin */
10183 +#define PCI_CLK 0x08 /* Gate for clock driven out to pin */
10185 +/* PCI arbiter control */
10186 +#define PCI_INT_ARB 0x01 /* When set, use an internal arbiter */
10187 +#define PCI_EXT_ARB 0x02 /* When set, use an external arbiter */
10188 +#define PCI_PARKID_MASK 0x06 /* Selects which agent is parked on an idle bus */
10189 +#define PCI_PARKID_SHIFT 1
10190 +#define PCI_PARKID_LAST 0 /* Last requestor */
10191 +#define PCI_PARKID_4710 1 /* 4710 */
10192 +#define PCI_PARKID_EXTREQ0 2 /* External requestor 0 */
10193 +#define PCI_PARKID_EXTREQ1 3 /* External requestor 1 */
10195 +/* Interrupt status/mask */
10196 +#define PCI_INTA 0x01 /* PCI INTA# is asserted */
10197 +#define PCI_INTB 0x02 /* PCI INTB# is asserted */
10198 +#define PCI_SERR 0x04 /* PCI SERR# has been asserted (write one to clear) */
10199 +#define PCI_PERR 0x08 /* PCI PERR# has been asserted (write one to clear) */
10200 +#define PCI_PME 0x10 /* PCI PME# is asserted */
10202 +/* (General) PCI/SB mailbox interrupts, two bits per pci function */
10203 +#define MAILBOX_F0_0 0x100 /* function 0, int 0 */
10204 +#define MAILBOX_F0_1 0x200 /* function 0, int 1 */
10205 +#define MAILBOX_F1_0 0x400 /* function 1, int 0 */
10206 +#define MAILBOX_F1_1 0x800 /* function 1, int 1 */
10207 +#define MAILBOX_F2_0 0x1000 /* function 2, int 0 */
10208 +#define MAILBOX_F2_1 0x2000 /* function 2, int 1 */
10209 +#define MAILBOX_F3_0 0x4000 /* function 3, int 0 */
10210 +#define MAILBOX_F3_1 0x8000 /* function 3, int 1 */
10212 +/* Sonics broadcast address */
10213 +#define BCAST_ADDR_MASK 0xff /* Broadcast register address */
10215 +/* Sonics to PCI translation types */
10216 +#define SBTOPCI0_MASK 0xfc000000
10217 +#define SBTOPCI1_MASK 0xfc000000
10218 +#define SBTOPCI2_MASK 0xc0000000
10219 +#define SBTOPCI_MEM 0
10220 +#define SBTOPCI_IO 1
10221 +#define SBTOPCI_CFG0 2
10222 +#define SBTOPCI_CFG1 3
10223 +#define SBTOPCI_PREF 0x4 /* prefetch enable */
10224 +#define SBTOPCI_BURST 0x8 /* burst enable */
10225 +#define SBTOPCI_RC_MASK 0x30 /* read command (>= rev11) */
10226 +#define SBTOPCI_RC_READ 0x00 /* memory read */
10227 +#define SBTOPCI_RC_READLINE 0x10 /* memory read line */
10228 +#define SBTOPCI_RC_READMULTI 0x20 /* memory read multiple */
10230 +/* PCI core index in SROM shadow area */
10231 +#define SRSH_PI_OFFSET 0 /* first word */
10232 +#define SRSH_PI_MASK 0xf000 /* bit 15:12 */
10233 +#define SRSH_PI_SHIFT 12 /* bit 15:12 */
10235 +/* PCI side: Reserved PCI configuration registers (see pcicfg.h) */
10236 +#define cap_list rsvd_a[0]
10237 +#define bar0_window dev_dep[0x80 - 0x40]
10238 +#define bar1_window dev_dep[0x84 - 0x40]
10239 +#define sprom_control dev_dep[0x88 - 0x40]
10241 +#ifndef _LANGUAGE_ASSEMBLY
10243 +extern int sbpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
10244 +extern int sbpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
10245 +extern void sbpci_ban(uint16 core);
10246 +extern int sbpci_init(sb_t *sbh);
10247 +extern void sbpci_check(sb_t *sbh);
10249 +#endif /* !_LANGUAGE_ASSEMBLY */
10251 +#endif /* _SBPCI_H */
10252 diff -urN linux.old/arch/mips/bcm947xx/include/sbsdram.h linux.dev/arch/mips/bcm947xx/include/sbsdram.h
10253 --- linux.old/arch/mips/bcm947xx/include/sbsdram.h 1970-01-01 01:00:00.000000000 +0100
10254 +++ linux.dev/arch/mips/bcm947xx/include/sbsdram.h 2005-12-15 15:35:40.175792500 +0100
10257 + * BCM47XX Sonics SiliconBackplane SDRAM controller core hardware definitions.
10259 + * Copyright 2005, Broadcom Corporation
10260 + * All Rights Reserved.
10262 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10263 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10264 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10265 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10269 +#ifndef _SBSDRAM_H
10270 +#define _SBSDRAM_H
10272 +#ifndef _LANGUAGE_ASSEMBLY
10274 +/* Sonics side: SDRAM core registers */
10275 +typedef volatile struct sbsdramregs {
10276 + uint32 initcontrol; /* Generates external SDRAM initialization sequence */
10277 + uint32 config; /* Initializes external SDRAM mode register */
10278 + uint32 refresh; /* Controls external SDRAM refresh rate */
10285 +/* SDRAM initialization control (initcontrol) register bits */
10286 +#define SDRAM_CBR 0x0001 /* Writing 1 generates refresh cycle and toggles bit */
10287 +#define SDRAM_PRE 0x0002 /* Writing 1 generates precharge cycle and toggles bit */
10288 +#define SDRAM_MRS 0x0004 /* Writing 1 generates mode register select cycle and toggles bit */
10289 +#define SDRAM_EN 0x0008 /* When set, enables access to SDRAM */
10290 +#define SDRAM_16Mb 0x0000 /* Use 16 Megabit SDRAM */
10291 +#define SDRAM_64Mb 0x0010 /* Use 64 Megabit SDRAM */
10292 +#define SDRAM_128Mb 0x0020 /* Use 128 Megabit SDRAM */
10293 +#define SDRAM_RSVMb 0x0030 /* Use special SDRAM */
10294 +#define SDRAM_RST 0x0080 /* Writing 1 causes soft reset of controller */
10295 +#define SDRAM_SELFREF 0x0100 /* Writing 1 enables self refresh mode */
10296 +#define SDRAM_PWRDOWN 0x0200 /* Writing 1 causes controller to power down */
10297 +#define SDRAM_32BIT 0x0400 /* When set, indicates 32 bit SDRAM interface */
10298 +#define SDRAM_9BITCOL 0x0800 /* When set, indicates 9 bit column */
10300 +/* SDRAM configuration (config) register bits */
10301 +#define SDRAM_BURSTFULL 0x0000 /* Use full page bursts */
10302 +#define SDRAM_BURST8 0x0001 /* Use burst of 8 */
10303 +#define SDRAM_BURST4 0x0002 /* Use burst of 4 */
10304 +#define SDRAM_BURST2 0x0003 /* Use burst of 2 */
10305 +#define SDRAM_CAS3 0x0000 /* Use CAS latency of 3 */
10306 +#define SDRAM_CAS2 0x0004 /* Use CAS latency of 2 */
10308 +/* SDRAM refresh control (refresh) register bits */
10309 +#define SDRAM_REF(p) (((p)&0xff) | SDRAM_REF_EN) /* Refresh period */
10310 +#define SDRAM_REF_EN 0x8000 /* Writing 1 enables periodic refresh */
10312 +/* SDRAM Core default Init values (OCP ID 0x803) */
10313 +#define SDRAM_INIT MEM4MX16X2
10314 +#define SDRAM_CONFIG SDRAM_BURSTFULL
10315 +#define SDRAM_REFRESH SDRAM_REF(0x40)
10317 +#define MEM1MX16 0x009 /* 2 MB */
10318 +#define MEM1MX16X2 0x409 /* 4 MB */
10319 +#define MEM2MX8X2 0x809 /* 4 MB */
10320 +#define MEM2MX8X4 0xc09 /* 8 MB */
10321 +#define MEM2MX32 0x439 /* 8 MB */
10322 +#define MEM4MX16 0x019 /* 8 MB */
10323 +#define MEM4MX16X2 0x419 /* 16 MB */
10324 +#define MEM8MX8X2 0x819 /* 16 MB */
10325 +#define MEM8MX16 0x829 /* 16 MB */
10326 +#define MEM4MX32 0x429 /* 16 MB */
10327 +#define MEM8MX8X4 0xc19 /* 32 MB */
10328 +#define MEM8MX16X2 0xc29 /* 32 MB */
10330 +#endif /* _SBSDRAM_H */
10331 diff -urN linux.old/arch/mips/bcm947xx/include/sbutils.h linux.dev/arch/mips/bcm947xx/include/sbutils.h
10332 --- linux.old/arch/mips/bcm947xx/include/sbutils.h 1970-01-01 01:00:00.000000000 +0100
10333 +++ linux.dev/arch/mips/bcm947xx/include/sbutils.h 2005-12-15 16:00:47.404550500 +0100
10336 + * Misc utility routines for accessing chip-specific features
10337 + * of Broadcom HNBU SiliconBackplane-based chips.
10339 + * Copyright 2005, Broadcom Corporation
10340 + * All Rights Reserved.
10342 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10343 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10344 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10345 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10350 +#ifndef _sbutils_h_
10351 +#define _sbutils_h_
10354 + * Datastructure to export all chip specific common variables
10355 + * public (read-only) portion of sbutils handle returned by
10356 + * sb_attach()/sb_kattach()
10361 + uint bustype; /* SB_BUS, PCI_BUS */
10362 + uint buscoretype; /* SB_PCI, SB_PCMCIA, SB_PCIE*/
10363 + uint buscorerev; /* buscore rev */
10364 + uint buscoreidx; /* buscore index */
10365 + int ccrev; /* chip common core rev */
10366 + uint boardtype; /* board type */
10367 + uint boardvendor; /* board vendor */
10368 + uint chip; /* chip number */
10369 + uint chiprev; /* chip revision */
10370 + uint chippkg; /* chip package option */
10371 + uint sonicsrev; /* sonics backplane rev */
10374 +typedef const struct sb_pub sb_t;
10377 + * Many of the routines below take an 'sbh' handle as their first arg.
10378 + * Allocate this by calling sb_attach(). Free it by calling sb_detach().
10379 + * At any one time, the sbh is logically focused on one particular sb core
10380 + * (the "current core").
10381 + * Use sb_setcore() or sb_setcoreidx() to change the association to another core.
10384 +/* exported externs */
10385 +extern sb_t * BCMINIT(sb_attach)(uint pcidev, osl_t *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz);
10386 +extern sb_t * BCMINIT(sb_kattach)(void);
10387 +extern void sb_detach(sb_t *sbh);
10388 +extern uint BCMINIT(sb_chip)(sb_t *sbh);
10389 +extern uint BCMINIT(sb_chiprev)(sb_t *sbh);
10390 +extern uint BCMINIT(sb_chipcrev)(sb_t *sbh);
10391 +extern uint BCMINIT(sb_chippkg)(sb_t *sbh);
10392 +extern uint BCMINIT(sb_pcirev)(sb_t *sbh);
10393 +extern bool BCMINIT(sb_war16165)(sb_t *sbh);
10394 +extern uint BCMINIT(sb_boardvendor)(sb_t *sbh);
10395 +extern uint BCMINIT(sb_boardtype)(sb_t *sbh);
10396 +extern uint sb_bus(sb_t *sbh);
10397 +extern uint sb_buscoretype(sb_t *sbh);
10398 +extern uint sb_buscorerev(sb_t *sbh);
10399 +extern uint sb_corelist(sb_t *sbh, uint coreid[]);
10400 +extern uint sb_coreid(sb_t *sbh);
10401 +extern uint sb_coreidx(sb_t *sbh);
10402 +extern uint sb_coreunit(sb_t *sbh);
10403 +extern uint sb_corevendor(sb_t *sbh);
10404 +extern uint sb_corerev(sb_t *sbh);
10405 +extern void *sb_osh(sb_t *sbh);
10406 +extern void *sb_coreregs(sb_t *sbh);
10407 +extern uint32 sb_coreflags(sb_t *sbh, uint32 mask, uint32 val);
10408 +extern uint32 sb_coreflagshi(sb_t *sbh, uint32 mask, uint32 val);
10409 +extern bool sb_iscoreup(sb_t *sbh);
10410 +extern void *sb_setcoreidx(sb_t *sbh, uint coreidx);
10411 +extern void *sb_setcore(sb_t *sbh, uint coreid, uint coreunit);
10412 +extern int sb_corebist(sb_t *sbh, uint coreid, uint coreunit);
10413 +extern void sb_commit(sb_t *sbh);
10414 +extern uint32 sb_base(uint32 admatch);
10415 +extern uint32 sb_size(uint32 admatch);
10416 +extern void sb_core_reset(sb_t *sbh, uint32 bits);
10417 +extern void sb_core_tofixup(sb_t *sbh);
10418 +extern void sb_core_disable(sb_t *sbh, uint32 bits);
10419 +extern uint32 sb_clock_rate(uint32 pll_type, uint32 n, uint32 m);
10420 +extern uint32 sb_clock(sb_t *sbh);
10421 +extern void sb_pci_setup(sb_t *sbh, uint coremask);
10422 +extern void sb_watchdog(sb_t *sbh, uint ticks);
10423 +extern void *sb_gpiosetcore(sb_t *sbh);
10424 +extern uint32 sb_gpiocontrol(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10425 +extern uint32 sb_gpioouten(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10426 +extern uint32 sb_gpioout(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10427 +extern uint32 sb_gpioin(sb_t *sbh);
10428 +extern uint32 sb_gpiointpolarity(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10429 +extern uint32 sb_gpiointmask(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10430 +extern uint32 sb_gpioled(sb_t *sbh, uint32 mask, uint32 val);
10431 +extern uint32 sb_gpioreserve(sb_t *sbh, uint32 gpio_num, uint8 priority);
10432 +extern uint32 sb_gpiorelease(sb_t *sbh, uint32 gpio_num, uint8 priority);
10434 +extern void sb_clkctl_init(sb_t *sbh);
10435 +extern uint16 sb_clkctl_fast_pwrup_delay(sb_t *sbh);
10436 +extern bool sb_clkctl_clk(sb_t *sbh, uint mode);
10437 +extern int sb_clkctl_xtal(sb_t *sbh, uint what, bool on);
10438 +extern void sb_register_intr_callback(sb_t *sbh, void *intrsoff_fn,
10439 + void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg);
10440 +extern uint32 sb_set_initiator_to(sb_t *sbh, uint32 to);
10441 +extern void sb_corepciid(sb_t *sbh, uint16 *pcivendor, uint16 *pcidevice,
10442 + uint8 *pciclass, uint8 *pcisubclass, uint8 *pciprogif);
10443 +extern uint32 sb_gpiotimerval(sb_t *sbh, uint32 mask, uint32 val);
10448 +* Build device path. Path size must be >= SB_DEVPATH_BUFSZ.
10449 +* The returned path is NULL terminated and has trailing '/'.
10450 +* Return 0 on success, nonzero otherwise.
10452 +extern int sb_devpath(sb_t *sbh, char *path, int size);
10454 +/* clkctl xtal what flags */
10455 +#define XTAL 0x1 /* primary crystal oscillator (2050) */
10456 +#define PLL 0x2 /* main chip pll */
10458 +/* clkctl clk mode */
10459 +#define CLK_FAST 0 /* force fast (pll) clock */
10460 +#define CLK_DYNAMIC 2 /* enable dynamic clock control */
10463 +/* GPIO usage priorities */
10464 +#define GPIO_DRV_PRIORITY 0
10465 +#define GPIO_APP_PRIORITY 1
10468 +#define SB_DEVPATH_BUFSZ 16 /* min buffer size in bytes */
10470 +#endif /* _sbutils_h_ */
10471 diff -urN linux.old/arch/mips/bcm947xx/include/sflash.h linux.dev/arch/mips/bcm947xx/include/sflash.h
10472 --- linux.old/arch/mips/bcm947xx/include/sflash.h 1970-01-01 01:00:00.000000000 +0100
10473 +++ linux.dev/arch/mips/bcm947xx/include/sflash.h 2005-12-15 16:49:23.001703000 +0100
10476 + * Broadcom SiliconBackplane chipcommon serial flash interface
10478 + * Copyright 2005, Broadcom Corporation
10479 + * All Rights Reserved.
10481 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10482 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10483 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10484 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10489 +#ifndef _sflash_h_
10490 +#define _sflash_h_
10492 +#include <typedefs.h>
10493 +#include <sbchipc.h>
10496 + uint blocksize; /* Block size */
10497 + uint numblocks; /* Number of blocks */
10498 + uint32 type; /* Type */
10499 + uint size; /* Total size in bytes */
10502 +/* Utility functions */
10503 +extern int sflash_poll(chipcregs_t *cc, uint offset);
10504 +extern int sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf);
10505 +extern int sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
10506 +extern int sflash_erase(chipcregs_t *cc, uint offset);
10507 +extern int sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
10508 +extern struct sflash * sflash_init(chipcregs_t *cc);
10510 +#endif /* _sflash_h_ */
10511 diff -urN linux.old/arch/mips/bcm947xx/include/trxhdr.h linux.dev/arch/mips/bcm947xx/include/trxhdr.h
10512 --- linux.old/arch/mips/bcm947xx/include/trxhdr.h 1970-01-01 01:00:00.000000000 +0100
10513 +++ linux.dev/arch/mips/bcm947xx/include/trxhdr.h 2005-12-15 15:35:49.220357750 +0100
10516 + * TRX image file header format.
10518 + * Copyright 2005, Broadcom Corporation
10519 + * All Rights Reserved.
10521 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10522 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10523 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10524 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10529 +#include <typedefs.h>
10531 +#define TRX_MAGIC 0x30524448 /* "HDR0" */
10532 +#define TRX_VERSION 1
10533 +#define TRX_MAX_LEN 0x3A0000
10534 +#define TRX_NO_HEADER 1 /* Do not write TRX header */
10535 +#define TRX_GZ_FILES 0x2 /* Contains up to TRX_MAX_OFFSET individual gzip files */
10536 +#define TRX_MAX_OFFSET 3
10538 +struct trx_header {
10539 + uint32 magic; /* "HDR0" */
10540 + uint32 len; /* Length of file including header */
10541 + uint32 crc32; /* 32-bit CRC from flag_version to end of file */
10542 + uint32 flag_version; /* 0:15 flags, 16:31 version */
10543 + uint32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
10546 +/* Compatibility */
10547 +typedef struct trx_header TRXHDR, *PTRXHDR;
10548 diff -urN linux.old/arch/mips/bcm947xx/include/typedefs.h linux.dev/arch/mips/bcm947xx/include/typedefs.h
10549 --- linux.old/arch/mips/bcm947xx/include/typedefs.h 1970-01-01 01:00:00.000000000 +0100
10550 +++ linux.dev/arch/mips/bcm947xx/include/typedefs.h 2005-12-15 15:35:52.436558750 +0100
10553 + * Copyright 2005, Broadcom Corporation
10554 + * All Rights Reserved.
10556 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10557 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10558 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10559 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10563 +#ifndef _TYPEDEFS_H_
10564 +#define _TYPEDEFS_H_
10567 +/* Define 'SITE_TYPEDEFS' in the compile to include a site specific
10568 + * typedef file "site_typedefs.h".
10570 + * If 'SITE_TYPEDEFS' is not defined, then the "Inferred Typedefs"
10571 + * section of this file makes inferences about the compile environment
10572 + * based on defined symbols and possibly compiler pragmas.
10574 + * Following these two sections is the "Default Typedefs"
10575 + * section. This section is only prcessed if 'USE_TYPEDEF_DEFAULTS' is
10576 + * defined. This section has a default set of typedefs and a few
10577 + * proprocessor symbols (TRUE, FALSE, NULL, ...).
10580 +#ifdef SITE_TYPEDEFS
10582 +/*******************************************************************************
10583 + * Site Specific Typedefs
10584 + *******************************************************************************/
10586 +#include "site_typedefs.h"
10590 +/*******************************************************************************
10591 + * Inferred Typedefs
10592 + *******************************************************************************/
10594 +/* Infer the compile environment based on preprocessor symbols and pramas.
10595 + * Override type definitions as needed, and include configuration dependent
10596 + * header files to define types.
10599 +#ifdef __cplusplus
10601 +#define TYPEDEF_BOOL
10603 +#define FALSE false
10609 +#else /* ! __cplusplus */
10611 +#if defined(_WIN32)
10613 +#define TYPEDEF_BOOL
10614 +typedef unsigned char bool; /* consistent w/BOOL */
10616 +#endif /* _WIN32 */
10618 +#endif /* ! __cplusplus */
10620 +/* use the Windows ULONG_PTR type when compiling for 64 bit */
10621 +#if defined(_WIN64)
10622 +#include <basetsd.h>
10623 +#define TYPEDEF_UINTPTR
10624 +typedef ULONG_PTR uintptr;
10628 +typedef long unsigned int size_t;
10631 +#ifdef _MSC_VER /* Microsoft C */
10632 +#define TYPEDEF_INT64
10633 +#define TYPEDEF_UINT64
10634 +typedef signed __int64 int64;
10635 +typedef unsigned __int64 uint64;
10638 +#if defined(MACOSX) && defined(KERNEL)
10639 +#define TYPEDEF_BOOL
10643 +#if defined(linux)
10644 +#define TYPEDEF_UINT
10645 +#define TYPEDEF_USHORT
10646 +#define TYPEDEF_ULONG
10649 +#if !defined(linux) && !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
10650 +#define TYPEDEF_UINT
10651 +#define TYPEDEF_USHORT
10655 +/* Do not support the (u)int64 types with strict ansi for GNU C */
10656 +#if defined(__GNUC__) && defined(__STRICT_ANSI__)
10657 +#define TYPEDEF_INT64
10658 +#define TYPEDEF_UINT64
10661 +/* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
10662 + * for singned or unsigned */
10663 +#if defined(__ICL)
10665 +#define TYPEDEF_INT64
10667 +#if defined(__STDC__)
10668 +#define TYPEDEF_UINT64
10671 +#endif /* __ICL */
10674 +#if !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
10676 +/* pick up ushort & uint from standard types.h */
10677 +#if defined(linux) && defined(__KERNEL__)
10679 +#include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
10683 +#include <sys/types.h>
10687 +#endif /* !_WIN32 && !PMON && !_CFE_ && !_HNDRTE_ && !_MINOSL_ */
10689 +#if defined(MACOSX) && defined(KERNEL)
10690 +#include <IOKit/IOTypes.h>
10694 +/* use the default typedefs in the next section of this file */
10695 +#define USE_TYPEDEF_DEFAULTS
10697 +#endif /* SITE_TYPEDEFS */
10700 +/*******************************************************************************
10701 + * Default Typedefs
10702 + *******************************************************************************/
10704 +#ifdef USE_TYPEDEF_DEFAULTS
10705 +#undef USE_TYPEDEF_DEFAULTS
10707 +#ifndef TYPEDEF_BOOL
10708 +typedef /*@abstract@*/ unsigned char bool;
10711 +/*----------------------- define uchar, ushort, uint, ulong ------------------*/
10713 +#ifndef TYPEDEF_UCHAR
10714 +typedef unsigned char uchar;
10717 +#ifndef TYPEDEF_USHORT
10718 +typedef unsigned short ushort;
10721 +#ifndef TYPEDEF_UINT
10722 +typedef unsigned int uint;
10725 +#ifndef TYPEDEF_ULONG
10726 +typedef unsigned long ulong;
10729 +/*----------------------- define [u]int8/16/32/64, uintptr --------------------*/
10731 +#ifndef TYPEDEF_UINT8
10732 +typedef unsigned char uint8;
10735 +#ifndef TYPEDEF_UINT16
10736 +typedef unsigned short uint16;
10739 +#ifndef TYPEDEF_UINT32
10740 +typedef unsigned int uint32;
10743 +#ifndef TYPEDEF_UINT64
10744 +typedef unsigned long long uint64;
10747 +#ifndef TYPEDEF_UINTPTR
10748 +typedef unsigned int uintptr;
10751 +#ifndef TYPEDEF_INT8
10752 +typedef signed char int8;
10755 +#ifndef TYPEDEF_INT16
10756 +typedef signed short int16;
10759 +#ifndef TYPEDEF_INT32
10760 +typedef signed int int32;
10763 +#ifndef TYPEDEF_INT64
10764 +typedef signed long long int64;
10767 +/*----------------------- define float32/64, float_t -----------------------*/
10769 +#ifndef TYPEDEF_FLOAT32
10770 +typedef float float32;
10773 +#ifndef TYPEDEF_FLOAT64
10774 +typedef double float64;
10778 + * abstracted floating point type allows for compile time selection of
10779 + * single or double precision arithmetic. Compiling with -DFLOAT32
10780 + * selects single precision; the default is double precision.
10783 +#ifndef TYPEDEF_FLOAT_T
10785 +#if defined(FLOAT32)
10786 +typedef float32 float_t;
10787 +#else /* default to double precision floating point */
10788 +typedef float64 float_t;
10791 +#endif /* TYPEDEF_FLOAT_T */
10793 +/*----------------------- define macro values -----------------------------*/
10817 +/* Reclaiming text and data :
10818 + The following macros specify special linker sections that can be reclaimed
10819 + after a system is considered 'up'.
10821 +#if defined(__GNUC__) && defined(BCMRECLAIM)
10822 +extern bool bcmreclaimed;
10823 +#define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini." #_data))) _data##_ini
10824 +#define BCMINITFN(_fn) __attribute__ ((__section__ (".textini." #_fn))) _fn##_ini
10825 +#define BCMINIT(_id) _id##_ini
10827 +#define BCMINITDATA(_data) _data
10828 +#define BCMINITFN(_fn) _fn
10829 +#define BCMINIT(_id) _id
10830 +#define bcmreclaimed 0
10833 +/*----------------------- define PTRSZ, INLINE ----------------------------*/
10836 +#define PTRSZ sizeof (char*)
10843 +#define INLINE __inline
10847 +#define INLINE __inline__
10853 +#endif /* _MSC_VER */
10855 +#endif /* INLINE */
10857 +#undef TYPEDEF_BOOL
10858 +#undef TYPEDEF_UCHAR
10859 +#undef TYPEDEF_USHORT
10860 +#undef TYPEDEF_UINT
10861 +#undef TYPEDEF_ULONG
10862 +#undef TYPEDEF_UINT8
10863 +#undef TYPEDEF_UINT16
10864 +#undef TYPEDEF_UINT32
10865 +#undef TYPEDEF_UINT64
10866 +#undef TYPEDEF_UINTPTR
10867 +#undef TYPEDEF_INT8
10868 +#undef TYPEDEF_INT16
10869 +#undef TYPEDEF_INT32
10870 +#undef TYPEDEF_INT64
10871 +#undef TYPEDEF_FLOAT32
10872 +#undef TYPEDEF_FLOAT64
10873 +#undef TYPEDEF_FLOAT_T
10875 +#endif /* USE_TYPEDEF_DEFAULTS */
10877 +#endif /* _TYPEDEFS_H_ */
10878 diff -urN linux.old/arch/mips/bcm947xx/int-handler.S linux.dev/arch/mips/bcm947xx/int-handler.S
10879 --- linux.old/arch/mips/bcm947xx/int-handler.S 1970-01-01 01:00:00.000000000 +0100
10880 +++ linux.dev/arch/mips/bcm947xx/int-handler.S 2005-12-15 12:57:27.877187750 +0100
10883 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
10885 + * This program is free software; you can redistribute it and/or modify it
10886 + * under the terms of the GNU General Public License as published by the
10887 + * Free Software Foundation; either version 2 of the License, or (at your
10888 + * option) any later version.
10890 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
10891 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
10892 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
10893 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
10894 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
10895 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
10896 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
10897 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
10898 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
10899 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10901 + * You should have received a copy of the GNU General Public License along
10902 + * with this program; if not, write to the Free Software Foundation, Inc.,
10903 + * 675 Mass Ave, Cambridge, MA 02139, USA.
10906 +#include <asm/asm.h>
10907 +#include <asm/mipsregs.h>
10908 +#include <asm/regdef.h>
10909 +#include <asm/stackframe.h>
10916 + NESTED(bcm47xx_irq_handler, PT_SIZE, sp)
10923 + jal bcm47xx_irq_dispatch
10929 + END(bcm47xx_irq_handler)
10930 diff -urN linux.old/arch/mips/bcm947xx/irq.c linux.dev/arch/mips/bcm947xx/irq.c
10931 --- linux.old/arch/mips/bcm947xx/irq.c 1970-01-01 01:00:00.000000000 +0100
10932 +++ linux.dev/arch/mips/bcm947xx/irq.c 2005-12-15 12:57:27.877187750 +0100
10935 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
10937 + * This program is free software; you can redistribute it and/or modify it
10938 + * under the terms of the GNU General Public License as published by the
10939 + * Free Software Foundation; either version 2 of the License, or (at your
10940 + * option) any later version.
10942 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
10943 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
10944 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
10945 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
10946 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
10947 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
10948 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
10949 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
10950 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
10951 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10953 + * You should have received a copy of the GNU General Public License along
10954 + * with this program; if not, write to the Free Software Foundation, Inc.,
10955 + * 675 Mass Ave, Cambridge, MA 02139, USA.
10958 +#include <linux/config.h>
10959 +#include <linux/errno.h>
10960 +#include <linux/init.h>
10961 +#include <linux/interrupt.h>
10962 +#include <linux/irq.h>
10963 +#include <linux/module.h>
10964 +#include <linux/smp.h>
10965 +#include <linux/types.h>
10967 +#include <asm/cpu.h>
10968 +#include <asm/io.h>
10969 +#include <asm/irq.h>
10970 +#include <asm/irq_cpu.h>
10972 +extern asmlinkage void bcm47xx_irq_handler(void);
10974 +void bcm47xx_irq_dispatch(struct pt_regs *regs)
10978 + cause = read_c0_cause() & read_c0_status() & CAUSEF_IP;
10980 + clear_c0_status(cause);
10982 + if (cause & CAUSEF_IP7)
10984 + if (cause & CAUSEF_IP2)
10986 + if (cause & CAUSEF_IP3)
10988 + if (cause & CAUSEF_IP4)
10990 + if (cause & CAUSEF_IP5)
10992 + if (cause & CAUSEF_IP6)
10996 +void __init arch_init_irq(void)
10998 + set_except_vector(0, bcm47xx_irq_handler);
10999 + mips_cpu_irq_init(0);
11001 diff -urN linux.old/arch/mips/bcm947xx/pci.c linux.dev/arch/mips/bcm947xx/pci.c
11002 --- linux.old/arch/mips/bcm947xx/pci.c 1970-01-01 01:00:00.000000000 +0100
11003 +++ linux.dev/arch/mips/bcm947xx/pci.c 2005-12-15 23:25:48.489984500 +0100
11005 +#include <linux/kernel.h>
11006 +#include <linux/init.h>
11007 +#include <linux/pci.h>
11008 +#include <linux/types.h>
11010 +#include <asm/cpu.h>
11011 +#include <asm/io.h>
11013 +#include <typedefs.h>
11015 +#include <sbutils.h>
11016 +#include <sbmips.h>
11017 +#include <sbconfig.h>
11018 +#include <sbpci.h>
11024 +sb_pci_read_config(struct pci_bus *bus, unsigned int devfn,
11025 + int reg, int size, u32 *val)
11028 + ret = sbpci_read_config(sbh, bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn), reg, val, size);
11029 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11033 +sb_pci_write_config(struct pci_bus *bus, unsigned int devfn,
11034 + int reg, int size, u32 val)
11037 + ret = sbpci_write_config(sbh, bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn), reg, &val, size);
11038 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11042 +static struct pci_ops sb_pci_ops = {
11043 + .read = sb_pci_read_config,
11044 + .write = sb_pci_write_config,
11048 +static struct resource sb_pci_mem_resource = {
11049 + .name = "SB PCI Memory resources",
11050 + .start = SB_ENUM_BASE,
11051 + .end = SB_ENUM_LIM - 1,
11052 + .flags = IORESOURCE_MEM,
11055 +static struct resource sb_pci_io_resource = {
11056 + .name = "SB PCI I/O resources",
11059 + .flags = IORESOURCE_IO,
11062 +static struct pci_controller bcm47xx_sb_pci_controller = {
11063 + .pci_ops = &sb_pci_ops,
11064 + .mem_resource = &sb_pci_mem_resource,
11065 + .io_resource = &sb_pci_io_resource,
11068 +static struct resource ext_pci_mem_resource = {
11069 + .name = "Ext PCI Memory resources",
11070 + .start = 0x40000000,
11071 + .end = 0x7fffffff,
11072 + .flags = IORESOURCE_MEM,
11075 +static struct resource ext_pci_io_resource = {
11076 + .name = "Ext PCI I/O resources",
11079 + .flags = IORESOURCE_IO,
11082 +static struct pci_controller bcm47xx_ext_pci_controller = {
11083 + .pci_ops = &sb_pci_ops,
11084 + .mem_resource = &ext_pci_mem_resource,
11085 + .io_resource = &ext_pci_io_resource,
11088 +void bcm47xx_pci_init(void)
11092 + set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000));
11094 + register_pci_controller(&bcm47xx_sb_pci_controller);
11095 + register_pci_controller(&bcm47xx_ext_pci_controller);
11097 diff -urN linux.old/arch/mips/bcm947xx/prom.c linux.dev/arch/mips/bcm947xx/prom.c
11098 --- linux.old/arch/mips/bcm947xx/prom.c 1970-01-01 01:00:00.000000000 +0100
11099 +++ linux.dev/arch/mips/bcm947xx/prom.c 2005-12-15 12:57:27.877187750 +0100
11102 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
11104 + * This program is free software; you can redistribute it and/or modify it
11105 + * under the terms of the GNU General Public License as published by the
11106 + * Free Software Foundation; either version 2 of the License, or (at your
11107 + * option) any later version.
11109 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11110 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
11111 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
11112 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11113 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
11114 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
11115 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
11116 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11117 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
11118 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11120 + * You should have received a copy of the GNU General Public License along
11121 + * with this program; if not, write to the Free Software Foundation, Inc.,
11122 + * 675 Mass Ave, Cambridge, MA 02139, USA.
11125 +#include <linux/init.h>
11126 +#include <linux/mm.h>
11127 +#include <linux/sched.h>
11128 +#include <linux/bootmem.h>
11130 +#include <asm/addrspace.h>
11131 +#include <asm/bootinfo.h>
11132 +#include <asm/pmon.h>
11134 +const char *get_system_type(void)
11136 + return "Broadcom BCM47xx";
11139 +void __init prom_init(void)
11141 + unsigned long mem;
11143 + mips_machgroup = MACH_GROUP_BRCM;
11144 + mips_machtype = MACH_BCM47XX;
11146 + /* Figure out memory size by finding aliases */
11147 + for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
11148 + if (*(unsigned long *)((unsigned long)(prom_init) + mem) ==
11149 + *(unsigned long *)(prom_init))
11153 + add_memory_region(0, mem, BOOT_MEM_RAM);
11156 +unsigned long __init prom_free_prom_memory(void)
11160 diff -urN linux.old/arch/mips/bcm947xx/setup.c linux.dev/arch/mips/bcm947xx/setup.c
11161 --- linux.old/arch/mips/bcm947xx/setup.c 1970-01-01 01:00:00.000000000 +0100
11162 +++ linux.dev/arch/mips/bcm947xx/setup.c 2005-12-15 19:17:21.508844000 +0100
11165 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
11166 + * Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
11168 + * This program is free software; you can redistribute it and/or modify it
11169 + * under the terms of the GNU General Public License as published by the
11170 + * Free Software Foundation; either version 2 of the License, or (at your
11171 + * option) any later version.
11173 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11174 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
11175 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
11176 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11177 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
11178 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
11179 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
11180 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11181 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
11182 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11184 + * You should have received a copy of the GNU General Public License along
11185 + * with this program; if not, write to the Free Software Foundation, Inc.,
11186 + * 675 Mass Ave, Cambridge, MA 02139, USA.
11189 +#include <linux/init.h>
11190 +#include <linux/types.h>
11191 +#include <linux/tty.h>
11192 +#include <linux/serial.h>
11193 +#include <linux/serial_core.h>
11194 +#include <linux/serial_reg.h>
11195 +#include <asm/bootinfo.h>
11196 +#include <asm/time.h>
11197 +#include <asm/reboot.h>
11199 +#include <typedefs.h>
11201 +#include <sbutils.h>
11202 +#include <sbmips.h>
11203 +#include <sbpci.h>
11204 +#include <sbconfig.h>
11205 +#include <bcmdevs.h>
11207 +extern void bcm47xx_pci_init(void);
11208 +extern void bcm47xx_time_init(void);
11209 +extern void bcm47xx_timer_setup(struct irqaction *irq);
11212 +static int ser_line = 0;
11215 +serial_add(void *regs, uint irq, uint baud_base, uint reg_shift)
11217 + struct uart_port s;
11219 + memset(&s, 0, sizeof(s));
11221 + s.line = ser_line++;
11222 + s.membase = regs;
11224 + s.uartclk = baud_base;
11225 + s.flags = ASYNC_BOOT_AUTOCONF;
11226 + s.iotype = SERIAL_IO_MEM;
11227 + s.regshift = reg_shift;
11229 + if (early_serial_setup(&s) != 0) {
11230 + printk(KERN_ERR "Serial setup failed!\n");
11234 +static void bcm47xx_machine_restart(char *command)
11236 + printk("Please stand by while rebooting the system...\n");
11238 + /* Set the watchdog timer to reset immediately */
11239 + local_irq_disable();
11240 + sb_watchdog(sbh, 1);
11244 +static void bcm47xx_machine_halt(void)
11246 + /* Disable interrupts and watchdog and spin forever */
11247 + local_irq_disable();
11248 + sb_watchdog(sbh, 0);
11252 +void __init plat_setup(void)
11255 + sbh = sb_kattach();
11256 + sb_mips_init(sbh);
11258 + bcm47xx_pci_init();
11260 + set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000));
11262 + sb_serial_init(sbh, serial_add);
11264 + _machine_restart = bcm47xx_machine_restart;
11265 + _machine_halt = bcm47xx_machine_halt;
11266 + _machine_power_off = bcm47xx_machine_halt;
11268 + board_time_init = bcm47xx_time_init;
11269 + board_timer_setup = bcm47xx_timer_setup;
11271 diff -urN linux.old/arch/mips/bcm947xx/time.c linux.dev/arch/mips/bcm947xx/time.c
11272 --- linux.old/arch/mips/bcm947xx/time.c 1970-01-01 01:00:00.000000000 +0100
11273 +++ linux.dev/arch/mips/bcm947xx/time.c 2005-12-15 12:57:27.877187750 +0100
11276 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
11278 + * This program is free software; you can redistribute it and/or modify it
11279 + * under the terms of the GNU General Public License as published by the
11280 + * Free Software Foundation; either version 2 of the License, or (at your
11281 + * option) any later version.
11283 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11284 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
11285 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
11286 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11287 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
11288 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
11289 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
11290 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11291 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
11292 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11294 + * You should have received a copy of the GNU General Public License along
11295 + * with this program; if not, write to the Free Software Foundation, Inc.,
11296 + * 675 Mass Ave, Cambridge, MA 02139, USA.
11299 +#include <linux/config.h>
11300 +#include <linux/init.h>
11301 +#include <linux/kernel.h>
11302 +#include <linux/sched.h>
11303 +#include <linux/serial_reg.h>
11304 +#include <linux/interrupt.h>
11305 +#include <asm/addrspace.h>
11306 +#include <asm/io.h>
11307 +#include <asm/time.h>
11310 +bcm47xx_time_init(void)
11315 + * Use deterministic values for initial counter interrupt
11316 + * so that calibrate delay avoids encountering a counter wrap.
11318 + write_c0_count(0);
11319 + write_c0_compare(0xffff);
11321 + hz = 200 * 1000 * 1000;
11323 + /* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
11324 + mips_hpt_frequency = hz / 2;
11329 +bcm47xx_timer_setup(struct irqaction *irq)
11331 + /* Enable the timer interrupt */
11332 + setup_irq(7, irq);
11334 diff -urN linux.old/arch/mips/kernel/cpu-probe.c linux.dev/arch/mips/kernel/cpu-probe.c
11335 --- linux.old/arch/mips/kernel/cpu-probe.c 2005-12-15 13:26:49.766024000 +0100
11336 +++ linux.dev/arch/mips/kernel/cpu-probe.c 2005-12-15 12:57:27.901177250 +0100
11337 @@ -656,6 +656,28 @@
11341 +static inline void cpu_probe_broadcom(struct cpuinfo_mips *c)
11343 + decode_config1(c);
11344 + switch (c->processor_id & 0xff00) {
11345 + case PRID_IMP_BCM3302:
11346 + c->cputype = CPU_BCM3302;
11347 + c->isa_level = MIPS_CPU_ISA_M32;
11348 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
11349 + MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER;
11351 + case PRID_IMP_BCM4710:
11352 + c->cputype = CPU_BCM4710;
11353 + c->isa_level = MIPS_CPU_ISA_M32;
11354 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
11355 + MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER;
11358 + c->cputype = CPU_UNKNOWN;
11363 __init void cpu_probe(void)
11365 struct cpuinfo_mips *c = ¤t_cpu_data;
11366 @@ -678,6 +700,9 @@
11367 case PRID_COMP_SIBYTE:
11368 cpu_probe_sibyte(c);
11370 + case PRID_COMP_BROADCOM:
11371 + cpu_probe_broadcom(c);
11373 case PRID_COMP_SANDCRAFT:
11374 cpu_probe_sandcraft(c);
11376 diff -urN linux.old/arch/mips/kernel/head.S linux.dev/arch/mips/kernel/head.S
11377 --- linux.old/arch/mips/kernel/head.S 2005-12-15 13:26:49.766024000 +0100
11378 +++ linux.dev/arch/mips/kernel/head.S 2005-12-15 12:57:27.901177250 +0100
11379 @@ -107,6 +107,14 @@
11383 +#ifdef CONFIG_BCM4710
11385 +#define eret nop; nop; eret
11392 * Reserved space for exception handlers.
11393 * Necessary for machines which link their kernels at KSEG0.
11394 diff -urN linux.old/arch/mips/kernel/proc.c linux.dev/arch/mips/kernel/proc.c
11395 --- linux.old/arch/mips/kernel/proc.c 2005-12-15 13:26:49.766024000 +0100
11396 +++ linux.dev/arch/mips/kernel/proc.c 2005-12-15 12:57:27.921168500 +0100
11398 [CPU_VR4181] = "NEC VR4181",
11399 [CPU_VR4181A] = "NEC VR4181A",
11400 [CPU_SR71000] = "Sandcraft SR71000",
11401 + [CPU_BCM3302] = "Broadcom BCM3302",
11402 + [CPU_BCM4710] = "Broadcom BCM4710",
11403 [CPU_PR4450] = "Philips PR4450",
11406 diff -urN linux.old/arch/mips/mm/tlbex.c linux.dev/arch/mips/mm/tlbex.c
11407 --- linux.old/arch/mips/mm/tlbex.c 2005-12-15 13:26:49.794011750 +0100
11408 +++ linux.dev/arch/mips/mm/tlbex.c 2005-12-15 12:57:27.945158000 +0100
11409 @@ -858,6 +858,8 @@
11413 + case CPU_BCM3302:
11414 + case CPU_BCM4710:
11418 diff -urN linux.old/arch/mips/pci/Makefile linux.dev/arch/mips/pci/Makefile
11419 --- linux.old/arch/mips/pci/Makefile 2005-12-15 13:26:49.814003000 +0100
11420 +++ linux.dev/arch/mips/pci/Makefile 2005-12-15 14:27:26.439319250 +0100
11422 obj-$(CONFIG_MIPS_TX3927) += ops-tx3927.o
11423 obj-$(CONFIG_PCI_VR41XX) += ops-vr41xx.o pci-vr41xx.o
11424 obj-$(CONFIG_NEC_CMBVR4133) += fixup-vr4133.o
11425 +obj-$(CONFIG_BCM947XX) += fixup-bcm47xx.o
11428 # These are still pretty much in the old state, watch, go blind.
11429 diff -urN linux.old/arch/mips/pci/fixup-bcm47xx.c linux.dev/arch/mips/pci/fixup-bcm47xx.c
11430 --- linux.old/arch/mips/pci/fixup-bcm47xx.c 1970-01-01 01:00:00.000000000 +0100
11431 +++ linux.dev/arch/mips/pci/fixup-bcm47xx.c 2005-12-15 12:57:27.945158000 +0100
11433 +#include <linux/init.h>
11434 +#include <linux/pci.h>
11436 +/* Do platform specific device initialization at pci_enable_device() time */
11437 +int pcibios_plat_dev_init(struct pci_dev *dev)
11442 +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
11446 + if (dev->bus->number == 1)
11449 + pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
11453 +struct pci_fixup pcibios_fixups[] = {
11456 diff -urN linux.old/include/asm-mips/bootinfo.h linux.dev/include/asm-mips/bootinfo.h
11457 --- linux.old/include/asm-mips/bootinfo.h 2005-12-15 13:26:49.818001250 +0100
11458 +++ linux.dev/include/asm-mips/bootinfo.h 2005-12-15 12:57:27.969147500 +0100
11459 @@ -218,6 +218,12 @@
11460 #define MACH_GROUP_TITAN 22 /* PMC-Sierra Titan */
11461 #define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */
11464 + * Valid machtype for group Broadcom
11466 +#define MACH_GROUP_BRCM 23 /* Broadcom */
11467 +#define MACH_BCM47XX 1 /* Broadcom BCM47xx */
11469 #define CL_SIZE COMMAND_LINE_SIZE
11471 const char *get_system_type(void);
11472 diff -urN linux.old/include/asm-mips/cpu.h linux.dev/include/asm-mips/cpu.h
11473 --- linux.old/include/asm-mips/cpu.h 2005-12-15 13:26:49.818001250 +0100
11474 +++ linux.dev/include/asm-mips/cpu.h 2005-12-15 12:57:27.969147500 +0100
11475 @@ -102,6 +102,13 @@
11476 #define PRID_IMP_SR71000 0x0400
11479 + * These are the PRID's for when 23:16 == PRID_COMP_BROADCOM
11482 +#define PRID_IMP_BCM4710 0x4000
11483 +#define PRID_IMP_BCM3302 0x9000
11486 * Definitions for 7:0 on legacy processors
11489 @@ -196,7 +203,9 @@
11491 #define CPU_PR4450 61
11492 #define CPU_SB1A 62
11493 -#define CPU_LAST 62
11494 +#define CPU_BCM3302 63
11495 +#define CPU_BCM4710 64
11496 +#define CPU_LAST 64
11499 * ISA Level encodings
11500 diff -urN linux.old/include/linux/init.h linux.dev/include/linux/init.h
11501 --- linux.old/include/linux/init.h 2005-12-15 13:26:49.818001250 +0100
11502 +++ linux.dev/include/linux/init.h 2005-12-15 12:57:27.973145750 +0100
11504 static initcall_t __initcall_##fn __attribute_used__ \
11505 __attribute__((__section__(".initcall" level ".init"))) = fn
11507 +#define early_initcall(fn) __define_initcall(".early1",fn)
11509 #define core_initcall(fn) __define_initcall("1",fn)
11510 #define postcore_initcall(fn) __define_initcall("2",fn)
11511 #define arch_initcall(fn) __define_initcall("3",fn)
11512 diff -urN linux.old/include/linux/pci_ids.h linux.dev/include/linux/pci_ids.h
11513 --- linux.old/include/linux/pci_ids.h 2005-12-15 13:26:49.818001250 +0100
11514 +++ linux.dev/include/linux/pci_ids.h 2005-12-15 12:57:27.977144000 +0100
11515 @@ -1835,6 +1835,7 @@
11516 #define PCI_DEVICE_ID_TIGON3_5901_2 0x170e
11517 #define PCI_DEVICE_ID_BCM4401 0x4401
11518 #define PCI_DEVICE_ID_BCM4401B0 0x4402
11519 +#define PCI_DEVICE_ID_BCM4713 0x4713
11521 #define PCI_VENDOR_ID_TOPIC 0x151f
11522 #define PCI_DEVICE_ID_TOPIC_TP560 0x0000