aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ssb
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2013-01-28 14:43:00 -0500
committerJohn W. Linville <linville@tuxdriver.com>2013-01-28 14:43:00 -0500
commit4205e6ef4ee747aa81930537b6035086ba5f1e28 (patch)
treeb2ebe2b4621f5f531f283cb9bf0005cd3c04ca7b /drivers/ssb
parentcef401de7be8c4e155c6746bfccf721a4fa5fab9 (diff)
parent9ebea3829fac7505e0cd2642fbd13cfa9c038831 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next into for-davem
Diffstat (limited to 'drivers/ssb')
-rw-r--r--drivers/ssb/Kconfig5
-rw-r--r--drivers/ssb/Makefile1
-rw-r--r--drivers/ssb/driver_chipcommon_sflash.c140
-rw-r--r--drivers/ssb/driver_mipscore.c3
-rw-r--r--drivers/ssb/ssb_private.h11
5 files changed, 159 insertions, 1 deletions
diff --git a/drivers/ssb/Kconfig b/drivers/ssb/Kconfig
index 5d6f2ec1c705..5ff3a4f19443 100644
--- a/drivers/ssb/Kconfig
+++ b/drivers/ssb/Kconfig
@@ -136,6 +136,11 @@ config SSB_DRIVER_MIPS
136 136
137 If unsure, say N 137 If unsure, say N
138 138
139config SSB_SFLASH
140 bool "SSB serial flash support"
141 depends on SSB_DRIVER_MIPS && BROKEN
142 default y
143
139# Assumption: We are on embedded, if we compile the MIPS core. 144# Assumption: We are on embedded, if we compile the MIPS core.
140config SSB_EMBEDDED 145config SSB_EMBEDDED
141 bool 146 bool
diff --git a/drivers/ssb/Makefile b/drivers/ssb/Makefile
index 9159ba77c388..b1ddc116d387 100644
--- a/drivers/ssb/Makefile
+++ b/drivers/ssb/Makefile
@@ -11,6 +11,7 @@ ssb-$(CONFIG_SSB_SDIOHOST) += sdio.o
11# built-in drivers 11# built-in drivers
12ssb-y += driver_chipcommon.o 12ssb-y += driver_chipcommon.o
13ssb-y += driver_chipcommon_pmu.o 13ssb-y += driver_chipcommon_pmu.o
14ssb-$(CONFIG_SSB_SFLASH) += driver_chipcommon_sflash.o
14ssb-$(CONFIG_SSB_DRIVER_MIPS) += driver_mipscore.o 15ssb-$(CONFIG_SSB_DRIVER_MIPS) += driver_mipscore.o
15ssb-$(CONFIG_SSB_DRIVER_EXTIF) += driver_extif.o 16ssb-$(CONFIG_SSB_DRIVER_EXTIF) += driver_extif.o
16ssb-$(CONFIG_SSB_DRIVER_PCICORE) += driver_pcicore.o 17ssb-$(CONFIG_SSB_DRIVER_PCICORE) += driver_pcicore.o
diff --git a/drivers/ssb/driver_chipcommon_sflash.c b/drivers/ssb/driver_chipcommon_sflash.c
new file mode 100644
index 000000000000..720665ca2bb1
--- /dev/null
+++ b/drivers/ssb/driver_chipcommon_sflash.c
@@ -0,0 +1,140 @@
1/*
2 * Sonics Silicon Backplane
3 * ChipCommon serial flash interface
4 *
5 * Licensed under the GNU/GPL. See COPYING for details.
6 */
7
8#include <linux/ssb/ssb.h>
9
10#include "ssb_private.h"
11
12struct ssb_sflash_tbl_e {
13 char *name;
14 u32 id;
15 u32 blocksize;
16 u16 numblocks;
17};
18
19static struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = {
20 { "M25P20", 0x11, 0x10000, 4, },
21 { "M25P40", 0x12, 0x10000, 8, },
22
23 { "M25P16", 0x14, 0x10000, 32, },
24 { "M25P32", 0x15, 0x10000, 64, },
25 { "M25P64", 0x16, 0x10000, 128, },
26 { "M25FL128", 0x17, 0x10000, 256, },
27 { 0 },
28};
29
30static struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = {
31 { "SST25WF512", 1, 0x1000, 16, },
32 { "SST25VF512", 0x48, 0x1000, 16, },
33 { "SST25WF010", 2, 0x1000, 32, },
34 { "SST25VF010", 0x49, 0x1000, 32, },
35 { "SST25WF020", 3, 0x1000, 64, },
36 { "SST25VF020", 0x43, 0x1000, 64, },
37 { "SST25WF040", 4, 0x1000, 128, },
38 { "SST25VF040", 0x44, 0x1000, 128, },
39 { "SST25VF040B", 0x8d, 0x1000, 128, },
40 { "SST25WF080", 5, 0x1000, 256, },
41 { "SST25VF080B", 0x8e, 0x1000, 256, },
42 { "SST25VF016", 0x41, 0x1000, 512, },
43 { "SST25VF032", 0x4a, 0x1000, 1024, },
44 { "SST25VF064", 0x4b, 0x1000, 2048, },
45 { 0 },
46};
47
48static struct ssb_sflash_tbl_e ssb_sflash_at_tbl[] = {
49 { "AT45DB011", 0xc, 256, 512, },
50 { "AT45DB021", 0x14, 256, 1024, },
51 { "AT45DB041", 0x1c, 256, 2048, },
52 { "AT45DB081", 0x24, 256, 4096, },
53 { "AT45DB161", 0x2c, 512, 4096, },
54 { "AT45DB321", 0x34, 512, 8192, },
55 { "AT45DB642", 0x3c, 1024, 8192, },
56 { 0 },
57};
58
59static void ssb_sflash_cmd(struct ssb_chipcommon *cc, u32 opcode)
60{
61 int i;
62 chipco_write32(cc, SSB_CHIPCO_FLASHCTL,
63 SSB_CHIPCO_FLASHCTL_START | opcode);
64 for (i = 0; i < 1000; i++) {
65 if (!(chipco_read32(cc, SSB_CHIPCO_FLASHCTL) &
66 SSB_CHIPCO_FLASHCTL_BUSY))
67 return;
68 cpu_relax();
69 }
70 pr_err("SFLASH control command failed (timeout)!\n");
71}
72
73/* Initialize serial flash access */
74int ssb_sflash_init(struct ssb_chipcommon *cc)
75{
76 struct ssb_sflash_tbl_e *e;
77 u32 id, id2;
78
79 switch (cc->capabilities & SSB_CHIPCO_CAP_FLASHT) {
80 case SSB_CHIPCO_FLASHT_STSER:
81 ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_ST_DP);
82
83 chipco_write32(cc, SSB_CHIPCO_FLASHADDR, 0);
84 ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_ST_RES);
85 id = chipco_read32(cc, SSB_CHIPCO_FLASHDATA);
86
87 chipco_write32(cc, SSB_CHIPCO_FLASHADDR, 1);
88 ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_ST_RES);
89 id2 = chipco_read32(cc, SSB_CHIPCO_FLASHDATA);
90
91 switch (id) {
92 case 0xbf:
93 for (e = ssb_sflash_sst_tbl; e->name; e++) {
94 if (e->id == id2)
95 break;
96 }
97 break;
98 case 0x13:
99 return -ENOTSUPP;
100 default:
101 for (e = ssb_sflash_st_tbl; e->name; e++) {
102 if (e->id == id)
103 break;
104 }
105 break;
106 }
107 if (!e->name) {
108 pr_err("Unsupported ST serial flash (id: 0x%X, id2: 0x%X)\n",
109 id, id2);
110 return -ENOTSUPP;
111 }
112
113 break;
114 case SSB_CHIPCO_FLASHT_ATSER:
115 ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_AT_STATUS);
116 id = chipco_read32(cc, SSB_CHIPCO_FLASHDATA) & 0x3c;
117
118 for (e = ssb_sflash_at_tbl; e->name; e++) {
119 if (e->id == id)
120 break;
121 }
122 if (!e->name) {
123 pr_err("Unsupported Atmel serial flash (id: 0x%X)\n",
124 id);
125 return -ENOTSUPP;
126 }
127
128 break;
129 default:
130 pr_err("Unsupported flash type\n");
131 return -ENOTSUPP;
132 }
133
134 pr_info("Found %s serial flash (blocksize: 0x%X, blocks: %d)\n",
135 e->name, e->blocksize, e->numblocks);
136
137 pr_err("Serial flash support is not implemented yet!\n");
138
139 return -ENOTSUPP;
140}
diff --git a/drivers/ssb/driver_mipscore.c b/drivers/ssb/driver_mipscore.c
index 5bd05b136d22..2a7684c90243 100644
--- a/drivers/ssb/driver_mipscore.c
+++ b/drivers/ssb/driver_mipscore.c
@@ -203,7 +203,8 @@ static void ssb_mips_flash_detect(struct ssb_mipscore *mcore)
203 switch (bus->chipco.capabilities & SSB_CHIPCO_CAP_FLASHT) { 203 switch (bus->chipco.capabilities & SSB_CHIPCO_CAP_FLASHT) {
204 case SSB_CHIPCO_FLASHT_STSER: 204 case SSB_CHIPCO_FLASHT_STSER:
205 case SSB_CHIPCO_FLASHT_ATSER: 205 case SSB_CHIPCO_FLASHT_ATSER:
206 pr_err("Serial flash not supported\n"); 206 pr_debug("Found serial flash\n");
207 ssb_sflash_init(&bus->chipco);
207 break; 208 break;
208 case SSB_CHIPCO_FLASHT_PARA: 209 case SSB_CHIPCO_FLASHT_PARA:
209 pr_debug("Found parallel flash\n"); 210 pr_debug("Found parallel flash\n");
diff --git a/drivers/ssb/ssb_private.h b/drivers/ssb/ssb_private.h
index 6c10b66c796c..77d942630750 100644
--- a/drivers/ssb/ssb_private.h
+++ b/drivers/ssb/ssb_private.h
@@ -217,6 +217,17 @@ extern u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
217 u32 ticks); 217 u32 ticks);
218extern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms); 218extern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
219 219
220/* driver_chipcommon_sflash.c */
221#ifdef CONFIG_SSB_SFLASH
222int ssb_sflash_init(struct ssb_chipcommon *cc);
223#else
224static inline int ssb_sflash_init(struct ssb_chipcommon *cc)
225{
226 pr_err("Serial flash not supported\n");
227 return 0;
228}
229#endif /* CONFIG_SSB_SFLASH */
230
220#ifdef CONFIG_SSB_DRIVER_EXTIF 231#ifdef CONFIG_SSB_DRIVER_EXTIF
221extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks); 232extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks);
222extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms); 233extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);