diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2016-02-12 04:15:44 -0500 |
---|---|---|
committer | Kalle Valo <kvalo@codeaurora.org> | 2016-03-07 07:41:08 -0500 |
commit | d6a3b51ada68c2bd3e184f4729ce626a1721cf74 (patch) | |
tree | a328a3f4e2101ba5748ce468c3a622fcd2bbc79e /drivers/bcma | |
parent | 2e62f9b2a41e4ade1a0bb3c1bbda4defe4c67243 (diff) |
bcma: move parallel flash support to separated file
This follows the way of handling other flashes and cleans code a bit. As
next task we will want to move flash code to ChipCommon driver as:
1) Flash controllers are accesible using ChipCommon registers
2) This code isn't MIPS specific
This change prepares bcma for that.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/bcma')
-rw-r--r-- | drivers/bcma/Kconfig | 5 | ||||
-rw-r--r-- | drivers/bcma/Makefile | 1 | ||||
-rw-r--r-- | drivers/bcma/bcma_private.h | 18 | ||||
-rw-r--r-- | drivers/bcma/driver_chipcommon_pflash.c | 49 | ||||
-rw-r--r-- | drivers/bcma/driver_mips.c | 35 | ||||
-rw-r--r-- | drivers/bcma/main.c | 2 |
6 files changed, 72 insertions, 38 deletions
diff --git a/drivers/bcma/Kconfig b/drivers/bcma/Kconfig index 023d448ed3fa..efdc2ae8441a 100644 --- a/drivers/bcma/Kconfig +++ b/drivers/bcma/Kconfig | |||
@@ -70,6 +70,11 @@ config BCMA_DRIVER_MIPS | |||
70 | 70 | ||
71 | If unsure, say N | 71 | If unsure, say N |
72 | 72 | ||
73 | config BCMA_PFLASH | ||
74 | bool | ||
75 | depends on BCMA_DRIVER_MIPS | ||
76 | default y | ||
77 | |||
73 | config BCMA_SFLASH | 78 | config BCMA_SFLASH |
74 | bool | 79 | bool |
75 | depends on BCMA_DRIVER_MIPS | 80 | depends on BCMA_DRIVER_MIPS |
diff --git a/drivers/bcma/Makefile b/drivers/bcma/Makefile index f32af9b76bcd..087948a1d20d 100644 --- a/drivers/bcma/Makefile +++ b/drivers/bcma/Makefile | |||
@@ -1,6 +1,7 @@ | |||
1 | bcma-y += main.o scan.o core.o sprom.o | 1 | bcma-y += main.o scan.o core.o sprom.o |
2 | bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o | 2 | bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o |
3 | bcma-y += driver_chipcommon_b.o | 3 | bcma-y += driver_chipcommon_b.o |
4 | bcma-$(CONFIG_BCMA_PFLASH) += driver_chipcommon_pflash.o | ||
4 | bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o | 5 | bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o |
5 | bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o | 6 | bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o |
6 | bcma-$(CONFIG_BCMA_DRIVER_PCI) += driver_pci.o | 7 | bcma-$(CONFIG_BCMA_DRIVER_PCI) += driver_pci.o |
diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h index 7e4ddfb076d3..eda09090cb52 100644 --- a/drivers/bcma/bcma_private.h +++ b/drivers/bcma/bcma_private.h | |||
@@ -47,9 +47,6 @@ int bcma_sprom_get(struct bcma_bus *bus); | |||
47 | void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc); | 47 | void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc); |
48 | void bcma_core_chipcommon_init(struct bcma_drv_cc *cc); | 48 | void bcma_core_chipcommon_init(struct bcma_drv_cc *cc); |
49 | void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable); | 49 | void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable); |
50 | #ifdef CONFIG_BCMA_DRIVER_MIPS | ||
51 | extern struct platform_device bcma_pflash_dev; | ||
52 | #endif /* CONFIG_BCMA_DRIVER_MIPS */ | ||
53 | 50 | ||
54 | /* driver_chipcommon_b.c */ | 51 | /* driver_chipcommon_b.c */ |
55 | int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb); | 52 | int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb); |
@@ -61,6 +58,21 @@ void bcma_pmu_init(struct bcma_drv_cc *cc); | |||
61 | u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc); | 58 | u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc); |
62 | u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc); | 59 | u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc); |
63 | 60 | ||
61 | /************************************************** | ||
62 | * driver_chipcommon_sflash.c | ||
63 | **************************************************/ | ||
64 | |||
65 | #ifdef CONFIG_BCMA_PFLASH | ||
66 | extern struct platform_device bcma_pflash_dev; | ||
67 | int bcma_pflash_init(struct bcma_drv_cc *cc); | ||
68 | #else | ||
69 | static inline int bcma_pflash_init(struct bcma_drv_cc *cc) | ||
70 | { | ||
71 | bcma_err(cc->core->bus, "Parallel flash not supported\n"); | ||
72 | return 0; | ||
73 | } | ||
74 | #endif /* CONFIG_BCMA_PFLASH */ | ||
75 | |||
64 | #ifdef CONFIG_BCMA_SFLASH | 76 | #ifdef CONFIG_BCMA_SFLASH |
65 | /* driver_chipcommon_sflash.c */ | 77 | /* driver_chipcommon_sflash.c */ |
66 | int bcma_sflash_init(struct bcma_drv_cc *cc); | 78 | int bcma_sflash_init(struct bcma_drv_cc *cc); |
diff --git a/drivers/bcma/driver_chipcommon_pflash.c b/drivers/bcma/driver_chipcommon_pflash.c new file mode 100644 index 000000000000..3b497c9ee0d4 --- /dev/null +++ b/drivers/bcma/driver_chipcommon_pflash.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * Broadcom specific AMBA | ||
3 | * ChipCommon parallel flash | ||
4 | * | ||
5 | * Licensed under the GNU/GPL. See COPYING for details. | ||
6 | */ | ||
7 | |||
8 | #include "bcma_private.h" | ||
9 | |||
10 | #include <linux/bcma/bcma.h> | ||
11 | #include <linux/mtd/physmap.h> | ||
12 | #include <linux/platform_device.h> | ||
13 | |||
14 | static const char * const part_probes[] = { "bcm47xxpart", NULL }; | ||
15 | |||
16 | static struct physmap_flash_data bcma_pflash_data = { | ||
17 | .part_probe_types = part_probes, | ||
18 | }; | ||
19 | |||
20 | static struct resource bcma_pflash_resource = { | ||
21 | .name = "bcma_pflash", | ||
22 | .flags = IORESOURCE_MEM, | ||
23 | }; | ||
24 | |||
25 | struct platform_device bcma_pflash_dev = { | ||
26 | .name = "physmap-flash", | ||
27 | .dev = { | ||
28 | .platform_data = &bcma_pflash_data, | ||
29 | }, | ||
30 | .resource = &bcma_pflash_resource, | ||
31 | .num_resources = 1, | ||
32 | }; | ||
33 | |||
34 | int bcma_pflash_init(struct bcma_drv_cc *cc) | ||
35 | { | ||
36 | struct bcma_pflash *pflash = &cc->pflash; | ||
37 | |||
38 | pflash->present = true; | ||
39 | |||
40 | if (!(bcma_read32(cc->core, BCMA_CC_FLASH_CFG) & BCMA_CC_FLASH_CFG_DS)) | ||
41 | bcma_pflash_data.width = 1; | ||
42 | else | ||
43 | bcma_pflash_data.width = 2; | ||
44 | |||
45 | bcma_pflash_resource.start = BCMA_SOC_FLASH2; | ||
46 | bcma_pflash_resource.end = BCMA_SOC_FLASH2 + BCMA_SOC_FLASH2_SZ; | ||
47 | |||
48 | return 0; | ||
49 | } | ||
diff --git a/drivers/bcma/driver_mips.c b/drivers/bcma/driver_mips.c index 20c134c016dc..967b0e85e2cc 100644 --- a/drivers/bcma/driver_mips.c +++ b/drivers/bcma/driver_mips.c | |||
@@ -14,8 +14,6 @@ | |||
14 | 14 | ||
15 | #include <linux/bcma/bcma.h> | 15 | #include <linux/bcma/bcma.h> |
16 | 16 | ||
17 | #include <linux/mtd/physmap.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <linux/serial.h> | 17 | #include <linux/serial.h> |
20 | #include <linux/serial_core.h> | 18 | #include <linux/serial_core.h> |
21 | #include <linux/serial_reg.h> | 19 | #include <linux/serial_reg.h> |
@@ -32,26 +30,6 @@ enum bcma_boot_dev { | |||
32 | BCMA_BOOT_DEV_NAND, | 30 | BCMA_BOOT_DEV_NAND, |
33 | }; | 31 | }; |
34 | 32 | ||
35 | static const char * const part_probes[] = { "bcm47xxpart", NULL }; | ||
36 | |||
37 | static struct physmap_flash_data bcma_pflash_data = { | ||
38 | .part_probe_types = part_probes, | ||
39 | }; | ||
40 | |||
41 | static struct resource bcma_pflash_resource = { | ||
42 | .name = "bcma_pflash", | ||
43 | .flags = IORESOURCE_MEM, | ||
44 | }; | ||
45 | |||
46 | struct platform_device bcma_pflash_dev = { | ||
47 | .name = "physmap-flash", | ||
48 | .dev = { | ||
49 | .platform_data = &bcma_pflash_data, | ||
50 | }, | ||
51 | .resource = &bcma_pflash_resource, | ||
52 | .num_resources = 1, | ||
53 | }; | ||
54 | |||
55 | /* The 47162a0 hangs when reading MIPS DMP registers registers */ | 33 | /* The 47162a0 hangs when reading MIPS DMP registers registers */ |
56 | static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev) | 34 | static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev) |
57 | { | 35 | { |
@@ -276,7 +254,6 @@ static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore) | |||
276 | { | 254 | { |
277 | struct bcma_bus *bus = mcore->core->bus; | 255 | struct bcma_bus *bus = mcore->core->bus; |
278 | struct bcma_drv_cc *cc = &bus->drv_cc; | 256 | struct bcma_drv_cc *cc = &bus->drv_cc; |
279 | struct bcma_pflash *pflash = &cc->pflash; | ||
280 | enum bcma_boot_dev boot_dev; | 257 | enum bcma_boot_dev boot_dev; |
281 | 258 | ||
282 | switch (cc->capabilities & BCMA_CC_CAP_FLASHT) { | 259 | switch (cc->capabilities & BCMA_CC_CAP_FLASHT) { |
@@ -287,17 +264,7 @@ static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore) | |||
287 | break; | 264 | break; |
288 | case BCMA_CC_FLASHT_PARA: | 265 | case BCMA_CC_FLASHT_PARA: |
289 | bcma_debug(bus, "Found parallel flash\n"); | 266 | bcma_debug(bus, "Found parallel flash\n"); |
290 | pflash->present = true; | 267 | bcma_pflash_init(cc); |
291 | |||
292 | if ((bcma_read32(cc->core, BCMA_CC_FLASH_CFG) & | ||
293 | BCMA_CC_FLASH_CFG_DS) == 0) | ||
294 | bcma_pflash_data.width = 1; | ||
295 | else | ||
296 | bcma_pflash_data.width = 2; | ||
297 | |||
298 | bcma_pflash_resource.start = BCMA_SOC_FLASH2; | ||
299 | bcma_pflash_resource.end = BCMA_SOC_FLASH2 + BCMA_SOC_FLASH2_SZ; | ||
300 | |||
301 | break; | 268 | break; |
302 | default: | 269 | default: |
303 | bcma_err(bus, "Flash type not supported\n"); | 270 | bcma_err(bus, "Flash type not supported\n"); |
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c index c466f752b067..786be8fed39e 100644 --- a/drivers/bcma/main.c +++ b/drivers/bcma/main.c | |||
@@ -350,7 +350,7 @@ static int bcma_register_devices(struct bcma_bus *bus) | |||
350 | bcma_register_core(bus, core); | 350 | bcma_register_core(bus, core); |
351 | } | 351 | } |
352 | 352 | ||
353 | #ifdef CONFIG_BCMA_DRIVER_MIPS | 353 | #ifdef CONFIG_BCMA_PFLASH |
354 | if (bus->drv_cc.pflash.present) { | 354 | if (bus->drv_cc.pflash.present) { |
355 | err = platform_device_register(&bcma_pflash_dev); | 355 | err = platform_device_register(&bcma_pflash_dev); |
356 | if (err) | 356 | if (err) |