aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bcma
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2014-09-03 04:35:13 -0400
committerJohn W. Linville <linville@tuxdriver.com>2014-09-04 13:50:11 -0400
commit87fed556d08d21dd7dd3e0222c94c187e4c2d5e2 (patch)
treea5c774f9d7c8ee110eb322d12c7233da3867988c /drivers/bcma
parentd17ec4d55223d9487df195012762da6f85862d4c (diff)
bcma: get info about flash type SoC booted from
There is an ongoing work on cleaning MIPS's nvram support so it could be re-used on other platforms (bcm53xx to say precisely). This will require a bit of extra logic in bcma this patch implements. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/bcma')
-rw-r--r--drivers/bcma/driver_mips.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/drivers/bcma/driver_mips.c b/drivers/bcma/driver_mips.c
index 11115bbe115c..004d6aa671ce 100644
--- a/drivers/bcma/driver_mips.c
+++ b/drivers/bcma/driver_mips.c
@@ -21,6 +21,14 @@
21#include <linux/serial_reg.h> 21#include <linux/serial_reg.h>
22#include <linux/time.h> 22#include <linux/time.h>
23 23
24enum bcma_boot_dev {
25 BCMA_BOOT_DEV_UNK = 0,
26 BCMA_BOOT_DEV_ROM,
27 BCMA_BOOT_DEV_PARALLEL,
28 BCMA_BOOT_DEV_SERIAL,
29 BCMA_BOOT_DEV_NAND,
30};
31
24static const char * const part_probes[] = { "bcm47xxpart", NULL }; 32static const char * const part_probes[] = { "bcm47xxpart", NULL };
25 33
26static struct physmap_flash_data bcma_pflash_data = { 34static struct physmap_flash_data bcma_pflash_data = {
@@ -229,11 +237,51 @@ u32 bcma_cpu_clock(struct bcma_drv_mips *mcore)
229} 237}
230EXPORT_SYMBOL(bcma_cpu_clock); 238EXPORT_SYMBOL(bcma_cpu_clock);
231 239
240static enum bcma_boot_dev bcma_boot_dev(struct bcma_bus *bus)
241{
242 struct bcma_drv_cc *cc = &bus->drv_cc;
243 u8 cc_rev = cc->core->id.rev;
244
245 if (cc_rev == 42) {
246 struct bcma_device *core;
247
248 core = bcma_find_core(bus, BCMA_CORE_NS_ROM);
249 if (core) {
250 switch (bcma_aread32(core, BCMA_IOST) &
251 BCMA_NS_ROM_IOST_BOOT_DEV_MASK) {
252 case BCMA_NS_ROM_IOST_BOOT_DEV_NOR:
253 return BCMA_BOOT_DEV_SERIAL;
254 case BCMA_NS_ROM_IOST_BOOT_DEV_NAND:
255 return BCMA_BOOT_DEV_NAND;
256 case BCMA_NS_ROM_IOST_BOOT_DEV_ROM:
257 default:
258 return BCMA_BOOT_DEV_ROM;
259 }
260 }
261 } else {
262 if (cc_rev == 38) {
263 if (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT)
264 return BCMA_BOOT_DEV_NAND;
265 else if (cc->status & BIT(5))
266 return BCMA_BOOT_DEV_ROM;
267 }
268
269 if ((cc->capabilities & BCMA_CC_CAP_FLASHT) ==
270 BCMA_CC_FLASHT_PARA)
271 return BCMA_BOOT_DEV_PARALLEL;
272 else
273 return BCMA_BOOT_DEV_SERIAL;
274 }
275
276 return BCMA_BOOT_DEV_SERIAL;
277}
278
232static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore) 279static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
233{ 280{
234 struct bcma_bus *bus = mcore->core->bus; 281 struct bcma_bus *bus = mcore->core->bus;
235 struct bcma_drv_cc *cc = &bus->drv_cc; 282 struct bcma_drv_cc *cc = &bus->drv_cc;
236 struct bcma_pflash *pflash = &cc->pflash; 283 struct bcma_pflash *pflash = &cc->pflash;
284 enum bcma_boot_dev boot_dev;
237 285
238 switch (cc->capabilities & BCMA_CC_CAP_FLASHT) { 286 switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
239 case BCMA_CC_FLASHT_STSER: 287 case BCMA_CC_FLASHT_STSER:
@@ -269,6 +317,20 @@ static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
269 bcma_nflash_init(cc); 317 bcma_nflash_init(cc);
270 } 318 }
271 } 319 }
320
321 /* Determine flash type this SoC boots from */
322 boot_dev = bcma_boot_dev(bus);
323 switch (boot_dev) {
324 case BCMA_BOOT_DEV_PARALLEL:
325 case BCMA_BOOT_DEV_SERIAL:
326 /* TODO: Init NVRAM using BCMA_SOC_FLASH2 window */
327 break;
328 case BCMA_BOOT_DEV_NAND:
329 /* TODO: Init NVRAM using BCMA_SOC_FLASH1 window */
330 break;
331 default:
332 break;
333 }
272} 334}
273 335
274void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) 336void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)