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-17 20:51:17.749271000 +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 cfe_env.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-17 01:21:23.007883000 +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);
282 + * Apply CRC over SROM content regardless SROM is present or not,
283 + * and use variable <devpath>sromrev's existance in flash to decide
284 + * if we should return an error when CRC fails or read SROM variables
287 + sprom_read_pci((void*)((int8*)curmap + PCI_BAR0_SPROM_OFFSET), 0, b, sizeof(b)/sizeof(b[0]), TRUE);
289 + /* top word of sprom contains version and crc8 */
290 + sromrev = b[63] & 0xff;
291 + /* bcm4401 sroms misprogrammed */
292 + if (sromrev == 0x10)
295 + /* srom version check */
302 + base = vp = MALLOC(osh, VARS_MAX);
307 + vp += sprintf(vp, "sromrev=%d", sromrev);
310 + if (sromrev >= 3) {
311 + /* New section takes over the 3th hardware function space */
313 + /* Words 22+23 are 11a (mid) ofdm power offsets */
314 + w32 = ((uint32)b[23] << 16) | b[22];
315 + vp += sprintf(vp, "ofdmapo=%d", w32);
318 + /* Words 24+25 are 11a (low) ofdm power offsets */
319 + w32 = ((uint32)b[25] << 16) | b[24];
320 + vp += sprintf(vp, "ofdmalpo=%d", w32);
323 + /* Words 26+27 are 11a (high) ofdm power offsets */
324 + w32 = ((uint32)b[27] << 16) | b[26];
325 + vp += sprintf(vp, "ofdmahpo=%d", w32);
328 + /*GPIO LED Powersave duty cycle (oncount >> 24) (offcount >> 8)*/
329 + w32 = ((uint32)b[43] << 24) | ((uint32)b[42] << 8);
330 + vp += sprintf(vp, "gpiotimerval=%d", w32);
332 + /*GPIO LED Powersave duty cycle (oncount >> 24) (offcount >> 8)*/
333 + w32 = ((uint32)((unsigned char)(b[21] >> 8) & 0xFF) << 24) | /* oncount*/
334 + ((uint32)((unsigned char)(b[21] & 0xFF)) << 8); /* offcount */
335 + vp += sprintf(vp, "gpiotimerval=%d", w32);
340 + if (sromrev >= 2) {
341 + /* New section takes over the 4th hardware function space */
343 + /* Word 29 is max power 11a high/low */
345 + vp += sprintf(vp, "pa1himaxpwr=%d", w & 0xff);
347 + vp += sprintf(vp, "pa1lomaxpwr=%d", (w >> 8) & 0xff);
350 + /* Words 30-32 set the 11alow pa settings,
351 + * 33-35 are the 11ahigh ones.
353 + for (i = 0; i < 3; i++) {
354 + vp += sprintf(vp, "pa1lob%d=%d", i, b[30 + i]);
356 + vp += sprintf(vp, "pa1hib%d=%d", i, b[33 + i]);
361 + vp += sprintf(vp, "ccode=");
363 + vp += sprintf(vp, "ccode=%c%c", (w >> 8), (w & 0xff));
368 + /* parameter section of sprom starts at byte offset 72 */
371 + /* first 6 bytes are il0macaddr */
372 + ea.octet[0] = (b[woff] >> 8) & 0xff;
373 + ea.octet[1] = b[woff] & 0xff;
374 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
375 + ea.octet[3] = b[woff+1] & 0xff;
376 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
377 + ea.octet[5] = b[woff+2] & 0xff;
378 + woff += ETHER_ADDR_LEN/2 ;
379 + bcm_ether_ntoa((uchar*)&ea, eabuf);
380 + vp += sprintf(vp, "il0macaddr=%s", eabuf);
383 + /* next 6 bytes are et0macaddr */
384 + ea.octet[0] = (b[woff] >> 8) & 0xff;
385 + ea.octet[1] = b[woff] & 0xff;
386 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
387 + ea.octet[3] = b[woff+1] & 0xff;
388 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
389 + ea.octet[5] = b[woff+2] & 0xff;
390 + woff += ETHER_ADDR_LEN/2 ;
391 + bcm_ether_ntoa((uchar*)&ea, eabuf);
392 + vp += sprintf(vp, "et0macaddr=%s", eabuf);
395 + /* next 6 bytes are et1macaddr */
396 + ea.octet[0] = (b[woff] >> 8) & 0xff;
397 + ea.octet[1] = b[woff] & 0xff;
398 + ea.octet[2] = (b[woff+1] >> 8) & 0xff;
399 + ea.octet[3] = b[woff+1] & 0xff;
400 + ea.octet[4] = (b[woff+2] >> 8) & 0xff;
401 + ea.octet[5] = b[woff+2] & 0xff;
402 + woff += ETHER_ADDR_LEN/2 ;
403 + bcm_ether_ntoa((uchar*)&ea, eabuf);
404 + vp += sprintf(vp, "et1macaddr=%s", eabuf);
408 + * Enet phy settings one or two singles or a dual
409 + * Bits 4-0 : MII address for enet0 (0x1f for not there)
410 + * Bits 9-5 : MII address for enet1 (0x1f for not there)
411 + * Bit 14 : Mdio for enet0
412 + * Bit 15 : Mdio for enet1
415 + vp += sprintf(vp, "et0phyaddr=%d", (w & 0x1f));
417 + vp += sprintf(vp, "et1phyaddr=%d", ((w >> 5) & 0x1f));
419 + vp += sprintf(vp, "et0mdcport=%d", ((w >> 14) & 0x1));
421 + vp += sprintf(vp, "et1mdcport=%d", ((w >> 15) & 0x1));
424 + /* Word 46 has board rev, antennas 0/1 & Country code/control */
426 + vp += sprintf(vp, "boardrev=%d", w & 0xff);
430 + vp += sprintf(vp, "cctl=%d", (w >> 8) & 0xf);
432 + vp += sprintf(vp, "cc=%d", (w >> 8) & 0xf);
435 + vp += sprintf(vp, "aa0=%d", (w >> 12) & 0x3);
438 + vp += sprintf(vp, "aa1=%d", (w >> 14) & 0x3);
441 + /* Words 47-49 set the (wl) pa settings */
444 + for (i = 0; i < 3; i++) {
445 + vp += sprintf(vp, "pa0b%d=%d", i, b[woff+i]);
447 + vp += sprintf(vp, "pa1b%d=%d", i, b[woff+i+6]);
452 + * Words 50-51 set the customer-configured wl led behavior.
453 + * 8 bits/gpio pin. High bit: activehi=0, activelo=1;
454 + * LED behavior values defined in wlioctl.h .
457 + if ((w != 0) && (w != 0xffff)) {
459 + vp += sprintf(vp, "wl0gpio0=%d", (w & 0xff));
463 + vp += sprintf(vp, "wl0gpio1=%d", (w >> 8) & 0xff);
467 + if ((w != 0) && (w != 0xffff)) {
469 + vp += sprintf(vp, "wl0gpio2=%d", w & 0xff);
473 + vp += sprintf(vp, "wl0gpio3=%d", (w >> 8) & 0xff);
477 + /* Word 52 is max power 0/1 */
479 + vp += sprintf(vp, "pa0maxpwr=%d", w & 0xff);
481 + vp += sprintf(vp, "pa1maxpwr=%d", (w >> 8) & 0xff);
484 + /* Word 56 is idle tssi target 0/1 */
486 + vp += sprintf(vp, "pa0itssit=%d", w & 0xff);
488 + vp += sprintf(vp, "pa1itssit=%d", (w >> 8) & 0xff);
491 + /* Word 57 is boardflags, if not programmed make it zero */
492 + w32 = (uint32)b[57];
493 + if (w32 == 0xffff) w32 = 0;
495 + /* Word 28 is the high bits of boardflags */
496 + w32 |= (uint32)b[28] << 16;
498 + vp += sprintf(vp, "boardflags=%d", w32);
501 + /* Word 58 is antenna gain 0/1 */
503 + vp += sprintf(vp, "ag0=%d", w & 0xff);
506 + vp += sprintf(vp, "ag1=%d", (w >> 8) & 0xff);
509 + if (sromrev == 1) {
510 + /* set the oem string */
511 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x",
512 + ((b[59] >> 8) & 0xff), (b[59] & 0xff),
513 + ((b[60] >> 8) & 0xff), (b[60] & 0xff),
514 + ((b[61] >> 8) & 0xff), (b[61] & 0xff),
515 + ((b[62] >> 8) & 0xff), (b[62] & 0xff));
517 + } else if (sromrev == 2) {
518 + /* Word 60 OFDM tx power offset from CCK level */
519 + /* OFDM Power Offset - opo */
520 + vp += sprintf(vp, "opo=%d", b[60] & 0xff);
523 + /* Word 60: cck power offsets */
524 + vp += sprintf(vp, "cckpo=%d", b[60]);
527 + /* Words 61+62: 11g ofdm power offsets */
528 + w32 = ((uint32)b[62] << 16) | b[61];
529 + vp += sprintf(vp, "ofdmgpo=%d", w32);
533 + /* final nullbyte terminator */
536 + ASSERT((vp - base) <= VARS_MAX);
538 + err = initvars_table(osh, base, vp, vars, count);
540 + MFREE(osh, base, VARS_MAX);
544 diff -urN linux.old/arch/mips/bcm947xx/broadcom/bcmutils.c linux.dev/arch/mips/bcm947xx/broadcom/bcmutils.c
545 --- linux.old/arch/mips/bcm947xx/broadcom/bcmutils.c 1970-01-01 01:00:00.000000000 +0100
546 +++ linux.dev/arch/mips/bcm947xx/broadcom/bcmutils.c 2005-12-17 17:53:52.387365000 +0100
549 + * Misc useful OS-independent routines.
551 + * Copyright 2005, Broadcom Corporation
552 + * All Rights Reserved.
554 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
555 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
556 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
557 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
561 +#include <typedefs.h>
563 +#include <sbutils.h>
564 +#include <bcmnvram.h>
565 +#include <bcmutils.h>
566 +#include <bcmendian.h>
567 +#include <bcmdevs.h>
569 +unsigned char bcm_ctype[] = {
570 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 0-7 */
571 + _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 */
572 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 16-23 */
573 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 24-31 */
574 + _BCM_S|_BCM_SP,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 32-39 */
575 + _BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 40-47 */
576 + _BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D, /* 48-55 */
577 + _BCM_D,_BCM_D,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 56-63 */
578 + _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 */
579 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 72-79 */
580 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 80-87 */
581 + _BCM_U,_BCM_U,_BCM_U,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 88-95 */
582 + _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 */
583 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 104-111 */
584 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 112-119 */
585 + _BCM_L,_BCM_L,_BCM_L,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_C, /* 120-127 */
586 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
587 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
588 + _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 */
589 + _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 */
590 + _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 */
591 + _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 */
592 + _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 */
593 + _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 */
597 +bcm_toupper(uchar c)
599 + if (bcm_islower(c))
605 +bcm_strtoul(char *cp, char **endp, uint base)
607 + ulong result, value;
612 + while (bcm_isspace(*cp))
617 + else if (cp[0] == '-') {
623 + if (cp[0] == '0') {
624 + if ((cp[1] == 'x') || (cp[1] == 'X')) {
633 + } else if (base == 16 && (cp[0] == '0') && ((cp[1] == 'x') || (cp[1] == 'X'))) {
639 + while (bcm_isxdigit(*cp) &&
640 + (value = bcm_isdigit(*cp) ? *cp-'0' : bcm_toupper(*cp)-'A'+10) < base) {
641 + result = result*base + value;
646 + result = (ulong)(result * -1);
649 + *endp = (char *)cp;
661 + while (bcm_isdigit(*s))
662 + n = (n * 10) + *s++ - '0';
666 +/* return pointer to location of substring 'needle' in 'haystack' */
668 +bcmstrstr(char *haystack, char *needle)
673 + if ((haystack == NULL) || (needle == NULL))
676 + nlen = strlen(needle);
677 + len = strlen(haystack) - nlen + 1;
679 + for (i = 0; i < len; i++)
680 + if (bcmp(needle, &haystack[i], nlen) == 0)
681 + return (&haystack[i]);
686 +bcmstrcat(char *dest, const char *src)
688 + strcpy(&dest[strlen(dest)], src);
694 +bcm_ether_ntoa(char *ea, char *buf)
696 + sprintf(buf,"%02x:%02x:%02x:%02x:%02x:%02x",
697 + (uchar)ea[0]&0xff, (uchar)ea[1]&0xff, (uchar)ea[2]&0xff,
698 + (uchar)ea[3]&0xff, (uchar)ea[4]&0xff, (uchar)ea[5]&0xff);
702 +/* parse a xx:xx:xx:xx:xx:xx format ethernet address */
704 +bcm_ether_atoe(char *p, char *ea)
709 + ea[i++] = (char) bcm_strtoul(p, &p, 16);
710 + if (!*p++ || i == 6)
722 + for (i = 0; i < ms; i++) {
728 + * Search the name=value vars for a specific one and return its value.
729 + * Returns NULL if not found.
732 +getvar(char *vars, char *name)
737 + len = strlen(name);
739 + /* first look in vars[] */
740 + for (s = vars; s && *s; ) {
741 + if ((bcmp(s, name, len) == 0) && (s[len] == '='))
742 + return (&s[len+1]);
748 + /* then query nvram */
749 + return (BCMINIT(nvram_get)(name));
753 + * Search the vars for a specific one and return its value as
754 + * an integer. Returns 0 if not found.
757 +getintvar(char *vars, char *name)
761 + if ((val = getvar(vars, name)) == NULL)
764 + return (bcm_strtoul(val, NULL, 0));
768 +/* Search for token in comma separated token-string */
770 +findmatch(char *string, char *name)
775 + len = strlen(name);
776 + while ((c = strchr(string, ',')) != NULL) {
777 + if (len == (uint)(c - string) && !strncmp(string, name, len))
782 + return (!strcmp(string, name));
785 +/* Return gpio pin number assigned to the named pin */
787 +* Variable should be in format:
789 +* gpio<N>=pin_name,pin_name
791 +* This format allows multiple features to share the gpio with mutual
794 +* 'def_pin' is returned if a specific gpio is not defined for the requested functionality
795 +* and if def_pin is not used by others.
798 +getgpiopin(char *vars, char *pin_name, uint def_pin)
800 + char name[] = "gpioXXXX";
804 + /* Go thru all possibilities till a match in pin name */
805 + for (pin = 0; pin < GPIO_NUMPINS; pin ++) {
806 + sprintf(name, "gpio%d", pin);
807 + val = getvar(vars, name);
808 + if (val && findmatch(val, pin_name))
812 + if (def_pin != GPIO_PIN_NOTDEFINED) {
813 + /* make sure the default pin is not used by someone else */
814 + sprintf(name, "gpio%d", def_pin);
815 + if (getvar(vars, name)) {
816 + def_pin = GPIO_PIN_NOTDEFINED;
824 +/*******************************************************************************
827 + * Computes a crc8 over the input data using the polynomial:
829 + * x^8 + x^7 +x^6 + x^4 + x^2 + 1
831 + * The caller provides the initial value (either CRC8_INIT_VALUE
832 + * or the previous returned value) to allow for processing of
833 + * discontiguous blocks of data. When generating the CRC the
834 + * caller is responsible for complementing the final return value
835 + * and inserting it into the byte stream. When checking, a final
836 + * return value of CRC8_GOOD_VALUE indicates a valid CRC.
838 + * Reference: Dallas Semiconductor Application Note 27
839 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
840 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
841 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
843 + ******************************************************************************/
845 +static uint8 crc8_table[256] = {
846 + 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B,
847 + 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21,
848 + 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF,
849 + 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5,
850 + 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14,
851 + 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E,
852 + 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80,
853 + 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA,
854 + 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95,
855 + 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF,
856 + 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01,
857 + 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B,
858 + 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA,
859 + 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0,
860 + 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E,
861 + 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34,
862 + 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0,
863 + 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A,
864 + 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54,
865 + 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E,
866 + 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF,
867 + 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5,
868 + 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B,
869 + 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61,
870 + 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E,
871 + 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74,
872 + 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA,
873 + 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0,
874 + 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41,
875 + 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B,
876 + 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5,
877 + 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F
880 +#define CRC_INNER_LOOP(n, c, x) \
881 + (c) = ((c) >> 8) ^ crc##n##_table[((c) ^ (x)) & 0xff]
885 + uint8 *pdata, /* pointer to array of data to process */
886 + uint nbytes, /* number of input data bytes to process */
887 + uint8 crc /* either CRC8_INIT_VALUE or previous return value */
890 + /* hard code the crc loop instead of using CRC_INNER_LOOP macro
891 + * to avoid the undefined and unnecessary (uint8 >> 8) operation. */
892 + while (nbytes-- > 0)
893 + crc = crc8_table[(crc ^ *pdata++) & 0xff];
900 +#define CBUFSIZ (CLEN+4)
904 diff -urN linux.old/arch/mips/bcm947xx/broadcom/cfe_env.c linux.dev/arch/mips/bcm947xx/broadcom/cfe_env.c
905 --- linux.old/arch/mips/bcm947xx/broadcom/cfe_env.c 1970-01-01 01:00:00.000000000 +0100
906 +++ linux.dev/arch/mips/bcm947xx/broadcom/cfe_env.c 2005-12-17 21:40:08.166726750 +0100
909 + * NVRAM variable manipulation (Linux kernel half)
911 + * Copyright 2001-2003, Broadcom Corporation
912 + * All Rights Reserved.
914 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
915 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
916 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
917 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
922 +#include <linux/config.h>
923 +#include <linux/init.h>
924 +#include <linux/module.h>
925 +#include <linux/kernel.h>
926 +#include <linux/string.h>
928 +#include <asm/uaccess.h>
930 +#include <typedefs.h>
932 +#include <bcmendian.h>
933 +#include <bcmutils.h>
935 +#define NVRAM_SIZE (0x1ff0)
936 +static char _nvdata[NVRAM_SIZE] __initdata;
937 +static char _valuestr[256] __initdata;
940 + * TLV types. These codes are used in the "type-length-value"
941 + * encoding of the items stored in the NVRAM device (flash or EEPROM)
943 + * The layout of the flash/nvram is as follows:
945 + * <type> <length> <data ...> <type> <length> <data ...> <type_end>
947 + * The type code of "ENV_TLV_TYPE_END" marks the end of the list.
948 + * The "length" field marks the length of the data section, not
949 + * including the type and length fields.
951 + * Environment variables are stored as follows:
953 + * <type_env> <length> <flags> <name> = <value>
955 + * If bit 0 (low bit) is set, the length is an 8-bit value.
956 + * If bit 0 (low bit) is clear, the length is a 16-bit value
958 + * Bit 7 set indicates "user" TLVs. In this case, bit 0 still
959 + * indicates the size of the length field.
961 + * Flags are from the constants below:
964 +#define ENV_LENGTH_16BITS 0x00 /* for low bit */
965 +#define ENV_LENGTH_8BITS 0x01
967 +#define ENV_TYPE_USER 0x80
969 +#define ENV_CODE_SYS(n,l) (((n)<<1)|(l))
970 +#define ENV_CODE_USER(n,l) ((((n)<<1)|(l)) | ENV_TYPE_USER)
973 + * The actual TLV types we support
976 +#define ENV_TLV_TYPE_END 0x00
977 +#define ENV_TLV_TYPE_ENV ENV_CODE_SYS(0,ENV_LENGTH_8BITS)
980 + * Environment variable flags
983 +#define ENV_FLG_NORMAL 0x00 /* normal read/write */
984 +#define ENV_FLG_BUILTIN 0x01 /* builtin - not stored in flash */
985 +#define ENV_FLG_READONLY 0x02 /* read-only - cannot be changed */
987 +#define ENV_FLG_MASK 0xFF /* mask of attributes we keep */
988 +#define ENV_FLG_ADMIN 0x100 /* lets us internally override permissions */
991 +/* *********************************************************************
992 + * _nvram_read(buffer,offset,length)
994 + * Read data from the NVRAM device
996 + * Input parameters:
997 + * buffer - destination buffer
998 + * offset - offset of data to read
999 + * length - number of bytes to read
1002 + * number of bytes read, or <0 if error occured
1003 + ********************************************************************* */
1005 +_nvram_read(unsigned char *nv_buf, unsigned char *buffer, int offset, int length)
1008 + if (offset > NVRAM_SIZE)
1011 + for ( i = 0; i < length; i++) {
1012 + buffer[i] = ((volatile unsigned char*)nv_buf)[offset + i];
1019 +_strnchr(const char *dest,int c,size_t cnt)
1021 + while (*dest && (cnt > 0)) {
1022 + if (*dest == c) return (char *) dest;
1032 + * Core support API: Externally visible.
1036 + * Get the value of an NVRAM variable
1037 + * @param name name of variable to get
1038 + * @return value of variable or NULL if undefined
1042 +cfe_env_get(unsigned char *nv_buf, char* name)
1045 + unsigned char *buffer;
1046 + unsigned char *ptr;
1047 + unsigned char *envval;
1048 + unsigned int reclen;
1049 + unsigned int rectype;
1053 + size = NVRAM_SIZE;
1054 + buffer = &_nvdata[0];
1059 + /* Read the record type and length */
1060 + if (_nvram_read(nv_buf, ptr,offset,1) != 1) {
1064 + while ((*ptr != ENV_TLV_TYPE_END) && (size > 1)) {
1066 + /* Adjust pointer for TLV type */
1072 + * Read the length. It can be either 1 or 2 bytes
1073 + * depending on the code
1075 + if (rectype & ENV_LENGTH_8BITS) {
1076 + /* Read the record type and length - 8 bits */
1077 + if (_nvram_read(nv_buf, ptr,offset,1) != 1) {
1085 + /* Read the record type and length - 16 bits, MSB first */
1086 + if (_nvram_read(nv_buf, ptr,offset,2) != 2) {
1089 + reclen = (((unsigned int) *(ptr)) << 8) + (unsigned int) *(ptr+1);
1094 + if (reclen > size)
1095 + break; /* should not happen, bad NVRAM */
1097 + switch (rectype) {
1098 + case ENV_TLV_TYPE_ENV:
1099 + /* Read the TLV data */
1100 + if (_nvram_read(nv_buf, ptr,offset,reclen) != reclen)
1103 + envval = (unsigned char *) _strnchr(ptr,'=',(reclen-1));
1106 + memcpy(_valuestr,envval,(reclen-1)-(envval-ptr));
1107 + _valuestr[(reclen-1)-(envval-ptr)] = '\0';
1109 + printk(KERN_INFO "NVRAM:%s=%s\n", ptr, _valuestr);
1111 + if(!strcmp(ptr, name)){
1114 + if((strlen(ptr) > 1) && !strcmp(&ptr[1], name))
1120 + /* Unknown TLV type, skip it. */
1125 + * Advance to next TLV
1128 + size -= (int)reclen;
1131 + /* Read the next record type */
1133 + if (_nvram_read(nv_buf, ptr,offset,1) != 1)
1142 diff -urN linux.old/arch/mips/bcm947xx/broadcom/linux_osl.c linux.dev/arch/mips/bcm947xx/broadcom/linux_osl.c
1143 --- linux.old/arch/mips/bcm947xx/broadcom/linux_osl.c 1970-01-01 01:00:00.000000000 +0100
1144 +++ linux.dev/arch/mips/bcm947xx/broadcom/linux_osl.c 2005-12-15 17:11:05.818041750 +0100
1147 + * Linux OS Independent Layer
1149 + * Copyright 2005, Broadcom Corporation
1150 + * All Rights Reserved.
1152 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1153 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1154 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1155 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1162 +#include <typedefs.h>
1163 +#include <bcmendian.h>
1164 +#include <linux/module.h>
1165 +#include <linuxver.h>
1167 +#include <bcmutils.h>
1168 +#include <linux/delay.h>
1170 +#include <asm/paccess.h>
1172 +#include <pcicfg.h>
1174 +#define PCI_CFG_RETRY 10
1176 +#define OS_HANDLE_MAGIC 0x1234abcd
1177 +#define BCM_MEM_FILENAME_LEN 24
1179 +typedef struct bcm_mem_link {
1180 + struct bcm_mem_link *prev;
1181 + struct bcm_mem_link *next;
1184 + char file[BCM_MEM_FILENAME_LEN];
1192 + bcm_mem_link_t *dbgmem_list;
1196 +osl_pci_read_config(osl_t *osh, uint offset, uint size)
1199 + uint retry=PCI_CFG_RETRY;
1201 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
1203 + /* only 4byte access supported */
1204 + ASSERT(size == 4);
1207 + pci_read_config_dword(osh->pdev, offset, &val);
1208 + if (val != 0xffffffff)
1210 + } while (retry--);
1217 +osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val)
1219 + uint retry=PCI_CFG_RETRY;
1221 + ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
1223 + /* only 4byte access supported */
1224 + ASSERT(size == 4);
1227 + pci_write_config_dword(osh->pdev, offset, val);
1228 + if (offset!=PCI_BAR0_WIN)
1230 + if (osl_pci_read_config(osh,offset,size) == val)
1232 + } while (retry--);
1237 +osl_delay(uint usec)
1241 + while (usec > 0) {
1242 + d = MIN(usec, 1000);
1248 diff -urN linux.old/arch/mips/bcm947xx/broadcom/nvram.c linux.dev/arch/mips/bcm947xx/broadcom/nvram.c
1249 --- linux.old/arch/mips/bcm947xx/broadcom/nvram.c 1970-01-01 01:00:00.000000000 +0100
1250 +++ linux.dev/arch/mips/bcm947xx/broadcom/nvram.c 2005-12-17 21:41:45.656819500 +0100
1253 + * NVRAM variable manipulation (Linux kernel half)
1255 + * Copyright 2005, Broadcom Corporation
1256 + * All Rights Reserved.
1258 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1259 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1260 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1261 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1266 +#include <linux/config.h>
1267 +#include <linux/init.h>
1268 +#include <linux/module.h>
1269 +#include <linux/kernel.h>
1270 +#include <linux/string.h>
1271 +#include <linux/interrupt.h>
1272 +#include <linux/spinlock.h>
1273 +#include <linux/slab.h>
1274 +#include <asm/bootinfo.h>
1275 +#include <asm/addrspace.h>
1276 +#include <asm/io.h>
1277 +#include <asm/uaccess.h>
1279 +#include <typedefs.h>
1280 +#include <bcmendian.h>
1281 +#include <bcmnvram.h>
1282 +#include <bcmutils.h>
1283 +#include <sbconfig.h>
1284 +#include <sbchipc.h>
1285 +#include <sbutils.h>
1286 +#include <sbmips.h>
1287 +#include <sflash.h>
1289 +/* In BSS to minimize text size and page aligned so it can be mmap()-ed */
1290 +static char nvram_buf[NVRAM_SPACE] __attribute__((aligned(PAGE_SIZE)));
1292 +/* Global SB handle */
1294 +extern spinlock_t bcm947xx_sbh_lock;
1295 +static int cfe_env;
1297 +extern char *cfe_env_get(unsigned char *nv_buf, char *name);
1301 +#define sbh_lock bcm947xx_sbh_lock
1303 +#define MB * 1024 * 1024
1305 +/* Probe for NVRAM header */
1307 +early_nvram_init(void)
1309 + struct nvram_header *header;
1311 + struct sflash *info = NULL;
1313 + uint32 base, off, lim;
1317 + if ((cc = sb_setcore(sbh, SB_CC, 0)) != NULL) {
1318 + base = KSEG1ADDR(SB_FLASH2);
1319 + switch (readl(&cc->capabilities) & CAP_FLASH_MASK) {
1321 + lim = SB_FLASH2_SZ;
1326 + if ((info = sflash_init(cc)) == NULL)
1336 + /* extif assumed, Stop at 4 MB */
1337 + base = KSEG1ADDR(SB_FLASH1);
1338 + lim = SB_FLASH1_SZ;
1341 + /* XXX: hack for supporting the CFE environment stuff on WGT634U */
1342 + src = (u32 *) KSEG1ADDR(base + 8 * 1024 * 1024 - 0x2000);
1343 + dst = (u32 *) nvram_buf;
1344 + if ((lim == 0x02000000) && ((*src & 0xff00ff) == 0x000001)) {
1345 + printk("early_nvram_init: WGT634U NVRAM found.\n");
1347 + for (i = 0; i < 0x1ff0; i++) {
1348 + if (*src == 0xFFFFFFFF)
1357 + while (off <= lim) {
1358 + /* Windowed flash access */
1359 + header = (struct nvram_header *) KSEG1ADDR(base + off - NVRAM_SPACE);
1360 + if (header->magic == NVRAM_MAGIC)
1365 + /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
1366 + header = (struct nvram_header *) KSEG1ADDR(base + 4 KB);
1367 + if (header->magic == NVRAM_MAGIC)
1370 + header = (struct nvram_header *) KSEG1ADDR(base + 1 KB);
1371 + if (header->magic == NVRAM_MAGIC)
1377 + src = (u32 *) header;
1378 + dst = (u32 *) nvram_buf;
1379 + for (i = 0; i < sizeof(struct nvram_header); i += 4)
1381 + for (; i < header->len && i < NVRAM_SPACE; i += 4)
1382 + *dst++ = ltoh32(*src++);
1385 +/* Early (before mm or mtd) read-only access to NVRAM */
1386 +char * __init nvram_get(const char *name)
1388 + char *var, *value, *end, *eq;
1397 + if (!nvram_buf[0])
1398 + early_nvram_init();
1401 + return cfe_env_get(nvram_buf, name);
1403 + /* Look for name=value and return value */
1404 + var = &nvram_buf[sizeof(struct nvram_header)];
1405 + end = nvram_buf + sizeof(nvram_buf) - 2;
1406 + end[0] = end[1] = '\0';
1407 + for (; *var; var = value + strlen(value) + 1) {
1408 + if (!(eq = strchr(var, '=')))
1411 + if ((eq - var) == strlen(name) && strncmp(var, name, (eq - var)) == 0)
1417 diff -urN linux.old/arch/mips/bcm947xx/broadcom/sbmips.c linux.dev/arch/mips/bcm947xx/broadcom/sbmips.c
1418 --- linux.old/arch/mips/bcm947xx/broadcom/sbmips.c 1970-01-01 01:00:00.000000000 +0100
1419 +++ linux.dev/arch/mips/bcm947xx/broadcom/sbmips.c 2005-12-15 16:46:31.122961250 +0100
1422 + * BCM47XX Sonics SiliconBackplane MIPS core routines
1424 + * Copyright 2005, Broadcom Corporation
1425 + * All Rights Reserved.
1427 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
1428 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
1429 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
1430 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
1435 +#include <typedefs.h>
1437 +#include <sbutils.h>
1438 +#include <bcmdevs.h>
1439 +#include <bcmnvram.h>
1440 +#include <bcmutils.h>
1441 +#include <hndmips.h>
1442 +#include <sbconfig.h>
1443 +#include <sbextif.h>
1444 +#include <sbchipc.h>
1445 +#include <sbmemc.h>
1446 +#include <mipsinc.h>
1447 +#include <sbutils.h>
1450 + * Returns TRUE if an external UART exists at the given base
1454 +BCMINITFN(serial_exists)(uint8 *regs)
1456 + uint8 save_mcr, status1;
1458 + save_mcr = R_REG(®s[UART_MCR]);
1459 + W_REG(®s[UART_MCR], UART_MCR_LOOP | 0x0a);
1460 + status1 = R_REG(®s[UART_MSR]) & 0xf0;
1461 + W_REG(®s[UART_MCR], save_mcr);
1463 + return (status1 == 0x90);
1467 + * Initializes UART access. The callback function will be called once
1471 +BCMINITFN(sb_serial_init)(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift))
1478 + if ((regs = sb_setcore(sbh, SB_EXTIF, 0))) {
1479 + extifregs_t *eir = (extifregs_t *) regs;
1482 + /* Determine external UART register base */
1483 + sb = (sbconfig_t *)((ulong) eir + SBCONFIGOFF);
1484 + base = EXTIF_CFGIF_BASE(sb_base(R_REG(&sb->sbadmatch1)));
1486 + /* Determine IRQ */
1487 + irq = sb_irq(sbh);
1489 + /* Disable GPIO interrupt initially */
1490 + W_REG(&eir->gpiointpolarity, 0);
1491 + W_REG(&eir->gpiointmask, 0);
1493 + /* Search for external UARTs */
1495 + for (i = 0; i < 2; i++) {
1496 + regs = (void *) REG_MAP(base + (i * 8), 8);
1497 + if (BCMINIT(serial_exists)(regs)) {
1498 + /* Set GPIO 1 to be the external UART IRQ */
1499 + W_REG(&eir->gpiointmask, 2);
1501 + add(regs, irq, 13500000, 0);
1505 + /* Add internal UART if enabled */
1506 + if (R_REG(&eir->corecontrol) & CC_UE)
1508 + add((void *) &eir->uartdata, irq, sb_clock(sbh), 2);
1509 + } else if ((regs = sb_setcore(sbh, SB_CC, 0))) {
1510 + chipcregs_t *cc = (chipcregs_t *) regs;
1511 + uint32 rev, cap, pll, baud_base, div;
1513 + /* Determine core revision and capabilities */
1514 + rev = sb_corerev(sbh);
1515 + cap = R_REG(&cc->capabilities);
1516 + pll = cap & CAP_PLL_MASK;
1518 + /* Determine IRQ */
1519 + irq = sb_irq(sbh);
1521 + if (pll == PLL_TYPE1) {
1523 + baud_base = sb_clock_rate(pll,
1524 + R_REG(&cc->clockcontrol_n),
1525 + R_REG(&cc->clockcontrol_m2));
1529 + /* Fixed ALP clock */
1530 + baud_base = 20000000;
1532 + /* Set the override bit so we don't divide it */
1533 + W_REG(&cc->corecontrol, CC_UARTCLKO);
1534 + } else if (rev >= 3) {
1535 + /* Internal backplane clock */
1536 + baud_base = sb_clock(sbh);
1537 + div = 2; /* Minimum divisor */
1538 + W_REG(&cc->clkdiv,
1539 + ((R_REG(&cc->clkdiv) & ~CLKD_UART) | div));
1541 + /* Fixed internal backplane clock */
1542 + baud_base = 88000000;
1546 + /* Clock source depends on strapping if UartClkOverride is unset */
1548 + ((R_REG(&cc->corecontrol) & CC_UARTCLKO) == 0)) {
1549 + if ((cap & CAP_UCLKSEL) == CAP_UINTCLK) {
1550 + /* Internal divided backplane clock */
1553 + /* Assume external clock of 1.8432 MHz */
1554 + baud_base = 1843200;
1559 + /* Add internal UARTs */
1560 + n = cap & CAP_UARTS_MASK;
1561 + for (i = 0; i < n; i++) {
1562 + /* Register offset changed after revision 0 */
1564 + regs = (void *)((ulong) &cc->uart0data + (i * 256));
1566 + regs = (void *)((ulong) &cc->uart0data + (i * 8));
1569 + add(regs, irq, baud_base, 0);
1575 + * Initialize jtag master and return handle for
1576 + * jtag_rwreg. Returns NULL on failure.
1579 +sb_jtagm_init(sb_t *sbh, uint clkd, bool exttap)
1583 + if ((regs = sb_setcore(sbh, SB_CC, 0)) != NULL) {
1584 + chipcregs_t *cc = (chipcregs_t *) regs;
1588 + * Determine jtagm availability from
1589 + * core revision and capabilities.
1591 + tmp = sb_corerev(sbh);
1593 + * Corerev 10 has jtagm, but the only chip
1594 + * with it does not have a mips, and
1595 + * the layout of the jtagcmd register is
1596 + * different. We'll only accept >= 11.
1601 + tmp = R_REG(&cc->capabilities);
1602 + if ((tmp & CAP_JTAGP) == 0)
1605 + /* Set clock divider if requested */
1607 + tmp = R_REG(&cc->clkdiv);
1608 + tmp = (tmp & ~CLKD_JTAG) |
1609 + ((clkd << CLKD_JTAG_SHIFT) & CLKD_JTAG);
1610 + W_REG(&cc->clkdiv, tmp);
1613 + /* Enable jtagm */
1614 + tmp = JCTRL_EN | (exttap ? JCTRL_EXT_EN : 0);
1615 + W_REG(&cc->jtagctrl, tmp);
1622 +sb_jtagm_disable(void *h)
1624 + chipcregs_t *cc = (chipcregs_t *)h;
1626 + W_REG(&cc->jtagctrl, R_REG(&cc->jtagctrl) & ~JCTRL_EN);
1630 + * Read/write a jtag register. Assumes a target with
1631 + * 8 bit IR and 32 bit DR.
1636 +jtag_rwreg(void *h, uint32 ir, uint32 dr)
1638 + chipcregs_t *cc = (chipcregs_t *) h;
1641 + W_REG(&cc->jtagir, ir);
1642 + W_REG(&cc->jtagdr, dr);
1643 + tmp = JCMD_START | JCMD_ACC_IRDR |
1644 + ((IRWIDTH - 1) << JCMD_IRW_SHIFT) |
1646 + W_REG(&cc->jtagcmd, tmp);
1647 + while (((tmp = R_REG(&cc->jtagcmd)) & JCMD_BUSY) == JCMD_BUSY) {
1648 + /* OSL_DELAY(1); */
1651 + tmp = R_REG(&cc->jtagdr);
1655 +/* Returns the SB interrupt flag of the current core. */
1662 + regs = sb_coreregs(sbh);
1663 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
1665 + return (R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK);
1668 +static const uint32 sbips_int_mask[] = {
1676 +static const uint32 sbips_int_shift[] = {
1685 + * Returns the MIPS IRQ assignment of the current core. If unassigned,
1694 + uint32 flag, sbipsflag;
1697 + flag = sb_flag(sbh);
1699 + idx = sb_coreidx(sbh);
1701 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
1702 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
1703 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
1705 + /* sbipsflag specifies which core is routed to interrupts 1 to 4 */
1706 + sbipsflag = R_REG(&sb->sbipsflag);
1707 + for (irq = 1; irq <= 4; irq++) {
1708 + if (((sbipsflag & sbips_int_mask[irq]) >> sbips_int_shift[irq]) == flag)
1715 + sb_setcoreidx(sbh, idx);
1720 +/* Clears the specified MIPS IRQ. */
1722 +BCMINITFN(sb_clearirq)(sb_t *sbh, uint irq)
1727 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
1728 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
1730 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
1733 + W_REG(&sb->sbintvec, 0);
1735 + OR_REG(&sb->sbipsflag, sbips_int_mask[irq]);
1739 + * Assigns the specified MIPS IRQ to the specified core. Shared MIPS
1740 + * IRQ 0 may be assigned more than once.
1743 +BCMINITFN(sb_setirq)(sb_t *sbh, uint irq, uint coreid, uint coreunit)
1749 + regs = sb_setcore(sbh, coreid, coreunit);
1751 + flag = sb_flag(sbh);
1753 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) &&
1754 + !(regs = sb_setcore(sbh, SB_MIPS33, 0)))
1756 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
1759 + OR_REG(&sb->sbintvec, 1 << flag);
1761 + flag <<= sbips_int_shift[irq];
1762 + ASSERT(!(flag & ~sbips_int_mask[irq]));
1763 + flag |= R_REG(&sb->sbipsflag) & ~sbips_int_mask[irq];
1764 + W_REG(&sb->sbipsflag, flag);
1769 + * Initializes clocks and interrupts. SB and NVRAM access must be
1770 + * initialized prior to calling.
1773 +BCMINITFN(sb_mips_init)(sb_t *sbh)
1775 + ulong hz, ns, tmp;
1781 + /* Figure out current SB clock speed */
1782 + if ((hz = sb_clock(sbh)) == 0)
1784 + ns = 1000000000 / hz;
1786 + /* Setup external interface timing */
1787 + if ((eir = sb_setcore(sbh, SB_EXTIF, 0))) {
1788 + /* Initialize extif so we can get to the LEDs and external UART */
1789 + W_REG(&eir->prog_config, CF_EN);
1791 + /* Set timing for the flash */
1792 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
1793 + tmp = tmp | (CEIL(40, ns) << FW_W1_SHIFT); /* W1 = 40nS */
1794 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
1795 + W_REG(&eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
1797 + /* Set programmable interface timing for external uart */
1798 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
1799 + tmp = tmp | (CEIL(20, ns) << FW_W2_SHIFT); /* W2 = 20nS */
1800 + tmp = tmp | (CEIL(100, ns) << FW_W1_SHIFT); /* W1 = 100nS */
1801 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */
1802 + W_REG(&eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */
1803 + } else if ((cc = sb_setcore(sbh, SB_CC, 0))) {
1804 + /* Set timing for the flash */
1805 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */
1806 + tmp |= CEIL(10, ns) << FW_W1_SHIFT; /* W1 = 10nS */
1807 + tmp |= CEIL(120, ns); /* W0 = 120nS */
1809 + // Added by Chen-I for 5365
1810 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
1812 + W_REG(&cc->flash_waitcount, tmp);
1813 + W_REG(&cc->pcmcia_memwait, tmp);
1817 + if (sb_corerev(sbh) < 9)
1818 + W_REG(&cc->flash_waitcount, tmp);
1820 + if ((sb_corerev(sbh) < 9) ||
1821 + ((BCMINIT(sb_chip)(sbh) == BCM5350_DEVICE_ID) && BCMINIT(sb_chiprev)(sbh) == 0)) {
1822 + W_REG(&cc->pcmcia_memwait, tmp);
1827 + /* Chip specific initialization */
1828 + switch (BCMINIT(sb_chip)(sbh)) {
1829 + case BCM4710_DEVICE_ID:
1830 + /* Clear interrupt map */
1831 + for (irq = 0; irq <= 4; irq++)
1832 + BCMINIT(sb_clearirq)(sbh, irq);
1833 + BCMINIT(sb_setirq)(sbh, 0, SB_CODEC, 0);
1834 + BCMINIT(sb_setirq)(sbh, 0, SB_EXTIF, 0);
1835 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 1);
1836 + BCMINIT(sb_setirq)(sbh, 3, SB_ILINE20, 0);
1837 + BCMINIT(sb_setirq)(sbh, 4, SB_PCI, 0);
1839 + value = BCMINIT(nvram_get)("et0phyaddr");
1840 + if (value && !strcmp(value, "31")) {
1841 + /* Enable internal UART */
1842 + W_REG(&eir->corecontrol, CC_UE);
1843 + /* Give USB its own interrupt */
1844 + BCMINIT(sb_setirq)(sbh, 1, SB_USB, 0);
1846 + /* Disable internal UART */
1847 + W_REG(&eir->corecontrol, 0);
1848 + /* Give Ethernet its own interrupt */
1849 + BCMINIT(sb_setirq)(sbh, 1, SB_ENET, 0);
1850 + BCMINIT(sb_setirq)(sbh, 0, SB_USB, 0);
1853 + case BCM5350_DEVICE_ID:
1854 + /* Clear interrupt map */
1855 + for (irq = 0; irq <= 4; irq++)
1856 + BCMINIT(sb_clearirq)(sbh, irq);
1857 + BCMINIT(sb_setirq)(sbh, 0, SB_CC, 0);
1858 + BCMINIT(sb_setirq)(sbh, 1, SB_D11, 0);
1859 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 0);
1860 + BCMINIT(sb_setirq)(sbh, 3, SB_PCI, 0);
1861 + BCMINIT(sb_setirq)(sbh, 4, SB_USB, 0);
1867 +BCMINITFN(sb_mips_clock)(sb_t *sbh)
1873 + uint32 pll_type, rate = 0;
1875 + /* get index of the current core */
1876 + idx = sb_coreidx(sbh);
1877 + pll_type = PLL_TYPE1;
1879 + /* switch to extif or chipc core */
1880 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
1881 + n = R_REG(&eir->clockcontrol_n);
1882 + m = R_REG(&eir->clockcontrol_sb);
1883 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
1884 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
1885 + n = R_REG(&cc->clockcontrol_n);
1886 + if ((pll_type == PLL_TYPE2) ||
1887 + (pll_type == PLL_TYPE4) ||
1888 + (pll_type == PLL_TYPE6) ||
1889 + (pll_type == PLL_TYPE7))
1890 + m = R_REG(&cc->clockcontrol_mips);
1891 + else if (pll_type == PLL_TYPE5) {
1895 + else if (pll_type == PLL_TYPE3) {
1896 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID) { /* 5365 is also type3 */
1900 + m = R_REG(&cc->clockcontrol_m2); /* 5350 uses m2 to control mips */
1902 + m = R_REG(&cc->clockcontrol_sb);
1906 + // Added by Chen-I for 5365
1907 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
1910 + /* calculate rate */
1911 + rate = sb_clock_rate(pll_type, n, m);
1913 + if (pll_type == PLL_TYPE6)
1914 + rate = SB2MIPS_T6(rate);
1917 + /* switch back to previous core */
1918 + sb_setcoreidx(sbh, idx);
1923 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4)
1926 +BCMINITFN(handler)(void)
1930 + ".set\tmips32\n\t"
1933 + /* Disable interrupts */
1934 + /* MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) & ~(ALLINTS | STO_IE)); */
1935 + "mfc0 $15, $12\n\t"
1936 + /* Just a Hack to not to use reg 'at' which was causing problems on 4704 A2 */
1937 + "li $14, -31746\n\t"
1938 + "and $15, $15, $14\n\t"
1939 + "mtc0 $15, $12\n\t"
1947 +/* The following MUST come right after handler() */
1949 +BCMINITFN(afterhandler)(void)
1954 + * Set the MIPS, backplane and PCI clocks as closely as possible.
1957 +BCMINITFN(sb_mips_setclock)(sb_t *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock)
1959 + extifregs_t *eir = NULL;
1960 + chipcregs_t *cc = NULL;
1961 + mipsregs_t *mipsr = NULL;
1962 + volatile uint32 *clockcontrol_n, *clockcontrol_sb, *clockcontrol_pci, *clockcontrol_m2;
1963 + uint32 orig_n, orig_sb, orig_pci, orig_m2, orig_mips, orig_ratio_parm, orig_ratio_cfg;
1964 + uint32 pll_type, sync_mode;
1965 + uint ic_size, ic_lsize;
1974 + static n3m_table_t BCMINITDATA(type1_table)[] = {
1975 + { 96000000, 0x0303, 0x04020011, 0x11030011, 0x11050011 }, /* 96.000 32.000 24.000 */
1976 + { 100000000, 0x0009, 0x04020011, 0x11030011, 0x11050011 }, /* 100.000 33.333 25.000 */
1977 + { 104000000, 0x0802, 0x04020011, 0x11050009, 0x11090009 }, /* 104.000 31.200 24.960 */
1978 + { 108000000, 0x0403, 0x04020011, 0x11050009, 0x02000802 }, /* 108.000 32.400 24.923 */
1979 + { 112000000, 0x0205, 0x04020011, 0x11030021, 0x02000403 }, /* 112.000 32.000 24.889 */
1980 + { 115200000, 0x0303, 0x04020009, 0x11030011, 0x11050011 }, /* 115.200 32.000 24.000 */
1981 + { 120000000, 0x0011, 0x04020011, 0x11050011, 0x11090011 }, /* 120.000 30.000 24.000 */
1982 + { 124800000, 0x0802, 0x04020009, 0x11050009, 0x11090009 }, /* 124.800 31.200 24.960 */
1983 + { 128000000, 0x0305, 0x04020011, 0x11050011, 0x02000305 }, /* 128.000 32.000 24.000 */
1984 + { 132000000, 0x0603, 0x04020011, 0x11050011, 0x02000305 }, /* 132.000 33.000 24.750 */
1985 + { 136000000, 0x0c02, 0x04020011, 0x11090009, 0x02000603 }, /* 136.000 32.640 24.727 */
1986 + { 140000000, 0x0021, 0x04020011, 0x11050021, 0x02000c02 }, /* 140.000 30.000 24.706 */
1987 + { 144000000, 0x0405, 0x04020011, 0x01020202, 0x11090021 }, /* 144.000 30.857 24.686 */
1988 + { 150857142, 0x0605, 0x04020021, 0x02000305, 0x02000605 }, /* 150.857 33.000 24.000 */
1989 + { 152000000, 0x0e02, 0x04020011, 0x11050021, 0x02000e02 }, /* 152.000 32.571 24.000 */
1990 + { 156000000, 0x0802, 0x04020005, 0x11050009, 0x11090009 }, /* 156.000 31.200 24.960 */
1991 + { 160000000, 0x0309, 0x04020011, 0x11090011, 0x02000309 }, /* 160.000 32.000 24.000 */
1992 + { 163200000, 0x0c02, 0x04020009, 0x11090009, 0x02000603 }, /* 163.200 32.640 24.727 */
1993 + { 168000000, 0x0205, 0x04020005, 0x11030021, 0x02000403 }, /* 168.000 32.000 24.889 */
1994 + { 176000000, 0x0602, 0x04020003, 0x11050005, 0x02000602 }, /* 176.000 33.000 24.000 */
1999 + uint32 m2; /* that is the clockcontrol_m2 */
2001 + static type3_table_t type3_table[] = { /* for 5350, mips clock is always double sb clock */
2002 + { 150000000, 0x311, 0x4020005 },
2003 + { 200000000, 0x311, 0x4020003 },
2014 + uint32 ratio_parm;
2017 + static n4m_table_t BCMINITDATA(type2_table)[] = {
2018 + { 180000000, 80000000, 0x0403, 0x01010000, 0x01020300, 0x01020600, 0x05000100, 8, 0x012a00a9 },
2019 + { 180000000, 90000000, 0x0403, 0x01000100, 0x01020300, 0x01000100, 0x05000100, 11, 0x0aaa0555 },
2020 + { 200000000, 100000000, 0x0303, 0x02010000, 0x02040001, 0x02010000, 0x06000001, 11, 0x0aaa0555 },
2021 + { 211200000, 105600000, 0x0902, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
2022 + { 220800000, 110400000, 0x1500, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
2023 + { 230400000, 115200000, 0x0604, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
2024 + { 234000000, 104000000, 0x0b01, 0x01010000, 0x01010700, 0x01020600, 0x05000100, 8, 0x012a00a9 },
2025 + { 240000000, 120000000, 0x0803, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
2026 + { 252000000, 126000000, 0x0504, 0x01000100, 0x01020500, 0x01000100, 0x05000100, 11, 0x0aaa0555 },
2027 + { 264000000, 132000000, 0x0903, 0x01000200, 0x01020700, 0x01000200, 0x05000200, 11, 0x0aaa0555 },
2028 + { 270000000, 120000000, 0x0703, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 },
2029 + { 276000000, 122666666, 0x1500, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 },
2030 + { 280000000, 140000000, 0x0503, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 11, 0x0aaa0555 },
2031 + { 288000000, 128000000, 0x0604, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 },
2032 + { 288000000, 144000000, 0x0404, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 11, 0x0aaa0555 },
2033 + { 300000000, 133333333, 0x0803, 0x01010000, 0x01020600, 0x01020600, 0x05000100, 8, 0x012a00a9 },
2034 + { 300000000, 150000000, 0x0803, 0x01000100, 0x01020600, 0x01000100, 0x05000100, 11, 0x0aaa0555 }
2037 + static n4m_table_t BCMINITDATA(type4_table)[] = {
2038 + { 192000000, 96000000, 0x0702, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 },
2039 + { 198000000, 99000000, 0x0603, 0x11020005, 0x11030011, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
2040 + { 200000000, 100000000, 0x0009, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 11, 0x0aaa0555 },
2041 + { 204000000, 102000000, 0x0c02, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
2042 + { 208000000, 104000000, 0x0802, 0x11030002, 0x11090005, 0x11030002, 0x04000003, 11, 0x0aaa0555 },
2043 + { 210000000, 105000000, 0x0209, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
2044 + { 216000000, 108000000, 0x0111, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
2045 + { 224000000, 112000000, 0x0205, 0x11030002, 0x02002103, 0x11030002, 0x04000003, 11, 0x0aaa0555 },
2046 + { 228000000, 101333333, 0x0e02, 0x11030003, 0x11210005, 0x01030305, 0x04000005, 8, 0x012a00a9 },
2047 + { 228000000, 114000000, 0x0e02, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
2048 + { 240000000, 102857143, 0x0109, 0x04000021, 0x01050203, 0x11030021, 0x04000003, 13, 0x254a14a9 },
2049 + { 240000000, 120000000, 0x0109, 0x11030002, 0x01050203, 0x11030002, 0x04000003, 11, 0x0aaa0555 },
2050 + { 252000000, 100800000, 0x0203, 0x04000009, 0x11050005, 0x02000209, 0x04000002, 9, 0x02520129 },
2051 + { 252000000, 126000000, 0x0203, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 11, 0x0aaa0555 },
2052 + { 264000000, 132000000, 0x0602, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 11, 0x0aaa0555 },
2053 + { 272000000, 116571428, 0x0c02, 0x04000021, 0x02000909, 0x02000221, 0x04000003, 13, 0x254a14a9 },
2054 + { 280000000, 120000000, 0x0209, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 13, 0x254a14a9 },
2055 + { 288000000, 123428571, 0x0111, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 13, 0x254a14a9 },
2056 + { 300000000, 120000000, 0x0009, 0x04000009, 0x01030203, 0x02000902, 0x04000002, 9, 0x02520129 },
2057 + { 300000000, 150000000, 0x0009, 0x04000005, 0x01030203, 0x04000005, 0x04000002, 11, 0x0aaa0555 }
2060 + static n4m_table_t BCMINITDATA(type7_table)[] = {
2061 + { 183333333, 91666666, 0x0605, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 },
2062 + { 187500000, 93750000, 0x0a03, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 },
2063 + { 196875000, 98437500, 0x1003, 0x11020005, 0x11050011, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
2064 + { 200000000, 100000000, 0x0311, 0x04000011, 0x11030011, 0x04000009, 0x04000003, 11, 0x0aaa0555 },
2065 + { 200000000, 100000000, 0x0311, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 11, 0x0aaa0555 },
2066 + { 206250000, 103125000, 0x1103, 0x11020005, 0x11050011, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
2067 + { 212500000, 106250000, 0x0c05, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
2068 + { 215625000, 107812500, 0x1203, 0x11090009, 0x11050005, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
2069 + { 216666666, 108333333, 0x0805, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 },
2070 + { 225000000, 112500000, 0x0d03, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 },
2071 + { 233333333, 116666666, 0x0905, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 },
2072 + { 237500000, 118750000, 0x0e05, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 11, 0x0aaa0555 },
2073 + { 240000000, 120000000, 0x0b11, 0x11020009, 0x11210009, 0x11020009, 0x04000009, 11, 0x0aaa0555 },
2074 + { 250000000, 125000000, 0x0f03, 0x11020003, 0x11210003, 0x11020003, 0x04000003, 11, 0x0aaa0555 }
2077 + ulong start, end, dst;
2080 + /* get index of the current core */
2081 + idx = sb_coreidx(sbh);
2082 + clockcontrol_m2 = NULL;
2084 + /* switch to extif or chipc core */
2085 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
2086 + pll_type = PLL_TYPE1;
2087 + clockcontrol_n = &eir->clockcontrol_n;
2088 + clockcontrol_sb = &eir->clockcontrol_sb;
2089 + clockcontrol_pci = &eir->clockcontrol_pci;
2090 + clockcontrol_m2 = &cc->clockcontrol_m2;
2091 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
2092 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
2093 + if (pll_type == PLL_TYPE6) {
2094 + clockcontrol_n = NULL;
2095 + clockcontrol_sb = NULL;
2096 + clockcontrol_pci = NULL;
2098 + clockcontrol_n = &cc->clockcontrol_n;
2099 + clockcontrol_sb = &cc->clockcontrol_sb;
2100 + clockcontrol_pci = &cc->clockcontrol_pci;
2101 + clockcontrol_m2 = &cc->clockcontrol_m2;
2106 + if (pll_type == PLL_TYPE6) {
2107 + /* Silence compilers */
2108 + orig_n = orig_sb = orig_pci = 0;
2110 + /* Store the current clock register values */
2111 + orig_n = R_REG(clockcontrol_n);
2112 + orig_sb = R_REG(clockcontrol_sb);
2113 + orig_pci = R_REG(clockcontrol_pci);
2116 + if (pll_type == PLL_TYPE1) {
2117 + /* Keep the current PCI clock if not specified */
2118 + if (pciclock == 0) {
2119 + pciclock = sb_clock_rate(pll_type, R_REG(clockcontrol_n), R_REG(clockcontrol_pci));
2120 + pciclock = (pciclock <= 25000000) ? 25000000 : 33000000;
2123 + /* Search for the closest MIPS clock less than or equal to a preferred value */
2124 + for (i = 0; i < ARRAYSIZE(BCMINIT(type1_table)); i++) {
2125 + ASSERT(BCMINIT(type1_table)[i].mipsclock ==
2126 + sb_clock_rate(pll_type, BCMINIT(type1_table)[i].n, BCMINIT(type1_table)[i].sb));
2127 + if (BCMINIT(type1_table)[i].mipsclock > mipsclock)
2137 + ASSERT(BCMINIT(type1_table)[i].mipsclock <= mipsclock);
2139 + /* No PLL change */
2140 + if ((orig_n == BCMINIT(type1_table)[i].n) &&
2141 + (orig_sb == BCMINIT(type1_table)[i].sb) &&
2142 + (orig_pci == BCMINIT(type1_table)[i].pci33))
2145 + /* Set the PLL controls */
2146 + W_REG(clockcontrol_n, BCMINIT(type1_table)[i].n);
2147 + W_REG(clockcontrol_sb, BCMINIT(type1_table)[i].sb);
2148 + if (pciclock == 25000000)
2149 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci25);
2151 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci33);
2154 + sb_watchdog(sbh, 1);
2157 + } else if ((pll_type == PLL_TYPE3) &&
2158 + (BCMINIT(sb_chip)(sbh) != BCM5365_DEVICE_ID)) {
2160 + /* Search for the closest MIPS clock less than or equal to a preferred value */
2162 + for (i = 0; i < ARRAYSIZE(type3_table); i++) {
2163 + if (type3_table[i].mipsclock > mipsclock)
2173 + ASSERT(type3_table[i].mipsclock <= mipsclock);
2175 + /* No PLL change */
2176 + orig_m2 = R_REG(&cc->clockcontrol_m2);
2177 + if ((orig_n == type3_table[i].n) &&
2178 + (orig_m2 == type3_table[i].m2)) {
2182 + /* Set the PLL controls */
2183 + W_REG(clockcontrol_n, type3_table[i].n);
2184 + W_REG(clockcontrol_m2, type3_table[i].m2);
2187 + sb_watchdog(sbh, 1);
2189 + } else if ((pll_type == PLL_TYPE2) ||
2190 + (pll_type == PLL_TYPE4) ||
2191 + (pll_type == PLL_TYPE6) ||
2192 + (pll_type == PLL_TYPE7)) {
2193 + n4m_table_t *table = NULL, *te;
2198 + orig_mips = R_REG(&cc->clockcontrol_mips);
2200 + if (pll_type == PLL_TYPE6) {
2201 + uint32 new_mips = 0;
2204 + if (mipsclock <= SB2MIPS_T6(CC_T6_M1))
2205 + new_mips = CC_T6_MMASK;
2207 + if (orig_mips == new_mips)
2210 + W_REG(&cc->clockcontrol_mips, new_mips);
2214 + if (pll_type == PLL_TYPE2) {
2215 + table = BCMINIT(type2_table);
2216 + tabsz = ARRAYSIZE(BCMINIT(type2_table));
2217 + } else if (pll_type == PLL_TYPE4) {
2218 + table = BCMINIT(type4_table);
2219 + tabsz = ARRAYSIZE(BCMINIT(type4_table));
2220 + } else if (pll_type == PLL_TYPE7) {
2221 + table = BCMINIT(type7_table);
2222 + tabsz = ARRAYSIZE(BCMINIT(type7_table));
2224 + ASSERT("No table for plltype" == NULL);
2226 + /* Store the current clock register values */
2227 + orig_m2 = R_REG(&cc->clockcontrol_m2);
2228 + orig_ratio_parm = 0;
2229 + orig_ratio_cfg = 0;
2231 + /* Look up current ratio */
2232 + for (i = 0; i < tabsz; i++) {
2233 + if ((orig_n == table[i].n) &&
2234 + (orig_sb == table[i].sb) &&
2235 + (orig_pci == table[i].pci33) &&
2236 + (orig_m2 == table[i].m2) &&
2237 + (orig_mips == table[i].m3)) {
2238 + orig_ratio_parm = table[i].ratio_parm;
2239 + orig_ratio_cfg = table[i].ratio_cfg;
2244 + /* Search for the closest MIPS clock greater or equal to a preferred value */
2245 + for (i = 0; i < tabsz; i++) {
2246 + ASSERT(table[i].mipsclock ==
2247 + sb_clock_rate(pll_type, table[i].n, table[i].m3));
2248 + if ((mipsclock <= table[i].mipsclock) &&
2249 + ((sbclock == 0) || (sbclock <= table[i].sbclock)))
2260 + /* No PLL change */
2261 + if ((orig_n == te->n) &&
2262 + (orig_sb == te->sb) &&
2263 + (orig_pci == te->pci33) &&
2264 + (orig_m2 == te->m2) &&
2265 + (orig_mips == te->m3))
2268 + /* Set the PLL controls */
2269 + W_REG(clockcontrol_n, te->n);
2270 + W_REG(clockcontrol_sb, te->sb);
2271 + W_REG(clockcontrol_pci, te->pci33);
2272 + W_REG(&cc->clockcontrol_m2, te->m2);
2273 + W_REG(&cc->clockcontrol_mips, te->m3);
2275 + /* Set the chipcontrol bit to change mipsref to the backplane divider if needed */
2276 + if ((pll_type == PLL_TYPE7) &&
2277 + (te->sb != te->m2) &&
2278 + (sb_clock_rate(pll_type, te->n, te->m2) == 120000000))
2279 + W_REG(&cc->chipcontrol, R_REG(&cc->chipcontrol) | 0x100);
2281 + /* No ratio change */
2282 + if (orig_ratio_parm == te->ratio_parm)
2285 + icache_probe(MFC0(C0_CONFIG, 1), &ic_size, &ic_lsize);
2287 + /* Preload the code into the cache */
2288 + start = ((ulong) &&start_fill) & ~(ic_lsize - 1);
2289 + end = ((ulong) &&end_fill + (ic_lsize - 1)) & ~(ic_lsize - 1);
2290 + while (start < end) {
2291 + cache_op(start, Fill_I);
2292 + start += ic_lsize;
2295 + /* Copy the handler */
2296 + start = (ulong) &BCMINIT(handler);
2297 + end = (ulong) &BCMINIT(afterhandler);
2298 + dst = KSEG1ADDR(0x180);
2299 + for (i = 0; i < (end - start); i += 4)
2300 + *((ulong *)(dst + i)) = *((ulong *)(start + i));
2302 + /* Preload handler into the cache one line at a time */
2303 + for (i = 0; i < (end - start); i += 4)
2304 + cache_op(dst + i, Fill_I);
2306 + /* Clear BEV bit */
2307 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) & ~ST0_BEV);
2309 + /* Enable interrupts */
2310 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) | (ALLINTS | ST0_IE));
2312 + /* Enable MIPS timer interrupt */
2313 + if (!(mipsr = sb_setcore(sbh, SB_MIPS, 0)) &&
2314 + !(mipsr = sb_setcore(sbh, SB_MIPS33, 0)))
2316 + W_REG(&mipsr->intmask, 1);
2319 + /* step 1, set clock ratios */
2320 + MTC0(C0_BROADCOM, 3, te->ratio_parm);
2321 + MTC0(C0_BROADCOM, 1, te->ratio_cfg);
2323 + /* step 2: program timer intr */
2324 + W_REG(&mipsr->timer, 100);
2325 + (void) R_REG(&mipsr->timer);
2327 + /* step 3, switch to async */
2328 + sync_mode = MFC0(C0_BROADCOM, 4);
2329 + MTC0(C0_BROADCOM, 4, 1 << 22);
2331 + /* step 4, set cfg active */
2332 + MTC0(C0_BROADCOM, 2, 0x9);
2336 + __asm__ __volatile__ (
2342 + /* step 7, clear cfg_active */
2343 + MTC0(C0_BROADCOM, 2, 0);
2345 + /* Additional Step: set back to orig sync mode */
2346 + MTC0(C0_BROADCOM, 4, sync_mode);
2348 + /* step 8, fake soft reset */
2349 + MTC0(C0_BROADCOM, 5, MFC0(C0_BROADCOM, 5) | 4);
2352 + /* step 9 set watchdog timer */
2353 + sb_watchdog(sbh, 20);
2354 + (void) R_REG(&cc->chipid);
2357 + __asm__ __volatile__ (
2367 + /* switch back to previous core */
2368 + sb_setcoreidx(sbh, idx);
2374 + * This also must be run from the cache on 47xx
2375 + * so there are no mips core BIU ops in progress
2376 + * when the PFC is enabled.
2380 +BCMINITFN(_enable_pfc)(uint32 mode)
2383 + *(volatile uint32 *)PFC_CR1 = 0xffff0000;
2386 + *(volatile uint32 *)PFC_CR0 = mode;
2390 +BCMINITFN(enable_pfc)(uint32 mode)
2395 + /* If auto then choose the correct mode for this
2396 + platform, currently we only ever select one mode */
2397 + if (mode == PFC_AUTO)
2400 + /* enable prefetch cache if available */
2401 + if (MFC0(C0_BROADCOM, 0) & BRCM_PFC_AVAIL) {
2402 + start = (ulong) &BCMINIT(_enable_pfc);
2403 + end = (ulong) &BCMINIT(enable_pfc);
2405 + /* Preload handler into the cache one line at a time */
2406 + for (i = 0; i < (end - start); i += 4)
2407 + cache_op(start + i, Fill_I);
2409 + BCMINIT(_enable_pfc)(mode);
2413 +/* returns the ncdl value to be programmed into sdram_ncdl for calibration */
2415 +BCMINITFN(sb_memc_get_ncdl)(sb_t *sbh)
2417 + sbmemcregs_t *memc;
2419 + uint32 config, rd, wr, misc, dqsg, cd, sm, sd;
2422 + idx = sb_coreidx(sbh);
2424 + memc = (sbmemcregs_t *)sb_setcore(sbh, SB_MEMC, 0);
2428 + rev = sb_corerev(sbh);
2430 + config = R_REG(&memc->config);
2431 + wr = R_REG(&memc->wrncdlcor);
2432 + rd = R_REG(&memc->rdncdlcor);
2433 + misc = R_REG(&memc->miscdlyctl);
2434 + dqsg = R_REG(&memc->dqsgatencdl);
2436 + rd &= MEMC_RDNCDLCOR_RD_MASK;
2437 + wr &= MEMC_WRNCDLCOR_WR_MASK;
2438 + dqsg &= MEMC_DQSGATENCDL_G_MASK;
2440 + if (config & MEMC_CONFIG_DDR) {
2441 + ret = (wr << 16) | (rd << 8) | dqsg;
2446 + cd = (rd == MEMC_CD_THRESHOLD) ? rd : (wr + MEMC_CD_THRESHOLD);
2447 + sm = (misc & MEMC_MISC_SM_MASK) >> MEMC_MISC_SM_SHIFT;
2448 + sd = (misc & MEMC_MISC_SD_MASK) >> MEMC_MISC_SD_SHIFT;
2449 + ret = (sm << 16) | (sd << 8) | cd;
2453 + /* switch back to previous core */
2454 + sb_setcoreidx(sbh, idx);
2459 diff -urN linux.old/arch/mips/bcm947xx/broadcom/sbpci.c linux.dev/arch/mips/bcm947xx/broadcom/sbpci.c
2460 --- linux.old/arch/mips/bcm947xx/broadcom/sbpci.c 1970-01-01 01:00:00.000000000 +0100
2461 +++ linux.dev/arch/mips/bcm947xx/broadcom/sbpci.c 2005-12-15 23:50:31.846688500 +0100
2464 + * Low-Level PCI and SB support for BCM47xx
2466 + * Copyright 2005, Broadcom Corporation
2467 + * All Rights Reserved.
2469 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
2470 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
2471 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
2472 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
2477 +#include <typedefs.h>
2478 +#include <pcicfg.h>
2479 +#include <bcmdevs.h>
2480 +#include <sbconfig.h>
2482 +#include <sbutils.h>
2484 +#include <bcmendian.h>
2485 +#include <bcmutils.h>
2486 +#include <bcmnvram.h>
2487 +#include <hndmips.h>
2489 +/* Can free sbpci_init() memory after boot */
2494 +/* Emulated configuration space */
2495 +static pci_config_regs sb_config_regs[SB_MAXCORES];
2498 +static uint16 pci_ban[32] = { 0 };
2499 +static uint pci_banned = 0;
2502 +static bool cardbus = FALSE;
2504 +/* Disable PCI host core */
2505 +static bool pci_disabled = FALSE;
2508 + * Functions for accessing external PCI configuration space
2511 +/* Assume one-hot slot wiring */
2512 +#define PCI_SLOT_MAX 16
2515 +config_cmd(sb_t *sbh, uint bus, uint dev, uint func, uint off)
2518 + sbpciregs_t *regs;
2521 + /* CardBusMode supports only one device */
2522 + if (cardbus && dev > 1)
2525 + coreidx = sb_coreidx(sbh);
2526 + regs = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0);
2528 + /* Type 0 transaction */
2530 + /* Skip unwired slots */
2531 + if (dev < PCI_SLOT_MAX) {
2532 + /* Slide the PCI window to the appropriate slot */
2533 + W_REG(®s->sbtopci1, SBTOPCI_CFG0 | ((1 << (dev + 16)) & SBTOPCI1_MASK));
2534 + addr = SB_PCI_CFG | ((1 << (dev + 16)) & ~SBTOPCI1_MASK) |
2535 + (func << 8) | (off & ~3);
2539 + /* Type 1 transaction */
2541 + W_REG(®s->sbtopci1, SBTOPCI_CFG1);
2542 + addr = SB_PCI_CFG | (bus << 16) | (dev << 11) | (func << 8) | (off & ~3);
2545 + sb_setcoreidx(sbh, coreidx);
2551 +extpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
2553 + uint32 addr, *reg = NULL, val;
2556 + if (pci_disabled ||
2557 + !(addr = config_cmd(sbh, bus, dev, func, off)) ||
2558 + !(reg = (uint32 *) REG_MAP(addr, len)) ||
2559 + BUSPROBE(val, reg))
2562 + val >>= 8 * (off & 3);
2564 + *((uint32 *) buf) = val;
2565 + else if (len == 2)
2566 + *((uint16 *) buf) = (uint16) val;
2567 + else if (len == 1)
2568 + *((uint8 *) buf) = (uint8) val;
2579 +extpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
2581 + uint32 addr, *reg = NULL, val;
2584 + if (pci_disabled ||
2585 + !(addr = config_cmd(sbh, bus, dev, func, off)) ||
2586 + !(reg = (uint32 *) REG_MAP(addr, len)) ||
2587 + BUSPROBE(val, reg))
2591 + val = *((uint32 *) buf);
2592 + else if (len == 2) {
2593 + val &= ~(0xffff << (8 * (off & 3)));
2594 + val |= *((uint16 *) buf) << (8 * (off & 3));
2595 + } else if (len == 1) {
2596 + val &= ~(0xff << (8 * (off & 3)));
2597 + val |= *((uint8 *) buf) << (8 * (off & 3));
2611 + * Functions for accessing translated SB configuration space
2615 +sb_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
2617 + pci_config_regs *cfg;
2619 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
2621 + cfg = &sb_config_regs[dev];
2623 + ASSERT(ISALIGNED(off, len));
2624 + ASSERT(ISALIGNED((uintptr)buf, len));
2627 + *((uint32 *) buf) = ltoh32(*((uint32 *)((ulong) cfg + off)));
2628 + else if (len == 2)
2629 + *((uint16 *) buf) = ltoh16(*((uint16 *)((ulong) cfg + off)));
2630 + else if (len == 1)
2631 + *((uint8 *) buf) = *((uint8 *)((ulong) cfg + off));
2639 +sb_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
2644 + pci_config_regs *cfg;
2646 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
2648 + cfg = &sb_config_regs[dev];
2650 + ASSERT(ISALIGNED(off, len));
2651 + ASSERT(ISALIGNED((uintptr)buf, len));
2653 + /* Emulate BAR sizing */
2654 + if (off >= OFFSETOF(pci_config_regs, base[0]) && off <= OFFSETOF(pci_config_regs, base[3]) &&
2655 + len == 4 && *((uint32 *) buf) == ~0) {
2656 + coreidx = sb_coreidx(sbh);
2657 + if ((regs = sb_setcoreidx(sbh, dev))) {
2658 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
2659 + /* Highest numbered address match register */
2660 + n = (R_REG(&sb->sbidlow) & SBIDL_AR_MASK) >> SBIDL_AR_SHIFT;
2661 + if (off == OFFSETOF(pci_config_regs, base[0]))
2662 + cfg->base[0] = ~(sb_size(R_REG(&sb->sbadmatch0)) - 1);
2664 + else if (off == OFFSETOF(pci_config_regs, base[1]) && n >= 1)
2665 + cfg->base[1] = ~(sb_size(R_REG(&sb->sbadmatch1)) - 1);
2666 + else if (off == OFFSETOF(pci_config_regs, base[2]) && n >= 2)
2667 + cfg->base[2] = ~(sb_size(R_REG(&sb->sbadmatch2)) - 1);
2668 + else if (off == OFFSETOF(pci_config_regs, base[3]) && n >= 3)
2669 + cfg->base[3] = ~(sb_size(R_REG(&sb->sbadmatch3)) - 1);
2672 + sb_setcoreidx(sbh, coreidx);
2677 + *((uint32 *)((ulong) cfg + off)) = htol32(*((uint32 *) buf));
2678 + else if (len == 2)
2679 + *((uint16 *)((ulong) cfg + off)) = htol16(*((uint16 *) buf));
2680 + else if (len == 1)
2681 + *((uint8 *)((ulong) cfg + off)) = *((uint8 *) buf);
2689 +sbpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
2692 + return sb_read_config(sbh, bus, dev, func, off, buf, len);
2694 + return extpci_read_config(sbh, bus, dev, func, off, buf, len);
2698 +sbpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
2701 + return sb_write_config(sbh, bus, dev, func, off, buf, len);
2703 + return extpci_write_config(sbh, bus, dev, func, off, buf, len);
2707 +sbpci_ban(uint16 core)
2709 + if (pci_banned < ARRAYSIZE(pci_ban))
2710 + pci_ban[pci_banned++] = core;
2714 +sbpci_init_pci(sb_t *sbh)
2716 + uint chip, chiprev, chippkg, host;
2717 + uint32 boardflags;
2722 + chip = sb_chip(sbh);
2723 + chiprev = sb_chiprev(sbh);
2724 + chippkg = sb_chippkg(sbh);
2726 + if (!(pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0))) {
2727 + printf("PCI: no core\n");
2728 + pci_disabled = TRUE;
2731 + sb_core_reset(sbh, 0);
2733 + boardflags = (uint32) getintvar(NULL, "boardflags");
2735 + if ((chip == BCM4310_DEVICE_ID) && (chiprev == 0))
2736 + pci_disabled = TRUE;
2739 + * The 200-pin BCM4712 package does not bond out PCI. Even when
2740 + * PCI is bonded out, some boards may leave the pins
2743 + if (((chip == BCM4712_DEVICE_ID) &&
2744 + ((chippkg == BCM4712SMALL_PKG_ID) ||
2745 + (chippkg == BCM4712MID_PKG_ID))) ||
2746 + (boardflags & BFL_NOPCI))
2747 + pci_disabled = TRUE;
2750 + * If the PCI core should not be touched (disabled, not bonded
2751 + * out, or pins floating), do not even attempt to access core
2752 + * registers. Otherwise, try to determine if it is in host
2758 + host = !BUSPROBE(val, &pci->control);
2761 + /* Disable PCI interrupts in client mode */
2762 + sb = (sbconfig_t *)((ulong) pci + SBCONFIGOFF);
2763 + W_REG(&sb->sbintvec, 0);
2765 + /* Disable the PCI bridge in client mode */
2766 + sbpci_ban(SB_PCI);
2767 + printf("PCI: Disabled\n");
2769 + /* Reset the external PCI bus and enable the clock */
2770 + W_REG(&pci->control, 0x5); /* enable the tristate drivers */
2771 + W_REG(&pci->control, 0xd); /* enable the PCI clock */
2772 + OSL_DELAY(150); /* delay > 100 us */
2773 + W_REG(&pci->control, 0xf); /* deassert PCI reset */
2774 + W_REG(&pci->arbcontrol, PCI_INT_ARB); /* use internal arbiter */
2775 + OSL_DELAY(1); /* delay 1 us */
2777 + /* Enable CardBusMode */
2778 + cardbus = nvram_match("cardbus", "1");
2780 + printf("PCI: Enabling CardBus\n");
2781 + /* GPIO 1 resets the CardBus device on bcm94710ap */
2782 + sb_gpioout(sbh, 1, 1, GPIO_DRV_PRIORITY);
2783 + sb_gpioouten(sbh, 1, 1, GPIO_DRV_PRIORITY);
2784 + W_REG(&pci->sprom[0], R_REG(&pci->sprom[0]) | 0x400);
2787 + /* 64 MB I/O access window */
2788 + W_REG(&pci->sbtopci0, SBTOPCI_IO);
2789 + /* 64 MB configuration access window */
2790 + W_REG(&pci->sbtopci1, SBTOPCI_CFG0);
2791 + /* 1 GB memory access window */
2792 + W_REG(&pci->sbtopci2, SBTOPCI_MEM | SB_PCI_DMA);
2794 + /* Enable PCI bridge BAR0 prefetch and burst */
2796 + sbpci_write_config(sbh, 1, 0, 0, PCI_CFG_CMD, &val, sizeof(val));
2798 + /* Enable PCI interrupts */
2799 + W_REG(&pci->intmask, PCI_INTA);
2806 +sbpci_init_cores(sb_t *sbh)
2808 + uint chip, chiprev, chippkg, coreidx, i;
2810 + pci_config_regs *cfg;
2814 + uint16 vendor, core;
2815 + uint8 class, subclass, progif;
2817 + uint32 sbips_int_mask[] = { 0, SBIPS_INT1_MASK, SBIPS_INT2_MASK, SBIPS_INT3_MASK, SBIPS_INT4_MASK };
2818 + uint32 sbips_int_shift[] = { 0, 0, SBIPS_INT2_SHIFT, SBIPS_INT3_SHIFT, SBIPS_INT4_SHIFT };
2820 + chip = sb_chip(sbh);
2821 + chiprev = sb_chiprev(sbh);
2822 + chippkg = sb_chippkg(sbh);
2823 + coreidx = sb_coreidx(sbh);
2825 + /* Scan the SB bus */
2826 + bzero(sb_config_regs, sizeof(sb_config_regs));
2827 + for (cfg = sb_config_regs; cfg < &sb_config_regs[SB_MAXCORES]; cfg++) {
2828 + cfg->vendor = 0xffff;
2829 + if (!(regs = sb_setcoreidx(sbh, cfg - sb_config_regs)))
2831 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
2833 + /* Read ID register and parse vendor and core */
2834 + val = R_REG(&sb->sbidhigh);
2835 + vendor = (val & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT;
2836 + core = (val & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT;
2839 + /* Check if this core is banned */
2840 + for (i = 0; i < pci_banned; i++)
2841 + if (core == pci_ban[i])
2843 + if (i < pci_banned)
2846 + /* Known vendor translations */
2849 + vendor = VENDOR_BROADCOM;
2853 + /* Determine class based on known core codes */
2856 + class = PCI_CLASS_NET;
2857 + subclass = PCI_NET_ETHER;
2858 + core = BCM47XX_ILINE_ID;
2861 + class = PCI_CLASS_NET;
2862 + subclass = PCI_NET_ETHER;
2863 + core = BCM4610_ILINE_ID;
2866 + class = PCI_CLASS_NET;
2867 + subclass = PCI_NET_ETHER;
2868 + core = BCM47XX_ENET_ID;
2872 + class = PCI_CLASS_MEMORY;
2873 + subclass = PCI_MEMORY_RAM;
2876 + class = PCI_CLASS_BRIDGE;
2877 + subclass = PCI_BRIDGE_PCI;
2881 + class = PCI_CLASS_CPU;
2882 + subclass = PCI_CPU_MIPS;
2885 + class = PCI_CLASS_COMM;
2886 + subclass = PCI_COMM_MODEM;
2887 + core = BCM47XX_V90_ID;
2890 + class = PCI_CLASS_SERIAL;
2891 + subclass = PCI_SERIAL_USB;
2892 + progif = 0x10; /* OHCI */
2893 + core = BCM47XX_USB_ID;
2896 + class = PCI_CLASS_SERIAL;
2897 + subclass = PCI_SERIAL_USB;
2898 + progif = 0x10; /* OHCI */
2899 + core = BCM47XX_USBH_ID;
2902 + class = PCI_CLASS_SERIAL;
2903 + subclass = PCI_SERIAL_USB;
2904 + core = BCM47XX_USBD_ID;
2907 + class = PCI_CLASS_CRYPT;
2908 + subclass = PCI_CRYPT_NETWORK;
2909 + core = BCM47XX_IPSEC_ID;
2912 + class = PCI_CLASS_NET;
2913 + subclass = PCI_NET_OTHER;
2914 + core = BCM47XX_ROBO_ID;
2918 + class = PCI_CLASS_MEMORY;
2919 + subclass = PCI_MEMORY_FLASH;
2922 + class = PCI_CLASS_NET;
2923 + subclass = PCI_NET_OTHER;
2924 + /* Let an nvram variable override this */
2925 + sprintf(varname, "wl%did", wlidx);
2927 + if ((core = getintvar(NULL, varname)) == 0) {
2928 + if (chip == BCM4712_DEVICE_ID) {
2929 + if (chippkg == BCM4712SMALL_PKG_ID)
2930 + core = BCM4306_D11G_ID;
2932 + core = BCM4306_D11DUAL_ID;
2935 + core = BCM4310_D11B_ID;
2941 + class = subclass = progif = 0xff;
2945 + /* Supported translations */
2946 + cfg->vendor = htol16(vendor);
2947 + cfg->device = htol16(core);
2948 + cfg->rev_id = chiprev;
2949 + cfg->prog_if = progif;
2950 + cfg->sub_class = subclass;
2951 + cfg->base_class = class;
2952 + cfg->base[0] = htol32(sb_base(R_REG(&sb->sbadmatch0)));
2953 + cfg->base[1] = 0;//htol32(sb_base(R_REG(&sb->sbadmatch1)));
2954 + cfg->base[2] = 0;//htol32(sb_base(R_REG(&sb->sbadmatch2)));
2955 + cfg->base[3] = 0;//htol32(sb_base(R_REG(&sb->sbadmatch3)));
2958 + if (class == PCI_CLASS_BRIDGE && subclass == PCI_BRIDGE_PCI)
2959 + cfg->header_type = PCI_HEADER_BRIDGE;
2961 + cfg->header_type = PCI_HEADER_NORMAL;
2962 + /* Save core interrupt flag */
2963 + cfg->int_pin = R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK;
2964 + /* Default to MIPS shared interrupt 0 */
2965 + cfg->int_line = 0;
2966 + /* MIPS sbipsflag maps core interrupt flags to interrupts 1 through 4 */
2967 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
2968 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
2969 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
2970 + val = R_REG(&sb->sbipsflag);
2971 + for (cfg->int_line = 1; cfg->int_line <= 4; cfg->int_line++) {
2972 + if (((val & sbips_int_mask[cfg->int_line]) >> sbips_int_shift[cfg->int_line]) == cfg->int_pin)
2975 + if (cfg->int_line > 4)
2976 + cfg->int_line = 0;
2978 + /* Emulated core */
2979 + *((uint32 *) &cfg->sprom_control) = 0xffffffff;
2982 + sb_setcoreidx(sbh, coreidx);
2987 +sbpci_init(sb_t *sbh)
2989 + sbpci_init_pci(sbh);
2990 + sbpci_init_cores(sbh);
2994 diff -urN linux.old/arch/mips/bcm947xx/broadcom/sbutils.c linux.dev/arch/mips/bcm947xx/broadcom/sbutils.c
2995 --- linux.old/arch/mips/bcm947xx/broadcom/sbutils.c 1970-01-01 01:00:00.000000000 +0100
2996 +++ linux.dev/arch/mips/bcm947xx/broadcom/sbutils.c 2005-12-17 01:21:12.951254500 +0100
2999 + * Misc utility routines for accessing chip-specific features
3000 + * of the SiliconBackplane-based Broadcom chips.
3002 + * Copyright 2005, Broadcom Corporation
3003 + * All Rights Reserved.
3005 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3006 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3007 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3008 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3012 +#include <typedefs.h>
3014 +#include <sbutils.h>
3015 +#include <bcmutils.h>
3016 +#include <bcmdevs.h>
3017 +#include <sbconfig.h>
3018 +#include <sbchipc.h>
3020 +#include <pcicfg.h>
3021 +#include <sbextif.h>
3022 +#include <bcmsrom.h>
3025 +#define SB_ERROR(args)
3028 +typedef uint32 (*sb_intrsoff_t)(void *intr_arg);
3029 +typedef void (*sb_intrsrestore_t)(void *intr_arg, uint32 arg);
3030 +typedef bool (*sb_intrsenabled_t)(void *intr_arg);
3032 +/* misc sb info needed by some of the routines */
3033 +typedef struct sb_info {
3035 + struct sb_pub sb; /* back plane public state(must be first field of sb_info */
3037 + void *osh; /* osl os handle */
3038 + void *sdh; /* bcmsdh handle */
3040 + void *curmap; /* current regs va */
3041 + void *regs[SB_MAXCORES]; /* other regs va */
3043 + uint curidx; /* current core index */
3044 + uint dev_coreid; /* the core provides driver functions */
3046 + uint gpioidx; /* gpio control core index */
3047 + uint gpioid; /* gpio control coretype */
3049 + uint numcores; /* # discovered cores */
3050 + uint coreid[SB_MAXCORES]; /* id of each core */
3052 + void *intr_arg; /* interrupt callback function arg */
3053 + sb_intrsoff_t intrsoff_fn; /* function turns chip interrupts off */
3054 + sb_intrsrestore_t intrsrestore_fn; /* function restore chip interrupts */
3055 + sb_intrsenabled_t intrsenabled_fn; /* function to check if chip interrupts are enabled */
3059 +/* local prototypes */
3060 +static sb_info_t * BCMINIT(sb_doattach)(sb_info_t *si, uint devid, osl_t *osh, void *regs,
3061 + uint bustype, void *sdh, char **vars, int *varsz);
3062 +static void BCMINIT(sb_scan)(sb_info_t *si);
3063 +static uint sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val);
3064 +static uint _sb_coreidx(sb_info_t *si);
3065 +static uint sb_findcoreidx(sb_info_t *si, uint coreid, uint coreunit);
3066 +static uint BCMINIT(sb_pcidev2chip)(uint pcidev);
3067 +static uint BCMINIT(sb_chip2numcores)(uint chip);
3068 +static int sb_pci_fixcfg(sb_info_t *si);
3070 +/* delay needed between the mdio control/ mdiodata register data access */
3071 +#define PR28829_DELAY() OSL_DELAY(10)
3074 +/* global variable to indicate reservation/release of gpio's*/
3075 +static uint32 sb_gpioreservation = 0;
3077 +#define SB_INFO(sbh) (sb_info_t*)sbh
3078 +#define SET_SBREG(sbh, r, mask, val) W_SBREG((sbh), (r), ((R_SBREG((sbh), (r)) & ~(mask)) | (val)))
3079 +#define GOODCOREADDR(x) (((x) >= SB_ENUM_BASE) && ((x) <= SB_ENUM_LIM) && ISALIGNED((x), SB_CORE_SIZE))
3080 +#define GOODREGS(regs) ((regs) && ISALIGNED((uintptr)(regs), SB_CORE_SIZE))
3081 +#define REGS2SB(va) (sbconfig_t*) ((int8*)(va) + SBCONFIGOFF)
3082 +#define GOODIDX(idx) (((uint)idx) < SB_MAXCORES)
3083 +#define BADIDX (SB_MAXCORES+1)
3086 +#define PCI(si) ((BUSTYPE(si->sb.bustype) == PCI_BUS) && (si->sb.buscoretype == SB_PCI))
3089 +#define SONICS_2_2 (SBIDL_RV_2_2 >> SBIDL_RV_SHIFT)
3090 +#define SONICS_2_3 (SBIDL_RV_2_3 >> SBIDL_RV_SHIFT)
3092 +#define R_SBREG(sbh, sbr) sb_read_sbreg((sbh), (sbr))
3093 +#define W_SBREG(sbh, sbr, v) sb_write_sbreg((sbh), (sbr), (v))
3094 +#define AND_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) & (v)))
3095 +#define OR_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) | (v)))
3098 + * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts before/
3099 + * after core switching to avoid invalid register accesss inside ISR.
3101 +#define INTR_OFF(si, intr_val) \
3102 + if ((si)->intrsoff_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
3103 + intr_val = (*(si)->intrsoff_fn)((si)->intr_arg); }
3104 +#define INTR_RESTORE(si, intr_val) \
3105 + if ((si)->intrsrestore_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
3106 + (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val); }
3108 +/* dynamic clock control defines */
3109 +#define LPOMINFREQ 25000 /* low power oscillator min */
3110 +#define LPOMAXFREQ 43000 /* low power oscillator max */
3111 +#define XTALMINFREQ 19800000 /* 20 MHz - 1% */
3112 +#define XTALMAXFREQ 20200000 /* 20 MHz + 1% */
3113 +#define PCIMINFREQ 25000000 /* 25 MHz */
3114 +#define PCIMAXFREQ 34000000 /* 33 MHz + fudge */
3116 +#define ILP_DIV_5MHZ 0 /* ILP = 5 MHz */
3117 +#define ILP_DIV_1MHZ 4 /* ILP = 1 MHz */
3119 +#define MIN_DUMPBUFLEN 32 /* debug */
3121 +/* GPIO Based LED powersave defines */
3122 +#define DEFAULT_GPIO_ONTIME 10
3123 +#define DEFAULT_GPIO_OFFTIME 90
3125 +#define DEFAULT_GPIOTIMERVAL ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME)
3128 +sb_read_sbreg(sb_info_t *si, volatile uint32 *sbr)
3130 + uint32 val = R_REG(sbr);
3136 +sb_write_sbreg(sb_info_t *si, volatile uint32 *sbr, uint32 v)
3141 +/* Using sb_kattach depends on SB_BUS support, either implicit */
3142 +/* no limiting BCMBUSTYPE value) or explicit (value is SB_BUS). */
3143 +#if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SB_BUS)
3145 +/* global kernel resource */
3146 +static sb_info_t ksi;
3148 +/* generic kernel variant of sb_attach() */
3150 +BCMINITFN(sb_kattach)()
3154 + if (ksi.curmap == NULL) {
3157 + regs = (uint32 *)REG_MAP(SB_ENUM_BASE, SB_CORE_SIZE);
3158 + cid = R_REG((uint32 *)regs);
3159 + if (((cid & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
3160 + ((cid & CID_PKG_MASK) != BCM4712LARGE_PKG_ID) &&
3161 + ((cid & CID_REV_MASK) <= (3 << CID_REV_SHIFT))) {
3164 + scc = (uint32 *)((uchar*)regs + OFFSETOF(chipcregs_t, slow_clk_ctl));
3166 + SB_ERROR((" initial scc = 0x%x\n", val));
3167 + val |= SCC_SS_XTAL;
3171 + if (BCMINIT(sb_doattach)(&ksi, BCM4710_DEVICE_ID, NULL, (void*)regs,
3172 + SB_BUS, NULL, NULL, NULL) == NULL) {
3177 + return (sb_t *)&ksi;
3182 +BCMINITFN(sb_doattach)(sb_info_t *si, uint devid, osl_t *osh, void *regs,
3183 + uint bustype, void *sdh, char **vars, int *varsz)
3190 + ASSERT(GOODREGS(regs));
3192 + bzero((uchar*)si, sizeof (sb_info_t));
3194 + si->sb.buscoreidx = si->gpioidx = BADIDX;
3197 + si->curmap = regs;
3200 + /* check to see if we are a sb core mimic'ing a pci core */
3201 + if (bustype == PCI_BUS) {
3202 + if (OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof (uint32)) == 0xffffffff)
3205 + bustype = PCI_BUS;
3208 + si->sb.bustype = bustype;
3209 + if (si->sb.bustype != BUSTYPE(si->sb.bustype)) {
3210 + SB_ERROR(("sb_doattach: bus type %d does not match configured bus type %d\n",
3211 + si->sb.bustype, BUSTYPE(si->sb.bustype)));
3215 + /* kludge to enable the clock on the 4306 which lacks a slowclock */
3216 + if (BUSTYPE(si->sb.bustype) == PCI_BUS)
3217 + sb_clkctl_xtal(&si->sb, XTAL|PLL, ON);
3219 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
3220 + w = OSL_PCI_READ_CONFIG(osh, PCI_BAR0_WIN, sizeof (uint32));
3221 + if (!GOODCOREADDR(w))
3222 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32), SB_ENUM_BASE);
3225 + /* initialize current core index value */
3226 + si->curidx = _sb_coreidx(si);
3228 + if (si->curidx == BADIDX) {
3229 + SB_ERROR(("sb_doattach: bad core index\n"));
3233 + /* get sonics backplane revision */
3234 + sb = REGS2SB(si->curmap);
3235 + si->sb.sonicsrev = (R_SBREG(si, &(sb)->sbidlow) & SBIDL_RV_MASK) >> SBIDL_RV_SHIFT;
3237 + /* keep and reuse the initial register mapping */
3238 + origidx = si->curidx;
3239 + if (BUSTYPE(si->sb.bustype) == SB_BUS)
3240 + si->regs[origidx] = regs;
3242 + /* is core-0 a chipcommon core? */
3244 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, 0);
3245 + if (sb_coreid(&si->sb) != SB_CC)
3248 + /* determine chip id and rev */
3250 + /* chip common core found! */
3251 + si->sb.chip = R_REG(&cc->chipid) & CID_ID_MASK;
3252 + si->sb.chiprev = (R_REG(&cc->chipid) & CID_REV_MASK) >> CID_REV_SHIFT;
3253 + si->sb.chippkg = (R_REG(&cc->chipid) & CID_PKG_MASK) >> CID_PKG_SHIFT;
3255 + /* no chip common core -- must convert device id to chip id */
3256 + if ((si->sb.chip = BCMINIT(sb_pcidev2chip)(devid)) == 0) {
3257 + SB_ERROR(("sb_doattach: unrecognized device id 0x%04x\n", devid));
3258 + sb_setcoreidx(&si->sb, origidx);
3263 + /* get chipcommon rev */
3264 + si->sb.ccrev = cc ? (int)sb_corerev(&si->sb) : NOREV;
3266 + /* determine numcores */
3267 + if (cc && ((si->sb.ccrev == 4) || (si->sb.ccrev >= 6)))
3268 + si->numcores = (R_REG(&cc->chipid) & CID_CC_MASK) >> CID_CC_SHIFT;
3270 + si->numcores = BCMINIT(sb_chip2numcores)(si->sb.chip);
3272 + /* return to original core */
3273 + sb_setcoreidx(&si->sb, origidx);
3275 + /* sanity checks */
3276 + ASSERT(si->sb.chip);
3278 + /* scan for cores */
3279 + BCMINIT(sb_scan)(si);
3281 + /* fixup necessary chip/core configurations */
3282 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
3283 + if (sb_pci_fixcfg(si)) {
3284 + SB_ERROR(("sb_doattach: sb_pci_fixcfg failed\n"));
3289 + /* srom_var_init() depends on sb_scan() info */
3290 + if (srom_var_init(si, si->sb.bustype, si->curmap, osh, vars, varsz)) {
3291 + SB_ERROR(("sb_doattach: srom_var_init failed: bad srom\n"));
3297 + * The chip revision number is hardwired into all
3298 + * of the pci function config rev fields and is
3299 + * independent from the individual core revision numbers.
3300 + * For example, the "A0" silicon of each chip is chip rev 0.
3302 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
3303 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_REV, sizeof (uint32));
3304 + si->sb.chiprev = w & 0xff;
3306 + si->sb.chiprev = 0;
3309 + /* gpio control core is required */
3310 + if (!GOODIDX(si->gpioidx)) {
3311 + SB_ERROR(("sb_doattach: gpio control core not found\n"));
3315 + /* get boardtype and boardrev */
3316 + switch (BUSTYPE(si->sb.bustype)) {
3318 + /* do a pci config read to get subsystem id and subvendor id */
3319 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_SVID, sizeof (uint32));
3320 + si->sb.boardvendor = w & 0xffff;
3321 + si->sb.boardtype = (w >> 16) & 0xffff;
3326 + si->sb.boardvendor = VENDOR_BROADCOM;
3327 + if ((si->sb.boardtype = getintvar(NULL, "boardtype")) == 0)
3328 + si->sb.boardtype = 0xffff;
3332 + if (si->sb.boardtype == 0) {
3333 + SB_ERROR(("sb_doattach: unknown board type\n"));
3334 + ASSERT(si->sb.boardtype);
3337 + /* setup the GPIO based LED powersave register */
3338 + if (si->sb.ccrev >= 16) {
3339 + w = getintvar(*vars, "gpiotimerval");
3341 + w = DEFAULT_GPIOTIMERVAL;
3342 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), ~0, w);
3350 +sb_coreid(sb_t *sbh)
3355 + si = SB_INFO(sbh);
3356 + sb = REGS2SB(si->curmap);
3358 + return ((R_SBREG(si, &(sb)->sbidhigh) & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT);
3362 +sb_coreidx(sb_t *sbh)
3366 + si = SB_INFO(sbh);
3367 + return (si->curidx);
3370 +/* return current index of core */
3372 +_sb_coreidx(sb_info_t *si)
3375 + uint32 sbaddr = 0;
3379 + switch (BUSTYPE(si->sb.bustype)) {
3381 + sb = REGS2SB(si->curmap);
3382 + sbaddr = sb_base(R_SBREG(si, &sb->sbadmatch0));
3386 + sbaddr = OSL_PCI_READ_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32));
3391 + sbaddr = (uint32)si->curmap;
3393 +#endif /* BCMJTAG */
3399 + if (!GOODCOREADDR(sbaddr))
3402 + return ((sbaddr - SB_ENUM_BASE) / SB_CORE_SIZE);
3406 +sb_corevendor(sb_t *sbh)
3411 + si = SB_INFO(sbh);
3412 + sb = REGS2SB(si->curmap);
3414 + return ((R_SBREG(si, &(sb)->sbidhigh) & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT);
3418 +sb_corerev(sb_t *sbh)
3424 + si = SB_INFO(sbh);
3425 + sb = REGS2SB(si->curmap);
3426 + sbidh = R_SBREG(si, &(sb)->sbidhigh);
3428 + return (SBCOREREV(sbidh));
3436 + si = SB_INFO(sbh);
3440 +#define SBTML_ALLOW (SBTML_PE | SBTML_FGC | SBTML_FL_MASK)
3442 +/* set/clear sbtmstatelow core-specific flags */
3444 +sb_coreflags(sb_t *sbh, uint32 mask, uint32 val)
3450 + si = SB_INFO(sbh);
3451 + sb = REGS2SB(si->curmap);
3453 + ASSERT((val & ~mask) == 0);
3454 + ASSERT((mask & ~SBTML_ALLOW) == 0);
3456 + /* mask and set */
3457 + if (mask || val) {
3458 + w = (R_SBREG(si, &sb->sbtmstatelow) & ~mask) | val;
3459 + W_SBREG(si, &sb->sbtmstatelow, w);
3462 + /* return the new value */
3463 + return (R_SBREG(si, &sb->sbtmstatelow) & SBTML_ALLOW);
3466 +/* set/clear sbtmstatehigh core-specific flags */
3468 +sb_coreflagshi(sb_t *sbh, uint32 mask, uint32 val)
3474 + si = SB_INFO(sbh);
3475 + sb = REGS2SB(si->curmap);
3477 + ASSERT((val & ~mask) == 0);
3478 + ASSERT((mask & ~SBTMH_FL_MASK) == 0);
3480 + /* mask and set */
3481 + if (mask || val) {
3482 + w = (R_SBREG(si, &sb->sbtmstatehigh) & ~mask) | val;
3483 + W_SBREG(si, &sb->sbtmstatehigh, w);
3486 + /* return the new value */
3487 + return (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_FL_MASK);
3490 +/* caller needs to take care of core-specific bist hazards */
3492 +sb_corebist(sb_t *sbh, uint coreid, uint coreunit)
3499 + si = SB_INFO(sbh);
3501 + coreidx = sb_findcoreidx(si, coreid, coreunit);
3502 + if (!GOODIDX(coreidx))
3503 + result = BCME_ERROR;
3505 + sblo = sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), 0, 0);
3506 + sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), ~0, (sblo | SBTML_FGC | SBTML_BE));
3508 + SPINWAIT(((sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatehigh), 0, 0) & SBTMH_BISTD) == 0), 100000);
3510 + if (sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatehigh), 0, 0) & SBTMH_BISTF)
3511 + result = BCME_ERROR;
3513 + sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), ~0, sblo);
3520 +sb_iscoreup(sb_t *sbh)
3525 + si = SB_INFO(sbh);
3526 + sb = REGS2SB(si->curmap);
3528 + return ((R_SBREG(si, &(sb)->sbtmstatelow) & (SBTML_RESET | SBTML_REJ_MASK | SBTML_CLK)) == SBTML_CLK);
3532 + * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set operation,
3533 + * switch back to the original core, and return the new value.
3536 +sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val)
3541 + uint intr_val = 0;
3543 + ASSERT(GOODIDX(coreidx));
3544 + ASSERT(regoff < SB_CORE_SIZE);
3545 + ASSERT((val & ~mask) == 0);
3547 + INTR_OFF(si, intr_val);
3549 + /* save current core index */
3550 + origidx = sb_coreidx(&si->sb);
3553 + r = (uint32*) ((uchar*) sb_setcoreidx(&si->sb, coreidx) + regoff);
3555 + /* mask and set */
3556 + if (mask || val) {
3557 + if (regoff >= SBCONFIGOFF) {
3558 + w = (R_SBREG(si, r) & ~mask) | val;
3559 + W_SBREG(si, r, w);
3561 + w = (R_REG(r) & ~mask) | val;
3567 + if (regoff >= SBCONFIGOFF)
3568 + w = R_SBREG(si, r);
3572 + /* restore core index */
3573 + if (origidx != coreidx)
3574 + sb_setcoreidx(&si->sb, origidx);
3576 + INTR_RESTORE(si, intr_val);
3580 +#define DWORD_ALIGN(x) (x & ~(0x03))
3581 +#define BYTE_POS(x) (x & 0x3)
3582 +#define WORD_POS(x) (x & 0x1)
3584 +#define BYTE_SHIFT(x) (8 * BYTE_POS(x))
3585 +#define WORD_SHIFT(x) (16 * WORD_POS(x))
3587 +#define BYTE_VAL(a, x) ((a >> BYTE_SHIFT(x)) & 0xFF)
3588 +#define WORD_VAL(a, x) ((a >> WORD_SHIFT(x)) & 0xFFFF)
3590 +#define read_pci_cfg_byte(a) \
3591 + (BYTE_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xff)
3593 +#define read_pci_cfg_write(a) \
3594 + (WORD_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xffff)
3597 +/* scan the sb enumerated space to identify all cores */
3599 +BCMINITFN(sb_scan)(sb_info_t *si)
3609 + /* numcores should already be set */
3610 + ASSERT((si->numcores > 0) && (si->numcores <= SB_MAXCORES));
3612 + /* save current core index */
3613 + origidx = sb_coreidx(&si->sb);
3615 + si->sb.buscorerev = NOREV;
3616 + si->sb.buscoreidx = BADIDX;
3618 + si->gpioidx = BADIDX;
3624 + for (i = 0; i < si->numcores; i++) {
3625 + sb_setcoreidx(&si->sb, i);
3626 + si->coreid[i] = sb_coreid(&si->sb);
3628 + if (si->coreid[i] == SB_PCI) {
3630 + pcirev = sb_corerev(&si->sb);
3635 + si->sb.buscoretype = SB_PCI;
3636 + si->sb.buscorerev = pcirev;
3637 + si->sb.buscoreidx = pciidx;
3641 + * Find the gpio "controlling core" type and index.
3643 + * - if there's a chip common core - use that
3644 + * - else if there's a pci core (rev >= 2) - use that
3645 + * - else there had better be an extif core (4710 only)
3647 + if (GOODIDX(sb_findcoreidx(si, SB_CC, 0))) {
3648 + si->gpioidx = sb_findcoreidx(si, SB_CC, 0);
3649 + si->gpioid = SB_CC;
3650 + } else if (PCI(si) && (si->sb.buscorerev >= 2)) {
3651 + si->gpioidx = si->sb.buscoreidx;
3652 + si->gpioid = SB_PCI;
3653 + } else if (sb_findcoreidx(si, SB_EXTIF, 0)) {
3654 + si->gpioidx = sb_findcoreidx(si, SB_EXTIF, 0);
3655 + si->gpioid = SB_EXTIF;
3657 + ASSERT(si->gpioidx != BADIDX);
3659 + /* return to original core index */
3660 + sb_setcoreidx(&si->sb, origidx);
3663 +/* may be called with core in reset */
3665 +sb_detach(sb_t *sbh)
3670 + si = SB_INFO(sbh);
3675 + if (BUSTYPE(si->sb.bustype) == SB_BUS)
3676 + for (idx = 0; idx < SB_MAXCORES; idx++)
3677 + if (si->regs[idx]) {
3678 + REG_UNMAP(si->regs[idx]);
3679 + si->regs[idx] = NULL;
3683 + MFREE(si->osh, si, sizeof (sb_info_t));
3686 +/* use pci dev id to determine chip id for chips not having a chipcommon core */
3688 +BCMINITFN(sb_pcidev2chip)(uint pcidev)
3690 + if ((pcidev >= BCM4710_DEVICE_ID) && (pcidev <= BCM47XX_USB_ID))
3691 + return (BCM4710_DEVICE_ID);
3692 + if ((pcidev >= BCM4402_DEVICE_ID) && (pcidev <= BCM4402_V90_ID))
3693 + return (BCM4402_DEVICE_ID);
3694 + if (pcidev == BCM4401_ENET_ID)
3695 + return (BCM4402_DEVICE_ID);
3696 + if ((pcidev >= BCM4307_V90_ID) && (pcidev <= BCM4307_D11B_ID))
3697 + return (BCM4307_DEVICE_ID);
3698 + if (pcidev == BCM4301_DEVICE_ID)
3699 + return (BCM4301_DEVICE_ID);
3704 +/* convert chip number to number of i/o cores */
3706 +BCMINITFN(sb_chip2numcores)(uint chip)
3708 + if (chip == BCM4710_DEVICE_ID)
3710 + if (chip == BCM4402_DEVICE_ID)
3712 + if ((chip == BCM4301_DEVICE_ID) || (chip == BCM4307_DEVICE_ID))
3714 + if (chip == BCM4306_DEVICE_ID) /* < 4306c0 */
3716 + if (chip == BCM4704_DEVICE_ID)
3718 + if (chip == BCM5365_DEVICE_ID)
3721 + SB_ERROR(("sb_chip2numcores: unsupported chip 0x%x\n", chip));
3726 +/* return index of coreid or BADIDX if not found */
3728 +sb_findcoreidx( sb_info_t *si, uint coreid, uint coreunit)
3735 + for (i = 0; i < si->numcores; i++)
3736 + if (si->coreid[i] == coreid) {
3737 + if (found == coreunit)
3746 + * this function changes logical "focus" to the indiciated core,
3747 + * must be called with interrupt off.
3748 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
3751 +sb_setcoreidx(sb_t *sbh, uint coreidx)
3756 + si = SB_INFO(sbh);
3758 + if (coreidx >= si->numcores)
3762 + * If the user has provided an interrupt mask enabled function,
3763 + * then assert interrupts are disabled before switching the core.
3765 + ASSERT((si->intrsenabled_fn == NULL) || !(*(si)->intrsenabled_fn)((si)->intr_arg));
3767 + sbaddr = SB_ENUM_BASE + (coreidx * SB_CORE_SIZE);
3769 + switch (BUSTYPE(si->sb.bustype)) {
3772 + if (!si->regs[coreidx]) {
3773 + si->regs[coreidx] = (void*)REG_MAP(sbaddr, SB_CORE_SIZE);
3774 + ASSERT(GOODREGS(si->regs[coreidx]));
3776 + si->curmap = si->regs[coreidx];
3780 + /* point bar0 window */
3781 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, 4, sbaddr);
3787 + if (!si->regs[coreidx]) {
3788 + si->regs[coreidx] = (void *)sbaddr;
3789 + ASSERT(GOODREGS(si->regs[coreidx]));
3791 + si->curmap = si->regs[coreidx];
3793 +#endif /* BCMJTAG */
3796 + si->curidx = coreidx;
3798 + return (si->curmap);
3802 + * this function changes logical "focus" to the indiciated core,
3803 + * must be called with interrupt off.
3804 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
3807 +sb_setcore(sb_t *sbh, uint coreid, uint coreunit)
3812 + si = SB_INFO(sbh);
3813 + idx = sb_findcoreidx(si, coreid, coreunit);
3814 + if (!GOODIDX(idx))
3817 + return (sb_setcoreidx(sbh, idx));
3820 +/* return chip number */
3822 +BCMINITFN(sb_chip)(sb_t *sbh)
3826 + si = SB_INFO(sbh);
3827 + return (si->sb.chip);
3830 +/* return chip revision number */
3832 +BCMINITFN(sb_chiprev)(sb_t *sbh)
3836 + si = SB_INFO(sbh);
3837 + return (si->sb.chiprev);
3840 +/* return chip common revision number */
3842 +BCMINITFN(sb_chipcrev)(sb_t *sbh)
3846 + si = SB_INFO(sbh);
3847 + return (si->sb.ccrev);
3850 +/* return chip package option */
3852 +BCMINITFN(sb_chippkg)(sb_t *sbh)
3856 + si = SB_INFO(sbh);
3857 + return (si->sb.chippkg);
3860 +/* return PCI core rev. */
3862 +BCMINITFN(sb_pcirev)(sb_t *sbh)
3866 + si = SB_INFO(sbh);
3867 + return (si->sb.buscorerev);
3871 +BCMINITFN(sb_war16165)(sb_t *sbh)
3875 + si = SB_INFO(sbh);
3877 + return (PCI(si) && (si->sb.buscorerev <= 10));
3880 +/* return board vendor id */
3882 +BCMINITFN(sb_boardvendor)(sb_t *sbh)
3886 + si = SB_INFO(sbh);
3887 + return (si->sb.boardvendor);
3890 +/* return boardtype */
3892 +BCMINITFN(sb_boardtype)(sb_t *sbh)
3897 + si = SB_INFO(sbh);
3899 + if (BUSTYPE(si->sb.bustype) == SB_BUS && si->sb.boardtype == 0xffff) {
3900 + /* boardtype format is a hex string */
3901 + si->sb.boardtype = getintvar(NULL, "boardtype");
3903 + /* backward compatibility for older boardtype string format */
3904 + if ((si->sb.boardtype == 0) && (var = getvar(NULL, "boardtype"))) {
3905 + if (!strcmp(var, "bcm94710dev"))
3906 + si->sb.boardtype = BCM94710D_BOARD;
3907 + else if (!strcmp(var, "bcm94710ap"))
3908 + si->sb.boardtype = BCM94710AP_BOARD;
3909 + else if (!strcmp(var, "bu4710"))
3910 + si->sb.boardtype = BU4710_BOARD;
3911 + else if (!strcmp(var, "bcm94702mn"))
3912 + si->sb.boardtype = BCM94702MN_BOARD;
3913 + else if (!strcmp(var, "bcm94710r1"))
3914 + si->sb.boardtype = BCM94710R1_BOARD;
3915 + else if (!strcmp(var, "bcm94710r4"))
3916 + si->sb.boardtype = BCM94710R4_BOARD;
3917 + else if (!strcmp(var, "bcm94702cpci"))
3918 + si->sb.boardtype = BCM94702CPCI_BOARD;
3919 + else if (!strcmp(var, "bcm95380_rr"))
3920 + si->sb.boardtype = BCM95380RR_BOARD;
3924 + return (si->sb.boardtype);
3927 +/* return bus type of sbh device */
3933 + si = SB_INFO(sbh);
3934 + return (si->sb.bustype);
3937 +/* return bus core type */
3939 +sb_buscoretype(sb_t *sbh)
3943 + si = SB_INFO(sbh);
3945 + return (si->sb.buscoretype);
3948 +/* return bus core revision */
3950 +sb_buscorerev(sb_t *sbh)
3953 + si = SB_INFO(sbh);
3955 + return (si->sb.buscorerev);
3958 +/* return list of found cores */
3960 +sb_corelist(sb_t *sbh, uint coreid[])
3964 + si = SB_INFO(sbh);
3966 + bcopy((uchar*)si->coreid, (uchar*)coreid, (si->numcores * sizeof (uint)));
3967 + return (si->numcores);
3970 +/* return current register mapping */
3972 +sb_coreregs(sb_t *sbh)
3976 + si = SB_INFO(sbh);
3977 + ASSERT(GOODREGS(si->curmap));
3979 + return (si->curmap);
3983 +/* do buffered registers update */
3985 +sb_commit(sb_t *sbh)
3989 + uint intr_val = 0;
3991 + si = SB_INFO(sbh);
3993 + origidx = si->curidx;
3994 + ASSERT(GOODIDX(origidx));
3996 + INTR_OFF(si, intr_val);
3998 + /* switch over to chipcommon core if there is one, else use pci */
3999 + if (si->sb.ccrev != NOREV) {
4000 + chipcregs_t *ccregs = (chipcregs_t *)sb_setcore(sbh, SB_CC, 0);
4002 + /* do the buffer registers update */
4003 + W_REG(&ccregs->broadcastaddress, SB_COMMIT);
4004 + W_REG(&ccregs->broadcastdata, 0x0);
4005 + } else if (PCI(si)) {
4006 + sbpciregs_t *pciregs = (sbpciregs_t *)sb_setcore(sbh, SB_PCI, 0);
4008 + /* do the buffer registers update */
4009 + W_REG(&pciregs->bcastaddr, SB_COMMIT);
4010 + W_REG(&pciregs->bcastdata, 0x0);
4014 + /* restore core index */
4015 + sb_setcoreidx(sbh, origidx);
4016 + INTR_RESTORE(si, intr_val);
4019 +/* reset and re-enable a core */
4021 +sb_core_reset(sb_t *sbh, uint32 bits)
4025 + volatile uint32 dummy;
4027 + si = SB_INFO(sbh);
4028 + ASSERT(GOODREGS(si->curmap));
4029 + sb = REGS2SB(si->curmap);
4032 + * Must do the disable sequence first to work for arbitrary current core state.
4034 + sb_core_disable(sbh, bits);
4037 + * Now do the initialization sequence.
4040 + /* set reset while enabling the clock and forcing them on throughout the core */
4041 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | SBTML_RESET | bits));
4042 + dummy = R_SBREG(si, &sb->sbtmstatelow);
4045 + if (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_SERR) {
4046 + W_SBREG(si, &sb->sbtmstatehigh, 0);
4048 + if ((dummy = R_SBREG(si, &sb->sbimstate)) & (SBIM_IBE | SBIM_TO)) {
4049 + AND_SBREG(si, &sb->sbimstate, ~(SBIM_IBE | SBIM_TO));
4052 + /* clear reset and allow it to propagate throughout the core */
4053 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | bits));
4054 + dummy = R_SBREG(si, &sb->sbtmstatelow);
4057 + /* leave clock enabled */
4058 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_CLK | bits));
4059 + dummy = R_SBREG(si, &sb->sbtmstatelow);
4064 +sb_core_tofixup(sb_t *sbh)
4069 + si = SB_INFO(sbh);
4071 + if ( (BUSTYPE(si->sb.bustype) != PCI_BUS) || (PCI(si) && (si->sb.buscorerev >= 5)) )
4074 + ASSERT(GOODREGS(si->curmap));
4075 + sb = REGS2SB(si->curmap);
4077 + if (BUSTYPE(si->sb.bustype) == SB_BUS) {
4078 + SET_SBREG(si, &sb->sbimconfiglow,
4079 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
4080 + (0x5 << SBIMCL_RTO_SHIFT) | 0x3);
4082 + if (sb_coreid(sbh) == SB_PCI) {
4083 + SET_SBREG(si, &sb->sbimconfiglow,
4084 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
4085 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
4087 + SET_SBREG(si, &sb->sbimconfiglow, (SBIMCL_RTO_MASK | SBIMCL_STO_MASK), 0);
4095 + * Set the initiator timeout for the "master core".
4096 + * The master core is defined to be the core in control
4097 + * of the chip and so it issues accesses to non-memory
4098 + * locations (Because of dma *any* core can access memeory).
4100 + * The routine uses the bus to decide who is the master:
4102 + * JTAG_BUS => chipc
4105 + * This routine exists so callers can disable initiator
4106 + * timeouts so accesses to very slow devices like otp
4107 + * won't cause an abort. The routine allows arbitrary
4108 + * settings of the service and request timeouts, though.
4110 + * Returns the timeout state before changing it or -1
4114 +#define TO_MASK (SBIMCL_RTO_MASK | SBIMCL_STO_MASK)
4117 +sb_set_initiator_to(sb_t *sbh, uint32 to)
4120 + uint origidx, idx;
4121 + uint intr_val = 0;
4122 + uint32 tmp, ret = 0xffffffff;
4125 + si = SB_INFO(sbh);
4127 + if ((to & ~TO_MASK) != 0)
4130 + /* Figure out the master core */
4132 + switch (BUSTYPE(si->sb.bustype)) {
4134 + idx = si->sb.buscoreidx;
4140 + if ((idx = sb_findcoreidx(si, SB_MIPS33, 0)) == BADIDX)
4141 + idx = sb_findcoreidx(si, SB_MIPS, 0);
4146 + if (idx == BADIDX)
4149 + INTR_OFF(si, intr_val);
4150 + origidx = sb_coreidx(sbh);
4152 + sb = REGS2SB(sb_setcoreidx(sbh, idx));
4154 + tmp = R_SBREG(si, &sb->sbimconfiglow);
4155 + ret = tmp & TO_MASK;
4156 + W_SBREG(si, &sb->sbimconfiglow, (tmp & ~TO_MASK) | to);
4159 + sb_setcoreidx(sbh, origidx);
4160 + INTR_RESTORE(si, intr_val);
4165 +sb_core_disable(sb_t *sbh, uint32 bits)
4168 + volatile uint32 dummy;
4172 + si = SB_INFO(sbh);
4174 + ASSERT(GOODREGS(si->curmap));
4175 + sb = REGS2SB(si->curmap);
4177 + /* if core is already in reset, just return */
4178 + if (R_SBREG(si, &sb->sbtmstatelow) & SBTML_RESET)
4181 + /* reject value changed between sonics 2.2 and 2.3 */
4182 + if (si->sb.sonicsrev == SONICS_2_2)
4183 + rej = (1 << SBTML_REJ_SHIFT);
4185 + rej = (2 << SBTML_REJ_SHIFT);
4187 + /* if clocks are not enabled, put into reset and return */
4188 + if ((R_SBREG(si, &sb->sbtmstatelow) & SBTML_CLK) == 0)
4191 + /* set target reject and spin until busy is clear (preserve core-specific bits) */
4192 + OR_SBREG(si, &sb->sbtmstatelow, rej);
4193 + dummy = R_SBREG(si, &sb->sbtmstatelow);
4195 + SPINWAIT((R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_BUSY), 100000);
4197 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT) {
4198 + OR_SBREG(si, &sb->sbimstate, SBIM_RJ);
4199 + dummy = R_SBREG(si, &sb->sbimstate);
4201 + SPINWAIT((R_SBREG(si, &sb->sbimstate) & SBIM_BY), 100000);
4204 + /* set reset and reject while enabling the clocks */
4205 + W_SBREG(si, &sb->sbtmstatelow, (bits | SBTML_FGC | SBTML_CLK | rej | SBTML_RESET));
4206 + dummy = R_SBREG(si, &sb->sbtmstatelow);
4209 + /* don't forget to clear the initiator reject bit */
4210 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT)
4211 + AND_SBREG(si, &sb->sbimstate, ~SBIM_RJ);
4214 + /* leave reset and reject asserted */
4215 + W_SBREG(si, &sb->sbtmstatelow, (bits | rej | SBTML_RESET));
4219 +/* set chip watchdog reset timer to fire in 'ticks' backplane cycles */
4221 +sb_watchdog(sb_t *sbh, uint ticks)
4223 + sb_info_t *si = SB_INFO(sbh);
4226 + switch (si->gpioid) {
4228 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, watchdog), ~0, ticks);
4231 + sb_corereg(si, si->gpioidx, OFFSETOF(extifregs_t, watchdog), ~0, ticks);
4238 + * Configure the pci core for pci client (NIC) action
4239 + * coremask is the bitvec of cores by index to be enabled.
4242 +sb_pci_setup(sb_t *sbh, uint coremask)
4246 + sbpciregs_t *pciregs;
4251 + si = SB_INFO(sbh);
4253 + /* if not pci bus, we're done */
4254 + if (BUSTYPE(si->sb.bustype) != PCI_BUS)
4258 + ASSERT(si->sb.buscoreidx != BADIDX);
4260 + /* get current core index */
4263 + /* we interrupt on this backplane flag number */
4264 + ASSERT(GOODREGS(si->curmap));
4265 + sb = REGS2SB(si->curmap);
4266 + sbflag = R_SBREG(si, &sb->sbtpsflag) & SBTPS_NUM0_MASK;
4268 + /* switch over to pci core */
4269 + pciregs = (sbpciregs_t*) sb_setcoreidx(sbh, si->sb.buscoreidx);
4270 + sb = REGS2SB(pciregs);
4273 + * Enable sb->pci interrupts. Assume
4274 + * PCI rev 2.3 support was added in pci core rev 6 and things changed..
4276 + if ((PCI(si) && ((si->sb.buscorerev) >= 6))) {
4277 + /* pci config write to set this core bit in PCIIntMask */
4278 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32));
4279 + w |= (coremask << PCI_SBIM_SHIFT);
4280 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32), w);
4282 + /* set sbintvec bit for our flag number */
4283 + OR_SBREG(si, &sb->sbintvec, (1 << sbflag));
4287 + OR_REG(&pciregs->sbtopci2, (SBTOPCI_PREF|SBTOPCI_BURST));
4288 + if (si->sb.buscorerev >= 11)
4289 + OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI);
4290 + if (si->sb.buscorerev < 5) {
4291 + SET_SBREG(si, &sb->sbimconfiglow, SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
4292 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
4297 + /* switch back to previous core */
4298 + sb_setcoreidx(sbh, idx);
4302 +sb_base(uint32 admatch)
4307 + type = admatch & SBAM_TYPE_MASK;
4313 + base = admatch & SBAM_BASE0_MASK;
4314 + } else if (type == 1) {
4315 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
4316 + base = admatch & SBAM_BASE1_MASK;
4317 + } else if (type == 2) {
4318 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
4319 + base = admatch & SBAM_BASE2_MASK;
4326 +sb_size(uint32 admatch)
4331 + type = admatch & SBAM_TYPE_MASK;
4337 + size = 1 << (((admatch & SBAM_ADINT0_MASK) >> SBAM_ADINT0_SHIFT) + 1);
4338 + } else if (type == 1) {
4339 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
4340 + size = 1 << (((admatch & SBAM_ADINT1_MASK) >> SBAM_ADINT1_SHIFT) + 1);
4341 + } else if (type == 2) {
4342 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
4343 + size = 1 << (((admatch & SBAM_ADINT2_MASK) >> SBAM_ADINT2_SHIFT) + 1);
4349 +/* return the core-type instantiation # of the current core */
4351 +sb_coreunit(sb_t *sbh)
4359 + si = SB_INFO(sbh);
4364 + ASSERT(GOODREGS(si->curmap));
4365 + coreid = sb_coreid(sbh);
4367 + /* count the cores of our type */
4368 + for (i = 0; i < idx; i++)
4369 + if (si->coreid[i] == coreid)
4372 + return (coreunit);
4375 +static INLINE uint32
4379 + case CC_F6_2: return 2;
4380 + case CC_F6_3: return 3;
4381 + case CC_F6_4: return 4;
4382 + case CC_F6_5: return 5;
4383 + case CC_F6_6: return 6;
4384 + case CC_F6_7: return 7;
4385 + default: return 0;
4389 +/* calculate the speed the SB would run at given a set of clockcontrol values */
4391 +sb_clock_rate(uint32 pll_type, uint32 n, uint32 m)
4393 + uint32 n1, n2, clock, m1, m2, m3, mc;
4395 + n1 = n & CN_N1_MASK;
4396 + n2 = (n & CN_N2_MASK) >> CN_N2_SHIFT;
4398 + if (pll_type == PLL_TYPE6) {
4399 + if (m & CC_T6_MMASK)
4403 + } else if ((pll_type == PLL_TYPE1) ||
4404 + (pll_type == PLL_TYPE3) ||
4405 + (pll_type == PLL_TYPE4) ||
4406 + (pll_type == PLL_TYPE7)) {
4409 + } else if (pll_type == PLL_TYPE2) {
4412 + ASSERT((n1 >= 2) && (n1 <= 7));
4413 + ASSERT((n2 >= 5) && (n2 <= 23));
4414 + } else if (pll_type == PLL_TYPE5) {
4415 + return (100000000);
4418 + /* PLL types 3 and 7 use BASE2 (25Mhz) */
4419 + if ((pll_type == PLL_TYPE3) ||
4420 + (pll_type == PLL_TYPE7)) {
4421 + clock = CC_CLOCK_BASE2 * n1 * n2;
4424 + clock = CC_CLOCK_BASE1 * n1 * n2;
4429 + m1 = m & CC_M1_MASK;
4430 + m2 = (m & CC_M2_MASK) >> CC_M2_SHIFT;
4431 + m3 = (m & CC_M3_MASK) >> CC_M3_SHIFT;
4432 + mc = (m & CC_MC_MASK) >> CC_MC_SHIFT;
4434 + if ((pll_type == PLL_TYPE1) ||
4435 + (pll_type == PLL_TYPE3) ||
4436 + (pll_type == PLL_TYPE4) ||
4437 + (pll_type == PLL_TYPE7)) {
4439 + if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE3))
4446 + case CC_MC_BYPASS: return (clock);
4447 + case CC_MC_M1: return (clock / m1);
4448 + case CC_MC_M1M2: return (clock / (m1 * m2));
4449 + case CC_MC_M1M2M3: return (clock / (m1 * m2 * m3));
4450 + case CC_MC_M1M3: return (clock / (m1 * m3));
4451 + default: return (0);
4454 + ASSERT(pll_type == PLL_TYPE2);
4457 + m2 += CC_T2M2_BIAS;
4459 + ASSERT((m1 >= 2) && (m1 <= 7));
4460 + ASSERT((m2 >= 3) && (m2 <= 10));
4461 + ASSERT((m3 >= 2) && (m3 <= 7));
4463 + if ((mc & CC_T2MC_M1BYP) == 0)
4465 + if ((mc & CC_T2MC_M2BYP) == 0)
4467 + if ((mc & CC_T2MC_M3BYP) == 0)
4474 +/* returns the current speed the SB is running at */
4476 +sb_clock(sb_t *sbh)
4483 + uint32 pll_type, rate;
4484 + uint intr_val = 0;
4486 + si = SB_INFO(sbh);
4488 + pll_type = PLL_TYPE1;
4490 + INTR_OFF(si, intr_val);
4492 + /* switch to extif or chipc core */
4493 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
4494 + n = R_REG(&eir->clockcontrol_n);
4495 + m = R_REG(&eir->clockcontrol_sb);
4496 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
4497 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
4498 + n = R_REG(&cc->clockcontrol_n);
4499 + if (pll_type == PLL_TYPE6)
4500 + m = R_REG(&cc->clockcontrol_mips);
4501 + else if (pll_type == PLL_TYPE3)
4503 + // Added by Chen-I for 5365
4504 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
4505 + m = R_REG(&cc->clockcontrol_sb);
4507 + m = R_REG(&cc->clockcontrol_m2);
4510 + m = R_REG(&cc->clockcontrol_sb);
4512 + INTR_RESTORE(si, intr_val);
4516 + // Added by Chen-I for 5365
4517 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
4523 + /* calculate rate */
4524 + rate = sb_clock_rate(pll_type, n, m);
4525 + if (pll_type == PLL_TYPE3)
4529 + /* switch back to previous core */
4530 + sb_setcoreidx(sbh, idx);
4532 + INTR_RESTORE(si, intr_val);
4537 +/* change logical "focus" to the gpio core for optimized access */
4539 +sb_gpiosetcore(sb_t *sbh)
4543 + si = SB_INFO(sbh);
4545 + return (sb_setcoreidx(sbh, si->gpioidx));
4548 +/* mask&set gpiocontrol bits */
4550 +sb_gpiocontrol(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4555 + si = SB_INFO(sbh);
4558 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4560 + /* gpios could be shared on router platforms */
4561 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4562 + mask = priority ? (sb_gpioreservation & mask) :
4563 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4567 + switch (si->gpioid) {
4569 + regoff = OFFSETOF(chipcregs_t, gpiocontrol);
4573 + regoff = OFFSETOF(sbpciregs_t, gpiocontrol);
4580 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4583 +/* mask&set gpio output enable bits */
4585 +sb_gpioouten(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4590 + si = SB_INFO(sbh);
4593 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4595 + /* gpios could be shared on router platforms */
4596 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4597 + mask = priority ? (sb_gpioreservation & mask) :
4598 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4602 + switch (si->gpioid) {
4604 + regoff = OFFSETOF(chipcregs_t, gpioouten);
4608 + regoff = OFFSETOF(sbpciregs_t, gpioouten);
4612 + regoff = OFFSETOF(extifregs_t, gpio[0].outen);
4616 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4619 +/* mask&set gpio output bits */
4621 +sb_gpioout(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4626 + si = SB_INFO(sbh);
4629 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4631 + /* gpios could be shared on router platforms */
4632 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4633 + mask = priority ? (sb_gpioreservation & mask) :
4634 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4638 + switch (si->gpioid) {
4640 + regoff = OFFSETOF(chipcregs_t, gpioout);
4644 + regoff = OFFSETOF(sbpciregs_t, gpioout);
4648 + regoff = OFFSETOF(extifregs_t, gpio[0].out);
4652 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4655 +/* reserve one gpio */
4657 +sb_gpioreserve(sb_t *sbh, uint32 gpio_bitmask, uint8 priority)
4661 + si = SB_INFO(sbh);
4663 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4665 + /* only cores on SB_BUS share GPIO's and only applcation users need to reserve/release GPIO */
4666 + if ( (BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) {
4667 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority));
4670 + /* make sure only one bit is set */
4671 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) {
4672 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1)));
4676 + /* already reserved */
4677 + if (sb_gpioreservation & gpio_bitmask)
4679 + /* set reservation */
4680 + sb_gpioreservation |= gpio_bitmask;
4682 + return sb_gpioreservation;
4685 +/* release one gpio */
4687 + * releasing the gpio doesn't change the current value on the GPIO last write value
4688 + * persists till some one overwrites it
4692 +sb_gpiorelease(sb_t *sbh, uint32 gpio_bitmask, uint8 priority)
4696 + si = SB_INFO(sbh);
4698 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4700 + /* only cores on SB_BUS share GPIO's and only applcation users need to reserve/release GPIO */
4701 + if ( (BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) {
4702 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority));
4705 + /* make sure only one bit is set */
4706 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) {
4707 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1)));
4711 + /* already released */
4712 + if (!(sb_gpioreservation & gpio_bitmask))
4715 + /* clear reservation */
4716 + sb_gpioreservation &= ~gpio_bitmask;
4718 + return sb_gpioreservation;
4721 +/* return the current gpioin register value */
4723 +sb_gpioin(sb_t *sbh)
4728 + si = SB_INFO(sbh);
4731 + switch (si->gpioid) {
4733 + regoff = OFFSETOF(chipcregs_t, gpioin);
4737 + regoff = OFFSETOF(sbpciregs_t, gpioin);
4741 + regoff = OFFSETOF(extifregs_t, gpioin);
4745 + return (sb_corereg(si, si->gpioidx, regoff, 0, 0));
4748 +/* mask&set gpio interrupt polarity bits */
4750 +sb_gpiointpolarity(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4755 + si = SB_INFO(sbh);
4758 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4760 + /* gpios could be shared on router platforms */
4761 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4762 + mask = priority ? (sb_gpioreservation & mask) :
4763 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4767 + switch (si->gpioid) {
4769 + regoff = OFFSETOF(chipcregs_t, gpiointpolarity);
4773 + /* pci gpio implementation does not support interrupt polarity */
4778 + regoff = OFFSETOF(extifregs_t, gpiointpolarity);
4782 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4785 +/* mask&set gpio interrupt mask bits */
4787 +sb_gpiointmask(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4792 + si = SB_INFO(sbh);
4795 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4797 + /* gpios could be shared on router platforms */
4798 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4799 + mask = priority ? (sb_gpioreservation & mask) :
4800 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4804 + switch (si->gpioid) {
4806 + regoff = OFFSETOF(chipcregs_t, gpiointmask);
4810 + /* pci gpio implementation does not support interrupt mask */
4815 + regoff = OFFSETOF(extifregs_t, gpiointmask);
4819 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4822 +/* assign the gpio to an led */
4824 +sb_gpioled(sb_t *sbh, uint32 mask, uint32 val)
4828 + si = SB_INFO(sbh);
4829 + if (si->sb.ccrev < 16)
4832 + /* gpio led powersave reg */
4833 + return(sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimeroutmask), mask, val));
4836 +/* mask&set gpio timer val */
4838 +sb_gpiotimerval(sb_t *sbh, uint32 mask, uint32 gpiotimerval)
4841 + si = SB_INFO(sbh);
4843 + if (si->sb.ccrev < 16)
4846 + return(sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), mask, gpiotimerval));
4850 +/* return the slow clock source - LPO, XTAL, or PCI */
4852 +sb_slowclk_src(sb_info_t *si)
4857 + ASSERT(sb_coreid(&si->sb) == SB_CC);
4859 + if (si->sb.ccrev < 6) {
4860 + if ((BUSTYPE(si->sb.bustype) == PCI_BUS)
4861 + && (OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32)) & PCI_CFG_GPIO_SCS))
4862 + return (SCC_SS_PCI);
4864 + return (SCC_SS_XTAL);
4865 + } else if (si->sb.ccrev < 10) {
4866 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx);
4867 + return (R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK);
4868 + } else /* Insta-clock */
4869 + return (SCC_SS_XTAL);
4872 +/* return the ILP (slowclock) min or max frequency */
4874 +sb_slowclk_freq(sb_info_t *si, bool max)
4881 + ASSERT(sb_coreid(&si->sb) == SB_CC);
4883 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx);
4885 + /* shouldn't be here unless we've established the chip has dynamic clk control */
4886 + ASSERT(R_REG(&cc->capabilities) & CAP_PWR_CTL);
4888 + slowclk = sb_slowclk_src(si);
4889 + if (si->sb.ccrev < 6) {
4890 + if (slowclk == SCC_SS_PCI)
4891 + return (max? (PCIMAXFREQ/64) : (PCIMINFREQ/64));
4893 + return (max? (XTALMAXFREQ/32) : (XTALMINFREQ/32));
4894 + } else if (si->sb.ccrev < 10) {
4895 + div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
4896 + if (slowclk == SCC_SS_LPO)
4897 + return (max? LPOMAXFREQ : LPOMINFREQ);
4898 + else if (slowclk == SCC_SS_XTAL)
4899 + return (max? (XTALMAXFREQ/div) : (XTALMINFREQ/div));
4900 + else if (slowclk == SCC_SS_PCI)
4901 + return (max? (PCIMAXFREQ/div) : (PCIMINFREQ/div));
4905 + /* Chipc rev 10 is InstaClock */
4906 + div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHIFT;
4907 + div = 4 * (div + 1);
4908 + return (max ? XTALMAXFREQ : (XTALMINFREQ/div));
4914 +sb_clkctl_setdelay(sb_info_t *si, void *chipcregs)
4917 + uint slowmaxfreq, pll_delay, slowclk;
4918 + uint pll_on_delay, fref_sel_delay;
4920 + pll_delay = PLL_DELAY;
4922 + /* If the slow clock is not sourced by the xtal then add the xtal_on_delay
4923 + * since the xtal will also be powered down by dynamic clk control logic.
4925 + slowclk = sb_slowclk_src(si);
4926 + if (slowclk != SCC_SS_XTAL)
4927 + pll_delay += XTAL_ON_DELAY;
4929 + /* Starting with 4318 it is ILP that is used for the delays */
4930 + slowmaxfreq = sb_slowclk_freq(si, (si->sb.ccrev >= 10) ? FALSE : TRUE);
4932 + pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000;
4933 + fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000;
4935 + cc = (chipcregs_t *)chipcregs;
4936 + W_REG(&cc->pll_on_delay, pll_on_delay);
4937 + W_REG(&cc->fref_sel_delay, fref_sel_delay);
4941 +sb_pwrctl_slowclk(void *sbh, bool set, uint *div)
4946 + uint intr_val = 0;
4949 + si = SB_INFO(sbh);
4951 + /* chipcommon cores prior to rev6 don't support slowclkcontrol */
4952 + if (si->sb.ccrev < 6)
4955 + /* chipcommon cores rev10 are a whole new ball game */
4956 + if (si->sb.ccrev >= 10)
4959 + if (set && ((*div % 4) || (*div < 4)))
4962 + INTR_OFF(si, intr_val);
4963 + origidx = si->curidx;
4964 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
4965 + ASSERT(cc != NULL);
4967 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL)) {
4973 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, ((*div / 4 - 1) << SCC_CD_SHIFT));
4974 + sb_clkctl_setdelay(sbh, (void *)cc);
4976 + *div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
4979 + sb_setcoreidx(sbh, origidx);
4980 + INTR_RESTORE(si, intr_val);
4984 +/* initialize power control delay registers */
4985 +void sb_clkctl_init(sb_t *sbh)
4991 + si = SB_INFO(sbh);
4993 + origidx = si->curidx;
4995 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
4998 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
5001 + /* set all Instaclk chip ILP to 1 MHz */
5002 + if (si->sb.ccrev >= 10)
5003 + SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK, (ILP_DIV_1MHZ << SYCC_CD_SHIFT));
5005 + sb_clkctl_setdelay(si, (void *)cc);
5008 + sb_setcoreidx(sbh, origidx);
5010 +void sb_pwrctl_init(sb_t *sbh)
5012 +sb_clkctl_init(sbh);
5014 +/* return the value suitable for writing to the dot11 core FAST_PWRUP_DELAY register */
5016 +sb_clkctl_fast_pwrup_delay(sb_t *sbh)
5023 + uint intr_val = 0;
5025 + si = SB_INFO(sbh);
5027 + origidx = si->curidx;
5029 + INTR_OFF(si, intr_val);
5031 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
5034 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
5037 + slowminfreq = sb_slowclk_freq(si, FALSE);
5038 + fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + (slowminfreq - 1)) / slowminfreq;
5041 + sb_setcoreidx(sbh, origidx);
5042 + INTR_RESTORE(si, intr_val);
5045 +uint16 sb_pwrctl_fast_pwrup_delay(sb_t *sbh)
5047 +return sb_clkctl_fast_pwrup_delay(sbh);
5049 +/* turn primary xtal and/or pll off/on */
5051 +sb_clkctl_xtal(sb_t *sbh, uint what, bool on)
5054 + uint32 in, out, outen;
5056 + si = SB_INFO(sbh);
5058 + switch (BUSTYPE(si->sb.bustype)) {
5061 + in = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_IN, sizeof (uint32));
5062 + out = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32));
5063 + outen = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32));
5066 + * Avoid glitching the clock if GPRS is already using it.
5067 + * We can't actually read the state of the PLLPD so we infer it
5068 + * by the value of XTAL_PU which *is* readable via gpioin.
5070 + if (on && (in & PCI_CFG_GPIO_XTAL))
5074 + outen |= PCI_CFG_GPIO_XTAL;
5076 + outen |= PCI_CFG_GPIO_PLL;
5079 + /* turn primary xtal on */
5080 + if (what & XTAL) {
5081 + out |= PCI_CFG_GPIO_XTAL;
5083 + out |= PCI_CFG_GPIO_PLL;
5084 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
5085 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
5086 + OSL_DELAY(XTAL_ON_DELAY);
5091 + out &= ~PCI_CFG_GPIO_PLL;
5092 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
5097 + out &= ~PCI_CFG_GPIO_XTAL;
5099 + out |= PCI_CFG_GPIO_PLL;
5100 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
5101 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
5111 +int sb_pwrctl_xtal(sb_t *sbh, uint what, bool on)
5113 +return sb_clkctl_xtal(sbh,what,on);
5116 +/* set dynamic clk control mode (forceslow, forcefast, dynamic) */
5117 +/* returns true if ignore pll off is set and false if it is not */
5119 +sb_clkctl_clk(sb_t *sbh, uint mode)
5125 + bool forcefastclk=FALSE;
5126 + uint intr_val = 0;
5128 + si = SB_INFO(sbh);
5130 + /* chipcommon cores prior to rev6 don't support dynamic clock control */
5131 + if (si->sb.ccrev < 6)
5134 + /* chipcommon cores rev10 are a whole new ball game */
5135 + if (si->sb.ccrev >= 10)
5138 + INTR_OFF(si, intr_val);
5140 + origidx = si->curidx;
5142 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
5143 + ASSERT(cc != NULL);
5145 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
5149 + case CLK_FAST: /* force fast (pll) clock */
5150 + /* don't forget to force xtal back on before we clear SCC_DYN_XTAL.. */
5151 + sb_clkctl_xtal(&si->sb, XTAL, ON);
5153 + SET_REG(&cc->slow_clk_ctl, (SCC_XC | SCC_FS | SCC_IP), SCC_IP);
5156 + case CLK_DYNAMIC: /* enable dynamic clock control */
5157 + scc = R_REG(&cc->slow_clk_ctl);
5158 + scc &= ~(SCC_FS | SCC_IP | SCC_XC);
5159 + if ((scc & SCC_SS_MASK) != SCC_SS_XTAL)
5161 + W_REG(&cc->slow_clk_ctl, scc);
5163 + /* for dynamic control, we have to release our xtal_pu "force on" */
5165 + sb_clkctl_xtal(&si->sb, XTAL, OFF);
5172 + /* Is the h/w forcing the use of the fast clk */
5173 + forcefastclk = (bool)((R_REG(&cc->slow_clk_ctl) & SCC_IP) == SCC_IP);
5176 + sb_setcoreidx(sbh, origidx);
5177 + INTR_RESTORE(si, intr_val);
5178 + return (forcefastclk);
5181 +bool sb_pwrctl_clk(sb_t *sbh, uint mode)
5183 +return sb_clkctl_clk(sbh, mode);
5185 +/* register driver interrupt disabling and restoring callback functions */
5187 +sb_register_intr_callback(sb_t *sbh, void *intrsoff_fn, void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg)
5191 + si = SB_INFO(sbh);
5192 + si->intr_arg = intr_arg;
5193 + si->intrsoff_fn = (sb_intrsoff_t)intrsoff_fn;
5194 + si->intrsrestore_fn = (sb_intrsrestore_t)intrsrestore_fn;
5195 + si->intrsenabled_fn = (sb_intrsenabled_t)intrsenabled_fn;
5196 + /* save current core id. when this function called, the current core
5197 + * must be the core which provides driver functions(il, et, wl, etc.)
5199 + si->dev_coreid = si->coreid[si->curidx];
5204 +sb_corepciid(sb_t *sbh, uint16 *pcivendor, uint16 *pcidevice,
5205 + uint8 *pciclass, uint8 *pcisubclass, uint8 *pciprogif)
5207 + uint vendor, core, unit;
5208 + uint chip, chippkg;
5210 + uint8 class, subclass, progif;
5212 + vendor = sb_corevendor(sbh);
5213 + core = sb_coreid(sbh);
5214 + unit = sb_coreunit(sbh);
5216 + chip = BCMINIT(sb_chip)(sbh);
5217 + chippkg = BCMINIT(sb_chippkg)(sbh);
5221 + /* Known vendor translations */
5224 + vendor = VENDOR_BROADCOM;
5228 + /* Determine class based on known core codes */
5231 + class = PCI_CLASS_NET;
5232 + subclass = PCI_NET_ETHER;
5233 + core = BCM47XX_ILINE_ID;
5236 + class = PCI_CLASS_NET;
5237 + subclass = PCI_NET_ETHER;
5238 + core = BCM47XX_ENET_ID;
5242 + class = PCI_CLASS_MEMORY;
5243 + subclass = PCI_MEMORY_RAM;
5246 + class = PCI_CLASS_BRIDGE;
5247 + subclass = PCI_BRIDGE_PCI;
5251 + class = PCI_CLASS_CPU;
5252 + subclass = PCI_CPU_MIPS;
5255 + class = PCI_CLASS_COMM;
5256 + subclass = PCI_COMM_MODEM;
5257 + core = BCM47XX_V90_ID;
5260 + class = PCI_CLASS_SERIAL;
5261 + subclass = PCI_SERIAL_USB;
5262 + progif = 0x10; /* OHCI */
5263 + core = BCM47XX_USB_ID;
5266 + class = PCI_CLASS_SERIAL;
5267 + subclass = PCI_SERIAL_USB;
5268 + progif = 0x10; /* OHCI */
5269 + core = BCM47XX_USBH_ID;
5272 + class = PCI_CLASS_SERIAL;
5273 + subclass = PCI_SERIAL_USB;
5274 + core = BCM47XX_USBD_ID;
5277 + class = PCI_CLASS_CRYPT;
5278 + subclass = PCI_CRYPT_NETWORK;
5279 + core = BCM47XX_IPSEC_ID;
5282 + class = PCI_CLASS_NET;
5283 + subclass = PCI_NET_OTHER;
5284 + core = BCM47XX_ROBO_ID;
5288 + class = PCI_CLASS_MEMORY;
5289 + subclass = PCI_MEMORY_FLASH;
5292 + class = PCI_CLASS_NET;
5293 + subclass = PCI_NET_OTHER;
5294 + /* Let an nvram variable override this */
5295 + sprintf(varname, "wl%did", unit);
5296 + if ((core = getintvar(NULL, varname)) == 0) {
5297 + if (chip == BCM4712_DEVICE_ID) {
5298 + if (chippkg == BCM4712SMALL_PKG_ID)
5299 + core = BCM4306_D11G_ID;
5301 + core = BCM4306_D11DUAL_ID;
5307 + class = subclass = progif = 0xff;
5311 + *pcivendor = (uint16)vendor;
5312 + *pcidevice = (uint16)core;
5313 + *pciclass = class;
5314 + *pcisubclass = subclass;
5315 + *pciprogif = progif;
5318 +/* Fix chip's configuration. The current core may be changed upon return */
5320 +sb_pci_fixcfg(sb_info_t *si)
5322 + uint origidx, pciidx;
5323 + sbpciregs_t *pciregs;
5324 + uint16 val16, *reg16;
5326 + ASSERT(BUSTYPE(si->sb.bustype) == PCI_BUS);
5328 + /* Fix PCI(e) SROM shadow area */
5329 + /* save the current index */
5330 + origidx = sb_coreidx(&si->sb);
5332 + if (si->sb.buscoretype == SB_PCI) {
5333 + pciregs = (sbpciregs_t *)sb_setcore(&si->sb, SB_PCI, 0);
5335 + reg16 = &pciregs->sprom[SRSH_PI_OFFSET];
5341 + pciidx = sb_coreidx(&si->sb);
5342 + val16 = R_REG(reg16);
5343 + if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (uint16)pciidx) {
5344 + val16 = (uint16)(pciidx << SRSH_PI_SHIFT) | (val16 & ~SRSH_PI_MASK);
5345 + W_REG(reg16, val16);
5348 + /* restore the original index */
5349 + sb_setcoreidx(&si->sb, origidx);
5354 +EXPORT_SYMBOL(sb_boardtype);
5355 +EXPORT_SYMBOL(sb_boardvendor);
5356 +EXPORT_SYMBOL(sb_gpiocontrol);
5357 +EXPORT_SYMBOL(sb_gpioin);
5358 +EXPORT_SYMBOL(sb_gpiointmask);
5359 +EXPORT_SYMBOL(sb_gpiointpolarity);
5360 +EXPORT_SYMBOL(sb_gpioled);
5361 +EXPORT_SYMBOL(sb_gpioout);
5362 +EXPORT_SYMBOL(sb_gpioouten);
5363 +EXPORT_SYMBOL(sb_gpiorelease);
5364 +EXPORT_SYMBOL(sb_gpioreserve);
5365 +EXPORT_SYMBOL(sb_gpiosetcore);
5366 +EXPORT_SYMBOL(sb_gpiotimerval);
5367 +EXPORT_SYMBOL(sb_watchdog);
5368 diff -urN linux.old/arch/mips/bcm947xx/broadcom/sflash.c linux.dev/arch/mips/bcm947xx/broadcom/sflash.c
5369 --- linux.old/arch/mips/bcm947xx/broadcom/sflash.c 1970-01-01 01:00:00.000000000 +0100
5370 +++ linux.dev/arch/mips/bcm947xx/broadcom/sflash.c 2005-12-15 16:59:20.045933750 +0100
5373 + * Broadcom SiliconBackplane chipcommon serial flash interface
5375 + * Copyright 2005, Broadcom Corporation
5376 + * All Rights Reserved.
5378 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5379 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5380 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5381 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5387 +#include <typedefs.h>
5388 +#include <sbconfig.h>
5389 +#include <sbchipc.h>
5390 +#include <mipsinc.h>
5391 +#include <bcmutils.h>
5392 +#include <bcmdevs.h>
5393 +#include <sflash.h>
5395 +/* Private global state */
5396 +static struct sflash sflash;
5398 +/* Issue a serial flash command */
5400 +sflash_cmd(chipcregs_t *cc, uint opcode)
5402 + W_REG(&cc->flashcontrol, SFLASH_START | opcode);
5403 + while (R_REG(&cc->flashcontrol) & SFLASH_BUSY);
5406 +/* Initialize serial flash access */
5408 +sflash_init(chipcregs_t *cc)
5412 + bzero(&sflash, sizeof(sflash));
5414 + sflash.type = R_REG(&cc->capabilities) & CAP_FLASH_MASK;
5416 + switch (sflash.type) {
5418 + /* Probe for ST chips */
5419 + sflash_cmd(cc, SFLASH_ST_DP);
5420 + sflash_cmd(cc, SFLASH_ST_RES);
5421 + id = R_REG(&cc->flashdata);
5424 + /* ST M25P20 2 Mbit Serial Flash */
5425 + sflash.blocksize = 64 * 1024;
5426 + sflash.numblocks = 4;
5429 + /* ST M25P40 4 Mbit Serial Flash */
5430 + sflash.blocksize = 64 * 1024;
5431 + sflash.numblocks = 8;
5434 + /* ST M25P80 8 Mbit Serial Flash */
5435 + sflash.blocksize = 64 * 1024;
5436 + sflash.numblocks = 16;
5439 + /* ST M25P16 16 Mbit Serial Flash */
5440 + sflash.blocksize = 64 * 1024;
5441 + sflash.numblocks = 32;
5444 + /* ST M25P32 32 Mbit Serial Flash */
5445 + sflash.blocksize = 64 * 1024;
5446 + sflash.numblocks = 64;
5449 + W_REG(&cc->flashaddress, 1);
5450 + sflash_cmd(cc, SFLASH_ST_RES);
5451 + id2 = R_REG(&cc->flashdata);
5452 + if (id2 == 0x44) {
5453 + /* SST M25VF80 4 Mbit Serial Flash */
5454 + sflash.blocksize = 64 * 1024;
5455 + sflash.numblocks = 8;
5462 + /* Probe for Atmel chips */
5463 + sflash_cmd(cc, SFLASH_AT_STATUS);
5464 + id = R_REG(&cc->flashdata) & 0x3c;
5467 + /* Atmel AT45DB011 1Mbit Serial Flash */
5468 + sflash.blocksize = 256;
5469 + sflash.numblocks = 512;
5472 + /* Atmel AT45DB021 2Mbit Serial Flash */
5473 + sflash.blocksize = 256;
5474 + sflash.numblocks = 1024;
5477 + /* Atmel AT45DB041 4Mbit Serial Flash */
5478 + sflash.blocksize = 256;
5479 + sflash.numblocks = 2048;
5482 + /* Atmel AT45DB081 8Mbit Serial Flash */
5483 + sflash.blocksize = 256;
5484 + sflash.numblocks = 4096;
5487 + /* Atmel AT45DB161 16Mbit Serial Flash */
5488 + sflash.blocksize = 512;
5489 + sflash.numblocks = 4096;
5492 + /* Atmel AT45DB321 32Mbit Serial Flash */
5493 + sflash.blocksize = 512;
5494 + sflash.numblocks = 8192;
5497 + /* Atmel AT45DB642 64Mbit Serial Flash */
5498 + sflash.blocksize = 1024;
5499 + sflash.numblocks = 8192;
5505 + sflash.size = sflash.blocksize * sflash.numblocks;
5506 + return sflash.size ? &sflash : NULL;
5509 +/* Read len bytes starting at offset into buf. Returns number of bytes read. */
5511 +sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf)
5514 + uint32 *from, *to;
5519 + if ((offset + len) > sflash.size)
5522 + if ((len >= 4) && (offset & 3))
5523 + cnt = 4 - (offset & 3);
5524 + else if ((len >= 4) && ((uint32)buf & 3))
5525 + cnt = 4 - ((uint32)buf & 3);
5529 + from = (uint32 *)KSEG1ADDR(SB_FLASH2 + offset);
5530 + to = (uint32 *)buf;
5533 + bcopy(from, to, cnt);
5537 + while (cnt >= 4) {
5542 + return (len - cnt);
5545 +/* Poll for command completion. Returns zero when complete. */
5547 +sflash_poll(chipcregs_t *cc, uint offset)
5549 + if (offset >= sflash.size)
5552 + switch (sflash.type) {
5554 + /* Check for ST Write In Progress bit */
5555 + sflash_cmd(cc, SFLASH_ST_RDSR);
5556 + return R_REG(&cc->flashdata) & SFLASH_ST_WIP;
5558 + /* Check for Atmel Ready bit */
5559 + sflash_cmd(cc, SFLASH_AT_STATUS);
5560 + return !(R_REG(&cc->flashdata) & SFLASH_AT_READY);
5566 +/* Write len bytes starting at offset into buf. Returns number of bytes
5567 + * written. Caller should poll for completion.
5570 +sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf)
5572 + struct sflash *sfl;
5575 + uint32 page, byte, mask;
5580 + if ((offset + len) > sflash.size)
5584 + switch (sfl->type) {
5586 + mask = R_REG(&cc->chipid);
5587 + is4712b0 = (((mask & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
5588 + ((mask & CID_REV_MASK) == (3 << CID_REV_SHIFT)));
5589 + /* Enable writes */
5590 + sflash_cmd(cc, SFLASH_ST_WREN);
5593 + W_REG(&cc->flashaddress, offset);
5594 + W_REG(&cc->flashdata, *buf++);
5595 + /* Set chip select */
5596 + OR_REG(&cc->gpioout, mask);
5597 + /* Issue a page program with the first byte */
5598 + sflash_cmd(cc, SFLASH_ST_PP);
5603 + if ((offset & 255) == 0) {
5604 + /* Page boundary, drop cs and return */
5605 + AND_REG(&cc->gpioout, ~mask);
5606 + if (!sflash_poll(cc, offset)) {
5607 + /* Flash rejected command */
5612 + /* Write single byte */
5613 + sflash_cmd(cc, *buf++);
5619 + /* All done, drop cs if needed */
5620 + if ((offset & 255) != 1) {
5622 + AND_REG(&cc->gpioout, ~mask);
5623 + if (!sflash_poll(cc, offset)) {
5624 + /* Flash rejected command */
5630 + W_REG(&cc->flashaddress, offset);
5631 + W_REG(&cc->flashdata, *buf);
5632 + /* Page program */
5633 + sflash_cmd(cc, SFLASH_ST_PP);
5637 + mask = sfl->blocksize - 1;
5638 + page = (offset & ~mask) << 1;
5639 + byte = offset & mask;
5640 + /* Read main memory page into buffer 1 */
5641 + if (byte || len < sfl->blocksize) {
5642 + W_REG(&cc->flashaddress, page);
5643 + sflash_cmd(cc, SFLASH_AT_BUF1_LOAD);
5644 + /* 250 us for AT45DB321B */
5645 + SPINWAIT(sflash_poll(cc, offset), 1000);
5646 + ASSERT(!sflash_poll(cc, offset));
5648 + /* Write into buffer 1 */
5649 + for (ret = 0; ret < len && byte < sfl->blocksize; ret++) {
5650 + W_REG(&cc->flashaddress, byte++);
5651 + W_REG(&cc->flashdata, *buf++);
5652 + sflash_cmd(cc, SFLASH_AT_BUF1_WRITE);
5654 + /* Write buffer 1 into main memory page */
5655 + W_REG(&cc->flashaddress, page);
5656 + sflash_cmd(cc, SFLASH_AT_BUF1_PROGRAM);
5663 +/* Erase a region. Returns number of bytes scheduled for erasure.
5664 + * Caller should poll for completion.
5667 +sflash_erase(chipcregs_t *cc, uint offset)
5669 + struct sflash *sfl;
5671 + if (offset >= sflash.size)
5675 + switch (sfl->type) {
5677 + sflash_cmd(cc, SFLASH_ST_WREN);
5678 + W_REG(&cc->flashaddress, offset);
5679 + sflash_cmd(cc, SFLASH_ST_SE);
5680 + return sfl->blocksize;
5682 + W_REG(&cc->flashaddress, offset << 1);
5683 + sflash_cmd(cc, SFLASH_AT_PAGE_ERASE);
5684 + return sfl->blocksize;
5691 + * writes the appropriate range of flash, a NULL buf simply erases
5692 + * the region of flash
5695 +sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf)
5697 + struct sflash *sfl;
5698 + uchar *block = NULL, *cur_ptr, *blk_ptr;
5699 + uint blocksize = 0, mask, cur_offset, cur_length, cur_retlen, remainder;
5700 + uint blk_offset, blk_len, copied;
5701 + int bytes, ret = 0;
5703 + /* Check address range */
5708 + if ((offset + len) > sfl->size)
5711 + blocksize = sfl->blocksize;
5712 + mask = blocksize - 1;
5714 + /* Allocate a block of mem */
5715 + if (!(block = MALLOC(NULL, blocksize)))
5719 + /* Align offset */
5720 + cur_offset = offset & ~mask;
5721 + cur_length = blocksize;
5724 + remainder = blocksize - (offset & mask);
5725 + if (len < remainder)
5728 + cur_retlen = remainder;
5730 + /* buf == NULL means erase only */
5732 + /* Copy existing data into holding block if necessary */
5733 + if ((offset & mask) || (len < blocksize)) {
5734 + blk_offset = cur_offset;
5735 + blk_len = cur_length;
5736 + blk_ptr = cur_ptr;
5738 + /* Copy entire block */
5740 + copied = sflash_read(cc, blk_offset, blk_len, blk_ptr);
5741 + blk_offset += copied;
5742 + blk_len -= copied;
5743 + blk_ptr += copied;
5747 + /* Copy input data into holding block */
5748 + memcpy(cur_ptr + (offset & mask), buf, cur_retlen);
5752 + if ((ret = sflash_erase(cc, (uint) cur_offset)) < 0)
5754 + while (sflash_poll(cc, (uint) cur_offset));
5756 + /* buf == NULL means erase only */
5758 + offset += cur_retlen;
5759 + len -= cur_retlen;
5763 + /* Write holding block */
5764 + while (cur_length > 0) {
5765 + if ((bytes = sflash_write(cc,
5766 + (uint) cur_offset,
5767 + (uint) cur_length,
5768 + (uchar *) cur_ptr)) < 0) {
5772 + while (sflash_poll(cc, (uint) cur_offset));
5773 + cur_offset += bytes;
5774 + cur_length -= bytes;
5778 + offset += cur_retlen;
5779 + len -= cur_retlen;
5780 + buf += cur_retlen;
5786 + MFREE(NULL, block, blocksize);
5790 diff -urN linux.old/arch/mips/bcm947xx/include/bcmdevs.h linux.dev/arch/mips/bcm947xx/include/bcmdevs.h
5791 --- linux.old/arch/mips/bcm947xx/include/bcmdevs.h 1970-01-01 01:00:00.000000000 +0100
5792 +++ linux.dev/arch/mips/bcm947xx/include/bcmdevs.h 2005-12-15 15:25:24.905340500 +0100
5795 + * Broadcom device-specific manifest constants.
5797 + * Copyright 2005, Broadcom Corporation
5798 + * All Rights Reserved.
5800 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5801 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5802 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5803 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5811 +/* Known PCI vendor Id's */
5812 +#define VENDOR_EPIGRAM 0xfeda
5813 +#define VENDOR_BROADCOM 0x14e4
5814 +#define VENDOR_3COM 0x10b7
5815 +#define VENDOR_NETGEAR 0x1385
5816 +#define VENDOR_DIAMOND 0x1092
5817 +#define VENDOR_DELL 0x1028
5818 +#define VENDOR_HP 0x0e11
5819 +#define VENDOR_APPLE 0x106b
5821 +/* PCI Device Id's */
5822 +#define BCM4210_DEVICE_ID 0x1072 /* never used */
5823 +#define BCM4211_DEVICE_ID 0x4211
5824 +#define BCM4230_DEVICE_ID 0x1086 /* never used */
5825 +#define BCM4231_DEVICE_ID 0x4231
5827 +#define BCM4410_DEVICE_ID 0x4410 /* bcm44xx family pci iline */
5828 +#define BCM4430_DEVICE_ID 0x4430 /* bcm44xx family cardbus iline */
5829 +#define BCM4412_DEVICE_ID 0x4412 /* bcm44xx family pci enet */
5830 +#define BCM4432_DEVICE_ID 0x4432 /* bcm44xx family cardbus enet */
5832 +#define BCM3352_DEVICE_ID 0x3352 /* bcm3352 device id */
5833 +#define BCM3360_DEVICE_ID 0x3360 /* bcm3360 device id */
5835 +#define EPI41210_DEVICE_ID 0xa0fa /* bcm4210 */
5836 +#define EPI41230_DEVICE_ID 0xa10e /* bcm4230 */
5838 +#define BCM47XX_ILINE_ID 0x4711 /* 47xx iline20 */
5839 +#define BCM47XX_V90_ID 0x4712 /* 47xx v90 codec */
5840 +#define BCM47XX_ENET_ID 0x4713 /* 47xx enet */
5841 +#define BCM47XX_EXT_ID 0x4714 /* 47xx external i/f */
5842 +#define BCM47XX_USB_ID 0x4715 /* 47xx usb */
5843 +#define BCM47XX_USBH_ID 0x4716 /* 47xx usb host */
5844 +#define BCM47XX_USBD_ID 0x4717 /* 47xx usb device */
5845 +#define BCM47XX_IPSEC_ID 0x4718 /* 47xx ipsec */
5846 +#define BCM47XX_ROBO_ID 0x4719 /* 47xx/53xx roboswitch core */
5847 +#define BCM47XX_USB20H_ID 0x471a /* 47xx usb 2.0 host */
5848 +#define BCM47XX_USB20D_ID 0x471b /* 47xx usb 2.0 device */
5850 +#define BCM4710_DEVICE_ID 0x4710 /* 4710 primary function 0 */
5852 +#define BCM4610_DEVICE_ID 0x4610 /* 4610 primary function 0 */
5853 +#define BCM4610_ILINE_ID 0x4611 /* 4610 iline100 */
5854 +#define BCM4610_V90_ID 0x4612 /* 4610 v90 codec */
5855 +#define BCM4610_ENET_ID 0x4613 /* 4610 enet */
5856 +#define BCM4610_EXT_ID 0x4614 /* 4610 external i/f */
5857 +#define BCM4610_USB_ID 0x4615 /* 4610 usb */
5859 +#define BCM4402_DEVICE_ID 0x4402 /* 4402 primary function 0 */
5860 +#define BCM4402_ENET_ID 0x4402 /* 4402 enet */
5861 +#define BCM4402_V90_ID 0x4403 /* 4402 v90 codec */
5862 +#define BCM4401_ENET_ID 0x170c /* 4401b0 production enet cards */
5864 +#define BCM4301_DEVICE_ID 0x4301 /* 4301 primary function 0 */
5865 +#define BCM4301_D11B_ID 0x4301 /* 4301 802.11b */
5867 +#define BCM4307_DEVICE_ID 0x4307 /* 4307 primary function 0 */
5868 +#define BCM4307_V90_ID 0x4305 /* 4307 v90 codec */
5869 +#define BCM4307_ENET_ID 0x4306 /* 4307 enet */
5870 +#define BCM4307_D11B_ID 0x4307 /* 4307 802.11b */
5872 +#define BCM4306_DEVICE_ID 0x4306 /* 4306 chipcommon chipid */
5873 +#define BCM4306_D11G_ID 0x4320 /* 4306 802.11g */
5874 +#define BCM4306_D11G_ID2 0x4325
5875 +#define BCM4306_D11A_ID 0x4321 /* 4306 802.11a */
5876 +#define BCM4306_UART_ID 0x4322 /* 4306 uart */
5877 +#define BCM4306_V90_ID 0x4323 /* 4306 v90 codec */
5878 +#define BCM4306_D11DUAL_ID 0x4324 /* 4306 dual A+B */
5880 +#define BCM4309_PKG_ID 1 /* 4309 package id */
5882 +#define BCM4303_D11B_ID 0x4303 /* 4303 802.11b */
5883 +#define BCM4303_PKG_ID 2 /* 4303 package id */
5885 +#define BCM4310_DEVICE_ID 0x4310 /* 4310 chipcommon chipid */
5886 +#define BCM4310_D11B_ID 0x4311 /* 4310 802.11b */
5887 +#define BCM4310_UART_ID 0x4312 /* 4310 uart */
5888 +#define BCM4310_ENET_ID 0x4313 /* 4310 enet */
5889 +#define BCM4310_USB_ID 0x4315 /* 4310 usb */
5891 +#define BCMGPRS_UART_ID 0x4333 /* Uart id used by 4306/gprs card */
5892 +#define BCMGPRS2_UART_ID 0x4344 /* Uart id used by 4306/gprs card */
5895 +#define BCM4704_DEVICE_ID 0x4704 /* 4704 chipcommon chipid */
5896 +#define BCM4704_ENET_ID 0x4706 /* 4704 enet (Use 47XX_ENET_ID instead!) */
5898 +#define BCM4317_DEVICE_ID 0x4317 /* 4317 chip common chipid */
5900 +#define BCM4318_DEVICE_ID 0x4318 /* 4318 chip common chipid */
5901 +#define BCM4318_D11G_ID 0x4318 /* 4318 801.11b/g id */
5902 +#define BCM4318_D11DUAL_ID 0x4319 /* 4318 801.11a/b/g id */
5903 +#define BCM4318_JTAGM_ID 0x4331 /* 4318 jtagm device id */
5905 +#define FPGA_JTAGM_ID 0x4330 /* ??? */
5908 +#define BCM4710_SDRAM 0x00000000 /* Physical SDRAM */
5909 +#define BCM4710_PCI_MEM 0x08000000 /* Host Mode PCI memory access space (64 MB) */
5910 +#define BCM4710_PCI_CFG 0x0c000000 /* Host Mode PCI configuration space (64 MB) */
5911 +#define BCM4710_PCI_DMA 0x40000000 /* Client Mode PCI memory access space (1 GB) */
5912 +#define BCM4710_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
5913 +#define BCM4710_ENUM 0x18000000 /* Beginning of core enumeration space */
5915 +/* Core register space */
5916 +#define BCM4710_REG_SDRAM 0x18000000 /* SDRAM core registers */
5917 +#define BCM4710_REG_ILINE20 0x18001000 /* InsideLine20 core registers */
5918 +#define BCM4710_REG_EMAC0 0x18002000 /* Ethernet MAC 0 core registers */
5919 +#define BCM4710_REG_CODEC 0x18003000 /* Codec core registers */
5920 +#define BCM4710_REG_USB 0x18004000 /* USB core registers */
5921 +#define BCM4710_REG_PCI 0x18005000 /* PCI core registers */
5922 +#define BCM4710_REG_MIPS 0x18006000 /* MIPS core registers */
5923 +#define BCM4710_REG_EXTIF 0x18007000 /* External Interface core registers */
5924 +#define BCM4710_REG_EMAC1 0x18008000 /* Ethernet MAC 1 core registers */
5926 +#define BCM4710_EXTIF 0x1f000000 /* External Interface base address */
5927 +#define BCM4710_PCMCIA_MEM 0x1f000000 /* External Interface PCMCIA memory access */
5928 +#define BCM4710_PCMCIA_IO 0x1f100000 /* PCMCIA I/O access */
5929 +#define BCM4710_PCMCIA_CONF 0x1f200000 /* PCMCIA configuration */
5930 +#define BCM4710_PROG 0x1f800000 /* Programable interface */
5931 +#define BCM4710_FLASH 0x1fc00000 /* Flash */
5933 +#define BCM4710_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
5935 +#define BCM4710_UART (BCM4710_REG_EXTIF + 0x00000300)
5937 +#define BCM4710_EUART (BCM4710_EXTIF + 0x00800000)
5938 +#define BCM4710_LED (BCM4710_EXTIF + 0x00900000)
5940 +#define BCM4712_DEVICE_ID 0x4712 /* 4712 chipcommon chipid */
5941 +#define BCM4712_MIPS_ID 0x4720 /* 4712 base devid */
5942 +#define BCM4712LARGE_PKG_ID 0 /* 340pin 4712 package id */
5943 +#define BCM4712SMALL_PKG_ID 1 /* 200pin 4712 package id */
5944 +#define BCM4712MID_PKG_ID 2 /* 225pin 4712 package id */
5946 +#define SDIOH_FPGA_ID 0x4380 /* sdio host fpga */
5948 +#define BCM5365_DEVICE_ID 0x5365 /* 5365 chipcommon chipid */
5949 +#define BCM5350_DEVICE_ID 0x5350 /* bcm5350 chipcommon chipid */
5950 +#define BCM5352_DEVICE_ID 0x5352 /* bcm5352 chipcommon chipid */
5952 +#define BCM4320_DEVICE_ID 0x4320 /* bcm4320 chipcommon chipid */
5954 +/* PCMCIA vendor Id's */
5956 +#define VENDOR_BROADCOM_PCMCIA 0x02d0
5958 +/* SDIO vendor Id's */
5959 +#define VENDOR_BROADCOM_SDIO 0x00BF
5963 +#define BFL_BTCOEXIST 0x0001 /* This board implements Bluetooth coexistance */
5964 +#define BFL_PACTRL 0x0002 /* This board has gpio 9 controlling the PA */
5965 +#define BFL_AIRLINEMODE 0x0004 /* This board implements gpio13 radio disable indication */
5966 +#define BFL_ENETROBO 0x0010 /* This board has robo switch or core */
5967 +#define BFL_CCKHIPWR 0x0040 /* Can do high-power CCK transmission */
5968 +#define BFL_ENETADM 0x0080 /* This board has ADMtek switch */
5969 +#define BFL_ENETVLAN 0x0100 /* This board has vlan capability */
5970 +#define BFL_AFTERBURNER 0x0200 /* This board supports Afterburner mode */
5971 +#define BFL_NOPCI 0x0400 /* This board leaves PCI floating */
5972 +#define BFL_FEM 0x0800 /* This board supports the Front End Module */
5973 +#define BFL_EXTLNA 0x1000 /* This board has an external LNA */
5974 +#define BFL_HGPA 0x2000 /* This board has a high gain PA */
5975 +#define BFL_BTCMOD 0x4000 /* This board' BTCOEXIST is in the alternate gpios */
5976 +#define BFL_ALTIQ 0x8000 /* Alternate I/Q settings */
5978 +/* board specific GPIO assignment, gpio 0-3 are also customer-configurable led */
5979 +#define BOARD_GPIO_HWRAD_B 0x010 /* bit 4 is HWRAD input on 4301 */
5980 +#define BOARD_GPIO_BTCMOD_IN 0x010 /* bit 4 is the alternate BT Coexistance Input */
5981 +#define BOARD_GPIO_BTCMOD_OUT 0x020 /* bit 5 is the alternate BT Coexistance Out */
5982 +#define BOARD_GPIO_BTC_IN 0x080 /* bit 7 is BT Coexistance Input */
5983 +#define BOARD_GPIO_BTC_OUT 0x100 /* bit 8 is BT Coexistance Out */
5984 +#define BOARD_GPIO_PACTRL 0x200 /* bit 9 controls the PA on new 4306 boards */
5985 +#define PCI_CFG_GPIO_SCS 0x10 /* PCI config space bit 4 for 4306c0 slow clock source */
5986 +#define PCI_CFG_GPIO_HWRAD 0x20 /* PCI config space GPIO 13 for hw radio disable */
5987 +#define PCI_CFG_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */
5988 +#define PCI_CFG_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */
5991 +#define SB_BUS 0 /* Silicon Backplane */
5992 +#define PCI_BUS 1 /* PCI target */
5993 +#define PCMCIA_BUS 2 /* PCMCIA target */
5994 +#define SDIO_BUS 3 /* SDIO target */
5995 +#define JTAG_BUS 4 /* JTAG */
5997 +/* Allows optimization for single-bus support */
5999 +#define BUSTYPE(bus) (BCMBUSTYPE)
6001 +#define BUSTYPE(bus) (bus)
6004 +/* power control defines */
6005 +#define PLL_DELAY 150 /* us pll on delay */
6006 +#define FREF_DELAY 200 /* us fref change delay */
6007 +#define MIN_SLOW_CLK 32 /* us Slow clock period */
6008 +#define XTAL_ON_DELAY 1000 /* us crystal power-on delay */
6010 +/* Reference Board Types */
6012 +#define BU4710_BOARD 0x0400
6013 +#define VSIM4710_BOARD 0x0401
6014 +#define QT4710_BOARD 0x0402
6016 +#define BU4610_BOARD 0x0403
6017 +#define VSIM4610_BOARD 0x0404
6019 +#define BU4307_BOARD 0x0405
6020 +#define BCM94301CB_BOARD 0x0406
6021 +#define BCM94301PC_BOARD 0x0406 /* Pcmcia 5v card */
6022 +#define BCM94301MP_BOARD 0x0407
6023 +#define BCM94307MP_BOARD 0x0408
6024 +#define BCMAP4307_BOARD 0x0409
6026 +#define BU4309_BOARD 0x040a
6027 +#define BCM94309CB_BOARD 0x040b
6028 +#define BCM94309MP_BOARD 0x040c
6029 +#define BCM4309AP_BOARD 0x040d
6031 +#define BCM94302MP_BOARD 0x040e
6033 +#define VSIM4310_BOARD 0x040f
6034 +#define BU4711_BOARD 0x0410
6035 +#define BCM94310U_BOARD 0x0411
6036 +#define BCM94310AP_BOARD 0x0412
6037 +#define BCM94310MP_BOARD 0x0414
6039 +#define BU4306_BOARD 0x0416
6040 +#define BCM94306CB_BOARD 0x0417
6041 +#define BCM94306MP_BOARD 0x0418
6043 +#define BCM94710D_BOARD 0x041a
6044 +#define BCM94710R1_BOARD 0x041b
6045 +#define BCM94710R4_BOARD 0x041c
6046 +#define BCM94710AP_BOARD 0x041d
6049 +#define BU2050_BOARD 0x041f
6052 +#define BCM94309G_BOARD 0x0421
6054 +#define BCM94301PC3_BOARD 0x0422 /* Pcmcia 3.3v card */
6056 +#define BU4704_BOARD 0x0423
6057 +#define BU4702_BOARD 0x0424
6059 +#define BCM94306PC_BOARD 0x0425 /* pcmcia 3.3v 4306 card */
6061 +#define BU4317_BOARD 0x0426
6064 +#define BCM94702MN_BOARD 0x0428
6066 +/* BCM4702 1U CompactPCI Board */
6067 +#define BCM94702CPCI_BOARD 0x0429
6069 +/* BCM4702 with BCM95380 VLAN Router */
6070 +#define BCM95380RR_BOARD 0x042a
6072 +/* cb4306 with SiGe PA */
6073 +#define BCM94306CBSG_BOARD 0x042b
6075 +/* mp4301 with 2050 radio */
6076 +#define BCM94301MPL_BOARD 0x042c
6078 +/* cb4306 with SiGe PA */
6079 +#define PCSG94306_BOARD 0x042d
6081 +/* bu4704 with sdram */
6082 +#define BU4704SD_BOARD 0x042e
6084 +/* Dual 11a/11g Router */
6085 +#define BCM94704AGR_BOARD 0x042f
6087 +/* 11a-only minipci */
6088 +#define BCM94308MP_BOARD 0x0430
6092 +/* BCM94317 boards */
6093 +#define BCM94317CB_BOARD 0x0440
6094 +#define BCM94317MP_BOARD 0x0441
6095 +#define BCM94317PCMCIA_BOARD 0x0442
6096 +#define BCM94317SDIO_BOARD 0x0443
6098 +#define BU4712_BOARD 0x0444
6099 +#define BU4712SD_BOARD 0x045d
6100 +#define BU4712L_BOARD 0x045f
6102 +/* BCM4712 boards */
6103 +#define BCM94712AP_BOARD 0x0445
6104 +#define BCM94712P_BOARD 0x0446
6106 +/* BCM4318 boards */
6107 +#define BU4318_BOARD 0x0447
6108 +#define CB4318_BOARD 0x0448
6109 +#define MPG4318_BOARD 0x0449
6110 +#define MP4318_BOARD 0x044a
6111 +#define SD4318_BOARD 0x044b
6113 +/* BCM63XX boards */
6114 +#define BCM96338_BOARD 0x6338
6115 +#define BCM96345_BOARD 0x6345
6116 +#define BCM96348_BOARD 0x6348
6118 +/* Another mp4306 with SiGe */
6119 +#define BCM94306P_BOARD 0x044c
6121 +/* CF-like 4317 modules */
6122 +#define BCM94317CF_BOARD 0x044d
6125 +#define BCM94303MP_BOARD 0x044e
6128 +#define BCM94306MPSGH_BOARD 0x044f
6130 +/* BRCM 4306 w/ Front End Modules */
6131 +#define BCM94306MPM 0x0450
6132 +#define BCM94306MPL 0x0453
6135 +#define BCM94712AGR_BOARD 0x0451
6137 +/* The real CF 4317 board */
6138 +#define CFI4317_BOARD 0x0452
6141 +#define PC4303_BOARD 0x0454
6144 +#define BCM95350K_BOARD 0x0455
6147 +#define BCM95350R_BOARD 0x0456
6150 +#define BCM94306MPLNA_BOARD 0x0457
6153 +#define BU4320_BOARD 0x0458
6154 +#define BU4320S_BOARD 0x0459
6155 +#define BCM94320PH_BOARD 0x045a
6158 +#define BCM94306MPH_BOARD 0x045b
6161 +#define BCM94306PCIV_BOARD 0x045c
6163 +#define BU4712SD_BOARD 0x045d
6165 +#define BCM94320PFLSH_BOARD 0x045e
6167 +#define BU4712L_BOARD 0x045f
6168 +#define BCM94712LGR_BOARD 0x0460
6169 +#define BCM94320R_BOARD 0x0461
6171 +#define BU5352_BOARD 0x0462
6173 +#define BCM94318MPGH_BOARD 0x0463
6176 +#define BCM95352GR_BOARD 0x0467
6179 +#define BCM95351AGR_BOARD 0x0470
6181 +/* # of GPIO pins */
6182 +#define GPIO_NUMPINS 16
6184 +#endif /* _BCMDEVS_H */
6185 diff -urN linux.old/arch/mips/bcm947xx/include/bcmendian.h linux.dev/arch/mips/bcm947xx/include/bcmendian.h
6186 --- linux.old/arch/mips/bcm947xx/include/bcmendian.h 1970-01-01 01:00:00.000000000 +0100
6187 +++ linux.dev/arch/mips/bcm947xx/include/bcmendian.h 2005-12-15 15:25:47.146730500 +0100
6190 + * local version of endian.h - byte order defines
6192 + * Copyright 2005, Broadcom Corporation
6193 + * All Rights Reserved.
6195 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6196 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6197 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6198 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6203 +#ifndef _BCMENDIAN_H_
6204 +#define _BCMENDIAN_H_
6206 +#include <typedefs.h>
6208 +/* Byte swap a 16 bit value */
6209 +#define BCMSWAP16(val) \
6211 + (((uint16)(val) & (uint16)0x00ffU) << 8) | \
6212 + (((uint16)(val) & (uint16)0xff00U) >> 8) ))
6214 +/* Byte swap a 32 bit value */
6215 +#define BCMSWAP32(val) \
6217 + (((uint32)(val) & (uint32)0x000000ffUL) << 24) | \
6218 + (((uint32)(val) & (uint32)0x0000ff00UL) << 8) | \
6219 + (((uint32)(val) & (uint32)0x00ff0000UL) >> 8) | \
6220 + (((uint32)(val) & (uint32)0xff000000UL) >> 24) ))
6222 +/* 2 Byte swap a 32 bit value */
6223 +#define BCMSWAP32BY16(val) \
6225 + (((uint32)(val) & (uint32)0x0000ffffUL) << 16) | \
6226 + (((uint32)(val) & (uint32)0xffff0000UL) >> 16) ))
6229 +static INLINE uint16
6230 +bcmswap16(uint16 val)
6232 + return BCMSWAP16(val);
6235 +static INLINE uint32
6236 +bcmswap32(uint32 val)
6238 + return BCMSWAP32(val);
6241 +static INLINE uint32
6242 +bcmswap32by16(uint32 val)
6244 + return BCMSWAP32BY16(val);
6247 +/* buf - start of buffer of shorts to swap */
6248 +/* len - byte length of buffer */
6250 +bcmswap16_buf(uint16 *buf, uint len)
6255 + *buf = bcmswap16(*buf);
6261 +#ifndef IL_BIGENDIAN
6262 +#define HTON16(i) BCMSWAP16(i)
6263 +#define hton16(i) bcmswap16(i)
6264 +#define hton32(i) bcmswap32(i)
6265 +#define ntoh16(i) bcmswap16(i)
6266 +#define ntoh32(i) bcmswap32(i)
6267 +#define ltoh16(i) (i)
6268 +#define ltoh32(i) (i)
6269 +#define htol16(i) (i)
6270 +#define htol32(i) (i)
6272 +#define HTON16(i) (i)
6273 +#define hton16(i) (i)
6274 +#define hton32(i) (i)
6275 +#define ntoh16(i) (i)
6276 +#define ntoh32(i) (i)
6277 +#define ltoh16(i) bcmswap16(i)
6278 +#define ltoh32(i) bcmswap32(i)
6279 +#define htol16(i) bcmswap16(i)
6280 +#define htol32(i) bcmswap32(i)
6284 +#ifndef IL_BIGENDIAN
6285 +#define ltoh16_buf(buf, i)
6286 +#define htol16_buf(buf, i)
6288 +#define ltoh16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
6289 +#define htol16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
6293 +* load 16-bit value from unaligned little endian byte array.
6295 +static INLINE uint16
6296 +ltoh16_ua(uint8 *bytes)
6298 + return (bytes[1]<<8)+bytes[0];
6302 +* load 32-bit value from unaligned little endian byte array.
6304 +static INLINE uint32
6305 +ltoh32_ua(uint8 *bytes)
6307 + return (bytes[3]<<24)+(bytes[2]<<16)+(bytes[1]<<8)+bytes[0];
6311 +* load 16-bit value from unaligned big(network) endian byte array.
6313 +static INLINE uint16
6314 +ntoh16_ua(uint8 *bytes)
6316 + return (bytes[0]<<8)+bytes[1];
6320 +* load 32-bit value from unaligned big(network) endian byte array.
6322 +static INLINE uint32
6323 +ntoh32_ua(uint8 *bytes)
6325 + return (bytes[0]<<24)+(bytes[1]<<16)+(bytes[2]<<8)+bytes[3];
6328 +#define ltoh_ua(ptr) ( \
6329 + sizeof(*(ptr)) == sizeof(uint8) ? *(uint8 *)ptr : \
6330 + sizeof(*(ptr)) == sizeof(uint16) ? (((uint8 *)ptr)[1]<<8)+((uint8 *)ptr)[0] : \
6331 + (((uint8 *)ptr)[3]<<24)+(((uint8 *)ptr)[2]<<16)+(((uint8 *)ptr)[1]<<8)+((uint8 *)ptr)[0] \
6334 +#define ntoh_ua(ptr) ( \
6335 + sizeof(*(ptr)) == sizeof(uint8) ? *(uint8 *)ptr : \
6336 + sizeof(*(ptr)) == sizeof(uint16) ? (((uint8 *)ptr)[0]<<8)+((uint8 *)ptr)[1] : \
6337 + (((uint8 *)ptr)[0]<<24)+(((uint8 *)ptr)[1]<<16)+(((uint8 *)ptr)[2]<<8)+((uint8 *)ptr)[3] \
6340 +#endif /* _BCMENDIAN_H_ */
6341 diff -urN linux.old/arch/mips/bcm947xx/include/bcmnvram.h linux.dev/arch/mips/bcm947xx/include/bcmnvram.h
6342 --- linux.old/arch/mips/bcm947xx/include/bcmnvram.h 1970-01-01 01:00:00.000000000 +0100
6343 +++ linux.dev/arch/mips/bcm947xx/include/bcmnvram.h 2005-12-15 16:04:35.850827500 +0100
6346 + * NVRAM variable manipulation
6348 + * Copyright 2005, Broadcom Corporation
6349 + * All Rights Reserved.
6351 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6352 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6353 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6354 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6359 +#ifndef _bcmnvram_h_
6360 +#define _bcmnvram_h_
6362 +#ifndef _LANGUAGE_ASSEMBLY
6364 +#include <typedefs.h>
6366 +struct nvram_header {
6369 + uint32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
6370 + uint32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
6371 + uint32 config_ncdl; /* ncdl values for memc */
6374 +struct nvram_tuple {
6377 + struct nvram_tuple *next;
6381 + * Get the value of an NVRAM variable. The pointer returned may be
6382 + * invalid after a set.
6383 + * @param name name of variable to get
6384 + * @return value of variable or NULL if undefined
6386 +extern char * __init nvram_get(const char *name);
6389 + * Get the value of an NVRAM variable.
6390 + * @param name name of variable to get
6391 + * @return value of variable or NUL if undefined
6393 +#define nvram_safe_get(name) (BCMINIT(nvram_get)(name) ? : "")
6396 + * Match an NVRAM variable.
6397 + * @param name name of variable to match
6398 + * @param match value to compare against value of variable
6399 + * @return TRUE if variable is defined and its value is string equal
6400 + * to match or FALSE otherwise
6403 +nvram_match(char *name, char *match) {
6404 + const char *value = BCMINIT(nvram_get)(name);
6405 + return (value && !strcmp(value, match));
6409 + * Inversely match an NVRAM variable.
6410 + * @param name name of variable to match
6411 + * @param match value to compare against value of variable
6412 + * @return TRUE if variable is defined and its value is not string
6413 + * equal to invmatch or FALSE otherwise
6416 +nvram_invmatch(char *name, char *invmatch) {
6417 + const char *value = BCMINIT(nvram_get)(name);
6418 + return (value && strcmp(value, invmatch));
6421 +#endif /* _LANGUAGE_ASSEMBLY */
6423 +#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
6424 +#define NVRAM_VERSION 1
6425 +#define NVRAM_HEADER_SIZE 20
6426 +#define NVRAM_SPACE 0x8000
6428 +#define NVRAM_MAX_VALUE_LEN 255
6429 +#define NVRAM_MAX_PARAM_LEN 64
6431 +#endif /* _bcmnvram_h_ */
6432 diff -urN linux.old/arch/mips/bcm947xx/include/bcmsrom.h linux.dev/arch/mips/bcm947xx/include/bcmsrom.h
6433 --- linux.old/arch/mips/bcm947xx/include/bcmsrom.h 1970-01-01 01:00:00.000000000 +0100
6434 +++ linux.dev/arch/mips/bcm947xx/include/bcmsrom.h 2005-12-15 15:34:32.919589250 +0100
6437 + * Misc useful routines to access NIC local SROM/OTP .
6439 + * Copyright 2005, Broadcom Corporation
6440 + * All Rights Reserved.
6442 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6443 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6444 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6445 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6450 +#ifndef _bcmsrom_h_
6451 +#define _bcmsrom_h_
6453 +extern int srom_var_init(void *sbh, uint bus, void *curmap, osl_t *osh, char **vars, int *count);
6455 +extern int srom_read(uint bus, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf);
6456 +extern int srom_write(uint bus, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf);
6458 +#endif /* _bcmsrom_h_ */
6459 diff -urN linux.old/arch/mips/bcm947xx/include/bcmutils.h linux.dev/arch/mips/bcm947xx/include/bcmutils.h
6460 --- linux.old/arch/mips/bcm947xx/include/bcmutils.h 1970-01-01 01:00:00.000000000 +0100
6461 +++ linux.dev/arch/mips/bcm947xx/include/bcmutils.h 2005-12-15 16:44:25.619117750 +0100
6464 + * Misc useful os-independent macros and functions.
6466 + * Copyright 2005, Broadcom Corporation
6467 + * All Rights Reserved.
6469 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6470 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6471 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6472 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6476 +#ifndef _bcmutils_h_
6477 +#define _bcmutils_h_
6479 +/*** driver-only section ***/
6482 +#define _BCM_U 0x01 /* upper */
6483 +#define _BCM_L 0x02 /* lower */
6484 +#define _BCM_D 0x04 /* digit */
6485 +#define _BCM_C 0x08 /* cntrl */
6486 +#define _BCM_P 0x10 /* punct */
6487 +#define _BCM_S 0x20 /* white space (space/lf/tab) */
6488 +#define _BCM_X 0x40 /* hex digit */
6489 +#define _BCM_SP 0x80 /* hard space (0x20) */
6491 +#define GPIO_PIN_NOTDEFINED 0x20
6493 +extern unsigned char bcm_ctype[];
6494 +#define bcm_ismask(x) (bcm_ctype[(int)(unsigned char)(x)])
6496 +#define bcm_isalnum(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L|_BCM_D)) != 0)
6497 +#define bcm_isalpha(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L)) != 0)
6498 +#define bcm_iscntrl(c) ((bcm_ismask(c)&(_BCM_C)) != 0)
6499 +#define bcm_isdigit(c) ((bcm_ismask(c)&(_BCM_D)) != 0)
6500 +#define bcm_isgraph(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D)) != 0)
6501 +#define bcm_islower(c) ((bcm_ismask(c)&(_BCM_L)) != 0)
6502 +#define bcm_isprint(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D|_BCM_SP)) != 0)
6503 +#define bcm_ispunct(c) ((bcm_ismask(c)&(_BCM_P)) != 0)
6504 +#define bcm_isspace(c) ((bcm_ismask(c)&(_BCM_S)) != 0)
6505 +#define bcm_isupper(c) ((bcm_ismask(c)&(_BCM_U)) != 0)
6506 +#define bcm_isxdigit(c) ((bcm_ismask(c)&(_BCM_D|_BCM_X)) != 0)
6509 + * Spin at most 'us' microseconds while 'exp' is true.
6510 + * Caller should explicitly test 'exp' when this completes
6511 + * and take appropriate error action if 'exp' is still true.
6513 +#define SPINWAIT(exp, us) { \
6514 + uint countdown = (us) + 9; \
6515 + while ((exp) && (countdown >= 10)) {\
6517 + countdown -= 10; \
6521 +/* generic osl packet queue */
6523 + void *head; /* first packet to dequeue */
6524 + void *tail; /* last packet to dequeue */
6525 + uint len; /* number of queued packets */
6526 + uint maxlen; /* maximum number of queued packets */
6527 + bool priority; /* enqueue by packet priority */
6528 + uint8 prio_map[MAXPRIO+1]; /* user priority to packet enqueue policy map */
6530 +#define DEFAULT_QLEN 128
6532 +#define pktq_len(q) ((q)->len)
6533 +#define pktq_avail(q) ((q)->maxlen - (q)->len)
6534 +#define pktq_head(q) ((q)->head)
6535 +#define pktq_full(q) ((q)->len >= (q)->maxlen)
6536 +#define _pktq_pri(q, pri) ((q)->prio_map[pri])
6537 +#define pktq_tailpri(q) ((q)->tail ? _pktq_pri(q, PKTPRIO((q)->tail)) : _pktq_pri(q, 0))
6541 +extern uint pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf);
6542 +extern uint pkttotlen(osl_t *osh, void *);
6543 +extern void pktq_init(struct pktq *q, uint maxlen, const uint8 prio_map[]);
6544 +extern void pktenq(struct pktq *q, void *p, bool lifo);
6545 +extern void *pktdeq(struct pktq *q);
6546 +extern void *pktdeqtail(struct pktq *q);
6548 +extern uint bcm_atoi(char *s);
6549 +extern uchar bcm_toupper(uchar c);
6550 +extern ulong bcm_strtoul(char *cp, char **endp, uint base);
6551 +extern char *bcmstrstr(char *haystack, char *needle);
6552 +extern char *bcmstrcat(char *dest, const char *src);
6553 +extern ulong wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen);
6554 +/* ethernet address */
6555 +extern char *bcm_ether_ntoa(char *ea, char *buf);
6556 +extern int bcm_ether_atoe(char *p, char *ea);
6558 +extern void bcm_mdelay(uint ms);
6559 +/* variable access */
6560 +extern char *getvar(char *vars, char *name);
6561 +extern int getintvar(char *vars, char *name);
6562 +extern uint getgpiopin(char *vars, char *pin_name, uint def_pin);
6563 +#define bcmlog(fmt, a1, a2)
6564 +#define bcmdumplog(buf, size) *buf = '\0'
6565 +#define bcmdumplogent(buf, idx) -1
6567 +/*** driver/apps-shared section ***/
6569 +#define BCME_STRLEN 64
6570 +#define VALID_BCMERROR(e) ((e <= 0) && (e >= BCME_LAST))
6574 + * error codes could be added but the defined ones shouldn't be changed/deleted
6575 + * these error codes are exposed to the user code
6576 + * when ever a new error code is added to this list
6577 + * please update errorstring table with the related error string and
6578 + * update osl files with os specific errorcode map
6581 +#define BCME_ERROR -1 /* Error generic */
6582 +#define BCME_BADARG -2 /* Bad Argument */
6583 +#define BCME_BADOPTION -3 /* Bad option */
6584 +#define BCME_NOTUP -4 /* Not up */
6585 +#define BCME_NOTDOWN -5 /* Not down */
6586 +#define BCME_NOTAP -6 /* Not AP */
6587 +#define BCME_NOTSTA -7 /* Not STA */
6588 +#define BCME_BADKEYIDX -8 /* BAD Key Index */
6589 +#define BCME_RADIOOFF -9 /* Radio Off */
6590 +#define BCME_NOTBANDLOCKED -10 /* Not bandlocked */
6591 +#define BCME_NOCLK -11 /* No Clock*/
6592 +#define BCME_BADRATESET -12 /* BAD RateSet*/
6593 +#define BCME_BADBAND -13 /* BAD Band */
6594 +#define BCME_BUFTOOSHORT -14 /* Buffer too short */
6595 +#define BCME_BUFTOOLONG -15 /* Buffer too Long */
6596 +#define BCME_BUSY -16 /* Busy*/
6597 +#define BCME_NOTASSOCIATED -17 /* Not associated*/
6598 +#define BCME_BADSSIDLEN -18 /* BAD SSID Len */
6599 +#define BCME_OUTOFRANGECHAN -19 /* Out of Range Channel*/
6600 +#define BCME_BADCHAN -20 /* BAD Channel */
6601 +#define BCME_BADADDR -21 /* BAD Address*/
6602 +#define BCME_NORESOURCE -22 /* No resources*/
6603 +#define BCME_UNSUPPORTED -23 /* Unsupported*/
6604 +#define BCME_BADLEN -24 /* Bad Length*/
6605 +#define BCME_NOTREADY -25 /* Not ready Yet*/
6606 +#define BCME_EPERM -26 /* Not Permitted */
6607 +#define BCME_NOMEM -27 /* No Memory */
6608 +#define BCME_ASSOCIATED -28 /* Associated */
6609 +#define BCME_RANGE -29 /* Range Error*/
6610 +#define BCME_NOTFOUND -30 /* Not found */
6611 +#define BCME_LAST BCME_NOTFOUND
6614 +#define ABS(a) (((a)<0)?-(a):(a))
6618 +#define MIN(a, b) (((a)<(b))?(a):(b))
6622 +#define MAX(a, b) (((a)>(b))?(a):(b))
6625 +#define CEIL(x, y) (((x) + ((y)-1)) / (y))
6626 +#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
6627 +#define ISALIGNED(a, x) (((a) & ((x)-1)) == 0)
6628 +#define ISPOWEROF2(x) ((((x)-1)&(x))==0)
6629 +#define VALID_MASK(mask) !((mask) & ((mask) + 1))
6630 +#define OFFSETOF(type, member) ((uint)(uintptr)&((type *)0)->member)
6631 +#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
6633 +/* bit map related macros */
6635 +#define NBBY 8 /* 8 bits per byte */
6636 +#define setbit(a,i) (((uint8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY))
6637 +#define clrbit(a,i) (((uint8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
6638 +#define isset(a,i) (((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY)))
6639 +#define isclr(a,i) ((((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
6642 +#define NBITS(type) (sizeof(type) * 8)
6643 +#define NBITVAL(bits) (1 << (bits))
6644 +#define MAXBITVAL(bits) ((1 << (bits)) - 1)
6647 +#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
6648 +#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */
6649 +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
6650 +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
6651 +#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
6652 +#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
6654 +/* bcm_format_flags() bit description structure */
6655 +typedef struct bcm_bit_desc {
6660 +/* tag_ID/length/value_buffer tuple */
6661 +typedef struct bcm_tlv {
6667 +/* Check that bcm_tlv_t fits into the given buflen */
6668 +#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (int)(buflen) >= (int)(2 + (elt)->len))
6670 +/* buffer length for ethernet address from bcm_ether_ntoa() */
6671 +#define ETHER_ADDR_STR_LEN 18
6673 +/* unaligned load and store macros */
6674 +#ifdef IL_BIGENDIAN
6675 +static INLINE uint32
6676 +load32_ua(uint8 *a)
6678 + return ((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]);
6682 +store32_ua(uint8 *a, uint32 v)
6684 + a[0] = (v >> 24) & 0xff;
6685 + a[1] = (v >> 16) & 0xff;
6686 + a[2] = (v >> 8) & 0xff;
6690 +static INLINE uint16
6691 +load16_ua(uint8 *a)
6693 + return ((a[0] << 8) | a[1]);
6697 +store16_ua(uint8 *a, uint16 v)
6699 + a[0] = (v >> 8) & 0xff;
6705 +static INLINE uint32
6706 +load32_ua(uint8 *a)
6708 + return ((a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]);
6712 +store32_ua(uint8 *a, uint32 v)
6714 + a[3] = (v >> 24) & 0xff;
6715 + a[2] = (v >> 16) & 0xff;
6716 + a[1] = (v >> 8) & 0xff;
6720 +static INLINE uint16
6721 +load16_ua(uint8 *a)
6723 + return ((a[1] << 8) | a[0]);
6727 +store16_ua(uint8 *a, uint16 v)
6729 + a[1] = (v >> 8) & 0xff;
6737 +extern uint8 hndcrc8(uint8 *p, uint nbytes, uint8 crc);
6740 +extern bcm_tlv_t *bcm_next_tlv(bcm_tlv_t *elt, int *buflen);
6741 +extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key);
6742 +extern bcm_tlv_t *bcm_parse_ordered_tlvs(void *buf, int buflen, uint key);
6745 +extern const char *bcmerrorstr(int bcmerror);
6747 +/* multi-bool data type: set of bools, mbool is true if any is set */
6748 +typedef uint32 mbool;
6749 +#define mboolset(mb, bit) (mb |= bit) /* set one bool */
6750 +#define mboolclr(mb, bit) (mb &= ~bit) /* clear one bool */
6751 +#define mboolisset(mb, bit) ((mb & bit) != 0) /* TRUE if one bool is set */
6752 +#define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val)))
6754 +/* power conversion */
6755 +extern uint16 bcm_qdbm_to_mw(uint8 qdbm);
6756 +extern uint8 bcm_mw_to_qdbm(uint16 mw);
6758 +/* generic datastruct to help dump routines */
6765 +typedef uint32 (*readreg_rtn)(void *arg0, void *arg1, uint32 offset);
6766 +extern uint bcmdumpfields(readreg_rtn func_ptr, void *arg0, void *arg1, struct fielddesc *str, char *buf, uint32 bufsize);
6768 +extern uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint len);
6770 +#endif /* _bcmutils_h_ */
6771 diff -urN linux.old/arch/mips/bcm947xx/include/bitfuncs.h linux.dev/arch/mips/bcm947xx/include/bitfuncs.h
6772 --- linux.old/arch/mips/bcm947xx/include/bitfuncs.h 1970-01-01 01:00:00.000000000 +0100
6773 +++ linux.dev/arch/mips/bcm947xx/include/bitfuncs.h 2005-12-15 15:34:40.268048500 +0100
6776 + * bit manipulation utility functions
6778 + * Copyright 2005, Broadcom Corporation
6779 + * All Rights Reserved.
6781 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6782 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6783 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6784 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6788 +#ifndef _BITFUNCS_H
6789 +#define _BITFUNCS_H
6791 +#include <typedefs.h>
6793 +/* local prototypes */
6794 +static INLINE uint32 find_msbit(uint32 x);
6798 + * find_msbit: returns index of most significant set bit in x, with index
6799 + * range defined as 0-31. NOTE: returns zero if input is zero.
6802 +#if defined(USE_PENTIUM_BSR) && defined(__GNUC__)
6805 + * Implementation for Pentium processors and gcc. Note that this
6806 + * instruction is actually very slow on some processors (e.g., family 5,
6807 + * model 2, stepping 12, "Pentium 75 - 200"), so we use the generic
6808 + * implementation instead.
6810 +static INLINE uint32 find_msbit(uint32 x)
6813 + __asm__("bsrl %1,%0"
6822 + * Generic Implementation
6825 +#define DB_POW_MASK16 0xffff0000
6826 +#define DB_POW_MASK8 0x0000ff00
6827 +#define DB_POW_MASK4 0x000000f0
6828 +#define DB_POW_MASK2 0x0000000c
6829 +#define DB_POW_MASK1 0x00000002
6831 +static INLINE uint32 find_msbit(uint32 x)
6833 + uint32 temp_x = x;
6835 + if (temp_x & DB_POW_MASK16) {
6839 + if (temp_x & DB_POW_MASK8) {
6843 + if (temp_x & DB_POW_MASK4) {
6847 + if (temp_x & DB_POW_MASK2) {
6851 + if (temp_x & DB_POW_MASK1) {
6859 +#endif /* _BITFUNCS_H */
6860 diff -urN linux.old/arch/mips/bcm947xx/include/flash.h linux.dev/arch/mips/bcm947xx/include/flash.h
6861 --- linux.old/arch/mips/bcm947xx/include/flash.h 1970-01-01 01:00:00.000000000 +0100
6862 +++ linux.dev/arch/mips/bcm947xx/include/flash.h 2005-12-15 15:34:44.280299250 +0100
6865 + * flash.h: Common definitions for flash access.
6867 + * Copyright 2005, Broadcom Corporation
6868 + * All Rights Reserved.
6870 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6871 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6872 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6873 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6878 +/* Types of flashes we know about */
6879 +typedef enum _flash_type {OLD, BSC, SCS, AMD, SST, SFLASH} flash_type_t;
6881 +/* Commands to write/erase the flases */
6882 +typedef struct _flash_cmds{
6883 + flash_type_t type;
6886 + uint16 erase_block;
6887 + uint16 erase_chip;
6888 + uint16 write_word;
6894 + uint16 read_array;
6897 +#define UNLOCK_CMD_WORDS 2
6899 +typedef struct _unlock_cmd {
6900 + uint addr[UNLOCK_CMD_WORDS];
6901 + uint16 cmd[UNLOCK_CMD_WORDS];
6904 +/* Flash descriptors */
6905 +typedef struct _flash_desc {
6906 + uint16 mfgid; /* Manufacturer Id */
6907 + uint16 devid; /* Device Id */
6908 + uint size; /* Total size in bytes */
6909 + uint width; /* Device width in bytes */
6910 + flash_type_t type; /* Device type old, S, J */
6911 + uint bsize; /* Block size */
6912 + uint nb; /* Number of blocks */
6913 + uint ff; /* First full block */
6914 + uint lf; /* Last full block */
6915 + uint nsub; /* Number of subblocks */
6916 + uint *subblocks; /* Offsets for subblocks */
6917 + char *desc; /* Description */
6921 +#ifdef DECLARE_FLASHES
6922 +flash_cmds_t sflash_cmd_t =
6923 + { SFLASH, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
6925 +flash_cmds_t flash_cmds[] = {
6926 +/* type needu preera eraseb erasech write wbuf clcsr rdcsr rdid confrm read */
6927 + { BSC, 0, 0x00, 0x20, 0x00, 0x40, 0x00, 0x50, 0x70, 0x90, 0xd0, 0xff },
6928 + { SCS, 0, 0x00, 0x20, 0x00, 0x40, 0xe8, 0x50, 0x70, 0x90, 0xd0, 0xff },
6929 + { AMD, 1, 0x80, 0x30, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
6930 + { SST, 1, 0x80, 0x50, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
6934 +unlock_cmd_t unlock_cmd_amd = {
6936 +/* addr: */ { 0x0aa8, 0x0556},
6938 +/* addr: */ { 0x0aaa, 0x0554},
6940 +/* data: */ { 0xaa, 0x55}
6943 +unlock_cmd_t unlock_cmd_sst = {
6945 +/* addr: */ { 0xaaa8, 0x5556},
6947 +/* addr: */ { 0xaaaa, 0x5554},
6949 +/* data: */ { 0xaa, 0x55}
6952 +#define AMD_CMD 0xaaa
6953 +#define SST_CMD 0xaaaa
6955 +/* intel unlock block cmds */
6956 +#define INTEL_UNLOCK1 0x60
6957 +#define INTEL_UNLOCK2 0xD0
6959 +/* Just eight blocks of 8KB byte each */
6961 +uint blk8x8k[] = { 0x00000000,
6972 +/* Funky AMD arrangement for 29xx800's */
6973 +uint amd800[] = { 0x00000000, /* 16KB */
6974 + 0x00004000, /* 32KB */
6975 + 0x0000c000, /* 8KB */
6976 + 0x0000e000, /* 8KB */
6977 + 0x00010000, /* 8KB */
6978 + 0x00012000, /* 8KB */
6979 + 0x00014000, /* 32KB */
6980 + 0x0001c000, /* 16KB */
6984 +/* AMD arrangement for 29xx160's */
6985 +uint amd4112[] = { 0x00000000, /* 32KB */
6986 + 0x00008000, /* 8KB */
6987 + 0x0000a000, /* 8KB */
6988 + 0x0000c000, /* 16KB */
6991 +uint amd2114[] = { 0x00000000, /* 16KB */
6992 + 0x00004000, /* 8KB */
6993 + 0x00006000, /* 8KB */
6994 + 0x00008000, /* 32KB */
6999 +flash_desc_t sflash_desc =
7000 + { 0, 0, 0, 0, SFLASH, 0, 0, 0, 0, 0, NULL, "SFLASH" };
7002 +flash_desc_t flashes[] = {
7003 + { 0x00b0, 0x00d0, 0x0200000, 2, SCS, 0x10000, 32, 0, 31, 0, NULL, "Intel 28F160S3/5 1Mx16" },
7004 + { 0x00b0, 0x00d4, 0x0400000, 2, SCS, 0x10000, 64, 0, 63, 0, NULL, "Intel 28F320S3/5 2Mx16" },
7005 + { 0x0089, 0x8890, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160B3 1Mx16 TopB" },
7006 + { 0x0089, 0x8891, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160B3 1Mx16 BotB" },
7007 + { 0x0089, 0x8896, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320B3 2Mx16 TopB" },
7008 + { 0x0089, 0x8897, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320B3 2Mx16 BotB" },
7009 + { 0x0089, 0x8898, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640B3 4Mx16 TopB" },
7010 + { 0x0089, 0x8899, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640B3 4Mx16 BotB" },
7011 + { 0x0089, 0x88C2, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160C3 1Mx16 TopB" },
7012 + { 0x0089, 0x88C3, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160C3 1Mx16 BotB" },
7013 + { 0x0089, 0x88C4, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320C3 2Mx16 TopB" },
7014 + { 0x0089, 0x88C5, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320C3 2Mx16 BotB" },
7015 + { 0x0089, 0x88CC, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640C3 4Mx16 TopB" },
7016 + { 0x0089, 0x88CD, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640C3 4Mx16 BotB" },
7017 + { 0x0089, 0x0014, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J5 2Mx16" },
7018 + { 0x0089, 0x0015, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J5 4Mx16" },
7019 + { 0x0089, 0x0016, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J3 2Mx16" },
7020 + { 0x0089, 0x0017, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J3 4Mx16" },
7021 + { 0x0089, 0x0018, 0x1000000, 2, SCS, 0x20000, 128, 0, 127, 0, NULL, "Intel 28F128J3 8Mx16" },
7022 + { 0x00b0, 0x00e3, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Sharp 28F320BJE 2Mx16 BotB" },
7023 + { 0x0001, 0x224a, 0x0100000, 2, AMD, 0x10000, 16, 0, 13, 8, amd800, "AMD 29DL800BT 512Kx16 TopB" },
7024 + { 0x0001, 0x22cb, 0x0100000, 2, AMD, 0x10000, 16, 2, 15, 8, amd800, "AMD 29DL800BB 512Kx16 BotB" },
7025 + { 0x0001, 0x22c4, 0x0200000, 2, AMD, 0x10000, 32, 0, 30, 4, amd2114, "AMD 29lv160DT 1Mx16 TopB" },
7026 + { 0x0001, 0x2249, 0x0200000, 2, AMD, 0x10000, 32, 1, 31, 4, amd4112, "AMD 29lv160DB 1Mx16 BotB" },
7027 + { 0x0001, 0x22f6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320DT 2Mx16 TopB" },
7028 + { 0x0001, 0x22f9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320DB 2Mx16 BotB" },
7029 + { 0x0001, 0x227e, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320MT 2Mx16 TopB" },
7030 + { 0x0001, 0x2200, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320MB 2Mx16 BotB" },
7031 + { 0x0020, 0x22CA, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "ST 29w320DT 2Mx16 TopB" },
7032 + { 0x0020, 0x22CB, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "ST 29w320DB 2Mx16 BotB" },
7033 + { 0x00C2, 0x00A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
7034 + { 0x00C2, 0x00A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
7035 + { 0x0004, 0x22F6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MBM29LV320TE 2Mx16 TopB" },
7036 + { 0x0004, 0x22F9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MBM29LV320BE 2Mx16 BotB" },
7037 + { 0x0098, 0x009A, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "TC58FVT321 2Mx16 TopB" },
7038 + { 0x0098, 0x009C, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "TC58FVB321 2Mx16 BotB" },
7039 + { 0x00C2, 0x22A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
7040 + { 0x00C2, 0x22A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
7041 + { 0x00BF, 0x2783, 0x0400000, 2, SST, 0x10000, 64, 0, 63, 0, NULL, "SST39VF320 2Mx16" },
7042 + { 0, 0, 0, 0, OLD, 0, 0, 0, 0, 0, NULL, NULL },
7047 +extern flash_cmds_t flash_cmds[];
7048 +extern unlock_cmd_t unlock_cmd;
7049 +extern flash_desc_t flashes[];
7052 diff -urN linux.old/arch/mips/bcm947xx/include/flashutl.h linux.dev/arch/mips/bcm947xx/include/flashutl.h
7053 --- linux.old/arch/mips/bcm947xx/include/flashutl.h 1970-01-01 01:00:00.000000000 +0100
7054 +++ linux.dev/arch/mips/bcm947xx/include/flashutl.h 2005-12-15 15:34:48.160541750 +0100
7057 + * BCM47XX FLASH driver interface
7059 + * Copyright 2005, Broadcom Corporation
7060 + * All Rights Reserved.
7062 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7063 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7064 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7065 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7069 +#ifndef _flashutl_h_
7070 +#define _flashutl_h_
7073 +#ifndef _LANGUAGE_ASSEMBLY
7075 +int sysFlashInit(char *flash_str);
7076 +int sysFlashRead(uint off, uchar *dst, uint bytes);
7077 +int sysFlashWrite(uint off, uchar *src, uint bytes);
7078 +void nvWrite(unsigned short *data, unsigned int len);
7080 +#endif /* _LANGUAGE_ASSEMBLY */
7082 +#endif /* _flashutl_h_ */
7083 diff -urN linux.old/arch/mips/bcm947xx/include/hndmips.h linux.dev/arch/mips/bcm947xx/include/hndmips.h
7084 --- linux.old/arch/mips/bcm947xx/include/hndmips.h 1970-01-01 01:00:00.000000000 +0100
7085 +++ linux.dev/arch/mips/bcm947xx/include/hndmips.h 2005-12-15 15:34:53.396869000 +0100
7088 + * Alternate include file for HND sbmips.h since CFE also ships with
7091 + * Copyright 2005, Broadcom Corporation
7092 + * All Rights Reserved.
7094 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7095 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7096 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7097 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7102 +#include "sbmips.h"
7103 diff -urN linux.old/arch/mips/bcm947xx/include/linux_osl.h linux.dev/arch/mips/bcm947xx/include/linux_osl.h
7104 --- linux.old/arch/mips/bcm947xx/include/linux_osl.h 1970-01-01 01:00:00.000000000 +0100
7105 +++ linux.dev/arch/mips/bcm947xx/include/linux_osl.h 2005-12-15 17:23:39.225126750 +0100
7108 + * Linux OS Independent Layer
7110 + * Copyright 2005, Broadcom Corporation
7111 + * All Rights Reserved.
7113 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7114 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7115 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7116 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7121 +#ifndef _linux_osl_h_
7122 +#define _linux_osl_h_
7124 +#include <typedefs.h>
7126 +/* use current 2.4.x calling conventions */
7127 +#include <linuxver.h>
7129 +/* assert and panic */
7131 +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
7132 +#if GCC_VERSION > 30100
7133 +#define ASSERT(exp) do {} while (0)
7135 +/* ASSERT could causes segmentation fault on GCC3.1, use empty instead*/
7136 +#define ASSERT(exp)
7140 +/* microsecond delay */
7141 +#define OSL_DELAY(usec) osl_delay(usec)
7142 +extern void osl_delay(uint usec);
7144 +/* PCI configuration space access macros */
7145 +#define OSL_PCI_READ_CONFIG(osh, offset, size) \
7146 + osl_pci_read_config((osh), (offset), (size))
7147 +#define OSL_PCI_WRITE_CONFIG(osh, offset, size, val) \
7148 + osl_pci_write_config((osh), (offset), (size), (val))
7149 +extern uint32 osl_pci_read_config(osl_t *osh, uint size, uint offset);
7150 +extern void osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val);
7152 +/* PCI device bus # and slot # */
7153 +#define OSL_PCI_BUS(osh) osl_pci_bus(osh)
7154 +#define OSL_PCI_SLOT(osh) osl_pci_slot(osh)
7155 +extern uint osl_pci_bus(osl_t *osh);
7156 +extern uint osl_pci_slot(osl_t *osh);
7158 +/* OSL initialization */
7159 +extern osl_t *osl_attach(void *pdev);
7160 +extern void osl_detach(osl_t *osh);
7162 +/* host/bus architecture-specific byte swap */
7163 +#define BUS_SWAP32(v) (v)
7165 +/* general purpose memory allocation */
7167 +#define MALLOC(osh, size) kmalloc(size, GFP_ATOMIC)
7168 +#define MFREE(osh, addr, size) kfree(addr);
7170 +#define MALLOC_FAILED(osh) osl_malloc_failed((osh))
7172 +extern void *osl_malloc(osl_t *osh, uint size);
7173 +extern void osl_mfree(osl_t *osh, void *addr, uint size);
7174 +extern uint osl_malloced(osl_t *osh);
7175 +extern uint osl_malloc_failed(osl_t *osh);
7177 +/* allocate/free shared (dma-able) consistent memory */
7178 +#define DMA_CONSISTENT_ALIGN PAGE_SIZE
7179 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) \
7180 + osl_dma_alloc_consistent((osh), (size), (pap))
7181 +#define DMA_FREE_CONSISTENT(osh, va, size, pa) \
7182 + osl_dma_free_consistent((osh), (void*)(va), (size), (pa))
7183 +extern void *osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap);
7184 +extern void osl_dma_free_consistent(osl_t *osh, void *va, uint size, ulong pa);
7186 +/* map/unmap direction */
7190 +/* register access macros */
7191 +#if defined(BCMJTAG)
7192 +#include <bcmjtag.h>
7193 +#define R_REG(r) bcmjtag_read(NULL, (uint32)(r), sizeof (*(r)))
7194 +#define W_REG(r, v) bcmjtag_write(NULL, (uint32)(r), (uint32)(v), sizeof (*(r)))
7198 + * BINOSL selects the slightly slower function-call-based binary compatible osl.
7199 + * Macros expand to calls to functions defined in linux_osl.c .
7203 +/* string library, kernel mode */
7204 +#define printf(fmt, args...) printk(fmt, ## args)
7205 +#include <linux/kernel.h>
7206 +#include <linux/string.h>
7208 +/* register access macros */
7209 +#if !defined(BCMJTAG)
7210 +#ifndef IL_BIGENDIAN
7211 +#define R_REG(r) ( \
7212 + sizeof(*(r)) == sizeof(uint8) ? readb((volatile uint8*)(r)) : \
7213 + sizeof(*(r)) == sizeof(uint16) ? readw((volatile uint16*)(r)) : \
7214 + readl((volatile uint32*)(r)) \
7216 +#define W_REG(r, v) do { \
7217 + switch (sizeof(*(r))) { \
7218 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)(r)); break; \
7219 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)(r)); break; \
7220 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \
7223 +#else /* IL_BIGENDIAN */
7224 +#define R_REG(r) ({ \
7225 + __typeof(*(r)) __osl_v; \
7226 + switch (sizeof(*(r))) { \
7227 + case sizeof(uint8): __osl_v = readb((volatile uint8*)((uint32)r^3)); break; \
7228 + case sizeof(uint16): __osl_v = readw((volatile uint16*)((uint32)r^2)); break; \
7229 + case sizeof(uint32): __osl_v = readl((volatile uint32*)(r)); break; \
7233 +#define W_REG(r, v) do { \
7234 + switch (sizeof(*(r))) { \
7235 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)((uint32)r^3)); break; \
7236 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)((uint32)r^2)); break; \
7237 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \
7243 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
7244 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
7246 +/* bcopy, bcmp, and bzero */
7247 +#define bcopy(src, dst, len) memcpy((dst), (src), (len))
7248 +#define bcmp(b1, b2, len) memcmp((b1), (b2), (len))
7249 +#define bzero(b, len) memset((b), '\0', (len))
7251 +/* uncached virtual address */
7253 +#define OSL_UNCACHED(va) KSEG1ADDR((va))
7254 +#include <asm/addrspace.h>
7256 +#define OSL_UNCACHED(va) (va)
7259 +/* get processor cycle count */
7261 +#define OSL_GETCYCLES(x) ((x) = read_c0_count() * 2)
7262 +#elif defined(__i386__)
7263 +#define OSL_GETCYCLES(x) rdtscl((x))
7265 +#define OSL_GETCYCLES(x) ((x) = 0)
7268 +/* dereference an address that may cause a bus exception */
7270 +#if defined(MODULE) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,17))
7271 +#define BUSPROBE(val, addr) panic("get_dbe() will not fixup a bus exception when compiled into a module")
7273 +#define BUSPROBE(val, addr) get_dbe((val), (addr))
7274 +#include <asm/paccess.h>
7277 +#define BUSPROBE(val, addr) ({ (val) = R_REG((addr)); 0; })
7280 +/* map/unmap physical to virtual I/O */
7281 +#define REG_MAP(pa, size) ioremap_nocache((unsigned long)(pa), (unsigned long)(size))
7282 +#define REG_UNMAP(va) iounmap((void *)(va))
7284 +/* shared (dma-able) memory access macros */
7285 +#define R_SM(r) *(r)
7286 +#define W_SM(r, v) (*(r) = (v))
7287 +#define BZERO_SM(r, len) memset((r), '\0', (len))
7289 +/* packet primitives */
7290 +#define PKTGET(osh, len, send) osl_pktget((osh), (len), (send))
7291 +#define PKTFREE(osh, skb, send) osl_pktfree((skb))
7292 +#define PKTDATA(osh, skb) (((struct sk_buff*)(skb))->data)
7293 +#define PKTLEN(osh, skb) (((struct sk_buff*)(skb))->len)
7294 +#define PKTHEADROOM(osh, skb) (PKTDATA(osh,skb)-(((struct sk_buff*)(skb))->head))
7295 +#define PKTTAILROOM(osh, skb) ((((struct sk_buff*)(skb))->end)-(((struct sk_buff*)(skb))->tail))
7296 +#define PKTNEXT(osh, skb) (((struct sk_buff*)(skb))->next)
7297 +#define PKTSETNEXT(skb, x) (((struct sk_buff*)(skb))->next = (struct sk_buff*)(x))
7298 +#define PKTSETLEN(osh, skb, len) __skb_trim((struct sk_buff*)(skb), (len))
7299 +#define PKTPUSH(osh, skb, bytes) skb_push((struct sk_buff*)(skb), (bytes))
7300 +#define PKTPULL(osh, skb, bytes) skb_pull((struct sk_buff*)(skb), (bytes))
7301 +#define PKTDUP(osh, skb) skb_clone((struct sk_buff*)(skb), GFP_ATOMIC)
7302 +#define PKTCOOKIE(skb) ((void*)((struct sk_buff*)(skb))->csum)
7303 +#define PKTSETCOOKIE(skb, x) (((struct sk_buff*)(skb))->csum = (uint)(x))
7304 +#define PKTLINK(skb) (((struct sk_buff*)(skb))->prev)
7305 +#define PKTSETLINK(skb, x) (((struct sk_buff*)(skb))->prev = (struct sk_buff*)(x))
7306 +#define PKTPRIO(skb) (((struct sk_buff*)(skb))->priority)
7307 +#define PKTSETPRIO(skb, x) (((struct sk_buff*)(skb))->priority = (x))
7308 +extern void *osl_pktget(osl_t *osh, uint len, bool send);
7309 +extern void osl_pktfree(void *skb);
7313 +/* string library */
7316 +#define printf(fmt, args...) osl_printf((fmt), ## args)
7318 +#define sprintf(buf, fmt, args...) osl_sprintf((buf), (fmt), ## args)
7320 +#define strcmp(s1, s2) osl_strcmp((s1), (s2))
7322 +#define strncmp(s1, s2, n) osl_strncmp((s1), (s2), (n))
7324 +#define strlen(s) osl_strlen((s))
7326 +#define strcpy(d, s) osl_strcpy((d), (s))
7328 +#define strncpy(d, s, n) osl_strncpy((d), (s), (n))
7330 +extern int osl_printf(const char *format, ...);
7331 +extern int osl_sprintf(char *buf, const char *format, ...);
7332 +extern int osl_strcmp(const char *s1, const char *s2);
7333 +extern int osl_strncmp(const char *s1, const char *s2, uint n);
7334 +extern int osl_strlen(const char *s);
7335 +extern char* osl_strcpy(char *d, const char *s);
7336 +extern char* osl_strncpy(char *d, const char *s, uint n);
7338 +/* register access macros */
7339 +#if !defined(BCMJTAG)
7340 +#define R_REG(r) ( \
7341 + sizeof(*(r)) == sizeof(uint8) ? osl_readb((volatile uint8*)(r)) : \
7342 + sizeof(*(r)) == sizeof(uint16) ? osl_readw((volatile uint16*)(r)) : \
7343 + osl_readl((volatile uint32*)(r)) \
7345 +#define W_REG(r, v) do { \
7346 + switch (sizeof(*(r))) { \
7347 + case sizeof(uint8): osl_writeb((uint8)(v), (volatile uint8*)(r)); break; \
7348 + case sizeof(uint16): osl_writew((uint16)(v), (volatile uint16*)(r)); break; \
7349 + case sizeof(uint32): osl_writel((uint32)(v), (volatile uint32*)(r)); break; \
7354 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
7355 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
7356 +extern uint8 osl_readb(volatile uint8 *r);
7357 +extern uint16 osl_readw(volatile uint16 *r);
7358 +extern uint32 osl_readl(volatile uint32 *r);
7359 +extern void osl_writeb(uint8 v, volatile uint8 *r);
7360 +extern void osl_writew(uint16 v, volatile uint16 *r);
7361 +extern void osl_writel(uint32 v, volatile uint32 *r);
7363 +/* bcopy, bcmp, and bzero */
7364 +extern void bcopy(const void *src, void *dst, int len);
7365 +extern int bcmp(const void *b1, const void *b2, int len);
7366 +extern void bzero(void *b, int len);
7368 +/* uncached virtual address */
7369 +#define OSL_UNCACHED(va) osl_uncached((va))
7370 +extern void *osl_uncached(void *va);
7372 +/* get processor cycle count */
7373 +#define OSL_GETCYCLES(x) ((x) = osl_getcycles())
7374 +extern uint osl_getcycles(void);
7376 +/* dereference an address that may target abort */
7377 +#define BUSPROBE(val, addr) osl_busprobe(&(val), (addr))
7378 +extern int osl_busprobe(uint32 *val, uint32 addr);
7380 +/* map/unmap physical to virtual */
7381 +#define REG_MAP(pa, size) osl_reg_map((pa), (size))
7382 +#define REG_UNMAP(va) osl_reg_unmap((va))
7383 +extern void *osl_reg_map(uint32 pa, uint size);
7384 +extern void osl_reg_unmap(void *va);
7386 +/* shared (dma-able) memory access macros */
7387 +#define R_SM(r) *(r)
7388 +#define W_SM(r, v) (*(r) = (v))
7389 +#define BZERO_SM(r, len) bzero((r), (len))
7391 +/* packet primitives */
7392 +#define PKTGET(osh, len, send) osl_pktget((osh), (len), (send))
7393 +#define PKTFREE(osh, skb, send) osl_pktfree((skb))
7394 +#define PKTDATA(osh, skb) osl_pktdata((osh), (skb))
7395 +#define PKTLEN(osh, skb) osl_pktlen((osh), (skb))
7396 +#define PKTHEADROOM(osh, skb) osl_pktheadroom((osh), (skb))
7397 +#define PKTTAILROOM(osh, skb) osl_pkttailroom((osh), (skb))
7398 +#define PKTNEXT(osh, skb) osl_pktnext((osh), (skb))
7399 +#define PKTSETNEXT(skb, x) osl_pktsetnext((skb), (x))
7400 +#define PKTSETLEN(osh, skb, len) osl_pktsetlen((osh), (skb), (len))
7401 +#define PKTPUSH(osh, skb, bytes) osl_pktpush((osh), (skb), (bytes))
7402 +#define PKTPULL(osh, skb, bytes) osl_pktpull((osh), (skb), (bytes))
7403 +#define PKTDUP(osh, skb) osl_pktdup((osh), (skb))
7404 +#define PKTCOOKIE(skb) osl_pktcookie((skb))
7405 +#define PKTSETCOOKIE(skb, x) osl_pktsetcookie((skb), (x))
7406 +#define PKTLINK(skb) osl_pktlink((skb))
7407 +#define PKTSETLINK(skb, x) osl_pktsetlink((skb), (x))
7408 +#define PKTPRIO(skb) osl_pktprio((skb))
7409 +#define PKTSETPRIO(skb, x) osl_pktsetprio((skb), (x))
7410 +extern void *osl_pktget(osl_t *osh, uint len, bool send);
7411 +extern void osl_pktfree(void *skb);
7412 +extern uchar *osl_pktdata(osl_t *osh, void *skb);
7413 +extern uint osl_pktlen(osl_t *osh, void *skb);
7414 +extern uint osl_pktheadroom(osl_t *osh, void *skb);
7415 +extern uint osl_pkttailroom(osl_t *osh, void *skb);
7416 +extern void *osl_pktnext(osl_t *osh, void *skb);
7417 +extern void osl_pktsetnext(void *skb, void *x);
7418 +extern void osl_pktsetlen(osl_t *osh, void *skb, uint len);
7419 +extern uchar *osl_pktpush(osl_t *osh, void *skb, int bytes);
7420 +extern uchar *osl_pktpull(osl_t *osh, void *skb, int bytes);
7421 +extern void *osl_pktdup(osl_t *osh, void *skb);
7422 +extern void *osl_pktcookie(void *skb);
7423 +extern void osl_pktsetcookie(void *skb, void *x);
7424 +extern void *osl_pktlink(void *skb);
7425 +extern void osl_pktsetlink(void *skb, void *x);
7426 +extern uint osl_pktprio(void *skb);
7427 +extern void osl_pktsetprio(void *skb, uint x);
7429 +#endif /* BINOSL */
7431 +#define OSL_ERROR(bcmerror) osl_error(bcmerror)
7432 +extern int osl_error(int bcmerror);
7434 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
7435 +#define PKTBUFSZ 2048
7437 +#endif /* _linux_osl_h_ */
7438 diff -urN linux.old/arch/mips/bcm947xx/include/linuxver.h linux.dev/arch/mips/bcm947xx/include/linuxver.h
7439 --- linux.old/arch/mips/bcm947xx/include/linuxver.h 1970-01-01 01:00:00.000000000 +0100
7440 +++ linux.dev/arch/mips/bcm947xx/include/linuxver.h 2005-12-15 16:02:45.467929000 +0100
7443 + * Linux-specific abstractions to gain some independence from linux kernel versions.
7444 + * Pave over some 2.2 versus 2.4 versus 2.6 kernel differences.
7446 + * Copyright 2005, Broadcom Corporation
7447 + * All Rights Reserved.
7449 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7450 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7451 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7452 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7457 +#ifndef _linuxver_h_
7458 +#define _linuxver_h_
7460 +#include <linux/config.h>
7461 +#include <linux/version.h>
7463 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
7464 +/* __NO_VERSION__ must be defined for all linkables except one in 2.2 */
7465 +#ifdef __UNDEF_NO_VERSION__
7466 +#undef __NO_VERSION__
7468 +#define __NO_VERSION__
7472 +#if defined(MODULE) && defined(MODVERSIONS)
7473 +#include <linux/modversions.h>
7476 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
7477 +#include <linux/moduleparam.h>
7481 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
7482 +#define module_param(_name_, _type_, _perm_) MODULE_PARM(_name_, "i")
7483 +#define module_param_string(_name_, _string_, _size_, _perm_) MODULE_PARM(_string_, "c" __MODULE_STRING(_size_))
7486 +/* linux/malloc.h is deprecated, use linux/slab.h instead. */
7487 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,9))
7488 +#include <linux/malloc.h>
7490 +#include <linux/slab.h>
7493 +#include <linux/types.h>
7494 +#include <linux/init.h>
7495 +#include <linux/mm.h>
7496 +#include <linux/string.h>
7497 +#include <linux/pci.h>
7498 +#include <linux/interrupt.h>
7499 +#include <linux/netdevice.h>
7500 +#include <asm/io.h>
7502 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41))
7503 +#include <linux/workqueue.h>
7505 +#include <linux/tqueue.h>
7506 +#ifndef work_struct
7507 +#define work_struct tq_struct
7510 +#define INIT_WORK(_work, _func, _data) INIT_TQUEUE((_work), (_func), (_data))
7512 +#ifndef schedule_work
7513 +#define schedule_work(_work) schedule_task((_work))
7515 +#ifndef flush_scheduled_work
7516 +#define flush_scheduled_work() flush_scheduled_tasks()
7520 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
7521 +/* Some distributions have their own 2.6.x compatibility layers */
7523 +typedef void irqreturn_t;
7525 +#define IRQ_HANDLED
7526 +#define IRQ_RETVAL(x)
7529 +typedef irqreturn_t (*FN_ISR) (int irq, void *dev_id, struct pt_regs *ptregs);
7539 +#define __devinit __init
7541 +#ifndef __devinitdata
7542 +#define __devinitdata
7544 +#ifndef __devexit_p
7545 +#define __devexit_p(x) x
7548 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
7550 +#define pci_get_drvdata(dev) (dev)->sysdata
7551 +#define pci_set_drvdata(dev, value) (dev)->sysdata=(value)
7554 + * New-style (2.4.x) PCI/hot-pluggable PCI/CardBus registration
7557 +struct pci_device_id {
7558 + unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */
7559 + unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
7560 + unsigned int class, class_mask; /* (class,subclass,prog-if) triplet */
7561 + unsigned long driver_data; /* Data private to the driver */
7564 +struct pci_driver {
7565 + struct list_head node;
7567 + const struct pci_device_id *id_table; /* NULL if wants all devices */
7568 + int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
7569 + void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
7570 + void (*suspend)(struct pci_dev *dev); /* Device suspended */
7571 + void (*resume)(struct pci_dev *dev); /* Device woken up */
7574 +#define MODULE_DEVICE_TABLE(type, name)
7575 +#define PCI_ANY_ID (~0)
7578 +#define pci_module_init pci_register_driver
7579 +extern int pci_register_driver(struct pci_driver *drv);
7580 +extern void pci_unregister_driver(struct pci_driver *drv);
7582 +#endif /* PCI registration */
7584 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
7586 +#define module_init(x) int init_module(void) { return x(); }
7587 +#define module_exit(x) void cleanup_module(void) { x(); }
7589 +#define module_init(x) __initcall(x);
7590 +#define module_exit(x) __exitcall(x);
7594 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,48))
7595 +#define list_for_each(pos, head) \
7596 + for (pos = (head)->next; pos != (head); pos = pos->next)
7599 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,13))
7600 +#define pci_resource_start(dev, bar) ((dev)->base_address[(bar)])
7601 +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,44))
7602 +#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
7605 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,23))
7606 +#define pci_enable_device(dev) do { } while (0)
7609 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,14))
7610 +#define net_device device
7613 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,42))
7618 + * See linux/Documentation/DMA-mapping.txt
7621 +#ifndef PCI_DMA_TODEVICE
7622 +#define PCI_DMA_TODEVICE 1
7623 +#define PCI_DMA_FROMDEVICE 2
7626 +typedef u32 dma_addr_t;
7628 +/* Pure 2^n version of get_order */
7629 +static inline int get_order(unsigned long size)
7633 + size = (size-1) >> (PAGE_SHIFT-1);
7642 +static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
7643 + dma_addr_t *dma_handle)
7646 + int gfp = GFP_ATOMIC | GFP_DMA;
7648 + ret = (void *)__get_free_pages(gfp, get_order(size));
7650 + if (ret != NULL) {
7651 + memset(ret, 0, size);
7652 + *dma_handle = virt_to_bus(ret);
7656 +static inline void pci_free_consistent(struct pci_dev *hwdev, size_t size,
7657 + void *vaddr, dma_addr_t dma_handle)
7659 + free_pages((unsigned long)vaddr, get_order(size));
7662 +extern uint pci_map_single(void *dev, void *va, uint size, int direction);
7663 +extern void pci_unmap_single(void *dev, uint pa, uint size, int direction);
7665 +#define pci_map_single(cookie, address, size, dir) virt_to_bus(address)
7666 +#define pci_unmap_single(cookie, address, size, dir)
7669 +#endif /* DMA mapping */
7671 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,43))
7673 +#define dev_kfree_skb_any(a) dev_kfree_skb(a)
7674 +#define netif_down(dev) do { (dev)->start = 0; } while(0)
7676 +/* pcmcia-cs provides its own netdevice compatibility layer */
7677 +#ifndef _COMPAT_NETDEVICE_H
7682 + * For pre-softnet kernels we need to tell the upper layer not to
7683 + * re-enter start_xmit() while we are in there. However softnet
7684 + * guarantees not to enter while we are in there so there is no need
7685 + * to do the netif_stop_queue() dance unless the transmit queue really
7686 + * gets stuck. This should also improve performance according to tests
7687 + * done by Aman Singla.
7690 +#define dev_kfree_skb_irq(a) dev_kfree_skb(a)
7691 +#define netif_wake_queue(dev) do { clear_bit(0, &(dev)->tbusy); mark_bh(NET_BH); } while(0)
7692 +#define netif_stop_queue(dev) set_bit(0, &(dev)->tbusy)
7694 +static inline void netif_start_queue(struct net_device *dev)
7697 + dev->interrupt = 0;
7701 +#define netif_queue_stopped(dev) (dev)->tbusy
7702 +#define netif_running(dev) (dev)->start
7704 +#endif /* _COMPAT_NETDEVICE_H */
7706 +#define netif_device_attach(dev) netif_start_queue(dev)
7707 +#define netif_device_detach(dev) netif_stop_queue(dev)
7709 +/* 2.4.x renamed bottom halves to tasklets */
7710 +#define tasklet_struct tq_struct
7711 +static inline void tasklet_schedule(struct tasklet_struct *tasklet)
7713 + queue_task(tasklet, &tq_immediate);
7714 + mark_bh(IMMEDIATE_BH);
7717 +static inline void tasklet_init(struct tasklet_struct *tasklet,
7718 + void (*func)(unsigned long),
7719 + unsigned long data)
7721 + tasklet->next = NULL;
7722 + tasklet->sync = 0;
7723 + tasklet->routine = (void (*)(void *))func;
7724 + tasklet->data = (void *)data;
7726 +#define tasklet_kill(tasklet) {do{} while(0);}
7728 +/* 2.4.x introduced del_timer_sync() */
7729 +#define del_timer_sync(timer) del_timer(timer)
7733 +#define netif_down(dev)
7735 +#endif /* SoftNet */
7737 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3))
7740 + * Emit code to initialise a tq_struct's routine and data pointers
7742 +#define PREPARE_TQUEUE(_tq, _routine, _data) \
7744 + (_tq)->routine = _routine; \
7745 + (_tq)->data = _data; \
7749 + * Emit code to initialise all of a tq_struct
7751 +#define INIT_TQUEUE(_tq, _routine, _data) \
7753 + INIT_LIST_HEAD(&(_tq)->list); \
7754 + (_tq)->sync = 0; \
7755 + PREPARE_TQUEUE((_tq), (_routine), (_data)); \
7760 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6))
7762 +/* Power management related routines */
7765 +pci_save_state(struct pci_dev *dev, u32 *buffer)
7769 + for (i = 0; i < 16; i++)
7770 + pci_read_config_dword(dev, i * 4,&buffer[i]);
7776 +pci_restore_state(struct pci_dev *dev, u32 *buffer)
7781 + for (i = 0; i < 16; i++)
7782 + pci_write_config_dword(dev,i * 4, buffer[i]);
7785 + * otherwise, write the context information we know from bootup.
7786 + * This works around a problem where warm-booting from Windows
7787 + * combined with a D3(hot)->D0 transition causes PCI config
7788 + * header data to be forgotten.
7791 + for (i = 0; i < 6; i ++)
7792 + pci_write_config_dword(dev,
7793 + PCI_BASE_ADDRESS_0 + (i * 4),
7794 + pci_resource_start(dev, i));
7795 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
7800 +#endif /* PCI power management */
7802 +/* Old cp0 access macros deprecated in 2.4.19 */
7803 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19))
7804 +#define read_c0_count() read_32bit_cp0_register(CP0_COUNT)
7807 +/* Module refcount handled internally in 2.6.x */
7808 +#ifndef SET_MODULE_OWNER
7809 +#define SET_MODULE_OWNER(dev) do {} while (0)
7810 +#define OLD_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
7811 +#define OLD_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
7813 +#define OLD_MOD_INC_USE_COUNT do {} while (0)
7814 +#define OLD_MOD_DEC_USE_COUNT do {} while (0)
7817 +#ifndef SET_NETDEV_DEV
7818 +#define SET_NETDEV_DEV(net, pdev) do {} while (0)
7821 +#ifndef HAVE_FREE_NETDEV
7822 +#define free_netdev(dev) kfree(dev)
7825 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
7826 +/* struct packet_type redefined in 2.6.x */
7827 +#define af_packet_priv data
7830 +#endif /* _linuxver_h_ */
7831 diff -urN linux.old/arch/mips/bcm947xx/include/mipsinc.h linux.dev/arch/mips/bcm947xx/include/mipsinc.h
7832 --- linux.old/arch/mips/bcm947xx/include/mipsinc.h 1970-01-01 01:00:00.000000000 +0100
7833 +++ linux.dev/arch/mips/bcm947xx/include/mipsinc.h 2005-12-15 16:47:29.886633750 +0100
7836 + * HND Run Time Environment for standalone MIPS programs.
7838 + * Copyright 2005, Broadcom Corporation
7839 + * All Rights Reserved.
7841 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7842 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7843 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7844 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7855 +#ifdef _LANGUAGE_ASSEMBLY
7858 + * Symbolic register names for 32 bit ABI
7860 +#define zero $0 /* wired zero */
7861 +#define AT $1 /* assembler temp - uppercase because of ".set at" */
7862 +#define v0 $2 /* return value */
7864 +#define a0 $4 /* argument registers */
7868 +#define t0 $8 /* caller saved */
7876 +#define s0 $16 /* callee saved */
7884 +#define t8 $24 /* caller saved */
7886 +#define jp $25 /* PIC jump register */
7887 +#define k0 $26 /* kernel scratch */
7889 +#define gp $28 /* global pointer */
7890 +#define sp $29 /* stack pointer */
7891 +#define fp $30 /* frame pointer */
7892 +#define s8 $30 /* same like fp! */
7893 +#define ra $31 /* return address */
7902 +#define C0_TLBLO0 $2
7903 +#define C0_TLBLO C0_TLBLO0
7904 +#define C0_TLBLO1 $3
7905 +#define C0_CTEXT $4
7906 +#define C0_PGMASK $5
7907 +#define C0_WIRED $6
7908 +#define C0_BADVADDR $8
7909 +#define C0_COUNT $9
7910 +#define C0_TLBHI $10
7911 +#define C0_COMPARE $11
7913 +#define C0_STATUS C0_SR
7914 +#define C0_CAUSE $13
7916 +#define C0_PRID $15
7917 +#define C0_CONFIG $16
7918 +#define C0_LLADDR $17
7919 +#define C0_WATCHLO $18
7920 +#define C0_WATCHHI $19
7921 +#define C0_XCTEXT $20
7922 +#define C0_DIAGNOSTIC $22
7923 +#define C0_BROADCOM C0_DIAGNOSTIC
7924 +#define C0_PERFORMANCE $25
7926 +#define C0_CACHEERR $27
7927 +#define C0_TAGLO $28
7928 +#define C0_TAGHI $29
7929 +#define C0_ERREPC $30
7930 +#define C0_DESAVE $31
7933 + * LEAF - declare leaf routine
7935 +#define LEAF(symbol) \
7938 + .type symbol,@function; \
7940 +symbol: .frame sp,0,ra
7943 + * END - mark end of function
7945 +#define END(function) \
7947 + .size function,.-function
7954 + * The following macros are especially useful for __asm__
7955 + * inline assembler.
7958 +#define __STR(x) #x
7961 +#define STR(x) __STR(x)
7964 +#define _ULCAST_ (unsigned long)
7971 +#define C0_INX 0 /* CP0: TLB Index */
7972 +#define C0_RAND 1 /* CP0: TLB Random */
7973 +#define C0_TLBLO0 2 /* CP0: TLB EntryLo0 */
7974 +#define C0_TLBLO C0_TLBLO0 /* CP0: TLB EntryLo0 */
7975 +#define C0_TLBLO1 3 /* CP0: TLB EntryLo1 */
7976 +#define C0_CTEXT 4 /* CP0: Context */
7977 +#define C0_PGMASK 5 /* CP0: TLB PageMask */
7978 +#define C0_WIRED 6 /* CP0: TLB Wired */
7979 +#define C0_BADVADDR 8 /* CP0: Bad Virtual Address */
7980 +#define C0_COUNT 9 /* CP0: Count */
7981 +#define C0_TLBHI 10 /* CP0: TLB EntryHi */
7982 +#define C0_COMPARE 11 /* CP0: Compare */
7983 +#define C0_SR 12 /* CP0: Processor Status */
7984 +#define C0_STATUS C0_SR /* CP0: Processor Status */
7985 +#define C0_CAUSE 13 /* CP0: Exception Cause */
7986 +#define C0_EPC 14 /* CP0: Exception PC */
7987 +#define C0_PRID 15 /* CP0: Processor Revision Indentifier */
7988 +#define C0_CONFIG 16 /* CP0: Config */
7989 +#define C0_LLADDR 17 /* CP0: LLAddr */
7990 +#define C0_WATCHLO 18 /* CP0: WatchpointLo */
7991 +#define C0_WATCHHI 19 /* CP0: WatchpointHi */
7992 +#define C0_XCTEXT 20 /* CP0: XContext */
7993 +#define C0_DIAGNOSTIC 22 /* CP0: Diagnostic */
7994 +#define C0_BROADCOM C0_DIAGNOSTIC /* CP0: Broadcom Register */
7995 +#define C0_PERFORMANCE 25 /* CP0: Performance Counter/Control Registers */
7996 +#define C0_ECC 26 /* CP0: ECC */
7997 +#define C0_CACHEERR 27 /* CP0: CacheErr */
7998 +#define C0_TAGLO 28 /* CP0: TagLo */
7999 +#define C0_TAGHI 29 /* CP0: TagHi */
8000 +#define C0_ERREPC 30 /* CP0: ErrorEPC */
8001 +#define C0_DESAVE 31 /* CP0: DebugSave */
8003 +#endif /* _LANGUAGE_ASSEMBLY */
8006 + * Memory segments (32bit kernel mode addresses)
8013 +#define KUSEG 0x00000000
8014 +#define KSEG0 0x80000000
8015 +#define KSEG1 0xa0000000
8016 +#define KSEG2 0xc0000000
8017 +#define KSEG3 0xe0000000
8018 +#define PHYSADDR_MASK 0x1fffffff
8021 + * Map an address to a certain kernel segment
8029 +#define PHYSADDR(a) (_ULCAST_(a) & PHYSADDR_MASK)
8030 +#define KSEG0ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG0)
8031 +#define KSEG1ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG1)
8032 +#define KSEG2ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG2)
8033 +#define KSEG3ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG3)
8036 +#ifndef Index_Invalidate_I
8038 + * Cache Operations
8040 +#define Index_Invalidate_I 0x00
8041 +#define Index_Writeback_Inv_D 0x01
8042 +#define Index_Invalidate_SI 0x02
8043 +#define Index_Writeback_Inv_SD 0x03
8044 +#define Index_Load_Tag_I 0x04
8045 +#define Index_Load_Tag_D 0x05
8046 +#define Index_Load_Tag_SI 0x06
8047 +#define Index_Load_Tag_SD 0x07
8048 +#define Index_Store_Tag_I 0x08
8049 +#define Index_Store_Tag_D 0x09
8050 +#define Index_Store_Tag_SI 0x0A
8051 +#define Index_Store_Tag_SD 0x0B
8052 +#define Create_Dirty_Excl_D 0x0d
8053 +#define Create_Dirty_Excl_SD 0x0f
8054 +#define Hit_Invalidate_I 0x10
8055 +#define Hit_Invalidate_D 0x11
8056 +#define Hit_Invalidate_SI 0x12
8057 +#define Hit_Invalidate_SD 0x13
8058 +#define Fill_I 0x14
8059 +#define Hit_Writeback_Inv_D 0x15
8060 + /* 0x16 is unused */
8061 +#define Hit_Writeback_Inv_SD 0x17
8062 +#define R5K_Page_Invalidate_S 0x17
8063 +#define Hit_Writeback_I 0x18
8064 +#define Hit_Writeback_D 0x19
8065 + /* 0x1a is unused */
8066 +#define Hit_Writeback_SD 0x1b
8067 + /* 0x1c is unused */
8068 + /* 0x1e is unused */
8069 +#define Hit_Set_Virtual_SI 0x1e
8070 +#define Hit_Set_Virtual_SD 0x1f
8075 + * R4x00 interrupt enable / cause bits
8077 +#define IE_SW0 (_ULCAST_(1) << 8)
8078 +#define IE_SW1 (_ULCAST_(1) << 9)
8079 +#define IE_IRQ0 (_ULCAST_(1) << 10)
8080 +#define IE_IRQ1 (_ULCAST_(1) << 11)
8081 +#define IE_IRQ2 (_ULCAST_(1) << 12)
8082 +#define IE_IRQ3 (_ULCAST_(1) << 13)
8083 +#define IE_IRQ4 (_ULCAST_(1) << 14)
8084 +#define IE_IRQ5 (_ULCAST_(1) << 15)
8088 + * Bitfields in the mips32 cp0 status register
8090 +#define ST0_IE 0x00000001
8091 +#define ST0_EXL 0x00000002
8092 +#define ST0_ERL 0x00000004
8093 +#define ST0_UM 0x00000010
8094 +#define ST0_SWINT0 0x00000100
8095 +#define ST0_SWINT1 0x00000200
8096 +#define ST0_HWINT0 0x00000400
8097 +#define ST0_HWINT1 0x00000800
8098 +#define ST0_HWINT2 0x00001000
8099 +#define ST0_HWINT3 0x00002000
8100 +#define ST0_HWINT4 0x00004000
8101 +#define ST0_HWINT5 0x00008000
8102 +#define ST0_IM 0x0000ff00
8103 +#define ST0_NMI 0x00080000
8104 +#define ST0_SR 0x00100000
8105 +#define ST0_TS 0x00200000
8106 +#define ST0_BEV 0x00400000
8107 +#define ST0_RE 0x02000000
8108 +#define ST0_RP 0x08000000
8109 +#define ST0_CU 0xf0000000
8110 +#define ST0_CU0 0x10000000
8111 +#define ST0_CU1 0x20000000
8112 +#define ST0_CU2 0x40000000
8113 +#define ST0_CU3 0x80000000
8118 + * Bitfields in the mips32 cp0 cause register
8120 +#define C_EXC 0x0000007c
8121 +#define C_EXC_SHIFT 2
8122 +#define C_INT 0x0000ff00
8123 +#define C_INT_SHIFT 8
8124 +#define C_SW0 (_ULCAST_(1) << 8)
8125 +#define C_SW1 (_ULCAST_(1) << 9)
8126 +#define C_IRQ0 (_ULCAST_(1) << 10)
8127 +#define C_IRQ1 (_ULCAST_(1) << 11)
8128 +#define C_IRQ2 (_ULCAST_(1) << 12)
8129 +#define C_IRQ3 (_ULCAST_(1) << 13)
8130 +#define C_IRQ4 (_ULCAST_(1) << 14)
8131 +#define C_IRQ5 (_ULCAST_(1) << 15)
8132 +#define C_WP 0x00400000
8133 +#define C_IV 0x00800000
8134 +#define C_CE 0x30000000
8135 +#define C_CE_SHIFT 28
8136 +#define C_BD 0x80000000
8138 +/* Values in C_EXC */
8153 +#define EXC_WATCH 23
8154 +#define EXC_MCHK 24
8158 + * Bits in the cp0 config register.
8160 +#define CONF_CM_CACHABLE_NO_WA 0
8161 +#define CONF_CM_CACHABLE_WA 1
8162 +#define CONF_CM_UNCACHED 2
8163 +#define CONF_CM_CACHABLE_NONCOHERENT 3
8164 +#define CONF_CM_CACHABLE_CE 4
8165 +#define CONF_CM_CACHABLE_COW 5
8166 +#define CONF_CM_CACHABLE_CUW 6
8167 +#define CONF_CM_CACHABLE_ACCELERATED 7
8168 +#define CONF_CM_CMASK 7
8169 +#define CONF_CU (_ULCAST_(1) << 3)
8170 +#define CONF_DB (_ULCAST_(1) << 4)
8171 +#define CONF_IB (_ULCAST_(1) << 5)
8172 +#define CONF_SE (_ULCAST_(1) << 12)
8173 +#define CONF_SC (_ULCAST_(1) << 17)
8174 +#define CONF_AC (_ULCAST_(1) << 23)
8175 +#define CONF_HALT (_ULCAST_(1) << 25)
8179 + * Bits in the cp0 config register select 1.
8181 +#define CONF1_FP 0x00000001 /* FPU present */
8182 +#define CONF1_EP 0x00000002 /* EJTAG present */
8183 +#define CONF1_CA 0x00000004 /* mips16 implemented */
8184 +#define CONF1_WR 0x00000008 /* Watch registers present */
8185 +#define CONF1_PC 0x00000010 /* Performance counters present */
8186 +#define CONF1_DA_SHIFT 7 /* D$ associativity */
8187 +#define CONF1_DA_MASK 0x00000380
8188 +#define CONF1_DA_BASE 1
8189 +#define CONF1_DL_SHIFT 10 /* D$ line size */
8190 +#define CONF1_DL_MASK 0x00001c00
8191 +#define CONF1_DL_BASE 2
8192 +#define CONF1_DS_SHIFT 13 /* D$ sets/way */
8193 +#define CONF1_DS_MASK 0x0000e000
8194 +#define CONF1_DS_BASE 64
8195 +#define CONF1_IA_SHIFT 16 /* I$ associativity */
8196 +#define CONF1_IA_MASK 0x00070000
8197 +#define CONF1_IA_BASE 1
8198 +#define CONF1_IL_SHIFT 19 /* I$ line size */
8199 +#define CONF1_IL_MASK 0x00380000
8200 +#define CONF1_IL_BASE 2
8201 +#define CONF1_IS_SHIFT 22 /* Instruction cache sets/way */
8202 +#define CONF1_IS_MASK 0x01c00000
8203 +#define CONF1_IS_BASE 64
8204 +#define CONF1_MS_MASK 0x7e000000 /* Number of tlb entries */
8205 +#define CONF1_MS_SHIFT 25
8207 +/* PRID register */
8208 +#define PRID_COPT_MASK 0xff000000
8209 +#define PRID_COMP_MASK 0x00ff0000
8210 +#define PRID_IMP_MASK 0x0000ff00
8211 +#define PRID_REV_MASK 0x000000ff
8213 +#define PRID_COMP_LEGACY 0x000000
8214 +#define PRID_COMP_MIPS 0x010000
8215 +#define PRID_COMP_BROADCOM 0x020000
8216 +#define PRID_COMP_ALCHEMY 0x030000
8217 +#define PRID_COMP_SIBYTE 0x040000
8218 +#define PRID_IMP_BCM4710 0x4000
8219 +#define PRID_IMP_BCM3302 0x9000
8220 +#define PRID_IMP_BCM3303 0x9100
8222 +#define PRID_IMP_UNKNOWN 0xff00
8224 +#define BCM330X(id) \
8225 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) \
8226 + || ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3303)))
8228 +/* Bits in C0_BROADCOM */
8229 +#define BRCM_PFC_AVAIL 0x20000000 /* PFC is available */
8230 +#define BRCM_DC_ENABLE 0x40000000 /* Enable Data $ */
8231 +#define BRCM_IC_ENABLE 0x80000000 /* Enable Instruction $ */
8232 +#define BRCM_PFC_ENABLE 0x00400000 /* Obsolete? Enable PFC (at least on 4310) */
8234 +/* PreFetch Cache aka Read Ahead Cache */
8236 +#define PFC_CR0 0xff400000 /* control reg 0 */
8237 +#define PFC_CR1 0xff400004 /* control reg 1 */
8239 +/* PFC operations */
8240 +#define PFC_I 0x00000001 /* Enable PFC use for instructions */
8241 +#define PFC_D 0x00000002 /* Enable PFC use for data */
8242 +#define PFC_PFI 0x00000004 /* Enable seq. prefetch for instructions */
8243 +#define PFC_PFD 0x00000008 /* Enable seq. prefetch for data */
8244 +#define PFC_CINV 0x00000010 /* Enable selective (i/d) cacheop flushing */
8245 +#define PFC_NCH 0x00000020 /* Disable flushing based on cacheops */
8246 +#define PFC_DPF 0x00000040 /* Enable directional prefetching */
8247 +#define PFC_FLUSH 0x00000100 /* Flush the PFC */
8248 +#define PFC_BRR 0x40000000 /* Bus error indication */
8249 +#define PFC_PWR 0x80000000 /* Disable power saving (clock gating) */
8251 +/* Handy defaults */
8252 +#define PFC_DISABLED 0
8253 +#define PFC_AUTO 0xffffffff /* auto select the default mode */
8254 +#define PFC_INST (PFC_I | PFC_PFI | PFC_CINV)
8255 +#define PFC_INST_NOPF (PFC_I | PFC_CINV)
8256 +#define PFC_DATA (PFC_D | PFC_PFD | PFC_CINV)
8257 +#define PFC_DATA_NOPF (PFC_D | PFC_CINV)
8258 +#define PFC_I_AND_D (PFC_INST | PFC_DATA)
8259 +#define PFC_I_AND_D_NOPF (PFC_INST_NOPF | PFC_DATA_NOPF)
8263 + * These are the UART port assignments, expressed as offsets from the base
8264 + * register. These assignments should hold for any serial port based on
8265 + * a 8250, 16450, or 16550(A).
8268 +#define UART_RX 0 /* In: Receive buffer (DLAB=0) */
8269 +#define UART_TX 0 /* Out: Transmit buffer (DLAB=0) */
8270 +#define UART_DLL 0 /* Out: Divisor Latch Low (DLAB=1) */
8271 +#define UART_DLM 1 /* Out: Divisor Latch High (DLAB=1) */
8272 +#define UART_LCR 3 /* Out: Line Control Register */
8273 +#define UART_MCR 4 /* Out: Modem Control Register */
8274 +#define UART_LSR 5 /* In: Line Status Register */
8275 +#define UART_MSR 6 /* In: Modem Status Register */
8276 +#define UART_SCR 7 /* I/O: Scratch Register */
8277 +#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */
8278 +#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */
8279 +#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */
8280 +#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
8281 +#define UART_LSR_RXRDY 0x01 /* Receiver ready */
8284 +#ifndef _LANGUAGE_ASSEMBLY
8287 + * Macros to access the system control coprocessor
8290 +#define MFC0(source, sel) \
8293 + __asm__ __volatile__( \
8294 + ".set\tnoreorder\n\t" \
8295 + ".set\tnoat\n\t" \
8296 + ".word\t"STR(0x40010000 | ((source)<<11) | (sel))"\n\t" \
8297 + "move\t%0,$1\n\t" \
8306 +#define MTC0(source, sel, value) \
8308 + __asm__ __volatile__( \
8309 + ".set\tnoreorder\n\t" \
8310 + ".set\tnoat\n\t" \
8311 + "move\t$1,%z0\n\t" \
8312 + ".word\t"STR(0x40810000 | ((source)<<11) | (sel))"\n\t" \
8320 +#define get_c0_count() \
8323 + __asm__ __volatile__( \
8324 + ".set\tnoreorder\n\t" \
8325 + ".set\tnoat\n\t" \
8326 + "mfc0\t%0,$9\n\t" \
8333 +static INLINE void icache_probe(uint32 config1, uint *size, uint *lsize)
8335 + uint lsz, sets, ways;
8337 + /* Instruction Cache Size = Associativity * Line Size * Sets Per Way */
8338 + if ((lsz = ((config1 & CONF1_IL_MASK) >> CONF1_IL_SHIFT)))
8339 + lsz = CONF1_IL_BASE << lsz;
8340 + sets = CONF1_IS_BASE << ((config1 & CONF1_IS_MASK) >> CONF1_IS_SHIFT);
8341 + ways = CONF1_IA_BASE + ((config1 & CONF1_IA_MASK) >> CONF1_IA_SHIFT);
8342 + *size = lsz * sets * ways;
8346 +static INLINE void dcache_probe(uint32 config1, uint *size, uint *lsize)
8348 + uint lsz, sets, ways;
8350 + /* Data Cache Size = Associativity * Line Size * Sets Per Way */
8351 + if ((lsz = ((config1 & CONF1_DL_MASK) >> CONF1_DL_SHIFT)))
8352 + lsz = CONF1_DL_BASE << lsz;
8353 + sets = CONF1_DS_BASE << ((config1 & CONF1_DS_MASK) >> CONF1_DS_SHIFT);
8354 + ways = CONF1_DA_BASE + ((config1 & CONF1_DA_MASK) >> CONF1_DA_SHIFT);
8355 + *size = lsz * sets * ways;
8359 +#define cache_op(base, op) \
8360 + __asm__ __volatile__(" \
8370 +#define cache_unroll4(base, delta, op) \
8371 + __asm__ __volatile__(" \
8375 + cache %1,delta(%0); \
8376 + cache %1,(2 * delta)(%0); \
8377 + cache %1,(3 * delta)(%0); \
8384 +#endif /* !_LANGUAGE_ASSEMBLY */
8386 +#endif /* _MISPINC_H */
8387 diff -urN linux.old/arch/mips/bcm947xx/include/osl.h linux.dev/arch/mips/bcm947xx/include/osl.h
8388 --- linux.old/arch/mips/bcm947xx/include/osl.h 1970-01-01 01:00:00.000000000 +0100
8389 +++ linux.dev/arch/mips/bcm947xx/include/osl.h 2005-12-15 15:35:08.321801750 +0100
8392 + * OS Abstraction Layer
8394 + * Copyright 2005, Broadcom Corporation
8395 + * All Rights Reserved.
8397 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8398 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8399 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8400 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8407 +/* osl handle type forward declaration */
8408 +typedef struct os_handle osl_t;
8411 +#include <linux_osl.h>
8412 +#elif defined(NDIS)
8413 +#include <ndis_osl.h>
8414 +#elif defined(_CFE_)
8415 +#include <cfe_osl.h>
8416 +#elif defined(_HNDRTE_)
8417 +#include <hndrte_osl.h>
8418 +#elif defined(_MINOSL_)
8419 +#include <min_osl.h>
8421 +#include <pmon_osl.h>
8422 +#elif defined(MACOSX)
8423 +#include <macosx_osl.h>
8425 +#error "Unsupported OSL requested"
8429 +#define SET_REG(r, mask, val) W_REG((r), ((R_REG(r) & ~(mask)) | (val)))
8430 +#define MAXPRIO 7 /* 0-7 */
8432 +#endif /* _osl_h_ */
8433 diff -urN linux.old/arch/mips/bcm947xx/include/pcicfg.h linux.dev/arch/mips/bcm947xx/include/pcicfg.h
8434 --- linux.old/arch/mips/bcm947xx/include/pcicfg.h 1970-01-01 01:00:00.000000000 +0100
8435 +++ linux.dev/arch/mips/bcm947xx/include/pcicfg.h 2005-12-15 15:36:31.719013750 +0100
8438 + * pcicfg.h: PCI configuration constants and structures.
8440 + * Copyright 2005, Broadcom Corporation
8441 + * All Rights Reserved.
8443 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8444 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8445 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8446 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8454 +/* The following inside ifndef's so we don't collide with NTDDK.H */
8455 +#ifndef PCI_MAX_BUS
8456 +#define PCI_MAX_BUS 0x100
8458 +#ifndef PCI_MAX_DEVICES
8459 +#define PCI_MAX_DEVICES 0x20
8461 +#ifndef PCI_MAX_FUNCTION
8462 +#define PCI_MAX_FUNCTION 0x8
8465 +#ifndef PCI_INVALID_VENDORID
8466 +#define PCI_INVALID_VENDORID 0xffff
8468 +#ifndef PCI_INVALID_DEVICEID
8469 +#define PCI_INVALID_DEVICEID 0xffff
8473 +/* Convert between bus-slot-function-register and config addresses */
8475 +#define PCICFG_BUS_SHIFT 16 /* Bus shift */
8476 +#define PCICFG_SLOT_SHIFT 11 /* Slot shift */
8477 +#define PCICFG_FUN_SHIFT 8 /* Function shift */
8478 +#define PCICFG_OFF_SHIFT 0 /* Register shift */
8480 +#define PCICFG_BUS_MASK 0xff /* Bus mask */
8481 +#define PCICFG_SLOT_MASK 0x1f /* Slot mask */
8482 +#define PCICFG_FUN_MASK 7 /* Function mask */
8483 +#define PCICFG_OFF_MASK 0xff /* Bus mask */
8485 +#define PCI_CONFIG_ADDR(b, s, f, o) \
8486 + ((((b) & PCICFG_BUS_MASK) << PCICFG_BUS_SHIFT) \
8487 + | (((s) & PCICFG_SLOT_MASK) << PCICFG_SLOT_SHIFT) \
8488 + | (((f) & PCICFG_FUN_MASK) << PCICFG_FUN_SHIFT) \
8489 + | (((o) & PCICFG_OFF_MASK) << PCICFG_OFF_SHIFT))
8491 +#define PCI_CONFIG_BUS(a) (((a) >> PCICFG_BUS_SHIFT) & PCICFG_BUS_MASK)
8492 +#define PCI_CONFIG_SLOT(a) (((a) >> PCICFG_SLOT_SHIFT) & PCICFG_SLOT_MASK)
8493 +#define PCI_CONFIG_FUN(a) (((a) >> PCICFG_FUN_SHIFT) & PCICFG_FUN_MASK)
8494 +#define PCI_CONFIG_OFF(a) (((a) >> PCICFG_OFF_SHIFT) & PCICFG_OFF_MASK)
8496 +/* The actual config space */
8498 +#define PCI_BAR_MAX 6
8500 +#define PCI_ROM_BAR 8
8502 +#define PCR_RSVDA_MAX 2
8504 +/* pci config status reg has a bit to indicate that capability ptr is present*/
8506 +#define PCI_CAPPTR_PRESENT 0x0010
8508 +typedef struct _pci_config_regs {
8509 + unsigned short vendor;
8510 + unsigned short device;
8511 + unsigned short command;
8512 + unsigned short status;
8513 + unsigned char rev_id;
8514 + unsigned char prog_if;
8515 + unsigned char sub_class;
8516 + unsigned char base_class;
8517 + unsigned char cache_line_size;
8518 + unsigned char latency_timer;
8519 + unsigned char header_type;
8520 + unsigned char bist;
8521 + unsigned long base[PCI_BAR_MAX];
8522 + unsigned long cardbus_cis;
8523 + unsigned short subsys_vendor;
8524 + unsigned short subsys_id;
8525 + unsigned long baserom;
8526 + unsigned long rsvd_a[PCR_RSVDA_MAX];
8527 + unsigned char int_line;
8528 + unsigned char int_pin;
8529 + unsigned char min_gnt;
8530 + unsigned char max_lat;
8531 + unsigned char dev_dep[192];
8534 +#define SZPCR (sizeof (pci_config_regs))
8535 +#define MINSZPCR 64 /* offsetof (dev_dep[0] */
8537 +/* A structure for the config registers is nice, but in most
8538 + * systems the config space is not memory mapped, so we need
8539 + * filed offsetts. :-(
8541 +#define PCI_CFG_VID 0
8542 +#define PCI_CFG_DID 2
8543 +#define PCI_CFG_CMD 4
8544 +#define PCI_CFG_STAT 6
8545 +#define PCI_CFG_REV 8
8546 +#define PCI_CFG_PROGIF 9
8547 +#define PCI_CFG_SUBCL 0xa
8548 +#define PCI_CFG_BASECL 0xb
8549 +#define PCI_CFG_CLSZ 0xc
8550 +#define PCI_CFG_LATTIM 0xd
8551 +#define PCI_CFG_HDR 0xe
8552 +#define PCI_CFG_BIST 0xf
8553 +#define PCI_CFG_BAR0 0x10
8554 +#define PCI_CFG_BAR1 0x14
8555 +#define PCI_CFG_BAR2 0x18
8556 +#define PCI_CFG_BAR3 0x1c
8557 +#define PCI_CFG_BAR4 0x20
8558 +#define PCI_CFG_BAR5 0x24
8559 +#define PCI_CFG_CIS 0x28
8560 +#define PCI_CFG_SVID 0x2c
8561 +#define PCI_CFG_SSID 0x2e
8562 +#define PCI_CFG_ROMBAR 0x30
8563 +#define PCI_CFG_CAPPTR 0x34
8564 +#define PCI_CFG_INT 0x3c
8565 +#define PCI_CFG_PIN 0x3d
8566 +#define PCI_CFG_MINGNT 0x3e
8567 +#define PCI_CFG_MAXLAT 0x3f
8569 +/* Classes and subclasses */
8572 + PCI_CLASS_OLD = 0,
8575 + PCI_CLASS_DISPLAY,
8585 + PCI_CLASS_INTELLIGENT = 0xe,
8586 + PCI_CLASS_SATELLITE,
8598 + PCI_DASDI_OTHER = 0x80
8599 +} pci_dasdi_subclasses;
8606 + PCI_NET_OTHER = 0x80
8607 +} pci_net_subclasses;
8613 + PCI_DISPLAY_OTHER = 0x80
8614 +} pci_display_subclasses;
8620 + PCI_MEDIA_OTHER = 0x80
8621 +} pci_mmedia_subclasses;
8626 + PCI_MEMORY_OTHER = 0x80
8627 +} pci_memory_subclasses;
8635 + PCI_BRIDGE_PCMCIA,
8637 + PCI_BRIDGE_CARDBUS,
8638 + PCI_BRIDGE_RACEWAY,
8639 + PCI_BRIDGE_OTHER = 0x80
8640 +} pci_bridge_subclasses;
8644 + PCI_COMM_PARALLEL,
8645 + PCI_COMM_MULTIUART,
8647 + PCI_COMM_OTHER = 0x80
8648 +} pci_comm_subclasses;
8655 + PCI_BASE_PCI_HOTPLUG,
8656 + PCI_BASE_OTHER = 0x80
8657 +} pci_base_subclasses;
8663 + PCI_INPUT_SCANNER,
8664 + PCI_INPUT_GAMEPORT,
8665 + PCI_INPUT_OTHER = 0x80
8666 +} pci_input_subclasses;
8670 + PCI_DOCK_OTHER = 0x80
8671 +} pci_dock_subclasses;
8677 + PCI_CPU_ALPHA = 0x10,
8678 + PCI_CPU_POWERPC = 0x20,
8679 + PCI_CPU_MIPS = 0x30,
8680 + PCI_CPU_COPROC = 0x40,
8681 + PCI_CPU_OTHER = 0x80
8682 +} pci_cpu_subclasses;
8685 + PCI_SERIAL_IEEE1394,
8686 + PCI_SERIAL_ACCESS,
8691 + PCI_SERIAL_OTHER = 0x80
8692 +} pci_serial_subclasses;
8695 + PCI_INTELLIGENT_I2O,
8696 +} pci_intelligent_subclasses;
8700 + PCI_SATELLITE_AUDIO,
8701 + PCI_SATELLITE_VOICE,
8702 + PCI_SATELLITE_DATA,
8703 + PCI_SATELLITE_OTHER = 0x80
8704 +} pci_satellite_subclasses;
8707 + PCI_CRYPT_NETWORK,
8708 + PCI_CRYPT_ENTERTAINMENT,
8709 + PCI_CRYPT_OTHER = 0x80
8710 +} pci_crypt_subclasses;
8714 + PCI_DSP_OTHER = 0x80
8715 +} pci_dsp_subclasses;
8719 + PCI_HEADER_NORMAL,
8720 + PCI_HEADER_BRIDGE,
8721 + PCI_HEADER_CARDBUS
8722 +} pci_header_types;
8725 +/* Overlay for a PCI-to-PCI bridge */
8727 +#define PPB_RSVDA_MAX 2
8728 +#define PPB_RSVDD_MAX 8
8730 +typedef struct _ppb_config_regs {
8731 + unsigned short vendor;
8732 + unsigned short device;
8733 + unsigned short command;
8734 + unsigned short status;
8735 + unsigned char rev_id;
8736 + unsigned char prog_if;
8737 + unsigned char sub_class;
8738 + unsigned char base_class;
8739 + unsigned char cache_line_size;
8740 + unsigned char latency_timer;
8741 + unsigned char header_type;
8742 + unsigned char bist;
8743 + unsigned long rsvd_a[PPB_RSVDA_MAX];
8744 + unsigned char prim_bus;
8745 + unsigned char sec_bus;
8746 + unsigned char sub_bus;
8747 + unsigned char sec_lat;
8748 + unsigned char io_base;
8749 + unsigned char io_lim;
8750 + unsigned short sec_status;
8751 + unsigned short mem_base;
8752 + unsigned short mem_lim;
8753 + unsigned short pf_mem_base;
8754 + unsigned short pf_mem_lim;
8755 + unsigned long pf_mem_base_hi;
8756 + unsigned long pf_mem_lim_hi;
8757 + unsigned short io_base_hi;
8758 + unsigned short io_lim_hi;
8759 + unsigned short subsys_vendor;
8760 + unsigned short subsys_id;
8761 + unsigned long rsvd_b;
8762 + unsigned char rsvd_c;
8763 + unsigned char int_pin;
8764 + unsigned short bridge_ctrl;
8765 + unsigned char chip_ctrl;
8766 + unsigned char diag_ctrl;
8767 + unsigned short arb_ctrl;
8768 + unsigned long rsvd_d[PPB_RSVDD_MAX];
8769 + unsigned char dev_dep[192];
8773 +/* PCI CAPABILITY DEFINES */
8774 +#define PCI_CAP_POWERMGMTCAP_ID 0x01
8775 +#define PCI_CAP_MSICAP_ID 0x05
8777 +/* Data structure to define the Message Signalled Interrupt facility
8778 + * Valid for PCI and PCIE configurations */
8779 +typedef struct _pciconfig_cap_msi {
8780 + unsigned char capID;
8781 + unsigned char nextptr;
8782 + unsigned short msgctrl;
8783 + unsigned int msgaddr;
8784 +} pciconfig_cap_msi;
8786 +/* Data structure to define the Power managment facility
8787 + * Valid for PCI and PCIE configurations */
8788 +typedef struct _pciconfig_cap_pwrmgmt {
8789 + unsigned char capID;
8790 + unsigned char nextptr;
8791 + unsigned short pme_cap;
8792 + unsigned short pme_sts_ctrl;
8793 + unsigned char pme_bridge_ext;
8794 + unsigned char data;
8795 +} pciconfig_cap_pwrmgmt;
8797 +/* Everything below is BRCM HND proprietary */
8799 +#define PCI_BAR0_WIN 0x80 /* backplane addres space accessed by BAR0 */
8800 +#define PCI_BAR1_WIN 0x84 /* backplane addres space accessed by BAR1 */
8801 +#define PCI_SPROM_CONTROL 0x88 /* sprom property control */
8802 +#define PCI_BAR1_CONTROL 0x8c /* BAR1 region burst control */
8803 +#define PCI_INT_STATUS 0x90 /* PCI and other cores interrupts */
8804 +#define PCI_INT_MASK 0x94 /* mask of PCI and other cores interrupts */
8805 +#define PCI_TO_SB_MB 0x98 /* signal backplane interrupts */
8806 +#define PCI_BACKPLANE_ADDR 0xA0 /* address an arbitrary location on the system backplane */
8807 +#define PCI_BACKPLANE_DATA 0xA4 /* data at the location specified by above address register */
8808 +#define PCI_GPIO_IN 0xb0 /* pci config space gpio input (>=rev3) */
8809 +#define PCI_GPIO_OUT 0xb4 /* pci config space gpio output (>=rev3) */
8810 +#define PCI_GPIO_OUTEN 0xb8 /* pci config space gpio output enable (>=rev3) */
8812 +#define PCI_BAR0_SPROM_OFFSET (4 * 1024) /* bar0 + 4K accesses external sprom */
8813 +#define PCI_BAR0_PCIREGS_OFFSET (6 * 1024) /* bar0 + 6K accesses pci core registers */
8815 +/* PCI_INT_STATUS */
8816 +#define PCI_SBIM_STATUS_SERR 0x4 /* backplane SBErr interrupt status */
8819 +#define PCI_SBIM_SHIFT 8 /* backplane core interrupt mask bits offset */
8820 +#define PCI_SBIM_MASK 0xff00 /* backplane core interrupt mask */
8821 +#define PCI_SBIM_MASK_SERR 0x4 /* backplane SBErr interrupt mask */
8823 +/* PCI_SPROM_CONTROL */
8824 +#define SPROM_BLANK 0x04 /* indicating a blank sprom */
8825 +#define SPROM_WRITEEN 0x10 /* sprom write enable */
8826 +#define SPROM_BOOTROM_WE 0x20 /* external bootrom write enable */
8828 +#define SPROM_SIZE 256 /* sprom size in 16-bit */
8829 +#define SPROM_CRC_RANGE 64 /* crc cover range in 16-bit */
8831 +/* PCI_CFG_CMD_STAT */
8832 +#define PCI_CFG_CMD_STAT_TA 0x08000000 /* target abort status */
8835 diff -urN linux.old/arch/mips/bcm947xx/include/proto/ethernet.h linux.dev/arch/mips/bcm947xx/include/proto/ethernet.h
8836 --- linux.old/arch/mips/bcm947xx/include/proto/ethernet.h 1970-01-01 01:00:00.000000000 +0100
8837 +++ linux.dev/arch/mips/bcm947xx/include/proto/ethernet.h 2005-12-15 12:57:27.869191250 +0100
8839 +/*******************************************************************************
8841 + * Copyright 2001-2003, Broadcom Corporation
8842 + * All Rights Reserved.
8844 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8845 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8846 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8847 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8848 + * From FreeBSD 2.2.7: Fundamental constants relating to ethernet.
8849 + ******************************************************************************/
8851 +#ifndef _NET_ETHERNET_H_ /* use native BSD ethernet.h when available */
8852 +#define _NET_ETHERNET_H_
8854 +#ifndef _TYPEDEFS_H_
8855 +#include "typedefs.h"
8858 +#if defined(__GNUC__)
8859 +#define PACKED __attribute__((packed))
8865 + * The number of bytes in an ethernet (MAC) address.
8867 +#define ETHER_ADDR_LEN 6
8870 + * The number of bytes in the type field.
8872 +#define ETHER_TYPE_LEN 2
8875 + * The number of bytes in the trailing CRC field.
8877 +#define ETHER_CRC_LEN 4
8880 + * The length of the combined header.
8882 +#define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
8885 + * The minimum packet length.
8887 +#define ETHER_MIN_LEN 64
8890 + * The minimum packet user data length.
8892 +#define ETHER_MIN_DATA 46
8895 + * The maximum packet length.
8897 +#define ETHER_MAX_LEN 1518
8900 + * The maximum packet user data length.
8902 +#define ETHER_MAX_DATA 1500
8905 + * Used to uniquely identify a 802.1q VLAN-tagged header.
8907 +#define VLAN_TAG 0x8100
8910 + * Located after dest & src address in ether header.
8912 +#define VLAN_FIELDS_OFFSET (ETHER_ADDR_LEN * 2)
8915 + * 4 bytes of vlan field info.
8917 +#define VLAN_FIELDS_SIZE 4
8919 +/* location of pri bits in 16-bit vlan fields */
8920 +#define VLAN_PRI_SHIFT 13
8922 +/* 3 bits of priority */
8923 +#define VLAN_PRI_MASK 7
8925 +/* 802.1X ethertype */
8926 +#define ETHER_TYPE_802_1X 0x888e
8929 + * A macro to validate a length with
8931 +#define ETHER_IS_VALID_LEN(foo) \
8932 + ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
8935 +#ifndef __INCif_etherh /* Quick and ugly hack for VxWorks */
8937 + * Structure of a 10Mb/s Ethernet header.
8939 +struct ether_header {
8940 + uint8 ether_dhost[ETHER_ADDR_LEN];
8941 + uint8 ether_shost[ETHER_ADDR_LEN];
8942 + uint16 ether_type;
8946 + * Structure of a 48-bit Ethernet address.
8948 +struct ether_addr {
8949 + uint8 octet[ETHER_ADDR_LEN];
8954 + * Takes a pointer, returns true if a 48-bit multicast address
8955 + * (including broadcast, since it is all ones)
8957 +#define ETHER_ISMULTI(ea) (((uint8 *)(ea))[0] & 1)
8960 + * Takes a pointer, returns true if a 48-bit broadcast (all ones)
8962 +#define ETHER_ISBCAST(ea) ((((uint8 *)(ea))[0] & \
8963 + ((uint8 *)(ea))[1] & \
8964 + ((uint8 *)(ea))[2] & \
8965 + ((uint8 *)(ea))[3] & \
8966 + ((uint8 *)(ea))[4] & \
8967 + ((uint8 *)(ea))[5]) == 0xff)
8969 +static const struct ether_addr ether_bcast = {{255, 255, 255, 255, 255, 255}};
8972 + * Takes a pointer, returns true if a 48-bit null address (all zeros)
8974 +#define ETHER_ISNULLADDR(ea) ((((uint8 *)(ea))[0] | \
8975 + ((uint8 *)(ea))[1] | \
8976 + ((uint8 *)(ea))[2] | \
8977 + ((uint8 *)(ea))[3] | \
8978 + ((uint8 *)(ea))[4] | \
8979 + ((uint8 *)(ea))[5]) == 0)
8983 +#endif /* _NET_ETHERNET_H_ */
8984 diff -urN linux.old/arch/mips/bcm947xx/include/s5.h linux.dev/arch/mips/bcm947xx/include/s5.h
8985 --- linux.old/arch/mips/bcm947xx/include/s5.h 1970-01-01 01:00:00.000000000 +0100
8986 +++ linux.dev/arch/mips/bcm947xx/include/s5.h 2005-12-15 12:57:27.869191250 +0100
8991 + * Copyright 2003, Broadcom Corporation
8992 + * All Rights Reserved.
8994 + * Broadcom Sentry5 (S5) BCM5365, 53xx, BCM58xx SOC Internal Core
8995 + * and MIPS3301 (R4K) System Address Space
8997 + * This program is free software; you can redistribute it and/or
8998 + * modify it under the terms of the GNU General Public License as
8999 + * published by the Free Software Foundation, located in the file
9002 + * $Id: s5.h,v 1.3 2003/06/10 18:54:51 jfd Exp $
9006 +/* BCM5365 Address map */
9007 +#define KSEG1ADDR(x) ( (x) | 0xa0000000)
9008 +#define BCM5365_SDRAM 0x00000000 /* 0-128MB Physical SDRAM */
9009 +#define BCM5365_PCI_MEM 0x08000000 /* Host Mode PCI mem space (64MB) */
9010 +#define BCM5365_PCI_CFG 0x0c000000 /* Host Mode PCI cfg space (64MB) */
9011 +#define BCM5365_PCI_DMA 0x40000000 /* Client Mode PCI mem space (1GB)*/
9012 +#define BCM5365_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
9013 +#define BCM5365_ENUM 0x18000000 /* Beginning of core enum space */
9015 +/* BCM5365 Core register space */
9016 +#define BCM5365_REG_CHIPC 0x18000000 /* Chipcommon registers */
9017 +#define BCM5365_REG_EMAC0 0x18001000 /* Ethernet MAC0 core registers */
9018 +#define BCM5365_REG_IPSEC 0x18002000 /* BCM582x CryptoCore registers */
9019 +#define BCM5365_REG_USB 0x18003000 /* USB core registers */
9020 +#define BCM5365_REG_PCI 0x18004000 /* PCI core registers */
9021 +#define BCM5365_REG_MIPS33 0x18005000 /* MIPS core registers */
9022 +#define BCM5365_REG_MEMC 0x18006000 /* MEMC core registers */
9023 +#define BCM5365_REG_UARTS (BCM5365_REG_CHIPC + 0x300) /* UART regs */
9024 +#define BCM5365_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
9026 +/* COM Ports 1/2 */
9027 +#define BCM5365_UART (BCM5365_REG_UARTS)
9028 +#define BCM5365_UART_COM2 (BCM5365_REG_UARTS + 0x00000100)
9030 +/* Registers common to MIPS33 Core used in 5365 */
9031 +#define MIPS33_FLASH_REGION 0x1fc00000 /* Boot FLASH Region */
9032 +#define MIPS33_EXTIF_REGION 0x1a000000 /* Chipcommon EXTIF region*/
9033 +#define BCM5365_EXTIF 0x1b000000 /* MISC_CS */
9034 +#define MIPS33_FLASH_REGION_AUX 0x1c000000 /* FLASH Region 2*/
9036 +/* Internal Core Sonics Backplane Devices */
9037 +#define INTERNAL_UART_COM1 BCM5365_UART
9038 +#define INTERNAL_UART_COM2 BCM5365_UART_COM2
9039 +#define SB_REG_CHIPC BCM5365_REG_CHIPC
9040 +#define SB_REG_ENET0 BCM5365_REG_EMAC0
9041 +#define SB_REG_IPSEC BCM5365_REG_IPSEC
9042 +#define SB_REG_USB BCM5365_REG_USB
9043 +#define SB_REG_PCI BCM5365_REG_PCI
9044 +#define SB_REG_MIPS BCM5365_REG_MIPS33
9045 +#define SB_REG_MEMC BCM5365_REG_MEMC
9046 +#define SB_REG_MEMC_OFF 0x6000
9047 +#define SB_EXTIF_SPACE MIPS33_EXTIF_REGION
9048 +#define SB_FLASH_SPACE MIPS33_FLASH_REGION
9052 + * 5365-specific backplane interrupt flag numbers. This should be done
9053 + * dynamically instead.
9055 +#define SBFLAG_PCI 0
9056 +#define SBFLAG_ENET0 1
9057 +#define SBFLAG_ILINE20 2
9058 +#define SBFLAG_CODEC 3
9059 +#define SBFLAG_USB 4
9060 +#define SBFLAG_EXTIF 5
9061 +#define SBFLAG_ENET1 6
9063 +/* BCM95365 Local Bus devices */
9064 +#define BCM95365K_RESET_ADDR BCM5365_EXTIF
9065 +#define BCM95365K_BOARDID_ADDR (BCM5365_EXTIF | 0x4000)
9066 +#define BCM95365K_DOC_ADDR (BCM5365_EXTIF | 0x6000)
9067 +#define BCM95365K_LED_ADDR (BCM5365_EXTIF | 0xc000)
9068 +#define BCM95365K_TOD_REG_BASE (BCM95365K_NVRAM_ADDR | 0x1ff0)
9069 +#define BCM95365K_NVRAM_ADDR (BCM5365_EXTIF | 0xe000)
9070 +#define BCM95365K_NVRAM_SIZE 0x1ff0 /* 8K NVRAM : DS1743/STM48txx*/
9072 +/* Write to DLR2416 VFD Display character RAM */
9073 +#define LED_REG(x) \
9074 + (*(volatile unsigned char *) (KSEG1ADDR(BCM95365K_LED_ADDR) + (x)))
9077 +#define BCM5365_TRACE(trval) do { *((int *)0xa0002ff8) = (trval); \
9080 +#define BCM5365_TRACE(trval) do { *((unsigned char *)\
9081 + KSEG1ADDR(BCM5365K_LED_ADDR)) = (trval); \
9082 + *((int *)0xa0002ff8) = (trval); } while (0)
9085 +/* BCM9536R Local Bus devices */
9086 +#define BCM95365R_DOC_ADDR BCM5365_EXTIF
9090 +#endif /*!_S5_H_ */
9091 diff -urN linux.old/arch/mips/bcm947xx/include/sbchipc.h linux.dev/arch/mips/bcm947xx/include/sbchipc.h
9092 --- linux.old/arch/mips/bcm947xx/include/sbchipc.h 1970-01-01 01:00:00.000000000 +0100
9093 +++ linux.dev/arch/mips/bcm947xx/include/sbchipc.h 2005-12-15 15:35:20.458560250 +0100
9096 + * SiliconBackplane Chipcommon core hardware definitions.
9098 + * The chipcommon core provides chip identification, SB control,
9099 + * jtag, 0/1/2 uarts, clock frequency control, a watchdog interrupt timer,
9100 + * gpio interface, extbus, and support for serial and parallel flashes.
9103 + * Copyright 2005, Broadcom Corporation
9104 + * All Rights Reserved.
9106 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9107 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9108 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9109 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9117 +#ifndef _LANGUAGE_ASSEMBLY
9119 +/* cpp contortions to concatenate w/arg prescan */
9121 +#define _PADLINE(line) pad ## line
9122 +#define _XSTR(line) _PADLINE(line)
9123 +#define PAD _XSTR(__LINE__)
9126 +typedef volatile struct {
9127 + uint32 chipid; /* 0x0 */
9128 + uint32 capabilities;
9129 + uint32 corecontrol; /* corerev >= 1 */
9133 + uint32 otpstatus; /* 0x10, corerev >= 10 */
9134 + uint32 otpcontrol;
9138 + /* Interrupt control */
9139 + uint32 intstatus; /* 0x20 */
9141 + uint32 chipcontrol; /* 0x28, rev >= 11 */
9142 + uint32 chipstatus; /* 0x2c, rev >= 11 */
9145 + uint32 jtagcmd; /* 0x30, rev >= 10 */
9150 + /* serial flash interface registers */
9151 + uint32 flashcontrol; /* 0x40 */
9152 + uint32 flashaddress;
9156 + /* Silicon backplane configuration broadcast control */
9157 + uint32 broadcastaddress; /* 0x50 */
9158 + uint32 broadcastdata;
9161 + /* gpio - cleared only by power-on-reset */
9162 + uint32 gpioin; /* 0x60 */
9165 + uint32 gpiocontrol;
9166 + uint32 gpiointpolarity;
9167 + uint32 gpiointmask;
9170 + /* Watchdog timer */
9171 + uint32 watchdog; /* 0x80 */
9174 + /*GPIO based LED powersave registers corerev >= 16*/
9175 + uint32 gpiotimerval; /*0x88 */
9176 + uint32 gpiotimeroutmask;
9178 + /* clock control */
9179 + uint32 clockcontrol_n; /* 0x90 */
9180 + uint32 clockcontrol_sb; /* aka m0 */
9181 + uint32 clockcontrol_pci; /* aka m1 */
9182 + uint32 clockcontrol_m2; /* mii/uart/mipsref */
9183 + uint32 clockcontrol_mips; /* aka m3 */
9184 + uint32 clkdiv; /* corerev >= 3 */
9187 + /* pll delay registers (corerev >= 4) */
9188 + uint32 pll_on_delay; /* 0xb0 */
9189 + uint32 fref_sel_delay;
9190 + uint32 slow_clk_ctl; /* 5 < corerev < 10 */
9193 + /* Instaclock registers (corerev >= 10) */
9194 + uint32 system_clk_ctl; /* 0xc0 */
9195 + uint32 clkstatestretch;
9198 + /* ExtBus control registers (corerev >= 3) */
9199 + uint32 pcmcia_config; /* 0x100 */
9200 + uint32 pcmcia_memwait;
9201 + uint32 pcmcia_attrwait;
9202 + uint32 pcmcia_iowait;
9203 + uint32 ide_config;
9204 + uint32 ide_memwait;
9205 + uint32 ide_attrwait;
9206 + uint32 ide_iowait;
9207 + uint32 prog_config;
9208 + uint32 prog_waitcount;
9209 + uint32 flash_config;
9210 + uint32 flash_waitcount;
9214 + uint8 uart0data; /* 0x300 */
9221 + uint8 uart0scratch;
9222 + uint8 PAD[248]; /* corerev >= 1 */
9224 + uint8 uart1data; /* 0x400 */
9231 + uint8 uart1scratch;
9234 +#endif /* _LANGUAGE_ASSEMBLY */
9236 +#define CC_CHIPID 0
9237 +#define CC_CAPABILITIES 4
9238 +#define CC_JTAGCMD 0x30
9239 +#define CC_JTAGIR 0x34
9240 +#define CC_JTAGDR 0x38
9241 +#define CC_JTAGCTRL 0x3c
9242 +#define CC_WATCHDOG 0x80
9243 +#define CC_CLKC_N 0x90
9244 +#define CC_CLKC_M0 0x94
9245 +#define CC_CLKC_M1 0x98
9246 +#define CC_CLKC_M2 0x9c
9247 +#define CC_CLKC_M3 0xa0
9248 +#define CC_CLKDIV 0xa4
9249 +#define CC_SYS_CLK_CTL 0xc0
9250 +#define CC_OTP 0x800
9253 +#define CID_ID_MASK 0x0000ffff /* Chip Id mask */
9254 +#define CID_REV_MASK 0x000f0000 /* Chip Revision mask */
9255 +#define CID_REV_SHIFT 16 /* Chip Revision shift */
9256 +#define CID_PKG_MASK 0x00f00000 /* Package Option mask */
9257 +#define CID_PKG_SHIFT 20 /* Package Option shift */
9258 +#define CID_CC_MASK 0x0f000000 /* CoreCount (corerev >= 4) */
9259 +#define CID_CC_SHIFT 24
9262 +#define CAP_UARTS_MASK 0x00000003 /* Number of uarts */
9263 +#define CAP_MIPSEB 0x00000004 /* MIPS is in big-endian mode */
9264 +#define CAP_UCLKSEL 0x00000018 /* UARTs clock select */
9265 +#define CAP_UINTCLK 0x00000008 /* UARTs are driven by internal divided clock */
9266 +#define CAP_UARTGPIO 0x00000020 /* UARTs own Gpio's 15:12 */
9267 +#define CAP_EXTBUS 0x00000040 /* External bus present */
9268 +#define CAP_FLASH_MASK 0x00000700 /* Type of flash */
9269 +#define CAP_PLL_MASK 0x00038000 /* Type of PLL */
9270 +#define CAP_PWR_CTL 0x00040000 /* Power control */
9271 +#define CAP_OTPSIZE 0x00380000 /* OTP Size (0 = none) */
9272 +#define CAP_OTPSIZE_SHIFT 19 /* OTP Size shift */
9273 +#define CAP_OTPSIZE_BASE 5 /* OTP Size base */
9274 +#define CAP_JTAGP 0x00400000 /* JTAG Master Present */
9275 +#define CAP_ROM 0x00800000 /* Internal boot rom active */
9278 +#define PLL_NONE 0x00000000
9279 +#define PLL_TYPE1 0x00010000 /* 48Mhz base, 3 dividers */
9280 +#define PLL_TYPE2 0x00020000 /* 48Mhz, 4 dividers */
9281 +#define PLL_TYPE3 0x00030000 /* 25Mhz, 2 dividers */
9282 +#define PLL_TYPE4 0x00008000 /* 48Mhz, 4 dividers */
9283 +#define PLL_TYPE5 0x00018000 /* 25Mhz, 4 dividers */
9284 +#define PLL_TYPE6 0x00028000 /* 100/200 or 120/240 only */
9285 +#define PLL_TYPE7 0x00038000 /* 25Mhz, 4 dividers */
9288 +#define CC_UARTCLKO 0x00000001 /* Drive UART with internal clock */
9289 +#define CC_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
9291 +/* Fields in the otpstatus register */
9292 +#define OTPS_PROGFAIL 0x80000000
9293 +#define OTPS_PROTECT 0x00000007
9294 +#define OTPS_HW_PROTECT 0x00000001
9295 +#define OTPS_SW_PROTECT 0x00000002
9296 +#define OTPS_CID_PROTECT 0x00000004
9298 +/* Fields in the otpcontrol register */
9299 +#define OTPC_RECWAIT 0xff000000
9300 +#define OTPC_PROGWAIT 0x00ffff00
9301 +#define OTPC_PRW_SHIFT 8
9302 +#define OTPC_MAXFAIL 0x00000038
9303 +#define OTPC_VSEL 0x00000006
9304 +#define OTPC_SELVL 0x00000001
9306 +/* Fields in otpprog */
9307 +#define OTPP_COL_MASK 0x000000ff
9308 +#define OTPP_ROW_MASK 0x0000ff00
9309 +#define OTPP_ROW_SHIFT 8
9310 +#define OTPP_READERR 0x10000000
9311 +#define OTPP_VALUE 0x20000000
9312 +#define OTPP_VALUE_SHIFT 29
9313 +#define OTPP_READ 0x40000000
9314 +#define OTPP_START 0x80000000
9315 +#define OTPP_BUSY 0x80000000
9318 +#define JCMD_START 0x80000000
9319 +#define JCMD_BUSY 0x80000000
9320 +#define JCMD_PAUSE 0x40000000
9321 +#define JCMD0_ACC_MASK 0x0000f000
9322 +#define JCMD0_ACC_IRDR 0x00000000
9323 +#define JCMD0_ACC_DR 0x00001000
9324 +#define JCMD0_ACC_IR 0x00002000
9325 +#define JCMD0_ACC_RESET 0x00003000
9326 +#define JCMD0_ACC_IRPDR 0x00004000
9327 +#define JCMD0_ACC_PDR 0x00005000
9328 +#define JCMD0_IRW_MASK 0x00000f00
9329 +#define JCMD_ACC_MASK 0x000f0000 /* Changes for corerev 11 */
9330 +#define JCMD_ACC_IRDR 0x00000000
9331 +#define JCMD_ACC_DR 0x00010000
9332 +#define JCMD_ACC_IR 0x00020000
9333 +#define JCMD_ACC_RESET 0x00030000
9334 +#define JCMD_ACC_IRPDR 0x00040000
9335 +#define JCMD_ACC_PDR 0x00050000
9336 +#define JCMD_IRW_MASK 0x00001f00
9337 +#define JCMD_IRW_SHIFT 8
9338 +#define JCMD_DRW_MASK 0x0000003f
9341 +#define JCTRL_FORCE_CLK 4 /* Force clock */
9342 +#define JCTRL_EXT_EN 2 /* Enable external targets */
9343 +#define JCTRL_EN 1 /* Enable Jtag master */
9345 +/* Fields in clkdiv */
9346 +#define CLKD_SFLASH 0x0f000000
9347 +#define CLKD_SFLASH_SHIFT 24
9348 +#define CLKD_OTP 0x000f0000
9349 +#define CLKD_OTP_SHIFT 16
9350 +#define CLKD_JTAG 0x00000f00
9351 +#define CLKD_JTAG_SHIFT 8
9352 +#define CLKD_UART 0x000000ff
9354 +/* intstatus/intmask */
9355 +#define CI_GPIO 0x00000001 /* gpio intr */
9356 +#define CI_EI 0x00000002 /* ro: ext intr pin (corerev >= 3) */
9357 +#define CI_WDRESET 0x80000000 /* watchdog reset occurred */
9360 +#define SCC_SS_MASK 0x00000007 /* slow clock source mask */
9361 +#define SCC_SS_LPO 0x00000000 /* source of slow clock is LPO */
9362 +#define SCC_SS_XTAL 0x00000001 /* source of slow clock is crystal */
9363 +#define SCC_SS_PCI 0x00000002 /* source of slow clock is PCI */
9364 +#define SCC_LF 0x00000200 /* LPOFreqSel, 1: 160Khz, 0: 32KHz */
9365 +#define SCC_LP 0x00000400 /* LPOPowerDown, 1: LPO is disabled, 0: LPO is enabled */
9366 +#define SCC_FS 0x00000800 /* ForceSlowClk, 1: sb/cores running on slow clock, 0: power logic control */
9367 +#define SCC_IP 0x00001000 /* IgnorePllOffReq, 1/0: power logic ignores/honors PLL clock disable requests from core */
9368 +#define SCC_XC 0x00002000 /* XtalControlEn, 1/0: power logic does/doesn't disable crystal when appropriate */
9369 +#define SCC_XP 0x00004000 /* XtalPU (RO), 1/0: crystal running/disabled */
9370 +#define SCC_CD_MASK 0xffff0000 /* ClockDivider (SlowClk = 1/(4+divisor)) */
9371 +#define SCC_CD_SHIFT 16
9373 +/* system_clk_ctl */
9374 +#define SYCC_IE 0x00000001 /* ILPen: Enable Idle Low Power */
9375 +#define SYCC_AE 0x00000002 /* ALPen: Enable Active Low Power */
9376 +#define SYCC_FP 0x00000004 /* ForcePLLOn */
9377 +#define SYCC_AR 0x00000008 /* Force ALP (or HT if ALPen is not set */
9378 +#define SYCC_HR 0x00000010 /* Force HT */
9379 +#define SYCC_CD_MASK 0xffff0000 /* ClkDiv (ILP = 1/(4+divisor)) */
9380 +#define SYCC_CD_SHIFT 16
9383 +#define GPIO_ONTIME_SHIFT 16
9385 +/* clockcontrol_n */
9386 +#define CN_N1_MASK 0x3f /* n1 control */
9387 +#define CN_N2_MASK 0x3f00 /* n2 control */
9388 +#define CN_N2_SHIFT 8
9389 +#define CN_PLLC_MASK 0xf0000 /* pll control */
9390 +#define CN_PLLC_SHIFT 16
9392 +/* clockcontrol_sb/pci/uart */
9393 +#define CC_M1_MASK 0x3f /* m1 control */
9394 +#define CC_M2_MASK 0x3f00 /* m2 control */
9395 +#define CC_M2_SHIFT 8
9396 +#define CC_M3_MASK 0x3f0000 /* m3 control */
9397 +#define CC_M3_SHIFT 16
9398 +#define CC_MC_MASK 0x1f000000 /* mux control */
9399 +#define CC_MC_SHIFT 24
9401 +/* N3M Clock control magic field values */
9402 +#define CC_F6_2 0x02 /* A factor of 2 in */
9403 +#define CC_F6_3 0x03 /* 6-bit fields like */
9404 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
9405 +#define CC_F6_5 0x09
9406 +#define CC_F6_6 0x11
9407 +#define CC_F6_7 0x21
9409 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
9411 +#define CC_MC_BYPASS 0x08
9412 +#define CC_MC_M1 0x04
9413 +#define CC_MC_M1M2 0x02
9414 +#define CC_MC_M1M2M3 0x01
9415 +#define CC_MC_M1M3 0x11
9417 +/* Type 2 Clock control magic field values */
9418 +#define CC_T2_BIAS 2 /* n1, n2, m1 & m3 bias */
9419 +#define CC_T2M2_BIAS 3 /* m2 bias */
9421 +#define CC_T2MC_M1BYP 1
9422 +#define CC_T2MC_M2BYP 2
9423 +#define CC_T2MC_M3BYP 4
9425 +/* Type 6 Clock control magic field values */
9426 +#define CC_T6_MMASK 1 /* bits of interest in m */
9427 +#define CC_T6_M0 120000000 /* sb clock for m = 0 */
9428 +#define CC_T6_M1 100000000 /* sb clock for m = 1 */
9429 +#define SB2MIPS_T6(sb) (2 * (sb))
9431 +/* Common clock base */
9432 +#define CC_CLOCK_BASE1 24000000 /* Half the clock freq */
9433 +#define CC_CLOCK_BASE2 12500000 /* Alternate crystal on some PLL's */
9435 +/* Clock control values for 200Mhz in 5350 */
9436 +#define CLKC_5350_N 0x0311
9437 +#define CLKC_5350_M 0x04020009
9439 +/* Flash types in the chipcommon capabilities register */
9440 +#define FLASH_NONE 0x000 /* No flash */
9441 +#define SFLASH_ST 0x100 /* ST serial flash */
9442 +#define SFLASH_AT 0x200 /* Atmel serial flash */
9443 +#define PFLASH 0x700 /* Parallel flash */
9445 +/* Bits in the config registers */
9446 +#define CC_CFG_EN 0x0001 /* Enable */
9447 +#define CC_CFG_EM_MASK 0x000e /* Extif Mode */
9448 +#define CC_CFG_EM_ASYNC 0x0002 /* Async/Parallel flash */
9449 +#define CC_CFG_EM_SYNC 0x0004 /* Synchronous */
9450 +#define CC_CFG_EM_PCMCIA 0x0008 /* PCMCIA */
9451 +#define CC_CFG_EM_IDE 0x000a /* IDE */
9452 +#define CC_CFG_DS 0x0010 /* Data size, 0=8bit, 1=16bit */
9453 +#define CC_CFG_CD_MASK 0x0060 /* Sync: Clock divisor */
9454 +#define CC_CFG_CE 0x0080 /* Sync: Clock enable */
9455 +#define CC_CFG_SB 0x0100 /* Sync: Size/Bytestrobe */
9457 +/* Start/busy bit in flashcontrol */
9458 +#define SFLASH_START 0x80000000
9459 +#define SFLASH_BUSY SFLASH_START
9461 +/* flashcontrol opcodes for ST flashes */
9462 +#define SFLASH_ST_WREN 0x0006 /* Write Enable */
9463 +#define SFLASH_ST_WRDIS 0x0004 /* Write Disable */
9464 +#define SFLASH_ST_RDSR 0x0105 /* Read Status Register */
9465 +#define SFLASH_ST_WRSR 0x0101 /* Write Status Register */
9466 +#define SFLASH_ST_READ 0x0303 /* Read Data Bytes */
9467 +#define SFLASH_ST_PP 0x0302 /* Page Program */
9468 +#define SFLASH_ST_SE 0x02d8 /* Sector Erase */
9469 +#define SFLASH_ST_BE 0x00c7 /* Bulk Erase */
9470 +#define SFLASH_ST_DP 0x00b9 /* Deep Power-down */
9471 +#define SFLASH_ST_RES 0x03ab /* Read Electronic Signature */
9473 +/* Status register bits for ST flashes */
9474 +#define SFLASH_ST_WIP 0x01 /* Write In Progress */
9475 +#define SFLASH_ST_WEL 0x02 /* Write Enable Latch */
9476 +#define SFLASH_ST_BP_MASK 0x1c /* Block Protect */
9477 +#define SFLASH_ST_BP_SHIFT 2
9478 +#define SFLASH_ST_SRWD 0x80 /* Status Register Write Disable */
9480 +/* flashcontrol opcodes for Atmel flashes */
9481 +#define SFLASH_AT_READ 0x07e8
9482 +#define SFLASH_AT_PAGE_READ 0x07d2
9483 +#define SFLASH_AT_BUF1_READ
9484 +#define SFLASH_AT_BUF2_READ
9485 +#define SFLASH_AT_STATUS 0x01d7
9486 +#define SFLASH_AT_BUF1_WRITE 0x0384
9487 +#define SFLASH_AT_BUF2_WRITE 0x0387
9488 +#define SFLASH_AT_BUF1_ERASE_PROGRAM 0x0283
9489 +#define SFLASH_AT_BUF2_ERASE_PROGRAM 0x0286
9490 +#define SFLASH_AT_BUF1_PROGRAM 0x0288
9491 +#define SFLASH_AT_BUF2_PROGRAM 0x0289
9492 +#define SFLASH_AT_PAGE_ERASE 0x0281
9493 +#define SFLASH_AT_BLOCK_ERASE 0x0250
9494 +#define SFLASH_AT_BUF1_WRITE_ERASE_PROGRAM 0x0382
9495 +#define SFLASH_AT_BUF2_WRITE_ERASE_PROGRAM 0x0385
9496 +#define SFLASH_AT_BUF1_LOAD 0x0253
9497 +#define SFLASH_AT_BUF2_LOAD 0x0255
9498 +#define SFLASH_AT_BUF1_COMPARE 0x0260
9499 +#define SFLASH_AT_BUF2_COMPARE 0x0261
9500 +#define SFLASH_AT_BUF1_REPROGRAM 0x0258
9501 +#define SFLASH_AT_BUF2_REPROGRAM 0x0259
9503 +/* Status register bits for Atmel flashes */
9504 +#define SFLASH_AT_READY 0x80
9505 +#define SFLASH_AT_MISMATCH 0x40
9506 +#define SFLASH_AT_ID_MASK 0x38
9507 +#define SFLASH_AT_ID_SHIFT 3
9510 +#define OTP_HW_REGION OTPS_HW_PROTECT
9511 +#define OTP_SW_REGION OTPS_SW_PROTECT
9512 +#define OTP_CID_REGION OTPS_CID_PROTECT
9514 +/* OTP regions (Byte offsets from otp size) */
9515 +#define OTP_SWLIM_OFF (-8)
9516 +#define OTP_CIDBASE_OFF 0
9517 +#define OTP_CIDLIM_OFF 8
9519 +/* Predefined OTP words (Word offset from otp size) */
9520 +#define OTP_BOUNDARY_OFF (-4)
9521 +#define OTP_HWSIGN_OFF (-3)
9522 +#define OTP_SWSIGN_OFF (-2)
9523 +#define OTP_CIDSIGN_OFF (-1)
9525 +#define OTP_CID_OFF 0
9526 +#define OTP_PKG_OFF 1
9527 +#define OTP_FID_OFF 2
9528 +#define OTP_RSV_OFF 3
9529 +#define OTP_LIM_OFF 4
9531 +#define OTP_SIGNATURE 0x578a
9532 +#define OTP_MAGIC 0x4e56
9534 +#endif /* _SBCHIPC_H */
9535 diff -urN linux.old/arch/mips/bcm947xx/include/sbconfig.h linux.dev/arch/mips/bcm947xx/include/sbconfig.h
9536 --- linux.old/arch/mips/bcm947xx/include/sbconfig.h 1970-01-01 01:00:00.000000000 +0100
9537 +++ linux.dev/arch/mips/bcm947xx/include/sbconfig.h 2005-12-15 15:35:24.538815250 +0100
9540 + * Broadcom SiliconBackplane hardware register definitions.
9542 + * Copyright 2005, Broadcom Corporation
9543 + * All Rights Reserved.
9545 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9546 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9547 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9548 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9552 +#ifndef _SBCONFIG_H
9553 +#define _SBCONFIG_H
9555 +/* cpp contortions to concatenate w/arg prescan */
9557 +#define _PADLINE(line) pad ## line
9558 +#define _XSTR(line) _PADLINE(line)
9559 +#define PAD _XSTR(__LINE__)
9563 + * SiliconBackplane Address Map.
9564 + * All regions may not exist on all chips.
9566 +#define SB_SDRAM_BASE 0x00000000 /* Physical SDRAM */
9567 +#define SB_PCI_MEM 0x08000000 /* Host Mode sb2pcitranslation0 (64 MB) */
9568 +#define SB_PCI_CFG 0x0c000000 /* Host Mode sb2pcitranslation1 (64 MB) */
9569 +#define SB_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
9570 +#define SB_ENUM_BASE 0x18000000 /* Enumeration space base */
9571 +#define SB_ENUM_LIM 0x18010000 /* Enumeration space limit */
9573 +#define SB_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
9574 +#define SB_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
9576 +#define SB_EXTIF_BASE 0x1f000000 /* External Interface region base address */
9577 +#define SB_FLASH1 0x1fc00000 /* Flash Region 1 */
9578 +#define SB_FLASH1_SZ 0x00400000 /* Size of Flash Region 1 */
9580 +#define SB_PCI_DMA 0x40000000 /* Client Mode sb2pcitranslation2 (1 GB) */
9581 +#define SB_PCI_DMA_SZ 0x40000000 /* Client Mode sb2pcitranslation2 size in bytes */
9582 +#define SB_PCIE_DMA_L32 0x00000000 /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), low 32 bits */
9583 +#define SB_PCIE_DMA_H32 0x80000000 /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */
9584 +#define SB_EUART (SB_EXTIF_BASE + 0x00800000)
9585 +#define SB_LED (SB_EXTIF_BASE + 0x00900000)
9588 +/* enumeration space related defs */
9589 +#define SB_CORE_SIZE 0x1000 /* each core gets 4Kbytes for registers */
9590 +#define SB_MAXCORES ((SB_ENUM_LIM - SB_ENUM_BASE)/SB_CORE_SIZE)
9591 +#define SBCONFIGOFF 0xf00 /* core sbconfig regs are top 256bytes of regs */
9592 +#define SBCONFIGSIZE 256 /* sizeof (sbconfig_t) */
9595 +#define SB_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
9598 + * Sonics Configuration Space Registers.
9600 +#define SBIPSFLAG 0x08
9601 +#define SBTPSFLAG 0x18
9602 +#define SBTMERRLOGA 0x48 /* sonics >= 2.3 */
9603 +#define SBTMERRLOG 0x50 /* sonics >= 2.3 */
9604 +#define SBADMATCH3 0x60
9605 +#define SBADMATCH2 0x68
9606 +#define SBADMATCH1 0x70
9607 +#define SBIMSTATE 0x90
9608 +#define SBINTVEC 0x94
9609 +#define SBTMSTATELOW 0x98
9610 +#define SBTMSTATEHIGH 0x9c
9611 +#define SBBWA0 0xa0
9612 +#define SBIMCONFIGLOW 0xa8
9613 +#define SBIMCONFIGHIGH 0xac
9614 +#define SBADMATCH0 0xb0
9615 +#define SBTMCONFIGLOW 0xb8
9616 +#define SBTMCONFIGHIGH 0xbc
9617 +#define SBBCONFIG 0xc0
9618 +#define SBBSTATE 0xc8
9619 +#define SBACTCNFG 0xd8
9620 +#define SBFLAGST 0xe8
9621 +#define SBIDLOW 0xf8
9622 +#define SBIDHIGH 0xfc
9624 +#ifndef _LANGUAGE_ASSEMBLY
9626 +typedef volatile struct _sbconfig {
9628 + uint32 sbipsflag; /* initiator port ocp slave flag */
9630 + uint32 sbtpsflag; /* target port ocp slave flag */
9632 + uint32 sbtmerrloga; /* (sonics >= 2.3) */
9634 + uint32 sbtmerrlog; /* (sonics >= 2.3) */
9636 + uint32 sbadmatch3; /* address match3 */
9638 + uint32 sbadmatch2; /* address match2 */
9640 + uint32 sbadmatch1; /* address match1 */
9642 + uint32 sbimstate; /* initiator agent state */
9643 + uint32 sbintvec; /* interrupt mask */
9644 + uint32 sbtmstatelow; /* target state */
9645 + uint32 sbtmstatehigh; /* target state */
9646 + uint32 sbbwa0; /* bandwidth allocation table0 */
9648 + uint32 sbimconfiglow; /* initiator configuration */
9649 + uint32 sbimconfighigh; /* initiator configuration */
9650 + uint32 sbadmatch0; /* address match0 */
9652 + uint32 sbtmconfiglow; /* target configuration */
9653 + uint32 sbtmconfighigh; /* target configuration */
9654 + uint32 sbbconfig; /* broadcast configuration */
9656 + uint32 sbbstate; /* broadcast state */
9658 + uint32 sbactcnfg; /* activate configuration */
9660 + uint32 sbflagst; /* current sbflags */
9662 + uint32 sbidlow; /* identification */
9663 + uint32 sbidhigh; /* identification */
9666 +#endif /* _LANGUAGE_ASSEMBLY */
9669 +#define SBIPS_INT1_MASK 0x3f /* which sbflags get routed to mips interrupt 1 */
9670 +#define SBIPS_INT1_SHIFT 0
9671 +#define SBIPS_INT2_MASK 0x3f00 /* which sbflags get routed to mips interrupt 2 */
9672 +#define SBIPS_INT2_SHIFT 8
9673 +#define SBIPS_INT3_MASK 0x3f0000 /* which sbflags get routed to mips interrupt 3 */
9674 +#define SBIPS_INT3_SHIFT 16
9675 +#define SBIPS_INT4_MASK 0x3f000000 /* which sbflags get routed to mips interrupt 4 */
9676 +#define SBIPS_INT4_SHIFT 24
9679 +#define SBTPS_NUM0_MASK 0x3f /* interrupt sbFlag # generated by this core */
9680 +#define SBTPS_F0EN0 0x40 /* interrupt is always sent on the backplane */
9683 +#define SBTMEL_CM 0x00000007 /* command */
9684 +#define SBTMEL_CI 0x0000ff00 /* connection id */
9685 +#define SBTMEL_EC 0x0f000000 /* error code */
9686 +#define SBTMEL_ME 0x80000000 /* multiple error */
9689 +#define SBIM_PC 0xf /* pipecount */
9690 +#define SBIM_AP_MASK 0x30 /* arbitration policy */
9691 +#define SBIM_AP_BOTH 0x00 /* use both timeslaces and token */
9692 +#define SBIM_AP_TS 0x10 /* use timesliaces only */
9693 +#define SBIM_AP_TK 0x20 /* use token only */
9694 +#define SBIM_AP_RSV 0x30 /* reserved */
9695 +#define SBIM_IBE 0x20000 /* inbanderror */
9696 +#define SBIM_TO 0x40000 /* timeout */
9697 +#define SBIM_BY 0x01800000 /* busy (sonics >= 2.3) */
9698 +#define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */
9701 +#define SBTML_RESET 0x1 /* reset */
9702 +#define SBTML_REJ_MASK 0x6 /* reject */
9703 +#define SBTML_REJ_SHIFT 1
9704 +#define SBTML_CLK 0x10000 /* clock enable */
9705 +#define SBTML_FGC 0x20000 /* force gated clocks on */
9706 +#define SBTML_FL_MASK 0x3ffc0000 /* core-specific flags */
9707 +#define SBTML_PE 0x40000000 /* pme enable */
9708 +#define SBTML_BE 0x80000000 /* bist enable */
9710 +/* sbtmstatehigh */
9711 +#define SBTMH_SERR 0x1 /* serror */
9712 +#define SBTMH_INT 0x2 /* interrupt */
9713 +#define SBTMH_BUSY 0x4 /* busy */
9714 +#define SBTMH_TO 0x00000020 /* timeout (sonics >= 2.3) */
9715 +#define SBTMH_FL_MASK 0x1fff0000 /* core-specific flags */
9716 +#define SBTMH_DMA64 0x10000000 /* supports DMA with 64-bit addresses */
9717 +#define SBTMH_GCR 0x20000000 /* gated clock request */
9718 +#define SBTMH_BISTF 0x40000000 /* bist failed */
9719 +#define SBTMH_BISTD 0x80000000 /* bist done */
9723 +#define SBBWA_TAB0_MASK 0xffff /* lookup table 0 */
9724 +#define SBBWA_TAB1_MASK 0xffff /* lookup table 1 */
9725 +#define SBBWA_TAB1_SHIFT 16
9727 +/* sbimconfiglow */
9728 +#define SBIMCL_STO_MASK 0x7 /* service timeout */
9729 +#define SBIMCL_RTO_MASK 0x70 /* request timeout */
9730 +#define SBIMCL_RTO_SHIFT 4
9731 +#define SBIMCL_CID_MASK 0xff0000 /* connection id */
9732 +#define SBIMCL_CID_SHIFT 16
9734 +/* sbimconfighigh */
9735 +#define SBIMCH_IEM_MASK 0xc /* inband error mode */
9736 +#define SBIMCH_TEM_MASK 0x30 /* timeout error mode */
9737 +#define SBIMCH_TEM_SHIFT 4
9738 +#define SBIMCH_BEM_MASK 0xc0 /* bus error mode */
9739 +#define SBIMCH_BEM_SHIFT 6
9742 +#define SBAM_TYPE_MASK 0x3 /* address type */
9743 +#define SBAM_AD64 0x4 /* reserved */
9744 +#define SBAM_ADINT0_MASK 0xf8 /* type0 size */
9745 +#define SBAM_ADINT0_SHIFT 3
9746 +#define SBAM_ADINT1_MASK 0x1f8 /* type1 size */
9747 +#define SBAM_ADINT1_SHIFT 3
9748 +#define SBAM_ADINT2_MASK 0x1f8 /* type2 size */
9749 +#define SBAM_ADINT2_SHIFT 3
9750 +#define SBAM_ADEN 0x400 /* enable */
9751 +#define SBAM_ADNEG 0x800 /* negative decode */
9752 +#define SBAM_BASE0_MASK 0xffffff00 /* type0 base address */
9753 +#define SBAM_BASE0_SHIFT 8
9754 +#define SBAM_BASE1_MASK 0xfffff000 /* type1 base address for the core */
9755 +#define SBAM_BASE1_SHIFT 12
9756 +#define SBAM_BASE2_MASK 0xffff0000 /* type2 base address for the core */
9757 +#define SBAM_BASE2_SHIFT 16
9759 +/* sbtmconfiglow */
9760 +#define SBTMCL_CD_MASK 0xff /* clock divide */
9761 +#define SBTMCL_CO_MASK 0xf800 /* clock offset */
9762 +#define SBTMCL_CO_SHIFT 11
9763 +#define SBTMCL_IF_MASK 0xfc0000 /* interrupt flags */
9764 +#define SBTMCL_IF_SHIFT 18
9765 +#define SBTMCL_IM_MASK 0x3000000 /* interrupt mode */
9766 +#define SBTMCL_IM_SHIFT 24
9768 +/* sbtmconfighigh */
9769 +#define SBTMCH_BM_MASK 0x3 /* busy mode */
9770 +#define SBTMCH_RM_MASK 0x3 /* retry mode */
9771 +#define SBTMCH_RM_SHIFT 2
9772 +#define SBTMCH_SM_MASK 0x30 /* stop mode */
9773 +#define SBTMCH_SM_SHIFT 4
9774 +#define SBTMCH_EM_MASK 0x300 /* sb error mode */
9775 +#define SBTMCH_EM_SHIFT 8
9776 +#define SBTMCH_IM_MASK 0xc00 /* int mode */
9777 +#define SBTMCH_IM_SHIFT 10
9780 +#define SBBC_LAT_MASK 0x3 /* sb latency */
9781 +#define SBBC_MAX0_MASK 0xf0000 /* maxccntr0 */
9782 +#define SBBC_MAX0_SHIFT 16
9783 +#define SBBC_MAX1_MASK 0xf00000 /* maxccntr1 */
9784 +#define SBBC_MAX1_SHIFT 20
9787 +#define SBBS_SRD 0x1 /* st reg disable */
9788 +#define SBBS_HRD 0x2 /* hold reg disable */
9791 +#define SBIDL_CS_MASK 0x3 /* config space */
9792 +#define SBIDL_AR_MASK 0x38 /* # address ranges supported */
9793 +#define SBIDL_AR_SHIFT 3
9794 +#define SBIDL_SYNCH 0x40 /* sync */
9795 +#define SBIDL_INIT 0x80 /* initiator */
9796 +#define SBIDL_MINLAT_MASK 0xf00 /* minimum backplane latency */
9797 +#define SBIDL_MINLAT_SHIFT 8
9798 +#define SBIDL_MAXLAT 0xf000 /* maximum backplane latency */
9799 +#define SBIDL_MAXLAT_SHIFT 12
9800 +#define SBIDL_FIRST 0x10000 /* this initiator is first */
9801 +#define SBIDL_CW_MASK 0xc0000 /* cycle counter width */
9802 +#define SBIDL_CW_SHIFT 18
9803 +#define SBIDL_TP_MASK 0xf00000 /* target ports */
9804 +#define SBIDL_TP_SHIFT 20
9805 +#define SBIDL_IP_MASK 0xf000000 /* initiator ports */
9806 +#define SBIDL_IP_SHIFT 24
9807 +#define SBIDL_RV_MASK 0xf0000000 /* sonics backplane revision code */
9808 +#define SBIDL_RV_SHIFT 28
9809 +#define SBIDL_RV_2_2 0x00000000 /* version 2.2 or earlier */
9810 +#define SBIDL_RV_2_3 0x10000000 /* version 2.3 */
9813 +#define SBIDH_RC_MASK 0x000f /* revision code */
9814 +#define SBIDH_RCE_MASK 0x7000 /* revision code extension field */
9815 +#define SBIDH_RCE_SHIFT 8
9816 +#define SBCOREREV(sbidh) \
9817 + ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | ((sbidh) & SBIDH_RC_MASK))
9818 +#define SBIDH_CC_MASK 0x8ff0 /* core code */
9819 +#define SBIDH_CC_SHIFT 4
9820 +#define SBIDH_VC_MASK 0xffff0000 /* vendor code */
9821 +#define SBIDH_VC_SHIFT 16
9823 +#define SB_COMMIT 0xfd8 /* update buffered registers value */
9826 +#define SB_VEND_BCM 0x4243 /* Broadcom's SB vendor code */
9829 +#define SB_CC 0x800 /* chipcommon core */
9830 +#define SB_ILINE20 0x801 /* iline20 core */
9831 +#define SB_SDRAM 0x803 /* sdram core */
9832 +#define SB_PCI 0x804 /* pci core */
9833 +#define SB_MIPS 0x805 /* mips core */
9834 +#define SB_ENET 0x806 /* enet mac core */
9835 +#define SB_CODEC 0x807 /* v90 codec core */
9836 +#define SB_USB 0x808 /* usb 1.1 host/device core */
9837 +#define SB_ADSL 0x809 /* ADSL core */
9838 +#define SB_ILINE100 0x80a /* iline100 core */
9839 +#define SB_IPSEC 0x80b /* ipsec core */
9840 +#define SB_PCMCIA 0x80d /* pcmcia core */
9841 +#define SB_SOCRAM 0x80e /* internal memory core */
9842 +#define SB_MEMC 0x80f /* memc sdram core */
9843 +#define SB_EXTIF 0x811 /* external interface core */
9844 +#define SB_D11 0x812 /* 802.11 MAC core */
9845 +#define SB_MIPS33 0x816 /* mips3302 core */
9846 +#define SB_USB11H 0x817 /* usb 1.1 host core */
9847 +#define SB_USB11D 0x818 /* usb 1.1 device core */
9848 +#define SB_USB20H 0x819 /* usb 2.0 host core */
9849 +#define SB_USB20D 0x81a /* usb 2.0 device core */
9850 +#define SB_SDIOH 0x81b /* sdio host core */
9851 +#define SB_ROBO 0x81c /* roboswitch core */
9852 +#define SB_ATA100 0x81d /* parallel ATA core */
9853 +#define SB_SATAXOR 0x81e /* serial ATA & XOR DMA core */
9854 +#define SB_GIGETH 0x81f /* gigabit ethernet core */
9855 +#define SB_PCIE 0x820 /* pci express core */
9856 +#define SB_SRAMC 0x822 /* SRAM controller core */
9857 +#define SB_MINIMAC 0x823 /* MINI MAC/phy core */
9859 +#define SB_CC_IDX 0 /* chipc, when present, is always core 0 */
9861 +/* Not really related to Silicon Backplane, but a couple of software
9862 + * conventions for the use the flash space:
9865 +/* Minumum amount of flash we support */
9866 +#define FLASH_MIN 0x00020000 /* Minimum flash size */
9868 +/* A boot/binary may have an embedded block that describes its size */
9869 +#define BISZ_OFFSET 0x3e0 /* At this offset into the binary */
9870 +#define BISZ_MAGIC 0x4249535a /* Marked with this value: 'BISZ' */
9871 +#define BISZ_MAGIC_IDX 0 /* Word 0: magic */
9872 +#define BISZ_TXTST_IDX 1 /* 1: text start */
9873 +#define BISZ_TXTEND_IDX 2 /* 2: text start */
9874 +#define BISZ_DATAST_IDX 3 /* 3: text start */
9875 +#define BISZ_DATAEND_IDX 4 /* 4: text start */
9876 +#define BISZ_BSSST_IDX 5 /* 5: text start */
9877 +#define BISZ_BSSEND_IDX 6 /* 6: text start */
9878 +#define BISZ_SIZE 7 /* descriptor size in 32-bit intergers */
9880 +#endif /* _SBCONFIG_H */
9881 diff -urN linux.old/arch/mips/bcm947xx/include/sbextif.h linux.dev/arch/mips/bcm947xx/include/sbextif.h
9882 --- linux.old/arch/mips/bcm947xx/include/sbextif.h 1970-01-01 01:00:00.000000000 +0100
9883 +++ linux.dev/arch/mips/bcm947xx/include/sbextif.h 2005-12-15 16:48:55.651993750 +0100
9886 + * Hardware-specific External Interface I/O core definitions
9887 + * for the BCM47xx family of SiliconBackplane-based chips.
9889 + * The External Interface core supports a total of three external chip selects
9890 + * supporting external interfaces. One of the external chip selects is
9891 + * used for Flash, one is used for PCMCIA, and the other may be
9892 + * programmed to support either a synchronous interface or an
9893 + * asynchronous interface. The asynchronous interface can be used to
9894 + * support external devices such as UARTs and the BCM2019 Bluetooth
9895 + * baseband processor.
9896 + * The external interface core also contains 2 on-chip 16550 UARTs, clock
9897 + * frequency control, a watchdog interrupt timer, and a GPIO interface.
9899 + * Copyright 2005, Broadcom Corporation
9900 + * All Rights Reserved.
9902 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9903 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9904 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9905 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9912 +/* external interface address space */
9913 +#define EXTIF_PCMCIA_MEMBASE(x) (x)
9914 +#define EXTIF_PCMCIA_IOBASE(x) ((x) + 0x100000)
9915 +#define EXTIF_PCMCIA_CFGBASE(x) ((x) + 0x200000)
9916 +#define EXTIF_CFGIF_BASE(x) ((x) + 0x800000)
9917 +#define EXTIF_FLASH_BASE(x) ((x) + 0xc00000)
9919 +/* cpp contortions to concatenate w/arg prescan */
9921 +#define _PADLINE(line) pad ## line
9922 +#define _XSTR(line) _PADLINE(line)
9923 +#define PAD _XSTR(__LINE__)
9927 + * The multiple instances of output and output enable registers
9928 + * are present to allow driver software for multiple cores to control
9929 + * gpio outputs without needing to share a single register pair.
9935 +#define NGPIOUSER 5
9937 +typedef volatile struct {
9938 + uint32 corecontrol;
9942 + /* pcmcia control registers */
9943 + uint32 pcmcia_config;
9944 + uint32 pcmcia_memwait;
9945 + uint32 pcmcia_attrwait;
9946 + uint32 pcmcia_iowait;
9948 + /* programmable interface control registers */
9949 + uint32 prog_config;
9950 + uint32 prog_waitcount;
9952 + /* flash control registers */
9953 + uint32 flash_config;
9954 + uint32 flash_waitcount;
9959 + /* clock control */
9960 + uint32 clockcontrol_n;
9961 + uint32 clockcontrol_sb;
9962 + uint32 clockcontrol_pci;
9963 + uint32 clockcontrol_mii;
9968 + struct gpiouser gpio[NGPIOUSER];
9970 + uint32 ejtagouten;
9971 + uint32 gpiointpolarity;
9972 + uint32 gpiointmask;
9989 + uint8 uartscratch;
9994 +#define CC_UE (1 << 0) /* uart enable */
9997 +#define ES_EM (1 << 0) /* endian mode (ro) */
9998 +#define ES_EI (1 << 1) /* external interrupt pin (ro) */
9999 +#define ES_GI (1 << 2) /* gpio interrupt pin (ro) */
10001 +/* gpio bit mask */
10002 +#define GPIO_BIT0 (1 << 0)
10003 +#define GPIO_BIT1 (1 << 1)
10004 +#define GPIO_BIT2 (1 << 2)
10005 +#define GPIO_BIT3 (1 << 3)
10006 +#define GPIO_BIT4 (1 << 4)
10007 +#define GPIO_BIT5 (1 << 5)
10008 +#define GPIO_BIT6 (1 << 6)
10009 +#define GPIO_BIT7 (1 << 7)
10012 +/* pcmcia/prog/flash_config */
10013 +#define CF_EN (1 << 0) /* enable */
10014 +#define CF_EM_MASK 0xe /* mode */
10015 +#define CF_EM_SHIFT 1
10016 +#define CF_EM_FLASH 0x0 /* flash/asynchronous mode */
10017 +#define CF_EM_SYNC 0x2 /* synchronous mode */
10018 +#define CF_EM_PCMCIA 0x4 /* pcmcia mode */
10019 +#define CF_DS (1 << 4) /* destsize: 0=8bit, 1=16bit */
10020 +#define CF_BS (1 << 5) /* byteswap */
10021 +#define CF_CD_MASK 0xc0 /* clock divider */
10022 +#define CF_CD_SHIFT 6
10023 +#define CF_CD_DIV2 0x0 /* backplane/2 */
10024 +#define CF_CD_DIV3 0x40 /* backplane/3 */
10025 +#define CF_CD_DIV4 0x80 /* backplane/4 */
10026 +#define CF_CE (1 << 8) /* clock enable */
10027 +#define CF_SB (1 << 9) /* size/bytestrobe (synch only) */
10029 +/* pcmcia_memwait */
10030 +#define PM_W0_MASK 0x3f /* waitcount0 */
10031 +#define PM_W1_MASK 0x1f00 /* waitcount1 */
10032 +#define PM_W1_SHIFT 8
10033 +#define PM_W2_MASK 0x1f0000 /* waitcount2 */
10034 +#define PM_W2_SHIFT 16
10035 +#define PM_W3_MASK 0x1f000000 /* waitcount3 */
10036 +#define PM_W3_SHIFT 24
10038 +/* pcmcia_attrwait */
10039 +#define PA_W0_MASK 0x3f /* waitcount0 */
10040 +#define PA_W1_MASK 0x1f00 /* waitcount1 */
10041 +#define PA_W1_SHIFT 8
10042 +#define PA_W2_MASK 0x1f0000 /* waitcount2 */
10043 +#define PA_W2_SHIFT 16
10044 +#define PA_W3_MASK 0x1f000000 /* waitcount3 */
10045 +#define PA_W3_SHIFT 24
10047 +/* pcmcia_iowait */
10048 +#define PI_W0_MASK 0x3f /* waitcount0 */
10049 +#define PI_W1_MASK 0x1f00 /* waitcount1 */
10050 +#define PI_W1_SHIFT 8
10051 +#define PI_W2_MASK 0x1f0000 /* waitcount2 */
10052 +#define PI_W2_SHIFT 16
10053 +#define PI_W3_MASK 0x1f000000 /* waitcount3 */
10054 +#define PI_W3_SHIFT 24
10056 +/* prog_waitcount */
10057 +#define PW_W0_MASK 0x0000001f /* waitcount0 */
10058 +#define PW_W1_MASK 0x00001f00 /* waitcount1 */
10059 +#define PW_W1_SHIFT 8
10060 +#define PW_W2_MASK 0x001f0000 /* waitcount2 */
10061 +#define PW_W2_SHIFT 16
10062 +#define PW_W3_MASK 0x1f000000 /* waitcount3 */
10063 +#define PW_W3_SHIFT 24
10065 +#define PW_W0 0x0000000c
10066 +#define PW_W1 0x00000a00
10067 +#define PW_W2 0x00020000
10068 +#define PW_W3 0x01000000
10070 +/* flash_waitcount */
10071 +#define FW_W0_MASK 0x1f /* waitcount0 */
10072 +#define FW_W1_MASK 0x1f00 /* waitcount1 */
10073 +#define FW_W1_SHIFT 8
10074 +#define FW_W2_MASK 0x1f0000 /* waitcount2 */
10075 +#define FW_W2_SHIFT 16
10076 +#define FW_W3_MASK 0x1f000000 /* waitcount3 */
10077 +#define FW_W3_SHIFT 24
10080 +#define WATCHDOG_CLOCK 48000000 /* Hz */
10082 +/* clockcontrol_n */
10083 +#define CN_N1_MASK 0x3f /* n1 control */
10084 +#define CN_N2_MASK 0x3f00 /* n2 control */
10085 +#define CN_N2_SHIFT 8
10087 +/* clockcontrol_sb/pci/mii */
10088 +#define CC_M1_MASK 0x3f /* m1 control */
10089 +#define CC_M2_MASK 0x3f00 /* m2 control */
10090 +#define CC_M2_SHIFT 8
10091 +#define CC_M3_MASK 0x3f0000 /* m3 control */
10092 +#define CC_M3_SHIFT 16
10093 +#define CC_MC_MASK 0x1f000000 /* mux control */
10094 +#define CC_MC_SHIFT 24
10096 +/* Clock control default values */
10097 +#define CC_DEF_N 0x0009 /* Default values for bcm4710 */
10098 +#define CC_DEF_100 0x04020011
10099 +#define CC_DEF_33 0x11030011
10100 +#define CC_DEF_25 0x11050011
10102 +/* Clock control values for 125Mhz */
10103 +#define CC_125_N 0x0802
10104 +#define CC_125_M 0x04020009
10105 +#define CC_125_M25 0x11090009
10106 +#define CC_125_M33 0x11090005
10108 +/* Clock control magic field values */
10109 +#define CC_F6_2 0x02 /* A factor of 2 in */
10110 +#define CC_F6_3 0x03 /* 6-bit fields like */
10111 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
10112 +#define CC_F6_5 0x09
10113 +#define CC_F6_6 0x11
10114 +#define CC_F6_7 0x21
10116 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
10118 +#define CC_MC_BYPASS 0x08
10119 +#define CC_MC_M1 0x04
10120 +#define CC_MC_M1M2 0x02
10121 +#define CC_MC_M1M2M3 0x01
10122 +#define CC_MC_M1M3 0x11
10124 +#define CC_CLOCK_BASE 24000000 /* Half the clock freq. in the 4710 */
10126 +#endif /* _SBEXTIF_H */
10127 diff -urN linux.old/arch/mips/bcm947xx/include/sbmemc.h linux.dev/arch/mips/bcm947xx/include/sbmemc.h
10128 --- linux.old/arch/mips/bcm947xx/include/sbmemc.h 1970-01-01 01:00:00.000000000 +0100
10129 +++ linux.dev/arch/mips/bcm947xx/include/sbmemc.h 2005-12-15 15:35:31.567254500 +0100
10132 + * BCM47XX Sonics SiliconBackplane DDR/SDRAM controller 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.
10148 +#ifdef _LANGUAGE_ASSEMBLY
10150 +#define MEMC_CONTROL 0x00
10151 +#define MEMC_CONFIG 0x04
10152 +#define MEMC_REFRESH 0x08
10153 +#define MEMC_BISTSTAT 0x0c
10154 +#define MEMC_MODEBUF 0x10
10155 +#define MEMC_BKCLS 0x14
10156 +#define MEMC_PRIORINV 0x18
10157 +#define MEMC_DRAMTIM 0x1c
10158 +#define MEMC_INTSTAT 0x20
10159 +#define MEMC_INTMASK 0x24
10160 +#define MEMC_INTINFO 0x28
10161 +#define MEMC_NCDLCTL 0x30
10162 +#define MEMC_RDNCDLCOR 0x34
10163 +#define MEMC_WRNCDLCOR 0x38
10164 +#define MEMC_MISCDLYCTL 0x3c
10165 +#define MEMC_DQSGATENCDL 0x40
10166 +#define MEMC_SPARE 0x44
10167 +#define MEMC_TPADDR 0x48
10168 +#define MEMC_TPDATA 0x4c
10169 +#define MEMC_BARRIER 0x50
10170 +#define MEMC_CORE 0x54
10175 +/* Sonics side: MEMC core registers */
10176 +typedef volatile struct sbmemcregs {
10188 + uint32 reserved1;
10190 + uint32 rdncdlcor;
10191 + uint32 wrncdlcor;
10192 + uint32 miscdlyctl;
10193 + uint32 dqsgatencdl;
10203 +/* MEMC Core Init values (OCP ID 0x80f) */
10206 +#define MEMC_SD_CONFIG_INIT 0x00048000
10207 +#define MEMC_SD_DRAMTIM2_INIT 0x000754d8
10208 +#define MEMC_SD_DRAMTIM3_INIT 0x000754da
10209 +#define MEMC_SD_RDNCDLCOR_INIT 0x00000000
10210 +#define MEMC_SD_WRNCDLCOR_INIT 0x49351200
10211 +#define MEMC_SD1_WRNCDLCOR_INIT 0x14500200 /* For corerev 1 (4712) */
10212 +#define MEMC_SD_MISCDLYCTL_INIT 0x00061c1b
10213 +#define MEMC_SD1_MISCDLYCTL_INIT 0x00021416 /* For corerev 1 (4712) */
10214 +#define MEMC_SD_CONTROL_INIT0 0x00000002
10215 +#define MEMC_SD_CONTROL_INIT1 0x00000008
10216 +#define MEMC_SD_CONTROL_INIT2 0x00000004
10217 +#define MEMC_SD_CONTROL_INIT3 0x00000010
10218 +#define MEMC_SD_CONTROL_INIT4 0x00000001
10219 +#define MEMC_SD_MODEBUF_INIT 0x00000000
10220 +#define MEMC_SD_REFRESH_INIT 0x0000840f
10223 +/* This is for SDRM8X8X4 */
10224 +#define MEMC_SDR_INIT 0x0008
10225 +#define MEMC_SDR_MODE 0x32
10226 +#define MEMC_SDR_NCDL 0x00020032
10227 +#define MEMC_SDR1_NCDL 0x0002020f /* For corerev 1 (4712) */
10230 +#define MEMC_CONFIG_INIT 0x00048000
10231 +#define MEMC_DRAMTIM2_INIT 0x000754d8
10232 +#define MEMC_DRAMTIM25_INIT 0x000754d9
10233 +#define MEMC_RDNCDLCOR_INIT 0x00000000
10234 +#define MEMC_RDNCDLCOR_SIMINIT 0xf6f6f6f6 /* For hdl sim */
10235 +#define MEMC_WRNCDLCOR_INIT 0x49351200
10236 +#define MEMC_1_WRNCDLCOR_INIT 0x14500200
10237 +#define MEMC_DQSGATENCDL_INIT 0x00030000
10238 +#define MEMC_MISCDLYCTL_INIT 0x21061c1b
10239 +#define MEMC_1_MISCDLYCTL_INIT 0x21021400
10240 +#define MEMC_NCDLCTL_INIT 0x00002001
10241 +#define MEMC_CONTROL_INIT0 0x00000002
10242 +#define MEMC_CONTROL_INIT1 0x00000008
10243 +#define MEMC_MODEBUF_INIT0 0x00004000
10244 +#define MEMC_CONTROL_INIT2 0x00000010
10245 +#define MEMC_MODEBUF_INIT1 0x00000100
10246 +#define MEMC_CONTROL_INIT3 0x00000010
10247 +#define MEMC_CONTROL_INIT4 0x00000008
10248 +#define MEMC_REFRESH_INIT 0x0000840f
10249 +#define MEMC_CONTROL_INIT5 0x00000004
10250 +#define MEMC_MODEBUF_INIT2 0x00000000
10251 +#define MEMC_CONTROL_INIT6 0x00000010
10252 +#define MEMC_CONTROL_INIT7 0x00000001
10255 +/* This is for DDRM16X16X2 */
10256 +#define MEMC_DDR_INIT 0x0009
10257 +#define MEMC_DDR_MODE 0x62
10258 +#define MEMC_DDR_NCDL 0x0005050a
10259 +#define MEMC_DDR1_NCDL 0x00000a0a /* For corerev 1 (4712) */
10261 +/* mask for sdr/ddr calibration registers */
10262 +#define MEMC_RDNCDLCOR_RD_MASK 0x000000ff
10263 +#define MEMC_WRNCDLCOR_WR_MASK 0x000000ff
10264 +#define MEMC_DQSGATENCDL_G_MASK 0x000000ff
10266 +/* masks for miscdlyctl registers */
10267 +#define MEMC_MISC_SM_MASK 0x30000000
10268 +#define MEMC_MISC_SM_SHIFT 28
10269 +#define MEMC_MISC_SD_MASK 0x0f000000
10270 +#define MEMC_MISC_SD_SHIFT 24
10272 +/* hw threshhold for calculating wr/rd for sdr memc */
10273 +#define MEMC_CD_THRESHOLD 128
10275 +/* Low bit of init register says if memc is ddr or sdr */
10276 +#define MEMC_CONFIG_DDR 0x00000001
10278 +#endif /* _SBMEMC_H */
10279 diff -urN linux.old/arch/mips/bcm947xx/include/sbmips.h linux.dev/arch/mips/bcm947xx/include/sbmips.h
10280 --- linux.old/arch/mips/bcm947xx/include/sbmips.h 1970-01-01 01:00:00.000000000 +0100
10281 +++ linux.dev/arch/mips/bcm947xx/include/sbmips.h 2005-12-15 16:46:57.616617000 +0100
10284 + * Broadcom SiliconBackplane MIPS definitions
10286 + * SB MIPS cores are custom MIPS32 processors with SiliconBackplane
10287 + * OCP interfaces. The CP0 processor ID is 0x00024000, where bits
10288 + * 23:16 mean Broadcom and bits 15:8 mean a MIPS core with an OCP
10289 + * interface. The core revision is stored in the SB ID register in SB
10290 + * configuration space.
10292 + * Copyright 2005, Broadcom Corporation
10293 + * All Rights Reserved.
10295 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10296 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10297 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10298 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10306 +#include <mipsinc.h>
10308 +#ifndef _LANGUAGE_ASSEMBLY
10310 +/* cpp contortions to concatenate w/arg prescan */
10312 +#define _PADLINE(line) pad ## line
10313 +#define _XSTR(line) _PADLINE(line)
10314 +#define PAD _XSTR(__LINE__)
10317 +typedef volatile struct {
10318 + uint32 corecontrol;
10320 + uint32 biststatus;
10322 + uint32 intstatus;
10327 +extern uint32 sb_flag(sb_t *sbh);
10328 +extern uint sb_irq(sb_t *sbh);
10330 +extern void BCMINIT(sb_serial_init)(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift));
10332 +extern void *sb_jtagm_init(sb_t *sbh, uint clkd, bool exttap);
10333 +extern void sb_jtagm_disable(void *h);
10334 +extern uint32 jtag_rwreg(void *h, uint32 ir, uint32 dr);
10335 +extern void BCMINIT(sb_mips_init)(sb_t *sbh);
10336 +extern uint32 BCMINIT(sb_mips_clock)(sb_t *sbh);
10337 +extern bool BCMINIT(sb_mips_setclock)(sb_t *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock);
10338 +extern void BCMINIT(enable_pfc)(uint32 mode);
10339 +extern uint32 BCMINIT(sb_memc_get_ncdl)(sb_t *sbh);
10342 +#endif /* _LANGUAGE_ASSEMBLY */
10344 +#endif /* _SBMIPS_H */
10345 diff -urN linux.old/arch/mips/bcm947xx/include/sbpci.h linux.dev/arch/mips/bcm947xx/include/sbpci.h
10346 --- linux.old/arch/mips/bcm947xx/include/sbpci.h 1970-01-01 01:00:00.000000000 +0100
10347 +++ linux.dev/arch/mips/bcm947xx/include/sbpci.h 2005-12-15 15:35:36.795581250 +0100
10350 + * BCM47XX Sonics SiliconBackplane PCI core hardware definitions.
10353 + * Copyright 2005, Broadcom Corporation
10354 + * All Rights Reserved.
10356 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10357 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10358 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10359 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10365 +/* cpp contortions to concatenate w/arg prescan */
10367 +#define _PADLINE(line) pad ## line
10368 +#define _XSTR(line) _PADLINE(line)
10369 +#define PAD _XSTR(__LINE__)
10372 +/* Sonics side: PCI core and host control registers */
10373 +typedef struct sbpciregs {
10374 + uint32 control; /* PCI control */
10376 + uint32 arbcontrol; /* PCI arbiter control */
10378 + uint32 intstatus; /* Interrupt status */
10379 + uint32 intmask; /* Interrupt mask */
10380 + uint32 sbtopcimailbox; /* Sonics to PCI mailbox */
10382 + uint32 bcastaddr; /* Sonics broadcast address */
10383 + uint32 bcastdata; /* Sonics broadcast data */
10385 + uint32 gpioin; /* ro: gpio input (>=rev2) */
10386 + uint32 gpioout; /* rw: gpio output (>=rev2) */
10387 + uint32 gpioouten; /* rw: gpio output enable (>= rev2) */
10388 + uint32 gpiocontrol; /* rw: gpio control (>= rev2) */
10390 + uint32 sbtopci0; /* Sonics to PCI translation 0 */
10391 + uint32 sbtopci1; /* Sonics to PCI translation 1 */
10392 + uint32 sbtopci2; /* Sonics to PCI translation 2 */
10394 + uint16 sprom[36]; /* SPROM shadow Area */
10399 +#define PCI_RST_OE 0x01 /* When set, drives PCI_RESET out to pin */
10400 +#define PCI_RST 0x02 /* Value driven out to pin */
10401 +#define PCI_CLK_OE 0x04 /* When set, drives clock as gated by PCI_CLK out to pin */
10402 +#define PCI_CLK 0x08 /* Gate for clock driven out to pin */
10404 +/* PCI arbiter control */
10405 +#define PCI_INT_ARB 0x01 /* When set, use an internal arbiter */
10406 +#define PCI_EXT_ARB 0x02 /* When set, use an external arbiter */
10407 +#define PCI_PARKID_MASK 0x06 /* Selects which agent is parked on an idle bus */
10408 +#define PCI_PARKID_SHIFT 1
10409 +#define PCI_PARKID_LAST 0 /* Last requestor */
10410 +#define PCI_PARKID_4710 1 /* 4710 */
10411 +#define PCI_PARKID_EXTREQ0 2 /* External requestor 0 */
10412 +#define PCI_PARKID_EXTREQ1 3 /* External requestor 1 */
10414 +/* Interrupt status/mask */
10415 +#define PCI_INTA 0x01 /* PCI INTA# is asserted */
10416 +#define PCI_INTB 0x02 /* PCI INTB# is asserted */
10417 +#define PCI_SERR 0x04 /* PCI SERR# has been asserted (write one to clear) */
10418 +#define PCI_PERR 0x08 /* PCI PERR# has been asserted (write one to clear) */
10419 +#define PCI_PME 0x10 /* PCI PME# is asserted */
10421 +/* (General) PCI/SB mailbox interrupts, two bits per pci function */
10422 +#define MAILBOX_F0_0 0x100 /* function 0, int 0 */
10423 +#define MAILBOX_F0_1 0x200 /* function 0, int 1 */
10424 +#define MAILBOX_F1_0 0x400 /* function 1, int 0 */
10425 +#define MAILBOX_F1_1 0x800 /* function 1, int 1 */
10426 +#define MAILBOX_F2_0 0x1000 /* function 2, int 0 */
10427 +#define MAILBOX_F2_1 0x2000 /* function 2, int 1 */
10428 +#define MAILBOX_F3_0 0x4000 /* function 3, int 0 */
10429 +#define MAILBOX_F3_1 0x8000 /* function 3, int 1 */
10431 +/* Sonics broadcast address */
10432 +#define BCAST_ADDR_MASK 0xff /* Broadcast register address */
10434 +/* Sonics to PCI translation types */
10435 +#define SBTOPCI0_MASK 0xfc000000
10436 +#define SBTOPCI1_MASK 0xfc000000
10437 +#define SBTOPCI2_MASK 0xc0000000
10438 +#define SBTOPCI_MEM 0
10439 +#define SBTOPCI_IO 1
10440 +#define SBTOPCI_CFG0 2
10441 +#define SBTOPCI_CFG1 3
10442 +#define SBTOPCI_PREF 0x4 /* prefetch enable */
10443 +#define SBTOPCI_BURST 0x8 /* burst enable */
10444 +#define SBTOPCI_RC_MASK 0x30 /* read command (>= rev11) */
10445 +#define SBTOPCI_RC_READ 0x00 /* memory read */
10446 +#define SBTOPCI_RC_READLINE 0x10 /* memory read line */
10447 +#define SBTOPCI_RC_READMULTI 0x20 /* memory read multiple */
10449 +/* PCI core index in SROM shadow area */
10450 +#define SRSH_PI_OFFSET 0 /* first word */
10451 +#define SRSH_PI_MASK 0xf000 /* bit 15:12 */
10452 +#define SRSH_PI_SHIFT 12 /* bit 15:12 */
10454 +/* PCI side: Reserved PCI configuration registers (see pcicfg.h) */
10455 +#define cap_list rsvd_a[0]
10456 +#define bar0_window dev_dep[0x80 - 0x40]
10457 +#define bar1_window dev_dep[0x84 - 0x40]
10458 +#define sprom_control dev_dep[0x88 - 0x40]
10460 +#ifndef _LANGUAGE_ASSEMBLY
10462 +extern int sbpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
10463 +extern int sbpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
10464 +extern void sbpci_ban(uint16 core);
10465 +extern int sbpci_init(sb_t *sbh);
10466 +extern void sbpci_check(sb_t *sbh);
10468 +#endif /* !_LANGUAGE_ASSEMBLY */
10470 +#endif /* _SBPCI_H */
10471 diff -urN linux.old/arch/mips/bcm947xx/include/sbsdram.h linux.dev/arch/mips/bcm947xx/include/sbsdram.h
10472 --- linux.old/arch/mips/bcm947xx/include/sbsdram.h 1970-01-01 01:00:00.000000000 +0100
10473 +++ linux.dev/arch/mips/bcm947xx/include/sbsdram.h 2005-12-15 15:35:40.175792500 +0100
10476 + * BCM47XX Sonics SiliconBackplane SDRAM controller core hardware definitions.
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.
10488 +#ifndef _SBSDRAM_H
10489 +#define _SBSDRAM_H
10491 +#ifndef _LANGUAGE_ASSEMBLY
10493 +/* Sonics side: SDRAM core registers */
10494 +typedef volatile struct sbsdramregs {
10495 + uint32 initcontrol; /* Generates external SDRAM initialization sequence */
10496 + uint32 config; /* Initializes external SDRAM mode register */
10497 + uint32 refresh; /* Controls external SDRAM refresh rate */
10504 +/* SDRAM initialization control (initcontrol) register bits */
10505 +#define SDRAM_CBR 0x0001 /* Writing 1 generates refresh cycle and toggles bit */
10506 +#define SDRAM_PRE 0x0002 /* Writing 1 generates precharge cycle and toggles bit */
10507 +#define SDRAM_MRS 0x0004 /* Writing 1 generates mode register select cycle and toggles bit */
10508 +#define SDRAM_EN 0x0008 /* When set, enables access to SDRAM */
10509 +#define SDRAM_16Mb 0x0000 /* Use 16 Megabit SDRAM */
10510 +#define SDRAM_64Mb 0x0010 /* Use 64 Megabit SDRAM */
10511 +#define SDRAM_128Mb 0x0020 /* Use 128 Megabit SDRAM */
10512 +#define SDRAM_RSVMb 0x0030 /* Use special SDRAM */
10513 +#define SDRAM_RST 0x0080 /* Writing 1 causes soft reset of controller */
10514 +#define SDRAM_SELFREF 0x0100 /* Writing 1 enables self refresh mode */
10515 +#define SDRAM_PWRDOWN 0x0200 /* Writing 1 causes controller to power down */
10516 +#define SDRAM_32BIT 0x0400 /* When set, indicates 32 bit SDRAM interface */
10517 +#define SDRAM_9BITCOL 0x0800 /* When set, indicates 9 bit column */
10519 +/* SDRAM configuration (config) register bits */
10520 +#define SDRAM_BURSTFULL 0x0000 /* Use full page bursts */
10521 +#define SDRAM_BURST8 0x0001 /* Use burst of 8 */
10522 +#define SDRAM_BURST4 0x0002 /* Use burst of 4 */
10523 +#define SDRAM_BURST2 0x0003 /* Use burst of 2 */
10524 +#define SDRAM_CAS3 0x0000 /* Use CAS latency of 3 */
10525 +#define SDRAM_CAS2 0x0004 /* Use CAS latency of 2 */
10527 +/* SDRAM refresh control (refresh) register bits */
10528 +#define SDRAM_REF(p) (((p)&0xff) | SDRAM_REF_EN) /* Refresh period */
10529 +#define SDRAM_REF_EN 0x8000 /* Writing 1 enables periodic refresh */
10531 +/* SDRAM Core default Init values (OCP ID 0x803) */
10532 +#define SDRAM_INIT MEM4MX16X2
10533 +#define SDRAM_CONFIG SDRAM_BURSTFULL
10534 +#define SDRAM_REFRESH SDRAM_REF(0x40)
10536 +#define MEM1MX16 0x009 /* 2 MB */
10537 +#define MEM1MX16X2 0x409 /* 4 MB */
10538 +#define MEM2MX8X2 0x809 /* 4 MB */
10539 +#define MEM2MX8X4 0xc09 /* 8 MB */
10540 +#define MEM2MX32 0x439 /* 8 MB */
10541 +#define MEM4MX16 0x019 /* 8 MB */
10542 +#define MEM4MX16X2 0x419 /* 16 MB */
10543 +#define MEM8MX8X2 0x819 /* 16 MB */
10544 +#define MEM8MX16 0x829 /* 16 MB */
10545 +#define MEM4MX32 0x429 /* 16 MB */
10546 +#define MEM8MX8X4 0xc19 /* 32 MB */
10547 +#define MEM8MX16X2 0xc29 /* 32 MB */
10549 +#endif /* _SBSDRAM_H */
10550 diff -urN linux.old/arch/mips/bcm947xx/include/sbutils.h linux.dev/arch/mips/bcm947xx/include/sbutils.h
10551 --- linux.old/arch/mips/bcm947xx/include/sbutils.h 1970-01-01 01:00:00.000000000 +0100
10552 +++ linux.dev/arch/mips/bcm947xx/include/sbutils.h 2005-12-15 16:00:47.404550500 +0100
10555 + * Misc utility routines for accessing chip-specific features
10556 + * of Broadcom HNBU SiliconBackplane-based chips.
10558 + * Copyright 2005, Broadcom Corporation
10559 + * All Rights Reserved.
10561 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10562 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10563 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10564 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10569 +#ifndef _sbutils_h_
10570 +#define _sbutils_h_
10573 + * Datastructure to export all chip specific common variables
10574 + * public (read-only) portion of sbutils handle returned by
10575 + * sb_attach()/sb_kattach()
10580 + uint bustype; /* SB_BUS, PCI_BUS */
10581 + uint buscoretype; /* SB_PCI, SB_PCMCIA, SB_PCIE*/
10582 + uint buscorerev; /* buscore rev */
10583 + uint buscoreidx; /* buscore index */
10584 + int ccrev; /* chip common core rev */
10585 + uint boardtype; /* board type */
10586 + uint boardvendor; /* board vendor */
10587 + uint chip; /* chip number */
10588 + uint chiprev; /* chip revision */
10589 + uint chippkg; /* chip package option */
10590 + uint sonicsrev; /* sonics backplane rev */
10593 +typedef const struct sb_pub sb_t;
10596 + * Many of the routines below take an 'sbh' handle as their first arg.
10597 + * Allocate this by calling sb_attach(). Free it by calling sb_detach().
10598 + * At any one time, the sbh is logically focused on one particular sb core
10599 + * (the "current core").
10600 + * Use sb_setcore() or sb_setcoreidx() to change the association to another core.
10603 +/* exported externs */
10604 +extern sb_t * BCMINIT(sb_attach)(uint pcidev, osl_t *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz);
10605 +extern sb_t * BCMINIT(sb_kattach)(void);
10606 +extern void sb_detach(sb_t *sbh);
10607 +extern uint BCMINIT(sb_chip)(sb_t *sbh);
10608 +extern uint BCMINIT(sb_chiprev)(sb_t *sbh);
10609 +extern uint BCMINIT(sb_chipcrev)(sb_t *sbh);
10610 +extern uint BCMINIT(sb_chippkg)(sb_t *sbh);
10611 +extern uint BCMINIT(sb_pcirev)(sb_t *sbh);
10612 +extern bool BCMINIT(sb_war16165)(sb_t *sbh);
10613 +extern uint BCMINIT(sb_boardvendor)(sb_t *sbh);
10614 +extern uint BCMINIT(sb_boardtype)(sb_t *sbh);
10615 +extern uint sb_bus(sb_t *sbh);
10616 +extern uint sb_buscoretype(sb_t *sbh);
10617 +extern uint sb_buscorerev(sb_t *sbh);
10618 +extern uint sb_corelist(sb_t *sbh, uint coreid[]);
10619 +extern uint sb_coreid(sb_t *sbh);
10620 +extern uint sb_coreidx(sb_t *sbh);
10621 +extern uint sb_coreunit(sb_t *sbh);
10622 +extern uint sb_corevendor(sb_t *sbh);
10623 +extern uint sb_corerev(sb_t *sbh);
10624 +extern void *sb_osh(sb_t *sbh);
10625 +extern void *sb_coreregs(sb_t *sbh);
10626 +extern uint32 sb_coreflags(sb_t *sbh, uint32 mask, uint32 val);
10627 +extern uint32 sb_coreflagshi(sb_t *sbh, uint32 mask, uint32 val);
10628 +extern bool sb_iscoreup(sb_t *sbh);
10629 +extern void *sb_setcoreidx(sb_t *sbh, uint coreidx);
10630 +extern void *sb_setcore(sb_t *sbh, uint coreid, uint coreunit);
10631 +extern int sb_corebist(sb_t *sbh, uint coreid, uint coreunit);
10632 +extern void sb_commit(sb_t *sbh);
10633 +extern uint32 sb_base(uint32 admatch);
10634 +extern uint32 sb_size(uint32 admatch);
10635 +extern void sb_core_reset(sb_t *sbh, uint32 bits);
10636 +extern void sb_core_tofixup(sb_t *sbh);
10637 +extern void sb_core_disable(sb_t *sbh, uint32 bits);
10638 +extern uint32 sb_clock_rate(uint32 pll_type, uint32 n, uint32 m);
10639 +extern uint32 sb_clock(sb_t *sbh);
10640 +extern void sb_pci_setup(sb_t *sbh, uint coremask);
10641 +extern void sb_watchdog(sb_t *sbh, uint ticks);
10642 +extern void *sb_gpiosetcore(sb_t *sbh);
10643 +extern uint32 sb_gpiocontrol(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10644 +extern uint32 sb_gpioouten(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10645 +extern uint32 sb_gpioout(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10646 +extern uint32 sb_gpioin(sb_t *sbh);
10647 +extern uint32 sb_gpiointpolarity(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10648 +extern uint32 sb_gpiointmask(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10649 +extern uint32 sb_gpioled(sb_t *sbh, uint32 mask, uint32 val);
10650 +extern uint32 sb_gpioreserve(sb_t *sbh, uint32 gpio_num, uint8 priority);
10651 +extern uint32 sb_gpiorelease(sb_t *sbh, uint32 gpio_num, uint8 priority);
10653 +extern void sb_clkctl_init(sb_t *sbh);
10654 +extern uint16 sb_clkctl_fast_pwrup_delay(sb_t *sbh);
10655 +extern bool sb_clkctl_clk(sb_t *sbh, uint mode);
10656 +extern int sb_clkctl_xtal(sb_t *sbh, uint what, bool on);
10657 +extern void sb_register_intr_callback(sb_t *sbh, void *intrsoff_fn,
10658 + void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg);
10659 +extern uint32 sb_set_initiator_to(sb_t *sbh, uint32 to);
10660 +extern void sb_corepciid(sb_t *sbh, uint16 *pcivendor, uint16 *pcidevice,
10661 + uint8 *pciclass, uint8 *pcisubclass, uint8 *pciprogif);
10662 +extern uint32 sb_gpiotimerval(sb_t *sbh, uint32 mask, uint32 val);
10667 +* Build device path. Path size must be >= SB_DEVPATH_BUFSZ.
10668 +* The returned path is NULL terminated and has trailing '/'.
10669 +* Return 0 on success, nonzero otherwise.
10671 +extern int sb_devpath(sb_t *sbh, char *path, int size);
10673 +/* clkctl xtal what flags */
10674 +#define XTAL 0x1 /* primary crystal oscillator (2050) */
10675 +#define PLL 0x2 /* main chip pll */
10677 +/* clkctl clk mode */
10678 +#define CLK_FAST 0 /* force fast (pll) clock */
10679 +#define CLK_DYNAMIC 2 /* enable dynamic clock control */
10682 +/* GPIO usage priorities */
10683 +#define GPIO_DRV_PRIORITY 0
10684 +#define GPIO_APP_PRIORITY 1
10687 +#define SB_DEVPATH_BUFSZ 16 /* min buffer size in bytes */
10689 +#endif /* _sbutils_h_ */
10690 diff -urN linux.old/arch/mips/bcm947xx/include/sflash.h linux.dev/arch/mips/bcm947xx/include/sflash.h
10691 --- linux.old/arch/mips/bcm947xx/include/sflash.h 1970-01-01 01:00:00.000000000 +0100
10692 +++ linux.dev/arch/mips/bcm947xx/include/sflash.h 2005-12-15 16:49:23.001703000 +0100
10695 + * Broadcom SiliconBackplane chipcommon serial flash interface
10697 + * Copyright 2005, Broadcom Corporation
10698 + * All Rights Reserved.
10700 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10701 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10702 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10703 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10708 +#ifndef _sflash_h_
10709 +#define _sflash_h_
10711 +#include <typedefs.h>
10712 +#include <sbchipc.h>
10715 + uint blocksize; /* Block size */
10716 + uint numblocks; /* Number of blocks */
10717 + uint32 type; /* Type */
10718 + uint size; /* Total size in bytes */
10721 +/* Utility functions */
10722 +extern int sflash_poll(chipcregs_t *cc, uint offset);
10723 +extern int sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf);
10724 +extern int sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
10725 +extern int sflash_erase(chipcregs_t *cc, uint offset);
10726 +extern int sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
10727 +extern struct sflash * sflash_init(chipcregs_t *cc);
10729 +#endif /* _sflash_h_ */
10730 diff -urN linux.old/arch/mips/bcm947xx/include/trxhdr.h linux.dev/arch/mips/bcm947xx/include/trxhdr.h
10731 --- linux.old/arch/mips/bcm947xx/include/trxhdr.h 1970-01-01 01:00:00.000000000 +0100
10732 +++ linux.dev/arch/mips/bcm947xx/include/trxhdr.h 2005-12-15 15:35:49.220357750 +0100
10735 + * TRX image file header format.
10737 + * Copyright 2005, Broadcom Corporation
10738 + * All Rights Reserved.
10740 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10741 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10742 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10743 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10748 +#include <typedefs.h>
10750 +#define TRX_MAGIC 0x30524448 /* "HDR0" */
10751 +#define TRX_VERSION 1
10752 +#define TRX_MAX_LEN 0x3A0000
10753 +#define TRX_NO_HEADER 1 /* Do not write TRX header */
10754 +#define TRX_GZ_FILES 0x2 /* Contains up to TRX_MAX_OFFSET individual gzip files */
10755 +#define TRX_MAX_OFFSET 3
10757 +struct trx_header {
10758 + uint32 magic; /* "HDR0" */
10759 + uint32 len; /* Length of file including header */
10760 + uint32 crc32; /* 32-bit CRC from flag_version to end of file */
10761 + uint32 flag_version; /* 0:15 flags, 16:31 version */
10762 + uint32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
10765 +/* Compatibility */
10766 +typedef struct trx_header TRXHDR, *PTRXHDR;
10767 diff -urN linux.old/arch/mips/bcm947xx/include/typedefs.h linux.dev/arch/mips/bcm947xx/include/typedefs.h
10768 --- linux.old/arch/mips/bcm947xx/include/typedefs.h 1970-01-01 01:00:00.000000000 +0100
10769 +++ linux.dev/arch/mips/bcm947xx/include/typedefs.h 2005-12-15 15:35:52.436558750 +0100
10772 + * Copyright 2005, Broadcom Corporation
10773 + * All Rights Reserved.
10775 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10776 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10777 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10778 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10782 +#ifndef _TYPEDEFS_H_
10783 +#define _TYPEDEFS_H_
10786 +/* Define 'SITE_TYPEDEFS' in the compile to include a site specific
10787 + * typedef file "site_typedefs.h".
10789 + * If 'SITE_TYPEDEFS' is not defined, then the "Inferred Typedefs"
10790 + * section of this file makes inferences about the compile environment
10791 + * based on defined symbols and possibly compiler pragmas.
10793 + * Following these two sections is the "Default Typedefs"
10794 + * section. This section is only prcessed if 'USE_TYPEDEF_DEFAULTS' is
10795 + * defined. This section has a default set of typedefs and a few
10796 + * proprocessor symbols (TRUE, FALSE, NULL, ...).
10799 +#ifdef SITE_TYPEDEFS
10801 +/*******************************************************************************
10802 + * Site Specific Typedefs
10803 + *******************************************************************************/
10805 +#include "site_typedefs.h"
10809 +/*******************************************************************************
10810 + * Inferred Typedefs
10811 + *******************************************************************************/
10813 +/* Infer the compile environment based on preprocessor symbols and pramas.
10814 + * Override type definitions as needed, and include configuration dependent
10815 + * header files to define types.
10818 +#ifdef __cplusplus
10820 +#define TYPEDEF_BOOL
10822 +#define FALSE false
10828 +#else /* ! __cplusplus */
10830 +#if defined(_WIN32)
10832 +#define TYPEDEF_BOOL
10833 +typedef unsigned char bool; /* consistent w/BOOL */
10835 +#endif /* _WIN32 */
10837 +#endif /* ! __cplusplus */
10839 +/* use the Windows ULONG_PTR type when compiling for 64 bit */
10840 +#if defined(_WIN64)
10841 +#include <basetsd.h>
10842 +#define TYPEDEF_UINTPTR
10843 +typedef ULONG_PTR uintptr;
10847 +typedef long unsigned int size_t;
10850 +#ifdef _MSC_VER /* Microsoft C */
10851 +#define TYPEDEF_INT64
10852 +#define TYPEDEF_UINT64
10853 +typedef signed __int64 int64;
10854 +typedef unsigned __int64 uint64;
10857 +#if defined(MACOSX) && defined(KERNEL)
10858 +#define TYPEDEF_BOOL
10862 +#if defined(linux)
10863 +#define TYPEDEF_UINT
10864 +#define TYPEDEF_USHORT
10865 +#define TYPEDEF_ULONG
10868 +#if !defined(linux) && !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
10869 +#define TYPEDEF_UINT
10870 +#define TYPEDEF_USHORT
10874 +/* Do not support the (u)int64 types with strict ansi for GNU C */
10875 +#if defined(__GNUC__) && defined(__STRICT_ANSI__)
10876 +#define TYPEDEF_INT64
10877 +#define TYPEDEF_UINT64
10880 +/* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
10881 + * for singned or unsigned */
10882 +#if defined(__ICL)
10884 +#define TYPEDEF_INT64
10886 +#if defined(__STDC__)
10887 +#define TYPEDEF_UINT64
10890 +#endif /* __ICL */
10893 +#if !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
10895 +/* pick up ushort & uint from standard types.h */
10896 +#if defined(linux) && defined(__KERNEL__)
10898 +#include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
10902 +#include <sys/types.h>
10906 +#endif /* !_WIN32 && !PMON && !_CFE_ && !_HNDRTE_ && !_MINOSL_ */
10908 +#if defined(MACOSX) && defined(KERNEL)
10909 +#include <IOKit/IOTypes.h>
10913 +/* use the default typedefs in the next section of this file */
10914 +#define USE_TYPEDEF_DEFAULTS
10916 +#endif /* SITE_TYPEDEFS */
10919 +/*******************************************************************************
10920 + * Default Typedefs
10921 + *******************************************************************************/
10923 +#ifdef USE_TYPEDEF_DEFAULTS
10924 +#undef USE_TYPEDEF_DEFAULTS
10926 +#ifndef TYPEDEF_BOOL
10927 +typedef /*@abstract@*/ unsigned char bool;
10930 +/*----------------------- define uchar, ushort, uint, ulong ------------------*/
10932 +#ifndef TYPEDEF_UCHAR
10933 +typedef unsigned char uchar;
10936 +#ifndef TYPEDEF_USHORT
10937 +typedef unsigned short ushort;
10940 +#ifndef TYPEDEF_UINT
10941 +typedef unsigned int uint;
10944 +#ifndef TYPEDEF_ULONG
10945 +typedef unsigned long ulong;
10948 +/*----------------------- define [u]int8/16/32/64, uintptr --------------------*/
10950 +#ifndef TYPEDEF_UINT8
10951 +typedef unsigned char uint8;
10954 +#ifndef TYPEDEF_UINT16
10955 +typedef unsigned short uint16;
10958 +#ifndef TYPEDEF_UINT32
10959 +typedef unsigned int uint32;
10962 +#ifndef TYPEDEF_UINT64
10963 +typedef unsigned long long uint64;
10966 +#ifndef TYPEDEF_UINTPTR
10967 +typedef unsigned int uintptr;
10970 +#ifndef TYPEDEF_INT8
10971 +typedef signed char int8;
10974 +#ifndef TYPEDEF_INT16
10975 +typedef signed short int16;
10978 +#ifndef TYPEDEF_INT32
10979 +typedef signed int int32;
10982 +#ifndef TYPEDEF_INT64
10983 +typedef signed long long int64;
10986 +/*----------------------- define float32/64, float_t -----------------------*/
10988 +#ifndef TYPEDEF_FLOAT32
10989 +typedef float float32;
10992 +#ifndef TYPEDEF_FLOAT64
10993 +typedef double float64;
10997 + * abstracted floating point type allows for compile time selection of
10998 + * single or double precision arithmetic. Compiling with -DFLOAT32
10999 + * selects single precision; the default is double precision.
11002 +#ifndef TYPEDEF_FLOAT_T
11004 +#if defined(FLOAT32)
11005 +typedef float32 float_t;
11006 +#else /* default to double precision floating point */
11007 +typedef float64 float_t;
11010 +#endif /* TYPEDEF_FLOAT_T */
11012 +/*----------------------- define macro values -----------------------------*/
11036 +/* Reclaiming text and data :
11037 + The following macros specify special linker sections that can be reclaimed
11038 + after a system is considered 'up'.
11040 +#if defined(__GNUC__) && defined(BCMRECLAIM)
11041 +extern bool bcmreclaimed;
11042 +#define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini." #_data))) _data##_ini
11043 +#define BCMINITFN(_fn) __attribute__ ((__section__ (".textini." #_fn))) _fn##_ini
11044 +#define BCMINIT(_id) _id##_ini
11046 +#define BCMINITDATA(_data) _data
11047 +#define BCMINITFN(_fn) _fn
11048 +#define BCMINIT(_id) _id
11049 +#define bcmreclaimed 0
11052 +/*----------------------- define PTRSZ, INLINE ----------------------------*/
11055 +#define PTRSZ sizeof (char*)
11062 +#define INLINE __inline
11066 +#define INLINE __inline__
11072 +#endif /* _MSC_VER */
11074 +#endif /* INLINE */
11076 +#undef TYPEDEF_BOOL
11077 +#undef TYPEDEF_UCHAR
11078 +#undef TYPEDEF_USHORT
11079 +#undef TYPEDEF_UINT
11080 +#undef TYPEDEF_ULONG
11081 +#undef TYPEDEF_UINT8
11082 +#undef TYPEDEF_UINT16
11083 +#undef TYPEDEF_UINT32
11084 +#undef TYPEDEF_UINT64
11085 +#undef TYPEDEF_UINTPTR
11086 +#undef TYPEDEF_INT8
11087 +#undef TYPEDEF_INT16
11088 +#undef TYPEDEF_INT32
11089 +#undef TYPEDEF_INT64
11090 +#undef TYPEDEF_FLOAT32
11091 +#undef TYPEDEF_FLOAT64
11092 +#undef TYPEDEF_FLOAT_T
11094 +#endif /* USE_TYPEDEF_DEFAULTS */
11096 +#endif /* _TYPEDEFS_H_ */
11097 diff -urN linux.old/arch/mips/bcm947xx/int-handler.S linux.dev/arch/mips/bcm947xx/int-handler.S
11098 --- linux.old/arch/mips/bcm947xx/int-handler.S 1970-01-01 01:00:00.000000000 +0100
11099 +++ linux.dev/arch/mips/bcm947xx/int-handler.S 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 <asm/asm.h>
11126 +#include <asm/mipsregs.h>
11127 +#include <asm/regdef.h>
11128 +#include <asm/stackframe.h>
11135 + NESTED(bcm47xx_irq_handler, PT_SIZE, sp)
11142 + jal bcm47xx_irq_dispatch
11148 + END(bcm47xx_irq_handler)
11149 diff -urN linux.old/arch/mips/bcm947xx/irq.c linux.dev/arch/mips/bcm947xx/irq.c
11150 --- linux.old/arch/mips/bcm947xx/irq.c 1970-01-01 01:00:00.000000000 +0100
11151 +++ linux.dev/arch/mips/bcm947xx/irq.c 2005-12-15 12:57:27.877187750 +0100
11154 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
11156 + * This program is free software; you can redistribute it and/or modify it
11157 + * under the terms of the GNU General Public License as published by the
11158 + * Free Software Foundation; either version 2 of the License, or (at your
11159 + * option) any later version.
11161 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11162 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
11163 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
11164 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11165 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
11166 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
11167 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
11168 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11169 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
11170 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11172 + * You should have received a copy of the GNU General Public License along
11173 + * with this program; if not, write to the Free Software Foundation, Inc.,
11174 + * 675 Mass Ave, Cambridge, MA 02139, USA.
11177 +#include <linux/config.h>
11178 +#include <linux/errno.h>
11179 +#include <linux/init.h>
11180 +#include <linux/interrupt.h>
11181 +#include <linux/irq.h>
11182 +#include <linux/module.h>
11183 +#include <linux/smp.h>
11184 +#include <linux/types.h>
11186 +#include <asm/cpu.h>
11187 +#include <asm/io.h>
11188 +#include <asm/irq.h>
11189 +#include <asm/irq_cpu.h>
11191 +extern asmlinkage void bcm47xx_irq_handler(void);
11193 +void bcm47xx_irq_dispatch(struct pt_regs *regs)
11197 + cause = read_c0_cause() & read_c0_status() & CAUSEF_IP;
11199 + clear_c0_status(cause);
11201 + if (cause & CAUSEF_IP7)
11203 + if (cause & CAUSEF_IP2)
11205 + if (cause & CAUSEF_IP3)
11207 + if (cause & CAUSEF_IP4)
11209 + if (cause & CAUSEF_IP5)
11211 + if (cause & CAUSEF_IP6)
11215 +void __init arch_init_irq(void)
11217 + set_except_vector(0, bcm47xx_irq_handler);
11218 + mips_cpu_irq_init(0);
11220 diff -urN linux.old/arch/mips/bcm947xx/pci.c linux.dev/arch/mips/bcm947xx/pci.c
11221 --- linux.old/arch/mips/bcm947xx/pci.c 1970-01-01 01:00:00.000000000 +0100
11222 +++ linux.dev/arch/mips/bcm947xx/pci.c 2005-12-17 18:11:52.350836000 +0100
11224 +#include <linux/kernel.h>
11225 +#include <linux/init.h>
11226 +#include <linux/pci.h>
11227 +#include <linux/types.h>
11229 +#include <asm/cpu.h>
11230 +#include <asm/io.h>
11232 +#include <typedefs.h>
11234 +#include <sbutils.h>
11235 +#include <sbmips.h>
11236 +#include <sbconfig.h>
11237 +#include <sbpci.h>
11243 +sb_pci_read_config(struct pci_bus *bus, unsigned int devfn,
11244 + int reg, int size, u32 *val)
11247 + ret = sbpci_read_config(sbh, bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn), reg, val, size);
11248 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11252 +sb_pci_write_config(struct pci_bus *bus, unsigned int devfn,
11253 + int reg, int size, u32 val)
11256 + ret = sbpci_write_config(sbh, bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn), reg, &val, size);
11257 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11261 +static struct pci_ops sb_pci_ops = {
11262 + .read = sb_pci_read_config,
11263 + .write = sb_pci_write_config,
11267 +static struct resource sb_pci_mem_resource = {
11268 + .name = "SB PCI Memory resources",
11269 + .start = SB_ENUM_BASE,
11270 + .end = SB_ENUM_LIM - 1,
11271 + .flags = IORESOURCE_MEM,
11274 +static struct resource sb_pci_io_resource = {
11275 + .name = "SB PCI I/O resources",
11278 + .flags = IORESOURCE_IO,
11281 +static struct pci_controller bcm47xx_sb_pci_controller = {
11282 + .pci_ops = &sb_pci_ops,
11283 + .mem_resource = &sb_pci_mem_resource,
11284 + .io_resource = &sb_pci_io_resource,
11287 +static struct resource ext_pci_mem_resource = {
11288 + .name = "Ext PCI Memory resources",
11289 + .start = 0x40000000,
11290 + .end = 0x40ffffff,
11291 + .flags = IORESOURCE_MEM,
11294 +static struct resource ext_pci_io_resource = {
11295 + .name = "Ext PCI I/O resources",
11298 + .flags = IORESOURCE_IO,
11301 +static struct pci_controller bcm47xx_ext_pci_controller = {
11302 + .pci_ops = &sb_pci_ops,
11303 + .mem_resource = &ext_pci_mem_resource,
11304 + .io_resource = &ext_pci_io_resource,
11307 +void bcm47xx_pci_init(void)
11311 + set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000));
11313 + register_pci_controller(&bcm47xx_sb_pci_controller);
11314 + register_pci_controller(&bcm47xx_ext_pci_controller);
11316 diff -urN linux.old/arch/mips/bcm947xx/prom.c linux.dev/arch/mips/bcm947xx/prom.c
11317 --- linux.old/arch/mips/bcm947xx/prom.c 1970-01-01 01:00:00.000000000 +0100
11318 +++ linux.dev/arch/mips/bcm947xx/prom.c 2005-12-15 12:57:27.877187750 +0100
11321 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
11323 + * This program is free software; you can redistribute it and/or modify it
11324 + * under the terms of the GNU General Public License as published by the
11325 + * Free Software Foundation; either version 2 of the License, or (at your
11326 + * option) any later version.
11328 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11329 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
11330 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
11331 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11332 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
11333 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
11334 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
11335 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11336 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
11337 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11339 + * You should have received a copy of the GNU General Public License along
11340 + * with this program; if not, write to the Free Software Foundation, Inc.,
11341 + * 675 Mass Ave, Cambridge, MA 02139, USA.
11344 +#include <linux/init.h>
11345 +#include <linux/mm.h>
11346 +#include <linux/sched.h>
11347 +#include <linux/bootmem.h>
11349 +#include <asm/addrspace.h>
11350 +#include <asm/bootinfo.h>
11351 +#include <asm/pmon.h>
11353 +const char *get_system_type(void)
11355 + return "Broadcom BCM47xx";
11358 +void __init prom_init(void)
11360 + unsigned long mem;
11362 + mips_machgroup = MACH_GROUP_BRCM;
11363 + mips_machtype = MACH_BCM47XX;
11365 + /* Figure out memory size by finding aliases */
11366 + for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
11367 + if (*(unsigned long *)((unsigned long)(prom_init) + mem) ==
11368 + *(unsigned long *)(prom_init))
11372 + add_memory_region(0, mem, BOOT_MEM_RAM);
11375 +unsigned long __init prom_free_prom_memory(void)
11379 diff -urN linux.old/arch/mips/bcm947xx/setup.c linux.dev/arch/mips/bcm947xx/setup.c
11380 --- linux.old/arch/mips/bcm947xx/setup.c 1970-01-01 01:00:00.000000000 +0100
11381 +++ linux.dev/arch/mips/bcm947xx/setup.c 2005-12-17 22:14:27.619043750 +0100
11384 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
11385 + * Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
11386 + * Copyright (C) 2005 Felix Fietkau <nbd@openwrt.org>
11388 + * This program is free software; you can redistribute it and/or modify it
11389 + * under the terms of the GNU General Public License as published by the
11390 + * Free Software Foundation; either version 2 of the License, or (at your
11391 + * option) any later version.
11393 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11394 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
11395 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
11396 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11397 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
11398 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
11399 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
11400 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11401 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
11402 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11404 + * You should have received a copy of the GNU General Public License along
11405 + * with this program; if not, write to the Free Software Foundation, Inc.,
11406 + * 675 Mass Ave, Cambridge, MA 02139, USA.
11409 +#include <linux/init.h>
11410 +#include <linux/types.h>
11411 +#include <linux/tty.h>
11412 +#include <linux/serial.h>
11413 +#include <linux/serial_core.h>
11414 +#include <linux/serial_reg.h>
11415 +#include <asm/bootinfo.h>
11416 +#include <asm/time.h>
11417 +#include <asm/reboot.h>
11419 +#include <typedefs.h>
11421 +#include <sbutils.h>
11422 +#include <sbmips.h>
11423 +#include <sbpci.h>
11424 +#include <sbconfig.h>
11425 +#include <bcmdevs.h>
11427 +extern void bcm47xx_pci_init(void);
11428 +extern void bcm47xx_time_init(void);
11429 +extern void bcm47xx_timer_setup(struct irqaction *irq);
11433 +static int ser_line = 0;
11442 +static serial_port ports[4];
11443 +static int num_ports = 0;
11446 +serial_add(void *regs, uint irq, uint baud_base, uint reg_shift)
11448 + ports[num_ports].regs = regs;
11449 + ports[num_ports].irq = irq;
11450 + ports[num_ports].baud_base = baud_base;
11451 + ports[num_ports].reg_shift = reg_shift;
11456 +do_serial_add(serial_port *port)
11462 + struct uart_port s;
11464 + regs = port->regs;
11466 + baud_base = port->baud_base;
11467 + reg_shift = port->reg_shift;
11469 + memset(&s, 0, sizeof(s));
11471 + s.line = ser_line++;
11472 + s.membase = regs;
11474 + s.uartclk = baud_base;
11475 + s.flags = ASYNC_BOOT_AUTOCONF;
11476 + s.iotype = SERIAL_IO_MEM;
11477 + s.regshift = reg_shift;
11479 + if (early_serial_setup(&s) != 0) {
11480 + printk(KERN_ERR "Serial setup failed!\n");
11484 +static void bcm47xx_machine_restart(char *command)
11486 + printk("Please stand by while rebooting the system...\n");
11488 + /* Set the watchdog timer to reset immediately */
11489 + local_irq_disable();
11490 + sb_watchdog(sbh, 1);
11494 +static void bcm47xx_machine_halt(void)
11496 + /* Disable interrupts and watchdog and spin forever */
11497 + local_irq_disable();
11498 + sb_watchdog(sbh, 0);
11502 +void __init plat_setup(void)
11507 + sbh = sb_kattach();
11508 + sb_mips_init(sbh);
11510 + bcm47xx_pci_init();
11512 + set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000));
11514 + sb_serial_init(sbh, serial_add);
11515 + boardflags = getintvar(NULL, "boardflags");
11517 + /* reverse serial ports if the nvram variable kernel_args starts with console=ttyS1 */
11518 + s = nvram_get("kernel_args");
11520 + if (!strncmp(s, "console=ttyS1", 13)) {
11521 + for (i = num_ports; i; i--)
11522 + do_serial_add(&ports[i - 1]);
11524 + for (i = 0; i < num_ports; i++)
11525 + do_serial_add(&ports[i]);
11528 + _machine_restart = bcm47xx_machine_restart;
11529 + _machine_halt = bcm47xx_machine_halt;
11530 + _machine_power_off = bcm47xx_machine_halt;
11532 + board_time_init = bcm47xx_time_init;
11533 + board_timer_setup = bcm47xx_timer_setup;
11536 +EXPORT_SYMBOL(sbh);
11537 +EXPORT_SYMBOL(boardflags);
11538 diff -urN linux.old/arch/mips/bcm947xx/time.c linux.dev/arch/mips/bcm947xx/time.c
11539 --- linux.old/arch/mips/bcm947xx/time.c 1970-01-01 01:00:00.000000000 +0100
11540 +++ linux.dev/arch/mips/bcm947xx/time.c 2005-12-15 12:57:27.877187750 +0100
11543 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
11545 + * This program is free software; you can redistribute it and/or modify it
11546 + * under the terms of the GNU General Public License as published by the
11547 + * Free Software Foundation; either version 2 of the License, or (at your
11548 + * option) any later version.
11550 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11551 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
11552 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
11553 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11554 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
11555 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
11556 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
11557 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11558 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
11559 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11561 + * You should have received a copy of the GNU General Public License along
11562 + * with this program; if not, write to the Free Software Foundation, Inc.,
11563 + * 675 Mass Ave, Cambridge, MA 02139, USA.
11566 +#include <linux/config.h>
11567 +#include <linux/init.h>
11568 +#include <linux/kernel.h>
11569 +#include <linux/sched.h>
11570 +#include <linux/serial_reg.h>
11571 +#include <linux/interrupt.h>
11572 +#include <asm/addrspace.h>
11573 +#include <asm/io.h>
11574 +#include <asm/time.h>
11577 +bcm47xx_time_init(void)
11582 + * Use deterministic values for initial counter interrupt
11583 + * so that calibrate delay avoids encountering a counter wrap.
11585 + write_c0_count(0);
11586 + write_c0_compare(0xffff);
11588 + hz = 200 * 1000 * 1000;
11590 + /* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
11591 + mips_hpt_frequency = hz / 2;
11596 +bcm47xx_timer_setup(struct irqaction *irq)
11598 + /* Enable the timer interrupt */
11599 + setup_irq(7, irq);
11601 diff -urN linux.old/arch/mips/kernel/cpu-probe.c linux.dev/arch/mips/kernel/cpu-probe.c
11602 --- linux.old/arch/mips/kernel/cpu-probe.c 2005-12-15 13:26:49.766024000 +0100
11603 +++ linux.dev/arch/mips/kernel/cpu-probe.c 2005-12-15 12:57:27.901177250 +0100
11604 @@ -656,6 +656,28 @@
11608 +static inline void cpu_probe_broadcom(struct cpuinfo_mips *c)
11610 + decode_config1(c);
11611 + switch (c->processor_id & 0xff00) {
11612 + case PRID_IMP_BCM3302:
11613 + c->cputype = CPU_BCM3302;
11614 + c->isa_level = MIPS_CPU_ISA_M32;
11615 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
11616 + MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER;
11618 + case PRID_IMP_BCM4710:
11619 + c->cputype = CPU_BCM4710;
11620 + c->isa_level = MIPS_CPU_ISA_M32;
11621 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
11622 + MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER;
11625 + c->cputype = CPU_UNKNOWN;
11630 __init void cpu_probe(void)
11632 struct cpuinfo_mips *c = ¤t_cpu_data;
11633 @@ -678,6 +700,9 @@
11634 case PRID_COMP_SIBYTE:
11635 cpu_probe_sibyte(c);
11637 + case PRID_COMP_BROADCOM:
11638 + cpu_probe_broadcom(c);
11640 case PRID_COMP_SANDCRAFT:
11641 cpu_probe_sandcraft(c);
11643 diff -urN linux.old/arch/mips/kernel/head.S linux.dev/arch/mips/kernel/head.S
11644 --- linux.old/arch/mips/kernel/head.S 2005-12-15 13:26:49.766024000 +0100
11645 +++ linux.dev/arch/mips/kernel/head.S 2005-12-15 12:57:27.901177250 +0100
11646 @@ -107,6 +107,14 @@
11650 +#ifdef CONFIG_BCM4710
11652 +#define eret nop; nop; eret
11659 * Reserved space for exception handlers.
11660 * Necessary for machines which link their kernels at KSEG0.
11661 diff -urN linux.old/arch/mips/kernel/proc.c linux.dev/arch/mips/kernel/proc.c
11662 --- linux.old/arch/mips/kernel/proc.c 2005-12-15 13:26:49.766024000 +0100
11663 +++ linux.dev/arch/mips/kernel/proc.c 2005-12-15 12:57:27.921168500 +0100
11665 [CPU_VR4181] = "NEC VR4181",
11666 [CPU_VR4181A] = "NEC VR4181A",
11667 [CPU_SR71000] = "Sandcraft SR71000",
11668 + [CPU_BCM3302] = "Broadcom BCM3302",
11669 + [CPU_BCM4710] = "Broadcom BCM4710",
11670 [CPU_PR4450] = "Philips PR4450",
11673 diff -urN linux.old/arch/mips/mm/tlbex.c linux.dev/arch/mips/mm/tlbex.c
11674 --- linux.old/arch/mips/mm/tlbex.c 2005-12-15 13:26:49.794011750 +0100
11675 +++ linux.dev/arch/mips/mm/tlbex.c 2005-12-15 12:57:27.945158000 +0100
11676 @@ -858,6 +858,8 @@
11680 + case CPU_BCM3302:
11681 + case CPU_BCM4710:
11685 diff -urN linux.old/arch/mips/pci/Makefile linux.dev/arch/mips/pci/Makefile
11686 --- linux.old/arch/mips/pci/Makefile 2005-12-15 13:26:49.814003000 +0100
11687 +++ linux.dev/arch/mips/pci/Makefile 2005-12-15 14:27:26.439319250 +0100
11689 obj-$(CONFIG_MIPS_TX3927) += ops-tx3927.o
11690 obj-$(CONFIG_PCI_VR41XX) += ops-vr41xx.o pci-vr41xx.o
11691 obj-$(CONFIG_NEC_CMBVR4133) += fixup-vr4133.o
11692 +obj-$(CONFIG_BCM947XX) += fixup-bcm47xx.o
11695 # These are still pretty much in the old state, watch, go blind.
11696 diff -urN linux.old/arch/mips/pci/fixup-bcm47xx.c linux.dev/arch/mips/pci/fixup-bcm47xx.c
11697 --- linux.old/arch/mips/pci/fixup-bcm47xx.c 1970-01-01 01:00:00.000000000 +0100
11698 +++ linux.dev/arch/mips/pci/fixup-bcm47xx.c 2005-12-15 12:57:27.945158000 +0100
11700 +#include <linux/init.h>
11701 +#include <linux/pci.h>
11703 +/* Do platform specific device initialization at pci_enable_device() time */
11704 +int pcibios_plat_dev_init(struct pci_dev *dev)
11709 +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
11713 + if (dev->bus->number == 1)
11716 + pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
11720 +struct pci_fixup pcibios_fixups[] = {
11723 diff -urN linux.old/arch/mips/pci/pci.c linux.dev/arch/mips/pci/pci.c
11724 --- linux.old/arch/mips/pci/pci.c 2005-12-15 13:26:49.814003000 +0100
11725 +++ linux.dev/arch/mips/pci/pci.c 2005-12-17 18:08:13.553162000 +0100
11726 @@ -307,7 +307,8 @@
11727 if (res->flags & IORESOURCE_IO)
11728 offset = hose->io_offset;
11729 else if (res->flags & IORESOURCE_MEM)
11730 - offset = hose->mem_offset;
11731 +// offset = hose->mem_offset;
11732 + offset = 0x24000000;
11734 res->start = region->start + offset;
11735 res->end = region->end + offset;
11736 diff -urN linux.old/include/asm-mips/bootinfo.h linux.dev/include/asm-mips/bootinfo.h
11737 --- linux.old/include/asm-mips/bootinfo.h 2005-12-15 13:26:49.818001250 +0100
11738 +++ linux.dev/include/asm-mips/bootinfo.h 2005-12-15 12:57:27.969147500 +0100
11739 @@ -218,6 +218,12 @@
11740 #define MACH_GROUP_TITAN 22 /* PMC-Sierra Titan */
11741 #define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */
11744 + * Valid machtype for group Broadcom
11746 +#define MACH_GROUP_BRCM 23 /* Broadcom */
11747 +#define MACH_BCM47XX 1 /* Broadcom BCM47xx */
11749 #define CL_SIZE COMMAND_LINE_SIZE
11751 const char *get_system_type(void);
11752 diff -urN linux.old/include/asm-mips/cpu.h linux.dev/include/asm-mips/cpu.h
11753 --- linux.old/include/asm-mips/cpu.h 2005-12-15 13:26:49.818001250 +0100
11754 +++ linux.dev/include/asm-mips/cpu.h 2005-12-15 12:57:27.969147500 +0100
11755 @@ -102,6 +102,13 @@
11756 #define PRID_IMP_SR71000 0x0400
11759 + * These are the PRID's for when 23:16 == PRID_COMP_BROADCOM
11762 +#define PRID_IMP_BCM4710 0x4000
11763 +#define PRID_IMP_BCM3302 0x9000
11766 * Definitions for 7:0 on legacy processors
11769 @@ -196,7 +203,9 @@
11771 #define CPU_PR4450 61
11772 #define CPU_SB1A 62
11773 -#define CPU_LAST 62
11774 +#define CPU_BCM3302 63
11775 +#define CPU_BCM4710 64
11776 +#define CPU_LAST 64
11779 * ISA Level encodings
11780 diff -urN linux.old/include/linux/init.h linux.dev/include/linux/init.h
11781 --- linux.old/include/linux/init.h 2005-12-15 13:26:49.818001250 +0100
11782 +++ linux.dev/include/linux/init.h 2005-12-15 12:57:27.973145750 +0100
11784 static initcall_t __initcall_##fn __attribute_used__ \
11785 __attribute__((__section__(".initcall" level ".init"))) = fn
11787 +#define early_initcall(fn) __define_initcall(".early1",fn)
11789 #define core_initcall(fn) __define_initcall("1",fn)
11790 #define postcore_initcall(fn) __define_initcall("2",fn)
11791 #define arch_initcall(fn) __define_initcall("3",fn)
11792 diff -urN linux.old/include/linux/pci_ids.h linux.dev/include/linux/pci_ids.h
11793 --- linux.old/include/linux/pci_ids.h 2005-12-15 13:26:49.818001250 +0100
11794 +++ linux.dev/include/linux/pci_ids.h 2005-12-15 12:57:27.977144000 +0100
11795 @@ -1835,6 +1835,7 @@
11796 #define PCI_DEVICE_ID_TIGON3_5901_2 0x170e
11797 #define PCI_DEVICE_ID_BCM4401 0x4401
11798 #define PCI_DEVICE_ID_BCM4401B0 0x4402
11799 +#define PCI_DEVICE_ID_BCM4713 0x4713
11801 #define PCI_VENDOR_ID_TOPIC 0x151f
11802 #define PCI_DEVICE_ID_TOPIC_TP560 0x0000