Changeset 92b0ce4 in freewrt
- Timestamp:
- Jan 7, 2007, 1:20:39 PM (19 years ago)
- Children:
- cdd5a3e
- Parents:
- cacb054
- Location:
- target/linux
- Files:
-
- 6 added
- 1 edited
- 1 moved
-
brcm-2.4/patches/001-bcm47xx.patch (modified) (316 diffs)
-
brcm-2.4/patches/003-bcm47xx_cache_fixes.patch (added)
-
brcm-2.4/patches/009-wrt54g3g_pcmcia.patch (added)
-
brcm-2.4/patches/010-bcm47xx-cam_absent.patch (added)
-
brcm-2.4/patches/011-wl_qdisc_war.patch (added)
-
brcm-2.4/patches/README (added)
-
generic-2.4/patches/114-sched_use_tsc.patch (moved) (moved from target/linux/brcm-2.4/patches/007-sched_use_tsc.patch )
-
generic-2.4/patches/README (added)
Legend:
- Unmodified
- Added
- Removed
-
target/linux/brcm-2.4/patches/001-bcm47xx.patch
rcacb054 r92b0ce4 1 diff -Nur linux-2.4.32/arch/mips/bcm947xx/cfe_env.c linux-2.4.32-freewrt/arch/mips/bcm947xx/cfe_env.c 2 --- linux-2.4.32/arch/mips/bcm947xx/cfe_env.c 1970-01-01 01:00:00.000000000 +0100 3 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/cfe_env.c 2006-09-16 15:41:31.000000000 +0200 1 diff -urN linux.old/arch/mips/bcm947xx/bcmsrom.c linux.dev/arch/mips/bcm947xx/bcmsrom.c 2 --- linux.old/arch/mips/bcm947xx/bcmsrom.c 1970-01-01 01:00:00.000000000 +0100 3 +++ linux.dev/arch/mips/bcm947xx/bcmsrom.c 2006-10-02 21:19:59.000000000 +0200 4 @@ -0,0 +1,1213 @@ 5 +/* 6 + * Misc useful routines to access NIC SROM/OTP . 7 + * 8 + * Copyright 2006, Broadcom Corporation 9 + * All Rights Reserved. 10 + * 11 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 12 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 13 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 14 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 15 + * $Id: bcmsrom.c,v 1.1.1.14 2006/04/15 01:28:25 michael Exp $ 16 + */ 17 + 18 +#include <typedefs.h> 19 +#include <bcmdefs.h> 20 +#include <osl.h> 21 +#include <bcmutils.h> 22 +#include <bcmsrom.h> 23 +#include <bcmdevs.h> 24 +#include <bcmendian.h> 25 +#include <sbpcmcia.h> 26 +#include <pcicfg.h> 27 +#include <sbutils.h> 28 +#include <bcmnvram.h> 29 + 30 +/* debug/trace */ 31 +#if defined(WLTEST) 32 +#define BS_ERROR(args) printf args 33 +#else 34 +#define BS_ERROR(args) 35 +#endif /* BCMDBG_ERR || WLTEST */ 36 + 37 +#define VARS_MAX 4096 /* should be reduced */ 38 + 39 +#define WRITE_ENABLE_DELAY 500 /* 500 ms after write enable/disable toggle */ 40 +#define WRITE_WORD_DELAY 20 /* 20 ms between each word write */ 41 + 42 +static int initvars_srom_pci(void *sbh, void *curmap, char **vars, uint *count); 43 +static int initvars_cis_pcmcia(void *sbh, osl_t *osh, char **vars, uint *count); 44 +static int initvars_flash_sb(void *sbh, char **vars, uint *count); 45 +static int srom_parsecis(osl_t *osh, uint8 **pcis, uint ciscnt, char **vars, uint *count); 46 +static int sprom_cmd_pcmcia(osl_t *osh, uint8 cmd); 47 +static int sprom_read_pcmcia(osl_t *osh, uint16 addr, uint16 *data); 48 +static int sprom_write_pcmcia(osl_t *osh, uint16 addr, uint16 data); 49 +static int sprom_read_pci(osl_t *osh, uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, 50 + bool check_crc); 51 + 52 +static int initvars_table(osl_t *osh, char *start, char *end, char **vars, uint *count); 53 +static int initvars_flash(osl_t *osh, char **vp, uint len, char *devpath); 54 + 55 +/* 56 + * Initialize local vars from the right source for this platform. 57 + * Return 0 on success, nonzero on error. 58 + */ 59 +int 60 +srom_var_init(void *sbh, uint bustype, void *curmap, osl_t *osh, char **vars, uint *count) 61 +{ 62 + ASSERT(bustype == BUSTYPE(bustype)); 63 + if (vars == NULL || count == NULL) 64 + return (0); 65 + 66 + switch (BUSTYPE(bustype)) { 67 + case SB_BUS: 68 + case JTAG_BUS: 69 + return initvars_flash_sb(sbh, vars, count); 70 + 71 + case PCI_BUS: 72 + ASSERT(curmap); /* can not be NULL */ 73 + return initvars_srom_pci(sbh, curmap, vars, count); 74 + 75 + case PCMCIA_BUS: 76 + return initvars_cis_pcmcia(sbh, osh, vars, count); 77 + 78 + 79 + default: 80 + ASSERT(0); 81 + } 82 + return (-1); 83 +} 84 + 85 +/* support only 16-bit word read from srom */ 86 +int 87 +srom_read(uint bustype, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf) 88 +{ 89 + void *srom; 90 + uint i, off, nw; 91 + 92 + ASSERT(bustype == BUSTYPE(bustype)); 93 + 94 + /* check input - 16-bit access only */ 95 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2)) 96 + return 1; 97 + 98 + off = byteoff / 2; 99 + nw = nbytes / 2; 100 + 101 + if (BUSTYPE(bustype) == PCI_BUS) { 102 + if (!curmap) 103 + return 1; 104 + srom = (uchar*)curmap + PCI_BAR0_SPROM_OFFSET; 105 + if (sprom_read_pci(osh, srom, off, buf, nw, FALSE)) 106 + return 1; 107 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) { 108 + for (i = 0; i < nw; i++) { 109 + if (sprom_read_pcmcia(osh, (uint16)(off + i), (uint16*)(buf + i))) 110 + return 1; 111 + } 112 + } else { 113 + return 1; 114 + } 115 + 116 + return 0; 117 +} 118 + 119 +/* support only 16-bit word write into srom */ 120 +int 121 +srom_write(uint bustype, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf) 122 +{ 123 + uint16 *srom; 124 + uint i, nw, crc_range; 125 + uint16 image[SPROM_SIZE]; 126 + uint8 crc; 127 + volatile uint32 val32; 128 + 129 + ASSERT(bustype == BUSTYPE(bustype)); 130 + 131 + /* check input - 16-bit access only */ 132 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2)) 133 + return 1; 134 + 135 + /* Are we writing the whole thing at once? */ 136 + if ((byteoff == 0) && 137 + ((nbytes == SPROM_SIZE) || 138 + (nbytes == (SPROM_CRC_RANGE * 2)) || 139 + (nbytes == (SROM4_WORDS * 2)))) { 140 + crc_range = nbytes; 141 + bcopy((void*)buf, (void*)image, nbytes); 142 + nw = nbytes / 2; 143 + } else { 144 + if ((BUSTYPE(bustype) == PCMCIA_BUS) || (BUSTYPE(bustype) == SDIO_BUS)) 145 + crc_range = SPROM_SIZE; 146 + else 147 + crc_range = SPROM_CRC_RANGE * 2; /* Tentative */ 148 + 149 + nw = crc_range / 2; 150 + /* read first 64 words from srom */ 151 + if (srom_read(bustype, curmap, osh, 0, crc_range, image)) 152 + return 1; 153 + if (image[SROM4_SIGN] == SROM4_SIGNATURE) { 154 + crc_range = SROM4_WORDS; 155 + nw = crc_range / 2; 156 + if (srom_read(bustype, curmap, osh, 0, crc_range, image)) 157 + return 1; 158 + } 159 + /* make changes */ 160 + bcopy((void*)buf, (void*)&image[byteoff / 2], nbytes); 161 + } 162 + 163 + /* calculate crc */ 164 + htol16_buf(image, crc_range); 165 + crc = ~hndcrc8((uint8 *)image, crc_range - 1, CRC8_INIT_VALUE); 166 + ltoh16_buf(image, crc_range); 167 + image[(crc_range / 2) - 1] = (crc << 8) | (image[(crc_range / 2) - 1] & 0xff); 168 + 169 + if (BUSTYPE(bustype) == PCI_BUS) { 170 + srom = (uint16*)((uchar*)curmap + PCI_BAR0_SPROM_OFFSET); 171 + /* enable writes to the SPROM */ 172 + val32 = OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32)); 173 + val32 |= SPROM_WRITEEN; 174 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32); 175 + bcm_mdelay(WRITE_ENABLE_DELAY); 176 + /* write srom */ 177 + for (i = 0; i < nw; i++) { 178 + W_REG(osh, &srom[i], image[i]); 179 + bcm_mdelay(WRITE_WORD_DELAY); 180 + } 181 + /* disable writes to the SPROM */ 182 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32 & 183 + ~SPROM_WRITEEN); 184 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) { 185 + /* enable writes to the SPROM */ 186 + if (sprom_cmd_pcmcia(osh, SROM_WEN)) 187 + return 1; 188 + bcm_mdelay(WRITE_ENABLE_DELAY); 189 + /* write srom */ 190 + for (i = 0; i < nw; i++) { 191 + sprom_write_pcmcia(osh, (uint16)(i), image[i]); 192 + bcm_mdelay(WRITE_WORD_DELAY); 193 + } 194 + /* disable writes to the SPROM */ 195 + if (sprom_cmd_pcmcia(osh, SROM_WDS)) 196 + return 1; 197 + } else { 198 + return 1; 199 + } 200 + 201 + bcm_mdelay(WRITE_ENABLE_DELAY); 202 + return 0; 203 +} 204 + 205 + 206 +static int 207 +srom_parsecis(osl_t *osh, uint8 **pcis, uint ciscnt, char **vars, uint *count) 208 +{ 209 + char eabuf[32]; 210 + char *vp, *base; 211 + uint8 *cis, tup, tlen, sromrev = 1; 212 + int i, j; 213 + uint varsize; 214 + bool ag_init = FALSE; 215 + uint32 w32; 216 + 217 + ASSERT(vars); 218 + ASSERT(count); 219 + 220 + base = vp = MALLOC(osh, VARS_MAX); 221 + ASSERT(vp); 222 + if (!vp) 223 + return -2; 224 + 225 + while (ciscnt--) { 226 + cis = *pcis++; 227 + i = 0; 228 + do { 229 + tup = cis[i++]; 230 + tlen = cis[i++]; 231 + if ((i + tlen) >= CIS_SIZE) 232 + break; 233 + 234 + switch (tup) { 235 + case CISTPL_MANFID: 236 + vp += sprintf(vp, "manfid=%d", (cis[i + 1] << 8) + cis[i]); 237 + vp++; 238 + vp += sprintf(vp, "prodid=%d", (cis[i + 3] << 8) + cis[i + 2]); 239 + vp++; 240 + break; 241 + 242 + case CISTPL_FUNCE: 243 + switch (cis[i]) { 244 + case LAN_NID: 245 + ASSERT(cis[i + 1] == 6); 246 + bcm_ether_ntoa((struct ether_addr *)&cis[i + 2], eabuf); 247 + vp += sprintf(vp, "il0macaddr=%s", eabuf); 248 + vp++; 249 + break; 250 + case 1: /* SDIO Extended Data */ 251 + vp += sprintf(vp, "sdmaxblk=%d", 252 + (cis[i + 13] << 8) | cis[i + 12]); 253 + vp++; 254 + break; 255 + } 256 + break; 257 + 258 + case CISTPL_CFTABLE: 259 + vp += sprintf(vp, "regwindowsz=%d", (cis[i + 7] << 8) | cis[i + 6]); 260 + vp++; 261 + break; 262 + 263 + case CISTPL_BRCM_HNBU: 264 + switch (cis[i]) { 265 + case HNBU_SROMREV: 266 + sromrev = cis[i + 1]; 267 + break; 268 + 269 + case HNBU_CHIPID: 270 + vp += sprintf(vp, "vendid=%d", (cis[i + 2] << 8) + 271 + cis[i + 1]); 272 + vp++; 273 + vp += sprintf(vp, "devid=%d", (cis[i + 4] << 8) + 274 + cis[i + 3]); 275 + vp++; 276 + if (tlen == 7) { 277 + vp += sprintf(vp, "chiprev=%d", 278 + (cis[i + 6] << 8) + cis[i + 5]); 279 + vp++; 280 + } 281 + break; 282 + 283 + case HNBU_BOARDREV: 284 + vp += sprintf(vp, "boardrev=%d", cis[i + 1]); 285 + vp++; 286 + break; 287 + 288 + case HNBU_AA: 289 + vp += sprintf(vp, "aa2g=%d", cis[i + 1]); 290 + vp++; 291 + break; 292 + 293 + case HNBU_AG: 294 + vp += sprintf(vp, "ag0=%d", cis[i + 1]); 295 + vp++; 296 + ag_init = TRUE; 297 + break; 298 + 299 + case HNBU_CC: 300 + ASSERT(sromrev == 1); 301 + vp += sprintf(vp, "cc=%d", cis[i + 1]); 302 + vp++; 303 + break; 304 + 305 + case HNBU_PAPARMS: 306 + if (tlen == 2) { 307 + ASSERT(sromrev == 1); 308 + vp += sprintf(vp, "pa0maxpwr=%d", cis[i + 1]); 309 + vp++; 310 + } else if (tlen >= 9) { 311 + if (tlen == 10) { 312 + ASSERT(sromrev == 2); 313 + vp += sprintf(vp, "opo=%d", cis[i + 9]); 314 + vp++; 315 + } else 316 + ASSERT(tlen == 9); 317 + 318 + for (j = 0; j < 3; j++) { 319 + vp += sprintf(vp, "pa0b%d=%d", j, 320 + (cis[i + (j * 2) + 2] << 8) + 321 + cis[i + (j * 2) + 1]); 322 + vp++; 323 + } 324 + vp += sprintf(vp, "pa0itssit=%d", cis[i + 7]); 325 + vp++; 326 + vp += sprintf(vp, "pa0maxpwr=%d", cis[i + 8]); 327 + vp++; 328 + } else 329 + ASSERT(tlen >= 9); 330 + break; 331 + 332 + case HNBU_OEM: 333 + ASSERT(sromrev == 1); 334 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x", 335 + cis[i + 1], cis[i + 2], 336 + cis[i + 3], cis[i + 4], 337 + cis[i + 5], cis[i + 6], 338 + cis[i + 7], cis[i + 8]); 339 + vp++; 340 + break; 341 + 342 + case HNBU_BOARDFLAGS: 343 + w32 = (cis[i + 2] << 8) + cis[i + 1]; 344 + if (tlen == 5) 345 + w32 |= (cis[i + 4] << 24) + (cis[i + 3] << 16); 346 + vp += sprintf(vp, "boardflags=0x%x", w32); 347 + vp++; 348 + break; 349 + 350 + case HNBU_LEDS: 351 + if (cis[i + 1] != 0xff) { 352 + vp += sprintf(vp, "ledbh0=%d", cis[i + 1]); 353 + vp++; 354 + } 355 + if (cis[i + 2] != 0xff) { 356 + vp += sprintf(vp, "ledbh1=%d", cis[i + 2]); 357 + vp++; 358 + } 359 + if (cis[i + 3] != 0xff) { 360 + vp += sprintf(vp, "ledbh2=%d", cis[i + 3]); 361 + vp++; 362 + } 363 + if (cis[i + 4] != 0xff) { 364 + vp += sprintf(vp, "ledbh3=%d", cis[i + 4]); 365 + vp++; 366 + } 367 + break; 368 + 369 + case HNBU_CCODE: 370 + { 371 + char str[3]; 372 + ASSERT(sromrev > 1); 373 + str[0] = cis[i + 1]; 374 + str[1] = cis[i + 2]; 375 + str[2] = 0; 376 + vp += sprintf(vp, "ccode=%s", str); 377 + vp++; 378 + vp += sprintf(vp, "cctl=0x%x", cis[i + 3]); 379 + vp++; 380 + break; 381 + } 382 + 383 + case HNBU_CCKPO: 384 + ASSERT(sromrev > 2); 385 + vp += sprintf(vp, "cckpo=0x%x", 386 + (cis[i + 2] << 8) | cis[i + 1]); 387 + vp++; 388 + break; 389 + 390 + case HNBU_OFDMPO: 391 + ASSERT(sromrev > 2); 392 + vp += sprintf(vp, "ofdmpo=0x%x", 393 + (cis[i + 4] << 24) | 394 + (cis[i + 3] << 16) | 395 + (cis[i + 2] << 8) | 396 + cis[i + 1]); 397 + vp++; 398 + break; 399 + } 400 + break; 401 + 402 + } 403 + i += tlen; 404 + } while (tup != 0xff); 405 + } 406 + 407 + /* Set the srom version */ 408 + vp += sprintf(vp, "sromrev=%d", sromrev); 409 + vp++; 410 + 411 + /* if there is no antenna gain field, set default */ 412 + if (ag_init == FALSE) { 413 + ASSERT(sromrev == 1); 414 + vp += sprintf(vp, "ag0=%d", 0xff); 415 + vp++; 416 + } 417 + 418 + /* final nullbyte terminator */ 419 + *vp++ = '\0'; 420 + varsize = (uint)(vp - base); 421 + 422 + ASSERT((vp - base) < VARS_MAX); 423 + 424 + if (varsize == VARS_MAX) { 425 + *vars = base; 426 + } else { 427 + vp = MALLOC(osh, varsize); 428 + ASSERT(vp); 429 + if (vp) 430 + bcopy(base, vp, varsize); 431 + MFREE(osh, base, VARS_MAX); 432 + *vars = vp; 433 + if (!vp) { 434 + *count = 0; 435 + return -2; 436 + } 437 + } 438 + *count = varsize; 439 + 440 + return (0); 441 +} 442 + 443 + 444 +/* set PCMCIA sprom command register */ 445 +static int 446 +sprom_cmd_pcmcia(osl_t *osh, uint8 cmd) 447 +{ 448 + uint8 status = 0; 449 + uint wait_cnt = 1000; 450 + 451 + /* write sprom command register */ 452 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_CS, &cmd, 1); 453 + 454 + /* wait status */ 455 + while (wait_cnt--) { 456 + OSL_PCMCIA_READ_ATTR(osh, SROM_CS, &status, 1); 457 + if (status & SROM_DONE) 458 + return 0; 459 + } 460 + 461 + return 1; 462 +} 463 + 464 +/* read a word from the PCMCIA srom */ 465 +static int 466 +sprom_read_pcmcia(osl_t *osh, uint16 addr, uint16 *data) 467 +{ 468 + uint8 addr_l, addr_h, data_l, data_h; 469 + 470 + addr_l = (uint8)((addr * 2) & 0xff); 471 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff); 472 + 473 + /* set address */ 474 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1); 475 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1); 476 + 477 + /* do read */ 478 + if (sprom_cmd_pcmcia(osh, SROM_READ)) 479 + return 1; 480 + 481 + /* read data */ 482 + data_h = data_l = 0; 483 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAH, &data_h, 1); 484 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAL, &data_l, 1); 485 + 486 + *data = (data_h << 8) | data_l; 487 + return 0; 488 +} 489 + 490 +/* write a word to the PCMCIA srom */ 491 +static int 492 +sprom_write_pcmcia(osl_t *osh, uint16 addr, uint16 data) 493 +{ 494 + uint8 addr_l, addr_h, data_l, data_h; 495 + 496 + addr_l = (uint8)((addr * 2) & 0xff); 497 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff); 498 + data_l = (uint8)(data & 0xff); 499 + data_h = (uint8)((data >> 8) & 0xff); 500 + 501 + /* set address */ 502 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1); 503 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1); 504 + 505 + /* write data */ 506 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAH, &data_h, 1); 507 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAL, &data_l, 1); 508 + 509 + /* do write */ 510 + return sprom_cmd_pcmcia(osh, SROM_WRITE); 511 +} 512 + 513 +/* 514 + * Read in and validate sprom. 515 + * Return 0 on success, nonzero on error. 516 + */ 517 +static int 518 +sprom_read_pci(osl_t *osh, uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc) 519 +{ 520 + int err = 0; 521 + uint i; 522 + 523 + /* read the sprom */ 524 + for (i = 0; i < nwords; i++) 525 + buf[i] = R_REG(osh, &sprom[wordoff + i]); 526 + 527 + if (check_crc) { 528 + /* fixup the endianness so crc8 will pass */ 529 + htol16_buf(buf, nwords * 2); 530 + if (hndcrc8((uint8*)buf, nwords * 2, CRC8_INIT_VALUE) != CRC8_GOOD_VALUE) 531 + err = 1; 532 + /* now correct the endianness of the byte array */ 533 + ltoh16_buf(buf, nwords * 2); 534 + } 535 + 536 + return err; 537 +} 538 + 539 +/* 540 +* Create variable table from memory. 541 +* Return 0 on success, nonzero on error. 542 +*/ 543 +static int 544 +initvars_table(osl_t *osh, char *start, char *end, char **vars, uint *count) 545 +{ 546 + int c = (int)(end - start); 547 + 548 + /* do it only when there is more than just the null string */ 549 + if (c > 1) { 550 + char *vp = MALLOC(osh, c); 551 + ASSERT(vp); 552 + if (!vp) 553 + return BCME_NOMEM; 554 + bcopy(start, vp, c); 555 + *vars = vp; 556 + *count = c; 557 + } 558 + else { 559 + *vars = NULL; 560 + *count = 0; 561 + } 562 + 563 + return 0; 564 +} 565 + 566 +/* 567 + * Find variables with <devpath> from flash. 'base' points to the beginning 568 + * of the table upon enter and to the end of the table upon exit when success. 569 + * Return 0 on success, nonzero on error. 570 + */ 571 +static int 572 +initvars_flash(osl_t *osh, char **base, uint len, char *devpath) 573 +{ 574 + char *vp = *base; 575 + char *flash; 576 + int err; 577 + char *s; 578 + uint l, dl, copy_len; 579 + 580 + /* allocate memory and read in flash */ 581 + if (!(flash = MALLOC(osh, NVRAM_SPACE))) 582 + return BCME_NOMEM; 583 + if ((err = nvram_getall(flash, NVRAM_SPACE))) 584 + goto exit; 585 + 586 + /* grab vars with the <devpath> prefix in name */ 587 + dl = strlen(devpath); 588 + for (s = flash; s && *s; s += l + 1) { 589 + l = strlen(s); 590 + 591 + /* skip non-matching variable */ 592 + if (strncmp(s, devpath, dl)) 593 + continue; 594 + 595 + /* is there enough room to copy? */ 596 + copy_len = l - dl + 1; 597 + if (len < copy_len) { 598 + err = BCME_BUFTOOSHORT; 599 + goto exit; 600 + } 601 + 602 + /* no prefix, just the name=value */ 603 + strcpy(vp, &s[dl]); 604 + vp += copy_len; 605 + len -= copy_len; 606 + } 607 + 608 + /* add null string as terminator */ 609 + if (len < 1) { 610 + err = BCME_BUFTOOSHORT; 611 + goto exit; 612 + } 613 + *vp++ = '\0'; 614 + 615 + *base = vp; 616 + 617 +exit: MFREE(osh, flash, NVRAM_SPACE); 618 + return err; 619 +} 620 + 621 +/* 622 + * Initialize nonvolatile variable table from flash. 623 + * Return 0 on success, nonzero on error. 624 + */ 625 +static int 626 +initvars_flash_sb(void *sbh, char **vars, uint *count) 627 +{ 628 + osl_t *osh = sb_osh(sbh); 629 + char devpath[SB_DEVPATH_BUFSZ]; 630 + char *vp, *base; 631 + int err; 632 + 633 + ASSERT(vars); 634 + ASSERT(count); 635 + 636 + if ((err = sb_devpath(sbh, devpath, sizeof(devpath)))) 637 + return err; 638 + 639 + base = vp = MALLOC(osh, VARS_MAX); 640 + ASSERT(vp); 641 + if (!vp) 642 + return BCME_NOMEM; 643 + 644 + if ((err = initvars_flash(osh, &vp, VARS_MAX, devpath))) 645 + goto err; 646 + 647 + err = initvars_table(osh, base, vp, vars, count); 648 + 649 +err: MFREE(osh, base, VARS_MAX); 650 + return err; 651 +} 652 + 653 +#ifdef WLTEST 654 +char mfgsromvars[256]; 655 +char *defaultsromvars = "il0macaddr=00:11:22:33:44:51\0" 656 + "et0macaddr=00:11:22:33:44:52\0" 657 + "et1macaddr=00:11:22:33:44:53\0" 658 + "boardtype=0xffff\0" 659 + "boardrev=0x10\0" 660 + "boardflags=8\0" 661 + "sromrev=2\0" 662 + "aa2g=3"; 663 +#define MFGSROM_DEFVARSLEN 147 /* default srom len */ 664 +#endif /* WL_TEST */ 665 + 666 +/* 667 + * Initialize nonvolatile variable table from sprom. 668 + * Return 0 on success, nonzero on error. 669 + */ 670 +static int 671 +initvars_srom_pci(void *sbh, void *curmap, char **vars, uint *count) 672 +{ 673 + uint16 w, *b; 674 + uint8 sromrev = 0; 675 + struct ether_addr ea; 676 + char eabuf[32]; 677 + uint32 w32; 678 + int woff, i; 679 + char *vp, *base; 680 + osl_t *osh = sb_osh(sbh); 681 + bool flash = FALSE; 682 + char name[SB_DEVPATH_BUFSZ+16], *value; 683 + char devpath[SB_DEVPATH_BUFSZ]; 684 + int err; 685 + 686 + /* 687 + * Apply CRC over SROM content regardless SROM is present or not, 688 + * and use variable <devpath>sromrev's existance in flash to decide 689 + * if we should return an error when CRC fails or read SROM variables 690 + * from flash. 691 + */ 692 + b = MALLOC(osh, SROM_MAX); 693 + ASSERT(b); 694 + if (!b) 695 + return -2; 696 + 697 + err = sprom_read_pci(osh, (void*)((int8*)curmap + PCI_BAR0_SPROM_OFFSET), 0, b, 698 + 64, TRUE); 699 + if (b[SROM4_SIGN] == SROM4_SIGNATURE) { 700 + /* sromrev >= 4, read more */ 701 + err = sprom_read_pci(osh, (void*)((int8*)curmap + PCI_BAR0_SPROM_OFFSET), 0, b, SROM4_WORDS, TRUE); 702 + sromrev = b[SROM4_WORDS - 1] & 0xff; 703 + } else if (err == 0) { 704 + /* srom is good and is rev < 4 */ 705 + /* top word of sprom contains version and crc8 */ 706 + sromrev = b[63] & 0xff; 707 + /* bcm4401 sroms misprogrammed */ 708 + if (sromrev == 0x10) 709 + sromrev = 1; 710 + } 711 + 712 + if (err) { 713 +#ifdef WLTEST 714 + BS_ERROR(("SROM Crc Error, so see if we could use a default\n")); 715 + w32 = OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32)); 716 + if (w32 & SPROM_OTPIN_USE) { 717 + BS_ERROR(("srom crc failed with OTP, use default vars....\n")); 718 + vp = base = mfgsromvars; 719 + if (sb_chip(sbh) == BCM4311_CHIP_ID) { 720 + BS_ERROR(("setting the devid to be 4311\n")); 721 + vp += sprintf(vp, "devid=0x4311"); 722 + vp++; 723 + } 724 + bcopy(defaultsromvars, vp, MFGSROM_DEFVARSLEN); 725 + vp += MFGSROM_DEFVARSLEN; 726 + goto varsdone; 727 + } else { 728 + BS_ERROR(("srom crc failed with SPROM....\n")); 729 +#endif /* WLTEST */ 730 + if ((err = sb_devpath(sbh, devpath, sizeof(devpath)))) 731 + return err; 732 + sprintf(name, "%ssromrev", devpath); 733 + if (!(value = getvar(NULL, name))) 734 + return (-1); 735 + sromrev = (uint8)bcm_strtoul(value, NULL, 0); 736 + flash = TRUE; 737 +#ifdef WLTEST 738 + } 739 +#endif /* WLTEST */ 740 + } 741 + 742 + /* srom version check */ 743 + if (sromrev > 4) 744 + return (-2); 745 + 746 + ASSERT(vars); 747 + ASSERT(count); 748 + 749 + base = vp = MALLOC(osh, VARS_MAX); 750 + ASSERT(vp); 751 + if (!vp) 752 + return -2; 753 + 754 + /* read variables from flash */ 755 + if (flash) { 756 + if ((err = initvars_flash(osh, &vp, VARS_MAX, devpath))) 757 + goto err; 758 + goto varsdone; 759 + } 760 + 761 + vp += sprintf(vp, "sromrev=%d", sromrev); 762 + vp++; 763 + 764 + if (sromrev >= 4) { 765 + uint path, pathbase; 766 + const uint pathbases[MAX_PATH] = {SROM4_PATH0, SROM4_PATH1, 767 + SROM4_PATH2, SROM4_PATH3}; 768 + 769 + vp += sprintf(vp, "boardrev=%d", b[SROM4_BREV]); 770 + vp++; 771 + 772 + vp += sprintf(vp, "boardflags=%d", (b[SROM4_BFL1] << 16) | b[SROM4_BFL0]); 773 + vp++; 774 + 775 + vp += sprintf(vp, "boardflags2=%d", (b[SROM4_BFL3] << 16) | b[SROM4_BFL2]); 776 + vp++; 777 + 778 + /* The macaddr */ 779 + ea.octet[0] = (b[SROM4_MACHI] >> 8) & 0xff; 780 + ea.octet[1] = b[SROM4_MACHI] & 0xff; 781 + ea.octet[2] = (b[SROM4_MACMID] >> 8) & 0xff; 782 + ea.octet[3] = b[SROM4_MACMID] & 0xff; 783 + ea.octet[4] = (b[SROM4_MACLO] >> 8) & 0xff; 784 + ea.octet[5] = b[SROM4_MACLO] & 0xff; 785 + bcm_ether_ntoa(&ea, eabuf); 786 + vp += sprintf(vp, "macaddr=%s", eabuf); 787 + vp++; 788 + 789 + w = b[SROM4_CCODE]; 790 + if (w == 0) 791 + vp += sprintf(vp, "ccode="); 792 + else 793 + vp += sprintf(vp, "ccode=%c%c", (w >> 8), (w & 0xff)); 794 + vp++; 795 + vp += sprintf(vp, "regrev=%d", b[SROM4_REGREV]); 796 + vp++; 797 + 798 + w = b[SROM4_LEDBH10]; 799 + if ((w != 0) && (w != 0xffff)) { 800 + /* ledbh0 */ 801 + vp += sprintf(vp, "ledbh0=%d", (w & 0xff)); 802 + vp++; 803 + 804 + /* ledbh1 */ 805 + vp += sprintf(vp, "ledbh1=%d", (w >> 8) & 0xff); 806 + vp++; 807 + } 808 + w = b[SROM4_LEDBH32]; 809 + if ((w != 0) && (w != 0xffff)) { 810 + /* ledbh2 */ 811 + vp += sprintf(vp, "ledbh2=%d", w & 0xff); 812 + vp++; 813 + 814 + /* ledbh3 */ 815 + vp += sprintf(vp, "ledbh3=%d", (w >> 8) & 0xff); 816 + vp++; 817 + } 818 + /* LED Powersave duty cycle (oncount >> 24) (offcount >> 8) */ 819 + if (w != 0xffff) { 820 + w = b[SROM4_LEDDC]; 821 + w32 = ((uint32)((unsigned char)(w >> 8) & 0xff) << 24) | /* oncount */ 822 + ((uint32)((unsigned char)(w & 0xff)) << 8); /* offcount */ 823 + vp += sprintf(vp, "leddc=%d", w32); 824 + vp++; 825 + } 826 + 827 + w = b[SROM4_AA]; 828 + vp += sprintf(vp, "aa2g=%d", w & SROM4_AA2G_MASK); 829 + vp++; 830 + vp += sprintf(vp, "aa5g=%d", w >> SROM4_AA5G_SHIFT); 831 + vp++; 832 + 833 + w = b[SROM4_AG10]; 834 + vp += sprintf(vp, "ag0=%d", w & 0xff); 835 + vp++; 836 + vp += sprintf(vp, "ag1=%d", (w >> 8) & 0xff); 837 + vp++; 838 + w = b[SROM4_AG32]; 839 + vp += sprintf(vp, "ag2=%d", w & 0xff); 840 + vp++; 841 + vp += sprintf(vp, "ag3=%d", (w >> 8) & 0xff); 842 + vp++; 843 + 844 + /* Fixed power indices when power control is disabled */ 845 + for (i = 0; i < 2; i++) { 846 + w = b[SROM4_TXPID2G + i]; 847 + vp += sprintf(vp, "txpid2ga%d=%d", 2 * i, w & 0xff); 848 + vp++; 849 + vp += sprintf(vp, "txpid2ga%d=%d", (2 * i) + 1, (w >> 8) & 0xff); 850 + vp++; 851 + w = b[SROM4_TXPID5G + i]; 852 + vp += sprintf(vp, "txpid5ga%d=%d", 2 * i, w & 0xff); 853 + vp++; 854 + vp += sprintf(vp, "txpid5ga%d=%d", (2 * i) + 1, (w >> 8) & 0xff); 855 + vp++; 856 + w = b[SROM4_TXPID5GL + i]; 857 + vp += sprintf(vp, "txpid5gla%d=%d", 2 * i, w & 0xff); 858 + vp++; 859 + vp += sprintf(vp, "txpid5gla%d=%d", (2 * i) + 1, (w >> 8) & 0xff); 860 + vp++; 861 + w = b[SROM4_TXPID5GH + i]; 862 + vp += sprintf(vp, "txpid5gha%d=%d", 2 * i, w & 0xff); 863 + vp++; 864 + vp += sprintf(vp, "txpid5gha%d=%d", (2 * i) + 1, (w >> 8) & 0xff); 865 + vp++; 866 + } 867 + 868 + /* Per path variables */ 869 + for (path = 0; path < MAX_PATH; path++) { 870 + pathbase = pathbases[path]; 871 + w = b[pathbase + SROM4_2G_ITT_MAXP]; 872 + vp += sprintf(vp, "itt2ga%d=%d", path, w >> B2G_ITT_SHIFT); 873 + vp++; 874 + vp += sprintf(vp, "maxp2ga%d=%d", path, w & B2G_MAXP_MASK); 875 + vp++; 876 + 877 + for (i = 0; i < 4; i++) { 878 + vp += sprintf(vp, "pa2gw%da%d=%d", i, path, 879 + b[pathbase + SROM4_2G_PA + i]); 880 + vp++; 881 + } 882 + 883 + w = b[pathbase + SROM4_5G_ITT_MAXP]; 884 + vp += sprintf(vp, "itt5ga%d=%d", path, w >> B5G_ITT_SHIFT); 885 + vp++; 886 + vp += sprintf(vp, "maxp5ga%d=%d", path, w & B5G_MAXP_MASK); 887 + vp++; 888 + 889 + w = b[pathbase + SROM4_5GLH_MAXP]; 890 + vp += sprintf(vp, "maxp5lga%d=%d", path, w >> B5GL_MAXP_SHIFT); 891 + vp++; 892 + vp += sprintf(vp, "maxp5gha%d=%d", path, w & B5GH_MAXP_MASK); 893 + vp++; 894 + 895 + for (i = 0; i < 4; i++) { 896 + vp += sprintf(vp, "pa5gw%da%d=%d", i, path, 897 + b[pathbase + SROM4_5G_PA + i]); 898 + vp++; 899 + vp += sprintf(vp, "pa5glw%da%d=%d", i, path, 900 + b[pathbase + SROM4_5GL_PA + i]); 901 + vp++; 902 + vp += sprintf(vp, "pa5hgw%da%d=%d", i, path, 903 + b[pathbase + SROM4_5GH_PA + i]); 904 + vp++; 905 + } 906 + } 907 + 908 + vp += sprintf(vp, "cck2gpo=%d", b[SROM4_2G_CCKPO]); 909 + vp++; 910 + 911 + w32 = ((uint32)b[SROM4_2G_OFDMPO + 1] << 16) | b[SROM4_2G_OFDMPO]; 912 + vp += sprintf(vp, "ofdm2gpo=%d", w32); 913 + vp++; 914 + 915 + w32 = ((uint32)b[SROM4_5G_OFDMPO + 1] << 16) | b[SROM4_5G_OFDMPO]; 916 + vp += sprintf(vp, "ofdm5gpo=%d", w32); 917 + vp++; 918 + 919 + w32 = ((uint32)b[SROM4_5GL_OFDMPO + 1] << 16) | b[SROM4_5GL_OFDMPO]; 920 + vp += sprintf(vp, "ofdm5glpo=%d", w32); 921 + vp++; 922 + 923 + w32 = ((uint32)b[SROM4_5GH_OFDMPO + 1] << 16) | b[SROM4_5GH_OFDMPO]; 924 + vp += sprintf(vp, "ofdm5ghpo=%d", w32); 925 + vp++; 926 + 927 + for (i = 0; i < 8; i++) { 928 + vp += sprintf(vp, "mcs2gpo%d=%d", i, b[SROM4_2G_MCSPO]); 929 + vp++; 930 + vp += sprintf(vp, "mcs5gpo%d=%d", i, b[SROM4_5G_MCSPO]); 931 + vp++; 932 + vp += sprintf(vp, "mcs5glpo%d=%d", i, b[SROM4_5GL_MCSPO]); 933 + vp++; 934 + vp += sprintf(vp, "mcs5ghpo%d=%d", i, b[SROM4_5GH_MCSPO]); 935 + vp++; 936 + } 937 + 938 + vp += sprintf(vp, "ccdpo%d=%d", i, b[SROM4_CCDPO]); 939 + vp++; 940 + vp += sprintf(vp, "stbcpo%d=%d", i, b[SROM4_STBCPO]); 941 + vp++; 942 + vp += sprintf(vp, "bw40po%d=%d", i, b[SROM4_BW40PO]); 943 + vp++; 944 + vp += sprintf(vp, "bwduppo%d=%d", i, b[SROM4_BWDUPPO]); 945 + vp++; 946 + 947 + goto done; 948 + } 949 + if (sromrev >= 3) { 950 + /* New section takes over the 3th hardware function space */ 951 + 952 + /* Words 22+23 are 11a (mid) ofdm power offsets */ 953 + w32 = ((uint32)b[23] << 16) | b[22]; 954 + vp += sprintf(vp, "ofdmapo=%d", w32); 955 + vp++; 956 + 957 + /* Words 24+25 are 11a (low) ofdm power offsets */ 958 + w32 = ((uint32)b[25] << 16) | b[24]; 959 + vp += sprintf(vp, "ofdmalpo=%d", w32); 960 + vp++; 961 + 962 + /* Words 26+27 are 11a (high) ofdm power offsets */ 963 + w32 = ((uint32)b[27] << 16) | b[26]; 964 + vp += sprintf(vp, "ofdmahpo=%d", w32); 965 + vp++; 966 + 967 + /* LED Powersave duty cycle (oncount >> 24) (offcount >> 8) */ 968 + w32 = ((uint32)((unsigned char)(b[21] >> 8) & 0xff) << 24) | /* oncount */ 969 + ((uint32)((unsigned char)(b[21] & 0xff)) << 8); /* offcount */ 970 + vp += sprintf(vp, "leddc=%d", w32); 971 + 972 + vp++; 973 + } 974 + 975 + if (sromrev >= 2) { 976 + /* New section takes over the 4th hardware function space */ 977 + 978 + /* Word 29 is max power 11a high/low */ 979 + w = b[29]; 980 + vp += sprintf(vp, "pa1himaxpwr=%d", w & 0xff); 981 + vp++; 982 + vp += sprintf(vp, "pa1lomaxpwr=%d", (w >> 8) & 0xff); 983 + vp++; 984 + 985 + /* Words 30-32 set the 11alow pa settings, 986 + * 33-35 are the 11ahigh ones. 987 + */ 988 + for (i = 0; i < 3; i++) { 989 + vp += sprintf(vp, "pa1lob%d=%d", i, b[30 + i]); 990 + vp++; 991 + vp += sprintf(vp, "pa1hib%d=%d", i, b[33 + i]); 992 + vp++; 993 + } 994 + w = b[59]; 995 + if (w == 0) 996 + vp += sprintf(vp, "ccode="); 997 + else 998 + vp += sprintf(vp, "ccode=%c%c", (w >> 8), (w & 0xff)); 999 + vp++; 1000 + 1001 + } 1002 + 1003 + /* parameter section of sprom starts at byte offset 72 */ 1004 + woff = 72/2; 1005 + 1006 + /* first 6 bytes are il0macaddr */ 1007 + ea.octet[0] = (b[woff] >> 8) & 0xff; 1008 + ea.octet[1] = b[woff] & 0xff; 1009 + ea.octet[2] = (b[woff+1] >> 8) & 0xff; 1010 + ea.octet[3] = b[woff+1] & 0xff; 1011 + ea.octet[4] = (b[woff+2] >> 8) & 0xff; 1012 + ea.octet[5] = b[woff+2] & 0xff; 1013 + woff += 3; 1014 + bcm_ether_ntoa(&ea, eabuf); 1015 + vp += sprintf(vp, "il0macaddr=%s", eabuf); 1016 + vp++; 1017 + 1018 + /* next 6 bytes are et0macaddr */ 1019 + ea.octet[0] = (b[woff] >> 8) & 0xff; 1020 + ea.octet[1] = b[woff] & 0xff; 1021 + ea.octet[2] = (b[woff+1] >> 8) & 0xff; 1022 + ea.octet[3] = b[woff+1] & 0xff; 1023 + ea.octet[4] = (b[woff+2] >> 8) & 0xff; 1024 + ea.octet[5] = b[woff+2] & 0xff; 1025 + woff += 3; 1026 + bcm_ether_ntoa(&ea, eabuf); 1027 + vp += sprintf(vp, "et0macaddr=%s", eabuf); 1028 + vp++; 1029 + 1030 + /* next 6 bytes are et1macaddr */ 1031 + ea.octet[0] = (b[woff] >> 8) & 0xff; 1032 + ea.octet[1] = b[woff] & 0xff; 1033 + ea.octet[2] = (b[woff+1] >> 8) & 0xff; 1034 + ea.octet[3] = b[woff+1] & 0xff; 1035 + ea.octet[4] = (b[woff+2] >> 8) & 0xff; 1036 + ea.octet[5] = b[woff+2] & 0xff; 1037 + woff += 3; 1038 + bcm_ether_ntoa(&ea, eabuf); 1039 + vp += sprintf(vp, "et1macaddr=%s", eabuf); 1040 + vp++; 1041 + 1042 + /* 1043 + * Enet phy settings one or two singles or a dual 1044 + * Bits 4-0 : MII address for enet0 (0x1f for not there) 1045 + * Bits 9-5 : MII address for enet1 (0x1f for not there) 1046 + * Bit 14 : Mdio for enet0 1047 + * Bit 15 : Mdio for enet1 1048 + */ 1049 + w = b[woff]; 1050 + vp += sprintf(vp, "et0phyaddr=%d", (w & 0x1f)); 1051 + vp++; 1052 + vp += sprintf(vp, "et1phyaddr=%d", ((w >> 5) & 0x1f)); 1053 + vp++; 1054 + vp += sprintf(vp, "et0mdcport=%d", ((w >> 14) & 0x1)); 1055 + vp++; 1056 + vp += sprintf(vp, "et1mdcport=%d", ((w >> 15) & 0x1)); 1057 + vp++; 1058 + 1059 + /* Word 46 has board rev, antennas 0/1 & Country code/control */ 1060 + w = b[46]; 1061 + vp += sprintf(vp, "boardrev=%d", w & 0xff); 1062 + vp++; 1063 + 1064 + if (sromrev > 1) 1065 + vp += sprintf(vp, "cctl=%d", (w >> 8) & 0xf); 1066 + else 1067 + vp += sprintf(vp, "cc=%d", (w >> 8) & 0xf); 1068 + vp++; 1069 + 1070 + vp += sprintf(vp, "aa2g=%d", (w >> 12) & 0x3); 1071 + vp++; 1072 + 1073 + vp += sprintf(vp, "aa5g=%d", (w >> 14) & 0x3); 1074 + vp++; 1075 + 1076 + /* Words 47-49 set the (wl) pa settings */ 1077 + woff = 47; 1078 + 1079 + for (i = 0; i < 3; i++) { 1080 + vp += sprintf(vp, "pa0b%d=%d", i, b[woff+i]); 1081 + vp++; 1082 + vp += sprintf(vp, "pa1b%d=%d", i, b[woff+i+6]); 1083 + vp++; 1084 + } 1085 + 1086 + /* 1087 + * Words 50-51 set the customer-configured wl led behavior. 1088 + * 8 bits/gpio pin. High bit: activehi=0, activelo=1; 1089 + * LED behavior values defined in wlioctl.h . 1090 + */ 1091 + w = b[50]; 1092 + if ((w != 0) && (w != 0xffff)) { 1093 + /* ledbh0 */ 1094 + vp += sprintf(vp, "ledbh0=%d", (w & 0xff)); 1095 + vp++; 1096 + 1097 + /* ledbh1 */ 1098 + vp += sprintf(vp, "ledbh1=%d", (w >> 8) & 0xff); 1099 + vp++; 1100 + } 1101 + w = b[51]; 1102 + if ((w != 0) && (w != 0xffff)) { 1103 + /* ledbh2 */ 1104 + vp += sprintf(vp, "ledbh2=%d", w & 0xff); 1105 + vp++; 1106 + 1107 + /* ledbh */ 1108 + vp += sprintf(vp, "ledbh3=%d", (w >> 8) & 0xff); 1109 + vp++; 1110 + } 1111 + 1112 + /* Word 52 is max power 0/1 */ 1113 + w = b[52]; 1114 + vp += sprintf(vp, "pa0maxpwr=%d", w & 0xff); 1115 + vp++; 1116 + vp += sprintf(vp, "pa1maxpwr=%d", (w >> 8) & 0xff); 1117 + vp++; 1118 + 1119 + /* Word 56 is idle tssi target 0/1 */ 1120 + w = b[56]; 1121 + vp += sprintf(vp, "pa0itssit=%d", w & 0xff); 1122 + vp++; 1123 + vp += sprintf(vp, "pa1itssit=%d", (w >> 8) & 0xff); 1124 + vp++; 1125 + 1126 + /* Word 57 is boardflags, if not programmed make it zero */ 1127 + w32 = (uint32)b[57]; 1128 + if (w32 == 0xffff) w32 = 0; 1129 + if (sromrev > 1) { 1130 + /* Word 28 is the high bits of boardflags */ 1131 + w32 |= (uint32)b[28] << 16; 1132 + } 1133 + vp += sprintf(vp, "boardflags=%d", w32); 1134 + vp++; 1135 + 1136 + /* Word 58 is antenna gain 0/1 */ 1137 + w = b[58]; 1138 + vp += sprintf(vp, "ag0=%d", w & 0xff); 1139 + vp++; 1140 + 1141 + vp += sprintf(vp, "ag1=%d", (w >> 8) & 0xff); 1142 + vp++; 1143 + 1144 + if (sromrev == 1) { 1145 + /* set the oem string */ 1146 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x", 1147 + ((b[59] >> 8) & 0xff), (b[59] & 0xff), 1148 + ((b[60] >> 8) & 0xff), (b[60] & 0xff), 1149 + ((b[61] >> 8) & 0xff), (b[61] & 0xff), 1150 + ((b[62] >> 8) & 0xff), (b[62] & 0xff)); 1151 + vp++; 1152 + } else if (sromrev == 2) { 1153 + /* Word 60 OFDM tx power offset from CCK level */ 1154 + /* OFDM Power Offset - opo */ 1155 + vp += sprintf(vp, "opo=%d", b[60] & 0xff); 1156 + vp++; 1157 + } else { 1158 + /* Word 60: cck power offsets */ 1159 + vp += sprintf(vp, "cckpo=%d", b[60]); 1160 + vp++; 1161 + 1162 + /* Words 61+62: 11g ofdm power offsets */ 1163 + w32 = ((uint32)b[62] << 16) | b[61]; 1164 + vp += sprintf(vp, "ofdmgpo=%d", w32); 1165 + vp++; 1166 + } 1167 + 1168 + /* final nullbyte terminator */ 1169 +done: *vp++ = '\0'; 1170 + 1171 + ASSERT((vp - base) <= VARS_MAX); 1172 + 1173 +varsdone: 1174 + err = initvars_table(osh, base, vp, vars, count); 1175 + 1176 +err: 1177 +#ifdef WLTEST 1178 + if (base != mfgsromvars) 1179 +#endif 1180 + MFREE(osh, base, VARS_MAX); 1181 + MFREE(osh, b, SROM_MAX); 1182 + return err; 1183 +} 1184 + 1185 +/* 1186 + * Read the cis and call parsecis to initialize the vars. 1187 + * Return 0 on success, nonzero on error. 1188 + */ 1189 +static int 1190 +initvars_cis_pcmcia(void *sbh, osl_t *osh, char **vars, uint *count) 1191 +{ 1192 + uint8 *cis = NULL; 1193 + int rc; 1194 + uint data_sz; 1195 + 1196 + data_sz = (sb_pcmciarev(sbh) == 1) ? (SPROM_SIZE * 2) : CIS_SIZE; 1197 + 1198 + if ((cis = MALLOC(osh, data_sz)) == NULL) 1199 + return (-2); 1200 + 1201 + if (sb_pcmciarev(sbh) == 1) { 1202 + if (srom_read(PCMCIA_BUS, (void *)NULL, osh, 0, data_sz, (uint16 *)cis)) { 1203 + MFREE(osh, cis, data_sz); 1204 + return (-1); 1205 + } 1206 + /* fix up endianess for 16-bit data vs 8-bit parsing */ 1207 + ltoh16_buf((uint16 *)cis, data_sz); 1208 + } else 1209 + OSL_PCMCIA_READ_ATTR(osh, 0, cis, data_sz); 1210 + 1211 + rc = srom_parsecis(osh, &cis, 1, vars, count); 1212 + 1213 + MFREE(osh, cis, data_sz); 1214 + 1215 + return (rc); 1216 +} 1217 + 1218 diff -urN linux.old/arch/mips/bcm947xx/bcmutils.c linux.dev/arch/mips/bcm947xx/bcmutils.c 1219 --- linux.old/arch/mips/bcm947xx/bcmutils.c 1970-01-01 01:00:00.000000000 +0100 1220 +++ linux.dev/arch/mips/bcm947xx/bcmutils.c 2006-10-02 21:19:59.000000000 +0200 1221 @@ -0,0 +1,247 @@ 1222 +/* 1223 + * Misc useful OS-independent routines. 1224 + * 1225 + * Copyright 2006, Broadcom Corporation 1226 + * All Rights Reserved. 1227 + * 1228 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 1229 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 1230 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 1231 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 1232 + * $Id: bcmutils.c,v 1.1.1.12 2006/02/27 03:43:16 honor Exp $ 1233 + */ 1234 + 1235 +#include <typedefs.h> 1236 +#include <bcmdefs.h> 1237 +#include <stdarg.h> 1238 +#include <bcmutils.h> 1239 +#include <osl.h> 1240 +#include <sbutils.h> 1241 +#include <bcmnvram.h> 1242 +#include <bcmendian.h> 1243 +#include <bcmdevs.h> 1244 + 1245 +unsigned char bcm_ctype[] = { 1246 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 0-7 */ 1247 + _BCM_C, _BCM_C|_BCM_S, _BCM_C|_BCM_S, _BCM_C|_BCM_S, _BCM_C|_BCM_S, _BCM_C|_BCM_S, _BCM_C, 1248 + _BCM_C, /* 8-15 */ 1249 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 16-23 */ 1250 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 24-31 */ 1251 + _BCM_S|_BCM_SP,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 32-39 */ 1252 + _BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 40-47 */ 1253 + _BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D, /* 48-55 */ 1254 + _BCM_D,_BCM_D,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 56-63 */ 1255 + _BCM_P, _BCM_U|_BCM_X, _BCM_U|_BCM_X, _BCM_U|_BCM_X, _BCM_U|_BCM_X, _BCM_U|_BCM_X, 1256 + _BCM_U|_BCM_X, _BCM_U, /* 64-71 */ 1257 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 72-79 */ 1258 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 80-87 */ 1259 + _BCM_U,_BCM_U,_BCM_U,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 88-95 */ 1260 + _BCM_P, _BCM_L|_BCM_X, _BCM_L|_BCM_X, _BCM_L|_BCM_X, _BCM_L|_BCM_X, _BCM_L|_BCM_X, 1261 + _BCM_L|_BCM_X, _BCM_L, /* 96-103 */ 1262 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 104-111 */ 1263 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 112-119 */ 1264 + _BCM_L,_BCM_L,_BCM_L,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_C, /* 120-127 */ 1265 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 128-143 */ 1266 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 144-159 */ 1267 + _BCM_S|_BCM_SP, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, 1268 + _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, /* 160-175 */ 1269 + _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, 1270 + _BCM_P, _BCM_P, _BCM_P, _BCM_P, _BCM_P, /* 176-191 */ 1271 + _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, 1272 + _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, /* 192-207 */ 1273 + _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_P, _BCM_U, _BCM_U, _BCM_U, 1274 + _BCM_U, _BCM_U, _BCM_U, _BCM_U, _BCM_L, /* 208-223 */ 1275 + _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, 1276 + _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, /* 224-239 */ 1277 + _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_P, _BCM_L, _BCM_L, _BCM_L, 1278 + _BCM_L, _BCM_L, _BCM_L, _BCM_L, _BCM_L /* 240-255 */ 1279 +}; 1280 + 1281 + 1282 +ulong 1283 +bcm_strtoul(char *cp, char **endp, uint base) 1284 +{ 1285 + ulong result, value; 1286 + bool minus; 1287 + 1288 + minus = FALSE; 1289 + 1290 + while (bcm_isspace(*cp)) 1291 + cp++; 1292 + 1293 + if (cp[0] == '+') 1294 + cp++; 1295 + else if (cp[0] == '-') { 1296 + minus = TRUE; 1297 + cp++; 1298 + } 1299 + 1300 + if (base == 0) { 1301 + if (cp[0] == '0') { 1302 + if ((cp[1] == 'x') || (cp[1] == 'X')) { 1303 + base = 16; 1304 + cp = &cp[2]; 1305 + } else { 1306 + base = 8; 1307 + cp = &cp[1]; 1308 + } 1309 + } else 1310 + base = 10; 1311 + } else if (base == 16 && (cp[0] == '0') && ((cp[1] == 'x') || (cp[1] == 'X'))) { 1312 + cp = &cp[2]; 1313 + } 1314 + 1315 + result = 0; 1316 + 1317 + while (bcm_isxdigit(*cp) && 1318 + (value = bcm_isdigit(*cp) ? *cp-'0' : bcm_toupper(*cp)-'A'+10) < base) { 1319 + result = result*base + value; 1320 + cp++; 1321 + } 1322 + 1323 + if (minus) 1324 + result = (ulong)(result * -1); 1325 + 1326 + if (endp) 1327 + *endp = (char *)cp; 1328 + 1329 + return (result); 1330 +} 1331 + 1332 +uchar 1333 +bcm_toupper(uchar c) 1334 +{ 1335 + if (bcm_islower(c)) 1336 + c -= 'a'-'A'; 1337 + return (c); 1338 +} 1339 + 1340 +char* 1341 +bcm_ether_ntoa(struct ether_addr *ea, char *buf) 1342 +{ 1343 + sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x", 1344 + ea->octet[0]&0xff, ea->octet[1]&0xff, ea->octet[2]&0xff, 1345 + ea->octet[3]&0xff, ea->octet[4]&0xff, ea->octet[5]&0xff); 1346 + return (buf); 1347 +} 1348 + 1349 + 1350 +/* 1351 + * Search the name=value vars for a specific one and return its value. 1352 + * Returns NULL if not found. 1353 + */ 1354 +char* 1355 +getvar(char *vars, char *name) 1356 +{ 1357 + char *s; 1358 + int len; 1359 + 1360 + len = strlen(name); 1361 + 1362 + /* first look in vars[] */ 1363 + for (s = vars; s && *s;) { 1364 + /* CSTYLED */ 1365 + if ((memcmp(s, name, len) == 0) && (s[len] == '=')) 1366 + return (&s[len+1]); 1367 + 1368 + while (*s++) 1369 + ; 1370 + } 1371 + 1372 + /* then query nvram */ 1373 + return (nvram_get(name)); 1374 +} 1375 + 1376 +/* 1377 + * Search the vars for a specific one and return its value as 1378 + * an integer. Returns 0 if not found. 1379 + */ 1380 +int 1381 +getintvar(char *vars, char *name) 1382 +{ 1383 + char *val; 1384 + 1385 + if ((val = getvar(vars, name)) == NULL) 1386 + return (0); 1387 + 1388 + return (bcm_strtoul(val, NULL, 0)); 1389 +} 1390 + 1391 + 1392 +/******************************************************************************* 1393 + * crc8 1394 + * 1395 + * Computes a crc8 over the input data using the polynomial: 1396 + * 1397 + * x^8 + x^7 +x^6 + x^4 + x^2 + 1 1398 + * 1399 + * The caller provides the initial value (either CRC8_INIT_VALUE 1400 + * or the previous returned value) to allow for processing of 1401 + * discontiguous blocks of data. When generating the CRC the 1402 + * caller is responsible for complementing the final return value 1403 + * and inserting it into the byte stream. When checking, a final 1404 + * return value of CRC8_GOOD_VALUE indicates a valid CRC. 1405 + * 1406 + * Reference: Dallas Semiconductor Application Note 27 1407 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms", 1408 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd., 1409 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt 1410 + * 1411 + * **************************************************************************** 1412 + */ 1413 + 1414 +static uint8 crc8_table[256] = { 1415 + 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B, 1416 + 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21, 1417 + 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF, 1418 + 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5, 1419 + 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14, 1420 + 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E, 1421 + 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80, 1422 + 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA, 1423 + 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95, 1424 + 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF, 1425 + 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01, 1426 + 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B, 1427 + 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA, 1428 + 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0, 1429 + 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E, 1430 + 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34, 1431 + 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0, 1432 + 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A, 1433 + 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54, 1434 + 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E, 1435 + 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF, 1436 + 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5, 1437 + 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B, 1438 + 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61, 1439 + 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E, 1440 + 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74, 1441 + 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA, 1442 + 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0, 1443 + 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41, 1444 + 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B, 1445 + 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5, 1446 + 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F 1447 +}; 1448 + 1449 +#define CRC_INNER_LOOP(n, c, x) \ 1450 + (c) = ((c) >> 8) ^ crc##n##_table[((c) ^ (x)) & 0xff] 1451 + 1452 +uint8 1453 +hndcrc8( 1454 + uint8 *pdata, /* pointer to array of data to process */ 1455 + uint nbytes, /* number of input data bytes to process */ 1456 + uint8 crc /* either CRC8_INIT_VALUE or previous return value */ 1457 +) 1458 +{ 1459 + /* hard code the crc loop instead of using CRC_INNER_LOOP macro 1460 + * to avoid the undefined and unnecessary (uint8 >> 8) operation. 1461 + */ 1462 + while (nbytes-- > 0) 1463 + crc = crc8_table[(crc ^ *pdata++) & 0xff]; 1464 + 1465 + return crc; 1466 +} 1467 + 1468 + 1469 diff -urN linux.old/arch/mips/bcm947xx/cfe_env.c linux.dev/arch/mips/bcm947xx/cfe_env.c 1470 --- linux.old/arch/mips/bcm947xx/cfe_env.c 1970-01-01 01:00:00.000000000 +0100 1471 +++ linux.dev/arch/mips/bcm947xx/cfe_env.c 2006-10-02 21:19:59.000000000 +0200 4 1472 @@ -0,0 +1,234 @@ 5 1473 +/* … … 237 1705 +} 238 1706 + 239 diff - Nur linux-2.4.32/arch/mips/bcm947xx/compressed/Makefile linux-2.4.32-freewrt/arch/mips/bcm947xx/compressed/Makefile240 --- linux -2.4.32/arch/mips/bcm947xx/compressed/Makefile 1970-01-01 01:00:00.000000000 +0100241 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/compressed/Makefile 2006-09-16 15:41:31.000000000 +02001707 diff -urN linux.old/arch/mips/bcm947xx/compressed/Makefile linux.dev/arch/mips/bcm947xx/compressed/Makefile 1708 --- linux.old/arch/mips/bcm947xx/compressed/Makefile 1970-01-01 01:00:00.000000000 +0100 1709 +++ linux.dev/arch/mips/bcm947xx/compressed/Makefile 2006-10-02 21:19:59.000000000 +0200 242 1710 @@ -0,0 +1,33 @@ 243 1711 +# … … 274 1742 +clean: 275 1743 + rm -f vmlinuz piggy 276 diff -Nur linux-2.4.32/arch/mips/bcm947xx/generic/int-handler.S linux-2.4.32-freewrt/arch/mips/bcm947xx/generic/int-handler.S 277 --- linux-2.4.32/arch/mips/bcm947xx/generic/int-handler.S 1970-01-01 01:00:00.000000000 +0100 278 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/generic/int-handler.S 2006-09-16 15:41:31.000000000 +0200 1744 diff -urN linux.old/arch/mips/bcm947xx/export.c linux.dev/arch/mips/bcm947xx/export.c 1745 --- linux.old/arch/mips/bcm947xx/export.c 1970-01-01 01:00:00.000000000 +0100 1746 +++ linux.dev/arch/mips/bcm947xx/export.c 2006-10-02 21:19:59.000000000 +0200 1747 @@ -0,0 +1,71 @@ 1748 +#include <linux/module.h> 1749 + 1750 +#define _export(n) \ 1751 + void n(void); \ 1752 + EXPORT_SYMBOL(n); 1753 + 1754 +_export(bcm947xx_sbh) 1755 + 1756 +_export(sb_attach) 1757 +_export(sb_kattach) 1758 +_export(sb_boardtype) 1759 +_export(sb_boardvendor) 1760 +_export(sb_btcgpiowar) 1761 +_export(sb_bus) 1762 +_export(sb_chip) 1763 +_export(sb_chiprev) 1764 +_export(sb_chipcrev) 1765 +_export(sb_chippkg) 1766 +_export(sb_clkctl_clk) 1767 +_export(sb_clkctl_fast_pwrup_delay) 1768 +_export(sb_clkctl_init) 1769 +_export(sb_clkctl_xtal) 1770 +_export(sb_core_disable) 1771 +_export(sb_core_reset) 1772 +_export(sb_core_tofixup) 1773 +_export(sb_coreflags) 1774 +_export(sb_coreflagshi) 1775 +_export(sb_coreidx) 1776 +_export(sb_coreregs) 1777 +_export(sb_corerev) 1778 +_export(sb_coreunit) 1779 +_export(sb_detach) 1780 +_export(sb_deviceremoved) 1781 +_export(sb_gpiosetcore) 1782 +_export(sb_gpiocontrol) 1783 +_export(sb_gpiointmask) 1784 +_export(sb_gpiointpolarity) 1785 +_export(sb_gpioled) 1786 +_export(sb_gpioin) 1787 +_export(sb_gpioout) 1788 +_export(sb_gpioouten) 1789 +_export(sb_gpiotimerval) 1790 +_export(sb_irq) 1791 +_export(sb_iscoreup) 1792 +_export(sb_pci_setup) 1793 +_export(sb_pcirev) 1794 +_export(sb_pcmcia_init) 1795 +_export(sb_pcmciarev) 1796 +_export(sb_register_intr_callback) 1797 +_export(sb_setcore) 1798 +_export(sb_setcoreidx) 1799 +_export(sb_war16165) 1800 +_export(sb_war32414_forceHT) 1801 +_export(sb_osh) 1802 + 1803 +_export(getvar) 1804 +_export(getintvar) 1805 +_export(bcm_strtoul) 1806 +_export(bcm_ctype) 1807 +_export(bcm_toupper) 1808 +_export(bcm_ether_ntoa) 1809 + 1810 +_export(nvram_get) 1811 +_export(nvram_getall) 1812 +_export(nvram_set) 1813 +_export(nvram_unset) 1814 +_export(nvram_commit) 1815 + 1816 +_export(srom_read) 1817 +_export(srom_write) 1818 + 1819 diff -urN linux.old/arch/mips/bcm947xx/generic/int-handler.S linux.dev/arch/mips/bcm947xx/generic/int-handler.S 1820 --- linux.old/arch/mips/bcm947xx/generic/int-handler.S 1970-01-01 01:00:00.000000000 +0100 1821 +++ linux.dev/arch/mips/bcm947xx/generic/int-handler.S 2006-10-02 21:19:59.000000000 +0200 279 1822 @@ -0,0 +1,51 @@ 280 1823 +/* … … 329 1872 + 330 1873 + END(brcmIRQ) 331 diff - Nur linux-2.4.32/arch/mips/bcm947xx/generic/irq.c linux-2.4.32-freewrt/arch/mips/bcm947xx/generic/irq.c332 --- linux -2.4.32/arch/mips/bcm947xx/generic/irq.c 1970-01-01 01:00:00.000000000 +0100333 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/generic/irq.c 2006-09-16 15:41:31.000000000 +02001874 diff -urN linux.old/arch/mips/bcm947xx/generic/irq.c linux.dev/arch/mips/bcm947xx/generic/irq.c 1875 --- linux.old/arch/mips/bcm947xx/generic/irq.c 1970-01-01 01:00:00.000000000 +0100 1876 +++ linux.dev/arch/mips/bcm947xx/generic/irq.c 2006-10-02 21:19:59.000000000 +0200 334 1877 @@ -0,0 +1,130 @@ 335 1878 +/* … … 463 2006 +#endif 464 2007 +} 465 diff - Nur linux-2.4.32/arch/mips/bcm947xx/generic/Makefile linux-2.4.32-freewrt/arch/mips/bcm947xx/generic/Makefile466 --- linux -2.4.32/arch/mips/bcm947xx/generic/Makefile 1970-01-01 01:00:00.000000000 +0100467 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/generic/Makefile 2006-09-16 15:41:31.000000000 +0200468 @@ -0,0 +1,1 5@@2008 diff -urN linux.old/arch/mips/bcm947xx/generic/Makefile linux.dev/arch/mips/bcm947xx/generic/Makefile 2009 --- linux.old/arch/mips/bcm947xx/generic/Makefile 1970-01-01 01:00:00.000000000 +0100 2010 +++ linux.dev/arch/mips/bcm947xx/generic/Makefile 2006-10-02 21:26:29.000000000 +0200 2011 @@ -0,0 +1,12 @@ 469 2012 +# 470 2013 +# Makefile for the BCM947xx specific kernel interface routines 471 2014 +# under Linux. 472 2015 +# 473 + 474 +.S.s: 475 + $(CPP) $(AFLAGS) $< -o $*.s 476 +.S.o: 477 + $(CC) $(AFLAGS) -c $< -o $*.o 2016 +EXTRA_CFLAGS += -fno-delayed-branch 2017 +USE_STANDARD_AS_RULE := true 478 2018 + 479 2019 +O_TARGET := brcm.o … … 482 2022 + 483 2023 +include $(TOPDIR)/Rules.make 484 diff - Nur linux-2.4.32/arch/mips/bcm947xx/gpio.c linux-2.4.32-freewrt/arch/mips/bcm947xx/gpio.c485 --- linux -2.4.32/arch/mips/bcm947xx/gpio.c 1970-01-01 01:00:00.000000000 +0100486 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/gpio.c 2006-09-16 15:41:31.000000000 +0200487 @@ -0,0 +1,15 8@@2024 diff -urN linux.old/arch/mips/bcm947xx/gpio.c linux.dev/arch/mips/bcm947xx/gpio.c 2025 --- linux.old/arch/mips/bcm947xx/gpio.c 1970-01-01 01:00:00.000000000 +0100 2026 +++ linux.dev/arch/mips/bcm947xx/gpio.c 2006-10-02 21:19:59.000000000 +0200 2027 @@ -0,0 +1,159 @@ 488 2028 +/* 489 2029 + * GPIO char driver 490 2030 + * 491 + * Copyright 200 4, Broadcom Corporation2031 + * Copyright 2005, Broadcom Corporation 492 2032 + * All Rights Reserved. 493 2033 + * … … 497 2037 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 498 2038 + * 499 + * $Id : gpio.c,v 1.1 2005/03/16 13:49:59 wbx Exp$2039 + * $Id$ 500 2040 + */ 501 2041 + … … 507 2047 + 508 2048 +#include <typedefs.h> 2049 +#include <osl.h> 509 2050 +#include <bcmutils.h> 510 2051 +#include <sbutils.h> 511 2052 +#include <bcmdevs.h> 512 2053 + 513 +static void*gpio_sbh;2054 +static sb_t *gpio_sbh; 514 2055 +static int gpio_major; 515 2056 +static devfs_handle_t gpio_dir; … … 551 2092 + break; 552 2093 + case 1: 553 + val = sb_gpioout(gpio_sbh, 0, 0 );2094 + val = sb_gpioout(gpio_sbh, 0, 0, GPIO_DRV_PRIORITY); 554 2095 + break; 555 2096 + case 2: 556 + val = sb_gpioouten(gpio_sbh, 0, 0 );2097 + val = sb_gpioouten(gpio_sbh, 0, 0, GPIO_DRV_PRIORITY); 557 2098 + break; 558 2099 + case 3: 559 + val = sb_gpiocontrol(gpio_sbh, 0, 0 );2100 + val = sb_gpiocontrol(gpio_sbh, 0, 0, GPIO_DRV_PRIORITY); 560 2101 + break; 561 2102 + default: … … 581 2122 + return -EACCES; 582 2123 + case 1: 583 + sb_gpioout(gpio_sbh, ~0, val );2124 + sb_gpioout(gpio_sbh, ~0, val, GPIO_DRV_PRIORITY); 584 2125 + break; 585 2126 + case 2: 586 + sb_gpioouten(gpio_sbh, ~0, val );2127 + sb_gpioouten(gpio_sbh, ~0, val, GPIO_DRV_PRIORITY); 587 2128 + break; 588 2129 + case 3: 589 + sb_gpiocontrol(gpio_sbh, ~0, val );2130 + sb_gpiocontrol(gpio_sbh, ~0, val, GPIO_DRV_PRIORITY); 590 2131 + break; 591 2132 + default: … … 623 2164 + gpio_file[i].name, 624 2165 + DEVFS_FL_DEFAULT, gpio_major, i, 625 + S_IFCHR | S_IRU SR | S_IWUSR | S_IRGRP,2166 + S_IFCHR | S_IRUGO | S_IWUGO, 626 2167 + &gpio_fops, NULL); 627 2168 + } … … 644 2185 +module_init(gpio_init); 645 2186 +module_exit(gpio_exit); 646 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmdevs.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/bcmdevs.h 647 --- linux-2.4.32/arch/mips/bcm947xx/include/bcmdevs.h 1970-01-01 01:00:00.000000000 +0100 648 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/include/bcmdevs.h 2006-09-16 15:41:31.000000000 +0200 649 @@ -0,0 +1,369 @@ 2187 diff -urN linux.old/arch/mips/bcm947xx/hndchipc.c linux.dev/arch/mips/bcm947xx/hndchipc.c 2188 --- linux.old/arch/mips/bcm947xx/hndchipc.c 1970-01-01 01:00:00.000000000 +0100 2189 +++ linux.dev/arch/mips/bcm947xx/hndchipc.c 2006-10-02 21:19:59.000000000 +0200 2190 @@ -0,0 +1,158 @@ 2191 +/* 2192 + * BCM47XX support code for some chipcommon (old extif) facilities (uart) 2193 + * 2194 + * Copyright 2006, Broadcom Corporation 2195 + * All Rights Reserved. 2196 + * 2197 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 2198 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 2199 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 2200 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 2201 + * 2202 + * $Id: hndchipc.c,v 1.1.1.1 2006/02/27 03:43:16 honor Exp $ 2203 + */ 2204 + 2205 +#include <typedefs.h> 2206 +#include <bcmdefs.h> 2207 +#include <osl.h> 2208 +#include <bcmutils.h> 2209 +#include <sbutils.h> 2210 +#include <bcmdevs.h> 2211 +#include <bcmnvram.h> 2212 +#include <sbconfig.h> 2213 +#include <sbextif.h> 2214 +#include <sbchipc.h> 2215 +#include <hndcpu.h> 2216 + 2217 +/* 2218 + * Returns TRUE if an external UART exists at the given base 2219 + * register. 2220 + */ 2221 +static bool 2222 +BCMINITFN(serial_exists)(osl_t *osh, uint8 *regs) 2223 +{ 2224 + uint8 save_mcr, status1; 2225 + 2226 + save_mcr = R_REG(osh, ®s[UART_MCR]); 2227 + W_REG(osh, ®s[UART_MCR], UART_MCR_LOOP | 0x0a); 2228 + status1 = R_REG(osh, ®s[UART_MSR]) & 0xf0; 2229 + W_REG(osh, ®s[UART_MCR], save_mcr); 2230 + 2231 + return (status1 == 0x90); 2232 +} 2233 + 2234 +/* 2235 + * Initializes UART access. The callback function will be called once 2236 + * per found UART. 2237 + */ 2238 +void 2239 +BCMINITFN(sb_serial_init)(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, 2240 + uint reg_shift)) 2241 +{ 2242 + osl_t *osh; 2243 + void *regs; 2244 + ulong base; 2245 + uint irq; 2246 + int i, n; 2247 + 2248 + osh = sb_osh(sbh); 2249 + 2250 + if ((regs = sb_setcore(sbh, SB_EXTIF, 0))) { 2251 + extifregs_t *eir = (extifregs_t *) regs; 2252 + sbconfig_t *sb; 2253 + 2254 + /* Determine external UART register base */ 2255 + sb = (sbconfig_t *)((ulong) eir + SBCONFIGOFF); 2256 + base = EXTIF_CFGIF_BASE(sb_base(R_REG(osh, &sb->sbadmatch1))); 2257 + 2258 + /* Determine IRQ */ 2259 + irq = sb_irq(sbh); 2260 + 2261 + /* Disable GPIO interrupt initially */ 2262 + W_REG(osh, &eir->gpiointpolarity, 0); 2263 + W_REG(osh, &eir->gpiointmask, 0); 2264 + 2265 + /* Search for external UARTs */ 2266 + n = 2; 2267 + for (i = 0; i < 2; i++) { 2268 + regs = (void *) REG_MAP(base + (i * 8), 8); 2269 + if (serial_exists(osh, regs)) { 2270 + /* Set GPIO 1 to be the external UART IRQ */ 2271 + W_REG(osh, &eir->gpiointmask, 2); 2272 + /* XXXDetermine external UART clock */ 2273 + if (add) 2274 + add(regs, irq, 13500000, 0); 2275 + } 2276 + } 2277 + 2278 + /* Add internal UART if enabled */ 2279 + if (R_REG(osh, &eir->corecontrol) & CC_UE) 2280 + if (add) 2281 + add((void *) &eir->uartdata, irq, sb_clock(sbh), 2); 2282 + } else if ((regs = sb_setcore(sbh, SB_CC, 0))) { 2283 + chipcregs_t *cc = (chipcregs_t *) regs; 2284 + uint32 rev, cap, pll, baud_base, div; 2285 + 2286 + /* Determine core revision and capabilities */ 2287 + rev = sb_corerev(sbh); 2288 + cap = R_REG(osh, &cc->capabilities); 2289 + pll = cap & CAP_PLL_MASK; 2290 + 2291 + /* Determine IRQ */ 2292 + irq = sb_irq(sbh); 2293 + 2294 + if (pll == PLL_TYPE1) { 2295 + /* PLL clock */ 2296 + baud_base = sb_clock_rate(pll, 2297 + R_REG(osh, &cc->clockcontrol_n), 2298 + R_REG(osh, &cc->clockcontrol_m2)); 2299 + div = 1; 2300 + } else { 2301 + /* Fixed ALP clock */ 2302 + if (rev >= 11 && rev != 15) { 2303 + baud_base = 20000000; 2304 + div = 1; 2305 + /* Set the override bit so we don't divide it */ 2306 + W_REG(osh, &cc->corecontrol, CC_UARTCLKO); 2307 + } 2308 + /* Internal backplane clock */ 2309 + else if (rev >= 3) { 2310 + baud_base = sb_clock(sbh); 2311 + div = 2; /* Minimum divisor */ 2312 + W_REG(osh, &cc->clkdiv, 2313 + ((R_REG(osh, &cc->clkdiv) & ~CLKD_UART) | div)); 2314 + } 2315 + /* Fixed internal backplane clock */ 2316 + else { 2317 + baud_base = 88000000; 2318 + div = 48; 2319 + } 2320 + 2321 + /* Clock source depends on strapping if UartClkOverride is unset */ 2322 + if ((rev > 0) && 2323 + ((R_REG(osh, &cc->corecontrol) & CC_UARTCLKO) == 0)) { 2324 + if ((cap & CAP_UCLKSEL) == CAP_UINTCLK) { 2325 + /* Internal divided backplane clock */ 2326 + baud_base /= div; 2327 + } else { 2328 + /* Assume external clock of 1.8432 MHz */ 2329 + baud_base = 1843200; 2330 + } 2331 + } 2332 + } 2333 + 2334 + /* Add internal UARTs */ 2335 + n = cap & CAP_UARTS_MASK; 2336 + for (i = 0; i < n; i++) { 2337 + /* Register offset changed after revision 0 */ 2338 + if (rev) 2339 + regs = (void *)((ulong) &cc->uart0data + (i * 256)); 2340 + else 2341 + regs = (void *)((ulong) &cc->uart0data + (i * 8)); 2342 + 2343 + if (add) 2344 + add(regs, irq, baud_base, 0); 2345 + } 2346 + } 2347 +} 2348 + 2349 diff -urN linux.old/arch/mips/bcm947xx/include/bcm4710.h linux.dev/arch/mips/bcm947xx/include/bcm4710.h 2350 --- linux.old/arch/mips/bcm947xx/include/bcm4710.h 1970-01-01 01:00:00.000000000 +0100 2351 +++ linux.dev/arch/mips/bcm947xx/include/bcm4710.h 2006-10-02 21:19:59.000000000 +0200 2352 @@ -0,0 +1,91 @@ 2353 +/* 2354 + * BCM4710 address space map and definitions 2355 + * Think twice before adding to this file, this is not the kitchen sink 2356 + * These definitions are not guaranteed for all 47xx chips, only the 4710 2357 + * 2358 + * Copyright 2004, Broadcom Corporation 2359 + * All Rights Reserved. 2360 + * 2361 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 2362 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 2363 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 2364 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 2365 + * 2366 + * $Id: bcm4710.h,v 1.3 2004/09/27 07:23:30 tallest Exp $ 2367 + */ 2368 + 2369 +#ifndef _bcm4710_h_ 2370 +#define _bcm4710_h_ 2371 + 2372 +/* Address map */ 2373 +#define BCM4710_SDRAM 0x00000000 /* Physical SDRAM */ 2374 +#define BCM4710_PCI_MEM 0x08000000 /* Host Mode PCI memory access space (64 MB) */ 2375 +#define BCM4710_PCI_CFG 0x0c000000 /* Host Mode PCI configuration space (64 MB) */ 2376 +#define BCM4710_PCI_DMA 0x40000000 /* Client Mode PCI memory access space (1 GB) */ 2377 +#define BCM4710_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */ 2378 +#define BCM4710_ENUM 0x18000000 /* Beginning of core enumeration space */ 2379 + 2380 +/* Core register space */ 2381 +#define BCM4710_REG_SDRAM 0x18000000 /* SDRAM core registers */ 2382 +#define BCM4710_REG_ILINE20 0x18001000 /* InsideLine20 core registers */ 2383 +#define BCM4710_REG_EMAC0 0x18002000 /* Ethernet MAC 0 core registers */ 2384 +#define BCM4710_REG_CODEC 0x18003000 /* Codec core registers */ 2385 +#define BCM4710_REG_USB 0x18004000 /* USB core registers */ 2386 +#define BCM4710_REG_PCI 0x18005000 /* PCI core registers */ 2387 +#define BCM4710_REG_MIPS 0x18006000 /* MIPS core registers */ 2388 +#define BCM4710_REG_EXTIF 0x18007000 /* External Interface core registers */ 2389 +#define BCM4710_REG_EMAC1 0x18008000 /* Ethernet MAC 1 core registers */ 2390 + 2391 +#define BCM4710_EXTIF 0x1f000000 /* External Interface base address */ 2392 +#define BCM4710_PCMCIA_MEM 0x1f000000 /* External Interface PCMCIA memory access */ 2393 +#define BCM4710_PCMCIA_IO 0x1f100000 /* PCMCIA I/O access */ 2394 +#define BCM4710_PCMCIA_CONF 0x1f200000 /* PCMCIA configuration */ 2395 +#define BCM4710_PROG 0x1f800000 /* Programable interface */ 2396 +#define BCM4710_FLASH 0x1fc00000 /* Flash */ 2397 + 2398 +#define BCM4710_EJTAG 0xff200000 /* MIPS EJTAG space (2M) */ 2399 + 2400 +#define BCM4710_UART (BCM4710_REG_EXTIF + 0x00000300) 2401 + 2402 +#define BCM4710_EUART (BCM4710_EXTIF + 0x00800000) 2403 +#define BCM4710_LED (BCM4710_EXTIF + 0x00900000) 2404 + 2405 +#define SBFLAG_PCI 0 2406 +#define SBFLAG_ENET0 1 2407 +#define SBFLAG_ILINE20 2 2408 +#define SBFLAG_CODEC 3 2409 +#define SBFLAG_USB 4 2410 +#define SBFLAG_EXTIF 5 2411 +#define SBFLAG_ENET1 6 2412 + 2413 +#ifdef CONFIG_HWSIM 2414 +#define BCM4710_TRACE(trval) do { *((int *)0xa0000f18) = (trval); } while (0) 2415 +#else 2416 +#define BCM4710_TRACE(trval) 2417 +#endif 2418 + 2419 + 2420 +/* BCM94702 CPCI -ExtIF used for LocalBus devs */ 2421 + 2422 +#define BCM94702_CPCI_RESET_ADDR BCM4710_EXTIF 2423 +#define BCM94702_CPCI_BOARDID_ADDR (BCM4710_EXTIF | 0x4000) 2424 +#define BCM94702_CPCI_DOC_ADDR (BCM4710_EXTIF | 0x6000) 2425 +#define BCM94702_DOC_ADDR BCM94702_CPCI_DOC_ADDR 2426 +#define BCM94702_CPCI_LED_ADDR (BCM4710_EXTIF | 0xc000) 2427 +#define BCM94702_CPCI_NVRAM_ADDR (BCM4710_EXTIF | 0xe000) 2428 +#define BCM94702_CPCI_NVRAM_SIZE 0x1ff0 /* 8K NVRAM : DS1743/STM48txx*/ 2429 +#define BCM94702_CPCI_TOD_REG_BASE (BCM94702_CPCI_NVRAM_ADDR | 0x1ff0) 2430 + 2431 +#define LED_REG(x) \ 2432 + (*(volatile unsigned char *) (KSEG1ADDR(BCM94702_CPCI_LED_ADDR) + (x))) 2433 + 2434 +/* 2435 + * Reset function implemented in PLD. Read or write should trigger hard reset 2436 + */ 2437 +#define SYS_HARD_RESET() \ 2438 + { for (;;) \ 2439 + *( (volatile unsigned char *)\ 2440 + KSEG1ADDR(BCM94702_CPCI_RESET_ADDR) ) = 0x80; \ 2441 + } 2442 + 2443 +#endif /* _bcm4710_h_ */ 2444 diff -urN linux.old/arch/mips/bcm947xx/include/bcmdefs.h linux.dev/arch/mips/bcm947xx/include/bcmdefs.h 2445 --- linux.old/arch/mips/bcm947xx/include/bcmdefs.h 1970-01-01 01:00:00.000000000 +0100 2446 +++ linux.dev/arch/mips/bcm947xx/include/bcmdefs.h 2006-10-02 21:19:59.000000000 +0200 2447 @@ -0,0 +1,106 @@ 2448 +/* 2449 + * Misc system wide definitions 2450 + * 2451 + * Copyright 2006, Broadcom Corporation 2452 + * All Rights Reserved. 2453 + * 2454 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 2455 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 2456 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 2457 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 2458 + * $Id: bcmdefs.h,v 1.1.1.3 2006/04/08 06:13:39 honor Exp $ 2459 + */ 2460 + 2461 +#ifndef _bcmdefs_h_ 2462 +#define _bcmdefs_h_ 2463 + 2464 +/* 2465 + * One doesn't need to include this file explicitly, gets included automatically if 2466 + * typedefs.h is included. 2467 + */ 2468 + 2469 +/* Reclaiming text and data : 2470 + * The following macros specify special linker sections that can be reclaimed 2471 + * after a system is considered 'up'. 2472 + */ 2473 +#if defined(__GNUC__) && defined(BCMRECLAIM) 2474 +extern bool bcmreclaimed; 2475 +#define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini." #_data))) _data 2476 +#define BCMINITFN(_fn) __attribute__ ((__section__ (".textini." #_fn))) _fn 2477 +#else /* #if defined(__GNUC__) && defined(BCMRECLAIM) */ 2478 +#define BCMINITDATA(_data) _data 2479 +#define BCMINITFN(_fn) _fn 2480 +#define bcmreclaimed 0 2481 +#endif /* #if defined(__GNUC__) && defined(BCMRECLAIM) */ 2482 + 2483 +/* Reclaim uninit functions if BCMNODOWN is defined */ 2484 +/* and if they are not already removed by -gc-sections */ 2485 +#ifdef BCMNODOWN 2486 +#define BCMUNINITFN(_fn) BCMINITFN(_fn) 2487 +#else 2488 +#define BCMUNINITFN(_fn) _fn 2489 +#endif 2490 + 2491 +#ifdef BCMRECLAIM 2492 +#define CONST 2493 +#else 2494 +#define CONST const 2495 +#endif /* BCMRECLAIM */ 2496 + 2497 +/* Compatibility with old-style BCMRECLAIM */ 2498 +#define BCMINIT(_id) _id 2499 + 2500 + 2501 +/* Put some library data/code into ROM to reduce RAM requirements */ 2502 +#if defined(__GNUC__) && defined(BCMROMOFFLOAD) 2503 +#define BCMROMDATA(_data) __attribute__ ((__section__ (".datarom." #_data))) _data 2504 +#define BCMROMFN(_fn) __attribute__ ((__section__ (".textrom." #_fn))) _fn 2505 +#else 2506 +#define BCMROMDATA(_data) _data 2507 +#define BCMROMFN(_fn) _fn 2508 +#endif 2509 + 2510 +/* Bus types */ 2511 +#define SB_BUS 0 /* Silicon Backplane */ 2512 +#define PCI_BUS 1 /* PCI target */ 2513 +#define PCMCIA_BUS 2 /* PCMCIA target */ 2514 +#define SDIO_BUS 3 /* SDIO target */ 2515 +#define JTAG_BUS 4 /* JTAG */ 2516 +#define NO_BUS 0xFF /* Bus that does not support R/W REG */ 2517 + 2518 +/* Allows optimization for single-bus support */ 2519 +#ifdef BCMBUSTYPE 2520 +#define BUSTYPE(bus) (BCMBUSTYPE) 2521 +#else 2522 +#define BUSTYPE(bus) (bus) 2523 +#endif 2524 + 2525 +/* Defines for DMA Address Width - Shared between OSL and HNDDMA */ 2526 +#define DMADDR_MASK_32 0x0 /* Address mask for 32-bits */ 2527 +#define DMADDR_MASK_30 0xc0000000 /* Address mask for 30-bits */ 2528 +#define DMADDR_MASK_0 0xffffffff /* Address mask for 0-bits (hi-part) */ 2529 + 2530 +#define DMADDRWIDTH_30 30 /* 30-bit addressing capability */ 2531 +#define DMADDRWIDTH_32 32 /* 32-bit addressing capability */ 2532 +#define DMADDRWIDTH_63 63 /* 64-bit addressing capability */ 2533 +#define DMADDRWIDTH_64 64 /* 64-bit addressing capability */ 2534 + 2535 +/* packet headroom necessary to accomodate the largest header in the system, (i.e TXOFF). 2536 + * By doing, we avoid the need to allocate an extra buffer for the header when bridging to WL. 2537 + * There is a compile time check in wlc.c which ensure that this value is at least as big 2538 + * as TXOFF. This value is used in dma_rxfill (hnddma.c). 2539 + */ 2540 +#define BCMEXTRAHDROOM 160 2541 + 2542 +/* Headroom required for dongle-to-host communication. Packets allocated 2543 + * locally in the dongle (e.g. for CDC ioctls or RNDIS messages) should 2544 + * leave this much room in front for low-level message headers which may 2545 + * be needed to get across the dongle bus to the host. (These messages 2546 + * don't go over the network, so room for the full WL header above would 2547 + * be a waste.) 2548 + */ 2549 +#define BCMDONGLEHDRSZ 8 2550 + 2551 + 2552 + 2553 +#endif /* _bcmdefs_h_ */ 2554 diff -urN linux.old/arch/mips/bcm947xx/include/bcmdevs1.h linux.dev/arch/mips/bcm947xx/include/bcmdevs1.h 2555 --- linux.old/arch/mips/bcm947xx/include/bcmdevs1.h 1970-01-01 01:00:00.000000000 +0100 2556 +++ linux.dev/arch/mips/bcm947xx/include/bcmdevs1.h 2006-10-02 21:19:59.000000000 +0200 2557 @@ -0,0 +1,391 @@ 650 2558 +/* 651 2559 + * Broadcom device-specific manifest constants. … … 746 2654 + 747 2655 +#define BCMGPRS_UART_ID 0x4333 /* Uart id used by 4306/gprs card */ 2656 +#define BCMGPRS2_UART_ID 0x4344 /* Uart id used by 4306/gprs card */ 2657 + 748 2658 + 749 2659 +#define BCM4704_DEVICE_ID 0x4704 /* 4704 chipcommon chipid */ … … 828 2738 +#define BFL_HGPA 0x2000 /* This board has a high gain PA */ 829 2739 +#define BFL_BTCMOD 0x4000 /* This board' BTCOEXIST is in the alternate gpios */ 2740 +#define BFL_ALTIQ 0x8000 /* Alternate I/Q settings */ 830 2741 + 831 2742 +/* board specific GPIO assignment, gpio 0-3 are also customer-configurable led */ … … 856 2767 + 857 2768 +/* power control defines */ 858 +#define PLL_DELAY 150 /* 150us pll on delay */ 859 +#define FREF_DELAY 200 /* 200us fref change delay */ 860 +#define MIN_SLOW_CLK 32 /* 32us Slow clock period */ 2769 +#define PLL_DELAY 150 /* us pll on delay */ 2770 +#define FREF_DELAY 200 /* us fref change delay */ 2771 +#define MIN_SLOW_CLK 32 /* us Slow clock period */ 2772 +#define XTAL_ON_DELAY 1000 /* us crystal power-on delay */ 861 2773 + 862 2774 +/* Reference Board Types */ … … 963 2875 +#define SD4318_BOARD 0x044b 964 2876 + 2877 +/* BCM63XX boards */ 2878 +#define BCM96338_BOARD 0x6338 2879 +#define BCM96345_BOARD 0x6345 2880 +#define BCM96348_BOARD 0x6348 2881 + 965 2882 +/* Another mp4306 with SiGe */ 966 2883 +#define BCM94306P_BOARD 0x044c … … 997 2914 +#define BCM94306MPLNA_BOARD 0x0457 998 2915 + 2916 +/* 4320 boards */ 2917 +#define BU4320_BOARD 0x0458 2918 +#define BU4320S_BOARD 0x0459 2919 +#define BCM94320PH_BOARD 0x045a 999 2920 + 1000 2921 +/* 4306mph */ … … 1006 2927 +#define BU4712SD_BOARD 0x045d 1007 2928 + 2929 +#define BCM94320PFLSH_BOARD 0x045e 1008 2930 + 1009 2931 +#define BU4712L_BOARD 0x045f 1010 2932 +#define BCM94712LGR_BOARD 0x0460 2933 +#define BCM94320R_BOARD 0x0461 1011 2934 + 1012 2935 +#define BU5352_BOARD 0x0462 2936 + 2937 +#define BCM94318MPGH_BOARD 0x0463 2938 + 2939 + 1013 2940 +#define BCM95352GR_BOARD 0x0467 2941 + 2942 +/* bcm95351agr */ 2943 +#define BCM95351AGR_BOARD 0x0470 1014 2944 + 1015 2945 +/* # of GPIO pins */ … … 1017 2947 + 1018 2948 +#endif /* _BCMDEVS_H */ 1019 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmendian.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/bcmendian.h 1020 --- linux-2.4.32/arch/mips/bcm947xx/include/bcmendian.h 1970-01-01 01:00:00.000000000 +0100 1021 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/include/bcmendian.h 2006-09-16 15:41:31.000000000 +0200 1022 @@ -0,0 +1,168 @@ 2949 diff -urN linux.old/arch/mips/bcm947xx/include/bcmdevs.h linux.dev/arch/mips/bcm947xx/include/bcmdevs.h 2950 --- linux.old/arch/mips/bcm947xx/include/bcmdevs.h 1970-01-01 01:00:00.000000000 +0100 2951 +++ linux.dev/arch/mips/bcm947xx/include/bcmdevs.h 2006-10-02 21:19:59.000000000 +0200 2952 @@ -0,0 +1,369 @@ 2953 +/* 2954 + * Broadcom device-specific manifest constants. 2955 + * 2956 + * Copyright 2006, Broadcom Corporation 2957 + * All Rights Reserved. 2958 + * 2959 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 2960 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 2961 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 2962 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 2963 + * $Id: bcmdevs.h,v 1.1.1.17 2006/04/15 01:29:08 michael Exp $ 2964 + */ 2965 + 2966 +#ifndef _BCMDEVS_H 2967 +#define _BCMDEVS_H 2968 + 2969 +#include "bcm4710.h" 2970 + 2971 +/* Known PCI vendor Id's */ 2972 +#define VENDOR_EPIGRAM 0xfeda 2973 +#define VENDOR_BROADCOM 0x14e4 2974 +#define VENDOR_3COM 0x10b7 2975 +#define VENDOR_NETGEAR 0x1385 2976 +#define VENDOR_DIAMOND 0x1092 2977 +#define VENDOR_DELL 0x1028 2978 +#define VENDOR_HP 0x0e11 2979 +#define VENDOR_APPLE 0x106b 2980 + 2981 +/* PCI Device Id's */ 2982 +#define BCM4210_DEVICE_ID 0x1072 /* never used */ 2983 +#define BCM4211_DEVICE_ID 0x4211 2984 +#define BCM4230_DEVICE_ID 0x1086 /* never used */ 2985 +#define BCM4231_DEVICE_ID 0x4231 2986 + 2987 +#define BCM4410_DEVICE_ID 0x4410 /* bcm44xx family pci iline */ 2988 +#define BCM4430_DEVICE_ID 0x4430 /* bcm44xx family cardbus iline */ 2989 +#define BCM4412_DEVICE_ID 0x4412 /* bcm44xx family pci enet */ 2990 +#define BCM4432_DEVICE_ID 0x4432 /* bcm44xx family cardbus enet */ 2991 + 2992 +#define BCM3352_DEVICE_ID 0x3352 /* bcm3352 device id */ 2993 +#define BCM3360_DEVICE_ID 0x3360 /* bcm3360 device id */ 2994 + 2995 +#define EPI41210_DEVICE_ID 0xa0fa /* bcm4210 */ 2996 +#define EPI41230_DEVICE_ID 0xa10e /* bcm4230 */ 2997 + 2998 +#define BCM47XX_ILINE_ID 0x4711 /* 47xx iline20 */ 2999 +#define BCM47XX_V90_ID 0x4712 /* 47xx v90 codec */ 3000 +#define BCM47XX_ENET_ID 0x4713 /* 47xx enet */ 3001 +#define BCM47XX_EXT_ID 0x4714 /* 47xx external i/f */ 3002 +#define BCM47XX_USB_ID 0x4715 /* 47xx usb */ 3003 +#define BCM47XX_USBH_ID 0x4716 /* 47xx usb host */ 3004 +#define BCM47XX_USBD_ID 0x4717 /* 47xx usb device */ 3005 +#define BCM47XX_IPSEC_ID 0x4718 /* 47xx ipsec */ 3006 +#define BCM47XX_ROBO_ID 0x4719 /* 47xx/53xx roboswitch core */ 3007 +#define BCM47XX_USB20H_ID 0x471a /* 47xx usb 2.0 host */ 3008 +#define BCM47XX_USB20D_ID 0x471b /* 47xx usb 2.0 device */ 3009 +#define BCM47XX_ATA100_ID 0x471d /* 47xx parallel ATA */ 3010 +#define BCM47XX_SATAXOR_ID 0x471e /* 47xx serial ATA & XOR DMA */ 3011 +#define BCM47XX_GIGETH_ID 0x471f /* 47xx GbE (5700) */ 3012 + 3013 +#define BCM47XX_SMBUS_EMU_ID 0x47fe /* 47xx emulated SMBus device */ 3014 +#define BCM47XX_XOR_EMU_ID 0x47ff /* 47xx emulated XOR engine */ 3015 + 3016 +#define BCM4710_CHIP_ID 0x4710 /* 4710 chipid returned by sb_chip() */ 3017 +#define BCM4710_DEVICE_ID 0x4710 /* 4710 primary function 0 */ 3018 + 3019 +#define BCM4402_CHIP_ID 0x4402 /* 4402 chipid */ 3020 +#define BCM4402_ENET_ID 0x4402 /* 4402 enet */ 3021 +#define BCM4402_V90_ID 0x4403 /* 4402 v90 codec */ 3022 +#define BCM4401_ENET_ID 0x170c /* 4401b0 production enet cards */ 3023 + 3024 +#define BCM4306_CHIP_ID 0x4306 /* 4306 chipcommon chipid */ 3025 +#define BCM4306_D11G_ID 0x4320 /* 4306 802.11g */ 3026 +#define BCM4306_D11G_ID2 0x4325 3027 +#define BCM4306_D11A_ID 0x4321 /* 4306 802.11a */ 3028 +#define BCM4306_UART_ID 0x4322 /* 4306 uart */ 3029 +#define BCM4306_V90_ID 0x4323 /* 4306 v90 codec */ 3030 +#define BCM4306_D11DUAL_ID 0x4324 /* 4306 dual A+B */ 3031 + 3032 +#define BCM4309_PKG_ID 1 /* 4309 package id */ 3033 + 3034 +#define BCM4311_CHIP_ID 0x4311 /* 4311 PCIe 802.11a/b/g */ 3035 +#define BCM4311_D11G_ID 0x4311 /* 4311 802.11b/g id */ 3036 +#define BCM4311_D11DUAL_ID 0x4312 /* 4311 802.11a/b/g id */ 3037 +#define BCM4311_D11A_ID 0x4313 /* 4311 802.11a id */ 3038 + 3039 +#define BCM4303_D11B_ID 0x4303 /* 4303 802.11b */ 3040 +#define BCM4303_PKG_ID 2 /* 4303 package id */ 3041 + 3042 +#define BCMGPRS_UART_ID 0x4333 /* Uart id used by 4306/gprs card */ 3043 +#define BCMGPRS2_UART_ID 0x4344 /* Uart id used by 4306/gprs card */ 3044 + 3045 +#define BCM4704_CHIP_ID 0x4704 /* 4704 chipcommon chipid */ 3046 +#define BCM4704_ENET_ID 0x4706 /* 4704 enet (Use 47XX_ENET_ID instead!) */ 3047 + 3048 +#define BCM4318_CHIP_ID 0x4318 /* 4318 chip common chipid */ 3049 +#define BCM4318_D11G_ID 0x4318 /* 4318 802.11b/g id */ 3050 +#define BCM4318_D11DUAL_ID 0x4319 /* 4318 802.11a/b/g id */ 3051 +#define BCM4318_D11A_ID 0x431a /* 4318 802.11a id */ 3052 + 3053 +#define BCM4321_CHIP_ID 0x4321 /* 4321 chip common chipid */ 3054 +#define BCM4321_D11N_ID 0x4328 /* 4321 802.11n dualband id */ 3055 +#define BCM4321_D11N2G_ID 0x4329 /* 4321 802.11n 2.4Hgz band id */ 3056 +#define BCM4321_D11N5G_ID 0x432a /* 4321 802.11n 5Ghz band id */ 3057 + 3058 +#define BCM4331_CHIP_ID 0x4331 /* 4331 chip common chipid */ 3059 +#define BCM4331_D11N2G_ID 0x4330 /* 4331 802.11n 2.4Ghz band id */ 3060 +#define BCM4331_D11N_ID 0x4331 /* 4331 802.11n dualband id */ 3061 +#define BCM4331_D11N5G_ID 0x4332 /* 4331 802.11n 5Ghz band id */ 3062 + 3063 +#define HDLSIM5350_PKG_ID 1 /* HDL simulator package id for a 5350 */ 3064 +#define HDLSIM_PKG_ID 14 /* HDL simulator package id */ 3065 +#define HWSIM_PKG_ID 15 /* Hardware simulator package id */ 3066 + 3067 +#define BCM4712_CHIP_ID 0x4712 /* 4712 chipcommon chipid */ 3068 +#define BCM4712_MIPS_ID 0x4720 /* 4712 base devid */ 3069 +#define BCM4712LARGE_PKG_ID 0 /* 340pin 4712 package id */ 3070 +#define BCM4712SMALL_PKG_ID 1 /* 200pin 4712 package id */ 3071 +#define BCM4712MID_PKG_ID 2 /* 225pin 4712 package id */ 3072 + 3073 +#define BCM5365_CHIP_ID 0x5365 /* 5365 chipcommon chipid */ 3074 +#define BCM5350_CHIP_ID 0x5350 /* bcm5350 chipcommon chipid */ 3075 +#define BCM5352_CHIP_ID 0x5352 /* bcm5352 chipcommon chipid */ 3076 + 3077 +#define BCM4320_CHIP_ID 0x4320 /* bcm4320 chipcommon chipid */ 3078 + 3079 +#define BCM4328_CHIP_ID 0x4328 /* bcm4328 chipcommon chipid */ 3080 + 3081 +#define FPGA_JTAGM_ID 0x43f0 /* FPGA jtagm device id */ 3082 +#define BCM43XX_JTAGM_ID 0x43f1 /* 43xx jtagm device id */ 3083 +#define BCM43XXOLD_JTAGM_ID 0x4331 /* 43xx old jtagm device id */ 3084 + 3085 +#define SDIOH_FPGA_ID 0x43f2 /* sdio host fpga */ 3086 +#define SDIOD_FPGA_ID 0x43f4 /* sdio device fpga */ 3087 + 3088 +#define MIMO_FPGA_ID 0x43f8 /* FPGA mimo minimacphy device id */ 3089 + 3090 +#define BCM4785_CHIP_ID 0x4785 /* 4785 chipcommon chipid */ 3091 + 3092 +/* PCMCIA vendor Id's */ 3093 + 3094 +#define VENDOR_BROADCOM_PCMCIA 0x02d0 3095 + 3096 +/* SDIO vendor Id's */ 3097 +#define VENDOR_BROADCOM_SDIO 0x00BF 3098 + 3099 + 3100 +/* boardflags */ 3101 +#define BFL_BTCOEXIST 0x0001 /* This board implements Bluetooth coexistance */ 3102 +#define BFL_PACTRL 0x0002 /* This board has gpio 9 controlling the PA */ 3103 +#define BFL_AIRLINEMODE 0x0004 /* This board implements gpio13 radio disable indication */ 3104 +#define BFL_ENETROBO 0x0010 /* This board has robo switch or core */ 3105 +#define BFL_CCKHIPWR 0x0040 /* Can do high-power CCK transmission */ 3106 +#define BFL_ENETADM 0x0080 /* This board has ADMtek switch */ 3107 +#define BFL_ENETVLAN 0x0100 /* This board has vlan capability */ 3108 +#define BFL_AFTERBURNER 0x0200 /* This board supports Afterburner mode */ 3109 +#define BFL_NOPCI 0x0400 /* This board leaves PCI floating */ 3110 +#define BFL_FEM 0x0800 /* This board supports the Front End Module */ 3111 +#define BFL_EXTLNA 0x1000 /* This board has an external LNA */ 3112 +#define BFL_HGPA 0x2000 /* This board has a high gain PA */ 3113 +#define BFL_BTCMOD 0x4000 /* This board' BTCOEXIST is in the alternate gpios */ 3114 +#define BFL_ALTIQ 0x8000 /* Alternate I/Q settings */ 3115 + 3116 +/* boardflags2 */ 3117 +#define BFL2_RXBB_INT_REG_DIS 0x00000001 /* This board has an external rxbb regulator */ 3118 +#define BFL2_SSWITCH_AVAIL 0x00000002 /* This board has a superswitch for > 2 antennas */ 3119 +#define BFL2_TXPWRCTRL_EN 0x00000004 /* This board permits TX Power Control to be enabled */ 3120 + 3121 +/* board specific GPIO assignment, gpio 0-3 are also customer-configurable led */ 3122 +#define BOARD_GPIO_BTCMOD_IN 0x010 /* bit 4 is the alternate BT Coexistance Input */ 3123 +#define BOARD_GPIO_BTCMOD_OUT 0x020 /* bit 5 is the alternate BT Coexistance Out */ 3124 +#define BOARD_GPIO_BTC_IN 0x080 /* bit 7 is BT Coexistance Input */ 3125 +#define BOARD_GPIO_BTC_OUT 0x100 /* bit 8 is BT Coexistance Out */ 3126 +#define BOARD_GPIO_PACTRL 0x200 /* bit 9 controls the PA on new 4306 boards */ 3127 +#define PCI_CFG_GPIO_SCS 0x10 /* PCI config space bit 4 for 4306c0 slow clock source */ 3128 +#define PCI_CFG_GPIO_HWRAD 0x20 /* PCI config space GPIO 13 for hw radio disable */ 3129 +#define PCI_CFG_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */ 3130 +#define PCI_CFG_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */ 3131 + 3132 +/* power control defines */ 3133 +#define PLL_DELAY 150 /* us pll on delay */ 3134 +#define FREF_DELAY 200 /* us fref change delay */ 3135 +#define MIN_SLOW_CLK 32 /* us Slow clock period */ 3136 +#define XTAL_ON_DELAY 1000 /* us crystal power-on delay */ 3137 + 3138 +/* Reference Board Types */ 3139 + 3140 +#define BU4710_BOARD 0x0400 3141 +#define VSIM4710_BOARD 0x0401 3142 +#define QT4710_BOARD 0x0402 3143 + 3144 +#define BU4309_BOARD 0x040a 3145 +#define BCM94309CB_BOARD 0x040b 3146 +#define BCM94309MP_BOARD 0x040c 3147 +#define BCM4309AP_BOARD 0x040d 3148 + 3149 +#define BCM94302MP_BOARD 0x040e 3150 + 3151 +#define BU4306_BOARD 0x0416 3152 +#define BCM94306CB_BOARD 0x0417 3153 +#define BCM94306MP_BOARD 0x0418 3154 + 3155 +#define BCM94710D_BOARD 0x041a 3156 +#define BCM94710R1_BOARD 0x041b 3157 +#define BCM94710R4_BOARD 0x041c 3158 +#define BCM94710AP_BOARD 0x041d 3159 + 3160 +#define BU2050_BOARD 0x041f 3161 + 3162 + 3163 +#define BCM94309G_BOARD 0x0421 3164 + 3165 +#define BU4704_BOARD 0x0423 3166 +#define BU4702_BOARD 0x0424 3167 + 3168 +#define BCM94306PC_BOARD 0x0425 /* pcmcia 3.3v 4306 card */ 3169 + 3170 + 3171 +#define BCM94702MN_BOARD 0x0428 3172 + 3173 +/* BCM4702 1U CompactPCI Board */ 3174 +#define BCM94702CPCI_BOARD 0x0429 3175 + 3176 +/* BCM4702 with BCM95380 VLAN Router */ 3177 +#define BCM95380RR_BOARD 0x042a 3178 + 3179 +/* cb4306 with SiGe PA */ 3180 +#define BCM94306CBSG_BOARD 0x042b 3181 + 3182 +/* cb4306 with SiGe PA */ 3183 +#define PCSG94306_BOARD 0x042d 3184 + 3185 +/* bu4704 with sdram */ 3186 +#define BU4704SD_BOARD 0x042e 3187 + 3188 +/* Dual 11a/11g Router */ 3189 +#define BCM94704AGR_BOARD 0x042f 3190 + 3191 +/* 11a-only minipci */ 3192 +#define BCM94308MP_BOARD 0x0430 3193 + 3194 + 3195 + 3196 +#define BU4712_BOARD 0x0444 3197 +#define BU4712SD_BOARD 0x045d 3198 +#define BU4712L_BOARD 0x045f 3199 + 3200 +/* BCM4712 boards */ 3201 +#define BCM94712AP_BOARD 0x0445 3202 +#define BCM94712P_BOARD 0x0446 3203 + 3204 +/* BCM4318 boards */ 3205 +#define BU4318_BOARD 0x0447 3206 +#define CB4318_BOARD 0x0448 3207 +#define MPG4318_BOARD 0x0449 3208 +#define MP4318_BOARD 0x044a 3209 +#define SD4318_BOARD 0x044b 3210 + 3211 +/* BCM63XX boards */ 3212 +#define BCM96338_BOARD 0x6338 3213 +#define BCM96348_BOARD 0x6348 3214 + 3215 +/* Another mp4306 with SiGe */ 3216 +#define BCM94306P_BOARD 0x044c 3217 + 3218 +/* mp4303 */ 3219 +#define BCM94303MP_BOARD 0x044e 3220 + 3221 +/* mpsgh4306 */ 3222 +#define BCM94306MPSGH_BOARD 0x044f 3223 + 3224 +/* BRCM 4306 w/ Front End Modules */ 3225 +#define BCM94306MPM 0x0450 3226 +#define BCM94306MPL 0x0453 3227 + 3228 +/* 4712agr */ 3229 +#define BCM94712AGR_BOARD 0x0451 3230 + 3231 +/* pcmcia 4303 */ 3232 +#define PC4303_BOARD 0x0454 3233 + 3234 +/* 5350K */ 3235 +#define BCM95350K_BOARD 0x0455 3236 + 3237 +/* 5350R */ 3238 +#define BCM95350R_BOARD 0x0456 3239 + 3240 +/* 4306mplna */ 3241 +#define BCM94306MPLNA_BOARD 0x0457 3242 + 3243 +/* 4320 boards */ 3244 +#define BU4320_BOARD 0x0458 3245 +#define BU4320S_BOARD 0x0459 3246 +#define BCM94320PH_BOARD 0x045a 3247 + 3248 +/* 4306mph */ 3249 +#define BCM94306MPH_BOARD 0x045b 3250 + 3251 +/* 4306pciv */ 3252 +#define BCM94306PCIV_BOARD 0x045c 3253 + 3254 +#define BU4712SD_BOARD 0x045d 3255 + 3256 +#define BCM94320PFLSH_BOARD 0x045e 3257 + 3258 +#define BU4712L_BOARD 0x045f 3259 +#define BCM94712LGR_BOARD 0x0460 3260 +#define BCM94320R_BOARD 0x0461 3261 + 3262 +#define BU5352_BOARD 0x0462 3263 + 3264 +#define BCM94318MPGH_BOARD 0x0463 3265 + 3266 +#define BU4311_BOARD 0x0464 3267 +#define BCM94311MC_BOARD 0x0465 3268 +#define BCM94311MCAG_BOARD 0x0466 3269 + 3270 +#define BCM95352GR_BOARD 0x0467 3271 + 3272 +/* bcm95351agr */ 3273 +#define BCM95351AGR_BOARD 0x0470 3274 + 3275 +/* bcm94704mpcb */ 3276 +#define BCM94704MPCB_BOARD 0x0472 3277 + 3278 +/* 4785 boards */ 3279 +#define BU4785_BOARD 0x0478 3280 + 3281 +/* 4321 boards */ 3282 +#define BU4321_BOARD 0x046b 3283 +#define BU4321E_BOARD 0x047c 3284 +#define MP4321_BOARD 0x046c 3285 +#define CB2_4321_BOARD 0x046d 3286 +#define MC4321_BOARD 0x046e 3287 + 3288 +/* # of GPIO pins */ 3289 +#define GPIO_NUMPINS 16 3290 + 3291 +/* radio ID codes */ 3292 +#define NORADIO_ID 0xe4f5 3293 +#define NORADIO_IDCODE 0x4e4f5246 3294 + 3295 +#define BCM2050_ID 0x2050 3296 +#define BCM2050_IDCODE 0x02050000 3297 +#define BCM2050A0_IDCODE 0x1205017f 3298 +#define BCM2050A1_IDCODE 0x2205017f 3299 +#define BCM2050R8_IDCODE 0x8205017f 3300 + 3301 +#define BCM2055_ID 0x2055 3302 +#define BCM2055_IDCODE 0x02055000 3303 +#define BCM2055A0_IDCODE 0x1205517f 3304 + 3305 +#define BCM2060_ID 0x2060 3306 +#define BCM2060_IDCODE 0x02060000 3307 +#define BCM2060WW_IDCODE 0x1206017f 3308 + 3309 +#define BCM2062_ID 0x2062 3310 +#define BCM2062_IDCODE 0x02062000 3311 +#define BCM2062A0_IDCODE 0x0206217f 3312 + 3313 +/* parts of an idcode: */ 3314 +#define IDCODE_MFG_MASK 0x00000fff 3315 +#define IDCODE_MFG_SHIFT 0 3316 +#define IDCODE_ID_MASK 0x0ffff000 3317 +#define IDCODE_ID_SHIFT 12 3318 +#define IDCODE_REV_MASK 0xf0000000 3319 +#define IDCODE_REV_SHIFT 28 3320 + 3321 +#endif /* _BCMDEVS_H */ 3322 diff -urN linux.old/arch/mips/bcm947xx/include/bcmendian.h linux.dev/arch/mips/bcm947xx/include/bcmendian.h 3323 --- linux.old/arch/mips/bcm947xx/include/bcmendian.h 1970-01-01 01:00:00.000000000 +0100 3324 +++ linux.dev/arch/mips/bcm947xx/include/bcmendian.h 2006-10-02 21:19:59.000000000 +0200 3325 @@ -0,0 +1,198 @@ 1023 3326 +/* 1024 3327 + * local version of endian.h - byte order defines 1025 3328 + * 1026 + * Copyright 200 5, Broadcom Corporation1027 + * All Rights Reserved. 1028 + * 1029 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 1030 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 1031 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 1032 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 3329 + * Copyright 2006, Broadcom Corporation 3330 + * All Rights Reserved. 3331 + * 3332 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 3333 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 3334 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 3335 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 1033 3336 + * 1034 + * $Id $3337 + * $Id: bcmendian.h,v 1.1.1.10 2006/02/27 03:43:16 honor Exp $ 1035 3338 +*/ 1036 3339 + … … 1042 3345 +/* Byte swap a 16 bit value */ 1043 3346 +#define BCMSWAP16(val) \ 1044 + ((uint16)( \3347 + ((uint16)(\ 1045 3348 + (((uint16)(val) & (uint16)0x00ffU) << 8) | \ 1046 + (((uint16)(val) & (uint16)0xff00U) >> 8) ))1047 + 3349 + (((uint16)(val) & (uint16)0xff00U) >> 8))) 3350 + 1048 3351 +/* Byte swap a 32 bit value */ 1049 3352 +#define BCMSWAP32(val) \ 1050 + ((uint32)( \3353 + ((uint32)(\ 1051 3354 + (((uint32)(val) & (uint32)0x000000ffUL) << 24) | \ 1052 3355 + (((uint32)(val) & (uint32)0x0000ff00UL) << 8) | \ 1053 3356 + (((uint32)(val) & (uint32)0x00ff0000UL) >> 8) | \ 1054 + (((uint32)(val) & (uint32)0xff000000UL) >> 24) )) 3357 + (((uint32)(val) & (uint32)0xff000000UL) >> 24))) 3358 + 3359 +/* 2 Byte swap a 32 bit value */ 3360 +#define BCMSWAP32BY16(val) \ 3361 + ((uint32)(\ 3362 + (((uint32)(val) & (uint32)0x0000ffffUL) << 16) | \ 3363 + (((uint32)(val) & (uint32)0xffff0000UL) >> 16))) 3364 + 1055 3365 + 1056 3366 +static INLINE uint16 … … 1064 3374 +{ 1065 3375 + return BCMSWAP32(val); 3376 +} 3377 + 3378 +static INLINE uint32 3379 +bcmswap32by16(uint32 val) 3380 +{ 3381 + return BCMSWAP32BY16(val); 1066 3382 +} 1067 3383 + … … 1073 3389 + len = len/2; 1074 3390 + 1075 + while (len--){3391 + while (len--) { 1076 3392 + *buf = bcmswap16(*buf); 1077 3393 + buf++; … … 1100 3416 +#define htol16(i) bcmswap16(i) 1101 3417 +#define htol32(i) bcmswap32(i) 1102 +#endif 1103 +#endif 3418 +#endif /* IL_BIGENDIAN */ 3419 +#endif /* hton16 */ 1104 3420 + 1105 3421 +#ifndef IL_BIGENDIAN … … 1109 3425 +#define ltoh16_buf(buf, i) bcmswap16_buf((uint16*)buf, i) 1110 3426 +#define htol16_buf(buf, i) bcmswap16_buf((uint16*)buf, i) 1111 +#endif 3427 +#endif /* IL_BIGENDIAN */ 3428 + 3429 +/* 3430 +* store 16-bit value to unaligned little endian byte array. 3431 +*/ 3432 +static INLINE void 3433 +htol16_ua_store(uint16 val, uint8 *bytes) 3434 +{ 3435 + bytes[0] = val&0xff; 3436 + bytes[1] = val>>8; 3437 +} 3438 + 3439 +/* 3440 +* store 32-bit value to unaligned little endian byte array. 3441 +*/ 3442 +static INLINE void 3443 +htol32_ua_store(uint32 val, uint8 *bytes) 3444 +{ 3445 + bytes[0] = val&0xff; 3446 + bytes[1] = (val>>8)&0xff; 3447 + bytes[2] = (val>>16)&0xff; 3448 + bytes[3] = val>>24; 3449 +} 3450 + 3451 +/* 3452 +* store 16-bit value to unaligned network(big) endian byte array. 3453 +*/ 3454 +static INLINE void 3455 +hton16_ua_store(uint16 val, uint8 *bytes) 3456 +{ 3457 + bytes[1] = val&0xff; 3458 + bytes[0] = val>>8; 3459 +} 3460 + 3461 +/* 3462 +* store 32-bit value to unaligned network(big) endian byte array. 3463 +*/ 3464 +static INLINE void 3465 +hton32_ua_store(uint32 val, uint8 *bytes) 3466 +{ 3467 + bytes[3] = val&0xff; 3468 + bytes[2] = (val>>8)&0xff; 3469 + bytes[1] = (val>>16)&0xff; 3470 + bytes[0] = val>>24; 3471 +} 1112 3472 + 1113 3473 +/* … … 1115 3475 +*/ 1116 3476 +static INLINE uint16 1117 +ltoh16_ua( uint8*bytes)1118 +{ 1119 + return ( bytes[1]<<8)+bytes[0];3477 +ltoh16_ua(void *bytes) 3478 +{ 3479 + return (((uint8*)bytes)[1]<<8)+((uint8 *)bytes)[0]; 1120 3480 +} 1121 3481 + … … 1124 3484 +*/ 1125 3485 +static INLINE uint32 1126 +ltoh32_ua(uint8 *bytes) 1127 +{ 1128 + return (bytes[3]<<24)+(bytes[2]<<16)+(bytes[1]<<8)+bytes[0]; 3486 +ltoh32_ua(void *bytes) 3487 +{ 3488 + return (((uint8*)bytes)[3]<<24)+(((uint8*)bytes)[2]<<16)+ 3489 + (((uint8*)bytes)[1]<<8)+((uint8*)bytes)[0]; 1129 3490 +} 1130 3491 + … … 1133 3494 +*/ 1134 3495 +static INLINE uint16 1135 +ntoh16_ua( uint8*bytes)1136 +{ 1137 + return ( bytes[0]<<8)+bytes[1];3496 +ntoh16_ua(void *bytes) 3497 +{ 3498 + return (((uint8*)bytes)[0]<<8)+((uint8*)bytes)[1]; 1138 3499 +} 1139 3500 + … … 1142 3503 +*/ 1143 3504 +static INLINE uint32 1144 +ntoh32_ua(uint8 *bytes) 1145 +{ 1146 + return (bytes[0]<<24)+(bytes[1]<<16)+(bytes[2]<<8)+bytes[3]; 1147 +} 1148 + 1149 +/* get_ua adapted from Linux asm-mips/unaligned.h */ 1150 +#ifdef IL_BIGENDIAN 1151 +#define get_ua(ptr) \ 1152 +({ \ 1153 + __typeof__(*(ptr)) __val; \ 1154 + \ 1155 + switch (sizeof(*(ptr))) { \ 1156 + case 1: \ 1157 + __val = *(uint8 *)ptr; \ 1158 + break; \ 1159 + case 2: \ 1160 + __val = ntoh16_ua((uint8 *)ptr); \ 1161 + break; \ 1162 + case 4: \ 1163 + __val = ntoh32_ua((uint8 *)ptr); \ 1164 + break; \ 1165 + } \ 1166 + \ 1167 + __val; \ 1168 +}) 1169 +#else 1170 +#define get_ua(ptr) \ 1171 +({ \ 1172 + __typeof__(*(ptr)) __val; \ 1173 + \ 1174 + switch (sizeof(*(ptr))) { \ 1175 + case 1: \ 1176 + __val = *(uint8 *)ptr; \ 1177 + break; \ 1178 + case 2: \ 1179 + __val = ltoh16_ua((uint8 *)ptr); \ 1180 + break; \ 1181 + case 4: \ 1182 + __val = ltoh32_ua((uint8 *)ptr); \ 1183 + break; \ 1184 + } \ 1185 + \ 1186 + __val; \ 1187 +}) 1188 +#endif 3505 +ntoh32_ua(void *bytes) 3506 +{ 3507 + return (((uint8*)bytes)[0]<<24)+(((uint8*)bytes)[1]<<16)+ 3508 + (((uint8*)bytes)[2]<<8)+((uint8*)bytes)[3]; 3509 +} 3510 + 3511 +#define ltoh_ua(ptr) (\ 3512 + sizeof(*(ptr)) == sizeof(uint8) ? *(uint8 *)ptr : \ 3513 + sizeof(*(ptr)) == sizeof(uint16) ? (((uint8 *)ptr)[1]<<8)+((uint8 *)ptr)[0] : \ 3514 + (((uint8 *)ptr)[3]<<24)+(((uint8 *)ptr)[2]<<16)+(((uint8 *)ptr)[1]<<8)+((uint8 *)ptr)[0] \ 3515 +) 3516 + 3517 +#define ntoh_ua(ptr) (\ 3518 + sizeof(*(ptr)) == sizeof(uint8) ? *(uint8 *)ptr : \ 3519 + sizeof(*(ptr)) == sizeof(uint16) ? (((uint8 *)ptr)[0]<<8)+((uint8 *)ptr)[1] : \ 3520 + (((uint8 *)ptr)[0]<<24)+(((uint8 *)ptr)[1]<<16)+(((uint8 *)ptr)[2]<<8)+((uint8 *)ptr)[3] \ 3521 +) 1189 3522 + 1190 3523 +#endif /* _BCMENDIAN_H_ */ 1191 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmnvram.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/bcmnvram.h1192 --- linux -2.4.32/arch/mips/bcm947xx/include/bcmnvram.h 1970-01-01 01:00:00.000000000 +01001193 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/bcmnvram.h 2006-09-16 15:41:31.000000000 +02001194 @@ -0,0 +1,1 32@@3524 diff -urN linux.old/arch/mips/bcm947xx/include/bcmnvram.h linux.dev/arch/mips/bcm947xx/include/bcmnvram.h 3525 --- linux.old/arch/mips/bcm947xx/include/bcmnvram.h 1970-01-01 01:00:00.000000000 +0100 3526 +++ linux.dev/arch/mips/bcm947xx/include/bcmnvram.h 2006-10-02 21:19:59.000000000 +0200 3527 @@ -0,0 +1,159 @@ 1195 3528 +/* 1196 3529 + * NVRAM variable manipulation 1197 3530 + * 1198 + * Copyright 200 5, Broadcom Corporation3531 + * Copyright 2006, Broadcom Corporation 1199 3532 + * All Rights Reserved. 1200 3533 + * … … 1204 3537 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 1205 3538 + * 1206 + * $Id $3539 + * $Id: bcmnvram.h,v 1.17 2006/03/02 12:33:44 honor Exp $ 1207 3540 + */ 1208 3541 + … … 1213 3546 + 1214 3547 +#include <typedefs.h> 3548 +#include <bcmdefs.h> 1215 3549 + 1216 3550 +struct nvram_header { 1217 3551 + uint32 magic; 1218 3552 + uint32 len; 1219 + uint32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16: 27 init, mem. test 28, 29-31 reserved*/1220 + uint32 config_refresh; /* 0:15 config, 16:31refresh */3553 + uint32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */ 3554 + uint32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */ 1221 3555 + uint32 config_ncdl; /* ncdl values for memc */ 1222 3556 +}; … … 1232 3566 + * platforms. 1233 3567 + */ 1234 +extern int BCMINIT(nvram_init)(void *sbh);3568 +extern int nvram_init(void *sbh); 1235 3569 + 1236 3570 +/* … … 1238 3572 + * platforms. 1239 3573 + */ 1240 +extern void BCMINIT(nvram_exit)(void);3574 +extern void nvram_exit(void *sbh); 1241 3575 + 1242 3576 +/* … … 1246 3580 + * @return value of variable or NULL if undefined 1247 3581 + */ 1248 +extern char * BCMINIT(nvram_get)(const char *name); 3582 +extern char * nvram_get(const char *name); 3583 + 3584 +/* 3585 + * Read the reset GPIO value from the nvram and set the GPIO 3586 + * as input 3587 + */ 3588 +extern int BCMINITFN(nvram_resetgpio_init)(void *sbh); 3589 +extern int BCMINITFN(nvram_gpio_init)(const char *name, void *sbh); 3590 +extern int BCMINITFN(nvram_gpio_set)(const char *name, void *sbh, int type); 1249 3591 + 1250 3592 +/* … … 1253 3595 + * @return value of variable or NUL if undefined 1254 3596 + */ 1255 +#define nvram_safe_get(name) (BCMINIT(nvram_get)(name) ? : "") 3597 +#define nvram_safe_get(name) (nvram_get(name) ? : "") 3598 + 3599 +#define nvram_safe_unset(name) ({ \ 3600 + if(nvram_get(name)) \ 3601 + nvram_unset(name); \ 3602 +}) 3603 + 3604 +#define nvram_safe_set(name, value) ({ \ 3605 + if(!nvram_get(name) || strcmp(nvram_get(name), value)) \ 3606 + nvram_set(name, value); \ 3607 +}) 1256 3608 + 1257 3609 +/* … … 1264 3616 +static INLINE int 1265 3617 +nvram_match(char *name, char *match) { 1266 + const char *value = BCMINIT(nvram_get)(name);3618 + const char *value = nvram_get(name); 1267 3619 + return (value && !strcmp(value, match)); 1268 3620 +} … … 1277 3629 +static INLINE int 1278 3630 +nvram_invmatch(char *name, char *invmatch) { 1279 + const char *value = BCMINIT(nvram_get)(name);3631 + const char *value = nvram_get(name); 1280 3632 + return (value && strcmp(value, invmatch)); 1281 3633 +} … … 1290 3642 + * @return 0 on success and errno on failure 1291 3643 + */ 1292 +extern int BCMINIT(nvram_set)(const char *name, const char *value);3644 +extern int nvram_set(const char *name, const char *value); 1293 3645 + 1294 3646 +/* … … 1299 3651 + * NOTE: use nvram_commit to commit this change to flash. 1300 3652 + */ 1301 +extern int BCMINIT(nvram_unset)(const char *name);3653 +extern int nvram_unset(const char *name); 1302 3654 + 1303 3655 +/* … … 1307 3659 + * @return 0 on success and errno on failure 1308 3660 + */ 1309 +extern int BCMINIT(nvram_commit)(void);3661 +extern int nvram_commit(void); 1310 3662 + 1311 3663 +/* … … 1315 3667 + * @return 0 on success and errno on failure 1316 3668 + */ 1317 +extern int BCMINIT(nvram_getall)(char *buf, int count); 3669 +extern int nvram_getall(char *buf, int count); 3670 + 3671 +extern int file2nvram(char *filename, char *varname); 3672 +extern int nvram2file(char *varname, char *filename); 1318 3673 + 1319 3674 +#endif /* _LANGUAGE_ASSEMBLY */ 1320 3675 + 1321 3676 +#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */ 3677 +#define NVRAM_CLEAR_MAGIC 0x0 3678 +#define NVRAM_INVALID_MAGIC 0xFFFFFFFF 1322 3679 +#define NVRAM_VERSION 1 1323 3680 +#define NVRAM_HEADER_SIZE 20 1324 3681 +#define NVRAM_SPACE 0x8000 1325 3682 + 3683 +#define NVRAM_MAX_VALUE_LEN 255 3684 +#define NVRAM_MAX_PARAM_LEN 64 3685 + 1326 3686 +#endif /* _bcmnvram_h_ */ 1327 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmsrom.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/bcmsrom.h1328 --- linux -2.4.32/arch/mips/bcm947xx/include/bcmsrom.h 1970-01-01 01:00:00.000000000 +01001329 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/bcmsrom.h 2006-09-16 15:41:31.000000000 +02001330 @@ -0,0 +1, 22@@3687 diff -urN linux.old/arch/mips/bcm947xx/include/bcmsrom.h linux.dev/arch/mips/bcm947xx/include/bcmsrom.h 3688 --- linux.old/arch/mips/bcm947xx/include/bcmsrom.h 1970-01-01 01:00:00.000000000 +0100 3689 +++ linux.dev/arch/mips/bcm947xx/include/bcmsrom.h 2006-10-02 21:19:59.000000000 +0200 3690 @@ -0,0 +1,108 @@ 1331 3691 +/* 1332 3692 + * Misc useful routines to access NIC local SROM/OTP . 1333 3693 + * 1334 + * Copyright 200 5, Broadcom Corporation3694 + * Copyright 2006, Broadcom Corporation 1335 3695 + * All Rights Reserved. 1336 3696 + * … … 1340 3700 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 1341 3701 + * 1342 + * $Id $3702 + * $Id: bcmsrom.h,v 1.1.1.13 2006/04/15 01:29:08 michael Exp $ 1343 3703 + */ 1344 3704 + … … 1346 3706 +#define _bcmsrom_h_ 1347 3707 + 1348 +extern int srom_var_init(void *sbh, uint bus, void *curmap, void *osh, char **vars, int *count); 1349 +extern int srom_read(uint bus, void *curmap, void *osh, uint byteoff, uint nbytes, uint16 *buf); 1350 +extern int srom_write(uint bus, void *curmap, void *osh, uint byteoff, uint nbytes, uint16 *buf); 1351 + 3708 +/* Maximum srom: 4 Kilobits == 512 bytes */ 3709 +#define SROM_MAX 512 3710 + 3711 +/* SROM Rev 4: Reallocate the software part of the srom to accomodate 3712 + * MIMO features. It assumes up to two PCIE functions and 440 bytes 3713 + * of useable srom i.e. the useable storage in chips with OTP that 3714 + * implements hardware redundancy. 3715 + */ 3716 + 3717 +#define SROM4_WORDS 220 3718 + 3719 +#define SROM4_SIGN 32 3720 +#define SROM4_SIGNATURE 0x5372 3721 + 3722 +#define SROM4_BREV 33 3723 + 3724 +#define SROM4_BFL0 34 3725 +#define SROM4_BFL1 35 3726 +#define SROM4_BFL2 36 3727 +#define SROM4_BFL3 37 3728 + 3729 +#define SROM4_MACHI 38 3730 +#define SROM4_MACMID 39 3731 +#define SROM4_MACLO 40 3732 + 3733 +#define SROM4_CCODE 41 3734 +#define SROM4_REGREV 42 3735 + 3736 +#define SROM4_LEDBH10 43 3737 +#define SROM4_LEDBH32 44 3738 + 3739 +#define SROM4_LEDDC 45 3740 + 3741 +#define SROM4_AA 46 3742 +#define SROM4_AA2G_MASK 0x00ff 3743 +#define SROM4_AA2G_SHIFT 0 3744 +#define SROM4_AA5G_MASK 0xff00 3745 +#define SROM4_AA5G_SHIFT 8 3746 + 3747 +#define SROM4_AG10 47 3748 +#define SROM4_AG32 48 3749 + 3750 +#define SROM4_TXPID2G 49 3751 +#define SROM4_TXPID5G 51 3752 +#define SROM4_TXPID5GL 53 3753 +#define SROM4_TXPID5GH 55 3754 + 3755 +/* Per-path fields */ 3756 +#define MAX_PATH 4 3757 +#define SROM4_PATH0 64 3758 +#define SROM4_PATH1 87 3759 +#define SROM4_PATH2 110 3760 +#define SROM4_PATH3 133 3761 + 3762 +#define SROM4_2G_ITT_MAXP 0 3763 +#define SROM4_2G_PA 1 3764 +#define SROM4_5G_ITT_MAXP 5 3765 +#define SROM4_5GLH_MAXP 6 3766 +#define SROM4_5G_PA 7 3767 +#define SROM4_5GL_PA 11 3768 +#define SROM4_5GH_PA 15 3769 + 3770 +/* Fields in the ITT_MAXP and 5GLH_MAXP words */ 3771 +#define B2G_MAXP_MASK 0xff 3772 +#define B2G_ITT_SHIFT 8 3773 +#define B5G_MAXP_MASK 0xff 3774 +#define B5G_ITT_SHIFT 8 3775 +#define B5GH_MAXP_MASK 0xff 3776 +#define B5GL_MAXP_SHIFT 8 3777 + 3778 +/* All the miriad power offsets */ 3779 +#define SROM4_2G_CCKPO 156 3780 +#define SROM4_2G_OFDMPO 157 3781 +#define SROM4_5G_OFDMPO 159 3782 +#define SROM4_5GL_OFDMPO 161 3783 +#define SROM4_5GH_OFDMPO 163 3784 +#define SROM4_2G_MCSPO 165 3785 +#define SROM4_5G_MCSPO 173 3786 +#define SROM4_5GL_MCSPO 181 3787 +#define SROM4_5GH_MCSPO 189 3788 +#define SROM4_CCDPO 197 3789 +#define SROM4_STBCPO 198 3790 +#define SROM4_BW40PO 199 3791 +#define SROM4_BWDUPPO 200 3792 + 3793 +extern int srom_var_init(void *sbh, uint bus, void *curmap, osl_t *osh, char **vars, uint *count); 3794 + 3795 +extern int srom_read(uint bus, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf); 3796 +extern int srom_write(uint bus, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf); 3797 + 1352 3798 +#endif /* _bcmsrom_h_ */ 1353 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/bcmutils.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/bcmutils.h1354 --- linux -2.4.32/arch/mips/bcm947xx/include/bcmutils.h 1970-01-01 01:00:00.000000000 +01001355 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/bcmutils.h 2006-09-16 15:41:31.000000000 +02001356 @@ -0,0 +1, 239@@3799 diff -urN linux.old/arch/mips/bcm947xx/include/bcmutils.h linux.dev/arch/mips/bcm947xx/include/bcmutils.h 3800 --- linux.old/arch/mips/bcm947xx/include/bcmutils.h 1970-01-01 01:00:00.000000000 +0100 3801 +++ linux.dev/arch/mips/bcm947xx/include/bcmutils.h 2006-10-02 21:19:59.000000000 +0200 3802 @@ -0,0 +1,433 @@ 1357 3803 +/* 1358 3804 + * Misc useful os-independent macros and functions. 1359 3805 + * 1360 + * Copyright 200 5, Broadcom Corporation3806 + * Copyright 2006, Broadcom Corporation 1361 3807 + * All Rights Reserved. 1362 3808 + * … … 1365 3811 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 1366 3812 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 1367 + * $Id $3813 + * $Id: bcmutils.h,v 1.1.1.16 2006/04/08 06:13:39 honor Exp $ 1368 3814 + */ 1369 3815 + … … 1371 3817 +#define _bcmutils_h_ 1372 3818 + 1373 +/* ** driver-only section ***/3819 +/* ** driver-only section ** */ 1374 3820 +#ifdef BCMDRIVER 1375 +#include <osl.h>1376 3821 + 1377 3822 +#define _BCM_U 0x01 /* upper */ … … 1383 3828 +#define _BCM_X 0x40 /* hex digit */ 1384 3829 +#define _BCM_SP 0x80 /* hard space (0x20) */ 3830 + 3831 +#define GPIO_PIN_NOTDEFINED 0x20 /* Pin not defined */ 1385 3832 + 1386 3833 +extern unsigned char bcm_ctype[]; … … 1412 3859 +} 1413 3860 + 1414 +/* generic osl packet queue */ 1415 +struct pktq { 1416 + void *head; /* first packet to dequeue */ 1417 + void *tail; /* last packet to dequeue */ 1418 + uint len; /* number of queued packets */ 1419 + uint maxlen; /* maximum number of queued packets */ 1420 + bool priority; /* enqueue by packet priority */ 1421 + uint8 prio_map[MAXPRIO+1]; /* user priority to packet enqueue policy map */ 1422 +}; 1423 +#define DEFAULT_QLEN 128 1424 + 1425 +#define pktq_len(q) ((q)->len) 1426 +#define pktq_avail(q) ((q)->maxlen - (q)->len) 1427 +#define pktq_head(q) ((q)->head) 1428 +#define pktq_full(q) ((q)->len >= (q)->maxlen) 1429 +#define _pktq_pri(q, pri) ((q)->prio_map[pri]) 1430 +#define pktq_tailpri(q) ((q)->tail ? _pktq_pri(q, PKTPRIO((q)->tail)) : _pktq_pri(q, 0)) 1431 + 1432 +/* externs */ 1433 +/* packet */ 1434 +extern uint pktcopy(void *drv, void *p, uint offset, int len, uchar *buf); 1435 +extern uint pkttotlen(void *drv, void *); 1436 +extern void pktq_init(struct pktq *q, uint maxlen, const uint8 prio_map[]); 1437 +extern void pktenq(struct pktq *q, void *p, bool lifo); 1438 +extern void *pktdeq(struct pktq *q); 1439 +extern void *pktdeqtail(struct pktq *q); 3861 +struct ether_addr { 3862 + uint8 octet[6]; 3863 +} __attribute__((packed)); 3864 + 1440 3865 +/* string */ 1441 +extern uint bcm_atoi(char *s);1442 3866 +extern uchar bcm_toupper(uchar c); 1443 3867 +extern ulong bcm_strtoul(char *cp, char **endp, uint base); … … 1446 3870 +extern ulong wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen); 1447 3871 +/* ethernet address */ 1448 +extern char *bcm_ether_ntoa(char *ea, char *buf); 1449 +extern int bcm_ether_atoe(char *p, char *ea); 1450 +/* delay */ 1451 +extern void bcm_mdelay(uint ms); 3872 +extern char *bcm_ether_ntoa(struct ether_addr *ea, char *buf); 1452 3873 +/* variable access */ 1453 3874 +extern char *getvar(char *vars, char *name); 1454 3875 +extern int getintvar(char *vars, char *name); 1455 3876 +extern uint getgpiopin(char *vars, char *pin_name, uint def_pin); 3877 +#ifdef BCMPERFSTATS 3878 +extern void bcm_perf_enable(void); 3879 +extern void bcmstats(char *fmt); 3880 +extern void bcmlog(char *fmt, uint a1, uint a2); 3881 +extern void bcmdumplog(char *buf, int size); 3882 +extern int bcmdumplogent(char *buf, uint idx); 3883 +#else 3884 +#define bcm_perf_enable() 3885 +#define bcmstats(fmt) 1456 3886 +#define bcmlog(fmt, a1, a2) 1457 3887 +#define bcmdumplog(buf, size) *buf = '\0' 1458 3888 +#define bcmdumplogent(buf, idx) -1 3889 +#endif /* BCMPERFSTATS */ 3890 +extern char *bcm_nvram_vars(uint *length); 3891 +extern int bcm_nvram_cache(void *sbh); 3892 + 3893 +/* Support for sharing code across in-driver iovar implementations. 3894 + * The intent is that a driver use this structure to map iovar names 3895 + * to its (private) iovar identifiers, and the lookup function to 3896 + * find the entry. Macros are provided to map ids and get/set actions 3897 + * into a single number space for a switch statement. 3898 + */ 3899 + 3900 +/* iovar structure */ 3901 +typedef struct bcm_iovar { 3902 + const char *name; /* name for lookup and display */ 3903 + uint16 varid; /* id for switch */ 3904 + uint16 flags; /* driver-specific flag bits */ 3905 + uint16 type; /* base type of argument */ 3906 + uint16 minlen; /* min length for buffer vars */ 3907 +} bcm_iovar_t; 3908 + 3909 +/* varid definitions are per-driver, may use these get/set bits */ 3910 + 3911 +/* IOVar action bits for id mapping */ 3912 +#define IOV_GET 0 /* Get an iovar */ 3913 +#define IOV_SET 1 /* Set an iovar */ 3914 + 3915 +/* Varid to actionid mapping */ 3916 +#define IOV_GVAL(id) ((id)*2) 3917 +#define IOV_SVAL(id) (((id)*2)+IOV_SET) 3918 +#define IOV_ISSET(actionid) ((actionid & IOV_SET) == IOV_SET) 3919 + 3920 +/* flags are per-driver based on driver attributes */ 3921 + 3922 +/* Base type definitions */ 3923 +#define IOVT_VOID 0 /* no value (implictly set only) */ 3924 +#define IOVT_BOOL 1 /* any value ok (zero/nonzero) */ 3925 +#define IOVT_INT8 2 /* integer values are range-checked */ 3926 +#define IOVT_UINT8 3 /* unsigned int 8 bits */ 3927 +#define IOVT_INT16 4 /* int 16 bits */ 3928 +#define IOVT_UINT16 5 /* unsigned int 16 bits */ 3929 +#define IOVT_INT32 6 /* int 32 bits */ 3930 +#define IOVT_UINT32 7 /* unsigned int 32 bits */ 3931 +#define IOVT_BUFFER 8 /* buffer is size-checked as per minlen */ 3932 + 3933 +extern const bcm_iovar_t *bcm_iovar_lookup(const bcm_iovar_t *table, const char *name); 3934 +extern int bcm_iovar_lencheck(const bcm_iovar_t *table, void *arg, int len, bool set); 3935 + 1459 3936 +#endif /* #ifdef BCMDRIVER */ 1460 3937 + 1461 +/*** driver/apps-shared section ***/ 3938 +/* ** driver/apps-shared section ** */ 3939 + 3940 +#define BCME_STRLEN 64 /* Max string length for BCM errors */ 3941 +#define VALID_BCMERROR(e) ((e <= 0) && (e >= BCME_LAST)) 3942 + 3943 + 3944 +/* 3945 + * error codes could be added but the defined ones shouldn't be changed/deleted 3946 + * these error codes are exposed to the user code 3947 + * when ever a new error code is added to this list 3948 + * please update errorstring table with the related error string and 3949 + * update osl files with os specific errorcode map 3950 +*/ 3951 + 3952 +#define BCME_OK 0 /* Success */ 3953 +#define BCME_ERROR -1 /* Error generic */ 3954 +#define BCME_BADARG -2 /* Bad Argument */ 3955 +#define BCME_BADOPTION -3 /* Bad option */ 3956 +#define BCME_NOTUP -4 /* Not up */ 3957 +#define BCME_NOTDOWN -5 /* Not down */ 3958 +#define BCME_NOTAP -6 /* Not AP */ 3959 +#define BCME_NOTSTA -7 /* Not STA */ 3960 +#define BCME_BADKEYIDX -8 /* BAD Key Index */ 3961 +#define BCME_RADIOOFF -9 /* Radio Off */ 3962 +#define BCME_NOTBANDLOCKED -10 /* Not band locked */ 3963 +#define BCME_NOCLK -11 /* No Clock */ 3964 +#define BCME_BADRATESET -12 /* BAD Rate valueset */ 3965 +#define BCME_BADBAND -13 /* BAD Band */ 3966 +#define BCME_BUFTOOSHORT -14 /* Buffer too short */ 3967 +#define BCME_BUFTOOLONG -15 /* Buffer too long */ 3968 +#define BCME_BUSY -16 /* Busy */ 3969 +#define BCME_NOTASSOCIATED -17 /* Not Associated */ 3970 +#define BCME_BADSSIDLEN -18 /* Bad SSID len */ 3971 +#define BCME_OUTOFRANGECHAN -19 /* Out of Range Channel */ 3972 +#define BCME_BADCHAN -20 /* Bad Channel */ 3973 +#define BCME_BADADDR -21 /* Bad Address */ 3974 +#define BCME_NORESOURCE -22 /* Not Enough Resources */ 3975 +#define BCME_UNSUPPORTED -23 /* Unsupported */ 3976 +#define BCME_BADLEN -24 /* Bad length */ 3977 +#define BCME_NOTREADY -25 /* Not Ready */ 3978 +#define BCME_EPERM -26 /* Not Permitted */ 3979 +#define BCME_NOMEM -27 /* No Memory */ 3980 +#define BCME_ASSOCIATED -28 /* Associated */ 3981 +#define BCME_RANGE -29 /* Not In Range */ 3982 +#define BCME_NOTFOUND -30 /* Not Found */ 3983 +#define BCME_WME_NOT_ENABLED -31 /* WME Not Enabled */ 3984 +#define BCME_TSPEC_NOTFOUND -32 /* TSPEC Not Found */ 3985 +#define BCME_ACM_NOTSUPPORTED -33 /* ACM Not Supported */ 3986 +#define BCME_NOT_WME_ASSOCIATION -34 /* Not WME Association */ 3987 +#define BCME_SDIO_ERROR -35 /* SDIO Bus Error */ 3988 +#define BCME_DONGLE_DOWN -36 /* Dongle Not Accessible */ 3989 +#define BCME_LAST BCME_DONGLE_DOWN 3990 + 3991 +/* These are collection of BCME Error strings */ 3992 +#define BCMERRSTRINGTABLE { \ 3993 + "OK", \ 3994 + "Undefined error", \ 3995 + "Bad Argument", \ 3996 + "Bad Option", \ 3997 + "Not up", \ 3998 + "Not down", \ 3999 + "Not AP", \ 4000 + "Not STA", \ 4001 + "Bad Key Index", \ 4002 + "Radio Off", \ 4003 + "Not band locked", \ 4004 + "No clock", \ 4005 + "Bad Rate valueset", \ 4006 + "Bad Band", \ 4007 + "Buffer too short", \ 4008 + "Buffer too long", \ 4009 + "Busy", \ 4010 + "Not Associated", \ 4011 + "Bad SSID len", \ 4012 + "Out of Range Channel", \ 4013 + "Bad Channel", \ 4014 + "Bad Address", \ 4015 + "Not Enough Resources", \ 4016 + "Unsupported", \ 4017 + "Bad length", \ 4018 + "Not Ready", \ 4019 + "Not Permitted", \ 4020 + "No Memory", \ 4021 + "Associated", \ 4022 + "Not In Range", \ 4023 + "Not Found", \ 4024 + "WME Not Enabled", \ 4025 + "TSPEC Not Found", \ 4026 + "ACM Not Supported", \ 4027 + "Not WME Association", \ 4028 + "SDIO Bus Error", \ 4029 + "Dongle Not Accessible" \ 4030 +} 4031 + 4032 +#ifndef ABS 4033 +#define ABS(a) (((a) < 0)?-(a):(a)) 4034 +#endif /* ABS */ 4035 + 1462 4036 +#ifndef MIN 1463 +#define MIN(a, b) (((a) <(b))?(a):(b))1464 +#endif 4037 +#define MIN(a, b) (((a) < (b))?(a):(b)) 4038 +#endif /* MIN */ 1465 4039 + 1466 4040 +#ifndef MAX 1467 +#define MAX(a, b) (((a) >(b))?(a):(b))1468 +#endif 4041 +#define MAX(a, b) (((a) > (b))?(a):(b)) 4042 +#endif /* MAX */ 1469 4043 + 1470 4044 +#define CEIL(x, y) (((x) + ((y)-1)) / (y)) 1471 4045 +#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y)) 1472 4046 +#define ISALIGNED(a, x) (((a) & ((x)-1)) == 0) 1473 +#define ISPOWEROF2(x) ((((x)-1)&(x))==0) 4047 +#define ISPOWEROF2(x) ((((x)-1)&(x)) == 0) 4048 +#define VALID_MASK(mask) !((mask) & ((mask) + 1)) 1474 4049 +#define OFFSETOF(type, member) ((uint)(uintptr)&((type *)0)->member) 1475 4050 +#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) … … 1477 4052 +/* bit map related macros */ 1478 4053 +#ifndef setbit 4054 +#ifndef NBBY /* the BSD family defines NBBY */ 1479 4055 +#define NBBY 8 /* 8 bits per byte */ 1480 +#define setbit(a,i) (((uint8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY)) 1481 +#define clrbit(a,i) (((uint8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 1482 +#define isset(a,i) (((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) 1483 +#define isclr(a,i) ((((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 1484 +#endif 1485 + 1486 +#define NBITS(type) (sizeof (type) * 8) 4056 +#endif /* #ifndef NBBY */ 4057 +#define setbit(a, i) (((uint8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY)) 4058 +#define clrbit(a, i) (((uint8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 4059 +#define isset(a, i) (((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) 4060 +#define isclr(a, i) ((((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 4061 +#endif /* setbit */ 4062 + 4063 +#define NBITS(type) (sizeof(type) * 8) 4064 +#define NBITVAL(nbits) (1 << (nbits)) 4065 +#define MAXBITVAL(nbits) ((1 << (nbits)) - 1) 4066 +#define NBITMASK(nbits) MAXBITVAL(nbits) 4067 +#define MAXNBVAL(nbyte) MAXBITVAL((nbyte) * 8) 4068 + 4069 +/* basic mux operation - can be optimized on several architectures */ 4070 +#define MUX(pred, true, false) ((pred) ? (true) : (false)) 4071 + 4072 +/* modulo inc/dec - assumes x E [0, bound - 1] */ 4073 +#define MODDEC(x, bound) MUX((x) == 0, (bound) - 1, (x) - 1) 4074 +#define MODINC(x, bound) MUX((x) == (bound) - 1, 0, (x) + 1) 4075 + 4076 +/* modulo inc/dec, bound = 2^k */ 4077 +#define MODDEC_POW2(x, bound) (((x) - 1) & ((bound) - 1)) 4078 +#define MODINC_POW2(x, bound) (((x) + 1) & ((bound) - 1)) 4079 + 4080 +/* modulo add/sub - assumes x, y E [0, bound - 1] */ 4081 +#define MODADD(x, y, bound) \ 4082 + MUX((x) + (y) >= (bound), (x) + (y) - (bound), (x) + (y)) 4083 +#define MODSUB(x, y, bound) \ 4084 + MUX(((int)(x)) - ((int)(y)) < 0, (x) - (y) + (bound), (x) - (y)) 4085 + 4086 +/* module add/sub, bound = 2^k */ 4087 +#define MODADD_POW2(x, y, bound) (((x) + (y)) & ((bound) - 1)) 4088 +#define MODSUB_POW2(x, y, bound) (((x) - (y)) & ((bound) - 1)) 1487 4089 + 1488 4090 +/* crc defines */ … … 1508 4110 + 1509 4111 +/* Check that bcm_tlv_t fits into the given buflen */ 1510 +#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && ( buflen) >= 2 + (elt)->len)4112 +#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (int)(buflen) >= (int)(2 + (elt)->len)) 1511 4113 + 1512 4114 +/* buffer length for ethernet address from bcm_ether_ntoa() */ 1513 +#define ETHER_ADDR_STR_LEN 18 4115 +#define ETHER_ADDR_STR_LEN 18 /* 18-bytes of Ethernet address buffer length */ 1514 4116 + 1515 4117 +/* unaligned load and store macros */ … … 1573 4175 +} 1574 4176 + 1575 +#endif 4177 +#endif /* IL_BIGENDIAN */ 1576 4178 + 1577 4179 +/* externs */ … … 1581 4183 +extern uint32 hndcrc32(uint8 *p, uint nbytes, uint32 crc); 1582 4184 +/* format/print */ 4185 +extern void printfbig(char *buf); 4186 + 1583 4187 +/* IE parsing */ 1584 4188 +extern bcm_tlv_t *bcm_next_tlv(bcm_tlv_t *elt, int *buflen); 1585 4189 +extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key); 1586 4190 +extern bcm_tlv_t *bcm_parse_ordered_tlvs(void *buf, int buflen, uint key); 4191 + 4192 +/* bcmerror */ 4193 +extern const char *bcmerrorstr(int bcmerror); 1587 4194 + 1588 4195 +/* multi-bool data type: set of bools, mbool is true if any is set */ … … 1593 4200 +#define mboolmaskset(mb, mask, val) ((mb) = (((mb) & ~(mask)) | (val))) 1594 4201 + 4202 +/* power conversion */ 4203 +extern uint16 bcm_qdbm_to_mw(uint8 qdbm); 4204 +extern uint8 bcm_mw_to_qdbm(uint16 mw); 4205 + 4206 +/* generic datastruct to help dump routines */ 4207 +struct fielddesc { 4208 + char *nameandfmt; 4209 + uint32 offset; 4210 + uint32 len; 4211 +}; 4212 + 4213 +/* Buffer structure for collecting string-formatted data 4214 +* using bcm_bprintf() API. 4215 +* Use bcm_binit() to initialize before use 4216 +*/ 4217 +struct bcmstrbuf 4218 +{ 4219 + char *buf; /* pointer to current position in origbuf */ 4220 + uint size; /* current (residual) size in bytes */ 4221 + char *origbuf; /* unmodified pointer to orignal buffer */ 4222 + uint origsize; /* unmodified orignal buffer size in bytes */ 4223 +}; 4224 + 4225 +extern void bcm_binit(struct bcmstrbuf *b, char *buf, uint size); 4226 +extern int bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...); 4227 + 4228 +typedef uint32 (*readreg_rtn)(void *arg0, void *arg1, uint32 offset); 4229 +extern uint bcmdumpfields(readreg_rtn func_ptr, void *arg0, void *arg1, struct fielddesc *str, 4230 + char *buf, uint32 bufsize); 4231 + 4232 +extern uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint len); 4233 +extern uint bcm_bitcount(uint8 *bitmap, uint bytelength); 4234 + 1595 4235 +#endif /* _bcmutils_h_ */ 1596 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/hnddma.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/hnddma.h1597 --- linux -2.4.32/arch/mips/bcm947xx/include/hnddma.h 1970-01-01 01:00:00.000000000 +01001598 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/hnddma.h 2006-09-16 15:41:31.000000000 +02001599 @@ -0,0 +1, 184@@4236 diff -urN linux.old/arch/mips/bcm947xx/include/hndcpu.h linux.dev/arch/mips/bcm947xx/include/hndcpu.h 4237 --- linux.old/arch/mips/bcm947xx/include/hndcpu.h 1970-01-01 01:00:00.000000000 +0100 4238 +++ linux.dev/arch/mips/bcm947xx/include/hndcpu.h 2006-10-02 21:19:59.000000000 +0200 4239 @@ -0,0 +1,28 @@ 1600 4240 +/* 1601 + * Generic Broadcom Home Networking Division (HND) DMA engine definitions. 1602 + * This supports the following chips: BCM42xx, 44xx, 47xx . 4241 + * HND SiliconBackplane MIPS/ARM cores software interface. 1603 4242 + * 1604 + * Copyright 2005, Broadcom Corporation 1605 + * All Rights Reserved. 1606 + * 1607 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 1608 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 1609 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 1610 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 1611 + * $Id$ 1612 + */ 1613 + 1614 +#ifndef _hnddma_h_ 1615 +#define _hnddma_h_ 1616 + 1617 +/* 1618 + * Each DMA processor consists of a transmit channel and a receive channel. 1619 + */ 1620 +typedef volatile struct { 1621 + /* transmit channel */ 1622 + uint32 xmtcontrol; /* enable, et al */ 1623 + uint32 xmtaddr; /* descriptor ring base address (4K aligned) */ 1624 + uint32 xmtptr; /* last descriptor posted to chip */ 1625 + uint32 xmtstatus; /* current active descriptor, et al */ 1626 + 1627 + /* receive channel */ 1628 + uint32 rcvcontrol; /* enable, et al */ 1629 + uint32 rcvaddr; /* descriptor ring base address (4K aligned) */ 1630 + uint32 rcvptr; /* last descriptor posted to chip */ 1631 + uint32 rcvstatus; /* current active descriptor, et al */ 1632 +} dmaregs_t; 1633 + 1634 +typedef volatile struct { 1635 + /* diag access */ 1636 + uint32 fifoaddr; /* diag address */ 1637 + uint32 fifodatalow; /* low 32bits of data */ 1638 + uint32 fifodatahigh; /* high 32bits of data */ 1639 + uint32 pad; /* reserved */ 1640 +} dmafifo_t; 1641 + 1642 +/* transmit channel control */ 1643 +#define XC_XE ((uint32)1 << 0) /* transmit enable */ 1644 +#define XC_SE ((uint32)1 << 1) /* transmit suspend request */ 1645 +#define XC_LE ((uint32)1 << 2) /* loopback enable */ 1646 +#define XC_FL ((uint32)1 << 4) /* flush request */ 1647 + 1648 +/* transmit descriptor table pointer */ 1649 +#define XP_LD_MASK 0xfff /* last valid descriptor */ 1650 + 1651 +/* transmit channel status */ 1652 +#define XS_CD_MASK 0x0fff /* current descriptor pointer */ 1653 +#define XS_XS_MASK 0xf000 /* transmit state */ 1654 +#define XS_XS_SHIFT 12 1655 +#define XS_XS_DISABLED 0x0000 /* disabled */ 1656 +#define XS_XS_ACTIVE 0x1000 /* active */ 1657 +#define XS_XS_IDLE 0x2000 /* idle wait */ 1658 +#define XS_XS_STOPPED 0x3000 /* stopped */ 1659 +#define XS_XS_SUSP 0x4000 /* suspend pending */ 1660 +#define XS_XE_MASK 0xf0000 /* transmit errors */ 1661 +#define XS_XE_SHIFT 16 1662 +#define XS_XE_NOERR 0x00000 /* no error */ 1663 +#define XS_XE_DPE 0x10000 /* descriptor protocol error */ 1664 +#define XS_XE_DFU 0x20000 /* data fifo underrun */ 1665 +#define XS_XE_BEBR 0x30000 /* bus error on buffer read */ 1666 +#define XS_XE_BEDA 0x40000 /* bus error on descriptor access */ 1667 +#define XS_AD_MASK 0xfff00000 /* active descriptor */ 1668 +#define XS_AD_SHIFT 20 1669 + 1670 +/* receive channel control */ 1671 +#define RC_RE ((uint32)1 << 0) /* receive enable */ 1672 +#define RC_RO_MASK 0xfe /* receive frame offset */ 1673 +#define RC_RO_SHIFT 1 1674 +#define RC_FM ((uint32)1 << 8) /* direct fifo receive (pio) mode */ 1675 + 1676 +/* receive descriptor table pointer */ 1677 +#define RP_LD_MASK 0xfff /* last valid descriptor */ 1678 + 1679 +/* receive channel status */ 1680 +#define RS_CD_MASK 0x0fff /* current descriptor pointer */ 1681 +#define RS_RS_MASK 0xf000 /* receive state */ 1682 +#define RS_RS_SHIFT 12 1683 +#define RS_RS_DISABLED 0x0000 /* disabled */ 1684 +#define RS_RS_ACTIVE 0x1000 /* active */ 1685 +#define RS_RS_IDLE 0x2000 /* idle wait */ 1686 +#define RS_RS_STOPPED 0x3000 /* reserved */ 1687 +#define RS_RE_MASK 0xf0000 /* receive errors */ 1688 +#define RS_RE_SHIFT 16 1689 +#define RS_RE_NOERR 0x00000 /* no error */ 1690 +#define RS_RE_DPE 0x10000 /* descriptor protocol error */ 1691 +#define RS_RE_DFO 0x20000 /* data fifo overflow */ 1692 +#define RS_RE_BEBW 0x30000 /* bus error on buffer write */ 1693 +#define RS_RE_BEDA 0x40000 /* bus error on descriptor access */ 1694 +#define RS_AD_MASK 0xfff00000 /* active descriptor */ 1695 +#define RS_AD_SHIFT 20 1696 + 1697 +/* fifoaddr */ 1698 +#define FA_OFF_MASK 0xffff /* offset */ 1699 +#define FA_SEL_MASK 0xf0000 /* select */ 1700 +#define FA_SEL_SHIFT 16 1701 +#define FA_SEL_XDD 0x00000 /* transmit dma data */ 1702 +#define FA_SEL_XDP 0x10000 /* transmit dma pointers */ 1703 +#define FA_SEL_RDD 0x40000 /* receive dma data */ 1704 +#define FA_SEL_RDP 0x50000 /* receive dma pointers */ 1705 +#define FA_SEL_XFD 0x80000 /* transmit fifo data */ 1706 +#define FA_SEL_XFP 0x90000 /* transmit fifo pointers */ 1707 +#define FA_SEL_RFD 0xc0000 /* receive fifo data */ 1708 +#define FA_SEL_RFP 0xd0000 /* receive fifo pointers */ 1709 + 1710 +/* 1711 + * DMA Descriptor 1712 + * Descriptors are only read by the hardware, never written back. 1713 + */ 1714 +typedef volatile struct { 1715 + uint32 ctrl; /* misc control bits & bufcount */ 1716 + uint32 addr; /* data buffer address */ 1717 +} dmadd_t; 1718 + 1719 +/* 1720 + * Each descriptor ring must be 4096byte aligned 1721 + * and fit within a single 4096byte page. 1722 + */ 1723 +#define DMAMAXRINGSZ 4096 1724 +#define DMARINGALIGN 4096 1725 + 1726 +/* control flags */ 1727 +#define CTRL_BC_MASK 0x1fff /* buffer byte count */ 1728 +#define CTRL_EOT ((uint32)1 << 28) /* end of descriptor table */ 1729 +#define CTRL_IOC ((uint32)1 << 29) /* interrupt on completion */ 1730 +#define CTRL_EOF ((uint32)1 << 30) /* end of frame */ 1731 +#define CTRL_SOF ((uint32)1 << 31) /* start of frame */ 1732 + 1733 +/* control flags in the range [27:20] are core-specific and not defined here */ 1734 +#define CTRL_CORE_MASK 0x0ff00000 1735 + 1736 +/* export structure */ 1737 +typedef volatile struct { 1738 + /* rx error counters */ 1739 + uint rxgiants; /* rx giant frames */ 1740 + uint rxnobuf; /* rx out of dma descriptors */ 1741 + /* tx error counters */ 1742 + uint txnobuf; /* tx out of dma descriptors */ 1743 +} hnddma_t; 1744 + 1745 +#ifndef di_t 1746 +#define di_t void 1747 +#endif 1748 + 1749 +/* externs */ 1750 +extern void * dma_attach(void *drv, void *dev, char *name, dmaregs_t *dmaregs, 1751 + uint ntxd, uint nrxd, uint rxbufsize, uint nrxpost, uint rxoffset, 1752 + uint ddoffset, uint dataoffset, uint *msg_level); 1753 +extern void dma_detach(di_t *di); 1754 +extern void dma_txreset(di_t *di); 1755 +extern void dma_rxreset(di_t *di); 1756 +extern void dma_txinit(di_t *di); 1757 +extern bool dma_txenabled(di_t *di); 1758 +extern void dma_rxinit(di_t *di); 1759 +extern void dma_rxenable(di_t *di); 1760 +extern bool dma_rxenabled(di_t *di); 1761 +extern void dma_txsuspend(di_t *di); 1762 +extern void dma_txresume(di_t *di); 1763 +extern bool dma_txsuspended(di_t *di); 1764 +extern bool dma_txstopped(di_t *di); 1765 +extern bool dma_rxstopped(di_t *di); 1766 +extern int dma_txfast(di_t *di, void *p, uint32 coreflags); 1767 +extern int dma_tx(di_t *di, void *p, uint32 coreflags); 1768 +extern void dma_fifoloopbackenable(di_t *di); 1769 +extern void *dma_rx(di_t *di); 1770 +extern void dma_rxfill(di_t *di); 1771 +extern void dma_txreclaim(di_t *di, bool forceall); 1772 +extern void dma_rxreclaim(di_t *di); 1773 +extern uintptr dma_getvar(di_t *di, char *name); 1774 +extern void *dma_getnexttxp(di_t *di, bool forceall); 1775 +extern void *dma_peeknexttxp(di_t *di); 1776 +extern void *dma_getnextrxp(di_t *di, bool forceall); 1777 +extern void dma_txblock(di_t *di); 1778 +extern void dma_txunblock(di_t *di); 1779 +extern uint dma_txactive(di_t *di); 1780 +extern void dma_txrotate(di_t *di); 1781 + 1782 + 1783 +#endif /* _hnddma_h_ */ 1784 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/hndmips.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/hndmips.h 1785 --- linux-2.4.32/arch/mips/bcm947xx/include/hndmips.h 1970-01-01 01:00:00.000000000 +0100 1786 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/include/hndmips.h 2006-09-16 15:41:31.000000000 +0200 1787 @@ -0,0 +1,16 @@ 1788 +/* 1789 + * Alternate include file for HND sbmips.h since CFE also ships with 1790 + * a sbmips.h. 1791 + * 1792 + * Copyright 2005, Broadcom Corporation 4243 + * Copyright 2006, Broadcom Corporation 1793 4244 + * All Rights Reserved. 1794 4245 + * … … 1798 4249 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 1799 4250 + * 1800 + * $Id $4251 + * $Id: hndcpu.h,v 1.1.1.1 2006/02/27 03:43:16 honor Exp $ 1801 4252 + */ 1802 4253 + 1803 +#include "sbmips.h" 1804 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/linux_osl.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/linux_osl.h 1805 --- linux-2.4.32/arch/mips/bcm947xx/include/linux_osl.h 1970-01-01 01:00:00.000000000 +0100 1806 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/include/linux_osl.h 2006-09-16 15:41:31.000000000 +0200 1807 @@ -0,0 +1,341 @@ 4254 +#ifndef _hndcpu_h_ 4255 +#define _hndcpu_h_ 4256 + 4257 +#if defined(mips) 4258 +#include <hndmips.h> 4259 +#elif defined(__ARM_ARCH_4T__) 4260 +#include <hndarm.h> 4261 +#endif 4262 + 4263 +extern uint sb_irq(sb_t *sbh); 4264 +extern uint32 sb_cpu_clock(sb_t *sbh); 4265 +extern void sb_cpu_wait(void); 4266 + 4267 +#endif /* _hndcpu_h_ */ 4268 diff -urN linux.old/arch/mips/bcm947xx/include/hndmips.h linux.dev/arch/mips/bcm947xx/include/hndmips.h 4269 --- linux.old/arch/mips/bcm947xx/include/hndmips.h 1970-01-01 01:00:00.000000000 +0100 4270 +++ linux.dev/arch/mips/bcm947xx/include/hndmips.h 2006-10-02 21:19:59.000000000 +0200 4271 @@ -0,0 +1,45 @@ 1808 4272 +/* 1809 + * Linux OS Independent Layer4273 + * HND SiliconBackplane MIPS core software interface. 1810 4274 + * 1811 + * Copyright 200 5, Broadcom Corporation4275 + * Copyright 2006, Broadcom Corporation 1812 4276 + * All Rights Reserved. 1813 4277 + * … … 1817 4281 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 1818 4282 + * 1819 + * $Id $4283 + * $Id: hndmips.h,v 1.1.1.8 2006/02/27 03:43:16 honor Exp $ 1820 4284 + */ 1821 4285 + 1822 +#ifndef _linux_osl_h_ 1823 +#define _linux_osl_h_ 1824 + 1825 +#include <typedefs.h> 1826 + 1827 +/* use current 2.4.x calling conventions */ 1828 +#include <linuxver.h> 1829 + 1830 +/* assert and panic */ 1831 +#define ASSERT(exp) do {} while (0) 1832 + 1833 +/* PCMCIA attribute space access macros */ 1834 +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) 1835 +struct pcmcia_dev { 1836 + dev_link_t link; /* PCMCIA device pointer */ 1837 + dev_node_t node; /* PCMCIA node structure */ 1838 + void *base; /* Mapped attribute memory window */ 1839 + size_t size; /* Size of window */ 1840 + void *drv; /* Driver data */ 1841 +}; 1842 +#endif 1843 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) \ 1844 + osl_pcmcia_read_attr((osh), (offset), (buf), (size)) 1845 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) \ 1846 + osl_pcmcia_write_attr((osh), (offset), (buf), (size)) 1847 +extern void osl_pcmcia_read_attr(void *osh, uint offset, void *buf, int size); 1848 +extern void osl_pcmcia_write_attr(void *osh, uint offset, void *buf, int size); 1849 + 1850 +/* PCI configuration space access macros */ 1851 +#define OSL_PCI_READ_CONFIG(osh, offset, size) \ 1852 + osl_pci_read_config((osh), (offset), (size)) 1853 +#define OSL_PCI_WRITE_CONFIG(osh, offset, size, val) \ 1854 + osl_pci_write_config((osh), (offset), (size), (val)) 1855 +extern uint32 osl_pci_read_config(void *osh, uint size, uint offset); 1856 +extern void osl_pci_write_config(void *osh, uint offset, uint size, uint val); 1857 + 1858 +/* OSL initialization */ 1859 +extern void *osl_attach(void *pdev); 1860 +extern void osl_detach(void *osh); 1861 + 1862 +/* host/bus architecture-specific byte swap */ 1863 +#define BUS_SWAP32(v) (v) 1864 + 1865 +/* general purpose memory allocation */ 1866 + 1867 +#if defined(BCMDBG_MEM) 1868 + 1869 +#define MALLOC(osh, size) osl_debug_malloc((osh), (size), __LINE__, __FILE__) 1870 +#define MFREE(osh, addr, size) osl_debug_mfree((osh), (addr), (size), __LINE__, __FILE__) 1871 +#define MALLOCED(osh) osl_malloced((osh)) 1872 +#define MALLOC_DUMP(osh, buf, sz) osl_debug_memdump((osh), (buf), (sz)) 1873 +extern void *osl_debug_malloc(void *osh, uint size, int line, char* file); 1874 +extern void osl_debug_mfree(void *osh, void *addr, uint size, int line, char* file); 1875 +extern char *osl_debug_memdump(void *osh, char *buf, uint sz); 1876 + 1877 +#else 1878 + 1879 +#define MALLOC(osh, size) osl_malloc((osh), (size)) 1880 +#define MFREE(osh, addr, size) osl_mfree((osh), (addr), (size)) 1881 +#define MALLOCED(osh) osl_malloced((osh)) 1882 + 1883 +#endif /* BCMDBG_MEM */ 1884 + 1885 +#define MALLOC_FAILED(osh) osl_malloc_failed((osh)) 1886 + 1887 +extern void *osl_malloc(void *osh, uint size); 1888 +extern void osl_mfree(void *osh, void *addr, uint size); 1889 +extern uint osl_malloced(void *osh); 1890 +extern uint osl_malloc_failed(void *osh); 1891 + 1892 +/* allocate/free shared (dma-able) consistent memory */ 1893 +#define DMA_CONSISTENT_ALIGN PAGE_SIZE 1894 +#define DMA_ALLOC_CONSISTENT(osh, size, pap) \ 1895 + osl_dma_alloc_consistent((osh), (size), (pap)) 1896 +#define DMA_FREE_CONSISTENT(osh, va, size, pa) \ 1897 + osl_dma_free_consistent((osh), (void*)(va), (size), (pa)) 1898 +extern void *osl_dma_alloc_consistent(void *osh, uint size, ulong *pap); 1899 +extern void osl_dma_free_consistent(void *osh, void *va, uint size, ulong pa); 1900 + 1901 +/* map/unmap direction */ 1902 +#define DMA_TX 1 1903 +#define DMA_RX 2 1904 + 1905 +/* map/unmap shared (dma-able) memory */ 1906 +#define DMA_MAP(osh, va, size, direction, p) \ 1907 + osl_dma_map((osh), (va), (size), (direction)) 1908 +#define DMA_UNMAP(osh, pa, size, direction, p) \ 1909 + osl_dma_unmap((osh), (pa), (size), (direction)) 1910 +extern uint osl_dma_map(void *osh, void *va, uint size, int direction); 1911 +extern void osl_dma_unmap(void *osh, uint pa, uint size, int direction); 1912 + 1913 +/* register access macros */ 1914 +#if defined(BCMJTAG) 1915 +struct bcmjtag_info; 1916 +extern uint32 bcmjtag_read(struct bcmjtag_info *ejh, uint32 addr, uint size); 1917 +extern void bcmjtag_write(struct bcmjtag_info *ejh, uint32 addr, uint32 val, uint size); 1918 +#define R_REG(r) bcmjtag_read(NULL, (uint32)(r), sizeof (*(r))) 1919 +#define W_REG(r, v) bcmjtag_write(NULL, (uint32)(r), (uint32)(v), sizeof (*(r))) 1920 +#endif 1921 + 4286 +#ifndef _hndmips_h_ 4287 +#define _hndmips_h_ 4288 + 4289 +extern void sb_mips_init(sb_t *sbh, uint shirq_map_base); 4290 +extern bool sb_mips_setclock(sb_t *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock); 4291 +extern void enable_pfc(uint32 mode); 4292 +extern uint32 sb_memc_get_ncdl(sb_t *sbh); 4293 + 4294 +#if defined(BCMPERFSTATS) 4295 +/* enable counting - exclusive version. Only one set of counters allowed at a time */ 4296 +extern void hndmips_perf_instrcount_enable(void); 4297 +extern void hndmips_perf_icachecount_enable(void); 4298 +extern void hndmips_perf_dcachecount_enable(void); 4299 +/* start and stop counting */ 4300 +#define hndmips_perf_start01() \ 4301 + MTC0(C0_PERFORMANCE, 4, MFC0(C0_PERFORMANCE, 4) | 0x80008000) 4302 +#define hndmips_perf_stop01() \ 4303 + MTC0(C0_PERFORMANCE, 4, MFC0(C0_PERFORMANCE, 4) & ~0x80008000) 4304 +/* retrieve coutners - counters *decrement* */ 4305 +#define hndmips_perf_read0() -(long)(MFC0(C0_PERFORMANCE, 0)) 4306 +#define hndmips_perf_read1() -(long)(MFC0(C0_PERFORMANCE, 1)) 4307 +#define hndmips_perf_read2() -(long)(MFC0(C0_PERFORMANCE, 2)) 4308 +/* enable counting - modular version. Each counters can be enabled separately. */ 4309 +extern void hndmips_perf_icache_hit_enable(void); 4310 +extern void hndmips_perf_icache_miss_enable(void); 4311 +extern uint32 hndmips_perf_read_instrcount(void); 4312 +extern uint32 hndmips_perf_read_cache_miss(void); 4313 +extern uint32 hndmips_perf_read_cache_hit(void); 4314 +#endif /* defined(BCMINTERNAL) || defined (BCMPERFSTATS) */ 4315 + 4316 +#endif /* _hndmips_h_ */ 4317 diff -urN linux.old/arch/mips/bcm947xx/include/hndpci.h linux.dev/arch/mips/bcm947xx/include/hndpci.h 4318 --- linux.old/arch/mips/bcm947xx/include/hndpci.h 1970-01-01 01:00:00.000000000 +0100 4319 +++ linux.dev/arch/mips/bcm947xx/include/hndpci.h 2006-10-02 21:19:59.000000000 +0200 4320 @@ -0,0 +1,30 @@ 1922 4321 +/* 1923 + * BINOSL selects the slightly slower function-call-based binary compatible osl. 1924 + * Macros expand to calls to functions defined in linux_osl.c . 1925 + */ 1926 +#ifndef BINOSL 1927 + 1928 +/* string library, kernel mode */ 1929 +#define printf(fmt, args...) printk(fmt, ## args) 1930 +#include <linux/kernel.h> 1931 +#include <linux/string.h> 1932 + 1933 +/* register access macros */ 1934 +#if !defined(BCMJTAG) 1935 +#define R_REG(r) ( \ 1936 + sizeof(*(r)) == sizeof(uint8) ? readb((volatile uint8*)(r)) : \ 1937 + sizeof(*(r)) == sizeof(uint16) ? readw((volatile uint16*)(r)) : \ 1938 + readl((volatile uint32*)(r)) \ 1939 +) 1940 +#define W_REG(r, v) do { \ 1941 + switch (sizeof(*(r))) { \ 1942 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)(r)); break; \ 1943 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)(r)); break; \ 1944 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \ 1945 + } \ 1946 +} while (0) 1947 +#endif 1948 + 1949 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v)) 1950 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v)) 1951 + 1952 +/* bcopy, bcmp, and bzero */ 1953 +#define bcopy(src, dst, len) memcpy((dst), (src), (len)) 1954 +#define bcmp(b1, b2, len) memcmp((b1), (b2), (len)) 1955 +#define bzero(b, len) memset((b), '\0', (len)) 1956 + 1957 +/* uncached virtual address */ 1958 +#ifdef mips 1959 +#define OSL_UNCACHED(va) KSEG1ADDR((va)) 1960 +#include <asm/addrspace.h> 1961 +#else 1962 +#define OSL_UNCACHED(va) (va) 1963 +#endif 1964 + 1965 +/* get processor cycle count */ 1966 +#if defined(mips) 1967 +#define OSL_GETCYCLES(x) ((x) = read_c0_count() * 2) 1968 +#elif defined(__i386__) 1969 +#define OSL_GETCYCLES(x) rdtscl((x)) 1970 +#else 1971 +#define OSL_GETCYCLES(x) ((x) = 0) 1972 +#endif 1973 + 1974 +/* dereference an address that may cause a bus exception */ 1975 +#ifdef mips 1976 +#if defined(MODULE) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,17)) 1977 +#define BUSPROBE(val, addr) panic("get_dbe() will not fixup a bus exception when compiled into a module") 1978 +#else 1979 +#define BUSPROBE(val, addr) get_dbe((val), (addr)) 1980 +#include <asm/paccess.h> 1981 +#endif 1982 +#else 1983 +#define BUSPROBE(val, addr) ({ (val) = R_REG((addr)); 0; }) 1984 +#endif 1985 + 1986 +/* map/unmap physical to virtual I/O */ 1987 +#define REG_MAP(pa, size) ioremap_nocache((unsigned long)(pa), (unsigned long)(size)) 1988 +#define REG_UNMAP(va) iounmap((void *)(va)) 1989 + 1990 +/* microsecond delay */ 1991 +#define OSL_DELAY(usec) udelay(usec) 1992 +#include <linux/delay.h> 1993 + 1994 +/* shared (dma-able) memory access macros */ 1995 +#define R_SM(r) *(r) 1996 +#define W_SM(r, v) (*(r) = (v)) 1997 +#define BZERO_SM(r, len) memset((r), '\0', (len)) 1998 + 1999 +/* packet primitives */ 2000 +#define PKTGET(drv, len, send) osl_pktget((drv), (len), (send)) 2001 +#define PKTFREE(drv, skb, send) osl_pktfree((skb)) 2002 +#define PKTDATA(drv, skb) (((struct sk_buff*)(skb))->data) 2003 +#define PKTLEN(drv, skb) (((struct sk_buff*)(skb))->len) 2004 +#define PKTHEADROOM(drv, skb) (PKTDATA(drv,skb)-(((struct sk_buff*)(skb))->head)) 2005 +#define PKTTAILROOM(drv, skb) ((((struct sk_buff*)(skb))->end)-(((struct sk_buff*)(skb))->tail)) 2006 +#define PKTNEXT(drv, skb) (((struct sk_buff*)(skb))->next) 2007 +#define PKTSETNEXT(skb, x) (((struct sk_buff*)(skb))->next = (struct sk_buff*)(x)) 2008 +#define PKTSETLEN(drv, skb, len) __skb_trim((struct sk_buff*)(skb), (len)) 2009 +#define PKTPUSH(drv, skb, bytes) skb_push((struct sk_buff*)(skb), (bytes)) 2010 +#define PKTPULL(drv, skb, bytes) skb_pull((struct sk_buff*)(skb), (bytes)) 2011 +#define PKTDUP(drv, skb) skb_clone((struct sk_buff*)(skb), GFP_ATOMIC) 2012 +#define PKTCOOKIE(skb) ((void*)((struct sk_buff*)(skb))->csum) 2013 +#define PKTSETCOOKIE(skb, x) (((struct sk_buff*)(skb))->csum = (uint)(x)) 2014 +#define PKTLINK(skb) (((struct sk_buff*)(skb))->prev) 2015 +#define PKTSETLINK(skb, x) (((struct sk_buff*)(skb))->prev = (struct sk_buff*)(x)) 2016 +#define PKTPRIO(skb) (((struct sk_buff*)(skb))->priority) 2017 +#define PKTSETPRIO(skb, x) (((struct sk_buff*)(skb))->priority = (x)) 2018 +extern void *osl_pktget(void *drv, uint len, bool send); 2019 +extern void osl_pktfree(void *skb); 2020 + 2021 +#else /* BINOSL */ 2022 + 2023 +/* string library */ 2024 +#ifndef LINUX_OSL 2025 +#undef printf 2026 +#define printf(fmt, args...) osl_printf((fmt), ## args) 2027 +#undef sprintf 2028 +#define sprintf(buf, fmt, args...) osl_sprintf((buf), (fmt), ## args) 2029 +#undef strcmp 2030 +#define strcmp(s1, s2) osl_strcmp((s1), (s2)) 2031 +#undef strncmp 2032 +#define strncmp(s1, s2, n) osl_strncmp((s1), (s2), (n)) 2033 +#undef strlen 2034 +#define strlen(s) osl_strlen((s)) 2035 +#undef strcpy 2036 +#define strcpy(d, s) osl_strcpy((d), (s)) 2037 +#undef strncpy 2038 +#define strncpy(d, s, n) osl_strncpy((d), (s), (n)) 2039 +#endif 2040 +extern int osl_printf(const char *format, ...); 2041 +extern int osl_sprintf(char *buf, const char *format, ...); 2042 +extern int osl_strcmp(const char *s1, const char *s2); 2043 +extern int osl_strncmp(const char *s1, const char *s2, uint n); 2044 +extern int osl_strlen(char *s); 2045 +extern char* osl_strcpy(char *d, const char *s); 2046 +extern char* osl_strncpy(char *d, const char *s, uint n); 2047 + 2048 +/* register access macros */ 2049 +#if !defined(BCMJTAG) 2050 +#define R_REG(r) ( \ 2051 + sizeof(*(r)) == sizeof(uint8) ? osl_readb((volatile uint8*)(r)) : \ 2052 + sizeof(*(r)) == sizeof(uint16) ? osl_readw((volatile uint16*)(r)) : \ 2053 + osl_readl((volatile uint32*)(r)) \ 2054 +) 2055 +#define W_REG(r, v) do { \ 2056 + switch (sizeof(*(r))) { \ 2057 + case sizeof(uint8): osl_writeb((uint8)(v), (volatile uint8*)(r)); break; \ 2058 + case sizeof(uint16): osl_writew((uint16)(v), (volatile uint16*)(r)); break; \ 2059 + case sizeof(uint32): osl_writel((uint32)(v), (volatile uint32*)(r)); break; \ 2060 + } \ 2061 +} while (0) 2062 +#endif 2063 + 2064 +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v)) 2065 +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v)) 2066 +extern uint8 osl_readb(volatile uint8 *r); 2067 +extern uint16 osl_readw(volatile uint16 *r); 2068 +extern uint32 osl_readl(volatile uint32 *r); 2069 +extern void osl_writeb(uint8 v, volatile uint8 *r); 2070 +extern void osl_writew(uint16 v, volatile uint16 *r); 2071 +extern void osl_writel(uint32 v, volatile uint32 *r); 2072 + 2073 +/* bcopy, bcmp, and bzero */ 2074 +extern void bcopy(const void *src, void *dst, int len); 2075 +extern int bcmp(const void *b1, const void *b2, int len); 2076 +extern void bzero(void *b, int len); 2077 + 2078 +/* uncached virtual address */ 2079 +#define OSL_UNCACHED(va) osl_uncached((va)) 2080 +extern void *osl_uncached(void *va); 2081 + 2082 +/* get processor cycle count */ 2083 +#define OSL_GETCYCLES(x) ((x) = osl_getcycles()) 2084 +extern uint osl_getcycles(void); 2085 + 2086 +/* dereference an address that may target abort */ 2087 +#define BUSPROBE(val, addr) osl_busprobe(&(val), (addr)) 2088 +extern int osl_busprobe(uint32 *val, uint32 addr); 2089 + 2090 +/* map/unmap physical to virtual */ 2091 +#define REG_MAP(pa, size) osl_reg_map((pa), (size)) 2092 +#define REG_UNMAP(va) osl_reg_unmap((va)) 2093 +extern void *osl_reg_map(uint32 pa, uint size); 2094 +extern void osl_reg_unmap(void *va); 2095 + 2096 +/* microsecond delay */ 2097 +#define OSL_DELAY(usec) osl_delay((usec)) 2098 +extern void osl_delay(uint usec); 2099 + 2100 +/* shared (dma-able) memory access macros */ 2101 +#define R_SM(r) *(r) 2102 +#define W_SM(r, v) (*(r) = (v)) 2103 +#define BZERO_SM(r, len) bzero((r), (len)) 2104 + 2105 +/* packet primitives */ 2106 +#define PKTGET(drv, len, send) osl_pktget((drv), (len), (send)) 2107 +#define PKTFREE(drv, skb, send) osl_pktfree((skb)) 2108 +#define PKTDATA(drv, skb) osl_pktdata((drv), (skb)) 2109 +#define PKTLEN(drv, skb) osl_pktlen((drv), (skb)) 2110 +#define PKTHEADROOM(drv, skb) osl_pktheadroom((drv), (skb)) 2111 +#define PKTTAILROOM(drv, skb) osl_pkttailroom((drv), (skb)) 2112 +#define PKTNEXT(drv, skb) osl_pktnext((drv), (skb)) 2113 +#define PKTSETNEXT(skb, x) osl_pktsetnext((skb), (x)) 2114 +#define PKTSETLEN(drv, skb, len) osl_pktsetlen((drv), (skb), (len)) 2115 +#define PKTPUSH(drv, skb, bytes) osl_pktpush((drv), (skb), (bytes)) 2116 +#define PKTPULL(drv, skb, bytes) osl_pktpull((drv), (skb), (bytes)) 2117 +#define PKTDUP(drv, skb) osl_pktdup((drv), (skb)) 2118 +#define PKTCOOKIE(skb) osl_pktcookie((skb)) 2119 +#define PKTSETCOOKIE(skb, x) osl_pktsetcookie((skb), (x)) 2120 +#define PKTLINK(skb) osl_pktlink((skb)) 2121 +#define PKTSETLINK(skb, x) osl_pktsetlink((skb), (x)) 2122 +#define PKTPRIO(skb) osl_pktprio((skb)) 2123 +#define PKTSETPRIO(skb, x) osl_pktsetprio((skb), (x)) 2124 +extern void *osl_pktget(void *drv, uint len, bool send); 2125 +extern void osl_pktfree(void *skb); 2126 +extern uchar *osl_pktdata(void *drv, void *skb); 2127 +extern uint osl_pktlen(void *drv, void *skb); 2128 +extern uint osl_pktheadroom(void *drv, void *skb); 2129 +extern uint osl_pkttailroom(void *drv, void *skb); 2130 +extern void *osl_pktnext(void *drv, void *skb); 2131 +extern void osl_pktsetnext(void *skb, void *x); 2132 +extern void osl_pktsetlen(void *drv, void *skb, uint len); 2133 +extern uchar *osl_pktpush(void *drv, void *skb, int bytes); 2134 +extern uchar *osl_pktpull(void *drv, void *skb, int bytes); 2135 +extern void *osl_pktdup(void *drv, void *skb); 2136 +extern void *osl_pktcookie(void *skb); 2137 +extern void osl_pktsetcookie(void *skb, void *x); 2138 +extern void *osl_pktlink(void *skb); 2139 +extern void osl_pktsetlink(void *skb, void *x); 2140 +extern uint osl_pktprio(void *skb); 2141 +extern void osl_pktsetprio(void *skb, uint x); 2142 + 2143 +#endif /* BINOSL */ 2144 + 2145 +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */ 2146 +#define PKTBUFSZ 2048 2147 + 2148 +#endif /* _linux_osl_h_ */ 2149 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/linuxver.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/linuxver.h 2150 --- linux-2.4.32/arch/mips/bcm947xx/include/linuxver.h 1970-01-01 01:00:00.000000000 +0100 2151 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/include/linuxver.h 2006-09-16 15:41:31.000000000 +0200 2152 @@ -0,0 +1,399 @@ 2153 +/* 2154 + * Linux-specific abstractions to gain some independence from linux kernel versions. 2155 + * Pave over some 2.2 versus 2.4 versus 2.6 kernel differences. 4322 + * HND SiliconBackplane PCI core software interface. 2156 4323 + * 2157 + * Copyright 2005, Broadcom Corporation 4324 + * $Id: hndpci.h,v 1.1.1.1 2006/02/27 03:43:16 honor Exp $ 4325 + * Copyright 2006, Broadcom Corporation 2158 4326 + * All Rights Reserved. 2159 4327 + * … … 2162 4330 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 2163 4331 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 2164 + * 2165 + * $Id$ 4332 + */ 4333 + 4334 +#ifndef _hndpci_h_ 4335 +#define _hndpci_h_ 4336 + 4337 +extern int sbpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, 4338 + int len); 4339 +extern int extpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, 4340 + int len); 4341 +extern int sbpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, 4342 + int len); 4343 +extern int extpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, 4344 + int len); 4345 +extern void sbpci_ban(uint16 core); 4346 +extern int sbpci_init(sb_t *sbh); 4347 +extern int sbpci_init_pci(sb_t *sbh); 4348 +extern void sbpci_check(sb_t *sbh); 4349 + 4350 +#endif /* _hndpci_h_ */ 4351 diff -urN linux.old/arch/mips/bcm947xx/include/linuxver.h linux.dev/arch/mips/bcm947xx/include/linuxver.h 4352 --- linux.old/arch/mips/bcm947xx/include/linuxver.h 1970-01-01 01:00:00.000000000 +0100 4353 +++ linux.dev/arch/mips/bcm947xx/include/linuxver.h 2006-10-02 21:19:59.000000000 +0200 4354 @@ -0,0 +1,417 @@ 4355 +/* 4356 + * Linux-specific abstractions to gain some independence from linux kernel versions. 4357 + * Pave over some 2.2 versus 2.4 versus 2.6 kernel differences. 4358 + * 4359 + * Copyright 2006, Broadcom Corporation 4360 + * All Rights Reserved. 4361 + * 4362 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 4363 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 4364 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 4365 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 4366 + * 4367 + * $Id: linuxver.h,v 1.1.1.10 2006/02/27 03:43:16 honor Exp $ 2166 4368 + */ 2167 4369 + … … 2172 4374 +#include <linux/version.h> 2173 4375 + 2174 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3,0))4376 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)) 2175 4377 +/* __NO_VERSION__ must be defined for all linkables except one in 2.2 */ 2176 4378 +#ifdef __UNDEF_NO_VERSION__ … … 2179 4381 +#define __NO_VERSION__ 2180 4382 +#endif 2181 +#endif 4383 +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0) */ 2182 4384 + 2183 4385 +#if defined(MODULE) && defined(MODVERSIONS) … … 2185 4387 +#endif 2186 4388 + 4389 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) 4390 +#include <linux/moduleparam.h> 4391 +#endif 4392 + 4393 + 4394 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) 4395 +#define module_param(_name_, _type_, _perm_) MODULE_PARM(_name_, "i") 4396 +#define module_param_string(_name_, _string_, _size_, _perm_) \ 4397 + MODULE_PARM(_string_, "c" __MODULE_STRING(_size_)) 4398 +#endif 4399 + 2187 4400 +/* linux/malloc.h is deprecated, use linux/slab.h instead. */ 2188 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4,9))4401 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 9)) 2189 4402 +#include <linux/malloc.h> 2190 4403 +#else … … 2201 4414 +#include <asm/io.h> 2202 4415 + 2203 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5,41))4416 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 41)) 2204 4417 +#include <linux/workqueue.h> 2205 4418 +#else … … 2217 4430 +#define flush_scheduled_work() flush_scheduled_tasks() 2218 4431 +#endif 2219 +#endif 2220 + 2221 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,0))4432 +#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 41) */ 4433 + 4434 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)) 2222 4435 +/* Some distributions have their own 2.6.x compatibility layers */ 2223 4436 +#ifndef IRQ_NONE … … 2227 4440 +#define IRQ_RETVAL(x) 2228 4441 +#endif 2229 +#endif 4442 +#else 4443 +typedef irqreturn_t(*FN_ISR) (int irq, void *dev_id, struct pt_regs *ptregs); 4444 +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) */ 2230 4445 + 2231 4446 +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) … … 2238 4453 +#include <pcmcia/ds.h> 2239 4454 + 2240 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 5,69))4455 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 69)) 2241 4456 +/* In 2.5 (as of 2.5.69 at least) there is a cs_error exported which 2242 + * does this, but it's not in 2.4 so we do our own for now. */ 4457 + * does this, but it's not in 2.4 so we do our own for now. 4458 + */ 2243 4459 +static inline void 2244 4460 +cs_error(client_handle_t handle, int func, int ret) … … 2267 4483 +#endif 2268 4484 + 2269 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4,0))4485 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)) 2270 4486 + 2271 4487 +#define pci_get_drvdata(dev) (dev)->sysdata 2272 +#define pci_set_drvdata(dev, value) (dev)->sysdata =(value)4488 +#define pci_set_drvdata(dev, value) (dev)->sysdata = (value) 2273 4489 + 2274 4490 +/* … … 2287 4503 + char *name; 2288 4504 + const struct pci_device_id *id_table; /* NULL if wants all devices */ 2289 + int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ 2290 + void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ 4505 + int (*probe)(struct pci_dev *dev, 4506 + const struct pci_device_id *id); /* New device inserted */ 4507 + void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug 4508 + * capable driver) 4509 + */ 2291 4510 + void (*suspend)(struct pci_dev *dev); /* Device suspended */ 2292 4511 + void (*resume)(struct pci_dev *dev); /* Device woken up */ … … 2303 4522 +#endif /* PCI registration */ 2304 4523 + 2305 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 2,18))4524 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 18)) 2306 4525 +#ifdef MODULE 2307 4526 +#define module_init(x) int init_module(void) { return x(); } … … 2311 4530 +#define module_exit(x) __exitcall(x); 2312 4531 +#endif 2313 +#endif 2314 + 2315 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3,48))4532 +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 18) */ 4533 + 4534 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 48)) 2316 4535 +#define list_for_each(pos, head) \ 2317 4536 + for (pos = (head)->next; pos != (head); pos = pos->next) 2318 4537 +#endif 2319 4538 + 2320 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3,13))4539 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 13)) 2321 4540 +#define pci_resource_start(dev, bar) ((dev)->base_address[(bar)]) 2322 +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3,44))4541 +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 44)) 2323 4542 +#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start) 2324 4543 +#endif 2325 4544 + 2326 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3,23))4545 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 23)) 2327 4546 +#define pci_enable_device(dev) do { } while (0) 2328 4547 +#endif 2329 4548 + 2330 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3,14))4549 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 14)) 2331 4550 +#define net_device device 2332 4551 +#endif 2333 4552 + 2334 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3,42))4553 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 42)) 2335 4554 + 2336 4555 +/* … … 2362 4581 + 2363 4582 +static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, 2364 + dma_addr_t *dma_handle)4583 + dma_addr_t *dma_handle) 2365 4584 +{ 2366 4585 + void *ret; … … 2376 4595 +} 2377 4596 +static inline void pci_free_consistent(struct pci_dev *hwdev, size_t size, 2378 + void *vaddr, dma_addr_t dma_handle)4597 + void *vaddr, dma_addr_t dma_handle) 2379 4598 +{ 2380 4599 + free_pages((unsigned long)vaddr, get_order(size)); … … 2390 4609 +#endif /* DMA mapping */ 2391 4610 + 2392 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3,43))4611 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 43)) 2393 4612 + 2394 4613 +#define dev_kfree_skb_any(a) dev_kfree_skb(a) 2395 +#define netif_down(dev) do { (dev)->start = 0; } while (0)4614 +#define netif_down(dev) do { (dev)->start = 0; } while (0) 2396 4615 + 2397 4616 +/* pcmcia-cs provides its own netdevice compatibility layer */ … … 2409 4628 + */ 2410 4629 + 2411 +#define dev_kfree_skb_irq(a) dev_kfree_skb(a) 2412 +#define netif_wake_queue(dev) do { clear_bit(0, &(dev)->tbusy); mark_bh(NET_BH); } while(0) 2413 +#define netif_stop_queue(dev) set_bit(0, &(dev)->tbusy) 4630 +#define dev_kfree_skb_irq(a) dev_kfree_skb(a) 4631 +#define netif_wake_queue(dev) \ 4632 + do { clear_bit(0, &(dev)->tbusy); mark_bh(NET_BH); } while (0) 4633 +#define netif_stop_queue(dev) set_bit(0, &(dev)->tbusy) 2414 4634 + 2415 4635 +static inline void netif_start_queue(struct net_device *dev) … … 2437 4657 + 2438 4658 +static inline void tasklet_init(struct tasklet_struct *tasklet, 2439 + void (*func)(unsigned long),2440 + unsigned long data)4659 + void (*func)(unsigned long), 4660 + unsigned long data) 2441 4661 +{ 2442 4662 + tasklet->next = NULL; … … 2445 4665 + tasklet->data = (void *)data; 2446 4666 +} 2447 +#define tasklet_kill(tasklet) {do{} while(0);}4667 +#define tasklet_kill(tasklet) { do{} while (0); } 2448 4668 + 2449 4669 +/* 2.4.x introduced del_timer_sync() */ … … 2456 4676 +#endif /* SoftNet */ 2457 4677 + 2458 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4,3))4678 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 3)) 2459 4679 + 2460 4680 +/* … … 2477 4697 + } while (0) 2478 4698 + 2479 +#endif 2480 + 2481 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4,6))4699 +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 3) */ 4700 + 4701 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 6)) 2482 4702 + 2483 4703 +/* Power management related routines */ … … 2489 4709 + if (buffer) { 2490 4710 + for (i = 0; i < 16; i++) 2491 + pci_read_config_dword(dev, i * 4, &buffer[i]);4711 + pci_read_config_dword(dev, i * 4, &buffer[i]); 2492 4712 + } 2493 4713 + return 0; 2494 4714 +} 2495 4715 + 2496 +static inline int 4716 +static inline int 2497 4717 +pci_restore_state(struct pci_dev *dev, u32 *buffer) 2498 4718 +{ … … 2501 4721 + if (buffer) { 2502 4722 + for (i = 0; i < 16; i++) 2503 + pci_write_config_dword(dev, i * 4, buffer[i]);4723 + pci_write_config_dword(dev, i * 4, buffer[i]); 2504 4724 + } 2505 4725 + /* … … 2508 4728 + * combined with a D3(hot)->D0 transition causes PCI config 2509 4729 + * header data to be forgotten. 2510 + */ 4730 + */ 2511 4731 + else { 2512 4732 + for (i = 0; i < 6; i ++) 2513 4733 + pci_write_config_dword(dev, 2514 + PCI_BASE_ADDRESS_0 + (i * 4),2515 + pci_resource_start(dev, i));4734 + PCI_BASE_ADDRESS_0 + (i * 4), 4735 + pci_resource_start(dev, i)); 2516 4736 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); 2517 4737 + } … … 2522 4742 + 2523 4743 +/* Old cp0 access macros deprecated in 2.4.19 */ 2524 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4,19))4744 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 19)) 2525 4745 +#define read_c0_count() read_32bit_cp0_register(CP0_COUNT) 2526 4746 +#endif … … 2544 4764 +#endif 2545 4765 + 2546 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,0))4766 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)) 2547 4767 +/* struct packet_type redefined in 2.6.x */ 2548 4768 +#define af_packet_priv data … … 2550 4770 + 2551 4771 +#endif /* _linuxver_h_ */ 2552 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/mipsinc.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/mipsinc.h2553 --- linux -2.4.32/arch/mips/bcm947xx/include/mipsinc.h 1970-01-01 01:00:00.000000000 +01002554 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/mipsinc.h 2006-09-16 15:41:31.000000000 +02002555 @@ -0,0 +1,5 24@@4772 diff -urN linux.old/arch/mips/bcm947xx/include/mipsinc.h linux.dev/arch/mips/bcm947xx/include/mipsinc.h 4773 --- linux.old/arch/mips/bcm947xx/include/mipsinc.h 1970-01-01 01:00:00.000000000 +0100 4774 +++ linux.dev/arch/mips/bcm947xx/include/mipsinc.h 2006-10-02 21:19:59.000000000 +0200 4775 @@ -0,0 +1,541 @@ 2556 4776 +/* 2557 4777 + * HND Run Time Environment for standalone MIPS programs. 2558 4778 + * 2559 + * Copyright 200 5, Broadcom Corporation4779 + * Copyright 2006, Broadcom Corporation 2560 4780 + * All Rights Reserved. 2561 4781 + * … … 2565 4785 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 2566 4786 + * 2567 + * $Id $4787 + * $Id: mipsinc.h,v 1.1.1.5 2006/02/27 03:43:16 honor Exp $ 2568 4788 + */ 2569 4789 + 2570 4790 +#ifndef _MISPINC_H 2571 +#define _MISPINC_H4791 +#define _MISPINC_H 2572 4792 + 2573 4793 + … … 2615 4835 + 2616 4836 + 2617 +/* ********************************************************************* 2618 + * CP0 Registers 2619 + ********************************************************************* */ 4837 +/* CP0 Registers */ 2620 4838 + 2621 4839 +#define C0_INX $0 … … 2643 4861 +#define C0_DIAGNOSTIC $22 2644 4862 +#define C0_BROADCOM C0_DIAGNOSTIC 4863 +#define C0_PERFORMANCE $25 2645 4864 +#define C0_ECC $26 2646 4865 +#define C0_CACHEERR $27 … … 2653 4872 + * LEAF - declare leaf routine 2654 4873 + */ 2655 +#define LEAF(symbol) \4874 +#define LEAF(symbol) \ 2656 4875 + .globl symbol; \ 2657 4876 + .align 2; \ 2658 + .type symbol, @function; \2659 + .ent symbol, 0; \2660 +symbol: .frame sp, 0,ra4877 + .type symbol, @function; \ 4878 + .ent symbol, 0; \ 4879 +symbol: .frame sp, 0, ra 2661 4880 + 2662 4881 +/* 2663 4882 + * END - mark end of function 2664 4883 + */ 2665 +#define END(function) \4884 +#define END(function) \ 2666 4885 + .end function; \ 2667 + .size function,.-function 2668 + 2669 +#define _ULCAST_ 4886 + .size function, . - function 4887 + 4888 +#define _ULCAST_ 4889 + 4890 +#define MFC0_SEL(dst, src, sel) \ 4891 + .word\t(0x40000000 | ((dst) << 16) | ((src) << 11) | (sel)) 4892 + 4893 + 4894 +#define MTC0_SEL(dst, src, sel) \ 4895 + .word\t(0x40800000 | ((dst) << 16) | ((src) << 11) | (sel)) 2670 4896 + 2671 4897 +#else … … 2682 4908 +#endif 2683 4909 + 2684 +#define _ULCAST_ (unsigned long) 2685 + 2686 + 2687 +/* ********************************************************************* 2688 + * CP0 Registers 2689 + ********************************************************************* */ 4910 +#define _ULCAST_ (unsigned long) 4911 + 4912 + 4913 +/* CP0 Registers */ 2690 4914 + 2691 4915 +#define C0_INX 0 /* CP0: TLB Index */ … … 2713 4937 +#define C0_DIAGNOSTIC 22 /* CP0: Diagnostic */ 2714 4938 +#define C0_BROADCOM C0_DIAGNOSTIC /* CP0: Broadcom Register */ 4939 +#define C0_PERFORMANCE 25 /* CP0: Performance Counter/Control Registers */ 2715 4940 +#define C0_ECC 26 /* CP0: ECC */ 2716 4941 +#define C0_CACHEERR 27 /* CP0: CacheErr */ … … 2757 4982 + * Cache Operations 2758 4983 + */ 2759 +#define Index_Invalidate_I 0x002760 +#define Index_Writeback_Inv_D 0x012761 +#define Index_Invalidate_SI 0x022762 +#define Index_Writeback_Inv_SD 0x034984 +#define Index_Invalidate_I 0x00 4985 +#define Index_Writeback_Inv_D 0x01 4986 +#define Index_Invalidate_SI 0x02 4987 +#define Index_Writeback_Inv_SD 0x03 2763 4988 +#define Index_Load_Tag_I 0x04 2764 4989 +#define Index_Load_Tag_D 0x05 … … 2788 5013 +#define Hit_Set_Virtual_SI 0x1e 2789 5014 +#define Hit_Set_Virtual_SD 0x1f 2790 +#endif 2791 + 2792 +#ifndef _LANGUAGE_ASSEMBLY 2793 + 2794 +/* 2795 + * Macros to access the system control coprocessor 2796 + */ 2797 + 2798 +#define MFC0(source, sel) \ 2799 +({ \ 2800 + int __res; \ 2801 + __asm__ __volatile__( \ 2802 + ".set\tnoreorder\n\t" \ 2803 + ".set\tnoat\n\t" \ 2804 + ".word\t"STR(0x40010000 | ((source)<<11) | (sel))"\n\t" \ 2805 + "move\t%0,$1\n\t" \ 2806 + ".set\tat\n\t" \ 2807 + ".set\treorder" \ 2808 + :"=r" (__res) \ 2809 + : \ 2810 + :"$1"); \ 2811 + __res; \ 2812 +}) 2813 + 2814 +#define MTC0(source, sel, value) \ 2815 +do { \ 2816 + __asm__ __volatile__( \ 2817 + ".set\tnoreorder\n\t" \ 2818 + ".set\tnoat\n\t" \ 2819 + "move\t$1,%z0\n\t" \ 2820 + ".word\t"STR(0x40810000 | ((source)<<11) | (sel))"\n\t" \ 2821 + ".set\tat\n\t" \ 2822 + ".set\treorder" \ 2823 + : \ 2824 + :"jr" (value) \ 2825 + :"$1"); \ 2826 +} while (0) 2827 + 2828 +#define get_c0_count() \ 2829 +({ \ 2830 + int __res; \ 2831 + __asm__ __volatile__( \ 2832 + ".set\tnoreorder\n\t" \ 2833 + ".set\tnoat\n\t" \ 2834 + "mfc0\t%0,$9\n\t" \ 2835 + ".set\tat\n\t" \ 2836 + ".set\treorder" \ 2837 + :"=r" (__res)); \ 2838 + __res; \ 2839 +}) 2840 + 2841 +static INLINE void icache_probe(uint32 config1, uint *size, uint *lsize) 2842 +{ 2843 + uint lsz, sets, ways; 2844 + 2845 + /* Instruction Cache Size = Associativity * Line Size * Sets Per Way */ 2846 + if ((lsz = ((config1 >> 19) & 7))) 2847 + lsz = 2 << lsz; 2848 + sets = 64 << ((config1 >> 22) & 7); 2849 + ways = 1 + ((config1 >> 16) & 7); 2850 + *size = lsz * sets * ways; 2851 + *lsize = lsz; 2852 +} 2853 + 2854 +static INLINE void dcache_probe(uint32 config1, uint *size, uint *lsize) 2855 +{ 2856 + uint lsz, sets, ways; 2857 + 2858 + /* Data Cache Size = Associativity * Line Size * Sets Per Way */ 2859 + if ((lsz = ((config1 >> 10) & 7))) 2860 + lsz = 2 << lsz; 2861 + sets = 64 << ((config1 >> 13) & 7); 2862 + ways = 1 + ((config1 >> 7) & 7); 2863 + *size = lsz * sets * ways; 2864 + *lsize = lsz; 2865 +} 2866 + 2867 +#define cache_unroll(base,op) \ 2868 + __asm__ __volatile__(" \ 2869 + .set noreorder; \ 2870 + .set mips3; \ 2871 + cache %1, (%0); \ 2872 + .set mips0; \ 2873 + .set reorder" \ 2874 + : \ 2875 + : "r" (base), \ 2876 + "i" (op)); 2877 + 2878 +#endif /* !_LANGUAGE_ASSEMBLY */ 5015 +#endif /* !Index_Invalidate_I */ 2879 5016 + 2880 5017 + … … 2882 5019 + * R4x00 interrupt enable / cause bits 2883 5020 + */ 2884 +#undef IE_SW0 2885 +#undef IE_SW1 2886 +#undef IE_IRQ0 2887 +#undef IE_IRQ1 2888 +#undef IE_IRQ2 2889 +#undef IE_IRQ3 2890 +#undef IE_IRQ4 2891 +#undef IE_IRQ5 2892 +#define IE_SW0 (1<< 8) 2893 +#define IE_SW1 (1<< 9) 2894 +#define IE_IRQ0 (1<<10) 2895 +#define IE_IRQ1 (1<<11) 2896 +#define IE_IRQ2 (1<<12) 2897 +#define IE_IRQ3 (1<<13) 2898 +#define IE_IRQ4 (1<<14) 2899 +#define IE_IRQ5 (1<<15) 2900 + 5021 +#define IE_SW0 (_ULCAST_(1) << 8) 5022 +#define IE_SW1 (_ULCAST_(1) << 9) 5023 +#define IE_IRQ0 (_ULCAST_(1) << 10) 5024 +#define IE_IRQ1 (_ULCAST_(1) << 11) 5025 +#define IE_IRQ2 (_ULCAST_(1) << 12) 5026 +#define IE_IRQ3 (_ULCAST_(1) << 13) 5027 +#define IE_IRQ4 (_ULCAST_(1) << 14) 5028 +#define IE_IRQ5 (_ULCAST_(1) << 15) 5029 + 5030 +#ifndef ST0_UM 2901 5031 +/* 2902 5032 + * Bitfields in the mips32 cp0 status register … … 2905 5035 +#define ST0_EXL 0x00000002 2906 5036 +#define ST0_ERL 0x00000004 2907 +/* already defined2908 5037 +#define ST0_UM 0x00000010 2909 5038 +#define ST0_SWINT0 0x00000100 2910 5039 +#define ST0_SWINT1 0x00000200 2911 +*/2912 5040 +#define ST0_HWINT0 0x00000400 2913 5041 +#define ST0_HWINT1 0x00000800 … … 2928 5056 +#define ST0_CU2 0x40000000 2929 5057 +#define ST0_CU3 0x80000000 5058 +#endif /* !ST0_UM */ 2930 5059 + 2931 5060 + … … 2937 5066 +#define C_INT 0x0000ff00 2938 5067 +#define C_INT_SHIFT 8 2939 +/* already defined 2940 +#define C_SW0 0x00000100 2941 +#define C_SW1 0x00000200 2942 +#define C_IRQ0 0x00000400 2943 +#define C_IRQ1 0x00000800 2944 +#define C_IRQ2 0x00001000 2945 +#define C_IRQ3 0x00002000 2946 +#define C_IRQ4 0x00004000 2947 +#define C_IRQ5 0x00008000 2948 +*/ 5068 +#define C_SW0 (_ULCAST_(1) << 8) 5069 +#define C_SW1 (_ULCAST_(1) << 9) 5070 +#define C_IRQ0 (_ULCAST_(1) << 10) 5071 +#define C_IRQ1 (_ULCAST_(1) << 11) 5072 +#define C_IRQ2 (_ULCAST_(1) << 12) 5073 +#define C_IRQ3 (_ULCAST_(1) << 13) 5074 +#define C_IRQ4 (_ULCAST_(1) << 14) 5075 +#define C_IRQ5 (_ULCAST_(1) << 15) 2949 5076 +#define C_WP 0x00400000 2950 5077 +#define C_IV 0x00800000 … … 2988 5115 +#define CONF_IB (_ULCAST_(1) << 5) 2989 5116 +#define CONF_SE (_ULCAST_(1) << 12) 5117 +#ifndef CONF_BE /* duplicate in mipsregs.h */ 5118 +#define CONF_BE (_ULCAST_(1) << 15) 5119 +#endif 2990 5120 +#define CONF_SC (_ULCAST_(1) << 17) 2991 5121 +#define CONF_AC (_ULCAST_(1) << 23) 2992 5122 +#define CONF_HALT (_ULCAST_(1) << 25) 5123 +#ifndef CONF_M /* duplicate in mipsregs.h */ 5124 +#define CONF_M (_ULCAST_(1) << 31) 5125 +#endif 2993 5126 + 2994 5127 + … … 2996 5129 + * Bits in the cp0 config register select 1. 2997 5130 + */ 2998 +#define CONF1_FP 0x00000001/* FPU present */2999 +#define CONF1_EP 0x00000002/* EJTAG present */3000 +#define CONF1_CA 0x00000004/* mips16 implemented */3001 +#define CONF1_WR 0x00000008/* Watch registers present */3002 +#define CONF1_PC 0x00000010/* Performance counters present */3003 +#define CONF1_DA_SHIFT 7/* D$ associativity */3004 +#define CONF1_DA_MASK 0x000003803005 +#define CONF1_DA_BASE 13006 +#define CONF1_DL_SHIFT 10/* D$ line size */3007 +#define CONF1_DL_MASK 0x00001c003008 +#define CONF1_DL_BASE 23009 +#define CONF1_DS_SHIFT 13/* D$ sets/way */3010 +#define CONF1_DS_MASK 0x0000e0003011 +#define CONF1_DS_BASE 643012 +#define CONF1_IA_SHIFT 16/* I$ associativity */3013 +#define CONF1_IA_MASK 0x000700003014 +#define CONF1_IA_BASE 13015 +#define CONF1_IL_SHIFT 19/* I$ line size */3016 +#define CONF1_IL_MASK 0x003800003017 +#define CONF1_IL_BASE 23018 +#define CONF1_IS_SHIFT 22/* Instruction cache sets/way */3019 +#define CONF1_IS_MASK 0x01c000003020 +#define CONF1_IS_BASE 643021 +#define CONF1_MS_MASK 0x7e000000/* Number of tlb entries */3022 +#define CONF1_MS_SHIFT 255131 +#define CONF1_FP 0x00000001 /* FPU present */ 5132 +#define CONF1_EP 0x00000002 /* EJTAG present */ 5133 +#define CONF1_CA 0x00000004 /* mips16 implemented */ 5134 +#define CONF1_WR 0x00000008 /* Watch registers present */ 5135 +#define CONF1_PC 0x00000010 /* Performance counters present */ 5136 +#define CONF1_DA_SHIFT 7 /* D$ associativity */ 5137 +#define CONF1_DA_MASK 0x00000380 5138 +#define CONF1_DA_BASE 1 5139 +#define CONF1_DL_SHIFT 10 /* D$ line size */ 5140 +#define CONF1_DL_MASK 0x00001c00 5141 +#define CONF1_DL_BASE 2 5142 +#define CONF1_DS_SHIFT 13 /* D$ sets/way */ 5143 +#define CONF1_DS_MASK 0x0000e000 5144 +#define CONF1_DS_BASE 64 5145 +#define CONF1_IA_SHIFT 16 /* I$ associativity */ 5146 +#define CONF1_IA_MASK 0x00070000 5147 +#define CONF1_IA_BASE 1 5148 +#define CONF1_IL_SHIFT 19 /* I$ line size */ 5149 +#define CONF1_IL_MASK 0x00380000 5150 +#define CONF1_IL_BASE 2 5151 +#define CONF1_IS_SHIFT 22 /* Instruction cache sets/way */ 5152 +#define CONF1_IS_MASK 0x01c00000 5153 +#define CONF1_IS_BASE 64 5154 +#define CONF1_MS_MASK 0x7e000000 /* Number of tlb entries */ 5155 +#define CONF1_MS_SHIFT 25 3023 5156 + 3024 5157 +/* PRID register */ … … 3036 5169 +#define PRID_IMP_BCM3302 0x9000 3037 5170 +#define PRID_IMP_BCM3303 0x9100 3038 +#define PRID_IMP_BCM3303 0x91003039 5171 + 3040 5172 +#define PRID_IMP_UNKNOWN 0xff00 3041 5173 + 3042 +#define BCM330X(id) \ 3043 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) \ 3044 + || ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == (PRID_COMP_BROADCOM | PRID_IMP_BCM3303))) 5174 +#define BCM330X(id) \ 5175 + (((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == \ 5176 + (PRID_COMP_BROADCOM | PRID_IMP_BCM3302)) || \ 5177 + ((id & (PRID_COMP_MASK | PRID_IMP_MASK)) == \ 5178 + (PRID_COMP_BROADCOM | PRID_IMP_BCM3303))) 3045 5179 + 3046 5180 +/* Bits in C0_BROADCOM */ 3047 +#define BRCM_PFC_AVAIL 0x20000000 /* PFC is available */ 3048 +#define BRCM_DC_ENABLE 0x40000000 /* Enable Data $ */ 3049 +#define BRCM_IC_ENABLE 0x80000000 /* Enable Instruction $ */ 3050 +#define BRCM_PFC_ENABLE 0x00400000 /* Obsolete? Enable PFC (at least on 4310) */ 5181 +#define BRCM_PFC_AVAIL 0x20000000 /* PFC is available */ 5182 +#define BRCM_DC_ENABLE 0x40000000 /* Enable Data $ */ 5183 +#define BRCM_IC_ENABLE 0x80000000 /* Enable Instruction $ */ 5184 +#define BRCM_PFC_ENABLE 0x00400000 /* Obsolete? Enable PFC (at least on 4310) */ 5185 +#define BRCM_CLF_ENABLE 0x00100000 /* Enable cache line first feature */ 3051 5186 + 3052 5187 +/* PreFetch Cache aka Read Ahead Cache */ 3053 5188 + 3054 +#define PFC_CR0 0xff400000 /* control reg 0 */ 3055 +#define PFC_CR1 0xff400004 /* control reg 1 */ 3056 + 3057 +/* 3058 + * These are the UART port assignments, expressed as offsets from the base 3059 + * register. These assignments should hold for any serial port based on 3060 + * a 8250, 16450, or 16550(A). 5189 +#define PFC_CR0 0xff400000 /* control reg 0 */ 5190 +#define PFC_CR1 0xff400004 /* control reg 1 */ 5191 + 5192 +/* PFC operations */ 5193 +#define PFC_I 0x00000001 /* Enable PFC use for instructions */ 5194 +#define PFC_D 0x00000002 /* Enable PFC use for data */ 5195 +#define PFC_PFI 0x00000004 /* Enable seq. prefetch for instructions */ 5196 +#define PFC_PFD 0x00000008 /* Enable seq. prefetch for data */ 5197 +#define PFC_CINV 0x00000010 /* Enable selective (i/d) cacheop flushing */ 5198 +#define PFC_NCH 0x00000020 /* Disable flushing based on cacheops */ 5199 +#define PFC_DPF 0x00000040 /* Enable directional prefetching */ 5200 +#define PFC_FLUSH 0x00000100 /* Flush the PFC */ 5201 +#define PFC_BRR 0x40000000 /* Bus error indication */ 5202 +#define PFC_PWR 0x80000000 /* Disable power saving (clock gating) */ 5203 + 5204 +/* Handy defaults */ 5205 +#define PFC_DISABLED 0 5206 +#define PFC_AUTO 0xffffffff /* auto select the default mode */ 5207 +#define PFC_INST (PFC_I | PFC_PFI | PFC_CINV) 5208 +#define PFC_INST_NOPF (PFC_I | PFC_CINV) 5209 +#define PFC_DATA (PFC_D | PFC_PFD | PFC_CINV) 5210 +#define PFC_DATA_NOPF (PFC_D | PFC_CINV) 5211 +#define PFC_I_AND_D (PFC_INST | PFC_DATA) 5212 +#define PFC_I_AND_D_NOPF (PFC_INST_NOPF | PFC_DATA_NOPF) 5213 + 5214 +#ifndef _LANGUAGE_ASSEMBLY 5215 + 5216 +/* 5217 + * Macros to access the system control coprocessor 3061 5218 + */ 3062 5219 + 3063 +#define UART_RX 0 /* In: Receive buffer (DLAB=0) */ 3064 +#define UART_TX 0 /* Out: Transmit buffer (DLAB=0) */ 3065 +#define UART_DLL 0 /* Out: Divisor Latch Low (DLAB=1) */ 3066 +#define UART_DLM 1 /* Out: Divisor Latch High (DLAB=1) */ 3067 +#define UART_LCR 3 /* Out: Line Control Register */ 3068 +#define UART_MCR 4 /* Out: Modem Control Register */ 3069 +#define UART_LSR 5 /* In: Line Status Register */ 3070 +#define UART_MSR 6 /* In: Modem Status Register */ 3071 +#define UART_SCR 7 /* I/O: Scratch Register */ 3072 +#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */ 3073 +#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */ 3074 +#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */ 3075 +#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */ 3076 +#define UART_LSR_RXRDY 0x01 /* Receiver ready */ 3077 + 5220 +#define MFC0(source, sel) \ 5221 +({ \ 5222 + int __res; \ 5223 + __asm__ __volatile__(" \ 5224 + .set\tnoreorder; \ 5225 + .set\tnoat; \ 5226 + .word\t"STR(0x40010000 | ((source) << 11) | (sel))"; \ 5227 + move\t%0, $1; \ 5228 + .set\tat; \ 5229 + .set\treorder" \ 5230 + :"=r" (__res) \ 5231 + : \ 5232 + :"$1"); \ 5233 + __res; \ 5234 +}) 5235 + 5236 +#define MTC0(source, sel, value) \ 5237 +do { \ 5238 + __asm__ __volatile__(" \ 5239 + .set\tnoreorder; \ 5240 + .set\tnoat; \ 5241 + move\t$1, %z0; \ 5242 + .word\t"STR(0x40810000 | ((source) << 11) | (sel))"; \ 5243 + .set\tat; \ 5244 + .set\treorder" \ 5245 + : \ 5246 + :"jr" (value) \ 5247 + :"$1"); \ 5248 +} while (0) 5249 + 5250 +#define get_c0_count() \ 5251 +({ \ 5252 + int __res; \ 5253 + __asm__ __volatile__(" \ 5254 + .set\tnoreorder; \ 5255 + .set\tnoat; \ 5256 + mfc0\t%0, $9; \ 5257 + .set\tat; \ 5258 + .set\treorder" \ 5259 + :"=r" (__res)); \ 5260 + __res; \ 5261 +}) 5262 + 5263 +static INLINE void icache_probe(uint32 config1, uint *size, uint *lsize) 5264 +{ 5265 + uint lsz, sets, ways; 5266 + 5267 + /* Instruction Cache Size = Associativity * Line Size * Sets Per Way */ 5268 + if ((lsz = ((config1 & CONF1_IL_MASK) >> CONF1_IL_SHIFT))) 5269 + lsz = CONF1_IL_BASE << lsz; 5270 + sets = CONF1_IS_BASE << ((config1 & CONF1_IS_MASK) >> CONF1_IS_SHIFT); 5271 + ways = CONF1_IA_BASE + ((config1 & CONF1_IA_MASK) >> CONF1_IA_SHIFT); 5272 + *size = lsz * sets * ways; 5273 + *lsize = lsz; 5274 +} 5275 + 5276 +static INLINE void dcache_probe(uint32 config1, uint *size, uint *lsize) 5277 +{ 5278 + uint lsz, sets, ways; 5279 + 5280 + /* Data Cache Size = Associativity * Line Size * Sets Per Way */ 5281 + if ((lsz = ((config1 & CONF1_DL_MASK) >> CONF1_DL_SHIFT))) 5282 + lsz = CONF1_DL_BASE << lsz; 5283 + sets = CONF1_DS_BASE << ((config1 & CONF1_DS_MASK) >> CONF1_DS_SHIFT); 5284 + ways = CONF1_DA_BASE + ((config1 & CONF1_DA_MASK) >> CONF1_DA_SHIFT); 5285 + *size = lsz * sets * ways; 5286 + *lsize = lsz; 5287 +} 5288 + 5289 +#define cache_op(base, op) \ 5290 + __asm__ __volatile__(" \ 5291 + .set noreorder; \ 5292 + .set mips3; \ 5293 + cache %1, (%0); \ 5294 + .set mips0; \ 5295 + .set reorder" \ 5296 + : \ 5297 + : "r" (base), \ 5298 + "i" (op)); 5299 + 5300 +#define cache_unroll4(base, delta, op) \ 5301 + __asm__ __volatile__(" \ 5302 + .set noreorder; \ 5303 + .set mips3; \ 5304 + cache %1, 0(%0); \ 5305 + cache %1, delta(%0); \ 5306 + cache %1, (2 * delta)(%0); \ 5307 + cache %1, (3 * delta)(%0); \ 5308 + .set mips0; \ 5309 + .set reorder" \ 5310 + : \ 5311 + : "r" (base), \ 5312 + "i" (op)); 5313 + 5314 +#endif /* !_LANGUAGE_ASSEMBLY */ 3078 5315 + 3079 5316 +#endif /* _MISPINC_H */ 3080 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/osl.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/osl.h 3081 --- linux-2.4.32/arch/mips/bcm947xx/include/osl.h 1970-01-01 01:00:00.000000000 +0100 3082 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/include/osl.h 2006-09-16 15:41:31.000000000 +0200 3083 @@ -0,0 +1,39 @@ 5317 diff -urN linux.old/arch/mips/bcm947xx/include/osl.h linux.dev/arch/mips/bcm947xx/include/osl.h 5318 --- linux.old/arch/mips/bcm947xx/include/osl.h 1970-01-01 01:00:00.000000000 +0100 5319 +++ linux.dev/arch/mips/bcm947xx/include/osl.h 2006-10-02 21:19:59.000000000 +0200 5320 @@ -0,0 +1,181 @@ 5321 +#ifndef __osl_h 5322 +#define __osl_h 5323 + 5324 +#include <linux/delay.h> 5325 +#include <typedefs.h> 5326 +#include <linuxver.h> 5327 +#include <bcmutils.h> 5328 +#include <pcicfg.h> 5329 + 5330 +#define ASSERT(n) 5331 + 5332 +/* Pkttag flag should be part of public information */ 5333 +typedef struct { 5334 + bool pkttag; 5335 + uint pktalloced; /* Number of allocated packet buffers */ 5336 + void *tx_fn; 5337 + void *tx_ctx; 5338 +} osl_pubinfo_t; 5339 + 5340 +struct osl_info { 5341 + osl_pubinfo_t pub; 5342 + uint magic; 5343 + void *pdev; 5344 + uint malloced; 5345 + uint failed; 5346 + void *dbgmem_list; 5347 +}; 5348 + 5349 +typedef struct osl_info osl_t; 5350 + 5351 +#define PCI_CFG_RETRY 10 5352 + 5353 +/* map/unmap direction */ 5354 +#define DMA_TX 1 /* TX direction for DMA */ 5355 +#define DMA_RX 2 /* RX direction for DMA */ 5356 + 5357 +#define AND_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) & (v)) 5358 +#define OR_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) | (v)) 5359 +#define SET_REG(osh, r, mask, val) W_REG((osh), (r), ((R_REG((osh), r) & ~(mask)) | (val))) 5360 + 5361 +/* bcopy, bcmp, and bzero */ 5362 +#define bcopy(src, dst, len) memcpy((dst), (src), (len)) 5363 +#define bcmp(b1, b2, len) memcmp((b1), (b2), (len)) 5364 +#define bzero(b, len) memset((b), '\0', (len)) 5365 + 5366 +/* uncached virtual address */ 5367 +#ifdef mips 5368 +#define OSL_UNCACHED(va) KSEG1ADDR((va)) 5369 +#include <asm/addrspace.h> 5370 +#else 5371 +#define OSL_UNCACHED(va) (va) 5372 +#endif /* mips */ 5373 + 5374 + 5375 +#ifndef IL_BIGENDIAN 5376 +#define R_REG(osh, r) (\ 5377 + sizeof(*(r)) == sizeof(uint8) ? readb((volatile uint8*)(r)) : \ 5378 + sizeof(*(r)) == sizeof(uint16) ? readw((volatile uint16*)(r)) : \ 5379 + readl((volatile uint32*)(r)) \ 5380 +) 5381 +#define W_REG(osh, r, v) do { \ 5382 + switch (sizeof(*(r))) { \ 5383 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)(r)); break; \ 5384 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)(r)); break; \ 5385 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \ 5386 + } \ 5387 +} while (0) 5388 +#else /* IL_BIGENDIAN */ 5389 +#define R_REG(osh, r) ({ \ 5390 + __typeof(*(r)) __osl_v; \ 5391 + switch (sizeof(*(r))) { \ 5392 + case sizeof(uint8): __osl_v = readb((volatile uint8*)((uint32)r^3)); break; \ 5393 + case sizeof(uint16): __osl_v = readw((volatile uint16*)((uint32)r^2)); break; \ 5394 + case sizeof(uint32): __osl_v = readl((volatile uint32*)(r)); break; \ 5395 + } \ 5396 + __osl_v; \ 5397 +}) 5398 +#define W_REG(osh, r, v) do { \ 5399 + switch (sizeof(*(r))) { \ 5400 + case sizeof(uint8): writeb((uint8)(v), (volatile uint8*)((uint32)r^3)); break; \ 5401 + case sizeof(uint16): writew((uint16)(v), (volatile uint16*)((uint32)r^2)); break; \ 5402 + case sizeof(uint32): writel((uint32)(v), (volatile uint32*)(r)); break; \ 5403 + } \ 5404 +} while (0) 5405 +#endif /* IL_BIGENDIAN */ 5406 + 5407 +/* dereference an address that may cause a bus exception */ 5408 +#define BUSPROBE(val, addr) get_dbe((val), (addr)) 5409 +#include <asm/paccess.h> 5410 + 5411 +/* map/unmap physical to virtual I/O */ 5412 +#define REG_MAP(pa, size) ioremap_nocache((unsigned long)(pa), (unsigned long)(size)) 5413 +#define REG_UNMAP(va) iounmap((void *)(va)) 5414 + 5415 +/* shared (dma-able) memory access macros */ 5416 +#define R_SM(r) *(r) 5417 +#define W_SM(r, v) (*(r) = (v)) 5418 +#define BZERO_SM(r, len) memset((r), '\0', (len)) 5419 + 5420 +#define MALLOC(osh, size) kmalloc((size), GFP_ATOMIC) 5421 +#define MFREE(osh, addr, size) kfree((addr)) 5422 +#define MALLOCED(osh) (0) 5423 + 5424 +#define osl_delay OSL_DELAY 5425 +static inline void OSL_DELAY(uint usec) 5426 +{ 5427 + uint d; 5428 + 5429 + while (usec > 0) { 5430 + d = MIN(usec, 1000); 5431 + udelay(d); 5432 + usec -= d; 5433 + } 5434 +} 5435 + 5436 +static inline void 5437 +bcm_mdelay(uint ms) 5438 +{ 5439 + uint i; 5440 + 5441 + for (i = 0; i < ms; i++) { 5442 + OSL_DELAY(1000); 5443 + } 5444 +} 5445 + 5446 + 5447 +#define OSL_PCMCIA_READ_ATTR(osh, offset, buf, size) 5448 +#define OSL_PCMCIA_WRITE_ATTR(osh, offset, buf, size) 5449 + 5450 +#define OSL_PCI_READ_CONFIG(osh, offset, size) \ 5451 + osl_pci_read_config((osh), (offset), (size)) 5452 + 5453 +static inline uint32 5454 +osl_pci_read_config(osl_t *osh, uint offset, uint size) 5455 +{ 5456 + uint val; 5457 + uint retry = PCI_CFG_RETRY; 5458 + 5459 + do { 5460 + pci_read_config_dword(osh->pdev, offset, &val); 5461 + if (val != 0xffffffff) 5462 + break; 5463 + } while (retry--); 5464 + 5465 + return (val); 5466 +} 5467 + 5468 +#define OSL_PCI_WRITE_CONFIG(osh, offset, size, val) \ 5469 + osl_pci_write_config((osh), (offset), (size), (val)) 5470 +static inline void 5471 +osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val) 5472 +{ 5473 + uint retry = PCI_CFG_RETRY; 5474 + 5475 + do { 5476 + pci_write_config_dword(osh->pdev, offset, val); 5477 + if (offset != PCI_BAR0_WIN) 5478 + break; 5479 + if (osl_pci_read_config(osh, offset, size) == val) 5480 + break; 5481 + } while (retry--); 5482 +} 5483 + 5484 + 5485 +/* return bus # for the pci device pointed by osh->pdev */ 5486 +#define OSL_PCI_BUS(osh) osl_pci_bus(osh) 5487 +static inline uint 5488 +osl_pci_bus(osl_t *osh) 5489 +{ 5490 + return ((struct pci_dev *)osh->pdev)->bus->number; 5491 +} 5492 + 5493 +/* return slot # for the pci device pointed by osh->pdev */ 5494 +#define OSL_PCI_SLOT(osh) osl_pci_slot(osh) 5495 +static inline uint 5496 +osl_pci_slot(osl_t *osh) 5497 +{ 5498 + return PCI_SLOT(((struct pci_dev *)osh->pdev)->devfn); 5499 +} 5500 + 5501 +#endif 5502 diff -urN linux.old/arch/mips/bcm947xx/include/pcicfg.h linux.dev/arch/mips/bcm947xx/include/pcicfg.h 5503 --- linux.old/arch/mips/bcm947xx/include/pcicfg.h 1970-01-01 01:00:00.000000000 +0100 5504 +++ linux.dev/arch/mips/bcm947xx/include/pcicfg.h 2006-10-02 21:19:59.000000000 +0200 5505 @@ -0,0 +1,495 @@ 3084 5506 +/* 3085 + * OS Independent Layer 3086 + * 3087 + * Copyright 2005, Broadcom Corporation 3088 + * All Rights Reserved. 3089 + * 3090 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 3091 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 3092 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 3093 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 3094 + * $Id$ 3095 + */ 3096 + 3097 +#ifndef _osl_h_ 3098 +#define _osl_h_ 3099 + 3100 +#if defined(linux) 3101 +#include <linux_osl.h> 3102 +#elif defined(NDIS) 3103 +#include <ndis_osl.h> 3104 +#elif defined(_CFE_) 3105 +#include <cfe_osl.h> 3106 +#elif defined(_HNDRTE_) 3107 +#include <hndrte_osl.h> 3108 +#elif defined(_MINOSL_) 3109 +#include <min_osl.h> 3110 +#elif PMON 3111 +#include <pmon_osl.h> 3112 +#elif defined(MACOSX) 3113 +#include <macosx_osl.h> 3114 +#else 3115 +#error "Unsupported OSL requested" 3116 +#endif 3117 + 3118 +/* handy */ 3119 +#define SET_REG(r, mask, val) W_REG((r), ((R_REG(r) & ~(mask)) | (val))) 3120 +#define MAXPRIO 7 /* 0-7 */ 3121 + 3122 +#endif /* _osl_h_ */ 3123 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/pcicfg.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/pcicfg.h 3124 --- linux-2.4.32/arch/mips/bcm947xx/include/pcicfg.h 1970-01-01 01:00:00.000000000 +0100 3125 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/include/pcicfg.h 2006-09-16 15:41:31.000000000 +0200 3126 @@ -0,0 +1,369 @@ 3127 +/* 3128 + * pcicfg.h: PCI configuration constants and structures. 5507 + * pcicfg.h: PCI configuration constants and structures. 3129 5508 + * 3130 + * Copyright 200 5, Broadcom Corporation5509 + * Copyright 2006, Broadcom Corporation 3131 5510 + * All Rights Reserved. 3132 5511 + * … … 3136 5515 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 3137 5516 + * 3138 + * $Id $5517 + * $Id: pcicfg.h,v 1.1.1.11 2006/04/08 06:13:40 honor Exp $ 3139 5518 + */ 3140 5519 + 3141 +#ifndef _h_pci _3142 +#define _h_pci _5520 +#ifndef _h_pcicfg_ 5521 +#define _h_pcicfg_ 3143 5522 + 3144 5523 +/* The following inside ifndef's so we don't collide with NTDDK.H */ … … 3166 5545 +#define PCICFG_SLOT_SHIFT 11 /* Slot shift */ 3167 5546 +#define PCICFG_FUN_SHIFT 8 /* Function shift */ 3168 +#define PCICFG_OFF_SHIFT 0 /* Busshift */5547 +#define PCICFG_OFF_SHIFT 0 /* Register shift */ 3169 5548 + 3170 5549 +#define PCICFG_BUS_MASK 0xff /* Bus mask */ … … 3184 5563 +#define PCI_CONFIG_OFF(a) (((a) >> PCICFG_OFF_SHIFT) & PCICFG_OFF_MASK) 3185 5564 + 5565 +/* PCIE Config space accessing MACROS */ 5566 + 5567 +#define PCIECFG_BUS_SHIFT 24 /* Bus shift */ 5568 +#define PCIECFG_SLOT_SHIFT 19 /* Slot/Device shift */ 5569 +#define PCIECFG_FUN_SHIFT 16 /* Function shift */ 5570 +#define PCIECFG_OFF_SHIFT 0 /* Register shift */ 5571 + 5572 +#define PCIECFG_BUS_MASK 0xff /* Bus mask */ 5573 +#define PCIECFG_SLOT_MASK 0x1f /* Slot/Device mask */ 5574 +#define PCIECFG_FUN_MASK 7 /* Function mask */ 5575 +#define PCIECFG_OFF_MASK 0x3ff /* Register mask */ 5576 + 5577 +#define PCIE_CONFIG_ADDR(b, s, f, o) \ 5578 + ((((b) & PCIECFG_BUS_MASK) << PCIECFG_BUS_SHIFT) \ 5579 + | (((s) & PCIECFG_SLOT_MASK) << PCIECFG_SLOT_SHIFT) \ 5580 + | (((f) & PCIECFG_FUN_MASK) << PCIECFG_FUN_SHIFT) \ 5581 + | (((o) & PCIECFG_OFF_MASK) << PCIECFG_OFF_SHIFT)) 5582 + 5583 +#define PCIE_CONFIG_BUS(a) (((a) >> PCIECFG_BUS_SHIFT) & PCIECFG_BUS_MASK) 5584 +#define PCIE_CONFIG_SLOT(a) (((a) >> PCIECFG_SLOT_SHIFT) & PCIECFG_SLOT_MASK) 5585 +#define PCIE_CONFIG_FUN(a) (((a) >> PCIECFG_FUN_SHIFT) & PCIECFG_FUN_MASK) 5586 +#define PCIE_CONFIG_OFF(a) (((a) >> PCIECFG_OFF_SHIFT) & PCIECFG_OFF_MASK) 3186 5587 + 3187 5588 +/* The actual config space */ … … 3193 5594 +#define PCR_RSVDA_MAX 2 3194 5595 + 5596 +/* Bits in PCI bars' flags */ 5597 + 5598 +#define PCIBAR_FLAGS 0xf 5599 +#define PCIBAR_IO 0x1 5600 +#define PCIBAR_MEM1M 0x2 5601 +#define PCIBAR_MEM64 0x4 5602 +#define PCIBAR_PREFETCH 0x8 5603 +#define PCIBAR_MEM32_MASK 0xFFFFFF80 5604 + 5605 +/* pci config status reg has a bit to indicate that capability ptr is present */ 5606 + 5607 +#define PCI_CAPPTR_PRESENT 0x0010 5608 + 3195 5609 +typedef struct _pci_config_regs { 3196 + unsigned short vendor;3197 + unsigned short device;3198 + unsigned short command;3199 + unsigned short status;3200 + unsigned char rev_id;3201 + unsigned char prog_if;3202 + unsigned char sub_class;3203 + unsigned char base_class;3204 + unsigned char cache_line_size;3205 + unsigned char latency_timer;3206 + unsigned char header_type;3207 + unsigned char bist;3208 + unsigned long base[PCI_BAR_MAX];3209 + unsigned long cardbus_cis;3210 + unsigned short subsys_vendor;3211 + unsigned short subsys_id;3212 + unsigned long baserom;3213 + unsigned long rsvd_a[PCR_RSVDA_MAX];3214 + unsigned char int_line;3215 + unsigned char int_pin;3216 + unsigned char min_gnt;3217 + unsigned char max_lat;3218 + unsigned char dev_dep[192];5610 + unsigned short vendor; 5611 + unsigned short device; 5612 + unsigned short command; 5613 + unsigned short status; 5614 + unsigned char rev_id; 5615 + unsigned char prog_if; 5616 + unsigned char sub_class; 5617 + unsigned char base_class; 5618 + unsigned char cache_line_size; 5619 + unsigned char latency_timer; 5620 + unsigned char header_type; 5621 + unsigned char bist; 5622 + unsigned long base[PCI_BAR_MAX]; 5623 + unsigned long cardbus_cis; 5624 + unsigned short subsys_vendor; 5625 + unsigned short subsys_id; 5626 + unsigned long baserom; 5627 + unsigned long rsvd_a[PCR_RSVDA_MAX]; 5628 + unsigned char int_line; 5629 + unsigned char int_pin; 5630 + unsigned char min_gnt; 5631 + unsigned char max_lat; 5632 + unsigned char dev_dep[192]; 3219 5633 +} pci_config_regs; 3220 5634 + … … 3248 5662 +#define PCI_CFG_SSID 0x2e 3249 5663 +#define PCI_CFG_ROMBAR 0x30 5664 +#define PCI_CFG_CAPPTR 0x34 3250 5665 +#define PCI_CFG_INT 0x3c 3251 5666 +#define PCI_CFG_PIN 0x3d … … 3253 5668 +#define PCI_CFG_MAXLAT 0x3f 3254 5669 + 5670 +#ifdef __NetBSD__ 5671 +#undef PCI_CLASS_DISPLAY 5672 +#undef PCI_CLASS_MEMORY 5673 +#undef PCI_CLASS_BRIDGE 5674 +#undef PCI_CLASS_INPUT 5675 +#undef PCI_CLASS_DOCK 5676 +#endif /* __NetBSD__ */ 5677 + 3255 5678 +/* Classes and subclasses */ 3256 5679 + 3257 5680 +typedef enum { 3258 + PCI_CLASS_OLD = 0,3259 + PCI_CLASS_DASDI,3260 + PCI_CLASS_NET,3261 + PCI_CLASS_DISPLAY,3262 + PCI_CLASS_MMEDIA,3263 + PCI_CLASS_MEMORY,3264 + PCI_CLASS_BRIDGE,3265 + PCI_CLASS_COMM,3266 + PCI_CLASS_BASE,3267 + PCI_CLASS_INPUT,3268 + PCI_CLASS_DOCK,3269 + PCI_CLASS_CPU,3270 + PCI_CLASS_SERIAL,3271 + PCI_CLASS_INTELLIGENT = 0xe,3272 + PCI_CLASS_SATELLITE,3273 + PCI_CLASS_CRYPT,3274 + PCI_CLASS_DSP,3275 + PCI_CLASS_MAX5681 + PCI_CLASS_OLD = 0, 5682 + PCI_CLASS_DASDI, 5683 + PCI_CLASS_NET, 5684 + PCI_CLASS_DISPLAY, 5685 + PCI_CLASS_MMEDIA, 5686 + PCI_CLASS_MEMORY, 5687 + PCI_CLASS_BRIDGE, 5688 + PCI_CLASS_COMM, 5689 + PCI_CLASS_BASE, 5690 + PCI_CLASS_INPUT, 5691 + PCI_CLASS_DOCK, 5692 + PCI_CLASS_CPU, 5693 + PCI_CLASS_SERIAL, 5694 + PCI_CLASS_INTELLIGENT = 0xe, 5695 + PCI_CLASS_SATELLITE, 5696 + PCI_CLASS_CRYPT, 5697 + PCI_CLASS_DSP, 5698 + PCI_CLASS_XOR = 0xfe 3276 5699 +} pci_classes; 3277 5700 + 3278 5701 +typedef enum { 3279 + PCI_DASDI_SCSI,3280 + PCI_DASDI_IDE,3281 + PCI_DASDI_FLOPPY,3282 + PCI_DASDI_IPI,3283 + PCI_DASDI_RAID,3284 + PCI_DASDI_OTHER = 0x805702 + PCI_DASDI_SCSI, 5703 + PCI_DASDI_IDE, 5704 + PCI_DASDI_FLOPPY, 5705 + PCI_DASDI_IPI, 5706 + PCI_DASDI_RAID, 5707 + PCI_DASDI_OTHER = 0x80 3285 5708 +} pci_dasdi_subclasses; 3286 5709 + 3287 5710 +typedef enum { 3288 + PCI_NET_ETHER,3289 + PCI_NET_TOKEN,3290 + PCI_NET_FDDI,3291 + PCI_NET_ATM,3292 + PCI_NET_OTHER = 0x805711 + PCI_NET_ETHER, 5712 + PCI_NET_TOKEN, 5713 + PCI_NET_FDDI, 5714 + PCI_NET_ATM, 5715 + PCI_NET_OTHER = 0x80 3293 5716 +} pci_net_subclasses; 3294 5717 + 3295 5718 +typedef enum { 3296 + PCI_DISPLAY_VGA,3297 + PCI_DISPLAY_XGA,3298 + PCI_DISPLAY_3D,3299 + PCI_DISPLAY_OTHER = 0x805719 + PCI_DISPLAY_VGA, 5720 + PCI_DISPLAY_XGA, 5721 + PCI_DISPLAY_3D, 5722 + PCI_DISPLAY_OTHER = 0x80 3300 5723 +} pci_display_subclasses; 3301 5724 + 3302 5725 +typedef enum { 3303 + PCI_MMEDIA_VIDEO,3304 + PCI_MMEDIA_AUDIO,3305 + PCI_MMEDIA_PHONE,3306 + PCI_MEDIA_OTHER = 0x805726 + PCI_MMEDIA_VIDEO, 5727 + PCI_MMEDIA_AUDIO, 5728 + PCI_MMEDIA_PHONE, 5729 + PCI_MEDIA_OTHER = 0x80 3307 5730 +} pci_mmedia_subclasses; 3308 5731 + 3309 5732 +typedef enum { 3310 + PCI_MEMORY_RAM,3311 + PCI_MEMORY_FLASH,3312 + PCI_MEMORY_OTHER = 0x805733 + PCI_MEMORY_RAM, 5734 + PCI_MEMORY_FLASH, 5735 + PCI_MEMORY_OTHER = 0x80 3313 5736 +} pci_memory_subclasses; 3314 5737 + 3315 5738 +typedef enum { 3316 + PCI_BRIDGE_HOST,3317 + PCI_BRIDGE_ISA,3318 + PCI_BRIDGE_EISA,3319 + PCI_BRIDGE_MC,3320 + PCI_BRIDGE_PCI,3321 + PCI_BRIDGE_PCMCIA,3322 + PCI_BRIDGE_NUBUS,3323 + PCI_BRIDGE_CARDBUS,3324 + PCI_BRIDGE_RACEWAY,3325 + PCI_BRIDGE_OTHER = 0x805739 + PCI_BRIDGE_HOST, 5740 + PCI_BRIDGE_ISA, 5741 + PCI_BRIDGE_EISA, 5742 + PCI_BRIDGE_MC, 5743 + PCI_BRIDGE_PCI, 5744 + PCI_BRIDGE_PCMCIA, 5745 + PCI_BRIDGE_NUBUS, 5746 + PCI_BRIDGE_CARDBUS, 5747 + PCI_BRIDGE_RACEWAY, 5748 + PCI_BRIDGE_OTHER = 0x80 3326 5749 +} pci_bridge_subclasses; 3327 5750 + 3328 5751 +typedef enum { 3329 + PCI_COMM_UART,3330 + PCI_COMM_PARALLEL,3331 + PCI_COMM_MULTIUART,3332 + PCI_COMM_MODEM,3333 + PCI_COMM_OTHER = 0x805752 + PCI_COMM_UART, 5753 + PCI_COMM_PARALLEL, 5754 + PCI_COMM_MULTIUART, 5755 + PCI_COMM_MODEM, 5756 + PCI_COMM_OTHER = 0x80 3334 5757 +} pci_comm_subclasses; 3335 5758 + 3336 5759 +typedef enum { 3337 + PCI_BASE_PIC,3338 + PCI_BASE_DMA,3339 + PCI_BASE_TIMER,3340 + PCI_BASE_RTC,3341 + PCI_BASE_PCI_HOTPLUG,3342 + PCI_BASE_OTHER = 0x805760 + PCI_BASE_PIC, 5761 + PCI_BASE_DMA, 5762 + PCI_BASE_TIMER, 5763 + PCI_BASE_RTC, 5764 + PCI_BASE_PCI_HOTPLUG, 5765 + PCI_BASE_OTHER = 0x80 3343 5766 +} pci_base_subclasses; 3344 5767 + 3345 5768 +typedef enum { 3346 + PCI_INPUT_KBD,3347 + PCI_INPUT_PEN,3348 + PCI_INPUT_MOUSE,3349 + PCI_INPUT_SCANNER,3350 + PCI_INPUT_GAMEPORT,3351 + PCI_INPUT_OTHER = 0x805769 + PCI_INPUT_KBD, 5770 + PCI_INPUT_PEN, 5771 + PCI_INPUT_MOUSE, 5772 + PCI_INPUT_SCANNER, 5773 + PCI_INPUT_GAMEPORT, 5774 + PCI_INPUT_OTHER = 0x80 3352 5775 +} pci_input_subclasses; 3353 5776 + 3354 5777 +typedef enum { 3355 + PCI_DOCK_GENERIC,3356 + PCI_DOCK_OTHER = 0x805778 + PCI_DOCK_GENERIC, 5779 + PCI_DOCK_OTHER = 0x80 3357 5780 +} pci_dock_subclasses; 3358 5781 + 3359 5782 +typedef enum { 3360 + PCI_CPU_386,3361 + PCI_CPU_486,3362 + PCI_CPU_PENTIUM,3363 + PCI_CPU_ALPHA = 0x10,3364 + PCI_CPU_POWERPC = 0x20,3365 + PCI_CPU_MIPS = 0x30,3366 + PCI_CPU_COPROC = 0x40,3367 + PCI_CPU_OTHER = 0x805783 + PCI_CPU_386, 5784 + PCI_CPU_486, 5785 + PCI_CPU_PENTIUM, 5786 + PCI_CPU_ALPHA = 0x10, 5787 + PCI_CPU_POWERPC = 0x20, 5788 + PCI_CPU_MIPS = 0x30, 5789 + PCI_CPU_COPROC = 0x40, 5790 + PCI_CPU_OTHER = 0x80 3368 5791 +} pci_cpu_subclasses; 3369 5792 + 3370 5793 +typedef enum { 3371 + PCI_SERIAL_IEEE1394,3372 + PCI_SERIAL_ACCESS,3373 + PCI_SERIAL_SSA,3374 + PCI_SERIAL_USB,3375 + PCI_SERIAL_FIBER,3376 + PCI_SERIAL_SMBUS,3377 + PCI_SERIAL_OTHER = 0x805794 + PCI_SERIAL_IEEE1394, 5795 + PCI_SERIAL_ACCESS, 5796 + PCI_SERIAL_SSA, 5797 + PCI_SERIAL_USB, 5798 + PCI_SERIAL_FIBER, 5799 + PCI_SERIAL_SMBUS, 5800 + PCI_SERIAL_OTHER = 0x80 3378 5801 +} pci_serial_subclasses; 3379 5802 + 3380 5803 +typedef enum { 3381 + PCI_INTELLIGENT_I2O,5804 + PCI_INTELLIGENT_I2O 3382 5805 +} pci_intelligent_subclasses; 3383 5806 + 3384 5807 +typedef enum { 3385 + PCI_SATELLITE_TV,3386 + PCI_SATELLITE_AUDIO,3387 + PCI_SATELLITE_VOICE,3388 + PCI_SATELLITE_DATA,3389 + PCI_SATELLITE_OTHER = 0x805808 + PCI_SATELLITE_TV, 5809 + PCI_SATELLITE_AUDIO, 5810 + PCI_SATELLITE_VOICE, 5811 + PCI_SATELLITE_DATA, 5812 + PCI_SATELLITE_OTHER = 0x80 3390 5813 +} pci_satellite_subclasses; 3391 5814 + 3392 5815 +typedef enum { 3393 + PCI_CRYPT_NETWORK,3394 + PCI_CRYPT_ENTERTAINMENT,3395 + PCI_CRYPT_OTHER = 0x805816 + PCI_CRYPT_NETWORK, 5817 + PCI_CRYPT_ENTERTAINMENT, 5818 + PCI_CRYPT_OTHER = 0x80 3396 5819 +} pci_crypt_subclasses; 3397 5820 + 3398 5821 +typedef enum { 3399 + PCI_DSP_DPIO,3400 + PCI_DSP_OTHER = 0x805822 + PCI_DSP_DPIO, 5823 + PCI_DSP_OTHER = 0x80 3401 5824 +} pci_dsp_subclasses; 5825 + 5826 +typedef enum { 5827 + PCI_XOR_QDMA, 5828 + PCI_XOR_OTHER = 0x80 5829 +} pci_xor_subclasses; 3402 5830 + 3403 5831 +/* Header types */ … … 3415 5843 + 3416 5844 +typedef struct _ppb_config_regs { 3417 + unsigned short vendor;3418 + unsigned short device;3419 + unsigned short command;3420 + unsigned short status;3421 + unsigned char rev_id;3422 + unsigned char prog_if;3423 + unsigned char sub_class;3424 + unsigned char base_class;3425 + unsigned char cache_line_size;3426 + unsigned char latency_timer;3427 + unsigned char header_type;3428 + unsigned char bist;3429 + unsigned long rsvd_a[PPB_RSVDA_MAX];3430 + unsigned char prim_bus;3431 + unsigned char sec_bus;3432 + unsigned char sub_bus;3433 + unsigned char sec_lat;3434 + unsigned char io_base;3435 + unsigned char io_lim;3436 + unsigned short sec_status;3437 + unsigned short mem_base;3438 + unsigned short mem_lim;3439 + unsigned short pf_mem_base;3440 + unsigned short pf_mem_lim;3441 + unsigned long pf_mem_base_hi;3442 + unsigned long pf_mem_lim_hi;3443 + unsigned short io_base_hi;3444 + unsigned short io_lim_hi;3445 + unsigned short subsys_vendor;3446 + unsigned short subsys_id;3447 + unsigned long rsvd_b;3448 + unsigned char rsvd_c;3449 + unsigned char int_pin;3450 + unsigned short bridge_ctrl;3451 + unsigned char chip_ctrl;3452 + unsigned char diag_ctrl;3453 + unsigned short arb_ctrl;3454 + unsigned long rsvd_d[PPB_RSVDD_MAX];3455 + unsigned char dev_dep[192];5845 + unsigned short vendor; 5846 + unsigned short device; 5847 + unsigned short command; 5848 + unsigned short status; 5849 + unsigned char rev_id; 5850 + unsigned char prog_if; 5851 + unsigned char sub_class; 5852 + unsigned char base_class; 5853 + unsigned char cache_line_size; 5854 + unsigned char latency_timer; 5855 + unsigned char header_type; 5856 + unsigned char bist; 5857 + unsigned long rsvd_a[PPB_RSVDA_MAX]; 5858 + unsigned char prim_bus; 5859 + unsigned char sec_bus; 5860 + unsigned char sub_bus; 5861 + unsigned char sec_lat; 5862 + unsigned char io_base; 5863 + unsigned char io_lim; 5864 + unsigned short sec_status; 5865 + unsigned short mem_base; 5866 + unsigned short mem_lim; 5867 + unsigned short pf_mem_base; 5868 + unsigned short pf_mem_lim; 5869 + unsigned long pf_mem_base_hi; 5870 + unsigned long pf_mem_lim_hi; 5871 + unsigned short io_base_hi; 5872 + unsigned short io_lim_hi; 5873 + unsigned short subsys_vendor; 5874 + unsigned short subsys_id; 5875 + unsigned long rsvd_b; 5876 + unsigned char rsvd_c; 5877 + unsigned char int_pin; 5878 + unsigned short bridge_ctrl; 5879 + unsigned char chip_ctrl; 5880 + unsigned char diag_ctrl; 5881 + unsigned short arb_ctrl; 5882 + unsigned long rsvd_d[PPB_RSVDD_MAX]; 5883 + unsigned char dev_dep[192]; 3456 5884 +} ppb_config_regs; 3457 5885 + 3458 +/* Eveything below is BRCM HND proprietary */ 5886 + 5887 +/* PCI CAPABILITY DEFINES */ 5888 +#define PCI_CAP_POWERMGMTCAP_ID 0x01 5889 +#define PCI_CAP_MSICAP_ID 0x05 5890 +#define PCI_CAP_PCIECAP_ID 0x10 5891 + 5892 +/* Data structure to define the Message Signalled Interrupt facility 5893 + * Valid for PCI and PCIE configurations 5894 + */ 5895 +typedef struct _pciconfig_cap_msi { 5896 + unsigned char capID; 5897 + unsigned char nextptr; 5898 + unsigned short msgctrl; 5899 + unsigned int msgaddr; 5900 +} pciconfig_cap_msi; 5901 + 5902 +/* Data structure to define the Power managment facility 5903 + * Valid for PCI and PCIE configurations 5904 + */ 5905 +typedef struct _pciconfig_cap_pwrmgmt { 5906 + unsigned char capID; 5907 + unsigned char nextptr; 5908 + unsigned short pme_cap; 5909 + unsigned short pme_sts_ctrl; 5910 + unsigned char pme_bridge_ext; 5911 + unsigned char data; 5912 +} pciconfig_cap_pwrmgmt; 5913 + 5914 +/* Data structure to define the PCIE capability */ 5915 +typedef struct _pciconfig_cap_pcie { 5916 + unsigned char capID; 5917 + unsigned char nextptr; 5918 + unsigned short pcie_cap; 5919 + unsigned int dev_cap; 5920 + unsigned short dev_ctrl; 5921 + unsigned short dev_status; 5922 + unsigned int link_cap; 5923 + unsigned short link_ctrl; 5924 + unsigned short link_status; 5925 +} pciconfig_cap_pcie; 5926 + 5927 +/* PCIE Enhanced CAPABILITY DEFINES */ 5928 +#define PCIE_EXTCFG_OFFSET 0x100 5929 +#define PCIE_ADVERRREP_CAPID 0x0001 5930 +#define PCIE_VC_CAPID 0x0002 5931 +#define PCIE_DEVSNUM_CAPID 0x0003 5932 +#define PCIE_PWRBUDGET_CAPID 0x0004 5933 + 5934 +/* Header to define the PCIE specific capabilities in the extended config space */ 5935 +typedef struct _pcie_enhanced_caphdr { 5936 + unsigned short capID; 5937 + unsigned short cap_ver : 4; 5938 + unsigned short next_ptr : 12; 5939 +} pcie_enhanced_caphdr; 5940 + 5941 + 5942 +/* Everything below is BRCM HND proprietary */ 5943 + 5944 + 5945 +/* Brcm PCI configuration registers */ 5946 +#define cap_list rsvd_a[0] 5947 +#define bar0_window dev_dep[0x80 - 0x40] 5948 +#define bar1_window dev_dep[0x84 - 0x40] 5949 +#define sprom_control dev_dep[0x88 - 0x40] 3459 5950 + 3460 5951 +#define PCI_BAR0_WIN 0x80 /* backplane addres space accessed by BAR0 */ … … 3466 5957 +#define PCI_TO_SB_MB 0x98 /* signal backplane interrupts */ 3467 5958 +#define PCI_BACKPLANE_ADDR 0xA0 /* address an arbitrary location on the system backplane */ 3468 +#define PCI_BACKPLANE_DATA 0xA4 /* data at the location specified by above address register*/5959 +#define PCI_BACKPLANE_DATA 0xA4 /* data at the location specified by above address */ 3469 5960 +#define PCI_GPIO_IN 0xb0 /* pci config space gpio input (>=rev3) */ 3470 5961 +#define PCI_GPIO_OUT 0xb4 /* pci config space gpio output (>=rev3) */ 3471 5962 +#define PCI_GPIO_OUTEN 0xb8 /* pci config space gpio output enable (>=rev3) */ 3472 5963 + 5964 +#define PCI_BAR0_SHADOW_OFFSET (2 * 1024) /* bar0 + 2K accesses sprom shadow (in pci core) */ 3473 5965 +#define PCI_BAR0_SPROM_OFFSET (4 * 1024) /* bar0 + 4K accesses external sprom */ 3474 5966 +#define PCI_BAR0_PCIREGS_OFFSET (6 * 1024) /* bar0 + 6K accesses pci core registers */ 5967 +#define PCI_BAR0_PCISBR_OFFSET (4 * 1024) /* pci core SB registers are at the end of the 5968 + * 8KB window, so their address is the "regular" 5969 + * address plus 4K 5970 + */ 5971 +#define PCI_BAR0_WINSZ 8192 /* bar0 window size */ 5972 + 5973 +/* On pci corerev >= 13 and all pcie, the bar0 is now 16KB and it maps: */ 5974 +#define PCI_16KB0_PCIREGS_OFFSET (8 * 1024) /* bar0 + 8K accesses pci/pcie core registers */ 5975 +#define PCI_16KB0_CCREGS_OFFSET (12 * 1024) /* bar0 + 12K accesses chipc core registers */ 5976 +#define PCI_16KBB0_WINSZ (16 * 1024) /* bar0 window size */ 3475 5977 + 3476 5978 +/* PCI_INT_STATUS */ … … 3483 5985 + 3484 5986 +/* PCI_SPROM_CONTROL */ 3485 +#define SPROM_BLANK 0x04 /* indicating a blank sprom */ 3486 +#define SPROM_WRITEEN 0x10 /* sprom write enable */ 5987 +#define SPROM_SZ_MSK 0x02 /* SPROM Size Mask */ 5988 +#define SPROM_LOCKED 0x08 /* SPROM Locked */ 5989 +#define SPROM_BLANK 0x04 /* indicating a blank SPROM */ 5990 +#define SPROM_WRITEEN 0x10 /* SPROM write enable */ 3487 5991 +#define SPROM_BOOTROM_WE 0x20 /* external bootrom write enable */ 5992 +#define SPROM_OTPIN_USE 0x80 /* device OTP In use */ 3488 5993 + 3489 5994 +#define SPROM_SIZE 256 /* sprom size in 16-bit */ … … 3493 5998 +#define PCI_CFG_CMD_STAT_TA 0x08000000 /* target abort status */ 3494 5999 + 3495 +#endif 3496 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/sbchipc.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbchipc.h3497 --- linux -2.4.32/arch/mips/bcm947xx/include/sbchipc.h 1970-01-01 01:00:00.000000000 +01003498 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/sbchipc.h 2006-09-16 15:41:31.000000000 +02003499 @@ -0,0 +1, 394@@6000 +#endif /* _h_pcicfg_ */ 6001 diff -urN linux.old/arch/mips/bcm947xx/include/sbchipc.h linux.dev/arch/mips/bcm947xx/include/sbchipc.h 6002 --- linux.old/arch/mips/bcm947xx/include/sbchipc.h 1970-01-01 01:00:00.000000000 +0100 6003 +++ linux.dev/arch/mips/bcm947xx/include/sbchipc.h 2006-10-02 21:19:59.000000000 +0200 6004 @@ -0,0 +1,516 @@ 3500 6005 +/* 3501 6006 + * SiliconBackplane Chipcommon core hardware definitions. … … 3505 6010 + * gpio interface, extbus, and support for serial and parallel flashes. 3506 6011 + * 3507 + * $Id $3508 + * Copyright 200 5, Broadcom Corporation6012 + * $Id: sbchipc.h,v 1.1.1.14 2006/04/15 01:29:08 michael Exp $ 6013 + * Copyright 2006, Broadcom Corporation 3509 6014 + * All Rights Reserved. 3510 6015 + * … … 3575 6080 + /* Watchdog timer */ 3576 6081 + uint32 watchdog; /* 0x80 */ 3577 + uint32 PAD[3]; 6082 + uint32 PAD[1]; 6083 + 6084 + /* GPIO based LED powersave registers corerev >= 16 */ 6085 + uint32 gpiotimerval; /* 0x88 */ 6086 + uint32 gpiotimeroutmask; 3578 6087 + 3579 6088 + /* clock control */ … … 3582 6091 + uint32 clockcontrol_pci; /* aka m1 */ 3583 6092 + uint32 clockcontrol_m2; /* mii/uart/mipsref */ 3584 + uint32 clockcontrol_m ips; /* aka m3*/6093 + uint32 clockcontrol_m3; /* cpu */ 3585 6094 + uint32 clkdiv; /* corerev >= 3 */ 3586 6095 + uint32 PAD[2]; … … 3610 6119 + uint32 flash_config; 3611 6120 + uint32 flash_waitcount; 3612 + uint32 PAD[116]; 6121 + uint32 PAD[44]; 6122 + 6123 + /* Clock control and hardware workarounds */ 6124 + uint32 clk_ctl_st; 6125 + uint32 hw_war; 6126 + uint32 PAD[70]; 3613 6127 + 3614 6128 + /* uarts */ … … 3641 6155 +#define CC_JTAGDR 0x38 3642 6156 +#define CC_JTAGCTRL 0x3c 6157 +#define CC_WATCHDOG 0x80 6158 +#define CC_CLKC_N 0x90 6159 +#define CC_CLKC_M0 0x94 6160 +#define CC_CLKC_M1 0x98 6161 +#define CC_CLKC_M2 0x9c 6162 +#define CC_CLKC_M3 0xa0 3643 6163 +#define CC_CLKDIV 0xa4 6164 +#define CC_SYS_CLK_CTL 0xc0 3644 6165 +#define CC_OTP 0x800 3645 6166 + 3646 6167 +/* chipid */ 3647 +#define CID_ID_MASK 0x0000ffff /* Chip Id mask */3648 +#define CID_REV_MASK 0x000f0000 /* Chip Revision mask */3649 +#define CID_REV_SHIFT 16 /* Chip Revision shift */3650 +#define CID_PKG_MASK 0x00f00000 /* Package Option mask */3651 +#define CID_PKG_SHIFT 20 /* Package Option shift */3652 +#define CID_CC_MASK 0x0f000000 /* CoreCount (corerev >= 4) */6168 +#define CID_ID_MASK 0x0000ffff /* Chip Id mask */ 6169 +#define CID_REV_MASK 0x000f0000 /* Chip Revision mask */ 6170 +#define CID_REV_SHIFT 16 /* Chip Revision shift */ 6171 +#define CID_PKG_MASK 0x00f00000 /* Package Option mask */ 6172 +#define CID_PKG_SHIFT 20 /* Package Option shift */ 6173 +#define CID_CC_MASK 0x0f000000 /* CoreCount (corerev >= 4) */ 3653 6174 +#define CID_CC_SHIFT 24 3654 6175 + 3655 6176 +/* capabilities */ 3656 +#define CAP_UARTS_MASK 0x00000003 /* Number of uarts */ 3657 +#define CAP_MIPSEB 0x00000004 /* MIPS is in big-endian mode */ 3658 +#define CAP_UCLKSEL 0x00000018 /* UARTs clock select */ 3659 +#define CAP_UINTCLK 0x00000008 /* UARTs are driven by internal divided clock */ 3660 +#define CAP_UARTGPIO 0x00000020 /* UARTs own Gpio's 15:12 */ 3661 +#define CAP_EXTBUS 0x00000040 /* External bus present */ 3662 +#define CAP_FLASH_MASK 0x00000700 /* Type of flash */ 3663 +#define CAP_PLL_MASK 0x00038000 /* Type of PLL */ 3664 +#define CAP_PWR_CTL 0x00040000 /* Power control */ 3665 +#define CAP_OTPSIZE 0x00380000 /* OTP Size (0 = none) */ 3666 +#define CAP_OTPSIZE_SHIFT 19 /* OTP Size shift */ 3667 +#define CAP_JTAGP 0x00400000 /* JTAG Master Present */ 3668 +#define CAP_ROM 0x00800000 /* Internal boot rom active */ 6177 +#define CAP_UARTS_MASK 0x00000003 /* Number of uarts */ 6178 +#define CAP_MIPSEB 0x00000004 /* MIPS is in big-endian mode */ 6179 +#define CAP_UCLKSEL 0x00000018 /* UARTs clock select */ 6180 +#define CAP_UINTCLK 0x00000008 /* UARTs are driven by internal divided clock */ 6181 +#define CAP_UARTGPIO 0x00000020 /* UARTs own Gpio's 15:12 */ 6182 +#define CAP_EXTBUS_MASK 0x000000c0 /* External bus mask */ 6183 +#define CAP_EXTBUS_NONE 0x00000000 /* No ExtBus present */ 6184 +#define CAP_EXTBUS_FULL 0x00000040 /* ExtBus: PCMCIA, IDE & Prog */ 6185 +#define CAP_EXTBUS_PROG 0x00000080 /* ExtBus: ProgIf only */ 6186 +#define CAP_FLASH_MASK 0x00000700 /* Type of flash */ 6187 +#define CAP_PLL_MASK 0x00038000 /* Type of PLL */ 6188 +#define CAP_PWR_CTL 0x00040000 /* Power control */ 6189 +#define CAP_OTPSIZE 0x00380000 /* OTP Size (0 = none) */ 6190 +#define CAP_OTPSIZE_SHIFT 19 /* OTP Size shift */ 6191 +#define CAP_OTPSIZE_BASE 5 /* OTP Size base */ 6192 +#define CAP_JTAGP 0x00400000 /* JTAG Master Present */ 6193 +#define CAP_ROM 0x00800000 /* Internal boot rom active */ 6194 +#define CAP_BKPLN64 0x08000000 /* 64-bit backplane */ 3669 6195 + 3670 6196 +/* PLL type */ 3671 6197 +#define PLL_NONE 0x00000000 3672 +#define PLL_TYPE1 0x00010000 /* 48Mhz base, 3 dividers */3673 +#define PLL_TYPE2 0x00020000 /* 48Mhz, 4 dividers */3674 +#define PLL_TYPE3 0x00030000 /* 25Mhz, 2 dividers */3675 +#define PLL_TYPE4 0x00008000 /* 48Mhz, 4 dividers */3676 +#define PLL_TYPE5 0x00018000 /* 25Mhz, 4 dividers */3677 +#define PLL_TYPE6 0x00028000 /* 100/200 or 120/240 only */3678 +#define PLL_TYPE7 0x00038000 /* 25Mhz, 4 dividers */6198 +#define PLL_TYPE1 0x00010000 /* 48Mhz base, 3 dividers */ 6199 +#define PLL_TYPE2 0x00020000 /* 48Mhz, 4 dividers */ 6200 +#define PLL_TYPE3 0x00030000 /* 25Mhz, 2 dividers */ 6201 +#define PLL_TYPE4 0x00008000 /* 48Mhz, 4 dividers */ 6202 +#define PLL_TYPE5 0x00018000 /* 25Mhz, 4 dividers */ 6203 +#define PLL_TYPE6 0x00028000 /* 100/200 or 120/240 only */ 6204 +#define PLL_TYPE7 0x00038000 /* 25Mhz, 4 dividers */ 3679 6205 + 3680 6206 +/* corecontrol */ 3681 +#define CC_UARTCLKO 0x00000001 /* Drive UART with internal clock */ 3682 +#define CC_SE 0x00000002 /* sync clk out enable (corerev >= 3) */ 6207 +#define CC_UARTCLKO 0x00000001 /* Drive UART with internal clock */ 6208 +#define CC_SE 0x00000002 /* sync clk out enable (corerev >= 3) */ 6209 + 6210 +/* chipcontrol */ 6211 +#define CHIPCTRL_4321A0_DEFAULT 0x3a4 6212 +#define CHIPCTRL_4321A1_DEFAULT 0x0a4 6213 + 6214 +/* Fields in the otpstatus register */ 6215 +#define OTPS_PROGFAIL 0x80000000 6216 +#define OTPS_PROTECT 0x00000007 6217 +#define OTPS_HW_PROTECT 0x00000001 6218 +#define OTPS_SW_PROTECT 0x00000002 6219 +#define OTPS_CID_PROTECT 0x00000004 6220 + 6221 +/* Fields in the otpcontrol register */ 6222 +#define OTPC_RECWAIT 0xff000000 6223 +#define OTPC_PROGWAIT 0x00ffff00 6224 +#define OTPC_PRW_SHIFT 8 6225 +#define OTPC_MAXFAIL 0x00000038 6226 +#define OTPC_VSEL 0x00000006 6227 +#define OTPC_SELVL 0x00000001 6228 + 6229 +/* Fields in otpprog */ 6230 +#define OTPP_COL_MASK 0x000000ff 6231 +#define OTPP_ROW_MASK 0x0000ff00 6232 +#define OTPP_ROW_SHIFT 8 6233 +#define OTPP_READERR 0x10000000 6234 +#define OTPP_VALUE 0x20000000 6235 +#define OTPP_VALUE_SHIFT 29 6236 +#define OTPP_READ 0x40000000 6237 +#define OTPP_START 0x80000000 6238 +#define OTPP_BUSY 0x80000000 3683 6239 + 3684 6240 +/* jtagcmd */ … … 3694 6250 +#define JCMD0_ACC_PDR 0x00005000 3695 6251 +#define JCMD0_IRW_MASK 0x00000f00 3696 +#define JCMD_ACC_MASK 0x000f0000 /* Changes for corerev 11 */6252 +#define JCMD_ACC_MASK 0x000f0000 /* Changes for corerev 11 */ 3697 6253 +#define JCMD_ACC_IRDR 0x00000000 3698 6254 +#define JCMD_ACC_DR 0x00010000 … … 3706 6262 + 3707 6263 +/* jtagctrl */ 3708 +#define JCTRL_FORCE_CLK 4 /* Force clock */3709 +#define JCTRL_EXT_EN 2 /* Enable external targets */3710 +#define JCTRL_EN 1 /* Enable Jtag master */6264 +#define JCTRL_FORCE_CLK 4 /* Force clock */ 6265 +#define JCTRL_EXT_EN 2 /* Enable external targets */ 6266 +#define JCTRL_EN 1 /* Enable Jtag master */ 3711 6267 + 3712 6268 +/* Fields in clkdiv */ 3713 6269 +#define CLKD_SFLASH 0x0f000000 3714 +#define CLKD_SFLASH_SHIFT 246270 +#define CLKD_SFLASH_SHIFT 24 3715 6271 +#define CLKD_OTP 0x000f0000 3716 6272 +#define CLKD_OTP_SHIFT 16 3717 6273 +#define CLKD_JTAG 0x00000f00 3718 +#define CLKD_JTAG_SHIFT 8 6274 +#define CLKD_JTAG_SHIFT 8 3719 6275 +#define CLKD_UART 0x000000ff 3720 6276 + 3721 6277 +/* intstatus/intmask */ 3722 +#define CI_GPIO 0x00000001 /* gpio intr */3723 +#define CI_EI 0x00000002 /* ro: ext intr pin (corerev >= 3) */3724 +#define CI_WDRESET 0x80000000 /* watchdog reset occurred */6278 +#define CI_GPIO 0x00000001 /* gpio intr */ 6279 +#define CI_EI 0x00000002 /* ro: ext intr pin (corerev >= 3) */ 6280 +#define CI_WDRESET 0x80000000 /* watchdog reset occurred */ 3725 6281 + 3726 6282 +/* slow_clk_ctl */ 3727 +#define SCC_SS_MASK 0x00000007 /* slow clock source mask */ 3728 +#define SCC_SS_LPO 0x00000000 /* source of slow clock is LPO */ 3729 +#define SCC_SS_XTAL 0x00000001 /* source of slow clock is crystal */ 3730 +#define SCC_SS_PCI 0x00000002 /* source of slow clock is PCI */ 3731 +#define SCC_LF 0x00000200 /* LPOFreqSel, 1: 160Khz, 0: 32KHz */ 3732 +#define SCC_LP 0x00000400 /* LPOPowerDown, 1: LPO is disabled, 0: LPO is enabled */ 3733 +#define SCC_FS 0x00000800 /* ForceSlowClk, 1: sb/cores running on slow clock, 0: power logic control */ 3734 +#define SCC_IP 0x00001000 /* IgnorePllOffReq, 1/0: power logic ignores/honors PLL clock disable requests from core */ 3735 +#define SCC_XC 0x00002000 /* XtalControlEn, 1/0: power logic does/doesn't disable crystal when appropriate */ 3736 +#define SCC_XP 0x00004000 /* XtalPU (RO), 1/0: crystal running/disabled */ 3737 +#define SCC_CD_MASK 0xffff0000 /* ClockDivider mask, SlowClk = 1/(4+divisor) * crystal/PCI clock */ 3738 +#define SCC_CD_SHF 16 /* CLockDivider shift */ 3739 + 3740 +/* sys_clk_ctl */ 3741 +#define SYCC_IE 0x00000001 /* ILPen: Enable Idle Low Power */ 3742 +#define SYCC_AE 0x00000002 /* ALPen: Enable Active Low Power */ 3743 +#define SYCC_FP 0x00000004 /* ForcePLLOn */ 3744 +#define SYCC_AR 0x00000008 /* Force ALP (or HT if ALPen is not set */ 3745 +#define SYCC_HR 0x00000010 /* Force HT */ 3746 +#define SYCC_CD_MASK 0xffff0000 /* ClockDivider mask, SlowClk = 1/(4+divisor) * crystal/PCI clock */ 3747 +#define SYCC_CD_SHF 16 /* CLockDivider shift */ 6283 +#define SCC_SS_MASK 0x00000007 /* slow clock source mask */ 6284 +#define SCC_SS_LPO 0x00000000 /* source of slow clock is LPO */ 6285 +#define SCC_SS_XTAL 0x00000001 /* source of slow clock is crystal */ 6286 +#define SCC_SS_PCI 0x00000002 /* source of slow clock is PCI */ 6287 +#define SCC_LF 0x00000200 /* LPOFreqSel, 1: 160Khz, 0: 32KHz */ 6288 +#define SCC_LP 0x00000400 /* LPOPowerDown, 1: LPO is disabled, 6289 + * 0: LPO is enabled 6290 + */ 6291 +#define SCC_FS 0x00000800 /* ForceSlowClk, 1: sb/cores running on slow clock, 6292 + * 0: power logic control 6293 + */ 6294 +#define SCC_IP 0x00001000 /* IgnorePllOffReq, 1/0: power logic ignores/honors 6295 + * PLL clock disable requests from core 6296 + */ 6297 +#define SCC_XC 0x00002000 /* XtalControlEn, 1/0: power logic does/doesn't 6298 + * disable crystal when appropriate 6299 + */ 6300 +#define SCC_XP 0x00004000 /* XtalPU (RO), 1/0: crystal running/disabled */ 6301 +#define SCC_CD_MASK 0xffff0000 /* ClockDivider (SlowClk = 1/(4+divisor)) */ 6302 +#define SCC_CD_SHIFT 16 6303 + 6304 +/* system_clk_ctl */ 6305 +#define SYCC_IE 0x00000001 /* ILPen: Enable Idle Low Power */ 6306 +#define SYCC_AE 0x00000002 /* ALPen: Enable Active Low Power */ 6307 +#define SYCC_FP 0x00000004 /* ForcePLLOn */ 6308 +#define SYCC_AR 0x00000008 /* Force ALP (or HT if ALPen is not set */ 6309 +#define SYCC_HR 0x00000010 /* Force HT */ 6310 +#define SYCC_CD_MASK 0xffff0000 /* ClkDiv (ILP = 1/(4 * (divisor + 1)) */ 6311 +#define SYCC_CD_SHIFT 16 6312 + 6313 +/* gpiotimerval */ 6314 +#define GPIO_ONTIME_SHIFT 16 3748 6315 + 3749 6316 +/* clockcontrol_n */ 3750 +#define CN_N1_MASK 0x3f /* n1 control */3751 +#define CN_N2_MASK 0x3f00 /* n2 control */6317 +#define CN_N1_MASK 0x3f /* n1 control */ 6318 +#define CN_N2_MASK 0x3f00 /* n2 control */ 3752 6319 +#define CN_N2_SHIFT 8 3753 +#define CN_PLLC_MASK 0xf0000 /* pll control */6320 +#define CN_PLLC_MASK 0xf0000 /* pll control */ 3754 6321 +#define CN_PLLC_SHIFT 16 3755 6322 + 3756 6323 +/* clockcontrol_sb/pci/uart */ 3757 +#define CC_M1_MASK 0x3f /* m1 control */3758 +#define CC_M2_MASK 0x3f00 /* m2 control */6324 +#define CC_M1_MASK 0x3f /* m1 control */ 6325 +#define CC_M2_MASK 0x3f00 /* m2 control */ 3759 6326 +#define CC_M2_SHIFT 8 3760 +#define CC_M3_MASK 0x3f0000 /* m3 control */6327 +#define CC_M3_MASK 0x3f0000 /* m3 control */ 3761 6328 +#define CC_M3_SHIFT 16 3762 +#define CC_MC_MASK 0x1f000000 /* mux control */6329 +#define CC_MC_MASK 0x1f000000 /* mux control */ 3763 6330 +#define CC_MC_SHIFT 24 3764 6331 + 3765 +/* N3M Clock control values for 125Mhz */3766 +#define CC_125_N 0x0802 /* Default values for bcm4310 */3767 +#define CC_125_M 0x040200093768 +#define CC_125_M25 0x110900093769 +#define CC_125_M33 0x110900053770 +3771 6332 +/* N3M Clock control magic field values */ 3772 +#define CC_F6_2 0x02 /* A factor of 2 in */3773 +#define CC_F6_3 0x03 /* 6-bit fields like */3774 +#define CC_F6_4 0x05 /* N1, M1 or M3 */6333 +#define CC_F6_2 0x02 /* A factor of 2 in */ 6334 +#define CC_F6_3 0x03 /* 6-bit fields like */ 6335 +#define CC_F6_4 0x05 /* N1, M1 or M3 */ 3775 6336 +#define CC_F6_5 0x09 3776 6337 +#define CC_F6_6 0x11 3777 6338 +#define CC_F6_7 0x21 3778 6339 + 3779 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */6340 +#define CC_F5_BIAS 5 /* 5-bit fields get this added */ 3780 6341 + 3781 6342 +#define CC_MC_BYPASS 0x08 … … 3786 6347 + 3787 6348 +/* Type 2 Clock control magic field values */ 3788 +#define CC_T2_BIAS 2 /* n1, n2, m1 & m3 bias */3789 +#define CC_T2M2_BIAS 3 /* m2 bias */6349 +#define CC_T2_BIAS 2 /* n1, n2, m1 & m3 bias */ 6350 +#define CC_T2M2_BIAS 3 /* m2 bias */ 3790 6351 + 3791 6352 +#define CC_T2MC_M1BYP 1 … … 3794 6355 + 3795 6356 +/* Type 6 Clock control magic field values */ 3796 +#define CC_T6_MMASK 1 /* bits of interest in m */3797 +#define CC_T6_M0 120000000 /* sb clock for m = 0 */3798 +#define CC_T6_M1 100000000 /* sb clock for m = 1 */6357 +#define CC_T6_MMASK 1 /* bits of interest in m */ 6358 +#define CC_T6_M0 120000000 /* sb clock for m = 0 */ 6359 +#define CC_T6_M1 100000000 /* sb clock for m = 1 */ 3799 6360 +#define SB2MIPS_T6(sb) (2 * (sb)) 3800 6361 + 3801 6362 +/* Common clock base */ 3802 +#define CC_CLOCK_BASE1 24000000 /* Half the clock freq */ 3803 +#define CC_CLOCK_BASE2 12500000 /* Alternate crystal on some PLL's */ 6363 +#define CC_CLOCK_BASE1 24000000 /* Half the clock freq */ 6364 +#define CC_CLOCK_BASE2 12500000 /* Alternate crystal on some PLL's */ 6365 + 6366 +/* Clock control values for 200Mhz in 5350 */ 6367 +#define CLKC_5350_N 0x0311 6368 +#define CLKC_5350_M 0x04020009 3804 6369 + 3805 6370 +/* Flash types in the chipcommon capabilities register */ … … 3809 6374 +#define PFLASH 0x700 /* Parallel flash */ 3810 6375 + 3811 +/* Bits in the config registers */6376 +/* Bits in the ExtBus config registers */ 3812 6377 +#define CC_CFG_EN 0x0001 /* Enable */ 3813 6378 +#define CC_CFG_EM_MASK 0x000e /* Extif Mode */ 3814 +#define CC_CFG_EM_ASYNC 0x000 2/* Async/Parallel flash */3815 +#define CC_CFG_EM_SYNC 0x000 4/* Synchronous */3816 +#define CC_CFG_EM_PCMCIA 0x000 8/* PCMCIA */3817 +#define CC_CFG_EM_IDE 0x000 a/* IDE */6379 +#define CC_CFG_EM_ASYNC 0x0000 /* Async/Parallel flash */ 6380 +#define CC_CFG_EM_SYNC 0x0002 /* Synchronous */ 6381 +#define CC_CFG_EM_PCMCIA 0x0004 /* PCMCIA */ 6382 +#define CC_CFG_EM_IDE 0x0006 /* IDE */ 3818 6383 +#define CC_CFG_DS 0x0010 /* Data size, 0=8bit, 1=16bit */ 3819 6384 +#define CC_CFG_CD_MASK 0x0060 /* Sync: Clock divisor */ … … 3821 6386 +#define CC_CFG_SB 0x0100 /* Sync: Size/Bytestrobe */ 3822 6387 + 6388 +/* ExtBus address space */ 6389 +#define CC_EB_BASE 0x1a000000 /* Chipc ExtBus base address */ 6390 +#define CC_EB_PCMCIA_MEM 0x1a000000 /* PCMCIA 0 memory base address */ 6391 +#define CC_EB_PCMCIA_IO 0x1a200000 /* PCMCIA 0 I/O base address */ 6392 +#define CC_EB_PCMCIA_CFG 0x1a400000 /* PCMCIA 0 config base address */ 6393 +#define CC_EB_IDE 0x1a800000 /* IDE memory base */ 6394 +#define CC_EB_PCMCIA1_MEM 0x1a800000 /* PCMCIA 1 memory base address */ 6395 +#define CC_EB_PCMCIA1_IO 0x1aa00000 /* PCMCIA 1 I/O base address */ 6396 +#define CC_EB_PCMCIA1_CFG 0x1ac00000 /* PCMCIA 1 config base address */ 6397 +#define CC_EB_PROGIF 0x1b000000 /* ProgIF Async/Sync base address */ 6398 + 6399 + 3823 6400 +/* Start/busy bit in flashcontrol */ 6401 +#define SFLASH_OPCODE 0x000000ff 6402 +#define SFLASH_ACTION 0x00000700 3824 6403 +#define SFLASH_START 0x80000000 3825 6404 +#define SFLASH_BUSY SFLASH_START 3826 6405 + 3827 +/* flashcontrol opcodes for ST flashes */ 6406 +/* flashcontrol action codes */ 6407 +#define SFLASH_ACT_OPONLY 0x0000 /* Issue opcode only */ 6408 +#define SFLASH_ACT_OP1D 0x0100 /* opcode + 1 data byte */ 6409 +#define SFLASH_ACT_OP3A 0x0200 /* opcode + 3 address bytes */ 6410 +#define SFLASH_ACT_OP3A1D 0x0300 /* opcode + 3 addres & 1 data bytes */ 6411 +#define SFLASH_ACT_OP3A4D 0x0400 /* opcode + 3 addres & 4 data bytes */ 6412 +#define SFLASH_ACT_OP3A4X4D 0x0500 /* opcode + 3 addres, 4 don't care & 4 data bytes */ 6413 +#define SFLASH_ACT_OP3A1X4D 0x0700 /* opcode + 3 addres, 1 don't care & 4 data bytes */ 6414 + 6415 +/* flashcontrol action+opcodes for ST flashes */ 3828 6416 +#define SFLASH_ST_WREN 0x0006 /* Write Enable */ 3829 6417 +#define SFLASH_ST_WRDIS 0x0004 /* Write Disable */ … … 3844 6432 +#define SFLASH_ST_SRWD 0x80 /* Status Register Write Disable */ 3845 6433 + 3846 +/* flashcontrol opcodes for Atmel flashes */6434 +/* flashcontrol action+opcodes for Atmel flashes */ 3847 6435 +#define SFLASH_AT_READ 0x07e8 3848 6436 +#define SFLASH_AT_PAGE_READ 0x07d2 … … 3873 6461 +#define SFLASH_AT_ID_SHIFT 3 3874 6462 + 3875 +/* OTP conventions */ 3876 +#define OTP_HWBASE 0 3877 +#define OTP_SWLIM 256 3878 +#define OTP_CIDBASE 256 3879 +#define OTP_CIDLIM 260 3880 + 3881 +#define OTP_BOUNDARY 252 3882 +#define OTP_HWSIGN 253 3883 +#define OTP_SWSIGN 254 3884 +#define OTP_CIDSIGN 255 3885 + 3886 +#define OTP_CID 256 3887 +#define OTP_PKG 257 3888 +#define OTP_FID 258 6463 +/* OTP regions */ 6464 +#define OTP_HW_REGION OTPS_HW_PROTECT 6465 +#define OTP_SW_REGION OTPS_SW_PROTECT 6466 +#define OTP_CID_REGION OTPS_CID_PROTECT 6467 + 6468 +/* OTP regions (Byte offsets from otp size) */ 6469 +#define OTP_SWLIM_OFF (-8) 6470 +#define OTP_CIDBASE_OFF 0 6471 +#define OTP_CIDLIM_OFF 8 6472 + 6473 +/* Predefined OTP words (Word offset from otp size) */ 6474 +#define OTP_BOUNDARY_OFF (-4) 6475 +#define OTP_HWSIGN_OFF (-3) 6476 +#define OTP_SWSIGN_OFF (-2) 6477 +#define OTP_CIDSIGN_OFF (-1) 6478 + 6479 +#define OTP_CID_OFF 0 6480 +#define OTP_PKG_OFF 1 6481 +#define OTP_FID_OFF 2 6482 +#define OTP_RSV_OFF 3 6483 +#define OTP_LIM_OFF 4 3889 6484 + 3890 6485 +#define OTP_SIGNATURE 0x578a 3891 6486 +#define OTP_MAGIC 0x4e56 3892 6487 + 6488 +/* 6489 + * These are the UART port assignments, expressed as offsets from the base 6490 + * register. These assignments should hold for any serial port based on 6491 + * a 8250, 16450, or 16550(A). 6492 + */ 6493 + 6494 +#define UART_RX 0 /* In: Receive buffer (DLAB=0) */ 6495 +#define UART_TX 0 /* Out: Transmit buffer (DLAB=0) */ 6496 +#define UART_DLL 0 /* Out: Divisor Latch Low (DLAB=1) */ 6497 +#define UART_IER 1 /* In/Out: Interrupt Enable Register (DLAB=0) */ 6498 +#define UART_DLM 1 /* Out: Divisor Latch High (DLAB=1) */ 6499 +#define UART_IIR 2 /* In: Interrupt Identity Register */ 6500 +#define UART_FCR 2 /* Out: FIFO Control Register */ 6501 +#define UART_LCR 3 /* Out: Line Control Register */ 6502 +#define UART_MCR 4 /* Out: Modem Control Register */ 6503 +#define UART_LSR 5 /* In: Line Status Register */ 6504 +#define UART_MSR 6 /* In: Modem Status Register */ 6505 +#define UART_SCR 7 /* I/O: Scratch Register */ 6506 +#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */ 6507 +#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */ 6508 +#define UART_MCR_OUT2 0x08 /* MCR GPIO out 2 */ 6509 +#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */ 6510 +#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */ 6511 +#define UART_LSR_RXRDY 0x01 /* Receiver ready */ 6512 +#define UART_FCR_FIFO_ENABLE 1 /* FIFO control register bit controlling FIFO enable/disable */ 6513 + 6514 +/* Interrupt Enable Register (IER) bits */ 6515 +#define UART_IER_EDSSI 8 /* enable modem status interrupt */ 6516 +#define UART_IER_ELSI 4 /* enable receiver line status interrupt */ 6517 +#define UART_IER_ETBEI 2 /* enable transmitter holding register empty interrupt */ 6518 +#define UART_IER_ERBFI 1 /* enable data available interrupt */ 6519 + 3893 6520 +#endif /* _SBCHIPC_H */ 3894 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/sbconfig.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbconfig.h3895 --- linux -2.4.32/arch/mips/bcm947xx/include/sbconfig.h 1970-01-01 01:00:00.000000000 +01003896 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/sbconfig.h 2006-09-16 15:41:31.000000000 +02003897 @@ -0,0 +1,3 24@@6521 diff -urN linux.old/arch/mips/bcm947xx/include/sbconfig.h linux.dev/arch/mips/bcm947xx/include/sbconfig.h 6522 --- linux.old/arch/mips/bcm947xx/include/sbconfig.h 1970-01-01 01:00:00.000000000 +0100 6523 +++ linux.dev/arch/mips/bcm947xx/include/sbconfig.h 2006-10-02 21:19:59.000000000 +0200 6524 @@ -0,0 +1,369 @@ 3898 6525 +/* 3899 6526 + * Broadcom SiliconBackplane hardware register definitions. 3900 6527 + * 3901 + * Copyright 2005, Broadcom Corporation 3902 + * All Rights Reserved. 3903 + * 3904 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 3905 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 3906 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 3907 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 3908 + * $Id$ 6528 + * Copyright 2006, Broadcom Corporation 6529 + * All Rights Reserved. 6530 + * 6531 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 6532 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 6533 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 6534 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 6535 + * 6536 + * $Id: sbconfig.h,v 1.1.1.11 2006/02/27 03:43:16 honor Exp $ 3909 6537 + */ 3910 6538 + … … 3925 6553 +#define SB_SDRAM_BASE 0x00000000 /* Physical SDRAM */ 3926 6554 +#define SB_PCI_MEM 0x08000000 /* Host Mode sb2pcitranslation0 (64 MB) */ 6555 +#define SB_PCI_MEM_SZ (64 * 1024 * 1024) 3927 6556 +#define SB_PCI_CFG 0x0c000000 /* Host Mode sb2pcitranslation1 (64 MB) */ 3928 6557 +#define SB_SDRAM_SWAPPED 0x10000000 /* Byteswapped Physical SDRAM */ … … 3934 6563 + 3935 6564 +#define SB_EXTIF_BASE 0x1f000000 /* External Interface region base address */ 3936 +#define SB_FLASH1 0x1fc00000 /* Flash Region 1 */ 3937 +#define SB_FLASH1_SZ 0x00400000 /* Size of Flash Region 1 */ 6565 +#define SB_FLASH1 0x1fc00000 /* MIPS Flash Region 1 */ 6566 +#define SB_FLASH1_SZ 0x00400000 /* MIPS Size of Flash Region 1 */ 6567 + 6568 +#define SB_ROM 0x20000000 /* ARM ROM */ 6569 +#define SB_SRAM2 0x80000000 /* ARM SRAM Region 2 */ 6570 +#define SB_ARM_FLASH1 0xffff0000 /* ARM Flash Region 1 */ 6571 +#define SB_ARM_FLASH1_SZ 0x00010000 /* ARM Size of Flash Region 1 */ 3938 6572 + 3939 6573 +#define SB_PCI_DMA 0x40000000 /* Client Mode sb2pcitranslation2 (1 GB) */ 3940 6574 +#define SB_PCI_DMA_SZ 0x40000000 /* Client Mode sb2pcitranslation2 size in bytes */ 6575 +#define SB_PCIE_DMA_L32 0x00000000 /* PCIE Client Mode sb2pcitranslation2 6576 + * (2 ZettaBytes), low 32 bits 6577 + */ 6578 +#define SB_PCIE_DMA_H32 0x80000000 /* PCIE Client Mode sb2pcitranslation2 6579 + * (2 ZettaBytes), high 32 bits 6580 + */ 3941 6581 +#define SB_EUART (SB_EXTIF_BASE + 0x00800000) 3942 6582 +#define SB_LED (SB_EXTIF_BASE + 0x00900000) 6583 + 3943 6584 + 3944 6585 +/* enumeration space related defs */ 3945 6586 +#define SB_CORE_SIZE 0x1000 /* each core gets 4Kbytes for registers */ 3946 6587 +#define SB_MAXCORES ((SB_ENUM_LIM - SB_ENUM_BASE)/SB_CORE_SIZE) 6588 +#define SB_MAXFUNCS 4 /* max. # functions per core */ 3947 6589 +#define SBCONFIGOFF 0xf00 /* core sbconfig regs are top 256bytes of regs */ 3948 6590 +#define SBCONFIGSIZE 256 /* sizeof (sbconfig_t) */ … … 3977 6619 +#define SBIDLOW 0xf8 3978 6620 +#define SBIDHIGH 0xfc 6621 + 6622 +/* All the previous registers are above SBCONFIGOFF, but with Sonics 2.3, we have 6623 + * a few registers *below* that line. I think it would be very confusing to try 6624 + * and change the value of SBCONFIGOFF, so I'm definig them as absolute offsets here, 6625 + */ 6626 + 6627 +#define SBIMERRLOGA 0xea8 6628 +#define SBIMERRLOG 0xeb0 6629 +#define SBTMPORTCONNID0 0xed8 6630 +#define SBTMPORTLOCK0 0xef8 3979 6631 + 3980 6632 +#ifndef _LANGUAGE_ASSEMBLY … … 4056 6708 +/* sbtmstatelow */ 4057 6709 +#define SBTML_RESET 0x1 /* reset */ 4058 +#define SBTML_REJ 0x2 /* reject */ 6710 +#define SBTML_REJ_MASK 0x6 /* reject */ 6711 +#define SBTML_REJ_SHIFT 1 4059 6712 +#define SBTML_CLK 0x10000 /* clock enable */ 4060 6713 +#define SBTML_FGC 0x20000 /* force gated clocks on */ … … 4069 6722 +#define SBTMH_TO 0x00000020 /* timeout (sonics >= 2.3) */ 4070 6723 +#define SBTMH_FL_MASK 0x1fff0000 /* core-specific flags */ 6724 +#define SBTMH_DMA64 0x10000000 /* supports DMA with 64-bit addresses */ 4071 6725 +#define SBTMH_GCR 0x20000000 /* gated clock request */ 4072 6726 +#define SBTMH_BISTF 0x40000000 /* bist failed */ 4073 6727 +#define SBTMH_BISTD 0x80000000 /* bist done */ 6728 + 4074 6729 + 4075 6730 +/* sbbwa0 */ … … 4160 6815 +#define SBIDL_RV_MASK 0xf0000000 /* sonics backplane revision code */ 4161 6816 +#define SBIDL_RV_SHIFT 28 6817 +#define SBIDL_RV_2_2 0x00000000 /* version 2.2 or earlier */ 6818 +#define SBIDL_RV_2_3 0x10000000 /* version 2.3 */ 4162 6819 + 4163 6820 +/* sbidhigh */ 4164 +#define SBIDH_RC_MASK 0xf /* revision code*/ 4165 +#define SBIDH_CC_MASK 0xfff0 /* core code */ 6821 +#define SBIDH_RC_MASK 0x000f /* revision code */ 6822 +#define SBIDH_RCE_MASK 0x7000 /* revision code extension field */ 6823 +#define SBIDH_RCE_SHIFT 8 6824 +#define SBCOREREV(sbidh) \ 6825 + ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | ((sbidh) & SBIDH_RC_MASK)) 6826 +#define SBIDH_CC_MASK 0x8ff0 /* core code */ 4166 6827 +#define SBIDH_CC_SHIFT 4 4167 6828 +#define SBIDH_VC_MASK 0xffff0000 /* vendor code */ … … 4174 6835 + 4175 6836 +/* core codes */ 6837 +#define SB_NODEV 0x700 /* Invalid coreid */ 4176 6838 +#define SB_CC 0x800 /* chipcommon core */ 4177 6839 +#define SB_ILINE20 0x801 /* iline20 core */ … … 4186 6848 +#define SB_IPSEC 0x80b /* ipsec core */ 4187 6849 +#define SB_PCMCIA 0x80d /* pcmcia core */ 6850 +#define SB_SDIOD SB_PCMCIA /* pcmcia core has sdio device */ 4188 6851 +#define SB_SOCRAM 0x80e /* internal memory core */ 4189 6852 +#define SB_MEMC 0x80f /* memc sdram core */ … … 4200 6863 +#define SB_SATAXOR 0x81e /* serial ATA & XOR DMA core */ 4201 6864 +#define SB_GIGETH 0x81f /* gigabit ethernet core */ 6865 +#define SB_PCIE 0x820 /* pci express core */ 6866 +#define SB_MIMO 0x821 /* MIMO phy core */ 6867 +#define SB_SRAMC 0x822 /* SRAM controller core */ 6868 +#define SB_MINIMAC 0x823 /* MINI MAC/phy core */ 6869 +#define SB_ARM11 0x824 /* ARM 1176 core */ 6870 +#define SB_ARM7 0x825 /* ARM 7tdmi core */ 6871 + 6872 +#define SB_CC_IDX 0 /* chipc, when present, is always core 0 */ 4202 6873 + 4203 6874 +/* Not really related to Silicon Backplane, but a couple of software … … 4218 6889 +#define BISZ_BSSST_IDX 5 /* 5: text start */ 4219 6890 +#define BISZ_BSSEND_IDX 6 /* 6: text start */ 6891 +#define BISZ_SIZE 7 /* descriptor size in 32-bit intergers */ 4220 6892 + 4221 6893 +#endif /* _SBCONFIG_H */ 4222 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/sbextif.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbextif.h4223 --- linux -2.4.32/arch/mips/bcm947xx/include/sbextif.h 1970-01-01 01:00:00.000000000 +01004224 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/sbextif.h 2006-09-16 15:41:31.000000000 +02004225 @@ -0,0 +1,24 2@@6894 diff -urN linux.old/arch/mips/bcm947xx/include/sbextif.h linux.dev/arch/mips/bcm947xx/include/sbextif.h 6895 --- linux.old/arch/mips/bcm947xx/include/sbextif.h 1970-01-01 01:00:00.000000000 +0100 6896 +++ linux.dev/arch/mips/bcm947xx/include/sbextif.h 2006-10-02 21:19:59.000000000 +0200 6897 @@ -0,0 +1,243 @@ 4226 6898 +/* 4227 6899 + * Hardware-specific External Interface I/O core definitions … … 4238 6910 + * frequency control, a watchdog interrupt timer, and a GPIO interface. 4239 6911 + * 4240 + * Copyright 2005, Broadcom Corporation 4241 + * All Rights Reserved. 4242 + * 4243 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 4244 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 4245 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 4246 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 4247 + * $Id$ 6912 + * Copyright 2006, Broadcom Corporation 6913 + * All Rights Reserved. 6914 + * 6915 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 6916 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 6917 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 6918 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 6919 + * 6920 + * $Id: sbextif.h,v 1.1.1.8 2006/02/27 03:43:16 honor Exp $ 4248 6921 + */ 4249 6922 + … … 4466 7139 + 4467 7140 +#endif /* _SBEXTIF_H */ 4468 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbmemc.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbmemc.h 4469 --- linux-2.4.32/arch/mips/bcm947xx/include/sbmemc.h 1970-01-01 01:00:00.000000000 +0100 4470 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbmemc.h 2006-09-16 15:41:31.000000000 +0200 7141 diff -urN linux.old/arch/mips/bcm947xx/include/sbhndmips.h linux.dev/arch/mips/bcm947xx/include/sbhndmips.h 7142 --- linux.old/arch/mips/bcm947xx/include/sbhndmips.h 1970-01-01 01:00:00.000000000 +0100 7143 +++ linux.dev/arch/mips/bcm947xx/include/sbhndmips.h 2006-10-02 21:19:59.000000000 +0200 7144 @@ -0,0 +1,47 @@ 7145 +/* 7146 + * Broadcom SiliconBackplane MIPS definitions 7147 + * 7148 + * SB MIPS cores are custom MIPS32 processors with SiliconBackplane 7149 + * OCP interfaces. The CP0 processor ID is 0x00024000, where bits 7150 + * 23:16 mean Broadcom and bits 15:8 mean a MIPS core with an OCP 7151 + * interface. The core revision is stored in the SB ID register in SB 7152 + * configuration space. 7153 + * 7154 + * Copyright 2006, Broadcom Corporation 7155 + * All Rights Reserved. 7156 + * 7157 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 7158 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 7159 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 7160 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 7161 + * 7162 + * $Id: sbhndmips.h,v 1.1.1.1 2006/02/27 03:43:16 honor Exp $ 7163 + */ 7164 + 7165 +#ifndef _sbhndmips_h_ 7166 +#define _sbhndmips_h_ 7167 + 7168 +#include <mipsinc.h> 7169 + 7170 +#ifndef _LANGUAGE_ASSEMBLY 7171 + 7172 +/* cpp contortions to concatenate w/arg prescan */ 7173 +#ifndef PAD 7174 +#define _PADLINE(line) pad ## line 7175 +#define _XSTR(line) _PADLINE(line) 7176 +#define PAD _XSTR(__LINE__) 7177 +#endif /* PAD */ 7178 + 7179 +typedef volatile struct { 7180 + uint32 corecontrol; 7181 + uint32 PAD[2]; 7182 + uint32 biststatus; 7183 + uint32 PAD[4]; 7184 + uint32 intstatus; 7185 + uint32 intmask; 7186 + uint32 timer; 7187 +} mipsregs_t; 7188 + 7189 +#endif /* _LANGUAGE_ASSEMBLY */ 7190 + 7191 +#endif /* _sbhndmips_h_ */ 7192 diff -urN linux.old/arch/mips/bcm947xx/include/sbmemc.h linux.dev/arch/mips/bcm947xx/include/sbmemc.h 7193 --- linux.old/arch/mips/bcm947xx/include/sbmemc.h 1970-01-01 01:00:00.000000000 +0100 7194 +++ linux.dev/arch/mips/bcm947xx/include/sbmemc.h 2006-10-02 21:19:59.000000000 +0200 4471 7195 @@ -0,0 +1,147 @@ 4472 7196 +/* 4473 7197 + * BCM47XX Sonics SiliconBackplane DDR/SDRAM controller core hardware definitions. 4474 7198 + * 4475 + * Copyright 200 5, Broadcom Corporation4476 + * All Rights Reserved. 4477 + * 4478 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 4479 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 4480 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 4481 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 7199 + * Copyright 2006, Broadcom Corporation 7200 + * All Rights Reserved. 7201 + * 7202 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 7203 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 7204 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 7205 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 4482 7206 + * 4483 + * $Id $7207 + * $Id: sbmemc.h,v 1.6 2006/03/02 12:33:44 honor Exp $ 4484 7208 + */ 4485 7209 + … … 4511 7235 +#define MEMC_CORE 0x54 4512 7236 + 4513 + 4514 +#else 7237 +#else /* !_LANGUAGE_ASSEMBLY */ 4515 7238 + 4516 7239 +/* Sonics side: MEMC core registers */ … … 4540 7263 +} sbmemcregs_t; 4541 7264 + 4542 +#endif 7265 +#endif /* _LANGUAGE_ASSEMBLY */ 4543 7266 + 4544 7267 +/* MEMC Core Init values (OCP ID 0x80f) */ … … 4573 7296 +#define MEMC_DRAMTIM25_INIT 0x000754d9 4574 7297 +#define MEMC_RDNCDLCOR_INIT 0x00000000 7298 +#define MEMC_RDNCDLCOR_SIMINIT 0xf6f6f6f6 /* For hdl sim */ 4575 7299 +#define MEMC_WRNCDLCOR_INIT 0x49351200 4576 7300 +#define MEMC_1_WRNCDLCOR_INIT 0x14500200 … … 4617 7341 + 4618 7342 +#endif /* _SBMEMC_H */ 4619 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/sbmips.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbmips.h4620 --- linux -2.4.32/arch/mips/bcm947xx/include/sbmips.h 1970-01-01 01:00:00.000000000 +01004621 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/sbmips.h 2006-09-16 15:41:31.000000000 +02004622 @@ -0,0 +1, 60 @@7343 diff -urN linux.old/arch/mips/bcm947xx/include/sbpcie.h linux.dev/arch/mips/bcm947xx/include/sbpcie.h 7344 --- linux.old/arch/mips/bcm947xx/include/sbpcie.h 1970-01-01 01:00:00.000000000 +0100 7345 +++ linux.dev/arch/mips/bcm947xx/include/sbpcie.h 2006-10-02 21:19:59.000000000 +0200 7346 @@ -0,0 +1,200 @@ 4623 7347 +/* 4624 + * B roadcom SiliconBackplane MIPS definitions7348 + * BCM43XX SiliconBackplane PCIE core hardware definitions. 4625 7349 + * 4626 + * SB MIPS cores are custom MIPS32 processors with SiliconBackplane 4627 + * OCP interfaces. The CP0 processor ID is 0x00024000, where bits 4628 + * 23:16 mean Broadcom and bits 15:8 mean a MIPS core with an OCP 4629 + * interface. The core revision is stored in the SB ID register in SB 4630 + * configuration space. 4631 + * 4632 + * Copyright 2005, Broadcom Corporation 7350 + * Copyright 2006, Broadcom Corporation 4633 7351 + * All Rights Reserved. 4634 7352 + * … … 4638 7356 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 4639 7357 + * 4640 + * $Id $7358 + * $Id: sbpcie.h,v 1.1.1.2 2006/02/27 03:43:16 honor Exp $ 4641 7359 + */ 4642 7360 + 4643 +#ifndef _SBMIPS_H 4644 +#define _SBMIPS_H 4645 + 4646 +#ifndef _LANGUAGE_ASSEMBLY 7361 +#ifndef _SBPCIE_H 7362 +#define _SBPCIE_H 4647 7363 + 4648 7364 +/* cpp contortions to concatenate w/arg prescan */ … … 4651 7367 +#define _XSTR(line) _PADLINE(line) 4652 7368 +#define PAD _XSTR(__LINE__) 4653 +#endif /* PAD */ 4654 + 4655 +typedef volatile struct { 4656 + uint32 corecontrol; 4657 + uint32 PAD[2]; 4658 + uint32 biststatus; 4659 + uint32 PAD[4]; 4660 + uint32 intstatus; 4661 + uint32 intmask; 4662 + uint32 timer; 4663 +} mipsregs_t; 4664 + 4665 +extern uint32 sb_flag(void *sbh); 4666 +extern uint sb_irq(void *sbh); 4667 + 4668 +extern void BCMINIT(sb_serial_init)(void *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift)); 4669 + 4670 +extern void *sb_jtagm_init(void *sbh, uint clkd, bool exttap); 4671 +extern void sb_jtagm_disable(void *h); 4672 +extern uint32 jtag_rwreg(void *h, uint32 ir, uint32 dr); 4673 +extern void BCMINIT(sb_mips_init)(void *sbh); 4674 +extern uint32 BCMINIT(sb_mips_clock)(void *sbh); 4675 +extern bool BCMINIT(sb_mips_setclock)(void *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock); 4676 + 4677 +extern uint32 BCMINIT(sb_memc_get_ncdl)(void *sbh); 4678 +extern uint32 BCMINIT(sb_mips_get_pfc)(void *sbh); 4679 + 4680 +#endif /* _LANGUAGE_ASSEMBLY */ 4681 + 4682 +#endif /* _SBMIPS_H */ 4683 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbpci.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbpci.h 4684 --- linux-2.4.32/arch/mips/bcm947xx/include/sbpci.h 1970-01-01 01:00:00.000000000 +0100 4685 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbpci.h 2006-09-16 15:41:31.000000000 +0200 4686 @@ -0,0 +1,117 @@ 7369 +#endif 7370 + 7371 +/* PCIE Enumeration space offsets */ 7372 +#define PCIE_CORE_CONFIG_OFFSET 0x0 7373 +#define PCIE_FUNC0_CONFIG_OFFSET 0x400 7374 +#define PCIE_FUNC1_CONFIG_OFFSET 0x500 7375 +#define PCIE_FUNC2_CONFIG_OFFSET 0x600 7376 +#define PCIE_FUNC3_CONFIG_OFFSET 0x700 7377 +#define PCIE_SPROM_SHADOW_OFFSET 0x800 7378 +#define PCIE_SBCONFIG_OFFSET 0xE00 7379 + 7380 +/* PCIE Bar0 Address Mapping. Each function maps 16KB config space */ 7381 +#define PCIE_DEV_BAR0_SIZE 0x4000 7382 +#define PCIE_BAR0_WINMAPCORE_OFFSET 0x0 7383 +#define PCIE_BAR0_EXTSPROM_OFFSET 0x1000 7384 +#define PCIE_BAR0_PCIECORE_OFFSET 0x2000 7385 +#define PCIE_BAR0_CCCOREREG_OFFSET 0x3000 7386 + 7387 +/* SB side: PCIE core and host control registers */ 7388 +typedef struct sbpcieregs { 7389 + uint32 PAD[3]; 7390 + uint32 biststatus; /* bist Status: 0x00C */ 7391 + uint32 PAD[6]; 7392 + uint32 sbtopcimailbox; /* sb to pcie mailbox: 0x028 */ 7393 + uint32 PAD[54]; 7394 + uint32 sbtopcie0; /* sb to pcie translation 0: 0x100 */ 7395 + uint32 sbtopcie1; /* sb to pcie translation 1: 0x104 */ 7396 + uint32 sbtopcie2; /* sb to pcie translation 2: 0x108 */ 7397 + uint32 PAD[4]; 7398 + 7399 + /* pcie core supports in direct access to config space */ 7400 + uint32 configaddr; /* pcie config space access: Address field: 0x120 */ 7401 + uint32 configdata; /* pcie config space access: Data field: 0x124 */ 7402 + 7403 + /* mdio access to serdes */ 7404 + uint32 mdiocontrol; /* controls the mdio access: 0x128 */ 7405 + uint32 mdiodata; /* Data to the mdio access: 0x12c */ 7406 + 7407 + /* pcie protocol phy/dllp/tlp register access mechanism */ 7408 + uint32 pcieaddr; /* address of the internal registeru: 0x130 */ 7409 + uint32 pciedata; /* Data to/from the internal regsiter: 0x134 */ 7410 + 7411 + uint32 PAD[434]; 7412 + uint16 sprom[36]; /* SPROM shadow Area */ 7413 +} sbpcieregs_t; 7414 + 7415 +/* SB to PCIE translation masks */ 7416 +#define SBTOPCIE0_MASK 0xfc000000 7417 +#define SBTOPCIE1_MASK 0xfc000000 7418 +#define SBTOPCIE2_MASK 0xc0000000 7419 + 7420 +/* Access type bits (0:1) */ 7421 +#define SBTOPCIE_MEM 0 7422 +#define SBTOPCIE_IO 1 7423 +#define SBTOPCIE_CFG0 2 7424 +#define SBTOPCIE_CFG1 3 7425 + 7426 +/* Prefetch enable bit 2 */ 7427 +#define SBTOPCIE_PF 4 7428 + 7429 +/* Write Burst enable for memory write bit 3 */ 7430 +#define SBTOPCIE_WR_BURST 8 7431 + 7432 +/* config access */ 7433 +#define CONFIGADDR_FUNC_MASK 0x7000 7434 +#define CONFIGADDR_FUNC_SHF 12 7435 +#define CONFIGADDR_REG_MASK 0x0FFF 7436 +#define CONFIGADDR_REG_SHF 0 7437 + 7438 +/* PCIE protocol regs Indirect Address */ 7439 +#define PCIEADDR_PROT_MASK 0x300 7440 +#define PCIEADDR_PROT_SHF 8 7441 +#define PCIEADDR_PL_TLP 0 7442 +#define PCIEADDR_PL_DLLP 1 7443 +#define PCIEADDR_PL_PLP 2 7444 + 7445 +/* PCIE protocol PHY diagnostic registers */ 7446 +#define PCIE_PLP_MODEREG 0x200 /* Mode */ 7447 +#define PCIE_PLP_STATUSREG 0x204 /* Status */ 7448 +#define PCIE_PLP_LTSSMCTRLREG 0x208 /* LTSSM control */ 7449 +#define PCIE_PLP_LTLINKNUMREG 0x20c /* Link Training Link number */ 7450 +#define PCIE_PLP_LTLANENUMREG 0x210 /* Link Training Lane number */ 7451 +#define PCIE_PLP_LTNFTSREG 0x214 /* Link Training N_FTS */ 7452 +#define PCIE_PLP_ATTNREG 0x218 /* Attention */ 7453 +#define PCIE_PLP_ATTNMASKREG 0x21C /* Attention Mask */ 7454 +#define PCIE_PLP_RXERRCTR 0x220 /* Rx Error */ 7455 +#define PCIE_PLP_RXFRMERRCTR 0x224 /* Rx Framing Error */ 7456 +#define PCIE_PLP_RXERRTHRESHREG 0x228 /* Rx Error threshold */ 7457 +#define PCIE_PLP_TESTCTRLREG 0x22C /* Test Control reg */ 7458 +#define PCIE_PLP_SERDESCTRLOVRDREG 0x230 /* SERDES Control Override */ 7459 +#define PCIE_PLP_TIMINGOVRDREG 0x234 /* Timing param override */ 7460 +#define PCIE_PLP_RXTXSMDIAGREG 0x238 /* RXTX State Machine Diag */ 7461 +#define PCIE_PLP_LTSSMDIAGREG 0x23C /* LTSSM State Machine Diag */ 7462 + 7463 +/* PCIE protocol DLLP diagnostic registers */ 7464 +#define PCIE_DLLP_LCREG 0x100 /* Link Control */ 7465 +#define PCIE_DLLP_LSREG 0x104 /* Link Status */ 7466 +#define PCIE_DLLP_LAREG 0x108 /* Link Attention */ 7467 +#define PCIE_DLLP_LAMASKREG 0x10C /* Link Attention Mask */ 7468 +#define PCIE_DLLP_NEXTTXSEQNUMREG 0x110 /* Next Tx Seq Num */ 7469 +#define PCIE_DLLP_ACKEDTXSEQNUMREG 0x114 /* Acked Tx Seq Num */ 7470 +#define PCIE_DLLP_PURGEDTXSEQNUMREG 0x118 /* Purged Tx Seq Num */ 7471 +#define PCIE_DLLP_RXSEQNUMREG 0x11C /* Rx Sequence Number */ 7472 +#define PCIE_DLLP_LRREG 0x120 /* Link Replay */ 7473 +#define PCIE_DLLP_LACKTOREG 0x124 /* Link Ack Timeout */ 7474 +#define PCIE_DLLP_PMTHRESHREG 0x128 /* Power Management Threshold */ 7475 +#define PCIE_DLLP_RTRYWPREG 0x12C /* Retry buffer write ptr */ 7476 +#define PCIE_DLLP_RTRYRPREG 0x130 /* Retry buffer Read ptr */ 7477 +#define PCIE_DLLP_RTRYPPREG 0x134 /* Retry buffer Purged ptr */ 7478 +#define PCIE_DLLP_RTRRWREG 0x138 /* Retry buffer Read/Write */ 7479 +#define PCIE_DLLP_ECTHRESHREG 0x13C /* Error Count Threshold */ 7480 +#define PCIE_DLLP_TLPERRCTRREG 0x140 /* TLP Error Counter */ 7481 +#define PCIE_DLLP_ERRCTRREG 0x144 /* Error Counter */ 7482 +#define PCIE_DLLP_NAKRXCTRREG 0x148 /* NAK Received Counter */ 7483 +#define PCIE_DLLP_TESTREG 0x14C /* Test */ 7484 +#define PCIE_DLLP_PKTBIST 0x150 /* Packet BIST */ 7485 + 7486 +/* PCIE protocol TLP diagnostic registers */ 7487 +#define PCIE_TLP_CONFIGREG 0x000 /* Configuration */ 7488 +#define PCIE_TLP_WORKAROUNDSREG 0x004 /* TLP Workarounds */ 7489 +#define PCIE_TLP_WRDMAUPPER 0x010 /* Write DMA Upper Address */ 7490 +#define PCIE_TLP_WRDMALOWER 0x014 /* Write DMA Lower Address */ 7491 +#define PCIE_TLP_WRDMAREQ_LBEREG 0x018 /* Write DMA Len/ByteEn Req */ 7492 +#define PCIE_TLP_RDDMAUPPER 0x01C /* Read DMA Upper Address */ 7493 +#define PCIE_TLP_RDDMALOWER 0x020 /* Read DMA Lower Address */ 7494 +#define PCIE_TLP_RDDMALENREG 0x024 /* Read DMA Len Req */ 7495 +#define PCIE_TLP_MSIDMAUPPER 0x028 /* MSI DMA Upper Address */ 7496 +#define PCIE_TLP_MSIDMALOWER 0x02C /* MSI DMA Lower Address */ 7497 +#define PCIE_TLP_MSIDMALENREG 0x030 /* MSI DMA Len Req */ 7498 +#define PCIE_TLP_SLVREQLENREG 0x034 /* Slave Request Len */ 7499 +#define PCIE_TLP_FCINPUTSREQ 0x038 /* Flow Control Inputs */ 7500 +#define PCIE_TLP_TXSMGRSREQ 0x03C /* Tx StateMachine and Gated Req */ 7501 +#define PCIE_TLP_ADRACKCNTARBLEN 0x040 /* Address Ack XferCnt and ARB Len */ 7502 +#define PCIE_TLP_DMACPLHDR0 0x044 /* DMA Completion Hdr 0 */ 7503 +#define PCIE_TLP_DMACPLHDR1 0x048 /* DMA Completion Hdr 1 */ 7504 +#define PCIE_TLP_DMACPLHDR2 0x04C /* DMA Completion Hdr 2 */ 7505 +#define PCIE_TLP_DMACPLMISC0 0x050 /* DMA Completion Misc0 */ 7506 +#define PCIE_TLP_DMACPLMISC1 0x054 /* DMA Completion Misc1 */ 7507 +#define PCIE_TLP_DMACPLMISC2 0x058 /* DMA Completion Misc2 */ 7508 +#define PCIE_TLP_SPTCTRLLEN 0x05C /* Split Controller Req len */ 7509 +#define PCIE_TLP_SPTCTRLMSIC0 0x060 /* Split Controller Misc 0 */ 7510 +#define PCIE_TLP_SPTCTRLMSIC1 0x064 /* Split Controller Misc 1 */ 7511 +#define PCIE_TLP_BUSDEVFUNC 0x068 /* Bus/Device/Func */ 7512 +#define PCIE_TLP_RESETCTR 0x06C /* Reset Counter */ 7513 +#define PCIE_TLP_RTRYBUF 0x070 /* Retry Buffer value */ 7514 +#define PCIE_TLP_TGTDEBUG1 0x074 /* Target Debug Reg1 */ 7515 +#define PCIE_TLP_TGTDEBUG2 0x078 /* Target Debug Reg2 */ 7516 +#define PCIE_TLP_TGTDEBUG3 0x07C /* Target Debug Reg3 */ 7517 +#define PCIE_TLP_TGTDEBUG4 0x080 /* Target Debug Reg4 */ 7518 + 7519 +/* MDIO control */ 7520 +#define MDIOCTL_DIVISOR_MASK 0x7f /* clock to be used on MDIO */ 7521 +#define MDIOCTL_DIVISOR_VAL 0x2 7522 +#define MDIOCTL_PREAM_EN 0x80 /* Enable preamble sequnce */ 7523 +#define MDIOCTL_ACCESS_DONE 0x100 /* Tranaction complete */ 7524 + 7525 +/* MDIO Data */ 7526 +#define MDIODATA_MASK 0x0000ffff /* data 2 bytes */ 7527 +#define MDIODATA_TA 0x00020000 /* Turnaround */ 7528 +#define MDIODATA_REGADDR_SHF 18 /* Regaddr shift */ 7529 +#define MDIODATA_REGADDR_MASK 0x003c0000 /* Regaddr Mask */ 7530 +#define MDIODATA_DEVADDR_SHF 22 /* Physmedia devaddr shift */ 7531 +#define MDIODATA_DEVADDR_MASK 0x0fc00000 /* Physmedia devaddr Mask */ 7532 +#define MDIODATA_WRITE 0x10000000 /* write Transaction */ 7533 +#define MDIODATA_READ 0x20000000 /* Read Transaction */ 7534 +#define MDIODATA_START 0x40000000 /* start of Transaction */ 7535 + 7536 +/* MDIO devices (SERDES modules) */ 7537 +#define MDIODATA_DEV_PLL 0x1d /* SERDES PLL Dev */ 7538 +#define MDIODATA_DEV_TX 0x1e /* SERDES TX Dev */ 7539 +#define MDIODATA_DEV_RX 0x1f /* SERDES RX Dev */ 7540 + 7541 +/* SERDES registers */ 7542 +#define SERDES_RX_TIMER1 2 /* Rx Timer1 */ 7543 +#define SERDES_RX_CDR 6 /* CDR */ 7544 +#define SERDES_RX_CDRBW 7 /* CDR BW */ 7545 + 7546 +#endif /* _SBPCIE_H */ 7547 diff -urN linux.old/arch/mips/bcm947xx/include/sbpci.h linux.dev/arch/mips/bcm947xx/include/sbpci.h 7548 --- linux.old/arch/mips/bcm947xx/include/sbpci.h 1970-01-01 01:00:00.000000000 +0100 7549 +++ linux.dev/arch/mips/bcm947xx/include/sbpci.h 2006-10-02 21:19:59.000000000 +0200 7550 @@ -0,0 +1,114 @@ 4687 7551 +/* 4688 + * BCM47XX SonicsSiliconBackplane PCI core hardware definitions.7552 + * HND SiliconBackplane PCI core hardware definitions. 4689 7553 + * 4690 + * $Id$ 4691 + * Copyright 2005, Broadcom Corporation 4692 + * All Rights Reserved. 4693 + * 4694 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 4695 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 4696 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 4697 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 7554 + * Copyright 2006, Broadcom Corporation 7555 + * All Rights Reserved. 7556 + * 7557 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 7558 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 7559 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 7560 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 7561 + * 7562 + * $Id: sbpci.h,v 1.1.1.11 2006/02/27 03:43:16 honor Exp $ 4698 7563 + */ 4699 7564 + 4700 +#ifndef _SBPCI_H 4701 +#define _SBPCI_H 7565 +#ifndef _sbpci_h_ 7566 +#define _sbpci_h_ 7567 + 7568 +#ifndef _LANGUAGE_ASSEMBLY 4702 7569 + 4703 7570 +/* cpp contortions to concatenate w/arg prescan */ … … 4729 7596 + uint32 sbtopci1; /* Sonics to PCI translation 1 */ 4730 7597 + uint32 sbtopci2; /* Sonics to PCI translation 2 */ 4731 + uint32 PAD[445]; 7598 + uint32 PAD[189]; 7599 + uint32 pcicfg[4][64]; /* 0x400 - 0x7FF, PCI Cfg Space (>=rev8) */ 4732 7600 + uint16 sprom[36]; /* SPROM shadow Area */ 4733 7601 + uint32 PAD[46]; 4734 7602 +} sbpciregs_t; 7603 + 7604 +#endif /* _LANGUAGE_ASSEMBLY */ 4735 7605 + 4736 7606 +/* PCI control */ … … 4738 7608 +#define PCI_RST 0x02 /* Value driven out to pin */ 4739 7609 +#define PCI_CLK_OE 0x04 /* When set, drives clock as gated by PCI_CLK out to pin */ 4740 +#define PCI_CLK 0x08 /* Gate for clock driven out to pin */ 7610 +#define PCI_CLK 0x08 /* Gate for clock driven out to pin */ 4741 7611 + 4742 7612 +/* PCI arbiter control */ 4743 7613 +#define PCI_INT_ARB 0x01 /* When set, use an internal arbiter */ 4744 7614 +#define PCI_EXT_ARB 0x02 /* When set, use an external arbiter */ 4745 +#define PCI_PARKID_MASK 0x06 /* Selects which agent is parked on an idle bus */ 4746 +#define PCI_PARKID_SHIFT 1 4747 +#define PCI_PARKID_LAST 0 /* Last requestor */ 4748 +#define PCI_PARKID_4710 1 /* 4710 */ 4749 +#define PCI_PARKID_EXTREQ0 2 /* External requestor 0 */ 4750 +#define PCI_PARKID_EXTREQ1 3 /* External requestor 1 */ 7615 +/* ParkID - for PCI corerev >= 8 */ 7616 +#define PCI_PARKID_MASK 0x1c /* Selects which agent is parked on an idle bus */ 7617 +#define PCI_PARKID_SHIFT 2 7618 +#define PCI_PARKID_EXT0 0 /* External master 0 */ 7619 +#define PCI_PARKID_EXT1 1 /* External master 1 */ 7620 +#define PCI_PARKID_EXT2 2 /* External master 2 */ 7621 +#define PCI_PARKID_INT 3 /* Internal master */ 7622 +#define PCI_PARKID_LAST 4 /* Last active master */ 4751 7623 + 4752 7624 +/* Interrupt status/mask */ … … 4785 7657 +#define SBTOPCI_RC_READMULTI 0x20 /* memory read multiple */ 4786 7658 + 4787 +/* PCI side: Reserved PCI configuration registers (see pcicfg.h) */ 4788 +#define cap_list rsvd_a[0] 4789 +#define bar0_window dev_dep[0x80 - 0x40] 4790 +#define bar1_window dev_dep[0x84 - 0x40] 4791 +#define sprom_control dev_dep[0x88 - 0x40] 4792 + 4793 +#ifndef _LANGUAGE_ASSEMBLY 4794 + 4795 +extern int sbpci_read_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len); 4796 +extern int sbpci_write_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len); 4797 +extern void sbpci_ban(uint16 core); 4798 +extern int sbpci_init(void *sbh); 4799 +extern void sbpci_check(void *sbh); 4800 + 4801 +#endif /* !_LANGUAGE_ASSEMBLY */ 4802 + 4803 +#endif /* _SBPCI_H */ 4804 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbpcmcia.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbpcmcia.h 4805 --- linux-2.4.32/arch/mips/bcm947xx/include/sbpcmcia.h 1970-01-01 01:00:00.000000000 +0100 4806 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbpcmcia.h 2006-09-16 15:41:31.000000000 +0200 4807 @@ -0,0 +1,139 @@ 7659 +/* PCI core index in SROM shadow area */ 7660 +#define SRSH_PI_OFFSET 0 /* first word */ 7661 +#define SRSH_PI_MASK 0xf000 /* bit 15:12 */ 7662 +#define SRSH_PI_SHIFT 12 /* bit 15:12 */ 7663 + 7664 +#endif /* _sbpci_h_ */ 7665 diff -urN linux.old/arch/mips/bcm947xx/include/sbpcmcia.h linux.dev/arch/mips/bcm947xx/include/sbpcmcia.h 7666 --- linux.old/arch/mips/bcm947xx/include/sbpcmcia.h 1970-01-01 01:00:00.000000000 +0100 7667 +++ linux.dev/arch/mips/bcm947xx/include/sbpcmcia.h 2006-10-02 21:19:59.000000000 +0200 7668 @@ -0,0 +1,147 @@ 4808 7669 +/* 4809 7670 + * BCM43XX Sonics SiliconBackplane PCMCIA core hardware definitions. 4810 7671 + * 4811 + * $Id$ 4812 + * Copyright 2005, Broadcom Corporation 4813 + * All Rights Reserved. 4814 + * 4815 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 4816 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 4817 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 4818 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 7672 + * Copyright 2006, Broadcom Corporation 7673 + * All Rights Reserved. 7674 + * 7675 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 7676 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 7677 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 7678 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 7679 + * 7680 + * $Id: sbpcmcia.h,v 1.1.1.9 2006/02/27 03:43:16 honor Exp $ 4819 7681 + */ 4820 7682 + … … 4924 7786 +/* Subtypes of BRCM_HNBU: */ 4925 7787 + 4926 +#define HNBU_CHIPID 0x01 /* Six bytes with PCI vendor & 4927 + * device id and chiprev 7788 +#define HNBU_SROMREV 0x00 /* A byte with sromrev, 1 if not present */ 7789 +#define HNBU_CHIPID 0x01 /* Two 16bit values: PCI vendor & device id */ 7790 +#define HNBU_BOARDREV 0x02 /* One byte board revision */ 7791 +#define HNBU_PAPARMS 0x03 /* PA parameters: 8 (sromrev == 1) 7792 + * or 9 (sromrev > 1) bytes 4928 7793 + */ 4929 +#define HNBU_BOARDREV 0x02 /* Two bytes board revision */ 4930 +#define HNBU_PAPARMS 0x03 /* Eleven bytes PA parameters */ 4931 +#define HNBU_OEM 0x04 /* Eight bytes OEM data */ 4932 +#define HNBU_CC 0x05 /* Default country code */ 7794 +#define HNBU_OEM 0x04 /* Eight bytes OEM data (sromrev == 1) */ 7795 +#define HNBU_CC 0x05 /* Default country code (sromrev == 1) */ 4933 7796 +#define HNBU_AA 0x06 /* Antennas available */ 4934 7797 +#define HNBU_AG 0x07 /* Antenna gain */ 4935 +#define HNBU_BOARDFLAGS 0x08 /* board flags */ 4936 +#define HNBU_LED 0x09 /* LED set */ 7798 +#define HNBU_BOARDFLAGS 0x08 /* board flags (2 or 4 bytes) */ 7799 +#define HNBU_LEDS 0x09 /* LED set */ 7800 +#define HNBU_CCODE 0x0a /* Country code (2 bytes ascii + 1 byte cctl) 7801 + * in rev 2 7802 + */ 7803 +#define HNBU_CCKPO 0x0b /* 2 byte cck power offsets in rev 3 */ 7804 +#define HNBU_OFDMPO 0x0c /* 4 byte 11g ofdm power offsets in rev 3 */ 7805 +#define HNBU_GPIOTIMER 0x0d /* 2 bytes with on/off values in rev 3 */ 4937 7806 + 4938 7807 + … … 4945 7814 + 4946 7815 +#endif /* _SBPCMCIA_H */ 4947 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/sbsdram.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbsdram.h4948 --- linux -2.4.32/arch/mips/bcm947xx/include/sbsdram.h 1970-01-01 01:00:00.000000000 +01004949 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/sbsdram.h 2006-09-16 15:41:31.000000000 +02004950 @@ -0,0 +1, 75 @@7816 diff -urN linux.old/arch/mips/bcm947xx/include/sbsdram.h linux.dev/arch/mips/bcm947xx/include/sbsdram.h 7817 --- linux.old/arch/mips/bcm947xx/include/sbsdram.h 1970-01-01 01:00:00.000000000 +0100 7818 +++ linux.dev/arch/mips/bcm947xx/include/sbsdram.h 2006-10-02 21:19:59.000000000 +0200 7819 @@ -0,0 +1,85 @@ 4951 7820 +/* 4952 7821 + * BCM47XX Sonics SiliconBackplane SDRAM controller core hardware definitions. 4953 7822 + * 4954 + * Copyright 2005, Broadcom Corporation 4955 + * All Rights Reserved. 4956 + * 4957 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 4958 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 4959 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 4960 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 4961 + * $Id$ 7823 + * Copyright 2006, Broadcom Corporation 7824 + * All Rights Reserved. 7825 + * 7826 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 7827 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 7828 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 7829 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 7830 + * 7831 + * $Id: sbsdram.h,v 1.1.1.9 2006/03/02 13:03:52 honor Exp $ 4962 7832 + */ 4963 7833 + … … 4976 7846 +} sbsdramregs_t; 4977 7847 + 7848 +/* SDRAM simulation */ 7849 +#ifdef RAMSZ 7850 +#define SDRAMSZ RAMSZ 7851 +#else 7852 +#define SDRAMSZ (4 * 1024 * 1024) 4978 7853 +#endif 7854 + 7855 +extern uchar sdrambuf[SDRAMSZ]; 7856 + 7857 +#endif /* _LANGUAGE_ASSEMBLY */ 4979 7858 + 4980 7859 +/* SDRAM initialization control (initcontrol) register bits */ … … 5024 7903 + 5025 7904 +#endif /* _SBSDRAM_H */ 5026 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/sbsocram.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbsocram.h5027 --- linux -2.4.32/arch/mips/bcm947xx/include/sbsocram.h 1970-01-01 01:00:00.000000000 +01005028 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/sbsocram.h 2006-09-16 15:41:31.000000000 +02005029 @@ -0,0 +1, 37@@7905 diff -urN linux.old/arch/mips/bcm947xx/include/sbsocram.h linux.dev/arch/mips/bcm947xx/include/sbsocram.h 7906 --- linux.old/arch/mips/bcm947xx/include/sbsocram.h 1970-01-01 01:00:00.000000000 +0100 7907 +++ linux.dev/arch/mips/bcm947xx/include/sbsocram.h 2006-10-02 21:19:59.000000000 +0200 7908 @@ -0,0 +1,64 @@ 5030 7909 +/* 5031 7910 + * BCM47XX Sonics SiliconBackplane embedded ram core 5032 7911 + * 5033 + * Copyright 2005, Broadcom Corporation 5034 + * All Rights Reserved. 5035 + * 5036 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 5037 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 5038 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 5039 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 5040 + * 5041 + * $Id$ 5042 + */ 5043 + 5044 +#ifndef _SBSOCRAM_H 5045 +#define _SBSOCRAM_H 5046 + 5047 +#define SOCRAM_MEMSIZE 0x00 5048 +#define SOCRAM_BISTSTAT 0x0c 5049 + 5050 + 5051 +#ifndef _LANGUAGE_ASSEMBLY 5052 + 5053 +/* Memcsocram core registers */ 5054 +typedef volatile struct sbsocramregs { 5055 + uint32 memsize; 5056 + uint32 biststat; 5057 +} sbsocramregs_t; 5058 + 5059 +#endif 5060 + 5061 +/* Them memory size is 2 to the power of the following 5062 + * base added to the contents of the memsize register. 5063 + */ 5064 +#define SOCRAM_MEMSIZE_BASESHIFT 16 5065 + 5066 +#endif /* _SBSOCRAM_H */ 5067 diff -Nur linux-2.4.32/arch/mips/bcm947xx/include/sbutils.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbutils.h 5068 --- linux-2.4.32/arch/mips/bcm947xx/include/sbutils.h 1970-01-01 01:00:00.000000000 +0100 5069 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sbutils.h 2006-09-16 15:41:31.000000000 +0200 5070 @@ -0,0 +1,91 @@ 5071 +/* 5072 + * Misc utility routines for accessing chip-specific features 5073 + * of Broadcom HNBU SiliconBackplane-based chips. 5074 + * 5075 + * Copyright 2005, Broadcom Corporation 7912 + * Copyright 2006, Broadcom Corporation 5076 7913 + * All Rights Reserved. 5077 7914 + * … … 5081 7918 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 5082 7919 + * 5083 + * $Id$ 7920 + * $Id: sbsocram.h,v 1.1.1.3 2006/02/27 03:43:16 honor Exp $ 7921 + */ 7922 + 7923 +#ifndef _SBSOCRAM_H 7924 +#define _SBSOCRAM_H 7925 + 7926 +#define SR_COREINFO 0x00 7927 +#define SR_BWALLOC 0x04 7928 +#define SR_BISTSTAT 0x0c 7929 +#define SR_BANKINDEX 0x10 7930 +#define SR_BANKSTBYCTL 0x14 7931 + 7932 + 7933 +#ifndef _LANGUAGE_ASSEMBLY 7934 + 7935 +/* Memcsocram core registers */ 7936 +typedef volatile struct sbsocramregs { 7937 + uint32 coreinfo; 7938 + uint32 bwalloc; 7939 + uint32 PAD; 7940 + uint32 biststat; 7941 + uint32 bankidx; 7942 + uint32 standbyctrl; 7943 +} sbsocramregs_t; 7944 + 7945 +#endif 7946 + 7947 +/* Coreinfo register */ 7948 +#define SRCI_PT_MASK 0x30000 7949 +#define SRCI_PT_SHIFT 16 7950 + 7951 +/* In corerev 0, the memory size is 2 to the power of the 7952 + * base plus 16 plus to the contents of the memsize field plus 1. 7953 + */ 7954 +#define SRCI_MS0_MASK 0xf 7955 +#define SR_MS0_BASE 16 7956 + 7957 +/* 7958 + * In corerev 1 the bank size is 2 ^ the bank size field plus 14, 7959 + * the memory size is number of banks times bank size. 7960 + * The same applies to rom size. 7961 + */ 7962 +#define SRCI_ROMNB_MASK 0xf000 7963 +#define SRCI_ROMNB_SHIFT 12 7964 +#define SRCI_ROMBSZ_MASK 0xf00 7965 +#define SRCI_ROMBSZ_SHIFT 8 7966 +#define SRCI_SRNB_MASK 0xf0 7967 +#define SRCI_SRNB_SHIFT 4 7968 +#define SRCI_SRBSZ_MASK 0xf 7969 +#define SRCI_SRBSZ_SHIFT 0 7970 + 7971 +#define SR_BSZ_BASE 14 7972 +#endif /* _SBSOCRAM_H */ 7973 diff -urN linux.old/arch/mips/bcm947xx/include/sbutils.h linux.dev/arch/mips/bcm947xx/include/sbutils.h 7974 --- linux.old/arch/mips/bcm947xx/include/sbutils.h 1970-01-01 01:00:00.000000000 +0100 7975 +++ linux.dev/arch/mips/bcm947xx/include/sbutils.h 2006-10-02 21:19:59.000000000 +0200 7976 @@ -0,0 +1,151 @@ 7977 +/* 7978 + * Misc utility routines for accessing chip-specific features 7979 + * of Broadcom HNBU SiliconBackplane-based chips. 7980 + * 7981 + * Copyright 2006, Broadcom Corporation 7982 + * All Rights Reserved. 7983 + * 7984 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 7985 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 7986 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 7987 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 7988 + * 7989 + * $Id: sbutils.h,v 1.4 2006/04/08 07:12:42 honor Exp $ 5084 7990 + */ 5085 7991 + 5086 7992 +#ifndef _sbutils_h_ 5087 7993 +#define _sbutils_h_ 7994 + 7995 +/* 7996 + * Datastructure to export all chip specific common variables 7997 + * public (read-only) portion of sbutils handle returned by 7998 + * sb_attach()/sb_kattach() 7999 +*/ 8000 + 8001 +struct sb_pub { 8002 + 8003 + uint bustype; /* SB_BUS, PCI_BUS */ 8004 + uint buscoretype; /* SB_PCI, SB_PCMCIA, SB_PCIE */ 8005 + uint buscorerev; /* buscore rev */ 8006 + uint buscoreidx; /* buscore index */ 8007 + int ccrev; /* chip common core rev */ 8008 + uint boardtype; /* board type */ 8009 + uint boardvendor; /* board vendor */ 8010 + uint chip; /* chip number */ 8011 + uint chiprev; /* chip revision */ 8012 + uint chippkg; /* chip package option */ 8013 + uint sonicsrev; /* sonics backplane rev */ 8014 +}; 8015 + 8016 +typedef const struct sb_pub sb_t; 5088 8017 + 5089 8018 +/* … … 5095 8024 + */ 5096 8025 + 8026 +#define SB_OSH NULL /* Use for sb_kattach when no osh is available */ 5097 8027 +/* exported externs */ 5098 +extern void * BCMINIT(sb_attach)(uint pcidev, void *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz); 5099 +extern void * BCMINIT(sb_kattach)(void); 5100 +extern void sb_detach(void *sbh); 5101 +extern uint BCMINIT(sb_chip)(void *sbh); 5102 +extern uint BCMINIT(sb_chiprev)(void *sbh); 5103 +extern uint BCMINIT(sb_chipcrev)(void *sbh); 5104 +extern uint BCMINIT(sb_chippkg)(void *sbh); 5105 +extern uint BCMINIT(sb_pcirev)(void *sbh); 5106 +extern uint BCMINIT(sb_pcmciarev)(void *sbh); 5107 +extern uint BCMINIT(sb_boardvendor)(void *sbh); 5108 +extern uint BCMINIT(sb_boardtype)(void *sbh); 5109 +extern uint sb_bus(void *sbh); 5110 +extern uint sb_corelist(void *sbh, uint coreid[]); 5111 +extern uint sb_coreid(void *sbh); 5112 +extern uint sb_coreidx(void *sbh); 5113 +extern uint sb_coreunit(void *sbh); 5114 +extern uint sb_corevendor(void *sbh); 5115 +extern uint sb_corerev(void *sbh); 5116 +extern void *sb_osh(void *sbh); 5117 +extern void *sb_coreregs(void *sbh); 5118 +extern uint32 sb_coreflags(void *sbh, uint32 mask, uint32 val); 5119 +extern uint32 sb_coreflagshi(void *sbh, uint32 mask, uint32 val); 5120 +extern bool sb_iscoreup(void *sbh); 5121 +extern void *sb_setcoreidx(void *sbh, uint coreidx); 5122 +extern void *sb_setcore(void *sbh, uint coreid, uint coreunit); 5123 +extern void sb_commit(void *sbh); 8028 +extern sb_t *sb_attach(uint pcidev, osl_t *osh, void *regs, uint bustype, 8029 + void *sdh, char **vars, uint *varsz); 8030 +extern sb_t *sb_kattach(void); 8031 +extern void sb_detach(sb_t *sbh); 8032 +extern uint sb_chip(sb_t *sbh); 8033 +extern uint sb_chiprev(sb_t *sbh); 8034 +extern uint sb_chipcrev(sb_t *sbh); 8035 +extern uint sb_chippkg(sb_t *sbh); 8036 +extern uint sb_pcirev(sb_t *sbh); 8037 +extern bool sb_war16165(sb_t *sbh); 8038 +extern uint sb_pcmciarev(sb_t *sbh); 8039 +extern uint sb_boardvendor(sb_t *sbh); 8040 +extern uint sb_boardtype(sb_t *sbh); 8041 +extern uint sb_bus(sb_t *sbh); 8042 +extern uint sb_buscoretype(sb_t *sbh); 8043 +extern uint sb_buscorerev(sb_t *sbh); 8044 +extern uint sb_corelist(sb_t *sbh, uint coreid[]); 8045 +extern uint sb_coreid(sb_t *sbh); 8046 +extern uint sb_coreidx(sb_t *sbh); 8047 +extern uint sb_coreunit(sb_t *sbh); 8048 +extern uint sb_corevendor(sb_t *sbh); 8049 +extern uint sb_corerev(sb_t *sbh); 8050 +extern void *sb_osh(sb_t *sbh); 8051 +extern void sb_setosh(sb_t *sbh, osl_t *osh); 8052 +extern void *sb_coreregs(sb_t *sbh); 8053 +extern uint32 sb_coreflags(sb_t *sbh, uint32 mask, uint32 val); 8054 +extern uint32 sb_coreflagshi(sb_t *sbh, uint32 mask, uint32 val); 8055 +extern bool sb_iscoreup(sb_t *sbh); 8056 +extern void *sb_setcoreidx(sb_t *sbh, uint coreidx); 8057 +extern void *sb_setcore(sb_t *sbh, uint coreid, uint coreunit); 8058 +extern int sb_corebist(sb_t *sbh); 8059 +extern void sb_commit(sb_t *sbh); 5124 8060 +extern uint32 sb_base(uint32 admatch); 5125 8061 +extern uint32 sb_size(uint32 admatch); 5126 +extern void sb_core_reset( void *sbh, uint32bits);5127 +extern void sb_core_tofixup( void*sbh);5128 +extern void sb_core_disable( void*sbh, uint32 bits);8062 +extern void sb_core_reset(sb_t *sbh, uint32 bits, uint32 resetbits); 8063 +extern void sb_core_tofixup(sb_t *sbh); 8064 +extern void sb_core_disable(sb_t *sbh, uint32 bits); 5129 8065 +extern uint32 sb_clock_rate(uint32 pll_type, uint32 n, uint32 m); 5130 +extern uint32 sb_clock(void *sbh); 5131 +extern void sb_pci_setup(void *sbh, uint32 *dmaoffset, uint coremask); 5132 +extern void sb_pcmcia_init(void *sbh); 5133 +extern void sb_watchdog(void *sbh, uint ticks); 5134 +extern void *sb_gpiosetcore(void *sbh); 5135 +extern uint32 sb_gpiocontrol(void *sbh, uint32 mask, uint32 val); 5136 +extern uint32 sb_gpioouten(void *sbh, uint32 mask, uint32 val); 5137 +extern uint32 sb_gpioout(void *sbh, uint32 mask, uint32 val); 5138 +extern uint32 sb_gpioin(void *sbh); 5139 +extern uint32 sb_gpiointpolarity(void *sbh, uint32 mask, uint32 val); 5140 +extern uint32 sb_gpiointmask(void *sbh, uint32 mask, uint32 val); 5141 +extern void sb_pwrctl_init(void *sbh); 5142 +extern uint16 sb_pwrctl_fast_pwrup_delay(void *sbh); 5143 +extern bool sb_pwrctl_clk(void *sbh, uint mode); 5144 +extern int sb_pwrctl_xtal(void *sbh, uint what, bool on); 5145 +extern int sb_pwrctl_slowclk(void *sbh, bool set, uint *div); 5146 +extern void sb_register_intr_callback(void *sbh, void *intrsoff_fn, void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg); 5147 + 5148 +/* pwrctl xtal what flags */ 5149 +#define XTAL 0x1 /* primary crystal oscillator (2050) */ 5150 +#define PLL 0x2 /* main chip pll */ 5151 + 5152 +/* pwrctl clk mode */ 5153 +#define CLK_FAST 0 /* force fast (pll) clock */ 5154 +#define CLK_SLOW 1 /* force slow clock */ 5155 +#define CLK_DYNAMIC 2 /* enable dynamic power control */ 8066 +extern uint32 sb_clock(sb_t *sbh); 8067 +extern void sb_pci_setup(sb_t *sbh, uint coremask); 8068 +extern void sb_pcmcia_init(sb_t *sbh); 8069 +extern void sb_watchdog(sb_t *sbh, uint ticks); 8070 +extern void *sb_gpiosetcore(sb_t *sbh); 8071 +extern uint32 sb_gpiocontrol(sb_t *sbh, uint32 mask, uint32 val, uint8 priority); 8072 +extern uint32 sb_gpioouten(sb_t *sbh, uint32 mask, uint32 val, uint8 priority); 8073 +extern uint32 sb_gpioout(sb_t *sbh, uint32 mask, uint32 val, uint8 priority); 8074 +extern uint32 sb_gpioin(sb_t *sbh); 8075 +extern uint32 sb_gpiointpolarity(sb_t *sbh, uint32 mask, uint32 val, uint8 priority); 8076 +extern uint32 sb_gpiointmask(sb_t *sbh, uint32 mask, uint32 val, uint8 priority); 8077 +extern uint32 sb_gpioled(sb_t *sbh, uint32 mask, uint32 val); 8078 +extern uint32 sb_gpioreserve(sb_t *sbh, uint32 gpio_num, uint8 priority); 8079 +extern uint32 sb_gpiorelease(sb_t *sbh, uint32 gpio_num, uint8 priority); 8080 + 8081 +extern void sb_clkctl_init(sb_t *sbh); 8082 +extern uint16 sb_clkctl_fast_pwrup_delay(sb_t *sbh); 8083 +extern bool sb_clkctl_clk(sb_t *sbh, uint mode); 8084 +extern int sb_clkctl_xtal(sb_t *sbh, uint what, bool on); 8085 +extern void sb_register_intr_callback(sb_t *sbh, void *intrsoff_fn, void *intrsrestore_fn, 8086 + void *intrsenabled_fn, void *intr_arg); 8087 +extern uint32 sb_set_initiator_to(sb_t *sbh, uint32 to); 8088 +extern int sb_corepciid(sb_t *sbh, uint func, uint16 *pcivendor, uint16 *pcidevice, 8089 + uint8 *pciclass, uint8 *pcisubclass, uint8 *pciprogif, 8090 + uint8 *pciheader); 8091 +extern uint sb_pcie_readreg(void *sbh, void* arg1, uint offset); 8092 +extern uint sb_pcie_writereg(sb_t *sbh, void *arg1, uint offset, uint val); 8093 +extern uint32 sb_gpiotimerval(sb_t *sbh, uint32 mask, uint32 val); 8094 +extern bool sb_backplane64(sb_t *sbh); 8095 +extern void sb_btcgpiowar(sb_t *sbh); 8096 + 8097 + 8098 + 8099 + 8100 +extern bool sb_deviceremoved(sb_t *sbh); 8101 +extern uint32 sb_socram_size(sb_t *sbh); 8102 + 8103 +/* 8104 +* Build device path. Path size must be >= SB_DEVPATH_BUFSZ. 8105 +* The returned path is NULL terminated and has trailing '/'. 8106 +* Return 0 on success, nonzero otherwise. 8107 +*/ 8108 +extern int sb_devpath(sb_t *sbh, char *path, int size); 8109 + 8110 +/* clkctl xtal what flags */ 8111 +#define XTAL 0x1 /* primary crystal oscillator (2050) */ 8112 +#define PLL 0x2 /* main chip pll */ 8113 + 8114 +/* clkctl clk mode */ 8115 +#define CLK_FAST 0 /* force fast (pll) clock */ 8116 +#define CLK_DYNAMIC 2 /* enable dynamic clock control */ 8117 + 5156 8118 + 5157 8119 +/* GPIO usage priorities */ 5158 +#define GPIO_DRV_PRIORITY 0 /* Driver */ 5159 +#define GPIO_APP_PRIORITY 1 /* Application */ 8120 +#define GPIO_DRV_PRIORITY 0 /* Driver */ 8121 +#define GPIO_APP_PRIORITY 1 /* Application */ 8122 +#define GPIO_HI_PRIORITY 2 /* Highest priority. Ignore GPIO reservation */ 8123 + 8124 +/* device path */ 8125 +#define SB_DEVPATH_BUFSZ 16 /* min buffer size in bytes */ 5160 8126 + 5161 8127 +#endif /* _sbutils_h_ */ 5162 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/sflash.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/sflash.h5163 --- linux -2.4.32/arch/mips/bcm947xx/include/sflash.h 1970-01-01 01:00:00.000000000 +01005164 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/sflash.h 2006-09-16 15:41:31.000000000 +02008128 diff -urN linux.old/arch/mips/bcm947xx/include/sflash.h linux.dev/arch/mips/bcm947xx/include/sflash.h 8129 --- linux.old/arch/mips/bcm947xx/include/sflash.h 1970-01-01 01:00:00.000000000 +0100 8130 +++ linux.dev/arch/mips/bcm947xx/include/sflash.h 2006-10-02 21:19:59.000000000 +0200 5165 8131 @@ -0,0 +1,36 @@ 5166 8132 +/* 5167 8133 + * Broadcom SiliconBackplane chipcommon serial flash interface 5168 8134 + * 5169 + * Copyright 200 5, Broadcom Corporation5170 + * All Rights Reserved. 5171 + * 5172 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 5173 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 5174 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 5175 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 8135 + * Copyright 2006, Broadcom Corporation 8136 + * All Rights Reserved. 8137 + * 8138 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 8139 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 8140 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 8141 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 5176 8142 + * 5177 + * $Id $8143 + * $Id: sflash.h,v 1.1.1.8 2006/02/27 03:43:16 honor Exp $ 5178 8144 + */ 5179 8145 + … … 5200 8166 + 5201 8167 +#endif /* _sflash_h_ */ 5202 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/trxhdr.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/trxhdr.h5203 --- linux -2.4.32/arch/mips/bcm947xx/include/trxhdr.h 1970-01-01 01:00:00.000000000 +01005204 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/trxhdr.h 2006-09-16 15:41:31.000000000 +02008168 diff -urN linux.old/arch/mips/bcm947xx/include/trxhdr.h linux.dev/arch/mips/bcm947xx/include/trxhdr.h 8169 --- linux.old/arch/mips/bcm947xx/include/trxhdr.h 1970-01-01 01:00:00.000000000 +0100 8170 +++ linux.dev/arch/mips/bcm947xx/include/trxhdr.h 2006-10-02 21:19:59.000000000 +0200 5205 8171 @@ -0,0 +1,33 @@ 5206 8172 +/* … … 5237 8203 +/* Compatibility */ 5238 8204 +typedef struct trx_header TRXHDR, *PTRXHDR; 5239 diff - Nur linux-2.4.32/arch/mips/bcm947xx/include/typedefs.h linux-2.4.32-freewrt/arch/mips/bcm947xx/include/typedefs.h5240 --- linux -2.4.32/arch/mips/bcm947xx/include/typedefs.h 1970-01-01 01:00:00.000000000 +01005241 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/include/typedefs.h 2006-09-16 15:41:31.000000000 +02005242 @@ -0,0 +1,3 22@@8205 diff -urN linux.old/arch/mips/bcm947xx/include/typedefs.h linux.dev/arch/mips/bcm947xx/include/typedefs.h 8206 --- linux.old/arch/mips/bcm947xx/include/typedefs.h 1970-01-01 01:00:00.000000000 +0100 8207 +++ linux.dev/arch/mips/bcm947xx/include/typedefs.h 2006-10-02 21:19:59.000000000 +0200 8208 @@ -0,0 +1,361 @@ 5243 8209 +/* 5244 + * Copyright 200 5, Broadcom Corporation5245 + * All Rights Reserved. 5246 + * 5247 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 5248 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 5249 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 5250 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 5251 + * $Id $8210 + * Copyright 2006, Broadcom Corporation 8211 + * All Rights Reserved. 8212 + * 8213 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 8214 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 8215 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 8216 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 8217 + * $Id: typedefs.h,v 1.1.1.12 2006/04/08 06:13:40 honor Exp $ 5252 8218 + */ 5253 8219 + … … 5271 8237 +#ifdef SITE_TYPEDEFS 5272 8238 + 5273 +/* ******************************************************************************8239 +/* 5274 8240 + * Site Specific Typedefs 5275 + *******************************************************************************/ 8241 + * 8242 + */ 5276 8243 + 5277 8244 +#include "site_typedefs.h" … … 5279 8246 +#else 5280 8247 + 5281 +/* ******************************************************************************8248 +/* 5282 8249 + * Inferred Typedefs 5283 + *******************************************************************************/ 8250 + * 8251 + */ 5284 8252 + 5285 8253 +/* Infer the compile environment based on preprocessor symbols and pramas. … … 5316 8284 +#endif 5317 8285 + 8286 + 8287 +#if defined(_MINOSL_) 8288 +#define _NEED_SIZE_T_ 8289 +#endif 8290 + 8291 +#if defined(_NEED_SIZE_T_) 8292 +typedef long unsigned int size_t; 8293 +#endif 8294 + 8295 +#ifdef __DJGPP__ 8296 +typedef long unsigned int size_t; 8297 +#endif /* __DJGPP__ */ 8298 + 5318 8299 +#ifdef _MSC_VER /* Microsoft C */ 5319 8300 +#define TYPEDEF_INT64 … … 5323 8304 +#endif 5324 8305 + 5325 +#if defined(MACOSX) && defined(KERNEL)8306 +#if defined(MACOSX) 5326 8307 +#define TYPEDEF_BOOL 8308 +#endif 8309 + 8310 +#if defined(__NetBSD__) 8311 +#define TYPEDEF_ULONG 5327 8312 +#endif 5328 8313 + … … 5334 8319 +#endif 5335 8320 + 5336 +#if !defined(linux) && !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_) 8321 +#if !defined(linux) && !defined(_WIN32) && !defined(_CFE_) && \ 8322 + !defined(_HNDRTE_) && !defined(_MINOSL_) && !defined(__DJGPP__) 5337 8323 +#define TYPEDEF_UINT 5338 8324 +#define TYPEDEF_USHORT … … 5347 8333 + 5348 8334 +/* ICL accepts unsigned 64 bit type only, and complains in ANSI mode 5349 + * for singned or unsigned */ 8335 + * for singned or unsigned 8336 + */ 5350 8337 +#if defined(__ICL) 5351 8338 + … … 5358 8345 +#endif /* __ICL */ 5359 8346 + 5360 + 5361 + #if !defined(_WIN32) && !defined(PMON) && !defined(_CFE_) && !defined(_HNDRTE_) && !defined(_MINOSL_)8347 +#if !defined(_WIN32) && !defined(_CFE_) && !defined(_MINOSL_) && \ 8348 + !defined(__DJGPP__) 5362 8349 + 5363 8350 +/* pick up ushort & uint from standard types.h */ … … 5368 8355 +#else 5369 8356 + 5370 +#include <sys/types.h> 8357 +#include <sys/types.h> 5371 8358 + 5372 8359 +#endif 5373 8360 + 5374 +#endif /* !_WIN32 && !PMON && !_CFE_ && !_HNDRTE_ && !_MINOSL_ */ 5375 + 5376 +#if defined(MACOSX) && defined(KERNEL) 8361 +#endif /* !_WIN32 && !PMON && !_CFE_ && !_HNDRTE_ && !_MINOSL_ && !__DJGPP__ */ 8362 + 8363 +#if defined(MACOSX) 8364 + 8365 +#ifdef __BIG_ENDIAN__ 8366 +#define IL_BIGENDIAN 8367 +#else 8368 +#ifdef IL_BIGENDIAN 8369 +#error "IL_BIGENDIAN was defined for a little-endian compile" 8370 +#endif 8371 +#endif /* __BIG_ENDIAN__ */ 8372 + 8373 +#if !defined(__cplusplus) 8374 + 8375 +#if defined(__i386__) 8376 +typedef unsigned char bool; 8377 +#else 8378 +typedef unsigned int bool; 8379 +#endif 8380 +#define TYPE_BOOL 1 8381 +enum { 8382 + false = 0, 8383 + true = 1 8384 +}; 8385 + 8386 +#if defined(KERNEL) 5377 8387 +#include <IOKit/IOTypes.h> 5378 +#endif 8388 +#endif /* KERNEL */ 8389 + 8390 +#endif /* __cplusplus */ 8391 + 8392 +#endif /* MACOSX */ 5379 8393 + 5380 8394 + … … 5385 8399 + 5386 8400 + 5387 +/* ******************************************************************************8401 +/* 5388 8402 + * Default Typedefs 5389 + *******************************************************************************/ 8403 + * 8404 + */ 5390 8405 + 5391 8406 +#ifdef USE_TYPEDEF_DEFAULTS … … 5393 8408 + 5394 8409 +#ifndef TYPEDEF_BOOL 5395 +typedef /* @abstract@*/ unsigned char bool;8410 +typedef /* @abstract@ */ unsigned char bool; 5396 8411 +#endif 5397 8412 + 5398 +/* ----------------------- define uchar, ushort, uint, ulong ------------------*/8413 +/* define uchar, ushort, uint, ulong */ 5399 8414 + 5400 8415 +#ifndef TYPEDEF_UCHAR … … 5414 8429 +#endif 5415 8430 + 5416 +/* ----------------------- define [u]int8/16/32/64, uintptr --------------------*/8431 +/* define [u]int8/16/32/64, uintptr */ 5417 8432 + 5418 8433 +#ifndef TYPEDEF_UINT8 … … 5452 8467 +#endif 5453 8468 + 5454 +/* ----------------------- define float32/64, float_t -----------------------*/8469 +/* define float32/64, float_t */ 5455 8470 + 5456 8471 +#ifndef TYPEDEF_FLOAT32 … … 5478 8493 +#endif /* TYPEDEF_FLOAT_T */ 5479 8494 + 5480 +/* ----------------------- define macro values -----------------------------*/8495 +/* define macro values */ 5481 8496 + 5482 8497 +#ifndef FALSE … … 5485 8500 + 5486 8501 +#ifndef TRUE 5487 +#define TRUE 1 8502 +#define TRUE 1 /* TRUE */ 5488 8503 +#endif 5489 8504 + … … 5497 8512 + 5498 8513 +#ifndef ON 5499 +#define ON 1 8514 +#define ON 1 /* ON = 1 */ 5500 8515 +#endif 5501 8516 + 5502 +#define AUTO (-1) 5503 + 5504 +/* Reclaiming text and data : 5505 + The following macros specify special linker sections that can be reclaimed 5506 + after a system is considered 'up'. 5507 + */ 5508 +#if defined(__GNUC__) && defined(BCMRECLAIM) 5509 +extern bool bcmreclaimed; 5510 +#define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini." #_data))) _data##_ini 5511 +#define BCMINITFN(_fn) __attribute__ ((__section__ (".textini." #_fn))) _fn##_ini 5512 +#define BCMINIT(_id) _id##_ini 5513 +#else 5514 +#define BCMINITDATA(_data) _data 5515 +#define BCMINITFN(_fn) _fn 5516 +#define BCMINIT(_id) _id 5517 +#define bcmreclaimed 0 5518 +#endif 5519 + 5520 +/*----------------------- define PTRSZ, INLINE ----------------------------*/ 8517 +#define AUTO (-1) /* Auto = -1 */ 8518 + 8519 +/* define PTRSZ, INLINE */ 5521 8520 + 5522 8521 +#ifndef PTRSZ 5523 +#define PTRSZ sizeof (char*)8522 +#define PTRSZ sizeof(char*) 5524 8523 +#endif 5525 8524 + … … 5562 8561 +#endif /* USE_TYPEDEF_DEFAULTS */ 5563 8562 + 8563 +/* 8564 + * Including the bcmdefs.h here, to make sure everyone including typedefs.h 8565 + * gets this automatically 8566 +*/ 8567 +#include "bcmdefs.h" 8568 + 5564 8569 +#endif /* _TYPEDEFS_H_ */ 5565 diff - Nur linux-2.4.32/arch/mips/bcm947xx/Makefile linux-2.4.32-freewrt/arch/mips/bcm947xx/Makefile5566 --- linux -2.4.32/arch/mips/bcm947xx/Makefile 1970-01-01 01:00:00.000000000 +01005567 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/Makefile 2006-09-16 15:41:31.000000000 +02005568 @@ -0,0 +1,1 5@@8570 diff -urN linux.old/arch/mips/bcm947xx/Makefile linux.dev/arch/mips/bcm947xx/Makefile 8571 --- linux.old/arch/mips/bcm947xx/Makefile 1970-01-01 01:00:00.000000000 +0100 8572 +++ linux.dev/arch/mips/bcm947xx/Makefile 2006-10-02 21:26:08.000000000 +0200 8573 @@ -0,0 +1,17 @@ 5569 8574 +# 5570 8575 +# Makefile for the BCM947xx specific kernel interface routines … … 5572 8577 +# 5573 8578 + 5574 +EXTRA_CFLAGS+=-I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER 8579 +EXTRA_CFLAGS+=-I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER -fno-delayed-branch 5575 8580 + 5576 8581 +O_TARGET := bcm947xx.o 5577 8582 + 5578 +export-objs := nvram_linux.o setup.o8583 +export-objs := export.o 5579 8584 +obj-y := prom.o setup.o time.o sbmips.o gpio.o 5580 +obj-y += nvram.o nvram_linux.o cfe_env.o 8585 +obj-y += nvram.o nvram_linux.o sflash.o cfe_env.o 8586 +obj-y += sbutils.o bcmutils.o bcmsrom.o hndchipc.o 5581 8587 +obj-$(CONFIG_PCI) += sbpci.o pcibios.o 8588 +obj-y += export.o 5582 8589 + 5583 8590 +include $(TOPDIR)/Rules.make 5584 diff - Nur linux-2.4.32/arch/mips/bcm947xx/nvram.c linux-2.4.32-freewrt/arch/mips/bcm947xx/nvram.c5585 --- linux -2.4.32/arch/mips/bcm947xx/nvram.c 1970-01-01 01:00:00.000000000 +01005586 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/nvram.c 2006-09-16 15:41:31.000000000 +02005587 @@ -0,0 +1,3 21@@8591 diff -urN linux.old/arch/mips/bcm947xx/nvram.c linux.dev/arch/mips/bcm947xx/nvram.c 8592 --- linux.old/arch/mips/bcm947xx/nvram.c 1970-01-01 01:00:00.000000000 +0100 8593 +++ linux.dev/arch/mips/bcm947xx/nvram.c 2006-10-02 21:19:59.000000000 +0200 8594 @@ -0,0 +1,315 @@ 5588 8595 +/* 5589 8596 + * NVRAM variable manipulation (common) … … 5597 8604 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 5598 8605 + * 5599 + * $Id$5600 8606 + */ 5601 8607 + … … 5883 8889 + struct nvram_header *header; 5884 8890 + int ret; 5885 + void *osh; 5886 + 5887 + /* get kernel osl handler */ 5888 + osh = osl_attach(NULL); 5889 + 5890 + if (!(header = (struct nvram_header *) MALLOC(osh, NVRAM_SPACE))) { 5891 + printf("nvram_init: out of memory, malloced %d bytes\n", MALLOCED(osh)); 8891 + 8892 + if (!(header = (struct nvram_header *) kmalloc(NVRAM_SPACE, GFP_ATOMIC))) { 5892 8893 + return -12; /* -ENOMEM */ 5893 8894 + } … … 5897 8898 + BCMINIT(nvram_rehash)(header); 5898 8899 + 5899 + MFREE(osh, header, NVRAM_SPACE);8900 + kfree(header); 5900 8901 + return ret; 5901 8902 +} … … 5907 8908 + BCMINIT(nvram_free)(); 5908 8909 +} 5909 diff - Nur linux-2.4.32/arch/mips/bcm947xx/nvram_linux.c linux-2.4.32-freewrt/arch/mips/bcm947xx/nvram_linux.c5910 --- linux -2.4.32/arch/mips/bcm947xx/nvram_linux.c 1970-01-01 01:00:00.000000000 +01005911 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/nvram_linux.c 2006-09-16 15:41:31.000000000 +02005912 @@ -0,0 +1, 639@@8910 diff -urN linux.old/arch/mips/bcm947xx/nvram_linux.c linux.dev/arch/mips/bcm947xx/nvram_linux.c 8911 --- linux.old/arch/mips/bcm947xx/nvram_linux.c 1970-01-01 01:00:00.000000000 +0100 8912 +++ linux.dev/arch/mips/bcm947xx/nvram_linux.c 2006-10-02 21:19:59.000000000 +0200 8913 @@ -0,0 +1,723 @@ 5913 8914 +/* 5914 8915 + * NVRAM variable manipulation (Linux kernel half) 5915 8916 + * 5916 + * Copyright 200 4, Broadcom Corporation8917 + * Copyright 2006, Broadcom Corporation 5917 8918 + * All Rights Reserved. 5918 8919 + * … … 5922 8923 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 5923 8924 + * 5924 + * $Id $8925 + * $Id: nvram_linux.c,v 1.19 2006/04/08 07:12:42 honor Exp $ 5925 8926 + */ 5926 8927 + … … 5943 8944 + 5944 8945 +#include <typedefs.h> 8946 +#include <osl.h> 5945 8947 +#include <bcmendian.h> 5946 8948 +#include <bcmnvram.h> … … 5949 8951 +#include <sbchipc.h> 5950 8952 +#include <sbutils.h> 5951 +#include <sbmips.h> 8953 +#include <hndmips.h> 8954 +#include <sflash.h> 5952 8955 + 5953 8956 +/* In BSS to minimize text size and page aligned so it can be mmap()-ed */ … … 5963 8966 +extern void *bcm947xx_sbh; 5964 8967 +extern spinlock_t bcm947xx_sbh_lock; 8968 + 5965 8969 +static int cfe_env; 5966 8970 +extern char *cfe_env_get(char *nv_buf, const char *name); … … 5978 8982 + struct nvram_header *header; 5979 8983 + chipcregs_t *cc; 8984 + struct sflash *info = NULL; 5980 8985 + int i; 5981 8986 + uint32 base, off, lim; 5982 8987 + u32 *src, *dst; 5983 8988 + 5984 + cfe_env = 0;5985 8989 + if ((cc = sb_setcore(sbh, SB_CC, 0)) != NULL) { 5986 8990 + base = KSEG1ADDR(SB_FLASH2); … … 5992 8996 + case SFLASH_ST: 5993 8997 + case SFLASH_AT: 8998 + if ((info = sflash_init(cc)) == NULL) 8999 + return; 9000 + lim = info->size; 9001 + break; 9002 + 5994 9003 + case FLASH_NONE: 5995 9004 + default: … … 6016 9025 + return; 6017 9026 + } 6018 + 9027 + 6019 9028 + off = FLASH_MIN; 6020 9029 + while (off <= lim) { 6021 9030 + /* Windowed flash access */ 6022 9031 + header = (struct nvram_header *) KSEG1ADDR(base + off - NVRAM_SPACE); 6023 + if (header->magic == NVRAM_MAGIC) { 6024 + u32 *src = (u32 *) header; 6025 + u32 *dst = (u32 *) nvram_buf; 6026 + for (i = 0; i < sizeof(struct nvram_header); i += 4) 6027 + *dst++ = *src++; 6028 + for (; i < header->len && i < NVRAM_SPACE; i += 4) 6029 + *dst++ = ltoh32(*src++); 6030 + return; 6031 + } 6032 + 6033 + /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */ 6034 + if (off == 1 KB) 6035 + break; 6036 + else if (off == 4 KB) 6037 + off = 1 KB; 6038 + else if (off == lim) 6039 + off = 4 KB; 6040 + else 6041 + off <<= 1; 6042 + } 9032 + if (header->magic == NVRAM_MAGIC) 9033 + goto found; 9034 + off <<= 1; 9035 + } 9036 + 9037 + /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */ 9038 + header = (struct nvram_header *) KSEG1ADDR(base + 4 KB); 9039 + if (header->magic == NVRAM_MAGIC) 9040 + goto found; 9041 + 9042 + header = (struct nvram_header *) KSEG1ADDR(base + 1 KB); 9043 + if (header->magic == NVRAM_MAGIC) 9044 + goto found; 9045 + 9046 + printk("early_nvram_init: NVRAM not found\n"); 9047 + return; 9048 + 9049 +found: 9050 + src = (u32 *) header; 9051 + dst = (u32 *) nvram_buf; 9052 + for (i = 0; i < sizeof(struct nvram_header); i += 4) 9053 + *dst++ = *src++; 9054 + for (; i < header->len && i < NVRAM_SPACE; i += 4) 9055 + *dst++ = ltoh32(*src++); 6043 9056 +} 6044 9057 + … … 6050 9063 + 6051 9064 + if (!name) 9065 + return NULL; 9066 + 9067 + /* Too early? */ 9068 + if (sbh == NULL) 6052 9069 + return NULL; 6053 9070 + … … 6073 9090 +} 6074 9091 + 9092 +static int __init 9093 +early_nvram_getall(char *buf, int count) 9094 +{ 9095 + char *var, *end; 9096 + int len = 0; 9097 + 9098 + /* Too early? */ 9099 + if (sbh == NULL) 9100 + return -1; 9101 + 9102 + if (!nvram_buf[0]) 9103 + early_nvram_init(); 9104 + 9105 + bzero(buf, count); 9106 + 9107 + /* Write name=value\0 ... \0\0 */ 9108 + var = &nvram_buf[sizeof(struct nvram_header)]; 9109 + end = nvram_buf + sizeof(nvram_buf) - 2; 9110 + end[0] = end[1] = '\0'; 9111 + for (; *var; var += strlen(var) + 1) { 9112 + if ((count - len) <= (strlen(var) + 1)) 9113 + break; 9114 + len += sprintf(buf + len, "%s", var) + 1; 9115 + } 9116 + 9117 + return 0; 9118 +} 6075 9119 +#endif /* !MODULE */ 6076 9120 + … … 6080 9124 +extern int _nvram_getall(char *buf, int count); 6081 9125 +extern int _nvram_commit(struct nvram_header *header); 6082 +extern int _nvram_init(void );9126 +extern int _nvram_init(void *sbh); 6083 9127 +extern void _nvram_exit(void); 6084 9128 + … … 6211 9255 +{ 6212 9256 + char *buf; 6213 + size_t erasesize, len ;9257 + size_t erasesize, len, magic_len; 6214 9258 + unsigned int i; 6215 9259 + int ret; … … 6220 9264 + wait_queue_head_t wait_q; 6221 9265 + struct erase_info erase; 9266 + u_int32_t magic_offset = 0; /* Offset for writing MAGIC # */ 6222 9267 + 6223 9268 + if (!nvram_mtd) { … … 6250 9295 + } 6251 9296 + header = (struct nvram_header *)(buf + i); 9297 + magic_offset = i + ((void *)&header->magic - (void *)header); 6252 9298 + } else { 6253 9299 + offset = nvram_mtd->size - NVRAM_SPACE; 9300 + magic_offset = ((void *)&header->magic - (void *)header); 6254 9301 + header = (struct nvram_header *)buf; 6255 9302 + } 6256 9303 + 9304 + /* clear the existing magic # to mark the NVRAM as unusable 9305 + we can pull MAGIC bits low without erase */ 9306 + header->magic = NVRAM_CLEAR_MAGIC; /* All zeros magic */ 9307 + 9308 + /* Unlock sector blocks (for Intel 28F320C3B flash) , 20060309 */ 9309 + if(nvram_mtd->unlock) 9310 + nvram_mtd->unlock(nvram_mtd, offset, nvram_mtd->erasesize); 9311 + 9312 + ret = MTD_WRITE(nvram_mtd, offset + magic_offset, sizeof(header->magic), 9313 + &magic_len, (char *)&header->magic); 9314 + if (ret || magic_len != sizeof(header->magic)) { 9315 + printk("nvram_commit: clear MAGIC error\n"); 9316 + ret = -EIO; 9317 + goto done; 9318 + } 9319 + 9320 + header->magic = NVRAM_MAGIC; /* reset MAGIC before we regenerate the NVRAM, 9321 + otherwise we'll have an incorrect CRC */ 6257 9322 + /* Regenerate NVRAM */ 6258 9323 + spin_lock_irqsave(&nvram_lock, flags); … … 6291 9356 + 6292 9357 + /* Write partition up to end of data area */ 9358 + header->magic = NVRAM_INVALID_MAGIC; /* All ones magic */ 6293 9359 + offset = nvram_mtd->size - erasesize; 6294 9360 + i = erasesize - NVRAM_SPACE + header->len; … … 6300 9366 + } 6301 9367 + 9368 + /* Now mark the NVRAM in flash as "valid" by setting the correct 9369 + MAGIC # */ 9370 + header->magic = NVRAM_MAGIC; 9371 + ret = MTD_WRITE(nvram_mtd, offset + magic_offset, sizeof(header->magic), 9372 + &magic_len, (char *)&header->magic); 9373 + if (ret || magic_len != sizeof(header->magic)) { 9374 + printk("nvram_commit: write MAGIC error\n"); 9375 + ret = -EIO; 9376 + goto done; 9377 + } 9378 + 9379 + /* 9380 + * Reading a few bytes back here will put the device 9381 + * back to the correct mode on certain flashes */ 6302 9382 + offset = nvram_mtd->size - erasesize; 6303 9383 + ret = MTD_READ(nvram_mtd, offset, 4, &len, buf); … … 6306 9386 + up(&nvram_sem); 6307 9387 + kfree(buf); 9388 + 6308 9389 + return ret; 6309 9390 +} … … 6316 9397 + 6317 9398 + spin_lock_irqsave(&nvram_lock, flags); 6318 + ret = _nvram_getall(buf, count); 9399 + if (nvram_major >= 0) 9400 + ret = _nvram_getall(buf, count); 9401 + else 9402 + ret = early_nvram_getall(buf, count); 6319 9403 + spin_unlock_irqrestore(&nvram_lock, flags); 6320 9404 + … … 6322 9406 +} 6323 9407 + 6324 + EXPORT_SYMBOL(nvram_get);6325 + EXPORT_SYMBOL(nvram_getall);6326 + EXPORT_SYMBOL(nvram_set);6327 + EXPORT_SYMBOL(nvram_unset);6328 + EXPORT_SYMBOL(nvram_commit);9408 + 9409 + 9410 + 9411 + 9412 + 6329 9413 + 6330 9414 +/* User mode interface below */ … … 6418 9502 + if (cmd != NVRAM_MAGIC) 6419 9503 + return -EINVAL; 9504 + 6420 9505 + return nvram_commit(); 6421 9506 +} … … 6523 9608 + 6524 9609 + /* Initialize hash table */ 6525 + _nvram_init( );9610 + _nvram_init(sbh); 6526 9611 + 6527 9612 + /* Create /dev/nvram handle */ … … 6550 9635 +module_init(dev_nvram_init); 6551 9636 +module_exit(dev_nvram_exit); 6552 diff - Nur linux-2.4.32/arch/mips/bcm947xx/pcibios.c linux-2.4.32-freewrt/arch/mips/bcm947xx/pcibios.c6553 --- linux -2.4.32/arch/mips/bcm947xx/pcibios.c 1970-01-01 01:00:00.000000000 +01006554 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/pcibios.c 2006-09-16 15:41:31.000000000 +02006555 @@ -0,0 +1,3 55@@9637 diff -urN linux.old/arch/mips/bcm947xx/pcibios.c linux.dev/arch/mips/bcm947xx/pcibios.c 9638 --- linux.old/arch/mips/bcm947xx/pcibios.c 1970-01-01 01:00:00.000000000 +0100 9639 +++ linux.dev/arch/mips/bcm947xx/pcibios.c 2006-10-02 21:22:56.000000000 +0200 9640 @@ -0,0 +1,380 @@ 6556 9641 +/* 6557 9642 + * Low-Level PCI and SB support for BCM47xx (Linux support code) 6558 9643 + * 6559 + * Copyright 200 4, Broadcom Corporation9644 + * Copyright 2006, Broadcom Corporation 6560 9645 + * All Rights Reserved. 6561 9646 + * … … 6565 9650 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 6566 9651 + * 6567 + * $Id $9652 + * $Id: pcibios.c,v 1.1.1.9 2006/02/27 03:42:55 honor Exp $ 6568 9653 + */ 6569 9654 + … … 6580 9665 + 6581 9666 +#include <typedefs.h> 9667 +#include <osl.h> 6582 9668 +#include <bcmutils.h> 6583 9669 +#include <sbconfig.h> 6584 +#include <sbpci.h> 9670 +#include <sbutils.h> 9671 +#include <hndpci.h> 6585 9672 +#include <pcicfg.h> 6586 +#include <sbutils.h>6587 9673 +#include <bcmdevs.h> 6588 9674 +#include <bcmnvram.h> 6589 9675 + 6590 9676 +/* Global SB handle */ 6591 +extern void*bcm947xx_sbh;9677 +extern sb_t *bcm947xx_sbh; 6592 9678 +extern spinlock_t bcm947xx_sbh_lock; 6593 9679 + … … 6603 9689 + 6604 9690 + spin_lock_irqsave(&sbh_lock, flags); 6605 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value)); 9691 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), 9692 + PCI_FUNC(dev->devfn), where, value, sizeof(*value)); 6606 9693 + spin_unlock_irqrestore(&sbh_lock, flags); 6607 9694 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL; … … 6615 9702 + 6616 9703 + spin_lock_irqsave(&sbh_lock, flags); 6617 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value)); 9704 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), 9705 + PCI_FUNC(dev->devfn), where, value, sizeof(*value)); 6618 9706 + spin_unlock_irqrestore(&sbh_lock, flags); 6619 9707 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL; … … 6627 9715 + 6628 9716 + spin_lock_irqsave(&sbh_lock, flags); 6629 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, value, sizeof(*value)); 9717 + ret = sbpci_read_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), 9718 + PCI_FUNC(dev->devfn), where, value, sizeof(*value)); 6630 9719 + spin_unlock_irqrestore(&sbh_lock, flags); 6631 9720 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL; … … 6639 9728 + 6640 9729 + spin_lock_irqsave(&sbh_lock, flags); 6641 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value)); 9730 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), 9731 + PCI_FUNC(dev->devfn), where, &value, sizeof(value)); 6642 9732 + spin_unlock_irqrestore(&sbh_lock, flags); 6643 9733 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL; … … 6651 9741 + 6652 9742 + spin_lock_irqsave(&sbh_lock, flags); 6653 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value)); 9743 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), 9744 + PCI_FUNC(dev->devfn), where, &value, sizeof(value)); 6654 9745 + spin_unlock_irqrestore(&sbh_lock, flags); 6655 9746 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL; … … 6663 9754 + 6664 9755 + spin_lock_irqsave(&sbh_lock, flags); 6665 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), where, &value, sizeof(value)); 9756 + ret = sbpci_write_config(sbh, dev->bus->number, PCI_SLOT(dev->devfn), 9757 + PCI_FUNC(dev->devfn), where, &value, sizeof(value)); 6666 9758 + spin_unlock_irqrestore(&sbh_lock, flags); 6667 9759 + return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL; … … 6693 9785 + set_io_port_base((unsigned long) ioremap_nocache(SB_PCI_MEM, 0x04000000)); 6694 9786 + 6695 + mdelay(300); //By Joey for Atheros Card6696 +6697 9787 + /* Scan the SB bus */ 6698 9788 + pci_scan_bus(0, &pcibios_ops, NULL); … … 6724 9814 + u8 irq; 6725 9815 + 6726 + printk("PCI: Fixing up bus %d\n", b->number);9816 + printk("PCI: Fixing up bus %d\n", b->number); 6727 9817 + 6728 9818 + /* Fix up SB */ 6729 9819 + if (b->number == 0) { 6730 + for (ln =b->devices.next; ln != &b->devices; ln=ln->next) {9820 + for (ln = b->devices.next; ln != &b->devices; ln = ln->next) { 6731 9821 + d = pci_dev_b(ln); 6732 9822 + /* Fix up interrupt lines */ … … 6739 9829 + /* Fix up external PCI */ 6740 9830 + else { 6741 + for (ln =b->devices.next; ln != &b->devices; ln=ln->next) {9831 + for (ln = b->devices.next; ln != &b->devices; ln = ln->next) { 6742 9832 + d = pci_dev_b(ln); 6743 9833 + /* Fix up resource bases */ … … 6747 9837 + if (res->end) { 6748 9838 + size = res->end - res->start + 1; 6749 + if (*base & (size - 1)) 6750 + *base = (*base + size) & ~(size - 1); 6751 + res->start = *base; 6752 + res->end = res->start + size - 1; 6753 + *base += size; 6754 + pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start); 9839 + if (*base & (size - 1)) 9840 + *base = (*base + size) & ~(size - 1); 9841 + res->start = *base; 9842 + res->end = res->start + size - 1; 9843 + *base += size; 9844 + pci_write_config_dword(d, 9845 + PCI_BASE_ADDRESS_0 + (pos << 2), res->start); 6755 9846 + } 6756 9847 + /* Fix up PCI bridge BAR0 only */ … … 6774 9865 +void 6775 9866 +pcibios_align_resource(void *data, struct resource *res, 6776 + unsigned long size, unsigned long align)9867 + unsigned long size, unsigned long align) 6777 9868 +{ 6778 9869 +} … … 6791 9882 + pci_read_config_word(dev, PCI_COMMAND, &cmd); 6792 9883 + old_cmd = cmd; 6793 + for (idx=0; idx<6; idx++) {9884 + for (idx = 0; idx < 6; idx++) { 6794 9885 + r = &dev->resource[idx]; 6795 9886 + if (r->flags & IORESOURCE_IO) … … 6812 9903 + ulong flags; 6813 9904 + uint coreidx; 9905 + void *regs; 6814 9906 + 6815 9907 + /* External PCI device enable */ … … 6826 9918 + spin_lock_irqsave(&sbh_lock, flags); 6827 9919 + coreidx = sb_coreidx(sbh); 6828 + if (!sb_setcoreidx(sbh, PCI_SLOT(dev->devfn))) 9920 + regs = sb_setcoreidx(sbh, PCI_SLOT(dev->devfn)); 9921 + if (!regs) 6829 9922 + return PCIBIOS_DEVICE_NOT_FOUND; 6830 9923 + … … 6840 9933 + if (sb_coreid(sbh) == SB_USB) { 6841 9934 + sb_core_disable(sbh, sb_coreflags(sbh, 0, 0)); 6842 + sb_core_reset(sbh, 1 << 29); 9935 + sb_core_reset(sbh, 1 << 29, 0); 9936 + } 9937 + /* 9938 + * USB 2.0 special considerations: 9939 + * 9940 + * 1. Since the core supports both OHCI and EHCI functions, it must 9941 + * only be reset once. 9942 + * 9943 + * 2. In addition to the standard SB reset sequence, the Host Control 9944 + * Register must be programmed to bring the USB core and various 9945 + * phy components out of reset. 9946 + */ 9947 + else if (sb_coreid(sbh) == SB_USB20H) { 9948 + if (!sb_iscoreup(sbh)) { 9949 + sb_core_reset(sbh, 0, 0); 9950 + writel(0x7FF, (ulong)regs + 0x200); 9951 + udelay(1); 9952 + } 6843 9953 + } else 6844 + sb_core_reset(sbh, 0 );9954 + sb_core_reset(sbh, 0, 0); 6845 9955 + 6846 9956 + sb_setcoreidx(sbh, coreidx); 6847 9957 + spin_unlock_irqrestore(&sbh_lock, flags); 6848 + 9958 + 6849 9959 + return 0; 6850 9960 +} … … 6852 9962 +void 6853 9963 +pcibios_update_resource(struct pci_dev *dev, struct resource *root, 6854 + struct resource *res, int resource)9964 + struct resource *res, int resource) 6855 9965 +{ 6856 9966 + unsigned long where, size; … … 6909 10019 +} 6910 10020 + 6911 diff - Nur linux-2.4.32/arch/mips/bcm947xx/prom.c linux-2.4.32-freewrt/arch/mips/bcm947xx/prom.c6912 --- linux -2.4.32/arch/mips/bcm947xx/prom.c 1970-01-01 01:00:00.000000000 +01006913 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/prom.c 2006-09-16 15:41:31.000000000 +020010021 diff -urN linux.old/arch/mips/bcm947xx/prom.c linux.dev/arch/mips/bcm947xx/prom.c 10022 --- linux.old/arch/mips/bcm947xx/prom.c 1970-01-01 01:00:00.000000000 +0100 10023 +++ linux.dev/arch/mips/bcm947xx/prom.c 2006-10-02 21:19:59.000000000 +0200 6914 10024 @@ -0,0 +1,41 @@ 6915 10025 +/* … … 6954 10064 +{ 6955 10065 +} 6956 diff - Nur linux-2.4.32/arch/mips/bcm947xx/sbmips.c linux-2.4.32-freewrt/arch/mips/bcm947xx/sbmips.c6957 --- linux -2.4.32/arch/mips/bcm947xx/sbmips.c 1970-01-01 01:00:00.000000000 +01006958 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/sbmips.c 2006-09-16 15:41:31.000000000 +02006959 @@ -0,0 +1,1 033@@10066 diff -urN linux.old/arch/mips/bcm947xx/sbmips.c linux.dev/arch/mips/bcm947xx/sbmips.c 10067 --- linux.old/arch/mips/bcm947xx/sbmips.c 1970-01-01 01:00:00.000000000 +0100 10068 +++ linux.dev/arch/mips/bcm947xx/sbmips.c 2006-10-02 21:19:59.000000000 +0200 10069 @@ -0,0 +1,1132 @@ 6960 10070 +/* 6961 10071 + * BCM47XX Sonics SiliconBackplane MIPS core routines 6962 10072 + * 6963 + * Copyright 200 5, Broadcom Corporation10073 + * Copyright 2006, Broadcom Corporation 6964 10074 + * All Rights Reserved. 6965 10075 + * … … 6969 10079 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 6970 10080 + * 6971 + * $Id: sbmips.c,v 1.3 2005/03/07 08:35:32 kankiExp $10081 + * $Id: hndmips.c,v 1.1.1.1 2006/02/27 03:43:16 honor Exp $ 6972 10082 + */ 6973 10083 + 6974 10084 +#include <typedefs.h> 10085 +#include <bcmdefs.h> 6975 10086 +#include <osl.h> 10087 +#include <bcmutils.h> 6976 10088 +#include <sbutils.h> 6977 10089 +#include <bcmdevs.h> 6978 10090 +#include <bcmnvram.h> 6979 +#include <bcmutils.h>6980 +#include <hndmips.h>6981 10091 +#include <sbconfig.h> 6982 10092 +#include <sbextif.h> … … 6984 10094 +#include <sbmemc.h> 6985 10095 +#include <mipsinc.h> 6986 + 6987 +/* 6988 + * Returns TRUE if an external UART exists at the given base 6989 + * register. 6990 + */ 6991 +static bool 6992 +BCMINITFN(serial_exists)(uint8 *regs) 6993 +{ 6994 + uint8 save_mcr, status1; 6995 + 6996 + save_mcr = R_REG(®s[UART_MCR]); 6997 + W_REG(®s[UART_MCR], UART_MCR_LOOP | 0x0a); 6998 + status1 = R_REG(®s[UART_MSR]) & 0xf0; 6999 + W_REG(®s[UART_MCR], save_mcr); 7000 + 7001 + return (status1 == 0x90); 7002 +} 7003 + 7004 +/* 7005 + * Initializes UART access. The callback function will be called once 7006 + * per found UART. 7007 + */ 7008 +void 7009 +BCMINITFN(sb_serial_init)(void *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift)) 7010 +{ 7011 + void *regs; 7012 + ulong base; 7013 + uint irq; 7014 + int i, n; 7015 + 7016 + if ((regs = sb_setcore(sbh, SB_EXTIF, 0))) { 7017 + extifregs_t *eir = (extifregs_t *) regs; 7018 + sbconfig_t *sb; 7019 + 7020 + /* Determine external UART register base */ 7021 + sb = (sbconfig_t *)((ulong) eir + SBCONFIGOFF); 7022 + base = EXTIF_CFGIF_BASE(sb_base(R_REG(&sb->sbadmatch1))); 7023 + 7024 + /* Determine IRQ */ 7025 + irq = sb_irq(sbh); 7026 + 7027 + /* Disable GPIO interrupt initially */ 7028 + W_REG(&eir->gpiointpolarity, 0); 7029 + W_REG(&eir->gpiointmask, 0); 7030 + 7031 + /* Search for external UARTs */ 7032 + n = 2; 7033 + for (i = 0; i < 2; i++) { 7034 + regs = (void *) REG_MAP(base + (i * 8), 8); 7035 + if (BCMINIT(serial_exists)(regs)) { 7036 + /* Set GPIO 1 to be the external UART IRQ */ 7037 + W_REG(&eir->gpiointmask, 2); 7038 + if (add) 7039 + add(regs, irq, 13500000, 0); 7040 + } 7041 + } 7042 + 7043 + /* Add internal UART if enabled */ 7044 + if (R_REG(&eir->corecontrol) & CC_UE) 7045 + if (add) 7046 + add((void *) &eir->uartdata, irq, sb_clock(sbh), 2); 7047 + } else if ((regs = sb_setcore(sbh, SB_CC, 0))) { 7048 + chipcregs_t *cc = (chipcregs_t *) regs; 7049 + uint32 rev, cap, pll, baud_base, div; 7050 + 7051 + /* Determine core revision and capabilities */ 7052 + rev = sb_corerev(sbh); 7053 + cap = R_REG(&cc->capabilities); 7054 + pll = cap & CAP_PLL_MASK; 7055 + 7056 + /* Determine IRQ */ 7057 + irq = sb_irq(sbh); 7058 + 7059 + if (pll == PLL_TYPE1) { 7060 + /* PLL clock */ 7061 + baud_base = sb_clock_rate(pll, 7062 + R_REG(&cc->clockcontrol_n), 7063 + R_REG(&cc->clockcontrol_m2)); 7064 + div = 1; 7065 + } else { 7066 + if (rev >= 11) { 7067 + /* Fixed ALP clock */ 7068 + baud_base = 20000000; 7069 + div = 1; 7070 + /* Set the override bit so we don't divide it */ 7071 + W_REG(&cc->corecontrol, CC_UARTCLKO); 7072 + } else if (rev >= 3) { 7073 + /* Internal backplane clock */ 7074 + baud_base = sb_clock(sbh); 7075 + div = 2; /* Minimum divisor */ 7076 + W_REG(&cc->clkdiv, ((R_REG(&cc->clkdiv) & ~CLKD_UART) | div)); 7077 + } else { 7078 + /* Fixed internal backplane clock */ 7079 + baud_base = 88000000; 7080 + div = 48; 7081 + } 7082 + 7083 + /* Clock source depends on strapping if UartClkOverride is unset */ 7084 + if ((rev > 0) && 7085 + ((R_REG(&cc->corecontrol) & CC_UARTCLKO) == 0)) { 7086 + if ((cap & CAP_UCLKSEL) == CAP_UINTCLK) { 7087 + /* Internal divided backplane clock */ 7088 + baud_base /= div; 7089 + } else { 7090 + /* Assume external clock of 1.8432 MHz */ 7091 + baud_base = 1843200; 7092 + } 7093 + } 7094 + } 7095 + 7096 + /* Add internal UARTs */ 7097 + n = cap & CAP_UARTS_MASK; 7098 + for (i = 0; i < n; i++) { 7099 + /* Register offset changed after revision 0 */ 7100 + if (rev) 7101 + regs = (void *)((ulong) &cc->uart0data + (i * 256)); 7102 + else 7103 + regs = (void *)((ulong) &cc->uart0data + (i * 8)); 7104 + 7105 + if (add) 7106 + add(regs, irq, baud_base, 0); 7107 + } 7108 + } 7109 +} 7110 + 7111 +/* 7112 + * Initialize jtag master and return handle for 7113 + * jtag_rwreg. Returns NULL on failure. 7114 + */ 7115 +void * 7116 +sb_jtagm_init(void *sbh, uint clkd, bool exttap) 7117 +{ 7118 + void *regs; 7119 + 7120 + if ((regs = sb_setcore(sbh, SB_CC, 0)) != NULL) { 7121 + chipcregs_t *cc = (chipcregs_t *) regs; 7122 + uint32 tmp; 7123 + 7124 + /* 7125 + * Determine jtagm availability from 7126 + * core revision and capabilities. 7127 + */ 7128 + tmp = sb_corerev(sbh); 7129 + /* 7130 + * Corerev 10 has jtagm, but the only chip 7131 + * with it does not have a mips, and 7132 + * the layout of the jtagcmd register is 7133 + * different. We'll only accept >= 11. 7134 + */ 7135 + if (tmp < 11) 7136 + return (NULL); 7137 + 7138 + tmp = R_REG(&cc->capabilities); 7139 + if ((tmp & CAP_JTAGP) == 0) 7140 + return (NULL); 7141 + 7142 + /* Set clock divider if requested */ 7143 + if (clkd != 0) { 7144 + tmp = R_REG(&cc->clkdiv); 7145 + tmp = (tmp & ~CLKD_JTAG) | 7146 + ((clkd << CLKD_JTAG_SHIFT) & CLKD_JTAG); 7147 + W_REG(&cc->clkdiv, tmp); 7148 + } 7149 + 7150 + /* Enable jtagm */ 7151 + tmp = JCTRL_EN | (exttap ? JCTRL_EXT_EN : 0); 7152 + W_REG(&cc->jtagctrl, tmp); 7153 + } 7154 + 7155 + return (regs); 7156 +} 7157 + 7158 +void 7159 +sb_jtagm_disable(void *h) 7160 +{ 7161 + chipcregs_t *cc = (chipcregs_t *)h; 7162 + 7163 + W_REG(&cc->jtagctrl, R_REG(&cc->jtagctrl) & ~JCTRL_EN); 7164 +} 7165 + 7166 +/* 7167 + * Read/write a jtag register. Assumes a target with 7168 + * 8 bit IR and 32 bit DR. 7169 + */ 7170 +#define IRWIDTH 8 7171 +#define DRWIDTH 32 7172 +uint32 7173 +jtag_rwreg(void *h, uint32 ir, uint32 dr) 7174 +{ 7175 + chipcregs_t *cc = (chipcregs_t *) h; 7176 + uint32 tmp; 7177 + 7178 + W_REG(&cc->jtagir, ir); 7179 + W_REG(&cc->jtagdr, dr); 7180 + tmp = JCMD_START | JCMD_ACC_IRDR | 7181 + ((IRWIDTH - 1) << JCMD_IRW_SHIFT) | 7182 + (DRWIDTH - 1); 7183 + W_REG(&cc->jtagcmd, tmp); 7184 + while (((tmp = R_REG(&cc->jtagcmd)) & JCMD_BUSY) == JCMD_BUSY) { 7185 + /* OSL_DELAY(1); */ 7186 + } 7187 + 7188 + tmp = R_REG(&cc->jtagdr); 7189 + return (tmp); 7190 +} 7191 + 7192 +/* Returns the SB interrupt flag of the current core. */ 7193 +uint32 7194 +sb_flag(void *sbh) 7195 +{ 7196 + void *regs; 7197 + sbconfig_t *sb; 7198 + 7199 + regs = sb_coreregs(sbh); 7200 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF); 7201 + 7202 + return (R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK); 7203 +} 7204 + 10096 +#include <sbhndmips.h> 10097 +#include <hndcpu.h> 10098 + 10099 +/* sbipsflag register format, indexed by irq. */ 7205 10100 +static const uint32 sbips_int_mask[] = { 7206 + 0, 10101 + 0, /* placeholder */ 7207 10102 + SBIPS_INT1_MASK, 7208 10103 + SBIPS_INT2_MASK, … … 7212 10107 + 7213 10108 +static const uint32 sbips_int_shift[] = { 7214 + 0, 7215 + 0,10109 + 0, /* placeholder */ 10110 + SBIPS_INT1_SHIFT, 7216 10111 + SBIPS_INT2_SHIFT, 7217 10112 + SBIPS_INT3_SHIFT, … … 7219 10114 +}; 7220 10115 + 7221 +/* 10116 +/* 10117 + * Map SB cores sharing the MIPS hardware IRQ0 to virtual dedicated OS IRQs. 10118 + * Per-port BSP code is required to provide necessary translations between 10119 + * the shared MIPS IRQ and the virtual OS IRQs based on SB core flag. 10120 + * 10121 + * See sb_irq() for the mapping. 10122 + */ 10123 +static uint shirq_map_base = 0; 10124 + 10125 +/* Returns the SB interrupt flag of the current core. */ 10126 +static uint32 10127 +sb_getflag(sb_t *sbh) 10128 +{ 10129 + osl_t *osh; 10130 + void *regs; 10131 + sbconfig_t *sb; 10132 + 10133 + osh = sb_osh(sbh); 10134 + regs = sb_coreregs(sbh); 10135 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF); 10136 + 10137 + return (R_REG(osh, &sb->sbtpsflag) & SBTPS_NUM0_MASK); 10138 +} 10139 + 10140 +/* 7222 10141 + * Returns the MIPS IRQ assignment of the current core. If unassigned, 7223 10142 + * 0 is returned. 7224 10143 + */ 7225 10144 +uint 7226 +sb_irq(void *sbh) 7227 +{ 10145 +sb_irq(sb_t *sbh) 10146 +{ 10147 + osl_t *osh; 7228 10148 + uint idx; 7229 10149 + void *regs; … … 7232 10152 + uint irq = 0; 7233 10153 + 7234 + flag = sb_flag(sbh); 10154 + osh = sb_osh(sbh); 10155 + flag = sb_getflag(sbh); 7235 10156 + 7236 10157 + idx = sb_coreidx(sbh); … … 7241 10162 + 7242 10163 + /* sbipsflag specifies which core is routed to interrupts 1 to 4 */ 7243 + sbipsflag = R_REG( &sb->sbipsflag);10164 + sbipsflag = R_REG(osh, &sb->sbipsflag); 7244 10165 + for (irq = 1; irq <= 4; irq++) { 7245 10166 + if (((sbipsflag & sbips_int_mask[irq]) >> sbips_int_shift[irq]) == flag) … … 7256 10177 + 7257 10178 +/* Clears the specified MIPS IRQ. */ 7258 +static void 7259 +BCMINITFN(sb_clearirq)(void *sbh, uint irq) 7260 +{ 10179 +static void 10180 +BCMINITFN(sb_clearirq)(sb_t *sbh, uint irq) 10181 +{ 10182 + osl_t *osh; 7261 10183 + void *regs; 7262 10184 + sbconfig_t *sb; 10185 + 10186 + osh = sb_osh(sbh); 7263 10187 + 7264 10188 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) && … … 7268 10192 + 7269 10193 + if (irq == 0) 7270 + W_REG( &sb->sbintvec, 0);10194 + W_REG(osh, &sb->sbintvec, 0); 7271 10195 + else 7272 + OR_REG( &sb->sbipsflag, sbips_int_mask[irq]);7273 +} 7274 + 7275 +/* 10196 + OR_REG(osh, &sb->sbipsflag, sbips_int_mask[irq]); 10197 +} 10198 + 10199 +/* 7276 10200 + * Assigns the specified MIPS IRQ to the specified core. Shared MIPS 7277 10201 + * IRQ 0 may be assigned more than once. 10202 + * 10203 + * The old assignment to the specified core is removed first. 7278 10204 + */ 7279 +static void 7280 +BCMINITFN(sb_setirq)(void *sbh, uint irq, uint coreid, uint coreunit) 7281 +{ 10205 +static void 10206 +BCMINITFN(sb_setirq)(sb_t *sbh, uint irq, uint coreid, uint coreunit) 10207 +{ 10208 + osl_t *osh; 7282 10209 + void *regs; 7283 10210 + sbconfig_t *sb; 7284 10211 + uint32 flag; 10212 + uint oldirq; 10213 + 10214 + osh = sb_osh(sbh); 7285 10215 + 7286 10216 + regs = sb_setcore(sbh, coreid, coreunit); 7287 10217 + ASSERT(regs); 7288 + flag = sb_flag(sbh); 10218 + flag = sb_getflag(sbh); 10219 + oldirq = sb_irq(sbh); 10220 + if (oldirq) 10221 + sb_clearirq(sbh, oldirq); 7289 10222 + 7290 10223 + if (!(regs = sb_setcore(sbh, SB_MIPS, 0)) && … … 7293 10226 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF); 7294 10227 + 10228 + if (!oldirq) 10229 + AND_REG(osh, &sb->sbintvec, ~(1 << flag)); 10230 + 7295 10231 + if (irq == 0) 7296 + OR_REG( &sb->sbintvec, 1 << flag);10232 + OR_REG(osh, &sb->sbintvec, 1 << flag); 7297 10233 + else { 7298 10234 + flag <<= sbips_int_shift[irq]; 7299 10235 + ASSERT(!(flag & ~sbips_int_mask[irq])); 7300 + flag |= R_REG( &sb->sbipsflag) & ~sbips_int_mask[irq];7301 + W_REG( &sb->sbipsflag, flag);7302 + } 7303 +} 7304 + 7305 +/* 10236 + flag |= R_REG(osh, &sb->sbipsflag) & ~sbips_int_mask[irq]; 10237 + W_REG(osh, &sb->sbipsflag, flag); 10238 + } 10239 +} 10240 + 10241 +/* 7306 10242 + * Initializes clocks and interrupts. SB and NVRAM access must be 7307 10243 + * initialized prior to calling. 10244 + * 10245 + * 'shirqmap' enables virtual dedicated OS IRQ mapping if non-zero. 7308 10246 + */ 7309 +void 7310 +BCMINITFN(sb_mips_init)(void *sbh) 7311 +{ 10247 +void 10248 +BCMINITFN(sb_mips_init)(sb_t *sbh, uint shirqmap) 10249 +{ 10250 + osl_t *osh; 7312 10251 + ulong hz, ns, tmp; 7313 10252 + extifregs_t *eir; … … 7316 10255 + uint irq; 7317 10256 + 10257 + osh = sb_osh(sbh); 10258 + 7318 10259 + /* Figure out current SB clock speed */ 7319 10260 + if ((hz = sb_clock(sbh)) == 0) … … 7324 10265 + if ((eir = sb_setcore(sbh, SB_EXTIF, 0))) { 7325 10266 + /* Initialize extif so we can get to the LEDs and external UART */ 7326 + W_REG( &eir->prog_config, CF_EN);10267 + W_REG(osh, &eir->prog_config, CF_EN); 7327 10268 + 7328 10269 + /* Set timing for the flash */ … … 7330 10271 + tmp = tmp | (CEIL(40, ns) << FW_W1_SHIFT); /* W1 = 40nS */ 7331 10272 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */ 7332 + W_REG( &eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */10273 + W_REG(osh, &eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */ 7333 10274 + 7334 10275 + /* Set programmable interface timing for external uart */ … … 7337 10278 + tmp = tmp | (CEIL(100, ns) << FW_W1_SHIFT); /* W1 = 100nS */ 7338 10279 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */ 7339 + W_REG( &eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */10280 + W_REG(osh, &eir->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */ 7340 10281 + } else if ((cc = sb_setcore(sbh, SB_CC, 0))) { 7341 +//==================================tallest===============================================7342 + /* set register for external IO to control LED. */7343 + W_REG(&cc->prog_config, 0x11);7344 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */7345 + tmp = tmp | (CEIL(40, ns) << FW_W1_SHIFT); /* W1 = 40nS */7346 + tmp = tmp | CEIL(240, ns); /* W0 = 120nS */7347 + W_REG(&cc->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */7348 +//========================================================================================7349 10282 + /* Set timing for the flash */ 7350 10283 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */ 7351 10284 + tmp |= CEIL(10, ns) << FW_W1_SHIFT; /* W1 = 10nS */ 7352 10285 + tmp |= CEIL(120, ns); /* W0 = 120nS */ 7353 + 7354 + // Added by Chen-I for 5365 7355 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID) 7356 + { 7357 + W_REG(&cc->flash_waitcount, tmp); 7358 + W_REG(&cc->pcmcia_memwait, tmp); 10286 + if ((sb_corerev(sbh) < 9) || 10287 + (BCMINIT(sb_chip)(sbh) == 0x5365)) 10288 + W_REG(osh, &cc->flash_waitcount, tmp); 10289 + 10290 + if ((sb_corerev(sbh) < 9) || 10291 + ((sb_chip(sbh) == BCM5350_CHIP_ID) && sb_chiprev(sbh) == 0) || 10292 + (BCMINIT(sb_chip)(sbh) == 0x5365)) { 10293 + W_REG(osh, &cc->pcmcia_memwait, tmp); 7359 10294 + } 7360 + else 7361 + { 7362 + if (sb_corerev(sbh) < 9) 7363 + W_REG(&cc->flash_waitcount, tmp); 7364 + 7365 + if ( (sb_corerev(sbh) < 9) || 7366 + ((BCMINIT(sb_chip)(sbh) == BCM5350_DEVICE_ID) && BCMINIT(sb_chiprev)(sbh) == 0) ) { 7367 + W_REG(&cc->pcmcia_memwait, tmp); 7368 + } 7369 + } 7370 + 7371 + // Added by Chen-I & Yen for enabling 5350 EXTIF 7372 + if (BCMINIT(sb_chip)(sbh) == BCM5350_DEVICE_ID) 7373 + { 7374 + /* Set programmable interface timing for external uart */ 7375 + tmp = CEIL(10, ns) << FW_W3_SHIFT; /* W3 = 10nS */ 7376 + tmp = tmp | (CEIL(20, ns) << FW_W2_SHIFT); /* W2 = 20nS */ 7377 + tmp = tmp | (CEIL(100, ns) << FW_W1_SHIFT); /* W1 = 100nS */ 7378 + tmp = tmp | CEIL(120, ns); /* W0 = 120nS */ 7379 + W_REG(&cc->prog_waitcount, tmp); /* 0x01020a0c for a 100Mhz clock */ 7380 + //printf("===========config_REG=%d\n", R_REG(&cc->prog_config)); 7381 + //printf("-----------config_REG_addr=%x\n", &cc->prog_config); 7382 + //printf("===========waitcount_REG=%d\n", R_REG(&cc->prog_waitcount)); 7383 + //printf("-----------waitcount_REG=%x\n", &cc->prog_waitcount); 7384 + } 10295 + 10296 + /* Save shared IRQ mapping base */ 10297 + shirq_map_base = shirqmap; 7385 10298 + } 7386 10299 + 7387 10300 + /* Chip specific initialization */ 7388 + switch ( BCMINIT(sb_chip)(sbh)) {7389 + case BCM4710_ DEVICE_ID:10301 + switch (sb_chip(sbh)) { 10302 + case BCM4710_CHIP_ID: 7390 10303 + /* Clear interrupt map */ 7391 10304 + for (irq = 0; irq <= 4; irq++) 7392 + BCMINIT(sb_clearirq)(sbh, irq);7393 + BCMINIT(sb_setirq)(sbh, 0, SB_CODEC, 0);7394 + BCMINIT(sb_setirq)(sbh, 0, SB_EXTIF, 0);7395 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 1);7396 + BCMINIT(sb_setirq)(sbh, 3, SB_ILINE20, 0);7397 + BCMINIT(sb_setirq)(sbh, 4, SB_PCI, 0);10305 + sb_clearirq(sbh, irq); 10306 + sb_setirq(sbh, 0, SB_CODEC, 0); 10307 + sb_setirq(sbh, 0, SB_EXTIF, 0); 10308 + sb_setirq(sbh, 2, SB_ENET, 1); 10309 + sb_setirq(sbh, 3, SB_ILINE20, 0); 10310 + sb_setirq(sbh, 4, SB_PCI, 0); 7398 10311 + ASSERT(eir); 7399 + value = BCMINIT(nvram_get)("et0phyaddr");10312 + value = nvram_get("et0phyaddr"); 7400 10313 + if (value && !strcmp(value, "31")) { 7401 10314 + /* Enable internal UART */ 7402 + W_REG( &eir->corecontrol, CC_UE);10315 + W_REG(osh, &eir->corecontrol, CC_UE); 7403 10316 + /* Give USB its own interrupt */ 7404 + BCMINIT(sb_setirq)(sbh, 1, SB_USB, 0);10317 + sb_setirq(sbh, 1, SB_USB, 0); 7405 10318 + } else { 7406 10319 + /* Disable internal UART */ 7407 + W_REG( &eir->corecontrol, 0);10320 + W_REG(osh, &eir->corecontrol, 0); 7408 10321 + /* Give Ethernet its own interrupt */ 7409 + BCMINIT(sb_setirq)(sbh, 1, SB_ENET, 0);7410 + BCMINIT(sb_setirq)(sbh, 0, SB_USB, 0);10322 + sb_setirq(sbh, 1, SB_ENET, 0); 10323 + sb_setirq(sbh, 0, SB_USB, 0); 7411 10324 + } 7412 10325 + break; 7413 + case BCM4310_DEVICE_ID: 7414 + MTC0(C0_BROADCOM, 0, MFC0(C0_BROADCOM, 0) & ~(1 << 22)); 10326 + case BCM5350_CHIP_ID: 10327 + /* Clear interrupt map */ 10328 + for (irq = 0; irq <= 4; irq++) 10329 + sb_clearirq(sbh, irq); 10330 + sb_setirq(sbh, 0, SB_CC, 0); 10331 + sb_setirq(sbh, 0, SB_MIPS33, 0); 10332 + sb_setirq(sbh, 1, SB_D11, 0); 10333 + sb_setirq(sbh, 2, SB_ENET, 0); 10334 + sb_setirq(sbh, 3, SB_PCI, 0); 10335 + sb_setirq(sbh, 4, SB_USB, 0); 7415 10336 + break; 7416 + case BCM5350_DEVICE_ID: 7417 + /* Clear interrupt map */ 7418 + for (irq = 0; irq <= 4; irq++) 7419 + BCMINIT(sb_clearirq)(sbh, irq); 7420 + BCMINIT(sb_setirq)(sbh, 0, SB_CC, 0); 7421 + BCMINIT(sb_setirq)(sbh, 1, SB_D11, 0); 7422 + BCMINIT(sb_setirq)(sbh, 2, SB_ENET, 0); 7423 + BCMINIT(sb_setirq)(sbh, 3, SB_IPSEC, 0); 7424 + BCMINIT(sb_setirq)(sbh, 4, SB_USB, 0); 10337 + case BCM4785_CHIP_ID: 10338 + /* Reassign PCI to irq 4 */ 10339 + sb_setirq(sbh, 4, SB_PCI, 0); 7425 10340 + break; 7426 10341 + } … … 7428 10343 + 7429 10344 +uint32 7430 +BCMINITFN(sb_ mips_clock)(void*sbh)10345 +BCMINITFN(sb_cpu_clock)(sb_t *sbh) 7431 10346 +{ 7432 10347 + extifregs_t *eir; … … 7442 10357 + /* switch to extif or chipc core */ 7443 10358 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) { 7444 + n = R_REG( &eir->clockcontrol_n);7445 + m = R_REG( &eir->clockcontrol_sb);10359 + n = R_REG(osh, &eir->clockcontrol_n); 10360 + m = R_REG(osh, &eir->clockcontrol_sb); 7446 10361 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) { 7447 + pll_type = R_REG( &cc->capabilities) & CAP_PLL_MASK;7448 + n = R_REG( &cc->clockcontrol_n);10362 + pll_type = R_REG(osh, &cc->capabilities) & CAP_PLL_MASK; 10363 + n = R_REG(osh, &cc->clockcontrol_n); 7449 10364 + if ((pll_type == PLL_TYPE2) || 7450 10365 + (pll_type == PLL_TYPE4) || 7451 10366 + (pll_type == PLL_TYPE6) || 7452 10367 + (pll_type == PLL_TYPE7)) 7453 + m = R_REG( &cc->clockcontrol_mips);10368 + m = R_REG(osh, &cc->clockcontrol_m3); 7454 10369 + else if (pll_type == PLL_TYPE5) { 7455 10370 + rate = 200000000; … … 7457 10372 + } 7458 10373 + else if (pll_type == PLL_TYPE3) { 7459 + if ( BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID) { /* 5365 is also type3 */10374 + if (sb_chip(sbh) == BCM5365_CHIP_ID) { 7460 10375 + rate = 200000000; 7461 10376 + goto out; 7462 + } else 7463 + m = R_REG(&cc->clockcontrol_m2); /* 5350 uses m2 to control mips */ 10377 + } 10378 + /* 5350 uses m2 to control mips */ 10379 + else 10380 + m = R_REG(osh, &cc->clockcontrol_m2); 7464 10381 + } else 7465 + m = R_REG( &cc->clockcontrol_sb);10382 + m = R_REG(osh, &cc->clockcontrol_sb); 7466 10383 + } else 7467 10384 + goto out; 7468 10385 + 7469 + // Added by Chen-I for 5365 7470 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID) 10386 + 10387 + /* calculate rate */ 10388 + if (BCMINIT(sb_chip)(sbh) == 0x5365) 7471 10389 + rate = 100000000; 7472 10390 + else 7473 + /* calculate rate */7474 10391 + rate = sb_clock_rate(pll_type, n, m); 7475 10392 + … … 7486 10403 +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4) 7487 10404 + 7488 +static void 10405 +static void 7489 10406 +BCMINITFN(handler)(void) 7490 10407 +{ 7491 + /* Step 11 */ 7492 + __asm__ ( 10408 + __asm__( 7493 10409 + ".set\tmips32\n\t" 7494 10410 + "ssnop\n\t" … … 7504 10420 + "nop\n\t" 7505 10421 + "nop\n\t" 7506 + ".set\tmips0" 7507 + ); 10422 + ".set\tmips0"); 7508 10423 +} 7509 10424 + 7510 10425 +/* The following MUST come right after handler() */ 7511 +static void 10426 +static void 7512 10427 +BCMINITFN(afterhandler)(void) 7513 10428 +{ … … 7516 10431 +/* 7517 10432 + * Set the MIPS, backplane and PCI clocks as closely as possible. 10433 + * 10434 + * MIPS clocks synchronization function has been moved from PLL in chipcommon 10435 + * core rev. 15 to a DLL inside the MIPS core in 4785. 7518 10436 + */ 7519 +bool 7520 +BCMINITFN(sb_mips_setclock)( void*sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock)10437 +bool 10438 +BCMINITFN(sb_mips_setclock)(sb_t *sbh, uint32 mipsclock, uint32 sbclock, uint32 pciclock) 7521 10439 +{ 7522 10440 + extifregs_t *eir = NULL; … … 7528 10446 + uint ic_size, ic_lsize; 7529 10447 + uint idx, i; 10448 + 10449 + /* PLL configuration: type 1 */ 7530 10450 + typedef struct { 7531 10451 + uint32 mipsclock; … … 7536 10456 + } n3m_table_t; 7537 10457 + static n3m_table_t BCMINITDATA(type1_table)[] = { 7538 + { 96000000, 0x0303, 0x04020011, 0x11030011, 0x11050011 }, /* 96.000 32.000 24.000 */ 7539 + { 100000000, 0x0009, 0x04020011, 0x11030011, 0x11050011 }, /* 100.000 33.333 25.000 */ 7540 + { 104000000, 0x0802, 0x04020011, 0x11050009, 0x11090009 }, /* 104.000 31.200 24.960 */ 7541 + { 108000000, 0x0403, 0x04020011, 0x11050009, 0x02000802 }, /* 108.000 32.400 24.923 */ 7542 + { 112000000, 0x0205, 0x04020011, 0x11030021, 0x02000403 }, /* 112.000 32.000 24.889 */ 7543 + { 115200000, 0x0303, 0x04020009, 0x11030011, 0x11050011 }, /* 115.200 32.000 24.000 */ 7544 + { 120000000, 0x0011, 0x04020011, 0x11050011, 0x11090011 }, /* 120.000 30.000 24.000 */ 7545 + { 124800000, 0x0802, 0x04020009, 0x11050009, 0x11090009 }, /* 124.800 31.200 24.960 */ 7546 + { 128000000, 0x0305, 0x04020011, 0x11050011, 0x02000305 }, /* 128.000 32.000 24.000 */ 7547 + { 132000000, 0x0603, 0x04020011, 0x11050011, 0x02000305 }, /* 132.000 33.000 24.750 */ 7548 + { 136000000, 0x0c02, 0x04020011, 0x11090009, 0x02000603 }, /* 136.000 32.640 24.727 */ 7549 + { 140000000, 0x0021, 0x04020011, 0x11050021, 0x02000c02 }, /* 140.000 30.000 24.706 */ 7550 + { 144000000, 0x0405, 0x04020011, 0x01020202, 0x11090021 }, /* 144.000 30.857 24.686 */ 7551 + { 150857142, 0x0605, 0x04020021, 0x02000305, 0x02000605 }, /* 150.857 33.000 24.000 */ 7552 + { 152000000, 0x0e02, 0x04020011, 0x11050021, 0x02000e02 }, /* 152.000 32.571 24.000 */ 7553 + { 156000000, 0x0802, 0x04020005, 0x11050009, 0x11090009 }, /* 156.000 31.200 24.960 */ 7554 + { 160000000, 0x0309, 0x04020011, 0x11090011, 0x02000309 }, /* 160.000 32.000 24.000 */ 7555 + { 163200000, 0x0c02, 0x04020009, 0x11090009, 0x02000603 }, /* 163.200 32.640 24.727 */ 7556 + { 168000000, 0x0205, 0x04020005, 0x11030021, 0x02000403 }, /* 168.000 32.000 24.889 */ 7557 + { 176000000, 0x0602, 0x04020003, 0x11050005, 0x02000602 }, /* 176.000 33.000 24.000 */ 7558 + }; 10458 + /* 96.000 32.000 24.000 */ 10459 + { 96000000, 0x0303, 0x04020011, 0x11030011, 0x11050011 }, 10460 + /* 100.000 33.333 25.000 */ 10461 + { 100000000, 0x0009, 0x04020011, 0x11030011, 0x11050011 }, 10462 + /* 104.000 31.200 24.960 */ 10463 + { 104000000, 0x0802, 0x04020011, 0x11050009, 0x11090009 }, 10464 + /* 108.000 32.400 24.923 */ 10465 + { 108000000, 0x0403, 0x04020011, 0x11050009, 0x02000802 }, 10466 + /* 112.000 32.000 24.889 */ 10467 + { 112000000, 0x0205, 0x04020011, 0x11030021, 0x02000403 }, 10468 + /* 115.200 32.000 24.000 */ 10469 + { 115200000, 0x0303, 0x04020009, 0x11030011, 0x11050011 }, 10470 + /* 120.000 30.000 24.000 */ 10471 + { 120000000, 0x0011, 0x04020011, 0x11050011, 0x11090011 }, 10472 + /* 124.800 31.200 24.960 */ 10473 + { 124800000, 0x0802, 0x04020009, 0x11050009, 0x11090009 }, 10474 + /* 128.000 32.000 24.000 */ 10475 + { 128000000, 0x0305, 0x04020011, 0x11050011, 0x02000305 }, 10476 + /* 132.000 33.000 24.750 */ 10477 + { 132000000, 0x0603, 0x04020011, 0x11050011, 0x02000305 }, 10478 + /* 136.000 32.640 24.727 */ 10479 + { 136000000, 0x0c02, 0x04020011, 0x11090009, 0x02000603 }, 10480 + /* 140.000 30.000 24.706 */ 10481 + { 140000000, 0x0021, 0x04020011, 0x11050021, 0x02000c02 }, 10482 + /* 144.000 30.857 24.686 */ 10483 + { 144000000, 0x0405, 0x04020011, 0x01020202, 0x11090021 }, 10484 + /* 150.857 33.000 24.000 */ 10485 + { 150857142, 0x0605, 0x04020021, 0x02000305, 0x02000605 }, 10486 + /* 152.000 32.571 24.000 */ 10487 + { 152000000, 0x0e02, 0x04020011, 0x11050021, 0x02000e02 }, 10488 + /* 156.000 31.200 24.960 */ 10489 + { 156000000, 0x0802, 0x04020005, 0x11050009, 0x11090009 }, 10490 + /* 160.000 32.000 24.000 */ 10491 + { 160000000, 0x0309, 0x04020011, 0x11090011, 0x02000309 }, 10492 + /* 163.200 32.640 24.727 */ 10493 + { 163200000, 0x0c02, 0x04020009, 0x11090009, 0x02000603 }, 10494 + /* 168.000 32.000 24.889 */ 10495 + { 168000000, 0x0205, 0x04020005, 0x11030021, 0x02000403 }, 10496 + /* 176.000 33.000 24.000 */ 10497 + { 176000000, 0x0602, 0x04020003, 0x11050005, 0x02000602 }, 10498 + }; 10499 + 10500 + /* PLL configuration: type 3 */ 7559 10501 + typedef struct { 7560 10502 + uint32 mipsclock; … … 7562 10504 + uint32 m2; /* that is the clockcontrol_m2 */ 7563 10505 + } type3_table_t; 7564 + static type3_table_t type3_table[] = { /* for 5350, mips clock is always double sb clock */ 7565 + { 150000000, 0x311, 0x4020005 }, 7566 + { 200000000, 0x311, 0x4020003 }, 7567 + }; 10506 + static type3_table_t type3_table[] = { 10507 + /* for 5350, mips clock is always double sb clock */ 10508 + { 150000000, 0x311, 0x4020005 }, 10509 + { 200000000, 0x311, 0x4020003 }, 10510 + }; 10511 + 10512 + /* PLL configuration: type 2, 4, 7 */ 7568 10513 + typedef struct { 7569 10514 + uint32 mipsclock; … … 7576 10521 + uint32 ratio_cfg; 7577 10522 + uint32 ratio_parm; 10523 + uint32 d11_r1; 10524 + uint32 d11_r2; 7578 10525 + } n4m_table_t; 7579 +7580 10526 + static n4m_table_t BCMINITDATA(type2_table)[] = { 7581 + { 180000000, 80000000, 0x0403, 0x01010000, 0x01020300, 0x01020600, 0x05000100, 8, 0x012a00a9 }, 7582 + { 180000000, 90000000, 0x0403, 0x01000100, 0x01020300, 0x01000100, 0x05000100, 11, 0x0aaa0555 }, 7583 + { 200000000, 100000000, 0x0303, 0x02010000, 0x02040001, 0x02010000, 0x06000001, 11, 0x0aaa0555 }, 7584 + { 211200000, 105600000, 0x0902, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 11, 0x0aaa0555 }, 7585 + { 220800000, 110400000, 0x1500, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 11, 0x0aaa0555 }, 7586 + { 230400000, 115200000, 0x0604, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 11, 0x0aaa0555 }, 7587 + { 234000000, 104000000, 0x0b01, 0x01010000, 0x01010700, 0x01020600, 0x05000100, 8, 0x012a00a9 }, 7588 + { 240000000, 120000000, 0x0803, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 11, 0x0aaa0555 }, 7589 + { 252000000, 126000000, 0x0504, 0x01000100, 0x01020500, 0x01000100, 0x05000100, 11, 0x0aaa0555 }, 7590 + { 264000000, 132000000, 0x0903, 0x01000200, 0x01020700, 0x01000200, 0x05000200, 11, 0x0aaa0555 }, 7591 + { 270000000, 120000000, 0x0703, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 }, 7592 + { 276000000, 122666666, 0x1500, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 }, 7593 + { 280000000, 140000000, 0x0503, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 11, 0x0aaa0555 }, 7594 + { 288000000, 128000000, 0x0604, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 0x012a00a9 }, 7595 + { 288000000, 144000000, 0x0404, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 11, 0x0aaa0555 }, 7596 + { 300000000, 133333333, 0x0803, 0x01010000, 0x01020600, 0x01020600, 0x05000100, 8, 0x012a00a9 }, 7597 + { 300000000, 150000000, 0x0803, 0x01000100, 0x01020600, 0x01000100, 0x05000100, 11, 0x0aaa0555 } 10527 + { 120000000, 60000000, 0x0303, 0x01000200, 0x01000600, 0x01000200, 0x05000200, 11, 10528 + 0x0aaa0555, 8 /* ratio 4/8 */, 0x00aa0055 }, 10529 + { 150000000, 75000000, 0x0303, 0x01000100, 0x01000600, 0x01000100, 0x05000100, 11, 10530 + 0x0aaa0555, 8 /* ratio 4/8 */, 0x00aa0055 }, 10531 + { 180000000, 80000000, 0x0403, 0x01010000, 0x01020300, 0x01020600, 0x05000100, 8, 10532 + 0x012a00a9, 9 /* ratio 4/9 */, 0x012a00a9 }, 10533 + { 180000000, 90000000, 0x0403, 0x01000100, 0x01020300, 0x01000100, 0x05000100, 11, 10534 + 0x0aaa0555, 8 /* ratio 4/8 */, 0x00aa0055 }, 10535 + { 200000000, 100000000, 0x0303, 0x02010000, 0x02040001, 0x02010000, 0x06000001, 11, 10536 + 0x0aaa0555, 8 /* ratio 4/8 */, 0x00aa0055 }, 10537 + { 211200000, 105600000, 0x0902, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 11, 10538 + 0x0aaa0555, 8 /* ratio 4/8 */, 0x00aa0055 }, 10539 + { 220800000, 110400000, 0x1500, 0x01000200, 0x01030400, 0x01000200, 0x05000200, 11, 10540 + 0x0aaa0555, 8 /* ratio 4/8 */, 0x00aa0055 }, 10541 + { 230400000, 115200000, 0x0604, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 11, 10542 + 0x0aaa0555, 8 /* ratio 4/8 */, 0x00aa0055 }, 10543 + { 234000000, 104000000, 0x0b01, 0x01010000, 0x01010700, 0x01020600, 0x05000100, 8, 10544 + 0x012a00a9, 9 /* ratio 4/9 */, 0x012a00a9 }, 10545 + { 240000000, 120000000, 0x0803, 0x01000200, 0x01020600, 0x01000200, 0x05000200, 11, 10546 + 0x0aaa0555, 8 /* ratio 4/8 */, 0x00aa0055 }, 10547 + { 252000000, 126000000, 0x0504, 0x01000100, 0x01020500, 0x01000100, 0x05000100, 11, 10548 + 0x0aaa0555, 8 /* ratio 4/8 */, 0x00aa0055 }, 10549 + { 264000000, 132000000, 0x0903, 0x01000200, 0x01020700, 0x01000200, 0x05000200, 11, 10550 + 0x0aaa0555, 8 /* ratio 4/8 */, 0x00aa0055 }, 10551 + { 270000000, 120000000, 0x0703, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 10552 + 0x012a00a9, 9 /* ratio 4/9 */, 0x012a00a9 }, 10553 + { 276000000, 122666666, 0x1500, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 10554 + 0x012a00a9, 9 /* ratio 4/9 */, 0x012a00a9 }, 10555 + { 280000000, 140000000, 0x0503, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 11, 10556 + 0x0aaa0555, 8 /* ratio 4/8 */, 0x00aa0055 }, 10557 + { 288000000, 128000000, 0x0604, 0x01010000, 0x01030400, 0x01020600, 0x05000100, 8, 10558 + 0x012a00a9, 9 /* ratio 4/9 */, 0x012a00a9 }, 10559 + { 288000000, 144000000, 0x0404, 0x01000000, 0x01010600, 0x01000000, 0x05000000, 11, 10560 + 0x0aaa0555, 8 /* ratio 4/8 */, 0x00aa0055 }, 10561 + { 300000000, 133333333, 0x0803, 0x01010000, 0x01020600, 0x01010100, 0x05000100, 8, 10562 + 0x012a00a9, 9 /* ratio 4/9 */, 0x012a00a9 }, 10563 + { 300000000, 150000000, 0x0803, 0x01000100, 0x01020600, 0x01010100, 0x05000100, 11, 10564 + 0x0aaa0555, 8 /* ratio 4/8 */, 0x00aa0055 }, 10565 + { 330000000, 132000000, 0x0903, 0x01000200, 0x00020200, 0x01010100, 0x05000100, 0, 10566 + 0, 10 /* ratio 4/10 */, 0x02520129 }, 10567 + { 330000000, 146666666, 0x0903, 0x01010000, 0x00020200, 0x01010100, 0x05000100, 0, 10568 + 0, 9 /* ratio 4/9 */, 0x012a00a9 }, 10569 + { 330000000, 165000000, 0x0903, 0x01000100, 0x00020200, 0x01010100, 0x05000100, 0, 10570 + 0, 8 /* ratio 4/8 */, 0x00aa0055 }, 10571 + { 360000000, 120000000, 0x0a03, 0x01000300, 0x00010201, 0x01010200, 0x05000100, 0, 10572 + 0, 12 /* ratio 4/12 */, 0x04920492 }, 10573 + { 360000000, 144000000, 0x0a03, 0x01000200, 0x00010201, 0x01010200, 0x05000100, 0, 10574 + 0, 10 /* ratio 4/10 */, 0x02520129 }, 10575 + { 360000000, 160000000, 0x0a03, 0x01010000, 0x00010201, 0x01010200, 0x05000100, 0, 10576 + 0, 9 /* ratio 4/9 */, 0x012a00a9 }, 10577 + { 360000000, 180000000, 0x0a03, 0x01000100, 0x00010201, 0x01010200, 0x05000100, 0, 10578 + 0, 8 /* ratio 4/8 */, 0x00aa0055 }, 10579 + { 390000000, 130000000, 0x0b03, 0x01010100, 0x00020101, 0x01020100, 0x05000100, 0, 10580 + 0, 12 /* ratio 4/12 */, 0x04920492 }, 10581 + { 390000000, 156000000, 0x0b03, 0x01000200, 0x00020101, 0x01020100, 0x05000100, 0, 10582 + 0, 10 /* ratio 4/10 */, 0x02520129 }, 10583 + { 390000000, 173000000, 0x0b03, 0x01010000, 0x00020101, 0x01020100, 0x05000100, 0, 10584 + 0, 9 /* ratio 4/9 */, 0x012a00a9 }, 10585 + { 390000000, 195000000, 0x0b03, 0x01000100, 0x00020101, 0x01020100, 0x05000100, 0, 10586 + 0, 8 /* ratio 4/8 */, 0x00aa0055 }, 7598 10587 + }; 7599 +7600 10588 + static n4m_table_t BCMINITDATA(type4_table)[] = { 7601 + { 192000000, 96000000, 0x0702, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 }, 7602 + { 198000000, 99000000, 0x0603, 0x11020005, 0x11030011, 0x11020005, 0x04000005, 11, 0x0aaa0555 }, 7603 + { 200000000, 100000000, 0x0009, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 11, 0x0aaa0555 }, 7604 + { 204000000, 102000000, 0x0c02, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 }, 7605 + { 208000000, 104000000, 0x0802, 0x11030002, 0x11090005, 0x11030002, 0x04000003, 11, 0x0aaa0555 }, 7606 + { 210000000, 105000000, 0x0209, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 }, 7607 + { 216000000, 108000000, 0x0111, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 }, 7608 + { 224000000, 112000000, 0x0205, 0x11030002, 0x02002103, 0x11030002, 0x04000003, 11, 0x0aaa0555 }, 7609 + { 228000000, 101333333, 0x0e02, 0x11030003, 0x11210005, 0x01030305, 0x04000005, 8, 0x012a00a9 }, 7610 + { 228000000, 114000000, 0x0e02, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 11, 0x0aaa0555 }, 7611 + { 240000000, 102857143, 0x0109, 0x04000021, 0x01050203, 0x11030021, 0x04000003, 13, 0x254a14a9 }, 7612 + { 240000000, 120000000, 0x0109, 0x11030002, 0x01050203, 0x11030002, 0x04000003, 11, 0x0aaa0555 }, 7613 + { 252000000, 100800000, 0x0203, 0x04000009, 0x11050005, 0x02000209, 0x04000002, 9, 0x02520129 }, 7614 + { 252000000, 126000000, 0x0203, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 11, 0x0aaa0555 }, 7615 + { 264000000, 132000000, 0x0602, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 11, 0x0aaa0555 }, 7616 + { 272000000, 116571428, 0x0c02, 0x04000021, 0x02000909, 0x02000221, 0x04000003, 13, 0x254a14a9 }, 7617 + { 280000000, 120000000, 0x0209, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 13, 0x254a14a9 }, 7618 + { 288000000, 123428571, 0x0111, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 13, 0x254a14a9 }, 7619 + { 300000000, 120000000, 0x0009, 0x04000009, 0x01030203, 0x02000902, 0x04000002, 9, 0x02520129 }, 7620 + { 300000000, 150000000, 0x0009, 0x04000005, 0x01030203, 0x04000005, 0x04000002, 11, 0x0aaa0555 } 10589 + { 120000000, 60000000, 0x0009, 0x11020009, 0x01030203, 0x11020009, 0x04000009, 11, 10590 + 0x0aaa0555 }, 10591 + { 150000000, 75000000, 0x0009, 0x11050002, 0x01030203, 0x11050002, 0x04000005, 11, 10592 + 0x0aaa0555 }, 10593 + { 192000000, 96000000, 0x0702, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 10594 + 0x0aaa0555 }, 10595 + { 198000000, 99000000, 0x0603, 0x11020005, 0x11030011, 0x11020005, 0x04000005, 11, 10596 + 0x0aaa0555 }, 10597 + { 200000000, 100000000, 0x0009, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 11, 10598 + 0x0aaa0555 }, 10599 + { 204000000, 102000000, 0x0c02, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 10600 + 0x0aaa0555 }, 10601 + { 208000000, 104000000, 0x0802, 0x11030002, 0x11090005, 0x11030002, 0x04000003, 11, 10602 + 0x0aaa0555 }, 10603 + { 210000000, 105000000, 0x0209, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 10604 + 0x0aaa0555 }, 10605 + { 216000000, 108000000, 0x0111, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 10606 + 0x0aaa0555 }, 10607 + { 224000000, 112000000, 0x0205, 0x11030002, 0x02002103, 0x11030002, 0x04000003, 11, 10608 + 0x0aaa0555 }, 10609 + { 228000000, 101333333, 0x0e02, 0x11030003, 0x11210005, 0x01030305, 0x04000005, 8, 10610 + 0x012a00a9 }, 10611 + { 228000000, 114000000, 0x0e02, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 11, 10612 + 0x0aaa0555 }, 10613 + { 240000000, 102857143, 0x0109, 0x04000021, 0x01050203, 0x11030021, 0x04000003, 13, 10614 + 0x254a14a9 }, 10615 + { 240000000, 120000000, 0x0109, 0x11030002, 0x01050203, 0x11030002, 0x04000003, 11, 10616 + 0x0aaa0555 }, 10617 + { 252000000, 100800000, 0x0203, 0x04000009, 0x11050005, 0x02000209, 0x04000002, 9, 10618 + 0x02520129 }, 10619 + { 252000000, 126000000, 0x0203, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 11, 10620 + 0x0aaa0555 }, 10621 + { 264000000, 132000000, 0x0602, 0x04000005, 0x11050005, 0x04000005, 0x04000002, 11, 10622 + 0x0aaa0555 }, 10623 + { 272000000, 116571428, 0x0c02, 0x04000021, 0x02000909, 0x02000221, 0x04000003, 13, 10624 + 0x254a14a9 }, 10625 + { 280000000, 120000000, 0x0209, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 13, 10626 + 0x254a14a9 }, 10627 + { 288000000, 123428571, 0x0111, 0x04000021, 0x01030303, 0x02000221, 0x04000003, 13, 10628 + 0x254a14a9 }, 10629 + { 300000000, 120000000, 0x0009, 0x04000009, 0x01030203, 0x02000902, 0x04000002, 9, 10630 + 0x02520129 }, 10631 + { 300000000, 150000000, 0x0009, 0x04000005, 0x01030203, 0x04000005, 0x04000002, 11, 10632 + 0x0aaa0555 } 7621 10633 + }; 7622 +7623 10634 + static n4m_table_t BCMINITDATA(type7_table)[] = { 7624 + { 183333333, 91666666, 0x0605, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 }, 7625 + { 187500000, 93750000, 0x0a03, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 0x0aaa0555 }, 7626 + { 196875000, 98437500, 0x1003, 0x11020005, 0x11050011, 0x11020005, 0x04000005, 11, 0x0aaa0555 }, 7627 + { 200000000, 100000000, 0x0311, 0x04000011, 0x11030011, 0x04000009, 0x04000003, 11, 0x0aaa0555 }, 7628 + { 200000000, 100000000, 0x0311, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 11, 0x0aaa0555 }, 7629 + { 206250000, 103125000, 0x1103, 0x11020005, 0x11050011, 0x11020005, 0x04000005, 11, 0x0aaa0555 }, 7630 + { 212500000, 106250000, 0x0c05, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 0x0aaa0555 }, 7631 + { 215625000, 107812500, 0x1203, 0x11090009, 0x11050005, 0x11020005, 0x04000005, 11, 0x0aaa0555 }, 7632 + { 216666666, 108333333, 0x0805, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 }, 7633 + { 225000000, 112500000, 0x0d03, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 }, 7634 + { 233333333, 116666666, 0x0905, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 0x0aaa0555 }, 7635 + { 237500000, 118750000, 0x0e05, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 11, 0x0aaa0555 }, 7636 + { 240000000, 120000000, 0x0b11, 0x11020009, 0x11210009, 0x11020009, 0x04000009, 11, 0x0aaa0555 }, 7637 + { 250000000, 125000000, 0x0f03, 0x11020003, 0x11210003, 0x11020003, 0x04000003, 11, 0x0aaa0555 } 10635 + { 183333333, 91666666, 0x0605, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 10636 + 0x0aaa0555 }, 10637 + { 187500000, 93750000, 0x0a03, 0x04000011, 0x11030011, 0x04000011, 0x04000003, 11, 10638 + 0x0aaa0555 }, 10639 + { 196875000, 98437500, 0x1003, 0x11020005, 0x11050011, 0x11020005, 0x04000005, 11, 10640 + 0x0aaa0555 }, 10641 + { 200000000, 100000000, 0x0311, 0x04000011, 0x11030011, 0x04000009, 0x04000003, 11, 10642 + 0x0aaa0555 }, 10643 + { 200000000, 100000000, 0x0311, 0x04020011, 0x11030011, 0x04020011, 0x04020003, 11, 10644 + 0x0aaa0555 }, 10645 + { 206250000, 103125000, 0x1103, 0x11020005, 0x11050011, 0x11020005, 0x04000005, 11, 10646 + 0x0aaa0555 }, 10647 + { 212500000, 106250000, 0x0c05, 0x11020005, 0x01030303, 0x11020005, 0x04000005, 11, 10648 + 0x0aaa0555 }, 10649 + { 215625000, 107812500, 0x1203, 0x11090009, 0x11050005, 0x11020005, 0x04000005, 11, 10650 + 0x0aaa0555 }, 10651 + { 216666666, 108333333, 0x0805, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 10652 + 0x0aaa0555 }, 10653 + { 225000000, 112500000, 0x0d03, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 10654 + 0x0aaa0555 }, 10655 + { 233333333, 116666666, 0x0905, 0x11020003, 0x11030011, 0x11020003, 0x04000003, 11, 10656 + 0x0aaa0555 }, 10657 + { 237500000, 118750000, 0x0e05, 0x11020005, 0x11210005, 0x11020005, 0x04000005, 11, 10658 + 0x0aaa0555 }, 10659 + { 240000000, 120000000, 0x0b11, 0x11020009, 0x11210009, 0x11020009, 0x04000009, 11, 10660 + 0x0aaa0555 }, 10661 + { 250000000, 125000000, 0x0f03, 0x11020003, 0x11210003, 0x11020003, 0x04000003, 11, 10662 + 0x0aaa0555 } 7638 10663 + }; 7639 10664 + 7640 10665 + ulong start, end, dst; 7641 10666 + bool ret = FALSE; 7642 + 10667 + 10668 + volatile uint32 *dll_ctrl = (volatile uint32 *)0xff400008; 10669 + volatile uint32 *dll_r1 = (volatile uint32 *)0xff400010; 10670 + volatile uint32 *dll_r2 = (volatile uint32 *)0xff400018; 10671 + 7643 10672 + /* get index of the current core */ 7644 10673 + idx = sb_coreidx(sbh); … … 7653 10682 + clockcontrol_m2 = &cc->clockcontrol_m2; 7654 10683 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) { 7655 + pll_type = R_REG( &cc->capabilities) & CAP_PLL_MASK;10684 + pll_type = R_REG(osh, &cc->capabilities) & CAP_PLL_MASK; 7656 10685 + if (pll_type == PLL_TYPE6) { 7657 10686 + clockcontrol_n = NULL; … … 7662 10691 + clockcontrol_sb = &cc->clockcontrol_sb; 7663 10692 + clockcontrol_pci = &cc->clockcontrol_pci; 7664 + clockcontrol_m2 = &cc->clockcontrol_m2;10693 + clockcontrol_m2 = &cc->clockcontrol_m2; 7665 10694 + } 7666 10695 + } else … … 7672 10701 + } else { 7673 10702 + /* Store the current clock register values */ 7674 + orig_n = R_REG( clockcontrol_n);7675 + orig_sb = R_REG( clockcontrol_sb);7676 + orig_pci = R_REG( clockcontrol_pci);10703 + orig_n = R_REG(osh, clockcontrol_n); 10704 + orig_sb = R_REG(osh, clockcontrol_sb); 10705 + orig_pci = R_REG(osh, clockcontrol_pci); 7677 10706 + } 7678 10707 + … … 7680 10709 + /* Keep the current PCI clock if not specified */ 7681 10710 + if (pciclock == 0) { 7682 + pciclock = sb_clock_rate(pll_type, R_REG(clockcontrol_n), R_REG(clockcontrol_pci)); 10711 + pciclock = sb_clock_rate(pll_type, R_REG(osh, clockcontrol_n), 10712 + R_REG(osh, clockcontrol_pci)); 7683 10713 + pciclock = (pciclock <= 25000000) ? 25000000 : 33000000; 7684 10714 + } 7685 10715 + 7686 10716 + /* Search for the closest MIPS clock less than or equal to a preferred value */ 7687 + for (i = 0; i < ARRAYSIZE(BCMINIT(type1_table)); i++) { 7688 + ASSERT(BCMINIT(type1_table)[i].mipsclock == 7689 + sb_clock_rate(pll_type, BCMINIT(type1_table)[i].n, BCMINIT(type1_table)[i].sb)); 7690 + if (BCMINIT(type1_table)[i].mipsclock > mipsclock) 10717 + for (i = 0; i < ARRAYSIZE(type1_table); i++) { 10718 + ASSERT(type1_table[i].mipsclock == 10719 + sb_clock_rate(pll_type, type1_table[i].n, 10720 + type1_table[i].sb)); 10721 + if (type1_table[i].mipsclock > mipsclock) 7691 10722 + break; 7692 10723 + } … … 7698 10729 + i--; 7699 10730 + } 7700 + ASSERT( BCMINIT(type1_table)[i].mipsclock <= mipsclock);10731 + ASSERT(type1_table[i].mipsclock <= mipsclock); 7701 10732 + 7702 10733 + /* No PLL change */ 7703 + if ((orig_n == BCMINIT(type1_table)[i].n) &&7704 + (orig_sb == BCMINIT(type1_table)[i].sb) &&7705 + (orig_pci == BCMINIT(type1_table)[i].pci33))10734 + if ((orig_n == type1_table[i].n) && 10735 + (orig_sb == type1_table[i].sb) && 10736 + (orig_pci == type1_table[i].pci33)) 7706 10737 + goto done; 7707 10738 + 7708 10739 + /* Set the PLL controls */ 7709 + W_REG( clockcontrol_n, BCMINIT(type1_table)[i].n);7710 + W_REG( clockcontrol_sb, BCMINIT(type1_table)[i].sb);10740 + W_REG(osh, clockcontrol_n, type1_table[i].n); 10741 + W_REG(osh, clockcontrol_sb, type1_table[i].sb); 7711 10742 + if (pciclock == 25000000) 7712 + W_REG( clockcontrol_pci, BCMINIT(type1_table)[i].pci25);10743 + W_REG(osh, clockcontrol_pci, type1_table[i].pci25); 7713 10744 + else 7714 + W_REG(clockcontrol_pci, BCMINIT(type1_table)[i].pci33); 7715 + 7716 + /* Reset */ 7717 + sb_watchdog(sbh, 1); 7718 + 7719 + while (1); 7720 + } else if ((pll_type == PLL_TYPE3) && 7721 + (BCMINIT(sb_chip)(sbh) != BCM5365_DEVICE_ID)) { 7722 + /* 5350 */ 7723 + /* Search for the closest MIPS clock less than or equal to a preferred value */ 7724 + 7725 + for (i = 0; i < ARRAYSIZE(type3_table); i++) { 7726 + if (type3_table[i].mipsclock > mipsclock) 7727 + break; 7728 + } 7729 + if (i == 0) { 7730 + ret = FALSE; 7731 + goto done; 7732 + } else { 7733 + ret = TRUE; 7734 + i--; 7735 + } 7736 + ASSERT(type3_table[i].mipsclock <= mipsclock); 7737 + 7738 + /* No PLL change */ 7739 + orig_m2 = R_REG(&cc->clockcontrol_m2); 7740 + if ((orig_n == type3_table[i].n) && 7741 + (orig_m2 == type3_table[i].m2)) { 7742 + goto done; 7743 + } 7744 + 7745 + /* Set the PLL controls */ 7746 + W_REG(clockcontrol_n, type3_table[i].n); 7747 + W_REG(clockcontrol_m2, type3_table[i].m2); 10745 + W_REG(osh, clockcontrol_pci, type1_table[i].pci33); 7748 10746 + 7749 10747 + /* Reset */ 7750 10748 + sb_watchdog(sbh, 1); 7751 10749 + while (1); 10750 + } else if (pll_type == PLL_TYPE3) { 10751 + /* 5350 */ 10752 + if (sb_chip(sbh) != BCM5365_CHIP_ID) { 10753 + /* 10754 + * Search for the closest MIPS clock less than or equal to 10755 + * a preferred value. 10756 + */ 10757 + for (i = 0; i < ARRAYSIZE(type3_table); i++) { 10758 + if (type3_table[i].mipsclock > mipsclock) 10759 + break; 10760 + } 10761 + if (i == 0) { 10762 + ret = FALSE; 10763 + goto done; 10764 + } else { 10765 + ret = TRUE; 10766 + i--; 10767 + } 10768 + ASSERT(type3_table[i].mipsclock <= mipsclock); 10769 + 10770 + /* No PLL change */ 10771 + orig_m2 = R_REG(osh, &cc->clockcontrol_m2); 10772 + if ((orig_n == type3_table[i].n) && 10773 + (orig_m2 == type3_table[i].m2)) { 10774 + goto done; 10775 + } 10776 + 10777 + /* Set the PLL controls */ 10778 + W_REG(osh, clockcontrol_n, type3_table[i].n); 10779 + W_REG(osh, clockcontrol_m2, type3_table[i].m2); 10780 + 10781 + /* Reset */ 10782 + sb_watchdog(sbh, 1); 10783 + while (1); 10784 + } 7752 10785 + } else if ((pll_type == PLL_TYPE2) || 7753 + (pll_type == PLL_TYPE4) ||7754 + (pll_type == PLL_TYPE6) ||7755 + (pll_type == PLL_TYPE7)) {10786 + (pll_type == PLL_TYPE4) || 10787 + (pll_type == PLL_TYPE6) || 10788 + (pll_type == PLL_TYPE7)) { 7756 10789 + n4m_table_t *table = NULL, *te; 7757 10790 + uint tabsz = 0; … … 7759 10792 + ASSERT(cc); 7760 10793 + 7761 + orig_mips = R_REG(&cc->clockcontrol_mips); 7762 + 7763 + if (pll_type == PLL_TYPE6) { 10794 + orig_mips = R_REG(osh, &cc->clockcontrol_m3); 10795 + 10796 + switch (pll_type) { 10797 + case PLL_TYPE6: { 7764 10798 + uint32 new_mips = 0; 7765 10799 + … … 7771 10805 + goto done; 7772 10806 + 7773 + W_REG( &cc->clockcontrol_mips, new_mips);10807 + W_REG(osh, &cc->clockcontrol_m3, new_mips); 7774 10808 + goto end_fill; 7775 10809 + } 7776 + 7777 + if (pll_type == PLL_TYPE2) { 7778 + table = BCMINIT(type2_table); 7779 + tabsz = ARRAYSIZE(BCMINIT(type2_table)); 7780 + } else if (pll_type == PLL_TYPE4) { 7781 + table = BCMINIT(type4_table); 7782 + tabsz = ARRAYSIZE(BCMINIT(type4_table)); 7783 + } else if (pll_type == PLL_TYPE7) { 7784 + table = BCMINIT(type7_table); 7785 + tabsz = ARRAYSIZE(BCMINIT(type7_table)); 7786 + } else 7787 + ASSERT((char *)"No table for plltype" == NULL); 10810 + case PLL_TYPE2: 10811 + table = type2_table; 10812 + tabsz = ARRAYSIZE(type2_table); 10813 + break; 10814 + case PLL_TYPE4: 10815 + table = type4_table; 10816 + tabsz = ARRAYSIZE(type4_table); 10817 + break; 10818 + case PLL_TYPE7: 10819 + table = type7_table; 10820 + tabsz = ARRAYSIZE(type7_table); 10821 + break; 10822 + default: 10823 + ASSERT("No table for plltype" == NULL); 10824 + break; 10825 + } 7788 10826 + 7789 10827 + /* Store the current clock register values */ 7790 + orig_m2 = R_REG( &cc->clockcontrol_m2);10828 + orig_m2 = R_REG(osh, &cc->clockcontrol_m2); 7791 10829 + orig_ratio_parm = 0; 7792 10830 + orig_ratio_cfg = 0; … … 7830 10868 + 7831 10869 + /* Set the PLL controls */ 7832 + W_REG( clockcontrol_n, te->n);7833 + W_REG( clockcontrol_sb, te->sb);7834 + W_REG( clockcontrol_pci, te->pci33);7835 + W_REG( &cc->clockcontrol_m2, te->m2);7836 + W_REG( &cc->clockcontrol_mips, te->m3);10870 + W_REG(osh, clockcontrol_n, te->n); 10871 + W_REG(osh, clockcontrol_sb, te->sb); 10872 + W_REG(osh, clockcontrol_pci, te->pci33); 10873 + W_REG(osh, &cc->clockcontrol_m2, te->m2); 10874 + W_REG(osh, &cc->clockcontrol_m3, te->m3); 7837 10875 + 7838 10876 + /* Set the chipcontrol bit to change mipsref to the backplane divider if needed */ 7839 + if ((pll_type == PLL_TYPE7) && 7840 + (te->sb != te->m2) && 10877 + if ((pll_type == PLL_TYPE7) && (te->sb != te->m2) && 7841 10878 + (sb_clock_rate(pll_type, te->n, te->m2) == 120000000)) 7842 + W_REG(&cc->chipcontrol, R_REG(&cc->chipcontrol) | 0x100); 10879 + W_REG(osh, &cc->chipcontrol, 10880 + R_REG(osh, &cc->chipcontrol) | 0x100); 7843 10881 + 7844 10882 + /* No ratio change */ 7845 + if (orig_ratio_parm == te->ratio_parm) 7846 + goto end_fill; 7847 + 10883 + if (sb_chip(sbh) != BCM4785_CHIP_ID) { 10884 + if (orig_ratio_parm == te->ratio_parm) 10885 + goto end_fill; 10886 + } 10887 + 10888 + /* Preload the code into the cache */ 7848 10889 + icache_probe(MFC0(C0_CONFIG, 1), &ic_size, &ic_lsize); 7849 + 7850 + /* Preload the code into the cache */ 7851 + start = ((ulong) &&start_fill) & ~(ic_lsize - 1); 7852 + end = ((ulong) &&end_fill + (ic_lsize - 1)) & ~(ic_lsize - 1); 10890 + if (sb_chip(sbh) == BCM4785_CHIP_ID) { 10891 + start = ((ulong) &&start_fill_4785) & ~(ic_lsize - 1); 10892 + end = ((ulong) &&end_fill_4785 + (ic_lsize - 1)) & ~(ic_lsize - 1); 10893 + } 10894 + else { 10895 + start = ((ulong) &&start_fill) & ~(ic_lsize - 1); 10896 + end = ((ulong) &&end_fill + (ic_lsize - 1)) & ~(ic_lsize - 1); 10897 + } 7853 10898 + while (start < end) { 7854 + cache_ unroll(start, Fill_I);10899 + cache_op(start, Fill_I); 7855 10900 + start += ic_lsize; 7856 10901 + } 7857 10902 + 7858 10903 + /* Copy the handler */ 7859 + start = (ulong) & BCMINIT(handler);7860 + end = (ulong) & BCMINIT(afterhandler);10904 + start = (ulong) &handler; 10905 + end = (ulong) &afterhandler; 7861 10906 + dst = KSEG1ADDR(0x180); 7862 10907 + for (i = 0; i < (end - start); i += 4) 7863 10908 + *((ulong *)(dst + i)) = *((ulong *)(start + i)); 7864 + 7865 + /* Preload handler into the cache one line at a time */7866 + for (i = 0; i < (end - start); i += 4)7867 + cache_ unroll(dst + i, Fill_I);10909 + 10910 + /* Preload the handler into the cache one line at a time */ 10911 + for (i = 0; i < (end - start); i += ic_lsize) 10912 + cache_op(dst + i, Fill_I); 7868 10913 + 7869 10914 + /* Clear BEV bit */ … … 7873 10918 + MTC0(C0_STATUS, 0, MFC0(C0_STATUS, 0) | (ALLINTS | ST0_IE)); 7874 10919 + 7875 + /* Enable MIPS timer interrupt */ 7876 + if (!(mipsr = sb_setcore(sbh, SB_MIPS, 0)) && 7877 + !(mipsr = sb_setcore(sbh, SB_MIPS33, 0))) 7878 + ASSERT(mipsr); 7879 + W_REG(&mipsr->intmask, 1); 10920 + /* 4785 clock freq change procedures */ 10921 + if (sb_chip(sbh) == BCM4785_CHIP_ID) { 10922 + start_fill_4785: 10923 + /* Switch to async */ 10924 + MTC0(C0_BROADCOM, 4, (1 << 22)); 10925 + 10926 + /* Set clock ratio in MIPS */ 10927 + *dll_r1 = (*dll_r1 & 0xfffffff0) | (te->d11_r1 - 1); 10928 + *dll_r2 = te->d11_r2; 10929 + 10930 + /* Enable new settings in MIPS */ 10931 + *dll_r1 = *dll_r1 | 0xc0000000; 10932 + 10933 + /* Set active cfg */ 10934 + MTC0(C0_BROADCOM, 2, MFC0(C0_BROADCOM, 2) | (1 << 3) | 1); 10935 + 10936 + /* Fake soft reset (clock cfg registers not reset) */ 10937 + MTC0(C0_BROADCOM, 5, MFC0(C0_BROADCOM, 5) | (1 << 2)); 10938 + 10939 + /* Clear active cfg */ 10940 + MTC0(C0_BROADCOM, 2, MFC0(C0_BROADCOM, 2) & ~(1 << 3)); 10941 + 10942 + /* set watchdog timer */ 10943 + W_REG(osh, &cc->watchdog, 20); 10944 + (void) R_REG(osh, &cc->chipid); 10945 + 10946 + /* wait for timer interrupt */ 10947 + __asm__ __volatile__( 10948 + ".set\tmips3\n\t" 10949 + "sync\n\t" 10950 + "wait\n\t" 10951 + ".set\tmips0"); 10952 + end_fill_4785: 10953 + while (1); 10954 + } 10955 + /* Generic clock freq change procedures */ 10956 + else { 10957 + /* Enable MIPS timer interrupt */ 10958 + if (!(mipsr = sb_setcore(sbh, SB_MIPS, 0)) && 10959 + !(mipsr = sb_setcore(sbh, SB_MIPS33, 0))) 10960 + ASSERT(mipsr); 10961 + W_REG(osh, &mipsr->intmask, 1); 7880 10962 + 7881 10963 + start_fill: 7882 + /* step 1, set clock ratios */ 7883 + MTC0(C0_BROADCOM, 3, te->ratio_parm); 7884 + MTC0(C0_BROADCOM, 1, te->ratio_cfg); 7885 + 7886 + /* step 2: program timer intr */ 7887 + W_REG(&mipsr->timer, 100); 7888 + (void) R_REG(&mipsr->timer); 7889 + 7890 + /* step 3, switch to async */ 7891 + sync_mode = MFC0(C0_BROADCOM, 4); 7892 + MTC0(C0_BROADCOM, 4, 1 << 22); 7893 + 7894 + /* step 4, set cfg active */ 7895 + MTC0(C0_BROADCOM, 2, 0x9); 7896 + 7897 + 7898 + /* steps 5 & 6 */ 7899 + __asm__ __volatile__ ( 7900 + ".set\tmips3\n\t" 7901 + "wait\n\t" 7902 + ".set\tmips0" 7903 + ); 7904 + 7905 + /* step 7, clear cfg_active */ 7906 + MTC0(C0_BROADCOM, 2, 0); 7907 + 7908 + /* Additional Step: set back to orig sync mode */ 7909 + MTC0(C0_BROADCOM, 4, sync_mode); 7910 + 7911 + /* step 8, fake soft reset */ 7912 + MTC0(C0_BROADCOM, 5, MFC0(C0_BROADCOM, 5) | 4); 10964 + /* step 1, set clock ratios */ 10965 + MTC0(C0_BROADCOM, 3, te->ratio_parm); 10966 + MTC0(C0_BROADCOM, 1, te->ratio_cfg); 10967 + 10968 + /* step 2: program timer intr */ 10969 + W_REG(osh, &mipsr->timer, 100); 10970 + (void) R_REG(osh, &mipsr->timer); 10971 + 10972 + /* step 3, switch to async */ 10973 + sync_mode = MFC0(C0_BROADCOM, 4); 10974 + MTC0(C0_BROADCOM, 4, 1 << 22); 10975 + 10976 + /* step 4, set cfg active */ 10977 + MTC0(C0_BROADCOM, 2, (1 << 3) | 1); 10978 + 10979 + /* steps 5 & 6 */ 10980 + __asm__ __volatile__( 10981 + ".set\tmips3\n\t" 10982 + "wait\n\t" 10983 + ".set\tmips0"); 10984 + 10985 + /* step 7, clear cfg active */ 10986 + MTC0(C0_BROADCOM, 2, 0); 10987 + 10988 + /* Additional Step: set back to orig sync mode */ 10989 + MTC0(C0_BROADCOM, 4, sync_mode); 10990 + 10991 + /* step 8, fake soft reset */ 10992 + MTC0(C0_BROADCOM, 5, MFC0(C0_BROADCOM, 5) | (1 << 2)); 7913 10993 + 7914 10994 + end_fill: 7915 + /* step 9set watchdog timer */7916 + sb_watchdog(sbh, 20);7917 + (void) R_REG(&cc->chipid);7918 + 7919 + /* step 11*/7920 + __asm__ __volatile__(7921 + ".set\tmips3\n\t"7922 + "sync\n\t"7923 + "wait\n\t"7924 + ".set\tmips0"7925 + );7926 + while (1);10995 + /* set watchdog timer */ 10996 + W_REG(osh, &cc->watchdog, 20); 10997 + (void) R_REG(osh, &cc->chipid); 10998 + 10999 + /* wait for timer interrupt */ 11000 + __asm__ __volatile__( 11001 + ".set\tmips3\n\t" 11002 + "sync\n\t" 11003 + "wait\n\t" 11004 + ".set\tmips0"); 11005 + while (1); 11006 + } 7927 11007 + } 7928 11008 + 7929 11009 +done: 11010 + /* Enable 4785 DLL */ 11011 + if (sb_chip(sbh) == BCM4785_CHIP_ID) { 11012 + uint32 tmp; 11013 + 11014 + /* set mask to 1e, enable DLL (bit 0) */ 11015 + *dll_ctrl |= 0x0041e021; 11016 + 11017 + /* enable aggressive hardware mode */ 11018 + *dll_ctrl |= 0x00000080; 11019 + 11020 + /* wait for lock flag to clear */ 11021 + while ((*dll_ctrl & 0x2) == 0); 11022 + 11023 + /* clear sticky flags (clear on write 1) */ 11024 + tmp = *dll_ctrl; 11025 + *dll_ctrl = tmp; 11026 + 11027 + /* set mask to 5b'10001 */ 11028 + *dll_ctrl = (*dll_ctrl & 0xfffc1fff) | 0x00022000; 11029 + 11030 + /* enable sync mode */ 11031 + MTC0(C0_BROADCOM, 4, MFC0(C0_BROADCOM, 4) & 0xfe3fffff); 11032 + (void)MFC0(C0_BROADCOM, 4); 11033 + } 11034 + 7930 11035 + /* switch back to previous core */ 7931 11036 + sb_setcoreidx(sbh, idx); … … 7934 11039 +} 7935 11040 + 11041 +void 11042 +BCMINITFN(enable_pfc)(uint32 mode) 11043 +{ 11044 + ulong start, end; 11045 + uint ic_size, ic_lsize; 11046 + 11047 + /* If auto then choose the correct mode for this 11048 + * platform, currently we only ever select one mode 11049 + */ 11050 + if (mode == PFC_AUTO) 11051 + mode = PFC_INST; 11052 + 11053 + icache_probe(MFC0(C0_CONFIG, 1), &ic_size, &ic_lsize); 11054 + 11055 + /* enable prefetch cache if available */ 11056 + if (MFC0(C0_BROADCOM, 0) & BRCM_PFC_AVAIL) { 11057 + start = ((ulong) &&setpfc_start) & ~(ic_lsize - 1); 11058 + end = ((ulong) &&setpfc_end + (ic_lsize - 1)) & ~(ic_lsize - 1); 11059 + 11060 + /* Preload setpfc code into the cache one line at a time */ 11061 + while (start < end) { 11062 + cache_op(start, Fill_I); 11063 + start += ic_lsize; 11064 + } 11065 + 11066 + /* Now set the pfc */ 11067 + setpfc_start: 11068 + /* write range */ 11069 + *(volatile uint32 *)PFC_CR1 = 0xffff0000; 11070 + 11071 + /* enable */ 11072 + *(volatile uint32 *)PFC_CR0 = mode; 11073 + setpfc_end: 11074 + /* Compiler foder */ 11075 + ic_size = 0; 11076 + } 11077 +} 7936 11078 + 7937 11079 +/* returns the ncdl value to be programmed into sdram_ncdl for calibration */ 7938 11080 +uint32 7939 +BCMINITFN(sb_memc_get_ncdl)(void *sbh) 7940 +{ 11081 +BCMINITFN(sb_memc_get_ncdl)(sb_t *sbh) 11082 +{ 11083 + osl_t *osh; 7941 11084 + sbmemcregs_t *memc; 7942 11085 + uint32 ret = 0; … … 7944 11087 + uint idx, rev; 7945 11088 + 11089 + osh = sb_osh(sbh); 11090 + 7946 11091 + idx = sb_coreidx(sbh); 7947 11092 + … … 7952 11097 + rev = sb_corerev(sbh); 7953 11098 + 7954 + config = R_REG( &memc->config);7955 + wr = R_REG( &memc->wrncdlcor);7956 + rd = R_REG( &memc->rdncdlcor);7957 + misc = R_REG( &memc->miscdlyctl);7958 + dqsg = R_REG( &memc->dqsgatencdl);11099 + config = R_REG(osh, &memc->config); 11100 + wr = R_REG(osh, &memc->wrncdlcor); 11101 + rd = R_REG(osh, &memc->rdncdlcor); 11102 + misc = R_REG(osh, &memc->miscdlyctl); 11103 + dqsg = R_REG(osh, &memc->dqsgatencdl); 7959 11104 + 7960 11105 + rd &= MEMC_RDNCDLCOR_RD_MASK; 7961 + wr &= MEMC_WRNCDLCOR_WR_MASK; 11106 + wr &= MEMC_WRNCDLCOR_WR_MASK; 7962 11107 + dqsg &= MEMC_DQSGATENCDL_G_MASK; 7963 11108 + … … 7965 11110 + ret = (wr << 16) | (rd << 8) | dqsg; 7966 11111 + } else { 7967 + if ( (rev > 0) || (sb_chip(sbh) == BCM5365_DEVICE_ID))11112 + if (rev > 0) 7968 11113 + cd = rd; 7969 11114 + else … … 7981 11126 +} 7982 11127 + 7983 +/* returns the PFC values to be used based on the chip ID*/ 11128 +#if defined(BCMPERFSTATS) 11129 +/* 11130 + * CP0 Register 25 supports 4 semi-independent 32bit performance counters. 11131 + * $25 select 0, 1, 2, and 3 are the counters. The counters *decrement* (who thought this one up?) 11132 + * $25 select 4 and 5 each contain 2-16bit control fields, one for each of the 4 counters 11133 + * $25 select 6 is the global perf control register. 11134 + */ 11135 +/* enable and start instruction counting */ 11136 + 11137 +void 11138 +hndmips_perf_instrcount_enable() 11139 +{ 11140 + MTC0(C0_PERFORMANCE, 6, 0x80000200); /* global enable perf counters */ 11141 + MTC0(C0_PERFORMANCE, 4, 11142 + 0x8044 | MFC0(C0_PERFORMANCE, 4)); /* enable instruction counting for counter 0 */ 11143 + MTC0(C0_PERFORMANCE, 0, 0); /* zero counter zero */ 11144 +} 11145 + 11146 +/* enable and start I$ hit and I$ miss counting */ 11147 +void 11148 +hndmips_perf_icachecount_enable(void) 11149 +{ 11150 + MTC0(C0_PERFORMANCE, 6, 0x80000218); /* enable I$ counting */ 11151 + MTC0(C0_PERFORMANCE, 4, 0x80148018); /* count I$ hits in cntr 0 and misses in cntr 1 */ 11152 + MTC0(C0_PERFORMANCE, 0, 0); /* zero counter 0 - # I$ hits */ 11153 + MTC0(C0_PERFORMANCE, 1, 0); /* zero counter 1 - # I$ misses */ 11154 +} 11155 + 11156 +/* enable and start D$ hit and I$ miss counting */ 11157 +void 11158 +hndmips_perf_dcachecount_enable(void) 11159 +{ 11160 + MTC0(C0_PERFORMANCE, 6, 0x80000211); /* enable D$ counting */ 11161 + MTC0(C0_PERFORMANCE, 4, 0x80248028); /* count D$ hits in cntr 0 and misses in cntr 1 */ 11162 + MTC0(C0_PERFORMANCE, 0, 0); /* zero counter 0 - # D$ hits */ 11163 + MTC0(C0_PERFORMANCE, 1, 0); /* zero counter 1 - # D$ misses */ 11164 +} 11165 + 11166 +void 11167 +hndmips_perf_icache_miss_enable() 11168 +{ 11169 + MTC0(C0_PERFORMANCE, 4, 11170 + 0x80140000 | MFC0(C0_PERFORMANCE, 4)); /* enable cache misses counting for counter 1 */ 11171 + MTC0(C0_PERFORMANCE, 1, 0); /* zero counter one */ 11172 +} 11173 + 11174 + 11175 +void 11176 +hndmips_perf_icache_hit_enable() 11177 +{ 11178 + MTC0(C0_PERFORMANCE, 5, 0x8018 | MFC0(C0_PERFORMANCE, 5)); 11179 + /* enable cache hits counting for counter 2 */ 11180 + MTC0(C0_PERFORMANCE, 2, 0); /* zero counter 2 */ 11181 +} 7984 11182 + 7985 11183 +uint32 7986 +BCMINITFN(sb_mips_get_pfc)(void *sbh) 7987 +{ 7988 + if (BCMINIT(sb_chip)(sbh) == BCM5350_DEVICE_ID) 7989 + return 0x11; 7990 + else 7991 + return 0x15; 7992 +} 7993 diff -Nur linux-2.4.32/arch/mips/bcm947xx/sbpci.c linux-2.4.32-freewrt/arch/mips/bcm947xx/sbpci.c 7994 --- linux-2.4.32/arch/mips/bcm947xx/sbpci.c 1970-01-01 01:00:00.000000000 +0100 7995 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/sbpci.c 2006-09-16 15:41:31.000000000 +0200 7996 @@ -0,0 +1,588 @@ 11184 +hndmips_perf_read_instrcount() 11185 +{ 11186 + return -(long)(MFC0(C0_PERFORMANCE, 0)); 11187 +} 11188 + 11189 +uint32 11190 +hndmips_perf_read_cache_miss() 11191 +{ 11192 + return -(long)(MFC0(C0_PERFORMANCE, 1)); 11193 +} 11194 + 11195 +uint32 11196 +hndmips_perf_read_cache_hit() 11197 +{ 11198 + return -(long)(MFC0(C0_PERFORMANCE, 2)); 11199 +} 11200 + 11201 +#endif /* BCMINTERNAL | BCMPERFSTATS */ 11202 diff -urN linux.old/arch/mips/bcm947xx/sbpci.c linux.dev/arch/mips/bcm947xx/sbpci.c 11203 --- linux.old/arch/mips/bcm947xx/sbpci.c 1970-01-01 01:00:00.000000000 +0100 11204 +++ linux.dev/arch/mips/bcm947xx/sbpci.c 2006-10-02 21:19:59.000000000 +0200 11205 @@ -0,0 +1,768 @@ 7997 11206 +/* 7998 11207 + * Low-Level PCI and SB support for BCM47xx 7999 11208 + * 8000 + * Copyright 200 5, Broadcom Corporation11209 + * Copyright 2006, Broadcom Corporation 8001 11210 + * All Rights Reserved. 8002 11211 + * … … 8006 11215 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 8007 11216 + * 8008 + * $Id: sbpci.c,v 1.7 2005/03/07 08:35:32 kankiExp $11217 + * $Id: hndpci.c,v 1.1.1.3 2006/04/08 06:13:39 honor Exp $ 8009 11218 + */ 8010 11219 + 8011 11220 +#include <typedefs.h> 11221 +#include <osl.h> 8012 11222 +#include <pcicfg.h> 8013 11223 +#include <bcmdevs.h> 8014 11224 +#include <sbconfig.h> 8015 +#include <sbpci.h>8016 +#include <osl.h>8017 +#include <bcmendian.h>8018 11225 +#include <bcmutils.h> 8019 11226 +#include <sbutils.h> 11227 +#include <sbpci.h> 11228 +#include <bcmendian.h> 8020 11229 +#include <bcmnvram.h> 11230 +#include <hndcpu.h> 8021 11231 +#include <hndmips.h> 11232 +#include <hndpci.h> 11233 + 11234 +/* debug/trace */ 11235 +#ifdef BCMDBG_PCI 11236 +#define PCI_MSG(args) printf args 11237 +#else 11238 +#define PCI_MSG(args) 11239 +#endif /* BCMDBG_PCI */ 8022 11240 + 8023 11241 +/* Can free sbpci_init() memory after boot */ 8024 11242 +#ifndef linux 8025 11243 +#define __init 8026 +#endif 11244 +#endif /* linux */ 8027 11245 + 8028 11246 +/* Emulated configuration space */ 11247 +typedef struct { 11248 + int n; 11249 + uint size0; 11250 + uint size1; 11251 + uint size2; 11252 + uint size3; 11253 +} sb_bar_cfg_t; 8029 11254 +static pci_config_regs sb_config_regs[SB_MAXCORES]; 11255 +static sb_bar_cfg_t sb_bar_cfg[SB_MAXCORES]; 11256 + 11257 +/* Links to emulated and real PCI configuration spaces */ 11258 +#define MAXFUNCS 2 11259 +typedef struct { 11260 + pci_config_regs *emu; /* emulated PCI config */ 11261 + pci_config_regs *pci; /* real PCI config */ 11262 + sb_bar_cfg_t *bar; /* region sizes */ 11263 +} sb_pci_cfg_t; 11264 +static sb_pci_cfg_t sb_pci_cfg[SB_MAXCORES][MAXFUNCS]; 11265 + 11266 +/* Special emulated config space for non-existing device */ 11267 +static pci_config_regs sb_pci_null = { 0xffff, 0xffff }; 8030 11268 + 8031 11269 +/* Banned cores */ 8032 +static uint16 pci_ban[ 32] = { 0 };11270 +static uint16 pci_ban[SB_MAXCORES] = { 0 }; 8033 11271 +static uint pci_banned = 0; 8034 11272 + … … 8038 11276 +/* Disable PCI host core */ 8039 11277 +static bool pci_disabled = FALSE; 11278 + 11279 +/* Host bridge slot #, default to 0 */ 11280 +static uint8 pci_hbslot = 0; 11281 + 11282 +/* Internal macros */ 11283 +#define PCI_SLOTAD_MAP 16 /* SLOT<n> mapps to AD<n+16> */ 11284 +#define PCI_HBSBCFG_REV 8 /* MIN. core rev. required to 11285 + * access host bridge PCI cfg space 11286 + * from SB 11287 + */ 8040 11288 + 8041 11289 +/* … … 8044 11292 + 8045 11293 +/* Assume one-hot slot wiring */ 8046 +#define PCI_SLOT_MAX 16 11294 +#define PCI_SLOT_MAX 16 /* Max. PCI Slots */ 8047 11295 + 8048 11296 +static uint32 8049 +config_cmd( void*sbh, uint bus, uint dev, uint func, uint off)11297 +config_cmd(sb_t *sbh, uint bus, uint dev, uint func, uint off) 8050 11298 +{ 8051 11299 + uint coreidx; 8052 11300 + sbpciregs_t *regs; 8053 11301 + uint32 addr = 0; 11302 + osl_t *osh; 8054 11303 + 8055 11304 + /* CardBusMode supports only one device */ 8056 11305 + if (cardbus && dev > 1) 8057 11306 + return 0; 11307 + 11308 + osh = sb_osh(sbh); 8058 11309 + 8059 11310 + coreidx = sb_coreidx(sbh); … … 8064 11315 + /* Skip unwired slots */ 8065 11316 + if (dev < PCI_SLOT_MAX) { 11317 + uint32 win; 11318 + 8066 11319 + /* Slide the PCI window to the appropriate slot */ 8067 + W_REG(®s->sbtopci1, SBTOPCI_CFG0 | ((1 << (dev + 16)) & SBTOPCI1_MASK)); 8068 + addr = SB_PCI_CFG | ((1 << (dev + 16)) & ~SBTOPCI1_MASK) | 8069 + (func << 8) | (off & ~3); 11320 + win = (SBTOPCI_CFG0 | ((1 << (dev + PCI_SLOTAD_MAP)) & SBTOPCI1_MASK)); 11321 + W_REG(osh, ®s->sbtopci1, win); 11322 + addr = SB_PCI_CFG | 11323 + ((1 << (dev + PCI_SLOTAD_MAP)) & ~SBTOPCI1_MASK) | 11324 + (func << PCICFG_FUN_SHIFT) | 11325 + (off & ~3); 8070 11326 + } 8071 + } 8072 + 8073 + /* Type 1 transaction */ 8074 + else { 8075 + W_REG(®s->sbtopci1, SBTOPCI_CFG1); 8076 + addr = SB_PCI_CFG | (bus << 16) | (dev << 11) | (func << 8) | (off & ~3); 11327 + } else { 11328 + /* Type 1 transaction */ 11329 + W_REG(osh, ®s->sbtopci1, SBTOPCI_CFG1); 11330 + addr = SB_PCI_CFG | 11331 + (bus << PCICFG_BUS_SHIFT) | 11332 + (dev << PCICFG_SLOT_SHIFT) | 11333 + (func << PCICFG_FUN_SHIFT) | 11334 + (off & ~3); 8077 11335 + } 8078 11336 + … … 8082 11340 +} 8083 11341 + 8084 +static int 8085 +extpci_read_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len) 8086 +{ 8087 + uint32 addr, *reg = NULL, val; 11342 +/* 11343 + * Read host bridge PCI config registers from Silicon Backplane (>=rev8). 11344 + * 11345 + * It returns TRUE to indicate that access to the host bridge's pci config 11346 + * from SB is ok, and values in 'addr' and 'val' are valid. 11347 + * 11348 + * It can only read registers at multiple of 4-bytes. Callers must pick up 11349 + * needed bytes from 'val' based on 'off' value. Value in 'addr' reflects 11350 + * the register address where value in 'val' is read. 11351 + */ 11352 +static bool 11353 +sb_pcihb_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, 11354 + uint32 **addr, uint32 *val) 11355 +{ 11356 + sbpciregs_t *regs; 11357 + osl_t *osh; 11358 + uint coreidx; 11359 + bool ret = FALSE; 11360 + 11361 + /* sanity check */ 11362 + ASSERT(bus == 1); 11363 + ASSERT(dev == pci_hbslot); 11364 + ASSERT(func == 0); 11365 + 11366 + osh = sb_osh(sbh); 11367 + 11368 + /* read pci config when core rev >= 8 */ 11369 + coreidx = sb_coreidx(sbh); 11370 + regs = (sbpciregs_t *)sb_setcore(sbh, SB_PCI, 0); 11371 + if (regs && sb_corerev(sbh) >= PCI_HBSBCFG_REV) { 11372 + *addr = (uint32 *)®s->pcicfg[func][off >> 2]; 11373 + *val = R_REG(osh, *addr); 11374 + ret = TRUE; 11375 + } 11376 + sb_setcoreidx(sbh, coreidx); 11377 + 11378 + return ret; 11379 +} 11380 + 11381 +int 11382 +extpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len) 11383 +{ 11384 + uint32 addr = 0, *reg = NULL, val; 8088 11385 + int ret = 0; 8089 11386 + 8090 + if (pci_disabled || 8091 + !(addr = config_cmd(sbh, bus, dev, func, off)) || 8092 + !(reg = (uint32 *) REG_MAP(addr, len)) || 8093 + BUSPROBE(val, reg)) 11387 + /* 11388 + * Set value to -1 when: 11389 + * flag 'pci_disabled' is true; 11390 + * value of 'addr' is zero; 11391 + * REG_MAP() fails; 11392 + * BUSPROBE() fails; 11393 + */ 11394 + if (pci_disabled) 8094 11395 + val = 0xffffffff; 11396 + else if (bus == 1 && dev == pci_hbslot && func == 0 && 11397 + sb_pcihb_read_config(sbh, bus, dev, func, off, ®, &val)) 11398 + ; 11399 + else if (((addr = config_cmd(sbh, bus, dev, func, off)) == 0) || 11400 + ((reg = (uint32 *)REG_MAP(addr, len)) == 0) || 11401 + (BUSPROBE(val, reg) != 0)) 11402 + val = 0xffffffff; 11403 + 11404 + PCI_MSG(("%s: 0x%x <= 0x%p(0x%x), len %d, off 0x%x, buf 0x%p\n", 11405 + __FUNCTION__, val, reg, addr, len, off, buf)); 8095 11406 + 8096 11407 + val >>= 8 * (off & 3); … … 8104 11415 + ret = -1; 8105 11416 + 8106 + if (reg )11417 + if (reg && addr) 8107 11418 + REG_UNMAP(reg); 8108 11419 + … … 8110 11421 +} 8111 11422 + 8112 +static int 8113 +extpci_write_config(void *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len) 8114 +{ 8115 + uint32 addr, *reg = NULL, val; 11423 +int 11424 +extpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len) 11425 +{ 11426 + osl_t *osh; 11427 + uint32 addr = 0, *reg = NULL, val; 8116 11428 + int ret = 0; 8117 11429 + 8118 + if (pci_disabled || 8119 + !(addr = config_cmd(sbh, bus, dev, func, off)) || 8120 + !(reg = (uint32 *) REG_MAP(addr, len)) || 8121 + BUSPROBE(val, reg)) 11430 + osh = sb_osh(sbh); 11431 + 11432 + /* 11433 + * Ignore write attempt when: 11434 + * flag 'pci_disabled' is true; 11435 + * value of 'addr' is zero; 11436 + * REG_MAP() fails; 11437 + * BUSPROBE() fails; 11438 + */ 11439 + if (pci_disabled) 11440 + return 0; 11441 + else if (bus == 1 && dev == pci_hbslot && func == 0 && 11442 + sb_pcihb_read_config(sbh, bus, dev, func, off, ®, &val)) 11443 + ; 11444 + else if (((addr = config_cmd(sbh, bus, dev, func, off)) == 0) || 11445 + ((reg = (uint32 *) REG_MAP(addr, len)) == 0) || 11446 + (BUSPROBE(val, reg) != 0)) 8122 11447 + goto done; 8123 11448 + … … 8130 11455 + val &= ~(0xff << (8 * (off & 3))); 8131 11456 + val |= *((uint8 *) buf) << (8 * (off & 3)); 8132 + } else 11457 + } else { 8133 11458 + ret = -1; 8134 + 8135 + W_REG(reg, val); 8136 + 8137 + done: 8138 + if (reg) 11459 + goto done; 11460 + } 11461 + 11462 + PCI_MSG(("%s: 0x%x => 0x%p\n", __FUNCTION__, val, reg)); 11463 + 11464 + W_REG(osh, reg, val); 11465 + 11466 +done: 11467 + if (reg && addr) 8139 11468 + REG_UNMAP(reg); 8140 11469 + 8141 11470 + return ret; 11471 +} 11472 + 11473 +/* 11474 + * Must access emulated PCI configuration at these locations even when 11475 + * the real PCI config space exists and is accessible. 11476 + * 11477 + * PCI_CFG_VID (0x00) 11478 + * PCI_CFG_DID (0x02) 11479 + * PCI_CFG_PROGIF (0x09) 11480 + * PCI_CFG_SUBCL (0x0a) 11481 + * PCI_CFG_BASECL (0x0b) 11482 + * PCI_CFG_HDR (0x0e) 11483 + * PCI_CFG_INT (0x3c) 11484 + * PCI_CFG_PIN (0x3d) 11485 + */ 11486 +#define FORCE_EMUCFG(off, len) \ 11487 + ((off == PCI_CFG_VID) || (off == PCI_CFG_DID) || \ 11488 + (off == PCI_CFG_PROGIF) || \ 11489 + (off == PCI_CFG_SUBCL) || (off == PCI_CFG_BASECL) || \ 11490 + (off == PCI_CFG_HDR) || \ 11491 + (off == PCI_CFG_INT) || (off == PCI_CFG_PIN)) 11492 + 11493 +/* Sync the emulation registers and the real PCI config registers. */ 11494 +static void 11495 +sb_pcid_read_config(sb_t *sbh, uint coreidx, sb_pci_cfg_t *cfg, 11496 + uint off, uint len) 11497 +{ 11498 + osl_t *osh; 11499 + uint oldidx; 11500 + 11501 + ASSERT(cfg); 11502 + ASSERT(cfg->emu); 11503 + ASSERT(cfg->pci); 11504 + 11505 + /* decide if real PCI config register access is necessary */ 11506 + if (FORCE_EMUCFG(off, len)) 11507 + return; 11508 + 11509 + osh = sb_osh(sbh); 11510 + 11511 + /* access to the real pci config space only when the core is up */ 11512 + oldidx = sb_coreidx(sbh); 11513 + sb_setcoreidx(sbh, coreidx); 11514 + if (sb_iscoreup(sbh)) { 11515 + if (len == 4) 11516 + *(uint32 *)((ulong)cfg->emu + off) = 11517 + htol32(R_REG(osh, (uint32 *)((ulong)cfg->pci + off))); 11518 + else if (len == 2) 11519 + *(uint16 *)((ulong)cfg->emu + off) = 11520 + htol16(R_REG(osh, (uint16 *)((ulong)cfg->pci + off))); 11521 + else if (len == 1) 11522 + *(uint8 *)((ulong)cfg->emu + off) = 11523 + R_REG(osh, (uint8 *)((ulong)cfg->pci + off)); 11524 + } 11525 + sb_setcoreidx(sbh, oldidx); 11526 +} 11527 + 11528 +static void 11529 +sb_pcid_write_config(sb_t *sbh, uint coreidx, sb_pci_cfg_t *cfg, 11530 + uint off, uint len) 11531 +{ 11532 + osl_t *osh; 11533 + uint oldidx; 11534 + 11535 + ASSERT(cfg); 11536 + ASSERT(cfg->emu); 11537 + ASSERT(cfg->pci); 11538 + 11539 + osh = sb_osh(sbh); 11540 + 11541 + /* decide if real PCI config register access is necessary */ 11542 + if (FORCE_EMUCFG(off, len)) 11543 + return; 11544 + 11545 + /* access to the real pci config space only when the core is up */ 11546 + oldidx = sb_coreidx(sbh); 11547 + sb_setcoreidx(sbh, coreidx); 11548 + if (sb_iscoreup(sbh)) { 11549 + if (len == 4) 11550 + W_REG(osh, (uint32 *)((ulong)cfg->pci + off), 11551 + ltoh32(*(uint32 *)((ulong)cfg->emu + off))); 11552 + else if (len == 2) 11553 + W_REG(osh, (uint16 *)((ulong)cfg->pci + off), 11554 + ltoh16(*(uint16 *)((ulong)cfg->emu + off))); 11555 + else if (len == 1) 11556 + W_REG(osh, (uint8 *)((ulong)cfg->pci + off), 11557 + *(uint8 *)((ulong)cfg->emu + off)); 11558 + } 11559 + sb_setcoreidx(sbh, oldidx); 8142 11560 +} 8143 11561 + … … 8145 11563 + * Functions for accessing translated SB configuration space 8146 11564 + */ 8147 +8148 11565 +static int 8149 +sb_read_config( void*sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)11566 +sb_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len) 8150 11567 +{ 8151 11568 + pci_config_regs *cfg; 8152 11569 + 8153 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))11570 + if (dev >= SB_MAXCORES || func >= MAXFUNCS || (off + len) > sizeof(pci_config_regs)) 8154 11571 + return -1; 8155 + cfg = &sb_config_regs[dev];11572 + cfg = sb_pci_cfg[dev][func].emu; 8156 11573 + 8157 11574 + ASSERT(ISALIGNED(off, len)); 8158 11575 + ASSERT(ISALIGNED((uintptr)buf, len)); 11576 + 11577 + /* use special config space if the device does not exist */ 11578 + if (!cfg) 11579 + cfg = &sb_pci_null; 11580 + /* sync emulation with real PCI config if necessary */ 11581 + else if (sb_pci_cfg[dev][func].pci) 11582 + sb_pcid_read_config(sbh, dev, &sb_pci_cfg[dev][func], off, len); 8159 11583 + 8160 11584 + if (len == 4) … … 8171 11595 + 8172 11596 +static int 8173 +sb_write_config( void*sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)8174 +{ 8175 + uint coreidx , n;11597 +sb_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len) 11598 +{ 11599 + uint coreidx; 8176 11600 + void *regs; 8177 + sbconfig_t *sb;8178 11601 + pci_config_regs *cfg; 8179 + 8180 + if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs)) 11602 + osl_t *osh; 11603 + sb_bar_cfg_t *bar; 11604 + 11605 + if (dev >= SB_MAXCORES || func >= MAXFUNCS || (off + len) > sizeof(pci_config_regs)) 8181 11606 + return -1; 8182 + cfg = &sb_config_regs[dev]; 11607 + cfg = sb_pci_cfg[dev][func].emu; 11608 + if (!cfg) 11609 + return -1; 8183 11610 + 8184 11611 + ASSERT(ISALIGNED(off, len)); 8185 11612 + ASSERT(ISALIGNED((uintptr)buf, len)); 8186 11613 + 11614 + osh = sb_osh(sbh); 11615 + 8187 11616 + /* Emulate BAR sizing */ 8188 + if (off >= OFFSETOF(pci_config_regs, base[0]) && off <= OFFSETOF(pci_config_regs, base[3]) && 11617 + if (off >= OFFSETOF(pci_config_regs, base[0]) && 11618 + off <= OFFSETOF(pci_config_regs, base[3]) && 8189 11619 + len == 4 && *((uint32 *) buf) == ~0) { 8190 11620 + coreidx = sb_coreidx(sbh); 8191 11621 + if ((regs = sb_setcoreidx(sbh, dev))) { 8192 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);11622 + bar = sb_pci_cfg[dev][func].bar; 8193 11623 + /* Highest numbered address match register */ 8194 + n = (R_REG(&sb->sbidlow) & SBIDL_AR_MASK) >> SBIDL_AR_SHIFT;8195 11624 + if (off == OFFSETOF(pci_config_regs, base[0])) 8196 + cfg->base[0] = ~( sb_size(R_REG(&sb->sbadmatch0))- 1);8197 + else if (off == OFFSETOF(pci_config_regs, base[1]) && n >= 1)8198 + cfg->base[1] = ~( sb_size(R_REG(&sb->sbadmatch1))- 1);8199 + else if (off == OFFSETOF(pci_config_regs, base[2]) && n >= 2)8200 + cfg->base[2] = ~( sb_size(R_REG(&sb->sbadmatch2))- 1);8201 + else if (off == OFFSETOF(pci_config_regs, base[3]) && n >= 3)8202 + cfg->base[3] = ~( sb_size(R_REG(&sb->sbadmatch3))- 1);11625 + cfg->base[0] = ~(bar->size0 - 1); 11626 + else if (off == OFFSETOF(pci_config_regs, base[1]) && bar->n >= 1) 11627 + cfg->base[1] = ~(bar->size1 - 1); 11628 + else if (off == OFFSETOF(pci_config_regs, base[2]) && bar->n >= 2) 11629 + cfg->base[2] = ~(bar->size2 - 1); 11630 + else if (off == OFFSETOF(pci_config_regs, base[3]) && bar->n >= 3) 11631 + cfg->base[3] = ~(bar->size3 - 1); 8203 11632 + } 8204 11633 + sb_setcoreidx(sbh, coreidx); 8205 + return 0; 8206 + } 8207 + 8208 + if (len == 4) 11634 + } 11635 + else if (len == 4) 8209 11636 + *((uint32 *)((ulong) cfg + off)) = htol32(*((uint32 *) buf)); 8210 11637 + else if (len == 2) … … 8215 11642 + return -1; 8216 11643 + 11644 + /* sync emulation with real PCI config if necessary */ 11645 + if (sb_pci_cfg[dev][func].pci) 11646 + sb_pcid_write_config(sbh, dev, &sb_pci_cfg[dev][func], off, len); 11647 + 8217 11648 + return 0; 8218 11649 +} 8219 11650 + 8220 11651 +int 8221 +sbpci_read_config( void*sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)11652 +sbpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len) 8222 11653 +{ 8223 11654 + if (bus == 0) … … 8228 11659 + 8229 11660 +int 8230 +sbpci_write_config( void*sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)11661 +sbpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len) 8231 11662 +{ 8232 11663 + if (bus == 0) … … 8243 11674 +} 8244 11675 + 8245 +static int 8246 +sbpci_init_pci(void *sbh) 11676 +/* 11677 + * Initiliaze PCI core. Return 0 after a successful initialization. 11678 + * Otherwise return -1 to indicate there is no PCI core and return 1 11679 + * to indicate PCI core is disabled. 11680 + */ 11681 +int __init 11682 +sbpci_init_pci(sb_t *sbh) 8247 11683 +{ 8248 11684 + uint chip, chiprev, chippkg, host; … … 8250 11686 + sbpciregs_t *pci; 8251 11687 + sbconfig_t *sb; 8252 + int CT4712_WR;8253 11688 + uint32 val; 11689 + int ret = 0; 11690 + char *hbslot; 11691 + osl_t *osh; 8254 11692 + 8255 11693 + chip = sb_chip(sbh); … … 8257 11695 + chippkg = sb_chippkg(sbh); 8258 11696 + 11697 + osh = sb_osh(sbh); 11698 + 8259 11699 + if (!(pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0))) { 8260 + print f("PCI: no core\n");11700 + printk("PCI: no core\n"); 8261 11701 + pci_disabled = TRUE; 8262 11702 + return -1; 8263 11703 + } 8264 + sb_core_reset(sbh, 0); 11704 + 11705 + if ((chip == 0x4310) && (chiprev == 0)) 11706 + pci_disabled = TRUE; 11707 + 11708 + sb = (sbconfig_t *)((ulong) pci + SBCONFIGOFF); 8265 11709 + 8266 11710 + boardflags = (uint32) getintvar(NULL, "boardflags"); 8267 +8268 + if ((chip == BCM4310_DEVICE_ID) && (chiprev == 0))8269 + pci_disabled = TRUE;8270 11711 + 8271 11712 + /* … … 8274 11715 + * floating. 8275 11716 + */ 8276 + if (((chip == BCM4712_ DEVICE_ID) &&11717 + if (((chip == BCM4712_CHIP_ID) && 8277 11718 + ((chippkg == BCM4712SMALL_PKG_ID) || 8278 11719 + (chippkg == BCM4712MID_PKG_ID))) || 8279 11720 + (boardflags & BFL_NOPCI)) 8280 11721 + pci_disabled = TRUE; 11722 + 11723 + /* Enable the core */ 11724 + sb_core_reset(sbh, 0, 0); 8281 11725 + 8282 11726 + /* … … 8292 11736 + 8293 11737 + if (!host) { 11738 + ret = 1; 11739 + 8294 11740 + /* Disable PCI interrupts in client mode */ 8295 + sb = (sbconfig_t *)((ulong) pci + SBCONFIGOFF); 8296 + W_REG(&sb->sbintvec, 0); 11741 + W_REG(osh, &sb->sbintvec, 0); 8297 11742 + 8298 11743 + /* Disable the PCI bridge in client mode */ 8299 11744 + sbpci_ban(SB_PCI); 8300 + printf("PCI: Disabled\n"); 11745 + sb_core_disable(sbh, 0); 11746 + 11747 + printk("PCI: Disabled\n"); 8301 11748 + } else { 11749 + printk("PCI: Initializing host\n"); 11750 + 11751 + /* Disable PCI SBReqeustTimeout for BCM4785 */ 11752 + if (chip == BCM4785_CHIP_ID) { 11753 + AND_REG(osh, &sb->sbimconfiglow, ~0x00000070); 11754 + sb_commit(sbh); 11755 + } 11756 + 8302 11757 + /* Reset the external PCI bus and enable the clock */ 8303 + W_REG( &pci->control, 0x5); /* enable the tristate drivers */8304 + W_REG( &pci->control, 0xd); /* enable the PCI clock */11758 + W_REG(osh, &pci->control, 0x5); /* enable the tristate drivers */ 11759 + W_REG(osh, &pci->control, 0xd); /* enable the PCI clock */ 8305 11760 + OSL_DELAY(150); /* delay > 100 us */ 8306 + W_REG(&pci->control, 0xf); /* deassert PCI reset */ 8307 + W_REG(&pci->arbcontrol, PCI_INT_ARB); /* use internal arbiter */ 11761 + W_REG(osh, &pci->control, 0xf); /* deassert PCI reset */ 11762 + /* Use internal arbiter and park REQ/GRNT at external master 0 */ 11763 + W_REG(osh, &pci->arbcontrol, PCI_INT_ARB); 8308 11764 + OSL_DELAY(1); /* delay 1 us */ 11765 + if (sb_corerev(sbh) >= 8) { 11766 + val = getintvar(NULL, "parkid"); 11767 + ASSERT(val <= PCI_PARKID_LAST); 11768 + OR_REG(osh, &pci->arbcontrol, val << PCI_PARKID_SHIFT); 11769 + OSL_DELAY(1); 11770 + } 8309 11771 + 8310 11772 + /* Enable CardBusMode */ 8311 + cardbus = nvram_match("cardbus", "1");11773 + cardbus = getintvar(NULL, "cardbus") == 1; 8312 11774 + if (cardbus) { 8313 + print f("PCI: Enabling CardBus\n");11775 + printk("PCI: Enabling CardBus\n"); 8314 11776 + /* GPIO 1 resets the CardBus device on bcm94710ap */ 8315 + sb_gpioout(sbh, 1, 1 );8316 + sb_gpioouten(sbh, 1, 1 );8317 + W_REG( &pci->sprom[0], R_REG(&pci->sprom[0]) | 0x400);11777 + sb_gpioout(sbh, 1, 1, GPIO_DRV_PRIORITY); 11778 + sb_gpioouten(sbh, 1, 1, GPIO_DRV_PRIORITY); 11779 + W_REG(osh, &pci->sprom[0], R_REG(osh, &pci->sprom[0]) | 0x400); 8318 11780 + } 8319 11781 + 8320 11782 + /* 64 MB I/O access window */ 8321 + W_REG( &pci->sbtopci0, SBTOPCI_IO);11783 + W_REG(osh, &pci->sbtopci0, SBTOPCI_IO); 8322 11784 + /* 64 MB configuration access window */ 8323 + W_REG( &pci->sbtopci1, SBTOPCI_CFG0);11785 + W_REG(osh, &pci->sbtopci1, SBTOPCI_CFG0); 8324 11786 + /* 1 GB memory access window */ 8325 + W_REG(&pci->sbtopci2, SBTOPCI_MEM | SB_PCI_DMA); 11787 + W_REG(osh, &pci->sbtopci2, SBTOPCI_MEM | SB_PCI_DMA); 11788 + 11789 + /* Host bridge slot # nvram overwrite */ 11790 + if ((hbslot = nvram_get("pcihbslot"))) { 11791 + pci_hbslot = bcm_strtoul(hbslot, NULL, 0); 11792 + ASSERT(pci_hbslot < PCI_MAX_DEVICES); 11793 + } 8326 11794 + 8327 11795 + /* Enable PCI bridge BAR0 prefetch and burst */ 8328 11796 + val = 6; 8329 + sbpci_write_config(sbh, 1, 0, 0, PCI_CFG_CMD, &val, sizeof(val));11797 + sbpci_write_config(sbh, 1, pci_hbslot, 0, PCI_CFG_CMD, &val, sizeof(val)); 8330 11798 + 8331 11799 + /* Enable PCI interrupts */ 8332 + W_REG(&pci->intmask, PCI_INTA); 8333 + } 8334 + 8335 + return 0; 8336 +} 8337 + 8338 +static int 8339 +sbpci_init_cores(void *sbh) 8340 +{ 8341 + uint chip, chiprev, chippkg, coreidx, i; 11800 + W_REG(osh, &pci->intmask, PCI_INTA); 11801 + } 11802 + 11803 + return ret; 11804 +} 11805 + 11806 +/* 11807 + * Get the PCI region address and size information. 11808 + */ 11809 +static void __init 11810 +sbpci_init_regions(sb_t *sbh, uint func, pci_config_regs *cfg, sb_bar_cfg_t *bar) 11811 +{ 11812 + osl_t *osh; 11813 + uint16 coreid; 11814 + void *regs; 8342 11815 + sbconfig_t *sb; 8343 + pci_config_regs *cfg; 11816 + uint32 base; 11817 + 11818 + osh = sb_osh(sbh); 11819 + coreid = sb_coreid(sbh); 11820 + regs = sb_coreregs(sbh); 11821 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF); 11822 + 11823 + switch (coreid) { 11824 + case SB_USB20H: 11825 + base = htol32(sb_base(R_REG(osh, &sb->sbadmatch0))); 11826 + 11827 + cfg->base[0] = func == 0 ? base : base + 0x800; /* OHCI/EHCI */ 11828 + cfg->base[1] = 0; 11829 + cfg->base[2] = 0; 11830 + cfg->base[3] = 0; 11831 + cfg->base[4] = 0; 11832 + cfg->base[5] = 0; 11833 + bar->n = 1; 11834 + bar->size0 = func == 0 ? 0x200 : 0x100; /* OHCI/EHCI */ 11835 + bar->size1 = 0; 11836 + bar->size2 = 0; 11837 + bar->size3 = 0; 11838 + break; 11839 + default: 11840 + cfg->base[0] = htol32(sb_base(R_REG(osh, &sb->sbadmatch0))); 11841 + cfg->base[1] = htol32(sb_base(R_REG(osh, &sb->sbadmatch1))); 11842 + cfg->base[2] = htol32(sb_base(R_REG(osh, &sb->sbadmatch2))); 11843 + cfg->base[3] = htol32(sb_base(R_REG(osh, &sb->sbadmatch3))); 11844 + cfg->base[4] = 0; 11845 + cfg->base[5] = 0; 11846 + bar->n = (R_REG(osh, &sb->sbidlow) & SBIDL_AR_MASK) >> SBIDL_AR_SHIFT; 11847 + bar->size0 = sb_size(R_REG(osh, &sb->sbadmatch0)); 11848 + bar->size1 = sb_size(R_REG(osh, &sb->sbadmatch1)); 11849 + bar->size2 = sb_size(R_REG(osh, &sb->sbadmatch2)); 11850 + bar->size3 = sb_size(R_REG(osh, &sb->sbadmatch3)); 11851 + break; 11852 + } 11853 +} 11854 + 11855 +/* 11856 + * Construct PCI config spaces for SB cores so that they 11857 + * can be accessed as if they were PCI devices. 11858 + */ 11859 +static void __init 11860 +sbpci_init_cores(sb_t *sbh) 11861 +{ 11862 + uint chiprev, coreidx, i; 11863 + sbconfig_t *sb; 11864 + pci_config_regs *cfg, *pci; 11865 + sb_bar_cfg_t *bar; 8344 11866 + void *regs; 8345 + char varname[8];8346 + uint wlidx = 0;8347 + uint16 vendor, core;11867 + osl_t *osh; 11868 + uint16 vendor, device; 11869 + uint16 coreid; 8348 11870 + uint8 class, subclass, progif; 8349 + uint32 val; 8350 + uint32 sbips_int_mask[] = { 0, SBIPS_INT1_MASK, SBIPS_INT2_MASK, SBIPS_INT3_MASK, SBIPS_INT4_MASK }; 8351 + uint32 sbips_int_shift[] = { 0, 0, SBIPS_INT2_SHIFT, SBIPS_INT3_SHIFT, SBIPS_INT4_SHIFT }; 8352 + 8353 + chip = sb_chip(sbh); 11871 + uint dev; 11872 + uint8 header; 11873 + uint func; 11874 + 8354 11875 + chiprev = sb_chiprev(sbh); 8355 + chippkg = sb_chippkg(sbh);8356 11876 + coreidx = sb_coreidx(sbh); 11877 + 11878 + osh = sb_osh(sbh); 8357 11879 + 8358 11880 + /* Scan the SB bus */ 8359 11881 + bzero(sb_config_regs, sizeof(sb_config_regs)); 8360 + for (cfg = sb_config_regs; cfg < &sb_config_regs[SB_MAXCORES]; cfg++) { 8361 + cfg->vendor = 0xffff; 8362 + if (!(regs = sb_setcoreidx(sbh, cfg - sb_config_regs))) 11882 + bzero(sb_bar_cfg, sizeof(sb_bar_cfg)); 11883 + bzero(sb_pci_cfg, sizeof(sb_pci_cfg)); 11884 + memset(&sb_pci_null, -1, sizeof(sb_pci_null)); 11885 + cfg = sb_config_regs; 11886 + bar = sb_bar_cfg; 11887 + for (dev = 0; dev < SB_MAXCORES; dev ++) { 11888 + /* Check if the core exists */ 11889 + if (!(regs = sb_setcoreidx(sbh, dev))) 8363 11890 + continue; 8364 11891 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF); 8365 11892 + 8366 + /* Read ID register and parse vendor and core */8367 + val = R_REG(&sb->sbidhigh);8368 + vendor = (val & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT;8369 + core = (val & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT;8370 + progif = 0;8371 +8372 11893 + /* Check if this core is banned */ 11894 + coreid = sb_coreid(sbh); 8373 11895 + for (i = 0; i < pci_banned; i++) 8374 + if (core == pci_ban[i])11896 + if (coreid == pci_ban[i]) 8375 11897 + break; 8376 11898 + if (i < pci_banned) 8377 11899 + continue; 8378 11900 + 8379 + /* Known vendor translations */ 8380 + switch (vendor) { 8381 + case SB_VEND_BCM: 8382 + vendor = VENDOR_BROADCOM; 11901 + for (func = 0; func < MAXFUNCS; ++func) { 11902 + /* Make sure we won't go beyond the limit */ 11903 + if (cfg >= &sb_config_regs[SB_MAXCORES]) { 11904 + printk("PCI: too many emulated devices\n"); 11905 + goto done; 11906 + } 11907 + 11908 + /* Convert core id to pci id */ 11909 + if (sb_corepciid(sbh, func, &vendor, &device, &class, &subclass, 11910 + &progif, &header)) 11911 + continue; 11912 + 11913 + /* 11914 + * Differentiate real PCI config from emulated. 11915 + * non zero 'pci' indicate there is a real PCI config space 11916 + * for this device. 11917 + */ 11918 + switch (device) { 11919 + case BCM47XX_GIGETH_ID: 11920 + pci = (pci_config_regs *)((uint32)regs + 0x800); 11921 + break; 11922 + case BCM47XX_SATAXOR_ID: 11923 + pci = (pci_config_regs *)((uint32)regs + 0x400); 11924 + break; 11925 + case BCM47XX_ATA100_ID: 11926 + pci = (pci_config_regs *)((uint32)regs + 0x800); 11927 + break; 11928 + default: 11929 + pci = NULL; 11930 + break; 11931 + } 11932 + /* Supported translations */ 11933 + cfg->vendor = htol16(vendor); 11934 + cfg->device = htol16(device); 11935 + cfg->rev_id = chiprev; 11936 + cfg->prog_if = progif; 11937 + cfg->sub_class = subclass; 11938 + cfg->base_class = class; 11939 + cfg->header_type = header; 11940 + sbpci_init_regions(sbh, func, cfg, bar); 11941 + /* Save core interrupt flag */ 11942 + cfg->int_pin = R_REG(osh, &sb->sbtpsflag) & SBTPS_NUM0_MASK; 11943 + /* Save core interrupt assignment */ 11944 + cfg->int_line = sb_irq(sbh); 11945 + /* Indicate there is no SROM */ 11946 + *((uint32 *) &cfg->sprom_control) = 0xffffffff; 11947 + 11948 + /* Point to the PCI config spaces */ 11949 + sb_pci_cfg[dev][func].emu = cfg; 11950 + sb_pci_cfg[dev][func].pci = pci; 11951 + sb_pci_cfg[dev][func].bar = bar; 11952 + cfg ++; 11953 + bar ++; 11954 + } 11955 + } 11956 + 11957 +done: 11958 + sb_setcoreidx(sbh, coreidx); 11959 +} 11960 + 11961 +/* 11962 + * Initialize PCI core and construct PCI config spaces for SB cores. 11963 + * Must propagate sbpci_init_pci() return value to the caller to let 11964 + * them know the PCI core initialization status. 11965 + */ 11966 +int __init 11967 +sbpci_init(sb_t *sbh) 11968 +{ 11969 + int status = sbpci_init_pci(sbh); 11970 + sbpci_init_cores(sbh); 11971 + return status; 11972 +} 11973 + 11974 diff -urN linux.old/arch/mips/bcm947xx/sbutils.c linux.dev/arch/mips/bcm947xx/sbutils.c 11975 --- linux.old/arch/mips/bcm947xx/sbutils.c 1970-01-01 01:00:00.000000000 +0100 11976 +++ linux.dev/arch/mips/bcm947xx/sbutils.c 2006-10-02 21:19:59.000000000 +0200 11977 @@ -0,0 +1,3103 @@ 11978 +/* 11979 + * Misc utility routines for accessing chip-specific features 11980 + * of the SiliconBackplane-based Broadcom chips. 11981 + * 11982 + * Copyright 2006, Broadcom Corporation 11983 + * All Rights Reserved. 11984 + * 11985 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 11986 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 11987 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 11988 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 11989 + * $Id: sbutils.c,v 1.10 2006/04/08 07:12:42 honor Exp $ 11990 + */ 11991 + 11992 +#include <typedefs.h> 11993 +#include <bcmdefs.h> 11994 +#include <osl.h> 11995 +#include <bcmutils.h> 11996 +#include <sbutils.h> 11997 +#include <bcmdevs.h> 11998 +#include <sbconfig.h> 11999 +#include <sbchipc.h> 12000 +#include <sbpci.h> 12001 +#include <sbpcie.h> 12002 +#include <pcicfg.h> 12003 +#include <sbpcmcia.h> 12004 +#include <sbextif.h> 12005 +#include <sbsocram.h> 12006 +#include <bcmsrom.h> 12007 +#ifdef __mips__ 12008 +#include <mipsinc.h> 12009 +#endif /* __mips__ */ 12010 + 12011 +/* debug/trace */ 12012 +#define SB_ERROR(args) 12013 + 12014 +typedef uint32 (*sb_intrsoff_t)(void *intr_arg); 12015 +typedef void (*sb_intrsrestore_t)(void *intr_arg, uint32 arg); 12016 +typedef bool (*sb_intrsenabled_t)(void *intr_arg); 12017 + 12018 +/* misc sb info needed by some of the routines */ 12019 +typedef struct sb_info { 12020 + 12021 + struct sb_pub sb; /* back plane public state (must be first field) */ 12022 + 12023 + void *osh; /* osl os handle */ 12024 + void *sdh; /* bcmsdh handle */ 12025 + 12026 + void *curmap; /* current regs va */ 12027 + void *regs[SB_MAXCORES]; /* other regs va */ 12028 + 12029 + uint curidx; /* current core index */ 12030 + uint dev_coreid; /* the core provides driver functions */ 12031 + 12032 + bool memseg; /* flag to toggle MEM_SEG register */ 12033 + 12034 + uint gpioidx; /* gpio control core index */ 12035 + uint gpioid; /* gpio control coretype */ 12036 + 12037 + uint numcores; /* # discovered cores */ 12038 + uint coreid[SB_MAXCORES]; /* id of each core */ 12039 + 12040 + void *intr_arg; /* interrupt callback function arg */ 12041 + sb_intrsoff_t intrsoff_fn; /* turns chip interrupts off */ 12042 + sb_intrsrestore_t intrsrestore_fn; /* restore chip interrupts */ 12043 + sb_intrsenabled_t intrsenabled_fn; /* check if interrupts are enabled */ 12044 + 12045 +} sb_info_t; 12046 + 12047 +/* local prototypes */ 12048 +static sb_info_t * sb_doattach(sb_info_t *si, uint devid, osl_t *osh, void *regs, 12049 + uint bustype, void *sdh, char **vars, uint *varsz); 12050 +static void sb_scan(sb_info_t *si); 12051 +static uint sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val); 12052 +static uint _sb_coreidx(sb_info_t *si); 12053 +static uint sb_findcoreidx(sb_info_t *si, uint coreid, uint coreunit); 12054 +static uint sb_pcidev2chip(uint pcidev); 12055 +static uint sb_chip2numcores(uint chip); 12056 +static bool sb_ispcie(sb_info_t *si); 12057 +static bool sb_find_pci_capability(sb_info_t *si, uint8 req_cap_id, uchar *buf, uint32 *buflen); 12058 +static int sb_pci_fixcfg(sb_info_t *si); 12059 + 12060 +/* routines to access mdio slave device registers */ 12061 +static int sb_pcie_mdiowrite(sb_info_t *si, uint physmedia, uint readdr, uint val); 12062 +static void sb_war30841(sb_info_t *si); 12063 + 12064 +/* delay needed between the mdio control/ mdiodata register data access */ 12065 +#define PR28829_DELAY() OSL_DELAY(10) 12066 + 12067 +/* size that can take bitfielddump */ 12068 +#define BITFIELD_DUMP_SIZE 32 12069 + 12070 +/* global variable to indicate reservation/release of gpio's */ 12071 +static uint32 sb_gpioreservation = 0; 12072 + 12073 +#define SB_INFO(sbh) (sb_info_t*)sbh 12074 +#define SET_SBREG(si, r, mask, val) \ 12075 + W_SBREG((si), (r), ((R_SBREG((si), (r)) & ~(mask)) | (val))) 12076 +#define GOODCOREADDR(x) (((x) >= SB_ENUM_BASE) && ((x) <= SB_ENUM_LIM) && \ 12077 + ISALIGNED((x), SB_CORE_SIZE)) 12078 +#define GOODREGS(regs) ((regs) && ISALIGNED((uintptr)(regs), SB_CORE_SIZE)) 12079 +#define REGS2SB(va) (sbconfig_t*) ((int8*)(va) + SBCONFIGOFF) 12080 +#define GOODIDX(idx) (((uint)idx) < SB_MAXCORES) 12081 +#define BADIDX (SB_MAXCORES+1) 12082 +#define NOREV -1 /* Invalid rev */ 12083 + 12084 +#define PCI(si) ((BUSTYPE(si->sb.bustype) == PCI_BUS) && (si->sb.buscoretype == SB_PCI)) 12085 +#define PCIE(si) ((BUSTYPE(si->sb.bustype) == PCI_BUS) && (si->sb.buscoretype == SB_PCIE)) 12086 + 12087 +/* sonicsrev */ 12088 +#define SONICS_2_2 (SBIDL_RV_2_2 >> SBIDL_RV_SHIFT) 12089 +#define SONICS_2_3 (SBIDL_RV_2_3 >> SBIDL_RV_SHIFT) 12090 + 12091 +#define R_SBREG(si, sbr) sb_read_sbreg((si), (sbr)) 12092 +#define W_SBREG(si, sbr, v) sb_write_sbreg((si), (sbr), (v)) 12093 +#define AND_SBREG(si, sbr, v) W_SBREG((si), (sbr), (R_SBREG((si), (sbr)) & (v))) 12094 +#define OR_SBREG(si, sbr, v) W_SBREG((si), (sbr), (R_SBREG((si), (sbr)) | (v))) 12095 + 12096 +/* 12097 + * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts before/ 12098 + * after core switching to avoid invalid register accesss inside ISR. 12099 + */ 12100 +#define INTR_OFF(si, intr_val) \ 12101 + if ((si)->intrsoff_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \ 12102 + intr_val = (*(si)->intrsoff_fn)((si)->intr_arg); } 12103 +#define INTR_RESTORE(si, intr_val) \ 12104 + if ((si)->intrsrestore_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \ 12105 + (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val); } 12106 + 12107 +/* dynamic clock control defines */ 12108 +#define LPOMINFREQ 25000 /* low power oscillator min */ 12109 +#define LPOMAXFREQ 43000 /* low power oscillator max */ 12110 +#define XTALMINFREQ 19800000 /* 20 MHz - 1% */ 12111 +#define XTALMAXFREQ 20200000 /* 20 MHz + 1% */ 12112 +#define PCIMINFREQ 25000000 /* 25 MHz */ 12113 +#define PCIMAXFREQ 34000000 /* 33 MHz + fudge */ 12114 + 12115 +#define ILP_DIV_5MHZ 0 /* ILP = 5 MHz */ 12116 +#define ILP_DIV_1MHZ 4 /* ILP = 1 MHz */ 12117 + 12118 +/* different register spaces to access thr'u pcie indirect access */ 12119 +#define PCIE_CONFIGREGS 1 /* Access to config space */ 12120 +#define PCIE_PCIEREGS 2 /* Access to pcie registers */ 12121 + 12122 +/* force HT war check */ 12123 +#define FORCEHT_WAR32414(si) \ 12124 + ((PCIE(si)) && (((si->sb.chip == BCM4311_CHIP_ID) && (si->sb.chiprev == 1)) || \ 12125 + ((si->sb.chip == BCM4321_CHIP_ID) && (si->sb.chiprev <= 3)))) 12126 + 12127 +/* GPIO Based LED powersave defines */ 12128 +#define DEFAULT_GPIO_ONTIME 10 /* Default: 10% on */ 12129 +#define DEFAULT_GPIO_OFFTIME 90 /* Default: 10% on */ 12130 + 12131 +#define DEFAULT_GPIOTIMERVAL ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME) 12132 + 12133 +static uint32 12134 +sb_read_sbreg(sb_info_t *si, volatile uint32 *sbr) 12135 +{ 12136 + uint8 tmp; 12137 + uint32 val, intr_val = 0; 12138 + 12139 + 12140 + /* 12141 + * compact flash only has 11 bits address, while we needs 12 bits address. 12142 + * MEM_SEG will be OR'd with other 11 bits address in hardware, 12143 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters). 12144 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special 12145 + */ 12146 + if (si->memseg) { 12147 + INTR_OFF(si, intr_val); 12148 + tmp = 1; 12149 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1); 12150 + sbr = (volatile uint32 *)((uintptr)sbr & ~(1 << 11)); /* mask out bit 11 */ 12151 + } 12152 + 12153 + val = R_REG(si->osh, sbr); 12154 + 12155 + if (si->memseg) { 12156 + tmp = 0; 12157 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1); 12158 + INTR_RESTORE(si, intr_val); 12159 + } 12160 + 12161 + return (val); 12162 +} 12163 + 12164 +static void 12165 +sb_write_sbreg(sb_info_t *si, volatile uint32 *sbr, uint32 v) 12166 +{ 12167 + uint8 tmp; 12168 + volatile uint32 dummy; 12169 + uint32 intr_val = 0; 12170 + 12171 + 12172 + /* 12173 + * compact flash only has 11 bits address, while we needs 12 bits address. 12174 + * MEM_SEG will be OR'd with other 11 bits address in hardware, 12175 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters). 12176 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special 12177 + */ 12178 + if (si->memseg) { 12179 + INTR_OFF(si, intr_val); 12180 + tmp = 1; 12181 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1); 12182 + sbr = (volatile uint32 *)((uintptr)sbr & ~(1 << 11)); /* mask out bit 11 */ 12183 + } 12184 + 12185 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS) { 12186 +#ifdef IL_BIGENDIAN 12187 + dummy = R_REG(si->osh, sbr); 12188 + W_REG(si->osh, ((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff)); 12189 + dummy = R_REG(si->osh, sbr); 12190 + W_REG(si->osh, (volatile uint16 *)sbr, (uint16)(v & 0xffff)); 12191 +#else 12192 + dummy = R_REG(si->osh, sbr); 12193 + W_REG(si->osh, (volatile uint16 *)sbr, (uint16)(v & 0xffff)); 12194 + dummy = R_REG(si->osh, sbr); 12195 + W_REG(si->osh, ((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff)); 12196 +#endif /* IL_BIGENDIAN */ 12197 + } else 12198 + W_REG(si->osh, sbr, v); 12199 + 12200 + if (si->memseg) { 12201 + tmp = 0; 12202 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1); 12203 + INTR_RESTORE(si, intr_val); 12204 + } 12205 +} 12206 + 12207 +/* 12208 + * Allocate a sb handle. 12209 + * devid - pci device id (used to determine chip#) 12210 + * osh - opaque OS handle 12211 + * regs - virtual address of initial core registers 12212 + * bustype - pci/pcmcia/sb/sdio/etc 12213 + * vars - pointer to a pointer area for "environment" variables 12214 + * varsz - pointer to int to return the size of the vars 12215 + */ 12216 +sb_t * 12217 +BCMINITFN(sb_attach)(uint devid, osl_t *osh, void *regs, 12218 + uint bustype, void *sdh, char **vars, uint *varsz) 12219 +{ 12220 + sb_info_t *si; 12221 + 12222 + /* alloc sb_info_t */ 12223 + if ((si = MALLOC(osh, sizeof (sb_info_t))) == NULL) { 12224 + SB_ERROR(("sb_attach: malloc failed! malloced %d bytes\n", MALLOCED(osh))); 12225 + return (NULL); 12226 + } 12227 + 12228 + if (sb_doattach(si, devid, osh, regs, bustype, sdh, vars, (uint*)varsz) == NULL) { 12229 + MFREE(osh, si, sizeof(sb_info_t)); 12230 + return (NULL); 12231 + } 12232 + 12233 + return (sb_t *)si; 12234 +} 12235 + 12236 +/* Using sb_kattach depends on SB_BUS support, either implicit */ 12237 +/* no limiting BCMBUSTYPE value) or explicit (value is SB_BUS). */ 12238 +#if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SB_BUS) 12239 + 12240 +/* global kernel resource */ 12241 +static sb_info_t ksi; 12242 +static bool ksi_attached = FALSE; 12243 + 12244 +/* generic kernel variant of sb_attach() */ 12245 +sb_t * 12246 +BCMINITFN(sb_kattach)(void) 12247 +{ 12248 + osl_t *osh = NULL; 12249 + uint32 *regs; 12250 + 12251 + if (!ksi_attached) { 12252 + uint32 cid; 12253 + 12254 + regs = (uint32 *)REG_MAP(SB_ENUM_BASE, SB_CORE_SIZE); 12255 + cid = R_REG(osh, (uint32 *)regs); 12256 + if (((cid & CID_ID_MASK) == BCM4712_CHIP_ID) && 12257 + ((cid & CID_PKG_MASK) != BCM4712LARGE_PKG_ID) && 12258 + ((cid & CID_REV_MASK) <= (3 << CID_REV_SHIFT))) { 12259 + uint32 *scc, val; 12260 + 12261 + scc = (uint32 *)((uchar*)regs + OFFSETOF(chipcregs_t, slow_clk_ctl)); 12262 + val = R_REG(osh, scc); 12263 + SB_ERROR((" initial scc = 0x%x\n", val)); 12264 + val |= SCC_SS_XTAL; 12265 + W_REG(osh, scc, val); 12266 + } 12267 + 12268 + if (sb_doattach(&ksi, BCM4710_DEVICE_ID, osh, (void*)regs, 12269 + SB_BUS, NULL, NULL, NULL) == NULL) { 12270 + return NULL; 12271 + } 12272 + else 12273 + ksi_attached = TRUE; 12274 + } 12275 + 12276 + return (sb_t *)&ksi; 12277 +} 12278 +#endif /* !BCMBUSTYPE || (BCMBUSTYPE == SB_BUS) */ 12279 + 12280 +void 12281 +BCMINITFN(sb_war32414_forceHT)(sb_t *sbh, bool forceHT) 12282 +{ 12283 + sb_info_t *si; 12284 + 12285 + si = SB_INFO(sbh); 12286 + 12287 + 12288 + if (FORCEHT_WAR32414(si)) { 12289 + uint32 val = 0; 12290 + if (forceHT) 12291 + val = SYCC_HR; 12292 + sb_corereg((void*)si, SB_CC_IDX, OFFSETOF(chipcregs_t, system_clk_ctl), 12293 + SYCC_HR, val); 12294 + } 12295 +} 12296 + 12297 +static sb_info_t * 12298 +BCMINITFN(sb_doattach)(sb_info_t *si, uint devid, osl_t *osh, void *regs, 12299 + uint bustype, void *sdh, char **vars, uint *varsz) 12300 +{ 12301 + uint origidx; 12302 + chipcregs_t *cc; 12303 + sbconfig_t *sb; 12304 + uint32 w; 12305 + 12306 + ASSERT(GOODREGS(regs)); 12307 + 12308 + bzero((uchar*)si, sizeof(sb_info_t)); 12309 + 12310 + si->sb.buscoreidx = si->gpioidx = BADIDX; 12311 + 12312 + si->curmap = regs; 12313 + si->sdh = sdh; 12314 + si->osh = osh; 12315 + 12316 + /* check to see if we are a sb core mimic'ing a pci core */ 12317 + if (bustype == PCI_BUS) { 12318 + if (OSL_PCI_READ_CONFIG(si->osh, PCI_SPROM_CONTROL, sizeof(uint32)) == 0xffffffff) { 12319 + SB_ERROR(("%s: incoming bus is PCI but it's a lie, switching to SB " 12320 + "devid:0x%x\n", __FUNCTION__, devid)); 12321 + bustype = SB_BUS; 12322 + } 12323 + } 12324 + 12325 + si->sb.bustype = bustype; 12326 + if (si->sb.bustype != BUSTYPE(si->sb.bustype)) { 12327 + SB_ERROR(("sb_doattach: bus type %d does not match configured bus type %d\n", 12328 + si->sb.bustype, BUSTYPE(si->sb.bustype))); 12329 + return NULL; 12330 + } 12331 + 12332 + /* need to set memseg flag for CF card first before any sb registers access */ 12333 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS) 12334 + si->memseg = TRUE; 12335 + 12336 + /* kludge to enable the clock on the 4306 which lacks a slowclock */ 12337 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) 12338 + sb_clkctl_xtal(&si->sb, XTAL|PLL, ON); 12339 + 12340 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) { 12341 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_BAR0_WIN, sizeof(uint32)); 12342 + if (!GOODCOREADDR(w)) 12343 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, sizeof(uint32), SB_ENUM_BASE); 12344 + } 12345 + 12346 + /* initialize current core index value */ 12347 + si->curidx = _sb_coreidx(si); 12348 + 12349 + if (si->curidx == BADIDX) { 12350 + SB_ERROR(("sb_doattach: bad core index\n")); 12351 + return NULL; 12352 + } 12353 + 12354 + /* get sonics backplane revision */ 12355 + sb = REGS2SB(si->curmap); 12356 + si->sb.sonicsrev = (R_SBREG(si, &sb->sbidlow) & SBIDL_RV_MASK) >> SBIDL_RV_SHIFT; 12357 + 12358 + /* keep and reuse the initial register mapping */ 12359 + origidx = si->curidx; 12360 + if (BUSTYPE(si->sb.bustype) == SB_BUS) 12361 + si->regs[origidx] = regs; 12362 + 12363 + /* is core-0 a chipcommon core? */ 12364 + si->numcores = 1; 12365 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, 0); 12366 + if (sb_coreid(&si->sb) != SB_CC) 12367 + cc = NULL; 12368 + 12369 + /* determine chip id and rev */ 12370 + if (cc) { 12371 + /* chip common core found! */ 12372 + si->sb.chip = R_REG(si->osh, &cc->chipid) & CID_ID_MASK; 12373 + si->sb.chiprev = (R_REG(si->osh, &cc->chipid) & CID_REV_MASK) >> CID_REV_SHIFT; 12374 + si->sb.chippkg = (R_REG(si->osh, &cc->chipid) & CID_PKG_MASK) >> CID_PKG_SHIFT; 12375 + } else { 12376 + /* no chip common core -- must convert device id to chip id */ 12377 + if ((si->sb.chip = sb_pcidev2chip(devid)) == 0) { 12378 + SB_ERROR(("sb_doattach: unrecognized device id 0x%04x\n", devid)); 12379 + sb_setcoreidx(&si->sb, origidx); 12380 + return NULL; 12381 + } 12382 + } 12383 + 12384 + /* get chipcommon rev */ 12385 + si->sb.ccrev = cc ? (int)sb_corerev(&si->sb) : NOREV; 12386 + 12387 + /* determine numcores */ 12388 + if (cc && ((si->sb.ccrev == 4) || (si->sb.ccrev >= 6))) 12389 + si->numcores = (R_REG(si->osh, &cc->chipid) & CID_CC_MASK) >> CID_CC_SHIFT; 12390 + else 12391 + si->numcores = sb_chip2numcores(si->sb.chip); 12392 + 12393 + /* return to original core */ 12394 + sb_setcoreidx(&si->sb, origidx); 12395 + 12396 + /* sanity checks */ 12397 + ASSERT(si->sb.chip); 12398 + 12399 + /* scan for cores */ 12400 + sb_scan(si); 12401 + 12402 + /* fixup necessary chip/core configurations */ 12403 + if (BUSTYPE(si->sb.bustype) == PCI_BUS) { 12404 + if (sb_pci_fixcfg(si)) { 12405 + SB_ERROR(("sb_doattach: sb_pci_fixcfg failed\n")); 12406 + return NULL; 12407 + } 12408 + } 12409 + 12410 + /* srom_var_init() depends on sb_scan() info */ 12411 + if (srom_var_init(si, si->sb.bustype, si->curmap, si->osh, vars, varsz)) { 12412 + SB_ERROR(("sb_doattach: srom_var_init failed: bad srom\n")); 12413 + return (NULL); 12414 + } 12415 + 12416 + if (cc == NULL) { 12417 + /* 12418 + * The chip revision number is hardwired into all 12419 + * of the pci function config rev fields and is 12420 + * independent from the individual core revision numbers. 12421 + * For example, the "A0" silicon of each chip is chip rev 0. 12422 + * For PCMCIA we get it from the CIS instead. 12423 + */ 12424 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS) { 12425 + ASSERT(vars); 12426 + si->sb.chiprev = getintvar(*vars, "chiprev"); 12427 + } else if (BUSTYPE(si->sb.bustype) == PCI_BUS) { 12428 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_CFG_REV, sizeof(uint32)); 12429 + si->sb.chiprev = w & 0xff; 12430 + } else 12431 + si->sb.chiprev = 0; 12432 + } 12433 + 12434 + if (BUSTYPE(si->sb.bustype) == PCMCIA_BUS) { 12435 + w = getintvar(*vars, "regwindowsz"); 12436 + si->memseg = (w <= CFTABLE_REGWIN_2K) ? TRUE : FALSE; 12437 + } 12438 + 12439 + /* gpio control core is required */ 12440 + if (!GOODIDX(si->gpioidx)) { 12441 + SB_ERROR(("sb_doattach: gpio control core not found\n")); 12442 + return NULL; 12443 + } 12444 + 12445 + /* get boardtype and boardrev */ 12446 + switch (BUSTYPE(si->sb.bustype)) { 12447 + case PCI_BUS: 12448 + /* do a pci config read to get subsystem id and subvendor id */ 12449 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_CFG_SVID, sizeof(uint32)); 12450 + si->sb.boardvendor = w & 0xffff; 12451 + si->sb.boardtype = (w >> 16) & 0xffff; 12452 + break; 12453 + 12454 + case PCMCIA_BUS: 12455 + case SDIO_BUS: 12456 + si->sb.boardvendor = getintvar(*vars, "manfid"); 12457 + si->sb.boardtype = getintvar(*vars, "prodid"); 12458 + break; 12459 + 12460 + case SB_BUS: 12461 + case JTAG_BUS: 12462 + si->sb.boardvendor = VENDOR_BROADCOM; 12463 + if ((si->sb.boardtype = getintvar(NULL, "boardtype")) == 0) 12464 + si->sb.boardtype = 0xffff; 12465 + break; 12466 + } 12467 + 12468 + if (si->sb.boardtype == 0) { 12469 + SB_ERROR(("sb_doattach: unknown board type\n")); 12470 + ASSERT(si->sb.boardtype); 12471 + } 12472 + 12473 + /* setup the GPIO based LED powersave register */ 12474 + if (si->sb.ccrev >= 16) { 12475 + if ((vars == NULL) || ((w = getintvar(*vars, "leddc")) == 0)) 12476 + w = DEFAULT_GPIOTIMERVAL; 12477 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), ~0, w); 12478 + } 12479 + if (FORCEHT_WAR32414(si)) { 12480 + /* set proper clk setup delays before forcing HT */ 12481 + sb_clkctl_init((void *)si); 12482 + sb_war32414_forceHT((void *)si, 1); 12483 + } 12484 + 12485 + 12486 + return (si); 12487 +} 12488 + 12489 + 12490 +uint 12491 +sb_coreid(sb_t *sbh) 12492 +{ 12493 + sb_info_t *si; 12494 + sbconfig_t *sb; 12495 + 12496 + si = SB_INFO(sbh); 12497 + sb = REGS2SB(si->curmap); 12498 + 12499 + return ((R_SBREG(si, &sb->sbidhigh) & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT); 12500 +} 12501 + 12502 +uint 12503 +sb_coreidx(sb_t *sbh) 12504 +{ 12505 + sb_info_t *si; 12506 + 12507 + si = SB_INFO(sbh); 12508 + return (si->curidx); 12509 +} 12510 + 12511 +/* return current index of core */ 12512 +static uint 12513 +_sb_coreidx(sb_info_t *si) 12514 +{ 12515 + sbconfig_t *sb; 12516 + uint32 sbaddr = 0; 12517 + 12518 + ASSERT(si); 12519 + 12520 + switch (BUSTYPE(si->sb.bustype)) { 12521 + case SB_BUS: 12522 + sb = REGS2SB(si->curmap); 12523 + sbaddr = sb_base(R_SBREG(si, &sb->sbadmatch0)); 12524 + break; 12525 + 12526 + case PCI_BUS: 12527 + sbaddr = OSL_PCI_READ_CONFIG(si->osh, PCI_BAR0_WIN, sizeof(uint32)); 12528 + break; 12529 + 12530 + case PCMCIA_BUS: { 12531 + uint8 tmp = 0; 12532 + 12533 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1); 12534 + sbaddr = (uint)tmp << 12; 12535 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1); 12536 + sbaddr |= (uint)tmp << 16; 12537 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1); 12538 + sbaddr |= (uint)tmp << 24; 12539 + break; 12540 + } 12541 + 12542 +#ifdef BCMJTAG 12543 + case JTAG_BUS: 12544 + sbaddr = (uint32)si->curmap; 12545 + break; 12546 +#endif /* BCMJTAG */ 12547 + 12548 + default: 12549 + ASSERT(0); 12550 + } 12551 + 12552 + if (!GOODCOREADDR(sbaddr)) 12553 + return BADIDX; 12554 + 12555 + return ((sbaddr - SB_ENUM_BASE) / SB_CORE_SIZE); 12556 +} 12557 + 12558 +uint 12559 +sb_corevendor(sb_t *sbh) 12560 +{ 12561 + sb_info_t *si; 12562 + sbconfig_t *sb; 12563 + 12564 + si = SB_INFO(sbh); 12565 + sb = REGS2SB(si->curmap); 12566 + 12567 + return ((R_SBREG(si, &sb->sbidhigh) & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT); 12568 +} 12569 + 12570 +uint 12571 +sb_corerev(sb_t *sbh) 12572 +{ 12573 + sb_info_t *si; 12574 + sbconfig_t *sb; 12575 + uint sbidh; 12576 + 12577 + si = SB_INFO(sbh); 12578 + sb = REGS2SB(si->curmap); 12579 + sbidh = R_SBREG(si, &sb->sbidhigh); 12580 + 12581 + return (SBCOREREV(sbidh)); 12582 +} 12583 + 12584 +void * 12585 +sb_osh(sb_t *sbh) 12586 +{ 12587 + sb_info_t *si; 12588 + 12589 + si = SB_INFO(sbh); 12590 + return si->osh; 12591 +} 12592 + 12593 +void 12594 +sb_setosh(sb_t *sbh, osl_t *osh) 12595 +{ 12596 + sb_info_t *si; 12597 + 12598 + si = SB_INFO(sbh); 12599 + if (si->osh != NULL) { 12600 + SB_ERROR(("osh is already set....\n")); 12601 + ASSERT(!si->osh); 12602 + } 12603 + si->osh = osh; 12604 +} 12605 + 12606 +/* set/clear sbtmstatelow core-specific flags */ 12607 +uint32 12608 +sb_coreflags(sb_t *sbh, uint32 mask, uint32 val) 12609 +{ 12610 + sb_info_t *si; 12611 + sbconfig_t *sb; 12612 + uint32 w; 12613 + 12614 + si = SB_INFO(sbh); 12615 + sb = REGS2SB(si->curmap); 12616 + 12617 + ASSERT((val & ~mask) == 0); 12618 + 12619 + /* mask and set */ 12620 + if (mask || val) { 12621 + w = (R_SBREG(si, &sb->sbtmstatelow) & ~mask) | val; 12622 + W_SBREG(si, &sb->sbtmstatelow, w); 12623 + } 12624 + 12625 + /* return the new value */ 12626 + return (R_SBREG(si, &sb->sbtmstatelow)); 12627 +} 12628 + 12629 +/* set/clear sbtmstatehigh core-specific flags */ 12630 +uint32 12631 +sb_coreflagshi(sb_t *sbh, uint32 mask, uint32 val) 12632 +{ 12633 + sb_info_t *si; 12634 + sbconfig_t *sb; 12635 + uint32 w; 12636 + 12637 + si = SB_INFO(sbh); 12638 + sb = REGS2SB(si->curmap); 12639 + 12640 + ASSERT((val & ~mask) == 0); 12641 + ASSERT((mask & ~SBTMH_FL_MASK) == 0); 12642 + 12643 + /* mask and set */ 12644 + if (mask || val) { 12645 + w = (R_SBREG(si, &sb->sbtmstatehigh) & ~mask) | val; 12646 + W_SBREG(si, &sb->sbtmstatehigh, w); 12647 + } 12648 + 12649 + /* return the new value */ 12650 + return (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_FL_MASK); 12651 +} 12652 + 12653 +/* Run bist on current core. Caller needs to take care of core-specific bist hazards */ 12654 +int 12655 +sb_corebist(sb_t *sbh) 12656 +{ 12657 + uint32 sblo; 12658 + sb_info_t *si; 12659 + sbconfig_t *sb; 12660 + int result = 0; 12661 + 12662 + si = SB_INFO(sbh); 12663 + sb = REGS2SB(si->curmap); 12664 + 12665 + sblo = R_SBREG(si, &sb->sbtmstatelow); 12666 + W_SBREG(si, &sb->sbtmstatelow, (sblo | SBTML_FGC | SBTML_BE)); 12667 + 12668 + SPINWAIT(((R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_BISTD) == 0), 100000); 12669 + 12670 + if (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_BISTF) 12671 + result = BCME_ERROR; 12672 + 12673 + W_SBREG(si, &sb->sbtmstatelow, sblo); 12674 + 12675 + return result; 12676 +} 12677 + 12678 +bool 12679 +sb_iscoreup(sb_t *sbh) 12680 +{ 12681 + sb_info_t *si; 12682 + sbconfig_t *sb; 12683 + 12684 + si = SB_INFO(sbh); 12685 + sb = REGS2SB(si->curmap); 12686 + 12687 + return ((R_SBREG(si, &sb->sbtmstatelow) & 12688 + (SBTML_RESET | SBTML_REJ_MASK | SBTML_CLK)) == SBTML_CLK); 12689 +} 12690 + 12691 +/* 12692 + * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set operation, 12693 + * switch back to the original core, and return the new value. 12694 + * 12695 + * When using the silicon backplane, no fidleing with interrupts or core switches are needed. 12696 + * 12697 + * Also, when using pci/pcie, we can optimize away the core switching for pci registers 12698 + * and (on newer pci cores) chipcommon registers. 12699 + */ 12700 +static uint 12701 +sb_corereg(sb_info_t *si, uint coreidx, uint regoff, uint mask, uint val) 12702 +{ 12703 + uint origidx = 0; 12704 + uint32 *r = NULL; 12705 + uint w; 12706 + uint intr_val = 0; 12707 + bool fast = FALSE; 12708 + 12709 + ASSERT(GOODIDX(coreidx)); 12710 + ASSERT(regoff < SB_CORE_SIZE); 12711 + ASSERT((val & ~mask) == 0); 12712 + 12713 +#ifdef notyet 12714 + if (si->sb.bustype == SB_BUS) { 12715 + /* If internal bus, we can always get at everything */ 12716 + fast = TRUE; 12717 + r = (uint32 *)((uchar *)si->regs[coreidx] + regoff); 12718 + } else if (si->sb.bustype == PCI_BUS) { 12719 + /* If pci/pcie, we can get at pci/pcie regs and on newer cores to chipc */ 12720 + 12721 + if ((si->coreid[coreidx] == SB_CC) && 12722 + ((si->sb.buscoretype == SB_PCIE) || 12723 + (si->sb.buscorerev >= 13))) { 12724 + /* Chipc registers are mapped at 12KB */ 12725 + 12726 + fast = TRUE; 12727 + r = (uint32 *)((char *)si->curmap + PCI_16KB0_CCREGS_OFFSET + regoff); 12728 + } else if (si->sb.buscoreidx == coreidx) { 12729 + /* pci registers are at either in the last 2KB of an 8KB window 12730 + * or, in pcie and pci rev 13 at 8KB 12731 + */ 12732 + fast = TRUE; 12733 + if ((si->sb.buscoretype == SB_PCIE) || 12734 + (si->sb.buscorerev >= 13)) 12735 + r = (uint32 *)((char *)si->curmap + 12736 + PCI_16KB0_PCIREGS_OFFSET + regoff); 12737 + else 12738 + r = (uint32 *)((char *)si->curmap + 12739 + ((regoff >= SBCONFIGOFF) ? 12740 + PCI_BAR0_PCISBR_OFFSET : PCI_BAR0_PCIREGS_OFFSET) + 12741 + regoff); 12742 + } 12743 + } 12744 +#endif /* notyet */ 12745 + 12746 + if (!fast) { 12747 + INTR_OFF(si, intr_val); 12748 + 12749 + /* save current core index */ 12750 + origidx = sb_coreidx(&si->sb); 12751 + 12752 + /* switch core */ 12753 + r = (uint32*) ((uchar*) sb_setcoreidx(&si->sb, coreidx) + regoff); 12754 + } 12755 + ASSERT(r); 12756 + 12757 + /* mask and set */ 12758 + if (mask || val) { 12759 + if (regoff >= SBCONFIGOFF) { 12760 + w = (R_SBREG(si, r) & ~mask) | val; 12761 + W_SBREG(si, r, w); 12762 + } else { 12763 + w = (R_REG(si->osh, r) & ~mask) | val; 12764 + W_REG(si->osh, r, w); 12765 + } 12766 + } 12767 + 12768 + /* readback */ 12769 + if (regoff >= SBCONFIGOFF) 12770 + w = R_SBREG(si, r); 12771 + else 12772 + w = R_REG(si->osh, r); 12773 + 12774 + if (!fast) { 12775 + /* restore core index */ 12776 + if (origidx != coreidx) 12777 + sb_setcoreidx(&si->sb, origidx); 12778 + 12779 + INTR_RESTORE(si, intr_val); 12780 + } 12781 + 12782 + return (w); 12783 +} 12784 + 12785 +#define DWORD_ALIGN(x) (x & ~(0x03)) 12786 +#define BYTE_POS(x) (x & 0x3) 12787 +#define WORD_POS(x) (x & 0x1) 12788 + 12789 +#define BYTE_SHIFT(x) (8 * BYTE_POS(x)) 12790 +#define WORD_SHIFT(x) (16 * WORD_POS(x)) 12791 + 12792 +#define BYTE_VAL(a, x) ((a >> BYTE_SHIFT(x)) & 0xFF) 12793 +#define WORD_VAL(a, x) ((a >> WORD_SHIFT(x)) & 0xFFFF) 12794 + 12795 +#define read_pci_cfg_byte(a) \ 12796 + (BYTE_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xff) 12797 + 12798 +#define read_pci_cfg_word(a) \ 12799 + (WORD_VAL(OSL_PCI_READ_CONFIG(si->osh, DWORD_ALIGN(a), 4), a) & 0xffff) 12800 + 12801 + 12802 +/* return TRUE if requested capability exists in the PCI config space */ 12803 +static bool 12804 +sb_find_pci_capability(sb_info_t *si, uint8 req_cap_id, uchar *buf, uint32 *buflen) 12805 +{ 12806 + uint8 cap_id; 12807 + uint8 cap_ptr; 12808 + uint32 bufsize; 12809 + uint8 byte_val; 12810 + 12811 + if (BUSTYPE(si->sb.bustype) != PCI_BUS) 12812 + return FALSE; 12813 + 12814 + /* check for Header type 0 */ 12815 + byte_val = read_pci_cfg_byte(PCI_CFG_HDR); 12816 + if ((byte_val & 0x7f) != PCI_HEADER_NORMAL) 12817 + return FALSE; 12818 + 12819 + /* check if the capability pointer field exists */ 12820 + byte_val = read_pci_cfg_byte(PCI_CFG_STAT); 12821 + if (!(byte_val & PCI_CAPPTR_PRESENT)) 12822 + return FALSE; 12823 + 12824 + cap_ptr = read_pci_cfg_byte(PCI_CFG_CAPPTR); 12825 + /* check if the capability pointer is 0x00 */ 12826 + if (cap_ptr == 0x00) 12827 + return FALSE; 12828 + 12829 + 12830 + /* loop thr'u the capability list and see if the pcie capabilty exists */ 12831 + 12832 + cap_id = read_pci_cfg_byte(cap_ptr); 12833 + 12834 + while (cap_id != req_cap_id) { 12835 + cap_ptr = read_pci_cfg_byte((cap_ptr+1)); 12836 + if (cap_ptr == 0x00) break; 12837 + cap_id = read_pci_cfg_byte(cap_ptr); 12838 + } 12839 + if (cap_id != req_cap_id) { 12840 + return FALSE; 12841 + } 12842 + /* found the caller requested capability */ 12843 + if ((buf != NULL) && (buflen != NULL)) { 12844 + bufsize = *buflen; 12845 + if (!bufsize) goto end; 12846 + *buflen = 0; 12847 + /* copy the cpability data excluding cap ID and next ptr */ 12848 + cap_ptr += 2; 12849 + if ((bufsize + cap_ptr) > SZPCR) 12850 + bufsize = SZPCR - cap_ptr; 12851 + *buflen = bufsize; 12852 + while (bufsize--) { 12853 + *buf = read_pci_cfg_byte(cap_ptr); 12854 + cap_ptr++; 12855 + buf++; 12856 + } 12857 + } 12858 +end: 12859 + return TRUE; 12860 +} 12861 + 12862 +/* return TRUE if PCIE capability exists the pci config space */ 12863 +static inline bool 12864 +sb_ispcie(sb_info_t *si) 12865 +{ 12866 + return (sb_find_pci_capability(si, PCI_CAP_PCIECAP_ID, NULL, NULL)); 12867 +} 12868 + 12869 +/* scan the sb enumerated space to identify all cores */ 12870 +static void 12871 +BCMINITFN(sb_scan)(sb_info_t *si) 12872 +{ 12873 + uint origidx; 12874 + uint i; 12875 + bool pci; 12876 + bool pcie; 12877 + uint pciidx; 12878 + uint pcieidx; 12879 + uint pcirev; 12880 + uint pcierev; 12881 + 12882 + 12883 + /* numcores should already be set */ 12884 + ASSERT((si->numcores > 0) && (si->numcores <= SB_MAXCORES)); 12885 + 12886 + /* save current core index */ 12887 + origidx = sb_coreidx(&si->sb); 12888 + 12889 + si->sb.buscorerev = NOREV; 12890 + si->sb.buscoreidx = BADIDX; 12891 + 12892 + si->gpioidx = BADIDX; 12893 + 12894 + pci = pcie = FALSE; 12895 + pcirev = pcierev = NOREV; 12896 + pciidx = pcieidx = BADIDX; 12897 + 12898 + for (i = 0; i < si->numcores; i++) { 12899 + sb_setcoreidx(&si->sb, i); 12900 + si->coreid[i] = sb_coreid(&si->sb); 12901 + 12902 + if (si->coreid[i] == SB_PCI) { 12903 + pciidx = i; 12904 + pcirev = sb_corerev(&si->sb); 12905 + pci = TRUE; 12906 + } else if (si->coreid[i] == SB_PCIE) { 12907 + pcieidx = i; 12908 + pcierev = sb_corerev(&si->sb); 12909 + pcie = TRUE; 12910 + } else if (si->coreid[i] == SB_PCMCIA) { 12911 + si->sb.buscorerev = sb_corerev(&si->sb); 12912 + si->sb.buscoretype = si->coreid[i]; 12913 + si->sb.buscoreidx = i; 12914 + } 12915 + } 12916 + if (pci && pcie) { 12917 + if (sb_ispcie(si)) 12918 + pci = FALSE; 12919 + else 12920 + pcie = FALSE; 12921 + } 12922 + if (pci) { 12923 + si->sb.buscoretype = SB_PCI; 12924 + si->sb.buscorerev = pcirev; 12925 + si->sb.buscoreidx = pciidx; 12926 + } else if (pcie) { 12927 + si->sb.buscoretype = SB_PCIE; 12928 + si->sb.buscorerev = pcierev; 12929 + si->sb.buscoreidx = pcieidx; 12930 + } 12931 + 12932 + /* 12933 + * Find the gpio "controlling core" type and index. 12934 + * Precedence: 12935 + * - if there's a chip common core - use that 12936 + * - else if there's a pci core (rev >= 2) - use that 12937 + * - else there had better be an extif core (4710 only) 12938 + */ 12939 + if (GOODIDX(sb_findcoreidx(si, SB_CC, 0))) { 12940 + si->gpioidx = sb_findcoreidx(si, SB_CC, 0); 12941 + si->gpioid = SB_CC; 12942 + } else if (PCI(si) && (si->sb.buscorerev >= 2)) { 12943 + si->gpioidx = si->sb.buscoreidx; 12944 + si->gpioid = SB_PCI; 12945 + } else if (sb_findcoreidx(si, SB_EXTIF, 0)) { 12946 + si->gpioidx = sb_findcoreidx(si, SB_EXTIF, 0); 12947 + si->gpioid = SB_EXTIF; 12948 + } else 12949 + ASSERT(si->gpioidx != BADIDX); 12950 + 12951 + /* return to original core index */ 12952 + sb_setcoreidx(&si->sb, origidx); 12953 +} 12954 + 12955 +/* may be called with core in reset */ 12956 +void 12957 +sb_detach(sb_t *sbh) 12958 +{ 12959 + sb_info_t *si; 12960 + uint idx; 12961 + 12962 + si = SB_INFO(sbh); 12963 + 12964 + if (si == NULL) 12965 + return; 12966 + 12967 + if (BUSTYPE(si->sb.bustype) == SB_BUS) 12968 + for (idx = 0; idx < SB_MAXCORES; idx++) 12969 + if (si->regs[idx]) { 12970 + REG_UNMAP(si->regs[idx]); 12971 + si->regs[idx] = NULL; 12972 + } 12973 +#if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SB_BUS) 12974 + if (si != &ksi) 12975 +#endif /* !BCMBUSTYPE || (BCMBUSTYPE == SB_BUS) */ 12976 + MFREE(si->osh, si, sizeof(sb_info_t)); 12977 + 12978 +} 12979 + 12980 +/* use pci dev id to determine chip id for chips not having a chipcommon core */ 12981 +static uint 12982 +BCMINITFN(sb_pcidev2chip)(uint pcidev) 12983 +{ 12984 + if ((pcidev >= BCM4710_DEVICE_ID) && (pcidev <= BCM47XX_USB_ID)) 12985 + return (BCM4710_CHIP_ID); 12986 + if ((pcidev >= BCM4402_ENET_ID) && (pcidev <= BCM4402_V90_ID)) 12987 + return (BCM4402_CHIP_ID); 12988 + if (pcidev == BCM4401_ENET_ID) 12989 + return (BCM4402_CHIP_ID); 12990 + 12991 + return (0); 12992 +} 12993 + 12994 +/* convert chip number to number of i/o cores */ 12995 +static uint 12996 +BCMINITFN(sb_chip2numcores)(uint chip) 12997 +{ 12998 + if (chip == BCM4710_CHIP_ID) 12999 + return (9); 13000 + if (chip == BCM4402_CHIP_ID) 13001 + return (3); 13002 + if (chip == BCM4306_CHIP_ID) /* < 4306c0 */ 13003 + return (6); 13004 + if (chip == BCM4704_CHIP_ID) 13005 + return (9); 13006 + if (chip == BCM5365_CHIP_ID) 13007 + return (7); 13008 + 13009 + SB_ERROR(("sb_chip2numcores: unsupported chip 0x%x\n", chip)); 13010 + ASSERT(0); 13011 + return (1); 13012 +} 13013 + 13014 +/* return index of coreid or BADIDX if not found */ 13015 +static uint 13016 +sb_findcoreidx(sb_info_t *si, uint coreid, uint coreunit) 13017 +{ 13018 + uint found; 13019 + uint i; 13020 + 13021 + found = 0; 13022 + 13023 + for (i = 0; i < si->numcores; i++) 13024 + if (si->coreid[i] == coreid) { 13025 + if (found == coreunit) 13026 + return (i); 13027 + found++; 13028 + } 13029 + 13030 + return (BADIDX); 13031 +} 13032 + 13033 +/* 13034 + * this function changes logical "focus" to the indiciated core, 13035 + * must be called with interrupt off. 13036 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core 13037 + */ 13038 +void* 13039 +sb_setcoreidx(sb_t *sbh, uint coreidx) 13040 +{ 13041 + sb_info_t *si; 13042 + uint32 sbaddr; 13043 + uint8 tmp; 13044 + 13045 + si = SB_INFO(sbh); 13046 + 13047 + if (coreidx >= si->numcores) 13048 + return (NULL); 13049 + 13050 + /* 13051 + * If the user has provided an interrupt mask enabled function, 13052 + * then assert interrupts are disabled before switching the core. 13053 + */ 13054 + ASSERT((si->intrsenabled_fn == NULL) || !(*(si)->intrsenabled_fn)((si)->intr_arg)); 13055 + 13056 + sbaddr = SB_ENUM_BASE + (coreidx * SB_CORE_SIZE); 13057 + 13058 + switch (BUSTYPE(si->sb.bustype)) { 13059 + case SB_BUS: 13060 + /* map new one */ 13061 + if (!si->regs[coreidx]) { 13062 + si->regs[coreidx] = (void*)REG_MAP(sbaddr, SB_CORE_SIZE); 13063 + ASSERT(GOODREGS(si->regs[coreidx])); 13064 + } 13065 + si->curmap = si->regs[coreidx]; 13066 + break; 13067 + 13068 + case PCI_BUS: 13069 + /* point bar0 window */ 13070 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, 4, sbaddr); 13071 + break; 13072 + 13073 + case PCMCIA_BUS: 13074 + tmp = (sbaddr >> 12) & 0x0f; 13075 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1); 13076 + tmp = (sbaddr >> 16) & 0xff; 13077 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1); 13078 + tmp = (sbaddr >> 24) & 0xff; 13079 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1); 13080 + break; 13081 +#ifdef BCMJTAG 13082 + case JTAG_BUS: 13083 + /* map new one */ 13084 + if (!si->regs[coreidx]) { 13085 + si->regs[coreidx] = (void *)sbaddr; 13086 + ASSERT(GOODREGS(si->regs[coreidx])); 13087 + } 13088 + si->curmap = si->regs[coreidx]; 13089 + break; 13090 +#endif /* BCMJTAG */ 13091 + } 13092 + 13093 + si->curidx = coreidx; 13094 + 13095 + return (si->curmap); 13096 +} 13097 + 13098 +/* 13099 + * this function changes logical "focus" to the indiciated core, 13100 + * must be called with interrupt off. 13101 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core 13102 + */ 13103 +void* 13104 +sb_setcore(sb_t *sbh, uint coreid, uint coreunit) 13105 +{ 13106 + sb_info_t *si; 13107 + uint idx; 13108 + 13109 + si = SB_INFO(sbh); 13110 + idx = sb_findcoreidx(si, coreid, coreunit); 13111 + if (!GOODIDX(idx)) 13112 + return (NULL); 13113 + 13114 + return (sb_setcoreidx(sbh, idx)); 13115 +} 13116 + 13117 +/* return chip number */ 13118 +uint 13119 +sb_chip(sb_t *sbh) 13120 +{ 13121 + sb_info_t *si; 13122 + 13123 + si = SB_INFO(sbh); 13124 + return (si->sb.chip); 13125 +} 13126 + 13127 +/* return chip revision number */ 13128 +uint 13129 +sb_chiprev(sb_t *sbh) 13130 +{ 13131 + sb_info_t *si; 13132 + 13133 + si = SB_INFO(sbh); 13134 + return (si->sb.chiprev); 13135 +} 13136 + 13137 +/* return chip common revision number */ 13138 +uint 13139 +sb_chipcrev(sb_t *sbh) 13140 +{ 13141 + sb_info_t *si; 13142 + 13143 + si = SB_INFO(sbh); 13144 + return (si->sb.ccrev); 13145 +} 13146 + 13147 +/* return chip package option */ 13148 +uint 13149 +sb_chippkg(sb_t *sbh) 13150 +{ 13151 + sb_info_t *si; 13152 + 13153 + si = SB_INFO(sbh); 13154 + return (si->sb.chippkg); 13155 +} 13156 + 13157 +/* return PCI core rev. */ 13158 +uint 13159 +sb_pcirev(sb_t *sbh) 13160 +{ 13161 + sb_info_t *si; 13162 + 13163 + si = SB_INFO(sbh); 13164 + return (si->sb.buscorerev); 13165 +} 13166 + 13167 +bool 13168 +BCMINITFN(sb_war16165)(sb_t *sbh) 13169 +{ 13170 + sb_info_t *si; 13171 + 13172 + si = SB_INFO(sbh); 13173 + 13174 + return (PCI(si) && (si->sb.buscorerev <= 10)); 13175 +} 13176 + 13177 +static void 13178 +BCMINITFN(sb_war30841)(sb_info_t *si) 13179 +{ 13180 + sb_pcie_mdiowrite(si, MDIODATA_DEV_RX, SERDES_RX_TIMER1, 0x8128); 13181 + sb_pcie_mdiowrite(si, MDIODATA_DEV_RX, SERDES_RX_CDR, 0x0100); 13182 + sb_pcie_mdiowrite(si, MDIODATA_DEV_RX, SERDES_RX_CDRBW, 0x1466); 13183 +} 13184 + 13185 +/* return PCMCIA core rev. */ 13186 +uint 13187 +BCMINITFN(sb_pcmciarev)(sb_t *sbh) 13188 +{ 13189 + sb_info_t *si; 13190 + 13191 + si = SB_INFO(sbh); 13192 + return (si->sb.buscorerev); 13193 +} 13194 + 13195 +/* return board vendor id */ 13196 +uint 13197 +sb_boardvendor(sb_t *sbh) 13198 +{ 13199 + sb_info_t *si; 13200 + 13201 + si = SB_INFO(sbh); 13202 + return (si->sb.boardvendor); 13203 +} 13204 + 13205 +/* return boardtype */ 13206 +uint 13207 +sb_boardtype(sb_t *sbh) 13208 +{ 13209 + sb_info_t *si; 13210 + char *var; 13211 + 13212 + si = SB_INFO(sbh); 13213 + 13214 + if (BUSTYPE(si->sb.bustype) == SB_BUS && si->sb.boardtype == 0xffff) { 13215 + /* boardtype format is a hex string */ 13216 + si->sb.boardtype = getintvar(NULL, "boardtype"); 13217 + 13218 + /* backward compatibility for older boardtype string format */ 13219 + if ((si->sb.boardtype == 0) && (var = getvar(NULL, "boardtype"))) { 13220 + if (!strcmp(var, "bcm94710dev")) 13221 + si->sb.boardtype = BCM94710D_BOARD; 13222 + else if (!strcmp(var, "bcm94710ap")) 13223 + si->sb.boardtype = BCM94710AP_BOARD; 13224 + else if (!strcmp(var, "bu4710")) 13225 + si->sb.boardtype = BU4710_BOARD; 13226 + else if (!strcmp(var, "bcm94702mn")) 13227 + si->sb.boardtype = BCM94702MN_BOARD; 13228 + else if (!strcmp(var, "bcm94710r1")) 13229 + si->sb.boardtype = BCM94710R1_BOARD; 13230 + else if (!strcmp(var, "bcm94710r4")) 13231 + si->sb.boardtype = BCM94710R4_BOARD; 13232 + else if (!strcmp(var, "bcm94702cpci")) 13233 + si->sb.boardtype = BCM94702CPCI_BOARD; 13234 + else if (!strcmp(var, "bcm95380_rr")) 13235 + si->sb.boardtype = BCM95380RR_BOARD; 13236 + } 13237 + } 13238 + 13239 + return (si->sb.boardtype); 13240 +} 13241 + 13242 +/* return bus type of sbh device */ 13243 +uint 13244 +sb_bus(sb_t *sbh) 13245 +{ 13246 + sb_info_t *si; 13247 + 13248 + si = SB_INFO(sbh); 13249 + return (si->sb.bustype); 13250 +} 13251 + 13252 +/* return bus core type */ 13253 +uint 13254 +sb_buscoretype(sb_t *sbh) 13255 +{ 13256 + sb_info_t *si; 13257 + 13258 + si = SB_INFO(sbh); 13259 + 13260 + return (si->sb.buscoretype); 13261 +} 13262 + 13263 +/* return bus core revision */ 13264 +uint 13265 +sb_buscorerev(sb_t *sbh) 13266 +{ 13267 + sb_info_t *si; 13268 + si = SB_INFO(sbh); 13269 + 13270 + return (si->sb.buscorerev); 13271 +} 13272 + 13273 +/* return list of found cores */ 13274 +uint 13275 +sb_corelist(sb_t *sbh, uint coreid[]) 13276 +{ 13277 + sb_info_t *si; 13278 + 13279 + si = SB_INFO(sbh); 13280 + 13281 + bcopy((uchar*)si->coreid, (uchar*)coreid, (si->numcores * sizeof(uint))); 13282 + return (si->numcores); 13283 +} 13284 + 13285 +/* return current register mapping */ 13286 +void * 13287 +sb_coreregs(sb_t *sbh) 13288 +{ 13289 + sb_info_t *si; 13290 + 13291 + si = SB_INFO(sbh); 13292 + ASSERT(GOODREGS(si->curmap)); 13293 + 13294 + return (si->curmap); 13295 +} 13296 + 13297 + 13298 +/* do buffered registers update */ 13299 +void 13300 +sb_commit(sb_t *sbh) 13301 +{ 13302 + sb_info_t *si; 13303 + uint origidx; 13304 + uint intr_val = 0; 13305 + 13306 + si = SB_INFO(sbh); 13307 + 13308 + origidx = si->curidx; 13309 + ASSERT(GOODIDX(origidx)); 13310 + 13311 + INTR_OFF(si, intr_val); 13312 + 13313 + /* switch over to chipcommon core if there is one, else use pci */ 13314 + if (si->sb.ccrev != NOREV) { 13315 + chipcregs_t *ccregs = (chipcregs_t *)sb_setcore(sbh, SB_CC, 0); 13316 + 13317 + /* do the buffer registers update */ 13318 + W_REG(si->osh, &ccregs->broadcastaddress, SB_COMMIT); 13319 + W_REG(si->osh, &ccregs->broadcastdata, 0x0); 13320 + } else if (PCI(si)) { 13321 + sbpciregs_t *pciregs = (sbpciregs_t *)sb_setcore(sbh, SB_PCI, 0); 13322 + 13323 + /* do the buffer registers update */ 13324 + W_REG(si->osh, &pciregs->bcastaddr, SB_COMMIT); 13325 + W_REG(si->osh, &pciregs->bcastdata, 0x0); 13326 + } else 13327 + ASSERT(0); 13328 + 13329 + /* restore core index */ 13330 + sb_setcoreidx(sbh, origidx); 13331 + INTR_RESTORE(si, intr_val); 13332 +} 13333 + 13334 +/* reset and re-enable a core 13335 + * inputs: 13336 + * bits - core specific bits that are set during and after reset sequence 13337 + * resetbits - core specific bits that are set only during reset sequence 13338 + */ 13339 +void 13340 +sb_core_reset(sb_t *sbh, uint32 bits, uint32 resetbits) 13341 +{ 13342 + sb_info_t *si; 13343 + sbconfig_t *sb; 13344 + volatile uint32 dummy; 13345 + 13346 + si = SB_INFO(sbh); 13347 + ASSERT(GOODREGS(si->curmap)); 13348 + sb = REGS2SB(si->curmap); 13349 + 13350 + /* 13351 + * Must do the disable sequence first to work for arbitrary current core state. 13352 + */ 13353 + sb_core_disable(sbh, (bits | resetbits)); 13354 + 13355 + /* 13356 + * Now do the initialization sequence. 13357 + */ 13358 + 13359 + /* set reset while enabling the clock and forcing them on throughout the core */ 13360 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | SBTML_RESET | bits | resetbits)); 13361 + dummy = R_SBREG(si, &sb->sbtmstatelow); 13362 + OSL_DELAY(1); 13363 + 13364 + if (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_SERR) { 13365 + W_SBREG(si, &sb->sbtmstatehigh, 0); 13366 + } 13367 + if ((dummy = R_SBREG(si, &sb->sbimstate)) & (SBIM_IBE | SBIM_TO)) { 13368 + AND_SBREG(si, &sb->sbimstate, ~(SBIM_IBE | SBIM_TO)); 13369 + } 13370 + 13371 + /* clear reset and allow it to propagate throughout the core */ 13372 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | bits)); 13373 + dummy = R_SBREG(si, &sb->sbtmstatelow); 13374 + OSL_DELAY(1); 13375 + 13376 + /* leave clock enabled */ 13377 + W_SBREG(si, &sb->sbtmstatelow, (SBTML_CLK | bits)); 13378 + dummy = R_SBREG(si, &sb->sbtmstatelow); 13379 + OSL_DELAY(1); 13380 +} 13381 + 13382 +void 13383 +sb_core_tofixup(sb_t *sbh) 13384 +{ 13385 + sb_info_t *si; 13386 + sbconfig_t *sb; 13387 + 13388 + si = SB_INFO(sbh); 13389 + 13390 + if ((BUSTYPE(si->sb.bustype) != PCI_BUS) || PCIE(si) || 13391 + (PCI(si) && (si->sb.buscorerev >= 5))) 13392 + return; 13393 + 13394 + ASSERT(GOODREGS(si->curmap)); 13395 + sb = REGS2SB(si->curmap); 13396 + 13397 + if (BUSTYPE(si->sb.bustype) == SB_BUS) { 13398 + SET_SBREG(si, &sb->sbimconfiglow, 13399 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK, 13400 + (0x5 << SBIMCL_RTO_SHIFT) | 0x3); 13401 + } else { 13402 + if (sb_coreid(sbh) == SB_PCI) { 13403 + SET_SBREG(si, &sb->sbimconfiglow, 13404 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK, 13405 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2); 13406 + } else { 13407 + SET_SBREG(si, &sb->sbimconfiglow, (SBIMCL_RTO_MASK | SBIMCL_STO_MASK), 0); 13408 + } 13409 + } 13410 + 13411 + sb_commit(sbh); 13412 +} 13413 + 13414 +/* 13415 + * Set the initiator timeout for the "master core". 13416 + * The master core is defined to be the core in control 13417 + * of the chip and so it issues accesses to non-memory 13418 + * locations (Because of dma *any* core can access memeory). 13419 + * 13420 + * The routine uses the bus to decide who is the master: 13421 + * SB_BUS => mips 13422 + * JTAG_BUS => chipc 13423 + * PCI_BUS => pci or pcie 13424 + * PCMCIA_BUS => pcmcia 13425 + * SDIO_BUS => pcmcia 13426 + * 13427 + * This routine exists so callers can disable initiator 13428 + * timeouts so accesses to very slow devices like otp 13429 + * won't cause an abort. The routine allows arbitrary 13430 + * settings of the service and request timeouts, though. 13431 + * 13432 + * Returns the timeout state before changing it or -1 13433 + * on error. 13434 + */ 13435 + 13436 +#define TO_MASK (SBIMCL_RTO_MASK | SBIMCL_STO_MASK) 13437 + 13438 +uint32 13439 +sb_set_initiator_to(sb_t *sbh, uint32 to) 13440 +{ 13441 + sb_info_t *si; 13442 + uint origidx, idx; 13443 + uint intr_val = 0; 13444 + uint32 tmp, ret = 0xffffffff; 13445 + sbconfig_t *sb; 13446 + 13447 + si = SB_INFO(sbh); 13448 + 13449 + if ((to & ~TO_MASK) != 0) 13450 + return ret; 13451 + 13452 + /* Figure out the master core */ 13453 + idx = BADIDX; 13454 + switch (BUSTYPE(si->sb.bustype)) { 13455 + case PCI_BUS: 13456 + idx = si->sb.buscoreidx; 13457 + break; 13458 + case JTAG_BUS: 13459 + idx = SB_CC_IDX; 13460 + break; 13461 + case PCMCIA_BUS: 13462 + case SDIO_BUS: 13463 + idx = sb_findcoreidx(si, SB_PCMCIA, 0); 13464 + break; 13465 + case SB_BUS: 13466 + if ((idx = sb_findcoreidx(si, SB_MIPS33, 0)) == BADIDX) 13467 + idx = sb_findcoreidx(si, SB_MIPS, 0); 13468 + break; 13469 + default: 13470 + ASSERT(0); 13471 + } 13472 + if (idx == BADIDX) 13473 + return ret; 13474 + 13475 + INTR_OFF(si, intr_val); 13476 + origidx = sb_coreidx(sbh); 13477 + 13478 + sb = REGS2SB(sb_setcoreidx(sbh, idx)); 13479 + 13480 + tmp = R_SBREG(si, &sb->sbimconfiglow); 13481 + ret = tmp & TO_MASK; 13482 + W_SBREG(si, &sb->sbimconfiglow, (tmp & ~TO_MASK) | to); 13483 + 13484 + sb_commit(sbh); 13485 + sb_setcoreidx(sbh, origidx); 13486 + INTR_RESTORE(si, intr_val); 13487 + return ret; 13488 +} 13489 + 13490 +void 13491 +sb_core_disable(sb_t *sbh, uint32 bits) 13492 +{ 13493 + sb_info_t *si; 13494 + volatile uint32 dummy; 13495 + uint32 rej; 13496 + sbconfig_t *sb; 13497 + 13498 + si = SB_INFO(sbh); 13499 + 13500 + ASSERT(GOODREGS(si->curmap)); 13501 + sb = REGS2SB(si->curmap); 13502 + 13503 + /* if core is already in reset, just return */ 13504 + if (R_SBREG(si, &sb->sbtmstatelow) & SBTML_RESET) 13505 + return; 13506 + 13507 + /* reject value changed between sonics 2.2 and 2.3 */ 13508 + if (si->sb.sonicsrev == SONICS_2_2) 13509 + rej = (1 << SBTML_REJ_SHIFT); 13510 + else 13511 + rej = (2 << SBTML_REJ_SHIFT); 13512 + 13513 + /* if clocks are not enabled, put into reset and return */ 13514 + if ((R_SBREG(si, &sb->sbtmstatelow) & SBTML_CLK) == 0) 13515 + goto disable; 13516 + 13517 + /* set target reject and spin until busy is clear (preserve core-specific bits) */ 13518 + OR_SBREG(si, &sb->sbtmstatelow, rej); 13519 + dummy = R_SBREG(si, &sb->sbtmstatelow); 13520 + OSL_DELAY(1); 13521 + SPINWAIT((R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_BUSY), 100000); 13522 + if (R_SBREG(si, &sb->sbtmstatehigh) & SBTMH_BUSY) 13523 + SB_ERROR(("%s: target state still busy\n", __FUNCTION__)); 13524 + 13525 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT) { 13526 + OR_SBREG(si, &sb->sbimstate, SBIM_RJ); 13527 + dummy = R_SBREG(si, &sb->sbimstate); 13528 + OSL_DELAY(1); 13529 + SPINWAIT((R_SBREG(si, &sb->sbimstate) & SBIM_BY), 100000); 13530 + } 13531 + 13532 + /* set reset and reject while enabling the clocks */ 13533 + W_SBREG(si, &sb->sbtmstatelow, (bits | SBTML_FGC | SBTML_CLK | rej | SBTML_RESET)); 13534 + dummy = R_SBREG(si, &sb->sbtmstatelow); 13535 + OSL_DELAY(10); 13536 + 13537 + /* don't forget to clear the initiator reject bit */ 13538 + if (R_SBREG(si, &sb->sbidlow) & SBIDL_INIT) 13539 + AND_SBREG(si, &sb->sbimstate, ~SBIM_RJ); 13540 + 13541 +disable: 13542 + /* leave reset and reject asserted */ 13543 + W_SBREG(si, &sb->sbtmstatelow, (bits | rej | SBTML_RESET)); 13544 + OSL_DELAY(1); 13545 +} 13546 + 13547 +/* set chip watchdog reset timer to fire in 'ticks' backplane cycles */ 13548 +void 13549 +sb_watchdog(sb_t *sbh, uint ticks) 13550 +{ 13551 + sb_info_t *si = SB_INFO(sbh); 13552 + 13553 + /* make sure we come up in fast clock mode */ 13554 + sb_clkctl_clk(sbh, CLK_FAST); 13555 + 13556 + /* instant NMI */ 13557 + switch (si->gpioid) { 13558 + case SB_CC: 13559 +#ifdef __mips__ 13560 + if (sb_chip(sbh) == BCM4785_CHIP_ID && ticks <= 1) 13561 + MTC0(C0_BROADCOM, 4, (1 << 22)); 13562 +#endif /* __mips__ */ 13563 + sb_corereg(si, 0, OFFSETOF(chipcregs_t, watchdog), ~0, ticks); 13564 +#ifdef __mips__ 13565 + if (sb_chip(sbh) == BCM4785_CHIP_ID && ticks <= 1) { 13566 + __asm__ __volatile__ ( 13567 + ".set\tmips3\n\t" 13568 + "sync\n\t" 13569 + "wait\n\t" 13570 + ".set\tmips0" 13571 + ); 13572 + while (1); 13573 + } 13574 +#endif /* __mips__ */ 13575 + break; 13576 + case SB_EXTIF: 13577 + sb_corereg(si, si->gpioidx, OFFSETOF(extifregs_t, watchdog), ~0, ticks); 13578 + break; 13579 + } 13580 +} 13581 + 13582 +/* initialize the pcmcia core */ 13583 +void 13584 +sb_pcmcia_init(sb_t *sbh) 13585 +{ 13586 + sb_info_t *si; 13587 + uint8 cor = 0; 13588 + 13589 + si = SB_INFO(sbh); 13590 + 13591 + /* enable d11 mac interrupts */ 13592 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1); 13593 + cor |= COR_IRQEN | COR_FUNEN; 13594 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1); 13595 + 13596 +} 13597 + 13598 + 13599 +/* 13600 + * Configure the pci core for pci client (NIC) action 13601 + * coremask is the bitvec of cores by index to be enabled. 13602 + */ 13603 +void 13604 +BCMINITFN(sb_pci_setup)(sb_t *sbh, uint coremask) 13605 +{ 13606 + sb_info_t *si; 13607 + sbconfig_t *sb; 13608 + sbpciregs_t *pciregs; 13609 + uint32 sbflag; 13610 + uint32 w; 13611 + uint idx; 13612 + int reg_val; 13613 + 13614 + si = SB_INFO(sbh); 13615 + 13616 + /* if not pci bus, we're done */ 13617 + if (BUSTYPE(si->sb.bustype) != PCI_BUS) 13618 + return; 13619 + 13620 + ASSERT(PCI(si) || PCIE(si)); 13621 + ASSERT(si->sb.buscoreidx != BADIDX); 13622 + 13623 + /* get current core index */ 13624 + idx = si->curidx; 13625 + 13626 + /* we interrupt on this backplane flag number */ 13627 + ASSERT(GOODREGS(si->curmap)); 13628 + sb = REGS2SB(si->curmap); 13629 + sbflag = R_SBREG(si, &sb->sbtpsflag) & SBTPS_NUM0_MASK; 13630 + 13631 + /* switch over to pci core */ 13632 + pciregs = (sbpciregs_t*) sb_setcoreidx(sbh, si->sb.buscoreidx); 13633 + sb = REGS2SB(pciregs); 13634 + 13635 + /* 13636 + * Enable sb->pci interrupts. Assume 13637 + * PCI rev 2.3 support was added in pci core rev 6 and things changed.. 13638 + */ 13639 + if (PCIE(si) || (PCI(si) && ((si->sb.buscorerev) >= 6))) { 13640 + /* pci config write to set this core bit in PCIIntMask */ 13641 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32)); 13642 + w |= (coremask << PCI_SBIM_SHIFT); 13643 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32), w); 13644 + } else { 13645 + /* set sbintvec bit for our flag number */ 13646 + OR_SBREG(si, &sb->sbintvec, (1 << sbflag)); 13647 + } 13648 + 13649 + if (PCI(si)) { 13650 + OR_REG(si->osh, &pciregs->sbtopci2, (SBTOPCI_PREF|SBTOPCI_BURST)); 13651 + if (si->sb.buscorerev >= 11) 13652 + OR_REG(si->osh, &pciregs->sbtopci2, SBTOPCI_RC_READMULTI); 13653 + if (si->sb.buscorerev < 5) { 13654 + SET_SBREG(si, &sb->sbimconfiglow, SBIMCL_RTO_MASK | SBIMCL_STO_MASK, 13655 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2); 13656 + sb_commit(sbh); 13657 + } 13658 + } 13659 + 13660 +#ifdef PCIE_SUPPOER 13661 + /* PCIE workarounds */ 13662 + if (PCIE(si)) { 13663 + if ((si->sb.buscorerev == 0) || (si->sb.buscorerev == 1)) { 13664 + reg_val = sb_pcie_readreg((void *)sbh, (void *)PCIE_PCIEREGS, 13665 + PCIE_TLP_WORKAROUNDSREG); 13666 + reg_val |= 0x8; 13667 + sb_pcie_writereg((void *)sbh, (void *)PCIE_PCIEREGS, 13668 + PCIE_TLP_WORKAROUNDSREG, reg_val); 13669 + } 13670 + 13671 + if (si->sb.buscorerev == 1) { 13672 + reg_val = sb_pcie_readreg((void *)sbh, (void *)PCIE_PCIEREGS, 13673 + PCIE_DLLP_LCREG); 13674 + reg_val |= (0x40); 13675 + sb_pcie_writereg(sbh, (void *)PCIE_PCIEREGS, PCIE_DLLP_LCREG, reg_val); 13676 + } 13677 + 13678 + if (si->sb.buscorerev == 0) 13679 + sb_war30841(si); 13680 + } 13681 +#endif 13682 + 13683 + /* switch back to previous core */ 13684 + sb_setcoreidx(sbh, idx); 13685 +} 13686 + 13687 +uint32 13688 +sb_base(uint32 admatch) 13689 +{ 13690 + uint32 base; 13691 + uint type; 13692 + 13693 + type = admatch & SBAM_TYPE_MASK; 13694 + ASSERT(type < 3); 13695 + 13696 + base = 0; 13697 + 13698 + if (type == 0) { 13699 + base = admatch & SBAM_BASE0_MASK; 13700 + } else if (type == 1) { 13701 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */ 13702 + base = admatch & SBAM_BASE1_MASK; 13703 + } else if (type == 2) { 13704 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */ 13705 + base = admatch & SBAM_BASE2_MASK; 13706 + } 13707 + 13708 + return (base); 13709 +} 13710 + 13711 +uint32 13712 +sb_size(uint32 admatch) 13713 +{ 13714 + uint32 size; 13715 + uint type; 13716 + 13717 + type = admatch & SBAM_TYPE_MASK; 13718 + ASSERT(type < 3); 13719 + 13720 + size = 0; 13721 + 13722 + if (type == 0) { 13723 + size = 1 << (((admatch & SBAM_ADINT0_MASK) >> SBAM_ADINT0_SHIFT) + 1); 13724 + } else if (type == 1) { 13725 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */ 13726 + size = 1 << (((admatch & SBAM_ADINT1_MASK) >> SBAM_ADINT1_SHIFT) + 1); 13727 + } else if (type == 2) { 13728 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */ 13729 + size = 1 << (((admatch & SBAM_ADINT2_MASK) >> SBAM_ADINT2_SHIFT) + 1); 13730 + } 13731 + 13732 + return (size); 13733 +} 13734 + 13735 +/* return the core-type instantiation # of the current core */ 13736 +uint 13737 +sb_coreunit(sb_t *sbh) 13738 +{ 13739 + sb_info_t *si; 13740 + uint idx; 13741 + uint coreid; 13742 + uint coreunit; 13743 + uint i; 13744 + 13745 + si = SB_INFO(sbh); 13746 + coreunit = 0; 13747 + 13748 + idx = si->curidx; 13749 + 13750 + ASSERT(GOODREGS(si->curmap)); 13751 + coreid = sb_coreid(sbh); 13752 + 13753 + /* count the cores of our type */ 13754 + for (i = 0; i < idx; i++) 13755 + if (si->coreid[i] == coreid) 13756 + coreunit++; 13757 + 13758 + return (coreunit); 13759 +} 13760 + 13761 +static INLINE uint32 13762 +factor6(uint32 x) 13763 +{ 13764 + switch (x) { 13765 + case CC_F6_2: return 2; 13766 + case CC_F6_3: return 3; 13767 + case CC_F6_4: return 4; 13768 + case CC_F6_5: return 5; 13769 + case CC_F6_6: return 6; 13770 + case CC_F6_7: return 7; 13771 + default: return 0; 13772 + } 13773 +} 13774 + 13775 +/* calculate the speed the SB would run at given a set of clockcontrol values */ 13776 +uint32 13777 +sb_clock_rate(uint32 pll_type, uint32 n, uint32 m) 13778 +{ 13779 + uint32 n1, n2, clock, m1, m2, m3, mc; 13780 + 13781 + n1 = n & CN_N1_MASK; 13782 + n2 = (n & CN_N2_MASK) >> CN_N2_SHIFT; 13783 + 13784 + if (pll_type == PLL_TYPE6) { 13785 + if (m & CC_T6_MMASK) 13786 + return CC_T6_M1; 13787 + else 13788 + return CC_T6_M0; 13789 + } else if ((pll_type == PLL_TYPE1) || 13790 + (pll_type == PLL_TYPE3) || 13791 + (pll_type == PLL_TYPE4) || 13792 + (pll_type == PLL_TYPE7)) { 13793 + n1 = factor6(n1); 13794 + n2 += CC_F5_BIAS; 13795 + } else if (pll_type == PLL_TYPE2) { 13796 + n1 += CC_T2_BIAS; 13797 + n2 += CC_T2_BIAS; 13798 + ASSERT((n1 >= 2) && (n1 <= 7)); 13799 + ASSERT((n2 >= 5) && (n2 <= 23)); 13800 + } else if (pll_type == PLL_TYPE5) { 13801 + return (100000000); 13802 + } else 13803 + ASSERT(0); 13804 + /* PLL types 3 and 7 use BASE2 (25Mhz) */ 13805 + if ((pll_type == PLL_TYPE3) || 13806 + (pll_type == PLL_TYPE7)) { 13807 + clock = CC_CLOCK_BASE2 * n1 * n2; 13808 + } else 13809 + clock = CC_CLOCK_BASE1 * n1 * n2; 13810 + 13811 + if (clock == 0) 13812 + return 0; 13813 + 13814 + m1 = m & CC_M1_MASK; 13815 + m2 = (m & CC_M2_MASK) >> CC_M2_SHIFT; 13816 + m3 = (m & CC_M3_MASK) >> CC_M3_SHIFT; 13817 + mc = (m & CC_MC_MASK) >> CC_MC_SHIFT; 13818 + 13819 + if ((pll_type == PLL_TYPE1) || 13820 + (pll_type == PLL_TYPE3) || 13821 + (pll_type == PLL_TYPE4) || 13822 + (pll_type == PLL_TYPE7)) { 13823 + m1 = factor6(m1); 13824 + if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE3)) 13825 + m2 += CC_F5_BIAS; 13826 + else 13827 + m2 = factor6(m2); 13828 + m3 = factor6(m3); 13829 + 13830 + switch (mc) { 13831 + case CC_MC_BYPASS: return (clock); 13832 + case CC_MC_M1: return (clock / m1); 13833 + case CC_MC_M1M2: return (clock / (m1 * m2)); 13834 + case CC_MC_M1M2M3: return (clock / (m1 * m2 * m3)); 13835 + case CC_MC_M1M3: return (clock / (m1 * m3)); 13836 + default: return (0); 13837 + } 13838 + } else { 13839 + ASSERT(pll_type == PLL_TYPE2); 13840 + 13841 + m1 += CC_T2_BIAS; 13842 + m2 += CC_T2M2_BIAS; 13843 + m3 += CC_T2_BIAS; 13844 + ASSERT((m1 >= 2) && (m1 <= 7)); 13845 + ASSERT((m2 >= 3) && (m2 <= 10)); 13846 + ASSERT((m3 >= 2) && (m3 <= 7)); 13847 + 13848 + if ((mc & CC_T2MC_M1BYP) == 0) 13849 + clock /= m1; 13850 + if ((mc & CC_T2MC_M2BYP) == 0) 13851 + clock /= m2; 13852 + if ((mc & CC_T2MC_M3BYP) == 0) 13853 + clock /= m3; 13854 + 13855 + return (clock); 13856 + } 13857 +} 13858 + 13859 +/* returns the current speed the SB is running at */ 13860 +uint32 13861 +sb_clock(sb_t *sbh) 13862 +{ 13863 + sb_info_t *si; 13864 + extifregs_t *eir; 13865 + chipcregs_t *cc; 13866 + uint32 n, m; 13867 + uint idx; 13868 + uint32 pll_type, rate; 13869 + uint intr_val = 0; 13870 + 13871 + si = SB_INFO(sbh); 13872 + idx = si->curidx; 13873 + pll_type = PLL_TYPE1; 13874 + 13875 + INTR_OFF(si, intr_val); 13876 + 13877 + /* switch to extif or chipc core */ 13878 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) { 13879 + n = R_REG(si->osh, &eir->clockcontrol_n); 13880 + m = R_REG(si->osh, &eir->clockcontrol_sb); 13881 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) { 13882 + pll_type = R_REG(si->osh, &cc->capabilities) & CAP_PLL_MASK; 13883 + if (pll_type == PLL_NONE) { 13884 + INTR_RESTORE(si, intr_val); 13885 + return 80000000; 13886 + } 13887 + n = R_REG(si->osh, &cc->clockcontrol_n); 13888 + if (pll_type == PLL_TYPE6) 13889 + m = R_REG(si->osh, &cc->clockcontrol_m3); 13890 + else if ((pll_type == PLL_TYPE3) && !(BCMINIT(sb_chip)(sbh) == 0x5365)) 13891 + m = R_REG(si->osh, &cc->clockcontrol_m2); 13892 + else 13893 + m = R_REG(si->osh, &cc->clockcontrol_sb); 13894 + } else { 13895 + INTR_RESTORE(si, intr_val); 13896 + return 0; 13897 + } 13898 + 13899 + /* calculate rate */ 13900 + if (BCMINIT(sb_chip)(sbh) == 0x5365) 13901 + rate = 100000000; 13902 + else { 13903 + rate = sb_clock_rate(pll_type, n, m); 13904 + 13905 + if (pll_type == PLL_TYPE3) 13906 + rate = rate / 2; 13907 + } 13908 + 13909 + /* switch back to previous core */ 13910 + sb_setcoreidx(sbh, idx); 13911 + 13912 + INTR_RESTORE(si, intr_val); 13913 + 13914 + return rate; 13915 +} 13916 + 13917 +/* change logical "focus" to the gpio core for optimized access */ 13918 +void* 13919 +sb_gpiosetcore(sb_t *sbh) 13920 +{ 13921 + sb_info_t *si; 13922 + 13923 + si = SB_INFO(sbh); 13924 + 13925 + return (sb_setcoreidx(sbh, si->gpioidx)); 13926 +} 13927 + 13928 +/* mask&set gpiocontrol bits */ 13929 +uint32 13930 +sb_gpiocontrol(sb_t *sbh, uint32 mask, uint32 val, uint8 priority) 13931 +{ 13932 + sb_info_t *si; 13933 + uint regoff; 13934 + 13935 + si = SB_INFO(sbh); 13936 + regoff = 0; 13937 + 13938 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */ 13939 + 13940 + /* gpios could be shared on router platforms */ 13941 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) { 13942 + mask = priority ? (sb_gpioreservation & mask) : 13943 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation)); 13944 + val &= mask; 13945 + } 13946 + 13947 + switch (si->gpioid) { 13948 + case SB_CC: 13949 + regoff = OFFSETOF(chipcregs_t, gpiocontrol); 13950 + break; 13951 + 13952 + case SB_PCI: 13953 + regoff = OFFSETOF(sbpciregs_t, gpiocontrol); 13954 + break; 13955 + 13956 + case SB_EXTIF: 13957 + return (0); 13958 + } 13959 + 13960 + return (sb_corereg(si, si->gpioidx, regoff, mask, val)); 13961 +} 13962 + 13963 +/* mask&set gpio output enable bits */ 13964 +uint32 13965 +sb_gpioouten(sb_t *sbh, uint32 mask, uint32 val, uint8 priority) 13966 +{ 13967 + sb_info_t *si; 13968 + uint regoff; 13969 + 13970 + si = SB_INFO(sbh); 13971 + regoff = 0; 13972 + 13973 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */ 13974 + 13975 + /* gpios could be shared on router platforms */ 13976 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) { 13977 + mask = priority ? (sb_gpioreservation & mask) : 13978 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation)); 13979 + val &= mask; 13980 + } 13981 + 13982 + switch (si->gpioid) { 13983 + case SB_CC: 13984 + regoff = OFFSETOF(chipcregs_t, gpioouten); 13985 + break; 13986 + 13987 + case SB_PCI: 13988 + regoff = OFFSETOF(sbpciregs_t, gpioouten); 13989 + break; 13990 + 13991 + case SB_EXTIF: 13992 + regoff = OFFSETOF(extifregs_t, gpio[0].outen); 13993 + break; 13994 + } 13995 + 13996 + return (sb_corereg(si, si->gpioidx, regoff, mask, val)); 13997 +} 13998 + 13999 +/* mask&set gpio output bits */ 14000 +uint32 14001 +sb_gpioout(sb_t *sbh, uint32 mask, uint32 val, uint8 priority) 14002 +{ 14003 + sb_info_t *si; 14004 + uint regoff; 14005 + 14006 + si = SB_INFO(sbh); 14007 + regoff = 0; 14008 + 14009 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */ 14010 + 14011 + /* gpios could be shared on router platforms */ 14012 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) { 14013 + mask = priority ? (sb_gpioreservation & mask) : 14014 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation)); 14015 + val &= mask; 14016 + } 14017 + 14018 + switch (si->gpioid) { 14019 + case SB_CC: 14020 + regoff = OFFSETOF(chipcregs_t, gpioout); 14021 + break; 14022 + 14023 + case SB_PCI: 14024 + regoff = OFFSETOF(sbpciregs_t, gpioout); 14025 + break; 14026 + 14027 + case SB_EXTIF: 14028 + regoff = OFFSETOF(extifregs_t, gpio[0].out); 14029 + break; 14030 + } 14031 + 14032 + return (sb_corereg(si, si->gpioidx, regoff, mask, val)); 14033 +} 14034 + 14035 +/* reserve one gpio */ 14036 +uint32 14037 +sb_gpioreserve(sb_t *sbh, uint32 gpio_bitmask, uint8 priority) 14038 +{ 14039 + sb_info_t *si; 14040 + 14041 + si = SB_INFO(sbh); 14042 + 14043 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */ 14044 + 14045 + /* only cores on SB_BUS share GPIO's and only applcation users need to 14046 + * reserve/release GPIO 14047 + */ 14048 + if ((BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) { 14049 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority)); 14050 + return -1; 14051 + } 14052 + /* make sure only one bit is set */ 14053 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) { 14054 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1))); 14055 + return -1; 14056 + } 14057 + 14058 + /* already reserved */ 14059 + if (sb_gpioreservation & gpio_bitmask) 14060 + return -1; 14061 + /* set reservation */ 14062 + sb_gpioreservation |= gpio_bitmask; 14063 + 14064 + return sb_gpioreservation; 14065 +} 14066 + 14067 +/* release one gpio */ 14068 +/* 14069 + * releasing the gpio doesn't change the current value on the GPIO last write value 14070 + * persists till some one overwrites it 14071 +*/ 14072 + 14073 +uint32 14074 +sb_gpiorelease(sb_t *sbh, uint32 gpio_bitmask, uint8 priority) 14075 +{ 14076 + sb_info_t *si; 14077 + 14078 + si = SB_INFO(sbh); 14079 + 14080 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */ 14081 + 14082 + /* only cores on SB_BUS share GPIO's and only applcation users need to 14083 + * reserve/release GPIO 14084 + */ 14085 + if ((BUSTYPE(si->sb.bustype) != SB_BUS) || (!priority)) { 14086 + ASSERT((BUSTYPE(si->sb.bustype) == SB_BUS) && (priority)); 14087 + return -1; 14088 + } 14089 + /* make sure only one bit is set */ 14090 + if ((!gpio_bitmask) || ((gpio_bitmask) & (gpio_bitmask - 1))) { 14091 + ASSERT((gpio_bitmask) && !((gpio_bitmask) & (gpio_bitmask - 1))); 14092 + return -1; 14093 + } 14094 + 14095 + /* already released */ 14096 + if (!(sb_gpioreservation & gpio_bitmask)) 14097 + return -1; 14098 + 14099 + /* clear reservation */ 14100 + sb_gpioreservation &= ~gpio_bitmask; 14101 + 14102 + return sb_gpioreservation; 14103 +} 14104 + 14105 +/* return the current gpioin register value */ 14106 +uint32 14107 +sb_gpioin(sb_t *sbh) 14108 +{ 14109 + sb_info_t *si; 14110 + uint regoff; 14111 + 14112 + si = SB_INFO(sbh); 14113 + regoff = 0; 14114 + 14115 + switch (si->gpioid) { 14116 + case SB_CC: 14117 + regoff = OFFSETOF(chipcregs_t, gpioin); 14118 + break; 14119 + 14120 + case SB_PCI: 14121 + regoff = OFFSETOF(sbpciregs_t, gpioin); 14122 + break; 14123 + 14124 + case SB_EXTIF: 14125 + regoff = OFFSETOF(extifregs_t, gpioin); 14126 + break; 14127 + } 14128 + 14129 + return (sb_corereg(si, si->gpioidx, regoff, 0, 0)); 14130 +} 14131 + 14132 +/* mask&set gpio interrupt polarity bits */ 14133 +uint32 14134 +sb_gpiointpolarity(sb_t *sbh, uint32 mask, uint32 val, uint8 priority) 14135 +{ 14136 + sb_info_t *si; 14137 + uint regoff; 14138 + 14139 + si = SB_INFO(sbh); 14140 + regoff = 0; 14141 + 14142 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */ 14143 + 14144 + /* gpios could be shared on router platforms */ 14145 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) { 14146 + mask = priority ? (sb_gpioreservation & mask) : 14147 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation)); 14148 + val &= mask; 14149 + } 14150 + 14151 + switch (si->gpioid) { 14152 + case SB_CC: 14153 + regoff = OFFSETOF(chipcregs_t, gpiointpolarity); 14154 + break; 14155 + 14156 + case SB_PCI: 14157 + /* pci gpio implementation does not support interrupt polarity */ 14158 + ASSERT(0); 14159 + break; 14160 + 14161 + case SB_EXTIF: 14162 + regoff = OFFSETOF(extifregs_t, gpiointpolarity); 14163 + break; 14164 + } 14165 + 14166 + return (sb_corereg(si, si->gpioidx, regoff, mask, val)); 14167 +} 14168 + 14169 +/* mask&set gpio interrupt mask bits */ 14170 +uint32 14171 +sb_gpiointmask(sb_t *sbh, uint32 mask, uint32 val, uint8 priority) 14172 +{ 14173 + sb_info_t *si; 14174 + uint regoff; 14175 + 14176 + si = SB_INFO(sbh); 14177 + regoff = 0; 14178 + 14179 + priority = GPIO_DRV_PRIORITY; /* compatibility hack */ 14180 + 14181 + /* gpios could be shared on router platforms */ 14182 + if ((BUSTYPE(si->sb.bustype) == SB_BUS) && (val || mask)) { 14183 + mask = priority ? (sb_gpioreservation & mask) : 14184 + ((sb_gpioreservation | mask) & ~(sb_gpioreservation)); 14185 + val &= mask; 14186 + } 14187 + 14188 + switch (si->gpioid) { 14189 + case SB_CC: 14190 + regoff = OFFSETOF(chipcregs_t, gpiointmask); 14191 + break; 14192 + 14193 + case SB_PCI: 14194 + /* pci gpio implementation does not support interrupt mask */ 14195 + ASSERT(0); 14196 + break; 14197 + 14198 + case SB_EXTIF: 14199 + regoff = OFFSETOF(extifregs_t, gpiointmask); 14200 + break; 14201 + } 14202 + 14203 + return (sb_corereg(si, si->gpioidx, regoff, mask, val)); 14204 +} 14205 + 14206 +/* assign the gpio to an led */ 14207 +uint32 14208 +sb_gpioled(sb_t *sbh, uint32 mask, uint32 val) 14209 +{ 14210 + sb_info_t *si; 14211 + 14212 + si = SB_INFO(sbh); 14213 + if (si->sb.ccrev < 16) 14214 + return -1; 14215 + 14216 + /* gpio led powersave reg */ 14217 + return (sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimeroutmask), mask, val)); 14218 +} 14219 + 14220 +/* mask & set gpio timer val */ 14221 +uint32 14222 +sb_gpiotimerval(sb_t *sbh, uint32 mask, uint32 gpiotimerval) 14223 +{ 14224 + sb_info_t *si; 14225 + si = SB_INFO(sbh); 14226 + 14227 + if (si->sb.ccrev < 16) 14228 + return -1; 14229 + 14230 + return (sb_corereg(si, 0, OFFSETOF(chipcregs_t, gpiotimerval), mask, gpiotimerval)); 14231 +} 14232 + 14233 + 14234 +/* return the slow clock source - LPO, XTAL, or PCI */ 14235 +static uint 14236 +sb_slowclk_src(sb_info_t *si) 14237 +{ 14238 + chipcregs_t *cc; 14239 + 14240 + 14241 + ASSERT(sb_coreid(&si->sb) == SB_CC); 14242 + 14243 + if (si->sb.ccrev < 6) { 14244 + if ((BUSTYPE(si->sb.bustype) == PCI_BUS) && 14245 + (OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof(uint32)) & 14246 + PCI_CFG_GPIO_SCS)) 14247 + return (SCC_SS_PCI); 14248 + else 14249 + return (SCC_SS_XTAL); 14250 + } else if (si->sb.ccrev < 10) { 14251 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx); 14252 + return (R_REG(si->osh, &cc->slow_clk_ctl) & SCC_SS_MASK); 14253 + } else /* Insta-clock */ 14254 + return (SCC_SS_XTAL); 14255 +} 14256 + 14257 +/* return the ILP (slowclock) min or max frequency */ 14258 +static uint 14259 +sb_slowclk_freq(sb_info_t *si, bool max) 14260 +{ 14261 + chipcregs_t *cc; 14262 + uint32 slowclk; 14263 + uint div; 14264 + 14265 + 14266 + ASSERT(sb_coreid(&si->sb) == SB_CC); 14267 + 14268 + cc = (chipcregs_t*) sb_setcoreidx(&si->sb, si->curidx); 14269 + 14270 + /* shouldn't be here unless we've established the chip has dynamic clk control */ 14271 + ASSERT(R_REG(si->osh, &cc->capabilities) & CAP_PWR_CTL); 14272 + 14273 + slowclk = sb_slowclk_src(si); 14274 + if (si->sb.ccrev < 6) { 14275 + if (slowclk == SCC_SS_PCI) 14276 + return (max? (PCIMAXFREQ/64) : (PCIMINFREQ/64)); 14277 + else 14278 + return (max? (XTALMAXFREQ/32) : (XTALMINFREQ/32)); 14279 + } else if (si->sb.ccrev < 10) { 14280 + div = 4 * (((R_REG(si->osh, &cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1); 14281 + if (slowclk == SCC_SS_LPO) 14282 + return (max? LPOMAXFREQ : LPOMINFREQ); 14283 + else if (slowclk == SCC_SS_XTAL) 14284 + return (max? (XTALMAXFREQ/div) : (XTALMINFREQ/div)); 14285 + else if (slowclk == SCC_SS_PCI) 14286 + return (max? (PCIMAXFREQ/div) : (PCIMINFREQ/div)); 14287 + else 14288 + ASSERT(0); 14289 + } else { 14290 + /* Chipc rev 10 is InstaClock */ 14291 + div = R_REG(si->osh, &cc->system_clk_ctl) >> SYCC_CD_SHIFT; 14292 + div = 4 * (div + 1); 14293 + return (max ? XTALMAXFREQ : (XTALMINFREQ/div)); 14294 + } 14295 + return (0); 14296 +} 14297 + 14298 +static void 14299 +BCMINITFN(sb_clkctl_setdelay)(sb_info_t *si, void *chipcregs) 14300 +{ 14301 + chipcregs_t * cc; 14302 + uint slowmaxfreq, pll_delay, slowclk; 14303 + uint pll_on_delay, fref_sel_delay; 14304 + 14305 + pll_delay = PLL_DELAY; 14306 + 14307 + /* If the slow clock is not sourced by the xtal then add the xtal_on_delay 14308 + * since the xtal will also be powered down by dynamic clk control logic. 14309 + */ 14310 + 14311 + slowclk = sb_slowclk_src(si); 14312 + if (slowclk != SCC_SS_XTAL) 14313 + pll_delay += XTAL_ON_DELAY; 14314 + 14315 + /* Starting with 4318 it is ILP that is used for the delays */ 14316 + slowmaxfreq = sb_slowclk_freq(si, (si->sb.ccrev >= 10) ? FALSE : TRUE); 14317 + 14318 + pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000; 14319 + fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000; 14320 + 14321 + cc = (chipcregs_t *)chipcregs; 14322 + W_REG(si->osh, &cc->pll_on_delay, pll_on_delay); 14323 + W_REG(si->osh, &cc->fref_sel_delay, fref_sel_delay); 14324 +} 14325 + 14326 +/* initialize power control delay registers */ 14327 +void 14328 +BCMINITFN(sb_clkctl_init)(sb_t *sbh) 14329 +{ 14330 + sb_info_t *si; 14331 + uint origidx; 14332 + chipcregs_t *cc; 14333 + 14334 + si = SB_INFO(sbh); 14335 + 14336 + origidx = si->curidx; 14337 + 14338 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL) 14339 + return; 14340 + 14341 + if ((si->sb.chip == BCM4321_CHIP_ID) && (si->sb.chiprev < 2)) 14342 + W_REG(si->osh, &cc->chipcontrol, 14343 + (si->sb.chiprev == 0) ? CHIPCTRL_4321A0_DEFAULT : CHIPCTRL_4321A1_DEFAULT); 14344 + 14345 + if (!(R_REG(si->osh, &cc->capabilities) & CAP_PWR_CTL)) 14346 + goto done; 14347 + 14348 + /* set all Instaclk chip ILP to 1 MHz */ 14349 + else if (si->sb.ccrev >= 10) 14350 + SET_REG(si->osh, &cc->system_clk_ctl, SYCC_CD_MASK, 14351 + (ILP_DIV_1MHZ << SYCC_CD_SHIFT)); 14352 + 14353 + sb_clkctl_setdelay(si, (void *)cc); 14354 + 14355 +done: 14356 + sb_setcoreidx(sbh, origidx); 14357 +} 14358 + 14359 +/* return the value suitable for writing to the dot11 core FAST_PWRUP_DELAY register */ 14360 +uint16 14361 +sb_clkctl_fast_pwrup_delay(sb_t *sbh) 14362 +{ 14363 + sb_info_t *si; 14364 + uint origidx; 14365 + chipcregs_t *cc; 14366 + uint slowminfreq; 14367 + uint16 fpdelay; 14368 + uint intr_val = 0; 14369 + 14370 + si = SB_INFO(sbh); 14371 + fpdelay = 0; 14372 + origidx = si->curidx; 14373 + 14374 + INTR_OFF(si, intr_val); 14375 + 14376 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL) 14377 + goto done; 14378 + 14379 + if (!(R_REG(si->osh, &cc->capabilities) & CAP_PWR_CTL)) 14380 + goto done; 14381 + 14382 + slowminfreq = sb_slowclk_freq(si, FALSE); 14383 + fpdelay = (((R_REG(si->osh, &cc->pll_on_delay) + 2) * 1000000) + 14384 + (slowminfreq - 1)) / slowminfreq; 14385 + 14386 +done: 14387 + sb_setcoreidx(sbh, origidx); 14388 + INTR_RESTORE(si, intr_val); 14389 + return (fpdelay); 14390 +} 14391 + 14392 +/* turn primary xtal and/or pll off/on */ 14393 +int 14394 +sb_clkctl_xtal(sb_t *sbh, uint what, bool on) 14395 +{ 14396 + sb_info_t *si; 14397 + uint32 in, out, outen; 14398 + 14399 + si = SB_INFO(sbh); 14400 + 14401 + switch (BUSTYPE(si->sb.bustype)) { 14402 + 14403 + 14404 + case PCMCIA_BUS: 14405 + return (0); 14406 + 14407 + 14408 + case PCI_BUS: 14409 + 14410 + /* pcie core doesn't have any mapping to control the xtal pu */ 14411 + if (PCIE(si)) 14412 + return -1; 14413 + 14414 + in = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_IN, sizeof(uint32)); 14415 + out = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof(uint32)); 14416 + outen = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof(uint32)); 14417 + 14418 + /* 14419 + * Avoid glitching the clock if GPRS is already using it. 14420 + * We can't actually read the state of the PLLPD so we infer it 14421 + * by the value of XTAL_PU which *is* readable via gpioin. 14422 + */ 14423 + if (on && (in & PCI_CFG_GPIO_XTAL)) 14424 + return (0); 14425 + 14426 + if (what & XTAL) 14427 + outen |= PCI_CFG_GPIO_XTAL; 14428 + if (what & PLL) 14429 + outen |= PCI_CFG_GPIO_PLL; 14430 + 14431 + if (on) { 14432 + /* turn primary xtal on */ 14433 + if (what & XTAL) { 14434 + out |= PCI_CFG_GPIO_XTAL; 14435 + if (what & PLL) 14436 + out |= PCI_CFG_GPIO_PLL; 14437 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, 14438 + sizeof(uint32), out); 14439 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, 14440 + sizeof(uint32), outen); 14441 + OSL_DELAY(XTAL_ON_DELAY); 14442 + } 14443 + 14444 + /* turn pll on */ 14445 + if (what & PLL) { 14446 + out &= ~PCI_CFG_GPIO_PLL; 14447 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, 14448 + sizeof(uint32), out); 14449 + OSL_DELAY(2000); 14450 + } 14451 + } else { 14452 + if (what & XTAL) 14453 + out &= ~PCI_CFG_GPIO_XTAL; 14454 + if (what & PLL) 14455 + out |= PCI_CFG_GPIO_PLL; 14456 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof(uint32), out); 14457 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof(uint32), 14458 + outen); 14459 + } 14460 + 14461 + default: 14462 + return (-1); 14463 + } 14464 + 14465 + return (0); 14466 +} 14467 + 14468 +/* set dynamic clk control mode (forceslow, forcefast, dynamic) */ 14469 +/* returns true if we are forcing fast clock */ 14470 +bool 14471 +sb_clkctl_clk(sb_t *sbh, uint mode) 14472 +{ 14473 + sb_info_t *si; 14474 + uint origidx; 14475 + chipcregs_t *cc; 14476 + uint32 scc; 14477 + uint intr_val = 0; 14478 + 14479 + si = SB_INFO(sbh); 14480 + 14481 + /* chipcommon cores prior to rev6 don't support dynamic clock control */ 14482 + if (si->sb.ccrev < 6) 14483 + return (FALSE); 14484 + 14485 + 14486 + /* Chips with ccrev 10 are EOL and they don't have SYCC_HR which we use below */ 14487 + ASSERT(si->sb.ccrev != 10); 14488 + 14489 + INTR_OFF(si, intr_val); 14490 + 14491 + origidx = si->curidx; 14492 + 14493 + if (sb_setcore(sbh, SB_MIPS33, 0) && (sb_corerev(&si->sb) <= 7) && 14494 + (BUSTYPE(si->sb.bustype) == SB_BUS) && (si->sb.ccrev >= 10)) 14495 + goto done; 14496 + 14497 + /* PR32414WAR "Force HT clock on" all the time, no dynamic clk ctl */ 14498 + if ((si->sb.chip == BCM4311_CHIP_ID) && (si->sb.chiprev <= 1)) 14499 + goto done; 14500 + 14501 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0); 14502 + ASSERT(cc != NULL); 14503 + 14504 + if (!(R_REG(si->osh, &cc->capabilities) & CAP_PWR_CTL)) 14505 + goto done; 14506 + 14507 + switch (mode) { 14508 + case CLK_FAST: /* force fast (pll) clock */ 14509 + if (si->sb.ccrev < 10) { 14510 + /* don't forget to force xtal back on before we clear SCC_DYN_XTAL.. */ 14511 + sb_clkctl_xtal(&si->sb, XTAL, ON); 14512 + 14513 + SET_REG(si->osh, &cc->slow_clk_ctl, (SCC_XC | SCC_FS | SCC_IP), SCC_IP); 14514 + } else 14515 + OR_REG(si->osh, &cc->system_clk_ctl, SYCC_HR); 14516 + /* wait for the PLL */ 14517 + OSL_DELAY(PLL_DELAY); 14518 + break; 14519 + 14520 + case CLK_DYNAMIC: /* enable dynamic clock control */ 14521 + 14522 + if (si->sb.ccrev < 10) { 14523 + scc = R_REG(si->osh, &cc->slow_clk_ctl); 14524 + scc &= ~(SCC_FS | SCC_IP | SCC_XC); 14525 + if ((scc & SCC_SS_MASK) != SCC_SS_XTAL) 14526 + scc |= SCC_XC; 14527 + W_REG(si->osh, &cc->slow_clk_ctl, scc); 14528 + 14529 + /* for dynamic control, we have to release our xtal_pu "force on" */ 14530 + if (scc & SCC_XC) 14531 + sb_clkctl_xtal(&si->sb, XTAL, OFF); 14532 + } else { 14533 + /* Instaclock */ 14534 + AND_REG(si->osh, &cc->system_clk_ctl, ~SYCC_HR); 14535 + } 14536 + break; 14537 + 14538 + default: 14539 + ASSERT(0); 14540 + } 14541 + 14542 +done: 14543 + sb_setcoreidx(sbh, origidx); 14544 + INTR_RESTORE(si, intr_val); 14545 + return (mode == CLK_FAST); 14546 +} 14547 + 14548 +/* register driver interrupt disabling and restoring callback functions */ 14549 +void 14550 +sb_register_intr_callback(sb_t *sbh, void *intrsoff_fn, void *intrsrestore_fn, 14551 + void *intrsenabled_fn, void *intr_arg) 14552 +{ 14553 + sb_info_t *si; 14554 + 14555 + si = SB_INFO(sbh); 14556 + si->intr_arg = intr_arg; 14557 + si->intrsoff_fn = (sb_intrsoff_t)intrsoff_fn; 14558 + si->intrsrestore_fn = (sb_intrsrestore_t)intrsrestore_fn; 14559 + si->intrsenabled_fn = (sb_intrsenabled_t)intrsenabled_fn; 14560 + /* save current core id. when this function called, the current core 14561 + * must be the core which provides driver functions(il, et, wl, etc.) 14562 + */ 14563 + si->dev_coreid = si->coreid[si->curidx]; 14564 +} 14565 + 14566 + 14567 +int 14568 +sb_corepciid(sb_t *sbh, uint func, uint16 *pcivendor, uint16 *pcidevice, 14569 + uint8 *pciclass, uint8 *pcisubclass, uint8 *pciprogif, 14570 + uint8 *pciheader) 14571 +{ 14572 + uint16 vendor = 0xffff, device = 0xffff; 14573 + uint core, unit; 14574 + uint chip, chippkg; 14575 + uint nfunc; 14576 + char varname[SB_DEVPATH_BUFSZ + 8]; 14577 + uint8 class, subclass, progif; 14578 + char devpath[SB_DEVPATH_BUFSZ]; 14579 + uint8 header; 14580 + 14581 + core = sb_coreid(sbh); 14582 + unit = sb_coreunit(sbh); 14583 + 14584 + chip = sb_chip(sbh); 14585 + chippkg = sb_chippkg(sbh); 14586 + 14587 + progif = 0; 14588 + header = PCI_HEADER_NORMAL; 14589 + 14590 + /* Verify whether the function exists for the core */ 14591 + nfunc = (core == SB_USB20H) ? 2 : 1; 14592 + if (func >= nfunc) 14593 + return BCME_ERROR; 14594 + 14595 + /* Known vendor translations */ 14596 + switch (sb_corevendor(sbh)) { 14597 + case SB_VEND_BCM: 14598 + vendor = VENDOR_BROADCOM; 14599 + break; 14600 + default: 14601 + return BCME_ERROR; 14602 + } 14603 + 14604 + /* Determine class based on known core codes */ 14605 + switch (core) { 14606 + case SB_ILINE20: 14607 + class = PCI_CLASS_NET; 14608 + subclass = PCI_NET_ETHER; 14609 + device = BCM47XX_ILINE_ID; 14610 + break; 14611 + case SB_ENET: 14612 + class = PCI_CLASS_NET; 14613 + subclass = PCI_NET_ETHER; 14614 + device = BCM47XX_ENET_ID; 14615 + break; 14616 + case SB_GIGETH: 14617 + class = PCI_CLASS_NET; 14618 + subclass = PCI_NET_ETHER; 14619 + device = BCM47XX_GIGETH_ID; 14620 + break; 14621 + case SB_SDRAM: 14622 + case SB_MEMC: 14623 + class = PCI_CLASS_MEMORY; 14624 + subclass = PCI_MEMORY_RAM; 14625 + device = (uint16)core; 14626 + break; 14627 + case SB_PCI: 14628 + case SB_PCIE: 14629 + class = PCI_CLASS_BRIDGE; 14630 + subclass = PCI_BRIDGE_PCI; 14631 + device = (uint16)core; 14632 + header = PCI_HEADER_BRIDGE; 14633 + break; 14634 + case SB_MIPS: 14635 + case SB_MIPS33: 14636 + class = PCI_CLASS_CPU; 14637 + subclass = PCI_CPU_MIPS; 14638 + device = (uint16)core; 14639 + break; 14640 + case SB_CODEC: 14641 + class = PCI_CLASS_COMM; 14642 + subclass = PCI_COMM_MODEM; 14643 + device = BCM47XX_V90_ID; 14644 + break; 14645 + case SB_USB: 14646 + class = PCI_CLASS_SERIAL; 14647 + subclass = PCI_SERIAL_USB; 14648 + progif = 0x10; /* OHCI */ 14649 + device = BCM47XX_USB_ID; 14650 + break; 14651 + case SB_USB11H: 14652 + class = PCI_CLASS_SERIAL; 14653 + subclass = PCI_SERIAL_USB; 14654 + progif = 0x10; /* OHCI */ 14655 + device = BCM47XX_USBH_ID; 14656 + break; 14657 + case SB_USB20H: 14658 + class = PCI_CLASS_SERIAL; 14659 + subclass = PCI_SERIAL_USB; 14660 + progif = func == 0 ? 0x10 : 0x20; /* OHCI/EHCI */ 14661 + device = BCM47XX_USB20H_ID; 14662 + header = 0x80; /* multifunction */ 14663 + break; 14664 + case SB_USB11D: 14665 + class = PCI_CLASS_SERIAL; 14666 + subclass = PCI_SERIAL_USB; 14667 + device = BCM47XX_USBD_ID; 14668 + break; 14669 + case SB_USB20D: 14670 + class = PCI_CLASS_SERIAL; 14671 + subclass = PCI_SERIAL_USB; 14672 + device = BCM47XX_USB20D_ID; 14673 + break; 14674 + case SB_IPSEC: 14675 + class = PCI_CLASS_CRYPT; 14676 + subclass = PCI_CRYPT_NETWORK; 14677 + device = BCM47XX_IPSEC_ID; 14678 + break; 14679 + case SB_ROBO: 14680 + class = PCI_CLASS_NET; 14681 + subclass = PCI_NET_OTHER; 14682 + device = BCM47XX_ROBO_ID; 14683 + break; 14684 + case SB_EXTIF: 14685 + case SB_CC: 14686 + class = PCI_CLASS_MEMORY; 14687 + subclass = PCI_MEMORY_FLASH; 14688 + device = (uint16)core; 14689 + break; 14690 + case SB_D11: 14691 + class = PCI_CLASS_NET; 14692 + subclass = PCI_NET_OTHER; 14693 + /* Let nvram variable override core ID */ 14694 + sb_devpath(sbh, devpath, sizeof(devpath)); 14695 + sprintf(varname, "%sdevid", devpath); 14696 + if ((device = (uint16)getintvar(NULL, varname))) 14697 + break; 14698 + /* 14699 + * no longer support wl%did, but keep the code 14700 + * here for backward compatibility. 14701 + */ 14702 + sprintf(varname, "wl%did", unit); 14703 + if ((device = (uint16)getintvar(NULL, varname))) 14704 + break; 14705 + /* Chip specific conversion */ 14706 + if (chip == BCM4712_CHIP_ID) { 14707 + if (chippkg == BCM4712SMALL_PKG_ID) 14708 + device = BCM4306_D11G_ID; 14709 + else 14710 + device = BCM4306_D11DUAL_ID; 8383 14711 + break; 8384 14712 + } 8385 + 8386 + /* Determine class based on known core codes */ 8387 + switch (core) { 8388 + case SB_ILINE20: 8389 + class = PCI_CLASS_NET; 8390 + subclass = PCI_NET_ETHER; 8391 + core = BCM47XX_ILINE_ID; 14713 + /* ignore it */ 14714 + device = 0xffff; 14715 + break; 14716 + case SB_SATAXOR: 14717 + class = PCI_CLASS_XOR; 14718 + subclass = PCI_XOR_QDMA; 14719 + device = BCM47XX_SATAXOR_ID; 14720 + break; 14721 + case SB_ATA100: 14722 + class = PCI_CLASS_DASDI; 14723 + subclass = PCI_DASDI_IDE; 14724 + device = BCM47XX_ATA100_ID; 14725 + break; 14726 + 14727 + default: 14728 + class = subclass = progif = 0xff; 14729 + device = (uint16)core; 14730 + break; 14731 + } 14732 + 14733 + *pcivendor = vendor; 14734 + *pcidevice = device; 14735 + *pciclass = class; 14736 + *pcisubclass = subclass; 14737 + *pciprogif = progif; 14738 + *pciheader = header; 14739 + 14740 + return 0; 14741 +} 14742 + 14743 + 14744 + 14745 +/* use the mdio interface to write to mdio slaves */ 14746 +static int 14747 +sb_pcie_mdiowrite(sb_info_t *si, uint physmedia, uint regaddr, uint val) 14748 +{ 14749 + uint mdiodata; 14750 + uint i = 0; 14751 + sbpcieregs_t *pcieregs; 14752 + 14753 + pcieregs = (sbpcieregs_t*) sb_setcoreidx(&si->sb, si->sb.buscoreidx); 14754 + ASSERT(pcieregs); 14755 + 14756 + /* enable mdio access to SERDES */ 14757 + W_REG(si->osh, (&pcieregs->mdiocontrol), MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL); 14758 + 14759 + mdiodata = MDIODATA_START | MDIODATA_WRITE | 14760 + (physmedia << MDIODATA_DEVADDR_SHF) | 14761 + (regaddr << MDIODATA_REGADDR_SHF) | MDIODATA_TA | val; 14762 + 14763 + W_REG(si->osh, (&pcieregs->mdiodata), mdiodata); 14764 + 14765 + PR28829_DELAY(); 14766 + 14767 + /* retry till the transaction is complete */ 14768 + while (i < 10) { 14769 + if (R_REG(si->osh, &(pcieregs->mdiocontrol)) & MDIOCTL_ACCESS_DONE) { 14770 + /* Disable mdio access to SERDES */ 14771 + W_REG(si->osh, (&pcieregs->mdiocontrol), 0); 14772 + return 0; 14773 + } 14774 + OSL_DELAY(1000); 14775 + i++; 14776 + } 14777 + 14778 + SB_ERROR(("sb_pcie_mdiowrite: timed out\n")); 14779 + /* Disable mdio access to SERDES */ 14780 + W_REG(si->osh, (&pcieregs->mdiocontrol), 0); 14781 + ASSERT(0); 14782 + return 1; 14783 + 14784 +} 14785 + 14786 +/* indirect way to read pcie config regs */ 14787 +uint 14788 +sb_pcie_readreg(void *sb, void* arg1, uint offset) 14789 +{ 14790 + sb_info_t *si; 14791 + sb_t *sbh; 14792 + uint retval = 0xFFFFFFFF; 14793 + sbpcieregs_t *pcieregs; 14794 + uint addrtype; 14795 + 14796 + sbh = (sb_t *)sb; 14797 + si = SB_INFO(sbh); 14798 + ASSERT(PCIE(si)); 14799 + 14800 + pcieregs = (sbpcieregs_t *)sb_setcore(sbh, SB_PCIE, 0); 14801 + ASSERT(pcieregs); 14802 + 14803 + addrtype = (uint)((uintptr)arg1); 14804 + switch (addrtype) { 14805 + case PCIE_CONFIGREGS: 14806 + W_REG(si->osh, (&pcieregs->configaddr), offset); 14807 + retval = R_REG(si->osh, &(pcieregs->configdata)); 8392 14808 + break; 8393 + case SB_ILINE100: 8394 + class = PCI_CLASS_NET; 8395 + subclass = PCI_NET_ETHER; 8396 + core = BCM4610_ILINE_ID; 14809 + case PCIE_PCIEREGS: 14810 + W_REG(si->osh, &(pcieregs->pcieaddr), offset); 14811 + retval = R_REG(si->osh, &(pcieregs->pciedata)); 8397 14812 + break; 8398 + case SB_ENET: 8399 + class = PCI_CLASS_NET; 8400 + subclass = PCI_NET_ETHER; 8401 + core = BCM47XX_ENET_ID; 14813 + default: 14814 + ASSERT(0); 8402 14815 + break; 8403 + case SB_SDRAM: 8404 + case SB_MEMC: 8405 + class = PCI_CLASS_MEMORY; 8406 + subclass = PCI_MEMORY_RAM; 14816 + } 14817 + return retval; 14818 +} 14819 + 14820 +/* indirect way to write pcie config/mdio/pciecore regs */ 14821 +uint 14822 +sb_pcie_writereg(sb_t *sbh, void *arg1, uint offset, uint val) 14823 +{ 14824 + sb_info_t *si; 14825 + sbpcieregs_t *pcieregs; 14826 + uint addrtype; 14827 + 14828 + si = SB_INFO(sbh); 14829 + ASSERT(PCIE(si)); 14830 + 14831 + pcieregs = (sbpcieregs_t *)sb_setcore(sbh, SB_PCIE, 0); 14832 + ASSERT(pcieregs); 14833 + 14834 + addrtype = (uint)((uintptr)arg1); 14835 + 14836 + switch (addrtype) { 14837 + case PCIE_CONFIGREGS: 14838 + W_REG(si->osh, (&pcieregs->configaddr), offset); 14839 + W_REG(si->osh, (&pcieregs->configdata), val); 8407 14840 + break; 8408 + case SB_PCI:8409 + class = PCI_CLASS_BRIDGE;8410 + subclass = PCI_BRIDGE_PCI;14841 + case PCIE_PCIEREGS: 14842 + W_REG(si->osh, (&pcieregs->pcieaddr), offset); 14843 + W_REG(si->osh, (&pcieregs->pciedata), val); 8411 14844 + break; 8412 + case SB_MIPS: 8413 + case SB_MIPS33: 8414 + class = PCI_CLASS_CPU; 8415 + subclass = PCI_CPU_MIPS; 14845 + default: 14846 + ASSERT(0); 8416 14847 + break; 8417 + case SB_CODEC: 8418 + class = PCI_CLASS_COMM; 8419 + subclass = PCI_COMM_MODEM; 8420 + core = BCM47XX_V90_ID; 8421 + break; 8422 + case SB_USB: 8423 + class = PCI_CLASS_SERIAL; 8424 + subclass = PCI_SERIAL_USB; 8425 + progif = 0x10; /* OHCI */ 8426 + core = BCM47XX_USB_ID; 8427 + break; 8428 + case SB_USB11H: 8429 + class = PCI_CLASS_SERIAL; 8430 + subclass = PCI_SERIAL_USB; 8431 + progif = 0x10; /* OHCI */ 8432 + core = BCM47XX_USBH_ID; 8433 + break; 8434 + case SB_USB11D: 8435 + class = PCI_CLASS_SERIAL; 8436 + subclass = PCI_SERIAL_USB; 8437 + core = BCM47XX_USBD_ID; 8438 + break; 8439 + case SB_IPSEC: 8440 + class = PCI_CLASS_CRYPT; 8441 + subclass = PCI_CRYPT_NETWORK; 8442 + core = BCM47XX_IPSEC_ID; 8443 + break; 8444 + case SB_ROBO: 8445 + class = PCI_CLASS_NET; 8446 + subclass = PCI_NET_OTHER; 8447 + core = BCM47XX_ROBO_ID; 8448 + break; 8449 + case SB_EXTIF: 8450 + case SB_CC: 8451 + class = PCI_CLASS_MEMORY; 8452 + subclass = PCI_MEMORY_FLASH; 8453 + break; 8454 + case SB_D11: 8455 + class = PCI_CLASS_NET; 8456 + subclass = PCI_NET_OTHER; 8457 + /* Let an nvram variable override this */ 8458 + sprintf(varname, "wl%did", wlidx); 8459 + wlidx++; 8460 + if ((core = getintvar(NULL, varname)) == 0) { 8461 + if (chip == BCM4712_DEVICE_ID) { 8462 + if (chippkg == BCM4712SMALL_PKG_ID) 8463 + core = BCM4306_D11G_ID; 8464 + else 8465 + core = BCM4306_D11DUAL_ID; 8466 + } else { 8467 + /* 4310 */ 8468 + core = BCM4310_D11B_ID; 8469 + } 8470 + } 8471 + break; 8472 + 8473 + default: 8474 + class = subclass = progif = 0xff; 8475 + break; 14848 + } 14849 + return 0; 14850 +} 14851 + 14852 +/* Build device path. Support SB, PCI, and JTAG for now. */ 14853 +int 14854 +sb_devpath(sb_t *sbh, char *path, int size) 14855 +{ 14856 + ASSERT(path); 14857 + ASSERT(size >= SB_DEVPATH_BUFSZ); 14858 + 14859 + switch (BUSTYPE((SB_INFO(sbh))->sb.bustype)) { 14860 + case SB_BUS: 14861 + case JTAG_BUS: 14862 + sprintf(path, "sb/%u/", sb_coreidx(sbh)); 14863 + break; 14864 + case PCI_BUS: 14865 + ASSERT((SB_INFO(sbh))->osh); 14866 + sprintf(path, "pci/%u/%u/", OSL_PCI_BUS((SB_INFO(sbh))->osh), 14867 + OSL_PCI_SLOT((SB_INFO(sbh))->osh)); 14868 + break; 14869 + case PCMCIA_BUS: 14870 + SB_ERROR(("sb_devpath: OSL_PCMCIA_BUS() not implemented, bus 1 assumed\n")); 14871 + SB_ERROR(("sb_devpath: OSL_PCMCIA_SLOT() not implemented, slot 1 assumed\n")); 14872 + sprintf(path, "pc/%u/%u/", 1, 1); 14873 + break; 14874 + case SDIO_BUS: 14875 + SB_ERROR(("sb_devpath: device 0 assumed\n")); 14876 + sprintf(path, "sd/%u/", sb_coreidx(sbh)); 14877 + break; 14878 + default: 14879 + ASSERT(0); 14880 + break; 14881 + } 14882 + 14883 + return 0; 14884 +} 14885 + 14886 +/* 14887 + * Fixup SROMless PCI device's configuration. 14888 + * The current core may be changed upon return. 14889 + */ 14890 +static int 14891 +sb_pci_fixcfg(sb_info_t *si) 14892 +{ 14893 + uint origidx, pciidx; 14894 + sbpciregs_t *pciregs; 14895 + sbpcieregs_t *pcieregs; 14896 + uint16 val16, *reg16; 14897 + char name[SB_DEVPATH_BUFSZ+16], *value; 14898 + char devpath[SB_DEVPATH_BUFSZ]; 14899 + 14900 + ASSERT(BUSTYPE(si->sb.bustype) == PCI_BUS); 14901 + 14902 + /* Fixup PI in SROM shadow area to enable the correct PCI core access */ 14903 + /* save the current index */ 14904 + origidx = sb_coreidx(&si->sb); 14905 + 14906 + /* check 'pi' is correct and fix it if not */ 14907 + if (si->sb.buscoretype == SB_PCIE) { 14908 + pcieregs = (sbpcieregs_t *)sb_setcore(&si->sb, SB_PCIE, 0); 14909 + ASSERT(pcieregs); 14910 + reg16 = &pcieregs->sprom[SRSH_PI_OFFSET]; 14911 + } else if (si->sb.buscoretype == SB_PCI) { 14912 + pciregs = (sbpciregs_t *)sb_setcore(&si->sb, SB_PCI, 0); 14913 + ASSERT(pciregs); 14914 + reg16 = &pciregs->sprom[SRSH_PI_OFFSET]; 14915 + } else { 14916 + ASSERT(0); 14917 + return -1; 14918 + } 14919 + pciidx = sb_coreidx(&si->sb); 14920 + val16 = R_REG(si->osh, reg16); 14921 + if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (uint16)pciidx) { 14922 + val16 = (uint16)(pciidx << SRSH_PI_SHIFT) | (val16 & ~SRSH_PI_MASK); 14923 + W_REG(si->osh, reg16, val16); 14924 + } 14925 + 14926 + /* restore the original index */ 14927 + sb_setcoreidx(&si->sb, origidx); 14928 + 14929 + /* 14930 + * Fixup bar0window in PCI config space to make the core indicated 14931 + * by the nvram variable the current core. 14932 + * !Do it last, it may change the current core! 14933 + */ 14934 + if (sb_devpath(&si->sb, devpath, sizeof(devpath))) 14935 + return -1; 14936 + sprintf(name, "%sb0w", devpath); 14937 + if ((value = getvar(NULL, name))) { 14938 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, sizeof(uint32), 14939 + bcm_strtoul(value, NULL, 16)); 14940 + /* update curidx since the current core is changed */ 14941 + si->curidx = _sb_coreidx(si); 14942 + if (si->curidx == BADIDX) { 14943 + SB_ERROR(("sb_pci_fixcfg: bad core index\n")); 14944 + return -1; 8476 14945 + } 8477 + 8478 + /* Supported translations */ 8479 + cfg->vendor = htol16(vendor); 8480 + cfg->device = htol16(core); 8481 + cfg->rev_id = chiprev; 8482 + cfg->prog_if = progif; 8483 + cfg->sub_class = subclass; 8484 + cfg->base_class = class; 8485 + cfg->base[0] = htol32(sb_base(R_REG(&sb->sbadmatch0))); 8486 + cfg->base[1] = htol32(sb_base(R_REG(&sb->sbadmatch1))); 8487 + cfg->base[2] = htol32(sb_base(R_REG(&sb->sbadmatch2))); 8488 + cfg->base[3] = htol32(sb_base(R_REG(&sb->sbadmatch3))); 8489 + cfg->base[4] = 0; 8490 + cfg->base[5] = 0; 8491 + if (class == PCI_CLASS_BRIDGE && subclass == PCI_BRIDGE_PCI) 8492 + cfg->header_type = PCI_HEADER_BRIDGE; 14946 + } 14947 + 14948 + return 0; 14949 +} 14950 + 14951 +static uint 14952 +sb_chipc_capability(sb_t *sbh) 14953 +{ 14954 + sb_info_t *si; 14955 + 14956 + si = SB_INFO(sbh); 14957 + 14958 + /* Make sure that there is ChipCommon core present */ 14959 + if (si->coreid[SB_CC_IDX] == SB_CC) 14960 + return (sb_corereg(si, SB_CC_IDX, OFFSETOF(chipcregs_t, capabilities), 14961 + 0, 0)); 14962 + return 0; 14963 +} 14964 + 14965 +/* Return ADDR64 capability of the backplane */ 14966 +bool 14967 +sb_backplane64(sb_t *sbh) 14968 +{ 14969 + return ((sb_chipc_capability(sbh) & CAP_BKPLN64) != 0); 14970 +} 14971 + 14972 +void 14973 +sb_btcgpiowar(sb_t *sbh) 14974 +{ 14975 + sb_info_t *si; 14976 + uint origidx; 14977 + uint intr_val = 0; 14978 + chipcregs_t *cc; 14979 + si = SB_INFO(sbh); 14980 + 14981 + /* Make sure that there is ChipCommon core present && 14982 + * UART_TX is strapped to 1 14983 + */ 14984 + if (!(sb_chipc_capability(sbh) & CAP_UARTGPIO)) 14985 + return; 14986 + 14987 + /* sb_corereg cannot be used as we have to guarantee 8-bit read/writes */ 14988 + INTR_OFF(si, intr_val); 14989 + 14990 + origidx = sb_coreidx(sbh); 14991 + 14992 + cc = (chipcregs_t *)sb_setcore(sbh, SB_CC, 0); 14993 + if (cc == NULL) 14994 + goto end; 14995 + 14996 + W_REG(si->osh, &cc->uart0mcr, R_REG(si->osh, &cc->uart0mcr) | 0x04); 14997 + 14998 +end: 14999 + /* restore the original index */ 15000 + sb_setcoreidx(sbh, origidx); 15001 + 15002 + INTR_RESTORE(si, intr_val); 15003 +} 15004 + 15005 +/* check if the device is removed */ 15006 +bool 15007 +sb_deviceremoved(sb_t *sbh) 15008 +{ 15009 + uint32 w; 15010 + sb_info_t *si; 15011 + 15012 + si = SB_INFO(sbh); 15013 + 15014 + switch (BUSTYPE(si->sb.bustype)) { 15015 + case PCI_BUS: 15016 + ASSERT(si->osh); 15017 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_CFG_VID, sizeof(uint32)); 15018 + if ((w & 0xFFFF) != VENDOR_BROADCOM) 15019 + return TRUE; 8493 15020 + else 8494 + cfg->header_type = PCI_HEADER_NORMAL; 8495 + /* Save core interrupt flag */ 8496 + cfg->int_pin = R_REG(&sb->sbtpsflag) & SBTPS_NUM0_MASK; 8497 + /* Default to MIPS shared interrupt 0 */ 8498 + cfg->int_line = 0; 8499 + /* MIPS sbipsflag maps core interrupt flags to interrupts 1 through 4 */ 8500 + if ((regs = sb_setcore(sbh, SB_MIPS, 0)) || 8501 + (regs = sb_setcore(sbh, SB_MIPS33, 0))) { 8502 + sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF); 8503 + val = R_REG(&sb->sbipsflag); 8504 + for (cfg->int_line = 1; cfg->int_line <= 4; cfg->int_line++) { 8505 + if (((val & sbips_int_mask[cfg->int_line]) >> sbips_int_shift[cfg->int_line]) == cfg->int_pin) 8506 + break; 8507 + } 8508 + if (cfg->int_line > 4) 8509 + cfg->int_line = 0; 8510 + } 8511 + /* Emulated core */ 8512 + *((uint32 *) &cfg->sprom_control) = 0xffffffff; 8513 + } 8514 + 8515 + sb_setcoreidx(sbh, coreidx); 8516 + return 0; 8517 +} 8518 + 8519 +int __init 8520 +sbpci_init(void *sbh) 8521 +{ 8522 + sbpci_init_pci(sbh); 8523 + sbpci_init_cores(sbh); 8524 + return 0; 8525 +} 8526 + 8527 +void 8528 +sbpci_check(void *sbh) 8529 +{ 8530 + uint coreidx; 8531 + sbpciregs_t *pci; 8532 + uint32 sbtopci1; 8533 + uint32 buf[64], *ptr, i; 8534 + ulong pa; 8535 + volatile uint j; 8536 + 8537 + coreidx = sb_coreidx(sbh); 8538 + pci = (sbpciregs_t *) sb_setcore(sbh, SB_PCI, 0); 8539 + 8540 + /* Clear the test array */ 8541 + pa = (ulong) DMA_MAP(NULL, buf, sizeof(buf), DMA_RX, NULL); 8542 + ptr = (uint32 *) OSL_UNCACHED(&buf[0]); 8543 + memset(ptr, 0, sizeof(buf)); 8544 + 8545 + /* Point PCI window 1 to memory */ 8546 + sbtopci1 = R_REG(&pci->sbtopci1); 8547 + W_REG(&pci->sbtopci1, SBTOPCI_MEM | (pa & SBTOPCI1_MASK)); 8548 + 8549 + /* Fill the test array via PCI window 1 */ 8550 + ptr = (uint32 *) REG_MAP(SB_PCI_CFG + (pa & ~SBTOPCI1_MASK), sizeof(buf)); 8551 + for (i = 0; i < ARRAYSIZE(buf); i++) { 8552 + for (j = 0; j < 2; j++); 8553 + W_REG(&ptr[i], i); 8554 + } 8555 + REG_UNMAP(ptr); 8556 + 8557 + /* Restore PCI window 1 */ 8558 + W_REG(&pci->sbtopci1, sbtopci1); 8559 + 8560 + /* Check the test array */ 8561 + DMA_UNMAP(NULL, pa, sizeof(buf), DMA_RX, NULL); 8562 + ptr = (uint32 *) OSL_UNCACHED(&buf[0]); 8563 + for (i = 0; i < ARRAYSIZE(buf); i++) { 8564 + if (ptr[i] != i) 8565 + break; 8566 + } 8567 + 8568 + /* Change the clock if the test fails */ 8569 + if (i < ARRAYSIZE(buf)) { 8570 + uint32 req, cur; 8571 + 8572 + cur = sb_clock(sbh); 8573 + printf("PCI: Test failed at %d MHz\n", (cur + 500000) / 1000000); 8574 + for (req = 104000000; req < 176000000; req += 4000000) { 8575 + printf("PCI: Resetting to %d MHz\n", (req + 500000) / 1000000); 8576 + /* This will only reset if the clocks are valid and have changed */ 8577 + sb_mips_setclock(sbh, req, 0, 0); 8578 + } 8579 + /* Should not reach here */ 8580 + ASSERT(0); 8581 + } 8582 + 8583 + sb_setcoreidx(sbh, coreidx); 8584 +} 8585 diff -Nur linux-2.4.32/arch/mips/bcm947xx/setup.c linux-2.4.32-freewrt/arch/mips/bcm947xx/setup.c 8586 --- linux-2.4.32/arch/mips/bcm947xx/setup.c 1970-01-01 01:00:00.000000000 +0100 8587 +++ linux-2.4.32-freewrt/arch/mips/bcm947xx/setup.c 2006-09-16 15:58:53.000000000 +0200 8588 @@ -0,0 +1,201 @@ 15021 + return FALSE; 15022 + default: 15023 + return FALSE; 15024 + } 15025 + return FALSE; 15026 +} 15027 + 15028 +/* Return the RAM size of the SOCRAM core */ 15029 +uint32 15030 +sb_socram_size(sb_t *sbh) 15031 +{ 15032 + sb_info_t *si; 15033 + uint origidx; 15034 + uint intr_val = 0; 15035 + 15036 + sbsocramregs_t *regs; 15037 + bool wasup; 15038 + uint corerev; 15039 + uint32 coreinfo; 15040 + uint memsize = 0; 15041 + 15042 + si = SB_INFO(sbh); 15043 + ASSERT(si); 15044 + 15045 + /* Block ints and save current core */ 15046 + INTR_OFF(si, intr_val); 15047 + origidx = sb_coreidx(sbh); 15048 + 15049 + /* Switch to SOCRAM core */ 15050 + if (!(regs = sb_setcore(sbh, SB_SOCRAM, 0))) 15051 + goto done; 15052 + 15053 + /* Get info for determining size */ 15054 + if (!(wasup = sb_iscoreup(sbh))) 15055 + sb_core_reset(sbh, 0, 0); 15056 + corerev = sb_corerev(sbh); 15057 + coreinfo = R_REG(si->osh, ®s->coreinfo); 15058 + 15059 + /* Calculate size from coreinfo based on rev */ 15060 + switch (corerev) { 15061 + case 0: 15062 + memsize = 1 << (16 + (coreinfo & SRCI_MS0_MASK)); 15063 + break; 15064 + default: /* rev >= 1 */ 15065 + memsize = 1 << (SR_BSZ_BASE + (coreinfo & SRCI_SRBSZ_MASK)); 15066 + memsize *= (coreinfo & SRCI_SRNB_MASK) >> SRCI_SRNB_SHIFT; 15067 + break; 15068 + } 15069 + 15070 + /* Return to previous state and core */ 15071 + if (!wasup) 15072 + sb_core_disable(sbh, 0); 15073 + sb_setcoreidx(sbh, origidx); 15074 + 15075 +done: 15076 + INTR_RESTORE(si, intr_val); 15077 + return memsize; 15078 +} 15079 + 15080 + 15081 diff -urN linux.old/arch/mips/bcm947xx/setup.c linux.dev/arch/mips/bcm947xx/setup.c 15082 --- linux.old/arch/mips/bcm947xx/setup.c 1970-01-01 01:00:00.000000000 +0100 15083 +++ linux.dev/arch/mips/bcm947xx/setup.c 2006-10-02 21:19:59.000000000 +0200 15084 @@ -0,0 +1,241 @@ 8589 15085 +/* 8590 + * Generic setup routines for Broadcom MIPS boards15086 + * Generic setup routines for Broadcom MIPS boards 8591 15087 + * 8592 + * Copyright 2004, Broadcom Corporation 15088 + * Copyright (C) 2005 Felix Fietkau <nbd@openwrt.org> 15089 + * 15090 + * This program is free software; you can redistribute it and/or modify it 15091 + * under the terms of the GNU General Public License as published by the 15092 + * Free Software Foundation; either version 2 of the License, or (at your 15093 + * option) any later version. 15094 + * 15095 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 15096 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15097 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 15098 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 15099 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 15100 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 15101 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 15102 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15103 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 15104 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 15105 + * 15106 + * You should have received a copy of the GNU General Public License along 15107 + * with this program; if not, write to the Free Software Foundation, Inc., 15108 + * 675 Mass Ave, Cambridge, MA 02139, USA. 15109 + * 15110 + * 15111 + * Copyright 2005, Broadcom Corporation 8593 15112 + * All Rights Reserved. 8594 15113 + * … … 8598 15117 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 8599 15118 + * 8600 + * $Id: setup.c,v 1.2 2005/04/02 12:12:57 wbx Exp $8601 15119 + */ 8602 15120 + … … 8608 15126 +#include <linux/ide.h> 8609 15127 +#include <asm/bootinfo.h> 15128 +#include <asm/cpu.h> 8610 15129 +#include <asm/time.h> 8611 15130 +#include <asm/reboot.h> 8612 15131 + 8613 15132 +#include <typedefs.h> 15133 +#include <osl.h> 15134 +#include <sbutils.h> 8614 15135 +#include <bcmutils.h> 8615 15136 +#include <bcmnvram.h> 8616 +#include <sb mips.h>8617 +#include < sbutils.h>15137 +#include <sbhndmips.h> 15138 +#include <hndmips.h> 8618 15139 +#include <trxhdr.h> 15140 + 15141 +/* Virtual IRQ base, after last hw IRQ */ 15142 +#define SBMIPS_VIRTIRQ_BASE 6 15143 + 15144 +/* # IRQs, hw and sw IRQs */ 15145 +#define SBMIPS_NUMIRQS 8 15146 + 15147 +/* Global SB handle */ 15148 +sb_t *bcm947xx_sbh = NULL; 15149 +spinlock_t bcm947xx_sbh_lock = SPIN_LOCK_UNLOCKED; 15150 + 15151 +/* Convenience */ 15152 +#define sbh bcm947xx_sbh 15153 +#define sbh_lock bcm947xx_sbh_lock 8619 15154 + 8620 15155 +extern void bcm947xx_time_init(void); 8621 15156 +extern void bcm947xx_timer_setup(struct irqaction *irq); 8622 +extern void check_enable_mips_pfc(int val);8623 15157 + 8624 15158 +#ifdef CONFIG_REMOTE_DEBUG … … 8632 15166 +#endif 8633 15167 + 8634 +/* Global SB handle */8635 +void *bcm947xx_sbh = NULL;8636 +spinlock_t bcm947xx_sbh_lock = SPIN_LOCK_UNLOCKED;8637 +8638 +/* Convenience */8639 +#define sbh bcm947xx_sbh8640 +#define sbh_lock bcm947xx_sbh_lock8641 +8642 +EXPORT_SYMBOL(bcm947xx_sbh);8643 +EXPORT_SYMBOL(bcm947xx_sbh_lock);8644 +8645 15168 +/* Kernel command line */ 8646 15169 +char arcs_cmdline[CL_SIZE] __initdata = CONFIG_CMDLINE; 15170 +extern void sb_serial_init(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift)); 8647 15171 + 8648 15172 +void … … 8715 15239 + s.io_type = SERIAL_IO_MEM; 8716 15240 + s.iomem_reg_shift = reg_shift; 15241 + 8717 15242 + if (early_serial_setup(&s) != 0) { 8718 15243 + printk(KERN_ERR "Serial setup failed!\n"); … … 8728 15253 + int i; 8729 15254 + char *value; 8730 + uint pfc_val;8731 15255 + 8732 15256 + /* Get global SB handle */ … … 8734 15258 + 8735 15259 + /* Initialize clocks and interrupts */ 8736 + sb_mips_init(sbh); 8737 + 8738 + /* 8739 + * Now that the sbh is inited set the proper PFC value 8740 + */ 8741 + pfc_val = sb_mips_get_pfc(sbh); 8742 + printk("Setting the PFC value as 0x%x\n", pfc_val); 8743 + check_enable_mips_pfc(pfc_val); 15260 + sb_mips_init(sbh, SBMIPS_VIRTIRQ_BASE); 15261 + 15262 + if (BCM330X(current_cpu_data.processor_id) && 15263 + (read_c0_diag() & BRCM_PFC_AVAIL)) { 15264 + /* 15265 + * Now that the sbh is inited set the proper PFC value 15266 + */ 15267 + printk("Setting the PFC to its default value\n"); 15268 + enable_pfc(PFC_AUTO); 15269 + } 15270 + 8744 15271 + 8745 15272 +#ifdef CONFIG_SERIAL 8746 15273 + sb_serial_init(sbh, serial_add); 15274 + 8747 15275 + /* reverse serial ports if nvram variable starts with console=ttyS1 */ 8748 15276 + /* Initialize UARTs */ … … 8780 15308 +get_system_type(void) 8781 15309 +{ 8782 + return "Broadcom BCM947XX"; 15310 + static char s[32]; 15311 + 15312 + if (bcm947xx_sbh) { 15313 + sprintf(s, "Broadcom BCM%X chip rev %d", sb_chip(bcm947xx_sbh), 15314 + sb_chiprev(bcm947xx_sbh)); 15315 + return s; 15316 + } 15317 + else 15318 + return "Broadcom BCM947XX"; 8783 15319 +} 8784 15320 + … … 8788 15324 +} 8789 15325 + 8790 diff - Nur linux-2.4.32/arch/mips/bcm947xx/time.c linux-2.4.32-freewrt/arch/mips/bcm947xx/time.c8791 --- linux -2.4.32/arch/mips/bcm947xx/time.c 1970-01-01 01:00:00.000000000 +01008792 +++ linux -2.4.32-freewrt/arch/mips/bcm947xx/time.c 2006-09-16 15:41:31.000000000 +02008793 @@ -0,0 +1, 102 @@15326 diff -urN linux.old/arch/mips/bcm947xx/sflash.c linux.dev/arch/mips/bcm947xx/sflash.c 15327 --- linux.old/arch/mips/bcm947xx/sflash.c 1970-01-01 01:00:00.000000000 +0100 15328 +++ linux.dev/arch/mips/bcm947xx/sflash.c 2006-10-02 21:19:59.000000000 +0200 15329 @@ -0,0 +1,422 @@ 8794 15330 +/* 8795 + * Copyright 2004, Broadcom Corporation 15331 + * Broadcom SiliconBackplane chipcommon serial flash interface 15332 + * 15333 + * Copyright 2006, Broadcom Corporation 8796 15334 + * All Rights Reserved. 8797 15335 + * … … 8801 15339 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 8802 15340 + * 8803 + * $Id: time.c,v 1.1 2005/03/16 13:49:59 wbx Exp $ 15341 + * $Id: sflash.c,v 1.1.1.13 2006/02/27 03:43:16 honor Exp $ 15342 + */ 15343 + 15344 +#include <osl.h> 15345 +#include <typedefs.h> 15346 +#include <sbconfig.h> 15347 +#include <sbchipc.h> 15348 +#include <mipsinc.h> 15349 +#include <bcmutils.h> 15350 +#include <bcmdevs.h> 15351 +#include <sflash.h> 15352 + 15353 +/* Private global state */ 15354 +static struct sflash sflash; 15355 + 15356 +/* Issue a serial flash command */ 15357 +static INLINE void 15358 +sflash_cmd(chipcregs_t *cc, uint opcode) 15359 +{ 15360 + W_REG(NULL, &cc->flashcontrol, SFLASH_START | opcode); 15361 + while (R_REG(NULL, &cc->flashcontrol) & SFLASH_BUSY); 15362 +} 15363 + 15364 +/* Initialize serial flash access */ 15365 +struct sflash * 15366 +sflash_init(chipcregs_t *cc) 15367 +{ 15368 + uint32 id, id2; 15369 + 15370 + bzero(&sflash, sizeof(sflash)); 15371 + 15372 + sflash.type = R_REG(NULL, &cc->capabilities) & CAP_FLASH_MASK; 15373 + 15374 + switch (sflash.type) { 15375 + case SFLASH_ST: 15376 + /* Probe for ST chips */ 15377 + sflash_cmd(cc, SFLASH_ST_DP); 15378 + sflash_cmd(cc, SFLASH_ST_RES); 15379 + id = R_REG(NULL, &cc->flashdata); 15380 + switch (id) { 15381 + case 0x11: 15382 + /* ST M25P20 2 Mbit Serial Flash */ 15383 + sflash.blocksize = 64 * 1024; 15384 + sflash.numblocks = 4; 15385 + break; 15386 + case 0x12: 15387 + /* ST M25P40 4 Mbit Serial Flash */ 15388 + sflash.blocksize = 64 * 1024; 15389 + sflash.numblocks = 8; 15390 + break; 15391 + case 0x13: 15392 + /* ST M25P80 8 Mbit Serial Flash */ 15393 + sflash.blocksize = 64 * 1024; 15394 + sflash.numblocks = 16; 15395 + break; 15396 + case 0x14: 15397 + /* ST M25P16 16 Mbit Serial Flash */ 15398 + sflash.blocksize = 64 * 1024; 15399 + sflash.numblocks = 32; 15400 + break; 15401 + case 0x15: 15402 + /* ST M25P32 32 Mbit Serial Flash */ 15403 + sflash.blocksize = 64 * 1024; 15404 + sflash.numblocks = 64; 15405 + break; 15406 + case 0x16: 15407 + /* ST M25P64 64 Mbit Serial Flash */ 15408 + sflash.blocksize = 64 * 1024; 15409 + sflash.numblocks = 128; 15410 + break; 15411 + case 0xbf: 15412 + W_REG(NULL, &cc->flashaddress, 1); 15413 + sflash_cmd(cc, SFLASH_ST_RES); 15414 + id2 = R_REG(NULL, &cc->flashdata); 15415 + if (id2 == 0x44) { 15416 + /* SST M25VF80 4 Mbit Serial Flash */ 15417 + sflash.blocksize = 64 * 1024; 15418 + sflash.numblocks = 8; 15419 + } 15420 + break; 15421 + } 15422 + break; 15423 + 15424 + case SFLASH_AT: 15425 + /* Probe for Atmel chips */ 15426 + sflash_cmd(cc, SFLASH_AT_STATUS); 15427 + id = R_REG(NULL, &cc->flashdata) & 0x3c; 15428 + switch (id) { 15429 + case 0xc: 15430 + /* Atmel AT45DB011 1Mbit Serial Flash */ 15431 + sflash.blocksize = 256; 15432 + sflash.numblocks = 512; 15433 + break; 15434 + case 0x14: 15435 + /* Atmel AT45DB021 2Mbit Serial Flash */ 15436 + sflash.blocksize = 256; 15437 + sflash.numblocks = 1024; 15438 + break; 15439 + case 0x1c: 15440 + /* Atmel AT45DB041 4Mbit Serial Flash */ 15441 + sflash.blocksize = 256; 15442 + sflash.numblocks = 2048; 15443 + break; 15444 + case 0x24: 15445 + /* Atmel AT45DB081 8Mbit Serial Flash */ 15446 + sflash.blocksize = 256; 15447 + sflash.numblocks = 4096; 15448 + break; 15449 + case 0x2c: 15450 + /* Atmel AT45DB161 16Mbit Serial Flash */ 15451 + sflash.blocksize = 512; 15452 + sflash.numblocks = 4096; 15453 + break; 15454 + case 0x34: 15455 + /* Atmel AT45DB321 32Mbit Serial Flash */ 15456 + sflash.blocksize = 512; 15457 + sflash.numblocks = 8192; 15458 + break; 15459 + case 0x3c: 15460 + /* Atmel AT45DB642 64Mbit Serial Flash */ 15461 + sflash.blocksize = 1024; 15462 + sflash.numblocks = 8192; 15463 + break; 15464 + } 15465 + break; 15466 + } 15467 + 15468 + sflash.size = sflash.blocksize * sflash.numblocks; 15469 + return sflash.size ? &sflash : NULL; 15470 +} 15471 + 15472 +/* Read len bytes starting at offset into buf. Returns number of bytes read. */ 15473 +int 15474 +sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf) 15475 +{ 15476 + int cnt; 15477 + uint32 *from, *to; 15478 + 15479 + if (!len) 15480 + return 0; 15481 + 15482 + if ((offset + len) > sflash.size) 15483 + return -22; 15484 + 15485 + if ((len >= 4) && (offset & 3)) 15486 + cnt = 4 - (offset & 3); 15487 + else if ((len >= 4) && ((uint32)buf & 3)) 15488 + cnt = 4 - ((uint32)buf & 3); 15489 + else 15490 + cnt = len; 15491 + 15492 + from = (uint32 *)KSEG1ADDR(SB_FLASH2 + offset); 15493 + to = (uint32 *)buf; 15494 + 15495 + if (cnt < 4) { 15496 + bcopy(from, to, cnt); 15497 + return cnt; 15498 + } 15499 + 15500 + while (cnt >= 4) { 15501 + *to++ = *from++; 15502 + cnt -= 4; 15503 + } 15504 + 15505 + return (len - cnt); 15506 +} 15507 + 15508 +/* Poll for command completion. Returns zero when complete. */ 15509 +int 15510 +sflash_poll(chipcregs_t *cc, uint offset) 15511 +{ 15512 + if (offset >= sflash.size) 15513 + return -22; 15514 + 15515 + switch (sflash.type) { 15516 + case SFLASH_ST: 15517 + /* Check for ST Write In Progress bit */ 15518 + sflash_cmd(cc, SFLASH_ST_RDSR); 15519 + return R_REG(NULL, &cc->flashdata) & SFLASH_ST_WIP; 15520 + case SFLASH_AT: 15521 + /* Check for Atmel Ready bit */ 15522 + sflash_cmd(cc, SFLASH_AT_STATUS); 15523 + return !(R_REG(NULL, &cc->flashdata) & SFLASH_AT_READY); 15524 + } 15525 + 15526 + return 0; 15527 +} 15528 + 15529 +/* Write len bytes starting at offset into buf. Returns number of bytes 15530 + * written. Caller should poll for completion. 15531 + */ 15532 +int 15533 +sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf) 15534 +{ 15535 + struct sflash *sfl; 15536 + int ret = 0; 15537 + bool is4712b0; 15538 + uint32 page, byte, mask; 15539 + 15540 + if (!len) 15541 + return 0; 15542 + 15543 + if ((offset + len) > sflash.size) 15544 + return -22; 15545 + 15546 + sfl = &sflash; 15547 + switch (sfl->type) { 15548 + case SFLASH_ST: 15549 + mask = R_REG(NULL, &cc->chipid); 15550 + is4712b0 = (((mask & CID_ID_MASK) == BCM4712_CHIP_ID) && 15551 + ((mask & CID_REV_MASK) == (3 << CID_REV_SHIFT))); 15552 + /* Enable writes */ 15553 + sflash_cmd(cc, SFLASH_ST_WREN); 15554 + if (is4712b0) { 15555 + mask = 1 << 14; 15556 + W_REG(NULL, &cc->flashaddress, offset); 15557 + W_REG(NULL, &cc->flashdata, *buf++); 15558 + /* Set chip select */ 15559 + OR_REG(NULL, &cc->gpioout, mask); 15560 + /* Issue a page program with the first byte */ 15561 + sflash_cmd(cc, SFLASH_ST_PP); 15562 + ret = 1; 15563 + offset++; 15564 + len--; 15565 + while (len > 0) { 15566 + if ((offset & 255) == 0) { 15567 + /* Page boundary, drop cs and return */ 15568 + AND_REG(NULL, &cc->gpioout, ~mask); 15569 + if (!sflash_poll(cc, offset)) { 15570 + /* Flash rejected command */ 15571 + return -11; 15572 + } 15573 + return ret; 15574 + } else { 15575 + /* Write single byte */ 15576 + sflash_cmd(cc, *buf++); 15577 + } 15578 + ret++; 15579 + offset++; 15580 + len--; 15581 + } 15582 + /* All done, drop cs if needed */ 15583 + if ((offset & 255) != 1) { 15584 + /* Drop cs */ 15585 + AND_REG(NULL, &cc->gpioout, ~mask); 15586 + if (!sflash_poll(cc, offset)) { 15587 + /* Flash rejected command */ 15588 + return -12; 15589 + } 15590 + } 15591 + } else { 15592 + ret = 1; 15593 + W_REG(NULL, &cc->flashaddress, offset); 15594 + W_REG(NULL, &cc->flashdata, *buf); 15595 + /* Page program */ 15596 + sflash_cmd(cc, SFLASH_ST_PP); 15597 + } 15598 + break; 15599 + case SFLASH_AT: 15600 + mask = sfl->blocksize - 1; 15601 + page = (offset & ~mask) << 1; 15602 + byte = offset & mask; 15603 + /* Read main memory page into buffer 1 */ 15604 + if (byte || (len < sfl->blocksize)) { 15605 + W_REG(NULL, &cc->flashaddress, page); 15606 + sflash_cmd(cc, SFLASH_AT_BUF1_LOAD); 15607 + /* 250 us for AT45DB321B */ 15608 + SPINWAIT(sflash_poll(cc, offset), 1000); 15609 + ASSERT(!sflash_poll(cc, offset)); 15610 + } 15611 + /* Write into buffer 1 */ 15612 + for (ret = 0; (ret < (int)len) && (byte < sfl->blocksize); ret++) { 15613 + W_REG(NULL, &cc->flashaddress, byte++); 15614 + W_REG(NULL, &cc->flashdata, *buf++); 15615 + sflash_cmd(cc, SFLASH_AT_BUF1_WRITE); 15616 + } 15617 + /* Write buffer 1 into main memory page */ 15618 + W_REG(NULL, &cc->flashaddress, page); 15619 + sflash_cmd(cc, SFLASH_AT_BUF1_PROGRAM); 15620 + break; 15621 + } 15622 + 15623 + return ret; 15624 +} 15625 + 15626 +/* Erase a region. Returns number of bytes scheduled for erasure. 15627 + * Caller should poll for completion. 15628 + */ 15629 +int 15630 +sflash_erase(chipcregs_t *cc, uint offset) 15631 +{ 15632 + struct sflash *sfl; 15633 + 15634 + if (offset >= sflash.size) 15635 + return -22; 15636 + 15637 + sfl = &sflash; 15638 + switch (sfl->type) { 15639 + case SFLASH_ST: 15640 + sflash_cmd(cc, SFLASH_ST_WREN); 15641 + W_REG(NULL, &cc->flashaddress, offset); 15642 + sflash_cmd(cc, SFLASH_ST_SE); 15643 + return sfl->blocksize; 15644 + case SFLASH_AT: 15645 + W_REG(NULL, &cc->flashaddress, offset << 1); 15646 + sflash_cmd(cc, SFLASH_AT_PAGE_ERASE); 15647 + return sfl->blocksize; 15648 + } 15649 + 15650 + return 0; 15651 +} 15652 + 15653 +/* 15654 + * writes the appropriate range of flash, a NULL buf simply erases 15655 + * the region of flash 15656 + */ 15657 +int 15658 +sflash_commit(chipcregs_t *cc, uint offset, uint len, const uchar *buf) 15659 +{ 15660 + struct sflash *sfl; 15661 + uchar *block = NULL, *cur_ptr, *blk_ptr; 15662 + uint blocksize = 0, mask, cur_offset, cur_length, cur_retlen, remainder; 15663 + uint blk_offset, blk_len, copied; 15664 + int bytes, ret = 0; 15665 + 15666 + /* Check address range */ 15667 + if (len <= 0) 15668 + return 0; 15669 + 15670 + sfl = &sflash; 15671 + if ((offset + len) > sfl->size) 15672 + return -1; 15673 + 15674 + blocksize = sfl->blocksize; 15675 + mask = blocksize - 1; 15676 + 15677 + /* Allocate a block of mem */ 15678 + if (!(block = MALLOC(NULL, blocksize))) 15679 + return -1; 15680 + 15681 + while (len) { 15682 + /* Align offset */ 15683 + cur_offset = offset & ~mask; 15684 + cur_length = blocksize; 15685 + cur_ptr = block; 15686 + 15687 + remainder = blocksize - (offset & mask); 15688 + if (len < remainder) 15689 + cur_retlen = len; 15690 + else 15691 + cur_retlen = remainder; 15692 + 15693 + /* buf == NULL means erase only */ 15694 + if (buf) { 15695 + /* Copy existing data into holding block if necessary */ 15696 + if ((offset & mask) || (len < blocksize)) { 15697 + blk_offset = cur_offset; 15698 + blk_len = cur_length; 15699 + blk_ptr = cur_ptr; 15700 + 15701 + /* Copy entire block */ 15702 + while (blk_len) { 15703 + copied = sflash_read(cc, blk_offset, blk_len, blk_ptr); 15704 + blk_offset += copied; 15705 + blk_len -= copied; 15706 + blk_ptr += copied; 15707 + } 15708 + } 15709 + 15710 + /* Copy input data into holding block */ 15711 + memcpy(cur_ptr + (offset & mask), buf, cur_retlen); 15712 + } 15713 + 15714 + /* Erase block */ 15715 + if ((ret = sflash_erase(cc, (uint) cur_offset)) < 0) 15716 + goto done; 15717 + while (sflash_poll(cc, (uint) cur_offset)); 15718 + 15719 + /* buf == NULL means erase only */ 15720 + if (!buf) { 15721 + offset += cur_retlen; 15722 + len -= cur_retlen; 15723 + continue; 15724 + } 15725 + 15726 + /* Write holding block */ 15727 + while (cur_length > 0) { 15728 + if ((bytes = sflash_write(cc, 15729 + (uint) cur_offset, 15730 + (uint) cur_length, 15731 + (uchar *) cur_ptr)) < 0) { 15732 + ret = bytes; 15733 + goto done; 15734 + } 15735 + while (sflash_poll(cc, (uint) cur_offset)); 15736 + cur_offset += bytes; 15737 + cur_length -= bytes; 15738 + cur_ptr += bytes; 15739 + } 15740 + 15741 + offset += cur_retlen; 15742 + len -= cur_retlen; 15743 + buf += cur_retlen; 15744 + } 15745 + 15746 + ret = len; 15747 +done: 15748 + if (block) 15749 + MFREE(NULL, block, blocksize); 15750 + return ret; 15751 +} 15752 diff -urN linux.old/arch/mips/bcm947xx/time.c linux.dev/arch/mips/bcm947xx/time.c 15753 --- linux.old/arch/mips/bcm947xx/time.c 1970-01-01 01:00:00.000000000 +0100 15754 +++ linux.dev/arch/mips/bcm947xx/time.c 2006-10-02 21:19:59.000000000 +0200 15755 @@ -0,0 +1,104 @@ 15756 +/* 15757 + * Copyright 2006, Broadcom Corporation 15758 + * All Rights Reserved. 15759 + * 15760 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 15761 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 15762 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 15763 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 15764 + * 15765 + * $Id: time.c,v 1.1.1.10 2006/02/27 03:42:55 honor Exp $ 8804 15766 + */ 8805 15767 +#include <linux/config.h> … … 8814 15776 + 8815 15777 +#include <typedefs.h> 15778 +#include <osl.h> 8816 15779 +#include <bcmnvram.h> 8817 15780 +#include <sbconfig.h> 8818 15781 +#include <sbextif.h> 8819 15782 +#include <sbutils.h> 8820 +#include <sbmips.h> 15783 +#include <hndmips.h> 15784 +#include <mipsinc.h> 15785 +#include <hndcpu.h> 8821 15786 + 8822 15787 +/* Global SB handle */ … … 8845 15810 + write_c0_compare(0xffff); 8846 15811 + 8847 + if (!(hz = sb_ mips_clock(sbh)))15812 + if (!(hz = sb_cpu_clock(sbh))) 8848 15813 + hz = 100000000; 8849 15814 + … … 8856 15821 + /* Set watchdog interval in ms */ 8857 15822 + watchdog = simple_strtoul(nvram_safe_get("watchdog"), NULL, 0); 8858 + 8859 + /* Please set the watchdog to 3 sec if it is less than 3 but not equal to 0 */15823 + 15824 + /* Please set the watchdog to 3 sec if it is less than 3 but not equal to 0 */ 8860 15825 + if (watchdog > 0) { 8861 15826 + if (watchdog < 3000) 8862 15827 + watchdog = 3000; 8863 15828 + } 8864 +8865 15829 + 8866 15830 + /* Set panic timeout in seconds */ … … 8894 15858 + setup_irq(7, &bcm947xx_timer_irqaction); 8895 15859 +} 8896 diff - Nur linux-2.4.32/arch/mips/config-shared.in linux-2.4.32-freewrt/arch/mips/config-shared.in8897 --- linux -2.4.32/arch/mips/config-shared.in 2005-01-19 15:09:27.000000000 +01008898 +++ linux -2.4.32-freewrt/arch/mips/config-shared.in 2006-09-16 15:41:31.000000000 +02008899 @@ -20 5,6 +205,14 @@15860 diff -urN linux.old/arch/mips/config-shared.in linux.dev/arch/mips/config-shared.in 15861 --- linux.old/arch/mips/config-shared.in 2006-10-02 21:23:10.000000000 +0200 15862 +++ linux.dev/arch/mips/config-shared.in 2006-10-02 21:19:59.000000000 +0200 15863 @@ -208,6 +208,14 @@ 8900 15864 fi 8901 15865 define_bool CONFIG_MIPS_RTC y … … 8912 15876 bool 'Support for TANBAC TB0226 (Mbase)' CONFIG_TANBAC_TB0226 8913 15877 bool 'Support for TANBAC TB0229 (VR4131DIMM)' CONFIG_TANBAC_TB0229 8914 @@ -22 6,6 +234,11 @@15878 @@ -229,6 +237,11 @@ 8915 15879 define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n 8916 15880 … … 8924 15888 # 8925 15889 if [ "$CONFIG_ACER_PICA_61" = "y" ]; then 8926 @@ -5 33,6 +546,13@@15890 @@ -554,6 +567,12 @@ 8927 15891 define_bool CONFIG_SWAP_IO_SPACE_L y 8928 15892 define_bool CONFIG_BOOT_ELF32 y … … 8933 15897 + define_bool CONFIG_NEW_TIME_C y 8934 15898 + define_bool CONFIG_NEW_IRQ y 8935 + define_bool CONFIG_HND y8936 15899 +fi 8937 15900 if [ "$CONFIG_SNI_RM200_PCI" = "y" ]; then 8938 15901 define_bool CONFIG_ARC32 y 8939 15902 define_bool CONFIG_ARC_MEMORY y 8940 @@ -10 11,7 +1031,11 @@15903 @@ -1042,7 +1061,11 @@ 8941 15904 8942 15905 bool 'Are you using a crosscompiler' CONFIG_CROSSCOMPILE … … 8951 15914 if [ "$CONFIG_KGDB" = "y" ]; then 8952 15915 define_bool CONFIG_DEBUG_INFO y 8953 diff - Nur linux-2.4.32/arch/mips/kernel/cpu-probe.c linux-2.4.32-freewrt/arch/mips/kernel/cpu-probe.c8954 --- linux -2.4.32/arch/mips/kernel/cpu-probe.c 2005-01-19 15:09:29.000000000 +01008955 +++ linux -2.4.32-freewrt/arch/mips/kernel/cpu-probe.c 2006-09-16 15:41:31.000000000 +02008956 @@ -1 74,7 +174,7 @@15916 diff -urN linux.old/arch/mips/kernel/cpu-probe.c linux.dev/arch/mips/kernel/cpu-probe.c 15917 --- linux.old/arch/mips/kernel/cpu-probe.c 2006-10-02 21:23:10.000000000 +0200 15918 +++ linux.dev/arch/mips/kernel/cpu-probe.c 2006-10-02 21:19:59.000000000 +0200 15919 @@ -162,7 +162,7 @@ 8957 15920 8958 15921 static inline void cpu_probe_legacy(struct cpuinfo_mips *c) … … 8963 15926 c->cputype = CPU_R2000; 8964 15927 c->isa_level = MIPS_CPU_ISA_I; 8965 @@ -1 84,7 +184,7 @@15928 @@ -172,7 +172,7 @@ 8966 15929 c->tlbsize = 64; 8967 15930 break; … … 8972 15935 c->cputype = CPU_R3081E; 8973 15936 else 8974 @@ -1 99,12 +199,12 @@15937 @@ -187,12 +187,12 @@ 8975 15938 break; 8976 15939 case PRID_IMP_R4000: … … 8987 15950 else 8988 15951 c->cputype = CPU_R4000SC; 8989 @@ -4 50,7 +450,7 @@15952 @@ -438,7 +438,7 @@ 8990 15953 static inline void cpu_probe_mips(struct cpuinfo_mips *c) 8991 15954 { … … 8996 15959 c->cputype = CPU_4KC; 8997 15960 c->isa_level = MIPS_CPU_ISA_M32; 8998 @@ -4 91,10 +491,10 @@15961 @@ -479,10 +479,10 @@ 8999 15962 { 9000 15963 decode_config1(c); … … 9009 15972 c->cputype = CPU_AU1000; 9010 15973 break; 9011 @@ -5 22,10 +522,34 @@15974 @@ -510,10 +510,34 @@ 9012 15975 } 9013 15976 } … … 9045 16008 c->cputype = CPU_SB1; 9046 16009 c->isa_level = MIPS_CPU_ISA_M64; 9047 @@ -5 47,7 +571,7 @@16010 @@ -535,7 +559,7 @@ 9048 16011 static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c) 9049 16012 { … … 9054 16017 c->cputype = CPU_SR71000; 9055 16018 c->isa_level = MIPS_CPU_ISA_M64; 9056 @@ -5 72,7 +596,7 @@16019 @@ -560,7 +584,7 @@ 9057 16020 c->cputype = CPU_UNKNOWN; 9058 16021 … … 9063 16026 case PRID_COMP_LEGACY: 9064 16027 cpu_probe_legacy(c); 9065 @@ -5 83,6 +607,9 @@16028 @@ -571,6 +595,9 @@ 9066 16029 case PRID_COMP_ALCHEMY: 9067 16030 cpu_probe_alchemy(c); … … 9073 16036 cpu_probe_sibyte(c); 9074 16037 break; 9075 diff - Nur linux-2.4.32/arch/mips/kernel/head.S linux-2.4.32-freewrt/arch/mips/kernel/head.S9076 --- linux -2.4.32/arch/mips/kernel/head.S 2005-01-19 15:09:29.000000000 +01009077 +++ linux -2.4.32-freewrt/arch/mips/kernel/head.S 2006-09-16 15:41:31.000000000 +020016038 diff -urN linux.old/arch/mips/kernel/head.S linux.dev/arch/mips/kernel/head.S 16039 --- linux.old/arch/mips/kernel/head.S 2006-10-02 21:23:10.000000000 +0200 16040 +++ linux.dev/arch/mips/kernel/head.S 2006-10-02 21:19:59.000000000 +0200 9078 16041 @@ -28,12 +28,20 @@ 9079 16042 #include <asm/mipsregs.h> … … 9098 16061 /* The following two symbols are used for kernel profiling. */ 9099 16062 EXPORT(stext) 9100 diff - Nur linux-2.4.32/arch/mips/kernel/proc.c linux-2.4.32-freewrt/arch/mips/kernel/proc.c9101 --- linux -2.4.32/arch/mips/kernel/proc.c 2005-01-19 15:09:29.000000000 +01009102 +++ linux -2.4.32-freewrt/arch/mips/kernel/proc.c 2006-09-16 15:41:31.000000000 +020016063 diff -urN linux.old/arch/mips/kernel/proc.c linux.dev/arch/mips/kernel/proc.c 16064 --- linux.old/arch/mips/kernel/proc.c 2006-10-02 21:23:10.000000000 +0200 16065 +++ linux.dev/arch/mips/kernel/proc.c 2006-10-02 21:19:59.000000000 +0200 9103 16066 @@ -78,9 +78,10 @@ 9104 16067 [CPU_AU1550] "Au1550", … … 9113 16076 { 9114 16077 unsigned int version = current_cpu_data.processor_id; 9115 diff - Nur linux-2.4.32/arch/mips/kernel/setup.c linux-2.4.32-freewrt/arch/mips/kernel/setup.c9116 --- linux -2.4.32/arch/mips/kernel/setup.c 2005-01-19 15:09:29.000000000 +01009117 +++ linux -2.4.32-freewrt/arch/mips/kernel/setup.c 2006-09-16 15:41:31.000000000 +02009118 @@ -49 5,6 +495,7 @@16078 diff -urN linux.old/arch/mips/kernel/setup.c linux.dev/arch/mips/kernel/setup.c 16079 --- linux.old/arch/mips/kernel/setup.c 2006-10-02 21:23:10.000000000 +0200 16080 +++ linux.dev/arch/mips/kernel/setup.c 2006-10-02 21:19:59.000000000 +0200 16081 @@ -493,6 +493,7 @@ 9119 16082 void swarm_setup(void); 9120 16083 void hp_setup(void); … … 9124 16087 9125 16088 frame_info_init(); 9126 @@ -69 3,6 +694,11 @@16089 @@ -691,6 +692,11 @@ 9127 16090 pmc_yosemite_setup(); 9128 16091 break; … … 9136 16099 panic("Unsupported architecture"); 9137 16100 } 9138 diff - Nur linux-2.4.32/arch/mips/kernel/traps.c linux-2.4.32-freewrt/arch/mips/kernel/traps.c9139 --- linux -2.4.32/arch/mips/kernel/traps.c 2005-01-19 15:09:29.000000000 +01009140 +++ linux -2.4.32-freewrt/arch/mips/kernel/traps.c 2006-09-16 15:41:31.000000000 +02009141 @@ -9 13,6 +913,7 @@16101 diff -urN linux.old/arch/mips/kernel/traps.c linux.dev/arch/mips/kernel/traps.c 16102 --- linux.old/arch/mips/kernel/traps.c 2006-10-02 21:23:10.000000000 +0200 16103 +++ linux.dev/arch/mips/kernel/traps.c 2006-10-02 21:19:59.000000000 +0200 16104 @@ -920,6 +920,7 @@ 9142 16105 void __init trap_init(void) 9143 16106 { … … 9147 16110 extern char except_vec_ejtag_debug; 9148 16111 extern char except_vec4; 9149 @@ -92 2,6 +923,7 @@16112 @@ -927,6 +928,7 @@ 9150 16113 9151 16114 /* Copy the generic exception handler code to it's final destination. */ … … 9155 16118 /* 9156 16119 * Setup default vectors 9157 @@ -98 0,6 +982,12 @@16120 @@ -985,6 +987,12 @@ 9158 16121 set_except_vector(13, handle_tr); 9159 16122 set_except_vector(22, handle_mdmx); … … 9168 16131 set_except_vector(15, handle_fpe); 9169 16132 9170 diff - Nur linux-2.4.32/arch/mips/Makefile linux-2.4.32-freewrt/arch/mips/Makefile9171 --- linux -2.4.32/arch/mips/Makefile 2005-01-19 15:09:26.000000000 +01009172 +++ linux -2.4.32-freewrt/arch/mips/Makefile 2006-09-16 15:41:31.000000000 +02009173 @@ -7 15,6 +715,19 @@16133 diff -urN linux.old/arch/mips/Makefile linux.dev/arch/mips/Makefile 16134 --- linux.old/arch/mips/Makefile 2006-10-02 21:23:10.000000000 +0200 16135 +++ linux.dev/arch/mips/Makefile 2006-10-02 21:19:59.000000000 +0200 16136 @@ -726,6 +726,19 @@ 9174 16137 endif 9175 16138 … … 9178 16141 +# 9179 16142 +ifdef CONFIG_BCM947XX 9180 +LIBS += arch/mips/bcm947xx/generic/brcm.o arch/mips/bcm947xx/bcm947xx.o9181 +SUBDIRS += arch/mips/bcm947xx/generic arch/mips/bcm947xx9182 +LOADADDR := 0x8000100016143 +LIBS += arch/mips/bcm947xx/generic/brcm.o arch/mips/bcm947xx/bcm947xx.o 16144 +SUBDIRS += arch/mips/bcm947xx/generic arch/mips/bcm947xx 16145 +LOADADDR := 0x80001000 9183 16146 + 9184 16147 +zImage: vmlinux … … 9191 16154 # error messages during linking. Select a default linkscript if 9192 16155 # none has been choosen above. 9193 @@ -7 67,6 +780,7 @@16156 @@ -778,6 +791,7 @@ 9194 16157 $(MAKE) -C arch/$(ARCH)/tools clean 9195 16158 $(MAKE) -C arch/mips/baget clean … … 9199 16162 archmrproper: 9200 16163 @$(MAKEBOOT) mrproper 9201 diff - Nur linux-2.4.32/arch/mips/mm/c-r4k.c linux-2.4.32-freewrt/arch/mips/mm/c-r4k.c9202 --- linux -2.4.32/arch/mips/mm/c-r4k.c 2005-01-19 15:09:29.000000000 +01009203 +++ linux -2.4.32-freewrt/arch/mips/mm/c-r4k.c 2006-09-16 15:41:31.000000000 +02009204 @@ -11 14,3 +1114,47 @@16164 diff -urN linux.old/arch/mips/mm/c-r4k.c linux.dev/arch/mips/mm/c-r4k.c 16165 --- linux.old/arch/mips/mm/c-r4k.c 2006-10-02 21:23:10.000000000 +0200 16166 +++ linux.dev/arch/mips/mm/c-r4k.c 2006-10-02 21:19:59.000000000 +0200 16167 @@ -1166,3 +1166,47 @@ 9205 16168 build_clear_page(); 9206 16169 build_copy_page(); … … 9250 16213 + 9251 16214 + 9252 diff - Nur linux-2.4.32/arch/mips/pci/Makefile linux-2.4.32-freewrt/arch/mips/pci/Makefile9253 --- linux -2.4.32/arch/mips/pci/Makefile 2005-01-19 15:09:29.000000000 +01009254 +++ linux -2.4.32-freewrt/arch/mips/pci/Makefile 2006-09-16 15:41:31.000000000 +020016215 diff -urN linux.old/arch/mips/pci/Makefile linux.dev/arch/mips/pci/Makefile 16216 --- linux.old/arch/mips/pci/Makefile 2006-10-02 21:23:10.000000000 +0200 16217 +++ linux.dev/arch/mips/pci/Makefile 2006-10-02 21:19:59.000000000 +0200 9255 16218 @@ -13,7 +13,9 @@ 9256 16219 obj-$(CONFIG_MIPS_MSC) += ops-msc.o … … 9263 16226 9264 16227 include $(TOPDIR)/Rules.make 9265 diff - Nur linux-2.4.32/drivers/char/serial.c linux-2.4.32-freewrt/drivers/char/serial.c9266 --- linux -2.4.32/drivers/char/serial.c 2005-11-16 20:12:54.000000000 +01009267 +++ linux -2.4.32-freewrt/drivers/char/serial.c 2006-09-16 15:41:31.000000000 +02009268 @@ -4 22,6 +422,10 @@16228 diff -urN linux.old/drivers/char/serial.c linux.dev/drivers/char/serial.c 16229 --- linux.old/drivers/char/serial.c 2006-10-02 21:23:10.000000000 +0200 16230 +++ linux.dev/drivers/char/serial.c 2006-10-02 21:19:59.000000000 +0200 16231 @@ -444,6 +444,10 @@ 9269 16232 return inb(info->port+1); 9270 16233 #endif … … 9277 16240 (offset<<info->iomem_reg_shift)); 9278 16241 default: 9279 @@ -4 42,6 +446,9 @@16242 @@ -464,6 +468,9 @@ 9280 16243 case SERIAL_IO_MEM: 9281 16244 writeb(value, (unsigned long) info->iomem_base + … … 9287 16250 default: 9288 16251 outb(value, info->port+offset); 9289 @@ -17 04,7 +1711,7 @@16252 @@ -1728,7 +1735,7 @@ 9290 16253 /* Special case since 134 is really 134.5 */ 9291 16254 quot = (2*baud_base / 269); … … 9296 16259 /* If the quotient is zero refuse the change */ 9297 16260 if (!quot && old_termios) { 9298 @@ -17 21,12 +1728,12 @@16261 @@ -1745,12 +1752,12 @@ 9299 16262 /* Special case since 134 is really 134.5 */ 9300 16263 quot = (2*baud_base / 269); … … 9311 16274 * Work around a bug in the Oxford Semiconductor 952 rev B 9312 16275 * chip which causes it to seriously miscalculate baud rates 9313 @@ -59 82,6 +5989,13 @@16276 @@ -5994,6 +6001,13 @@ 9314 16277 * Divisor, bytesize and parity 9315 16278 */ … … 9325 16288 state->flags |= ASYNC_CONS_FLOW; 9326 16289 info = &async_sercons; 9327 @@ - 5995,7 +6009,7 @@16290 @@ -6007,7 +6021,7 @@ 9328 16291 info->io_type = state->io_type; 9329 16292 info->iomem_base = state->iomem_base; … … 9334 16297 #if defined(__powerpc__) || defined(__alpha__) 9335 16298 cval >>= 8; 9336 diff -Nur linux-2.4.32/drivers/net/Config.in linux-2.4.32-freewrt/drivers/net/Config.in 9337 --- linux-2.4.32/drivers/net/Config.in 2005-01-19 15:09:56.000000000 +0100 9338 +++ linux-2.4.32-freewrt/drivers/net/Config.in 2006-09-16 15:41:31.000000000 +0200 9339 @@ -2,6 +2,8 @@ 9340 # Network device configuration 9341 # 9342 9343 +tristate 'Broadcom Home Network Division' CONFIG_HND $CONFIG_PCI 9344 + 9345 source drivers/net/arcnet/Config.in 9346 9347 tristate 'Dummy net driver support' CONFIG_DUMMY 9348 diff -Nur linux-2.4.32/drivers/net/hnd/bcmsrom.c linux-2.4.32-freewrt/drivers/net/hnd/bcmsrom.c 9349 --- linux-2.4.32/drivers/net/hnd/bcmsrom.c 1970-01-01 01:00:00.000000000 +0100 9350 +++ linux-2.4.32-freewrt/drivers/net/hnd/bcmsrom.c 2006-09-16 15:41:31.000000000 +0200 9351 @@ -0,0 +1,716 @@ 9352 +/* 9353 + * Misc useful routines to access NIC SROM/OTP . 9354 + * 9355 + * Copyright 2004, Broadcom Corporation 9356 + * All Rights Reserved. 9357 + * 9358 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 9359 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 9360 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 9361 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 9362 + * $Id$ 9363 + */ 9364 + 9365 +#include <typedefs.h> 9366 +#include <osl.h> 9367 +#include <bcmutils.h> 9368 +#include <bcmsrom.h> 9369 +#include <bcmdevs.h> 9370 +#include <bcmendian.h> 9371 +#include <sbpcmcia.h> 9372 +#include <pcicfg.h> 9373 +#include <sbutils.h> 9374 + 9375 +struct ether_addr { 9376 + uint8 octet[6]; 9377 +} PACKED; 9378 + 9379 +#define VARS_MAX 4096 /* should be reduced */ 9380 + 9381 +#define WRITE_ENABLE_DELAY 500 /* 500 ms after write enable/disable toggle */ 9382 +#define WRITE_WORD_DELAY 20 /* 20 ms between each word write */ 9383 + 9384 +static int initvars_srom_pci(void *osh, void *curmap, char **vars, int *count); 9385 +static int initvars_cis_pcmcia(void *sbh, void *curmap, void *osh, char **vars, int *count); 9386 +static int srom_parsecis(void *osh, uint8 *cis, char **vars, int *count); 9387 +static int sprom_cmd_pcmcia(void *osh, uint8 cmd); 9388 +static int sprom_read_pcmcia(void *osh, uint16 addr, uint16 *data); 9389 +static int sprom_write_pcmcia(void *osh, uint16 addr, uint16 data); 9390 +static int sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc); 9391 + 9392 +/* 9393 + * Initialize local vars from the right source for this platform. 9394 + * Return 0 on success, nonzero on error. 9395 + */ 9396 +int 9397 +srom_var_init(void *sbh, uint bustype, void *curmap, void *osh, char **vars, int *count) 9398 +{ 9399 + ASSERT(bustype == BUSTYPE(bustype)); 9400 + if (vars == NULL) 9401 + return (0); 9402 + 9403 + switch (BUSTYPE(bustype)) { 9404 + case SB_BUS: 9405 + /* These two could be asserts ... */ 9406 + *vars = NULL; 9407 + *count = 0; 9408 + return(0); 9409 + 9410 + case PCI_BUS: 9411 + ASSERT(curmap); /* can not be NULL */ 9412 + return(initvars_srom_pci(osh, curmap, vars, count)); 9413 + 9414 + case PCMCIA_BUS: 9415 + return(initvars_cis_pcmcia(sbh, curmap, osh, vars, count)); 9416 + 9417 + 9418 + default: 9419 + ASSERT(0); 9420 + } 9421 + return (-1); 9422 +} 9423 + 9424 +/* support only 16-bit word read from srom */ 9425 +int 9426 +srom_read(uint bustype, void *curmap, void *osh, uint byteoff, uint nbytes, uint16 *buf) 9427 +{ 9428 + void *srom; 9429 + uint i, off, nw; 9430 + 9431 + ASSERT(bustype == BUSTYPE(bustype)); 9432 + 9433 + /* check input - 16-bit access only */ 9434 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2)) 9435 + return 1; 9436 + 9437 + off = byteoff / 2; 9438 + nw = nbytes / 2; 9439 + 9440 + if (BUSTYPE(bustype) == PCI_BUS) { 9441 + if (!curmap) 9442 + return 1; 9443 + srom = (uchar*)curmap + PCI_BAR0_SPROM_OFFSET; 9444 + if (sprom_read_pci(srom, off, buf, nw, FALSE)) 9445 + return 1; 9446 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) { 9447 + for (i = 0; i < nw; i++) { 9448 + if (sprom_read_pcmcia(osh, (uint16)(off + i), (uint16*)(buf + i))) 9449 + return 1; 9450 + } 9451 + } else { 9452 + return 1; 9453 + } 9454 + 9455 + return 0; 9456 +} 9457 + 9458 +/* support only 16-bit word write into srom */ 9459 +int 9460 +srom_write(uint bustype, void *curmap, void *osh, uint byteoff, uint nbytes, uint16 *buf) 9461 +{ 9462 + uint16 *srom; 9463 + uint i, off, nw, crc_range; 9464 + uint16 image[SPROM_SIZE], *p; 9465 + uint8 crc; 9466 + volatile uint32 val32; 9467 + 9468 + ASSERT(bustype == BUSTYPE(bustype)); 9469 + 9470 + /* check input - 16-bit access only */ 9471 + if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2)) 9472 + return 1; 9473 + 9474 + crc_range = (((BUSTYPE(bustype) == PCMCIA_BUS) || (BUSTYPE(bustype) == SDIO_BUS)) ? SPROM_SIZE : SPROM_CRC_RANGE) * 2; 9475 + 9476 + /* if changes made inside crc cover range */ 9477 + if (byteoff < crc_range) { 9478 + nw = (((byteoff + nbytes) > crc_range) ? byteoff + nbytes : crc_range) / 2; 9479 + /* read data including entire first 64 words from srom */ 9480 + if (srom_read(bustype, curmap, osh, 0, nw * 2, image)) 9481 + return 1; 9482 + /* make changes */ 9483 + bcopy((void*)buf, (void*)&image[byteoff / 2], nbytes); 9484 + /* calculate crc */ 9485 + htol16_buf(image, crc_range); 9486 + crc = ~hndcrc8((uint8 *)image, crc_range - 1, CRC8_INIT_VALUE); 9487 + ltoh16_buf(image, crc_range); 9488 + image[(crc_range / 2) - 1] = (crc << 8) | (image[(crc_range / 2) - 1] & 0xff); 9489 + p = image; 9490 + off = 0; 9491 + } else { 9492 + p = buf; 9493 + off = byteoff / 2; 9494 + nw = nbytes / 2; 9495 + } 9496 + 9497 + if (BUSTYPE(bustype) == PCI_BUS) { 9498 + srom = (uint16*)((uchar*)curmap + PCI_BAR0_SPROM_OFFSET); 9499 + /* enable writes to the SPROM */ 9500 + val32 = OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32)); 9501 + val32 |= SPROM_WRITEEN; 9502 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32); 9503 + bcm_mdelay(WRITE_ENABLE_DELAY); 9504 + /* write srom */ 9505 + for (i = 0; i < nw; i++) { 9506 + W_REG(&srom[off + i], p[i]); 9507 + bcm_mdelay(WRITE_WORD_DELAY); 9508 + } 9509 + /* disable writes to the SPROM */ 9510 + OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32 & ~SPROM_WRITEEN); 9511 + } else if (BUSTYPE(bustype) == PCMCIA_BUS) { 9512 + /* enable writes to the SPROM */ 9513 + if (sprom_cmd_pcmcia(osh, SROM_WEN)) 9514 + return 1; 9515 + bcm_mdelay(WRITE_ENABLE_DELAY); 9516 + /* write srom */ 9517 + for (i = 0; i < nw; i++) { 9518 + sprom_write_pcmcia(osh, (uint16)(off + i), p[i]); 9519 + bcm_mdelay(WRITE_WORD_DELAY); 9520 + } 9521 + /* disable writes to the SPROM */ 9522 + if (sprom_cmd_pcmcia(osh, SROM_WDS)) 9523 + return 1; 9524 + } else { 9525 + return 1; 9526 + } 9527 + 9528 + bcm_mdelay(WRITE_ENABLE_DELAY); 9529 + return 0; 9530 +} 9531 + 9532 + 9533 +static int 9534 +srom_parsecis(void *osh, uint8 *cis, char **vars, int *count) 9535 +{ 9536 + char eabuf[32]; 9537 + char *vp, *base; 9538 + uint8 tup, tlen, sromrev = 1; 9539 + int i, j; 9540 + uint varsize; 9541 + bool ag_init = FALSE; 9542 + uint16 w; 9543 + 9544 + ASSERT(vars); 9545 + ASSERT(count); 9546 + 9547 + base = vp = MALLOC(osh, VARS_MAX); 9548 + ASSERT(vp); 9549 + 9550 + i = 0; 9551 + do { 9552 + tup = cis[i++]; 9553 + tlen = cis[i++]; 9554 + if ((i + tlen) >= CIS_SIZE) 9555 + break; 9556 + 9557 + switch (tup) { 9558 + case CISTPL_MANFID: 9559 + vp += sprintf(vp, "manfid=%d", (cis[i + 1] << 8) + cis[i]); 9560 + vp++; 9561 + vp += sprintf(vp, "prodid=%d", (cis[i + 3] << 8) + cis[i + 2]); 9562 + vp++; 9563 + break; 9564 + 9565 + case CISTPL_FUNCE: 9566 + if (cis[i] == LAN_NID) { 9567 + ASSERT(cis[i + 1] == 6); 9568 + bcm_ether_ntoa((uchar*)&cis[i + 2], eabuf); 9569 + vp += sprintf(vp, "il0macaddr=%s", eabuf); 9570 + vp++; 9571 + } 9572 + break; 9573 + 9574 + case CISTPL_CFTABLE: 9575 + vp += sprintf(vp, "regwindowsz=%d", (cis[i + 7] << 8) | cis[i + 6]); 9576 + vp++; 9577 + break; 9578 + 9579 + case CISTPL_BRCM_HNBU: 9580 + switch (cis[i]) { 9581 + case HNBU_CHIPID: 9582 + vp += sprintf(vp, "vendid=%d", (cis[i + 2] << 8) + cis[i + 1]); 9583 + vp++; 9584 + vp += sprintf(vp, "devid=%d", (cis[i + 4] << 8) + cis[i + 3]); 9585 + vp++; 9586 + if (tlen == 7) { 9587 + vp += sprintf(vp, "chiprev=%d", (cis[i + 6] << 8) + cis[i + 5]); 9588 + vp++; 9589 + } 9590 + break; 9591 + 9592 + case HNBU_BOARDREV: 9593 + vp += sprintf(vp, "boardrev=%d", cis[i + 1]); 9594 + vp++; 9595 + break; 9596 + 9597 + case HNBU_AA: 9598 + vp += sprintf(vp, "aa0=%d", cis[i + 1]); 9599 + vp++; 9600 + break; 9601 + 9602 + case HNBU_AG: 9603 + vp += sprintf(vp, "ag0=%d", cis[i + 1]); 9604 + vp++; 9605 + ag_init = TRUE; 9606 + break; 9607 + 9608 + case HNBU_CC: 9609 + vp += sprintf(vp, "cc=%d", cis[i + 1]); 9610 + vp++; 9611 + break; 9612 + 9613 + case HNBU_PAPARMS: 9614 + vp += sprintf(vp, "pa0maxpwr=%d", cis[i + tlen - 1]); 9615 + vp++; 9616 + if (tlen == 9) { 9617 + /* New version */ 9618 + for (j = 0; j < 3; j++) { 9619 + vp += sprintf(vp, "pa0b%d=%d", j, 9620 + (cis[i + (j * 2) + 2] << 8) + cis[i + (j * 2) + 1]); 9621 + vp++; 9622 + } 9623 + vp += sprintf(vp, "pa0itssit=%d", cis[i + 7]); 9624 + vp++; 9625 + } 9626 + break; 9627 + 9628 + case HNBU_OEM: 9629 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x", 9630 + cis[i + 1], cis[i + 2], cis[i + 3], cis[i + 4], 9631 + cis[i + 5], cis[i + 6], cis[i + 7], cis[i + 8]); 9632 + vp++; 9633 + break; 9634 + case HNBU_BOARDFLAGS: 9635 + w = (cis[i + 2] << 8) + cis[i + 1]; 9636 + if (w == 0xffff) w = 0; 9637 + vp += sprintf(vp, "boardflags=%d", w); 9638 + vp++; 9639 + break; 9640 + case HNBU_LED: 9641 + if (cis[i + 1] != 0xff) { 9642 + vp += sprintf(vp, "wl0gpio0=%d", cis[i + 1]); 9643 + vp++; 9644 + } 9645 + if (cis[i + 2] != 0xff) { 9646 + vp += sprintf(vp, "wl0gpio1=%d", cis[i + 2]); 9647 + vp++; 9648 + } 9649 + if (cis[i + 3] != 0xff) { 9650 + vp += sprintf(vp, "wl0gpio2=%d", cis[i + 3]); 9651 + vp++; 9652 + } 9653 + if (cis[i + 4] != 0xff) { 9654 + vp += sprintf(vp, "wl0gpio3=%d", cis[i + 4]); 9655 + vp++; 9656 + } 9657 + break; 9658 + } 9659 + break; 9660 + 9661 + } 9662 + i += tlen; 9663 + } while (tup != 0xff); 9664 + 9665 + /* Set the srom version */ 9666 + vp += sprintf(vp, "sromrev=%d", sromrev); 9667 + vp++; 9668 + 9669 + /* For now just set boardflags2 to zero */ 9670 + vp += sprintf(vp, "boardflags2=0"); 9671 + vp++; 9672 + 9673 + /* if there is no antenna gain field, set default */ 9674 + if (ag_init == FALSE) { 9675 + vp += sprintf(vp, "ag0=%d", 0xff); 9676 + vp++; 9677 + } 9678 + 9679 + /* final nullbyte terminator */ 9680 + *vp++ = '\0'; 9681 + varsize = (uint)(vp - base); 9682 + 9683 + ASSERT((vp - base) < VARS_MAX); 9684 + 9685 + if (varsize == VARS_MAX) { 9686 + *vars = base; 9687 + } else { 9688 + vp = MALLOC(osh, varsize); 9689 + ASSERT(vp); 9690 + bcopy(base, vp, varsize); 9691 + MFREE(osh, base, VARS_MAX); 9692 + *vars = vp; 9693 + } 9694 + *count = varsize; 9695 + 9696 + return (0); 9697 +} 9698 + 9699 + 9700 +/* set PCMCIA sprom command register */ 9701 +static int 9702 +sprom_cmd_pcmcia(void *osh, uint8 cmd) 9703 +{ 9704 + uint8 status = 0; 9705 + uint wait_cnt = 1000; 9706 + 9707 + /* write sprom command register */ 9708 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_CS, &cmd, 1); 9709 + 9710 + /* wait status */ 9711 + while (wait_cnt--) { 9712 + OSL_PCMCIA_READ_ATTR(osh, SROM_CS, &status, 1); 9713 + if (status & SROM_DONE) 9714 + return 0; 9715 + } 9716 + 9717 + return 1; 9718 +} 9719 + 9720 +/* read a word from the PCMCIA srom */ 9721 +static int 9722 +sprom_read_pcmcia(void *osh, uint16 addr, uint16 *data) 9723 +{ 9724 + uint8 addr_l, addr_h, data_l, data_h; 9725 + 9726 + addr_l = (uint8)((addr * 2) & 0xff); 9727 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff); 9728 + 9729 + /* set address */ 9730 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1); 9731 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1); 9732 + 9733 + /* do read */ 9734 + if (sprom_cmd_pcmcia(osh, SROM_READ)) 9735 + return 1; 9736 + 9737 + /* read data */ 9738 + data_h = data_l = 0; 9739 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAH, &data_h, 1); 9740 + OSL_PCMCIA_READ_ATTR(osh, SROM_DATAL, &data_l, 1); 9741 + 9742 + *data = (data_h << 8) | data_l; 9743 + return 0; 9744 +} 9745 + 9746 +/* write a word to the PCMCIA srom */ 9747 +static int 9748 +sprom_write_pcmcia(void *osh, uint16 addr, uint16 data) 9749 +{ 9750 + uint8 addr_l, addr_h, data_l, data_h; 9751 + 9752 + addr_l = (uint8)((addr * 2) & 0xff); 9753 + addr_h = (uint8)(((addr * 2) >> 8) & 0xff); 9754 + data_l = (uint8)(data & 0xff); 9755 + data_h = (uint8)((data >> 8) & 0xff); 9756 + 9757 + /* set address */ 9758 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRH, &addr_h, 1); 9759 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_ADDRL, &addr_l, 1); 9760 + 9761 + /* write data */ 9762 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAH, &data_h, 1); 9763 + OSL_PCMCIA_WRITE_ATTR(osh, SROM_DATAL, &data_l, 1); 9764 + 9765 + /* do write */ 9766 + return sprom_cmd_pcmcia(osh, SROM_WRITE); 9767 +} 9768 + 9769 +/* 9770 + * Read in and validate sprom. 9771 + * Return 0 on success, nonzero on error. 9772 + */ 9773 +static int 9774 +sprom_read_pci(uint16 *sprom, uint wordoff, uint16 *buf, uint nwords, bool check_crc) 9775 +{ 9776 + uint8 chk8; 9777 + uint i; 9778 + 9779 + /* read the sprom */ 9780 + for (i = 0; i < nwords; i++) 9781 + buf[i] = R_REG(&sprom[wordoff + i]); 9782 + 9783 + if (check_crc) { 9784 + /* fixup the endianness so crc8 will pass */ 9785 + htol16_buf(buf, nwords * 2); 9786 + if ((chk8 = hndcrc8((uchar*)buf, nwords * 2, CRC8_INIT_VALUE)) != CRC8_GOOD_VALUE) 9787 + return (1); 9788 + /* now correct the endianness of the byte array */ 9789 + ltoh16_buf(buf, nwords * 2); 9790 + } 9791 + 9792 + return (0); 9793 +} 9794 + 9795 +/* 9796 + * Initialize nonvolatile variable table from sprom. 9797 + * Return 0 on success, nonzero on error. 9798 + */ 9799 + 9800 +static int 9801 +initvars_srom_pci(void *osh, void *curmap, char **vars, int *count) 9802 +{ 9803 + uint16 w, b[64]; 9804 + uint8 sromrev; 9805 + struct ether_addr ea; 9806 + char eabuf[32]; 9807 + uint32 bfl; 9808 + int c, woff, i; 9809 + char *vp, *base; 9810 + 9811 + if (sprom_read_pci((void*)((int8*)curmap + PCI_BAR0_SPROM_OFFSET), 0, b, sizeof(b)/sizeof(b[0]), TRUE)) 9812 + return (-1); 9813 + 9814 + /* top word of sprom contains version and crc8 */ 9815 + sromrev = b[63] & 0xff; 9816 + /* bcm4401 sroms misprogrammed */ 9817 + if (sromrev == 0x10) 9818 + sromrev = 1; 9819 + if ((sromrev != 1) && (sromrev != 2)) 9820 + return (-2); 9821 + 9822 + ASSERT(vars); 9823 + ASSERT(count); 9824 + 9825 + base = vp = MALLOC(osh, VARS_MAX); 9826 + ASSERT(vp); 9827 + 9828 + vp += sprintf(vp, "sromrev=%d", sromrev); 9829 + vp++; 9830 + 9831 + if (sromrev >= 2) { 9832 + /* New section takes over the 4th hardware function space */ 9833 + 9834 + /* Word 29 is max power 11a high/low */ 9835 + w = b[29]; 9836 + vp += sprintf(vp, "pa1himaxpwr=%d", w & 0xff); 9837 + vp++; 9838 + vp += sprintf(vp, "pa1lomaxpwr=%d", (w >> 8) & 0xff); 9839 + vp++; 9840 + 9841 + /* Words 30-32 set the 11alow pa settings, 9842 + * 33-35 are the 11ahigh ones. 9843 + */ 9844 + for (i = 0; i < 3; i++) { 9845 + vp += sprintf(vp, "pa1lob%d=%d", i, b[30 + i]); 9846 + vp++; 9847 + vp += sprintf(vp, "pa1hib%d=%d", i, b[33 + i]); 9848 + vp++; 9849 + } 9850 + w = b[59]; 9851 + if (w == 0) 9852 + vp += sprintf(vp, "ccode="); 9853 + else 9854 + vp += sprintf(vp, "ccode=%c%c", (w >> 8), (w & 0xff)); 9855 + vp++; 9856 + 9857 + } 9858 + 9859 + /* parameter section of sprom starts at byte offset 72 */ 9860 + woff = 72/2; 9861 + 9862 + /* first 6 bytes are il0macaddr */ 9863 + ea.octet[0] = (b[woff] >> 8) & 0xff; 9864 + ea.octet[1] = b[woff] & 0xff; 9865 + ea.octet[2] = (b[woff+1] >> 8) & 0xff; 9866 + ea.octet[3] = b[woff+1] & 0xff; 9867 + ea.octet[4] = (b[woff+2] >> 8) & 0xff; 9868 + ea.octet[5] = b[woff+2] & 0xff; 9869 + woff += 3; 9870 + bcm_ether_ntoa((uchar*)&ea, eabuf); 9871 + vp += sprintf(vp, "il0macaddr=%s", eabuf); 9872 + vp++; 9873 + 9874 + /* next 6 bytes are et0macaddr */ 9875 + ea.octet[0] = (b[woff] >> 8) & 0xff; 9876 + ea.octet[1] = b[woff] & 0xff; 9877 + ea.octet[2] = (b[woff+1] >> 8) & 0xff; 9878 + ea.octet[3] = b[woff+1] & 0xff; 9879 + ea.octet[4] = (b[woff+2] >> 8) & 0xff; 9880 + ea.octet[5] = b[woff+2] & 0xff; 9881 + woff += 3; 9882 + bcm_ether_ntoa((uchar*)&ea, eabuf); 9883 + vp += sprintf(vp, "et0macaddr=%s", eabuf); 9884 + vp++; 9885 + 9886 + /* next 6 bytes are et1macaddr */ 9887 + ea.octet[0] = (b[woff] >> 8) & 0xff; 9888 + ea.octet[1] = b[woff] & 0xff; 9889 + ea.octet[2] = (b[woff+1] >> 8) & 0xff; 9890 + ea.octet[3] = b[woff+1] & 0xff; 9891 + ea.octet[4] = (b[woff+2] >> 8) & 0xff; 9892 + ea.octet[5] = b[woff+2] & 0xff; 9893 + woff += 3; 9894 + bcm_ether_ntoa((uchar*)&ea, eabuf); 9895 + vp += sprintf(vp, "et1macaddr=%s", eabuf); 9896 + vp++; 9897 + 9898 + /* 9899 + * Enet phy settings one or two singles or a dual 9900 + * Bits 4-0 : MII address for enet0 (0x1f for not there) 9901 + * Bits 9-5 : MII address for enet1 (0x1f for not there) 9902 + * Bit 14 : Mdio for enet0 9903 + * Bit 15 : Mdio for enet1 9904 + */ 9905 + w = b[woff]; 9906 + vp += sprintf(vp, "et0phyaddr=%d", (w & 0x1f)); 9907 + vp++; 9908 + vp += sprintf(vp, "et1phyaddr=%d", ((w >> 5) & 0x1f)); 9909 + vp++; 9910 + vp += sprintf(vp, "et0mdcport=%d", ((w >> 14) & 0x1)); 9911 + vp++; 9912 + vp += sprintf(vp, "et1mdcport=%d", ((w >> 15) & 0x1)); 9913 + vp++; 9914 + 9915 + /* Word 46 has board rev, antennas 0/1 & Country code/control */ 9916 + w = b[46]; 9917 + vp += sprintf(vp, "boardrev=%d", w & 0xff); 9918 + vp++; 9919 + 9920 + if (sromrev > 1) 9921 + vp += sprintf(vp, "cctl=%d", (w >> 8) & 0xf); 9922 + else 9923 + vp += sprintf(vp, "cc=%d", (w >> 8) & 0xf); 9924 + vp++; 9925 + 9926 + vp += sprintf(vp, "aa0=%d", (w >> 12) & 0x3); 9927 + vp++; 9928 + 9929 + vp += sprintf(vp, "aa1=%d", (w >> 14) & 0x3); 9930 + vp++; 9931 + 9932 + /* Words 47-49 set the (wl) pa settings */ 9933 + woff = 47; 9934 + 9935 + for (i = 0; i < 3; i++) { 9936 + vp += sprintf(vp, "pa0b%d=%d", i, b[woff+i]); 9937 + vp++; 9938 + vp += sprintf(vp, "pa1b%d=%d", i, b[woff+i+6]); 9939 + vp++; 9940 + } 9941 + 9942 + /* 9943 + * Words 50-51 set the customer-configured wl led behavior. 9944 + * 8 bits/gpio pin. High bit: activehi=0, activelo=1; 9945 + * LED behavior values defined in wlioctl.h . 9946 + */ 9947 + w = b[50]; 9948 + if ((w != 0) && (w != 0xffff)) { 9949 + /* gpio0 */ 9950 + vp += sprintf(vp, "wl0gpio0=%d", (w & 0xff)); 9951 + vp++; 9952 + 9953 + /* gpio1 */ 9954 + vp += sprintf(vp, "wl0gpio1=%d", (w >> 8) & 0xff); 9955 + vp++; 9956 + } 9957 + w = b[51]; 9958 + if ((w != 0) && (w != 0xffff)) { 9959 + /* gpio2 */ 9960 + vp += sprintf(vp, "wl0gpio2=%d", w & 0xff); 9961 + vp++; 9962 + 9963 + /* gpio3 */ 9964 + vp += sprintf(vp, "wl0gpio3=%d", (w >> 8) & 0xff); 9965 + vp++; 9966 + } 9967 + 9968 + /* Word 52 is max power 0/1 */ 9969 + w = b[52]; 9970 + vp += sprintf(vp, "pa0maxpwr=%d", w & 0xff); 9971 + vp++; 9972 + vp += sprintf(vp, "pa1maxpwr=%d", (w >> 8) & 0xff); 9973 + vp++; 9974 + 9975 + /* Word 56 is idle tssi target 0/1 */ 9976 + w = b[56]; 9977 + vp += sprintf(vp, "pa0itssit=%d", w & 0xff); 9978 + vp++; 9979 + vp += sprintf(vp, "pa1itssit=%d", (w >> 8) & 0xff); 9980 + vp++; 9981 + 9982 + /* Word 57 is boardflags, if not programmed make it zero */ 9983 + bfl = (uint32)b[57]; 9984 + if (bfl == 0xffff) bfl = 0; 9985 + if (sromrev > 1) { 9986 + /* Word 28 is boardflags2 */ 9987 + bfl |= (uint32)b[28] << 16; 9988 + } 9989 + vp += sprintf(vp, "boardflags=%d", bfl); 9990 + vp++; 9991 + 9992 + /* Word 58 is antenna gain 0/1 */ 9993 + w = b[58]; 9994 + vp += sprintf(vp, "ag0=%d", w & 0xff); 9995 + vp++; 9996 + 9997 + vp += sprintf(vp, "ag1=%d", (w >> 8) & 0xff); 9998 + vp++; 9999 + 10000 + if (sromrev == 1) { 10001 + /* set the oem string */ 10002 + vp += sprintf(vp, "oem=%02x%02x%02x%02x%02x%02x%02x%02x", 10003 + ((b[59] >> 8) & 0xff), (b[59] & 0xff), 10004 + ((b[60] >> 8) & 0xff), (b[60] & 0xff), 10005 + ((b[61] >> 8) & 0xff), (b[61] & 0xff), 10006 + ((b[62] >> 8) & 0xff), (b[62] & 0xff)); 10007 + vp++; 10008 + } else { 10009 + /* Word 60 OFDM tx power offset from CCK level */ 10010 + /* OFDM Power Offset - opo */ 10011 + vp += sprintf(vp, "opo=%d", b[60] & 0xff); 10012 + vp++; 10013 + } 10014 + 10015 + /* final nullbyte terminator */ 10016 + *vp++ = '\0'; 10017 + 10018 + c = (int)(vp - base); 10019 + ASSERT((vp - base) <= VARS_MAX); 10020 + 10021 + if (c == VARS_MAX) { 10022 + *vars = base; 10023 + } else { 10024 + vp = MALLOC(osh, c); 10025 + ASSERT(vp); 10026 + bcopy(base, vp, c); 10027 + MFREE(osh, base, VARS_MAX); 10028 + *vars = vp; 10029 + } 10030 + *count = c; 10031 + 10032 + return (0); 10033 +} 10034 + 10035 +/* 10036 + * Read the cis and call parsecis to initialize the vars. 10037 + * Return 0 on success, nonzero on error. 10038 + */ 10039 +static int 10040 +initvars_cis_pcmcia(void *sbh, void *curmap, void *osh, char **vars, int *count) 10041 +{ 10042 + uint8 *cis = NULL; 10043 + int rc; 10044 + uint data_sz; 10045 + 10046 + data_sz = (sb_pcmciarev(sbh) == 1) ? (SPROM_SIZE * 2) : CIS_SIZE; 10047 + 10048 + if ((cis = MALLOC(osh, data_sz)) == NULL) 10049 + return (-2); 10050 + 10051 + if (sb_pcmciarev(sbh) == 1) { 10052 + if (srom_read(PCMCIA_BUS, (void *)NULL, osh, 0, data_sz, (uint16 *)cis)) { 10053 + MFREE(osh, cis, data_sz); 10054 + return (-1); 10055 + } 10056 + /* fix up endianess for 16-bit data vs 8-bit parsing */ 10057 + ltoh16_buf((uint16 *)cis, data_sz); 10058 + } else 10059 + OSL_PCMCIA_READ_ATTR(osh, 0, cis, data_sz); 10060 + 10061 + rc = srom_parsecis(osh, cis, vars, count); 10062 + 10063 + MFREE(osh, cis, data_sz); 10064 + 10065 + return (rc); 10066 +} 10067 + 10068 diff -Nur linux-2.4.32/drivers/net/hnd/bcmutils.c linux-2.4.32-freewrt/drivers/net/hnd/bcmutils.c 10069 --- linux-2.4.32/drivers/net/hnd/bcmutils.c 1970-01-01 01:00:00.000000000 +0100 10070 +++ linux-2.4.32-freewrt/drivers/net/hnd/bcmutils.c 2006-09-16 15:41:31.000000000 +0200 10071 @@ -0,0 +1,862 @@ 10072 +/* 10073 + * Misc useful OS-independent routines. 10074 + * 10075 + * Copyright 2004, Broadcom Corporation 10076 + * All Rights Reserved. 10077 + * 10078 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 10079 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 10080 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 10081 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 10082 + * $Id$ 10083 + */ 10084 + 10085 +#include <typedefs.h> 10086 +#include <osl.h> 10087 +#include <bcmnvram.h> 10088 +#include <bcmutils.h> 10089 +#include <bcmendian.h> 10090 +#include <bcmdevs.h> 10091 + 10092 +#ifdef BCMDRIVER 10093 +/* copy a pkt buffer chain into a buffer */ 10094 +uint 10095 +pktcopy(void *drv, void *p, uint offset, int len, uchar *buf) 10096 +{ 10097 + uint n, ret = 0; 10098 + 10099 + if (len < 0) 10100 + len = 4096; /* "infinite" */ 10101 + 10102 + /* skip 'offset' bytes */ 10103 + for (; p && offset; p = PKTNEXT(drv, p)) { 10104 + if (offset < (uint)PKTLEN(drv, p)) 10105 + break; 10106 + offset -= PKTLEN(drv, p); 10107 + } 10108 + 10109 + if (!p) 10110 + return 0; 10111 + 10112 + /* copy the data */ 10113 + for (; p && len; p = PKTNEXT(drv, p)) { 10114 + n = MIN((uint)PKTLEN(drv, p) - offset, (uint)len); 10115 + bcopy(PKTDATA(drv, p) + offset, buf, n); 10116 + buf += n; 10117 + len -= n; 10118 + ret += n; 10119 + offset = 0; 10120 + } 10121 + 10122 + return ret; 10123 +} 10124 + 10125 +/* return total length of buffer chain */ 10126 +uint 10127 +pkttotlen(void *drv, void *p) 10128 +{ 10129 + uint total; 10130 + 10131 + total = 0; 10132 + for (; p; p = PKTNEXT(drv, p)) 10133 + total += PKTLEN(drv, p); 10134 + return (total); 10135 +} 10136 + 10137 +void 10138 +pktq_init(struct pktq *q, uint maxlen, const bool prio_map[]) 10139 +{ 10140 + q->head = q->tail = NULL; 10141 + q->maxlen = maxlen; 10142 + q->len = 0; 10143 + if (prio_map) { 10144 + q->priority = TRUE; 10145 + bcopy(prio_map, q->prio_map, sizeof(q->prio_map)); 10146 + } 10147 + else 10148 + q->priority = FALSE; 10149 +} 10150 + 10151 +/* should always check pktq_full before calling pktenq */ 10152 +void 10153 +pktenq(struct pktq *q, void *p, bool lifo) 10154 +{ 10155 + void *next, *prev; 10156 + 10157 + /* allow 10 pkts slack */ 10158 + ASSERT(q->len < (q->maxlen + 10)); 10159 + 10160 + /* Queueing chains not allowed */ 10161 + ASSERT(PKTLINK(p) == NULL); 10162 + 10163 + /* Queue is empty */ 10164 + if (q->tail == NULL) { 10165 + ASSERT(q->head == NULL); 10166 + q->head = q->tail = p; 10167 + } 10168 + 10169 + /* Insert at head or tail */ 10170 + else if (q->priority == FALSE) { 10171 + /* Insert at head (LIFO) */ 10172 + if (lifo) { 10173 + PKTSETLINK(p, q->head); 10174 + q->head = p; 10175 + } 10176 + /* Insert at tail (FIFO) */ 10177 + else { 10178 + ASSERT(PKTLINK(q->tail) == NULL); 10179 + PKTSETLINK(q->tail, p); 10180 + PKTSETLINK(p, NULL); 10181 + q->tail = p; 10182 + } 10183 + } 10184 + 10185 + /* Insert by priority */ 10186 + else { 10187 + /* legal priorities 0-7 */ 10188 + ASSERT(PKTPRIO(p) <= MAXPRIO); 10189 + 10190 + ASSERT(q->head); 10191 + ASSERT(q->tail); 10192 + /* Shortcut to insertion at tail */ 10193 + if (_pktq_pri(q, PKTPRIO(p)) < _pktq_pri(q, PKTPRIO(q->tail)) || 10194 + (!lifo && _pktq_pri(q, PKTPRIO(p)) <= _pktq_pri(q, PKTPRIO(q->tail)))) { 10195 + prev = q->tail; 10196 + next = NULL; 10197 + } 10198 + /* Insert at head or in the middle */ 10199 + else { 10200 + prev = NULL; 10201 + next = q->head; 10202 + } 10203 + /* Walk the queue */ 10204 + for (; next; prev = next, next = PKTLINK(next)) { 10205 + /* Priority queue invariant */ 10206 + ASSERT(!prev || _pktq_pri(q, PKTPRIO(prev)) >= _pktq_pri(q, PKTPRIO(next))); 10207 + /* Insert at head of string of packets of same priority (LIFO) */ 10208 + if (lifo) { 10209 + if (_pktq_pri(q, PKTPRIO(p)) >= _pktq_pri(q, PKTPRIO(next))) 10210 + break; 10211 + } 10212 + /* Insert at tail of string of packets of same priority (FIFO) */ 10213 + else { 10214 + if (_pktq_pri(q, PKTPRIO(p)) > _pktq_pri(q, PKTPRIO(next))) 10215 + break; 10216 + } 10217 + } 10218 + /* Insert at tail */ 10219 + if (next == NULL) { 10220 + ASSERT(PKTLINK(q->tail) == NULL); 10221 + PKTSETLINK(q->tail, p); 10222 + PKTSETLINK(p, NULL); 10223 + q->tail = p; 10224 + } 10225 + /* Insert in the middle */ 10226 + else if (prev) { 10227 + PKTSETLINK(prev, p); 10228 + PKTSETLINK(p, next); 10229 + } 10230 + /* Insert at head */ 10231 + else { 10232 + PKTSETLINK(p, q->head); 10233 + q->head = p; 10234 + } 10235 + } 10236 + 10237 + /* List invariants after insertion */ 10238 + ASSERT(q->head); 10239 + ASSERT(PKTLINK(q->tail) == NULL); 10240 + 10241 + q->len++; 10242 +} 10243 + 10244 +/* dequeue packet at head */ 10245 +void* 10246 +pktdeq(struct pktq *q) 10247 +{ 10248 + void *p; 10249 + 10250 + if ((p = q->head)) { 10251 + ASSERT(q->tail); 10252 + q->head = PKTLINK(p); 10253 + PKTSETLINK(p, NULL); 10254 + q->len--; 10255 + if (q->head == NULL) 10256 + q->tail = NULL; 10257 + } 10258 + else { 10259 + ASSERT(q->tail == NULL); 10260 + } 10261 + 10262 + return (p); 10263 +} 10264 + 10265 +/* dequeue packet at tail */ 10266 +void* 10267 +pktdeqtail(struct pktq *q) 10268 +{ 10269 + void *p; 10270 + void *next, *prev; 10271 + 10272 + if (q->head == q->tail) { /* last packet on queue or queue empty */ 10273 + p = q->head; 10274 + q->head = q->tail = NULL; 10275 + q->len = 0; 10276 + return(p); 10277 + } 10278 + 10279 + /* start walk at head */ 10280 + prev = NULL; 10281 + next = q->head; 10282 + 10283 + /* Walk the queue to find prev of q->tail */ 10284 + for (; next; prev = next, next = PKTLINK(next)) { 10285 + if (next == q->tail) 10286 + break; 10287 + } 10288 + 10289 + ASSERT(prev); 10290 + 10291 + PKTSETLINK(prev, NULL); 10292 + q->tail = prev; 10293 + q->len--; 10294 + p = next; 10295 + 10296 + return (p); 10297 +} 10298 + 10299 +unsigned char bcm_ctype[] = { 10300 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 0-7 */ 10301 + _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 */ 10302 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 16-23 */ 10303 + _BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C,_BCM_C, /* 24-31 */ 10304 + _BCM_S|_BCM_SP,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 32-39 */ 10305 + _BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 40-47 */ 10306 + _BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D,_BCM_D, /* 48-55 */ 10307 + _BCM_D,_BCM_D,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 56-63 */ 10308 + _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 */ 10309 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 72-79 */ 10310 + _BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U,_BCM_U, /* 80-87 */ 10311 + _BCM_U,_BCM_U,_BCM_U,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_P, /* 88-95 */ 10312 + _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 */ 10313 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 104-111 */ 10314 + _BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L,_BCM_L, /* 112-119 */ 10315 + _BCM_L,_BCM_L,_BCM_L,_BCM_P,_BCM_P,_BCM_P,_BCM_P,_BCM_C, /* 120-127 */ 10316 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */ 10317 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */ 10318 + _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 */ 10319 + _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 */ 10320 + _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 */ 10321 + _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 */ 10322 + _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 */ 10323 + _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 */ 10324 +}; 10325 + 10326 +uchar 10327 +bcm_toupper(uchar c) 10328 +{ 10329 + if (bcm_islower(c)) 10330 + c -= 'a'-'A'; 10331 + return (c); 10332 +} 10333 + 10334 +ulong 10335 +bcm_strtoul(char *cp, char **endp, uint base) 10336 +{ 10337 + ulong result, value; 10338 + bool minus; 10339 + 10340 + minus = FALSE; 10341 + 10342 + while (bcm_isspace(*cp)) 10343 + cp++; 10344 + 10345 + if (cp[0] == '+') 10346 + cp++; 10347 + else if (cp[0] == '-') { 10348 + minus = TRUE; 10349 + cp++; 10350 + } 10351 + 10352 + if (base == 0) { 10353 + if (cp[0] == '0') { 10354 + if ((cp[1] == 'x') || (cp[1] == 'X')) { 10355 + base = 16; 10356 + cp = &cp[2]; 10357 + } else { 10358 + base = 8; 10359 + cp = &cp[1]; 10360 + } 10361 + } else 10362 + base = 10; 10363 + } else if (base == 16 && (cp[0] == '0') && ((cp[1] == 'x') || (cp[1] == 'X'))) { 10364 + cp = &cp[2]; 10365 + } 10366 + 10367 + result = 0; 10368 + 10369 + while (bcm_isxdigit(*cp) && 10370 + (value = bcm_isdigit(*cp) ? *cp-'0' : bcm_toupper(*cp)-'A'+10) < base) { 10371 + result = result*base + value; 10372 + cp++; 10373 + } 10374 + 10375 + if (minus) 10376 + result = (ulong)(result * -1); 10377 + 10378 + if (endp) 10379 + *endp = (char *)cp; 10380 + 10381 + return (result); 10382 +} 10383 + 10384 +uint 10385 +bcm_atoi(char *s) 10386 +{ 10387 + uint n; 10388 + 10389 + n = 0; 10390 + 10391 + while (bcm_isdigit(*s)) 10392 + n = (n * 10) + *s++ - '0'; 10393 + return (n); 10394 +} 10395 + 10396 +/* return pointer to location of substring 'needle' in 'haystack' */ 10397 +char* 10398 +bcmstrstr(char *haystack, char *needle) 10399 +{ 10400 + int len, nlen; 10401 + int i; 10402 + 10403 + if ((haystack == NULL) || (needle == NULL)) 10404 + return (haystack); 10405 + 10406 + nlen = strlen(needle); 10407 + len = strlen(haystack) - nlen + 1; 10408 + 10409 + for (i = 0; i < len; i++) 10410 + if (bcmp(needle, &haystack[i], nlen) == 0) 10411 + return (&haystack[i]); 10412 + return (NULL); 10413 +} 10414 + 10415 +char* 10416 +bcmstrcat(char *dest, const char *src) 10417 +{ 10418 + strcpy(&dest[strlen(dest)], src); 10419 + return (dest); 10420 +} 10421 + 10422 +#if defined(CONFIG_USBRNDIS_RETAIL) || defined(NDIS_MINIPORT_DRIVER) 10423 +/* registry routine buffer preparation utility functions: 10424 + * parameter order is like strncpy, but returns count 10425 + * of bytes copied. Minimum bytes copied is null char(1)/wchar(2) 10426 + */ 10427 +ulong 10428 +wchar2ascii( 10429 + char *abuf, 10430 + ushort *wbuf, 10431 + ushort wbuflen, 10432 + ulong abuflen 10433 +) 10434 +{ 10435 + ulong copyct = 1; 10436 + ushort i; 10437 + 10438 + if (abuflen == 0) 10439 + return 0; 10440 + 10441 + /* wbuflen is in bytes */ 10442 + wbuflen /= sizeof(ushort); 10443 + 10444 + for (i = 0; i < wbuflen; ++i) { 10445 + if (--abuflen == 0) 10446 + break; 10447 + *abuf++ = (char) *wbuf++; 10448 + ++copyct; 10449 + } 10450 + *abuf = '\0'; 10451 + 10452 + return copyct; 10453 +} 10454 +#endif 10455 + 10456 +char* 10457 +bcm_ether_ntoa(char *ea, char *buf) 10458 +{ 10459 + sprintf(buf,"%02x:%02x:%02x:%02x:%02x:%02x", 10460 + (uchar)ea[0]&0xff, (uchar)ea[1]&0xff, (uchar)ea[2]&0xff, 10461 + (uchar)ea[3]&0xff, (uchar)ea[4]&0xff, (uchar)ea[5]&0xff); 10462 + return (buf); 10463 +} 10464 + 10465 +/* parse a xx:xx:xx:xx:xx:xx format ethernet address */ 10466 +int 10467 +bcm_ether_atoe(char *p, char *ea) 10468 +{ 10469 + int i = 0; 10470 + 10471 + for (;;) { 10472 + ea[i++] = (char) bcm_strtoul(p, &p, 16); 10473 + if (!*p++ || i == 6) 10474 + break; 10475 + } 10476 + 10477 + return (i == 6); 10478 +} 10479 + 10480 +void 10481 +bcm_mdelay(uint ms) 10482 +{ 10483 + uint i; 10484 + 10485 + for (i = 0; i < ms; i++) { 10486 + OSL_DELAY(1000); 10487 + } 10488 +} 10489 + 10490 +/* 10491 + * Search the name=value vars for a specific one and return its value. 10492 + * Returns NULL if not found. 10493 + */ 10494 +char* 10495 +getvar(char *vars, char *name) 10496 +{ 10497 + char *s; 10498 + int len; 10499 + 10500 + len = strlen(name); 10501 + 10502 + /* first look in vars[] */ 10503 + for (s = vars; s && *s; ) { 10504 + if ((bcmp(s, name, len) == 0) && (s[len] == '=')) 10505 + return (&s[len+1]); 10506 + 10507 + while (*s++) 10508 + ; 10509 + } 10510 + 10511 + /* then query nvram */ 10512 + return (BCMINIT(nvram_get)(name)); 10513 +} 10514 + 10515 +/* 10516 + * Search the vars for a specific one and return its value as 10517 + * an integer. Returns 0 if not found. 10518 + */ 10519 +int 10520 +getintvar(char *vars, char *name) 10521 +{ 10522 + char *val; 10523 + 10524 + if ((val = getvar(vars, name)) == NULL) 10525 + return (0); 10526 + 10527 + return (bcm_strtoul(val, NULL, 0)); 10528 +} 10529 + 10530 +/* Return gpio pin number assigned to the named pin */ 10531 +/* 10532 +* Variable should be in format: 10533 +* 10534 +* gpio<N>=pin_name 10535 +* 10536 +* 'def_pin' is returned if there is no such variable found. 10537 +*/ 10538 +uint 10539 +getgpiopin(char *vars, char *pin_name, uint def_pin) 10540 +{ 10541 + char name[] = "gpioXXXX"; 10542 + char *val; 10543 + uint pin; 10544 + 10545 + /* Go thru all possibilities till a match in pin name */ 10546 + for (pin = 0; pin < GPIO_NUMPINS; pin ++) { 10547 + sprintf(name, "gpio%d", pin); 10548 + val = getvar(vars, name); 10549 + if (val && !strcmp(val, pin_name)) 10550 + return pin; 10551 + } 10552 + return def_pin; 10553 +} 10554 + 10555 +#endif /* #ifdef BCMDRIVER */ 10556 + 10557 +/******************************************************************************* 10558 + * crc8 10559 + * 10560 + * Computes a crc8 over the input data using the polynomial: 10561 + * 10562 + * x^8 + x^7 +x^6 + x^4 + x^2 + 1 10563 + * 10564 + * The caller provides the initial value (either CRC8_INIT_VALUE 10565 + * or the previous returned value) to allow for processing of 10566 + * discontiguous blocks of data. When generating the CRC the 10567 + * caller is responsible for complementing the final return value 10568 + * and inserting it into the byte stream. When checking, a final 10569 + * return value of CRC8_GOOD_VALUE indicates a valid CRC. 10570 + * 10571 + * Reference: Dallas Semiconductor Application Note 27 10572 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms", 10573 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd., 10574 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt 10575 + * 10576 + ******************************************************************************/ 10577 + 10578 +static uint8 crc8_table[256] = { 10579 + 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B, 10580 + 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21, 10581 + 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF, 10582 + 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5, 10583 + 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14, 10584 + 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E, 10585 + 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80, 10586 + 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA, 10587 + 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95, 10588 + 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF, 10589 + 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01, 10590 + 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B, 10591 + 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA, 10592 + 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0, 10593 + 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E, 10594 + 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34, 10595 + 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0, 10596 + 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A, 10597 + 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54, 10598 + 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E, 10599 + 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF, 10600 + 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5, 10601 + 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B, 10602 + 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61, 10603 + 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E, 10604 + 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74, 10605 + 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA, 10606 + 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0, 10607 + 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41, 10608 + 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B, 10609 + 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5, 10610 + 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F 10611 +}; 10612 + 10613 +#define CRC_INNER_LOOP(n, c, x) \ 10614 + (c) = ((c) >> 8) ^ crc##n##_table[((c) ^ (x)) & 0xff] 10615 + 10616 +uint8 10617 +hndcrc8( 10618 + uint8 *pdata, /* pointer to array of data to process */ 10619 + uint nbytes, /* number of input data bytes to process */ 10620 + uint8 crc /* either CRC8_INIT_VALUE or previous return value */ 10621 +) 10622 +{ 10623 + /* hard code the crc loop instead of using CRC_INNER_LOOP macro 10624 + * to avoid the undefined and unnecessary (uint8 >> 8) operation. */ 10625 + while (nbytes-- > 0) 10626 + crc = crc8_table[(crc ^ *pdata++) & 0xff]; 10627 + 10628 + return crc; 10629 +} 10630 + 10631 +/******************************************************************************* 10632 + * crc16 10633 + * 10634 + * Computes a crc16 over the input data using the polynomial: 10635 + * 10636 + * x^16 + x^12 +x^5 + 1 10637 + * 10638 + * The caller provides the initial value (either CRC16_INIT_VALUE 10639 + * or the previous returned value) to allow for processing of 10640 + * discontiguous blocks of data. When generating the CRC the 10641 + * caller is responsible for complementing the final return value 10642 + * and inserting it into the byte stream. When checking, a final 10643 + * return value of CRC16_GOOD_VALUE indicates a valid CRC. 10644 + * 10645 + * Reference: Dallas Semiconductor Application Note 27 10646 + * Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms", 10647 + * ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd., 10648 + * ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt 10649 + * 10650 + ******************************************************************************/ 10651 + 10652 +static uint16 crc16_table[256] = { 10653 + 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF, 10654 + 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7, 10655 + 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E, 10656 + 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876, 10657 + 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD, 10658 + 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5, 10659 + 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C, 10660 + 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974, 10661 + 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB, 10662 + 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3, 10663 + 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A, 10664 + 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72, 10665 + 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9, 10666 + 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1, 10667 + 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738, 10668 + 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70, 10669 + 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7, 10670 + 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF, 10671 + 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036, 10672 + 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E, 10673 + 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5, 10674 + 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD, 10675 + 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134, 10676 + 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C, 10677 + 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3, 10678 + 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB, 10679 + 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232, 10680 + 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A, 10681 + 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1, 10682 + 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9, 10683 + 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330, 10684 + 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78 10685 +}; 10686 + 10687 +uint16 10688 +hndcrc16( 10689 + uint8 *pdata, /* pointer to array of data to process */ 10690 + uint nbytes, /* number of input data bytes to process */ 10691 + uint16 crc /* either CRC16_INIT_VALUE or previous return value */ 10692 +) 10693 +{ 10694 + while (nbytes-- > 0) 10695 + CRC_INNER_LOOP(16, crc, *pdata++); 10696 + return crc; 10697 +} 10698 + 10699 +static uint32 crc32_table[256] = { 10700 + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 10701 + 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 10702 + 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 10703 + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 10704 + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 10705 + 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 10706 + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 10707 + 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 10708 + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 10709 + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 10710 + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 10711 + 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 10712 + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 10713 + 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 10714 + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 10715 + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 10716 + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 10717 + 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 10718 + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 10719 + 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 10720 + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 10721 + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 10722 + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 10723 + 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 10724 + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 10725 + 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 10726 + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 10727 + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 10728 + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 10729 + 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 10730 + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 10731 + 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 10732 + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 10733 + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 10734 + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 10735 + 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 10736 + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 10737 + 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 10738 + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 10739 + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 10740 + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 10741 + 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 10742 + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 10743 + 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 10744 + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 10745 + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 10746 + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 10747 + 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 10748 + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 10749 + 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 10750 + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 10751 + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 10752 + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 10753 + 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 10754 + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 10755 + 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 10756 + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 10757 + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 10758 + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 10759 + 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 10760 + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 10761 + 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 10762 + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 10763 + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D 10764 +}; 10765 + 10766 +uint32 10767 +hndcrc32( 10768 + uint8 *pdata, /* pointer to array of data to process */ 10769 + uint nbytes, /* number of input data bytes to process */ 10770 + uint32 crc /* either CRC32_INIT_VALUE or previous return value */ 10771 +) 10772 +{ 10773 + uint8 *pend; 10774 +#ifdef __mips__ 10775 + uint8 tmp[4]; 10776 + ulong *tptr = (ulong *)tmp; 10777 + 10778 + /* in case the beginning of the buffer isn't aligned */ 10779 + pend = (uint8 *)((uint)(pdata + 3) & 0xfffffffc); 10780 + nbytes -= (pend - pdata); 10781 + while (pdata < pend) 10782 + CRC_INNER_LOOP(32, crc, *pdata++); 10783 + 10784 + /* handle bulk of data as 32-bit words */ 10785 + pend = pdata + (nbytes & 0xfffffffc); 10786 + while (pdata < pend) { 10787 + *tptr = *((ulong *)pdata)++; 10788 + CRC_INNER_LOOP(32, crc, tmp[0]); 10789 + CRC_INNER_LOOP(32, crc, tmp[1]); 10790 + CRC_INNER_LOOP(32, crc, tmp[2]); 10791 + CRC_INNER_LOOP(32, crc, tmp[3]); 10792 + } 10793 + 10794 + /* 1-3 bytes at end of buffer */ 10795 + pend = pdata + (nbytes & 0x03); 10796 + while (pdata < pend) 10797 + CRC_INNER_LOOP(32, crc, *pdata++); 10798 +#else 10799 + pend = pdata + nbytes; 10800 + while (pdata < pend) 10801 + CRC_INNER_LOOP(32, crc, *pdata++); 10802 +#endif 10803 + 10804 + return crc; 10805 +} 10806 + 10807 +#ifdef notdef 10808 +#define CLEN 1499 10809 +#define CBUFSIZ (CLEN+4) 10810 +#define CNBUFS 5 10811 + 10812 +void testcrc32(void) 10813 +{ 10814 + uint j,k,l; 10815 + uint8 *buf; 10816 + uint len[CNBUFS]; 10817 + uint32 crcr; 10818 + uint32 crc32tv[CNBUFS] = 10819 + {0xd2cb1faa, 0xd385c8fa, 0xf5b4f3f3, 0x55789e20, 0x00343110}; 10820 + 10821 + ASSERT((buf = MALLOC(CBUFSIZ*CNBUFS)) != NULL); 10822 + 10823 + /* step through all possible alignments */ 10824 + for (l=0;l<=4;l++) { 10825 + for (j=0; j<CNBUFS; j++) { 10826 + len[j] = CLEN; 10827 + for (k=0; k<len[j]; k++) 10828 + *(buf + j*CBUFSIZ + (k+l)) = (j+k) & 0xff; 10829 + } 10830 + 10831 + for (j=0; j<CNBUFS; j++) { 10832 + crcr = crc32(buf + j*CBUFSIZ + l, len[j], CRC32_INIT_VALUE); 10833 + ASSERT(crcr == crc32tv[j]); 10834 + } 10835 + } 10836 + 10837 + MFREE(buf, CBUFSIZ*CNBUFS); 10838 + return; 10839 +} 10840 +#endif 10841 + 10842 + 10843 +/* 10844 + * Advance from the current 1-byte tag/1-byte length/variable-length value 10845 + * triple, to the next, returning a pointer to the next. 10846 + */ 10847 +bcm_tlv_t * 10848 +bcm_next_tlv(bcm_tlv_t *elt, int *buflen) 10849 +{ 10850 + int len; 10851 + 10852 + /* validate current elt */ 10853 + if (*buflen < 2) { 10854 + return NULL; 10855 + } 10856 + 10857 + len = elt->len; 10858 + 10859 + /* validate remaining buflen */ 10860 + if (*buflen >= (2 + len + 2)) { 10861 + elt = (bcm_tlv_t*)(elt->data + len); 10862 + *buflen -= (2 + len); 10863 + } else { 10864 + elt = NULL; 10865 + } 10866 + 10867 + return elt; 10868 +} 10869 + 10870 +/* 10871 + * Traverse a string of 1-byte tag/1-byte length/variable-length value 10872 + * triples, returning a pointer to the substring whose first element 10873 + * matches tag 10874 + */ 10875 +bcm_tlv_t * 10876 +bcm_parse_tlvs(void *buf, int buflen, uint key) 10877 +{ 10878 + bcm_tlv_t *elt; 10879 + int totlen; 10880 + 10881 + elt = (bcm_tlv_t*)buf; 10882 + totlen = buflen; 10883 + 10884 + /* find tagged parameter */ 10885 + while (totlen >= 2) { 10886 + int len = elt->len; 10887 + 10888 + /* validate remaining totlen */ 10889 + if ((elt->id == key) && (totlen >= (len + 2))) 10890 + return (elt); 10891 + 10892 + elt = (bcm_tlv_t*)((uint8*)elt + (len + 2)); 10893 + totlen -= (len + 2); 10894 + } 10895 + 10896 + return NULL; 10897 +} 10898 + 10899 +/* 10900 + * Traverse a string of 1-byte tag/1-byte length/variable-length value 10901 + * triples, returning a pointer to the substring whose first element 10902 + * matches tag. Stop parsing when we see an element whose ID is greater 10903 + * than the target key. 10904 + */ 10905 +bcm_tlv_t * 10906 +bcm_parse_ordered_tlvs(void *buf, int buflen, uint key) 10907 +{ 10908 + bcm_tlv_t *elt; 10909 + int totlen; 10910 + 10911 + elt = (bcm_tlv_t*)buf; 10912 + totlen = buflen; 10913 + 10914 + /* find tagged parameter */ 10915 + while (totlen >= 2) { 10916 + uint id = elt->id; 10917 + int len = elt->len; 10918 + 10919 + /* Punt if we start seeing IDs > than target key */ 10920 + if (id > key) 10921 + return(NULL); 10922 + 10923 + /* validate remaining totlen */ 10924 + if ((id == key) && (totlen >= (len + 2))) 10925 + return (elt); 10926 + 10927 + elt = (bcm_tlv_t*)((uint8*)elt + (len + 2)); 10928 + totlen -= (len + 2); 10929 + } 10930 + return NULL; 10931 +} 10932 + 10933 + 10934 diff -Nur linux-2.4.32/drivers/net/hnd/hnddma.c linux-2.4.32-freewrt/drivers/net/hnd/hnddma.c 10935 --- linux-2.4.32/drivers/net/hnd/hnddma.c 1970-01-01 01:00:00.000000000 +0100 10936 +++ linux-2.4.32-freewrt/drivers/net/hnd/hnddma.c 2006-09-16 15:41:31.000000000 +0200 10937 @@ -0,0 +1,865 @@ 10938 +/* 10939 + * Generic Broadcom Home Networking Division (HND) DMA module. 10940 + * This supports the following chips: BCM42xx, 44xx, 47xx . 10941 + * 10942 + * Copyright 2004, Broadcom Corporation 10943 + * All Rights Reserved. 10944 + * 10945 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 10946 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 10947 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 10948 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 10949 + * 10950 + * $Id$ 10951 + */ 10952 + 10953 +#include <typedefs.h> 10954 +#include <osl.h> 10955 +#include <bcmendian.h> 10956 +#include <sbconfig.h> 10957 +#include <bcmutils.h> 10958 + 10959 +struct dma_info; /* forward declaration */ 10960 +#define di_t struct dma_info 10961 +#include <hnddma.h> 10962 + 10963 +/* debug/trace */ 10964 +#define DMA_ERROR(args) 10965 +#define DMA_TRACE(args) 10966 + 10967 +/* default dma message level(if input msg_level pointer is null in dma_attach()) */ 10968 +static uint dma_msg_level = 0; 10969 + 10970 +#define MAXNAMEL 8 10971 +#define MAXDD (DMAMAXRINGSZ / sizeof (dmadd_t)) 10972 + 10973 +/* dma engine software state */ 10974 +typedef struct dma_info { 10975 + hnddma_t hnddma; /* exported structure */ 10976 + uint *msg_level; /* message level pointer */ 10977 + 10978 + char name[MAXNAMEL]; /* callers name for diag msgs */ 10979 + void *drv; /* driver handle */ 10980 + void *osh; /* os handle */ 10981 + dmaregs_t *regs; /* dma engine registers */ 10982 + 10983 + dmadd_t *txd; /* pointer to chip-specific tx descriptor ring */ 10984 + uint txin; /* index of next descriptor to reclaim */ 10985 + uint txout; /* index of next descriptor to post */ 10986 + uint txavail; /* # free tx descriptors */ 10987 + void **txp; /* pointer to parallel array of pointers to packets */ 10988 + ulong txdpa; /* physical address of descriptor ring */ 10989 + uint txdalign; /* #bytes added to alloc'd mem to align txd */ 10990 + uint txdalloc; /* #bytes allocated for the ring */ 10991 + 10992 + dmadd_t *rxd; /* pointer to chip-specific rx descriptor ring */ 10993 + uint rxin; /* index of next descriptor to reclaim */ 10994 + uint rxout; /* index of next descriptor to post */ 10995 + void **rxp; /* pointer to parallel array of pointers to packets */ 10996 + ulong rxdpa; /* physical address of descriptor ring */ 10997 + uint rxdalign; /* #bytes added to alloc'd mem to align rxd */ 10998 + uint rxdalloc; /* #bytes allocated for the ring */ 10999 + 11000 + /* tunables */ 11001 + uint ntxd; /* # tx descriptors */ 11002 + uint nrxd; /* # rx descriptors */ 11003 + uint rxbufsize; /* rx buffer size in bytes */ 11004 + uint nrxpost; /* # rx buffers to keep posted */ 11005 + uint rxoffset; /* rxcontrol offset */ 11006 + uint ddoffset; /* add to get dma address of descriptor ring */ 11007 + uint dataoffset; /* add to get dma address of data buffer */ 11008 +} dma_info_t; 11009 + 11010 +/* descriptor bumping macros */ 11011 +#define XXD(x, n) ((x) & ((n) - 1)) 11012 +#define TXD(x) XXD((x), di->ntxd) 11013 +#define RXD(x) XXD((x), di->nrxd) 11014 +#define NEXTTXD(i) TXD(i + 1) 11015 +#define PREVTXD(i) TXD(i - 1) 11016 +#define NEXTRXD(i) RXD(i + 1) 11017 +#define NTXDACTIVE(h, t) TXD(t - h) 11018 +#define NRXDACTIVE(h, t) RXD(t - h) 11019 + 11020 +/* macros to convert between byte offsets and indexes */ 11021 +#define B2I(bytes) ((bytes) / sizeof (dmadd_t)) 11022 +#define I2B(index) ((index) * sizeof (dmadd_t)) 11023 + 11024 +/* 11025 + * This assume the largest i/o address is, in fact, the pci big window 11026 + * and that the pci core sb2pcitranslation2 register has been left with 11027 + * the default 0x0 pci base address. 11028 + */ 11029 +#define MAXDMAADDR SB_PCI_DMA_SZ 11030 +#define DMA_ADDRESSABLE(x) !((x) & ~(MAXDMAADDR - 1)) 11031 + 11032 +/* prototypes */ 11033 + 11034 +void* 11035 +dma_attach(void *drv, void *osh, char *name, dmaregs_t *regs, uint ntxd, uint nrxd, 11036 + uint rxbufsize, uint nrxpost, uint rxoffset, uint ddoffset, uint dataoffset, uint *msg_level) 11037 +{ 11038 + dma_info_t *di; 11039 + uint size; 11040 + void *va; 11041 + 11042 + ASSERT(ntxd <= MAXDD); 11043 + ASSERT(ISPOWEROF2(ntxd)); 11044 + ASSERT(nrxd <= MAXDD); 11045 + ASSERT(ISPOWEROF2(nrxd)); 11046 + 11047 + /* allocate private info structure */ 11048 + if ((di = MALLOC(osh, sizeof (dma_info_t))) == NULL) { 11049 + return (NULL); 11050 + } 11051 + bzero((char*)di, sizeof (dma_info_t)); 11052 + 11053 + /* allocate tx packet pointer vector */ 11054 + if (ntxd) { 11055 + size = ntxd * sizeof (void*); 11056 + if ((di->txp = MALLOC(osh, size)) == NULL) 11057 + goto fail; 11058 + bzero((char*)di->txp, size); 11059 + } 11060 + 11061 + /* allocate rx packet pointer vector */ 11062 + if (nrxd) { 11063 + size = nrxd * sizeof (void*); 11064 + if ((di->rxp = MALLOC(osh, size)) == NULL) 11065 + goto fail; 11066 + bzero((char*)di->rxp, size); 11067 + } 11068 + 11069 + /* set message level */ 11070 + di->msg_level = msg_level ? msg_level : &dma_msg_level; 11071 + 11072 + DMA_TRACE(("%s: dma_attach: drv %p osh %p regs %p ntxd %d nrxd %d rxbufsize %d nrxpost %d rxoffset %d ddoffset 0x%x dataoffset 0x%x\n", name, drv, osh, regs, ntxd, nrxd, rxbufsize, nrxpost, rxoffset, ddoffset, dataoffset)); 11073 + 11074 + /* make a private copy of our callers name */ 11075 + strncpy(di->name, name, MAXNAMEL); 11076 + di->name[MAXNAMEL-1] = '\0'; 11077 + 11078 + di->drv = drv; 11079 + di->osh = osh; 11080 + di->regs = regs; 11081 + 11082 + /* allocate transmit descriptor ring */ 11083 + if (ntxd) { 11084 + /* only need ntxd descriptors but it must be DMARINGALIGNed */ 11085 + size = ntxd * sizeof (dmadd_t); 11086 + if (!ISALIGNED(DMA_CONSISTENT_ALIGN, DMARINGALIGN)) 11087 + size += DMARINGALIGN; 11088 + if ((va = DMA_ALLOC_CONSISTENT(osh, size, &di->txdpa)) == NULL) 11089 + goto fail; 11090 + di->txd = (dmadd_t*) ROUNDUP((uintptr)va, DMARINGALIGN); 11091 + di->txdalign = (uint)((int8*)di->txd - (int8*)va); 11092 + di->txdpa += di->txdalign; 11093 + di->txdalloc = size; 11094 + ASSERT(ISALIGNED((uintptr)di->txd, DMARINGALIGN)); 11095 + ASSERT(DMA_ADDRESSABLE(di->txdpa)); 11096 + } 11097 + 11098 + /* allocate receive descriptor ring */ 11099 + if (nrxd) { 11100 + /* only need nrxd descriptors but it must be DMARINGALIGNed */ 11101 + size = nrxd * sizeof (dmadd_t); 11102 + if (!ISALIGNED(DMA_CONSISTENT_ALIGN, DMARINGALIGN)) 11103 + size += DMARINGALIGN; 11104 + if ((va = DMA_ALLOC_CONSISTENT(osh, size, &di->rxdpa)) == NULL) 11105 + goto fail; 11106 + di->rxd = (dmadd_t*) ROUNDUP((uintptr)va, DMARINGALIGN); 11107 + di->rxdalign = (uint)((int8*)di->rxd - (int8*)va); 11108 + di->rxdpa += di->rxdalign; 11109 + di->rxdalloc = size; 11110 + ASSERT(ISALIGNED((uintptr)di->rxd, DMARINGALIGN)); 11111 + ASSERT(DMA_ADDRESSABLE(di->rxdpa)); 11112 + } 11113 + 11114 + /* save tunables */ 11115 + di->ntxd = ntxd; 11116 + di->nrxd = nrxd; 11117 + di->rxbufsize = rxbufsize; 11118 + di->nrxpost = nrxpost; 11119 + di->rxoffset = rxoffset; 11120 + di->ddoffset = ddoffset; 11121 + di->dataoffset = dataoffset; 11122 + 11123 + return ((void*)di); 11124 + 11125 +fail: 11126 + dma_detach((void*)di); 11127 + return (NULL); 11128 +} 11129 + 11130 +/* may be called with core in reset */ 11131 +void 11132 +dma_detach(dma_info_t *di) 11133 +{ 11134 + if (di == NULL) 11135 + return; 11136 + 11137 + DMA_TRACE(("%s: dma_detach\n", di->name)); 11138 + 11139 + /* shouldn't be here if descriptors are unreclaimed */ 11140 + ASSERT(di->txin == di->txout); 11141 + ASSERT(di->rxin == di->rxout); 11142 + 11143 + /* free dma descriptor rings */ 11144 + if (di->txd) 11145 + DMA_FREE_CONSISTENT(di->osh, ((int8*)di->txd - di->txdalign), 11146 + di->txdalloc, (di->txdpa - di->txdalign)); 11147 + if (di->rxd) 11148 + DMA_FREE_CONSISTENT(di->osh, ((int8*)di->rxd - di->rxdalign), 11149 + di->rxdalloc, (di->rxdpa - di->rxdalign)); 11150 + 11151 + /* free packet pointer vectors */ 11152 + if (di->txp) 11153 + MFREE(di->osh, (void*)di->txp, (di->ntxd * sizeof (void*))); 11154 + if (di->rxp) 11155 + MFREE(di->osh, (void*)di->rxp, (di->nrxd * sizeof (void*))); 11156 + 11157 + /* free our private info structure */ 11158 + MFREE(di->osh, (void*)di, sizeof (dma_info_t)); 11159 +} 11160 + 11161 + 11162 +void 11163 +dma_txreset(dma_info_t *di) 11164 +{ 11165 + uint32 status; 11166 + 11167 + DMA_TRACE(("%s: dma_txreset\n", di->name)); 11168 + 11169 + /* suspend tx DMA first */ 11170 + W_REG(&di->regs->xmtcontrol, XC_SE); 11171 + SPINWAIT((status = (R_REG(&di->regs->xmtstatus) & XS_XS_MASK)) != XS_XS_DISABLED && 11172 + status != XS_XS_IDLE && 11173 + status != XS_XS_STOPPED, 11174 + 10000); 11175 + 11176 + W_REG(&di->regs->xmtcontrol, 0); 11177 + SPINWAIT((status = (R_REG(&di->regs->xmtstatus) & XS_XS_MASK)) != XS_XS_DISABLED, 11178 + 10000); 11179 + 11180 + if (status != XS_XS_DISABLED) { 11181 + DMA_ERROR(("%s: dma_txreset: dma cannot be stopped\n", di->name)); 11182 + } 11183 + 11184 + /* wait for the last transaction to complete */ 11185 + OSL_DELAY(300); 11186 +} 11187 + 11188 +void 11189 +dma_rxreset(dma_info_t *di) 11190 +{ 11191 + uint32 status; 11192 + 11193 + DMA_TRACE(("%s: dma_rxreset\n", di->name)); 11194 + 11195 + W_REG(&di->regs->rcvcontrol, 0); 11196 + SPINWAIT((status = (R_REG(&di->regs->rcvstatus) & RS_RS_MASK)) != RS_RS_DISABLED, 11197 + 10000); 11198 + 11199 + if (status != RS_RS_DISABLED) { 11200 + DMA_ERROR(("%s: dma_rxreset: dma cannot be stopped\n", di->name)); 11201 + } 11202 +} 11203 + 11204 +void 11205 +dma_txinit(dma_info_t *di) 11206 +{ 11207 + DMA_TRACE(("%s: dma_txinit\n", di->name)); 11208 + 11209 + di->txin = di->txout = 0; 11210 + di->txavail = di->ntxd - 1; 11211 + 11212 + /* clear tx descriptor ring */ 11213 + BZERO_SM((void*)di->txd, (di->ntxd * sizeof (dmadd_t))); 11214 + 11215 + W_REG(&di->regs->xmtcontrol, XC_XE); 11216 + W_REG(&di->regs->xmtaddr, (di->txdpa + di->ddoffset)); 11217 +} 11218 + 11219 +bool 11220 +dma_txenabled(dma_info_t *di) 11221 +{ 11222 + uint32 xc; 11223 + 11224 + /* If the chip is dead, it is not enabled :-) */ 11225 + xc = R_REG(&di->regs->xmtcontrol); 11226 + return ((xc != 0xffffffff) && (xc & XC_XE)); 11227 +} 11228 + 11229 +void 11230 +dma_txsuspend(dma_info_t *di) 11231 +{ 11232 + DMA_TRACE(("%s: dma_txsuspend\n", di->name)); 11233 + OR_REG(&di->regs->xmtcontrol, XC_SE); 11234 +} 11235 + 11236 +void 11237 +dma_txresume(dma_info_t *di) 11238 +{ 11239 + DMA_TRACE(("%s: dma_txresume\n", di->name)); 11240 + AND_REG(&di->regs->xmtcontrol, ~XC_SE); 11241 +} 11242 + 11243 +bool 11244 +dma_txsuspended(dma_info_t *di) 11245 +{ 11246 + if (!(R_REG(&di->regs->xmtcontrol) & XC_SE)) 11247 + return 0; 11248 + 11249 + if ((R_REG(&di->regs->xmtstatus) & XS_XS_MASK) != XS_XS_IDLE) 11250 + return 0; 11251 + 11252 + OSL_DELAY(2); 11253 + return ((R_REG(&di->regs->xmtstatus) & XS_XS_MASK) == XS_XS_IDLE); 11254 +} 11255 + 11256 +bool 11257 +dma_txstopped(dma_info_t *di) 11258 +{ 11259 + return ((R_REG(&di->regs->xmtstatus) & XS_XS_MASK) == XS_XS_STOPPED); 11260 +} 11261 + 11262 +bool 11263 +dma_rxstopped(dma_info_t *di) 11264 +{ 11265 + return ((R_REG(&di->regs->rcvstatus) & RS_RS_MASK) == RS_RS_STOPPED); 11266 +} 11267 + 11268 +void 11269 +dma_fifoloopbackenable(dma_info_t *di) 11270 +{ 11271 + DMA_TRACE(("%s: dma_fifoloopbackenable\n", di->name)); 11272 + OR_REG(&di->regs->xmtcontrol, XC_LE); 11273 +} 11274 + 11275 +void 11276 +dma_rxinit(dma_info_t *di) 11277 +{ 11278 + DMA_TRACE(("%s: dma_rxinit\n", di->name)); 11279 + 11280 + di->rxin = di->rxout = 0; 11281 + 11282 + /* clear rx descriptor ring */ 11283 + BZERO_SM((void*)di->rxd, (di->nrxd * sizeof (dmadd_t))); 11284 + 11285 + dma_rxenable(di); 11286 + W_REG(&di->regs->rcvaddr, (di->rxdpa + di->ddoffset)); 11287 +} 11288 + 11289 +void 11290 +dma_rxenable(dma_info_t *di) 11291 +{ 11292 + DMA_TRACE(("%s: dma_rxenable\n", di->name)); 11293 + W_REG(&di->regs->rcvcontrol, ((di->rxoffset << RC_RO_SHIFT) | RC_RE)); 11294 +} 11295 + 11296 +bool 11297 +dma_rxenabled(dma_info_t *di) 11298 +{ 11299 + uint32 rc; 11300 + 11301 + rc = R_REG(&di->regs->rcvcontrol); 11302 + return ((rc != 0xffffffff) && (rc & RC_RE)); 11303 +} 11304 + 11305 +/* 11306 + * The BCM47XX family supports full 32bit dma engine buffer addressing so 11307 + * dma buffers can cross 4 Kbyte page boundaries. 11308 + */ 11309 +int 11310 +dma_txfast(dma_info_t *di, void *p0, uint32 coreflags) 11311 +{ 11312 + void *p, *next; 11313 + uchar *data; 11314 + uint len; 11315 + uint txout; 11316 + uint32 ctrl; 11317 + uint32 pa; 11318 + 11319 + DMA_TRACE(("%s: dma_txfast\n", di->name)); 11320 + 11321 + txout = di->txout; 11322 + ctrl = 0; 11323 + 11324 + /* 11325 + * Walk the chain of packet buffers 11326 + * allocating and initializing transmit descriptor entries. 11327 + */ 11328 + for (p = p0; p; p = next) { 11329 + data = PKTDATA(di->drv, p); 11330 + len = PKTLEN(di->drv, p); 11331 + next = PKTNEXT(di->drv, p); 11332 + 11333 + /* return nonzero if out of tx descriptors */ 11334 + if (NEXTTXD(txout) == di->txin) 11335 + goto outoftxd; 11336 + 11337 + if (len == 0) 11338 + continue; 11339 + 11340 + /* get physical address of buffer start */ 11341 + pa = (uint32) DMA_MAP(di->osh, data, len, DMA_TX, p); 11342 + ASSERT(DMA_ADDRESSABLE(pa)); 11343 + 11344 + /* build the descriptor control value */ 11345 + ctrl = len & CTRL_BC_MASK; 11346 + 11347 + ctrl |= coreflags; 11348 + 11349 + if (p == p0) 11350 + ctrl |= CTRL_SOF; 11351 + if (next == NULL) 11352 + ctrl |= (CTRL_IOC | CTRL_EOF); 11353 + if (txout == (di->ntxd - 1)) 11354 + ctrl |= CTRL_EOT; 11355 + 11356 + /* init the tx descriptor */ 11357 + W_SM(&di->txd[txout].ctrl, BUS_SWAP32(ctrl)); 11358 + W_SM(&di->txd[txout].addr, BUS_SWAP32(pa + di->dataoffset)); 11359 + 11360 + ASSERT(di->txp[txout] == NULL); 11361 + 11362 + txout = NEXTTXD(txout); 11363 + } 11364 + 11365 + /* if last txd eof not set, fix it */ 11366 + if (!(ctrl & CTRL_EOF)) 11367 + W_SM(&di->txd[PREVTXD(txout)].ctrl, BUS_SWAP32(ctrl | CTRL_IOC | CTRL_EOF)); 11368 + 11369 + /* save the packet */ 11370 + di->txp[PREVTXD(txout)] = p0; 11371 + 11372 + /* bump the tx descriptor index */ 11373 + di->txout = txout; 11374 + 11375 + /* kick the chip */ 11376 + W_REG(&di->regs->xmtptr, I2B(txout)); 11377 + 11378 + /* tx flow control */ 11379 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; 11380 + 11381 + return (0); 11382 + 11383 +outoftxd: 11384 + DMA_ERROR(("%s: dma_txfast: out of txds\n", di->name)); 11385 + PKTFREE(di->drv, p0, TRUE); 11386 + di->txavail = 0; 11387 + di->hnddma.txnobuf++; 11388 + return (-1); 11389 +} 11390 + 11391 +#define PAGESZ 4096 11392 +#define PAGEBASE(x) ((uintptr)(x) & ~4095) 11393 + 11394 +/* 11395 + * Just like above except go through the extra effort of splitting 11396 + * buffers that cross 4Kbyte boundaries into multiple tx descriptors. 11397 + */ 11398 +int 11399 +dma_tx(dma_info_t *di, void *p0, uint32 coreflags) 11400 +{ 11401 + void *p, *next; 11402 + uchar *data; 11403 + uint plen, len; 11404 + uchar *page, *start, *end; 11405 + uint txout; 11406 + uint32 ctrl; 11407 + uint32 pa; 11408 + 11409 + DMA_TRACE(("%s: dma_tx\n", di->name)); 11410 + 11411 + txout = di->txout; 11412 + ctrl = 0; 11413 + 11414 + /* 11415 + * Walk the chain of packet buffers 11416 + * splitting those that cross 4 Kbyte boundaries 11417 + * allocating and initializing transmit descriptor entries. 11418 + */ 11419 + for (p = p0; p; p = next) { 11420 + data = PKTDATA(di->drv, p); 11421 + plen = PKTLEN(di->drv, p); 11422 + next = PKTNEXT(di->drv, p); 11423 + 11424 + if (plen == 0) 11425 + continue; 11426 + 11427 + for (page = (uchar*)PAGEBASE(data); 11428 + page <= (uchar*)PAGEBASE(data + plen - 1); 11429 + page += PAGESZ) { 11430 + 11431 + /* return nonzero if out of tx descriptors */ 11432 + if (NEXTTXD(txout) == di->txin) 11433 + goto outoftxd; 11434 + 11435 + start = (page == (uchar*)PAGEBASE(data))? data: page; 11436 + end = (page == (uchar*)PAGEBASE(data + plen))? 11437 + (data + plen): (page + PAGESZ); 11438 + len = (uint)(end - start); 11439 + 11440 + /* build the descriptor control value */ 11441 + ctrl = len & CTRL_BC_MASK; 11442 + 11443 + ctrl |= coreflags; 11444 + 11445 + if ((p == p0) && (start == data)) 11446 + ctrl |= CTRL_SOF; 11447 + if ((next == NULL) && (end == (data + plen))) 11448 + ctrl |= (CTRL_IOC | CTRL_EOF); 11449 + if (txout == (di->ntxd - 1)) 11450 + ctrl |= CTRL_EOT; 11451 + 11452 + /* get physical address of buffer start */ 11453 + pa = (uint32) DMA_MAP(di->osh, start, len, DMA_TX, p); 11454 + ASSERT(DMA_ADDRESSABLE(pa)); 11455 + 11456 + /* init the tx descriptor */ 11457 + W_SM(&di->txd[txout].ctrl, BUS_SWAP32(ctrl)); 11458 + W_SM(&di->txd[txout].addr, BUS_SWAP32(pa + di->dataoffset)); 11459 + 11460 + ASSERT(di->txp[txout] == NULL); 11461 + 11462 + txout = NEXTTXD(txout); 11463 + } 11464 + } 11465 + 11466 + /* if last txd eof not set, fix it */ 11467 + if (!(ctrl & CTRL_EOF)) 11468 + W_SM(&di->txd[PREVTXD(txout)].ctrl, BUS_SWAP32(ctrl | CTRL_IOC | CTRL_EOF)); 11469 + 11470 + /* save the packet */ 11471 + di->txp[PREVTXD(txout)] = p0; 11472 + 11473 + /* bump the tx descriptor index */ 11474 + di->txout = txout; 11475 + 11476 + /* kick the chip */ 11477 + W_REG(&di->regs->xmtptr, I2B(txout)); 11478 + 11479 + /* tx flow control */ 11480 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; 11481 + 11482 + return (0); 11483 + 11484 +outoftxd: 11485 + DMA_ERROR(("%s: dma_tx: out of txds\n", di->name)); 11486 + PKTFREE(di->drv, p0, TRUE); 11487 + di->txavail = 0; 11488 + di->hnddma.txnobuf++; 11489 + return (-1); 11490 +} 11491 + 11492 +/* returns a pointer to the next frame received, or NULL if there are no more */ 11493 +void* 11494 +dma_rx(dma_info_t *di) 11495 +{ 11496 + void *p; 11497 + uint len; 11498 + int skiplen = 0; 11499 + 11500 + while ((p = dma_getnextrxp(di, FALSE))) { 11501 + /* skip giant packets which span multiple rx descriptors */ 11502 + if (skiplen > 0) { 11503 + skiplen -= di->rxbufsize; 11504 + if (skiplen < 0) 11505 + skiplen = 0; 11506 + PKTFREE(di->drv, p, FALSE); 11507 + continue; 11508 + } 11509 + 11510 + len = ltoh16(*(uint16*)(PKTDATA(di->drv, p))); 11511 + DMA_TRACE(("%s: dma_rx len %d\n", di->name, len)); 11512 + 11513 + /* bad frame length check */ 11514 + if (len > (di->rxbufsize - di->rxoffset)) { 11515 + DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", di->name, len)); 11516 + if (len > 0) 11517 + skiplen = len - (di->rxbufsize - di->rxoffset); 11518 + PKTFREE(di->drv, p, FALSE); 11519 + di->hnddma.rxgiants++; 11520 + continue; 11521 + } 11522 + 11523 + /* set actual length */ 11524 + PKTSETLEN(di->drv, p, (di->rxoffset + len)); 11525 + 11526 + break; 11527 + } 11528 + 11529 + return (p); 11530 +} 11531 + 11532 +/* post receive buffers */ 11533 +void 11534 +dma_rxfill(dma_info_t *di) 11535 +{ 11536 + void *p; 11537 + uint rxin, rxout; 11538 + uint ctrl; 11539 + uint n; 11540 + uint i; 11541 + uint32 pa; 11542 + uint rxbufsize; 11543 + 11544 + /* 11545 + * Determine how many receive buffers we're lacking 11546 + * from the full complement, allocate, initialize, 11547 + * and post them, then update the chip rx lastdscr. 11548 + */ 11549 + 11550 + rxin = di->rxin; 11551 + rxout = di->rxout; 11552 + rxbufsize = di->rxbufsize; 11553 + 11554 + n = di->nrxpost - NRXDACTIVE(rxin, rxout); 11555 + 11556 + DMA_TRACE(("%s: dma_rxfill: post %d\n", di->name, n)); 11557 + 11558 + for (i = 0; i < n; i++) { 11559 + if ((p = PKTGET(di->drv, rxbufsize, FALSE)) == NULL) { 11560 + DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n", di->name)); 11561 + di->hnddma.rxnobuf++; 11562 + break; 11563 + } 11564 + 11565 + *(uint32*)(OSL_UNCACHED(PKTDATA(di->drv, p))) = 0; 11566 + 11567 + pa = (uint32) DMA_MAP(di->osh, PKTDATA(di->drv, p), rxbufsize, DMA_RX, p); 11568 + ASSERT(ISALIGNED(pa, 4)); 11569 + ASSERT(DMA_ADDRESSABLE(pa)); 11570 + 11571 + /* save the free packet pointer */ 11572 + ASSERT(di->rxp[rxout] == NULL); 11573 + di->rxp[rxout] = p; 11574 + 11575 + /* prep the descriptor control value */ 11576 + ctrl = rxbufsize; 11577 + if (rxout == (di->nrxd - 1)) 11578 + ctrl |= CTRL_EOT; 11579 + 11580 + /* init the rx descriptor */ 11581 + W_SM(&di->rxd[rxout].ctrl, BUS_SWAP32(ctrl)); 11582 + W_SM(&di->rxd[rxout].addr, BUS_SWAP32(pa + di->dataoffset)); 11583 + 11584 + rxout = NEXTRXD(rxout); 11585 + } 11586 + 11587 + di->rxout = rxout; 11588 + 11589 + /* update the chip lastdscr pointer */ 11590 + W_REG(&di->regs->rcvptr, I2B(rxout)); 11591 +} 11592 + 11593 +void 11594 +dma_txreclaim(dma_info_t *di, bool forceall) 11595 +{ 11596 + void *p; 11597 + 11598 + DMA_TRACE(("%s: dma_txreclaim %s\n", di->name, forceall ? "all" : "")); 11599 + 11600 + while ((p = dma_getnexttxp(di, forceall))) 11601 + PKTFREE(di->drv, p, TRUE); 11602 +} 11603 + 11604 +/* 11605 + * Reclaim next completed txd (txds if using chained buffers) and 11606 + * return associated packet. 11607 + * If 'force' is true, reclaim txd(s) and return associated packet 11608 + * regardless of the value of the hardware "curr" pointer. 11609 + */ 11610 +void* 11611 +dma_getnexttxp(dma_info_t *di, bool forceall) 11612 +{ 11613 + uint start, end, i; 11614 + void *txp; 11615 + 11616 + DMA_TRACE(("%s: dma_getnexttxp %s\n", di->name, forceall ? "all" : "")); 11617 + 11618 + txp = NULL; 11619 + 11620 + start = di->txin; 11621 + if (forceall) 11622 + end = di->txout; 11623 + else 11624 + end = B2I(R_REG(&di->regs->xmtstatus) & XS_CD_MASK); 11625 + 11626 + if ((start == 0) && (end > di->txout)) 11627 + goto bogus; 11628 + 11629 + for (i = start; i != end && !txp; i = NEXTTXD(i)) { 11630 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->txd[i].addr)) - di->dataoffset), 11631 + (BUS_SWAP32(R_SM(&di->txd[i].ctrl)) & CTRL_BC_MASK), DMA_TX, di->txp[i]); 11632 + W_SM(&di->txd[i].addr, 0xdeadbeef); 11633 + txp = di->txp[i]; 11634 + di->txp[i] = NULL; 11635 + } 11636 + 11637 + di->txin = i; 11638 + 11639 + /* tx flow control */ 11640 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; 11641 + 11642 + return (txp); 11643 + 11644 +bogus: 11645 +/* 11646 + DMA_ERROR(("dma_getnexttxp: bogus curr: start %d end %d txout %d force %d\n", 11647 + start, end, di->txout, forceall)); 11648 +*/ 11649 + return (NULL); 11650 +} 11651 + 11652 +/* like getnexttxp but no reclaim */ 11653 +void* 11654 +dma_peeknexttxp(dma_info_t *di) 11655 +{ 11656 + uint end, i; 11657 + 11658 + end = B2I(R_REG(&di->regs->xmtstatus) & XS_CD_MASK); 11659 + 11660 + for (i = di->txin; i != end; i = NEXTTXD(i)) 11661 + if (di->txp[i]) 11662 + return (di->txp[i]); 11663 + 11664 + return (NULL); 11665 +} 11666 + 11667 +void 11668 +dma_rxreclaim(dma_info_t *di) 11669 +{ 11670 + void *p; 11671 + 11672 + DMA_TRACE(("%s: dma_rxreclaim\n", di->name)); 11673 + 11674 + while ((p = dma_getnextrxp(di, TRUE))) 11675 + PKTFREE(di->drv, p, FALSE); 11676 +} 11677 + 11678 +void * 11679 +dma_getnextrxp(dma_info_t *di, bool forceall) 11680 +{ 11681 + uint i; 11682 + void *rxp; 11683 + 11684 + /* if forcing, dma engine must be disabled */ 11685 + ASSERT(!forceall || !dma_rxenabled(di)); 11686 + 11687 + i = di->rxin; 11688 + 11689 + /* return if no packets posted */ 11690 + if (i == di->rxout) 11691 + return (NULL); 11692 + 11693 + /* ignore curr if forceall */ 11694 + if (!forceall && (i == B2I(R_REG(&di->regs->rcvstatus) & RS_CD_MASK))) 11695 + return (NULL); 11696 + 11697 + /* get the packet pointer that corresponds to the rx descriptor */ 11698 + rxp = di->rxp[i]; 11699 + ASSERT(rxp); 11700 + di->rxp[i] = NULL; 11701 + 11702 + /* clear this packet from the descriptor ring */ 11703 + DMA_UNMAP(di->osh, (BUS_SWAP32(R_SM(&di->rxd[i].addr)) - di->dataoffset), 11704 + di->rxbufsize, DMA_RX, rxp); 11705 + W_SM(&di->rxd[i].addr, 0xdeadbeef); 11706 + 11707 + di->rxin = NEXTRXD(i); 11708 + 11709 + return (rxp); 11710 +} 11711 + 11712 + 11713 +uintptr 11714 +dma_getvar(dma_info_t *di, char *name) 11715 +{ 11716 + if (!strcmp(name, "&txavail")) 11717 + return ((uintptr) &di->txavail); 11718 + else { 11719 + ASSERT(0); 11720 + } 11721 + return (0); 11722 +} 11723 + 11724 +void 11725 +dma_txblock(dma_info_t *di) 11726 +{ 11727 + di->txavail = 0; 11728 +} 11729 + 11730 +void 11731 +dma_txunblock(dma_info_t *di) 11732 +{ 11733 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; 11734 +} 11735 + 11736 +uint 11737 +dma_txactive(dma_info_t *di) 11738 +{ 11739 + return (NTXDACTIVE(di->txin, di->txout)); 11740 +} 11741 + 11742 +/* 11743 + * Rotate all active tx dma ring entries "forward" by (ActiveDescriptor - txin). 11744 + */ 11745 +void 11746 +dma_txrotate(di_t *di) 11747 +{ 11748 + uint ad; 11749 + uint nactive; 11750 + uint rot; 11751 + uint old, new; 11752 + uint32 w; 11753 + uint first, last; 11754 + 11755 + ASSERT(dma_txsuspended(di)); 11756 + 11757 + nactive = dma_txactive(di); 11758 + ad = B2I((R_REG(&di->regs->xmtstatus) & XS_AD_MASK) >> XS_AD_SHIFT); 11759 + rot = TXD(ad - di->txin); 11760 + 11761 + ASSERT(rot < di->ntxd); 11762 + 11763 + /* full-ring case is a lot harder - don't worry about this */ 11764 + if (rot >= (di->ntxd - nactive)) { 11765 + DMA_ERROR(("%s: dma_txrotate: ring full - punt\n", di->name)); 11766 + return; 11767 + } 11768 + 11769 + first = di->txin; 11770 + last = PREVTXD(di->txout); 11771 + 11772 + /* move entries starting at last and moving backwards to first */ 11773 + for (old = last; old != PREVTXD(first); old = PREVTXD(old)) { 11774 + new = TXD(old + rot); 11775 + 11776 + /* 11777 + * Move the tx dma descriptor. 11778 + * EOT is set only in the last entry in the ring. 11779 + */ 11780 + w = R_SM(&di->txd[old].ctrl) & ~CTRL_EOT; 11781 + if (new == (di->ntxd - 1)) 11782 + w |= CTRL_EOT; 11783 + W_SM(&di->txd[new].ctrl, w); 11784 + W_SM(&di->txd[new].addr, R_SM(&di->txd[old].addr)); 11785 + 11786 + /* zap the old tx dma descriptor address field */ 11787 + W_SM(&di->txd[old].addr, 0xdeadbeef); 11788 + 11789 + /* move the corresponding txp[] entry */ 11790 + ASSERT(di->txp[new] == NULL); 11791 + di->txp[new] = di->txp[old]; 11792 + di->txp[old] = NULL; 11793 + } 11794 + 11795 + /* update txin and txout */ 11796 + di->txin = ad; 11797 + di->txout = TXD(di->txout + rot); 11798 + di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; 11799 + 11800 + /* kick the chip */ 11801 + W_REG(&di->regs->xmtptr, I2B(di->txout)); 11802 +} 11803 diff -Nur linux-2.4.32/drivers/net/hnd/linux_osl.c linux-2.4.32-freewrt/drivers/net/hnd/linux_osl.c 11804 --- linux-2.4.32/drivers/net/hnd/linux_osl.c 1970-01-01 01:00:00.000000000 +0100 11805 +++ linux-2.4.32-freewrt/drivers/net/hnd/linux_osl.c 2006-09-16 15:41:31.000000000 +0200 11806 @@ -0,0 +1,640 @@ 11807 +/* 11808 + * Linux OS Independent Layer 11809 + * 11810 + * Copyright 2004, Broadcom Corporation 11811 + * All Rights Reserved. 11812 + * 11813 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 11814 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 11815 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 11816 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 11817 + * 11818 + * $Id$ 11819 + */ 11820 + 11821 +#define LINUX_OSL 11822 + 11823 +#include <typedefs.h> 11824 +#include <bcmendian.h> 11825 +#include <linux/module.h> 11826 +#include <linuxver.h> 11827 +#include <linux_osl.h> 11828 +#include <bcmutils.h> 11829 +#include <linux/delay.h> 11830 +#ifdef mips 11831 +#include <asm/paccess.h> 11832 +#endif 11833 +#include <pcicfg.h> 11834 + 11835 +#define PCI_CFG_RETRY 10 11836 + 11837 +#define OS_HANDLE_MAGIC 0x1234abcd 11838 +#define BCM_MEM_FILENAME_LEN 24 11839 + 11840 +typedef struct bcm_mem_link { 11841 + struct bcm_mem_link *prev; 11842 + struct bcm_mem_link *next; 11843 + uint size; 11844 + int line; 11845 + char file[BCM_MEM_FILENAME_LEN]; 11846 +} bcm_mem_link_t; 11847 + 11848 +typedef struct os_handle { 11849 + uint magic; 11850 + void *pdev; 11851 + uint malloced; 11852 + uint failed; 11853 + bcm_mem_link_t *dbgmem_list; 11854 +} os_handle_t; 11855 + 11856 +void * 11857 +osl_attach(void *pdev) 11858 +{ 11859 + os_handle_t *osh; 11860 + 11861 + osh = kmalloc(sizeof(os_handle_t), GFP_ATOMIC); 11862 + ASSERT(osh); 11863 + 11864 + osh->magic = OS_HANDLE_MAGIC; 11865 + osh->malloced = 0; 11866 + osh->failed = 0; 11867 + osh->dbgmem_list = NULL; 11868 + osh->pdev = pdev; 11869 + 11870 + return osh; 11871 +} 11872 + 11873 +void 11874 +osl_detach(void *osh) 11875 +{ 11876 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC))); 11877 + kfree(osh); 11878 +} 11879 + 11880 +void* 11881 +osl_pktget(void *drv, uint len, bool send) 11882 +{ 11883 + struct sk_buff *skb; 11884 + 11885 + if ((skb = dev_alloc_skb(len)) == NULL) 11886 + return (NULL); 11887 + 11888 + skb_put(skb, len); 11889 + 11890 + /* ensure the cookie field is cleared */ 11891 + PKTSETCOOKIE(skb, NULL); 11892 + 11893 + return ((void*) skb); 11894 +} 11895 + 11896 +void 11897 +osl_pktfree(void *p) 11898 +{ 11899 + struct sk_buff *skb, *nskb; 11900 + 11901 + skb = (struct sk_buff*) p; 11902 + 11903 + /* perversion: we use skb->next to chain multi-skb packets */ 11904 + while (skb) { 11905 + nskb = skb->next; 11906 + skb->next = NULL; 11907 + if (skb->destructor) { 11908 + /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if destructor exists */ 11909 + dev_kfree_skb_any(skb); 11910 + } else { 11911 + /* can free immediately (even in_irq()) if destructor does not exist */ 11912 + dev_kfree_skb(skb); 11913 + } 11914 + skb = nskb; 11915 + } 11916 +} 11917 + 11918 +uint32 11919 +osl_pci_read_config(void *osh, uint offset, uint size) 11920 +{ 11921 + struct pci_dev *pdev; 11922 + uint val; 11923 + uint retry=PCI_CFG_RETRY; 11924 + 11925 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC))); 11926 + 11927 + /* only 4byte access supported */ 11928 + ASSERT(size == 4); 11929 + 11930 + pdev = ((os_handle_t *)osh)->pdev; 11931 + do { 11932 + pci_read_config_dword(pdev, offset, &val); 11933 + if (val != 0xffffffff) 11934 + break; 11935 + } while (retry--); 11936 + 11937 + 11938 + return (val); 11939 +} 11940 + 11941 +void 11942 +osl_pci_write_config(void *osh, uint offset, uint size, uint val) 11943 +{ 11944 + struct pci_dev *pdev; 11945 + uint retry=PCI_CFG_RETRY; 11946 + 11947 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC))); 11948 + 11949 + /* only 4byte access supported */ 11950 + ASSERT(size == 4); 11951 + 11952 + pdev = ((os_handle_t *)osh)->pdev; 11953 + 11954 + do { 11955 + pci_write_config_dword(pdev, offset, val); 11956 + if (offset!=PCI_BAR0_WIN) 11957 + break; 11958 + if (osl_pci_read_config(osh,offset,size) == val) 11959 + break; 11960 + } while (retry--); 11961 + 11962 +} 11963 + 11964 +static void 11965 +osl_pcmcia_attr(void *osh, uint offset, char *buf, int size, bool write) 11966 +{ 11967 +} 11968 + 11969 +void 11970 +osl_pcmcia_read_attr(void *osh, uint offset, void *buf, int size) 11971 +{ 11972 + osl_pcmcia_attr(osh, offset, (char *) buf, size, FALSE); 11973 +} 11974 + 11975 +void 11976 +osl_pcmcia_write_attr(void *osh, uint offset, void *buf, int size) 11977 +{ 11978 + osl_pcmcia_attr(osh, offset, (char *) buf, size, TRUE); 11979 +} 11980 + 11981 + 11982 +#ifdef BCMDBG_MEM 11983 + 11984 +void* 11985 +osl_debug_malloc(void *osh, uint size, int line, char* file) 11986 +{ 11987 + bcm_mem_link_t *p; 11988 + char* basename; 11989 + os_handle_t *h = (os_handle_t *)osh; 11990 + 11991 + if (size == 0) { 11992 + return NULL; 11993 + } 11994 + 11995 + p = (bcm_mem_link_t*)osl_malloc(osh, sizeof(bcm_mem_link_t) + size); 11996 + if (p == NULL) 11997 + return p; 11998 + 11999 + p->size = size; 12000 + p->line = line; 12001 + 12002 + basename = strrchr(file, '/'); 12003 + /* skip the '/' */ 12004 + if (basename) 12005 + basename++; 12006 + 12007 + if (!basename) 12008 + basename = file; 12009 + 12010 + strncpy(p->file, basename, BCM_MEM_FILENAME_LEN); 12011 + p->file[BCM_MEM_FILENAME_LEN - 1] = '\0'; 12012 + 12013 + /* link this block */ 12014 + p->prev = NULL; 12015 + p->next = h->dbgmem_list; 12016 + if (p->next) 12017 + p->next->prev = p; 12018 + h->dbgmem_list = p; 12019 + 12020 + return p + 1; 12021 +} 12022 + 12023 +void 12024 +osl_debug_mfree(void *osh, void *addr, uint size, int line, char* file) 12025 +{ 12026 + bcm_mem_link_t *p = (bcm_mem_link_t *)((int8*)addr - sizeof(bcm_mem_link_t)); 12027 + os_handle_t *h = (os_handle_t *)osh; 12028 + 12029 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC))); 12030 + 12031 + if (p->size == 0) { 12032 + printk("osl_debug_mfree: double free on addr 0x%x size %d at line %d file %s\n", 12033 + (uint)addr, size, line, file); 12034 + return; 12035 + } 12036 + 12037 + if (p->size != size) { 12038 + printk("osl_debug_mfree: dealloc size %d does not match alloc size %d on addr 0x%x at line %d file %s\n", 12039 + size, p->size, (uint)addr, line, file); 12040 + return; 12041 + } 12042 + 12043 + /* unlink this block */ 12044 + if (p->prev) 12045 + p->prev->next = p->next; 12046 + if (p->next) 12047 + p->next->prev = p->prev; 12048 + if (h->dbgmem_list == p) 12049 + h->dbgmem_list = p->next; 12050 + p->next = p->prev = NULL; 12051 + 12052 + osl_mfree(osh, p, size + sizeof(bcm_mem_link_t)); 12053 +} 12054 + 12055 +char* 12056 +osl_debug_memdump(void *osh, char *buf, uint sz) 12057 +{ 12058 + bcm_mem_link_t *p; 12059 + char *obuf; 12060 + os_handle_t *h = (os_handle_t *)osh; 12061 + 12062 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC))); 12063 + obuf = buf; 12064 + 12065 + buf += sprintf(buf, " Address\tSize\tFile:line\n"); 12066 + for (p = h->dbgmem_list; p && ((buf - obuf) < (sz - 128)); p = p->next) 12067 + buf += sprintf(buf, "0x%08x\t%5d\t%s:%d\n", 12068 + (int)p + sizeof(bcm_mem_link_t), p->size, p->file, p->line); 12069 + 12070 + return (obuf); 12071 +} 12072 + 12073 +#endif /* BCMDBG_MEM */ 12074 + 12075 +void* 12076 +osl_malloc(void *osh, uint size) 12077 +{ 12078 + os_handle_t *h = (os_handle_t *)osh; 12079 + void *addr; 12080 + 12081 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC))); 12082 + h->malloced += size; 12083 + addr = kmalloc(size, GFP_ATOMIC); 12084 + if (!addr) 12085 + h->failed++; 12086 + return (addr); 12087 +} 12088 + 12089 +void 12090 +osl_mfree(void *osh, void *addr, uint size) 12091 +{ 12092 + os_handle_t *h = (os_handle_t *)osh; 12093 + 12094 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC))); 12095 + h->malloced -= size; 12096 + kfree(addr); 12097 +} 12098 + 12099 +uint 12100 +osl_malloced(void *osh) 12101 +{ 12102 + os_handle_t *h = (os_handle_t *)osh; 12103 + 12104 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC))); 12105 + return (h->malloced); 12106 +} 12107 + 12108 +uint osl_malloc_failed(void *osh) 12109 +{ 12110 + os_handle_t *h = (os_handle_t *)osh; 12111 + 12112 + ASSERT((h && (h->magic == OS_HANDLE_MAGIC))); 12113 + return (h->failed); 12114 +} 12115 + 12116 +void* 12117 +osl_dma_alloc_consistent(void *osh, uint size, ulong *pap) 12118 +{ 12119 + struct pci_dev *dev; 12120 + 12121 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC))); 12122 + 12123 + dev = ((os_handle_t *)osh)->pdev; 12124 + return (pci_alloc_consistent(dev, size, (dma_addr_t*)pap)); 12125 +} 12126 + 12127 +void 12128 +osl_dma_free_consistent(void *osh, void *va, uint size, ulong pa) 12129 +{ 12130 + struct pci_dev *dev; 12131 + 12132 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC))); 12133 + 12134 + dev = ((os_handle_t *)osh)->pdev; 12135 + pci_free_consistent(dev, size, va, (dma_addr_t)pa); 12136 +} 12137 + 12138 +uint 12139 +osl_dma_map(void *osh, void *va, uint size, int direction) 12140 +{ 12141 + int dir; 12142 + struct pci_dev *dev; 12143 + 12144 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC))); 12145 + 12146 + dev = ((os_handle_t *)osh)->pdev; 12147 + dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE; 12148 + return (pci_map_single(dev, va, size, dir)); 12149 +} 12150 + 12151 +void 12152 +osl_dma_unmap(void *osh, uint pa, uint size, int direction) 12153 +{ 12154 + int dir; 12155 + struct pci_dev *dev; 12156 + 12157 + ASSERT((osh && (((os_handle_t *)osh)->magic == OS_HANDLE_MAGIC))); 12158 + 12159 + dev = ((os_handle_t *)osh)->pdev; 12160 + dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE; 12161 + pci_unmap_single(dev, (uint32)pa, size, dir); 12162 +} 12163 + 12164 +#if defined(BINOSL) 12165 +void 12166 +osl_assert(char *exp, char *file, int line) 12167 +{ 12168 + char tempbuf[255]; 12169 + 12170 + sprintf(tempbuf, "assertion \"%s\" failed: file \"%s\", line %d\n", exp, file, line); 12171 + panic(tempbuf); 12172 +} 12173 +#endif /* BCMDBG || BINOSL */ 12174 + 12175 +/* 12176 + * BINOSL selects the slightly slower function-call-based binary compatible osl. 12177 + */ 12178 +#ifdef BINOSL 12179 + 12180 +int 12181 +osl_printf(const char *format, ...) 12182 +{ 12183 + va_list args; 12184 + char buf[1024]; 12185 + int len; 12186 + 12187 + /* sprintf into a local buffer because there *is* no "vprintk()".. */ 12188 + va_start(args, format); 12189 + len = vsprintf(buf, format, args); 12190 + va_end(args); 12191 + 12192 + if (len > sizeof (buf)) { 12193 + printk("osl_printf: buffer overrun\n"); 12194 + return (0); 12195 + } 12196 + 12197 + return (printk(buf)); 12198 +} 12199 + 12200 +int 12201 +osl_sprintf(char *buf, const char *format, ...) 12202 +{ 12203 + va_list args; 12204 + int rc; 12205 + 12206 + va_start(args, format); 12207 + rc = vsprintf(buf, format, args); 12208 + va_end(args); 12209 + return (rc); 12210 +} 12211 + 12212 +int 12213 +osl_strcmp(const char *s1, const char *s2) 12214 +{ 12215 + return (strcmp(s1, s2)); 12216 +} 12217 + 12218 +int 12219 +osl_strncmp(const char *s1, const char *s2, uint n) 12220 +{ 12221 + return (strncmp(s1, s2, n)); 12222 +} 12223 + 12224 +int 12225 +osl_strlen(char *s) 12226 +{ 12227 + return (strlen(s)); 12228 +} 12229 + 12230 +char* 12231 +osl_strcpy(char *d, const char *s) 12232 +{ 12233 + return (strcpy(d, s)); 12234 +} 12235 + 12236 +char* 12237 +osl_strncpy(char *d, const char *s, uint n) 12238 +{ 12239 + return (strncpy(d, s, n)); 12240 +} 12241 + 12242 +void 12243 +bcopy(const void *src, void *dst, int len) 12244 +{ 12245 + memcpy(dst, src, len); 12246 +} 12247 + 12248 +int 12249 +bcmp(const void *b1, const void *b2, int len) 12250 +{ 12251 + return (memcmp(b1, b2, len)); 12252 +} 12253 + 12254 +void 12255 +bzero(void *b, int len) 12256 +{ 12257 + memset(b, '\0', len); 12258 +} 12259 + 12260 +uint32 12261 +osl_readl(volatile uint32 *r) 12262 +{ 12263 + return (readl(r)); 12264 +} 12265 + 12266 +uint16 12267 +osl_readw(volatile uint16 *r) 12268 +{ 12269 + return (readw(r)); 12270 +} 12271 + 12272 +uint8 12273 +osl_readb(volatile uint8 *r) 12274 +{ 12275 + return (readb(r)); 12276 +} 12277 + 12278 +void 12279 +osl_writel(uint32 v, volatile uint32 *r) 12280 +{ 12281 + writel(v, r); 12282 +} 12283 + 12284 +void 12285 +osl_writew(uint16 v, volatile uint16 *r) 12286 +{ 12287 + writew(v, r); 12288 +} 12289 + 12290 +void 12291 +osl_writeb(uint8 v, volatile uint8 *r) 12292 +{ 12293 + writeb(v, r); 12294 +} 12295 + 12296 +void * 12297 +osl_uncached(void *va) 12298 +{ 12299 +#ifdef mips 12300 + return ((void*)KSEG1ADDR(va)); 12301 +#else 12302 + return ((void*)va); 12303 +#endif 12304 +} 12305 + 12306 +uint 12307 +osl_getcycles(void) 12308 +{ 12309 + uint cycles; 12310 + 12311 +#if defined(mips) 12312 + cycles = read_c0_count() * 2; 12313 +#elif defined(__i386__) 12314 + rdtscl(cycles); 12315 +#else 12316 + cycles = 0; 12317 +#endif 12318 + return cycles; 12319 +} 12320 + 12321 +void * 12322 +osl_reg_map(uint32 pa, uint size) 12323 +{ 12324 + return (ioremap_nocache((unsigned long)pa, (unsigned long)size)); 12325 +} 12326 + 12327 +void 12328 +osl_reg_unmap(void *va) 12329 +{ 12330 + iounmap(va); 12331 +} 12332 + 12333 +int 12334 +osl_busprobe(uint32 *val, uint32 addr) 12335 +{ 12336 +#ifdef mips 12337 + return get_dbe(*val, (uint32*)addr); 12338 +#else 12339 + *val = readl(addr); 12340 + return 0; 12341 +#endif 12342 +} 12343 + 12344 +void 12345 +osl_delay(uint usec) 12346 +{ 12347 + udelay(usec); 12348 +} 12349 + 12350 +uchar* 12351 +osl_pktdata(void *drv, void *skb) 12352 +{ 12353 + return (((struct sk_buff*)skb)->data); 12354 +} 12355 + 12356 +uint 12357 +osl_pktlen(void *drv, void *skb) 12358 +{ 12359 + return (((struct sk_buff*)skb)->len); 12360 +} 12361 + 12362 +uint 12363 +osl_pktheadroom(void *drv, void *skb) 12364 +{ 12365 + return (uint) skb_headroom((struct sk_buff *) skb); 12366 +} 12367 + 12368 +uint 12369 +osl_pkttailroom(void *drv, void *skb) 12370 +{ 12371 + return (uint) skb_tailroom((struct sk_buff *) skb); 12372 +} 12373 + 12374 +void* 12375 +osl_pktnext(void *drv, void *skb) 12376 +{ 12377 + return (((struct sk_buff*)skb)->next); 12378 +} 12379 + 12380 +void 12381 +osl_pktsetnext(void *skb, void *x) 12382 +{ 12383 + ((struct sk_buff*)skb)->next = (struct sk_buff*)x; 12384 +} 12385 + 12386 +void 12387 +osl_pktsetlen(void *drv, void *skb, uint len) 12388 +{ 12389 + __skb_trim((struct sk_buff*)skb, len); 12390 +} 12391 + 12392 +uchar* 12393 +osl_pktpush(void *drv, void *skb, int bytes) 12394 +{ 12395 + return (skb_push((struct sk_buff*)skb, bytes)); 12396 +} 12397 + 12398 +uchar* 12399 +osl_pktpull(void *drv, void *skb, int bytes) 12400 +{ 12401 + return (skb_pull((struct sk_buff*)skb, bytes)); 12402 +} 12403 + 12404 +void* 12405 +osl_pktdup(void *drv, void *skb) 12406 +{ 12407 + return (skb_clone((struct sk_buff*)skb, GFP_ATOMIC)); 12408 +} 12409 + 12410 +void* 12411 +osl_pktcookie(void *skb) 12412 +{ 12413 + return ((void*)((struct sk_buff*)skb)->csum); 12414 +} 12415 + 12416 +void 12417 +osl_pktsetcookie(void *skb, void *x) 12418 +{ 12419 + ((struct sk_buff*)skb)->csum = (uint)x; 12420 +} 12421 + 12422 +void* 12423 +osl_pktlink(void *skb) 12424 +{ 12425 + return (((struct sk_buff*)skb)->prev); 12426 +} 12427 + 12428 +void 12429 +osl_pktsetlink(void *skb, void *x) 12430 +{ 12431 + ((struct sk_buff*)skb)->prev = (struct sk_buff*)x; 12432 +} 12433 + 12434 +uint 12435 +osl_pktprio(void *skb) 12436 +{ 12437 + return (((struct sk_buff*)skb)->priority); 12438 +} 12439 + 12440 +void 12441 +osl_pktsetprio(void *skb, uint x) 12442 +{ 12443 + ((struct sk_buff*)skb)->priority = x; 12444 +} 12445 + 12446 +#endif /* BINOSL */ 12447 diff -Nur linux-2.4.32/drivers/net/hnd/Makefile linux-2.4.32-freewrt/drivers/net/hnd/Makefile 12448 --- linux-2.4.32/drivers/net/hnd/Makefile 1970-01-01 01:00:00.000000000 +0100 12449 +++ linux-2.4.32-freewrt/drivers/net/hnd/Makefile 2006-09-16 15:41:31.000000000 +0200 12450 @@ -0,0 +1,19 @@ 12451 +# 12452 +# Makefile for the BCM47xx specific kernel interface routines 12453 +# under Linux. 12454 +# 12455 + 12456 +EXTRA_CFLAGS += -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER 12457 + 12458 +O_TARGET := hnd.o 12459 + 12460 +HND_OBJS := bcmutils.o hnddma.o linux_osl.o sbutils.o bcmsrom.o 12461 + 12462 +export-objs := shared_ksyms.o 12463 +obj-y := shared_ksyms.o $(HND_OBJS) 12464 +obj-m := $(O_TARGET) 12465 + 12466 +include $(TOPDIR)/Rules.make 12467 + 12468 +shared_ksyms.c: shared_ksyms.sh $(HND_OBJS) 12469 + sh -e $< $(HND_OBJS) > $@ 12470 diff -Nur linux-2.4.32/drivers/net/hnd/sbutils.c linux-2.4.32-freewrt/drivers/net/hnd/sbutils.c 12471 --- linux-2.4.32/drivers/net/hnd/sbutils.c 1970-01-01 01:00:00.000000000 +0100 12472 +++ linux-2.4.32-freewrt/drivers/net/hnd/sbutils.c 2006-09-16 15:41:31.000000000 +0200 12473 @@ -0,0 +1,2061 @@ 12474 +/* 12475 + * Misc utility routines for accessing chip-specific features 12476 + * of the SiliconBackplane-based Broadcom chips. 12477 + * 12478 + * Copyright 2005, Broadcom Corporation 12479 + * All Rights Reserved. 12480 + * 12481 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 12482 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 12483 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 12484 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 12485 + * $Id: sbutils.c,v 1.6 2005/03/07 08:35:32 kanki Exp $ 12486 + */ 12487 + 12488 +#include <typedefs.h> 12489 +#include <osl.h> 12490 +#include <bcmutils.h> 12491 +#include <bcmdevs.h> 12492 +#include <sbconfig.h> 12493 +#include <sbchipc.h> 12494 +#include <sbpci.h> 12495 +#include <pcicfg.h> 12496 +#include <sbpcmcia.h> 12497 +#include <sbextif.h> 12498 +#include <sbutils.h> 12499 +#include <bcmsrom.h> 12500 + 12501 +/* debug/trace */ 12502 +#define SB_ERROR(args) 12503 + 12504 + 12505 +typedef uint32 (*sb_intrsoff_t)(void *intr_arg); 12506 +typedef void (*sb_intrsrestore_t)(void *intr_arg, uint32 arg); 12507 +typedef bool (*sb_intrsenabled_t)(void *intr_arg); 12508 + 12509 +/* misc sb info needed by some of the routines */ 12510 +typedef struct sb_info { 12511 + uint chip; /* chip number */ 12512 + uint chiprev; /* chip revision */ 12513 + uint chippkg; /* chip package option */ 12514 + uint boardtype; /* board type */ 12515 + uint boardvendor; /* board vendor id */ 12516 + uint bustype; /* what bus type we are going through */ 12517 + 12518 + void *osh; /* osl os handle */ 12519 + void *sdh; /* bcmsdh handle */ 12520 + 12521 + void *curmap; /* current regs va */ 12522 + void *regs[SB_MAXCORES]; /* other regs va */ 12523 + 12524 + uint curidx; /* current core index */ 12525 + uint dev_coreid; /* the core provides driver functions */ 12526 + uint pciidx; /* pci core index */ 12527 + uint pcirev; /* pci core rev */ 12528 + 12529 + uint pcmciaidx; /* pcmcia core index */ 12530 + uint pcmciarev; /* pcmcia core rev */ 12531 + bool memseg; /* flag to toggle MEM_SEG register */ 12532 + 12533 + uint ccrev; /* chipc core rev */ 12534 + 12535 + uint gpioidx; /* gpio control core index */ 12536 + uint gpioid; /* gpio control coretype */ 12537 + 12538 + uint numcores; /* # discovered cores */ 12539 + uint coreid[SB_MAXCORES]; /* id of each core */ 12540 + 12541 + void *intr_arg; /* interrupt callback function arg */ 12542 + sb_intrsoff_t intrsoff_fn; /* function turns chip interrupts off */ 12543 + sb_intrsrestore_t intrsrestore_fn; /* function restore chip interrupts */ 12544 + sb_intrsenabled_t intrsenabled_fn; /* function to check if chip interrupts are enabled */ 12545 +} sb_info_t; 12546 + 12547 +/* local prototypes */ 12548 +static void* BCMINIT(sb_doattach)(sb_info_t *si, uint devid, void *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz); 12549 +static void BCMINIT(sb_scan)(sb_info_t *si); 12550 +static uint sb_corereg(void *sbh, uint coreidx, uint regoff, uint mask, uint val); 12551 +static uint _sb_coreidx(void *sbh); 12552 +static uint sb_findcoreidx(void *sbh, uint coreid, uint coreunit); 12553 +static uint BCMINIT(sb_pcidev2chip)(uint pcidev); 12554 +static uint BCMINIT(sb_chip2numcores)(uint chip); 12555 + 12556 +#define SB_INFO(sbh) (sb_info_t*)sbh 12557 +#define SET_SBREG(sbh, r, mask, val) W_SBREG((sbh), (r), ((R_SBREG((sbh), (r)) & ~(mask)) | (val))) 12558 +#define GOODCOREADDR(x) (((x) >= SB_ENUM_BASE) && ((x) <= SB_ENUM_LIM) && ISALIGNED((x), SB_CORE_SIZE)) 12559 +#define GOODREGS(regs) ((regs) && ISALIGNED((uintptr)(regs), SB_CORE_SIZE)) 12560 +#define REGS2SB(va) (sbconfig_t*) ((int8*)(va) + SBCONFIGOFF) 12561 +#define GOODIDX(idx) (((uint)idx) < SB_MAXCORES) 12562 +#define BADIDX (SB_MAXCORES+1) 12563 +#define NOREV (SBIDH_RC_MASK + 1) 12564 + 12565 +#define R_SBREG(sbh, sbr) sb_read_sbreg((sbh), (sbr)) 12566 +#define W_SBREG(sbh, sbr, v) sb_write_sbreg((sbh), (sbr), (v)) 12567 +#define AND_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) & (v))) 12568 +#define OR_SBREG(sbh, sbr, v) W_SBREG((sbh), (sbr), (R_SBREG((sbh), (sbr)) | (v))) 12569 + 12570 +/* 12571 + * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts before/ 12572 + * after core switching to avoid invalid register accesss inside ISR. 12573 + */ 12574 +#define INTR_OFF(si, intr_val) \ 12575 + if ((si)->intrsoff_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \ 12576 + intr_val = (*(si)->intrsoff_fn)((si)->intr_arg); } 12577 +#define INTR_RESTORE(si, intr_val) \ 12578 + if ((si)->intrsrestore_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \ 12579 + (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val); } 12580 + 12581 +/* power control defines */ 12582 +#define LPOMINFREQ 25000 /* low power oscillator min */ 12583 +#define LPOMAXFREQ 43000 /* low power oscillator max */ 12584 +#define XTALMINFREQ 19800000 /* 20mhz - 1% */ 12585 +#define XTALMAXFREQ 20200000 /* 20mhz + 1% */ 12586 +#define PCIMINFREQ 25000000 /* 25mhz */ 12587 +#define PCIMAXFREQ 34000000 /* 33mhz + fudge */ 12588 +#define SCC_DEF_DIV 0 /* default slow clock divider */ 12589 + 12590 +#define XTAL_ON_DELAY 1000 /* Xtal power on delay in us */ 12591 + 12592 +#define SCC_LOW2FAST_LIMIT 5000 /* turn on fast clock time, in unit of ms */ 12593 + 12594 +static uint32 12595 +sb_read_sbreg(void *sbh, volatile uint32 *sbr) 12596 +{ 12597 + sb_info_t *si; 12598 + uint8 tmp; 12599 + uint32 val, intr_val = 0; 12600 + 12601 + si = SB_INFO(sbh); 12602 + 12603 + /* 12604 + * compact flash only has 11 bits address, while we needs 12 bits address. 12605 + * MEM_SEG will be OR'd with other 11 bits address in hardware, 12606 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters). 12607 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special 12608 + */ 12609 + if(si->memseg) { 12610 + INTR_OFF(si, intr_val); 12611 + tmp = 1; 12612 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1); 12613 + (uintptr)sbr &= ~(1 << 11); /* mask out bit 11*/ 12614 + } 12615 + 12616 + val = R_REG(sbr); 12617 + 12618 + if(si->memseg) { 12619 + tmp = 0; 12620 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1); 12621 + INTR_RESTORE(si, intr_val); 12622 + } 12623 + 12624 + return (val); 12625 +} 12626 + 12627 +static void 12628 +sb_write_sbreg(void *sbh, volatile uint32 *sbr, uint32 v) 12629 +{ 12630 + sb_info_t *si; 12631 + uint8 tmp; 12632 + volatile uint32 dummy; 12633 + uint32 intr_val = 0; 12634 + 12635 + si = SB_INFO(sbh); 12636 + 12637 + /* 12638 + * compact flash only has 11 bits address, while we needs 12 bits address. 12639 + * MEM_SEG will be OR'd with other 11 bits address in hardware, 12640 + * so we program MEM_SEG with 12th bit when necessary(access sb regsiters). 12641 + * For normal PCMCIA bus(CFTable_regwinsz > 2k), do nothing special 12642 + */ 12643 + if(si->memseg) { 12644 + INTR_OFF(si, intr_val); 12645 + tmp = 1; 12646 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1); 12647 + (uintptr)sbr &= ~(1 << 11); /* mask out bit 11 */ 12648 + } 12649 + 12650 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) { 12651 +#ifdef IL_BIGENDIAN 12652 + dummy = R_REG(sbr); 12653 + W_REG(((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff)); 12654 + dummy = R_REG(sbr); 12655 + W_REG((volatile uint16 *)sbr, (uint16)(v & 0xffff)); 12656 +#else 12657 + dummy = R_REG(sbr); 12658 + W_REG((volatile uint16 *)sbr, (uint16)(v & 0xffff)); 12659 + dummy = R_REG(sbr); 12660 + W_REG(((volatile uint16 *)sbr + 1), (uint16)((v >> 16) & 0xffff)); 12661 +#endif 12662 + } else 12663 + W_REG(sbr, v); 12664 + 12665 + if(si->memseg) { 12666 + tmp = 0; 12667 + OSL_PCMCIA_WRITE_ATTR(si->osh, MEM_SEG, &tmp, 1); 12668 + INTR_RESTORE(si, intr_val); 12669 + } 12670 +} 12671 + 12672 +/* 12673 + * Allocate a sb handle. 12674 + * devid - pci device id (used to determine chip#) 12675 + * osh - opaque OS handle 12676 + * regs - virtual address of initial core registers 12677 + * bustype - pci/pcmcia/sb/sdio/etc 12678 + * vars - pointer to a pointer area for "environment" variables 12679 + * varsz - pointer to int to return the size of the vars 12680 + */ 12681 +void* 12682 +BCMINITFN(sb_attach)(uint devid, void *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz) 12683 +{ 12684 + sb_info_t *si; 12685 + 12686 + /* alloc sb_info_t */ 12687 + if ((si = MALLOC(osh, sizeof (sb_info_t))) == NULL) { 12688 + SB_ERROR(("sb_attach: malloc failed! malloced %d bytes\n", MALLOCED(osh))); 12689 + return (NULL); 12690 + } 12691 + 12692 + if (BCMINIT(sb_doattach)(si, devid, osh, regs, bustype, sdh, vars, varsz) == NULL) { 12693 + MFREE(osh, si, sizeof (sb_info_t)); 12694 + return (NULL); 12695 + } 12696 + return si; 12697 +} 12698 + 12699 +/* Using sb_kattach depends on SB_BUS support, either implicit */ 12700 +/* no limiting BCMBUSTYPE value) or explicit (value is SB_BUS). */ 12701 +#if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SB_BUS) 12702 + 12703 +/* global kernel resource */ 12704 +static sb_info_t ksi; 12705 + 12706 +/* generic kernel variant of sb_attach() */ 12707 +void* 12708 +BCMINITFN(sb_kattach)() 12709 +{ 12710 + uint32 *regs; 12711 + char *unused; 12712 + int varsz; 12713 + 12714 + if (ksi.curmap == NULL) { 12715 + uint32 cid; 12716 + 12717 + regs = (uint32 *)REG_MAP(SB_ENUM_BASE, SB_CORE_SIZE); 12718 + cid = R_REG((uint32 *)regs); 12719 + if (((cid & CID_ID_MASK) == BCM4712_DEVICE_ID) && 12720 + ((cid & CID_PKG_MASK) != BCM4712LARGE_PKG_ID) && 12721 + ((cid & CID_REV_MASK) <= (3 << CID_REV_SHIFT))) { 12722 + uint32 *scc, val; 12723 + 12724 + scc = (uint32 *)((uchar*)regs + OFFSETOF(chipcregs_t, slow_clk_ctl)); 12725 + val = R_REG(scc); 12726 + SB_ERROR((" initial scc = 0x%x\n", val)); 12727 + val |= SCC_SS_XTAL; 12728 + W_REG(scc, val); 12729 + } 12730 + 12731 + if (BCMINIT(sb_doattach)(&ksi, BCM4710_DEVICE_ID, NULL, (void*)regs, 12732 + SB_BUS, NULL, &unused, &varsz) == NULL) { 12733 + return NULL; 12734 + } 12735 + } 12736 + 12737 + return &ksi; 12738 +} 12739 +#endif 12740 + 12741 +static void* 12742 +BCMINITFN(sb_doattach)(sb_info_t *si, uint devid, void *osh, void *regs, uint bustype, void *sdh, char **vars, int *varsz) 12743 +{ 12744 + uint origidx; 12745 + chipcregs_t *cc; 12746 + uint32 w; 12747 + int res; 12748 + 12749 + ASSERT(GOODREGS(regs)); 12750 + 12751 + bzero((uchar*)si, sizeof (sb_info_t)); 12752 + 12753 + si->pciidx = si->gpioidx = BADIDX; 12754 + 12755 + si->osh = osh; 12756 + si->curmap = regs; 12757 + si->sdh = sdh; 12758 + 12759 + /* check to see if we are a sb core mimic'ing a pci core */ 12760 + if (bustype == PCI_BUS) { 12761 + if (OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof (uint32)) == 0xffffffff) 12762 + bustype = SB_BUS; 12763 + else 12764 + bustype = PCI_BUS; 12765 + } 12766 + 12767 + si->bustype = bustype; 12768 + if (si->bustype != BUSTYPE(si->bustype)) { 12769 + SB_ERROR(("sb_doattach: bus type %d does not match configured bus type %d\n", 12770 + si->bustype, BUSTYPE(si->bustype))); 12771 + return NULL; 12772 + } 12773 + 12774 + /* need to set memseg flag for CF card first before any sb registers access */ 12775 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) 12776 + si->memseg = TRUE; 12777 + 12778 + /* kludge to enable the clock on the 4306 which lacks a slowclock */ 12779 + if (BUSTYPE(si->bustype) == PCI_BUS) 12780 + sb_pwrctl_xtal((void*)si, XTAL|PLL, ON); 12781 + 12782 + /* initialize current core index value */ 12783 + si->curidx = _sb_coreidx((void*)si); 12784 + if (si->curidx == BADIDX) { 12785 + return NULL; 12786 + } 12787 + 12788 + /* keep and reuse the initial register mapping */ 12789 + origidx = si->curidx; 12790 + if (BUSTYPE(si->bustype) == SB_BUS) 12791 + si->regs[origidx] = regs; 12792 + 12793 + /* is core-0 a chipcommon core? */ 12794 + si->numcores = 1; 12795 + cc = (chipcregs_t*) sb_setcoreidx((void*)si, 0); 12796 + if (sb_coreid((void*)si) != SB_CC) 12797 + cc = NULL; 12798 + 12799 + /* determine chip id and rev */ 12800 + if (cc) { 12801 + /* chip common core found! */ 12802 + si->chip = R_REG(&cc->chipid) & CID_ID_MASK; 12803 + si->chiprev = (R_REG(&cc->chipid) & CID_REV_MASK) >> CID_REV_SHIFT; 12804 + si->chippkg = (R_REG(&cc->chipid) & CID_PKG_MASK) >> CID_PKG_SHIFT; 12805 + } else { 12806 + /* The only pcmcia chip without a chipcommon core is a 4301 */ 12807 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) 12808 + devid = BCM4301_DEVICE_ID; 12809 + 12810 + /* no chip common core -- must convert device id to chip id */ 12811 + if ((si->chip = BCMINIT(sb_pcidev2chip)(devid)) == 0) { 12812 + SB_ERROR(("sb_attach: unrecognized device id 0x%04x\n", devid)); 12813 + return NULL; 12814 + } 12815 + } 12816 + 12817 + /* get chipcommon rev */ 12818 + si->ccrev = cc ? sb_corerev((void*)si) : NOREV; 12819 + 12820 + /* determine numcores */ 12821 + if (cc && ((si->ccrev == 4) || (si->ccrev >= 6))) 12822 + si->numcores = (R_REG(&cc->chipid) & CID_CC_MASK) >> CID_CC_SHIFT; 12823 + else 12824 + si->numcores = BCMINIT(sb_chip2numcores)(si->chip); 12825 + 12826 + /* return to original core */ 12827 + sb_setcoreidx((void*)si, origidx); 12828 + 12829 + /* sanity checks */ 12830 + ASSERT(si->chip); 12831 + 12832 + /* scan for cores */ 12833 + BCMINIT(sb_scan)(si); 12834 + 12835 + /* srom_var_init() depends on sb_scan() info */ 12836 + if ((res = srom_var_init(si, si->bustype, si->curmap, osh, vars, varsz))) { 12837 + SB_ERROR(("sb_attach: srom_var_init failed: bad srom\n")); 12838 + return (NULL); 12839 + } 12840 + 12841 + if (cc == NULL) { 12842 + /* 12843 + * The chip revision number is hardwired into all 12844 + * of the pci function config rev fields and is 12845 + * independent from the individual core revision numbers. 12846 + * For example, the "A0" silicon of each chip is chip rev 0. 12847 + * For PCMCIA we get it from the CIS instead. 12848 + */ 12849 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) { 12850 + ASSERT(vars); 12851 + si->chiprev = getintvar(*vars, "chiprev"); 12852 + } else if (BUSTYPE(si->bustype) == PCI_BUS) { 12853 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_REV, sizeof (uint32)); 12854 + si->chiprev = w & 0xff; 12855 + } else 12856 + si->chiprev = 0; 12857 + } 12858 + 12859 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) { 12860 + w = getintvar(*vars, "regwindowsz"); 12861 + si->memseg = (w <= CFTABLE_REGWIN_2K) ? TRUE : FALSE; 12862 + } 12863 + 12864 + /* gpio control core is required */ 12865 + if (!GOODIDX(si->gpioidx)) { 12866 + SB_ERROR(("sb_attach: gpio control core not found\n")); 12867 + return NULL; 12868 + } 12869 + 12870 + /* get boardtype and boardrev */ 12871 + switch (BUSTYPE(si->bustype)) { 12872 + case PCI_BUS: 12873 + /* do a pci config read to get subsystem id and subvendor id */ 12874 + w = OSL_PCI_READ_CONFIG(osh, PCI_CFG_SVID, sizeof (uint32)); 12875 + si->boardvendor = w & 0xffff; 12876 + si->boardtype = (w >> 16) & 0xffff; 12877 + break; 12878 + 12879 + case PCMCIA_BUS: 12880 + case SDIO_BUS: 12881 + si->boardvendor = getintvar(*vars, "manfid"); 12882 + si->boardtype = getintvar(*vars, "prodid"); 12883 + break; 12884 + 12885 + case SB_BUS: 12886 + si->boardvendor = VENDOR_BROADCOM; 12887 + si->boardtype = 0xffff; 12888 + break; 12889 + } 12890 + 12891 + if (si->boardtype == 0) { 12892 + SB_ERROR(("sb_attach: unknown board type\n")); 12893 + ASSERT(si->boardtype); 12894 + } 12895 + 12896 + 12897 + return ((void*)si); 12898 +} 12899 + 12900 +uint 12901 +sb_coreid(void *sbh) 12902 +{ 12903 + sb_info_t *si; 12904 + sbconfig_t *sb; 12905 + 12906 + si = SB_INFO(sbh); 12907 + sb = REGS2SB(si->curmap); 12908 + 12909 + return ((R_SBREG(sbh, &(sb)->sbidhigh) & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT); 12910 +} 12911 + 12912 +uint 12913 +sb_coreidx(void *sbh) 12914 +{ 12915 + sb_info_t *si; 12916 + 12917 + si = SB_INFO(sbh); 12918 + return (si->curidx); 12919 +} 12920 + 12921 +/* return current index of core */ 12922 +static uint 12923 +_sb_coreidx(void *sbh) 12924 +{ 12925 + sb_info_t *si; 12926 + sbconfig_t *sb; 12927 + uint32 sbaddr = 0; 12928 + 12929 + si = SB_INFO(sbh); 12930 + ASSERT(si); 12931 + 12932 + switch (BUSTYPE(si->bustype)) { 12933 + case SB_BUS: 12934 + sb = REGS2SB(si->curmap); 12935 + sbaddr = sb_base(R_SBREG(sbh, &sb->sbadmatch0)); 12936 + break; 12937 + 12938 + case PCI_BUS: 12939 + sbaddr = OSL_PCI_READ_CONFIG(si->osh, PCI_BAR0_WIN, sizeof (uint32)); 12940 + break; 12941 + 12942 + case PCMCIA_BUS: { 12943 + uint8 tmp = 0; 12944 + 12945 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1); 12946 + sbaddr = (uint)tmp << 12; 12947 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1); 12948 + sbaddr |= (uint)tmp << 16; 12949 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1); 12950 + sbaddr |= (uint)tmp << 24; 12951 + break; 12952 + } 12953 + default: 12954 + ASSERT(0); 12955 + } 12956 + 12957 + if (!GOODCOREADDR(sbaddr)) 12958 + return BADIDX; 12959 + 12960 + return ((sbaddr - SB_ENUM_BASE) / SB_CORE_SIZE); 12961 +} 12962 + 12963 +uint 12964 +sb_corevendor(void *sbh) 12965 +{ 12966 + sb_info_t *si; 12967 + sbconfig_t *sb; 12968 + 12969 + si = SB_INFO(sbh); 12970 + sb = REGS2SB(si->curmap); 12971 + 12972 + return ((R_SBREG(sbh, &(sb)->sbidhigh) & SBIDH_VC_MASK) >> SBIDH_VC_SHIFT); 12973 +} 12974 + 12975 +uint 12976 +sb_corerev(void *sbh) 12977 +{ 12978 + sb_info_t *si; 12979 + sbconfig_t *sb; 12980 + 12981 + si = SB_INFO(sbh); 12982 + sb = REGS2SB(si->curmap); 12983 + 12984 + return (R_SBREG(sbh, &(sb)->sbidhigh) & SBIDH_RC_MASK); 12985 +} 12986 + 12987 +void * 12988 +sb_osh(void *sbh) 12989 +{ 12990 + sb_info_t *si; 12991 + 12992 + si = SB_INFO(sbh); 12993 + return si->osh; 12994 +} 12995 + 12996 +#define SBTML_ALLOW (SBTML_PE | SBTML_FGC | SBTML_FL_MASK) 12997 + 12998 +/* set/clear sbtmstatelow core-specific flags */ 12999 +uint32 13000 +sb_coreflags(void *sbh, uint32 mask, uint32 val) 13001 +{ 13002 + sb_info_t *si; 13003 + sbconfig_t *sb; 13004 + uint32 w; 13005 + 13006 + si = SB_INFO(sbh); 13007 + sb = REGS2SB(si->curmap); 13008 + 13009 + ASSERT((val & ~mask) == 0); 13010 + ASSERT((mask & ~SBTML_ALLOW) == 0); 13011 + 13012 + /* mask and set */ 13013 + if (mask || val) { 13014 + w = (R_SBREG(sbh, &sb->sbtmstatelow) & ~mask) | val; 13015 + W_SBREG(sbh, &sb->sbtmstatelow, w); 13016 + } 13017 + 13018 + /* return the new value */ 13019 + return (R_SBREG(sbh, &sb->sbtmstatelow) & SBTML_ALLOW); 13020 +} 13021 + 13022 +/* set/clear sbtmstatehigh core-specific flags */ 13023 +uint32 13024 +sb_coreflagshi(void *sbh, uint32 mask, uint32 val) 13025 +{ 13026 + sb_info_t *si; 13027 + sbconfig_t *sb; 13028 + uint32 w; 13029 + 13030 + si = SB_INFO(sbh); 13031 + sb = REGS2SB(si->curmap); 13032 + 13033 + ASSERT((val & ~mask) == 0); 13034 + ASSERT((mask & ~SBTMH_FL_MASK) == 0); 13035 + 13036 + /* mask and set */ 13037 + if (mask || val) { 13038 + w = (R_SBREG(sbh, &sb->sbtmstatehigh) & ~mask) | val; 13039 + W_SBREG(sbh, &sb->sbtmstatehigh, w); 13040 + } 13041 + 13042 + /* return the new value */ 13043 + return (R_SBREG(sbh, &sb->sbtmstatehigh) & SBTMH_FL_MASK); 13044 +} 13045 + 13046 +bool 13047 +sb_iscoreup(void *sbh) 13048 +{ 13049 + sb_info_t *si; 13050 + sbconfig_t *sb; 13051 + 13052 + si = SB_INFO(sbh); 13053 + sb = REGS2SB(si->curmap); 13054 + 13055 + return ((R_SBREG(sbh, &(sb)->sbtmstatelow) & (SBTML_RESET | SBTML_REJ | SBTML_CLK)) == SBTML_CLK); 13056 +} 13057 + 13058 +/* 13059 + * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set operation, 13060 + * switch back to the original core, and return the new value. 13061 + */ 13062 +static uint 13063 +sb_corereg(void *sbh, uint coreidx, uint regoff, uint mask, uint val) 13064 +{ 13065 + sb_info_t *si; 13066 + uint origidx; 13067 + uint32 *r; 13068 + uint w; 13069 + uint intr_val = 0; 13070 + 13071 + ASSERT(GOODIDX(coreidx)); 13072 + ASSERT(regoff < SB_CORE_SIZE); 13073 + ASSERT((val & ~mask) == 0); 13074 + 13075 + si = SB_INFO(sbh); 13076 + 13077 + INTR_OFF(si, intr_val); 13078 + 13079 + /* save current core index */ 13080 + origidx = sb_coreidx(sbh); 13081 + 13082 + /* switch core */ 13083 + r = (uint32*) ((uchar*) sb_setcoreidx(sbh, coreidx) + regoff); 13084 + 13085 + /* mask and set */ 13086 + if (mask || val) { 13087 + if (regoff >= SBCONFIGOFF) { 13088 + w = (R_SBREG(sbh, r) & ~mask) | val; 13089 + W_SBREG(sbh, r, w); 13090 + } else { 13091 + w = (R_REG(r) & ~mask) | val; 13092 + W_REG(r, w); 13093 + } 13094 + } 13095 + 13096 + /* readback */ 13097 + if (regoff >= SBCONFIGOFF) 13098 + w = R_SBREG(sbh, r); 13099 + else 13100 + w = R_REG(r); 13101 + 13102 + /* restore core index */ 13103 + if (origidx != coreidx) 13104 + sb_setcoreidx(sbh, origidx); 13105 + 13106 + INTR_RESTORE(si, intr_val); 13107 + return (w); 13108 +} 13109 + 13110 +/* scan the sb enumerated space to identify all cores */ 13111 +static void 13112 +BCMINITFN(sb_scan)(sb_info_t *si) 13113 +{ 13114 + void *sbh; 13115 + uint origidx; 13116 + uint i; 13117 + 13118 + sbh = (void*) si; 13119 + 13120 + /* numcores should already be set */ 13121 + ASSERT((si->numcores > 0) && (si->numcores <= SB_MAXCORES)); 13122 + 13123 + /* save current core index */ 13124 + origidx = sb_coreidx(sbh); 13125 + 13126 + si->pciidx = si->pcmciaidx = si->gpioidx = BADIDX; 13127 + si->pcirev = si->pcmciarev = NOREV; 13128 + 13129 + for (i = 0; i < si->numcores; i++) { 13130 + sb_setcoreidx(sbh, i); 13131 + si->coreid[i] = sb_coreid(sbh); 13132 + 13133 + if (si->coreid[i] == SB_PCI) { 13134 + si->pciidx = i; 13135 + si->pcirev = sb_corerev(sbh); 13136 + 13137 + } else if (si->coreid[i] == SB_PCMCIA) { 13138 + si->pcmciaidx = i; 13139 + si->pcmciarev = sb_corerev(sbh); 13140 + } 13141 + } 13142 + 13143 + /* 13144 + * Find the gpio "controlling core" type and index. 13145 + * Precedence: 13146 + * - if there's a chip common core - use that 13147 + * - else if there's a pci core (rev >= 2) - use that 13148 + * - else there had better be an extif core (4710 only) 13149 + */ 13150 + if (GOODIDX(sb_findcoreidx(sbh, SB_CC, 0))) { 13151 + si->gpioidx = sb_findcoreidx(sbh, SB_CC, 0); 13152 + si->gpioid = SB_CC; 13153 + } else if (GOODIDX(si->pciidx) && (si->pcirev >= 2)) { 13154 + si->gpioidx = si->pciidx; 13155 + si->gpioid = SB_PCI; 13156 + } else if (sb_findcoreidx(sbh, SB_EXTIF, 0)) { 13157 + si->gpioidx = sb_findcoreidx(sbh, SB_EXTIF, 0); 13158 + si->gpioid = SB_EXTIF; 13159 + } else 13160 + ASSERT(si->gpioidx != BADIDX); 13161 + 13162 + /* return to original core index */ 13163 + sb_setcoreidx(sbh, origidx); 13164 +} 13165 + 13166 +/* may be called with core in reset */ 13167 +void 13168 +sb_detach(void *sbh) 13169 +{ 13170 + sb_info_t *si; 13171 + uint idx; 13172 + 13173 + si = SB_INFO(sbh); 13174 + 13175 + if (si == NULL) 13176 + return; 13177 + 13178 + if (BUSTYPE(si->bustype) == SB_BUS) 13179 + for (idx = 0; idx < SB_MAXCORES; idx++) 13180 + if (si->regs[idx]) { 13181 + REG_UNMAP(si->regs[idx]); 13182 + si->regs[idx] = NULL; 13183 + } 13184 + 13185 + MFREE(si->osh, si, sizeof (sb_info_t)); 13186 +} 13187 + 13188 +/* use pci dev id to determine chip id for chips not having a chipcommon core */ 13189 +static uint 13190 +BCMINITFN(sb_pcidev2chip)(uint pcidev) 13191 +{ 13192 + if ((pcidev >= BCM4710_DEVICE_ID) && (pcidev <= BCM47XX_USB_ID)) 13193 + return (BCM4710_DEVICE_ID); 13194 + if ((pcidev >= BCM4610_DEVICE_ID) && (pcidev <= BCM4610_USB_ID)) 13195 + return (BCM4610_DEVICE_ID); 13196 + if ((pcidev >= BCM4402_DEVICE_ID) && (pcidev <= BCM4402_V90_ID)) 13197 + return (BCM4402_DEVICE_ID); 13198 + if (pcidev == BCM4401_ENET_ID) 13199 + return (BCM4402_DEVICE_ID); 13200 + if ((pcidev >= BCM4307_V90_ID) && (pcidev <= BCM4307_D11B_ID)) 13201 + return (BCM4307_DEVICE_ID); 13202 + if (pcidev == BCM4301_DEVICE_ID) 13203 + return (BCM4301_DEVICE_ID); 13204 + 13205 + return (0); 13206 +} 13207 + 13208 +/* convert chip number to number of i/o cores */ 13209 +static uint 13210 +BCMINITFN(sb_chip2numcores)(uint chip) 13211 +{ 13212 + if (chip == 0x4710) 13213 + return (9); 13214 + if (chip == 0x4610) 13215 + return (9); 13216 + if (chip == 0x4402) 13217 + return (3); 13218 + if ((chip == 0x4307) || (chip == 0x4301)) 13219 + return (5); 13220 + if (chip == 0x4310) 13221 + return (8); 13222 + if (chip == 0x4306) /* < 4306c0 */ 13223 + return (6); 13224 + if (chip == 0x4704) 13225 + return (9); 13226 + if (chip == 0x5365) 13227 + return (7); 13228 + 13229 + SB_ERROR(("sb_chip2numcores: unsupported chip 0x%x\n", chip)); 13230 + ASSERT(0); 13231 + return (1); 13232 +} 13233 + 13234 +/* return index of coreid or BADIDX if not found */ 13235 +static uint 13236 +sb_findcoreidx(void *sbh, uint coreid, uint coreunit) 13237 +{ 13238 + sb_info_t *si; 13239 + uint found; 13240 + uint i; 13241 + 13242 + si = SB_INFO(sbh); 13243 + found = 0; 13244 + 13245 + for (i = 0; i < si->numcores; i++) 13246 + if (si->coreid[i] == coreid) { 13247 + if (found == coreunit) 13248 + return (i); 13249 + found++; 13250 + } 13251 + 13252 + return (BADIDX); 13253 +} 13254 + 13255 +/* 13256 + * this function changes logical "focus" to the indiciated core, 13257 + * must be called with interrupt off. 13258 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core 13259 + */ 13260 +void* 13261 +sb_setcoreidx(void *sbh, uint coreidx) 13262 +{ 13263 + sb_info_t *si; 13264 + uint32 sbaddr; 13265 + uint8 tmp; 13266 + 13267 + si = SB_INFO(sbh); 13268 + 13269 + if (coreidx >= si->numcores) 13270 + return (NULL); 13271 + 13272 + /* 13273 + * If the user has provided an interrupt mask enabled function, 13274 + * then assert interrupts are disabled before switching the core. 13275 + */ 13276 + ASSERT((si->intrsenabled_fn == NULL) || !(*(si)->intrsenabled_fn)((si)->intr_arg)); 13277 + 13278 + sbaddr = SB_ENUM_BASE + (coreidx * SB_CORE_SIZE); 13279 + 13280 + switch (BUSTYPE(si->bustype)) { 13281 + case SB_BUS: 13282 + /* map new one */ 13283 + if (!si->regs[coreidx]) { 13284 + si->regs[coreidx] = (void*)REG_MAP(sbaddr, SB_CORE_SIZE); 13285 + ASSERT(GOODREGS(si->regs[coreidx])); 13286 + } 13287 + si->curmap = si->regs[coreidx]; 13288 + break; 13289 + 13290 + case PCI_BUS: 13291 + /* point bar0 window */ 13292 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_BAR0_WIN, 4, sbaddr); 13293 + break; 13294 + 13295 + case PCMCIA_BUS: 13296 + tmp = (sbaddr >> 12) & 0x0f; 13297 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR0, &tmp, 1); 13298 + tmp = (sbaddr >> 16) & 0xff; 13299 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR1, &tmp, 1); 13300 + tmp = (sbaddr >> 24) & 0xff; 13301 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_ADDR2, &tmp, 1); 13302 + break; 13303 + } 13304 + 13305 + si->curidx = coreidx; 13306 + 13307 + return (si->curmap); 13308 +} 13309 + 13310 +/* 13311 + * this function changes logical "focus" to the indiciated core, 13312 + * must be called with interrupt off. 13313 + * Moreover, callers should keep interrupts off during switching out of and back to d11 core 13314 + */ 13315 +void* 13316 +sb_setcore(void *sbh, uint coreid, uint coreunit) 13317 +{ 13318 + sb_info_t *si; 13319 + uint idx; 13320 + 13321 + si = SB_INFO(sbh); 13322 + 13323 + idx = sb_findcoreidx(sbh, coreid, coreunit); 13324 + if (!GOODIDX(idx)) 13325 + return (NULL); 13326 + 13327 + return (sb_setcoreidx(sbh, idx)); 13328 +} 13329 + 13330 +/* return chip number */ 13331 +uint 13332 +BCMINITFN(sb_chip)(void *sbh) 13333 +{ 13334 + sb_info_t *si; 13335 + 13336 + si = SB_INFO(sbh); 13337 + return (si->chip); 13338 +} 13339 + 13340 +/* return chip revision number */ 13341 +uint 13342 +BCMINITFN(sb_chiprev)(void *sbh) 13343 +{ 13344 + sb_info_t *si; 13345 + 13346 + si = SB_INFO(sbh); 13347 + return (si->chiprev); 13348 +} 13349 + 13350 +/* return chip common revision number */ 13351 +uint 13352 +BCMINITFN(sb_chipcrev)(void *sbh) 13353 +{ 13354 + sb_info_t *si; 13355 + 13356 + si = SB_INFO(sbh); 13357 + return (si->ccrev); 13358 +} 13359 + 13360 +/* return chip package option */ 13361 +uint 13362 +BCMINITFN(sb_chippkg)(void *sbh) 13363 +{ 13364 + sb_info_t *si; 13365 + 13366 + si = SB_INFO(sbh); 13367 + return (si->chippkg); 13368 +} 13369 + 13370 +/* return PCI core rev. */ 13371 +uint 13372 +BCMINITFN(sb_pcirev)(void *sbh) 13373 +{ 13374 + sb_info_t *si; 13375 + 13376 + si = SB_INFO(sbh); 13377 + return (si->pcirev); 13378 +} 13379 + 13380 +/* return PCMCIA core rev. */ 13381 +uint 13382 +BCMINITFN(sb_pcmciarev)(void *sbh) 13383 +{ 13384 + sb_info_t *si; 13385 + 13386 + si = SB_INFO(sbh); 13387 + return (si->pcmciarev); 13388 +} 13389 + 13390 +/* return board vendor id */ 13391 +uint 13392 +BCMINITFN(sb_boardvendor)(void *sbh) 13393 +{ 13394 + sb_info_t *si; 13395 + 13396 + si = SB_INFO(sbh); 13397 + return (si->boardvendor); 13398 +} 13399 + 13400 +/* return boardtype */ 13401 +uint 13402 +BCMINITFN(sb_boardtype)(void *sbh) 13403 +{ 13404 + sb_info_t *si; 13405 + char *var; 13406 + 13407 + si = SB_INFO(sbh); 13408 + 13409 + if (BUSTYPE(si->bustype) == SB_BUS && si->boardtype == 0xffff) { 13410 + /* boardtype format is a hex string */ 13411 + si->boardtype = getintvar(NULL, "boardtype"); 13412 + 13413 + /* backward compatibility for older boardtype string format */ 13414 + if ((si->boardtype == 0) && (var = getvar(NULL, "boardtype"))) { 13415 + if (!strcmp(var, "bcm94710dev")) 13416 + si->boardtype = BCM94710D_BOARD; 13417 + else if (!strcmp(var, "bcm94710ap")) 13418 + si->boardtype = BCM94710AP_BOARD; 13419 + else if (!strcmp(var, "bcm94310u")) 13420 + si->boardtype = BCM94310U_BOARD; 13421 + else if (!strcmp(var, "bu4711")) 13422 + si->boardtype = BU4711_BOARD; 13423 + else if (!strcmp(var, "bu4710")) 13424 + si->boardtype = BU4710_BOARD; 13425 + else if (!strcmp(var, "bcm94702mn")) 13426 + si->boardtype = BCM94702MN_BOARD; 13427 + else if (!strcmp(var, "bcm94710r1")) 13428 + si->boardtype = BCM94710R1_BOARD; 13429 + else if (!strcmp(var, "bcm94710r4")) 13430 + si->boardtype = BCM94710R4_BOARD; 13431 + else if (!strcmp(var, "bcm94702cpci")) 13432 + si->boardtype = BCM94702CPCI_BOARD; 13433 + else if (!strcmp(var, "bcm95380_rr")) 13434 + si->boardtype = BCM95380RR_BOARD; 13435 + } 13436 + } 13437 + 13438 + return (si->boardtype); 13439 +} 13440 + 13441 +/* return bus type of sdh device */ 13442 +uint 13443 +sb_bus(void *sbh) 13444 +{ 13445 + sb_info_t *si; 13446 + 13447 + si = SB_INFO(sbh); 13448 + return (si->bustype); 13449 +} 13450 + 13451 +/* return list of found cores */ 13452 +uint 13453 +sb_corelist(void *sbh, uint coreid[]) 13454 +{ 13455 + sb_info_t *si; 13456 + 13457 + si = SB_INFO(sbh); 13458 + 13459 + bcopy((uchar*)si->coreid, (uchar*)coreid, (si->numcores * sizeof (uint))); 13460 + return (si->numcores); 13461 +} 13462 + 13463 +/* return current register mapping */ 13464 +void * 13465 +sb_coreregs(void *sbh) 13466 +{ 13467 + sb_info_t *si; 13468 + 13469 + si = SB_INFO(sbh); 13470 + ASSERT(GOODREGS(si->curmap)); 13471 + 13472 + return (si->curmap); 13473 +} 13474 + 13475 + 13476 +/* do buffered registers update */ 13477 +void 13478 +sb_commit(void *sbh) 13479 +{ 13480 + sb_info_t *si; 13481 + uint origidx; 13482 + uint intr_val = 0; 13483 + 13484 + si = SB_INFO(sbh); 13485 + 13486 + origidx = si->curidx; 13487 + ASSERT(GOODIDX(origidx)); 13488 + 13489 + INTR_OFF(si, intr_val); 13490 + 13491 + /* switch over to chipcommon core if there is one, else use pci */ 13492 + if (si->ccrev != NOREV) { 13493 + chipcregs_t *ccregs = (chipcregs_t *)sb_setcore(sbh, SB_CC, 0); 13494 + 13495 + /* do the buffer registers update */ 13496 + W_REG(&ccregs->broadcastaddress, SB_COMMIT); 13497 + W_REG(&ccregs->broadcastdata, 0x0); 13498 + } else if (si->pciidx != BADIDX) { 13499 + sbpciregs_t *pciregs = (sbpciregs_t *)sb_setcore(sbh, SB_PCI, 0); 13500 + 13501 + /* do the buffer registers update */ 13502 + W_REG(&pciregs->bcastaddr, SB_COMMIT); 13503 + W_REG(&pciregs->bcastdata, 0x0); 13504 + } else { 13505 + ASSERT((si->ccrev != NOREV) && (si->pciidx != BADIDX)); 13506 + } 13507 + 13508 + /* restore core index */ 13509 + sb_setcoreidx(sbh, origidx); 13510 + INTR_RESTORE(si, intr_val); 13511 +} 13512 + 13513 +/* reset and re-enable a core */ 13514 +void 13515 +sb_core_reset(void *sbh, uint32 bits) 13516 +{ 13517 + sb_info_t *si; 13518 + sbconfig_t *sb; 13519 + volatile uint32 dummy; 13520 + 13521 + si = SB_INFO(sbh); 13522 + ASSERT(GOODREGS(si->curmap)); 13523 + sb = REGS2SB(si->curmap); 13524 + 13525 + /* 13526 + * Must do the disable sequence first to work for arbitrary current core state. 13527 + */ 13528 + sb_core_disable(sbh, bits); 13529 + 13530 + /* 13531 + * Now do the initialization sequence. 13532 + */ 13533 + 13534 + /* set reset while enabling the clock and forcing them on throughout the core */ 13535 + W_SBREG(sbh, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | SBTML_RESET | bits)); 13536 + dummy = R_SBREG(sbh, &sb->sbtmstatelow); 13537 + 13538 + if (sb_coreid(sbh) == SB_ILINE100) { 13539 + bcm_mdelay(50); 13540 + } else { 13541 + OSL_DELAY(1); 13542 + } 13543 + 13544 + if (R_SBREG(sbh, &sb->sbtmstatehigh) & SBTMH_SERR) { 13545 + W_SBREG(sbh, &sb->sbtmstatehigh, 0); 13546 + } 13547 + if ((dummy = R_SBREG(sbh, &sb->sbimstate)) & (SBIM_IBE | SBIM_TO)) { 13548 + AND_SBREG(sbh, &sb->sbimstate, ~(SBIM_IBE | SBIM_TO)); 13549 + } 13550 + 13551 + /* clear reset and allow it to propagate throughout the core */ 13552 + W_SBREG(sbh, &sb->sbtmstatelow, (SBTML_FGC | SBTML_CLK | bits)); 13553 + dummy = R_SBREG(sbh, &sb->sbtmstatelow); 13554 + OSL_DELAY(1); 13555 + 13556 + /* leave clock enabled */ 13557 + W_SBREG(sbh, &sb->sbtmstatelow, (SBTML_CLK | bits)); 13558 + dummy = R_SBREG(sbh, &sb->sbtmstatelow); 13559 + OSL_DELAY(1); 13560 +} 13561 + 13562 +void 13563 +sb_core_tofixup(void *sbh) 13564 +{ 13565 + sb_info_t *si; 13566 + sbconfig_t *sb; 13567 + 13568 + si = SB_INFO(sbh); 13569 + 13570 + if ((si->pciidx == BADIDX) || (si->pcirev >= 5)) 13571 + return; 13572 + 13573 + ASSERT(GOODREGS(si->curmap)); 13574 + sb = REGS2SB(si->curmap); 13575 + 13576 + if (BUSTYPE(si->bustype) == SB_BUS) { 13577 + SET_SBREG(sbh, &sb->sbimconfiglow, 13578 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK, 13579 + (0x5 << SBIMCL_RTO_SHIFT) | 0x3); 13580 + } else { 13581 + if (sb_coreid(sbh) == SB_PCI) { 13582 + SET_SBREG(sbh, &sb->sbimconfiglow, 13583 + SBIMCL_RTO_MASK | SBIMCL_STO_MASK, 13584 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2); 13585 + } else { 13586 + SET_SBREG(sbh, &sb->sbimconfiglow, (SBIMCL_RTO_MASK | SBIMCL_STO_MASK), 0); 13587 + } 13588 + } 13589 + 13590 + sb_commit(sbh); 13591 +} 13592 + 13593 +void 13594 +sb_core_disable(void *sbh, uint32 bits) 13595 +{ 13596 + sb_info_t *si; 13597 + volatile uint32 dummy; 13598 + sbconfig_t *sb; 13599 + 13600 + si = SB_INFO(sbh); 13601 + 13602 + ASSERT(GOODREGS(si->curmap)); 13603 + sb = REGS2SB(si->curmap); 13604 + 13605 + /* if core is already in reset, just return */ 13606 + if (R_SBREG(sbh, &sb->sbtmstatelow) & SBTML_RESET) 13607 + return; 13608 + 13609 + /* if clocks are not enabled, put into reset and return */ 13610 + if ((R_SBREG(sbh, &sb->sbtmstatelow) & SBTML_CLK) == 0) 13611 + goto disable; 13612 + 13613 + /* set the target reject bit and spin until busy is clear */ 13614 + W_SBREG(sbh, &sb->sbtmstatelow, (SBTML_CLK | SBTML_REJ)); 13615 + dummy = R_SBREG(sbh, &sb->sbtmstatelow); 13616 + OSL_DELAY(1); 13617 + SPINWAIT((R_SBREG(sbh, &sb->sbtmstatehigh) & SBTMH_BUSY), 100000); 13618 + 13619 + if (R_SBREG(sbh, &sb->sbidlow) & SBIDL_INIT) { 13620 + OR_SBREG(sbh, &sb->sbimstate, SBIM_RJ); 13621 + dummy = R_SBREG(sbh, &sb->sbimstate); 13622 + OSL_DELAY(1); 13623 + SPINWAIT((R_SBREG(sbh, &sb->sbimstate) & SBIM_BY), 100000); 13624 + } 13625 + 13626 + /* set reset and reject while enabling the clocks */ 13627 + W_SBREG(sbh, &sb->sbtmstatelow, (bits | SBTML_FGC | SBTML_CLK | SBTML_REJ | SBTML_RESET)); 13628 + dummy = R_SBREG(sbh, &sb->sbtmstatelow); 13629 + OSL_DELAY(10); 13630 + 13631 + /* don't forget to clear the initiator reject bit */ 13632 + if (R_SBREG(sbh, &sb->sbidlow) & SBIDL_INIT) 13633 + AND_SBREG(sbh, &sb->sbimstate, ~SBIM_RJ); 13634 + 13635 +disable: 13636 + /* leave reset and reject asserted */ 13637 + W_SBREG(sbh, &sb->sbtmstatelow, (bits | SBTML_REJ | SBTML_RESET)); 13638 + OSL_DELAY(1); 13639 +} 13640 + 13641 +void 13642 +sb_watchdog(void *sbh, uint ticks) 13643 +{ 13644 + sb_info_t *si = SB_INFO(sbh); 13645 + 13646 + /* instant NMI */ 13647 + switch (si->gpioid) { 13648 + case SB_CC: 13649 + sb_corereg(sbh, si->gpioidx, OFFSETOF(chipcregs_t, watchdog), ~0, ticks); 13650 + break; 13651 + case SB_EXTIF: 13652 + sb_corereg(sbh, si->gpioidx, OFFSETOF(extifregs_t, watchdog), ~0, ticks); 13653 + break; 13654 + } 13655 +} 13656 + 13657 +/* initialize the pcmcia core */ 13658 +void 13659 +sb_pcmcia_init(void *sbh) 13660 +{ 13661 + sb_info_t *si; 13662 + uint8 cor; 13663 + 13664 + si = SB_INFO(sbh); 13665 + 13666 + /* enable d11 mac interrupts */ 13667 + if (si->chip == BCM4301_DEVICE_ID) { 13668 + /* Have to use FCR2 in 4301 */ 13669 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_FCR2 + PCMCIA_COR, &cor, 1); 13670 + cor |= COR_IRQEN | COR_FUNEN; 13671 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_FCR2 + PCMCIA_COR, &cor, 1); 13672 + } else { 13673 + OSL_PCMCIA_READ_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1); 13674 + cor |= COR_IRQEN | COR_FUNEN; 13675 + OSL_PCMCIA_WRITE_ATTR(si->osh, PCMCIA_FCR0 + PCMCIA_COR, &cor, 1); 13676 + } 13677 + 13678 +} 13679 + 13680 + 13681 +/* 13682 + * Configure the pci core for pci client (NIC) action 13683 + * and get appropriate dma offset value. 13684 + * coremask is the bitvec of cores by index to be enabled. 13685 + */ 13686 +void 13687 +sb_pci_setup(void *sbh, uint32 *dmaoffset, uint coremask) 13688 +{ 13689 + sb_info_t *si; 13690 + sbconfig_t *sb; 13691 + sbpciregs_t *pciregs; 13692 + uint32 sbflag; 13693 + uint32 w; 13694 + uint idx; 13695 + 13696 + si = SB_INFO(sbh); 13697 + 13698 + if (dmaoffset) 13699 + *dmaoffset = 0; 13700 + 13701 + /* if not pci bus, we're done */ 13702 + if (BUSTYPE(si->bustype) != PCI_BUS) 13703 + return; 13704 + 13705 + ASSERT(si->pciidx != BADIDX); 13706 + 13707 + /* get current core index */ 13708 + idx = si->curidx; 13709 + 13710 + /* we interrupt on this backplane flag number */ 13711 + ASSERT(GOODREGS(si->curmap)); 13712 + sb = REGS2SB(si->curmap); 13713 + sbflag = R_SBREG(sbh, &sb->sbtpsflag) & SBTPS_NUM0_MASK; 13714 + 13715 + /* switch over to pci core */ 13716 + pciregs = (sbpciregs_t*) sb_setcoreidx(sbh, si->pciidx); 13717 + sb = REGS2SB(pciregs); 13718 + 13719 + /* 13720 + * Enable sb->pci interrupts. Assume 13721 + * PCI rev 2.3 support was added in pci core rev 6 and things changed.. 13722 + */ 13723 + if (si->pcirev < 6) { 13724 + /* set sbintvec bit for our flag number */ 13725 + OR_SBREG(sbh, &sb->sbintvec, (1 << sbflag)); 13726 + } else { 13727 + /* pci config write to set this core bit in PCIIntMask */ 13728 + w = OSL_PCI_READ_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32)); 13729 + w |= (coremask << PCI_SBIM_SHIFT); 13730 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_INT_MASK, sizeof(uint32), w); 13731 + } 13732 + 13733 + /* enable prefetch and bursts for dma big window */ 13734 + OR_REG(&pciregs->sbtopci2, (SBTOPCI_PREF|SBTOPCI_BURST)); 13735 + 13736 + /* enable read multiple for dma big window */ 13737 + if (si->pcirev >= 11) 13738 + OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI); 13739 + 13740 + if (si->pcirev < 5) { 13741 + SET_SBREG(sbh, &sb->sbimconfiglow, SBIMCL_RTO_MASK | SBIMCL_STO_MASK, 13742 + (0x3 << SBIMCL_RTO_SHIFT) | 0x2); 13743 + sb_commit(sbh); 13744 + } 13745 + 13746 + /* switch back to previous core */ 13747 + sb_setcoreidx(sbh, idx); 13748 + 13749 + /* use large sb pci dma window */ 13750 + if (dmaoffset) 13751 + *dmaoffset = SB_PCI_DMA; 13752 +} 13753 + 13754 +uint32 13755 +sb_base(uint32 admatch) 13756 +{ 13757 + uint32 base; 13758 + uint type; 13759 + 13760 + type = admatch & SBAM_TYPE_MASK; 13761 + ASSERT(type < 3); 13762 + 13763 + base = 0; 13764 + 13765 + if (type == 0) { 13766 + base = admatch & SBAM_BASE0_MASK; 13767 + } else if (type == 1) { 13768 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */ 13769 + base = admatch & SBAM_BASE1_MASK; 13770 + } else if (type == 2) { 13771 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */ 13772 + base = admatch & SBAM_BASE2_MASK; 13773 + } 13774 + 13775 + return (base); 13776 +} 13777 + 13778 +uint32 13779 +sb_size(uint32 admatch) 13780 +{ 13781 + uint32 size; 13782 + uint type; 13783 + 13784 + type = admatch & SBAM_TYPE_MASK; 13785 + ASSERT(type < 3); 13786 + 13787 + size = 0; 13788 + 13789 + if (type == 0) { 13790 + size = 1 << (((admatch & SBAM_ADINT0_MASK) >> SBAM_ADINT0_SHIFT) + 1); 13791 + } else if (type == 1) { 13792 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */ 13793 + size = 1 << (((admatch & SBAM_ADINT1_MASK) >> SBAM_ADINT1_SHIFT) + 1); 13794 + } else if (type == 2) { 13795 + ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */ 13796 + size = 1 << (((admatch & SBAM_ADINT2_MASK) >> SBAM_ADINT2_SHIFT) + 1); 13797 + } 13798 + 13799 + return (size); 13800 +} 13801 + 13802 +/* return the core-type instantiation # of the current core */ 13803 +uint 13804 +sb_coreunit(void *sbh) 13805 +{ 13806 + sb_info_t *si; 13807 + uint idx; 13808 + uint coreid; 13809 + uint coreunit; 13810 + uint i; 13811 + 13812 + si = SB_INFO(sbh); 13813 + coreunit = 0; 13814 + 13815 + idx = si->curidx; 13816 + 13817 + ASSERT(GOODREGS(si->curmap)); 13818 + coreid = sb_coreid(sbh); 13819 + 13820 + /* count the cores of our type */ 13821 + for (i = 0; i < idx; i++) 13822 + if (si->coreid[i] == coreid) 13823 + coreunit++; 13824 + 13825 + return (coreunit); 13826 +} 13827 + 13828 +static INLINE uint32 13829 +factor6(uint32 x) 13830 +{ 13831 + switch (x) { 13832 + case CC_F6_2: return 2; 13833 + case CC_F6_3: return 3; 13834 + case CC_F6_4: return 4; 13835 + case CC_F6_5: return 5; 13836 + case CC_F6_6: return 6; 13837 + case CC_F6_7: return 7; 13838 + default: return 0; 13839 + } 13840 +} 13841 + 13842 +/* calculate the speed the SB would run at given a set of clockcontrol values */ 13843 +uint32 13844 +sb_clock_rate(uint32 pll_type, uint32 n, uint32 m) 13845 +{ 13846 + uint32 n1, n2, clock, m1, m2, m3, mc; 13847 + 13848 + n1 = n & CN_N1_MASK; 13849 + n2 = (n & CN_N2_MASK) >> CN_N2_SHIFT; 13850 + 13851 + if (pll_type == PLL_TYPE6) { 13852 + if (m & CC_T6_MMASK) 13853 + return CC_T6_M1; 13854 + else 13855 + return CC_T6_M0; 13856 + } else if ((pll_type == PLL_TYPE1) || 13857 + (pll_type == PLL_TYPE3) || 13858 + (pll_type == PLL_TYPE4) || 13859 + (pll_type == PLL_TYPE7)) { 13860 + n1 = factor6(n1); 13861 + n2 += CC_F5_BIAS; 13862 + } else if (pll_type == PLL_TYPE2) { 13863 + n1 += CC_T2_BIAS; 13864 + n2 += CC_T2_BIAS; 13865 + ASSERT((n1 >= 2) && (n1 <= 7)); 13866 + ASSERT((n2 >= 5) && (n2 <= 23)); 13867 + } else if (pll_type == PLL_TYPE5) { 13868 + return (100000000); 13869 + } else 13870 + ASSERT((pll_type >= PLL_TYPE1) && (pll_type <= PLL_TYPE4)); 13871 + /* PLL types 3 and 7 use BASE2 (25Mhz) */ 13872 + if ((pll_type == PLL_TYPE3) || 13873 + (pll_type == PLL_TYPE7)) { 13874 + clock = CC_CLOCK_BASE2 * n1 * n2; 13875 + } 13876 + else 13877 + clock = CC_CLOCK_BASE1 * n1 * n2; 13878 + 13879 + if (clock == 0) 13880 + return 0; 13881 + 13882 + m1 = m & CC_M1_MASK; 13883 + m2 = (m & CC_M2_MASK) >> CC_M2_SHIFT; 13884 + m3 = (m & CC_M3_MASK) >> CC_M3_SHIFT; 13885 + mc = (m & CC_MC_MASK) >> CC_MC_SHIFT; 13886 + 13887 + if ((pll_type == PLL_TYPE1) || 13888 + (pll_type == PLL_TYPE3) || 13889 + (pll_type == PLL_TYPE4) || 13890 + (pll_type == PLL_TYPE7)) { 13891 + m1 = factor6(m1); 13892 + if ((pll_type == PLL_TYPE1) || (pll_type == PLL_TYPE3)) 13893 + m2 += CC_F5_BIAS; 13894 + else 13895 + m2 = factor6(m2); 13896 + m3 = factor6(m3); 13897 + 13898 + switch (mc) { 13899 + case CC_MC_BYPASS: return (clock); 13900 + case CC_MC_M1: return (clock / m1); 13901 + case CC_MC_M1M2: return (clock / (m1 * m2)); 13902 + case CC_MC_M1M2M3: return (clock / (m1 * m2 * m3)); 13903 + case CC_MC_M1M3: return (clock / (m1 * m3)); 13904 + default: return (0); 13905 + } 13906 + } else { 13907 + ASSERT(pll_type == PLL_TYPE2); 13908 + 13909 + m1 += CC_T2_BIAS; 13910 + m2 += CC_T2M2_BIAS; 13911 + m3 += CC_T2_BIAS; 13912 + ASSERT((m1 >= 2) && (m1 <= 7)); 13913 + ASSERT((m2 >= 3) && (m2 <= 10)); 13914 + ASSERT((m3 >= 2) && (m3 <= 7)); 13915 + 13916 + if ((mc & CC_T2MC_M1BYP) == 0) 13917 + clock /= m1; 13918 + if ((mc & CC_T2MC_M2BYP) == 0) 13919 + clock /= m2; 13920 + if ((mc & CC_T2MC_M3BYP) == 0) 13921 + clock /= m3; 13922 + 13923 + return(clock); 13924 + } 13925 +} 13926 + 13927 +/* returns the current speed the SB is running at */ 13928 +uint32 13929 +sb_clock(void *sbh) 13930 +{ 13931 + sb_info_t *si; 13932 + extifregs_t *eir; 13933 + chipcregs_t *cc; 13934 + uint32 n, m; 13935 + uint idx; 13936 + uint32 pll_type, rate; 13937 + uint intr_val = 0; 13938 + 13939 + si = SB_INFO(sbh); 13940 + idx = si->curidx; 13941 + pll_type = PLL_TYPE1; 13942 + 13943 + INTR_OFF(si, intr_val); 13944 + 13945 + /* switch to extif or chipc core */ 13946 + if ((eir = (extifregs_t *) sb_setcore(sbh, SB_EXTIF, 0))) { 13947 + n = R_REG(&eir->clockcontrol_n); 13948 + m = R_REG(&eir->clockcontrol_sb); 13949 + } else if ((cc = (chipcregs_t *) sb_setcore(sbh, SB_CC, 0))) { 13950 + pll_type = R_REG(&cc->capabilities) & CAP_PLL_MASK; 13951 + n = R_REG(&cc->clockcontrol_n); 13952 + if (pll_type == PLL_TYPE6) 13953 + m = R_REG(&cc->clockcontrol_mips); 13954 + else if ((pll_type == PLL_TYPE3) && (BCMINIT(sb_chip)(sbh) != BCM5365_DEVICE_ID)) 13955 + m = R_REG(&cc->clockcontrol_m2); 13956 + else 13957 + m = R_REG(&cc->clockcontrol_sb); 13958 + } else { 13959 + INTR_RESTORE(si, intr_val); 13960 + return 0; 13961 + } 13962 + 13963 + if (BCMINIT(sb_chip)(sbh) == BCM5365_DEVICE_ID) { 13964 + rate = 100000000; 13965 + } else { 13966 + /* calculate rate */ 13967 + rate = sb_clock_rate(pll_type, n, m); 13968 + if (pll_type == PLL_TYPE3) 13969 + rate = rate / 2; 13970 + } 13971 + 13972 + 13973 + /* switch back to previous core */ 13974 + sb_setcoreidx(sbh, idx); 13975 + 13976 + INTR_RESTORE(si, intr_val); 13977 + 13978 + return rate; 13979 +} 13980 + 13981 +/* change logical "focus" to the gpio core for optimized access */ 13982 +void* 13983 +sb_gpiosetcore(void *sbh) 13984 +{ 13985 + sb_info_t *si; 13986 + 13987 + si = SB_INFO(sbh); 13988 + 13989 + return (sb_setcoreidx(sbh, si->gpioidx)); 13990 +} 13991 + 13992 +/* mask&set gpiocontrol bits */ 13993 +uint32 13994 +sb_gpiocontrol(void *sbh, uint32 mask, uint32 val) 13995 +{ 13996 + sb_info_t *si; 13997 + uint regoff; 13998 + 13999 + si = SB_INFO(sbh); 14000 + regoff = 0; 14001 + 14002 + switch (si->gpioid) { 14003 + case SB_CC: 14004 + regoff = OFFSETOF(chipcregs_t, gpiocontrol); 14005 + break; 14006 + 14007 + case SB_PCI: 14008 + regoff = OFFSETOF(sbpciregs_t, gpiocontrol); 14009 + break; 14010 + 14011 + case SB_EXTIF: 14012 + return (0); 14013 + } 14014 + 14015 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val)); 14016 +} 14017 + 14018 +/* mask&set gpio output enable bits */ 14019 +uint32 14020 +sb_gpioouten(void *sbh, uint32 mask, uint32 val) 14021 +{ 14022 + sb_info_t *si; 14023 + uint regoff; 14024 + 14025 + si = SB_INFO(sbh); 14026 + regoff = 0; 14027 + 14028 + switch (si->gpioid) { 14029 + case SB_CC: 14030 + regoff = OFFSETOF(chipcregs_t, gpioouten); 14031 + break; 14032 + 14033 + case SB_PCI: 14034 + regoff = OFFSETOF(sbpciregs_t, gpioouten); 14035 + break; 14036 + 14037 + case SB_EXTIF: 14038 + regoff = OFFSETOF(extifregs_t, gpio[0].outen); 14039 + break; 14040 + } 14041 + 14042 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val)); 14043 +} 14044 + 14045 +/* mask&set gpio output bits */ 14046 +uint32 14047 +sb_gpioout(void *sbh, uint32 mask, uint32 val) 14048 +{ 14049 + sb_info_t *si; 14050 + uint regoff; 14051 + 14052 + si = SB_INFO(sbh); 14053 + regoff = 0; 14054 + 14055 + switch (si->gpioid) { 14056 + case SB_CC: 14057 + regoff = OFFSETOF(chipcregs_t, gpioout); 14058 + break; 14059 + 14060 + case SB_PCI: 14061 + regoff = OFFSETOF(sbpciregs_t, gpioout); 14062 + break; 14063 + 14064 + case SB_EXTIF: 14065 + regoff = OFFSETOF(extifregs_t, gpio[0].out); 14066 + break; 14067 + } 14068 + 14069 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val)); 14070 +} 14071 + 14072 +/* return the current gpioin register value */ 14073 +uint32 14074 +sb_gpioin(void *sbh) 14075 +{ 14076 + sb_info_t *si; 14077 + uint regoff; 14078 + 14079 + si = SB_INFO(sbh); 14080 + regoff = 0; 14081 + 14082 + switch (si->gpioid) { 14083 + case SB_CC: 14084 + regoff = OFFSETOF(chipcregs_t, gpioin); 14085 + break; 14086 + 14087 + case SB_PCI: 14088 + regoff = OFFSETOF(sbpciregs_t, gpioin); 14089 + break; 14090 + 14091 + case SB_EXTIF: 14092 + regoff = OFFSETOF(extifregs_t, gpioin); 14093 + break; 14094 + } 14095 + 14096 + return (sb_corereg(sbh, si->gpioidx, regoff, 0, 0)); 14097 +} 14098 + 14099 +/* mask&set gpio interrupt polarity bits */ 14100 +uint32 14101 +sb_gpiointpolarity(void *sbh, uint32 mask, uint32 val) 14102 +{ 14103 + sb_info_t *si; 14104 + uint regoff; 14105 + 14106 + si = SB_INFO(sbh); 14107 + regoff = 0; 14108 + 14109 + switch (si->gpioid) { 14110 + case SB_CC: 14111 + regoff = OFFSETOF(chipcregs_t, gpiointpolarity); 14112 + break; 14113 + 14114 + case SB_PCI: 14115 + /* pci gpio implementation does not support interrupt polarity */ 14116 + ASSERT(0); 14117 + break; 14118 + 14119 + case SB_EXTIF: 14120 + regoff = OFFSETOF(extifregs_t, gpiointpolarity); 14121 + break; 14122 + } 14123 + 14124 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val)); 14125 +} 14126 + 14127 +/* mask&set gpio interrupt mask bits */ 14128 +uint32 14129 +sb_gpiointmask(void *sbh, uint32 mask, uint32 val) 14130 +{ 14131 + sb_info_t *si; 14132 + uint regoff; 14133 + 14134 + si = SB_INFO(sbh); 14135 + regoff = 0; 14136 + 14137 + switch (si->gpioid) { 14138 + case SB_CC: 14139 + regoff = OFFSETOF(chipcregs_t, gpiointmask); 14140 + break; 14141 + 14142 + case SB_PCI: 14143 + /* pci gpio implementation does not support interrupt mask */ 14144 + ASSERT(0); 14145 + break; 14146 + 14147 + case SB_EXTIF: 14148 + regoff = OFFSETOF(extifregs_t, gpiointmask); 14149 + break; 14150 + } 14151 + 14152 + return (sb_corereg(sbh, si->gpioidx, regoff, mask, val)); 14153 +} 14154 + 14155 + 14156 +/* 14157 + * Return the slow clock source. 14158 + * Three sources of SLOW CLOCK: LPO, Xtal, PCI 14159 + */ 14160 +static uint 14161 +sb_slowclk_src(void *sbh) 14162 +{ 14163 + sb_info_t *si; 14164 + chipcregs_t *cc; 14165 + uint32 v; 14166 + 14167 + si = SB_INFO(sbh); 14168 + 14169 + ASSERT(sb_coreid(sbh) == SB_CC); 14170 + 14171 + if (si->ccrev < 6) { 14172 + switch (BUSTYPE(si->bustype)) { 14173 + case PCMCIA_BUS: return (SCC_SS_XTAL); 14174 + case PCI_BUS: 14175 + v = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32)); 14176 + if (v & PCI_CFG_GPIO_SCS) 14177 + return (SCC_SS_PCI); 14178 + else 14179 + return (SCC_SS_XTAL); 14180 + default: return (SCC_SS_XTAL); 14181 + } 14182 + } else if (si->ccrev < 10) { 14183 + cc = (chipcregs_t*) sb_setcoreidx(sbh, si->curidx); 14184 + v = R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK; 14185 + return (v); 14186 + } else { 14187 + return (SCC_SS_XTAL); 14188 + } 14189 +} 14190 + 14191 +/* 14192 + * Return the slowclock min or max frequency. 14193 + * Three sources of SLOW CLOCK: 14194 + * 1. On Chip LPO - 32khz or 160khz 14195 + * 2. On Chip Xtal OSC - 20mhz/4*(divider+1) 14196 + * 3. External PCI clock - 66mhz/4*(divider+1) 14197 + */ 14198 +static uint 14199 +sb_slowclk_freq(void *sbh, bool max) 14200 +{ 14201 + sb_info_t *si; 14202 + chipcregs_t *cc; 14203 + uint32 slowclk; 14204 + uint div; 14205 + 14206 + si = SB_INFO(sbh); 14207 + 14208 + ASSERT(sb_coreid(sbh) == SB_CC); 14209 + 14210 + cc = (chipcregs_t*) sb_setcoreidx(sbh, si->curidx); 14211 + 14212 + /* shouldn't be here unless we've established the chip has dynamic power control */ 14213 + ASSERT(R_REG(&cc->capabilities) & CAP_PWR_CTL); 14214 + 14215 + slowclk = sb_slowclk_src(sbh); 14216 + if (si->ccrev < 6) { 14217 + if (slowclk == SCC_SS_PCI) 14218 + return (max? (PCIMAXFREQ/64) : (PCIMINFREQ/64)); 14219 + else 14220 + return (max? (XTALMAXFREQ/32) : (XTALMINFREQ/32)); 14221 + } else if (si->ccrev < 10) { 14222 + div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHF) + 1); 14223 + if (slowclk == SCC_SS_LPO) 14224 + return (max? LPOMAXFREQ : LPOMINFREQ); 14225 + else if (slowclk == SCC_SS_XTAL) 14226 + return (max? (XTALMAXFREQ/div) : (XTALMINFREQ/div)); 14227 + else if (slowclk == SCC_SS_PCI) 14228 + return (max? (PCIMAXFREQ/div) : (PCIMINFREQ/div)); 14229 + else 14230 + ASSERT(0); 14231 + } else { 14232 + /* Chipc rev 10 is InstaClock */ 14233 + div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHF; 14234 + div = 4 * (div + 1); 14235 + return (max ? XTALMAXFREQ : (XTALMINFREQ/div)); 14236 + } 14237 + return (0); 14238 +} 14239 + 14240 +static void 14241 +sb_pwrctl_setdelay(void *sbh, void *chipcregs) 14242 +{ 14243 + sb_info_t *si; 14244 + chipcregs_t * cc; 14245 + uint slowmaxfreq, pll_delay, slowclk; 14246 + uint pll_on_delay, fref_sel_delay; 14247 + 14248 + si = SB_INFO(sbh); 14249 + pll_delay = PLL_DELAY; 14250 + 14251 + /* If the slow clock is not sourced by the xtal then add the xtal_on_delay 14252 + * since the xtal will also be powered down by dynamic power control logic. 14253 + */ 14254 + slowclk = sb_slowclk_src(sbh); 14255 + if (slowclk != SCC_SS_XTAL) 14256 + pll_delay += XTAL_ON_DELAY; 14257 + 14258 + /* Starting with 4318 it is ILP that is used for the delays */ 14259 + slowmaxfreq = sb_slowclk_freq(sbh, (si->ccrev >= 10) ? FALSE : TRUE); 14260 + 14261 + pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000; 14262 + fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000; 14263 + 14264 + cc = (chipcregs_t *)chipcregs; 14265 + W_REG(&cc->pll_on_delay, pll_on_delay); 14266 + W_REG(&cc->fref_sel_delay, fref_sel_delay); 14267 +} 14268 + 14269 +/* set or get slow clock divider */ 14270 +int 14271 +sb_pwrctl_slowclk(void *sbh, bool set, uint *div) 14272 +{ 14273 + sb_info_t *si; 14274 + uint origidx; 14275 + chipcregs_t *cc; 14276 + uint intr_val = 0; 14277 + uint err = 0; 14278 + 14279 + si = SB_INFO(sbh); 14280 + 14281 + /* chipcommon cores prior to rev6 don't support slowclkcontrol */ 14282 + if (si->ccrev < 6) 14283 + return 1; 14284 + 14285 + /* chipcommon cores rev10 are a whole new ball game */ 14286 + if (si->ccrev >= 10) 14287 + return 1; 14288 + 14289 + if (set && ((*div % 4) || (*div < 4))) 14290 + return 2; 14291 + 14292 + INTR_OFF(si, intr_val); 14293 + origidx = si->curidx; 14294 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0); 14295 + ASSERT(cc != NULL); 14296 + 14297 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL)) { 14298 + err = 3; 14299 + goto done; 14300 + } 14301 + 14302 + if (set) { 14303 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, ((*div / 4 - 1) << SCC_CD_SHF)); 14304 + sb_pwrctl_setdelay(sbh, (void *)cc); 14305 + } else 14306 + *div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHF) + 1); 14307 + 14308 +done: 14309 + sb_setcoreidx(sbh, origidx); 14310 + INTR_RESTORE(si, intr_val); 14311 + return err; 14312 +} 14313 + 14314 +/* initialize power control delay registers */ 14315 +void 14316 +sb_pwrctl_init(void *sbh) 14317 +{ 14318 + sb_info_t *si; 14319 + uint origidx; 14320 + chipcregs_t *cc; 14321 + 14322 + si = SB_INFO(sbh); 14323 + 14324 + origidx = si->curidx; 14325 + 14326 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL) 14327 + return; 14328 + 14329 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL)) 14330 + goto done; 14331 + 14332 + /* 4317pc does not work with SlowClock less than 5Mhz */ 14333 + if (BUSTYPE(si->bustype) == PCMCIA_BUS) { 14334 + if ((si->ccrev >= 6) && (si->ccrev < 10)) 14335 + SET_REG(&cc->slow_clk_ctl, SCC_CD_MASK, (SCC_DEF_DIV << SCC_CD_SHF)); 14336 + } 14337 + 14338 + sb_pwrctl_setdelay(sbh, (void *)cc); 14339 + 14340 +done: 14341 + sb_setcoreidx(sbh, origidx); 14342 +} 14343 + 14344 +/* return the value suitable for writing to the dot11 core FAST_PWRUP_DELAY register */ 14345 +uint16 14346 +sb_pwrctl_fast_pwrup_delay(void *sbh) 14347 +{ 14348 + sb_info_t *si; 14349 + uint origidx; 14350 + chipcregs_t *cc; 14351 + uint slowminfreq; 14352 + uint16 fpdelay; 14353 + uint intr_val = 0; 14354 + 14355 + si = SB_INFO(sbh); 14356 + fpdelay = 0; 14357 + origidx = si->curidx; 14358 + 14359 + if (BUSTYPE(si->bustype) == SB_BUS) 14360 + goto done; 14361 + 14362 + INTR_OFF(si, intr_val); 14363 + 14364 + if ((cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0)) == NULL) 14365 + goto done; 14366 + 14367 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL)) 14368 + goto done; 14369 + 14370 + slowminfreq = sb_slowclk_freq(sbh, FALSE); 14371 + fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + (slowminfreq - 1)) / slowminfreq; 14372 + 14373 +done: 14374 + sb_setcoreidx(sbh, origidx); 14375 + INTR_RESTORE(si, intr_val); 14376 + return (fpdelay); 14377 +} 14378 + 14379 +/* turn primary xtal and/or pll off/on */ 14380 +int 14381 +sb_pwrctl_xtal(void *sbh, uint what, bool on) 14382 +{ 14383 + sb_info_t *si; 14384 + uint32 in, out, outen; 14385 + 14386 + si = SB_INFO(sbh); 14387 + 14388 + switch (BUSTYPE(si->bustype)) { 14389 + 14390 + 14391 + case PCMCIA_BUS: 14392 + return (0); 14393 + 14394 + 14395 + case PCI_BUS: 14396 + 14397 + in = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_IN, sizeof (uint32)); 14398 + out = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32)); 14399 + outen = OSL_PCI_READ_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32)); 14400 + 14401 + /* 14402 + * Avoid glitching the clock if GPRS is already using it. 14403 + * We can't actually read the state of the PLLPD so we infer it 14404 + * by the value of XTAL_PU which *is* readable via gpioin. 14405 + */ 14406 + if (on && (in & PCI_CFG_GPIO_XTAL)) 14407 + return (0); 14408 + 14409 + if (what & XTAL) 14410 + outen |= PCI_CFG_GPIO_XTAL; 14411 + if (what & PLL) 14412 + outen |= PCI_CFG_GPIO_PLL; 14413 + 14414 + if (on) { 14415 + /* turn primary xtal on */ 14416 + if (what & XTAL) { 14417 + out |= PCI_CFG_GPIO_XTAL; 14418 + if (what & PLL) 14419 + out |= PCI_CFG_GPIO_PLL; 14420 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out); 14421 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen); 14422 + OSL_DELAY(XTAL_ON_DELAY); 14423 + } 14424 + 14425 + /* turn pll on */ 14426 + if (what & PLL) { 14427 + out &= ~PCI_CFG_GPIO_PLL; 14428 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out); 14429 + OSL_DELAY(2000); 14430 + } 14431 + } else { 14432 + if (what & XTAL) 14433 + out &= ~PCI_CFG_GPIO_XTAL; 14434 + if (what & PLL) 14435 + out |= PCI_CFG_GPIO_PLL; 14436 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUT, sizeof (uint32), out); 14437 + OSL_PCI_WRITE_CONFIG(si->osh, PCI_GPIO_OUTEN, sizeof (uint32), outen); 14438 + } 14439 + 14440 + default: 14441 + return (-1); 14442 + } 14443 + 14444 + return (0); 14445 +} 14446 + 14447 +/* set dynamic power control mode (forceslow, forcefast, dynamic) */ 14448 +/* returns true if ignore pll off is set and false if it is not */ 14449 +bool 14450 +sb_pwrctl_clk(void *sbh, uint mode) 14451 +{ 14452 + sb_info_t *si; 14453 + uint origidx; 14454 + chipcregs_t *cc; 14455 + uint32 scc; 14456 + bool forcefastclk=FALSE; 14457 + uint intr_val = 0; 14458 + 14459 + si = SB_INFO(sbh); 14460 + 14461 + /* chipcommon cores prior to rev6 don't support slowclkcontrol */ 14462 + if (si->ccrev < 6) 14463 + return (FALSE); 14464 + 14465 + /* chipcommon cores rev10 are a whole new ball game */ 14466 + if (si->ccrev >= 10) 14467 + return (FALSE); 14468 + 14469 + INTR_OFF(si, intr_val); 14470 + 14471 + origidx = si->curidx; 14472 + 14473 + cc = (chipcregs_t*) sb_setcore(sbh, SB_CC, 0); 14474 + ASSERT(cc != NULL); 14475 + 14476 + if (!(R_REG(&cc->capabilities) & CAP_PWR_CTL)) 14477 + goto done; 14478 + 14479 + switch (mode) { 14480 + case CLK_FAST: /* force fast (pll) clock */ 14481 + /* don't forget to force xtal back on before we clear SCC_DYN_XTAL.. */ 14482 + sb_pwrctl_xtal(sbh, XTAL, ON); 14483 + 14484 + SET_REG(&cc->slow_clk_ctl, (SCC_XC | SCC_FS | SCC_IP), SCC_IP); 14485 + break; 14486 + 14487 + case CLK_SLOW: /* force slow clock */ 14488 + if ((BUSTYPE(si->bustype) == SDIO_BUS) || (BUSTYPE(si->bustype) == PCMCIA_BUS)) 14489 + return (-1); 14490 + 14491 + if (si->ccrev >= 6) 14492 + OR_REG(&cc->slow_clk_ctl, SCC_FS); 14493 + break; 14494 + 14495 + case CLK_DYNAMIC: /* enable dynamic power control */ 14496 + scc = R_REG(&cc->slow_clk_ctl); 14497 + scc &= ~(SCC_FS | SCC_IP | SCC_XC); 14498 + if ((scc & SCC_SS_MASK) != SCC_SS_XTAL) 14499 + scc |= SCC_XC; 14500 + W_REG(&cc->slow_clk_ctl, scc); 14501 + 14502 + /* for dynamic control, we have to release our xtal_pu "force on" */ 14503 + if (scc & SCC_XC) 14504 + sb_pwrctl_xtal(sbh, XTAL, OFF); 14505 + break; 14506 + } 14507 + 14508 + /* Is the h/w forcing the use of the fast clk */ 14509 + forcefastclk = (bool)((R_REG(&cc->slow_clk_ctl) & SCC_IP) == SCC_IP); 14510 + 14511 +done: 14512 + sb_setcoreidx(sbh, origidx); 14513 + INTR_RESTORE(si, intr_val); 14514 + return (forcefastclk); 14515 +} 14516 + 14517 +/* register driver interrupt disabling and restoring callback functions */ 14518 +void 14519 +sb_register_intr_callback(void *sbh, void *intrsoff_fn, void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg) 14520 +{ 14521 + sb_info_t *si; 14522 + 14523 + si = SB_INFO(sbh); 14524 + si->intr_arg = intr_arg; 14525 + si->intrsoff_fn = (sb_intrsoff_t)intrsoff_fn; 14526 + si->intrsrestore_fn = (sb_intrsrestore_t)intrsrestore_fn; 14527 + si->intrsenabled_fn = (sb_intrsenabled_t)intrsenabled_fn; 14528 + /* save current core id. when this function called, the current core 14529 + * must be the core which provides driver functions(il, et, wl, etc.) 14530 + */ 14531 + si->dev_coreid = si->coreid[si->curidx]; 14532 +} 14533 + 14534 + 14535 diff -Nur linux-2.4.32/drivers/net/hnd/shared_ksyms.sh linux-2.4.32-freewrt/drivers/net/hnd/shared_ksyms.sh 14536 --- linux-2.4.32/drivers/net/hnd/shared_ksyms.sh 1970-01-01 01:00:00.000000000 +0100 14537 +++ linux-2.4.32-freewrt/drivers/net/hnd/shared_ksyms.sh 2006-09-16 15:41:31.000000000 +0200 14538 @@ -0,0 +1,21 @@ 14539 +#!/bin/sh 14540 +# 14541 +# Copyright 2004, Broadcom Corporation 14542 +# All Rights Reserved. 14543 +# 14544 +# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 14545 +# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 14546 +# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 14547 +# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 14548 +# 14549 +# $Id: shared_ksyms.sh,v 1.1 2005/03/16 13:50:00 wbx Exp $ 14550 +# 14551 + 14552 +cat <<EOF 14553 +#include <linux/config.h> 14554 +#include <linux/module.h> 14555 +EOF 14556 + 14557 +for file in $* ; do 14558 + ${NM} $file | sed -ne 's/[0-9A-Fa-f]* [DT] \([^ ]*\)/extern void \1; EXPORT_SYMBOL(\1);/p' 14559 +done 14560 diff -Nur linux-2.4.32/drivers/net/Makefile linux-2.4.32-freewrt/drivers/net/Makefile 14561 --- linux-2.4.32/drivers/net/Makefile 2005-01-19 15:09:56.000000000 +0100 14562 +++ linux-2.4.32-freewrt/drivers/net/Makefile 2006-09-16 15:41:31.000000000 +0200 16299 diff -urN linux.old/drivers/net/Makefile linux.dev/drivers/net/Makefile 16300 --- linux.old/drivers/net/Makefile 2006-10-02 21:23:10.000000000 +0200 16301 +++ linux.dev/drivers/net/Makefile 2006-10-02 21:19:59.000000000 +0200 14563 16302 @@ -3,6 +3,8 @@ 14564 16303 # Makefile for the Linux network (ethercard) device drivers. … … 14570 16309 obj-m := 14571 16310 obj-n := 14572 @@ -39,6 +41,7 @@ 14573 obj-$(CONFIG_ISDN) += slhc.o 14574 endif 14575 14576 +subdir-$(CONFIG_HND) += hnd 14577 subdir-$(CONFIG_NET_PCMCIA) += pcmcia 14578 subdir-$(CONFIG_NET_WIRELESS) += wireless 14579 subdir-$(CONFIG_TULIP) += tulip 14580 @@ -69,6 +72,13 @@ 14581 obj-$(CONFIG_MYRI_SBUS) += myri_sbus.o 14582 obj-$(CONFIG_SUNGEM) += sungem.o 14583 14584 +ifeq ($(CONFIG_HND),y) 14585 + obj-y += hnd/hnd.o 14586 +endif 14587 +ifeq ($(CONFIG_WL),y) 14588 + obj-y += wl/wl.o 14589 +endif 14590 + 14591 obj-$(CONFIG_MACE) += mace.o 14592 obj-$(CONFIG_BMAC) += bmac.o 14593 obj-$(CONFIG_GMAC) += gmac.o 14594 diff -Nur linux-2.4.32/drivers/net/wireless/Config.in linux-2.4.32-freewrt/drivers/net/wireless/Config.in 14595 --- linux-2.4.32/drivers/net/wireless/Config.in 2004-11-17 12:54:21.000000000 +0100 14596 +++ linux-2.4.32-freewrt/drivers/net/wireless/Config.in 2006-09-16 15:41:31.000000000 +0200 14597 @@ -13,6 +13,7 @@ 14598 fi 14599 14600 if [ "$CONFIG_PCI" = "y" ]; then 14601 + dep_tristate ' Proprietary Broadcom BCM43xx 802.11 Wireless support' CONFIG_WL 14602 dep_tristate ' Hermes in PLX9052 based PCI adaptor support (Netgear MA301 etc.) (EXPERIMENTAL)' CONFIG_PLX_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL 14603 dep_tristate ' Hermes in TMD7160/NCP130 based PCI adaptor support (Pheecom WL-PCI etc.) (EXPERIMENTAL)' CONFIG_TMD_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL 14604 dep_tristate ' Prism 2.5 PCI 802.11b adaptor support (EXPERIMENTAL)' CONFIG_PCI_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL 14605 diff -Nur linux-2.4.32/drivers/parport/Config.in linux-2.4.32-freewrt/drivers/parport/Config.in 14606 --- linux-2.4.32/drivers/parport/Config.in 2004-02-18 14:36:31.000000000 +0100 14607 +++ linux-2.4.32-freewrt/drivers/parport/Config.in 2006-09-16 15:41:31.000000000 +0200 16311 diff -urN linux.old/drivers/parport/Config.in linux.dev/drivers/parport/Config.in 16312 --- linux.old/drivers/parport/Config.in 2006-10-02 21:23:10.000000000 +0200 16313 +++ linux.dev/drivers/parport/Config.in 2006-10-02 21:19:59.000000000 +0200 14608 16314 @@ -11,6 +11,7 @@ 14609 16315 tristate 'Parallel port support' CONFIG_PARPORT … … 14614 16320 if [ "$CONFIG_SERIAL" = "m" ]; then 14615 16321 define_tristate CONFIG_PARPORT_PC_CML1 m 14616 diff - Nur linux-2.4.32/drivers/parport/Makefile linux-2.4.32-freewrt/drivers/parport/Makefile14617 --- linux -2.4.32/drivers/parport/Makefile 2004-08-08 01:26:05.000000000 +020014618 +++ linux -2.4.32-freewrt/drivers/parport/Makefile 2006-09-16 15:41:31.000000000 +020016322 diff -urN linux.old/drivers/parport/Makefile linux.dev/drivers/parport/Makefile 16323 --- linux.old/drivers/parport/Makefile 2006-10-02 21:23:10.000000000 +0200 16324 +++ linux.dev/drivers/parport/Makefile 2006-10-02 21:19:59.000000000 +0200 14619 16325 @@ -22,6 +22,7 @@ 14620 16326 … … 14625 16331 obj-$(CONFIG_PARPORT_AMIGA) += parport_amiga.o 14626 16332 obj-$(CONFIG_PARPORT_MFC3) += parport_mfc3.o 14627 diff - Nur linux-2.4.32/drivers/parport/parport_splink.c linux-2.4.32-freewrt/drivers/parport/parport_splink.c14628 --- linux -2.4.32/drivers/parport/parport_splink.c 1970-01-01 01:00:00.000000000 +010014629 +++ linux -2.4.32-freewrt/drivers/parport/parport_splink.c 2006-09-16 15:41:31.000000000 +020016333 diff -urN linux.old/drivers/parport/parport_splink.c linux.dev/drivers/parport/parport_splink.c 16334 --- linux.old/drivers/parport/parport_splink.c 1970-01-01 01:00:00.000000000 +0100 16335 +++ linux.dev/drivers/parport/parport_splink.c 2006-10-02 21:19:59.000000000 +0200 14630 16336 @@ -0,0 +1,345 @@ 14631 16337 +/* Low-level parallel port routines for the ASUS WL-500g built-in port … … 14974 16680 +module_exit(parport_splink_cleanup) 14975 16681 + 14976 diff -Nur linux-2.4.32/drivers/pcmcia/bcm4710_generic.c linux-2.4.32-freewrt/drivers/pcmcia/bcm4710_generic.c 14977 --- linux-2.4.32/drivers/pcmcia/bcm4710_generic.c 1970-01-01 01:00:00.000000000 +0100 14978 +++ linux-2.4.32-freewrt/drivers/pcmcia/bcm4710_generic.c 2006-09-16 15:41:31.000000000 +0200 14979 @@ -0,0 +1,912 @@ 14980 +/* 14981 + * 14982 + * bcm47xx pcmcia driver 14983 + * 14984 + * Copyright 2004, Broadcom Corporation 14985 + * All Rights Reserved. 14986 + * 14987 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 14988 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 14989 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 14990 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 14991 + * 14992 + * Based on sa1100_generic.c from www.handhelds.org, 14993 + * and au1000_generic.c from oss.sgi.com. 14994 + * 14995 + * $Id: bcm4710_generic.c,v 1.1 2005/03/16 13:50:00 wbx Exp $ 14996 + */ 14997 +#include <linux/module.h> 14998 +#include <linux/init.h> 14999 +#include <linux/config.h> 15000 +#include <linux/delay.h> 15001 +#include <linux/ioport.h> 15002 +#include <linux/kernel.h> 15003 +#include <linux/tqueue.h> 15004 +#include <linux/timer.h> 15005 +#include <linux/mm.h> 15006 +#include <linux/proc_fs.h> 15007 +#include <linux/version.h> 15008 +#include <linux/types.h> 15009 +#include <linux/vmalloc.h> 15010 + 15011 +#include <pcmcia/version.h> 15012 +#include <pcmcia/cs_types.h> 15013 +#include <pcmcia/cs.h> 15014 +#include <pcmcia/ss.h> 15015 +#include <pcmcia/bulkmem.h> 15016 +#include <pcmcia/cistpl.h> 15017 +#include <pcmcia/bus_ops.h> 15018 +#include "cs_internal.h" 15019 + 15020 +#include <asm/io.h> 15021 +#include <asm/irq.h> 15022 +#include <asm/system.h> 15023 + 15024 +#include <typedefs.h> 15025 +#include <bcm4710.h> 15026 +#include <sbextif.h> 15027 + 15028 +#include "bcm4710pcmcia.h" 15029 + 15030 +#ifdef PCMCIA_DEBUG 15031 +static int pc_debug = PCMCIA_DEBUG; 15032 +#endif 15033 + 15034 +MODULE_DESCRIPTION("Linux PCMCIA Card Services: bcm47xx Socket Controller"); 15035 + 15036 +/* This structure maintains housekeeping state for each socket, such 15037 + * as the last known values of the card detect pins, or the Card Services 15038 + * callback value associated with the socket: 15039 + */ 15040 +static struct bcm47xx_pcmcia_socket *pcmcia_socket; 15041 +static int socket_count; 15042 + 15043 + 15044 +/* Returned by the low-level PCMCIA interface: */ 15045 +static struct pcmcia_low_level *pcmcia_low_level; 15046 + 15047 +/* Event poll timer structure */ 15048 +static struct timer_list poll_timer; 15049 + 15050 + 15051 +/* Prototypes for routines which are used internally: */ 15052 + 15053 +static int bcm47xx_pcmcia_driver_init(void); 15054 +static void bcm47xx_pcmcia_driver_shutdown(void); 15055 +static void bcm47xx_pcmcia_task_handler(void *data); 15056 +static void bcm47xx_pcmcia_poll_event(unsigned long data); 15057 +static void bcm47xx_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs); 15058 +static struct tq_struct bcm47xx_pcmcia_task; 15059 + 15060 +#ifdef CONFIG_PROC_FS 15061 +static int bcm47xx_pcmcia_proc_status(char *buf, char **start, 15062 + off_t pos, int count, int *eof, void *data); 15063 +#endif 15064 + 15065 + 15066 +/* Prototypes for operations which are exported to the 15067 + * in-kernel PCMCIA core: 15068 + */ 15069 + 15070 +static int bcm47xx_pcmcia_init(unsigned int sock); 15071 +static int bcm47xx_pcmcia_suspend(unsigned int sock); 15072 +static int bcm47xx_pcmcia_register_callback(unsigned int sock, 15073 + void (*handler)(void *, unsigned int), void *info); 15074 +static int bcm47xx_pcmcia_inquire_socket(unsigned int sock, socket_cap_t *cap); 15075 +static int bcm47xx_pcmcia_get_status(unsigned int sock, u_int *value); 15076 +static int bcm47xx_pcmcia_get_socket(unsigned int sock, socket_state_t *state); 15077 +static int bcm47xx_pcmcia_set_socket(unsigned int sock, socket_state_t *state); 15078 +static int bcm47xx_pcmcia_get_io_map(unsigned int sock, struct pccard_io_map *io); 15079 +static int bcm47xx_pcmcia_set_io_map(unsigned int sock, struct pccard_io_map *io); 15080 +static int bcm47xx_pcmcia_get_mem_map(unsigned int sock, struct pccard_mem_map *mem); 15081 +static int bcm47xx_pcmcia_set_mem_map(unsigned int sock, struct pccard_mem_map *mem); 15082 +#ifdef CONFIG_PROC_FS 15083 +static void bcm47xx_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base); 15084 +#endif 15085 + 15086 +static struct pccard_operations bcm47xx_pcmcia_operations = { 15087 + bcm47xx_pcmcia_init, 15088 + bcm47xx_pcmcia_suspend, 15089 + bcm47xx_pcmcia_register_callback, 15090 + bcm47xx_pcmcia_inquire_socket, 15091 + bcm47xx_pcmcia_get_status, 15092 + bcm47xx_pcmcia_get_socket, 15093 + bcm47xx_pcmcia_set_socket, 15094 + bcm47xx_pcmcia_get_io_map, 15095 + bcm47xx_pcmcia_set_io_map, 15096 + bcm47xx_pcmcia_get_mem_map, 15097 + bcm47xx_pcmcia_set_mem_map, 15098 +#ifdef CONFIG_PROC_FS 15099 + bcm47xx_pcmcia_proc_setup 15100 +#endif 15101 +}; 15102 + 15103 + 15104 +/* 15105 + * bcm47xx_pcmcia_driver_init() 15106 + * 15107 + * This routine performs a basic sanity check to ensure that this 15108 + * kernel has been built with the appropriate board-specific low-level 15109 + * PCMCIA support, performs low-level PCMCIA initialization, registers 15110 + * this socket driver with Card Services, and then spawns the daemon 15111 + * thread which is the real workhorse of the socket driver. 15112 + * 15113 + * Please see linux/Documentation/arm/SA1100/PCMCIA for more information 15114 + * on the low-level kernel interface. 15115 + * 15116 + * Returns: 0 on success, -1 on error 15117 + */ 15118 +static int __init bcm47xx_pcmcia_driver_init(void) 15119 +{ 15120 + servinfo_t info; 15121 + struct pcmcia_init pcmcia_init; 15122 + struct pcmcia_state state; 15123 + unsigned int i; 15124 + unsigned long tmp; 15125 + 15126 + 15127 + printk("\nBCM47XX PCMCIA (CS release %s)\n", CS_RELEASE); 15128 + 15129 + CardServices(GetCardServicesInfo, &info); 15130 + 15131 + if (info.Revision != CS_RELEASE_CODE) { 15132 + printk(KERN_ERR "Card Services release codes do not match\n"); 15133 + return -1; 15134 + } 15135 + 15136 +#ifdef CONFIG_BCM4710 15137 + pcmcia_low_level=&bcm4710_pcmcia_ops; 15138 +#else 15139 +#error Unsupported Broadcom BCM47XX board. 15140 +#endif 15141 + 15142 + pcmcia_init.handler=bcm47xx_pcmcia_interrupt; 15143 + 15144 + if ((socket_count = pcmcia_low_level->init(&pcmcia_init)) < 0) { 15145 + printk(KERN_ERR "Unable to initialize PCMCIA service.\n"); 15146 + return -EIO; 15147 + } else { 15148 + printk("\t%d PCMCIA sockets initialized.\n", socket_count); 15149 + } 15150 + 15151 + pcmcia_socket = 15152 + kmalloc(sizeof(struct bcm47xx_pcmcia_socket) * socket_count, 15153 + GFP_KERNEL); 15154 + memset(pcmcia_socket, 0, 15155 + sizeof(struct bcm47xx_pcmcia_socket) * socket_count); 15156 + if (!pcmcia_socket) { 15157 + printk(KERN_ERR "Card Services can't get memory \n"); 15158 + return -1; 15159 + } 15160 + 15161 + for (i = 0; i < socket_count; i++) { 15162 + if (pcmcia_low_level->socket_state(i, &state) < 0) { 15163 + printk(KERN_ERR "Unable to get PCMCIA status\n"); 15164 + return -EIO; 15165 + } 15166 + pcmcia_socket[i].k_state = state; 15167 + pcmcia_socket[i].cs_state.csc_mask = SS_DETECT; 15168 + 15169 + if (i == 0) { 15170 + pcmcia_socket[i].virt_io = 15171 + (unsigned long)ioremap_nocache(EXTIF_PCMCIA_IOBASE(BCM4710_EXTIF), 0x1000); 15172 + /* Substract ioport base which gets added by in/out */ 15173 + pcmcia_socket[i].virt_io -= mips_io_port_base; 15174 + pcmcia_socket[i].phys_attr = 15175 + (unsigned long)EXTIF_PCMCIA_CFGBASE(BCM4710_EXTIF); 15176 + pcmcia_socket[i].phys_mem = 15177 + (unsigned long)EXTIF_PCMCIA_MEMBASE(BCM4710_EXTIF); 15178 + } else { 15179 + printk(KERN_ERR "bcm4710: socket 1 not supported\n"); 15180 + return 1; 15181 + } 15182 + } 15183 + 15184 + /* Only advertise as many sockets as we can detect: */ 15185 + if (register_ss_entry(socket_count, &bcm47xx_pcmcia_operations) < 0) { 15186 + printk(KERN_ERR "Unable to register socket service routine\n"); 15187 + return -ENXIO; 15188 + } 15189 + 15190 + /* Start the event poll timer. 15191 + * It will reschedule by itself afterwards. 15192 + */ 15193 + bcm47xx_pcmcia_poll_event(0); 15194 + 15195 + DEBUG(1, "bcm4710: initialization complete\n"); 15196 + return 0; 15197 + 15198 +} 15199 + 15200 +module_init(bcm47xx_pcmcia_driver_init); 15201 + 15202 + 15203 +/* 15204 + * bcm47xx_pcmcia_driver_shutdown() 15205 + * 15206 + * Invokes the low-level kernel service to free IRQs associated with this 15207 + * socket controller and reset GPIO edge detection. 15208 + */ 15209 +static void __exit bcm47xx_pcmcia_driver_shutdown(void) 15210 +{ 15211 + int i; 15212 + 15213 + del_timer_sync(&poll_timer); 15214 + unregister_ss_entry(&bcm47xx_pcmcia_operations); 15215 + pcmcia_low_level->shutdown(); 15216 + flush_scheduled_tasks(); 15217 + for (i = 0; i < socket_count; i++) { 15218 + if (pcmcia_socket[i].virt_io) 15219 + iounmap((void *)pcmcia_socket[i].virt_io); 15220 + if (pcmcia_socket[i].phys_attr) 15221 + iounmap((void *)pcmcia_socket[i].phys_attr); 15222 + if (pcmcia_socket[i].phys_mem) 15223 + iounmap((void *)pcmcia_socket[i].phys_mem); 15224 + } 15225 + DEBUG(1, "bcm4710: shutdown complete\n"); 15226 +} 15227 + 15228 +module_exit(bcm47xx_pcmcia_driver_shutdown); 15229 + 15230 +/* 15231 + * bcm47xx_pcmcia_init() 15232 + * We perform all of the interesting initialization tasks in 15233 + * bcm47xx_pcmcia_driver_init(). 15234 + * 15235 + * Returns: 0 15236 + */ 15237 +static int bcm47xx_pcmcia_init(unsigned int sock) 15238 +{ 15239 + DEBUG(1, "%s(): initializing socket %u\n", __FUNCTION__, sock); 15240 + 15241 + return 0; 15242 +} 15243 + 15244 +/* 15245 + * bcm47xx_pcmcia_suspend() 15246 + * 15247 + * We don't currently perform any actions on a suspend. 15248 + * 15249 + * Returns: 0 15250 + */ 15251 +static int bcm47xx_pcmcia_suspend(unsigned int sock) 15252 +{ 15253 + DEBUG(1, "%s(): suspending socket %u\n", __FUNCTION__, sock); 15254 + 15255 + return 0; 15256 +} 15257 + 15258 + 15259 +/* 15260 + * bcm47xx_pcmcia_events() 15261 + * 15262 + * Helper routine to generate a Card Services event mask based on 15263 + * state information obtained from the kernel low-level PCMCIA layer 15264 + * in a recent (and previous) sampling. Updates `prev_state'. 15265 + * 15266 + * Returns: an event mask for the given socket state. 15267 + */ 15268 +static inline unsigned 15269 +bcm47xx_pcmcia_events(struct pcmcia_state *state, 15270 + struct pcmcia_state *prev_state, 15271 + unsigned int mask, unsigned int flags) 15272 +{ 15273 + unsigned int events=0; 15274 + 15275 + if (state->bvd1 != prev_state->bvd1) { 15276 + 15277 + DEBUG(3, "%s(): card BVD1 value %u\n", __FUNCTION__, state->bvd1); 15278 + 15279 + events |= mask & (flags & SS_IOCARD) ? SS_STSCHG : SS_BATDEAD; 15280 + } 15281 + 15282 + if (state->bvd2 != prev_state->bvd2) { 15283 + 15284 + DEBUG(3, "%s(): card BVD2 value %u\n", __FUNCTION__, state->bvd2); 15285 + 15286 + events |= mask & (flags & SS_IOCARD) ? 0 : SS_BATWARN; 15287 + } 15288 + 15289 + if (state->detect != prev_state->detect) { 15290 + 15291 + DEBUG(3, "%s(): card detect value %u\n", __FUNCTION__, state->detect); 15292 + 15293 + events |= mask & SS_DETECT; 15294 + } 15295 + 15296 + 15297 + if (state->ready != prev_state->ready) { 15298 + 15299 + DEBUG(3, "%s(): card ready value %u\n", __FUNCTION__, state->ready); 15300 + 15301 + events |= mask & ((flags & SS_IOCARD) ? 0 : SS_READY); 15302 + } 15303 + 15304 + if (events != 0) { 15305 + DEBUG(2, "events: %s%s%s%s%s\n", 15306 + (events & SS_DETECT) ? "DETECT " : "", 15307 + (events & SS_READY) ? "READY " : "", 15308 + (events & SS_BATDEAD) ? "BATDEAD " : "", 15309 + (events & SS_BATWARN) ? "BATWARN " : "", 15310 + (events & SS_STSCHG) ? "STSCHG " : ""); 15311 + } 15312 + 15313 + *prev_state=*state; 15314 + return events; 15315 +} 15316 + 15317 + 15318 +/* 15319 + * bcm47xx_pcmcia_task_handler() 15320 + * 15321 + * Processes serviceable socket events using the "eventd" thread context. 15322 + * 15323 + * Event processing (specifically, the invocation of the Card Services event 15324 + * callback) occurs in this thread rather than in the actual interrupt 15325 + * handler due to the use of scheduling operations in the PCMCIA core. 15326 + */ 15327 +static void bcm47xx_pcmcia_task_handler(void *data) 15328 +{ 15329 + struct pcmcia_state state; 15330 + int i, events, irq_status; 15331 + 15332 + DEBUG(4, "%s(): entering PCMCIA monitoring thread\n", __FUNCTION__); 15333 + 15334 + for (i = 0; i < socket_count; i++) { 15335 + if ((irq_status = pcmcia_low_level->socket_state(i, &state)) < 0) 15336 + printk(KERN_ERR "Error in kernel low-level PCMCIA service.\n"); 15337 + 15338 + events = bcm47xx_pcmcia_events(&state, 15339 + &pcmcia_socket[i].k_state, 15340 + pcmcia_socket[i].cs_state.csc_mask, 15341 + pcmcia_socket[i].cs_state.flags); 15342 + 15343 + if (pcmcia_socket[i].handler != NULL) { 15344 + pcmcia_socket[i].handler(pcmcia_socket[i].handler_info, 15345 + events); 15346 + } 15347 + } 15348 +} 15349 + 15350 +static struct tq_struct bcm47xx_pcmcia_task = { 15351 + routine: bcm47xx_pcmcia_task_handler 15352 +}; 15353 + 15354 + 15355 +/* 15356 + * bcm47xx_pcmcia_poll_event() 15357 + * 15358 + * Let's poll for events in addition to IRQs since IRQ only is unreliable... 15359 + */ 15360 +static void bcm47xx_pcmcia_poll_event(unsigned long dummy) 15361 +{ 15362 + DEBUG(4, "%s(): polling for events\n", __FUNCTION__); 15363 + 15364 + poll_timer.function = bcm47xx_pcmcia_poll_event; 15365 + poll_timer.expires = jiffies + BCM47XX_PCMCIA_POLL_PERIOD; 15366 + add_timer(&poll_timer); 15367 + schedule_task(&bcm47xx_pcmcia_task); 15368 +} 15369 + 15370 + 15371 +/* 15372 + * bcm47xx_pcmcia_interrupt() 15373 + * 15374 + * Service routine for socket driver interrupts (requested by the 15375 + * low-level PCMCIA init() operation via bcm47xx_pcmcia_thread()). 15376 + * 15377 + * The actual interrupt-servicing work is performed by 15378 + * bcm47xx_pcmcia_task(), largely because the Card Services event- 15379 + * handling code performs scheduling operations which cannot be 15380 + * executed from within an interrupt context. 15381 + */ 15382 +static void 15383 +bcm47xx_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs) 15384 +{ 15385 + DEBUG(3, "%s(): servicing IRQ %d\n", __FUNCTION__, irq); 15386 + schedule_task(&bcm47xx_pcmcia_task); 15387 +} 15388 + 15389 + 15390 +/* 15391 + * bcm47xx_pcmcia_register_callback() 15392 + * 15393 + * Implements the register_callback() operation for the in-kernel 15394 + * PCMCIA service (formerly SS_RegisterCallback in Card Services). If 15395 + * the function pointer `handler' is not NULL, remember the callback 15396 + * location in the state for `sock', and increment the usage counter 15397 + * for the driver module. (The callback is invoked from the interrupt 15398 + * service routine, bcm47xx_pcmcia_interrupt(), to notify Card Services 15399 + * of interesting events.) Otherwise, clear the callback pointer in the 15400 + * socket state and decrement the module usage count. 15401 + * 15402 + * Returns: 0 15403 + */ 15404 +static int 15405 +bcm47xx_pcmcia_register_callback(unsigned int sock, 15406 + void (*handler)(void *, unsigned int), void *info) 15407 +{ 15408 + if (handler == NULL) { 15409 + pcmcia_socket[sock].handler = NULL; 15410 + MOD_DEC_USE_COUNT; 15411 + } else { 15412 + MOD_INC_USE_COUNT; 15413 + pcmcia_socket[sock].handler = handler; 15414 + pcmcia_socket[sock].handler_info = info; 15415 + } 15416 + return 0; 15417 +} 15418 + 15419 + 15420 +/* 15421 + * bcm47xx_pcmcia_inquire_socket() 15422 + * 15423 + * Implements the inquire_socket() operation for the in-kernel PCMCIA 15424 + * service (formerly SS_InquireSocket in Card Services). Of note is 15425 + * the setting of the SS_CAP_PAGE_REGS bit in the `features' field of 15426 + * `cap' to "trick" Card Services into tolerating large "I/O memory" 15427 + * addresses. Also set is SS_CAP_STATIC_MAP, which disables the memory 15428 + * resource database check. (Mapped memory is set up within the socket 15429 + * driver itself.) 15430 + * 15431 + * In conjunction with the STATIC_MAP capability is a new field, 15432 + * `io_offset', recommended by David Hinds. Rather than go through 15433 + * the SetIOMap interface (which is not quite suited for communicating 15434 + * window locations up from the socket driver), we just pass up 15435 + * an offset which is applied to client-requested base I/O addresses 15436 + * in alloc_io_space(). 15437 + * 15438 + * Returns: 0 on success, -1 if no pin has been configured for `sock' 15439 + */ 15440 +static int 15441 +bcm47xx_pcmcia_inquire_socket(unsigned int sock, socket_cap_t *cap) 15442 +{ 15443 + struct pcmcia_irq_info irq_info; 15444 + 15445 + if (sock >= socket_count) { 15446 + printk(KERN_ERR "bcm47xx: socket %u not configured\n", sock); 15447 + return -1; 15448 + } 15449 + 15450 + /* SS_CAP_PAGE_REGS: used by setup_cis_mem() in cistpl.c to set the 15451 + * force_low argument to validate_mem() in rsrc_mgr.c -- since in 15452 + * general, the mapped * addresses of the PCMCIA memory regions 15453 + * will not be within 0xffff, setting force_low would be 15454 + * undesirable. 15455 + * 15456 + * SS_CAP_STATIC_MAP: don't bother with the (user-configured) memory 15457 + * resource database; we instead pass up physical address ranges 15458 + * and allow other parts of Card Services to deal with remapping. 15459 + * 15460 + * SS_CAP_PCCARD: we can deal with 16-bit PCMCIA & CF cards, but 15461 + * not 32-bit CardBus devices. 15462 + */ 15463 + cap->features = (SS_CAP_PAGE_REGS | SS_CAP_STATIC_MAP | SS_CAP_PCCARD); 15464 + 15465 + irq_info.sock = sock; 15466 + irq_info.irq = -1; 15467 + 15468 + if (pcmcia_low_level->get_irq_info(&irq_info) < 0) { 15469 + printk(KERN_ERR "Error obtaining IRQ info socket %u\n", sock); 15470 + return -1; 15471 + } 15472 + 15473 + cap->irq_mask = 0; 15474 + cap->map_size = PAGE_SIZE; 15475 + cap->pci_irq = irq_info.irq; 15476 + cap->io_offset = pcmcia_socket[sock].virt_io; 15477 + 15478 + return 0; 15479 +} 15480 + 15481 + 15482 +/* 15483 + * bcm47xx_pcmcia_get_status() 15484 + * 15485 + * Implements the get_status() operation for the in-kernel PCMCIA 15486 + * service (formerly SS_GetStatus in Card Services). Essentially just 15487 + * fills in bits in `status' according to internal driver state or 15488 + * the value of the voltage detect chipselect register. 15489 + * 15490 + * As a debugging note, during card startup, the PCMCIA core issues 15491 + * three set_socket() commands in a row the first with RESET deasserted, 15492 + * the second with RESET asserted, and the last with RESET deasserted 15493 + * again. Following the third set_socket(), a get_status() command will 15494 + * be issued. The kernel is looking for the SS_READY flag (see 15495 + * setup_socket(), reset_socket(), and unreset_socket() in cs.c). 15496 + * 15497 + * Returns: 0 15498 + */ 15499 +static int 15500 +bcm47xx_pcmcia_get_status(unsigned int sock, unsigned int *status) 15501 +{ 15502 + struct pcmcia_state state; 15503 + 15504 + 15505 + if ((pcmcia_low_level->socket_state(sock, &state)) < 0) { 15506 + printk(KERN_ERR "Unable to get PCMCIA status from kernel.\n"); 15507 + return -1; 15508 + } 15509 + 15510 + pcmcia_socket[sock].k_state = state; 15511 + 15512 + *status = state.detect ? SS_DETECT : 0; 15513 + 15514 + *status |= state.ready ? SS_READY : 0; 15515 + 15516 + /* The power status of individual sockets is not available 15517 + * explicitly from the hardware, so we just remember the state 15518 + * and regurgitate it upon request: 15519 + */ 15520 + *status |= pcmcia_socket[sock].cs_state.Vcc ? SS_POWERON : 0; 15521 + 15522 + if (pcmcia_socket[sock].cs_state.flags & SS_IOCARD) 15523 + *status |= state.bvd1 ? SS_STSCHG : 0; 15524 + else { 15525 + if (state.bvd1 == 0) 15526 + *status |= SS_BATDEAD; 15527 + else if (state.bvd2 == 0) 15528 + *status |= SS_BATWARN; 15529 + } 15530 + 15531 + *status |= state.vs_3v ? SS_3VCARD : 0; 15532 + 15533 + *status |= state.vs_Xv ? SS_XVCARD : 0; 15534 + 15535 + DEBUG(2, "\tstatus: %s%s%s%s%s%s%s%s\n", 15536 + (*status&SS_DETECT)?"DETECT ":"", 15537 + (*status&SS_READY)?"READY ":"", 15538 + (*status&SS_BATDEAD)?"BATDEAD ":"", 15539 + (*status&SS_BATWARN)?"BATWARN ":"", 15540 + (*status&SS_POWERON)?"POWERON ":"", 15541 + (*status&SS_STSCHG)?"STSCHG ":"", 15542 + (*status&SS_3VCARD)?"3VCARD ":"", 15543 + (*status&SS_XVCARD)?"XVCARD ":""); 15544 + 15545 + return 0; 15546 +} 15547 + 15548 + 15549 +/* 15550 + * bcm47xx_pcmcia_get_socket() 15551 + * 15552 + * Implements the get_socket() operation for the in-kernel PCMCIA 15553 + * service (formerly SS_GetSocket in Card Services). Not a very 15554 + * exciting routine. 15555 + * 15556 + * Returns: 0 15557 + */ 15558 +static int 15559 +bcm47xx_pcmcia_get_socket(unsigned int sock, socket_state_t *state) 15560 +{ 15561 + DEBUG(2, "%s() for sock %u\n", __FUNCTION__, sock); 15562 + 15563 + /* This information was given to us in an earlier call to set_socket(), 15564 + * so we're just regurgitating it here: 15565 + */ 15566 + *state = pcmcia_socket[sock].cs_state; 15567 + return 0; 15568 +} 15569 + 15570 + 15571 +/* 15572 + * bcm47xx_pcmcia_set_socket() 15573 + * 15574 + * Implements the set_socket() operation for the in-kernel PCMCIA 15575 + * service (formerly SS_SetSocket in Card Services). We more or 15576 + * less punt all of this work and let the kernel handle the details 15577 + * of power configuration, reset, &c. We also record the value of 15578 + * `state' in order to regurgitate it to the PCMCIA core later. 15579 + * 15580 + * Returns: 0 15581 + */ 15582 +static int 15583 +bcm47xx_pcmcia_set_socket(unsigned int sock, socket_state_t *state) 15584 +{ 15585 + struct pcmcia_configure configure; 15586 + 15587 + DEBUG(2, "\tmask: %s%s%s%s%s%s\n\tflags: %s%s%s%s%s%s\n" 15588 + "\tVcc %d Vpp %d irq %d\n", 15589 + (state->csc_mask == 0) ? "<NONE>" : "", 15590 + (state->csc_mask & SS_DETECT) ? "DETECT " : "", 15591 + (state->csc_mask & SS_READY) ? "READY " : "", 15592 + (state->csc_mask & SS_BATDEAD) ? "BATDEAD " : "", 15593 + (state->csc_mask & SS_BATWARN) ? "BATWARN " : "", 15594 + (state->csc_mask & SS_STSCHG) ? "STSCHG " : "", 15595 + (state->flags == 0) ? "<NONE>" : "", 15596 + (state->flags & SS_PWR_AUTO) ? "PWR_AUTO " : "", 15597 + (state->flags & SS_IOCARD) ? "IOCARD " : "", 15598 + (state->flags & SS_RESET) ? "RESET " : "", 15599 + (state->flags & SS_SPKR_ENA) ? "SPKR_ENA " : "", 15600 + (state->flags & SS_OUTPUT_ENA) ? "OUTPUT_ENA " : "", 15601 + state->Vcc, state->Vpp, state->io_irq); 15602 + 15603 + configure.sock = sock; 15604 + configure.vcc = state->Vcc; 15605 + configure.vpp = state->Vpp; 15606 + configure.output = (state->flags & SS_OUTPUT_ENA) ? 1 : 0; 15607 + configure.speaker = (state->flags & SS_SPKR_ENA) ? 1 : 0; 15608 + configure.reset = (state->flags & SS_RESET) ? 1 : 0; 15609 + 15610 + if (pcmcia_low_level->configure_socket(&configure) < 0) { 15611 + printk(KERN_ERR "Unable to configure socket %u\n", sock); 15612 + return -1; 15613 + } 15614 + 15615 + pcmcia_socket[sock].cs_state = *state; 15616 + return 0; 15617 +} 15618 + 15619 + 15620 +/* 15621 + * bcm47xx_pcmcia_get_io_map() 15622 + * 15623 + * Implements the get_io_map() operation for the in-kernel PCMCIA 15624 + * service (formerly SS_GetIOMap in Card Services). Just returns an 15625 + * I/O map descriptor which was assigned earlier by a set_io_map(). 15626 + * 15627 + * Returns: 0 on success, -1 if the map index was out of range 15628 + */ 15629 +static int 15630 +bcm47xx_pcmcia_get_io_map(unsigned int sock, struct pccard_io_map *map) 15631 +{ 15632 + DEBUG(2, "bcm47xx_pcmcia_get_io_map: sock %d\n", sock); 15633 + 15634 + if (map->map >= MAX_IO_WIN) { 15635 + printk(KERN_ERR "%s(): map (%d) out of range\n", 15636 + __FUNCTION__, map->map); 15637 + return -1; 15638 + } 15639 + 15640 + *map = pcmcia_socket[sock].io_map[map->map]; 15641 + return 0; 15642 +} 15643 + 15644 + 15645 +/* 15646 + * bcm47xx_pcmcia_set_io_map() 15647 + * 15648 + * Implements the set_io_map() operation for the in-kernel PCMCIA 15649 + * service (formerly SS_SetIOMap in Card Services). We configure 15650 + * the map speed as requested, but override the address ranges 15651 + * supplied by Card Services. 15652 + * 15653 + * Returns: 0 on success, -1 on error 15654 + */ 15655 +int 15656 +bcm47xx_pcmcia_set_io_map(unsigned int sock, struct pccard_io_map *map) 15657 +{ 15658 + unsigned int speed; 15659 + unsigned long start; 15660 + 15661 + DEBUG(2, "\tmap %u speed %u\n\tstart 0x%08lx stop 0x%08lx\n" 15662 + "\tflags: %s%s%s%s%s%s%s%s\n", 15663 + map->map, map->speed, map->start, map->stop, 15664 + (map->flags == 0) ? "<NONE>" : "", 15665 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "", 15666 + (map->flags & MAP_16BIT) ? "16BIT " : "", 15667 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "", 15668 + (map->flags & MAP_0WS) ? "0WS " : "", 15669 + (map->flags & MAP_WRPROT) ? "WRPROT " : "", 15670 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "", 15671 + (map->flags & MAP_PREFETCH) ? "PREFETCH " : ""); 15672 + 15673 + if (map->map >= MAX_IO_WIN) { 15674 + printk(KERN_ERR "%s(): map (%d) out of range\n", 15675 + __FUNCTION__, map->map); 15676 + return -1; 15677 + } 15678 + 15679 + if (map->flags & MAP_ACTIVE) { 15680 + speed = (map->speed > 0) ? map->speed : BCM47XX_PCMCIA_IO_SPEED; 15681 + pcmcia_socket[sock].speed_io = speed; 15682 + } 15683 + 15684 + start = map->start; 15685 + 15686 + if (map->stop == 1) { 15687 + map->stop = PAGE_SIZE - 1; 15688 + } 15689 + 15690 + map->start = pcmcia_socket[sock].virt_io; 15691 + map->stop = map->start + (map->stop - start); 15692 + pcmcia_socket[sock].io_map[map->map] = *map; 15693 + DEBUG(2, "set_io_map %d start %x stop %x\n", 15694 + map->map, map->start, map->stop); 15695 + return 0; 15696 +} 15697 + 15698 + 15699 +/* 15700 + * bcm47xx_pcmcia_get_mem_map() 15701 + * 15702 + * Implements the get_mem_map() operation for the in-kernel PCMCIA 15703 + * service (formerly SS_GetMemMap in Card Services). Just returns a 15704 + * memory map descriptor which was assigned earlier by a 15705 + * set_mem_map() request. 15706 + * 15707 + * Returns: 0 on success, -1 if the map index was out of range 15708 + */ 15709 +static int 15710 +bcm47xx_pcmcia_get_mem_map(unsigned int sock, struct pccard_mem_map *map) 15711 +{ 15712 + DEBUG(2, "%s() for sock %u\n", __FUNCTION__, sock); 15713 + 15714 + if (map->map >= MAX_WIN) { 15715 + printk(KERN_ERR "%s(): map (%d) out of range\n", 15716 + __FUNCTION__, map->map); 15717 + return -1; 15718 + } 15719 + 15720 + *map = pcmcia_socket[sock].mem_map[map->map]; 15721 + return 0; 15722 +} 15723 + 15724 + 15725 +/* 15726 + * bcm47xx_pcmcia_set_mem_map() 15727 + * 15728 + * Implements the set_mem_map() operation for the in-kernel PCMCIA 15729 + * service (formerly SS_SetMemMap in Card Services). We configure 15730 + * the map speed as requested, but override the address ranges 15731 + * supplied by Card Services. 15732 + * 15733 + * Returns: 0 on success, -1 on error 15734 + */ 15735 +static int 15736 +bcm47xx_pcmcia_set_mem_map(unsigned int sock, struct pccard_mem_map *map) 15737 +{ 15738 + unsigned int speed; 15739 + unsigned long start; 15740 + u_long flags; 15741 + 15742 + if (map->map >= MAX_WIN) { 15743 + printk(KERN_ERR "%s(): map (%d) out of range\n", 15744 + __FUNCTION__, map->map); 15745 + return -1; 15746 + } 15747 + 15748 + DEBUG(2, "\tmap %u speed %u\n\tsys_start %#lx\n" 15749 + "\tsys_stop %#lx\n\tcard_start %#x\n" 15750 + "\tflags: %s%s%s%s%s%s%s%s\n", 15751 + map->map, map->speed, map->sys_start, map->sys_stop, 15752 + map->card_start, (map->flags == 0) ? "<NONE>" : "", 15753 + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "", 15754 + (map->flags & MAP_16BIT) ? "16BIT " : "", 15755 + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "", 15756 + (map->flags & MAP_0WS) ? "0WS " : "", 15757 + (map->flags & MAP_WRPROT) ? "WRPROT " : "", 15758 + (map->flags & MAP_ATTRIB) ? "ATTRIB " : "", 15759 + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : ""); 15760 + 15761 + if (map->flags & MAP_ACTIVE) { 15762 + /* When clients issue RequestMap, the access speed is not always 15763 + * properly configured: 15764 + */ 15765 + speed = (map->speed > 0) ? map->speed : BCM47XX_PCMCIA_MEM_SPEED; 15766 + 15767 + /* TBD */ 15768 + if (map->flags & MAP_ATTRIB) { 15769 + pcmcia_socket[sock].speed_attr = speed; 15770 + } else { 15771 + pcmcia_socket[sock].speed_mem = speed; 15772 + } 15773 + } 15774 + 15775 + save_flags(flags); 15776 + cli(); 15777 + start = map->sys_start; 15778 + 15779 + if (map->sys_stop == 0) 15780 + map->sys_stop = PAGE_SIZE - 1; 15781 + 15782 + if (map->flags & MAP_ATTRIB) { 15783 + map->sys_start = pcmcia_socket[sock].phys_attr + 15784 + map->card_start; 15785 + } else { 15786 + map->sys_start = pcmcia_socket[sock].phys_mem + 15787 + map->card_start; 15788 + } 15789 + 15790 + map->sys_stop = map->sys_start + (map->sys_stop - start); 15791 + pcmcia_socket[sock].mem_map[map->map] = *map; 15792 + restore_flags(flags); 15793 + DEBUG(2, "set_mem_map %d start %x stop %x card_start %x\n", 15794 + map->map, map->sys_start, map->sys_stop, 15795 + map->card_start); 15796 + return 0; 15797 +} 15798 + 15799 + 15800 +#if defined(CONFIG_PROC_FS) 15801 + 15802 +/* 15803 + * bcm47xx_pcmcia_proc_setup() 15804 + * 15805 + * Implements the proc_setup() operation for the in-kernel PCMCIA 15806 + * service (formerly SS_ProcSetup in Card Services). 15807 + * 15808 + * Returns: 0 on success, -1 on error 15809 + */ 15810 +static void 15811 +bcm47xx_pcmcia_proc_setup(unsigned int sock, struct proc_dir_entry *base) 15812 +{ 15813 + struct proc_dir_entry *entry; 15814 + 15815 + if ((entry = create_proc_entry("status", 0, base)) == NULL) { 15816 + printk(KERN_ERR "Unable to install \"status\" procfs entry\n"); 15817 + return; 15818 + } 15819 + 15820 + entry->read_proc = bcm47xx_pcmcia_proc_status; 15821 + entry->data = (void *)sock; 15822 +} 15823 + 15824 + 15825 +/* 15826 + * bcm47xx_pcmcia_proc_status() 15827 + * 15828 + * Implements the /proc/bus/pccard/??/status file. 15829 + * 15830 + * Returns: the number of characters added to the buffer 15831 + */ 15832 +static int 15833 +bcm47xx_pcmcia_proc_status(char *buf, char **start, off_t pos, 15834 + int count, int *eof, void *data) 15835 +{ 15836 + char *p = buf; 15837 + unsigned int sock = (unsigned int)data; 15838 + 15839 + p += sprintf(p, "k_flags : %s%s%s%s%s%s%s\n", 15840 + pcmcia_socket[sock].k_state.detect ? "detect " : "", 15841 + pcmcia_socket[sock].k_state.ready ? "ready " : "", 15842 + pcmcia_socket[sock].k_state.bvd1 ? "bvd1 " : "", 15843 + pcmcia_socket[sock].k_state.bvd2 ? "bvd2 " : "", 15844 + pcmcia_socket[sock].k_state.wrprot ? "wrprot " : "", 15845 + pcmcia_socket[sock].k_state.vs_3v ? "vs_3v " : "", 15846 + pcmcia_socket[sock].k_state.vs_Xv ? "vs_Xv " : ""); 15847 + 15848 + p += sprintf(p, "status : %s%s%s%s%s%s%s%s%s\n", 15849 + pcmcia_socket[sock].k_state.detect ? "SS_DETECT " : "", 15850 + pcmcia_socket[sock].k_state.ready ? "SS_READY " : "", 15851 + pcmcia_socket[sock].cs_state.Vcc ? "SS_POWERON " : "", 15852 + pcmcia_socket[sock].cs_state.flags & SS_IOCARD ? "SS_IOCARD " : "", 15853 + (pcmcia_socket[sock].cs_state.flags & SS_IOCARD && 15854 + pcmcia_socket[sock].k_state.bvd1) ? "SS_STSCHG " : "", 15855 + ((pcmcia_socket[sock].cs_state.flags & SS_IOCARD) == 0 && 15856 + (pcmcia_socket[sock].k_state.bvd1 == 0)) ? "SS_BATDEAD " : "", 15857 + ((pcmcia_socket[sock].cs_state.flags & SS_IOCARD) == 0 && 15858 + (pcmcia_socket[sock].k_state.bvd2 == 0)) ? "SS_BATWARN " : "", 15859 + pcmcia_socket[sock].k_state.vs_3v ? "SS_3VCARD " : "", 15860 + pcmcia_socket[sock].k_state.vs_Xv ? "SS_XVCARD " : ""); 15861 + 15862 + p += sprintf(p, "mask : %s%s%s%s%s\n", 15863 + pcmcia_socket[sock].cs_state.csc_mask & SS_DETECT ? "SS_DETECT " : "", 15864 + pcmcia_socket[sock].cs_state.csc_mask & SS_READY ? "SS_READY " : "", 15865 + pcmcia_socket[sock].cs_state.csc_mask & SS_BATDEAD ? "SS_BATDEAD " : "", 15866 + pcmcia_socket[sock].cs_state.csc_mask & SS_BATWARN ? "SS_BATWARN " : "", 15867 + pcmcia_socket[sock].cs_state.csc_mask & SS_STSCHG ? "SS_STSCHG " : ""); 15868 + 15869 + p += sprintf(p, "cs_flags : %s%s%s%s%s\n", 15870 + pcmcia_socket[sock].cs_state.flags & SS_PWR_AUTO ? 15871 + "SS_PWR_AUTO " : "", 15872 + pcmcia_socket[sock].cs_state.flags & SS_IOCARD ? 15873 + "SS_IOCARD " : "", 15874 + pcmcia_socket[sock].cs_state.flags & SS_RESET ? 15875 + "SS_RESET " : "", 15876 + pcmcia_socket[sock].cs_state.flags & SS_SPKR_ENA ? 15877 + "SS_SPKR_ENA " : "", 15878 + pcmcia_socket[sock].cs_state.flags & SS_OUTPUT_ENA ? 15879 + "SS_OUTPUT_ENA " : ""); 15880 + 15881 + p += sprintf(p, "Vcc : %d\n", pcmcia_socket[sock].cs_state.Vcc); 15882 + p += sprintf(p, "Vpp : %d\n", pcmcia_socket[sock].cs_state.Vpp); 15883 + p += sprintf(p, "irq : %d\n", pcmcia_socket[sock].cs_state.io_irq); 15884 + p += sprintf(p, "I/O : %u\n", pcmcia_socket[sock].speed_io); 15885 + p += sprintf(p, "attribute: %u\n", pcmcia_socket[sock].speed_attr); 15886 + p += sprintf(p, "common : %u\n", pcmcia_socket[sock].speed_mem); 15887 + return p-buf; 15888 +} 15889 + 15890 + 15891 +#endif /* defined(CONFIG_PROC_FS) */ 15892 diff -Nur linux-2.4.32/drivers/pcmcia/bcm4710_pcmcia.c linux-2.4.32-freewrt/drivers/pcmcia/bcm4710_pcmcia.c 15893 --- linux-2.4.32/drivers/pcmcia/bcm4710_pcmcia.c 1970-01-01 01:00:00.000000000 +0100 15894 +++ linux-2.4.32-freewrt/drivers/pcmcia/bcm4710_pcmcia.c 2006-09-16 15:41:31.000000000 +0200 15895 @@ -0,0 +1,266 @@ 15896 +/* 15897 + * BCM4710 specific pcmcia routines. 15898 + * 15899 + * Copyright 2004, Broadcom Corporation 15900 + * All Rights Reserved. 15901 + * 15902 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 15903 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 15904 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 15905 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 15906 + * 15907 + * $Id: bcm4710_pcmcia.c,v 1.1 2005/03/16 13:50:00 wbx Exp $ 15908 + */ 15909 +#include <linux/module.h> 15910 +#include <linux/init.h> 15911 +#include <linux/config.h> 15912 +#include <linux/delay.h> 15913 +#include <linux/ioport.h> 15914 +#include <linux/kernel.h> 15915 +#include <linux/tqueue.h> 15916 +#include <linux/timer.h> 15917 +#include <linux/mm.h> 15918 +#include <linux/proc_fs.h> 15919 +#include <linux/version.h> 15920 +#include <linux/types.h> 15921 +#include <linux/pci.h> 15922 + 15923 +#include <pcmcia/version.h> 15924 +#include <pcmcia/cs_types.h> 15925 +#include <pcmcia/cs.h> 15926 +#include <pcmcia/ss.h> 15927 +#include <pcmcia/bulkmem.h> 15928 +#include <pcmcia/cistpl.h> 15929 +#include <pcmcia/bus_ops.h> 15930 +#include "cs_internal.h" 15931 + 15932 +#include <asm/io.h> 15933 +#include <asm/irq.h> 15934 +#include <asm/system.h> 15935 + 15936 + 15937 +#include <typedefs.h> 15938 +#include <bcmdevs.h> 15939 +#include <bcm4710.h> 15940 +#include <sbconfig.h> 15941 +#include <sbextif.h> 15942 + 15943 +#include "bcm4710pcmcia.h" 15944 + 15945 +/* Use a static var for irq dev_id */ 15946 +static int bcm47xx_pcmcia_dev_id; 15947 + 15948 +/* Do we think we have a card or not? */ 15949 +static int bcm47xx_pcmcia_present = 0; 15950 + 15951 + 15952 +static void bcm4710_pcmcia_reset(void) 15953 +{ 15954 + extifregs_t *eir; 15955 + unsigned long s; 15956 + uint32 out0, out1, outen; 15957 + 15958 + 15959 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t)); 15960 + 15961 + save_and_cli(s); 15962 + 15963 + /* Use gpio7 to reset the pcmcia slot */ 15964 + outen = readl(&eir->gpio[0].outen); 15965 + outen |= BCM47XX_PCMCIA_RESET; 15966 + out0 = readl(&eir->gpio[0].out); 15967 + out0 &= ~(BCM47XX_PCMCIA_RESET); 15968 + out1 = out0 | BCM47XX_PCMCIA_RESET; 15969 + 15970 + writel(out0, &eir->gpio[0].out); 15971 + writel(outen, &eir->gpio[0].outen); 15972 + mdelay(1); 15973 + writel(out1, &eir->gpio[0].out); 15974 + mdelay(1); 15975 + writel(out0, &eir->gpio[0].out); 15976 + 15977 + restore_flags(s); 15978 +} 15979 + 15980 + 15981 +static int bcm4710_pcmcia_init(struct pcmcia_init *init) 15982 +{ 15983 + struct pci_dev *pdev; 15984 + extifregs_t *eir; 15985 + uint32 outen, intp, intm, tmp; 15986 + uint16 *attrsp; 15987 + int rc = 0, i; 15988 + extern unsigned long bcm4710_cpu_cycle; 15989 + 15990 + 15991 + if (!(pdev = pci_find_device(VENDOR_BROADCOM, SB_EXTIF, NULL))) { 15992 + printk(KERN_ERR "bcm4710_pcmcia: extif not found\n"); 15993 + return -ENODEV; 15994 + } 15995 + eir = (extifregs_t *) ioremap_nocache(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); 15996 + 15997 + /* Initialize the pcmcia i/f: 16bit no swap */ 15998 + writel(CF_EM_PCMCIA | CF_DS | CF_EN, &eir->pcmcia_config); 15999 + 16000 +#ifdef notYet 16001 + 16002 + /* Set the timing for memory accesses */ 16003 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */ 16004 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */ 16005 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */ 16006 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */ 16007 + writel(tmp, &eir->pcmcia_memwait); /* 0x01020a0c for a 100Mhz clock */ 16008 + 16009 + /* Set the timing for I/O accesses */ 16010 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */ 16011 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */ 16012 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */ 16013 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */ 16014 + writel(tmp, &eir->pcmcia_iowait); /* 0x01020a0c for a 100Mhz clock */ 16015 + 16016 + /* Set the timing for attribute accesses */ 16017 + tmp = (19 / bcm4710_cpu_cycle) << 24; /* W3 = 10nS */ 16018 + tmp = tmp | ((29 / bcm4710_cpu_cycle) << 16); /* W2 = 20nS */ 16019 + tmp = tmp | ((109 / bcm4710_cpu_cycle) << 8); /* W1 = 100nS */ 16020 + tmp = tmp | (129 / bcm4710_cpu_cycle); /* W0 = 120nS */ 16021 + writel(tmp, &eir->pcmcia_attrwait); /* 0x01020a0c for a 100Mhz clock */ 16022 + 16023 +#endif 16024 + /* Make sure gpio0 and gpio5 are inputs */ 16025 + outen = readl(&eir->gpio[0].outen); 16026 + outen &= ~(BCM47XX_PCMCIA_WP | BCM47XX_PCMCIA_STSCHG | BCM47XX_PCMCIA_RESET); 16027 + writel(outen, &eir->gpio[0].outen); 16028 + 16029 + /* Issue a reset to the pcmcia socket */ 16030 + bcm4710_pcmcia_reset(); 16031 + 16032 +#ifdef DO_BCM47XX_PCMCIA_INTERRUPTS 16033 + /* Setup gpio5 to be the STSCHG interrupt */ 16034 + intp = readl(&eir->gpiointpolarity); 16035 + writel(intp | BCM47XX_PCMCIA_STSCHG, &eir->gpiointpolarity); /* Active low */ 16036 + intm = readl(&eir->gpiointmask); 16037 + writel(intm | BCM47XX_PCMCIA_STSCHG, &eir->gpiointmask); /* Enable it */ 16038 +#endif 16039 + 16040 + DEBUG(2, "bcm4710_pcmcia after reset:\n"); 16041 + DEBUG(2, "\textstatus\t= 0x%08x:\n", readl(&eir->extstatus)); 16042 + DEBUG(2, "\tpcmcia_config\t= 0x%08x:\n", readl(&eir->pcmcia_config)); 16043 + DEBUG(2, "\tpcmcia_memwait\t= 0x%08x:\n", readl(&eir->pcmcia_memwait)); 16044 + DEBUG(2, "\tpcmcia_attrwait\t= 0x%08x:\n", readl(&eir->pcmcia_attrwait)); 16045 + DEBUG(2, "\tpcmcia_iowait\t= 0x%08x:\n", readl(&eir->pcmcia_iowait)); 16046 + DEBUG(2, "\tgpioin\t\t= 0x%08x:\n", readl(&eir->gpioin)); 16047 + DEBUG(2, "\tgpio_outen0\t= 0x%08x:\n", readl(&eir->gpio[0].outen)); 16048 + DEBUG(2, "\tgpio_out0\t= 0x%08x:\n", readl(&eir->gpio[0].out)); 16049 + DEBUG(2, "\tgpiointpolarity\t= 0x%08x:\n", readl(&eir->gpiointpolarity)); 16050 + DEBUG(2, "\tgpiointmask\t= 0x%08x:\n", readl(&eir->gpiointmask)); 16051 + 16052 +#ifdef DO_BCM47XX_PCMCIA_INTERRUPTS 16053 + /* Request pcmcia interrupt */ 16054 + rc = request_irq(BCM47XX_PCMCIA_IRQ, init->handler, SA_INTERRUPT, 16055 + "PCMCIA Interrupt", &bcm47xx_pcmcia_dev_id); 16056 +#endif 16057 + 16058 + attrsp = (uint16 *)ioremap_nocache(EXTIF_PCMCIA_CFGBASE(BCM4710_EXTIF), 0x1000); 16059 + tmp = readw(&attrsp[0]); 16060 + DEBUG(2, "\tattr[0] = 0x%04x\n", tmp); 16061 + if ((tmp == 0x7fff) || (tmp == 0x7f00)) { 16062 + bcm47xx_pcmcia_present = 0; 16063 + } else { 16064 + bcm47xx_pcmcia_present = 1; 16065 + } 16066 + 16067 + /* There's only one socket */ 16068 + return 1; 16069 +} 16070 + 16071 +static int bcm4710_pcmcia_shutdown(void) 16072 +{ 16073 + extifregs_t *eir; 16074 + uint32 intm; 16075 + 16076 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t)); 16077 + 16078 + /* Disable the pcmcia i/f */ 16079 + writel(0, &eir->pcmcia_config); 16080 + 16081 + /* Reset gpio's */ 16082 + intm = readl(&eir->gpiointmask); 16083 + writel(intm & ~BCM47XX_PCMCIA_STSCHG, &eir->gpiointmask); /* Disable it */ 16084 + 16085 + free_irq(BCM47XX_PCMCIA_IRQ, &bcm47xx_pcmcia_dev_id); 16086 + 16087 + return 0; 16088 +} 16089 + 16090 +static int 16091 +bcm4710_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state) 16092 +{ 16093 + extifregs_t *eir; 16094 + 16095 + eir = (extifregs_t *) ioremap_nocache(BCM4710_REG_EXTIF, sizeof(extifregs_t)); 16096 + 16097 + 16098 + if (sock != 0) { 16099 + printk(KERN_ERR "bcm4710 socket_state bad sock %d\n", sock); 16100 + return -1; 16101 + } 16102 + 16103 + if (bcm47xx_pcmcia_present) { 16104 + state->detect = 1; 16105 + state->ready = 1; 16106 + state->bvd1 = 1; 16107 + state->bvd2 = 1; 16108 + state->wrprot = (readl(&eir->gpioin) & BCM47XX_PCMCIA_WP) == BCM47XX_PCMCIA_WP; 16109 + state->vs_3v = 0; 16110 + state->vs_Xv = 0; 16111 + } else { 16112 + state->detect = 0; 16113 + state->ready = 0; 16114 + } 16115 + 16116 + return 1; 16117 +} 16118 + 16119 + 16120 +static int bcm4710_pcmcia_get_irq_info(struct pcmcia_irq_info *info) 16121 +{ 16122 + if (info->sock >= BCM47XX_PCMCIA_MAX_SOCK) return -1; 16123 + 16124 + info->irq = BCM47XX_PCMCIA_IRQ; 16125 + 16126 + return 0; 16127 +} 16128 + 16129 + 16130 +static int 16131 +bcm4710_pcmcia_configure_socket(const struct pcmcia_configure *configure) 16132 +{ 16133 + if (configure->sock >= BCM47XX_PCMCIA_MAX_SOCK) return -1; 16134 + 16135 + 16136 + DEBUG(2, "Vcc %dV Vpp %dV output %d speaker %d reset %d\n", configure->vcc, 16137 + configure->vpp, configure->output, configure->speaker, configure->reset); 16138 + 16139 + if ((configure->vcc != 50) || (configure->vpp != 50)) { 16140 + printk("%s: bad Vcc/Vpp (%d:%d)\n", __FUNCTION__, configure->vcc, 16141 + configure->vpp); 16142 + } 16143 + 16144 + if (configure->reset) { 16145 + /* Issue a reset to the pcmcia socket */ 16146 + DEBUG(1, "%s: Reseting socket\n", __FUNCTION__); 16147 + bcm4710_pcmcia_reset(); 16148 + } 16149 + 16150 + 16151 + return 0; 16152 +} 16153 + 16154 +struct pcmcia_low_level bcm4710_pcmcia_ops = { 16155 + bcm4710_pcmcia_init, 16156 + bcm4710_pcmcia_shutdown, 16157 + bcm4710_pcmcia_socket_state, 16158 + bcm4710_pcmcia_get_irq_info, 16159 + bcm4710_pcmcia_configure_socket 16160 +}; 16161 + 16162 diff -Nur linux-2.4.32/drivers/pcmcia/bcm4710pcmcia.h linux-2.4.32-freewrt/drivers/pcmcia/bcm4710pcmcia.h 16163 --- linux-2.4.32/drivers/pcmcia/bcm4710pcmcia.h 1970-01-01 01:00:00.000000000 +0100 16164 +++ linux-2.4.32-freewrt/drivers/pcmcia/bcm4710pcmcia.h 2006-09-16 15:41:31.000000000 +0200 16165 @@ -0,0 +1,118 @@ 16166 +/* 16167 + * 16168 + * bcm47xx pcmcia driver 16169 + * 16170 + * Copyright 2004, Broadcom Corporation 16171 + * All Rights Reserved. 16172 + * 16173 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 16174 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 16175 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 16176 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 16177 + * 16178 + * Based on sa1100.h and include/asm-arm/arch-sa1100/pcmica.h 16179 + * from www.handhelds.org, 16180 + * and au1000_generic.c from oss.sgi.com. 16181 + * 16182 + * $Id: bcm4710pcmcia.h,v 1.1 2005/03/16 13:50:00 wbx Exp $ 16183 + */ 16184 + 16185 +#if !defined(_BCM4710PCMCIA_H) 16186 +#define _BCM4710PCMCIA_H 16187 + 16188 +#include <pcmcia/cs_types.h> 16189 +#include <pcmcia/ss.h> 16190 +#include <pcmcia/bulkmem.h> 16191 +#include <pcmcia/cistpl.h> 16192 +#include "cs_internal.h" 16193 + 16194 + 16195 +/* The 47xx can only support one socket */ 16196 +#define BCM47XX_PCMCIA_MAX_SOCK 1 16197 + 16198 +/* In the bcm947xx gpio's are used for some pcmcia functions */ 16199 +#define BCM47XX_PCMCIA_WP 0x01 /* Bit 0 is WP input */ 16200 +#define BCM47XX_PCMCIA_STSCHG 0x20 /* Bit 5 is STSCHG input/interrupt */ 16201 +#define BCM47XX_PCMCIA_RESET 0x80 /* Bit 7 is RESET */ 16202 + 16203 +#define BCM47XX_PCMCIA_IRQ 2 16204 + 16205 +/* The socket driver actually works nicely in interrupt-driven form, 16206 + * so the (relatively infrequent) polling is "just to be sure." 16207 + */ 16208 +#define BCM47XX_PCMCIA_POLL_PERIOD (2 * HZ) 16209 + 16210 +#define BCM47XX_PCMCIA_IO_SPEED (255) 16211 +#define BCM47XX_PCMCIA_MEM_SPEED (300) 16212 + 16213 + 16214 +struct pcmcia_state { 16215 + unsigned detect: 1, 16216 + ready: 1, 16217 + bvd1: 1, 16218 + bvd2: 1, 16219 + wrprot: 1, 16220 + vs_3v: 1, 16221 + vs_Xv: 1; 16222 +}; 16223 + 16224 + 16225 +struct pcmcia_configure { 16226 + unsigned sock: 8, 16227 + vcc: 8, 16228 + vpp: 8, 16229 + output: 1, 16230 + speaker: 1, 16231 + reset: 1; 16232 +}; 16233 + 16234 +struct pcmcia_irq_info { 16235 + unsigned int sock; 16236 + unsigned int irq; 16237 +}; 16238 + 16239 +/* This structure encapsulates per-socket state which we might need to 16240 + * use when responding to a Card Services query of some kind. 16241 + */ 16242 +struct bcm47xx_pcmcia_socket { 16243 + socket_state_t cs_state; 16244 + struct pcmcia_state k_state; 16245 + unsigned int irq; 16246 + void (*handler)(void *, unsigned int); 16247 + void *handler_info; 16248 + pccard_io_map io_map[MAX_IO_WIN]; 16249 + pccard_mem_map mem_map[MAX_WIN]; 16250 + ioaddr_t virt_io, phys_attr, phys_mem; 16251 + unsigned short speed_io, speed_attr, speed_mem; 16252 +}; 16253 + 16254 +struct pcmcia_init { 16255 + void (*handler)(int irq, void *dev, struct pt_regs *regs); 16256 +}; 16257 + 16258 +struct pcmcia_low_level { 16259 + int (*init)(struct pcmcia_init *); 16260 + int (*shutdown)(void); 16261 + int (*socket_state)(unsigned sock, struct pcmcia_state *); 16262 + int (*get_irq_info)(struct pcmcia_irq_info *); 16263 + int (*configure_socket)(const struct pcmcia_configure *); 16264 +}; 16265 + 16266 +extern struct pcmcia_low_level bcm47xx_pcmcia_ops; 16267 + 16268 +/* I/O pins replacing memory pins 16269 + * (PCMCIA System Architecture, 2nd ed., by Don Anderson, p.75) 16270 + * 16271 + * These signals change meaning when going from memory-only to 16272 + * memory-or-I/O interface: 16273 + */ 16274 +#define iostschg bvd1 16275 +#define iospkr bvd2 16276 + 16277 + 16278 +/* 16279 + * Declaration for implementation specific low_level operations. 16280 + */ 16281 +extern struct pcmcia_low_level bcm4710_pcmcia_ops; 16282 + 16283 +#endif /* !defined(_BCM4710PCMCIA_H) */ 16284 diff -Nur linux-2.4.32/drivers/pcmcia/Makefile linux-2.4.32-freewrt/drivers/pcmcia/Makefile 16285 --- linux-2.4.32/drivers/pcmcia/Makefile 2004-02-18 14:36:31.000000000 +0100 16286 +++ linux-2.4.32-freewrt/drivers/pcmcia/Makefile 2006-09-16 15:41:31.000000000 +0200 16287 @@ -65,6 +65,10 @@ 16288 au1000_ss-objs-$(CONFIG_PCMCIA_DB1X00) += au1000_db1x00.o 16289 au1000_ss-objs-$(CONFIG_PCMCIA_XXS1500) += au1000_xxs1500.o 16290 16291 +obj-$(CONFIG_PCMCIA_BCM4710) += bcm4710_ss.o 16292 +bcm4710_ss-objs := bcm4710_generic.o 16293 +bcm4710_ss-objs += bcm4710_pcmcia.o 16294 + 16295 obj-$(CONFIG_PCMCIA_SA1100) += sa1100_cs.o 16296 obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o 16297 obj-$(CONFIG_PCMCIA_SIBYTE) += sibyte_generic.o 16298 @@ -102,5 +106,8 @@ 16299 au1x00_ss.o: $(au1000_ss-objs-y) 16300 $(LD) -r -o $@ $(au1000_ss-objs-y) 16301 16302 +bcm4710_ss.o: $(bcm4710_ss-objs) 16303 + $(LD) -r -o $@ $(bcm4710_ss-objs) 16304 + 16305 yenta_socket.o: $(yenta_socket-objs) 16306 $(LD) $(LD_RFLAG) -r -o $@ $(yenta_socket-objs) 16307 diff -Nur linux-2.4.32/include/asm-mips/bootinfo.h linux-2.4.32-freewrt/include/asm-mips/bootinfo.h 16308 --- linux-2.4.32/include/asm-mips/bootinfo.h 2004-02-18 14:36:32.000000000 +0100 16309 +++ linux-2.4.32-freewrt/include/asm-mips/bootinfo.h 2006-09-16 15:41:31.000000000 +0200 16682 diff -urN linux.old/include/asm-mips/bootinfo.h linux.dev/include/asm-mips/bootinfo.h 16683 --- linux.old/include/asm-mips/bootinfo.h 2006-10-02 21:23:10.000000000 +0200 16684 +++ linux.dev/include/asm-mips/bootinfo.h 2006-10-02 21:19:59.000000000 +0200 16310 16685 @@ -37,6 +37,7 @@ 16311 16686 #define MACH_GROUP_HP_LJ 20 /* Hewlett Packard LaserJet */ … … 16316 16691 /* 16317 16692 * Valid machtype values for group unknown (low order halfword of mips_machtype) 16318 @@ -19 4,6 +195,15 @@16693 @@ -197,6 +198,15 @@ 16319 16694 #define MACH_TANBAC_TB0229 7 /* TANBAC TB0229 (VR4131DIMM) */ 16320 16695 … … 16332 16707 */ 16333 16708 #define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */ 16334 diff - Nur linux-2.4.32/include/asm-mips/cpu.h linux-2.4.32-freewrt/include/asm-mips/cpu.h16335 --- linux -2.4.32/include/asm-mips/cpu.h 2005-01-19 15:10:11.000000000 +010016336 +++ linux -2.4.32-freewrt/include/asm-mips/cpu.h 2006-09-16 15:41:31.000000000 +020016709 diff -urN linux.old/include/asm-mips/cpu.h linux.dev/include/asm-mips/cpu.h 16710 --- linux.old/include/asm-mips/cpu.h 2006-10-02 21:23:10.000000000 +0200 16711 +++ linux.dev/include/asm-mips/cpu.h 2006-10-02 21:19:59.000000000 +0200 16337 16712 @@ -22,6 +22,11 @@ 16338 16713 spec. … … 16383 16758 /* 16384 16759 * ISA Level encodings 16385 diff - Nur linux-2.4.32/include/asm-mips/r4kcache.h linux-2.4.32-freewrt/include/asm-mips/r4kcache.h16386 --- linux -2.4.32/include/asm-mips/r4kcache.h 2004-02-18 14:36:32.000000000 +010016387 +++ linux -2.4.32-freewrt/include/asm-mips/r4kcache.h 2006-09-16 15:41:31.000000000 +020016388 @@ - 567,4 +567,17 @@16760 diff -urN linux.old/include/asm-mips/r4kcache.h linux.dev/include/asm-mips/r4kcache.h 16761 --- linux.old/include/asm-mips/r4kcache.h 2006-10-02 21:23:10.000000000 +0200 16762 +++ linux.dev/include/asm-mips/r4kcache.h 2006-10-02 21:19:59.000000000 +0200 16763 @@ -658,4 +658,17 @@ 16389 16764 cache128_unroll32(addr|ws,Index_Writeback_Inv_SD); 16390 16765 } … … 16404 16779 + 16405 16780 #endif /* __ASM_R4KCACHE_H */ 16406 diff - Nur linux-2.4.32/include/asm-mips/serial.h linux-2.4.32-freewrt/include/asm-mips/serial.h16407 --- linux -2.4.32/include/asm-mips/serial.h 2005-01-19 15:10:12.000000000 +010016408 +++ linux -2.4.32-freewrt/include/asm-mips/serial.h 2006-09-16 15:41:31.000000000 +020016781 diff -urN linux.old/include/asm-mips/serial.h linux.dev/include/asm-mips/serial.h 16782 --- linux.old/include/asm-mips/serial.h 2006-10-02 21:23:10.000000000 +0200 16783 +++ linux.dev/include/asm-mips/serial.h 2006-10-02 21:19:59.000000000 +0200 16409 16784 @@ -223,6 +223,13 @@ 16410 16785 #define TXX927_SERIAL_PORT_DEFNS … … 16429 16804 DDB5477_SERIAL_PORT_DEFNS \ 16430 16805 EV96100_SERIAL_PORT_DEFNS \ 16431 diff - Nur linux-2.4.32/init/do_mounts.c linux-2.4.32-freewrt/init/do_mounts.c16432 --- linux -2.4.32/init/do_mounts.c 2003-11-28 19:26:21.000000000 +010016433 +++ linux -2.4.32-freewrt/init/do_mounts.c 2006-09-16 15:41:31.000000000 +020016434 @@ -25 3,7 +253,13 @@16806 diff -urN linux.old/init/do_mounts.c linux.dev/init/do_mounts.c 16807 --- linux.old/init/do_mounts.c 2006-10-02 21:23:10.000000000 +0200 16808 +++ linux.dev/init/do_mounts.c 2006-10-02 21:19:59.000000000 +0200 16809 @@ -254,7 +254,13 @@ 16435 16810 { "ftlb", 0x2c08 }, 16436 16811 { "ftlc", 0x2c10 },
Note:
See TracChangeset
for help on using the changeset viewer.
