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-18 04:59:36.185204500 +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(char *nv_buf, const 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-18 05:36:53.351735500 +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;
2877 + class = PCI_CLASS_BRIDGE;
2878 + subclass = PCI_BRIDGE_PCI;
2883 + class = PCI_CLASS_CPU;
2884 + subclass = PCI_CPU_MIPS;
2887 + class = PCI_CLASS_COMM;
2888 + subclass = PCI_COMM_MODEM;
2889 + core = BCM47XX_V90_ID;
2892 + class = PCI_CLASS_SERIAL;
2893 + subclass = PCI_SERIAL_USB;
2894 + progif = 0x10; /* OHCI */
2895 + core = BCM47XX_USB_ID;
2898 + class = PCI_CLASS_SERIAL;
2899 + subclass = PCI_SERIAL_USB;
2900 + progif = 0x10; /* OHCI */
2901 + core = BCM47XX_USBH_ID;
2904 + class = PCI_CLASS_SERIAL;
2905 + subclass = PCI_SERIAL_USB;
2906 + core = BCM47XX_USBD_ID;
2909 + class = PCI_CLASS_CRYPT;
2910 + subclass = PCI_CRYPT_NETWORK;
2911 + core = BCM47XX_IPSEC_ID;
2914 + class = PCI_CLASS_NET;
2915 + subclass = PCI_NET_OTHER;
2916 + core = BCM47XX_ROBO_ID;
2920 + class = PCI_CLASS_MEMORY;
2921 + subclass = PCI_MEMORY_FLASH;
2924 + class = PCI_CLASS_NET;
2925 + subclass = PCI_NET_OTHER;
2926 + /* Let an nvram variable override this */
2927 + sprintf(varname, "wl%did", wlidx);
2929 + if ((core = getintvar(NULL, varname)) == 0) {
2930 + if (chip == BCM4712_DEVICE_ID) {
2931 + if (chippkg == BCM4712SMALL_PKG_ID)
2932 + core = BCM4306_D11G_ID;
2934 + core = BCM4306_D11DUAL_ID;
2937 + core = BCM4310_D11B_ID;
2943 + class = subclass = progif = 0xff;
2947 + /* Supported translations */
2948 + cfg->vendor = htol16(vendor);
2949 + cfg->device = htol16(core);
2950 + cfg->rev_id = chiprev;
2951 + cfg->prog_if = progif;
2952 + cfg->sub_class = subclass;
2953 + cfg->base_class = class;
2954 + cfg->base[0] = htol32(sb_base(R_REG(&sb->sbadmatch0)));
2955 + cfg->base[1] = 0;//htol32(sb_base(R_REG(&sb->sbadmatch1)));
2956 + cfg->base[2] = 0;//htol32(sb_base(R_REG(&sb->sbadmatch2)));
2957 + cfg->base[3] = 0;//htol32(sb_base(R_REG(&sb->sbadmatch3)));
2960 + if (class == PCI_CLASS_BRIDGE && subclass == PCI_BRIDGE_PCI)
2961 + cfg->header_type = PCI_HEADER_BRIDGE;
2963 + cfg->header_type = PCI_HEADER_NORMAL;
2964 + /* Save core interrupt flag */
2965 + cfg->int_pin = R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK;
2966 + /* Default to MIPS shared interrupt 0 */
2967 + cfg->int_line = 0;
2968 + /* MIPS sbipsflag maps core interrupt flags to interrupts 1 through 4 */
2969 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) ||
2970 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) {
2971 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
2972 + val = R_REG(&sb->sbipsflag);
2973 + for (cfg->int_line = 1; cfg->int_line <= 4; cfg->int_line++) {
2974 + if (((val & sbips_int_mask[cfg->int_line]) >> sbips_int_shift[cfg->int_line]) == cfg->int_pin)
2977 + if (cfg->int_line > 4)
2978 + cfg->int_line = 0;
2980 + /* Emulated core */
2981 + *((uint32 *) &cfg->sprom_control) = 0xffffffff;
2984 + sb_setcoreidx(sbh, coreidx);
2989 +sbpci_init(sb_t *sbh)
2991 + sbpci_init_pci(sbh);
2992 + sbpci_init_cores(sbh);
2996 diff -urN linux.old/arch/mips/bcm947xx/broadcom/sbutils.c linux.dev/arch/mips/bcm947xx/broadcom/sbutils.c
2997 --- linux.old/arch/mips/bcm947xx/broadcom/sbutils.c 1970-01-01 01:00:00.000000000 +0100
2998 +++ linux.dev/arch/mips/bcm947xx/broadcom/sbutils.c 2005-12-17 01:21:12.951254500 +0100
3001 + * Misc utility routines for accessing chip-specific features
3002 + * of the SiliconBackplane-based Broadcom chips.
3004 + * Copyright 2005, Broadcom Corporation
3005 + * All Rights Reserved.
3007 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
3008 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
3009 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
3010 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
3014 +#include <typedefs.h>
3016 +#include <sbutils.h>
3017 +#include <bcmutils.h>
3018 +#include <bcmdevs.h>
3019 +#include <sbconfig.h>
3020 +#include <sbchipc.h>
3022 +#include <pcicfg.h>
3023 +#include <sbextif.h>
3024 +#include <bcmsrom.h>
3027 +#define SB_ERROR(args)
3030 +typedef uint32 (*sb_intrsoff_t)(void *intr_arg);
3031 +typedef void (*sb_intrsrestore_t)(void *intr_arg, uint32 arg);
3032 +typedef bool (*sb_intrsenabled_t)(void *intr_arg);
3034 +/* misc sb info needed by some of the routines */
3035 +typedef struct sb_info {
3037 + struct sb_pub sb; /* back plane public state(must be first field of sb_info */
3039 + void *osh; /* osl os handle */
3040 + void *sdh; /* bcmsdh handle */
3042 + void *curmap; /* current regs va */
3043 + void *regs[SB_MAXCORES]; /* other regs va */
3045 + uint curidx; /* current core index */
3046 + uint dev_coreid; /* the core provides driver functions */
3048 + uint gpioidx; /* gpio control core index */
3049 + uint gpioid; /* gpio control coretype */
3051 + uint numcores; /* # discovered cores */
3052 + uint coreid[SB_MAXCORES]; /* id of each core */
3054 + void *intr_arg; /* interrupt callback function arg */
3055 + sb_intrsoff_t intrsoff_fn; /* function turns chip interrupts off */
3056 + sb_intrsrestore_t intrsrestore_fn; /* function restore chip interrupts */
3057 + sb_intrsenabled_t intrsenabled_fn; /* function to check if chip interrupts are enabled */
3061 +/* local prototypes */
3062 +static sb_info_t * BCMINIT(sb_doattach)(sb_info_t *si, uint devid, osl_t *osh, void *regs,
3063 + uint bustype, void *sdh, char **vars, int *varsz);
3064 +static void BCMINIT(sb_scan)(sb_info_t *si);
3065 +static uint sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val);
3066 +static uint _sb_coreidx(sb_info_t *si);
3067 +static uint sb_findcoreidx(sb_info_t *si, uint coreid, uint coreunit);
3068 +static uint BCMINIT(sb_pcidev2chip)(uint pcidev);
3069 +static uint BCMINIT(sb_chip2numcores)(uint chip);
3070 +static int sb_pci_fixcfg(sb_info_t *si);
3072 +/* delay needed between the mdio control/ mdiodata register data access */
3073 +#define PR28829_DELAY() OSL_DELAY(10)
3076 +/* global variable to indicate reservation/release of gpio's*/
3077 +static uint32 sb_gpioreservation = 0;
3079 +#define SB_INFO(sbh) (sb_info_t*)sbh
3080 +#define SET_SBREG(sbh, r, mask, val) W_SBREG((sbh), (r), ((R_SBREG((sbh), (r)) & ~(mask)) | (val)))
3081 +#define GOODCOREADDR(x) (((x) >= SB_ENUM_BASE) && ((x) <= SB_ENUM_LIM) && ISALIGNED((x), SB_CORE_SIZE))
3082 +#define GOODREGS(regs) ((regs) && ISALIGNED((uintptr)(regs), SB_CORE_SIZE))
3083 +#define REGS2SB(va) (sbconfig_t*) ((int8*)(va) + SBCONFIGOFF)
3084 +#define GOODIDX(idx) (((uint)idx) < SB_MAXCORES)
3085 +#define BADIDX (SB_MAXCORES+1)
3088 +#define PCI(si) ((BUSTYPE(si->sb.bustype) == PCI_BUS) && (si->sb.buscoretype == SB_PCI))
3091 +#define SONICS_2_2 (SBIDL_RV_2_2 >> SBIDL_RV_SHIFT)
3092 +#define SONICS_2_3 (SBIDL_RV_2_3 >> SBIDL_RV_SHIFT)
3094 +#define R_SBREG(sbh, sbr) sb_read_sbreg((sbh), (sbr))
3095 +#define W_SBREG(sbh, sbr, v) sb_write_sbreg((sbh), (sbr), (v))
3096 +#define AND_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) & (v)))
3097 +#define OR_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) | (v)))
3100 + * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts before/
3101 + * after core switching to avoid invalid register accesss inside ISR.
3103 +#define INTR_OFF(si, intr_val) \
3104 + if ((si)->intrsoff_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
3105 + intr_val = (*(si)->intrsoff_fn)((si)->intr_arg); }
3106 +#define INTR_RESTORE(si, intr_val) \
3107 + if ((si)->intrsrestore_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \
3108 + (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val); }
3110 +/* dynamic clock control defines */
3111 +#define LPOMINFREQ 25000 /* low power oscillator min */
3112 +#define LPOMAXFREQ 43000 /* low power oscillator max */
3113 +#define XTALMINFREQ 19800000 /* 20 MHz - 1% */
3114 +#define XTALMAXFREQ 20200000 /* 20 MHz + 1% */
3115 +#define PCIMINFREQ 25000000 /* 25 MHz */
3116 +#define PCIMAXFREQ 34000000 /* 33 MHz + fudge */
3118 +#define ILP_DIV_5MHZ 0 /* ILP = 5 MHz */
3119 +#define ILP_DIV_1MHZ 4 /* ILP = 1 MHz */
3121 +#define MIN_DUMPBUFLEN 32 /* debug */
3123 +/* GPIO Based LED powersave defines */
3124 +#define DEFAULT_GPIO_ONTIME 10
3125 +#define DEFAULT_GPIO_OFFTIME 90
3127 +#define DEFAULT_GPIOTIMERVAL ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME)
3130 +sb_read_sbreg(sb_info_t *si, volatile uint32 *sbr)
3132 + uint32 val = R_REG(sbr);
3138 +sb_write_sbreg(sb_info_t *si, volatile uint32 *sbr, uint32 v)
3143 +/* Using sb_kattach depends on SB_BUS support, either implicit */
3144 +/* no limiting BCMBUSTYPE value) or explicit (value is SB_BUS). */
3145 +#if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SB_BUS)
3147 +/* global kernel resource */
3148 +static sb_info_t ksi;
3150 +/* generic kernel variant of sb_attach() */
3152 +BCMINITFN(sb_kattach)()
3156 + if (ksi.curmap == NULL) {
3159 + regs = (uint32 *)REG_MAP(SB_ENUM_BASE, SB_CORE_SIZE);
3160 + cid = R_REG((uint32 *)regs);
3161 + if (((cid & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
3162 + ((cid & CID_PKG_MASK) != BCM4712LARGE_PKG_ID) &&
3163 + ((cid & CID_REV_MASK) <= (3 << CID_REV_SHIFT))) {
3166 + scc = (uint32 *)((uchar*)regs + OFFSETOF(chipcregs_t, slow_clk_ctl));
3168 + SB_ERROR((" initial scc = 0x%x\n", val));
3169 + val |= SCC_SS_XTAL;
3173 + if (BCMINIT(sb_doattach)(&ksi, BCM4710_DEVICE_ID, NULL, (void*)regs,
3174 + SB_BUS, NULL, NULL, NULL) == NULL) {
3179 + return (sb_t *)&ksi;
3184 +BCMINITFN(sb_doattach)(sb_info_t *si, uint devid, osl_t *osh, void *regs,
3185 + uint bustype, void *sdh, char **vars, int *varsz)
3192 + ASSERT(GOODREGS(regs));
3194 + bzero((uchar*)si, sizeof (sb_info_t));
3196 + si->sb.buscoreidx = si->gpioidx = BADIDX;
3199 + si->curmap = regs;
3202 + /* check to see if we are a sb core mimic'ing a pci core */
3203 + if (bustype == PCI_BUS) {
3204 + if (OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof (uint32)) == 0xffffffff)
3207 + bustype = PCI_BUS;
3210 + si->sb.bustype = bustype;
3211 + if (si->sb.bustype != BUSTYPE(si->sb.bustype)) {
3212 + SB_ERROR(("sb_doattach: bus type %d does not match configured bus type %d\n",
3213 + si->sb.bustype, BUSTYPE(si->sb.bustype)));
3217 + /* kludge to enable the clock on the 4306 which lacks a slowclock */
3218 + if (BUSTYPE(si->sb.bustype) == PCI_BUS)
3219 + sb_clkctl_xtal(&si->sb, XTAL|PLL, ON);
3221 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
3222 + w = OSL_PCI_READ_CONFIG(osh, PCI_BAR0_WIN, sizeof (uint32));
3223 + if (!GOODCOREADDR(w))
3224 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32), SB_ENUM_BASE);
3227 + /* initialize current core index value */
3228 + si->curidx = _sb_coreidx(si);
3230 + if (si->curidx == BADIDX) {
3231 + SB_ERROR(("sb_doattach: bad core index\n"));
3235 + /* get sonics backplane revision */
3236 + sb = REGS2SB(si->curmap);
3237 + si->sb.sonicsrev = (R_SBREG(si, &(sb)->sbidlow) & SBIDL_RV_MASK) >> SBIDL_RV_SHIFT;
3239 + /* keep and reuse the initial register mapping */
3240 + origidx = si->curidx;
3241 + if (BUSTYPE(si->sb.bustype) == SB_BUS)
3242 + si->regs[origidx] = regs;
3244 + /* is core-0 a chipcommon core? */
3246 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, 0);
3247 + if (sb_coreid(&si->sb) != SB_CC)
3250 + /* determine chip id and rev */
3252 + /* chip common core found! */
3253 + si->sb.chip = R_REG(&cc->chipid) & CID_ID_MASK;
3254 + si->sb.chiprev = (R_REG(&cc->chipid) & CID_REV_MASK) >> CID_REV_SHIFT;
3255 + si->sb.chippkg = (R_REG(&cc->chipid) & CID_PKG_MASK) >> CID_PKG_SHIFT;
3257 + /* no chip common core -- must convert device id to chip id */
3258 + if ((si->sb.chip = BCMINIT(sb_pcidev2chip)(devid)) == 0) {
3259 + SB_ERROR(("sb_doattach: unrecognized device id 0x%04x\n", devid));
3260 + sb_setcoreidx(&si->sb, origidx);
3265 + /* get chipcommon rev */
3266 + si->sb.ccrev = cc ? (int)sb_corerev(&si->sb) : NOREV;
3268 + /* determine numcores */
3269 + if (cc && ((si->sb.ccrev == 4) || (si->sb.ccrev >= 6)))
3270 + si->numcores = (R_REG(&cc->chipid) & CID_CC_MASK) >> CID_CC_SHIFT;
3272 + si->numcores = BCMINIT(sb_chip2numcores)(si->sb.chip);
3274 + /* return to original core */
3275 + sb_setcoreidx(&si->sb, origidx);
3277 + /* sanity checks */
3278 + ASSERT(si->sb.chip);
3280 + /* scan for cores */
3281 + BCMINIT(sb_scan)(si);
3283 + /* fixup necessary chip/core configurations */
3284 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
3285 + if (sb_pci_fixcfg(si)) {
3286 + SB_ERROR(("sb_doattach: sb_pci_fixcfg failed\n"));
3291 + /* srom_var_init() depends on sb_scan() info */
3292 + if (srom_var_init(si, si->sb.bustype, si->curmap, osh, vars, varsz)) {
3293 + SB_ERROR(("sb_doattach: srom_var_init failed: bad srom\n"));
3299 + * The chip revision number is hardwired into all
3300 + * of the pci function config rev fields and is
3301 + * independent from the individual core revision numbers.
3302 + * For example, the "A0" silicon of each chip is chip rev 0.
3304 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) {
3305 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_REV, sizeof (uint32));
3306 + si->sb.chiprev = w & 0xff;
3308 + si->sb.chiprev = 0;
3311 + /* gpio control core is required */
3312 + if (!GOODIDX(si->gpioidx)) {
3313 + SB_ERROR(("sb_doattach: gpio control core not found\n"));
3317 + /* get boardtype and boardrev */
3318 + switch (BUSTYPE(si->sb.bustype)) {
3320 + /* do a pci config read to get subsystem id and subvendor id */
3321 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_SVID, sizeof (uint32));
3322 + si->sb.boardvendor = w & 0xffff;
3323 + si->sb.boardtype = (w >> 16) & 0xffff;
3328 + si->sb.boardvendor = VENDOR_BROADCOM;
3329 + if ((si->sb.boardtype = getintvar(NULL, "boardtype")) == 0)
3330 + si->sb.boardtype = 0xffff;
3334 + if (si->sb.boardtype == 0) {
3335 + SB_ERROR(("sb_doattach: unknown board type\n"));
3336 + ASSERT(si->sb.boardtype);
3339 + /* setup the GPIO based LED powersave register */
3340 + if (si->sb.ccrev >= 16) {
3341 + w = getintvar(*vars, "gpiotimerval");
3343 + w = DEFAULT_GPIOTIMERVAL;
3344 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), ~0, w);
3352 +sb_coreid(sb_t *sbh)
3357 + si = SB_INFO(sbh);
3358 + sb = REGS2SB(si->curmap);
3360 + return ((R_SBREG(si, &(sb)->sbidhigh) & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT);
3364 +sb_coreidx(sb_t *sbh)
3368 + si = SB_INFO(sbh);
3369 + return (si->curidx);
3372 +/* return current index of core */
3374 +_sb_coreidx(sb_info_t *si)
3377 + uint32 sbaddr = 0;
3381 + switch (BUSTYPE(si->sb.bustype)) {
3383 + sb = REGS2SB(si->curmap);
3384 + sbaddr = sb_base(R_SBREG(si, &sb->sbadmatch0));
3388 + sbaddr = OSL_PCI_READ_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32));
3393 + sbaddr = (uint32)si->curmap;
3395 +#endif /* BCMJTAG */
3401 + if (!GOODCOREADDR(sbaddr))
3404 + return ((sbaddr - SB_ENUM_BASE) / SB_CORE_SIZE);
3408 +sb_corevendor(sb_t *sbh)
3413 + si = SB_INFO(sbh);
3414 + sb = REGS2SB(si->curmap);
3416 + return ((R_SBREG(si, &(sb)->sbidhigh) & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT);
3420 +sb_corerev(sb_t *sbh)
3426 + si = SB_INFO(sbh);
3427 + sb = REGS2SB(si->curmap);
3428 + sbidh = R_SBREG(si, &(sb)->sbidhigh);
3430 + return (SBCOREREV(sbidh));
3438 + si = SB_INFO(sbh);
3442 +#define SBTML_ALLOW (SBTML_PE | SBTML_FGC | SBTML_FL_MASK)
3444 +/* set/clear sbtmstatelow core-specific flags */
3446 +sb_coreflags(sb_t *sbh, uint32 mask, uint32 val)
3452 + si = SB_INFO(sbh);
3453 + sb = REGS2SB(si->curmap);
3455 + ASSERT((val & ~mask) == 0);
3456 + ASSERT((mask & ~SBTML_ALLOW) == 0);
3458 + /* mask and set */
3459 + if (mask || val) {
3460 + w = (R_SBREG(si, &sb->sbtmstatelow) & ~mask) | val;
3461 + W_SBREG(si, &sb->sbtmstatelow, w);
3464 + /* return the new value */
3465 + return (R_SBREG(si, &sb->sbtmstatelow) & SBTML_ALLOW);
3468 +/* set/clear sbtmstatehigh core-specific flags */
3470 +sb_coreflagshi(sb_t *sbh, uint32 mask, uint32 val)
3476 + si = SB_INFO(sbh);
3477 + sb = REGS2SB(si->curmap);
3479 + ASSERT((val & ~mask) == 0);
3480 + ASSERT((mask & ~SBTMH_FL_MASK) == 0);
3482 + /* mask and set */
3483 + if (mask || val) {
3484 + w = (R_SBREG(si, &sb->sbtmstatehigh) & ~mask) | val;
3485 + W_SBREG(si, &sb->sbtmstatehigh, w);
3488 + /* return the new value */
3489 + return (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_FL_MASK);
3492 +/* caller needs to take care of core-specific bist hazards */
3494 +sb_corebist(sb_t *sbh, uint coreid, uint coreunit)
3501 + si = SB_INFO(sbh);
3503 + coreidx = sb_findcoreidx(si, coreid, coreunit);
3504 + if (!GOODIDX(coreidx))
3505 + result = BCME_ERROR;
3507 + sblo = sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), 0, 0);
3508 + sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), ~0, (sblo | SBTML_FGC | SBTML_BE));
3510 + SPINWAIT(((sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatehigh), 0, 0) & SBTMH_BISTD) == 0), 100000);
3512 + if (sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatehigh), 0, 0) & SBTMH_BISTF)
3513 + result = BCME_ERROR;
3515 + sb_corereg(si, coreidx, SBCONFIGOFF + OFFSETOF(sbconfig_t, sbtmstatelow), ~0, sblo);
3522 +sb_iscoreup(sb_t *sbh)
3527 + si = SB_INFO(sbh);
3528 + sb = REGS2SB(si->curmap);
3530 + return ((R_SBREG(si, &(sb)->sbtmstatelow) & (SBTML_RESET | SBTML_REJ_MASK | SBTML_CLK)) == SBTML_CLK);
3534 + * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set operation,
3535 + * switch back to the original core, and return the new value.
3538 +sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val)
3543 + uint intr_val = 0;
3545 + ASSERT(GOODIDX(coreidx));
3546 + ASSERT(regoff < SB_CORE_SIZE);
3547 + ASSERT((val & ~mask) == 0);
3549 + INTR_OFF(si, intr_val);
3551 + /* save current core index */
3552 + origidx = sb_coreidx(&si->sb);
3555 + r = (uint32*) ((uchar*) sb_setcoreidx(&si->sb, coreidx) + regoff);
3557 + /* mask and set */
3558 + if (mask || val) {
3559 + if (regoff >= SBCONFIGOFF) {
3560 + w = (R_SBREG(si, r) & ~mask) | val;
3561 + W_SBREG(si, r, w);
3563 + w = (R_REG(r) & ~mask) | val;
3569 + if (regoff >= SBCONFIGOFF)
3570 + w = R_SBREG(si, r);
3574 + /* restore core index */
3575 + if (origidx != coreidx)
3576 + sb_setcoreidx(&si->sb, origidx);
3578 + INTR_RESTORE(si, intr_val);
3582 +#define DWORD_ALIGN(x) (x & ~(0x03))
3583 +#define BYTE_POS(x) (x & 0x3)
3584 +#define WORD_POS(x) (x & 0x1)
3586 +#define BYTE_SHIFT(x) (8 * BYTE_POS(x))
3587 +#define WORD_SHIFT(x) (16 * WORD_POS(x))
3589 +#define BYTE_VAL(a, x) ((a >> BYTE_SHIFT(x)) & 0xFF)
3590 +#define WORD_VAL(a, x) ((a >> WORD_SHIFT(x)) & 0xFFFF)
3592 +#define read_pci_cfg_byte(a) \
3593 + (BYTE_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xff)
3595 +#define read_pci_cfg_write(a) \
3596 + (WORD_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xffff)
3599 +/* scan the sb enumerated space to identify all cores */
3601 +BCMINITFN(sb_scan)(sb_info_t *si)
3611 + /* numcores should already be set */
3612 + ASSERT((si->numcores > 0) && (si->numcores <= SB_MAXCORES));
3614 + /* save current core index */
3615 + origidx = sb_coreidx(&si->sb);
3617 + si->sb.buscorerev = NOREV;
3618 + si->sb.buscoreidx = BADIDX;
3620 + si->gpioidx = BADIDX;
3626 + for (i = 0; i < si->numcores; i++) {
3627 + sb_setcoreidx(&si->sb, i);
3628 + si->coreid[i] = sb_coreid(&si->sb);
3630 + if (si->coreid[i] == SB_PCI) {
3632 + pcirev = sb_corerev(&si->sb);
3637 + si->sb.buscoretype = SB_PCI;
3638 + si->sb.buscorerev = pcirev;
3639 + si->sb.buscoreidx = pciidx;
3643 + * Find the gpio "controlling core" type and index.
3645 + * - if there's a chip common core - use that
3646 + * - else if there's a pci core (rev >= 2) - use that
3647 + * - else there had better be an extif core (4710 only)
3649 + if (GOODIDX(sb_findcoreidx(si, SB_CC, 0))) {
3650 + si->gpioidx = sb_findcoreidx(si, SB_CC, 0);
3651 + si->gpioid = SB_CC;
3652 + } else if (PCI(si) && (si->sb.buscorerev >= 2)) {
3653 + si->gpioidx = si->sb.buscoreidx;
3654 + si->gpioid = SB_PCI;
3655 + } else if (sb_findcoreidx(si, SB_EXTIF, 0)) {
3656 + si->gpioidx = sb_findcoreidx(si, SB_EXTIF, 0);
3657 + si->gpioid = SB_EXTIF;
3659 + ASSERT(si->gpioidx != BADIDX);
3661 + /* return to original core index */
3662 + sb_setcoreidx(&si->sb, origidx);
3665 +/* may be called with core in reset */
3667 +sb_detach(sb_t *sbh)
3672 + si = SB_INFO(sbh);
3677 + if (BUSTYPE(si->sb.bustype) == SB_BUS)
3678 + for (idx = 0; idx < SB_MAXCORES; idx++)
3679 + if (si->regs[idx]) {
3680 + REG_UNMAP(si->regs[idx]);
3681 + si->regs[idx] = NULL;
3685 + MFREE(si->osh, si, sizeof (sb_info_t));
3688 +/* use pci dev id to determine chip id for chips not having a chipcommon core */
3690 +BCMINITFN(sb_pcidev2chip)(uint pcidev)
3692 + if ((pcidev >= BCM4710_DEVICE_ID) && (pcidev <= BCM47XX_USB_ID))
3693 + return (BCM4710_DEVICE_ID);
3694 + if ((pcidev >= BCM4402_DEVICE_ID) && (pcidev <= BCM4402_V90_ID))
3695 + return (BCM4402_DEVICE_ID);
3696 + if (pcidev == BCM4401_ENET_ID)
3697 + return (BCM4402_DEVICE_ID);
3698 + if ((pcidev >= BCM4307_V90_ID) && (pcidev <= BCM4307_D11B_ID))
3699 + return (BCM4307_DEVICE_ID);
3700 + if (pcidev == BCM4301_DEVICE_ID)
3701 + return (BCM4301_DEVICE_ID);
3706 +/* convert chip number to number of i/o cores */
3708 +BCMINITFN(sb_chip2numcores)(uint chip)
3710 + if (chip == BCM4710_DEVICE_ID)
3712 + if (chip == BCM4402_DEVICE_ID)
3714 + if ((chip == BCM4301_DEVICE_ID) || (chip == BCM4307_DEVICE_ID))
3716 + if (chip == BCM4306_DEVICE_ID) /* < 4306c0 */
3718 + if (chip == BCM4704_DEVICE_ID)
3720 + if (chip == BCM5365_DEVICE_ID)
3723 + SB_ERROR(("sb_chip2numcores: unsupported chip 0x%x\n", chip));
3728 +/* return index of coreid or BADIDX if not found */
3730 +sb_findcoreidx( sb_info_t *si, uint coreid, uint coreunit)
3737 + for (i = 0; i < si->numcores; i++)
3738 + if (si->coreid[i] == coreid) {
3739 + if (found == coreunit)
3748 + * this function changes logical "focus" to the indiciated core,
3749 + * must be called with interrupt off.
3750 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
3753 +sb_setcoreidx(sb_t *sbh, uint coreidx)
3758 + si = SB_INFO(sbh);
3760 + if (coreidx >= si->numcores)
3764 + * If the user has provided an interrupt mask enabled function,
3765 + * then assert interrupts are disabled before switching the core.
3767 + ASSERT((si->intrsenabled_fn == NULL) || !(*(si)->intrsenabled_fn)((si)->intr_arg));
3769 + sbaddr = SB_ENUM_BASE + (coreidx * SB_CORE_SIZE);
3771 + switch (BUSTYPE(si->sb.bustype)) {
3774 + if (!si->regs[coreidx]) {
3775 + si->regs[coreidx] = (void*)REG_MAP(sbaddr, SB_CORE_SIZE);
3776 + ASSERT(GOODREGS(si->regs[coreidx]));
3778 + si->curmap = si->regs[coreidx];
3782 + /* point bar0 window */
3783 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, 4, sbaddr);
3789 + if (!si->regs[coreidx]) {
3790 + si->regs[coreidx] = (void *)sbaddr;
3791 + ASSERT(GOODREGS(si->regs[coreidx]));
3793 + si->curmap = si->regs[coreidx];
3795 +#endif /* BCMJTAG */
3798 + si->curidx = coreidx;
3800 + return (si->curmap);
3804 + * this function changes logical "focus" to the indiciated core,
3805 + * must be called with interrupt off.
3806 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core
3809 +sb_setcore(sb_t *sbh, uint coreid, uint coreunit)
3814 + si = SB_INFO(sbh);
3815 + idx = sb_findcoreidx(si, coreid, coreunit);
3816 + if (!GOODIDX(idx))
3819 + return (sb_setcoreidx(sbh, idx));
3822 +/* return chip number */
3824 +BCMINITFN(sb_chip)(sb_t *sbh)
3828 + si = SB_INFO(sbh);
3829 + return (si->sb.chip);
3832 +/* return chip revision number */
3834 +BCMINITFN(sb_chiprev)(sb_t *sbh)
3838 + si = SB_INFO(sbh);
3839 + return (si->sb.chiprev);
3842 +/* return chip common revision number */
3844 +BCMINITFN(sb_chipcrev)(sb_t *sbh)
3848 + si = SB_INFO(sbh);
3849 + return (si->sb.ccrev);
3852 +/* return chip package option */
3854 +BCMINITFN(sb_chippkg)(sb_t *sbh)
3858 + si = SB_INFO(sbh);
3859 + return (si->sb.chippkg);
3862 +/* return PCI core rev. */
3864 +BCMINITFN(sb_pcirev)(sb_t *sbh)
3868 + si = SB_INFO(sbh);
3869 + return (si->sb.buscorerev);
3873 +BCMINITFN(sb_war16165)(sb_t *sbh)
3877 + si = SB_INFO(sbh);
3879 + return (PCI(si) && (si->sb.buscorerev <= 10));
3882 +/* return board vendor id */
3884 +BCMINITFN(sb_boardvendor)(sb_t *sbh)
3888 + si = SB_INFO(sbh);
3889 + return (si->sb.boardvendor);
3892 +/* return boardtype */
3894 +BCMINITFN(sb_boardtype)(sb_t *sbh)
3899 + si = SB_INFO(sbh);
3901 + if (BUSTYPE(si->sb.bustype) == SB_BUS && si->sb.boardtype == 0xffff) {
3902 + /* boardtype format is a hex string */
3903 + si->sb.boardtype = getintvar(NULL, "boardtype");
3905 + /* backward compatibility for older boardtype string format */
3906 + if ((si->sb.boardtype == 0) && (var = getvar(NULL, "boardtype"))) {
3907 + if (!strcmp(var, "bcm94710dev"))
3908 + si->sb.boardtype = BCM94710D_BOARD;
3909 + else if (!strcmp(var, "bcm94710ap"))
3910 + si->sb.boardtype = BCM94710AP_BOARD;
3911 + else if (!strcmp(var, "bu4710"))
3912 + si->sb.boardtype = BU4710_BOARD;
3913 + else if (!strcmp(var, "bcm94702mn"))
3914 + si->sb.boardtype = BCM94702MN_BOARD;
3915 + else if (!strcmp(var, "bcm94710r1"))
3916 + si->sb.boardtype = BCM94710R1_BOARD;
3917 + else if (!strcmp(var, "bcm94710r4"))
3918 + si->sb.boardtype = BCM94710R4_BOARD;
3919 + else if (!strcmp(var, "bcm94702cpci"))
3920 + si->sb.boardtype = BCM94702CPCI_BOARD;
3921 + else if (!strcmp(var, "bcm95380_rr"))
3922 + si->sb.boardtype = BCM95380RR_BOARD;
3926 + return (si->sb.boardtype);
3929 +/* return bus type of sbh device */
3935 + si = SB_INFO(sbh);
3936 + return (si->sb.bustype);
3939 +/* return bus core type */
3941 +sb_buscoretype(sb_t *sbh)
3945 + si = SB_INFO(sbh);
3947 + return (si->sb.buscoretype);
3950 +/* return bus core revision */
3952 +sb_buscorerev(sb_t *sbh)
3955 + si = SB_INFO(sbh);
3957 + return (si->sb.buscorerev);
3960 +/* return list of found cores */
3962 +sb_corelist(sb_t *sbh, uint coreid[])
3966 + si = SB_INFO(sbh);
3968 + bcopy((uchar*)si->coreid, (uchar*)coreid, (si->numcores * sizeof (uint)));
3969 + return (si->numcores);
3972 +/* return current register mapping */
3974 +sb_coreregs(sb_t *sbh)
3978 + si = SB_INFO(sbh);
3979 + ASSERT(GOODREGS(si->curmap));
3981 + return (si->curmap);
3985 +/* do buffered registers update */
3987 +sb_commit(sb_t *sbh)
3991 + uint intr_val = 0;
3993 + si = SB_INFO(sbh);
3995 + origidx = si->curidx;
3996 + ASSERT(GOODIDX(origidx));
3998 + INTR_OFF(si, intr_val);
4000 + /* switch over to chipcommon core if there is one, else use pci */
4001 + if (si->sb.ccrev != NOREV) {
4002 + chipcregs_t *ccregs = (chipcregs_t *)sb_setcore(sbh, SB_CC, 0);
4004 + /* do the buffer registers update */
4005 + W_REG(&ccregs->broadcastaddress, SB_COMMIT);
4006 + W_REG(&ccregs->broadcastdata, 0x0);
4007 + } else if (PCI(si)) {
4008 + sbpciregs_t *pciregs = (sbpciregs_t *)sb_setcore(sbh, SB_PCI, 0);
4010 + /* do the buffer registers update */
4011 + W_REG(&pciregs->bcastaddr, SB_COMMIT);
4012 + W_REG(&pciregs->bcastdata, 0x0);
4016 + /* restore core index */
4017 + sb_setcoreidx(sbh, origidx);
4018 + INTR_RESTORE(si, intr_val);
4021 +/* reset and re-enable a core */
4023 +sb_core_reset(sb_t *sbh, uint32 bits)
4027 + volatile uint32 dummy;
4029 + si = SB_INFO(sbh);
4030 + ASSERT(GOODREGS(si->curmap));
4031 + sb = REGS2SB(si->curmap);
4034 + * Must do the disable sequence first to work for arbitrary current core state.
4036 + sb_core_disable(sbh, bits);
4039 + * Now do the initialization sequence.
4042 + /* set reset while enabling the clock and forcing them on throughout the core */
4043 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | SBTML_RESET | bits));
4044 + dummy = R_SBREG(si, &sb->sbtmstatelow);
4047 + if (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_SERR) {
4048 + W_SBREG(si, &sb->sbtmstatehigh, 0);
4050 + if ((dummy = R_SBREG(si, &sb->sbimstate)) & (SBIM_IBE | SBIM_TO)) {
4051 + AND_SBREG(si, &sb->sbimstate, ~(SBIM_IBE | SBIM_TO));
4054 + /* clear reset and allow it to propagate throughout the core */
4055 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | bits));
4056 + dummy = R_SBREG(si, &sb->sbtmstatelow);
4059 + /* leave clock enabled */
4060 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_CLK | bits));
4061 + dummy = R_SBREG(si, &sb->sbtmstatelow);
4066 +sb_core_tofixup(sb_t *sbh)
4071 + si = SB_INFO(sbh);
4073 + if ( (BUSTYPE(si->sb.bustype) != PCI_BUS) || (PCI(si) && (si->sb.buscorerev >= 5)) )
4076 + ASSERT(GOODREGS(si->curmap));
4077 + sb = REGS2SB(si->curmap);
4079 + if (BUSTYPE(si->sb.bustype) == SB_BUS) {
4080 + SET_SBREG(si, &sb->sbimconfiglow,
4081 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
4082 + (0x5 << SBIMCL_RTO_SHIFT) | 0x3);
4084 + if (sb_coreid(sbh) == SB_PCI) {
4085 + SET_SBREG(si, &sb->sbimconfiglow,
4086 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
4087 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
4089 + SET_SBREG(si, &sb->sbimconfiglow, (SBIMCL_RTO_MASK | SBIMCL_STO_MASK), 0);
4097 + * Set the initiator timeout for the "master core".
4098 + * The master core is defined to be the core in control
4099 + * of the chip and so it issues accesses to non-memory
4100 + * locations (Because of dma *any* core can access memeory).
4102 + * The routine uses the bus to decide who is the master:
4104 + * JTAG_BUS => chipc
4107 + * This routine exists so callers can disable initiator
4108 + * timeouts so accesses to very slow devices like otp
4109 + * won't cause an abort. The routine allows arbitrary
4110 + * settings of the service and request timeouts, though.
4112 + * Returns the timeout state before changing it or -1
4116 +#define TO_MASK (SBIMCL_RTO_MASK | SBIMCL_STO_MASK)
4119 +sb_set_initiator_to(sb_t *sbh, uint32 to)
4122 + uint origidx, idx;
4123 + uint intr_val = 0;
4124 + uint32 tmp, ret = 0xffffffff;
4127 + si = SB_INFO(sbh);
4129 + if ((to & ~TO_MASK) != 0)
4132 + /* Figure out the master core */
4134 + switch (BUSTYPE(si->sb.bustype)) {
4136 + idx = si->sb.buscoreidx;
4142 + if ((idx = sb_findcoreidx(si, SB_MIPS33, 0)) == BADIDX)
4143 + idx = sb_findcoreidx(si, SB_MIPS, 0);
4148 + if (idx == BADIDX)
4151 + INTR_OFF(si, intr_val);
4152 + origidx = sb_coreidx(sbh);
4154 + sb = REGS2SB(sb_setcoreidx(sbh, idx));
4156 + tmp = R_SBREG(si, &sb->sbimconfiglow);
4157 + ret = tmp & TO_MASK;
4158 + W_SBREG(si, &sb->sbimconfiglow, (tmp & ~TO_MASK) | to);
4161 + sb_setcoreidx(sbh, origidx);
4162 + INTR_RESTORE(si, intr_val);
4167 +sb_core_disable(sb_t *sbh, uint32 bits)
4170 + volatile uint32 dummy;
4174 + si = SB_INFO(sbh);
4176 + ASSERT(GOODREGS(si->curmap));
4177 + sb = REGS2SB(si->curmap);
4179 + /* if core is already in reset, just return */
4180 + if (R_SBREG(si, &sb->sbtmstatelow) & SBTML_RESET)
4183 + /* reject value changed between sonics 2.2 and 2.3 */
4184 + if (si->sb.sonicsrev == SONICS_2_2)
4185 + rej = (1 << SBTML_REJ_SHIFT);
4187 + rej = (2 << SBTML_REJ_SHIFT);
4189 + /* if clocks are not enabled, put into reset and return */
4190 + if ((R_SBREG(si, &sb->sbtmstatelow) & SBTML_CLK) == 0)
4193 + /* set target reject and spin until busy is clear (preserve core-specific bits) */
4194 + OR_SBREG(si, &sb->sbtmstatelow, rej);
4195 + dummy = R_SBREG(si, &sb->sbtmstatelow);
4197 + SPINWAIT((R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_BUSY), 100000);
4199 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT) {
4200 + OR_SBREG(si, &sb->sbimstate, SBIM_RJ);
4201 + dummy = R_SBREG(si, &sb->sbimstate);
4203 + SPINWAIT((R_SBREG(si, &sb->sbimstate) & SBIM_BY), 100000);
4206 + /* set reset and reject while enabling the clocks */
4207 + W_SBREG(si, &sb->sbtmstatelow, (bits | SBTML_FGC | SBTML_CLK | rej | SBTML_RESET));
4208 + dummy = R_SBREG(si, &sb->sbtmstatelow);
4211 + /* don't forget to clear the initiator reject bit */
4212 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT)
4213 + AND_SBREG(si, &sb->sbimstate, ~SBIM_RJ);
4216 + /* leave reset and reject asserted */
4217 + W_SBREG(si, &sb->sbtmstatelow, (bits | rej | SBTML_RESET));
4221 +/* set chip watchdog reset timer to fire in 'ticks' backplane cycles */
4223 +sb_watchdog(sb_t *sbh, uint ticks)
4225 + sb_info_t *si = SB_INFO(sbh);
4228 + switch (si->gpioid) {
4230 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, watchdog), ~0, ticks);
4233 + sb_corereg(si, si->gpioidx, OFFSETOF(extifregs_t, watchdog), ~0, ticks);
4240 + * Configure the pci core for pci client (NIC) action
4241 + * coremask is the bitvec of cores by index to be enabled.
4244 +sb_pci_setup(sb_t *sbh, uint coremask)
4248 + sbpciregs_t *pciregs;
4253 + si = SB_INFO(sbh);
4255 + /* if not pci bus, we're done */
4256 + if (BUSTYPE(si->sb.bustype) != PCI_BUS)
4260 + ASSERT(si->sb.buscoreidx != BADIDX);
4262 + /* get current core index */
4265 + /* we interrupt on this backplane flag number */
4266 + ASSERT(GOODREGS(si->curmap));
4267 + sb = REGS2SB(si->curmap);
4268 + sbflag = R_SBREG(si, &sb->sbtpsflag) & SBTPS_NUM0_MASK;
4270 + /* switch over to pci core */
4271 + pciregs = (sbpciregs_t*) sb_setcoreidx(sbh, si->sb.buscoreidx);
4272 + sb = REGS2SB(pciregs);
4275 + * Enable sb->pci interrupts. Assume
4276 + * PCI rev 2.3 support was added in pci core rev 6 and things changed..
4278 + if ((PCI(si) && ((si->sb.buscorerev) >= 6))) {
4279 + /* pci config write to set this core bit in PCIIntMask */
4280 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32));
4281 + w |= (coremask << PCI_SBIM_SHIFT);
4282 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32), w);
4284 + /* set sbintvec bit for our flag number */
4285 + OR_SBREG(si, &sb->sbintvec, (1 << sbflag));
4289 + OR_REG(&pciregs->sbtopci2, (SBTOPCI_PREF|SBTOPCI_BURST));
4290 + if (si->sb.buscorerev >= 11)
4291 + OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI);
4292 + if (si->sb.buscorerev < 5) {
4293 + SET_SBREG(si, &sb->sbimconfiglow, SBIMCL_RTO_MASK | SBIMCL_STO_MASK,
4294 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2);
4299 + /* switch back to previous core */
4300 + sb_setcoreidx(sbh, idx);
4304 +sb_base(uint32 admatch)
4309 + type = admatch & SBAM_TYPE_MASK;
4315 + base = admatch & SBAM_BASE0_MASK;
4316 + } else if (type == 1) {
4317 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
4318 + base = admatch & SBAM_BASE1_MASK;
4319 + } else if (type == 2) {
4320 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
4321 + base = admatch & SBAM_BASE2_MASK;
4328 +sb_size(uint32 admatch)
4333 + type = admatch & SBAM_TYPE_MASK;
4339 + size = 1 << (((admatch & SBAM_ADINT0_MASK) >> SBAM_ADINT0_SHIFT) + 1);
4340 + } else if (type == 1) {
4341 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
4342 + size = 1 << (((admatch & SBAM_ADINT1_MASK) >> SBAM_ADINT1_SHIFT) + 1);
4343 + } else if (type == 2) {
4344 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */
4345 + size = 1 << (((admatch & SBAM_ADINT2_MASK) >> SBAM_ADINT2_SHIFT) + 1);
4351 +/* return the core-type instantiation # of the current core */
4353 +sb_coreunit(sb_t *sbh)
4361 + si = SB_INFO(sbh);
4366 + ASSERT(GOODREGS(si->curmap));
4367 + coreid = sb_coreid(sbh);
4369 + /* count the cores of our type */
4370 + for (i = 0; i < idx; i++)
4371 + if (si->coreid[i] == coreid)
4374 + return (coreunit);
4377 +static INLINE uint32
4381 + case CC_F6_2: return 2;
4382 + case CC_F6_3: return 3;
4383 + case CC_F6_4: return 4;
4384 + case CC_F6_5: return 5;
4385 + case CC_F6_6: return 6;
4386 + case CC_F6_7: return 7;
4387 + default: return 0;
4391 +/* calculate the speed the SB would run at given a set of clockcontrol values */
4393 +sb_clock_rate(uint32 pll_type, uint32 n, uint32 m)
4395 + uint32 n1, n2, clock, m1, m2, m3, mc;
4397 + n1 = n & CN_N1_MASK;
4398 + n2 = (n & CN_N2_MASK) >> CN_N2_SHIFT;
4400 + if (pll_type == PLL_TYPE6) {
4401 + if (m & CC_T6_MMASK)
4405 + } else if ((pll_type == PLL_TYPE1) ||
4406 + (pll_type == PLL_TYPE3) ||
4407 + (pll_type == PLL_TYPE4) ||
4408 + (pll_type == PLL_TYPE7)) {
4411 + } else if (pll_type == PLL_TYPE2) {
4414 + ASSERT((n1 >= 2) && (n1 <= 7));
4415 + ASSERT((n2 >= 5) && (n2 <= 23));
4416 + } else if (pll_type == PLL_TYPE5) {
4417 + return (100000000);
4420 + /* PLL types 3 and 7 use BASE2 (25Mhz) */
4421 + if ((pll_type == PLL_TYPE3) ||
4422 + (pll_type == PLL_TYPE7)) {
4423 + clock = CC_CLOCK_BASE2 * n1 * n2;
4426 + clock = CC_CLOCK_BASE1 * n1 * n2;
4431 + m1 = m & CC_M1_MASK;
4432 + m2 = (m & CC_M2_MASK) >> CC_M2_SHIFT;
4433 + m3 = (m & CC_M3_MASK) >> CC_M3_SHIFT;
4434 + mc = (m & CC_MC_MASK) >> CC_MC_SHIFT;
4436 + if ((pll_type == PLL_TYPE1) ||
4437 + (pll_type == PLL_TYPE3) ||
4438 + (pll_type == PLL_TYPE4) ||
4439 + (pll_type == PLL_TYPE7)) {
4441 + if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE3))
4448 + case CC_MC_BYPASS: return (clock);
4449 + case CC_MC_M1: return (clock / m1);
4450 + case CC_MC_M1M2: return (clock / (m1 * m2));
4451 + case CC_MC_M1M2M3: return (clock / (m1 * m2 * m3));
4452 + case CC_MC_M1M3: return (clock / (m1 * m3));
4453 + default: return (0);
4456 + ASSERT(pll_type == PLL_TYPE2);
4459 + m2 += CC_T2M2_BIAS;
4461 + ASSERT((m1 >= 2) && (m1 <= 7));
4462 + ASSERT((m2 >= 3) && (m2 <= 10));
4463 + ASSERT((m3 >= 2) && (m3 <= 7));
4465 + if ((mc & CC_T2MC_M1BYP) == 0)
4467 + if ((mc & CC_T2MC_M2BYP) == 0)
4469 + if ((mc & CC_T2MC_M3BYP) == 0)
4476 +/* returns the current speed the SB is running at */
4478 +sb_clock(sb_t *sbh)
4485 + uint32 pll_type, rate;
4486 + uint intr_val = 0;
4488 + si = SB_INFO(sbh);
4490 + pll_type = PLL_TYPE1;
4492 + INTR_OFF(si, intr_val);
4494 + /* switch to extif or chipc core */
4495 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) {
4496 + n = R_REG(&eir->clockcontrol_n);
4497 + m = R_REG(&eir->clockcontrol_sb);
4498 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) {
4499 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK;
4500 + n = R_REG(&cc->clockcontrol_n);
4501 + if (pll_type == PLL_TYPE6)
4502 + m = R_REG(&cc->clockcontrol_mips);
4503 + else if (pll_type == PLL_TYPE3)
4505 + // Added by Chen-I for 5365
4506 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
4507 + m = R_REG(&cc->clockcontrol_sb);
4509 + m = R_REG(&cc->clockcontrol_m2);
4512 + m = R_REG(&cc->clockcontrol_sb);
4514 + INTR_RESTORE(si, intr_val);
4518 + // Added by Chen-I for 5365
4519 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID)
4525 + /* calculate rate */
4526 + rate = sb_clock_rate(pll_type, n, m);
4527 + if (pll_type == PLL_TYPE3)
4531 + /* switch back to previous core */
4532 + sb_setcoreidx(sbh, idx);
4534 + INTR_RESTORE(si, intr_val);
4539 +/* change logical "focus" to the gpio core for optimized access */
4541 +sb_gpiosetcore(sb_t *sbh)
4545 + si = SB_INFO(sbh);
4547 + return (sb_setcoreidx(sbh, si->gpioidx));
4550 +/* mask&set gpiocontrol bits */
4552 +sb_gpiocontrol(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4557 + si = SB_INFO(sbh);
4560 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4562 + /* gpios could be shared on router platforms */
4563 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4564 + mask = priority ? (sb_gpioreservation & mask) :
4565 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4569 + switch (si->gpioid) {
4571 + regoff = OFFSETOF(chipcregs_t, gpiocontrol);
4575 + regoff = OFFSETOF(sbpciregs_t, gpiocontrol);
4582 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4585 +/* mask&set gpio output enable bits */
4587 +sb_gpioouten(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4592 + si = SB_INFO(sbh);
4595 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4597 + /* gpios could be shared on router platforms */
4598 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4599 + mask = priority ? (sb_gpioreservation & mask) :
4600 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4604 + switch (si->gpioid) {
4606 + regoff = OFFSETOF(chipcregs_t, gpioouten);
4610 + regoff = OFFSETOF(sbpciregs_t, gpioouten);
4614 + regoff = OFFSETOF(extifregs_t, gpio[0].outen);
4618 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4621 +/* mask&set gpio output bits */
4623 +sb_gpioout(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4628 + si = SB_INFO(sbh);
4631 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4633 + /* gpios could be shared on router platforms */
4634 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4635 + mask = priority ? (sb_gpioreservation & mask) :
4636 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4640 + switch (si->gpioid) {
4642 + regoff = OFFSETOF(chipcregs_t, gpioout);
4646 + regoff = OFFSETOF(sbpciregs_t, gpioout);
4650 + regoff = OFFSETOF(extifregs_t, gpio[0].out);
4654 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4657 +/* reserve one gpio */
4659 +sb_gpioreserve(sb_t *sbh, uint32 gpio_bitmask, uint8 priority)
4663 + si = SB_INFO(sbh);
4665 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4667 + /* only cores on SB_BUS share GPIO's and only applcation users need to reserve/release GPIO */
4668 + if ( (BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) {
4669 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority));
4672 + /* make sure only one bit is set */
4673 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) {
4674 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1)));
4678 + /* already reserved */
4679 + if (sb_gpioreservation & gpio_bitmask)
4681 + /* set reservation */
4682 + sb_gpioreservation |= gpio_bitmask;
4684 + return sb_gpioreservation;
4687 +/* release one gpio */
4689 + * releasing the gpio doesn't change the current value on the GPIO last write value
4690 + * persists till some one overwrites it
4694 +sb_gpiorelease(sb_t *sbh, uint32 gpio_bitmask, uint8 priority)
4698 + si = SB_INFO(sbh);
4700 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4702 + /* only cores on SB_BUS share GPIO's and only applcation users need to reserve/release GPIO */
4703 + if ( (BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) {
4704 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority));
4707 + /* make sure only one bit is set */
4708 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) {
4709 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1)));
4713 + /* already released */
4714 + if (!(sb_gpioreservation & gpio_bitmask))
4717 + /* clear reservation */
4718 + sb_gpioreservation &= ~gpio_bitmask;
4720 + return sb_gpioreservation;
4723 +/* return the current gpioin register value */
4725 +sb_gpioin(sb_t *sbh)
4730 + si = SB_INFO(sbh);
4733 + switch (si->gpioid) {
4735 + regoff = OFFSETOF(chipcregs_t, gpioin);
4739 + regoff = OFFSETOF(sbpciregs_t, gpioin);
4743 + regoff = OFFSETOF(extifregs_t, gpioin);
4747 + return (sb_corereg(si, si->gpioidx, regoff, 0, 0));
4750 +/* mask&set gpio interrupt polarity bits */
4752 +sb_gpiointpolarity(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4757 + si = SB_INFO(sbh);
4760 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4762 + /* gpios could be shared on router platforms */
4763 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4764 + mask = priority ? (sb_gpioreservation & mask) :
4765 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4769 + switch (si->gpioid) {
4771 + regoff = OFFSETOF(chipcregs_t, gpiointpolarity);
4775 + /* pci gpio implementation does not support interrupt polarity */
4780 + regoff = OFFSETOF(extifregs_t, gpiointpolarity);
4784 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4787 +/* mask&set gpio interrupt mask bits */
4789 +sb_gpiointmask(sb_t *sbh, uint32 mask, uint32 val, uint8 priority)
4794 + si = SB_INFO(sbh);
4797 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */
4799 + /* gpios could be shared on router platforms */
4800 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) {
4801 + mask = priority ? (sb_gpioreservation & mask) :
4802 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation));
4806 + switch (si->gpioid) {
4808 + regoff = OFFSETOF(chipcregs_t, gpiointmask);
4812 + /* pci gpio implementation does not support interrupt mask */
4817 + regoff = OFFSETOF(extifregs_t, gpiointmask);
4821 + return (sb_corereg(si, si->gpioidx, regoff, mask, val));
4824 +/* assign the gpio to an led */
4826 +sb_gpioled(sb_t *sbh, uint32 mask, uint32 val)
4830 + si = SB_INFO(sbh);
4831 + if (si->sb.ccrev < 16)
4834 + /* gpio led powersave reg */
4835 + return(sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimeroutmask), mask, val));
4838 +/* mask&set gpio timer val */
4840 +sb_gpiotimerval(sb_t *sbh, uint32 mask, uint32 gpiotimerval)
4843 + si = SB_INFO(sbh);
4845 + if (si->sb.ccrev < 16)
4848 + return(sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), mask, gpiotimerval));
4852 +/* return the slow clock source - LPO, XTAL, or PCI */
4854 +sb_slowclk_src(sb_info_t *si)
4859 + ASSERT(sb_coreid(&si->sb) == SB_CC);
4861 + if (si->sb.ccrev < 6) {
4862 + if ((BUSTYPE(si->sb.bustype) == PCI_BUS)
4863 + && (OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32)) & PCI_CFG_GPIO_SCS))
4864 + return (SCC_SS_PCI);
4866 + return (SCC_SS_XTAL);
4867 + } else if (si->sb.ccrev < 10) {
4868 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx);
4869 + return (R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK);
4870 + } else /* Insta-clock */
4871 + return (SCC_SS_XTAL);
4874 +/* return the ILP (slowclock) min or max frequency */
4876 +sb_slowclk_freq(sb_info_t *si, bool max)
4883 + ASSERT(sb_coreid(&si->sb) == SB_CC);
4885 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx);
4887 + /* shouldn't be here unless we've established the chip has dynamic clk control */
4888 + ASSERT(R_REG(&cc->capabilities) & CAP_PWR_CTL);
4890 + slowclk = sb_slowclk_src(si);
4891 + if (si->sb.ccrev < 6) {
4892 + if (slowclk == SCC_SS_PCI)
4893 + return (max? (PCIMAXFREQ/64) : (PCIMINFREQ/64));
4895 + return (max? (XTALMAXFREQ/32) : (XTALMINFREQ/32));
4896 + } else if (si->sb.ccrev < 10) {
4897 + div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
4898 + if (slowclk == SCC_SS_LPO)
4899 + return (max? LPOMAXFREQ : LPOMINFREQ);
4900 + else if (slowclk == SCC_SS_XTAL)
4901 + return (max? (XTALMAXFREQ/div) : (XTALMINFREQ/div));
4902 + else if (slowclk == SCC_SS_PCI)
4903 + return (max? (PCIMAXFREQ/div) : (PCIMINFREQ/div));
4907 + /* Chipc rev 10 is InstaClock */
4908 + div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHIFT;
4909 + div = 4 * (div + 1);
4910 + return (max ? XTALMAXFREQ : (XTALMINFREQ/div));
4916 +sb_clkctl_setdelay(sb_info_t *si, void *chipcregs)
4919 + uint slowmaxfreq, pll_delay, slowclk;
4920 + uint pll_on_delay, fref_sel_delay;
4922 + pll_delay = PLL_DELAY;
4924 + /* If the slow clock is not sourced by the xtal then add the xtal_on_delay
4925 + * since the xtal will also be powered down by dynamic clk control logic.
4927 + slowclk = sb_slowclk_src(si);
4928 + if (slowclk != SCC_SS_XTAL)
4929 + pll_delay += XTAL_ON_DELAY;
4931 + /* Starting with 4318 it is ILP that is used for the delays */
4932 + slowmaxfreq = sb_slowclk_freq(si, (si->sb.ccrev >= 10) ? FALSE : TRUE);
4934 + pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000;
4935 + fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000;
4937 + cc = (chipcregs_t *)chipcregs;
4938 + W_REG(&cc->pll_on_delay, pll_on_delay);
4939 + W_REG(&cc->fref_sel_delay, fref_sel_delay);
4943 +sb_pwrctl_slowclk(void *sbh, bool set, uint *div)
4948 + uint intr_val = 0;
4951 + si = SB_INFO(sbh);
4953 + /* chipcommon cores prior to rev6 don't support slowclkcontrol */
4954 + if (si->sb.ccrev < 6)
4957 + /* chipcommon cores rev10 are a whole new ball game */
4958 + if (si->sb.ccrev >= 10)
4961 + if (set && ((*div % 4) || (*div < 4)))
4964 + INTR_OFF(si, intr_val);
4965 + origidx = si->curidx;
4966 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
4967 + ASSERT(cc != NULL);
4969 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL)) {
4975 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, ((*div / 4 - 1) << SCC_CD_SHIFT));
4976 + sb_clkctl_setdelay(sbh, (void *)cc);
4978 + *div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
4981 + sb_setcoreidx(sbh, origidx);
4982 + INTR_RESTORE(si, intr_val);
4986 +/* initialize power control delay registers */
4987 +void sb_clkctl_init(sb_t *sbh)
4993 + si = SB_INFO(sbh);
4995 + origidx = si->curidx;
4997 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
5000 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
5003 + /* set all Instaclk chip ILP to 1 MHz */
5004 + if (si->sb.ccrev >= 10)
5005 + SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK, (ILP_DIV_1MHZ << SYCC_CD_SHIFT));
5007 + sb_clkctl_setdelay(si, (void *)cc);
5010 + sb_setcoreidx(sbh, origidx);
5012 +void sb_pwrctl_init(sb_t *sbh)
5014 +sb_clkctl_init(sbh);
5016 +/* return the value suitable for writing to the dot11 core FAST_PWRUP_DELAY register */
5018 +sb_clkctl_fast_pwrup_delay(sb_t *sbh)
5025 + uint intr_val = 0;
5027 + si = SB_INFO(sbh);
5029 + origidx = si->curidx;
5031 + INTR_OFF(si, intr_val);
5033 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL)
5036 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
5039 + slowminfreq = sb_slowclk_freq(si, FALSE);
5040 + fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + (slowminfreq - 1)) / slowminfreq;
5043 + sb_setcoreidx(sbh, origidx);
5044 + INTR_RESTORE(si, intr_val);
5047 +uint16 sb_pwrctl_fast_pwrup_delay(sb_t *sbh)
5049 +return sb_clkctl_fast_pwrup_delay(sbh);
5051 +/* turn primary xtal and/or pll off/on */
5053 +sb_clkctl_xtal(sb_t *sbh, uint what, bool on)
5056 + uint32 in, out, outen;
5058 + si = SB_INFO(sbh);
5060 + switch (BUSTYPE(si->sb.bustype)) {
5063 + in = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_IN, sizeof (uint32));
5064 + out = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32));
5065 + outen = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32));
5068 + * Avoid glitching the clock if GPRS is already using it.
5069 + * We can't actually read the state of the PLLPD so we infer it
5070 + * by the value of XTAL_PU which *is* readable via gpioin.
5072 + if (on && (in & PCI_CFG_GPIO_XTAL))
5076 + outen |= PCI_CFG_GPIO_XTAL;
5078 + outen |= PCI_CFG_GPIO_PLL;
5081 + /* turn primary xtal on */
5082 + if (what & XTAL) {
5083 + out |= PCI_CFG_GPIO_XTAL;
5085 + out |= PCI_CFG_GPIO_PLL;
5086 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
5087 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
5088 + OSL_DELAY(XTAL_ON_DELAY);
5093 + out &= ~PCI_CFG_GPIO_PLL;
5094 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
5099 + out &= ~PCI_CFG_GPIO_XTAL;
5101 + out |= PCI_CFG_GPIO_PLL;
5102 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out);
5103 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen);
5113 +int sb_pwrctl_xtal(sb_t *sbh, uint what, bool on)
5115 +return sb_clkctl_xtal(sbh,what,on);
5118 +/* set dynamic clk control mode (forceslow, forcefast, dynamic) */
5119 +/* returns true if ignore pll off is set and false if it is not */
5121 +sb_clkctl_clk(sb_t *sbh, uint mode)
5127 + bool forcefastclk=FALSE;
5128 + uint intr_val = 0;
5130 + si = SB_INFO(sbh);
5132 + /* chipcommon cores prior to rev6 don't support dynamic clock control */
5133 + if (si->sb.ccrev < 6)
5136 + /* chipcommon cores rev10 are a whole new ball game */
5137 + if (si->sb.ccrev >= 10)
5140 + INTR_OFF(si, intr_val);
5142 + origidx = si->curidx;
5144 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0);
5145 + ASSERT(cc != NULL);
5147 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL))
5151 + case CLK_FAST: /* force fast (pll) clock */
5152 + /* don't forget to force xtal back on before we clear SCC_DYN_XTAL.. */
5153 + sb_clkctl_xtal(&si->sb, XTAL, ON);
5155 + SET_REG(&cc->slow_clk_ctl, (SCC_XC | SCC_FS | SCC_IP), SCC_IP);
5158 + case CLK_DYNAMIC: /* enable dynamic clock control */
5159 + scc = R_REG(&cc->slow_clk_ctl);
5160 + scc &= ~(SCC_FS | SCC_IP | SCC_XC);
5161 + if ((scc & SCC_SS_MASK) != SCC_SS_XTAL)
5163 + W_REG(&cc->slow_clk_ctl, scc);
5165 + /* for dynamic control, we have to release our xtal_pu "force on" */
5167 + sb_clkctl_xtal(&si->sb, XTAL, OFF);
5174 + /* Is the h/w forcing the use of the fast clk */
5175 + forcefastclk = (bool)((R_REG(&cc->slow_clk_ctl) & SCC_IP) == SCC_IP);
5178 + sb_setcoreidx(sbh, origidx);
5179 + INTR_RESTORE(si, intr_val);
5180 + return (forcefastclk);
5183 +bool sb_pwrctl_clk(sb_t *sbh, uint mode)
5185 +return sb_clkctl_clk(sbh, mode);
5187 +/* register driver interrupt disabling and restoring callback functions */
5189 +sb_register_intr_callback(sb_t *sbh, void *intrsoff_fn, void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg)
5193 + si = SB_INFO(sbh);
5194 + si->intr_arg = intr_arg;
5195 + si->intrsoff_fn = (sb_intrsoff_t)intrsoff_fn;
5196 + si->intrsrestore_fn = (sb_intrsrestore_t)intrsrestore_fn;
5197 + si->intrsenabled_fn = (sb_intrsenabled_t)intrsenabled_fn;
5198 + /* save current core id. when this function called, the current core
5199 + * must be the core which provides driver functions(il, et, wl, etc.)
5201 + si->dev_coreid = si->coreid[si->curidx];
5206 +sb_corepciid(sb_t *sbh, uint16 *pcivendor, uint16 *pcidevice,
5207 + uint8 *pciclass, uint8 *pcisubclass, uint8 *pciprogif)
5209 + uint vendor, core, unit;
5210 + uint chip, chippkg;
5212 + uint8 class, subclass, progif;
5214 + vendor = sb_corevendor(sbh);
5215 + core = sb_coreid(sbh);
5216 + unit = sb_coreunit(sbh);
5218 + chip = BCMINIT(sb_chip)(sbh);
5219 + chippkg = BCMINIT(sb_chippkg)(sbh);
5223 + /* Known vendor translations */
5226 + vendor = VENDOR_BROADCOM;
5230 + /* Determine class based on known core codes */
5233 + class = PCI_CLASS_NET;
5234 + subclass = PCI_NET_ETHER;
5235 + core = BCM47XX_ILINE_ID;
5238 + class = PCI_CLASS_NET;
5239 + subclass = PCI_NET_ETHER;
5240 + core = BCM47XX_ENET_ID;
5244 + class = PCI_CLASS_MEMORY;
5245 + subclass = PCI_MEMORY_RAM;
5248 + class = PCI_CLASS_BRIDGE;
5249 + subclass = PCI_BRIDGE_PCI;
5253 + class = PCI_CLASS_CPU;
5254 + subclass = PCI_CPU_MIPS;
5257 + class = PCI_CLASS_COMM;
5258 + subclass = PCI_COMM_MODEM;
5259 + core = BCM47XX_V90_ID;
5262 + class = PCI_CLASS_SERIAL;
5263 + subclass = PCI_SERIAL_USB;
5264 + progif = 0x10; /* OHCI */
5265 + core = BCM47XX_USB_ID;
5268 + class = PCI_CLASS_SERIAL;
5269 + subclass = PCI_SERIAL_USB;
5270 + progif = 0x10; /* OHCI */
5271 + core = BCM47XX_USBH_ID;
5274 + class = PCI_CLASS_SERIAL;
5275 + subclass = PCI_SERIAL_USB;
5276 + core = BCM47XX_USBD_ID;
5279 + class = PCI_CLASS_CRYPT;
5280 + subclass = PCI_CRYPT_NETWORK;
5281 + core = BCM47XX_IPSEC_ID;
5284 + class = PCI_CLASS_NET;
5285 + subclass = PCI_NET_OTHER;
5286 + core = BCM47XX_ROBO_ID;
5290 + class = PCI_CLASS_MEMORY;
5291 + subclass = PCI_MEMORY_FLASH;
5294 + class = PCI_CLASS_NET;
5295 + subclass = PCI_NET_OTHER;
5296 + /* Let an nvram variable override this */
5297 + sprintf(varname, "wl%did", unit);
5298 + if ((core = getintvar(NULL, varname)) == 0) {
5299 + if (chip == BCM4712_DEVICE_ID) {
5300 + if (chippkg == BCM4712SMALL_PKG_ID)
5301 + core = BCM4306_D11G_ID;
5303 + core = BCM4306_D11DUAL_ID;
5309 + class = subclass = progif = 0xff;
5313 + *pcivendor = (uint16)vendor;
5314 + *pcidevice = (uint16)core;
5315 + *pciclass = class;
5316 + *pcisubclass = subclass;
5317 + *pciprogif = progif;
5320 +/* Fix chip's configuration. The current core may be changed upon return */
5322 +sb_pci_fixcfg(sb_info_t *si)
5324 + uint origidx, pciidx;
5325 + sbpciregs_t *pciregs;
5326 + uint16 val16, *reg16;
5328 + ASSERT(BUSTYPE(si->sb.bustype) == PCI_BUS);
5330 + /* Fix PCI(e) SROM shadow area */
5331 + /* save the current index */
5332 + origidx = sb_coreidx(&si->sb);
5334 + if (si->sb.buscoretype == SB_PCI) {
5335 + pciregs = (sbpciregs_t *)sb_setcore(&si->sb, SB_PCI, 0);
5337 + reg16 = &pciregs->sprom[SRSH_PI_OFFSET];
5343 + pciidx = sb_coreidx(&si->sb);
5344 + val16 = R_REG(reg16);
5345 + if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (uint16)pciidx) {
5346 + val16 = (uint16)(pciidx << SRSH_PI_SHIFT) | (val16 & ~SRSH_PI_MASK);
5347 + W_REG(reg16, val16);
5350 + /* restore the original index */
5351 + sb_setcoreidx(&si->sb, origidx);
5356 +EXPORT_SYMBOL(sb_boardtype);
5357 +EXPORT_SYMBOL(sb_boardvendor);
5358 +EXPORT_SYMBOL(sb_gpiocontrol);
5359 +EXPORT_SYMBOL(sb_gpioin);
5360 +EXPORT_SYMBOL(sb_gpiointmask);
5361 +EXPORT_SYMBOL(sb_gpiointpolarity);
5362 +EXPORT_SYMBOL(sb_gpioled);
5363 +EXPORT_SYMBOL(sb_gpioout);
5364 +EXPORT_SYMBOL(sb_gpioouten);
5365 +EXPORT_SYMBOL(sb_gpiorelease);
5366 +EXPORT_SYMBOL(sb_gpioreserve);
5367 +EXPORT_SYMBOL(sb_gpiosetcore);
5368 +EXPORT_SYMBOL(sb_gpiotimerval);
5369 +EXPORT_SYMBOL(sb_watchdog);
5370 diff -urN linux.old/arch/mips/bcm947xx/broadcom/sflash.c linux.dev/arch/mips/bcm947xx/broadcom/sflash.c
5371 --- linux.old/arch/mips/bcm947xx/broadcom/sflash.c 1970-01-01 01:00:00.000000000 +0100
5372 +++ linux.dev/arch/mips/bcm947xx/broadcom/sflash.c 2005-12-15 16:59:20.045933750 +0100
5375 + * Broadcom SiliconBackplane chipcommon serial flash interface
5377 + * Copyright 2005, Broadcom Corporation
5378 + * All Rights Reserved.
5380 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5381 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5382 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5383 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5389 +#include <typedefs.h>
5390 +#include <sbconfig.h>
5391 +#include <sbchipc.h>
5392 +#include <mipsinc.h>
5393 +#include <bcmutils.h>
5394 +#include <bcmdevs.h>
5395 +#include <sflash.h>
5397 +/* Private global state */
5398 +static struct sflash sflash;
5400 +/* Issue a serial flash command */
5402 +sflash_cmd(chipcregs_t *cc, uint opcode)
5404 + W_REG(&cc->flashcontrol, SFLASH_START | opcode);
5405 + while (R_REG(&cc->flashcontrol) & SFLASH_BUSY);
5408 +/* Initialize serial flash access */
5410 +sflash_init(chipcregs_t *cc)
5414 + bzero(&sflash, sizeof(sflash));
5416 + sflash.type = R_REG(&cc->capabilities) & CAP_FLASH_MASK;
5418 + switch (sflash.type) {
5420 + /* Probe for ST chips */
5421 + sflash_cmd(cc, SFLASH_ST_DP);
5422 + sflash_cmd(cc, SFLASH_ST_RES);
5423 + id = R_REG(&cc->flashdata);
5426 + /* ST M25P20 2 Mbit Serial Flash */
5427 + sflash.blocksize = 64 * 1024;
5428 + sflash.numblocks = 4;
5431 + /* ST M25P40 4 Mbit Serial Flash */
5432 + sflash.blocksize = 64 * 1024;
5433 + sflash.numblocks = 8;
5436 + /* ST M25P80 8 Mbit Serial Flash */
5437 + sflash.blocksize = 64 * 1024;
5438 + sflash.numblocks = 16;
5441 + /* ST M25P16 16 Mbit Serial Flash */
5442 + sflash.blocksize = 64 * 1024;
5443 + sflash.numblocks = 32;
5446 + /* ST M25P32 32 Mbit Serial Flash */
5447 + sflash.blocksize = 64 * 1024;
5448 + sflash.numblocks = 64;
5451 + W_REG(&cc->flashaddress, 1);
5452 + sflash_cmd(cc, SFLASH_ST_RES);
5453 + id2 = R_REG(&cc->flashdata);
5454 + if (id2 == 0x44) {
5455 + /* SST M25VF80 4 Mbit Serial Flash */
5456 + sflash.blocksize = 64 * 1024;
5457 + sflash.numblocks = 8;
5464 + /* Probe for Atmel chips */
5465 + sflash_cmd(cc, SFLASH_AT_STATUS);
5466 + id = R_REG(&cc->flashdata) & 0x3c;
5469 + /* Atmel AT45DB011 1Mbit Serial Flash */
5470 + sflash.blocksize = 256;
5471 + sflash.numblocks = 512;
5474 + /* Atmel AT45DB021 2Mbit Serial Flash */
5475 + sflash.blocksize = 256;
5476 + sflash.numblocks = 1024;
5479 + /* Atmel AT45DB041 4Mbit Serial Flash */
5480 + sflash.blocksize = 256;
5481 + sflash.numblocks = 2048;
5484 + /* Atmel AT45DB081 8Mbit Serial Flash */
5485 + sflash.blocksize = 256;
5486 + sflash.numblocks = 4096;
5489 + /* Atmel AT45DB161 16Mbit Serial Flash */
5490 + sflash.blocksize = 512;
5491 + sflash.numblocks = 4096;
5494 + /* Atmel AT45DB321 32Mbit Serial Flash */
5495 + sflash.blocksize = 512;
5496 + sflash.numblocks = 8192;
5499 + /* Atmel AT45DB642 64Mbit Serial Flash */
5500 + sflash.blocksize = 1024;
5501 + sflash.numblocks = 8192;
5507 + sflash.size = sflash.blocksize * sflash.numblocks;
5508 + return sflash.size ? &sflash : NULL;
5511 +/* Read len bytes starting at offset into buf. Returns number of bytes read. */
5513 +sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf)
5516 + uint32 *from, *to;
5521 + if ((offset + len) > sflash.size)
5524 + if ((len >= 4) && (offset & 3))
5525 + cnt = 4 - (offset & 3);
5526 + else if ((len >= 4) && ((uint32)buf & 3))
5527 + cnt = 4 - ((uint32)buf & 3);
5531 + from = (uint32 *)KSEG1ADDR(SB_FLASH2 + offset);
5532 + to = (uint32 *)buf;
5535 + bcopy(from, to, cnt);
5539 + while (cnt >= 4) {
5544 + return (len - cnt);
5547 +/* Poll for command completion. Returns zero when complete. */
5549 +sflash_poll(chipcregs_t *cc, uint offset)
5551 + if (offset >= sflash.size)
5554 + switch (sflash.type) {
5556 + /* Check for ST Write In Progress bit */
5557 + sflash_cmd(cc, SFLASH_ST_RDSR);
5558 + return R_REG(&cc->flashdata) & SFLASH_ST_WIP;
5560 + /* Check for Atmel Ready bit */
5561 + sflash_cmd(cc, SFLASH_AT_STATUS);
5562 + return !(R_REG(&cc->flashdata) & SFLASH_AT_READY);
5568 +/* Write len bytes starting at offset into buf. Returns number of bytes
5569 + * written. Caller should poll for completion.
5572 +sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf)
5574 + struct sflash *sfl;
5577 + uint32 page, byte, mask;
5582 + if ((offset + len) > sflash.size)
5586 + switch (sfl->type) {
5588 + mask = R_REG(&cc->chipid);
5589 + is4712b0 = (((mask & CID_ID_MASK) == BCM4712_DEVICE_ID) &&
5590 + ((mask & CID_REV_MASK) == (3 << CID_REV_SHIFT)));
5591 + /* Enable writes */
5592 + sflash_cmd(cc, SFLASH_ST_WREN);
5595 + W_REG(&cc->flashaddress, offset);
5596 + W_REG(&cc->flashdata, *buf++);
5597 + /* Set chip select */
5598 + OR_REG(&cc->gpioout, mask);
5599 + /* Issue a page program with the first byte */
5600 + sflash_cmd(cc, SFLASH_ST_PP);
5605 + if ((offset & 255) == 0) {
5606 + /* Page boundary, drop cs and return */
5607 + AND_REG(&cc->gpioout, ~mask);
5608 + if (!sflash_poll(cc, offset)) {
5609 + /* Flash rejected command */
5614 + /* Write single byte */
5615 + sflash_cmd(cc, *buf++);
5621 + /* All done, drop cs if needed */
5622 + if ((offset & 255) != 1) {
5624 + AND_REG(&cc->gpioout, ~mask);
5625 + if (!sflash_poll(cc, offset)) {
5626 + /* Flash rejected command */
5632 + W_REG(&cc->flashaddress, offset);
5633 + W_REG(&cc->flashdata, *buf);
5634 + /* Page program */
5635 + sflash_cmd(cc, SFLASH_ST_PP);
5639 + mask = sfl->blocksize - 1;
5640 + page = (offset & ~mask) << 1;
5641 + byte = offset & mask;
5642 + /* Read main memory page into buffer 1 */
5643 + if (byte || len < sfl->blocksize) {
5644 + W_REG(&cc->flashaddress, page);
5645 + sflash_cmd(cc, SFLASH_AT_BUF1_LOAD);
5646 + /* 250 us for AT45DB321B */
5647 + SPINWAIT(sflash_poll(cc, offset), 1000);
5648 + ASSERT(!sflash_poll(cc, offset));
5650 + /* Write into buffer 1 */
5651 + for (ret = 0; ret < len && byte < sfl->blocksize; ret++) {
5652 + W_REG(&cc->flashaddress, byte++);
5653 + W_REG(&cc->flashdata, *buf++);
5654 + sflash_cmd(cc, SFLASH_AT_BUF1_WRITE);
5656 + /* Write buffer 1 into main memory page */
5657 + W_REG(&cc->flashaddress, page);
5658 + sflash_cmd(cc, SFLASH_AT_BUF1_PROGRAM);
5665 +/* Erase a region. Returns number of bytes scheduled for erasure.
5666 + * Caller should poll for completion.
5669 +sflash_erase(chipcregs_t *cc, uint offset)
5671 + struct sflash *sfl;
5673 + if (offset >= sflash.size)
5677 + switch (sfl->type) {
5679 + sflash_cmd(cc, SFLASH_ST_WREN);
5680 + W_REG(&cc->flashaddress, offset);
5681 + sflash_cmd(cc, SFLASH_ST_SE);
5682 + return sfl->blocksize;
5684 + W_REG(&cc->flashaddress, offset << 1);
5685 + sflash_cmd(cc, SFLASH_AT_PAGE_ERASE);
5686 + return sfl->blocksize;
5693 + * writes the appropriate range of flash, a NULL buf simply erases
5694 + * the region of flash
5697 +sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf)
5699 + struct sflash *sfl;
5700 + uchar *block = NULL, *cur_ptr, *blk_ptr;
5701 + uint blocksize = 0, mask, cur_offset, cur_length, cur_retlen, remainder;
5702 + uint blk_offset, blk_len, copied;
5703 + int bytes, ret = 0;
5705 + /* Check address range */
5710 + if ((offset + len) > sfl->size)
5713 + blocksize = sfl->blocksize;
5714 + mask = blocksize - 1;
5716 + /* Allocate a block of mem */
5717 + if (!(block = MALLOC(NULL, blocksize)))
5721 + /* Align offset */
5722 + cur_offset = offset & ~mask;
5723 + cur_length = blocksize;
5726 + remainder = blocksize - (offset & mask);
5727 + if (len < remainder)
5730 + cur_retlen = remainder;
5732 + /* buf == NULL means erase only */
5734 + /* Copy existing data into holding block if necessary */
5735 + if ((offset & mask) || (len < blocksize)) {
5736 + blk_offset = cur_offset;
5737 + blk_len = cur_length;
5738 + blk_ptr = cur_ptr;
5740 + /* Copy entire block */
5742 + copied = sflash_read(cc, blk_offset, blk_len, blk_ptr);
5743 + blk_offset += copied;
5744 + blk_len -= copied;
5745 + blk_ptr += copied;
5749 + /* Copy input data into holding block */
5750 + memcpy(cur_ptr + (offset & mask), buf, cur_retlen);
5754 + if ((ret = sflash_erase(cc, (uint) cur_offset)) < 0)
5756 + while (sflash_poll(cc, (uint) cur_offset));
5758 + /* buf == NULL means erase only */
5760 + offset += cur_retlen;
5761 + len -= cur_retlen;
5765 + /* Write holding block */
5766 + while (cur_length > 0) {
5767 + if ((bytes = sflash_write(cc,
5768 + (uint) cur_offset,
5769 + (uint) cur_length,
5770 + (uchar *) cur_ptr)) < 0) {
5774 + while (sflash_poll(cc, (uint) cur_offset));
5775 + cur_offset += bytes;
5776 + cur_length -= bytes;
5780 + offset += cur_retlen;
5781 + len -= cur_retlen;
5782 + buf += cur_retlen;
5788 + MFREE(NULL, block, blocksize);
5792 diff -urN linux.old/arch/mips/bcm947xx/include/bcmdevs.h linux.dev/arch/mips/bcm947xx/include/bcmdevs.h
5793 --- linux.old/arch/mips/bcm947xx/include/bcmdevs.h 1970-01-01 01:00:00.000000000 +0100
5794 +++ linux.dev/arch/mips/bcm947xx/include/bcmdevs.h 2005-12-15 15:25:24.905340500 +0100
5797 + * Broadcom device-specific manifest constants.
5799 + * Copyright 2005, Broadcom Corporation
5800 + * All Rights Reserved.
5802 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
5803 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
5804 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
5805 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
5813 +/* Known PCI vendor Id's */
5814 +#define VENDOR_EPIGRAM 0xfeda
5815 +#define VENDOR_BROADCOM 0x14e4
5816 +#define VENDOR_3COM 0x10b7
5817 +#define VENDOR_NETGEAR 0x1385
5818 +#define VENDOR_DIAMOND 0x1092
5819 +#define VENDOR_DELL 0x1028
5820 +#define VENDOR_HP 0x0e11
5821 +#define VENDOR_APPLE 0x106b
5823 +/* PCI Device Id's */
5824 +#define BCM4210_DEVICE_ID 0x1072 /* never used */
5825 +#define BCM4211_DEVICE_ID 0x4211
5826 +#define BCM4230_DEVICE_ID 0x1086 /* never used */
5827 +#define BCM4231_DEVICE_ID 0x4231
5829 +#define BCM4410_DEVICE_ID 0x4410 /* bcm44xx family pci iline */
5830 +#define BCM4430_DEVICE_ID 0x4430 /* bcm44xx family cardbus iline */
5831 +#define BCM4412_DEVICE_ID 0x4412 /* bcm44xx family pci enet */
5832 +#define BCM4432_DEVICE_ID 0x4432 /* bcm44xx family cardbus enet */
5834 +#define BCM3352_DEVICE_ID 0x3352 /* bcm3352 device id */
5835 +#define BCM3360_DEVICE_ID 0x3360 /* bcm3360 device id */
5837 +#define EPI41210_DEVICE_ID 0xa0fa /* bcm4210 */
5838 +#define EPI41230_DEVICE_ID 0xa10e /* bcm4230 */
5840 +#define BCM47XX_ILINE_ID 0x4711 /* 47xx iline20 */
5841 +#define BCM47XX_V90_ID 0x4712 /* 47xx v90 codec */
5842 +#define BCM47XX_ENET_ID 0x4713 /* 47xx enet */
5843 +#define BCM47XX_EXT_ID 0x4714 /* 47xx external i/f */
5844 +#define BCM47XX_USB_ID 0x4715 /* 47xx usb */
5845 +#define BCM47XX_USBH_ID 0x4716 /* 47xx usb host */
5846 +#define BCM47XX_USBD_ID 0x4717 /* 47xx usb device */
5847 +#define BCM47XX_IPSEC_ID 0x4718 /* 47xx ipsec */
5848 +#define BCM47XX_ROBO_ID 0x4719 /* 47xx/53xx roboswitch core */
5849 +#define BCM47XX_USB20H_ID 0x471a /* 47xx usb 2.0 host */
5850 +#define BCM47XX_USB20D_ID 0x471b /* 47xx usb 2.0 device */
5852 +#define BCM4710_DEVICE_ID 0x4710 /* 4710 primary function 0 */
5854 +#define BCM4610_DEVICE_ID 0x4610 /* 4610 primary function 0 */
5855 +#define BCM4610_ILINE_ID 0x4611 /* 4610 iline100 */
5856 +#define BCM4610_V90_ID 0x4612 /* 4610 v90 codec */
5857 +#define BCM4610_ENET_ID 0x4613 /* 4610 enet */
5858 +#define BCM4610_EXT_ID 0x4614 /* 4610 external i/f */
5859 +#define BCM4610_USB_ID 0x4615 /* 4610 usb */
5861 +#define BCM4402_DEVICE_ID 0x4402 /* 4402 primary function 0 */
5862 +#define BCM4402_ENET_ID 0x4402 /* 4402 enet */
5863 +#define BCM4402_V90_ID 0x4403 /* 4402 v90 codec */
5864 +#define BCM4401_ENET_ID 0x170c /* 4401b0 production enet cards */
5866 +#define BCM4301_DEVICE_ID 0x4301 /* 4301 primary function 0 */
5867 +#define BCM4301_D11B_ID 0x4301 /* 4301 802.11b */
5869 +#define BCM4307_DEVICE_ID 0x4307 /* 4307 primary function 0 */
5870 +#define BCM4307_V90_ID 0x4305 /* 4307 v90 codec */
5871 +#define BCM4307_ENET_ID 0x4306 /* 4307 enet */
5872 +#define BCM4307_D11B_ID 0x4307 /* 4307 802.11b */
5874 +#define BCM4306_DEVICE_ID 0x4306 /* 4306 chipcommon chipid */
5875 +#define BCM4306_D11G_ID 0x4320 /* 4306 802.11g */
5876 +#define BCM4306_D11G_ID2 0x4325
5877 +#define BCM4306_D11A_ID 0x4321 /* 4306 802.11a */
5878 +#define BCM4306_UART_ID 0x4322 /* 4306 uart */
5879 +#define BCM4306_V90_ID 0x4323 /* 4306 v90 codec */
5880 +#define BCM4306_D11DUAL_ID 0x4324 /* 4306 dual A+B */
5882 +#define BCM4309_PKG_ID 1 /* 4309 package id */
5884 +#define BCM4303_D11B_ID 0x4303 /* 4303 802.11b */
5885 +#define BCM4303_PKG_ID 2 /* 4303 package id */
5887 +#define BCM4310_DEVICE_ID 0x4310 /* 4310 chipcommon chipid */
5888 +#define BCM4310_D11B_ID 0x4311 /* 4310 802.11b */
5889 +#define BCM4310_UART_ID 0x4312 /* 4310 uart */
5890 +#define BCM4310_ENET_ID 0x4313 /* 4310 enet */
5891 +#define BCM4310_USB_ID 0x4315 /* 4310 usb */
5893 +#define BCMGPRS_UART_ID 0x4333 /* Uart id used by 4306/gprs card */
5894 +#define BCMGPRS2_UART_ID 0x4344 /* Uart id used by 4306/gprs card */
5897 +#define BCM4704_DEVICE_ID 0x4704 /* 4704 chipcommon chipid */
5898 +#define BCM4704_ENET_ID 0x4706 /* 4704 enet (Use 47XX_ENET_ID instead!) */
5900 +#define BCM4317_DEVICE_ID 0x4317 /* 4317 chip common chipid */
5902 +#define BCM4318_DEVICE_ID 0x4318 /* 4318 chip common chipid */
5903 +#define BCM4318_D11G_ID 0x4318 /* 4318 801.11b/g id */
5904 +#define BCM4318_D11DUAL_ID 0x4319 /* 4318 801.11a/b/g id */
5905 +#define BCM4318_JTAGM_ID 0x4331 /* 4318 jtagm device id */
5907 +#define FPGA_JTAGM_ID 0x4330 /* ??? */
5910 +#define BCM4710_SDRAM 0x00000000 /* Physical SDRAM */
5911 +#define BCM4710_PCI_MEM 0x08000000 /* Host Mode PCI memory access space (64 MB) */
5912 +#define BCM4710_PCI_CFG 0x0c000000 /* Host Mode PCI configuration space (64 MB) */
5913 +#define BCM4710_PCI_DMA 0x40000000 /* Client Mode PCI memory access space (1 GB) */
5914 +#define BCM4710_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
5915 +#define BCM4710_ENUM 0x18000000 /* Beginning of core enumeration space */
5917 +/* Core register space */
5918 +#define BCM4710_REG_SDRAM 0x18000000 /* SDRAM core registers */
5919 +#define BCM4710_REG_ILINE20 0x18001000 /* InsideLine20 core registers */
5920 +#define BCM4710_REG_EMAC0 0x18002000 /* Ethernet MAC 0 core registers */
5921 +#define BCM4710_REG_CODEC 0x18003000 /* Codec core registers */
5922 +#define BCM4710_REG_USB 0x18004000 /* USB core registers */
5923 +#define BCM4710_REG_PCI 0x18005000 /* PCI core registers */
5924 +#define BCM4710_REG_MIPS 0x18006000 /* MIPS core registers */
5925 +#define BCM4710_REG_EXTIF 0x18007000 /* External Interface core registers */
5926 +#define BCM4710_REG_EMAC1 0x18008000 /* Ethernet MAC 1 core registers */
5928 +#define BCM4710_EXTIF 0x1f000000 /* External Interface base address */
5929 +#define BCM4710_PCMCIA_MEM 0x1f000000 /* External Interface PCMCIA memory access */
5930 +#define BCM4710_PCMCIA_IO 0x1f100000 /* PCMCIA I/O access */
5931 +#define BCM4710_PCMCIA_CONF 0x1f200000 /* PCMCIA configuration */
5932 +#define BCM4710_PROG 0x1f800000 /* Programable interface */
5933 +#define BCM4710_FLASH 0x1fc00000 /* Flash */
5935 +#define BCM4710_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
5937 +#define BCM4710_UART (BCM4710_REG_EXTIF + 0x00000300)
5939 +#define BCM4710_EUART (BCM4710_EXTIF + 0x00800000)
5940 +#define BCM4710_LED (BCM4710_EXTIF + 0x00900000)
5942 +#define BCM4712_DEVICE_ID 0x4712 /* 4712 chipcommon chipid */
5943 +#define BCM4712_MIPS_ID 0x4720 /* 4712 base devid */
5944 +#define BCM4712LARGE_PKG_ID 0 /* 340pin 4712 package id */
5945 +#define BCM4712SMALL_PKG_ID 1 /* 200pin 4712 package id */
5946 +#define BCM4712MID_PKG_ID 2 /* 225pin 4712 package id */
5948 +#define SDIOH_FPGA_ID 0x4380 /* sdio host fpga */
5950 +#define BCM5365_DEVICE_ID 0x5365 /* 5365 chipcommon chipid */
5951 +#define BCM5350_DEVICE_ID 0x5350 /* bcm5350 chipcommon chipid */
5952 +#define BCM5352_DEVICE_ID 0x5352 /* bcm5352 chipcommon chipid */
5954 +#define BCM4320_DEVICE_ID 0x4320 /* bcm4320 chipcommon chipid */
5956 +/* PCMCIA vendor Id's */
5958 +#define VENDOR_BROADCOM_PCMCIA 0x02d0
5960 +/* SDIO vendor Id's */
5961 +#define VENDOR_BROADCOM_SDIO 0x00BF
5965 +#define BFL_BTCOEXIST 0x0001 /* This board implements Bluetooth coexistance */
5966 +#define BFL_PACTRL 0x0002 /* This board has gpio 9 controlling the PA */
5967 +#define BFL_AIRLINEMODE 0x0004 /* This board implements gpio13 radio disable indication */
5968 +#define BFL_ENETROBO 0x0010 /* This board has robo switch or core */
5969 +#define BFL_CCKHIPWR 0x0040 /* Can do high-power CCK transmission */
5970 +#define BFL_ENETADM 0x0080 /* This board has ADMtek switch */
5971 +#define BFL_ENETVLAN 0x0100 /* This board has vlan capability */
5972 +#define BFL_AFTERBURNER 0x0200 /* This board supports Afterburner mode */
5973 +#define BFL_NOPCI 0x0400 /* This board leaves PCI floating */
5974 +#define BFL_FEM 0x0800 /* This board supports the Front End Module */
5975 +#define BFL_EXTLNA 0x1000 /* This board has an external LNA */
5976 +#define BFL_HGPA 0x2000 /* This board has a high gain PA */
5977 +#define BFL_BTCMOD 0x4000 /* This board' BTCOEXIST is in the alternate gpios */
5978 +#define BFL_ALTIQ 0x8000 /* Alternate I/Q settings */
5980 +/* board specific GPIO assignment, gpio 0-3 are also customer-configurable led */
5981 +#define BOARD_GPIO_HWRAD_B 0x010 /* bit 4 is HWRAD input on 4301 */
5982 +#define BOARD_GPIO_BTCMOD_IN 0x010 /* bit 4 is the alternate BT Coexistance Input */
5983 +#define BOARD_GPIO_BTCMOD_OUT 0x020 /* bit 5 is the alternate BT Coexistance Out */
5984 +#define BOARD_GPIO_BTC_IN 0x080 /* bit 7 is BT Coexistance Input */
5985 +#define BOARD_GPIO_BTC_OUT 0x100 /* bit 8 is BT Coexistance Out */
5986 +#define BOARD_GPIO_PACTRL 0x200 /* bit 9 controls the PA on new 4306 boards */
5987 +#define PCI_CFG_GPIO_SCS 0x10 /* PCI config space bit 4 for 4306c0 slow clock source */
5988 +#define PCI_CFG_GPIO_HWRAD 0x20 /* PCI config space GPIO 13 for hw radio disable */
5989 +#define PCI_CFG_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */
5990 +#define PCI_CFG_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */
5993 +#define SB_BUS 0 /* Silicon Backplane */
5994 +#define PCI_BUS 1 /* PCI target */
5995 +#define PCMCIA_BUS 2 /* PCMCIA target */
5996 +#define SDIO_BUS 3 /* SDIO target */
5997 +#define JTAG_BUS 4 /* JTAG */
5999 +/* Allows optimization for single-bus support */
6001 +#define BUSTYPE(bus) (BCMBUSTYPE)
6003 +#define BUSTYPE(bus) (bus)
6006 +/* power control defines */
6007 +#define PLL_DELAY 150 /* us pll on delay */
6008 +#define FREF_DELAY 200 /* us fref change delay */
6009 +#define MIN_SLOW_CLK 32 /* us Slow clock period */
6010 +#define XTAL_ON_DELAY 1000 /* us crystal power-on delay */
6012 +/* Reference Board Types */
6014 +#define BU4710_BOARD 0x0400
6015 +#define VSIM4710_BOARD 0x0401
6016 +#define QT4710_BOARD 0x0402
6018 +#define BU4610_BOARD 0x0403
6019 +#define VSIM4610_BOARD 0x0404
6021 +#define BU4307_BOARD 0x0405
6022 +#define BCM94301CB_BOARD 0x0406
6023 +#define BCM94301PC_BOARD 0x0406 /* Pcmcia 5v card */
6024 +#define BCM94301MP_BOARD 0x0407
6025 +#define BCM94307MP_BOARD 0x0408
6026 +#define BCMAP4307_BOARD 0x0409
6028 +#define BU4309_BOARD 0x040a
6029 +#define BCM94309CB_BOARD 0x040b
6030 +#define BCM94309MP_BOARD 0x040c
6031 +#define BCM4309AP_BOARD 0x040d
6033 +#define BCM94302MP_BOARD 0x040e
6035 +#define VSIM4310_BOARD 0x040f
6036 +#define BU4711_BOARD 0x0410
6037 +#define BCM94310U_BOARD 0x0411
6038 +#define BCM94310AP_BOARD 0x0412
6039 +#define BCM94310MP_BOARD 0x0414
6041 +#define BU4306_BOARD 0x0416
6042 +#define BCM94306CB_BOARD 0x0417
6043 +#define BCM94306MP_BOARD 0x0418
6045 +#define BCM94710D_BOARD 0x041a
6046 +#define BCM94710R1_BOARD 0x041b
6047 +#define BCM94710R4_BOARD 0x041c
6048 +#define BCM94710AP_BOARD 0x041d
6051 +#define BU2050_BOARD 0x041f
6054 +#define BCM94309G_BOARD 0x0421
6056 +#define BCM94301PC3_BOARD 0x0422 /* Pcmcia 3.3v card */
6058 +#define BU4704_BOARD 0x0423
6059 +#define BU4702_BOARD 0x0424
6061 +#define BCM94306PC_BOARD 0x0425 /* pcmcia 3.3v 4306 card */
6063 +#define BU4317_BOARD 0x0426
6066 +#define BCM94702MN_BOARD 0x0428
6068 +/* BCM4702 1U CompactPCI Board */
6069 +#define BCM94702CPCI_BOARD 0x0429
6071 +/* BCM4702 with BCM95380 VLAN Router */
6072 +#define BCM95380RR_BOARD 0x042a
6074 +/* cb4306 with SiGe PA */
6075 +#define BCM94306CBSG_BOARD 0x042b
6077 +/* mp4301 with 2050 radio */
6078 +#define BCM94301MPL_BOARD 0x042c
6080 +/* cb4306 with SiGe PA */
6081 +#define PCSG94306_BOARD 0x042d
6083 +/* bu4704 with sdram */
6084 +#define BU4704SD_BOARD 0x042e
6086 +/* Dual 11a/11g Router */
6087 +#define BCM94704AGR_BOARD 0x042f
6089 +/* 11a-only minipci */
6090 +#define BCM94308MP_BOARD 0x0430
6094 +/* BCM94317 boards */
6095 +#define BCM94317CB_BOARD 0x0440
6096 +#define BCM94317MP_BOARD 0x0441
6097 +#define BCM94317PCMCIA_BOARD 0x0442
6098 +#define BCM94317SDIO_BOARD 0x0443
6100 +#define BU4712_BOARD 0x0444
6101 +#define BU4712SD_BOARD 0x045d
6102 +#define BU4712L_BOARD 0x045f
6104 +/* BCM4712 boards */
6105 +#define BCM94712AP_BOARD 0x0445
6106 +#define BCM94712P_BOARD 0x0446
6108 +/* BCM4318 boards */
6109 +#define BU4318_BOARD 0x0447
6110 +#define CB4318_BOARD 0x0448
6111 +#define MPG4318_BOARD 0x0449
6112 +#define MP4318_BOARD 0x044a
6113 +#define SD4318_BOARD 0x044b
6115 +/* BCM63XX boards */
6116 +#define BCM96338_BOARD 0x6338
6117 +#define BCM96345_BOARD 0x6345
6118 +#define BCM96348_BOARD 0x6348
6120 +/* Another mp4306 with SiGe */
6121 +#define BCM94306P_BOARD 0x044c
6123 +/* CF-like 4317 modules */
6124 +#define BCM94317CF_BOARD 0x044d
6127 +#define BCM94303MP_BOARD 0x044e
6130 +#define BCM94306MPSGH_BOARD 0x044f
6132 +/* BRCM 4306 w/ Front End Modules */
6133 +#define BCM94306MPM 0x0450
6134 +#define BCM94306MPL 0x0453
6137 +#define BCM94712AGR_BOARD 0x0451
6139 +/* The real CF 4317 board */
6140 +#define CFI4317_BOARD 0x0452
6143 +#define PC4303_BOARD 0x0454
6146 +#define BCM95350K_BOARD 0x0455
6149 +#define BCM95350R_BOARD 0x0456
6152 +#define BCM94306MPLNA_BOARD 0x0457
6155 +#define BU4320_BOARD 0x0458
6156 +#define BU4320S_BOARD 0x0459
6157 +#define BCM94320PH_BOARD 0x045a
6160 +#define BCM94306MPH_BOARD 0x045b
6163 +#define BCM94306PCIV_BOARD 0x045c
6165 +#define BU4712SD_BOARD 0x045d
6167 +#define BCM94320PFLSH_BOARD 0x045e
6169 +#define BU4712L_BOARD 0x045f
6170 +#define BCM94712LGR_BOARD 0x0460
6171 +#define BCM94320R_BOARD 0x0461
6173 +#define BU5352_BOARD 0x0462
6175 +#define BCM94318MPGH_BOARD 0x0463
6178 +#define BCM95352GR_BOARD 0x0467
6181 +#define BCM95351AGR_BOARD 0x0470
6183 +/* # of GPIO pins */
6184 +#define GPIO_NUMPINS 16
6186 +#endif /* _BCMDEVS_H */
6187 diff -urN linux.old/arch/mips/bcm947xx/include/bcmendian.h linux.dev/arch/mips/bcm947xx/include/bcmendian.h
6188 --- linux.old/arch/mips/bcm947xx/include/bcmendian.h 1970-01-01 01:00:00.000000000 +0100
6189 +++ linux.dev/arch/mips/bcm947xx/include/bcmendian.h 2005-12-15 15:25:47.146730500 +0100
6192 + * local version of endian.h - byte order defines
6194 + * Copyright 2005, Broadcom Corporation
6195 + * All Rights Reserved.
6197 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6198 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6199 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6200 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6205 +#ifndef _BCMENDIAN_H_
6206 +#define _BCMENDIAN_H_
6208 +#include <typedefs.h>
6210 +/* Byte swap a 16 bit value */
6211 +#define BCMSWAP16(val) \
6213 + (((uint16)(val) & (uint16)0x00ffU) << 8) | \
6214 + (((uint16)(val) & (uint16)0xff00U) >> 8) ))
6216 +/* Byte swap a 32 bit value */
6217 +#define BCMSWAP32(val) \
6219 + (((uint32)(val) & (uint32)0x000000ffUL) << 24) | \
6220 + (((uint32)(val) & (uint32)0x0000ff00UL) << 8) | \
6221 + (((uint32)(val) & (uint32)0x00ff0000UL) >> 8) | \
6222 + (((uint32)(val) & (uint32)0xff000000UL) >> 24) ))
6224 +/* 2 Byte swap a 32 bit value */
6225 +#define BCMSWAP32BY16(val) \
6227 + (((uint32)(val) & (uint32)0x0000ffffUL) << 16) | \
6228 + (((uint32)(val) & (uint32)0xffff0000UL) >> 16) ))
6231 +static INLINE uint16
6232 +bcmswap16(uint16 val)
6234 + return BCMSWAP16(val);
6237 +static INLINE uint32
6238 +bcmswap32(uint32 val)
6240 + return BCMSWAP32(val);
6243 +static INLINE uint32
6244 +bcmswap32by16(uint32 val)
6246 + return BCMSWAP32BY16(val);
6249 +/* buf - start of buffer of shorts to swap */
6250 +/* len - byte length of buffer */
6252 +bcmswap16_buf(uint16 *buf, uint len)
6257 + *buf = bcmswap16(*buf);
6263 +#ifndef IL_BIGENDIAN
6264 +#define HTON16(i) BCMSWAP16(i)
6265 +#define hton16(i) bcmswap16(i)
6266 +#define hton32(i) bcmswap32(i)
6267 +#define ntoh16(i) bcmswap16(i)
6268 +#define ntoh32(i) bcmswap32(i)
6269 +#define ltoh16(i) (i)
6270 +#define ltoh32(i) (i)
6271 +#define htol16(i) (i)
6272 +#define htol32(i) (i)
6274 +#define HTON16(i) (i)
6275 +#define hton16(i) (i)
6276 +#define hton32(i) (i)
6277 +#define ntoh16(i) (i)
6278 +#define ntoh32(i) (i)
6279 +#define ltoh16(i) bcmswap16(i)
6280 +#define ltoh32(i) bcmswap32(i)
6281 +#define htol16(i) bcmswap16(i)
6282 +#define htol32(i) bcmswap32(i)
6286 +#ifndef IL_BIGENDIAN
6287 +#define ltoh16_buf(buf, i)
6288 +#define htol16_buf(buf, i)
6290 +#define ltoh16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
6291 +#define htol16_buf(buf, i) bcmswap16_buf((uint16*)buf, i)
6295 +* load 16-bit value from unaligned little endian byte array.
6297 +static INLINE uint16
6298 +ltoh16_ua(uint8 *bytes)
6300 + return (bytes[1]<<8)+bytes[0];
6304 +* load 32-bit value from unaligned little endian byte array.
6306 +static INLINE uint32
6307 +ltoh32_ua(uint8 *bytes)
6309 + return (bytes[3]<<24)+(bytes[2]<<16)+(bytes[1]<<8)+bytes[0];
6313 +* load 16-bit value from unaligned big(network) endian byte array.
6315 +static INLINE uint16
6316 +ntoh16_ua(uint8 *bytes)
6318 + return (bytes[0]<<8)+bytes[1];
6322 +* load 32-bit value from unaligned big(network) endian byte array.
6324 +static INLINE uint32
6325 +ntoh32_ua(uint8 *bytes)
6327 + return (bytes[0]<<24)+(bytes[1]<<16)+(bytes[2]<<8)+bytes[3];
6330 +#define ltoh_ua(ptr) ( \
6331 + sizeof(*(ptr)) == sizeof(uint8) ? *(uint8 *)ptr : \
6332 + sizeof(*(ptr)) == sizeof(uint16) ? (((uint8 *)ptr)[1]<<8)+((uint8 *)ptr)[0] : \
6333 + (((uint8 *)ptr)[3]<<24)+(((uint8 *)ptr)[2]<<16)+(((uint8 *)ptr)[1]<<8)+((uint8 *)ptr)[0] \
6336 +#define ntoh_ua(ptr) ( \
6337 + sizeof(*(ptr)) == sizeof(uint8) ? *(uint8 *)ptr : \
6338 + sizeof(*(ptr)) == sizeof(uint16) ? (((uint8 *)ptr)[0]<<8)+((uint8 *)ptr)[1] : \
6339 + (((uint8 *)ptr)[0]<<24)+(((uint8 *)ptr)[1]<<16)+(((uint8 *)ptr)[2]<<8)+((uint8 *)ptr)[3] \
6342 +#endif /* _BCMENDIAN_H_ */
6343 diff -urN linux.old/arch/mips/bcm947xx/include/bcmnvram.h linux.dev/arch/mips/bcm947xx/include/bcmnvram.h
6344 --- linux.old/arch/mips/bcm947xx/include/bcmnvram.h 1970-01-01 01:00:00.000000000 +0100
6345 +++ linux.dev/arch/mips/bcm947xx/include/bcmnvram.h 2005-12-15 16:04:35.850827500 +0100
6348 + * NVRAM variable manipulation
6350 + * Copyright 2005, Broadcom Corporation
6351 + * All Rights Reserved.
6353 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6354 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6355 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6356 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6361 +#ifndef _bcmnvram_h_
6362 +#define _bcmnvram_h_
6364 +#ifndef _LANGUAGE_ASSEMBLY
6366 +#include <typedefs.h>
6368 +struct nvram_header {
6371 + uint32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
6372 + uint32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
6373 + uint32 config_ncdl; /* ncdl values for memc */
6376 +struct nvram_tuple {
6379 + struct nvram_tuple *next;
6383 + * Get the value of an NVRAM variable. The pointer returned may be
6384 + * invalid after a set.
6385 + * @param name name of variable to get
6386 + * @return value of variable or NULL if undefined
6388 +extern char * __init nvram_get(const char *name);
6391 + * Get the value of an NVRAM variable.
6392 + * @param name name of variable to get
6393 + * @return value of variable or NUL if undefined
6395 +#define nvram_safe_get(name) (BCMINIT(nvram_get)(name) ? : "")
6398 + * Match an NVRAM variable.
6399 + * @param name name of variable to match
6400 + * @param match value to compare against value of variable
6401 + * @return TRUE if variable is defined and its value is string equal
6402 + * to match or FALSE otherwise
6405 +nvram_match(char *name, char *match) {
6406 + const char *value = BCMINIT(nvram_get)(name);
6407 + return (value && !strcmp(value, match));
6411 + * Inversely match an NVRAM variable.
6412 + * @param name name of variable to match
6413 + * @param match value to compare against value of variable
6414 + * @return TRUE if variable is defined and its value is not string
6415 + * equal to invmatch or FALSE otherwise
6418 +nvram_invmatch(char *name, char *invmatch) {
6419 + const char *value = BCMINIT(nvram_get)(name);
6420 + return (value && strcmp(value, invmatch));
6423 +#endif /* _LANGUAGE_ASSEMBLY */
6425 +#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
6426 +#define NVRAM_VERSION 1
6427 +#define NVRAM_HEADER_SIZE 20
6428 +#define NVRAM_SPACE 0x8000
6430 +#define NVRAM_MAX_VALUE_LEN 255
6431 +#define NVRAM_MAX_PARAM_LEN 64
6433 +#endif /* _bcmnvram_h_ */
6434 diff -urN linux.old/arch/mips/bcm947xx/include/bcmsrom.h linux.dev/arch/mips/bcm947xx/include/bcmsrom.h
6435 --- linux.old/arch/mips/bcm947xx/include/bcmsrom.h 1970-01-01 01:00:00.000000000 +0100
6436 +++ linux.dev/arch/mips/bcm947xx/include/bcmsrom.h 2005-12-15 15:34:32.919589250 +0100
6439 + * Misc useful routines to access NIC local SROM/OTP .
6441 + * Copyright 2005, Broadcom Corporation
6442 + * All Rights Reserved.
6444 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6445 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6446 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6447 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6452 +#ifndef _bcmsrom_h_
6453 +#define _bcmsrom_h_
6455 +extern int srom_var_init(void *sbh, uint bus, void *curmap, osl_t *osh, char **vars, int *count);
6457 +extern int srom_read(uint bus, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf);
6458 +extern int srom_write(uint bus, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf);
6460 +#endif /* _bcmsrom_h_ */
6461 diff -urN linux.old/arch/mips/bcm947xx/include/bcmutils.h linux.dev/arch/mips/bcm947xx/include/bcmutils.h
6462 --- linux.old/arch/mips/bcm947xx/include/bcmutils.h 1970-01-01 01:00:00.000000000 +0100
6463 +++ linux.dev/arch/mips/bcm947xx/include/bcmutils.h 2005-12-15 16:44:25.619117750 +0100
6466 + * Misc useful os-independent macros and functions.
6468 + * Copyright 2005, Broadcom Corporation
6469 + * All Rights Reserved.
6471 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6472 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6473 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6474 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6478 +#ifndef _bcmutils_h_
6479 +#define _bcmutils_h_
6481 +/*** driver-only section ***/
6484 +#define _BCM_U 0x01 /* upper */
6485 +#define _BCM_L 0x02 /* lower */
6486 +#define _BCM_D 0x04 /* digit */
6487 +#define _BCM_C 0x08 /* cntrl */
6488 +#define _BCM_P 0x10 /* punct */
6489 +#define _BCM_S 0x20 /* white space (space/lf/tab) */
6490 +#define _BCM_X 0x40 /* hex digit */
6491 +#define _BCM_SP 0x80 /* hard space (0x20) */
6493 +#define GPIO_PIN_NOTDEFINED 0x20
6495 +extern unsigned char bcm_ctype[];
6496 +#define bcm_ismask(x) (bcm_ctype[(int)(unsigned char)(x)])
6498 +#define bcm_isalnum(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L|_BCM_D)) != 0)
6499 +#define bcm_isalpha(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L)) != 0)
6500 +#define bcm_iscntrl(c) ((bcm_ismask(c)&(_BCM_C)) != 0)
6501 +#define bcm_isdigit(c) ((bcm_ismask(c)&(_BCM_D)) != 0)
6502 +#define bcm_isgraph(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D)) != 0)
6503 +#define bcm_islower(c) ((bcm_ismask(c)&(_BCM_L)) != 0)
6504 +#define bcm_isprint(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D|_BCM_SP)) != 0)
6505 +#define bcm_ispunct(c) ((bcm_ismask(c)&(_BCM_P)) != 0)
6506 +#define bcm_isspace(c) ((bcm_ismask(c)&(_BCM_S)) != 0)
6507 +#define bcm_isupper(c) ((bcm_ismask(c)&(_BCM_U)) != 0)
6508 +#define bcm_isxdigit(c) ((bcm_ismask(c)&(_BCM_D|_BCM_X)) != 0)
6511 + * Spin at most 'us' microseconds while 'exp' is true.
6512 + * Caller should explicitly test 'exp' when this completes
6513 + * and take appropriate error action if 'exp' is still true.
6515 +#define SPINWAIT(exp, us) { \
6516 + uint countdown = (us) + 9; \
6517 + while ((exp) && (countdown >= 10)) {\
6519 + countdown -= 10; \
6523 +/* generic osl packet queue */
6525 + void *head; /* first packet to dequeue */
6526 + void *tail; /* last packet to dequeue */
6527 + uint len; /* number of queued packets */
6528 + uint maxlen; /* maximum number of queued packets */
6529 + bool priority; /* enqueue by packet priority */
6530 + uint8 prio_map[MAXPRIO+1]; /* user priority to packet enqueue policy map */
6532 +#define DEFAULT_QLEN 128
6534 +#define pktq_len(q) ((q)->len)
6535 +#define pktq_avail(q) ((q)->maxlen - (q)->len)
6536 +#define pktq_head(q) ((q)->head)
6537 +#define pktq_full(q) ((q)->len >= (q)->maxlen)
6538 +#define _pktq_pri(q, pri) ((q)->prio_map[pri])
6539 +#define pktq_tailpri(q) ((q)->tail ? _pktq_pri(q, PKTPRIO((q)->tail)) : _pktq_pri(q, 0))
6543 +extern uint pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf);
6544 +extern uint pkttotlen(osl_t *osh, void *);
6545 +extern void pktq_init(struct pktq *q, uint maxlen, const uint8 prio_map[]);
6546 +extern void pktenq(struct pktq *q, void *p, bool lifo);
6547 +extern void *pktdeq(struct pktq *q);
6548 +extern void *pktdeqtail(struct pktq *q);
6550 +extern uint bcm_atoi(char *s);
6551 +extern uchar bcm_toupper(uchar c);
6552 +extern ulong bcm_strtoul(char *cp, char **endp, uint base);
6553 +extern char *bcmstrstr(char *haystack, char *needle);
6554 +extern char *bcmstrcat(char *dest, const char *src);
6555 +extern ulong wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen);
6556 +/* ethernet address */
6557 +extern char *bcm_ether_ntoa(char *ea, char *buf);
6558 +extern int bcm_ether_atoe(char *p, char *ea);
6560 +extern void bcm_mdelay(uint ms);
6561 +/* variable access */
6562 +extern char *getvar(char *vars, char *name);
6563 +extern int getintvar(char *vars, char *name);
6564 +extern uint getgpiopin(char *vars, char *pin_name, uint def_pin);
6565 +#define bcmlog(fmt, a1, a2)
6566 +#define bcmdumplog(buf, size) *buf = '\0'
6567 +#define bcmdumplogent(buf, idx) -1
6569 +/*** driver/apps-shared section ***/
6571 +#define BCME_STRLEN 64
6572 +#define VALID_BCMERROR(e) ((e <= 0) && (e >= BCME_LAST))
6576 + * error codes could be added but the defined ones shouldn't be changed/deleted
6577 + * these error codes are exposed to the user code
6578 + * when ever a new error code is added to this list
6579 + * please update errorstring table with the related error string and
6580 + * update osl files with os specific errorcode map
6583 +#define BCME_ERROR -1 /* Error generic */
6584 +#define BCME_BADARG -2 /* Bad Argument */
6585 +#define BCME_BADOPTION -3 /* Bad option */
6586 +#define BCME_NOTUP -4 /* Not up */
6587 +#define BCME_NOTDOWN -5 /* Not down */
6588 +#define BCME_NOTAP -6 /* Not AP */
6589 +#define BCME_NOTSTA -7 /* Not STA */
6590 +#define BCME_BADKEYIDX -8 /* BAD Key Index */
6591 +#define BCME_RADIOOFF -9 /* Radio Off */
6592 +#define BCME_NOTBANDLOCKED -10 /* Not bandlocked */
6593 +#define BCME_NOCLK -11 /* No Clock*/
6594 +#define BCME_BADRATESET -12 /* BAD RateSet*/
6595 +#define BCME_BADBAND -13 /* BAD Band */
6596 +#define BCME_BUFTOOSHORT -14 /* Buffer too short */
6597 +#define BCME_BUFTOOLONG -15 /* Buffer too Long */
6598 +#define BCME_BUSY -16 /* Busy*/
6599 +#define BCME_NOTASSOCIATED -17 /* Not associated*/
6600 +#define BCME_BADSSIDLEN -18 /* BAD SSID Len */
6601 +#define BCME_OUTOFRANGECHAN -19 /* Out of Range Channel*/
6602 +#define BCME_BADCHAN -20 /* BAD Channel */
6603 +#define BCME_BADADDR -21 /* BAD Address*/
6604 +#define BCME_NORESOURCE -22 /* No resources*/
6605 +#define BCME_UNSUPPORTED -23 /* Unsupported*/
6606 +#define BCME_BADLEN -24 /* Bad Length*/
6607 +#define BCME_NOTREADY -25 /* Not ready Yet*/
6608 +#define BCME_EPERM -26 /* Not Permitted */
6609 +#define BCME_NOMEM -27 /* No Memory */
6610 +#define BCME_ASSOCIATED -28 /* Associated */
6611 +#define BCME_RANGE -29 /* Range Error*/
6612 +#define BCME_NOTFOUND -30 /* Not found */
6613 +#define BCME_LAST BCME_NOTFOUND
6616 +#define ABS(a) (((a)<0)?-(a):(a))
6620 +#define MIN(a, b) (((a)<(b))?(a):(b))
6624 +#define MAX(a, b) (((a)>(b))?(a):(b))
6627 +#define CEIL(x, y) (((x) + ((y)-1)) / (y))
6628 +#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
6629 +#define ISALIGNED(a, x) (((a) & ((x)-1)) == 0)
6630 +#define ISPOWEROF2(x) ((((x)-1)&(x))==0)
6631 +#define VALID_MASK(mask) !((mask) & ((mask) + 1))
6632 +#define OFFSETOF(type, member) ((uint)(uintptr)&((type *)0)->member)
6633 +#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
6635 +/* bit map related macros */
6637 +#define NBBY 8 /* 8 bits per byte */
6638 +#define setbit(a,i) (((uint8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY))
6639 +#define clrbit(a,i) (((uint8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
6640 +#define isset(a,i) (((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY)))
6641 +#define isclr(a,i) ((((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
6644 +#define NBITS(type) (sizeof(type) * 8)
6645 +#define NBITVAL(bits) (1 << (bits))
6646 +#define MAXBITVAL(bits) ((1 << (bits)) - 1)
6649 +#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
6650 +#define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */
6651 +#define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
6652 +#define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
6653 +#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
6654 +#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
6656 +/* bcm_format_flags() bit description structure */
6657 +typedef struct bcm_bit_desc {
6662 +/* tag_ID/length/value_buffer tuple */
6663 +typedef struct bcm_tlv {
6669 +/* Check that bcm_tlv_t fits into the given buflen */
6670 +#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (int)(buflen) >= (int)(2 + (elt)->len))
6672 +/* buffer length for ethernet address from bcm_ether_ntoa() */
6673 +#define ETHER_ADDR_STR_LEN 18
6675 +/* unaligned load and store macros */
6676 +#ifdef IL_BIGENDIAN
6677 +static INLINE uint32
6678 +load32_ua(uint8 *a)
6680 + return ((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]);
6684 +store32_ua(uint8 *a, uint32 v)
6686 + a[0] = (v >> 24) & 0xff;
6687 + a[1] = (v >> 16) & 0xff;
6688 + a[2] = (v >> 8) & 0xff;
6692 +static INLINE uint16
6693 +load16_ua(uint8 *a)
6695 + return ((a[0] << 8) | a[1]);
6699 +store16_ua(uint8 *a, uint16 v)
6701 + a[0] = (v >> 8) & 0xff;
6707 +static INLINE uint32
6708 +load32_ua(uint8 *a)
6710 + return ((a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]);
6714 +store32_ua(uint8 *a, uint32 v)
6716 + a[3] = (v >> 24) & 0xff;
6717 + a[2] = (v >> 16) & 0xff;
6718 + a[1] = (v >> 8) & 0xff;
6722 +static INLINE uint16
6723 +load16_ua(uint8 *a)
6725 + return ((a[1] << 8) | a[0]);
6729 +store16_ua(uint8 *a, uint16 v)
6731 + a[1] = (v >> 8) & 0xff;
6739 +extern uint8 hndcrc8(uint8 *p, uint nbytes, uint8 crc);
6742 +extern bcm_tlv_t *bcm_next_tlv(bcm_tlv_t *elt, int *buflen);
6743 +extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key);
6744 +extern bcm_tlv_t *bcm_parse_ordered_tlvs(void *buf, int buflen, uint key);
6747 +extern const char *bcmerrorstr(int bcmerror);
6749 +/* multi-bool data type: set of bools, mbool is true if any is set */
6750 +typedef uint32 mbool;
6751 +#define mboolset(mb, bit) (mb |= bit) /* set one bool */
6752 +#define mboolclr(mb, bit) (mb &= ~bit) /* clear one bool */
6753 +#define mboolisset(mb, bit) ((mb & bit) != 0) /* TRUE if one bool is set */
6754 +#define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val)))
6756 +/* power conversion */
6757 +extern uint16 bcm_qdbm_to_mw(uint8 qdbm);
6758 +extern uint8 bcm_mw_to_qdbm(uint16 mw);
6760 +/* generic datastruct to help dump routines */
6767 +typedef uint32 (*readreg_rtn)(void *arg0, void *arg1, uint32 offset);
6768 +extern uint bcmdumpfields(readreg_rtn func_ptr, void *arg0, void *arg1, struct fielddesc *str, char *buf, uint32 bufsize);
6770 +extern uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint len);
6772 +#endif /* _bcmutils_h_ */
6773 diff -urN linux.old/arch/mips/bcm947xx/include/bitfuncs.h linux.dev/arch/mips/bcm947xx/include/bitfuncs.h
6774 --- linux.old/arch/mips/bcm947xx/include/bitfuncs.h 1970-01-01 01:00:00.000000000 +0100
6775 +++ linux.dev/arch/mips/bcm947xx/include/bitfuncs.h 2005-12-15 15:34:40.268048500 +0100
6778 + * bit manipulation utility functions
6780 + * Copyright 2005, Broadcom Corporation
6781 + * All Rights Reserved.
6783 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6784 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6785 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6786 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6790 +#ifndef _BITFUNCS_H
6791 +#define _BITFUNCS_H
6793 +#include <typedefs.h>
6795 +/* local prototypes */
6796 +static INLINE uint32 find_msbit(uint32 x);
6800 + * find_msbit: returns index of most significant set bit in x, with index
6801 + * range defined as 0-31. NOTE: returns zero if input is zero.
6804 +#if defined(USE_PENTIUM_BSR) && defined(__GNUC__)
6807 + * Implementation for Pentium processors and gcc. Note that this
6808 + * instruction is actually very slow on some processors (e.g., family 5,
6809 + * model 2, stepping 12, "Pentium 75 - 200"), so we use the generic
6810 + * implementation instead.
6812 +static INLINE uint32 find_msbit(uint32 x)
6815 + __asm__("bsrl %1,%0"
6824 + * Generic Implementation
6827 +#define DB_POW_MASK16 0xffff0000
6828 +#define DB_POW_MASK8 0x0000ff00
6829 +#define DB_POW_MASK4 0x000000f0
6830 +#define DB_POW_MASK2 0x0000000c
6831 +#define DB_POW_MASK1 0x00000002
6833 +static INLINE uint32 find_msbit(uint32 x)
6835 + uint32 temp_x = x;
6837 + if (temp_x & DB_POW_MASK16) {
6841 + if (temp_x & DB_POW_MASK8) {
6845 + if (temp_x & DB_POW_MASK4) {
6849 + if (temp_x & DB_POW_MASK2) {
6853 + if (temp_x & DB_POW_MASK1) {
6861 +#endif /* _BITFUNCS_H */
6862 diff -urN linux.old/arch/mips/bcm947xx/include/flash.h linux.dev/arch/mips/bcm947xx/include/flash.h
6863 --- linux.old/arch/mips/bcm947xx/include/flash.h 1970-01-01 01:00:00.000000000 +0100
6864 +++ linux.dev/arch/mips/bcm947xx/include/flash.h 2005-12-15 15:34:44.280299250 +0100
6867 + * flash.h: Common definitions for flash access.
6869 + * Copyright 2005, Broadcom Corporation
6870 + * All Rights Reserved.
6872 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6873 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
6874 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
6875 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
6880 +/* Types of flashes we know about */
6881 +typedef enum _flash_type {OLD, BSC, SCS, AMD, SST, SFLASH} flash_type_t;
6883 +/* Commands to write/erase the flases */
6884 +typedef struct _flash_cmds{
6885 + flash_type_t type;
6888 + uint16 erase_block;
6889 + uint16 erase_chip;
6890 + uint16 write_word;
6896 + uint16 read_array;
6899 +#define UNLOCK_CMD_WORDS 2
6901 +typedef struct _unlock_cmd {
6902 + uint addr[UNLOCK_CMD_WORDS];
6903 + uint16 cmd[UNLOCK_CMD_WORDS];
6906 +/* Flash descriptors */
6907 +typedef struct _flash_desc {
6908 + uint16 mfgid; /* Manufacturer Id */
6909 + uint16 devid; /* Device Id */
6910 + uint size; /* Total size in bytes */
6911 + uint width; /* Device width in bytes */
6912 + flash_type_t type; /* Device type old, S, J */
6913 + uint bsize; /* Block size */
6914 + uint nb; /* Number of blocks */
6915 + uint ff; /* First full block */
6916 + uint lf; /* Last full block */
6917 + uint nsub; /* Number of subblocks */
6918 + uint *subblocks; /* Offsets for subblocks */
6919 + char *desc; /* Description */
6923 +#ifdef DECLARE_FLASHES
6924 +flash_cmds_t sflash_cmd_t =
6925 + { SFLASH, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
6927 +flash_cmds_t flash_cmds[] = {
6928 +/* type needu preera eraseb erasech write wbuf clcsr rdcsr rdid confrm read */
6929 + { BSC, 0, 0x00, 0x20, 0x00, 0x40, 0x00, 0x50, 0x70, 0x90, 0xd0, 0xff },
6930 + { SCS, 0, 0x00, 0x20, 0x00, 0x40, 0xe8, 0x50, 0x70, 0x90, 0xd0, 0xff },
6931 + { AMD, 1, 0x80, 0x30, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
6932 + { SST, 1, 0x80, 0x50, 0x10, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf0 },
6936 +unlock_cmd_t unlock_cmd_amd = {
6938 +/* addr: */ { 0x0aa8, 0x0556},
6940 +/* addr: */ { 0x0aaa, 0x0554},
6942 +/* data: */ { 0xaa, 0x55}
6945 +unlock_cmd_t unlock_cmd_sst = {
6947 +/* addr: */ { 0xaaa8, 0x5556},
6949 +/* addr: */ { 0xaaaa, 0x5554},
6951 +/* data: */ { 0xaa, 0x55}
6954 +#define AMD_CMD 0xaaa
6955 +#define SST_CMD 0xaaaa
6957 +/* intel unlock block cmds */
6958 +#define INTEL_UNLOCK1 0x60
6959 +#define INTEL_UNLOCK2 0xD0
6961 +/* Just eight blocks of 8KB byte each */
6963 +uint blk8x8k[] = { 0x00000000,
6974 +/* Funky AMD arrangement for 29xx800's */
6975 +uint amd800[] = { 0x00000000, /* 16KB */
6976 + 0x00004000, /* 32KB */
6977 + 0x0000c000, /* 8KB */
6978 + 0x0000e000, /* 8KB */
6979 + 0x00010000, /* 8KB */
6980 + 0x00012000, /* 8KB */
6981 + 0x00014000, /* 32KB */
6982 + 0x0001c000, /* 16KB */
6986 +/* AMD arrangement for 29xx160's */
6987 +uint amd4112[] = { 0x00000000, /* 32KB */
6988 + 0x00008000, /* 8KB */
6989 + 0x0000a000, /* 8KB */
6990 + 0x0000c000, /* 16KB */
6993 +uint amd2114[] = { 0x00000000, /* 16KB */
6994 + 0x00004000, /* 8KB */
6995 + 0x00006000, /* 8KB */
6996 + 0x00008000, /* 32KB */
7001 +flash_desc_t sflash_desc =
7002 + { 0, 0, 0, 0, SFLASH, 0, 0, 0, 0, 0, NULL, "SFLASH" };
7004 +flash_desc_t flashes[] = {
7005 + { 0x00b0, 0x00d0, 0x0200000, 2, SCS, 0x10000, 32, 0, 31, 0, NULL, "Intel 28F160S3/5 1Mx16" },
7006 + { 0x00b0, 0x00d4, 0x0400000, 2, SCS, 0x10000, 64, 0, 63, 0, NULL, "Intel 28F320S3/5 2Mx16" },
7007 + { 0x0089, 0x8890, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160B3 1Mx16 TopB" },
7008 + { 0x0089, 0x8891, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160B3 1Mx16 BotB" },
7009 + { 0x0089, 0x8896, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320B3 2Mx16 TopB" },
7010 + { 0x0089, 0x8897, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320B3 2Mx16 BotB" },
7011 + { 0x0089, 0x8898, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640B3 4Mx16 TopB" },
7012 + { 0x0089, 0x8899, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640B3 4Mx16 BotB" },
7013 + { 0x0089, 0x88C2, 0x0200000, 2, BSC, 0x10000, 32, 0, 30, 8, blk8x8k, "Intel 28F160C3 1Mx16 TopB" },
7014 + { 0x0089, 0x88C3, 0x0200000, 2, BSC, 0x10000, 32, 1, 31, 8, blk8x8k, "Intel 28F160C3 1Mx16 BotB" },
7015 + { 0x0089, 0x88C4, 0x0400000, 2, BSC, 0x10000, 64, 0, 62, 8, blk8x8k, "Intel 28F320C3 2Mx16 TopB" },
7016 + { 0x0089, 0x88C5, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Intel 28F320C3 2Mx16 BotB" },
7017 + { 0x0089, 0x88CC, 0x0800000, 2, BSC, 0x10000, 128, 0, 126, 8, blk8x8k, "Intel 28F640C3 4Mx16 TopB" },
7018 + { 0x0089, 0x88CD, 0x0800000, 2, BSC, 0x10000, 128, 1, 127, 8, blk8x8k, "Intel 28F640C3 4Mx16 BotB" },
7019 + { 0x0089, 0x0014, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J5 2Mx16" },
7020 + { 0x0089, 0x0015, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J5 4Mx16" },
7021 + { 0x0089, 0x0016, 0x0400000, 2, SCS, 0x20000, 32, 0, 31, 0, NULL, "Intel 28F320J3 2Mx16" },
7022 + { 0x0089, 0x0017, 0x0800000, 2, SCS, 0x20000, 64, 0, 63, 0, NULL, "Intel 28F640J3 4Mx16" },
7023 + { 0x0089, 0x0018, 0x1000000, 2, SCS, 0x20000, 128, 0, 127, 0, NULL, "Intel 28F128J3 8Mx16" },
7024 + { 0x00b0, 0x00e3, 0x0400000, 2, BSC, 0x10000, 64, 1, 63, 8, blk8x8k, "Sharp 28F320BJE 2Mx16 BotB" },
7025 + { 0x0001, 0x224a, 0x0100000, 2, AMD, 0x10000, 16, 0, 13, 8, amd800, "AMD 29DL800BT 512Kx16 TopB" },
7026 + { 0x0001, 0x22cb, 0x0100000, 2, AMD, 0x10000, 16, 2, 15, 8, amd800, "AMD 29DL800BB 512Kx16 BotB" },
7027 + { 0x0001, 0x22c4, 0x0200000, 2, AMD, 0x10000, 32, 0, 30, 4, amd2114, "AMD 29lv160DT 1Mx16 TopB" },
7028 + { 0x0001, 0x2249, 0x0200000, 2, AMD, 0x10000, 32, 1, 31, 4, amd4112, "AMD 29lv160DB 1Mx16 BotB" },
7029 + { 0x0001, 0x22f6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320DT 2Mx16 TopB" },
7030 + { 0x0001, 0x22f9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320DB 2Mx16 BotB" },
7031 + { 0x0001, 0x227e, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 8, blk8x8k, "AMD 29lv320MT 2Mx16 TopB" },
7032 + { 0x0001, 0x2200, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 8, blk8x8k, "AMD 29lv320MB 2Mx16 BotB" },
7033 + { 0x0020, 0x22CA, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "ST 29w320DT 2Mx16 TopB" },
7034 + { 0x0020, 0x22CB, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "ST 29w320DB 2Mx16 BotB" },
7035 + { 0x00C2, 0x00A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
7036 + { 0x00C2, 0x00A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
7037 + { 0x0004, 0x22F6, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MBM29LV320TE 2Mx16 TopB" },
7038 + { 0x0004, 0x22F9, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MBM29LV320BE 2Mx16 BotB" },
7039 + { 0x0098, 0x009A, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "TC58FVT321 2Mx16 TopB" },
7040 + { 0x0098, 0x009C, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "TC58FVB321 2Mx16 BotB" },
7041 + { 0x00C2, 0x22A7, 0x0400000, 2, AMD, 0x10000, 64, 0, 62, 4, amd4112, "MX29LV320T 2Mx16 TopB" },
7042 + { 0x00C2, 0x22A8, 0x0400000, 2, AMD, 0x10000, 64, 1, 63, 4, amd2114, "MX29LV320B 2Mx16 BotB" },
7043 + { 0x00BF, 0x2783, 0x0400000, 2, SST, 0x10000, 64, 0, 63, 0, NULL, "SST39VF320 2Mx16" },
7044 + { 0, 0, 0, 0, OLD, 0, 0, 0, 0, 0, NULL, NULL },
7049 +extern flash_cmds_t flash_cmds[];
7050 +extern unlock_cmd_t unlock_cmd;
7051 +extern flash_desc_t flashes[];
7054 diff -urN linux.old/arch/mips/bcm947xx/include/flashutl.h linux.dev/arch/mips/bcm947xx/include/flashutl.h
7055 --- linux.old/arch/mips/bcm947xx/include/flashutl.h 1970-01-01 01:00:00.000000000 +0100
7056 +++ linux.dev/arch/mips/bcm947xx/include/flashutl.h 2005-12-15 15:34:48.160541750 +0100
7059 + * BCM47XX FLASH driver interface
7061 + * Copyright 2005, Broadcom Corporation
7062 + * All Rights Reserved.
7064 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7065 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7066 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7067 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7071 +#ifndef _flashutl_h_
7072 +#define _flashutl_h_
7075 +#ifndef _LANGUAGE_ASSEMBLY
7077 +int sysFlashInit(char *flash_str);
7078 +int sysFlashRead(uint off, uchar *dst, uint bytes);
7079 +int sysFlashWrite(uint off, uchar *src, uint bytes);
7080 +void nvWrite(unsigned short *data, unsigned int len);
7082 +#endif /* _LANGUAGE_ASSEMBLY */
7084 +#endif /* _flashutl_h_ */
7085 diff -urN linux.old/arch/mips/bcm947xx/include/hndmips.h linux.dev/arch/mips/bcm947xx/include/hndmips.h
7086 --- linux.old/arch/mips/bcm947xx/include/hndmips.h 1970-01-01 01:00:00.000000000 +0100
7087 +++ linux.dev/arch/mips/bcm947xx/include/hndmips.h 2005-12-15 15:34:53.396869000 +0100
7090 + * Alternate include file for HND sbmips.h since CFE also ships with
7093 + * Copyright 2005, Broadcom Corporation
7094 + * All Rights Reserved.
7096 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7097 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7098 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7099 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7104 +#include "sbmips.h"
7105 diff -urN linux.old/arch/mips/bcm947xx/include/linux_osl.h linux.dev/arch/mips/bcm947xx/include/linux_osl.h
7106 --- linux.old/arch/mips/bcm947xx/include/linux_osl.h 1970-01-01 01:00:00.000000000 +0100
7107 +++ linux.dev/arch/mips/bcm947xx/include/linux_osl.h 2005-12-15 17:23:39.225126750 +0100
7110 + * Linux OS Independent Layer
7112 + * Copyright 2005, Broadcom Corporation
7113 + * All Rights Reserved.
7115 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7116 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7117 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7118 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7123 +#ifndef _linux_osl_h_
7124 +#define _linux_osl_h_
7126 +#include <typedefs.h>
7128 +/* use current 2.4.x calling conventions */
7129 +#include <linuxver.h>
7131 +/* assert and panic */
7133 +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
7134 +#if GCC_VERSION > 30100
7135 +#define ASSERT(exp) do {} while (0)
7137 +/* ASSERT could causes segmentation fault on GCC3.1, use empty instead*/
7138 +#define ASSERT(exp)
7142 +/* microsecond delay */
7143 +#define OSL_DELAY(usec) osl_delay(usec)
7144 +extern void osl_delay(uint usec);
7146 +/* PCI configuration space access macros */
7147 +#define OSL_PCI_READ_CONFIG(osh, offset, size) \
7148 + osl_pci_read_config((osh), (offset), (size))
7149 +#define OSL_PCI_WRITE_CONFIG(osh, offset, size, val) \
7150 + osl_pci_write_config((osh), (offset), (size), (val))
7151 +extern uint32 osl_pci_read_config(osl_t *osh, uint size, uint offset);
7152 +extern void osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val);
7154 +/* PCI device bus # and slot # */
7155 +#define OSL_PCI_BUS(osh) osl_pci_bus(osh)
7156 +#define OSL_PCI_SLOT(osh) osl_pci_slot(osh)
7157 +extern uint osl_pci_bus(osl_t *osh);
7158 +extern uint osl_pci_slot(osl_t *osh);
7160 +/* OSL initialization */
7161 +extern osl_t *osl_attach(void *pdev);
7162 +extern void osl_detach(osl_t *osh);
7164 +/* host/bus architecture-specific byte swap */
7165 +#define BUS_SWAP32(v) (v)
7167 +/* general purpose memory allocation */
7169 +#define MALLOC(osh, size) kmalloc(size, GFP_ATOMIC)
7170 +#define MFREE(osh, addr, size) kfree(addr);
7172 +#define MALLOC_FAILED(osh) osl_malloc_failed((osh))
7174 +extern void *osl_malloc(osl_t *osh, uint size);
7175 +extern void osl_mfree(osl_t *osh, void *addr, uint size);
7176 +extern uint osl_malloced(osl_t *osh);
7177 +extern uint osl_malloc_failed(osl_t *osh);
7179 +/* allocate/free shared (dma-able) consistent memory */
7180 +#define DMA_CONSISTENT_ALIGN PAGE_SIZE
7181 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) \
7182 + osl_dma_alloc_consistent((osh), (size), (pap))
7183 +#define DMA_FREE_CONSISTENT(osh, va, size, pa) \
7184 + osl_dma_free_consistent((osh), (void*)(va), (size), (pa))
7185 +extern void *osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap);
7186 +extern void osl_dma_free_consistent(osl_t *osh, void *va, uint size, ulong pa);
7188 +/* map/unmap direction */
7192 +/* register access macros */
7193 +#if defined(BCMJTAG)
7194 +#include <bcmjtag.h>
7195 +#define R_REG(r) bcmjtag_read(NULL, (uint32)(r), sizeof (*(r)))
7196 +#define W_REG(r, v) bcmjtag_write(NULL, (uint32)(r), (uint32)(v), sizeof (*(r)))
7200 + * BINOSL selects the slightly slower function-call-based binary compatible osl.
7201 + * Macros expand to calls to functions defined in linux_osl.c .
7205 +/* string library, kernel mode */
7206 +#define printf(fmt, args...) printk(fmt, ## args)
7207 +#include <linux/kernel.h>
7208 +#include <linux/string.h>
7210 +/* register access macros */
7211 +#if !defined(BCMJTAG)
7212 +#ifndef IL_BIGENDIAN
7213 +#define R_REG(r) ( \
7214 + sizeof(*(r)) == sizeof(uint8) ? readb((volatile uint8*)(r)) : \
7215 + sizeof(*(r)) == sizeof(uint16) ? readw((volatile uint16*)(r)) : \
7216 + readl((volatile uint32*)(r)) \
7218 +#define W_REG(r, v) do { \
7219 + switch (sizeof(*(r))) { \
7220 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)(r)); break; \
7221 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)(r)); break; \
7222 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \
7225 +#else /* IL_BIGENDIAN */
7226 +#define R_REG(r) ({ \
7227 + __typeof(*(r)) __osl_v; \
7228 + switch (sizeof(*(r))) { \
7229 + case sizeof(uint8): __osl_v = readb((volatile uint8*)((uint32)r^3)); break; \
7230 + case sizeof(uint16): __osl_v = readw((volatile uint16*)((uint32)r^2)); break; \
7231 + case sizeof(uint32): __osl_v = readl((volatile uint32*)(r)); break; \
7235 +#define W_REG(r, v) do { \
7236 + switch (sizeof(*(r))) { \
7237 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)((uint32)r^3)); break; \
7238 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)((uint32)r^2)); break; \
7239 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \
7245 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
7246 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
7248 +/* bcopy, bcmp, and bzero */
7249 +#define bcopy(src, dst, len) memcpy((dst), (src), (len))
7250 +#define bcmp(b1, b2, len) memcmp((b1), (b2), (len))
7251 +#define bzero(b, len) memset((b), '\0', (len))
7253 +/* uncached virtual address */
7255 +#define OSL_UNCACHED(va) KSEG1ADDR((va))
7256 +#include <asm/addrspace.h>
7258 +#define OSL_UNCACHED(va) (va)
7261 +/* get processor cycle count */
7263 +#define OSL_GETCYCLES(x) ((x) = read_c0_count() * 2)
7264 +#elif defined(__i386__)
7265 +#define OSL_GETCYCLES(x) rdtscl((x))
7267 +#define OSL_GETCYCLES(x) ((x) = 0)
7270 +/* dereference an address that may cause a bus exception */
7272 +#if defined(MODULE) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,17))
7273 +#define BUSPROBE(val, addr) panic("get_dbe() will not fixup a bus exception when compiled into a module")
7275 +#define BUSPROBE(val, addr) get_dbe((val), (addr))
7276 +#include <asm/paccess.h>
7279 +#define BUSPROBE(val, addr) ({ (val) = R_REG((addr)); 0; })
7282 +/* map/unmap physical to virtual I/O */
7283 +#define REG_MAP(pa, size) ioremap_nocache((unsigned long)(pa), (unsigned long)(size))
7284 +#define REG_UNMAP(va) iounmap((void *)(va))
7286 +/* shared (dma-able) memory access macros */
7287 +#define R_SM(r) *(r)
7288 +#define W_SM(r, v) (*(r) = (v))
7289 +#define BZERO_SM(r, len) memset((r), '\0', (len))
7291 +/* packet primitives */
7292 +#define PKTGET(osh, len, send) osl_pktget((osh), (len), (send))
7293 +#define PKTFREE(osh, skb, send) osl_pktfree((skb))
7294 +#define PKTDATA(osh, skb) (((struct sk_buff*)(skb))->data)
7295 +#define PKTLEN(osh, skb) (((struct sk_buff*)(skb))->len)
7296 +#define PKTHEADROOM(osh, skb) (PKTDATA(osh,skb)-(((struct sk_buff*)(skb))->head))
7297 +#define PKTTAILROOM(osh, skb) ((((struct sk_buff*)(skb))->end)-(((struct sk_buff*)(skb))->tail))
7298 +#define PKTNEXT(osh, skb) (((struct sk_buff*)(skb))->next)
7299 +#define PKTSETNEXT(skb, x) (((struct sk_buff*)(skb))->next = (struct sk_buff*)(x))
7300 +#define PKTSETLEN(osh, skb, len) __skb_trim((struct sk_buff*)(skb), (len))
7301 +#define PKTPUSH(osh, skb, bytes) skb_push((struct sk_buff*)(skb), (bytes))
7302 +#define PKTPULL(osh, skb, bytes) skb_pull((struct sk_buff*)(skb), (bytes))
7303 +#define PKTDUP(osh, skb) skb_clone((struct sk_buff*)(skb), GFP_ATOMIC)
7304 +#define PKTCOOKIE(skb) ((void*)((struct sk_buff*)(skb))->csum)
7305 +#define PKTSETCOOKIE(skb, x) (((struct sk_buff*)(skb))->csum = (uint)(x))
7306 +#define PKTLINK(skb) (((struct sk_buff*)(skb))->prev)
7307 +#define PKTSETLINK(skb, x) (((struct sk_buff*)(skb))->prev = (struct sk_buff*)(x))
7308 +#define PKTPRIO(skb) (((struct sk_buff*)(skb))->priority)
7309 +#define PKTSETPRIO(skb, x) (((struct sk_buff*)(skb))->priority = (x))
7310 +extern void *osl_pktget(osl_t *osh, uint len, bool send);
7311 +extern void osl_pktfree(void *skb);
7315 +/* string library */
7318 +#define printf(fmt, args...) osl_printf((fmt), ## args)
7320 +#define sprintf(buf, fmt, args...) osl_sprintf((buf), (fmt), ## args)
7322 +#define strcmp(s1, s2) osl_strcmp((s1), (s2))
7324 +#define strncmp(s1, s2, n) osl_strncmp((s1), (s2), (n))
7326 +#define strlen(s) osl_strlen((s))
7328 +#define strcpy(d, s) osl_strcpy((d), (s))
7330 +#define strncpy(d, s, n) osl_strncpy((d), (s), (n))
7332 +extern int osl_printf(const char *format, ...);
7333 +extern int osl_sprintf(char *buf, const char *format, ...);
7334 +extern int osl_strcmp(const char *s1, const char *s2);
7335 +extern int osl_strncmp(const char *s1, const char *s2, uint n);
7336 +extern int osl_strlen(const char *s);
7337 +extern char* osl_strcpy(char *d, const char *s);
7338 +extern char* osl_strncpy(char *d, const char *s, uint n);
7340 +/* register access macros */
7341 +#if !defined(BCMJTAG)
7342 +#define R_REG(r) ( \
7343 + sizeof(*(r)) == sizeof(uint8) ? osl_readb((volatile uint8*)(r)) : \
7344 + sizeof(*(r)) == sizeof(uint16) ? osl_readw((volatile uint16*)(r)) : \
7345 + osl_readl((volatile uint32*)(r)) \
7347 +#define W_REG(r, v) do { \
7348 + switch (sizeof(*(r))) { \
7349 + case sizeof(uint8): osl_writeb((uint8)(v), (volatile uint8*)(r)); break; \
7350 + case sizeof(uint16): osl_writew((uint16)(v), (volatile uint16*)(r)); break; \
7351 + case sizeof(uint32): osl_writel((uint32)(v), (volatile uint32*)(r)); break; \
7356 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
7357 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
7358 +extern uint8 osl_readb(volatile uint8 *r);
7359 +extern uint16 osl_readw(volatile uint16 *r);
7360 +extern uint32 osl_readl(volatile uint32 *r);
7361 +extern void osl_writeb(uint8 v, volatile uint8 *r);
7362 +extern void osl_writew(uint16 v, volatile uint16 *r);
7363 +extern void osl_writel(uint32 v, volatile uint32 *r);
7365 +/* bcopy, bcmp, and bzero */
7366 +extern void bcopy(const void *src, void *dst, int len);
7367 +extern int bcmp(const void *b1, const void *b2, int len);
7368 +extern void bzero(void *b, int len);
7370 +/* uncached virtual address */
7371 +#define OSL_UNCACHED(va) osl_uncached((va))
7372 +extern void *osl_uncached(void *va);
7374 +/* get processor cycle count */
7375 +#define OSL_GETCYCLES(x) ((x) = osl_getcycles())
7376 +extern uint osl_getcycles(void);
7378 +/* dereference an address that may target abort */
7379 +#define BUSPROBE(val, addr) osl_busprobe(&(val), (addr))
7380 +extern int osl_busprobe(uint32 *val, uint32 addr);
7382 +/* map/unmap physical to virtual */
7383 +#define REG_MAP(pa, size) osl_reg_map((pa), (size))
7384 +#define REG_UNMAP(va) osl_reg_unmap((va))
7385 +extern void *osl_reg_map(uint32 pa, uint size);
7386 +extern void osl_reg_unmap(void *va);
7388 +/* shared (dma-able) memory access macros */
7389 +#define R_SM(r) *(r)
7390 +#define W_SM(r, v) (*(r) = (v))
7391 +#define BZERO_SM(r, len) bzero((r), (len))
7393 +/* packet primitives */
7394 +#define PKTGET(osh, len, send) osl_pktget((osh), (len), (send))
7395 +#define PKTFREE(osh, skb, send) osl_pktfree((skb))
7396 +#define PKTDATA(osh, skb) osl_pktdata((osh), (skb))
7397 +#define PKTLEN(osh, skb) osl_pktlen((osh), (skb))
7398 +#define PKTHEADROOM(osh, skb) osl_pktheadroom((osh), (skb))
7399 +#define PKTTAILROOM(osh, skb) osl_pkttailroom((osh), (skb))
7400 +#define PKTNEXT(osh, skb) osl_pktnext((osh), (skb))
7401 +#define PKTSETNEXT(skb, x) osl_pktsetnext((skb), (x))
7402 +#define PKTSETLEN(osh, skb, len) osl_pktsetlen((osh), (skb), (len))
7403 +#define PKTPUSH(osh, skb, bytes) osl_pktpush((osh), (skb), (bytes))
7404 +#define PKTPULL(osh, skb, bytes) osl_pktpull((osh), (skb), (bytes))
7405 +#define PKTDUP(osh, skb) osl_pktdup((osh), (skb))
7406 +#define PKTCOOKIE(skb) osl_pktcookie((skb))
7407 +#define PKTSETCOOKIE(skb, x) osl_pktsetcookie((skb), (x))
7408 +#define PKTLINK(skb) osl_pktlink((skb))
7409 +#define PKTSETLINK(skb, x) osl_pktsetlink((skb), (x))
7410 +#define PKTPRIO(skb) osl_pktprio((skb))
7411 +#define PKTSETPRIO(skb, x) osl_pktsetprio((skb), (x))
7412 +extern void *osl_pktget(osl_t *osh, uint len, bool send);
7413 +extern void osl_pktfree(void *skb);
7414 +extern uchar *osl_pktdata(osl_t *osh, void *skb);
7415 +extern uint osl_pktlen(osl_t *osh, void *skb);
7416 +extern uint osl_pktheadroom(osl_t *osh, void *skb);
7417 +extern uint osl_pkttailroom(osl_t *osh, void *skb);
7418 +extern void *osl_pktnext(osl_t *osh, void *skb);
7419 +extern void osl_pktsetnext(void *skb, void *x);
7420 +extern void osl_pktsetlen(osl_t *osh, void *skb, uint len);
7421 +extern uchar *osl_pktpush(osl_t *osh, void *skb, int bytes);
7422 +extern uchar *osl_pktpull(osl_t *osh, void *skb, int bytes);
7423 +extern void *osl_pktdup(osl_t *osh, void *skb);
7424 +extern void *osl_pktcookie(void *skb);
7425 +extern void osl_pktsetcookie(void *skb, void *x);
7426 +extern void *osl_pktlink(void *skb);
7427 +extern void osl_pktsetlink(void *skb, void *x);
7428 +extern uint osl_pktprio(void *skb);
7429 +extern void osl_pktsetprio(void *skb, uint x);
7431 +#endif /* BINOSL */
7433 +#define OSL_ERROR(bcmerror) osl_error(bcmerror)
7434 +extern int osl_error(int bcmerror);
7436 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
7437 +#define PKTBUFSZ 2048
7439 +#endif /* _linux_osl_h_ */
7440 diff -urN linux.old/arch/mips/bcm947xx/include/linuxver.h linux.dev/arch/mips/bcm947xx/include/linuxver.h
7441 --- linux.old/arch/mips/bcm947xx/include/linuxver.h 1970-01-01 01:00:00.000000000 +0100
7442 +++ linux.dev/arch/mips/bcm947xx/include/linuxver.h 2005-12-15 16:02:45.467929000 +0100
7445 + * Linux-specific abstractions to gain some independence from linux kernel versions.
7446 + * Pave over some 2.2 versus 2.4 versus 2.6 kernel differences.
7448 + * Copyright 2005, Broadcom Corporation
7449 + * All Rights Reserved.
7451 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7452 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7453 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7454 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7459 +#ifndef _linuxver_h_
7460 +#define _linuxver_h_
7462 +#include <linux/config.h>
7463 +#include <linux/version.h>
7465 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
7466 +/* __NO_VERSION__ must be defined for all linkables except one in 2.2 */
7467 +#ifdef __UNDEF_NO_VERSION__
7468 +#undef __NO_VERSION__
7470 +#define __NO_VERSION__
7474 +#if defined(MODULE) && defined(MODVERSIONS)
7475 +#include <linux/modversions.h>
7478 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
7479 +#include <linux/moduleparam.h>
7483 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
7484 +#define module_param(_name_, _type_, _perm_) MODULE_PARM(_name_, "i")
7485 +#define module_param_string(_name_, _string_, _size_, _perm_) MODULE_PARM(_string_, "c" __MODULE_STRING(_size_))
7488 +/* linux/malloc.h is deprecated, use linux/slab.h instead. */
7489 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,9))
7490 +#include <linux/malloc.h>
7492 +#include <linux/slab.h>
7495 +#include <linux/types.h>
7496 +#include <linux/init.h>
7497 +#include <linux/mm.h>
7498 +#include <linux/string.h>
7499 +#include <linux/pci.h>
7500 +#include <linux/interrupt.h>
7501 +#include <linux/netdevice.h>
7502 +#include <asm/io.h>
7504 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41))
7505 +#include <linux/workqueue.h>
7507 +#include <linux/tqueue.h>
7508 +#ifndef work_struct
7509 +#define work_struct tq_struct
7512 +#define INIT_WORK(_work, _func, _data) INIT_TQUEUE((_work), (_func), (_data))
7514 +#ifndef schedule_work
7515 +#define schedule_work(_work) schedule_task((_work))
7517 +#ifndef flush_scheduled_work
7518 +#define flush_scheduled_work() flush_scheduled_tasks()
7522 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
7523 +/* Some distributions have their own 2.6.x compatibility layers */
7525 +typedef void irqreturn_t;
7527 +#define IRQ_HANDLED
7528 +#define IRQ_RETVAL(x)
7531 +typedef irqreturn_t (*FN_ISR) (int irq, void *dev_id, struct pt_regs *ptregs);
7541 +#define __devinit __init
7543 +#ifndef __devinitdata
7544 +#define __devinitdata
7546 +#ifndef __devexit_p
7547 +#define __devexit_p(x) x
7550 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
7552 +#define pci_get_drvdata(dev) (dev)->sysdata
7553 +#define pci_set_drvdata(dev, value) (dev)->sysdata=(value)
7556 + * New-style (2.4.x) PCI/hot-pluggable PCI/CardBus registration
7559 +struct pci_device_id {
7560 + unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */
7561 + unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
7562 + unsigned int class, class_mask; /* (class,subclass,prog-if) triplet */
7563 + unsigned long driver_data; /* Data private to the driver */
7566 +struct pci_driver {
7567 + struct list_head node;
7569 + const struct pci_device_id *id_table; /* NULL if wants all devices */
7570 + int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
7571 + void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
7572 + void (*suspend)(struct pci_dev *dev); /* Device suspended */
7573 + void (*resume)(struct pci_dev *dev); /* Device woken up */
7576 +#define MODULE_DEVICE_TABLE(type, name)
7577 +#define PCI_ANY_ID (~0)
7580 +#define pci_module_init pci_register_driver
7581 +extern int pci_register_driver(struct pci_driver *drv);
7582 +extern void pci_unregister_driver(struct pci_driver *drv);
7584 +#endif /* PCI registration */
7586 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
7588 +#define module_init(x) int init_module(void) { return x(); }
7589 +#define module_exit(x) void cleanup_module(void) { x(); }
7591 +#define module_init(x) __initcall(x);
7592 +#define module_exit(x) __exitcall(x);
7596 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,48))
7597 +#define list_for_each(pos, head) \
7598 + for (pos = (head)->next; pos != (head); pos = pos->next)
7601 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,13))
7602 +#define pci_resource_start(dev, bar) ((dev)->base_address[(bar)])
7603 +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,44))
7604 +#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
7607 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,23))
7608 +#define pci_enable_device(dev) do { } while (0)
7611 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,14))
7612 +#define net_device device
7615 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,42))
7620 + * See linux/Documentation/DMA-mapping.txt
7623 +#ifndef PCI_DMA_TODEVICE
7624 +#define PCI_DMA_TODEVICE 1
7625 +#define PCI_DMA_FROMDEVICE 2
7628 +typedef u32 dma_addr_t;
7630 +/* Pure 2^n version of get_order */
7631 +static inline int get_order(unsigned long size)
7635 + size = (size-1) >> (PAGE_SHIFT-1);
7644 +static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
7645 + dma_addr_t *dma_handle)
7648 + int gfp = GFP_ATOMIC | GFP_DMA;
7650 + ret = (void *)__get_free_pages(gfp, get_order(size));
7652 + if (ret != NULL) {
7653 + memset(ret, 0, size);
7654 + *dma_handle = virt_to_bus(ret);
7658 +static inline void pci_free_consistent(struct pci_dev *hwdev, size_t size,
7659 + void *vaddr, dma_addr_t dma_handle)
7661 + free_pages((unsigned long)vaddr, get_order(size));
7664 +extern uint pci_map_single(void *dev, void *va, uint size, int direction);
7665 +extern void pci_unmap_single(void *dev, uint pa, uint size, int direction);
7667 +#define pci_map_single(cookie, address, size, dir) virt_to_bus(address)
7668 +#define pci_unmap_single(cookie, address, size, dir)
7671 +#endif /* DMA mapping */
7673 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,43))
7675 +#define dev_kfree_skb_any(a) dev_kfree_skb(a)
7676 +#define netif_down(dev) do { (dev)->start = 0; } while(0)
7678 +/* pcmcia-cs provides its own netdevice compatibility layer */
7679 +#ifndef _COMPAT_NETDEVICE_H
7684 + * For pre-softnet kernels we need to tell the upper layer not to
7685 + * re-enter start_xmit() while we are in there. However softnet
7686 + * guarantees not to enter while we are in there so there is no need
7687 + * to do the netif_stop_queue() dance unless the transmit queue really
7688 + * gets stuck. This should also improve performance according to tests
7689 + * done by Aman Singla.
7692 +#define dev_kfree_skb_irq(a) dev_kfree_skb(a)
7693 +#define netif_wake_queue(dev) do { clear_bit(0, &(dev)->tbusy); mark_bh(NET_BH); } while(0)
7694 +#define netif_stop_queue(dev) set_bit(0, &(dev)->tbusy)
7696 +static inline void netif_start_queue(struct net_device *dev)
7699 + dev->interrupt = 0;
7703 +#define netif_queue_stopped(dev) (dev)->tbusy
7704 +#define netif_running(dev) (dev)->start
7706 +#endif /* _COMPAT_NETDEVICE_H */
7708 +#define netif_device_attach(dev) netif_start_queue(dev)
7709 +#define netif_device_detach(dev) netif_stop_queue(dev)
7711 +/* 2.4.x renamed bottom halves to tasklets */
7712 +#define tasklet_struct tq_struct
7713 +static inline void tasklet_schedule(struct tasklet_struct *tasklet)
7715 + queue_task(tasklet, &tq_immediate);
7716 + mark_bh(IMMEDIATE_BH);
7719 +static inline void tasklet_init(struct tasklet_struct *tasklet,
7720 + void (*func)(unsigned long),
7721 + unsigned long data)
7723 + tasklet->next = NULL;
7724 + tasklet->sync = 0;
7725 + tasklet->routine = (void (*)(void *))func;
7726 + tasklet->data = (void *)data;
7728 +#define tasklet_kill(tasklet) {do{} while(0);}
7730 +/* 2.4.x introduced del_timer_sync() */
7731 +#define del_timer_sync(timer) del_timer(timer)
7735 +#define netif_down(dev)
7737 +#endif /* SoftNet */
7739 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3))
7742 + * Emit code to initialise a tq_struct's routine and data pointers
7744 +#define PREPARE_TQUEUE(_tq, _routine, _data) \
7746 + (_tq)->routine = _routine; \
7747 + (_tq)->data = _data; \
7751 + * Emit code to initialise all of a tq_struct
7753 +#define INIT_TQUEUE(_tq, _routine, _data) \
7755 + INIT_LIST_HEAD(&(_tq)->list); \
7756 + (_tq)->sync = 0; \
7757 + PREPARE_TQUEUE((_tq), (_routine), (_data)); \
7762 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6))
7764 +/* Power management related routines */
7767 +pci_save_state(struct pci_dev *dev, u32 *buffer)
7771 + for (i = 0; i < 16; i++)
7772 + pci_read_config_dword(dev, i * 4,&buffer[i]);
7778 +pci_restore_state(struct pci_dev *dev, u32 *buffer)
7783 + for (i = 0; i < 16; i++)
7784 + pci_write_config_dword(dev,i * 4, buffer[i]);
7787 + * otherwise, write the context information we know from bootup.
7788 + * This works around a problem where warm-booting from Windows
7789 + * combined with a D3(hot)->D0 transition causes PCI config
7790 + * header data to be forgotten.
7793 + for (i = 0; i < 6; i ++)
7794 + pci_write_config_dword(dev,
7795 + PCI_BASE_ADDRESS_0 + (i * 4),
7796 + pci_resource_start(dev, i));
7797 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
7802 +#endif /* PCI power management */
7804 +/* Old cp0 access macros deprecated in 2.4.19 */
7805 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19))
7806 +#define read_c0_count() read_32bit_cp0_register(CP0_COUNT)
7809 +/* Module refcount handled internally in 2.6.x */
7810 +#ifndef SET_MODULE_OWNER
7811 +#define SET_MODULE_OWNER(dev) do {} while (0)
7812 +#define OLD_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
7813 +#define OLD_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
7815 +#define OLD_MOD_INC_USE_COUNT do {} while (0)
7816 +#define OLD_MOD_DEC_USE_COUNT do {} while (0)
7819 +#ifndef SET_NETDEV_DEV
7820 +#define SET_NETDEV_DEV(net, pdev) do {} while (0)
7823 +#ifndef HAVE_FREE_NETDEV
7824 +#define free_netdev(dev) kfree(dev)
7827 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
7828 +/* struct packet_type redefined in 2.6.x */
7829 +#define af_packet_priv data
7832 +#endif /* _linuxver_h_ */
7833 diff -urN linux.old/arch/mips/bcm947xx/include/mipsinc.h linux.dev/arch/mips/bcm947xx/include/mipsinc.h
7834 --- linux.old/arch/mips/bcm947xx/include/mipsinc.h 1970-01-01 01:00:00.000000000 +0100
7835 +++ linux.dev/arch/mips/bcm947xx/include/mipsinc.h 2005-12-15 16:47:29.886633750 +0100
7838 + * HND Run Time Environment for standalone MIPS programs.
7840 + * Copyright 2005, Broadcom Corporation
7841 + * All Rights Reserved.
7843 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7844 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7845 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
7846 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
7857 +#ifdef _LANGUAGE_ASSEMBLY
7860 + * Symbolic register names for 32 bit ABI
7862 +#define zero $0 /* wired zero */
7863 +#define AT $1 /* assembler temp - uppercase because of ".set at" */
7864 +#define v0 $2 /* return value */
7866 +#define a0 $4 /* argument registers */
7870 +#define t0 $8 /* caller saved */
7878 +#define s0 $16 /* callee saved */
7886 +#define t8 $24 /* caller saved */
7888 +#define jp $25 /* PIC jump register */
7889 +#define k0 $26 /* kernel scratch */
7891 +#define gp $28 /* global pointer */
7892 +#define sp $29 /* stack pointer */
7893 +#define fp $30 /* frame pointer */
7894 +#define s8 $30 /* same like fp! */
7895 +#define ra $31 /* return address */
7904 +#define C0_TLBLO0 $2
7905 +#define C0_TLBLO C0_TLBLO0
7906 +#define C0_TLBLO1 $3
7907 +#define C0_CTEXT $4
7908 +#define C0_PGMASK $5
7909 +#define C0_WIRED $6
7910 +#define C0_BADVADDR $8
7911 +#define C0_COUNT $9
7912 +#define C0_TLBHI $10
7913 +#define C0_COMPARE $11
7915 +#define C0_STATUS C0_SR
7916 +#define C0_CAUSE $13
7918 +#define C0_PRID $15
7919 +#define C0_CONFIG $16
7920 +#define C0_LLADDR $17
7921 +#define C0_WATCHLO $18
7922 +#define C0_WATCHHI $19
7923 +#define C0_XCTEXT $20
7924 +#define C0_DIAGNOSTIC $22
7925 +#define C0_BROADCOM C0_DIAGNOSTIC
7926 +#define C0_PERFORMANCE $25
7928 +#define C0_CACHEERR $27
7929 +#define C0_TAGLO $28
7930 +#define C0_TAGHI $29
7931 +#define C0_ERREPC $30
7932 +#define C0_DESAVE $31
7935 + * LEAF - declare leaf routine
7937 +#define LEAF(symbol) \
7940 + .type symbol,@function; \
7942 +symbol: .frame sp,0,ra
7945 + * END - mark end of function
7947 +#define END(function) \
7949 + .size function,.-function
7956 + * The following macros are especially useful for __asm__
7957 + * inline assembler.
7960 +#define __STR(x) #x
7963 +#define STR(x) __STR(x)
7966 +#define _ULCAST_ (unsigned long)
7973 +#define C0_INX 0 /* CP0: TLB Index */
7974 +#define C0_RAND 1 /* CP0: TLB Random */
7975 +#define C0_TLBLO0 2 /* CP0: TLB EntryLo0 */
7976 +#define C0_TLBLO C0_TLBLO0 /* CP0: TLB EntryLo0 */
7977 +#define C0_TLBLO1 3 /* CP0: TLB EntryLo1 */
7978 +#define C0_CTEXT 4 /* CP0: Context */
7979 +#define C0_PGMASK 5 /* CP0: TLB PageMask */
7980 +#define C0_WIRED 6 /* CP0: TLB Wired */
7981 +#define C0_BADVADDR 8 /* CP0: Bad Virtual Address */
7982 +#define C0_COUNT 9 /* CP0: Count */
7983 +#define C0_TLBHI 10 /* CP0: TLB EntryHi */
7984 +#define C0_COMPARE 11 /* CP0: Compare */
7985 +#define C0_SR 12 /* CP0: Processor Status */
7986 +#define C0_STATUS C0_SR /* CP0: Processor Status */
7987 +#define C0_CAUSE 13 /* CP0: Exception Cause */
7988 +#define C0_EPC 14 /* CP0: Exception PC */
7989 +#define C0_PRID 15 /* CP0: Processor Revision Indentifier */
7990 +#define C0_CONFIG 16 /* CP0: Config */
7991 +#define C0_LLADDR 17 /* CP0: LLAddr */
7992 +#define C0_WATCHLO 18 /* CP0: WatchpointLo */
7993 +#define C0_WATCHHI 19 /* CP0: WatchpointHi */
7994 +#define C0_XCTEXT 20 /* CP0: XContext */
7995 +#define C0_DIAGNOSTIC 22 /* CP0: Diagnostic */
7996 +#define C0_BROADCOM C0_DIAGNOSTIC /* CP0: Broadcom Register */
7997 +#define C0_PERFORMANCE 25 /* CP0: Performance Counter/Control Registers */
7998 +#define C0_ECC 26 /* CP0: ECC */
7999 +#define C0_CACHEERR 27 /* CP0: CacheErr */
8000 +#define C0_TAGLO 28 /* CP0: TagLo */
8001 +#define C0_TAGHI 29 /* CP0: TagHi */
8002 +#define C0_ERREPC 30 /* CP0: ErrorEPC */
8003 +#define C0_DESAVE 31 /* CP0: DebugSave */
8005 +#endif /* _LANGUAGE_ASSEMBLY */
8008 + * Memory segments (32bit kernel mode addresses)
8015 +#define KUSEG 0x00000000
8016 +#define KSEG0 0x80000000
8017 +#define KSEG1 0xa0000000
8018 +#define KSEG2 0xc0000000
8019 +#define KSEG3 0xe0000000
8020 +#define PHYSADDR_MASK 0x1fffffff
8023 + * Map an address to a certain kernel segment
8031 +#define PHYSADDR(a) (_ULCAST_(a) & PHYSADDR_MASK)
8032 +#define KSEG0ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG0)
8033 +#define KSEG1ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG1)
8034 +#define KSEG2ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG2)
8035 +#define KSEG3ADDR(a) ((_ULCAST_(a) & PHYSADDR_MASK) | KSEG3)
8038 +#ifndef Index_Invalidate_I
8040 + * Cache Operations
8042 +#define Index_Invalidate_I 0x00
8043 +#define Index_Writeback_Inv_D 0x01
8044 +#define Index_Invalidate_SI 0x02
8045 +#define Index_Writeback_Inv_SD 0x03
8046 +#define Index_Load_Tag_I 0x04
8047 +#define Index_Load_Tag_D 0x05
8048 +#define Index_Load_Tag_SI 0x06
8049 +#define Index_Load_Tag_SD 0x07
8050 +#define Index_Store_Tag_I 0x08
8051 +#define Index_Store_Tag_D 0x09
8052 +#define Index_Store_Tag_SI 0x0A
8053 +#define Index_Store_Tag_SD 0x0B
8054 +#define Create_Dirty_Excl_D 0x0d
8055 +#define Create_Dirty_Excl_SD 0x0f
8056 +#define Hit_Invalidate_I 0x10
8057 +#define Hit_Invalidate_D 0x11
8058 +#define Hit_Invalidate_SI 0x12
8059 +#define Hit_Invalidate_SD 0x13
8060 +#define Fill_I 0x14
8061 +#define Hit_Writeback_Inv_D 0x15
8062 + /* 0x16 is unused */
8063 +#define Hit_Writeback_Inv_SD 0x17
8064 +#define R5K_Page_Invalidate_S 0x17
8065 +#define Hit_Writeback_I 0x18
8066 +#define Hit_Writeback_D 0x19
8067 + /* 0x1a is unused */
8068 +#define Hit_Writeback_SD 0x1b
8069 + /* 0x1c is unused */
8070 + /* 0x1e is unused */
8071 +#define Hit_Set_Virtual_SI 0x1e
8072 +#define Hit_Set_Virtual_SD 0x1f
8077 + * R4x00 interrupt enable / cause bits
8079 +#define IE_SW0 (_ULCAST_(1) << 8)
8080 +#define IE_SW1 (_ULCAST_(1) << 9)
8081 +#define IE_IRQ0 (_ULCAST_(1) << 10)
8082 +#define IE_IRQ1 (_ULCAST_(1) << 11)
8083 +#define IE_IRQ2 (_ULCAST_(1) << 12)
8084 +#define IE_IRQ3 (_ULCAST_(1) << 13)
8085 +#define IE_IRQ4 (_ULCAST_(1) << 14)
8086 +#define IE_IRQ5 (_ULCAST_(1) << 15)
8090 + * Bitfields in the mips32 cp0 status register
8092 +#define ST0_IE 0x00000001
8093 +#define ST0_EXL 0x00000002
8094 +#define ST0_ERL 0x00000004
8095 +#define ST0_UM 0x00000010
8096 +#define ST0_SWINT0 0x00000100
8097 +#define ST0_SWINT1 0x00000200
8098 +#define ST0_HWINT0 0x00000400
8099 +#define ST0_HWINT1 0x00000800
8100 +#define ST0_HWINT2 0x00001000
8101 +#define ST0_HWINT3 0x00002000
8102 +#define ST0_HWINT4 0x00004000
8103 +#define ST0_HWINT5 0x00008000
8104 +#define ST0_IM 0x0000ff00
8105 +#define ST0_NMI 0x00080000
8106 +#define ST0_SR 0x00100000
8107 +#define ST0_TS 0x00200000
8108 +#define ST0_BEV 0x00400000
8109 +#define ST0_RE 0x02000000
8110 +#define ST0_RP 0x08000000
8111 +#define ST0_CU 0xf0000000
8112 +#define ST0_CU0 0x10000000
8113 +#define ST0_CU1 0x20000000
8114 +#define ST0_CU2 0x40000000
8115 +#define ST0_CU3 0x80000000
8120 + * Bitfields in the mips32 cp0 cause register
8122 +#define C_EXC 0x0000007c
8123 +#define C_EXC_SHIFT 2
8124 +#define C_INT 0x0000ff00
8125 +#define C_INT_SHIFT 8
8126 +#define C_SW0 (_ULCAST_(1) << 8)
8127 +#define C_SW1 (_ULCAST_(1) << 9)
8128 +#define C_IRQ0 (_ULCAST_(1) << 10)
8129 +#define C_IRQ1 (_ULCAST_(1) << 11)
8130 +#define C_IRQ2 (_ULCAST_(1) << 12)
8131 +#define C_IRQ3 (_ULCAST_(1) << 13)
8132 +#define C_IRQ4 (_ULCAST_(1) << 14)
8133 +#define C_IRQ5 (_ULCAST_(1) << 15)
8134 +#define C_WP 0x00400000
8135 +#define C_IV 0x00800000
8136 +#define C_CE 0x30000000
8137 +#define C_CE_SHIFT 28
8138 +#define C_BD 0x80000000
8140 +/* Values in C_EXC */
8155 +#define EXC_WATCH 23
8156 +#define EXC_MCHK 24
8160 + * Bits in the cp0 config register.
8162 +#define CONF_CM_CACHABLE_NO_WA 0
8163 +#define CONF_CM_CACHABLE_WA 1
8164 +#define CONF_CM_UNCACHED 2
8165 +#define CONF_CM_CACHABLE_NONCOHERENT 3
8166 +#define CONF_CM_CACHABLE_CE 4
8167 +#define CONF_CM_CACHABLE_COW 5
8168 +#define CONF_CM_CACHABLE_CUW 6
8169 +#define CONF_CM_CACHABLE_ACCELERATED 7
8170 +#define CONF_CM_CMASK 7
8171 +#define CONF_CU (_ULCAST_(1) << 3)
8172 +#define CONF_DB (_ULCAST_(1) << 4)
8173 +#define CONF_IB (_ULCAST_(1) << 5)
8174 +#define CONF_SE (_ULCAST_(1) << 12)
8175 +#define CONF_SC (_ULCAST_(1) << 17)
8176 +#define CONF_AC (_ULCAST_(1) << 23)
8177 +#define CONF_HALT (_ULCAST_(1) << 25)
8181 + * Bits in the cp0 config register select 1.
8183 +#define CONF1_FP 0x00000001 /* FPU present */
8184 +#define CONF1_EP 0x00000002 /* EJTAG present */
8185 +#define CONF1_CA 0x00000004 /* mips16 implemented */
8186 +#define CONF1_WR 0x00000008 /* Watch registers present */
8187 +#define CONF1_PC 0x00000010 /* Performance counters present */
8188 +#define CONF1_DA_SHIFT 7 /* D$ associativity */
8189 +#define CONF1_DA_MASK 0x00000380
8190 +#define CONF1_DA_BASE 1
8191 +#define CONF1_DL_SHIFT 10 /* D$ line size */
8192 +#define CONF1_DL_MASK 0x00001c00
8193 +#define CONF1_DL_BASE 2
8194 +#define CONF1_DS_SHIFT 13 /* D$ sets/way */
8195 +#define CONF1_DS_MASK 0x0000e000
8196 +#define CONF1_DS_BASE 64
8197 +#define CONF1_IA_SHIFT 16 /* I$ associativity */
8198 +#define CONF1_IA_MASK 0x00070000
8199 +#define CONF1_IA_BASE 1
8200 +#define CONF1_IL_SHIFT 19 /* I$ line size */
8201 +#define CONF1_IL_MASK 0x00380000
8202 +#define CONF1_IL_BASE 2
8203 +#define CONF1_IS_SHIFT 22 /* Instruction cache sets/way */
8204 +#define CONF1_IS_MASK 0x01c00000
8205 +#define CONF1_IS_BASE 64
8206 +#define CONF1_MS_MASK 0x7e000000 /* Number of tlb entries */
8207 +#define CONF1_MS_SHIFT 25
8209 +/* PRID register */
8210 +#define PRID_COPT_MASK 0xff000000
8211 +#define PRID_COMP_MASK 0x00ff0000
8212 +#define PRID_IMP_MASK 0x0000ff00
8213 +#define PRID_REV_MASK 0x000000ff
8215 +#define PRID_COMP_LEGACY 0x000000
8216 +#define PRID_COMP_MIPS 0x010000
8217 +#define PRID_COMP_BROADCOM 0x020000
8218 +#define PRID_COMP_ALCHEMY 0x030000
8219 +#define PRID_COMP_SIBYTE 0x040000
8220 +#define PRID_IMP_BCM4710 0x4000
8221 +#define PRID_IMP_BCM3302 0x9000
8222 +#define PRID_IMP_BCM3303 0x9100
8224 +#define PRID_IMP_UNKNOWN 0xff00
8226 +#define BCM330X(id) \
8227 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) \
8228 + || ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3303)))
8230 +/* Bits in C0_BROADCOM */
8231 +#define BRCM_PFC_AVAIL 0x20000000 /* PFC is available */
8232 +#define BRCM_DC_ENABLE 0x40000000 /* Enable Data $ */
8233 +#define BRCM_IC_ENABLE 0x80000000 /* Enable Instruction $ */
8234 +#define BRCM_PFC_ENABLE 0x00400000 /* Obsolete? Enable PFC (at least on 4310) */
8236 +/* PreFetch Cache aka Read Ahead Cache */
8238 +#define PFC_CR0 0xff400000 /* control reg 0 */
8239 +#define PFC_CR1 0xff400004 /* control reg 1 */
8241 +/* PFC operations */
8242 +#define PFC_I 0x00000001 /* Enable PFC use for instructions */
8243 +#define PFC_D 0x00000002 /* Enable PFC use for data */
8244 +#define PFC_PFI 0x00000004 /* Enable seq. prefetch for instructions */
8245 +#define PFC_PFD 0x00000008 /* Enable seq. prefetch for data */
8246 +#define PFC_CINV 0x00000010 /* Enable selective (i/d) cacheop flushing */
8247 +#define PFC_NCH 0x00000020 /* Disable flushing based on cacheops */
8248 +#define PFC_DPF 0x00000040 /* Enable directional prefetching */
8249 +#define PFC_FLUSH 0x00000100 /* Flush the PFC */
8250 +#define PFC_BRR 0x40000000 /* Bus error indication */
8251 +#define PFC_PWR 0x80000000 /* Disable power saving (clock gating) */
8253 +/* Handy defaults */
8254 +#define PFC_DISABLED 0
8255 +#define PFC_AUTO 0xffffffff /* auto select the default mode */
8256 +#define PFC_INST (PFC_I | PFC_PFI | PFC_CINV)
8257 +#define PFC_INST_NOPF (PFC_I | PFC_CINV)
8258 +#define PFC_DATA (PFC_D | PFC_PFD | PFC_CINV)
8259 +#define PFC_DATA_NOPF (PFC_D | PFC_CINV)
8260 +#define PFC_I_AND_D (PFC_INST | PFC_DATA)
8261 +#define PFC_I_AND_D_NOPF (PFC_INST_NOPF | PFC_DATA_NOPF)
8265 + * These are the UART port assignments, expressed as offsets from the base
8266 + * register. These assignments should hold for any serial port based on
8267 + * a 8250, 16450, or 16550(A).
8270 +#define UART_RX 0 /* In: Receive buffer (DLAB=0) */
8271 +#define UART_TX 0 /* Out: Transmit buffer (DLAB=0) */
8272 +#define UART_DLL 0 /* Out: Divisor Latch Low (DLAB=1) */
8273 +#define UART_DLM 1 /* Out: Divisor Latch High (DLAB=1) */
8274 +#define UART_LCR 3 /* Out: Line Control Register */
8275 +#define UART_MCR 4 /* Out: Modem Control Register */
8276 +#define UART_LSR 5 /* In: Line Status Register */
8277 +#define UART_MSR 6 /* In: Modem Status Register */
8278 +#define UART_SCR 7 /* I/O: Scratch Register */
8279 +#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */
8280 +#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */
8281 +#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */
8282 +#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
8283 +#define UART_LSR_RXRDY 0x01 /* Receiver ready */
8286 +#ifndef _LANGUAGE_ASSEMBLY
8289 + * Macros to access the system control coprocessor
8292 +#define MFC0(source, sel) \
8295 + __asm__ __volatile__( \
8296 + ".set\tnoreorder\n\t" \
8297 + ".set\tnoat\n\t" \
8298 + ".word\t"STR(0x40010000 | ((source)<<11) | (sel))"\n\t" \
8299 + "move\t%0,$1\n\t" \
8308 +#define MTC0(source, sel, value) \
8310 + __asm__ __volatile__( \
8311 + ".set\tnoreorder\n\t" \
8312 + ".set\tnoat\n\t" \
8313 + "move\t$1,%z0\n\t" \
8314 + ".word\t"STR(0x40810000 | ((source)<<11) | (sel))"\n\t" \
8322 +#define get_c0_count() \
8325 + __asm__ __volatile__( \
8326 + ".set\tnoreorder\n\t" \
8327 + ".set\tnoat\n\t" \
8328 + "mfc0\t%0,$9\n\t" \
8335 +static INLINE void icache_probe(uint32 config1, uint *size, uint *lsize)
8337 + uint lsz, sets, ways;
8339 + /* Instruction Cache Size = Associativity * Line Size * Sets Per Way */
8340 + if ((lsz = ((config1 & CONF1_IL_MASK) >> CONF1_IL_SHIFT)))
8341 + lsz = CONF1_IL_BASE << lsz;
8342 + sets = CONF1_IS_BASE << ((config1 & CONF1_IS_MASK) >> CONF1_IS_SHIFT);
8343 + ways = CONF1_IA_BASE + ((config1 & CONF1_IA_MASK) >> CONF1_IA_SHIFT);
8344 + *size = lsz * sets * ways;
8348 +static INLINE void dcache_probe(uint32 config1, uint *size, uint *lsize)
8350 + uint lsz, sets, ways;
8352 + /* Data Cache Size = Associativity * Line Size * Sets Per Way */
8353 + if ((lsz = ((config1 & CONF1_DL_MASK) >> CONF1_DL_SHIFT)))
8354 + lsz = CONF1_DL_BASE << lsz;
8355 + sets = CONF1_DS_BASE << ((config1 & CONF1_DS_MASK) >> CONF1_DS_SHIFT);
8356 + ways = CONF1_DA_BASE + ((config1 & CONF1_DA_MASK) >> CONF1_DA_SHIFT);
8357 + *size = lsz * sets * ways;
8361 +#define cache_op(base, op) \
8362 + __asm__ __volatile__(" \
8372 +#define cache_unroll4(base, delta, op) \
8373 + __asm__ __volatile__(" \
8377 + cache %1,delta(%0); \
8378 + cache %1,(2 * delta)(%0); \
8379 + cache %1,(3 * delta)(%0); \
8386 +#endif /* !_LANGUAGE_ASSEMBLY */
8388 +#endif /* _MISPINC_H */
8389 diff -urN linux.old/arch/mips/bcm947xx/include/osl.h linux.dev/arch/mips/bcm947xx/include/osl.h
8390 --- linux.old/arch/mips/bcm947xx/include/osl.h 1970-01-01 01:00:00.000000000 +0100
8391 +++ linux.dev/arch/mips/bcm947xx/include/osl.h 2005-12-15 15:35:08.321801750 +0100
8394 + * OS Abstraction Layer
8396 + * Copyright 2005, Broadcom Corporation
8397 + * All Rights Reserved.
8399 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8400 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8401 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8402 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8409 +/* osl handle type forward declaration */
8410 +typedef struct os_handle osl_t;
8413 +#include <linux_osl.h>
8414 +#elif defined(NDIS)
8415 +#include <ndis_osl.h>
8416 +#elif defined(_CFE_)
8417 +#include <cfe_osl.h>
8418 +#elif defined(_HNDRTE_)
8419 +#include <hndrte_osl.h>
8420 +#elif defined(_MINOSL_)
8421 +#include <min_osl.h>
8423 +#include <pmon_osl.h>
8424 +#elif defined(MACOSX)
8425 +#include <macosx_osl.h>
8427 +#error "Unsupported OSL requested"
8431 +#define SET_REG(r, mask, val) W_REG((r), ((R_REG(r) & ~(mask)) | (val)))
8432 +#define MAXPRIO 7 /* 0-7 */
8434 +#endif /* _osl_h_ */
8435 diff -urN linux.old/arch/mips/bcm947xx/include/pcicfg.h linux.dev/arch/mips/bcm947xx/include/pcicfg.h
8436 --- linux.old/arch/mips/bcm947xx/include/pcicfg.h 1970-01-01 01:00:00.000000000 +0100
8437 +++ linux.dev/arch/mips/bcm947xx/include/pcicfg.h 2005-12-15 15:36:31.719013750 +0100
8440 + * pcicfg.h: PCI configuration constants and structures.
8442 + * Copyright 2005, Broadcom Corporation
8443 + * All Rights Reserved.
8445 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8446 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8447 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8448 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8456 +/* The following inside ifndef's so we don't collide with NTDDK.H */
8457 +#ifndef PCI_MAX_BUS
8458 +#define PCI_MAX_BUS 0x100
8460 +#ifndef PCI_MAX_DEVICES
8461 +#define PCI_MAX_DEVICES 0x20
8463 +#ifndef PCI_MAX_FUNCTION
8464 +#define PCI_MAX_FUNCTION 0x8
8467 +#ifndef PCI_INVALID_VENDORID
8468 +#define PCI_INVALID_VENDORID 0xffff
8470 +#ifndef PCI_INVALID_DEVICEID
8471 +#define PCI_INVALID_DEVICEID 0xffff
8475 +/* Convert between bus-slot-function-register and config addresses */
8477 +#define PCICFG_BUS_SHIFT 16 /* Bus shift */
8478 +#define PCICFG_SLOT_SHIFT 11 /* Slot shift */
8479 +#define PCICFG_FUN_SHIFT 8 /* Function shift */
8480 +#define PCICFG_OFF_SHIFT 0 /* Register shift */
8482 +#define PCICFG_BUS_MASK 0xff /* Bus mask */
8483 +#define PCICFG_SLOT_MASK 0x1f /* Slot mask */
8484 +#define PCICFG_FUN_MASK 7 /* Function mask */
8485 +#define PCICFG_OFF_MASK 0xff /* Bus mask */
8487 +#define PCI_CONFIG_ADDR(b, s, f, o) \
8488 + ((((b) & PCICFG_BUS_MASK) << PCICFG_BUS_SHIFT) \
8489 + | (((s) & PCICFG_SLOT_MASK) << PCICFG_SLOT_SHIFT) \
8490 + | (((f) & PCICFG_FUN_MASK) << PCICFG_FUN_SHIFT) \
8491 + | (((o) & PCICFG_OFF_MASK) << PCICFG_OFF_SHIFT))
8493 +#define PCI_CONFIG_BUS(a) (((a) >> PCICFG_BUS_SHIFT) & PCICFG_BUS_MASK)
8494 +#define PCI_CONFIG_SLOT(a) (((a) >> PCICFG_SLOT_SHIFT) & PCICFG_SLOT_MASK)
8495 +#define PCI_CONFIG_FUN(a) (((a) >> PCICFG_FUN_SHIFT) & PCICFG_FUN_MASK)
8496 +#define PCI_CONFIG_OFF(a) (((a) >> PCICFG_OFF_SHIFT) & PCICFG_OFF_MASK)
8498 +/* The actual config space */
8500 +#define PCI_BAR_MAX 6
8502 +#define PCI_ROM_BAR 8
8504 +#define PCR_RSVDA_MAX 2
8506 +/* pci config status reg has a bit to indicate that capability ptr is present*/
8508 +#define PCI_CAPPTR_PRESENT 0x0010
8510 +typedef struct _pci_config_regs {
8511 + unsigned short vendor;
8512 + unsigned short device;
8513 + unsigned short command;
8514 + unsigned short status;
8515 + unsigned char rev_id;
8516 + unsigned char prog_if;
8517 + unsigned char sub_class;
8518 + unsigned char base_class;
8519 + unsigned char cache_line_size;
8520 + unsigned char latency_timer;
8521 + unsigned char header_type;
8522 + unsigned char bist;
8523 + unsigned long base[PCI_BAR_MAX];
8524 + unsigned long cardbus_cis;
8525 + unsigned short subsys_vendor;
8526 + unsigned short subsys_id;
8527 + unsigned long baserom;
8528 + unsigned long rsvd_a[PCR_RSVDA_MAX];
8529 + unsigned char int_line;
8530 + unsigned char int_pin;
8531 + unsigned char min_gnt;
8532 + unsigned char max_lat;
8533 + unsigned char dev_dep[192];
8536 +#define SZPCR (sizeof (pci_config_regs))
8537 +#define MINSZPCR 64 /* offsetof (dev_dep[0] */
8539 +/* A structure for the config registers is nice, but in most
8540 + * systems the config space is not memory mapped, so we need
8541 + * filed offsetts. :-(
8543 +#define PCI_CFG_VID 0
8544 +#define PCI_CFG_DID 2
8545 +#define PCI_CFG_CMD 4
8546 +#define PCI_CFG_STAT 6
8547 +#define PCI_CFG_REV 8
8548 +#define PCI_CFG_PROGIF 9
8549 +#define PCI_CFG_SUBCL 0xa
8550 +#define PCI_CFG_BASECL 0xb
8551 +#define PCI_CFG_CLSZ 0xc
8552 +#define PCI_CFG_LATTIM 0xd
8553 +#define PCI_CFG_HDR 0xe
8554 +#define PCI_CFG_BIST 0xf
8555 +#define PCI_CFG_BAR0 0x10
8556 +#define PCI_CFG_BAR1 0x14
8557 +#define PCI_CFG_BAR2 0x18
8558 +#define PCI_CFG_BAR3 0x1c
8559 +#define PCI_CFG_BAR4 0x20
8560 +#define PCI_CFG_BAR5 0x24
8561 +#define PCI_CFG_CIS 0x28
8562 +#define PCI_CFG_SVID 0x2c
8563 +#define PCI_CFG_SSID 0x2e
8564 +#define PCI_CFG_ROMBAR 0x30
8565 +#define PCI_CFG_CAPPTR 0x34
8566 +#define PCI_CFG_INT 0x3c
8567 +#define PCI_CFG_PIN 0x3d
8568 +#define PCI_CFG_MINGNT 0x3e
8569 +#define PCI_CFG_MAXLAT 0x3f
8571 +/* Classes and subclasses */
8574 + PCI_CLASS_OLD = 0,
8577 + PCI_CLASS_DISPLAY,
8587 + PCI_CLASS_INTELLIGENT = 0xe,
8588 + PCI_CLASS_SATELLITE,
8600 + PCI_DASDI_OTHER = 0x80
8601 +} pci_dasdi_subclasses;
8608 + PCI_NET_OTHER = 0x80
8609 +} pci_net_subclasses;
8615 + PCI_DISPLAY_OTHER = 0x80
8616 +} pci_display_subclasses;
8622 + PCI_MEDIA_OTHER = 0x80
8623 +} pci_mmedia_subclasses;
8628 + PCI_MEMORY_OTHER = 0x80
8629 +} pci_memory_subclasses;
8637 + PCI_BRIDGE_PCMCIA,
8639 + PCI_BRIDGE_CARDBUS,
8640 + PCI_BRIDGE_RACEWAY,
8641 + PCI_BRIDGE_OTHER = 0x80
8642 +} pci_bridge_subclasses;
8646 + PCI_COMM_PARALLEL,
8647 + PCI_COMM_MULTIUART,
8649 + PCI_COMM_OTHER = 0x80
8650 +} pci_comm_subclasses;
8657 + PCI_BASE_PCI_HOTPLUG,
8658 + PCI_BASE_OTHER = 0x80
8659 +} pci_base_subclasses;
8665 + PCI_INPUT_SCANNER,
8666 + PCI_INPUT_GAMEPORT,
8667 + PCI_INPUT_OTHER = 0x80
8668 +} pci_input_subclasses;
8672 + PCI_DOCK_OTHER = 0x80
8673 +} pci_dock_subclasses;
8679 + PCI_CPU_ALPHA = 0x10,
8680 + PCI_CPU_POWERPC = 0x20,
8681 + PCI_CPU_MIPS = 0x30,
8682 + PCI_CPU_COPROC = 0x40,
8683 + PCI_CPU_OTHER = 0x80
8684 +} pci_cpu_subclasses;
8687 + PCI_SERIAL_IEEE1394,
8688 + PCI_SERIAL_ACCESS,
8693 + PCI_SERIAL_OTHER = 0x80
8694 +} pci_serial_subclasses;
8697 + PCI_INTELLIGENT_I2O,
8698 +} pci_intelligent_subclasses;
8702 + PCI_SATELLITE_AUDIO,
8703 + PCI_SATELLITE_VOICE,
8704 + PCI_SATELLITE_DATA,
8705 + PCI_SATELLITE_OTHER = 0x80
8706 +} pci_satellite_subclasses;
8709 + PCI_CRYPT_NETWORK,
8710 + PCI_CRYPT_ENTERTAINMENT,
8711 + PCI_CRYPT_OTHER = 0x80
8712 +} pci_crypt_subclasses;
8716 + PCI_DSP_OTHER = 0x80
8717 +} pci_dsp_subclasses;
8721 + PCI_HEADER_NORMAL,
8722 + PCI_HEADER_BRIDGE,
8723 + PCI_HEADER_CARDBUS
8724 +} pci_header_types;
8727 +/* Overlay for a PCI-to-PCI bridge */
8729 +#define PPB_RSVDA_MAX 2
8730 +#define PPB_RSVDD_MAX 8
8732 +typedef struct _ppb_config_regs {
8733 + unsigned short vendor;
8734 + unsigned short device;
8735 + unsigned short command;
8736 + unsigned short status;
8737 + unsigned char rev_id;
8738 + unsigned char prog_if;
8739 + unsigned char sub_class;
8740 + unsigned char base_class;
8741 + unsigned char cache_line_size;
8742 + unsigned char latency_timer;
8743 + unsigned char header_type;
8744 + unsigned char bist;
8745 + unsigned long rsvd_a[PPB_RSVDA_MAX];
8746 + unsigned char prim_bus;
8747 + unsigned char sec_bus;
8748 + unsigned char sub_bus;
8749 + unsigned char sec_lat;
8750 + unsigned char io_base;
8751 + unsigned char io_lim;
8752 + unsigned short sec_status;
8753 + unsigned short mem_base;
8754 + unsigned short mem_lim;
8755 + unsigned short pf_mem_base;
8756 + unsigned short pf_mem_lim;
8757 + unsigned long pf_mem_base_hi;
8758 + unsigned long pf_mem_lim_hi;
8759 + unsigned short io_base_hi;
8760 + unsigned short io_lim_hi;
8761 + unsigned short subsys_vendor;
8762 + unsigned short subsys_id;
8763 + unsigned long rsvd_b;
8764 + unsigned char rsvd_c;
8765 + unsigned char int_pin;
8766 + unsigned short bridge_ctrl;
8767 + unsigned char chip_ctrl;
8768 + unsigned char diag_ctrl;
8769 + unsigned short arb_ctrl;
8770 + unsigned long rsvd_d[PPB_RSVDD_MAX];
8771 + unsigned char dev_dep[192];
8775 +/* PCI CAPABILITY DEFINES */
8776 +#define PCI_CAP_POWERMGMTCAP_ID 0x01
8777 +#define PCI_CAP_MSICAP_ID 0x05
8779 +/* Data structure to define the Message Signalled Interrupt facility
8780 + * Valid for PCI and PCIE configurations */
8781 +typedef struct _pciconfig_cap_msi {
8782 + unsigned char capID;
8783 + unsigned char nextptr;
8784 + unsigned short msgctrl;
8785 + unsigned int msgaddr;
8786 +} pciconfig_cap_msi;
8788 +/* Data structure to define the Power managment facility
8789 + * Valid for PCI and PCIE configurations */
8790 +typedef struct _pciconfig_cap_pwrmgmt {
8791 + unsigned char capID;
8792 + unsigned char nextptr;
8793 + unsigned short pme_cap;
8794 + unsigned short pme_sts_ctrl;
8795 + unsigned char pme_bridge_ext;
8796 + unsigned char data;
8797 +} pciconfig_cap_pwrmgmt;
8799 +/* Everything below is BRCM HND proprietary */
8801 +#define PCI_BAR0_WIN 0x80 /* backplane addres space accessed by BAR0 */
8802 +#define PCI_BAR1_WIN 0x84 /* backplane addres space accessed by BAR1 */
8803 +#define PCI_SPROM_CONTROL 0x88 /* sprom property control */
8804 +#define PCI_BAR1_CONTROL 0x8c /* BAR1 region burst control */
8805 +#define PCI_INT_STATUS 0x90 /* PCI and other cores interrupts */
8806 +#define PCI_INT_MASK 0x94 /* mask of PCI and other cores interrupts */
8807 +#define PCI_TO_SB_MB 0x98 /* signal backplane interrupts */
8808 +#define PCI_BACKPLANE_ADDR 0xA0 /* address an arbitrary location on the system backplane */
8809 +#define PCI_BACKPLANE_DATA 0xA4 /* data at the location specified by above address register */
8810 +#define PCI_GPIO_IN 0xb0 /* pci config space gpio input (>=rev3) */
8811 +#define PCI_GPIO_OUT 0xb4 /* pci config space gpio output (>=rev3) */
8812 +#define PCI_GPIO_OUTEN 0xb8 /* pci config space gpio output enable (>=rev3) */
8814 +#define PCI_BAR0_SPROM_OFFSET (4 * 1024) /* bar0 + 4K accesses external sprom */
8815 +#define PCI_BAR0_PCIREGS_OFFSET (6 * 1024) /* bar0 + 6K accesses pci core registers */
8817 +/* PCI_INT_STATUS */
8818 +#define PCI_SBIM_STATUS_SERR 0x4 /* backplane SBErr interrupt status */
8821 +#define PCI_SBIM_SHIFT 8 /* backplane core interrupt mask bits offset */
8822 +#define PCI_SBIM_MASK 0xff00 /* backplane core interrupt mask */
8823 +#define PCI_SBIM_MASK_SERR 0x4 /* backplane SBErr interrupt mask */
8825 +/* PCI_SPROM_CONTROL */
8826 +#define SPROM_BLANK 0x04 /* indicating a blank sprom */
8827 +#define SPROM_WRITEEN 0x10 /* sprom write enable */
8828 +#define SPROM_BOOTROM_WE 0x20 /* external bootrom write enable */
8830 +#define SPROM_SIZE 256 /* sprom size in 16-bit */
8831 +#define SPROM_CRC_RANGE 64 /* crc cover range in 16-bit */
8833 +/* PCI_CFG_CMD_STAT */
8834 +#define PCI_CFG_CMD_STAT_TA 0x08000000 /* target abort status */
8837 diff -urN linux.old/arch/mips/bcm947xx/include/proto/ethernet.h linux.dev/arch/mips/bcm947xx/include/proto/ethernet.h
8838 --- linux.old/arch/mips/bcm947xx/include/proto/ethernet.h 1970-01-01 01:00:00.000000000 +0100
8839 +++ linux.dev/arch/mips/bcm947xx/include/proto/ethernet.h 2005-12-15 12:57:27.869191250 +0100
8841 +/*******************************************************************************
8843 + * Copyright 2001-2003, Broadcom Corporation
8844 + * All Rights Reserved.
8846 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8847 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8848 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8849 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
8850 + * From FreeBSD 2.2.7: Fundamental constants relating to ethernet.
8851 + ******************************************************************************/
8853 +#ifndef _NET_ETHERNET_H_ /* use native BSD ethernet.h when available */
8854 +#define _NET_ETHERNET_H_
8856 +#ifndef _TYPEDEFS_H_
8857 +#include "typedefs.h"
8860 +#if defined(__GNUC__)
8861 +#define PACKED __attribute__((packed))
8867 + * The number of bytes in an ethernet (MAC) address.
8869 +#define ETHER_ADDR_LEN 6
8872 + * The number of bytes in the type field.
8874 +#define ETHER_TYPE_LEN 2
8877 + * The number of bytes in the trailing CRC field.
8879 +#define ETHER_CRC_LEN 4
8882 + * The length of the combined header.
8884 +#define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
8887 + * The minimum packet length.
8889 +#define ETHER_MIN_LEN 64
8892 + * The minimum packet user data length.
8894 +#define ETHER_MIN_DATA 46
8897 + * The maximum packet length.
8899 +#define ETHER_MAX_LEN 1518
8902 + * The maximum packet user data length.
8904 +#define ETHER_MAX_DATA 1500
8907 + * Used to uniquely identify a 802.1q VLAN-tagged header.
8909 +#define VLAN_TAG 0x8100
8912 + * Located after dest & src address in ether header.
8914 +#define VLAN_FIELDS_OFFSET (ETHER_ADDR_LEN * 2)
8917 + * 4 bytes of vlan field info.
8919 +#define VLAN_FIELDS_SIZE 4
8921 +/* location of pri bits in 16-bit vlan fields */
8922 +#define VLAN_PRI_SHIFT 13
8924 +/* 3 bits of priority */
8925 +#define VLAN_PRI_MASK 7
8927 +/* 802.1X ethertype */
8928 +#define ETHER_TYPE_802_1X 0x888e
8931 + * A macro to validate a length with
8933 +#define ETHER_IS_VALID_LEN(foo) \
8934 + ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
8937 +#ifndef __INCif_etherh /* Quick and ugly hack for VxWorks */
8939 + * Structure of a 10Mb/s Ethernet header.
8941 +struct ether_header {
8942 + uint8 ether_dhost[ETHER_ADDR_LEN];
8943 + uint8 ether_shost[ETHER_ADDR_LEN];
8944 + uint16 ether_type;
8948 + * Structure of a 48-bit Ethernet address.
8950 +struct ether_addr {
8951 + uint8 octet[ETHER_ADDR_LEN];
8956 + * Takes a pointer, returns true if a 48-bit multicast address
8957 + * (including broadcast, since it is all ones)
8959 +#define ETHER_ISMULTI(ea) (((uint8 *)(ea))[0] & 1)
8962 + * Takes a pointer, returns true if a 48-bit broadcast (all ones)
8964 +#define ETHER_ISBCAST(ea) ((((uint8 *)(ea))[0] & \
8965 + ((uint8 *)(ea))[1] & \
8966 + ((uint8 *)(ea))[2] & \
8967 + ((uint8 *)(ea))[3] & \
8968 + ((uint8 *)(ea))[4] & \
8969 + ((uint8 *)(ea))[5]) == 0xff)
8971 +static const struct ether_addr ether_bcast = {{255, 255, 255, 255, 255, 255}};
8974 + * Takes a pointer, returns true if a 48-bit null address (all zeros)
8976 +#define ETHER_ISNULLADDR(ea) ((((uint8 *)(ea))[0] | \
8977 + ((uint8 *)(ea))[1] | \
8978 + ((uint8 *)(ea))[2] | \
8979 + ((uint8 *)(ea))[3] | \
8980 + ((uint8 *)(ea))[4] | \
8981 + ((uint8 *)(ea))[5]) == 0)
8985 +#endif /* _NET_ETHERNET_H_ */
8986 diff -urN linux.old/arch/mips/bcm947xx/include/s5.h linux.dev/arch/mips/bcm947xx/include/s5.h
8987 --- linux.old/arch/mips/bcm947xx/include/s5.h 1970-01-01 01:00:00.000000000 +0100
8988 +++ linux.dev/arch/mips/bcm947xx/include/s5.h 2005-12-15 12:57:27.869191250 +0100
8993 + * Copyright 2003, Broadcom Corporation
8994 + * All Rights Reserved.
8996 + * Broadcom Sentry5 (S5) BCM5365, 53xx, BCM58xx SOC Internal Core
8997 + * and MIPS3301 (R4K) System Address Space
8999 + * This program is free software; you can redistribute it and/or
9000 + * modify it under the terms of the GNU General Public License as
9001 + * published by the Free Software Foundation, located in the file
9004 + * $Id: s5.h,v 1.3 2003/06/10 18:54:51 jfd Exp $
9008 +/* BCM5365 Address map */
9009 +#define KSEG1ADDR(x) ( (x) | 0xa0000000)
9010 +#define BCM5365_SDRAM 0x00000000 /* 0-128MB Physical SDRAM */
9011 +#define BCM5365_PCI_MEM 0x08000000 /* Host Mode PCI mem space (64MB) */
9012 +#define BCM5365_PCI_CFG 0x0c000000 /* Host Mode PCI cfg space (64MB) */
9013 +#define BCM5365_PCI_DMA 0x40000000 /* Client Mode PCI mem space (1GB)*/
9014 +#define BCM5365_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
9015 +#define BCM5365_ENUM 0x18000000 /* Beginning of core enum space */
9017 +/* BCM5365 Core register space */
9018 +#define BCM5365_REG_CHIPC 0x18000000 /* Chipcommon registers */
9019 +#define BCM5365_REG_EMAC0 0x18001000 /* Ethernet MAC0 core registers */
9020 +#define BCM5365_REG_IPSEC 0x18002000 /* BCM582x CryptoCore registers */
9021 +#define BCM5365_REG_USB 0x18003000 /* USB core registers */
9022 +#define BCM5365_REG_PCI 0x18004000 /* PCI core registers */
9023 +#define BCM5365_REG_MIPS33 0x18005000 /* MIPS core registers */
9024 +#define BCM5365_REG_MEMC 0x18006000 /* MEMC core registers */
9025 +#define BCM5365_REG_UARTS (BCM5365_REG_CHIPC + 0x300) /* UART regs */
9026 +#define BCM5365_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
9028 +/* COM Ports 1/2 */
9029 +#define BCM5365_UART (BCM5365_REG_UARTS)
9030 +#define BCM5365_UART_COM2 (BCM5365_REG_UARTS + 0x00000100)
9032 +/* Registers common to MIPS33 Core used in 5365 */
9033 +#define MIPS33_FLASH_REGION 0x1fc00000 /* Boot FLASH Region */
9034 +#define MIPS33_EXTIF_REGION 0x1a000000 /* Chipcommon EXTIF region*/
9035 +#define BCM5365_EXTIF 0x1b000000 /* MISC_CS */
9036 +#define MIPS33_FLASH_REGION_AUX 0x1c000000 /* FLASH Region 2*/
9038 +/* Internal Core Sonics Backplane Devices */
9039 +#define INTERNAL_UART_COM1 BCM5365_UART
9040 +#define INTERNAL_UART_COM2 BCM5365_UART_COM2
9041 +#define SB_REG_CHIPC BCM5365_REG_CHIPC
9042 +#define SB_REG_ENET0 BCM5365_REG_EMAC0
9043 +#define SB_REG_IPSEC BCM5365_REG_IPSEC
9044 +#define SB_REG_USB BCM5365_REG_USB
9045 +#define SB_REG_PCI BCM5365_REG_PCI
9046 +#define SB_REG_MIPS BCM5365_REG_MIPS33
9047 +#define SB_REG_MEMC BCM5365_REG_MEMC
9048 +#define SB_REG_MEMC_OFF 0x6000
9049 +#define SB_EXTIF_SPACE MIPS33_EXTIF_REGION
9050 +#define SB_FLASH_SPACE MIPS33_FLASH_REGION
9054 + * 5365-specific backplane interrupt flag numbers. This should be done
9055 + * dynamically instead.
9057 +#define SBFLAG_PCI 0
9058 +#define SBFLAG_ENET0 1
9059 +#define SBFLAG_ILINE20 2
9060 +#define SBFLAG_CODEC 3
9061 +#define SBFLAG_USB 4
9062 +#define SBFLAG_EXTIF 5
9063 +#define SBFLAG_ENET1 6
9065 +/* BCM95365 Local Bus devices */
9066 +#define BCM95365K_RESET_ADDR BCM5365_EXTIF
9067 +#define BCM95365K_BOARDID_ADDR (BCM5365_EXTIF | 0x4000)
9068 +#define BCM95365K_DOC_ADDR (BCM5365_EXTIF | 0x6000)
9069 +#define BCM95365K_LED_ADDR (BCM5365_EXTIF | 0xc000)
9070 +#define BCM95365K_TOD_REG_BASE (BCM95365K_NVRAM_ADDR | 0x1ff0)
9071 +#define BCM95365K_NVRAM_ADDR (BCM5365_EXTIF | 0xe000)
9072 +#define BCM95365K_NVRAM_SIZE 0x1ff0 /* 8K NVRAM : DS1743/STM48txx*/
9074 +/* Write to DLR2416 VFD Display character RAM */
9075 +#define LED_REG(x) \
9076 + (*(volatile unsigned char *) (KSEG1ADDR(BCM95365K_LED_ADDR) + (x)))
9079 +#define BCM5365_TRACE(trval) do { *((int *)0xa0002ff8) = (trval); \
9082 +#define BCM5365_TRACE(trval) do { *((unsigned char *)\
9083 + KSEG1ADDR(BCM5365K_LED_ADDR)) = (trval); \
9084 + *((int *)0xa0002ff8) = (trval); } while (0)
9087 +/* BCM9536R Local Bus devices */
9088 +#define BCM95365R_DOC_ADDR BCM5365_EXTIF
9092 +#endif /*!_S5_H_ */
9093 diff -urN linux.old/arch/mips/bcm947xx/include/sbchipc.h linux.dev/arch/mips/bcm947xx/include/sbchipc.h
9094 --- linux.old/arch/mips/bcm947xx/include/sbchipc.h 1970-01-01 01:00:00.000000000 +0100
9095 +++ linux.dev/arch/mips/bcm947xx/include/sbchipc.h 2005-12-15 15:35:20.458560250 +0100
9098 + * SiliconBackplane Chipcommon core hardware definitions.
9100 + * The chipcommon core provides chip identification, SB control,
9101 + * jtag, 0/1/2 uarts, clock frequency control, a watchdog interrupt timer,
9102 + * gpio interface, extbus, and support for serial and parallel flashes.
9105 + * Copyright 2005, Broadcom Corporation
9106 + * All Rights Reserved.
9108 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9109 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9110 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9111 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9119 +#ifndef _LANGUAGE_ASSEMBLY
9121 +/* cpp contortions to concatenate w/arg prescan */
9123 +#define _PADLINE(line) pad ## line
9124 +#define _XSTR(line) _PADLINE(line)
9125 +#define PAD _XSTR(__LINE__)
9128 +typedef volatile struct {
9129 + uint32 chipid; /* 0x0 */
9130 + uint32 capabilities;
9131 + uint32 corecontrol; /* corerev >= 1 */
9135 + uint32 otpstatus; /* 0x10, corerev >= 10 */
9136 + uint32 otpcontrol;
9140 + /* Interrupt control */
9141 + uint32 intstatus; /* 0x20 */
9143 + uint32 chipcontrol; /* 0x28, rev >= 11 */
9144 + uint32 chipstatus; /* 0x2c, rev >= 11 */
9147 + uint32 jtagcmd; /* 0x30, rev >= 10 */
9152 + /* serial flash interface registers */
9153 + uint32 flashcontrol; /* 0x40 */
9154 + uint32 flashaddress;
9158 + /* Silicon backplane configuration broadcast control */
9159 + uint32 broadcastaddress; /* 0x50 */
9160 + uint32 broadcastdata;
9163 + /* gpio - cleared only by power-on-reset */
9164 + uint32 gpioin; /* 0x60 */
9167 + uint32 gpiocontrol;
9168 + uint32 gpiointpolarity;
9169 + uint32 gpiointmask;
9172 + /* Watchdog timer */
9173 + uint32 watchdog; /* 0x80 */
9176 + /*GPIO based LED powersave registers corerev >= 16*/
9177 + uint32 gpiotimerval; /*0x88 */
9178 + uint32 gpiotimeroutmask;
9180 + /* clock control */
9181 + uint32 clockcontrol_n; /* 0x90 */
9182 + uint32 clockcontrol_sb; /* aka m0 */
9183 + uint32 clockcontrol_pci; /* aka m1 */
9184 + uint32 clockcontrol_m2; /* mii/uart/mipsref */
9185 + uint32 clockcontrol_mips; /* aka m3 */
9186 + uint32 clkdiv; /* corerev >= 3 */
9189 + /* pll delay registers (corerev >= 4) */
9190 + uint32 pll_on_delay; /* 0xb0 */
9191 + uint32 fref_sel_delay;
9192 + uint32 slow_clk_ctl; /* 5 < corerev < 10 */
9195 + /* Instaclock registers (corerev >= 10) */
9196 + uint32 system_clk_ctl; /* 0xc0 */
9197 + uint32 clkstatestretch;
9200 + /* ExtBus control registers (corerev >= 3) */
9201 + uint32 pcmcia_config; /* 0x100 */
9202 + uint32 pcmcia_memwait;
9203 + uint32 pcmcia_attrwait;
9204 + uint32 pcmcia_iowait;
9205 + uint32 ide_config;
9206 + uint32 ide_memwait;
9207 + uint32 ide_attrwait;
9208 + uint32 ide_iowait;
9209 + uint32 prog_config;
9210 + uint32 prog_waitcount;
9211 + uint32 flash_config;
9212 + uint32 flash_waitcount;
9216 + uint8 uart0data; /* 0x300 */
9223 + uint8 uart0scratch;
9224 + uint8 PAD[248]; /* corerev >= 1 */
9226 + uint8 uart1data; /* 0x400 */
9233 + uint8 uart1scratch;
9236 +#endif /* _LANGUAGE_ASSEMBLY */
9238 +#define CC_CHIPID 0
9239 +#define CC_CAPABILITIES 4
9240 +#define CC_JTAGCMD 0x30
9241 +#define CC_JTAGIR 0x34
9242 +#define CC_JTAGDR 0x38
9243 +#define CC_JTAGCTRL 0x3c
9244 +#define CC_WATCHDOG 0x80
9245 +#define CC_CLKC_N 0x90
9246 +#define CC_CLKC_M0 0x94
9247 +#define CC_CLKC_M1 0x98
9248 +#define CC_CLKC_M2 0x9c
9249 +#define CC_CLKC_M3 0xa0
9250 +#define CC_CLKDIV 0xa4
9251 +#define CC_SYS_CLK_CTL 0xc0
9252 +#define CC_OTP 0x800
9255 +#define CID_ID_MASK 0x0000ffff /* Chip Id mask */
9256 +#define CID_REV_MASK 0x000f0000 /* Chip Revision mask */
9257 +#define CID_REV_SHIFT 16 /* Chip Revision shift */
9258 +#define CID_PKG_MASK 0x00f00000 /* Package Option mask */
9259 +#define CID_PKG_SHIFT 20 /* Package Option shift */
9260 +#define CID_CC_MASK 0x0f000000 /* CoreCount (corerev >= 4) */
9261 +#define CID_CC_SHIFT 24
9264 +#define CAP_UARTS_MASK 0x00000003 /* Number of uarts */
9265 +#define CAP_MIPSEB 0x00000004 /* MIPS is in big-endian mode */
9266 +#define CAP_UCLKSEL 0x00000018 /* UARTs clock select */
9267 +#define CAP_UINTCLK 0x00000008 /* UARTs are driven by internal divided clock */
9268 +#define CAP_UARTGPIO 0x00000020 /* UARTs own Gpio's 15:12 */
9269 +#define CAP_EXTBUS 0x00000040 /* External bus present */
9270 +#define CAP_FLASH_MASK 0x00000700 /* Type of flash */
9271 +#define CAP_PLL_MASK 0x00038000 /* Type of PLL */
9272 +#define CAP_PWR_CTL 0x00040000 /* Power control */
9273 +#define CAP_OTPSIZE 0x00380000 /* OTP Size (0 = none) */
9274 +#define CAP_OTPSIZE_SHIFT 19 /* OTP Size shift */
9275 +#define CAP_OTPSIZE_BASE 5 /* OTP Size base */
9276 +#define CAP_JTAGP 0x00400000 /* JTAG Master Present */
9277 +#define CAP_ROM 0x00800000 /* Internal boot rom active */
9280 +#define PLL_NONE 0x00000000
9281 +#define PLL_TYPE1 0x00010000 /* 48Mhz base, 3 dividers */
9282 +#define PLL_TYPE2 0x00020000 /* 48Mhz, 4 dividers */
9283 +#define PLL_TYPE3 0x00030000 /* 25Mhz, 2 dividers */
9284 +#define PLL_TYPE4 0x00008000 /* 48Mhz, 4 dividers */
9285 +#define PLL_TYPE5 0x00018000 /* 25Mhz, 4 dividers */
9286 +#define PLL_TYPE6 0x00028000 /* 100/200 or 120/240 only */
9287 +#define PLL_TYPE7 0x00038000 /* 25Mhz, 4 dividers */
9290 +#define CC_UARTCLKO 0x00000001 /* Drive UART with internal clock */
9291 +#define CC_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
9293 +/* Fields in the otpstatus register */
9294 +#define OTPS_PROGFAIL 0x80000000
9295 +#define OTPS_PROTECT 0x00000007
9296 +#define OTPS_HW_PROTECT 0x00000001
9297 +#define OTPS_SW_PROTECT 0x00000002
9298 +#define OTPS_CID_PROTECT 0x00000004
9300 +/* Fields in the otpcontrol register */
9301 +#define OTPC_RECWAIT 0xff000000
9302 +#define OTPC_PROGWAIT 0x00ffff00
9303 +#define OTPC_PRW_SHIFT 8
9304 +#define OTPC_MAXFAIL 0x00000038
9305 +#define OTPC_VSEL 0x00000006
9306 +#define OTPC_SELVL 0x00000001
9308 +/* Fields in otpprog */
9309 +#define OTPP_COL_MASK 0x000000ff
9310 +#define OTPP_ROW_MASK 0x0000ff00
9311 +#define OTPP_ROW_SHIFT 8
9312 +#define OTPP_READERR 0x10000000
9313 +#define OTPP_VALUE 0x20000000
9314 +#define OTPP_VALUE_SHIFT 29
9315 +#define OTPP_READ 0x40000000
9316 +#define OTPP_START 0x80000000
9317 +#define OTPP_BUSY 0x80000000
9320 +#define JCMD_START 0x80000000
9321 +#define JCMD_BUSY 0x80000000
9322 +#define JCMD_PAUSE 0x40000000
9323 +#define JCMD0_ACC_MASK 0x0000f000
9324 +#define JCMD0_ACC_IRDR 0x00000000
9325 +#define JCMD0_ACC_DR 0x00001000
9326 +#define JCMD0_ACC_IR 0x00002000
9327 +#define JCMD0_ACC_RESET 0x00003000
9328 +#define JCMD0_ACC_IRPDR 0x00004000
9329 +#define JCMD0_ACC_PDR 0x00005000
9330 +#define JCMD0_IRW_MASK 0x00000f00
9331 +#define JCMD_ACC_MASK 0x000f0000 /* Changes for corerev 11 */
9332 +#define JCMD_ACC_IRDR 0x00000000
9333 +#define JCMD_ACC_DR 0x00010000
9334 +#define JCMD_ACC_IR 0x00020000
9335 +#define JCMD_ACC_RESET 0x00030000
9336 +#define JCMD_ACC_IRPDR 0x00040000
9337 +#define JCMD_ACC_PDR 0x00050000
9338 +#define JCMD_IRW_MASK 0x00001f00
9339 +#define JCMD_IRW_SHIFT 8
9340 +#define JCMD_DRW_MASK 0x0000003f
9343 +#define JCTRL_FORCE_CLK 4 /* Force clock */
9344 +#define JCTRL_EXT_EN 2 /* Enable external targets */
9345 +#define JCTRL_EN 1 /* Enable Jtag master */
9347 +/* Fields in clkdiv */
9348 +#define CLKD_SFLASH 0x0f000000
9349 +#define CLKD_SFLASH_SHIFT 24
9350 +#define CLKD_OTP 0x000f0000
9351 +#define CLKD_OTP_SHIFT 16
9352 +#define CLKD_JTAG 0x00000f00
9353 +#define CLKD_JTAG_SHIFT 8
9354 +#define CLKD_UART 0x000000ff
9356 +/* intstatus/intmask */
9357 +#define CI_GPIO 0x00000001 /* gpio intr */
9358 +#define CI_EI 0x00000002 /* ro: ext intr pin (corerev >= 3) */
9359 +#define CI_WDRESET 0x80000000 /* watchdog reset occurred */
9362 +#define SCC_SS_MASK 0x00000007 /* slow clock source mask */
9363 +#define SCC_SS_LPO 0x00000000 /* source of slow clock is LPO */
9364 +#define SCC_SS_XTAL 0x00000001 /* source of slow clock is crystal */
9365 +#define SCC_SS_PCI 0x00000002 /* source of slow clock is PCI */
9366 +#define SCC_LF 0x00000200 /* LPOFreqSel, 1: 160Khz, 0: 32KHz */
9367 +#define SCC_LP 0x00000400 /* LPOPowerDown, 1: LPO is disabled, 0: LPO is enabled */
9368 +#define SCC_FS 0x00000800 /* ForceSlowClk, 1: sb/cores running on slow clock, 0: power logic control */
9369 +#define SCC_IP 0x00001000 /* IgnorePllOffReq, 1/0: power logic ignores/honors PLL clock disable requests from core */
9370 +#define SCC_XC 0x00002000 /* XtalControlEn, 1/0: power logic does/doesn't disable crystal when appropriate */
9371 +#define SCC_XP 0x00004000 /* XtalPU (RO), 1/0: crystal running/disabled */
9372 +#define SCC_CD_MASK 0xffff0000 /* ClockDivider (SlowClk = 1/(4+divisor)) */
9373 +#define SCC_CD_SHIFT 16
9375 +/* system_clk_ctl */
9376 +#define SYCC_IE 0x00000001 /* ILPen: Enable Idle Low Power */
9377 +#define SYCC_AE 0x00000002 /* ALPen: Enable Active Low Power */
9378 +#define SYCC_FP 0x00000004 /* ForcePLLOn */
9379 +#define SYCC_AR 0x00000008 /* Force ALP (or HT if ALPen is not set */
9380 +#define SYCC_HR 0x00000010 /* Force HT */
9381 +#define SYCC_CD_MASK 0xffff0000 /* ClkDiv (ILP = 1/(4+divisor)) */
9382 +#define SYCC_CD_SHIFT 16
9385 +#define GPIO_ONTIME_SHIFT 16
9387 +/* clockcontrol_n */
9388 +#define CN_N1_MASK 0x3f /* n1 control */
9389 +#define CN_N2_MASK 0x3f00 /* n2 control */
9390 +#define CN_N2_SHIFT 8
9391 +#define CN_PLLC_MASK 0xf0000 /* pll control */
9392 +#define CN_PLLC_SHIFT 16
9394 +/* clockcontrol_sb/pci/uart */
9395 +#define CC_M1_MASK 0x3f /* m1 control */
9396 +#define CC_M2_MASK 0x3f00 /* m2 control */
9397 +#define CC_M2_SHIFT 8
9398 +#define CC_M3_MASK 0x3f0000 /* m3 control */
9399 +#define CC_M3_SHIFT 16
9400 +#define CC_MC_MASK 0x1f000000 /* mux control */
9401 +#define CC_MC_SHIFT 24
9403 +/* N3M Clock control magic field values */
9404 +#define CC_F6_2 0x02 /* A factor of 2 in */
9405 +#define CC_F6_3 0x03 /* 6-bit fields like */
9406 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
9407 +#define CC_F6_5 0x09
9408 +#define CC_F6_6 0x11
9409 +#define CC_F6_7 0x21
9411 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
9413 +#define CC_MC_BYPASS 0x08
9414 +#define CC_MC_M1 0x04
9415 +#define CC_MC_M1M2 0x02
9416 +#define CC_MC_M1M2M3 0x01
9417 +#define CC_MC_M1M3 0x11
9419 +/* Type 2 Clock control magic field values */
9420 +#define CC_T2_BIAS 2 /* n1, n2, m1 & m3 bias */
9421 +#define CC_T2M2_BIAS 3 /* m2 bias */
9423 +#define CC_T2MC_M1BYP 1
9424 +#define CC_T2MC_M2BYP 2
9425 +#define CC_T2MC_M3BYP 4
9427 +/* Type 6 Clock control magic field values */
9428 +#define CC_T6_MMASK 1 /* bits of interest in m */
9429 +#define CC_T6_M0 120000000 /* sb clock for m = 0 */
9430 +#define CC_T6_M1 100000000 /* sb clock for m = 1 */
9431 +#define SB2MIPS_T6(sb) (2 * (sb))
9433 +/* Common clock base */
9434 +#define CC_CLOCK_BASE1 24000000 /* Half the clock freq */
9435 +#define CC_CLOCK_BASE2 12500000 /* Alternate crystal on some PLL's */
9437 +/* Clock control values for 200Mhz in 5350 */
9438 +#define CLKC_5350_N 0x0311
9439 +#define CLKC_5350_M 0x04020009
9441 +/* Flash types in the chipcommon capabilities register */
9442 +#define FLASH_NONE 0x000 /* No flash */
9443 +#define SFLASH_ST 0x100 /* ST serial flash */
9444 +#define SFLASH_AT 0x200 /* Atmel serial flash */
9445 +#define PFLASH 0x700 /* Parallel flash */
9447 +/* Bits in the config registers */
9448 +#define CC_CFG_EN 0x0001 /* Enable */
9449 +#define CC_CFG_EM_MASK 0x000e /* Extif Mode */
9450 +#define CC_CFG_EM_ASYNC 0x0002 /* Async/Parallel flash */
9451 +#define CC_CFG_EM_SYNC 0x0004 /* Synchronous */
9452 +#define CC_CFG_EM_PCMCIA 0x0008 /* PCMCIA */
9453 +#define CC_CFG_EM_IDE 0x000a /* IDE */
9454 +#define CC_CFG_DS 0x0010 /* Data size, 0=8bit, 1=16bit */
9455 +#define CC_CFG_CD_MASK 0x0060 /* Sync: Clock divisor */
9456 +#define CC_CFG_CE 0x0080 /* Sync: Clock enable */
9457 +#define CC_CFG_SB 0x0100 /* Sync: Size/Bytestrobe */
9459 +/* Start/busy bit in flashcontrol */
9460 +#define SFLASH_START 0x80000000
9461 +#define SFLASH_BUSY SFLASH_START
9463 +/* flashcontrol opcodes for ST flashes */
9464 +#define SFLASH_ST_WREN 0x0006 /* Write Enable */
9465 +#define SFLASH_ST_WRDIS 0x0004 /* Write Disable */
9466 +#define SFLASH_ST_RDSR 0x0105 /* Read Status Register */
9467 +#define SFLASH_ST_WRSR 0x0101 /* Write Status Register */
9468 +#define SFLASH_ST_READ 0x0303 /* Read Data Bytes */
9469 +#define SFLASH_ST_PP 0x0302 /* Page Program */
9470 +#define SFLASH_ST_SE 0x02d8 /* Sector Erase */
9471 +#define SFLASH_ST_BE 0x00c7 /* Bulk Erase */
9472 +#define SFLASH_ST_DP 0x00b9 /* Deep Power-down */
9473 +#define SFLASH_ST_RES 0x03ab /* Read Electronic Signature */
9475 +/* Status register bits for ST flashes */
9476 +#define SFLASH_ST_WIP 0x01 /* Write In Progress */
9477 +#define SFLASH_ST_WEL 0x02 /* Write Enable Latch */
9478 +#define SFLASH_ST_BP_MASK 0x1c /* Block Protect */
9479 +#define SFLASH_ST_BP_SHIFT 2
9480 +#define SFLASH_ST_SRWD 0x80 /* Status Register Write Disable */
9482 +/* flashcontrol opcodes for Atmel flashes */
9483 +#define SFLASH_AT_READ 0x07e8
9484 +#define SFLASH_AT_PAGE_READ 0x07d2
9485 +#define SFLASH_AT_BUF1_READ
9486 +#define SFLASH_AT_BUF2_READ
9487 +#define SFLASH_AT_STATUS 0x01d7
9488 +#define SFLASH_AT_BUF1_WRITE 0x0384
9489 +#define SFLASH_AT_BUF2_WRITE 0x0387
9490 +#define SFLASH_AT_BUF1_ERASE_PROGRAM 0x0283
9491 +#define SFLASH_AT_BUF2_ERASE_PROGRAM 0x0286
9492 +#define SFLASH_AT_BUF1_PROGRAM 0x0288
9493 +#define SFLASH_AT_BUF2_PROGRAM 0x0289
9494 +#define SFLASH_AT_PAGE_ERASE 0x0281
9495 +#define SFLASH_AT_BLOCK_ERASE 0x0250
9496 +#define SFLASH_AT_BUF1_WRITE_ERASE_PROGRAM 0x0382
9497 +#define SFLASH_AT_BUF2_WRITE_ERASE_PROGRAM 0x0385
9498 +#define SFLASH_AT_BUF1_LOAD 0x0253
9499 +#define SFLASH_AT_BUF2_LOAD 0x0255
9500 +#define SFLASH_AT_BUF1_COMPARE 0x0260
9501 +#define SFLASH_AT_BUF2_COMPARE 0x0261
9502 +#define SFLASH_AT_BUF1_REPROGRAM 0x0258
9503 +#define SFLASH_AT_BUF2_REPROGRAM 0x0259
9505 +/* Status register bits for Atmel flashes */
9506 +#define SFLASH_AT_READY 0x80
9507 +#define SFLASH_AT_MISMATCH 0x40
9508 +#define SFLASH_AT_ID_MASK 0x38
9509 +#define SFLASH_AT_ID_SHIFT 3
9512 +#define OTP_HW_REGION OTPS_HW_PROTECT
9513 +#define OTP_SW_REGION OTPS_SW_PROTECT
9514 +#define OTP_CID_REGION OTPS_CID_PROTECT
9516 +/* OTP regions (Byte offsets from otp size) */
9517 +#define OTP_SWLIM_OFF (-8)
9518 +#define OTP_CIDBASE_OFF 0
9519 +#define OTP_CIDLIM_OFF 8
9521 +/* Predefined OTP words (Word offset from otp size) */
9522 +#define OTP_BOUNDARY_OFF (-4)
9523 +#define OTP_HWSIGN_OFF (-3)
9524 +#define OTP_SWSIGN_OFF (-2)
9525 +#define OTP_CIDSIGN_OFF (-1)
9527 +#define OTP_CID_OFF 0
9528 +#define OTP_PKG_OFF 1
9529 +#define OTP_FID_OFF 2
9530 +#define OTP_RSV_OFF 3
9531 +#define OTP_LIM_OFF 4
9533 +#define OTP_SIGNATURE 0x578a
9534 +#define OTP_MAGIC 0x4e56
9536 +#endif /* _SBCHIPC_H */
9537 diff -urN linux.old/arch/mips/bcm947xx/include/sbconfig.h linux.dev/arch/mips/bcm947xx/include/sbconfig.h
9538 --- linux.old/arch/mips/bcm947xx/include/sbconfig.h 1970-01-01 01:00:00.000000000 +0100
9539 +++ linux.dev/arch/mips/bcm947xx/include/sbconfig.h 2005-12-15 15:35:24.538815250 +0100
9542 + * Broadcom SiliconBackplane hardware register definitions.
9544 + * Copyright 2005, Broadcom Corporation
9545 + * All Rights Reserved.
9547 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9548 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9549 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9550 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9554 +#ifndef _SBCONFIG_H
9555 +#define _SBCONFIG_H
9557 +/* cpp contortions to concatenate w/arg prescan */
9559 +#define _PADLINE(line) pad ## line
9560 +#define _XSTR(line) _PADLINE(line)
9561 +#define PAD _XSTR(__LINE__)
9565 + * SiliconBackplane Address Map.
9566 + * All regions may not exist on all chips.
9568 +#define SB_SDRAM_BASE 0x00000000 /* Physical SDRAM */
9569 +#define SB_PCI_MEM 0x08000000 /* Host Mode sb2pcitranslation0 (64 MB) */
9570 +#define SB_PCI_CFG 0x0c000000 /* Host Mode sb2pcitranslation1 (64 MB) */
9571 +#define SB_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */
9572 +#define SB_ENUM_BASE 0x18000000 /* Enumeration space base */
9573 +#define SB_ENUM_LIM 0x18010000 /* Enumeration space limit */
9575 +#define SB_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
9576 +#define SB_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
9578 +#define SB_EXTIF_BASE 0x1f000000 /* External Interface region base address */
9579 +#define SB_FLASH1 0x1fc00000 /* Flash Region 1 */
9580 +#define SB_FLASH1_SZ 0x00400000 /* Size of Flash Region 1 */
9582 +#define SB_PCI_DMA 0x40000000 /* Client Mode sb2pcitranslation2 (1 GB) */
9583 +#define SB_PCI_DMA_SZ 0x40000000 /* Client Mode sb2pcitranslation2 size in bytes */
9584 +#define SB_PCIE_DMA_L32 0x00000000 /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), low 32 bits */
9585 +#define SB_PCIE_DMA_H32 0x80000000 /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */
9586 +#define SB_EUART (SB_EXTIF_BASE + 0x00800000)
9587 +#define SB_LED (SB_EXTIF_BASE + 0x00900000)
9590 +/* enumeration space related defs */
9591 +#define SB_CORE_SIZE 0x1000 /* each core gets 4Kbytes for registers */
9592 +#define SB_MAXCORES ((SB_ENUM_LIM - SB_ENUM_BASE)/SB_CORE_SIZE)
9593 +#define SBCONFIGOFF 0xf00 /* core sbconfig regs are top 256bytes of regs */
9594 +#define SBCONFIGSIZE 256 /* sizeof (sbconfig_t) */
9597 +#define SB_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */
9600 + * Sonics Configuration Space Registers.
9602 +#define SBIPSFLAG 0x08
9603 +#define SBTPSFLAG 0x18
9604 +#define SBTMERRLOGA 0x48 /* sonics >= 2.3 */
9605 +#define SBTMERRLOG 0x50 /* sonics >= 2.3 */
9606 +#define SBADMATCH3 0x60
9607 +#define SBADMATCH2 0x68
9608 +#define SBADMATCH1 0x70
9609 +#define SBIMSTATE 0x90
9610 +#define SBINTVEC 0x94
9611 +#define SBTMSTATELOW 0x98
9612 +#define SBTMSTATEHIGH 0x9c
9613 +#define SBBWA0 0xa0
9614 +#define SBIMCONFIGLOW 0xa8
9615 +#define SBIMCONFIGHIGH 0xac
9616 +#define SBADMATCH0 0xb0
9617 +#define SBTMCONFIGLOW 0xb8
9618 +#define SBTMCONFIGHIGH 0xbc
9619 +#define SBBCONFIG 0xc0
9620 +#define SBBSTATE 0xc8
9621 +#define SBACTCNFG 0xd8
9622 +#define SBFLAGST 0xe8
9623 +#define SBIDLOW 0xf8
9624 +#define SBIDHIGH 0xfc
9626 +#ifndef _LANGUAGE_ASSEMBLY
9628 +typedef volatile struct _sbconfig {
9630 + uint32 sbipsflag; /* initiator port ocp slave flag */
9632 + uint32 sbtpsflag; /* target port ocp slave flag */
9634 + uint32 sbtmerrloga; /* (sonics >= 2.3) */
9636 + uint32 sbtmerrlog; /* (sonics >= 2.3) */
9638 + uint32 sbadmatch3; /* address match3 */
9640 + uint32 sbadmatch2; /* address match2 */
9642 + uint32 sbadmatch1; /* address match1 */
9644 + uint32 sbimstate; /* initiator agent state */
9645 + uint32 sbintvec; /* interrupt mask */
9646 + uint32 sbtmstatelow; /* target state */
9647 + uint32 sbtmstatehigh; /* target state */
9648 + uint32 sbbwa0; /* bandwidth allocation table0 */
9650 + uint32 sbimconfiglow; /* initiator configuration */
9651 + uint32 sbimconfighigh; /* initiator configuration */
9652 + uint32 sbadmatch0; /* address match0 */
9654 + uint32 sbtmconfiglow; /* target configuration */
9655 + uint32 sbtmconfighigh; /* target configuration */
9656 + uint32 sbbconfig; /* broadcast configuration */
9658 + uint32 sbbstate; /* broadcast state */
9660 + uint32 sbactcnfg; /* activate configuration */
9662 + uint32 sbflagst; /* current sbflags */
9664 + uint32 sbidlow; /* identification */
9665 + uint32 sbidhigh; /* identification */
9668 +#endif /* _LANGUAGE_ASSEMBLY */
9671 +#define SBIPS_INT1_MASK 0x3f /* which sbflags get routed to mips interrupt 1 */
9672 +#define SBIPS_INT1_SHIFT 0
9673 +#define SBIPS_INT2_MASK 0x3f00 /* which sbflags get routed to mips interrupt 2 */
9674 +#define SBIPS_INT2_SHIFT 8
9675 +#define SBIPS_INT3_MASK 0x3f0000 /* which sbflags get routed to mips interrupt 3 */
9676 +#define SBIPS_INT3_SHIFT 16
9677 +#define SBIPS_INT4_MASK 0x3f000000 /* which sbflags get routed to mips interrupt 4 */
9678 +#define SBIPS_INT4_SHIFT 24
9681 +#define SBTPS_NUM0_MASK 0x3f /* interrupt sbFlag # generated by this core */
9682 +#define SBTPS_F0EN0 0x40 /* interrupt is always sent on the backplane */
9685 +#define SBTMEL_CM 0x00000007 /* command */
9686 +#define SBTMEL_CI 0x0000ff00 /* connection id */
9687 +#define SBTMEL_EC 0x0f000000 /* error code */
9688 +#define SBTMEL_ME 0x80000000 /* multiple error */
9691 +#define SBIM_PC 0xf /* pipecount */
9692 +#define SBIM_AP_MASK 0x30 /* arbitration policy */
9693 +#define SBIM_AP_BOTH 0x00 /* use both timeslaces and token */
9694 +#define SBIM_AP_TS 0x10 /* use timesliaces only */
9695 +#define SBIM_AP_TK 0x20 /* use token only */
9696 +#define SBIM_AP_RSV 0x30 /* reserved */
9697 +#define SBIM_IBE 0x20000 /* inbanderror */
9698 +#define SBIM_TO 0x40000 /* timeout */
9699 +#define SBIM_BY 0x01800000 /* busy (sonics >= 2.3) */
9700 +#define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */
9703 +#define SBTML_RESET 0x1 /* reset */
9704 +#define SBTML_REJ_MASK 0x6 /* reject */
9705 +#define SBTML_REJ_SHIFT 1
9706 +#define SBTML_CLK 0x10000 /* clock enable */
9707 +#define SBTML_FGC 0x20000 /* force gated clocks on */
9708 +#define SBTML_FL_MASK 0x3ffc0000 /* core-specific flags */
9709 +#define SBTML_PE 0x40000000 /* pme enable */
9710 +#define SBTML_BE 0x80000000 /* bist enable */
9712 +/* sbtmstatehigh */
9713 +#define SBTMH_SERR 0x1 /* serror */
9714 +#define SBTMH_INT 0x2 /* interrupt */
9715 +#define SBTMH_BUSY 0x4 /* busy */
9716 +#define SBTMH_TO 0x00000020 /* timeout (sonics >= 2.3) */
9717 +#define SBTMH_FL_MASK 0x1fff0000 /* core-specific flags */
9718 +#define SBTMH_DMA64 0x10000000 /* supports DMA with 64-bit addresses */
9719 +#define SBTMH_GCR 0x20000000 /* gated clock request */
9720 +#define SBTMH_BISTF 0x40000000 /* bist failed */
9721 +#define SBTMH_BISTD 0x80000000 /* bist done */
9725 +#define SBBWA_TAB0_MASK 0xffff /* lookup table 0 */
9726 +#define SBBWA_TAB1_MASK 0xffff /* lookup table 1 */
9727 +#define SBBWA_TAB1_SHIFT 16
9729 +/* sbimconfiglow */
9730 +#define SBIMCL_STO_MASK 0x7 /* service timeout */
9731 +#define SBIMCL_RTO_MASK 0x70 /* request timeout */
9732 +#define SBIMCL_RTO_SHIFT 4
9733 +#define SBIMCL_CID_MASK 0xff0000 /* connection id */
9734 +#define SBIMCL_CID_SHIFT 16
9736 +/* sbimconfighigh */
9737 +#define SBIMCH_IEM_MASK 0xc /* inband error mode */
9738 +#define SBIMCH_TEM_MASK 0x30 /* timeout error mode */
9739 +#define SBIMCH_TEM_SHIFT 4
9740 +#define SBIMCH_BEM_MASK 0xc0 /* bus error mode */
9741 +#define SBIMCH_BEM_SHIFT 6
9744 +#define SBAM_TYPE_MASK 0x3 /* address type */
9745 +#define SBAM_AD64 0x4 /* reserved */
9746 +#define SBAM_ADINT0_MASK 0xf8 /* type0 size */
9747 +#define SBAM_ADINT0_SHIFT 3
9748 +#define SBAM_ADINT1_MASK 0x1f8 /* type1 size */
9749 +#define SBAM_ADINT1_SHIFT 3
9750 +#define SBAM_ADINT2_MASK 0x1f8 /* type2 size */
9751 +#define SBAM_ADINT2_SHIFT 3
9752 +#define SBAM_ADEN 0x400 /* enable */
9753 +#define SBAM_ADNEG 0x800 /* negative decode */
9754 +#define SBAM_BASE0_MASK 0xffffff00 /* type0 base address */
9755 +#define SBAM_BASE0_SHIFT 8
9756 +#define SBAM_BASE1_MASK 0xfffff000 /* type1 base address for the core */
9757 +#define SBAM_BASE1_SHIFT 12
9758 +#define SBAM_BASE2_MASK 0xffff0000 /* type2 base address for the core */
9759 +#define SBAM_BASE2_SHIFT 16
9761 +/* sbtmconfiglow */
9762 +#define SBTMCL_CD_MASK 0xff /* clock divide */
9763 +#define SBTMCL_CO_MASK 0xf800 /* clock offset */
9764 +#define SBTMCL_CO_SHIFT 11
9765 +#define SBTMCL_IF_MASK 0xfc0000 /* interrupt flags */
9766 +#define SBTMCL_IF_SHIFT 18
9767 +#define SBTMCL_IM_MASK 0x3000000 /* interrupt mode */
9768 +#define SBTMCL_IM_SHIFT 24
9770 +/* sbtmconfighigh */
9771 +#define SBTMCH_BM_MASK 0x3 /* busy mode */
9772 +#define SBTMCH_RM_MASK 0x3 /* retry mode */
9773 +#define SBTMCH_RM_SHIFT 2
9774 +#define SBTMCH_SM_MASK 0x30 /* stop mode */
9775 +#define SBTMCH_SM_SHIFT 4
9776 +#define SBTMCH_EM_MASK 0x300 /* sb error mode */
9777 +#define SBTMCH_EM_SHIFT 8
9778 +#define SBTMCH_IM_MASK 0xc00 /* int mode */
9779 +#define SBTMCH_IM_SHIFT 10
9782 +#define SBBC_LAT_MASK 0x3 /* sb latency */
9783 +#define SBBC_MAX0_MASK 0xf0000 /* maxccntr0 */
9784 +#define SBBC_MAX0_SHIFT 16
9785 +#define SBBC_MAX1_MASK 0xf00000 /* maxccntr1 */
9786 +#define SBBC_MAX1_SHIFT 20
9789 +#define SBBS_SRD 0x1 /* st reg disable */
9790 +#define SBBS_HRD 0x2 /* hold reg disable */
9793 +#define SBIDL_CS_MASK 0x3 /* config space */
9794 +#define SBIDL_AR_MASK 0x38 /* # address ranges supported */
9795 +#define SBIDL_AR_SHIFT 3
9796 +#define SBIDL_SYNCH 0x40 /* sync */
9797 +#define SBIDL_INIT 0x80 /* initiator */
9798 +#define SBIDL_MINLAT_MASK 0xf00 /* minimum backplane latency */
9799 +#define SBIDL_MINLAT_SHIFT 8
9800 +#define SBIDL_MAXLAT 0xf000 /* maximum backplane latency */
9801 +#define SBIDL_MAXLAT_SHIFT 12
9802 +#define SBIDL_FIRST 0x10000 /* this initiator is first */
9803 +#define SBIDL_CW_MASK 0xc0000 /* cycle counter width */
9804 +#define SBIDL_CW_SHIFT 18
9805 +#define SBIDL_TP_MASK 0xf00000 /* target ports */
9806 +#define SBIDL_TP_SHIFT 20
9807 +#define SBIDL_IP_MASK 0xf000000 /* initiator ports */
9808 +#define SBIDL_IP_SHIFT 24
9809 +#define SBIDL_RV_MASK 0xf0000000 /* sonics backplane revision code */
9810 +#define SBIDL_RV_SHIFT 28
9811 +#define SBIDL_RV_2_2 0x00000000 /* version 2.2 or earlier */
9812 +#define SBIDL_RV_2_3 0x10000000 /* version 2.3 */
9815 +#define SBIDH_RC_MASK 0x000f /* revision code */
9816 +#define SBIDH_RCE_MASK 0x7000 /* revision code extension field */
9817 +#define SBIDH_RCE_SHIFT 8
9818 +#define SBCOREREV(sbidh) \
9819 + ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | ((sbidh) & SBIDH_RC_MASK))
9820 +#define SBIDH_CC_MASK 0x8ff0 /* core code */
9821 +#define SBIDH_CC_SHIFT 4
9822 +#define SBIDH_VC_MASK 0xffff0000 /* vendor code */
9823 +#define SBIDH_VC_SHIFT 16
9825 +#define SB_COMMIT 0xfd8 /* update buffered registers value */
9828 +#define SB_VEND_BCM 0x4243 /* Broadcom's SB vendor code */
9831 +#define SB_CC 0x800 /* chipcommon core */
9832 +#define SB_ILINE20 0x801 /* iline20 core */
9833 +#define SB_SDRAM 0x803 /* sdram core */
9834 +#define SB_PCI 0x804 /* pci core */
9835 +#define SB_MIPS 0x805 /* mips core */
9836 +#define SB_ENET 0x806 /* enet mac core */
9837 +#define SB_CODEC 0x807 /* v90 codec core */
9838 +#define SB_USB 0x808 /* usb 1.1 host/device core */
9839 +#define SB_ADSL 0x809 /* ADSL core */
9840 +#define SB_ILINE100 0x80a /* iline100 core */
9841 +#define SB_IPSEC 0x80b /* ipsec core */
9842 +#define SB_PCMCIA 0x80d /* pcmcia core */
9843 +#define SB_SOCRAM 0x80e /* internal memory core */
9844 +#define SB_MEMC 0x80f /* memc sdram core */
9845 +#define SB_EXTIF 0x811 /* external interface core */
9846 +#define SB_D11 0x812 /* 802.11 MAC core */
9847 +#define SB_MIPS33 0x816 /* mips3302 core */
9848 +#define SB_USB11H 0x817 /* usb 1.1 host core */
9849 +#define SB_USB11D 0x818 /* usb 1.1 device core */
9850 +#define SB_USB20H 0x819 /* usb 2.0 host core */
9851 +#define SB_USB20D 0x81a /* usb 2.0 device core */
9852 +#define SB_SDIOH 0x81b /* sdio host core */
9853 +#define SB_ROBO 0x81c /* roboswitch core */
9854 +#define SB_ATA100 0x81d /* parallel ATA core */
9855 +#define SB_SATAXOR 0x81e /* serial ATA & XOR DMA core */
9856 +#define SB_GIGETH 0x81f /* gigabit ethernet core */
9857 +#define SB_PCIE 0x820 /* pci express core */
9858 +#define SB_SRAMC 0x822 /* SRAM controller core */
9859 +#define SB_MINIMAC 0x823 /* MINI MAC/phy core */
9861 +#define SB_CC_IDX 0 /* chipc, when present, is always core 0 */
9863 +/* Not really related to Silicon Backplane, but a couple of software
9864 + * conventions for the use the flash space:
9867 +/* Minumum amount of flash we support */
9868 +#define FLASH_MIN 0x00020000 /* Minimum flash size */
9870 +/* A boot/binary may have an embedded block that describes its size */
9871 +#define BISZ_OFFSET 0x3e0 /* At this offset into the binary */
9872 +#define BISZ_MAGIC 0x4249535a /* Marked with this value: 'BISZ' */
9873 +#define BISZ_MAGIC_IDX 0 /* Word 0: magic */
9874 +#define BISZ_TXTST_IDX 1 /* 1: text start */
9875 +#define BISZ_TXTEND_IDX 2 /* 2: text start */
9876 +#define BISZ_DATAST_IDX 3 /* 3: text start */
9877 +#define BISZ_DATAEND_IDX 4 /* 4: text start */
9878 +#define BISZ_BSSST_IDX 5 /* 5: text start */
9879 +#define BISZ_BSSEND_IDX 6 /* 6: text start */
9880 +#define BISZ_SIZE 7 /* descriptor size in 32-bit intergers */
9882 +#endif /* _SBCONFIG_H */
9883 diff -urN linux.old/arch/mips/bcm947xx/include/sbextif.h linux.dev/arch/mips/bcm947xx/include/sbextif.h
9884 --- linux.old/arch/mips/bcm947xx/include/sbextif.h 1970-01-01 01:00:00.000000000 +0100
9885 +++ linux.dev/arch/mips/bcm947xx/include/sbextif.h 2005-12-15 16:48:55.651993750 +0100
9888 + * Hardware-specific External Interface I/O core definitions
9889 + * for the BCM47xx family of SiliconBackplane-based chips.
9891 + * The External Interface core supports a total of three external chip selects
9892 + * supporting external interfaces. One of the external chip selects is
9893 + * used for Flash, one is used for PCMCIA, and the other may be
9894 + * programmed to support either a synchronous interface or an
9895 + * asynchronous interface. The asynchronous interface can be used to
9896 + * support external devices such as UARTs and the BCM2019 Bluetooth
9897 + * baseband processor.
9898 + * The external interface core also contains 2 on-chip 16550 UARTs, clock
9899 + * frequency control, a watchdog interrupt timer, and a GPIO interface.
9901 + * Copyright 2005, Broadcom Corporation
9902 + * All Rights Reserved.
9904 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9905 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9906 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9907 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9914 +/* external interface address space */
9915 +#define EXTIF_PCMCIA_MEMBASE(x) (x)
9916 +#define EXTIF_PCMCIA_IOBASE(x) ((x) + 0x100000)
9917 +#define EXTIF_PCMCIA_CFGBASE(x) ((x) + 0x200000)
9918 +#define EXTIF_CFGIF_BASE(x) ((x) + 0x800000)
9919 +#define EXTIF_FLASH_BASE(x) ((x) + 0xc00000)
9921 +/* cpp contortions to concatenate w/arg prescan */
9923 +#define _PADLINE(line) pad ## line
9924 +#define _XSTR(line) _PADLINE(line)
9925 +#define PAD _XSTR(__LINE__)
9929 + * The multiple instances of output and output enable registers
9930 + * are present to allow driver software for multiple cores to control
9931 + * gpio outputs without needing to share a single register pair.
9937 +#define NGPIOUSER 5
9939 +typedef volatile struct {
9940 + uint32 corecontrol;
9944 + /* pcmcia control registers */
9945 + uint32 pcmcia_config;
9946 + uint32 pcmcia_memwait;
9947 + uint32 pcmcia_attrwait;
9948 + uint32 pcmcia_iowait;
9950 + /* programmable interface control registers */
9951 + uint32 prog_config;
9952 + uint32 prog_waitcount;
9954 + /* flash control registers */
9955 + uint32 flash_config;
9956 + uint32 flash_waitcount;
9961 + /* clock control */
9962 + uint32 clockcontrol_n;
9963 + uint32 clockcontrol_sb;
9964 + uint32 clockcontrol_pci;
9965 + uint32 clockcontrol_mii;
9970 + struct gpiouser gpio[NGPIOUSER];
9972 + uint32 ejtagouten;
9973 + uint32 gpiointpolarity;
9974 + uint32 gpiointmask;
9991 + uint8 uartscratch;
9996 +#define CC_UE (1 << 0) /* uart enable */
9999 +#define ES_EM (1 << 0) /* endian mode (ro) */
10000 +#define ES_EI (1 << 1) /* external interrupt pin (ro) */
10001 +#define ES_GI (1 << 2) /* gpio interrupt pin (ro) */
10003 +/* gpio bit mask */
10004 +#define GPIO_BIT0 (1 << 0)
10005 +#define GPIO_BIT1 (1 << 1)
10006 +#define GPIO_BIT2 (1 << 2)
10007 +#define GPIO_BIT3 (1 << 3)
10008 +#define GPIO_BIT4 (1 << 4)
10009 +#define GPIO_BIT5 (1 << 5)
10010 +#define GPIO_BIT6 (1 << 6)
10011 +#define GPIO_BIT7 (1 << 7)
10014 +/* pcmcia/prog/flash_config */
10015 +#define CF_EN (1 << 0) /* enable */
10016 +#define CF_EM_MASK 0xe /* mode */
10017 +#define CF_EM_SHIFT 1
10018 +#define CF_EM_FLASH 0x0 /* flash/asynchronous mode */
10019 +#define CF_EM_SYNC 0x2 /* synchronous mode */
10020 +#define CF_EM_PCMCIA 0x4 /* pcmcia mode */
10021 +#define CF_DS (1 << 4) /* destsize: 0=8bit, 1=16bit */
10022 +#define CF_BS (1 << 5) /* byteswap */
10023 +#define CF_CD_MASK 0xc0 /* clock divider */
10024 +#define CF_CD_SHIFT 6
10025 +#define CF_CD_DIV2 0x0 /* backplane/2 */
10026 +#define CF_CD_DIV3 0x40 /* backplane/3 */
10027 +#define CF_CD_DIV4 0x80 /* backplane/4 */
10028 +#define CF_CE (1 << 8) /* clock enable */
10029 +#define CF_SB (1 << 9) /* size/bytestrobe (synch only) */
10031 +/* pcmcia_memwait */
10032 +#define PM_W0_MASK 0x3f /* waitcount0 */
10033 +#define PM_W1_MASK 0x1f00 /* waitcount1 */
10034 +#define PM_W1_SHIFT 8
10035 +#define PM_W2_MASK 0x1f0000 /* waitcount2 */
10036 +#define PM_W2_SHIFT 16
10037 +#define PM_W3_MASK 0x1f000000 /* waitcount3 */
10038 +#define PM_W3_SHIFT 24
10040 +/* pcmcia_attrwait */
10041 +#define PA_W0_MASK 0x3f /* waitcount0 */
10042 +#define PA_W1_MASK 0x1f00 /* waitcount1 */
10043 +#define PA_W1_SHIFT 8
10044 +#define PA_W2_MASK 0x1f0000 /* waitcount2 */
10045 +#define PA_W2_SHIFT 16
10046 +#define PA_W3_MASK 0x1f000000 /* waitcount3 */
10047 +#define PA_W3_SHIFT 24
10049 +/* pcmcia_iowait */
10050 +#define PI_W0_MASK 0x3f /* waitcount0 */
10051 +#define PI_W1_MASK 0x1f00 /* waitcount1 */
10052 +#define PI_W1_SHIFT 8
10053 +#define PI_W2_MASK 0x1f0000 /* waitcount2 */
10054 +#define PI_W2_SHIFT 16
10055 +#define PI_W3_MASK 0x1f000000 /* waitcount3 */
10056 +#define PI_W3_SHIFT 24
10058 +/* prog_waitcount */
10059 +#define PW_W0_MASK 0x0000001f /* waitcount0 */
10060 +#define PW_W1_MASK 0x00001f00 /* waitcount1 */
10061 +#define PW_W1_SHIFT 8
10062 +#define PW_W2_MASK 0x001f0000 /* waitcount2 */
10063 +#define PW_W2_SHIFT 16
10064 +#define PW_W3_MASK 0x1f000000 /* waitcount3 */
10065 +#define PW_W3_SHIFT 24
10067 +#define PW_W0 0x0000000c
10068 +#define PW_W1 0x00000a00
10069 +#define PW_W2 0x00020000
10070 +#define PW_W3 0x01000000
10072 +/* flash_waitcount */
10073 +#define FW_W0_MASK 0x1f /* waitcount0 */
10074 +#define FW_W1_MASK 0x1f00 /* waitcount1 */
10075 +#define FW_W1_SHIFT 8
10076 +#define FW_W2_MASK 0x1f0000 /* waitcount2 */
10077 +#define FW_W2_SHIFT 16
10078 +#define FW_W3_MASK 0x1f000000 /* waitcount3 */
10079 +#define FW_W3_SHIFT 24
10082 +#define WATCHDOG_CLOCK 48000000 /* Hz */
10084 +/* clockcontrol_n */
10085 +#define CN_N1_MASK 0x3f /* n1 control */
10086 +#define CN_N2_MASK 0x3f00 /* n2 control */
10087 +#define CN_N2_SHIFT 8
10089 +/* clockcontrol_sb/pci/mii */
10090 +#define CC_M1_MASK 0x3f /* m1 control */
10091 +#define CC_M2_MASK 0x3f00 /* m2 control */
10092 +#define CC_M2_SHIFT 8
10093 +#define CC_M3_MASK 0x3f0000 /* m3 control */
10094 +#define CC_M3_SHIFT 16
10095 +#define CC_MC_MASK 0x1f000000 /* mux control */
10096 +#define CC_MC_SHIFT 24
10098 +/* Clock control default values */
10099 +#define CC_DEF_N 0x0009 /* Default values for bcm4710 */
10100 +#define CC_DEF_100 0x04020011
10101 +#define CC_DEF_33 0x11030011
10102 +#define CC_DEF_25 0x11050011
10104 +/* Clock control values for 125Mhz */
10105 +#define CC_125_N 0x0802
10106 +#define CC_125_M 0x04020009
10107 +#define CC_125_M25 0x11090009
10108 +#define CC_125_M33 0x11090005
10110 +/* Clock control magic field values */
10111 +#define CC_F6_2 0x02 /* A factor of 2 in */
10112 +#define CC_F6_3 0x03 /* 6-bit fields like */
10113 +#define CC_F6_4 0x05 /* N1, M1 or M3 */
10114 +#define CC_F6_5 0x09
10115 +#define CC_F6_6 0x11
10116 +#define CC_F6_7 0x21
10118 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */
10120 +#define CC_MC_BYPASS 0x08
10121 +#define CC_MC_M1 0x04
10122 +#define CC_MC_M1M2 0x02
10123 +#define CC_MC_M1M2M3 0x01
10124 +#define CC_MC_M1M3 0x11
10126 +#define CC_CLOCK_BASE 24000000 /* Half the clock freq. in the 4710 */
10128 +#endif /* _SBEXTIF_H */
10129 diff -urN linux.old/arch/mips/bcm947xx/include/sbmemc.h linux.dev/arch/mips/bcm947xx/include/sbmemc.h
10130 --- linux.old/arch/mips/bcm947xx/include/sbmemc.h 1970-01-01 01:00:00.000000000 +0100
10131 +++ linux.dev/arch/mips/bcm947xx/include/sbmemc.h 2005-12-15 15:35:31.567254500 +0100
10134 + * BCM47XX Sonics SiliconBackplane DDR/SDRAM controller core hardware definitions.
10136 + * Copyright 2005, Broadcom Corporation
10137 + * All Rights Reserved.
10139 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10140 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10141 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10142 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10150 +#ifdef _LANGUAGE_ASSEMBLY
10152 +#define MEMC_CONTROL 0x00
10153 +#define MEMC_CONFIG 0x04
10154 +#define MEMC_REFRESH 0x08
10155 +#define MEMC_BISTSTAT 0x0c
10156 +#define MEMC_MODEBUF 0x10
10157 +#define MEMC_BKCLS 0x14
10158 +#define MEMC_PRIORINV 0x18
10159 +#define MEMC_DRAMTIM 0x1c
10160 +#define MEMC_INTSTAT 0x20
10161 +#define MEMC_INTMASK 0x24
10162 +#define MEMC_INTINFO 0x28
10163 +#define MEMC_NCDLCTL 0x30
10164 +#define MEMC_RDNCDLCOR 0x34
10165 +#define MEMC_WRNCDLCOR 0x38
10166 +#define MEMC_MISCDLYCTL 0x3c
10167 +#define MEMC_DQSGATENCDL 0x40
10168 +#define MEMC_SPARE 0x44
10169 +#define MEMC_TPADDR 0x48
10170 +#define MEMC_TPDATA 0x4c
10171 +#define MEMC_BARRIER 0x50
10172 +#define MEMC_CORE 0x54
10177 +/* Sonics side: MEMC core registers */
10178 +typedef volatile struct sbmemcregs {
10190 + uint32 reserved1;
10192 + uint32 rdncdlcor;
10193 + uint32 wrncdlcor;
10194 + uint32 miscdlyctl;
10195 + uint32 dqsgatencdl;
10205 +/* MEMC Core Init values (OCP ID 0x80f) */
10208 +#define MEMC_SD_CONFIG_INIT 0x00048000
10209 +#define MEMC_SD_DRAMTIM2_INIT 0x000754d8
10210 +#define MEMC_SD_DRAMTIM3_INIT 0x000754da
10211 +#define MEMC_SD_RDNCDLCOR_INIT 0x00000000
10212 +#define MEMC_SD_WRNCDLCOR_INIT 0x49351200
10213 +#define MEMC_SD1_WRNCDLCOR_INIT 0x14500200 /* For corerev 1 (4712) */
10214 +#define MEMC_SD_MISCDLYCTL_INIT 0x00061c1b
10215 +#define MEMC_SD1_MISCDLYCTL_INIT 0x00021416 /* For corerev 1 (4712) */
10216 +#define MEMC_SD_CONTROL_INIT0 0x00000002
10217 +#define MEMC_SD_CONTROL_INIT1 0x00000008
10218 +#define MEMC_SD_CONTROL_INIT2 0x00000004
10219 +#define MEMC_SD_CONTROL_INIT3 0x00000010
10220 +#define MEMC_SD_CONTROL_INIT4 0x00000001
10221 +#define MEMC_SD_MODEBUF_INIT 0x00000000
10222 +#define MEMC_SD_REFRESH_INIT 0x0000840f
10225 +/* This is for SDRM8X8X4 */
10226 +#define MEMC_SDR_INIT 0x0008
10227 +#define MEMC_SDR_MODE 0x32
10228 +#define MEMC_SDR_NCDL 0x00020032
10229 +#define MEMC_SDR1_NCDL 0x0002020f /* For corerev 1 (4712) */
10232 +#define MEMC_CONFIG_INIT 0x00048000
10233 +#define MEMC_DRAMTIM2_INIT 0x000754d8
10234 +#define MEMC_DRAMTIM25_INIT 0x000754d9
10235 +#define MEMC_RDNCDLCOR_INIT 0x00000000
10236 +#define MEMC_RDNCDLCOR_SIMINIT 0xf6f6f6f6 /* For hdl sim */
10237 +#define MEMC_WRNCDLCOR_INIT 0x49351200
10238 +#define MEMC_1_WRNCDLCOR_INIT 0x14500200
10239 +#define MEMC_DQSGATENCDL_INIT 0x00030000
10240 +#define MEMC_MISCDLYCTL_INIT 0x21061c1b
10241 +#define MEMC_1_MISCDLYCTL_INIT 0x21021400
10242 +#define MEMC_NCDLCTL_INIT 0x00002001
10243 +#define MEMC_CONTROL_INIT0 0x00000002
10244 +#define MEMC_CONTROL_INIT1 0x00000008
10245 +#define MEMC_MODEBUF_INIT0 0x00004000
10246 +#define MEMC_CONTROL_INIT2 0x00000010
10247 +#define MEMC_MODEBUF_INIT1 0x00000100
10248 +#define MEMC_CONTROL_INIT3 0x00000010
10249 +#define MEMC_CONTROL_INIT4 0x00000008
10250 +#define MEMC_REFRESH_INIT 0x0000840f
10251 +#define MEMC_CONTROL_INIT5 0x00000004
10252 +#define MEMC_MODEBUF_INIT2 0x00000000
10253 +#define MEMC_CONTROL_INIT6 0x00000010
10254 +#define MEMC_CONTROL_INIT7 0x00000001
10257 +/* This is for DDRM16X16X2 */
10258 +#define MEMC_DDR_INIT 0x0009
10259 +#define MEMC_DDR_MODE 0x62
10260 +#define MEMC_DDR_NCDL 0x0005050a
10261 +#define MEMC_DDR1_NCDL 0x00000a0a /* For corerev 1 (4712) */
10263 +/* mask for sdr/ddr calibration registers */
10264 +#define MEMC_RDNCDLCOR_RD_MASK 0x000000ff
10265 +#define MEMC_WRNCDLCOR_WR_MASK 0x000000ff
10266 +#define MEMC_DQSGATENCDL_G_MASK 0x000000ff
10268 +/* masks for miscdlyctl registers */
10269 +#define MEMC_MISC_SM_MASK 0x30000000
10270 +#define MEMC_MISC_SM_SHIFT 28
10271 +#define MEMC_MISC_SD_MASK 0x0f000000
10272 +#define MEMC_MISC_SD_SHIFT 24
10274 +/* hw threshhold for calculating wr/rd for sdr memc */
10275 +#define MEMC_CD_THRESHOLD 128
10277 +/* Low bit of init register says if memc is ddr or sdr */
10278 +#define MEMC_CONFIG_DDR 0x00000001
10280 +#endif /* _SBMEMC_H */
10281 diff -urN linux.old/arch/mips/bcm947xx/include/sbmips.h linux.dev/arch/mips/bcm947xx/include/sbmips.h
10282 --- linux.old/arch/mips/bcm947xx/include/sbmips.h 1970-01-01 01:00:00.000000000 +0100
10283 +++ linux.dev/arch/mips/bcm947xx/include/sbmips.h 2005-12-15 16:46:57.616617000 +0100
10286 + * Broadcom SiliconBackplane MIPS definitions
10288 + * SB MIPS cores are custom MIPS32 processors with SiliconBackplane
10289 + * OCP interfaces. The CP0 processor ID is 0x00024000, where bits
10290 + * 23:16 mean Broadcom and bits 15:8 mean a MIPS core with an OCP
10291 + * interface. The core revision is stored in the SB ID register in SB
10292 + * configuration space.
10294 + * Copyright 2005, Broadcom Corporation
10295 + * All Rights Reserved.
10297 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10298 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10299 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10300 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10308 +#include <mipsinc.h>
10310 +#ifndef _LANGUAGE_ASSEMBLY
10312 +/* cpp contortions to concatenate w/arg prescan */
10314 +#define _PADLINE(line) pad ## line
10315 +#define _XSTR(line) _PADLINE(line)
10316 +#define PAD _XSTR(__LINE__)
10319 +typedef volatile struct {
10320 + uint32 corecontrol;
10322 + uint32 biststatus;
10324 + uint32 intstatus;
10329 +extern uint32 sb_flag(sb_t *sbh);
10330 +extern uint sb_irq(sb_t *sbh);
10332 +extern void BCMINIT(sb_serial_init)(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift));
10334 +extern void *sb_jtagm_init(sb_t *sbh, uint clkd, bool exttap);
10335 +extern void sb_jtagm_disable(void *h);
10336 +extern uint32 jtag_rwreg(void *h, uint32 ir, uint32 dr);
10337 +extern void BCMINIT(sb_mips_init)(sb_t *sbh);
10338 +extern uint32 BCMINIT(sb_mips_clock)(sb_t *sbh);
10339 +extern bool BCMINIT(sb_mips_setclock)(sb_t *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock);
10340 +extern void BCMINIT(enable_pfc)(uint32 mode);
10341 +extern uint32 BCMINIT(sb_memc_get_ncdl)(sb_t *sbh);
10344 +#endif /* _LANGUAGE_ASSEMBLY */
10346 +#endif /* _SBMIPS_H */
10347 diff -urN linux.old/arch/mips/bcm947xx/include/sbpci.h linux.dev/arch/mips/bcm947xx/include/sbpci.h
10348 --- linux.old/arch/mips/bcm947xx/include/sbpci.h 1970-01-01 01:00:00.000000000 +0100
10349 +++ linux.dev/arch/mips/bcm947xx/include/sbpci.h 2005-12-15 15:35:36.795581250 +0100
10352 + * BCM47XX Sonics SiliconBackplane PCI core hardware definitions.
10355 + * Copyright 2005, Broadcom Corporation
10356 + * All Rights Reserved.
10358 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10359 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10360 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10361 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10367 +/* cpp contortions to concatenate w/arg prescan */
10369 +#define _PADLINE(line) pad ## line
10370 +#define _XSTR(line) _PADLINE(line)
10371 +#define PAD _XSTR(__LINE__)
10374 +/* Sonics side: PCI core and host control registers */
10375 +typedef struct sbpciregs {
10376 + uint32 control; /* PCI control */
10378 + uint32 arbcontrol; /* PCI arbiter control */
10380 + uint32 intstatus; /* Interrupt status */
10381 + uint32 intmask; /* Interrupt mask */
10382 + uint32 sbtopcimailbox; /* Sonics to PCI mailbox */
10384 + uint32 bcastaddr; /* Sonics broadcast address */
10385 + uint32 bcastdata; /* Sonics broadcast data */
10387 + uint32 gpioin; /* ro: gpio input (>=rev2) */
10388 + uint32 gpioout; /* rw: gpio output (>=rev2) */
10389 + uint32 gpioouten; /* rw: gpio output enable (>= rev2) */
10390 + uint32 gpiocontrol; /* rw: gpio control (>= rev2) */
10392 + uint32 sbtopci0; /* Sonics to PCI translation 0 */
10393 + uint32 sbtopci1; /* Sonics to PCI translation 1 */
10394 + uint32 sbtopci2; /* Sonics to PCI translation 2 */
10396 + uint16 sprom[36]; /* SPROM shadow Area */
10401 +#define PCI_RST_OE 0x01 /* When set, drives PCI_RESET out to pin */
10402 +#define PCI_RST 0x02 /* Value driven out to pin */
10403 +#define PCI_CLK_OE 0x04 /* When set, drives clock as gated by PCI_CLK out to pin */
10404 +#define PCI_CLK 0x08 /* Gate for clock driven out to pin */
10406 +/* PCI arbiter control */
10407 +#define PCI_INT_ARB 0x01 /* When set, use an internal arbiter */
10408 +#define PCI_EXT_ARB 0x02 /* When set, use an external arbiter */
10409 +#define PCI_PARKID_MASK 0x06 /* Selects which agent is parked on an idle bus */
10410 +#define PCI_PARKID_SHIFT 1
10411 +#define PCI_PARKID_LAST 0 /* Last requestor */
10412 +#define PCI_PARKID_4710 1 /* 4710 */
10413 +#define PCI_PARKID_EXTREQ0 2 /* External requestor 0 */
10414 +#define PCI_PARKID_EXTREQ1 3 /* External requestor 1 */
10416 +/* Interrupt status/mask */
10417 +#define PCI_INTA 0x01 /* PCI INTA# is asserted */
10418 +#define PCI_INTB 0x02 /* PCI INTB# is asserted */
10419 +#define PCI_SERR 0x04 /* PCI SERR# has been asserted (write one to clear) */
10420 +#define PCI_PERR 0x08 /* PCI PERR# has been asserted (write one to clear) */
10421 +#define PCI_PME 0x10 /* PCI PME# is asserted */
10423 +/* (General) PCI/SB mailbox interrupts, two bits per pci function */
10424 +#define MAILBOX_F0_0 0x100 /* function 0, int 0 */
10425 +#define MAILBOX_F0_1 0x200 /* function 0, int 1 */
10426 +#define MAILBOX_F1_0 0x400 /* function 1, int 0 */
10427 +#define MAILBOX_F1_1 0x800 /* function 1, int 1 */
10428 +#define MAILBOX_F2_0 0x1000 /* function 2, int 0 */
10429 +#define MAILBOX_F2_1 0x2000 /* function 2, int 1 */
10430 +#define MAILBOX_F3_0 0x4000 /* function 3, int 0 */
10431 +#define MAILBOX_F3_1 0x8000 /* function 3, int 1 */
10433 +/* Sonics broadcast address */
10434 +#define BCAST_ADDR_MASK 0xff /* Broadcast register address */
10436 +/* Sonics to PCI translation types */
10437 +#define SBTOPCI0_MASK 0xfc000000
10438 +#define SBTOPCI1_MASK 0xfc000000
10439 +#define SBTOPCI2_MASK 0xc0000000
10440 +#define SBTOPCI_MEM 0
10441 +#define SBTOPCI_IO 1
10442 +#define SBTOPCI_CFG0 2
10443 +#define SBTOPCI_CFG1 3
10444 +#define SBTOPCI_PREF 0x4 /* prefetch enable */
10445 +#define SBTOPCI_BURST 0x8 /* burst enable */
10446 +#define SBTOPCI_RC_MASK 0x30 /* read command (>= rev11) */
10447 +#define SBTOPCI_RC_READ 0x00 /* memory read */
10448 +#define SBTOPCI_RC_READLINE 0x10 /* memory read line */
10449 +#define SBTOPCI_RC_READMULTI 0x20 /* memory read multiple */
10451 +/* PCI core index in SROM shadow area */
10452 +#define SRSH_PI_OFFSET 0 /* first word */
10453 +#define SRSH_PI_MASK 0xf000 /* bit 15:12 */
10454 +#define SRSH_PI_SHIFT 12 /* bit 15:12 */
10456 +/* PCI side: Reserved PCI configuration registers (see pcicfg.h) */
10457 +#define cap_list rsvd_a[0]
10458 +#define bar0_window dev_dep[0x80 - 0x40]
10459 +#define bar1_window dev_dep[0x84 - 0x40]
10460 +#define sprom_control dev_dep[0x88 - 0x40]
10462 +#ifndef _LANGUAGE_ASSEMBLY
10464 +extern int sbpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
10465 +extern int sbpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len);
10466 +extern void sbpci_ban(uint16 core);
10467 +extern int sbpci_init(sb_t *sbh);
10468 +extern void sbpci_check(sb_t *sbh);
10470 +#endif /* !_LANGUAGE_ASSEMBLY */
10472 +#endif /* _SBPCI_H */
10473 diff -urN linux.old/arch/mips/bcm947xx/include/sbsdram.h linux.dev/arch/mips/bcm947xx/include/sbsdram.h
10474 --- linux.old/arch/mips/bcm947xx/include/sbsdram.h 1970-01-01 01:00:00.000000000 +0100
10475 +++ linux.dev/arch/mips/bcm947xx/include/sbsdram.h 2005-12-15 15:35:40.175792500 +0100
10478 + * BCM47XX Sonics SiliconBackplane SDRAM controller core hardware definitions.
10480 + * Copyright 2005, Broadcom Corporation
10481 + * All Rights Reserved.
10483 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10484 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10485 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10486 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10490 +#ifndef _SBSDRAM_H
10491 +#define _SBSDRAM_H
10493 +#ifndef _LANGUAGE_ASSEMBLY
10495 +/* Sonics side: SDRAM core registers */
10496 +typedef volatile struct sbsdramregs {
10497 + uint32 initcontrol; /* Generates external SDRAM initialization sequence */
10498 + uint32 config; /* Initializes external SDRAM mode register */
10499 + uint32 refresh; /* Controls external SDRAM refresh rate */
10506 +/* SDRAM initialization control (initcontrol) register bits */
10507 +#define SDRAM_CBR 0x0001 /* Writing 1 generates refresh cycle and toggles bit */
10508 +#define SDRAM_PRE 0x0002 /* Writing 1 generates precharge cycle and toggles bit */
10509 +#define SDRAM_MRS 0x0004 /* Writing 1 generates mode register select cycle and toggles bit */
10510 +#define SDRAM_EN 0x0008 /* When set, enables access to SDRAM */
10511 +#define SDRAM_16Mb 0x0000 /* Use 16 Megabit SDRAM */
10512 +#define SDRAM_64Mb 0x0010 /* Use 64 Megabit SDRAM */
10513 +#define SDRAM_128Mb 0x0020 /* Use 128 Megabit SDRAM */
10514 +#define SDRAM_RSVMb 0x0030 /* Use special SDRAM */
10515 +#define SDRAM_RST 0x0080 /* Writing 1 causes soft reset of controller */
10516 +#define SDRAM_SELFREF 0x0100 /* Writing 1 enables self refresh mode */
10517 +#define SDRAM_PWRDOWN 0x0200 /* Writing 1 causes controller to power down */
10518 +#define SDRAM_32BIT 0x0400 /* When set, indicates 32 bit SDRAM interface */
10519 +#define SDRAM_9BITCOL 0x0800 /* When set, indicates 9 bit column */
10521 +/* SDRAM configuration (config) register bits */
10522 +#define SDRAM_BURSTFULL 0x0000 /* Use full page bursts */
10523 +#define SDRAM_BURST8 0x0001 /* Use burst of 8 */
10524 +#define SDRAM_BURST4 0x0002 /* Use burst of 4 */
10525 +#define SDRAM_BURST2 0x0003 /* Use burst of 2 */
10526 +#define SDRAM_CAS3 0x0000 /* Use CAS latency of 3 */
10527 +#define SDRAM_CAS2 0x0004 /* Use CAS latency of 2 */
10529 +/* SDRAM refresh control (refresh) register bits */
10530 +#define SDRAM_REF(p) (((p)&0xff) | SDRAM_REF_EN) /* Refresh period */
10531 +#define SDRAM_REF_EN 0x8000 /* Writing 1 enables periodic refresh */
10533 +/* SDRAM Core default Init values (OCP ID 0x803) */
10534 +#define SDRAM_INIT MEM4MX16X2
10535 +#define SDRAM_CONFIG SDRAM_BURSTFULL
10536 +#define SDRAM_REFRESH SDRAM_REF(0x40)
10538 +#define MEM1MX16 0x009 /* 2 MB */
10539 +#define MEM1MX16X2 0x409 /* 4 MB */
10540 +#define MEM2MX8X2 0x809 /* 4 MB */
10541 +#define MEM2MX8X4 0xc09 /* 8 MB */
10542 +#define MEM2MX32 0x439 /* 8 MB */
10543 +#define MEM4MX16 0x019 /* 8 MB */
10544 +#define MEM4MX16X2 0x419 /* 16 MB */
10545 +#define MEM8MX8X2 0x819 /* 16 MB */
10546 +#define MEM8MX16 0x829 /* 16 MB */
10547 +#define MEM4MX32 0x429 /* 16 MB */
10548 +#define MEM8MX8X4 0xc19 /* 32 MB */
10549 +#define MEM8MX16X2 0xc29 /* 32 MB */
10551 +#endif /* _SBSDRAM_H */
10552 diff -urN linux.old/arch/mips/bcm947xx/include/sbutils.h linux.dev/arch/mips/bcm947xx/include/sbutils.h
10553 --- linux.old/arch/mips/bcm947xx/include/sbutils.h 1970-01-01 01:00:00.000000000 +0100
10554 +++ linux.dev/arch/mips/bcm947xx/include/sbutils.h 2005-12-15 16:00:47.404550500 +0100
10557 + * Misc utility routines for accessing chip-specific features
10558 + * of Broadcom HNBU SiliconBackplane-based chips.
10560 + * Copyright 2005, Broadcom Corporation
10561 + * All Rights Reserved.
10563 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10564 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10565 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10566 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10571 +#ifndef _sbutils_h_
10572 +#define _sbutils_h_
10575 + * Datastructure to export all chip specific common variables
10576 + * public (read-only) portion of sbutils handle returned by
10577 + * sb_attach()/sb_kattach()
10582 + uint bustype; /* SB_BUS, PCI_BUS */
10583 + uint buscoretype; /* SB_PCI, SB_PCMCIA, SB_PCIE*/
10584 + uint buscorerev; /* buscore rev */
10585 + uint buscoreidx; /* buscore index */
10586 + int ccrev; /* chip common core rev */
10587 + uint boardtype; /* board type */
10588 + uint boardvendor; /* board vendor */
10589 + uint chip; /* chip number */
10590 + uint chiprev; /* chip revision */
10591 + uint chippkg; /* chip package option */
10592 + uint sonicsrev; /* sonics backplane rev */
10595 +typedef const struct sb_pub sb_t;
10598 + * Many of the routines below take an 'sbh' handle as their first arg.
10599 + * Allocate this by calling sb_attach(). Free it by calling sb_detach().
10600 + * At any one time, the sbh is logically focused on one particular sb core
10601 + * (the "current core").
10602 + * Use sb_setcore() or sb_setcoreidx() to change the association to another core.
10605 +/* exported externs */
10606 +extern sb_t * BCMINIT(sb_attach)(uint pcidev, osl_t *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz);
10607 +extern sb_t * BCMINIT(sb_kattach)(void);
10608 +extern void sb_detach(sb_t *sbh);
10609 +extern uint BCMINIT(sb_chip)(sb_t *sbh);
10610 +extern uint BCMINIT(sb_chiprev)(sb_t *sbh);
10611 +extern uint BCMINIT(sb_chipcrev)(sb_t *sbh);
10612 +extern uint BCMINIT(sb_chippkg)(sb_t *sbh);
10613 +extern uint BCMINIT(sb_pcirev)(sb_t *sbh);
10614 +extern bool BCMINIT(sb_war16165)(sb_t *sbh);
10615 +extern uint BCMINIT(sb_boardvendor)(sb_t *sbh);
10616 +extern uint BCMINIT(sb_boardtype)(sb_t *sbh);
10617 +extern uint sb_bus(sb_t *sbh);
10618 +extern uint sb_buscoretype(sb_t *sbh);
10619 +extern uint sb_buscorerev(sb_t *sbh);
10620 +extern uint sb_corelist(sb_t *sbh, uint coreid[]);
10621 +extern uint sb_coreid(sb_t *sbh);
10622 +extern uint sb_coreidx(sb_t *sbh);
10623 +extern uint sb_coreunit(sb_t *sbh);
10624 +extern uint sb_corevendor(sb_t *sbh);
10625 +extern uint sb_corerev(sb_t *sbh);
10626 +extern void *sb_osh(sb_t *sbh);
10627 +extern void *sb_coreregs(sb_t *sbh);
10628 +extern uint32 sb_coreflags(sb_t *sbh, uint32 mask, uint32 val);
10629 +extern uint32 sb_coreflagshi(sb_t *sbh, uint32 mask, uint32 val);
10630 +extern bool sb_iscoreup(sb_t *sbh);
10631 +extern void *sb_setcoreidx(sb_t *sbh, uint coreidx);
10632 +extern void *sb_setcore(sb_t *sbh, uint coreid, uint coreunit);
10633 +extern int sb_corebist(sb_t *sbh, uint coreid, uint coreunit);
10634 +extern void sb_commit(sb_t *sbh);
10635 +extern uint32 sb_base(uint32 admatch);
10636 +extern uint32 sb_size(uint32 admatch);
10637 +extern void sb_core_reset(sb_t *sbh, uint32 bits);
10638 +extern void sb_core_tofixup(sb_t *sbh);
10639 +extern void sb_core_disable(sb_t *sbh, uint32 bits);
10640 +extern uint32 sb_clock_rate(uint32 pll_type, uint32 n, uint32 m);
10641 +extern uint32 sb_clock(sb_t *sbh);
10642 +extern void sb_pci_setup(sb_t *sbh, uint coremask);
10643 +extern void sb_watchdog(sb_t *sbh, uint ticks);
10644 +extern void *sb_gpiosetcore(sb_t *sbh);
10645 +extern uint32 sb_gpiocontrol(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10646 +extern uint32 sb_gpioouten(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10647 +extern uint32 sb_gpioout(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10648 +extern uint32 sb_gpioin(sb_t *sbh);
10649 +extern uint32 sb_gpiointpolarity(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10650 +extern uint32 sb_gpiointmask(sb_t *sbh, uint32 mask, uint32 val, uint8 priority);
10651 +extern uint32 sb_gpioled(sb_t *sbh, uint32 mask, uint32 val);
10652 +extern uint32 sb_gpioreserve(sb_t *sbh, uint32 gpio_num, uint8 priority);
10653 +extern uint32 sb_gpiorelease(sb_t *sbh, uint32 gpio_num, uint8 priority);
10655 +extern void sb_clkctl_init(sb_t *sbh);
10656 +extern uint16 sb_clkctl_fast_pwrup_delay(sb_t *sbh);
10657 +extern bool sb_clkctl_clk(sb_t *sbh, uint mode);
10658 +extern int sb_clkctl_xtal(sb_t *sbh, uint what, bool on);
10659 +extern void sb_register_intr_callback(sb_t *sbh, void *intrsoff_fn,
10660 + void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg);
10661 +extern uint32 sb_set_initiator_to(sb_t *sbh, uint32 to);
10662 +extern void sb_corepciid(sb_t *sbh, uint16 *pcivendor, uint16 *pcidevice,
10663 + uint8 *pciclass, uint8 *pcisubclass, uint8 *pciprogif);
10664 +extern uint32 sb_gpiotimerval(sb_t *sbh, uint32 mask, uint32 val);
10669 +* Build device path. Path size must be >= SB_DEVPATH_BUFSZ.
10670 +* The returned path is NULL terminated and has trailing '/'.
10671 +* Return 0 on success, nonzero otherwise.
10673 +extern int sb_devpath(sb_t *sbh, char *path, int size);
10675 +/* clkctl xtal what flags */
10676 +#define XTAL 0x1 /* primary crystal oscillator (2050) */
10677 +#define PLL 0x2 /* main chip pll */
10679 +/* clkctl clk mode */
10680 +#define CLK_FAST 0 /* force fast (pll) clock */
10681 +#define CLK_DYNAMIC 2 /* enable dynamic clock control */
10684 +/* GPIO usage priorities */
10685 +#define GPIO_DRV_PRIORITY 0
10686 +#define GPIO_APP_PRIORITY 1
10689 +#define SB_DEVPATH_BUFSZ 16 /* min buffer size in bytes */
10691 +#endif /* _sbutils_h_ */
10692 diff -urN linux.old/arch/mips/bcm947xx/include/sflash.h linux.dev/arch/mips/bcm947xx/include/sflash.h
10693 --- linux.old/arch/mips/bcm947xx/include/sflash.h 1970-01-01 01:00:00.000000000 +0100
10694 +++ linux.dev/arch/mips/bcm947xx/include/sflash.h 2005-12-15 16:49:23.001703000 +0100
10697 + * Broadcom SiliconBackplane chipcommon serial flash interface
10699 + * Copyright 2005, Broadcom Corporation
10700 + * All Rights Reserved.
10702 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10703 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10704 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10705 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10710 +#ifndef _sflash_h_
10711 +#define _sflash_h_
10713 +#include <typedefs.h>
10714 +#include <sbchipc.h>
10717 + uint blocksize; /* Block size */
10718 + uint numblocks; /* Number of blocks */
10719 + uint32 type; /* Type */
10720 + uint size; /* Total size in bytes */
10723 +/* Utility functions */
10724 +extern int sflash_poll(chipcregs_t *cc, uint offset);
10725 +extern int sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf);
10726 +extern int sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
10727 +extern int sflash_erase(chipcregs_t *cc, uint offset);
10728 +extern int sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf);
10729 +extern struct sflash * sflash_init(chipcregs_t *cc);
10731 +#endif /* _sflash_h_ */
10732 diff -urN linux.old/arch/mips/bcm947xx/include/trxhdr.h linux.dev/arch/mips/bcm947xx/include/trxhdr.h
10733 --- linux.old/arch/mips/bcm947xx/include/trxhdr.h 1970-01-01 01:00:00.000000000 +0100
10734 +++ linux.dev/arch/mips/bcm947xx/include/trxhdr.h 2005-12-15 15:35:49.220357750 +0100
10737 + * TRX image file header format.
10739 + * Copyright 2005, Broadcom Corporation
10740 + * All Rights Reserved.
10742 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10743 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10744 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10745 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10750 +#include <typedefs.h>
10752 +#define TRX_MAGIC 0x30524448 /* "HDR0" */
10753 +#define TRX_VERSION 1
10754 +#define TRX_MAX_LEN 0x3A0000
10755 +#define TRX_NO_HEADER 1 /* Do not write TRX header */
10756 +#define TRX_GZ_FILES 0x2 /* Contains up to TRX_MAX_OFFSET individual gzip files */
10757 +#define TRX_MAX_OFFSET 3
10759 +struct trx_header {
10760 + uint32 magic; /* "HDR0" */
10761 + uint32 len; /* Length of file including header */
10762 + uint32 crc32; /* 32-bit CRC from flag_version to end of file */
10763 + uint32 flag_version; /* 0:15 flags, 16:31 version */
10764 + uint32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
10767 +/* Compatibility */
10768 +typedef struct trx_header TRXHDR, *PTRXHDR;
10769 diff -urN linux.old/arch/mips/bcm947xx/include/typedefs.h linux.dev/arch/mips/bcm947xx/include/typedefs.h
10770 --- linux.old/arch/mips/bcm947xx/include/typedefs.h 1970-01-01 01:00:00.000000000 +0100
10771 +++ linux.dev/arch/mips/bcm947xx/include/typedefs.h 2005-12-15 15:35:52.436558750 +0100
10774 + * Copyright 2005, Broadcom Corporation
10775 + * All Rights Reserved.
10777 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10778 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10779 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10780 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10784 +#ifndef _TYPEDEFS_H_
10785 +#define _TYPEDEFS_H_
10788 +/* Define 'SITE_TYPEDEFS' in the compile to include a site specific
10789 + * typedef file "site_typedefs.h".
10791 + * If 'SITE_TYPEDEFS' is not defined, then the "Inferred Typedefs"
10792 + * section of this file makes inferences about the compile environment
10793 + * based on defined symbols and possibly compiler pragmas.
10795 + * Following these two sections is the "Default Typedefs"
10796 + * section. This section is only prcessed if 'USE_TYPEDEF_DEFAULTS' is
10797 + * defined. This section has a default set of typedefs and a few
10798 + * proprocessor symbols (TRUE, FALSE, NULL, ...).
10801 +#ifdef SITE_TYPEDEFS
10803 +/*******************************************************************************
10804 + * Site Specific Typedefs
10805 + *******************************************************************************/
10807 +#include "site_typedefs.h"
10811 +/*******************************************************************************
10812 + * Inferred Typedefs
10813 + *******************************************************************************/
10815 +/* Infer the compile environment based on preprocessor symbols and pramas.
10816 + * Override type definitions as needed, and include configuration dependent
10817 + * header files to define types.
10820 +#ifdef __cplusplus
10822 +#define TYPEDEF_BOOL
10824 +#define FALSE false
10830 +#else /* ! __cplusplus */
10832 +#if defined(_WIN32)
10834 +#define TYPEDEF_BOOL
10835 +typedef unsigned char bool; /* consistent w/BOOL */
10837 +#endif /* _WIN32 */
10839 +#endif /* ! __cplusplus */
10841 +/* use the Windows ULONG_PTR type when compiling for 64 bit */
10842 +#if defined(_WIN64)
10843 +#include <basetsd.h>
10844 +#define TYPEDEF_UINTPTR
10845 +typedef ULONG_PTR uintptr;
10849 +typedef long unsigned int size_t;
10852 +#ifdef _MSC_VER /* Microsoft C */
10853 +#define TYPEDEF_INT64
10854 +#define TYPEDEF_UINT64
10855 +typedef signed __int64 int64;
10856 +typedef unsigned __int64 uint64;
10859 +#if defined(MACOSX) && defined(KERNEL)
10860 +#define TYPEDEF_BOOL
10864 +#if defined(linux)
10865 +#define TYPEDEF_UINT
10866 +#define TYPEDEF_USHORT
10867 +#define TYPEDEF_ULONG
10870 +#if !defined(linux) && !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
10871 +#define TYPEDEF_UINT
10872 +#define TYPEDEF_USHORT
10876 +/* Do not support the (u)int64 types with strict ansi for GNU C */
10877 +#if defined(__GNUC__) && defined(__STRICT_ANSI__)
10878 +#define TYPEDEF_INT64
10879 +#define TYPEDEF_UINT64
10882 +/* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
10883 + * for singned or unsigned */
10884 +#if defined(__ICL)
10886 +#define TYPEDEF_INT64
10888 +#if defined(__STDC__)
10889 +#define TYPEDEF_UINT64
10892 +#endif /* __ICL */
10895 +#if !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)
10897 +/* pick up ushort & uint from standard types.h */
10898 +#if defined(linux) && defined(__KERNEL__)
10900 +#include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
10904 +#include <sys/types.h>
10908 +#endif /* !_WIN32 && !PMON && !_CFE_ && !_HNDRTE_ && !_MINOSL_ */
10910 +#if defined(MACOSX) && defined(KERNEL)
10911 +#include <IOKit/IOTypes.h>
10915 +/* use the default typedefs in the next section of this file */
10916 +#define USE_TYPEDEF_DEFAULTS
10918 +#endif /* SITE_TYPEDEFS */
10921 +/*******************************************************************************
10922 + * Default Typedefs
10923 + *******************************************************************************/
10925 +#ifdef USE_TYPEDEF_DEFAULTS
10926 +#undef USE_TYPEDEF_DEFAULTS
10928 +#ifndef TYPEDEF_BOOL
10929 +typedef /*@abstract@*/ unsigned char bool;
10932 +/*----------------------- define uchar, ushort, uint, ulong ------------------*/
10934 +#ifndef TYPEDEF_UCHAR
10935 +typedef unsigned char uchar;
10938 +#ifndef TYPEDEF_USHORT
10939 +typedef unsigned short ushort;
10942 +#ifndef TYPEDEF_UINT
10943 +typedef unsigned int uint;
10946 +#ifndef TYPEDEF_ULONG
10947 +typedef unsigned long ulong;
10950 +/*----------------------- define [u]int8/16/32/64, uintptr --------------------*/
10952 +#ifndef TYPEDEF_UINT8
10953 +typedef unsigned char uint8;
10956 +#ifndef TYPEDEF_UINT16
10957 +typedef unsigned short uint16;
10960 +#ifndef TYPEDEF_UINT32
10961 +typedef unsigned int uint32;
10964 +#ifndef TYPEDEF_UINT64
10965 +typedef unsigned long long uint64;
10968 +#ifndef TYPEDEF_UINTPTR
10969 +typedef unsigned int uintptr;
10972 +#ifndef TYPEDEF_INT8
10973 +typedef signed char int8;
10976 +#ifndef TYPEDEF_INT16
10977 +typedef signed short int16;
10980 +#ifndef TYPEDEF_INT32
10981 +typedef signed int int32;
10984 +#ifndef TYPEDEF_INT64
10985 +typedef signed long long int64;
10988 +/*----------------------- define float32/64, float_t -----------------------*/
10990 +#ifndef TYPEDEF_FLOAT32
10991 +typedef float float32;
10994 +#ifndef TYPEDEF_FLOAT64
10995 +typedef double float64;
10999 + * abstracted floating point type allows for compile time selection of
11000 + * single or double precision arithmetic. Compiling with -DFLOAT32
11001 + * selects single precision; the default is double precision.
11004 +#ifndef TYPEDEF_FLOAT_T
11006 +#if defined(FLOAT32)
11007 +typedef float32 float_t;
11008 +#else /* default to double precision floating point */
11009 +typedef float64 float_t;
11012 +#endif /* TYPEDEF_FLOAT_T */
11014 +/*----------------------- define macro values -----------------------------*/
11038 +/* Reclaiming text and data :
11039 + The following macros specify special linker sections that can be reclaimed
11040 + after a system is considered 'up'.
11042 +#if defined(__GNUC__) && defined(BCMRECLAIM)
11043 +extern bool bcmreclaimed;
11044 +#define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini." #_data))) _data##_ini
11045 +#define BCMINITFN(_fn) __attribute__ ((__section__ (".textini." #_fn))) _fn##_ini
11046 +#define BCMINIT(_id) _id##_ini
11048 +#define BCMINITDATA(_data) _data
11049 +#define BCMINITFN(_fn) _fn
11050 +#define BCMINIT(_id) _id
11051 +#define bcmreclaimed 0
11054 +/*----------------------- define PTRSZ, INLINE ----------------------------*/
11057 +#define PTRSZ sizeof (char*)
11064 +#define INLINE __inline
11068 +#define INLINE __inline__
11074 +#endif /* _MSC_VER */
11076 +#endif /* INLINE */
11078 +#undef TYPEDEF_BOOL
11079 +#undef TYPEDEF_UCHAR
11080 +#undef TYPEDEF_USHORT
11081 +#undef TYPEDEF_UINT
11082 +#undef TYPEDEF_ULONG
11083 +#undef TYPEDEF_UINT8
11084 +#undef TYPEDEF_UINT16
11085 +#undef TYPEDEF_UINT32
11086 +#undef TYPEDEF_UINT64
11087 +#undef TYPEDEF_UINTPTR
11088 +#undef TYPEDEF_INT8
11089 +#undef TYPEDEF_INT16
11090 +#undef TYPEDEF_INT32
11091 +#undef TYPEDEF_INT64
11092 +#undef TYPEDEF_FLOAT32
11093 +#undef TYPEDEF_FLOAT64
11094 +#undef TYPEDEF_FLOAT_T
11096 +#endif /* USE_TYPEDEF_DEFAULTS */
11098 +#endif /* _TYPEDEFS_H_ */
11099 diff -urN linux.old/arch/mips/bcm947xx/int-handler.S linux.dev/arch/mips/bcm947xx/int-handler.S
11100 --- linux.old/arch/mips/bcm947xx/int-handler.S 1970-01-01 01:00:00.000000000 +0100
11101 +++ linux.dev/arch/mips/bcm947xx/int-handler.S 2005-12-15 12:57:27.877187750 +0100
11104 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
11106 + * This program is free software; you can redistribute it and/or modify it
11107 + * under the terms of the GNU General Public License as published by the
11108 + * Free Software Foundation; either version 2 of the License, or (at your
11109 + * option) any later version.
11111 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11112 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
11113 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
11114 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11115 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
11116 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
11117 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
11118 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11119 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
11120 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11122 + * You should have received a copy of the GNU General Public License along
11123 + * with this program; if not, write to the Free Software Foundation, Inc.,
11124 + * 675 Mass Ave, Cambridge, MA 02139, USA.
11127 +#include <asm/asm.h>
11128 +#include <asm/mipsregs.h>
11129 +#include <asm/regdef.h>
11130 +#include <asm/stackframe.h>
11137 + NESTED(bcm47xx_irq_handler, PT_SIZE, sp)
11144 + jal bcm47xx_irq_dispatch
11150 + END(bcm47xx_irq_handler)
11151 diff -urN linux.old/arch/mips/bcm947xx/irq.c linux.dev/arch/mips/bcm947xx/irq.c
11152 --- linux.old/arch/mips/bcm947xx/irq.c 1970-01-01 01:00:00.000000000 +0100
11153 +++ linux.dev/arch/mips/bcm947xx/irq.c 2005-12-15 12:57:27.877187750 +0100
11156 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
11158 + * This program is free software; you can redistribute it and/or modify it
11159 + * under the terms of the GNU General Public License as published by the
11160 + * Free Software Foundation; either version 2 of the License, or (at your
11161 + * option) any later version.
11163 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11164 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
11165 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
11166 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11167 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
11168 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
11169 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
11170 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11171 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
11172 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11174 + * You should have received a copy of the GNU General Public License along
11175 + * with this program; if not, write to the Free Software Foundation, Inc.,
11176 + * 675 Mass Ave, Cambridge, MA 02139, USA.
11179 +#include <linux/config.h>
11180 +#include <linux/errno.h>
11181 +#include <linux/init.h>
11182 +#include <linux/interrupt.h>
11183 +#include <linux/irq.h>
11184 +#include <linux/module.h>
11185 +#include <linux/smp.h>
11186 +#include <linux/types.h>
11188 +#include <asm/cpu.h>
11189 +#include <asm/io.h>
11190 +#include <asm/irq.h>
11191 +#include <asm/irq_cpu.h>
11193 +extern asmlinkage void bcm47xx_irq_handler(void);
11195 +void bcm47xx_irq_dispatch(struct pt_regs *regs)
11199 + cause = read_c0_cause() & read_c0_status() & CAUSEF_IP;
11201 + clear_c0_status(cause);
11203 + if (cause & CAUSEF_IP7)
11205 + if (cause & CAUSEF_IP2)
11207 + if (cause & CAUSEF_IP3)
11209 + if (cause & CAUSEF_IP4)
11211 + if (cause & CAUSEF_IP5)
11213 + if (cause & CAUSEF_IP6)
11217 +void __init arch_init_irq(void)
11219 + set_except_vector(0, bcm47xx_irq_handler);
11220 + mips_cpu_irq_init(0);
11222 diff -urN linux.old/arch/mips/bcm947xx/pci.c linux.dev/arch/mips/bcm947xx/pci.c
11223 --- linux.old/arch/mips/bcm947xx/pci.c 1970-01-01 01:00:00.000000000 +0100
11224 +++ linux.dev/arch/mips/bcm947xx/pci.c 2005-12-18 07:01:36.731635000 +0100
11226 +#include <linux/kernel.h>
11227 +#include <linux/init.h>
11228 +#include <linux/pci.h>
11229 +#include <linux/types.h>
11231 +#include <asm/cpu.h>
11232 +#include <asm/io.h>
11234 +#include <typedefs.h>
11236 +#include <sbutils.h>
11237 +#include <sbmips.h>
11238 +#include <sbconfig.h>
11239 +#include <sbpci.h>
11240 +#include <bcmdevs.h>
11241 +#include <pcicfg.h>
11244 +extern spinlock_t sbh_lock;
11248 +sb_pci_read_config(struct pci_bus *bus, unsigned int devfn,
11249 + int reg, int size, u32 *val)
11252 + unsigned long flags;
11254 + spin_lock_irqsave(&sbh_lock, flags);
11255 + ret = sbpci_read_config(sbh, bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn), reg, val, size);
11256 + spin_unlock_irqrestore(&sbh_lock, flags);
11258 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11262 +sb_pci_write_config(struct pci_bus *bus, unsigned int devfn,
11263 + int reg, int size, u32 val)
11266 + unsigned long flags;
11268 + spin_lock_irqsave(&sbh_lock, flags);
11269 + ret = sbpci_write_config(sbh, bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn), reg, &val, size);
11270 + spin_unlock_irqrestore(&sbh_lock, flags);
11272 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
11276 +static struct pci_ops sb_pci_ops = {
11277 + .read = sb_pci_read_config,
11278 + .write = sb_pci_write_config,
11281 +static struct resource sb_pci_mem_resource = {
11282 + .name = "SB PCI Memory resources",
11283 + .start = SB_ENUM_BASE,
11284 + .end = SB_ENUM_LIM - 1,
11285 + .flags = IORESOURCE_MEM,
11288 +static struct resource sb_pci_io_resource = {
11289 + .name = "SB PCI I/O resources",
11292 + .flags = IORESOURCE_IO,
11295 +static struct pci_controller bcm47xx_sb_pci_controller = {
11296 + .pci_ops = &sb_pci_ops,
11297 + .mem_resource = &sb_pci_mem_resource,
11298 + .io_resource = &sb_pci_io_resource,
11301 +static struct resource ext_pci_mem_resource = {
11302 + .name = "Ext PCI Memory resources",
11303 + .start = 0x40000000,
11304 + .end = 0x7fffffff,
11305 + .flags = IORESOURCE_MEM,
11308 +static struct resource ext_pci_io_resource = {
11309 + .name = "Ext PCI I/O resources",
11312 + .flags = IORESOURCE_IO,
11315 +static struct pci_controller bcm47xx_ext_pci_controller = {
11316 + .pci_ops = &sb_pci_ops,
11317 + .io_resource = &ext_pci_io_resource,
11318 + .mem_resource = &ext_pci_mem_resource,
11319 + .mem_offset = 0x24000000,
11322 +void bcm47xx_pci_init(void)
11324 + unsigned long flags;
11326 + spin_lock_irqsave(&sbh_lock, flags);
11328 + spin_unlock_irqrestore(&sbh_lock, flags);
11330 + set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000));
11332 + register_pci_controller(&bcm47xx_sb_pci_controller);
11333 + register_pci_controller(&bcm47xx_ext_pci_controller);
11336 +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
11340 + if (dev->bus->number == 1)
11343 + pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
11347 +u32 pci_iobase = 0x100;
11348 +u32 pci_membase = SB_PCI_DMA;
11350 +static void bcm47xx_fixup_device(struct pci_dev *d)
11352 + struct resource *res;
11356 + if (d->bus->number == 0)
11359 + printk("PCI: Fixing up device %s\n", pci_name(d));
11361 + /* Fix up resource bases */
11362 + for (pos = 0; pos < 6; pos++) {
11363 + res = &d->resource[pos];
11364 + base = ((res->flags & IORESOURCE_IO) ? &pci_iobase : &pci_membase);
11366 + size = res->end - res->start + 1;
11367 + if (*base & (size - 1))
11368 + *base = (*base + size) & ~(size - 1);
11369 + res->start = *base;
11370 + res->end = res->start + size - 1;
11372 + pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
11374 + /* Fix up PCI bridge BAR0 only */
11375 + if (d->bus->number == 1 && PCI_SLOT(d->devfn) == 0)
11378 + /* Fix up interrupt lines */
11379 + if (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))
11380 + d->irq = (pci_find_device(VENDOR_BROADCOM, SB_PCI, NULL))->irq;
11381 + pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
11385 +static void bcm47xx_fixup_bridge(struct pci_dev *dev)
11387 + if (dev->bus->number != 1 || PCI_SLOT(dev->devfn) != 0)
11390 + printk("PCI: fixing up bridge\n");
11392 + /* Enable PCI bridge bus mastering and memory space */
11393 + pci_set_master(dev);
11394 + pcibios_enable_device(dev, ~0);
11396 + /* Enable PCI bridge BAR1 prefetch and burst */
11397 + pci_write_config_dword(dev, PCI_BAR1_CONTROL, 3);
11400 +/* Do platform specific device initialization at pci_enable_device() time */
11401 +int pcibios_plat_dev_init(struct pci_dev *dev)
11404 + unsigned long flags;
11406 + bcm47xx_fixup_device(dev);
11408 + /* These cores come out of reset enabled */
11409 + if ((dev->bus->number != 0) ||
11410 + (dev->device == SB_MIPS) ||
11411 + (dev->device == SB_MIPS33) ||
11412 + (dev->device == SB_EXTIF) ||
11413 + (dev->device == SB_CC))
11416 + /* Do a core reset */
11417 + spin_lock_irqsave(&sbh_lock, flags);
11418 + coreidx = sb_coreidx(sbh);
11419 + if (sb_setcoreidx(sbh, PCI_SLOT(dev->devfn)) && (sb_coreid(sbh) == SB_USB)) {
11421 + * The USB core requires a special bit to be set during core
11422 + * reset to enable host (OHCI) mode. Resetting the SB core in
11423 + * pcibios_enable_device() is a hack for compatibility with
11424 + * vanilla usb-ohci so that it does not have to know about
11425 + * SB. A driver that wants to use the USB core in device mode
11426 + * should know about SB and should reset the bit back to 0
11427 + * after calling pcibios_enable_device().
11429 + sb_core_disable(sbh, sb_coreflags(sbh, 0, 0));
11430 + sb_core_reset(sbh, 1 << 29);
11432 + sb_core_reset(sbh, 0);
11434 + sb_setcoreidx(sbh, coreidx);
11435 + spin_unlock_irqrestore(&sbh_lock, flags);
11440 +DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, bcm47xx_fixup_bridge);
11441 diff -urN linux.old/arch/mips/bcm947xx/prom.c linux.dev/arch/mips/bcm947xx/prom.c
11442 --- linux.old/arch/mips/bcm947xx/prom.c 1970-01-01 01:00:00.000000000 +0100
11443 +++ linux.dev/arch/mips/bcm947xx/prom.c 2005-12-15 12:57:27.877187750 +0100
11446 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
11448 + * This program is free software; you can redistribute it and/or modify it
11449 + * under the terms of the GNU General Public License as published by the
11450 + * Free Software Foundation; either version 2 of the License, or (at your
11451 + * option) any later version.
11453 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11454 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
11455 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
11456 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11457 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
11458 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
11459 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
11460 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11461 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
11462 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11464 + * You should have received a copy of the GNU General Public License along
11465 + * with this program; if not, write to the Free Software Foundation, Inc.,
11466 + * 675 Mass Ave, Cambridge, MA 02139, USA.
11469 +#include <linux/init.h>
11470 +#include <linux/mm.h>
11471 +#include <linux/sched.h>
11472 +#include <linux/bootmem.h>
11474 +#include <asm/addrspace.h>
11475 +#include <asm/bootinfo.h>
11476 +#include <asm/pmon.h>
11478 +const char *get_system_type(void)
11480 + return "Broadcom BCM47xx";
11483 +void __init prom_init(void)
11485 + unsigned long mem;
11487 + mips_machgroup = MACH_GROUP_BRCM;
11488 + mips_machtype = MACH_BCM47XX;
11490 + /* Figure out memory size by finding aliases */
11491 + for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
11492 + if (*(unsigned long *)((unsigned long)(prom_init) + mem) ==
11493 + *(unsigned long *)(prom_init))
11497 + add_memory_region(0, mem, BOOT_MEM_RAM);
11500 +unsigned long __init prom_free_prom_memory(void)
11504 diff -urN linux.old/arch/mips/bcm947xx/setup.c linux.dev/arch/mips/bcm947xx/setup.c
11505 --- linux.old/arch/mips/bcm947xx/setup.c 1970-01-01 01:00:00.000000000 +0100
11506 +++ linux.dev/arch/mips/bcm947xx/setup.c 2005-12-18 06:34:52.106215250 +0100
11509 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
11510 + * Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
11511 + * Copyright (C) 2005 Felix Fietkau <nbd@openwrt.org>
11513 + * This program is free software; you can redistribute it and/or modify it
11514 + * under the terms of the GNU General Public License as published by the
11515 + * Free Software Foundation; either version 2 of the License, or (at your
11516 + * option) any later version.
11518 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11519 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
11520 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
11521 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11522 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
11523 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
11524 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
11525 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11526 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
11527 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11529 + * You should have received a copy of the GNU General Public License along
11530 + * with this program; if not, write to the Free Software Foundation, Inc.,
11531 + * 675 Mass Ave, Cambridge, MA 02139, USA.
11534 +#include <linux/init.h>
11535 +#include <linux/types.h>
11536 +#include <linux/tty.h>
11537 +#include <linux/serial.h>
11538 +#include <linux/serial_core.h>
11539 +#include <linux/serial_reg.h>
11540 +#include <asm/bootinfo.h>
11541 +#include <asm/time.h>
11542 +#include <asm/reboot.h>
11544 +#include <typedefs.h>
11546 +#include <sbutils.h>
11547 +#include <sbmips.h>
11548 +#include <sbpci.h>
11549 +#include <sbconfig.h>
11550 +#include <bcmdevs.h>
11551 +#include <bcmutils.h>
11552 +#include <bcmnvram.h>
11554 +extern void bcm47xx_pci_init(void);
11555 +extern void bcm47xx_time_init(void);
11556 +extern void bcm47xx_timer_setup(struct irqaction *irq);
11558 +spinlock_t sbh_lock = SPIN_LOCK_UNLOCKED;
11561 +static int ser_line = 0;
11570 +static serial_port ports[4];
11571 +static int num_ports = 0;
11574 +serial_add(void *regs, uint irq, uint baud_base, uint reg_shift)
11576 + ports[num_ports].regs = regs;
11577 + ports[num_ports].irq = irq;
11578 + ports[num_ports].baud_base = baud_base;
11579 + ports[num_ports].reg_shift = reg_shift;
11584 +do_serial_add(serial_port *port)
11590 + struct uart_port s;
11592 + regs = port->regs;
11594 + baud_base = port->baud_base;
11595 + reg_shift = port->reg_shift;
11597 + memset(&s, 0, sizeof(s));
11599 + s.line = ser_line++;
11600 + s.membase = regs;
11602 + s.uartclk = baud_base;
11603 + s.flags = ASYNC_BOOT_AUTOCONF;
11604 + s.iotype = SERIAL_IO_MEM;
11605 + s.regshift = reg_shift;
11607 + if (early_serial_setup(&s) != 0) {
11608 + printk(KERN_ERR "Serial setup failed!\n");
11612 +static void bcm47xx_machine_restart(char *command)
11614 + printk("Please stand by while rebooting the system...\n");
11616 + /* Set the watchdog timer to reset immediately */
11617 + local_irq_disable();
11618 + sb_watchdog(sbh, 1);
11622 +static void bcm47xx_machine_halt(void)
11624 + /* Disable interrupts and watchdog and spin forever */
11625 + local_irq_disable();
11626 + sb_watchdog(sbh, 0);
11630 +void __init plat_setup(void)
11635 + sbh = (void *) sb_kattach();
11636 + sb_mips_init(sbh);
11638 + bcm47xx_pci_init();
11640 + sb_serial_init(sbh, serial_add);
11641 + boardflags = getintvar(NULL, "boardflags");
11643 + /* reverse serial ports if the nvram variable kernel_args starts with console=ttyS1 */
11644 + s = nvram_get("kernel_args");
11646 + if (!strncmp(s, "console=ttyS1", 13)) {
11647 + for (i = num_ports; i; i--)
11648 + do_serial_add(&ports[i - 1]);
11650 + for (i = 0; i < num_ports; i++)
11651 + do_serial_add(&ports[i]);
11654 + _machine_restart = bcm47xx_machine_restart;
11655 + _machine_halt = bcm47xx_machine_halt;
11656 + _machine_power_off = bcm47xx_machine_halt;
11658 + board_time_init = bcm47xx_time_init;
11659 + board_timer_setup = bcm47xx_timer_setup;
11662 +EXPORT_SYMBOL(sbh);
11663 +EXPORT_SYMBOL(sbh_lock);
11664 +EXPORT_SYMBOL(boardflags);
11665 diff -urN linux.old/arch/mips/bcm947xx/time.c linux.dev/arch/mips/bcm947xx/time.c
11666 --- linux.old/arch/mips/bcm947xx/time.c 1970-01-01 01:00:00.000000000 +0100
11667 +++ linux.dev/arch/mips/bcm947xx/time.c 2005-12-15 12:57:27.877187750 +0100
11670 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
11672 + * This program is free software; you can redistribute it and/or modify it
11673 + * under the terms of the GNU General Public License as published by the
11674 + * Free Software Foundation; either version 2 of the License, or (at your
11675 + * option) any later version.
11677 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11678 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
11679 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
11680 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11681 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
11682 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
11683 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
11684 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11685 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
11686 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11688 + * You should have received a copy of the GNU General Public License along
11689 + * with this program; if not, write to the Free Software Foundation, Inc.,
11690 + * 675 Mass Ave, Cambridge, MA 02139, USA.
11693 +#include <linux/config.h>
11694 +#include <linux/init.h>
11695 +#include <linux/kernel.h>
11696 +#include <linux/sched.h>
11697 +#include <linux/serial_reg.h>
11698 +#include <linux/interrupt.h>
11699 +#include <asm/addrspace.h>
11700 +#include <asm/io.h>
11701 +#include <asm/time.h>
11704 +bcm47xx_time_init(void)
11709 + * Use deterministic values for initial counter interrupt
11710 + * so that calibrate delay avoids encountering a counter wrap.
11712 + write_c0_count(0);
11713 + write_c0_compare(0xffff);
11715 + hz = 200 * 1000 * 1000;
11717 + /* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
11718 + mips_hpt_frequency = hz / 2;
11723 +bcm47xx_timer_setup(struct irqaction *irq)
11725 + /* Enable the timer interrupt */
11726 + setup_irq(7, irq);
11728 diff -urN linux.old/arch/mips/kernel/cpu-probe.c linux.dev/arch/mips/kernel/cpu-probe.c
11729 --- linux.old/arch/mips/kernel/cpu-probe.c 2005-12-15 13:26:49.766024000 +0100
11730 +++ linux.dev/arch/mips/kernel/cpu-probe.c 2005-12-15 12:57:27.901177250 +0100
11731 @@ -656,6 +656,28 @@
11735 +static inline void cpu_probe_broadcom(struct cpuinfo_mips *c)
11737 + decode_config1(c);
11738 + switch (c->processor_id & 0xff00) {
11739 + case PRID_IMP_BCM3302:
11740 + c->cputype = CPU_BCM3302;
11741 + c->isa_level = MIPS_CPU_ISA_M32;
11742 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
11743 + MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER;
11745 + case PRID_IMP_BCM4710:
11746 + c->cputype = CPU_BCM4710;
11747 + c->isa_level = MIPS_CPU_ISA_M32;
11748 + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
11749 + MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER;
11752 + c->cputype = CPU_UNKNOWN;
11757 __init void cpu_probe(void)
11759 struct cpuinfo_mips *c = ¤t_cpu_data;
11760 @@ -678,6 +700,9 @@
11761 case PRID_COMP_SIBYTE:
11762 cpu_probe_sibyte(c);
11764 + case PRID_COMP_BROADCOM:
11765 + cpu_probe_broadcom(c);
11767 case PRID_COMP_SANDCRAFT:
11768 cpu_probe_sandcraft(c);
11770 diff -urN linux.old/arch/mips/kernel/head.S linux.dev/arch/mips/kernel/head.S
11771 --- linux.old/arch/mips/kernel/head.S 2005-12-15 13:26:49.766024000 +0100
11772 +++ linux.dev/arch/mips/kernel/head.S 2005-12-15 12:57:27.901177250 +0100
11773 @@ -107,6 +107,14 @@
11777 +#ifdef CONFIG_BCM4710
11779 +#define eret nop; nop; eret
11786 * Reserved space for exception handlers.
11787 * Necessary for machines which link their kernels at KSEG0.
11788 diff -urN linux.old/arch/mips/kernel/proc.c linux.dev/arch/mips/kernel/proc.c
11789 --- linux.old/arch/mips/kernel/proc.c 2005-12-15 13:26:49.766024000 +0100
11790 +++ linux.dev/arch/mips/kernel/proc.c 2005-12-15 12:57:27.921168500 +0100
11792 [CPU_VR4181] = "NEC VR4181",
11793 [CPU_VR4181A] = "NEC VR4181A",
11794 [CPU_SR71000] = "Sandcraft SR71000",
11795 + [CPU_BCM3302] = "Broadcom BCM3302",
11796 + [CPU_BCM4710] = "Broadcom BCM4710",
11797 [CPU_PR4450] = "Philips PR4450",
11800 diff -urN linux.old/arch/mips/mm/tlbex.c linux.dev/arch/mips/mm/tlbex.c
11801 --- linux.old/arch/mips/mm/tlbex.c 2005-12-15 13:26:49.794011750 +0100
11802 +++ linux.dev/arch/mips/mm/tlbex.c 2005-12-15 12:57:27.945158000 +0100
11803 @@ -858,6 +858,8 @@
11807 + case CPU_BCM3302:
11808 + case CPU_BCM4710:
11812 diff -urN linux.old/include/asm-mips/bootinfo.h linux.dev/include/asm-mips/bootinfo.h
11813 --- linux.old/include/asm-mips/bootinfo.h 2005-12-15 13:26:49.818001250 +0100
11814 +++ linux.dev/include/asm-mips/bootinfo.h 2005-12-15 12:57:27.969147500 +0100
11815 @@ -218,6 +218,12 @@
11816 #define MACH_GROUP_TITAN 22 /* PMC-Sierra Titan */
11817 #define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */
11820 + * Valid machtype for group Broadcom
11822 +#define MACH_GROUP_BRCM 23 /* Broadcom */
11823 +#define MACH_BCM47XX 1 /* Broadcom BCM47xx */
11825 #define CL_SIZE COMMAND_LINE_SIZE
11827 const char *get_system_type(void);
11828 diff -urN linux.old/include/asm-mips/cpu.h linux.dev/include/asm-mips/cpu.h
11829 --- linux.old/include/asm-mips/cpu.h 2005-12-15 13:26:49.818001250 +0100
11830 +++ linux.dev/include/asm-mips/cpu.h 2005-12-15 12:57:27.969147500 +0100
11831 @@ -102,6 +102,13 @@
11832 #define PRID_IMP_SR71000 0x0400
11835 + * These are the PRID's for when 23:16 == PRID_COMP_BROADCOM
11838 +#define PRID_IMP_BCM4710 0x4000
11839 +#define PRID_IMP_BCM3302 0x9000
11842 * Definitions for 7:0 on legacy processors
11845 @@ -196,7 +203,9 @@
11847 #define CPU_PR4450 61
11848 #define CPU_SB1A 62
11849 -#define CPU_LAST 62
11850 +#define CPU_BCM3302 63
11851 +#define CPU_BCM4710 64
11852 +#define CPU_LAST 64
11855 * ISA Level encodings
11856 diff -urN linux.old/include/linux/init.h linux.dev/include/linux/init.h
11857 --- linux.old/include/linux/init.h 2005-12-15 13:26:49.818001250 +0100
11858 +++ linux.dev/include/linux/init.h 2005-12-15 12:57:27.973145750 +0100
11860 static initcall_t __initcall_##fn __attribute_used__ \
11861 __attribute__((__section__(".initcall" level ".init"))) = fn
11863 +#define early_initcall(fn) __define_initcall(".early1",fn)
11865 #define core_initcall(fn) __define_initcall("1",fn)
11866 #define postcore_initcall(fn) __define_initcall("2",fn)
11867 #define arch_initcall(fn) __define_initcall("3",fn)
11868 diff -urN linux.old/include/linux/pci_ids.h linux.dev/include/linux/pci_ids.h
11869 --- linux.old/include/linux/pci_ids.h 2005-12-15 13:26:49.818001250 +0100
11870 +++ linux.dev/include/linux/pci_ids.h 2005-12-15 12:57:27.977144000 +0100
11871 @@ -1835,6 +1835,7 @@
11872 #define PCI_DEVICE_ID_TIGON3_5901_2 0x170e
11873 #define PCI_DEVICE_ID_BCM4401 0x4401
11874 #define PCI_DEVICE_ID_BCM4401B0 0x4402
11875 +#define PCI_DEVICE_ID_BCM4713 0x4713
11877 #define PCI_VENDOR_ID_TOPIC 0x151f
11878 #define PCI_DEVICE_ID_TOPIC_TP560 0x0000