summaryrefslogtreecommitdiff
path: root/target/linux/brcm47xx/patches-3.0/0013-bcma-add-serial-flash-support-to-bcma.patch
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2011-08-04 20:04:54 +0000
committerHauke Mehrtens <hauke@hauke-m.de>2011-08-04 20:04:54 +0000
commit8428ebd8e84d4adef3267fc66c5d94105f79db15 (patch)
tree4c80f88d2fc88cb7f3c7e365eb58e8ad293dc3e3 /target/linux/brcm47xx/patches-3.0/0013-bcma-add-serial-flash-support-to-bcma.patch
parent85b858fae67e4659cb990601b13ccc2078c1dffd (diff)
downloadmtk-20170518-8428ebd8e84d4adef3267fc66c5d94105f79db15.zip
mtk-20170518-8428ebd8e84d4adef3267fc66c5d94105f79db15.tar.gz
mtk-20170518-8428ebd8e84d4adef3267fc66c5d94105f79db15.tar.bz2
brcm47xx: update patches
* this adds sflash support for ssb devices * the flash is now a platform device * minor updates SVN-Revision: 27902
Diffstat (limited to 'target/linux/brcm47xx/patches-3.0/0013-bcma-add-serial-flash-support-to-bcma.patch')
-rw-r--r--target/linux/brcm47xx/patches-3.0/0013-bcma-add-serial-flash-support-to-bcma.patch120
1 files changed, 63 insertions, 57 deletions
diff --git a/target/linux/brcm47xx/patches-3.0/0013-bcma-add-serial-flash-support-to-bcma.patch b/target/linux/brcm47xx/patches-3.0/0013-bcma-add-serial-flash-support-to-bcma.patch
index bcaf85b..14e5a3b 100644
--- a/target/linux/brcm47xx/patches-3.0/0013-bcma-add-serial-flash-support-to-bcma.patch
+++ b/target/linux/brcm47xx/patches-3.0/0013-bcma-add-serial-flash-support-to-bcma.patch
@@ -1,7 +1,7 @@
-From b5be6e3037650ff5615cb869f1972dea5a49bcb6 Mon Sep 17 00:00:00 2001
+From a62940e988526c881966a8c72cc28c95fca89f3c Mon Sep 17 00:00:00 2001
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Sun, 17 Jul 2011 14:53:07 +0200
-Subject: [PATCH 13/22] bcma: add serial flash support to bcma
+Subject: [PATCH 13/26] bcma: add serial flash support to bcma
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
@@ -9,10 +9,10 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
drivers/bcma/Kconfig | 5 +
drivers/bcma/Makefile | 1 +
drivers/bcma/bcma_private.h | 5 +
- drivers/bcma/driver_chipcommon_sflash.c | 554 +++++++++++++++++++++++++++
+ drivers/bcma/driver_chipcommon_sflash.c | 555 +++++++++++++++++++++++++++
drivers/bcma/driver_mips.c | 8 +-
include/linux/bcma/bcma_driver_chipcommon.h | 24 ++
- 6 files changed, 596 insertions(+), 1 deletions(-)
+ 6 files changed, 597 insertions(+), 1 deletions(-)
create mode 100644 drivers/bcma/driver_chipcommon_sflash.c
--- a/drivers/bcma/Kconfig
@@ -54,7 +54,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
extern int __init bcma_host_pci_init(void);
--- /dev/null
+++ b/drivers/bcma/driver_chipcommon_sflash.c
-@@ -0,0 +1,554 @@
+@@ -0,0 +1,555 @@
+/*
+ * Broadcom SiliconBackplane chipcommon serial flash interface
+ *
@@ -78,8 +78,8 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+{
+ bcma_cc_write32(cc, BCMA_CC_FLASHCTL,
+ BCMA_CC_FLASHCTL_START | opcode);
-+ while (bcma_cc_read32(cc, BCMA_CC_FLASHCTL)
-+ & BCMA_CC_FLASHCTL_BUSY);
++ while (bcma_cc_read32(cc, BCMA_CC_FLASHCTL) & BCMA_CC_FLASHCTL_BUSY)
++ ;
+}
+
+
@@ -95,7 +95,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+{
+ u32 id, id2;
+
-+ memset(&cc->flash.sflash, 0, sizeof(struct bcma_sflash));
++ memset(&cc->sflash, 0, sizeof(struct bcma_sflash));
+
+ switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
+ case BCMA_CC_FLASHT_STSER:
@@ -104,35 +104,35 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+ bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 0);
+ bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
+ id = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
-+ cc->flash.sflash.blocksize = 64 * 1024;
++ cc->sflash.blocksize = 64 * 1024;
+ switch (id) {
+ case 0x11:
+ /* ST M25P20 2 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 4;
++ cc->sflash.numblocks = 4;
+ break;
+ case 0x12:
+ /* ST M25P40 4 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 8;
++ cc->sflash.numblocks = 8;
+ break;
+ case 0x13:
+ /* ST M25P80 8 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 16;
++ cc->sflash.numblocks = 16;
+ break;
+ case 0x14:
+ /* ST M25P16 16 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 32;
++ cc->sflash.numblocks = 32;
+ break;
+ case 0x15:
+ /* ST M25P32 32 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 64;
++ cc->sflash.numblocks = 64;
+ break;
+ case 0x16:
+ /* ST M25P64 64 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 128;
++ cc->sflash.numblocks = 128;
+ break;
+ case 0x17:
+ /* ST M25FL128 128 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 256;
++ cc->sflash.numblocks = 256;
+ break;
+ case 0xbf:
+ /* All of the following flashes are SST with
@@ -140,7 +140,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+ * We'll have to revamp the way we identify them
+ * since RES is not eough to disambiguate them.
+ */
-+ cc->flash.sflash.blocksize = 4 * 1024;
++ cc->sflash.blocksize = 4 * 1024;
+ bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 1);
+ bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
+ id2 = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
@@ -149,19 +149,19 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+ /* SST25WF512 512 Kbit Serial Flash */
+ case 0x48:
+ /* SST25VF512 512 Kbit Serial Flash */
-+ cc->flash.sflash.numblocks = 16;
++ cc->sflash.numblocks = 16;
+ break;
+ case 2:
+ /* SST25WF010 1 Mbit Serial Flash */
+ case 0x49:
+ /* SST25VF010 1 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 32;
++ cc->sflash.numblocks = 32;
+ break;
+ case 3:
+ /* SST25WF020 2 Mbit Serial Flash */
+ case 0x43:
+ /* SST25VF020 2 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 64;
++ cc->sflash.numblocks = 64;
+ break;
+ case 4:
+ /* SST25WF040 4 Mbit Serial Flash */
@@ -169,25 +169,25 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+ /* SST25VF040 4 Mbit Serial Flash */
+ case 0x8d:
+ /* SST25VF040B 4 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 128;
++ cc->sflash.numblocks = 128;
+ break;
+ case 5:
+ /* SST25WF080 8 Mbit Serial Flash */
+ case 0x8e:
+ /* SST25VF080B 8 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 256;
++ cc->sflash.numblocks = 256;
+ break;
+ case 0x41:
+ /* SST25VF016 16 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 512;
++ cc->sflash.numblocks = 512;
+ break;
+ case 0x4a:
+ /* SST25VF032 32 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 1024;
++ cc->sflash.numblocks = 1024;
+ break;
+ case 0x4b:
+ /* SST25VF064 64 Mbit Serial Flash */
-+ cc->flash.sflash.numblocks = 2048;
++ cc->sflash.numblocks = 2048;
+ break;
+ }
+ break;
@@ -201,46 +201,46 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+ switch (id) {
+ case 0xc:
+ /* Atmel AT45DB011 1Mbit Serial Flash */
-+ cc->flash.sflash.blocksize = 256;
-+ cc->flash.sflash.numblocks = 512;
++ cc->sflash.blocksize = 256;
++ cc->sflash.numblocks = 512;
+ break;
+ case 0x14:
+ /* Atmel AT45DB021 2Mbit Serial Flash */
-+ cc->flash.sflash.blocksize = 256;
-+ cc->flash.sflash.numblocks = 1024;
++ cc->sflash.blocksize = 256;
++ cc->sflash.numblocks = 1024;
+ break;
+ case 0x1c:
+ /* Atmel AT45DB041 4Mbit Serial Flash */
-+ cc->flash.sflash.blocksize = 256;
-+ cc->flash.sflash.numblocks = 2048;
++ cc->sflash.blocksize = 256;
++ cc->sflash.numblocks = 2048;
+ break;
+ case 0x24:
+ /* Atmel AT45DB081 8Mbit Serial Flash */
-+ cc->flash.sflash.blocksize = 256;
-+ cc->flash.sflash.numblocks = 4096;
++ cc->sflash.blocksize = 256;
++ cc->sflash.numblocks = 4096;
+ break;
+ case 0x2c:
+ /* Atmel AT45DB161 16Mbit Serial Flash */
-+ cc->flash.sflash.blocksize = 512;
-+ cc->flash.sflash.numblocks = 4096;
++ cc->sflash.blocksize = 512;
++ cc->sflash.numblocks = 4096;
+ break;
+ case 0x34:
+ /* Atmel AT45DB321 32Mbit Serial Flash */
-+ cc->flash.sflash.blocksize = 512;
-+ cc->flash.sflash.numblocks = 8192;
++ cc->sflash.blocksize = 512;
++ cc->sflash.numblocks = 8192;
+ break;
+ case 0x3c:
+ /* Atmel AT45DB642 64Mbit Serial Flash */
-+ cc->flash.sflash.blocksize = 1024;
-+ cc->flash.sflash.numblocks = 8192;
++ cc->sflash.blocksize = 1024;
++ cc->sflash.numblocks = 8192;
+ break;
+ }
+ break;
+ }
+
-+ cc->flash.sflash.size = cc->flash.sflash.blocksize * cc->flash.sflash.numblocks;
++ cc->sflash.size = cc->sflash.blocksize * cc->sflash.numblocks;
+
-+ return cc->flash.sflash.size ? 0 : -ENODEV;
++ return cc->sflash.size ? 0 : -ENODEV;
+}
+
+/* Read len bytes starting at offset into buf. Returns number of bytes read. */
@@ -253,7 +253,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+ if (!len)
+ return 0;
+
-+ if ((offset + len) > cc->flash.sflash.size)
++ if ((offset + len) > cc->sflash.size)
+ return -EINVAL;
+
+ if ((len >= 4) && (offset & 3))
@@ -293,7 +293,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+/* Poll for command completion. Returns zero when complete. */
+int bcma_sflash_poll(struct bcma_drv_cc *cc, u32 offset)
+{
-+ if (offset >= cc->flash.sflash.size)
++ if (offset >= cc->sflash.size)
+ return -22;
+
+ switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
@@ -407,7 +407,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+static int sflash_at_write(struct bcma_drv_cc *cc, u32 offset, u32 len,
+ const u8 *buf)
+{
-+ struct bcma_sflash *sfl = &cc->flash.sflash;
++ struct bcma_sflash *sfl = &cc->sflash;
+ u32 page, byte, mask;
+ int ret = 0;
+ mask = sfl->blocksize - 1;
@@ -450,10 +450,10 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+ if (!len)
+ return 0;
+
-+ if ((offset + len) > cc->flash.sflash.size)
++ if ((offset + len) > cc->sflash.size)
+ return -EINVAL;
+
-+ sfl = &cc->flash.sflash;
++ sfl = &cc->sflash;
+ switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
+ case BCMA_CC_FLASHT_STSER:
+ do {
@@ -481,10 +481,10 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+{
+ struct bcma_sflash *sfl;
+
-+ if (offset >= cc->flash.sflash.size)
++ if (offset >= cc->sflash.size)
+ return -EINVAL;
+
-+ sfl = &cc->flash.sflash;
++ sfl = &cc->sflash;
+ switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
+ case BCMA_CC_FLASHT_STSER:
+ bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_WREN);
@@ -521,7 +521,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+ if (len <= 0)
+ return 0;
+
-+ sfl = &cc->flash.sflash;
++ sfl = &cc->sflash;
+ if ((offset + len) > sfl->size)
+ return -EINVAL;
+
@@ -592,7 +592,8 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+ goto done;
+ }
+
-+ while (bcma_sflash_poll(cc, cur_offset));
++ while (bcma_sflash_poll(cc, cur_offset))
++ ;
+
+ cur_offset += bytes;
+ cur_length -= bytes;
@@ -636,7 +637,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
};
struct bcma_pflash {
-@@ -366,8 +367,19 @@ struct bcma_pflash {
+@@ -366,6 +367,14 @@ struct bcma_pflash {
u32 window_size;
};
@@ -648,15 +649,20 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+};
+#endif /* CONFIG_BCMA_SFLASH */
+
- union bcma_flash {
- struct bcma_pflash pflash;
+ struct bcma_serial_port {
+ void *regs;
+ unsigned long clockspeed;
+@@ -388,6 +397,9 @@ struct bcma_drv_cc {
+ enum bcma_flash_type flash_type;
+ union {
+ struct bcma_pflash pflash;
+#ifdef CONFIG_BCMA_SFLASH
-+ struct bcma_sflash sflash;
++ struct bcma_sflash sflash;
+#endif /* CONFIG_BCMA_SFLASH */
- };
+ };
- struct bcma_serial_port {
-@@ -433,4 +445,16 @@ u32 bcma_chipco_gpio_polarity(struct bcm
+ int nr_serial_ports;
+@@ -431,4 +443,16 @@ u32 bcma_chipco_gpio_polarity(struct bcm
/* PMU support */
extern void bcma_pmu_init(struct bcma_drv_cc *cc);