aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2012-08-12 07:08:05 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-08-21 16:05:53 -0400
commit371a00448f95adaa612cf1a0b31a11e7093bc706 (patch)
tree6ffb57fcb3050a54942ffd320c149780da41b841
parentd57ef3a6a2eeb88df47e892c66692e3f59722ffe (diff)
bcma: detect and register NAND flash device
Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/bcma/Kconfig2
-rw-r--r--drivers/bcma/bcma_private.h1
-rw-r--r--drivers/bcma/driver_chipcommon_nflash.c28
-rw-r--r--drivers/bcma/main.c8
-rw-r--r--include/linux/bcma/bcma_driver_chipcommon.h13
5 files changed, 48 insertions, 4 deletions
diff --git a/drivers/bcma/Kconfig b/drivers/bcma/Kconfig
index cf6e4dd22fd2..a533af218368 100644
--- a/drivers/bcma/Kconfig
+++ b/drivers/bcma/Kconfig
@@ -53,7 +53,7 @@ config BCMA_SFLASH
53 53
54config BCMA_NFLASH 54config BCMA_NFLASH
55 bool 55 bool
56 depends on BCMA_DRIVER_MIPS && BROKEN 56 depends on BCMA_DRIVER_MIPS
57 default y 57 default y
58 58
59config BCMA_DRIVER_GMAC_CMN 59config BCMA_DRIVER_GMAC_CMN
diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index 94bf07c54a43..169fc58427d3 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -66,6 +66,7 @@ static inline int bcma_sflash_init(struct bcma_drv_cc *cc)
66#ifdef CONFIG_BCMA_NFLASH 66#ifdef CONFIG_BCMA_NFLASH
67/* driver_chipcommon_nflash.c */ 67/* driver_chipcommon_nflash.c */
68int bcma_nflash_init(struct bcma_drv_cc *cc); 68int bcma_nflash_init(struct bcma_drv_cc *cc);
69extern struct platform_device bcma_nflash_dev;
69#else 70#else
70static inline int bcma_nflash_init(struct bcma_drv_cc *cc) 71static inline int bcma_nflash_init(struct bcma_drv_cc *cc)
71{ 72{
diff --git a/drivers/bcma/driver_chipcommon_nflash.c b/drivers/bcma/driver_chipcommon_nflash.c
index 574d62435bc2..9042781edec3 100644
--- a/drivers/bcma/driver_chipcommon_nflash.c
+++ b/drivers/bcma/driver_chipcommon_nflash.c
@@ -5,15 +5,37 @@
5 * Licensed under the GNU/GPL. See COPYING for details. 5 * Licensed under the GNU/GPL. See COPYING for details.
6 */ 6 */
7 7
8#include <linux/platform_device.h>
8#include <linux/bcma/bcma.h> 9#include <linux/bcma/bcma.h>
9#include <linux/bcma/bcma_driver_chipcommon.h>
10#include <linux/delay.h>
11 10
12#include "bcma_private.h" 11#include "bcma_private.h"
13 12
13struct platform_device bcma_nflash_dev = {
14 .name = "bcma_nflash",
15 .num_resources = 0,
16};
17
14/* Initialize NAND flash access */ 18/* Initialize NAND flash access */
15int bcma_nflash_init(struct bcma_drv_cc *cc) 19int bcma_nflash_init(struct bcma_drv_cc *cc)
16{ 20{
17 bcma_err(cc->core->bus, "NAND flash support is broken\n"); 21 struct bcma_bus *bus = cc->core->bus;
22
23 if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
24 cc->core->id.rev != 0x38) {
25 bcma_err(bus, "NAND flash on unsupported board!\n");
26 return -ENOTSUPP;
27 }
28
29 if (!(cc->capabilities & BCMA_CC_CAP_NFLASH)) {
30 bcma_err(bus, "NAND flash not present according to ChipCommon\n");
31 return -ENODEV;
32 }
33
34 cc->nflash.present = true;
35
36 /* Prepare platform device, but don't register it yet. It's too early,
37 * malloc (required by device_private_init) is not available yet. */
38 bcma_nflash_dev.dev.platform_data = &cc->nflash;
39
18 return 0; 40 return 0;
19} 41}
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index a501d259287c..a8f570d69075 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -145,6 +145,14 @@ static int bcma_register_cores(struct bcma_bus *bus)
145 } 145 }
146#endif 146#endif
147 147
148#ifdef CONFIG_BCMA_NFLASH
149 if (bus->drv_cc.nflash.present) {
150 err = platform_device_register(&bcma_nflash_dev);
151 if (err)
152 bcma_err(bus, "Error registering NAND flash\n");
153 }
154#endif
155
148 return 0; 156 return 0;
149} 157}
150 158
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
index bed89694c5f9..9810d4b29abf 100644
--- a/include/linux/bcma/bcma_driver_chipcommon.h
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -519,6 +519,16 @@ struct bcma_sflash {
519}; 519};
520#endif 520#endif
521 521
522#ifdef CONFIG_BCMA_NFLASH
523struct mtd_info;
524
525struct bcma_nflash {
526 bool present;
527
528 struct mtd_info *mtd;
529};
530#endif
531
522struct bcma_serial_port { 532struct bcma_serial_port {
523 void *regs; 533 void *regs;
524 unsigned long clockspeed; 534 unsigned long clockspeed;
@@ -542,6 +552,9 @@ struct bcma_drv_cc {
542#ifdef CONFIG_BCMA_SFLASH 552#ifdef CONFIG_BCMA_SFLASH
543 struct bcma_sflash sflash; 553 struct bcma_sflash sflash;
544#endif 554#endif
555#ifdef CONFIG_BCMA_NFLASH
556 struct bcma_nflash nflash;
557#endif
545 558
546 int nr_serial_ports; 559 int nr_serial_ports;
547 struct bcma_serial_port serial_ports[4]; 560 struct bcma_serial_port serial_ports[4];