Changeset 31126
- Timestamp:
- 2012-03-28T19:03:18+02:00 (6 years ago)
- Location:
- trunk/target/linux/brcm47xx/patches-3.2
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/target/linux/brcm47xx/patches-3.2/020-bcma-move-parallel-flash-into-a-union.patch
r30942 r31126 1 From b7d9f9cd6a8e463c1061ea29ed3e614403625024 Mon Sep 17 00:00:00 20012 From: Hauke Mehrtens <hauke@hauke-m.de>3 Date: Sun, 17 Jul 2011 14:51:47 +02004 Subject: [PATCH 12/26] bcma: move parallel flash into a union5 6 7 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>8 ---9 arch/mips/bcm47xx/nvram.c | 3 +10 drivers/bcma/driver_mips.c | 1 +11 include/linux/bcma/bcma_driver_chipcommon.h | 73 ++++++++++++++++++++++++++-12 3 files changed, 76 insertions(+), 1 deletions(-)13 14 1 --- a/arch/mips/bcm47xx/nvram.c 15 2 +++ b/arch/mips/bcm47xx/nvram.c -
trunk/target/linux/brcm47xx/patches-3.2/021-bcma-add-serial-flash-support-to-bcma.patch
r30942 r31126 1 From a62940e988526c881966a8c72cc28c95fca89f3c Mon Sep 17 00:00:00 20012 From: Hauke Mehrtens <hauke@hauke-m.de>3 Date: Sun, 17 Jul 2011 14:53:07 +02004 Subject: [PATCH 13/26] bcma: add serial flash support to bcma5 6 7 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>8 ---9 drivers/bcma/Kconfig | 5 +10 drivers/bcma/Makefile | 1 +11 drivers/bcma/bcma_private.h | 5 +12 drivers/bcma/driver_chipcommon_sflash.c | 555 +++++++++++++++++++++++++++13 drivers/bcma/driver_mips.c | 8 +-14 include/linux/bcma/bcma_driver_chipcommon.h | 24 ++15 6 files changed, 597 insertions(+), 1 deletions(-)16 create mode 100644 drivers/bcma/driver_chipcommon_sflash.c17 18 1 --- a/drivers/bcma/Kconfig 19 2 +++ b/drivers/bcma/Kconfig … … 55 38 --- /dev/null 56 39 +++ b/drivers/bcma/driver_chipcommon_sflash.c 57 @@ -0,0 +1, 555@@40 @@ -0,0 +1,398 @@ 58 41 +/* 59 42 + * Broadcom SiliconBackplane chipcommon serial flash interface 60 43 + * 61 44 + * Copyright 2011, Jonas Gorski <jonas.gorski@gmail.com> 45 + * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de> 62 46 + * Copyright 2010, Broadcom Corporation 63 47 + * … … 85 69 + 86 70 +static inline void bcma_sflash_write_u8(struct bcma_drv_cc *cc, 87 + 71 + u32 offset, u8 byte) 88 72 +{ 89 73 + bcma_cc_write32(cc, BCMA_CC_FLASHADDR, offset); … … 245 229 + 246 230 +/* Read len bytes starting at offset into buf. Returns number of bytes read. */ 247 +int bcma_sflash_read(struct bcma_drv_cc *cc, u32 offset, u32 len, 248 + u8 *buf) 231 +int bcma_sflash_read(struct bcma_drv_cc *cc, u32 offset, u32 len, u8 *buf) 249 232 +{ 250 233 + u8 *from, *to; … … 264 247 + cnt = len; 265 248 + 266 + 267 + if (cc->core->id.rev == 12) 268 + from = (u8 *)KSEG1ADDR(BCMA_FLASH2 + offset); 269 + else 270 + from = (u8 *)KSEG0ADDR(BCMA_FLASH2 + offset); 249 + from = (u8 *)KSEG0ADDR(BCMA_FLASH2 + offset); 271 250 + 272 251 + to = (u8 *)buf; … … 317 296 + const u8 *buf) 318 297 +{ 319 + struct bcma_bus *bus = cc->core->bus; 320 + int ret = 0; 321 + bool is4712b0 = (bus->chipinfo.id == 0x4712) && (bus->chipinfo.rev == 3); 322 + u32 mask; 323 + 298 + int written = 1; 324 299 + 325 300 + /* Enable writes */ 326 301 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_WREN); 327 + if (is4712b0) { 328 + mask = 1 << 14; 329 + bcma_sflash_write_u8(cc, offset, *buf++); 330 + /* Set chip select */ 331 + bcma_cc_set32(cc, BCMA_CC_GPIOOUT, mask); 332 + /* Issue a page program with the first byte */ 333 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_PP); 334 + ret = 1; 302 + bcma_sflash_write_u8(cc, offset, *buf++); 303 + /* Issue a page program with CSA bit set */ 304 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_CSA | BCMA_CC_FLASHCTL_ST_PP); 305 + offset++; 306 + len--; 307 + while (len > 0) { 308 + if ((offset & 255) == 0) { 309 + /* Page boundary, poll droping cs and return */ 310 + bcma_cc_write32(cc, BCMA_CC_FLASHCTL, 0); 311 + udelay(1); 312 + if (!bcma_sflash_poll(cc, offset)) { 313 + /* Flash rejected command */ 314 + return -EAGAIN; 315 + } 316 + return written; 317 + } else { 318 + /* Write single byte */ 319 + bcma_sflash_cmd(cc, 320 + BCMA_CC_FLASHCTL_ST_CSA | 321 + *buf++); 322 + } 323 + written++; 335 324 + offset++; 336 325 + len--; 337 + while (len > 0) { 338 + if ((offset & 255) == 0) { 339 + /* Page boundary, drop cs and return */ 340 + bcma_cc_mask32(cc, BCMA_CC_GPIOOUT, ~mask); 341 + udelay(1); 342 + if (!bcma_sflash_poll(cc, offset)) { 343 + /* Flash rejected command */ 344 + return -EAGAIN; 345 + } 346 + return ret; 347 + } else { 348 + /* Write single byte */ 349 + bcma_sflash_cmd(cc, *buf++); 350 + } 351 + ret++; 352 + offset++; 353 + len--; 354 + } 355 + /* All done, drop cs */ 356 + bcma_cc_mask32(cc, BCMA_CC_GPIOOUT, ~mask); 357 + udelay(1); 358 + if (!bcma_sflash_poll(cc, offset)) { 359 + /* Flash rejected command */ 360 + return -EAGAIN; 361 + } 362 + } else if (cc->core->id.rev >= 20) { 363 + bcma_sflash_write_u8(cc, offset, *buf++); 364 + /* Issue a page program with CSA bit set */ 365 + bcma_sflash_cmd(cc, 366 + BCMA_CC_FLASHCTL_ST_CSA | 367 + BCMA_CC_FLASHCTL_ST_PP); 368 + ret = 1; 369 + offset++; 370 + len--; 371 + while (len > 0) { 372 + if ((offset & 255) == 0) { 373 + /* Page boundary, poll droping cs and return */ 374 + bcma_cc_write32(cc, BCMA_CC_FLASHCTL, 0); 375 + udelay(1); 376 + if (!bcma_sflash_poll(cc, offset)) { 377 + /* Flash rejected command */ 378 + return -EAGAIN; 379 + } 380 + return ret; 381 + } else { 382 + /* Write single byte */ 383 + bcma_sflash_cmd(cc, 384 + BCMA_CC_FLASHCTL_ST_CSA | 385 + *buf++); 386 + } 387 + ret++; 388 + offset++; 389 + len--; 390 + } 391 + /* All done, drop cs & poll */ 392 + bcma_cc_write32(cc, BCMA_CC_FLASHCTL, 0); 393 + udelay(1); 394 + if (!bcma_sflash_poll(cc, offset)) { 395 + /* Flash rejected command */ 396 + return -EAGAIN; 397 + } 398 + } else { 399 + ret = 1; 400 + bcma_sflash_write_u8(cc, offset, *buf); 401 + /* Page program */ 402 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_PP); 403 + } 404 + return ret; 326 + } 327 + /* All done, drop cs & poll */ 328 + bcma_cc_write32(cc, BCMA_CC_FLASHCTL, 0); 329 + udelay(1); 330 + if (!bcma_sflash_poll(cc, offset)) { 331 + /* Flash rejected command */ 332 + return -EAGAIN; 333 + } 334 + return written; 405 335 +} 406 336 + … … 411 341 + u32 page, byte, mask; 412 342 + int ret = 0; 343 + 413 344 + mask = sfl->blocksize - 1; 414 345 + page = (offset & ~mask) << 1; … … 429 360 + for (ret = 0; (ret < (int)len) && (byte < sfl->blocksize); ret++) { 430 361 + bcma_sflash_write_u8(cc, byte++, *buf++); 431 + bcma_sflash_cmd(cc, 432 + BCMA_CC_FLASHCTL_AT_BUF1_WRITE); 362 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_AT_BUF1_WRITE); 433 363 + } 434 364 + /* Write buffer 1 into main memory page */ … … 443 373 + */ 444 374 +int bcma_sflash_write(struct bcma_drv_cc *cc, u32 offset, u32 len, 445 + 375 + const u8 *buf) 446 376 +{ 447 377 + struct bcma_sflash *sfl; … … 494 424 + * before. 495 425 + */ 496 + bcma_sflash_cmd(cc, (sfl->blocksize < (64 * 1024)) ? BCMA_CC_FLASHCTL_ST_SSE : BCMA_CC_FLASHCTL_ST_SE); 426 + if (sfl->blocksize < (64 * 1024)) 427 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_SSE); 428 + else 429 + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_SE); 497 430 + return sfl->blocksize; 498 431 + case BCMA_CC_FLASHT_ATSER: … … 503 436 + 504 437 + return 0; 505 +}506 +507 +/*508 + * writes the appropriate range of flash, a NULL buf simply erases509 + * the region of flash510 + */511 +int bcma_sflash_commit(struct bcma_drv_cc *cc, u32 offset, u32 len,512 + const u8 *buf)513 +{514 + struct bcma_sflash *sfl;515 + u8 *block = NULL, *cur_ptr, *blk_ptr;516 + u32 blocksize = 0, mask, cur_offset, cur_length, cur_retlen, remainder;517 + u32 blk_offset, blk_len, copied;518 + int bytes, ret = 0;519 +520 + /* Check address range */521 + if (len <= 0)522 + return 0;523 +524 + sfl = &cc->sflash;525 + if ((offset + len) > sfl->size)526 + return -EINVAL;527 +528 + blocksize = sfl->blocksize;529 + mask = blocksize - 1;530 +531 + /* Allocate a block of mem */532 + block = kmalloc(blocksize, GFP_KERNEL);533 + if (!block)534 + return -ENOMEM;535 +536 + while (len) {537 + /* Align offset */538 + cur_offset = offset & ~mask;539 + cur_length = blocksize;540 + cur_ptr = block;541 +542 + remainder = blocksize - (offset & mask);543 + if (len < remainder)544 + cur_retlen = len;545 + else546 + cur_retlen = remainder;547 +548 + /* buf == NULL means erase only */549 + if (buf) {550 + /* Copy existing data into holding block if necessary */551 + if ((offset & mask) || (len < blocksize)) {552 + blk_offset = cur_offset;553 + blk_len = cur_length;554 + blk_ptr = cur_ptr;555 +556 + /* Copy entire block */557 + while (blk_len) {558 + copied = bcma_sflash_read(cc,559 + blk_offset,560 + blk_len, blk_ptr);561 + blk_offset += copied;562 + blk_len -= copied;563 + blk_ptr += copied;564 + }565 + }566 +567 + /* Copy input data into holding block */568 + memcpy(cur_ptr + (offset & mask), buf, cur_retlen);569 + }570 +571 + /* Erase block */572 + ret = bcma_sflash_erase(cc, cur_offset);573 + if (ret < 0)574 + goto done;575 +576 + while (bcma_sflash_poll(cc, cur_offset));577 +578 + /* buf == NULL means erase only */579 + if (!buf) {580 + offset += cur_retlen;581 + len -= cur_retlen;582 + continue;583 + }584 +585 + /* Write holding block */586 + while (cur_length > 0) {587 + bytes = bcma_sflash_write(cc, cur_offset,588 + cur_length, cur_ptr);589 +590 + if (bytes < 0) {591 + ret = bytes;592 + goto done;593 + }594 +595 + while (bcma_sflash_poll(cc, cur_offset))596 + ;597 +598 + cur_offset += bytes;599 + cur_length -= bytes;600 + cur_ptr += bytes;601 + }602 +603 + offset += cur_retlen;604 + len -= cur_retlen;605 + buf += cur_retlen;606 + }607 +608 + ret = len;609 +done:610 + kfree(block);611 + return ret;612 438 +} 613 439 --- a/drivers/bcma/driver_mips.c … … 663 489 664 490 int nr_serial_ports; 665 @@ -459,4 +471,1 6@@ extern void bcma_chipco_chipctl_maskset(491 @@ -459,4 +471,14 @@ extern void bcma_chipco_chipctl_maskset( 666 492 extern void bcma_chipco_regctl_maskset(struct bcma_drv_cc *cc, 667 493 u32 offset, u32 mask, u32 set); … … 675 501 + const u8 *buf); 676 502 +int bcma_sflash_erase(struct bcma_drv_cc *cc, u32 offset); 677 +int bcma_sflash_commit(struct bcma_drv_cc *cc, u32 offset, u32 len,678 + const u8 *buf);679 503 +#endif /* CONFIG_BCMA_SFLASH */ 680 504 + -
trunk/target/linux/brcm47xx/patches-3.2/022-ssb-move-flash-to-chipcommon.patch
r30942 r31126 1 From e8afde87ecf56beff67c7d5371cabaa4fc018541 Mon Sep 17 00:00:00 20012 From: Hauke Mehrtens <hauke@hauke-m.de>3 Date: Sat, 23 Jul 2011 23:57:06 +02004 Subject: [PATCH 14/26] ssb: move flash to chipcommon5 6 7 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>8 ---9 arch/mips/bcm47xx/nvram.c | 8 +++---10 arch/mips/bcm47xx/wgt634u.c | 8 +++---11 drivers/ssb/driver_mipscore.c | 36 +++++++++++++++++++++-------12 include/linux/ssb/ssb_driver_chipcommon.h | 18 ++++++++++++++13 include/linux/ssb/ssb_driver_mips.h | 4 ---14 5 files changed, 53 insertions(+), 21 deletions(-)15 16 1 --- a/arch/mips/bcm47xx/nvram.c 17 2 +++ b/arch/mips/bcm47xx/nvram.c -
trunk/target/linux/brcm47xx/patches-3.2/023-ssb-add-serial-flash-support.patch
r30942 r31126 1 From 980da78179592a3f5f99168bc5af415835aa8c13 Mon Sep 17 00:00:00 20012 From: Hauke Mehrtens <hauke@hauke-m.de>3 Date: Sun, 24 Jul 2011 20:20:36 +02004 Subject: [PATCH 15/26] ssb: add serial flash support5 6 7 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>8 ---9 drivers/ssb/Kconfig | 6 +10 drivers/ssb/Makefile | 1 +11 drivers/ssb/driver_chipcommon_sflash.c | 556 +++++++++++++++++++++++++++++12 drivers/ssb/driver_mipscore.c | 6 +13 drivers/ssb/ssb_private.h | 4 +14 include/linux/ssb/ssb_driver_chipcommon.h | 30 ++-15 6 files changed, 601 insertions(+), 2 deletions(-)16 create mode 100644 drivers/ssb/driver_chipcommon_sflash.c17 18 1 --- a/drivers/ssb/Kconfig 19 2 +++ b/drivers/ssb/Kconfig … … 43 26 --- /dev/null 44 27 +++ b/drivers/ssb/driver_chipcommon_sflash.c 45 @@ -0,0 +1, 556@@28 @@ -0,0 +1,451 @@ 46 29 +/* 47 30 + * Broadcom SiliconBackplane chipcommon serial flash interface 48 31 + * 49 32 + * Copyright 2011, Jonas Gorski <jonas.gorski@gmail.com> 33 + * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de> 50 34 + * Copyright 2010, Broadcom Corporation 51 35 + * … … 74 58 + 75 59 +static inline void ssb_sflash_write_u8(struct ssb_chipcommon *cc, 76 + 60 + u32 offset, u8 byte) 77 61 +{ 78 62 + chipco_write32(cc, SSB_CHIPCO_FLASHADDR, offset); … … 234 218 + 235 219 +/* Read len bytes starting at offset into buf. Returns number of bytes read. */ 236 +int ssb_sflash_read(struct ssb_chipcommon *cc, u32 offset, u32 len, 237 + u8 *buf) 220 +int ssb_sflash_read(struct ssb_chipcommon *cc, u32 offset, u32 len, u8 *buf) 238 221 +{ 239 222 + u8 *from, *to; … … 310 293 + bool is4712b0 = (bus->chip_id == 0x4712) && (bus->chip_rev == 3); 311 294 + u32 mask; 312 +313 295 + 314 296 + /* Enable writes */ … … 479 461 + ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_ST_WREN); 480 462 + chipco_write32(cc, SSB_CHIPCO_FLASHADDR, offset); 481 + /* Newer flashes have "sub-sectors" which can be erased independently482 + * with a new command: ST_SSE. The ST_SE command erases 64KB just as483 + * before.463 + /* Newer flashes have "sub-sectors" which can be erased 464 + * independently with a new command: ST_SSE. The ST_SE command 465 + * erases 64KB just as before. 484 466 + */ 485 + ssb_sflash_cmd(cc, (sfl->blocksize < (64 * 1024)) ? SSB_CHIPCO_FLASHCTL_ST_SSE : SSB_CHIPCO_FLASHCTL_ST_SE); 467 + if (sfl->blocksize < (64 * 1024)) 468 + ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_ST_SSE); 469 + else 470 + ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_ST_SE); 486 471 + return sfl->blocksize; 487 472 + case SSB_CHIPCO_FLASHT_ATSER: … … 492 477 + 493 478 + return 0; 494 +}495 +496 +/*497 + * writes the appropriate range of flash, a NULL buf simply erases498 + * the region of flash499 + */500 +int ssb_sflash_commit(struct ssb_chipcommon *cc, u32 offset, u32 len,501 + const u8 *buf)502 +{503 + struct ssb_sflash *sfl;504 + u8 *block = NULL, *cur_ptr, *blk_ptr;505 + u32 blocksize = 0, mask, cur_offset, cur_length, cur_retlen, remainder;506 + u32 blk_offset, blk_len, copied;507 + int bytes, ret = 0;508 +509 + /* Check address range */510 + if (len <= 0)511 + return 0;512 +513 + sfl = &cc->sflash;514 + if ((offset + len) > sfl->size)515 + return -EINVAL;516 +517 + blocksize = sfl->blocksize;518 + mask = blocksize - 1;519 +520 + /* Allocate a block of mem */521 + block = kmalloc(blocksize, GFP_KERNEL);522 + if (!block)523 + return -ENOMEM;524 +525 + while (len) {526 + /* Align offset */527 + cur_offset = offset & ~mask;528 + cur_length = blocksize;529 + cur_ptr = block;530 +531 + remainder = blocksize - (offset & mask);532 + if (len < remainder)533 + cur_retlen = len;534 + else535 + cur_retlen = remainder;536 +537 + /* buf == NULL means erase only */538 + if (buf) {539 + /* Copy existing data into holding block if necessary */540 + if ((offset & mask) || (len < blocksize)) {541 + blk_offset = cur_offset;542 + blk_len = cur_length;543 + blk_ptr = cur_ptr;544 +545 + /* Copy entire block */546 + while (blk_len) {547 + copied = ssb_sflash_read(cc,548 + blk_offset,549 + blk_len, blk_ptr);550 + blk_offset += copied;551 + blk_len -= copied;552 + blk_ptr += copied;553 + }554 + }555 +556 + /* Copy input data into holding block */557 + memcpy(cur_ptr + (offset & mask), buf, cur_retlen);558 + }559 +560 + /* Erase block */561 + ret = ssb_sflash_erase(cc, cur_offset);562 + if (ret < 0)563 + goto done;564 +565 + while (ssb_sflash_poll(cc, cur_offset));566 +567 + /* buf == NULL means erase only */568 + if (!buf) {569 + offset += cur_retlen;570 + len -= cur_retlen;571 + continue;572 + }573 +574 + /* Write holding block */575 + while (cur_length > 0) {576 + bytes = ssb_sflash_write(cc, cur_offset,577 + cur_length, cur_ptr);578 +579 + if (bytes < 0) {580 + ret = bytes;581 + goto done;582 + }583 +584 + while (ssb_sflash_poll(cc, cur_offset))585 + ;586 +587 + cur_offset += bytes;588 + cur_length -= bytes;589 + cur_ptr += bytes;590 + }591 +592 + offset += cur_retlen;593 + len -= cur_retlen;594 + buf += cur_retlen;595 + }596 +597 + ret = len;598 +done:599 + kfree(block);600 + return ret;601 479 +} 602 480 --- a/drivers/ssb/driver_mipscore.c … … 677 555 #endif /* CONFIG_SSB_DRIVER_MIPS */ 678 556 }; 679 @@ -666,6 +680,1 8@@ extern int ssb_chipco_serial_init(struct557 @@ -666,6 +680,16 @@ extern int ssb_chipco_serial_init(struct 680 558 struct ssb_serial_port *ports); 681 559 #endif /* CONFIG_SSB_SERIAL */ … … 689 567 + const u8 *buf); 690 568 +int ssb_sflash_erase(struct ssb_chipcommon *cc, u32 offset); 691 +int ssb_sflash_commit(struct ssb_chipcommon *cc, u32 offset, u32 len,692 + const u8 *buf);693 569 +#endif /* CONFIG_SSB_SFLASH */ 694 570 + -
trunk/target/linux/brcm47xx/patches-3.2/024-brcm47xx-add-common-interface-for-sflash.patch
r30942 r31126 1 From 4f314ac9edbc80897f158fdb4e1b1de8a2d0d432 Mon Sep 17 00:00:00 20012 From: Hauke Mehrtens <hauke@hauke-m.de>3 Date: Sun, 24 Jul 2011 21:10:49 +02004 Subject: [PATCH 16/26] brcm47xx: add common interface for sflash5 6 7 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>8 ---9 arch/mips/bcm47xx/Makefile | 2 +-10 arch/mips/bcm47xx/bus.c | 94 ++++++++++++++++++++++++++++++11 arch/mips/bcm47xx/setup.c | 8 +++12 arch/mips/include/asm/mach-bcm47xx/bus.h | 37 ++++++++++++13 4 files changed, 140 insertions(+), 1 deletions(-)14 create mode 100644 arch/mips/bcm47xx/bus.c15 create mode 100644 arch/mips/include/asm/mach-bcm47xx/bus.h16 17 1 --- a/arch/mips/bcm47xx/Makefile 18 2 +++ b/arch/mips/bcm47xx/Makefile … … 26 10 --- /dev/null 27 11 +++ b/arch/mips/bcm47xx/bus.c 28 @@ -0,0 +1, 94@@12 @@ -0,0 +1,82 @@ 29 13 +/* 30 14 + * BCM947xx nvram variable access … … 60 44 +} 61 45 + 62 +static int bcm47xx_sflash_bcma_commit(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf)63 +{64 + return bcma_sflash_commit(dev->bcc, offset, len, buf);65 +}66 +67 46 +void bcm47xx_sflash_struct_bcma_init(struct bcm47xx_sflash *sflash, struct bcma_drv_cc *bcc) 68 47 +{ … … 74 53 + sflash->write = bcm47xx_sflash_bcma_write; 75 54 + sflash->erase = bcm47xx_sflash_bcma_erase; 76 + sflash->commit = bcm47xx_sflash_bcma_commit;77 55 + 78 56 + sflash->blocksize = bcc->sflash.blocksize; … … 101 79 +} 102 80 + 103 +static int bcm47xx_sflash_ssb_commit(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf)104 +{105 + return ssb_sflash_commit(dev->scc, offset, len, buf);106 +}107 +108 81 +void bcm47xx_sflash_struct_ssb_init(struct bcm47xx_sflash *sflash, struct ssb_chipcommon *scc) 109 82 +{ … … 115 88 + sflash->write = bcm47xx_sflash_ssb_write; 116 89 + sflash->erase = bcm47xx_sflash_ssb_erase; 117 + sflash->commit = bcm47xx_sflash_ssb_commit;118 90 + 119 91 + sflash->blocksize = scc->sflash.blocksize; … … 154 126 --- /dev/null 155 127 +++ b/arch/mips/include/asm/mach-bcm47xx/bus.h 156 @@ -0,0 +1,3 7@@128 @@ -0,0 +1,36 @@ 157 129 +/* 158 130 + * BCM947xx nvram variable access … … 181 153 + int (*write)(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf); 182 154 + int (*erase)(struct bcm47xx_sflash *dev, u32 offset); 183 + int (*commit)(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf);184 155 + 185 156 + u32 blocksize; /* Block size */ -
trunk/target/linux/brcm47xx/patches-3.2/025-mtd-bcm47xx-add-bcm47xx-part-parser.patch
r30942 r31126 1 From d50d2d8e3ab5446f791deff0cb78820989ed93e7 Mon Sep 17 00:00:00 20012 From: Hauke Mehrtens <hauke@hauke-m.de>3 Date: Sun, 17 Jul 2011 14:54:11 +02004 Subject: [PATCH 06/19] mtd: bcm47xx: add bcm47xx part parser5 6 7 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>8 ---9 drivers/mtd/Kconfig | 7 +10 drivers/mtd/Makefile | 1 +11 drivers/mtd/bcm47xxpart.c | 542 +++++++++++++++++++++++++++++++++++++++++++++12 3 files changed, 550 insertions(+), 0 deletions(-)13 create mode 100644 drivers/mtd/bcm47xxpart.c14 15 1 --- a/drivers/mtd/Kconfig 16 2 +++ b/drivers/mtd/Kconfig … … 501 487 + bcm47xx_parts[4].name = "board_data"; 502 488 + bcm47xx_parts[4].offset = bcm47xx_parts[3].offset - custom_data_size; 503 + bcm47xx_parts[4].size = 489 + bcm47xx_parts[4].size = custom_data_size; 504 490 + break; 505 491 + -
trunk/target/linux/brcm47xx/patches-3.2/026-mtd-bcm47xx-add-parallel-flash-driver.patch
r30942 r31126 1 From 36f8b899174a445a98fe02ed8d1db177525f0c52 Mon Sep 17 00:00:00 20012 From: Hauke Mehrtens <hauke@hauke-m.de>3 Date: Sun, 17 Jul 2011 14:55:18 +02004 Subject: [PATCH 07/15] mtd: bcm47xx: add parallel flash driver5 6 7 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>8 ---9 drivers/mtd/maps/Kconfig | 9 ++10 drivers/mtd/maps/Makefile | 1 +11 drivers/mtd/maps/bcm47xx-pflash.c | 188 +++++++++++++++++++++++++++++++++++++12 3 files changed, 198 insertions(+), 0 deletions(-)13 create mode 100644 drivers/mtd/maps/bcm47xx-pflash.c14 15 1 --- a/drivers/mtd/maps/Kconfig 16 2 +++ b/drivers/mtd/maps/Kconfig -
trunk/target/linux/brcm47xx/patches-3.2/027-mtd-bcm47xx-add-serial-flash-driver.patch
r30942 r31126 1 From 2e2951220bf63e05449c03a95453680da1029e44 Mon Sep 17 00:00:00 20012 From: Hauke Mehrtens <hauke@hauke-m.de>3 Date: Sun, 17 Jul 2011 14:55:45 +02004 Subject: [PATCH 08/15] mtd: bcm47xx: add serial flash driver5 6 sflash get the sflash ops from platform device7 8 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>9 ---10 arch/mips/include/asm/mach-bcm47xx/bus.h | 3 +11 drivers/mtd/maps/Kconfig | 9 +12 drivers/mtd/maps/Makefile | 1 +13 drivers/mtd/maps/bcm47xx-sflash.c | 252 ++++++++++++++++++++++++++++++14 4 files changed, 265 insertions(+), 0 deletions(-)15 create mode 100644 drivers/mtd/maps/bcm47xx-sflash.c16 17 1 --- a/arch/mips/include/asm/mach-bcm47xx/bus.h 18 2 +++ b/arch/mips/include/asm/mach-bcm47xx/bus.h … … 25 9 26 10 struct bcm47xx_sflash { 27 @@ -2 9,6 +30,8 @@ struct bcm47xx_sflash {11 @@ -28,6 +29,8 @@ struct bcm47xx_sflash { 28 12 u32 blocksize; /* Block size */ 29 13 u32 numblocks; /* Number of blocks */ … … 61 45 --- /dev/null 62 46 +++ b/drivers/mtd/maps/bcm47xx-sflash.c 63 @@ -0,0 +1,2 52@@47 @@ -0,0 +1,263 @@ 64 48 +/* 65 49 + * Broadcom SiliconBackplane chipcommon serial flash interface 66 50 + * 51 + * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de> 67 52 + * Copyright 2006, Broadcom Corporation 68 53 + * All Rights Reserved. 69 54 + * 70 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 71 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM 72 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 73 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. 74 + * 75 + * $Id$ 55 + * Licensed under the GNU/GPL. See COPYING for details. 76 56 + */ 77 57 + … … 94 74 +{ 95 75 + unsigned long now = jiffies; 96 + int ret = 0;97 76 + 98 77 + for (;;) { 99 78 + if (!sflash->poll(sflash, offset)) { 100 + ret = 0;101 79 + break; 102 80 + } 103 81 + if (time_after(jiffies, now + timeout)) { 104 82 + pr_err("timeout while polling\n"); 105 + ret =-ETIMEDOUT;106 + break;83 + return -ETIMEDOUT; 84 + 107 85 + } 86 + cpu_relax(); 108 87 + udelay(1); 109 88 + } 110 89 + 111 + return ret;90 + return 0; 112 91 +} 113 92 + … … 115 94 +sflash_mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) 116 95 +{ 117 + struct bcm47xx_sflash *sflash = (struct bcm47xx_sflash *) 96 + struct bcm47xx_sflash *sflash = (struct bcm47xx_sflash *)mtd->priv; 118 97 + 119 98 + /* Check address range */ … … 125 104 + 126 105 + *retlen = 0; 127 +128 106 + while (len) { 129 107 + int ret = sflash->read(sflash, from, len, buf); … … 143 121 +sflash_mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) 144 122 +{ 145 + struct bcm47xx_sflash *sflash = (struct bcm47xx_sflash *) mtd->priv; 123 + int bytes; 124 + int ret; 125 + struct bcm47xx_sflash *sflash = (struct bcm47xx_sflash *)mtd->priv; 146 126 + 147 127 + /* Check address range */ … … 154 134 + *retlen = 0; 155 135 + while (len) { 156 + int bytes; 157 + int ret = sflash->write(sflash, to, len, buf); 136 + ret = sflash->write(sflash, to, len, buf); 158 137 + if (ret < 0) 159 138 + return ret; … … 229 208 + struct bcm47xx_sflash *sflash = dev_get_platdata(&pdev->dev); 230 209 + struct mtd_info *mtd; 231 + struct mtd_erase_region_info * regions;210 + struct mtd_erase_region_info *eraseregions; 232 211 + int ret = 0; 233 212 + 234 213 + mtd = kzalloc(sizeof(struct mtd_info), GFP_KERNEL); 235 + if (!mtd) 236 + return -ENOMEM; 237 + 238 + regions = kzalloc(sizeof(struct mtd_erase_region_info), GFP_KERNEL); 239 + if (!mtd) 240 + return -ENOMEM; 214 + if (!mtd){ 215 + ret = -ENOMEM; 216 + goto err_out; 217 + } 218 + 219 + eraseregions = kzalloc(sizeof(struct mtd_erase_region_info), GFP_KERNEL); 220 + if (!eraseregions) { 221 + ret = -ENOMEM; 222 + goto err_free_mtd; 223 + } 241 224 + 242 225 + pr_info("found serial flash: blocksize=%dKB, numblocks=%d, size=%dKB\n", 243 + sflash->blocksize /1024, sflash->numblocks, sflash->size / 1024);226 + sflash->blocksize / 1024, sflash->numblocks, sflash->size / 1024); 244 227 + 245 228 + /* Setup region info */ 246 + regions->offset = 0;247 + regions->erasesize = sflash->blocksize;248 + regions->numblocks = sflash->numblocks;249 + if ( regions->erasesize > mtd->erasesize)250 + mtd->erasesize = regions->erasesize;229 + eraseregions->offset = 0; 230 + eraseregions->erasesize = sflash->blocksize; 231 + eraseregions->numblocks = sflash->numblocks; 232 + if (eraseregions->erasesize > mtd->erasesize) 233 + mtd->erasesize = eraseregions->erasesize; 251 234 + mtd->size = sflash->size; 252 235 + mtd->numeraseregions = 1; … … 256 239 + mtd->type = MTD_NORFLASH; 257 240 + mtd->flags = MTD_CAP_NORFLASH; 258 + mtd->eraseregions = regions;241 + mtd->eraseregions = eraseregions; 259 242 + mtd->erase = sflash_mtd_erase; 260 243 + mtd->read = sflash_mtd_read; … … 262 245 + mtd->writesize = 1; 263 246 + mtd->priv = sflash; 247 + ret = dev_set_drvdata(&pdev->dev, mtd); 264 248 + mtd->owner = THIS_MODULE; 249 + if (ret) { 250 + pr_err("adding private data failed\n"); 251 + goto err_free_eraseregions; 252 + } 265 253 + 266 254 + ret = mtd_device_parse_register(mtd, probes, NULL, NULL, 0); … … 268 256 + if (ret) { 269 257 + pr_err("mtd_device_register failed\n"); 270 + return ret; 271 + } 272 + sflash->mtd = mtd; 273 + return 0; 258 + goto err_free_eraseregions; 259 + } 260 + return 0; 261 + 262 +err_free_eraseregions: 263 + kfree(eraseregions); 264 +err_free_mtd: 265 + kfree(mtd); 266 +err_out: 267 + return ret; 274 268 +} 275 269 + 276 270 +static int __devexit bcm47xx_sflash_remove(struct platform_device *pdev) 277 271 +{ 278 + struct bcm47xx_sflash *sflash = dev_get_platdata(&pdev->dev); 279 + 280 + if (sflash) { 281 + mtd_device_unregister(sflash->mtd); 282 + map_destroy(sflash->mtd); 283 + kfree(sflash->mtd->eraseregions); 284 + kfree(sflash->mtd); 272 + struct mtd_info *mtd = dev_get_drvdata(&pdev->dev); 273 + 274 + if (mtd) { 275 + mtd_device_unregister(mtd); 276 + map_destroy(mtd); 277 + kfree(mtd->eraseregions); 278 + kfree(mtd); 279 + dev_set_drvdata(&pdev->dev, NULL); 285 280 + } 286 281 + return 0; -
trunk/target/linux/brcm47xx/patches-3.2/028-bcm47xx-register-flash-drivers.patch
r30942 r31126 1 From 64f3d068654589d6114048ac5933cd4498706cfc Mon Sep 17 00:00:00 2001 2 From: Hauke Mehrtens <hauke@hauke-m.de> 3 Date: Sun, 17 Jul 2011 15:02:10 +0200 4 Subject: [PATCH 20/26] bcm47xx: register flash drivers 5 6 7 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> 8 --- 9 arch/mips/bcm47xx/setup.c | 72 +++++++++++++++++++++++++++++++++++++++++++++ 10 1 files changed, 72 insertions(+), 0 deletions(-) 11 1 --- a/arch/mips/bcm47xx/Kconfig 2 +++ b/arch/mips/bcm47xx/Kconfig 3 @@ -9,6 +9,7 @@ config BCM47XX_SSB 4 select SSB_EMBEDDED 5 select SSB_B43_PCI_BRIDGE if PCI 6 select SSB_PCICORE_HOSTMODE if PCI 7 + select SSB_SFLASH 8 default y 9 help 10 Add support for old Broadcom BCM47xx boards with Sonics Silicon Backplane support. 11 @@ -22,6 +23,7 @@ config BCM47XX_BCMA 12 select BCMA_HOST_SOC 13 select BCMA_DRIVER_MIPS 14 select BCMA_DRIVER_PCI_HOSTMODE if PCI 15 + select BCMA_SFLASH 16 default y 17 help 18 Add support for new Broadcom BCM47xx boards with Broadcom specific Advanced Microcontroller Bus. 12 19 --- a/arch/mips/bcm47xx/setup.c 13 20 +++ b/arch/mips/bcm47xx/setup.c … … 25 32 26 33 union bcm47xx_bus bcm47xx_bus; 27 @@ -366,3 +368,73 @@ static int __init bcm47xx_register_bus_c 28 return 0; 29 } 30 device_initcall(bcm47xx_register_bus_complete); 31 + 34 @@ -45,6 +47,32 @@ EXPORT_SYMBOL(bcm47xx_bus_type); 35 36 struct bcm47xx_sflash bcm47xx_sflash; 37 32 38 +static struct resource bcm47xx_pflash_resource = { 33 39 + .name = "bcm47xx_pflash", … … 56 62 +}; 57 63 + 64 static void bcm47xx_machine_restart(char *command) 65 { 66 printk(KERN_ALERT "Please stand by while rebooting the system...\n"); 67 @@ -310,6 +338,24 @@ static void __init bcm47xx_register_ssb( 68 } 69 } 70 } 71 + 72 +static int __init bcm47xx_register_flash_ssb(void) 73 +{ 74 + struct ssb_chipcommon *chipco = &bcm47xx_bus.ssb.chipco; 75 + 76 + switch (chipco->flash_type) { 77 + case SSB_PFLASH: 78 + bcm47xx_pflash_resource.start = chipco->pflash.window; 79 + bcm47xx_pflash_resource.end = chipco->pflash.window + chipco->pflash.window_size; 80 + return platform_device_register(&bcm47xx_pflash_dev); 81 + case SSB_SFLASH: 82 + bcm47xx_sflash_dev.dev.platform_data = &bcm47xx_sflash; 83 + return platform_device_register(&bcm47xx_sflash_dev); 84 + default: 85 + printk(KERN_ERR "No flash device found\n"); 86 + return -1; 87 + } 88 +} 89 #endif 90 91 #ifdef CONFIG_BCM47XX_BCMA 92 @@ -324,6 +370,24 @@ static void __init bcm47xx_register_bcma 93 if (bcm47xx_bus.bcma.bus.drv_cc.flash_type == BCMA_SFLASH) 94 bcm47xx_sflash_struct_bcma_init(&bcm47xx_sflash, &bcm47xx_bus.bcma.bus.drv_cc); 95 } 96 + 97 +static int __init bcm47xx_register_flash_bcma(void) 98 +{ 99 + struct bcma_drv_cc *drv_cc = &bcm47xx_bus.bcma.bus.drv_cc; 100 + 101 + switch (drv_cc->flash_type) { 102 + case BCMA_PFLASH: 103 + bcm47xx_pflash_resource.start = drv_cc->pflash.window; 104 + bcm47xx_pflash_resource.end = drv_cc->pflash.window + drv_cc->pflash.window_size; 105 + return platform_device_register(&bcm47xx_pflash_dev); 106 + case BCMA_SFLASH: 107 + bcm47xx_sflash_dev.dev.platform_data = &bcm47xx_sflash; 108 + return platform_device_register(&bcm47xx_sflash_dev); 109 + default: 110 + printk(KERN_ERR "No flash device found\n"); 111 + return -1; 112 + } 113 +} 114 #endif 115 116 void __init plat_mem_setup(void) 117 @@ -366,3 +430,19 @@ static int __init bcm47xx_register_bus_c 118 return 0; 119 } 120 device_initcall(bcm47xx_register_bus_complete); 121 + 58 122 +static int __init bcm47xx_register_flash(void) 59 123 +{ 60 +#ifdef CONFIG_BCM47XX_SSB61 + struct ssb_chipcommon *chipco;62 +#endif63 +#ifdef CONFIG_BCM47XX_BCMA64 + struct bcma_drv_cc *drv_cc;65 +#endif66 124 + switch (bcm47xx_bus_type) { 67 125 +#ifdef CONFIG_BCM47XX_SSB 68 126 + case BCM47XX_BUS_TYPE_SSB: 69 + chipco = &bcm47xx_bus.ssb.chipco; 70 + if (chipco->flash_type == SSB_PFLASH) { 71 + bcm47xx_pflash_resource.start = chipco->pflash.window; 72 + bcm47xx_pflash_resource.end = chipco->pflash.window + chipco->pflash.window_size; 73 + return platform_device_register(&bcm47xx_pflash_dev); 74 + } else if (chipco->flash_type == SSB_SFLASH) { 75 + bcm47xx_sflash_dev.dev.platform_data = &bcm47xx_sflash; 76 + return platform_device_register(&bcm47xx_sflash_dev); 77 + } else { 78 + printk(KERN_ERR "No flash device found\n"); 79 + return -1; 80 + } 127 + return bcm47xx_register_flash_ssb(); 81 128 +#endif 82 129 +#ifdef CONFIG_BCM47XX_BCMA 83 130 + case BCM47XX_BUS_TYPE_BCMA: 84 + drv_cc = &bcm47xx_bus.bcma.bus.drv_cc; 85 + if (drv_cc->flash_type == BCMA_PFLASH) { 86 + bcm47xx_pflash_resource.start = drv_cc->pflash.window; 87 + bcm47xx_pflash_resource.end = drv_cc->pflash.window + drv_cc->pflash.window_size; 88 + return platform_device_register(&bcm47xx_pflash_dev); 89 + } else if (drv_cc->flash_type == BCMA_SFLASH) { 90 + bcm47xx_sflash_dev.dev.platform_data = &bcm47xx_sflash; 91 + return platform_device_register(&bcm47xx_sflash_dev); 92 + } else { 93 + printk(KERN_ERR "No flash device found\n"); 94 + return -1; 95 + } 131 + return bcm47xx_register_flash_bcma(); 96 132 +#endif 97 133 + } -
trunk/target/linux/brcm47xx/patches-3.2/029-bcm47xx-read-nvram-from-sflash.patch
r30942 r31126 1 From 1d693b2c9d5943cbe938f879041b837cd004737f Mon Sep 17 00:00:00 20012 From: Hauke Mehrtens <hauke@hauke-m.de>3 Date: Sat, 23 Jul 2011 18:29:38 +02004 Subject: [PATCH 25/26] bcm47xx: read nvram from sflash5 6 bcm47xx: add sflash support to nvram7 8 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>9 ---10 arch/mips/bcm47xx/nvram.c | 86 +++++++++++++++++++++++++++++++++++++++++++-11 1 files changed, 84 insertions(+), 2 deletions(-)12 13 1 --- a/arch/mips/bcm47xx/nvram.c 14 2 +++ b/arch/mips/bcm47xx/nvram.c … … 27 15 #ifdef CONFIG_BCM47XX_SSB 28 16 struct ssb_chipcommon *ssb_cc; 29 @@ -86,7 +87,88 @@ found: 17 @@ -50,9 +51,6 @@ static void early_nvram_init(void) 18 #ifdef CONFIG_BCM47XX_BCMA 19 case BCM47XX_BUS_TYPE_BCMA: 20 bcma_cc = &bcm47xx_bus.bcma.bus.drv_cc; 21 - if (bcma_cc->flash_type != BCMA_PFLASH) 22 - return; 23 - 24 base = bcma_cc->pflash.window; 25 lim = bcma_cc->pflash.window_size; 26 break; 27 @@ -86,7 +84,106 @@ found: 30 28 for (i = 0; i < sizeof(struct nvram_header); i += 4) 31 29 *dst++ = *src++; … … 82 80 +} 83 81 + 82 +#ifdef CONFIG_BCM47XX_SSB 83 +static void early_nvram_init_ssb(void) 84 +{ 85 + int err; 86 + 87 + switch (bcm47xx_bus.ssb.chipco.flash_type) { 88 + case SSB_PFLASH: 89 + early_nvram_init_pflash(); 90 + case SSB_SFLASH: 91 + err = early_nvram_init_sflash(); 92 + if (err < 0) 93 + printk(KERN_WARNING "can not read from flash: %i\n", err); 94 + default: 95 + printk(KERN_WARNING "unknow flash type\n"); 96 + } 97 +} 98 +#endif 99 + 100 +#ifdef CONFIG_BCM47XX_BCMA 101 +static void early_nvram_init_bcma(void) 102 +{ 103 + int err; 104 + 105 + switch (bcm47xx_bus.bcma.bus.drv_cc.flash_type) { 106 + case BCMA_PFLASH: 107 + early_nvram_init_pflash(); 108 + case BCMA_SFLASH: 109 + err = early_nvram_init_sflash(); 110 + if (err < 0) 111 + printk(KERN_WARNING "can not read from flash: %i\n", err); 112 + default: 113 + printk(KERN_WARNING "unknow flash type\n"); 114 + } 115 +} 116 +#endif 117 + 84 118 +static void early_nvram_init(void) 85 119 +{ 86 + int err = 0;87 +88 120 + switch (bcm47xx_bus_type) { 89 121 +#ifdef CONFIG_BCM47XX_SSB 90 122 + case BCM47XX_BUS_TYPE_SSB: 91 + if (bcm47xx_bus.ssb.chipco.flash_type == SSB_PFLASH) { 92 + early_nvram_init_pflash(); 93 + } else if (bcm47xx_bus.ssb.chipco.flash_type == SSB_SFLASH) { 94 + err = early_nvram_init_sflash(); 95 + if (err < 0) 96 + printk(KERN_WARNING "can not read from flash: %i\n", err); 97 + } else { 98 + printk(KERN_WARNING "unknow flash type\n"); 99 + } 123 + early_nvram_init_ssb(); 100 124 + break; 101 125 +#endif 102 126 +#ifdef CONFIG_BCM47XX_BCMA 103 127 + case BCM47XX_BUS_TYPE_BCMA: 104 + if (bcm47xx_bus.bcma.bus.drv_cc.flash_type == BCMA_PFLASH) { 105 + early_nvram_init_pflash(); 106 + } else if (bcm47xx_bus.bcma.bus.drv_cc.flash_type == BCMA_SFLASH) { 107 + err = early_nvram_init_sflash(); 108 + if (err < 0) 109 + printk(KERN_WARNING "can not read from flash: %i\n", err); 110 + } else { 111 + printk(KERN_WARNING "unknow flash type\n"); 112 + } 128 + early_nvram_init_bcma(); 113 129 + break; 114 130 +#endif -
trunk/target/linux/brcm47xx/patches-3.2/030-bcm47xx-bcma-nandflash.patch
r30943 r31126 1 --- a/arch/mips/bcm47xx/Kconfig 2 +++ b/arch/mips/bcm47xx/Kconfig 3 @@ -24,6 +24,7 @@ config BCM47XX_BCMA 4 select BCMA_DRIVER_MIPS 5 select BCMA_DRIVER_PCI_HOSTMODE if PCI 6 select BCMA_SFLASH 7 + select BCMA_NFLASH 8 default y 9 help 10 Add support for new Broadcom BCM47xx boards with Broadcom specific Advanced Microcontroller Bus. 1 11 --- a/arch/mips/bcm47xx/bus.c 2 12 +++ b/arch/mips/bcm47xx/bus.c … … 9 19 * This program is free software; you can redistribute it and/or modify it 10 20 * under the terms of the GNU General Public License as published by the 11 @@ - 92,3 +93,9 @@ void bcm47xx_sflash_struct_ssb_init(stru21 @@ -80,3 +81,9 @@ void bcm47xx_sflash_struct_ssb_init(stru 12 22 sflash->numblocks = scc->sflash.numblocks; 13 23 sflash->size = scc->sflash.size; … … 37 47 static char nvram_buf[NVRAM_SPACE]; 38 48 39 @@ -13 7,6 +139,51 @@ found:49 @@ -134,6 +136,51 @@ found: 40 50 return 0; 41 51 } … … 86 96 +} 87 97 + 88 static void early_nvram_init(void) 98 #ifdef CONFIG_BCM47XX_SSB 99 static void early_nvram_init_ssb(void) 89 100 { 90 int err = 0; 91 @@ -163,6 +210,10 @@ static void early_nvram_init(void) 92 err = early_nvram_init_sflash(); 93 if (err < 0) 94 printk(KERN_WARNING "can not read from flash: %i\n", err); 95 + } else if (bcm47xx_bus.bcma.bus.drv_cc.flash_type == BCMA_NFLASH) { 96 + err = early_nvram_init_nflash(); 97 + if (err < 0) 98 + printk(KERN_WARNING "can not read from nflash: %i\n", err); 99 } else { 100 printk(KERN_WARNING "unknow flash type\n"); 101 } 101 @@ -164,6 +211,10 @@ static void early_nvram_init_bcma(void) 102 err = early_nvram_init_sflash(); 103 if (err < 0) 104 printk(KERN_WARNING "can not read from flash: %i\n", err); 105 + case BCMA_NFLASH: 106 + err = early_nvram_init_nflash(); 107 + if (err < 0) 108 + printk(KERN_WARNING "can not read from nflash: %i\n", err); 109 default: 110 printk(KERN_WARNING "unknow flash type\n"); 111 } 102 112 --- a/arch/mips/bcm47xx/setup.c 103 113 +++ b/arch/mips/bcm47xx/setup.c … … 116 126 +struct bcm47xx_nflash bcm47xx_nflash; 117 127 128 static struct resource bcm47xx_pflash_resource = { 129 .name = "bcm47xx_pflash", 130 @@ -73,6 +75,19 @@ static struct platform_device bcm47xx_sf 131 .num_resources = 1, 132 }; 133 134 +static struct resource bcm47xx_nflash_resource = { 135 + .name = "bcm47xx_nflash", 136 + .start = 0, 137 + .end = 0, 138 + .flags = 0, 139 +}; 140 + 141 +static struct platform_device bcm47xx_nflash_dev = { 142 + .name = "bcm47xx_nflash", 143 + .resource = &bcm47xx_nflash_resource, 144 + .num_resources = 1, 145 +}; 146 + 118 147 static void bcm47xx_machine_restart(char *command) 119 148 { 120 @@ -325,6 +327,9 @@ static void __init bcm47xx_register_bcma 149 printk(KERN_ALERT "Please stand by while rebooting the system...\n"); 150 @@ -369,6 +384,9 @@ static void __init bcm47xx_register_bcma 121 151 122 152 if (bcm47xx_bus.bcma.bus.drv_cc.flash_type == BCMA_SFLASH) … … 126 156 + bcm47xx_nflash_struct_bcma_init(&bcm47xx_nflash, &bcm47xx_bus.bcma.bus.drv_cc); 127 157 } 128 #endif 129 130 @@ -395,6 +400,19 @@ static struct platform_device bcm47xx_sf 131 .num_resources = 1, 132 }; 133 134 +static struct resource bcm47xx_nflash_resource = { 135 + .name = "bcm47xx_nflash", 136 + .start = 0, 137 + .end = 0, 138 + .flags = 0, 139 +}; 140 + 141 +static struct platform_device bcm47xx_nflash_dev = { 142 + .name = "bcm47xx_nflash", 143 + .resource = &bcm47xx_nflash_resource, 144 + .num_resources = 1, 145 +}; 146 + 147 static int __init bcm47xx_register_flash(void) 148 { 149 #ifdef CONFIG_BCM47XX_SSB 150 @@ -429,6 +447,9 @@ static int __init bcm47xx_register_flash 151 } else if (drv_cc->flash_type == BCMA_SFLASH) { 152 bcm47xx_sflash_dev.dev.platform_data = &bcm47xx_sflash; 153 return platform_device_register(&bcm47xx_sflash_dev); 154 + } else if (drv_cc->flash_type == BCMA_NFLASH) { 155 + bcm47xx_nflash_dev.dev.platform_data = &bcm47xx_nflash; 156 + return platform_device_register(&bcm47xx_nflash_dev); 157 } else { 158 printk(KERN_ERR "No flash device found\n"); 159 return -1; 158 159 static int __init bcm47xx_register_flash_bcma(void) 160 @@ -383,6 +401,9 @@ static int __init bcm47xx_register_flash 161 case BCMA_SFLASH: 162 bcm47xx_sflash_dev.dev.platform_data = &bcm47xx_sflash; 163 return platform_device_register(&bcm47xx_sflash_dev); 164 + case BCMA_NFLASH: 165 + bcm47xx_nflash_dev.dev.platform_data = &bcm47xx_nflash; 166 + return platform_device_register(&bcm47xx_nflash_dev); 167 default: 168 printk(KERN_ERR "No flash device found\n"); 169 return -1; 160 170 --- a/arch/mips/include/asm/mach-bcm47xx/bus.h 161 171 +++ b/arch/mips/include/asm/mach-bcm47xx/bus.h … … 176 186 struct bcm47xx_sflash { 177 187 enum bcm47xx_bus_type sflash_type; 178 @@ -38,3 +40,18 @@ void bcm47xx_sflash_struct_bcma_init(str 188 @@ -29,11 +31,24 @@ struct bcm47xx_sflash { 189 u32 blocksize; /* Block size */ 190 u32 numblocks; /* Number of blocks */ 191 u32 size; /* Total size in bytes */ 192 - 193 - struct mtd_info *mtd; 194 }; 195 196 void bcm47xx_sflash_struct_bcma_init(struct bcm47xx_sflash *sflash, struct bcma_drv_cc *bcc); 179 197 void bcm47xx_sflash_struct_ssb_init(struct bcm47xx_sflash *sflash, struct ssb_chipcommon *scc); 180 198 … … 195 213 + 196 214 +extern struct bcm47xx_nflash bcm47xx_nflash; 215 --- a/drivers/bcma/Kconfig 216 +++ b/drivers/bcma/Kconfig 217 @@ -43,6 +43,11 @@ config BCMA_SFLASH 218 depends on BCMA_DRIVER_MIPS 219 default y 220 221 +config BCMA_NFLASH 222 + bool 223 + depends on BCMA_DRIVER_MIPS 224 + default y 225 + 226 config BCMA_DRIVER_MIPS 227 bool "BCMA Broadcom MIPS core driver" 228 depends on BCMA && MIPS 229 --- a/drivers/bcma/Makefile 230 +++ b/drivers/bcma/Makefile 231 @@ -1,6 +1,7 @@ 232 bcma-y += main.o scan.o core.o sprom.o 233 bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o 234 bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o 235 +bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o 236 bcma-y += driver_pci.o 237 bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o 238 bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o 197 239 --- a/drivers/bcma/bcma_private.h 198 240 +++ b/drivers/bcma/bcma_private.h … … 321 363 + if (bcma_nflash_offset_is_valid(cc, offset, len, mask)) 322 364 + return 1; 323 + 365 + 324 366 + /* disable partial page enable */ 325 367 + reg = bcma_cc_read32(cc, NAND_ACC_CONTROL); … … 350 392 +} 351 393 + 352 +/* Erase a region. Returns success (0) or failure (-1). 394 +/* Erase a region. Returns success (0) or failure (-1). 353 395 + * Poll for completion. 354 396 + */ … … 394 436 case BCMA_CC_FLASHT_STSER: 395 437 case BCMA_CC_FLASHT_ATSER: 396 --- a/drivers/bcma/Kconfig 397 +++ b/drivers/bcma/Kconfig 398 @@ -43,6 +43,11 @@ config BCMA_SFLASH 399 depends on BCMA_DRIVER_MIPS 400 default y 401 402 +config BCMA_NFLASH 403 + bool 404 + depends on BCMA_DRIVER_MIPS 438 --- a/drivers/mtd/nand/Kconfig 439 +++ b/drivers/mtd/nand/Kconfig 440 @@ -537,4 +537,12 @@ config MTD_NAND_FSMC 441 Enables support for NAND Flash chips on the ST Microelectronics 442 Flexible Static Memory Controller (FSMC) 443 444 +config MTD_NAND_BCM47XX 445 + tristate "bcm47xx nand flash support" 405 446 + default y 406 + 407 config BCMA_DRIVER_MIPS 408 bool "BCMA Broadcom MIPS core driver" 409 depends on BCMA && MIPS 410 --- a/drivers/bcma/Makefile 411 +++ b/drivers/bcma/Makefile 412 @@ -1,6 +1,7 @@ 413 bcma-y += main.o scan.o core.o sprom.o 414 bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o 415 bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o 416 +bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o 417 bcma-y += driver_pci.o 418 bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o 419 bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o 447 + depends on BCM47XX 448 + select MTD_PARTITIONS 449 + help 450 + Support for bcm47xx nand flash 451 + 452 endif # MTD_NAND 453 --- a/drivers/mtd/nand/Makefile 454 +++ b/drivers/mtd/nand/Makefile 455 @@ -49,5 +49,6 @@ obj-$(CONFIG_MTD_NAND_MPC5121_NFC) += mp 456 obj-$(CONFIG_MTD_NAND_RICOH) += r852.o 457 obj-$(CONFIG_MTD_NAND_JZ4740) += jz4740_nand.o 458 obj-$(CONFIG_MTD_NAND_GPMI_NAND) += gpmi-nand/ 459 +obj-$(CONFIG_MTD_NAND_BCM47XX) += bcm47xx_nand.o 460 461 nand-objs := nand_base.o nand_bbt.o 420 462 --- /dev/null 421 463 +++ b/drivers/mtd/nand/bcm47xx_nand.c … … 591 633 + } 592 634 + } 593 + 635 + 594 636 + /* Copy input data into holding block */ 595 637 + copy_len = min(len, blocksize - (offset & mask)); … … 640 682 + return 1; 641 683 + } 642 + 684 + 643 685 + return 0; 644 686 +} … … 705 747 + bcm47xx_erase(mtd, page_addr*pagesize, pagesize); 706 748 + break; 707 + 749 + 708 750 + case NAND_CMD_ERASE2: 709 751 + break; … … 712 754 + if (column > mtd->writesize) 713 755 + read_offset += (column - mtd->writesize); 714 + else 756 + else 715 757 + read_offset += column; 716 758 + break; … … 741 783 + 742 784 + if (nflash->next_opcode == NAND_CMD_STATUS) 743 + return NAND_STATUS_WP; 785 + return NAND_STATUS_WP; 744 786 + 745 787 + id = bcma_cc_read32(nflash->bcc, nflash->next_opcode); … … 880 922 + return ret; 881 923 + } 882 + 924 + 883 925 + return 0; 884 926 + … … 927 969 +MODULE_LICENSE("GPL"); 928 970 +MODULE_DESCRIPTION("BCM47XX NAND flash driver"); 929 --- a/drivers/mtd/nand/Kconfig930 +++ b/drivers/mtd/nand/Kconfig931 @@ -537,4 +537,12 @@ config MTD_NAND_FSMC932 Enables support for NAND Flash chips on the ST Microelectronics933 Flexible Static Memory Controller (FSMC)934 935 +config MTD_NAND_BCM47XX936 + tristate "bcm47xx nand flash support"937 + default y938 + depends on BCM47XX939 + select MTD_PARTITIONS940 + help941 + Support for bcm47xx nand flash942 +943 endif # MTD_NAND944 --- a/drivers/mtd/nand/Makefile945 +++ b/drivers/mtd/nand/Makefile946 @@ -49,5 +49,6 @@ obj-$(CONFIG_MTD_NAND_MPC5121_NFC) += mp947 obj-$(CONFIG_MTD_NAND_RICOH) += r852.o948 obj-$(CONFIG_MTD_NAND_JZ4740) += jz4740_nand.o949 obj-$(CONFIG_MTD_NAND_GPMI_NAND) += gpmi-nand/950 +obj-$(CONFIG_MTD_NAND_BCM47XX) += bcm47xx_nand.o951 952 nand-objs := nand_base.o nand_bbt.o953 971 --- a/include/linux/bcma/bcma_driver_chipcommon.h 954 972 +++ b/include/linux/bcma/bcma_driver_chipcommon.h … … 986 1004 987 1005 int nr_serial_ports; 988 @@ -48 3,4 +495,13 @@ int bcma_sflash_commit(struct bcma_drv_c989 const u8 *buf);1006 @@ -481,4 +493,13 @@ int bcma_sflash_write(struct bcma_drv_cc 1007 int bcma_sflash_erase(struct bcma_drv_cc *cc, u32 offset); 990 1008 #endif /* CONFIG_BCMA_SFLASH */ 991 1009 … … 1009 1027 + * Copyright (C) 2009, Broadcom Corporation 1010 1028 + * All Rights Reserved. 1011 + * 1029 + * 1012 1030 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY 1013 1031 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM -
trunk/target/linux/brcm47xx/patches-3.2/114-MIPS-BCM47xx-Setup-and-register-serial-early.patch
r30943 r31126 25 25 #include <asm/reboot.h> 26 26 #include <asm/time.h> 27 @@ - 281,6 +283,31 @@ static int bcm47xx_get_invariants(struct27 @@ -320,6 +322,31 @@ static int bcm47xx_get_invariants(struct 28 28 return 0; 29 29 } … … 57 57 { 58 58 int err; 59 @@ -3 13,6 +340,10 @@ static void __init bcm47xx_register_ssb(59 @@ -352,6 +379,10 @@ static void __init bcm47xx_register_ssb( 60 60 memcpy(&mcore->serial_ports[1], &port, sizeof(port)); 61 61 } … … 66 66 +#endif 67 67 } 68 #endif69 68 69 static int __init bcm47xx_register_flash_ssb(void) -
trunk/target/linux/brcm47xx/patches-3.2/197-MIPS-BCM47XX-return-number-of-written-bytes-in-nvram.patch
r31093 r31126 2 2 --- a/arch/mips/bcm47xx/nvram.c 3 3 +++ b/arch/mips/bcm47xx/nvram.c 4 @@ -2 43,8 +243,7 @@ int nvram_getenv(char *name, char *val,4 @@ -258,8 +258,7 @@ int nvram_getenv(char *name, char *val, 5 5 value = eq + 1; 6 6 if ((eq - var) == strlen(name) && -
trunk/target/linux/brcm47xx/patches-3.2/199-MIPS-BCM47XX-move-and-extend-sprom-parsing.patch
r31093 r31126 10 10 --- a/arch/mips/bcm47xx/setup.c 11 11 +++ b/arch/mips/bcm47xx/setup.c 12 @@ - 93,156 +93,7 @@ static void bcm47xx_machine_halt(void)12 @@ -132,156 +132,7 @@ static void bcm47xx_machine_halt(void) 13 13 } 14 14 -
trunk/target/linux/brcm47xx/patches-3.2/200-MIPS-BCM47XX-provide-sprom-to-bcma-bus.patch
r31093 r31126 10 10 * 11 11 * This program is free software; you can redistribute it and/or modify it 12 @@ - 93,7 +93,7 @@ static void bcm47xx_machine_halt(void)12 @@ -132,7 +132,7 @@ static void bcm47xx_machine_halt(void) 13 13 } 14 14 … … 19 19 char prefix[10]; 20 20 21 @@ -1 10,7 +110,7 @@ static int bcm47xx_get_sprom(struct ssb_21 @@ -149,7 +149,7 @@ static int bcm47xx_get_sprom(struct ssb_ 22 22 } 23 23 … … 28 28 char buf[20]; 29 29 30 @@ - 165,7 +165,7 @@ static void __init bcm47xx_register_ssb(30 @@ -204,7 +204,7 @@ static void __init bcm47xx_register_ssb( 31 31 char buf[100]; 32 32 struct ssb_mipscore *mcore; … … 37 37 printk(KERN_WARNING "bcm47xx: someone else already registered" 38 38 " a ssb SPROM callback handler (err %d)\n", err); 39 @@ - 199,10 +199,41 @@ static void __init bcm47xx_register_ssb(39 @@ -256,10 +256,41 @@ static int __init bcm47xx_register_flash 40 40 #endif 41 41 -
trunk/target/linux/brcm47xx/patches-3.2/231-bcma_reorder_sprom_fill.patch
r31093 r31126 1 1 --- a/arch/mips/bcm47xx/setup.c 2 2 +++ b/arch/mips/bcm47xx/setup.c 3 @@ - 98,6 +98,7 @@ static int bcm47xx_get_sprom_ssb(struct3 @@ -137,6 +137,7 @@ static int bcm47xx_get_sprom_ssb(struct 4 4 char prefix[10]; 5 5 … … 9 9 bus->host_pci->bus->number + 1, 10 10 PCI_SLOT(bus->host_pci->devfn)); 11 @@ -1 26,6 +127,7 @@ static int bcm47xx_get_invariants(struct11 @@ -165,6 +166,7 @@ static int bcm47xx_get_invariants(struct 12 12 if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0) 13 13 iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0); … … 17 17 18 18 if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0) 19 @@ -2 06,12 +208,14 @@ static int bcm47xx_get_sprom_bcma(struct19 @@ -263,12 +265,14 @@ static int bcm47xx_get_sprom_bcma(struct 20 20 21 21 switch (bus->hosttype) { -
trunk/target/linux/brcm47xx/patches-3.2/400-arch-bcm47xx.patch
r30943 r31126 1 1 --- a/arch/mips/bcm47xx/nvram.c 2 2 +++ b/arch/mips/bcm47xx/nvram.c 3 @@ -2 49,3 +249,30 @@ int nvram_getenv(char *name, char *val,3 @@ -264,3 +264,30 @@ int nvram_getenv(char *name, char *val, 4 4 return NVRAM_ERR_ENVNOTFOUND; 5 5 } … … 34 34 --- a/arch/mips/bcm47xx/setup.c 35 35 +++ b/arch/mips/bcm47xx/setup.c 36 @@ -3 76,3 +376,20 @@ static int __init bcm47xx_register_flash36 @@ -384,3 +384,20 @@ static int __init bcm47xx_register_flash 37 37 return -1; 38 38 } -
trunk/target/linux/brcm47xx/patches-3.2/820-wgt634u-nvram-fix.patch
r30943 r31126 255 255 /* Probe for NVRAM header */ 256 256 static void early_nvram_init_pflash(void) 257 @@ - 61,6 +63,25 @@ static void early_nvram_init_pflash(void257 @@ -58,6 +60,25 @@ static void early_nvram_init_pflash(void 258 258 break; 259 259 #endif … … 281 281 off = FLASH_MIN; 282 282 while (off <= lim) { 283 @@ -2 32,6 +253,12 @@ int nvram_getenv(char *name, char *val,283 @@ -247,6 +268,12 @@ int nvram_getenv(char *name, char *val, 284 284 if (!nvram_buf[0]) 285 285 early_nvram_init(); … … 294 294 var = &nvram_buf[sizeof(struct nvram_header)]; 295 295 end = nvram_buf + sizeof(nvram_buf) - 2; 296 @@ -2 60,6 +287,9 @@ char *nvram_get(const char *name)296 @@ -275,6 +302,9 @@ char *nvram_get(const char *name) 297 297 if (!nvram_buf[0]) 298 298 early_nvram_init(); -
trunk/target/linux/brcm47xx/patches-3.2/980-wnr834b_no_cardbus_invariant.patch
r30943 r31126 1 1 --- a/arch/mips/bcm47xx/setup.c 2 2 +++ b/arch/mips/bcm47xx/setup.c 3 @@ -1 33,6 +133,10 @@ static int bcm47xx_get_invariants(struct3 @@ -172,6 +172,10 @@ static int bcm47xx_get_invariants(struct 4 4 if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0) 5 5 iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
Note: See TracChangeset
for help on using the changeset viewer.