Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Rafał Miłecki and committed by
Kalle Valo
d6a3b51a 2e62f9b2

+78 -40
+5
drivers/bcma/Kconfig
··· 70 70 71 71 If unsure, say N 72 72 73 + config BCMA_PFLASH 74 + bool 75 + depends on BCMA_DRIVER_MIPS 76 + default y 77 + 73 78 config BCMA_SFLASH 74 79 bool 75 80 depends on BCMA_DRIVER_MIPS
+1
drivers/bcma/Makefile
··· 1 1 bcma-y += main.o scan.o core.o sprom.o 2 2 bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o 3 3 bcma-y += driver_chipcommon_b.o 4 + bcma-$(CONFIG_BCMA_PFLASH) += driver_chipcommon_pflash.o 4 5 bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o 5 6 bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o 6 7 bcma-$(CONFIG_BCMA_DRIVER_PCI) += driver_pci.o
+15 -3
drivers/bcma/bcma_private.h
··· 47 47 void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc); 48 48 void bcma_core_chipcommon_init(struct bcma_drv_cc *cc); 49 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 51 /* driver_chipcommon_b.c */ 55 52 int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb); ··· 57 60 void bcma_pmu_init(struct bcma_drv_cc *cc); 58 61 u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc); 59 62 u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc); 63 + 64 + /************************************************** 65 + * driver_chipcommon_sflash.c 66 + **************************************************/ 67 + 68 + #ifdef CONFIG_BCMA_PFLASH 69 + extern struct platform_device bcma_pflash_dev; 70 + int bcma_pflash_init(struct bcma_drv_cc *cc); 71 + #else 72 + static inline int bcma_pflash_init(struct bcma_drv_cc *cc) 73 + { 74 + bcma_err(cc->core->bus, "Parallel flash not supported\n"); 75 + return 0; 76 + } 77 + #endif /* CONFIG_BCMA_PFLASH */ 60 78 61 79 #ifdef CONFIG_BCMA_SFLASH 62 80 /* driver_chipcommon_sflash.c */
+49
drivers/bcma/driver_chipcommon_pflash.c
··· 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 + }
+1 -34
drivers/bcma/driver_mips.c
··· 14 14 15 15 #include <linux/bcma/bcma.h> 16 16 17 - #include <linux/mtd/physmap.h> 18 - #include <linux/platform_device.h> 19 17 #include <linux/serial.h> 20 18 #include <linux/serial_core.h> 21 19 #include <linux/serial_reg.h> ··· 28 30 BCMA_BOOT_DEV_PARALLEL, 29 31 BCMA_BOOT_DEV_SERIAL, 30 32 BCMA_BOOT_DEV_NAND, 31 - }; 32 - 33 - static const char * const part_probes[] = { "bcm47xxpart", NULL }; 34 - 35 - static struct physmap_flash_data bcma_pflash_data = { 36 - .part_probe_types = part_probes, 37 - }; 38 - 39 - static struct resource bcma_pflash_resource = { 40 - .name = "bcma_pflash", 41 - .flags = IORESOURCE_MEM, 42 - }; 43 - 44 - struct platform_device bcma_pflash_dev = { 45 - .name = "physmap-flash", 46 - .dev = { 47 - .platform_data = &bcma_pflash_data, 48 - }, 49 - .resource = &bcma_pflash_resource, 50 - .num_resources = 1, 51 33 }; 52 34 53 35 /* The 47162a0 hangs when reading MIPS DMP registers registers */ ··· 254 276 { 255 277 struct bcma_bus *bus = mcore->core->bus; 256 278 struct bcma_drv_cc *cc = &bus->drv_cc; 257 - struct bcma_pflash *pflash = &cc->pflash; 258 279 enum bcma_boot_dev boot_dev; 259 280 260 281 switch (cc->capabilities & BCMA_CC_CAP_FLASHT) { ··· 264 287 break; 265 288 case BCMA_CC_FLASHT_PARA: 266 289 bcma_debug(bus, "Found parallel flash\n"); 267 - pflash->present = true; 268 - 269 - if ((bcma_read32(cc->core, BCMA_CC_FLASH_CFG) & 270 - BCMA_CC_FLASH_CFG_DS) == 0) 271 - bcma_pflash_data.width = 1; 272 - else 273 - bcma_pflash_data.width = 2; 274 - 275 - bcma_pflash_resource.start = BCMA_SOC_FLASH2; 276 - bcma_pflash_resource.end = BCMA_SOC_FLASH2 + BCMA_SOC_FLASH2_SZ; 277 - 290 + bcma_pflash_init(cc); 278 291 break; 279 292 default: 280 293 bcma_err(bus, "Flash type not supported\n");
+1 -1
drivers/bcma/main.c
··· 350 350 bcma_register_core(bus, core); 351 351 } 352 352 353 - #ifdef CONFIG_BCMA_DRIVER_MIPS 353 + #ifdef CONFIG_BCMA_PFLASH 354 354 if (bus->drv_cc.pflash.present) { 355 355 err = platform_device_register(&bcma_pflash_dev); 356 356 if (err)
+6 -2
include/linux/bcma/bcma_driver_chipcommon.h
··· 576 576 u32 crystalfreq; /* The active crystal frequency (in kHz) */ 577 577 }; 578 578 579 - #ifdef CONFIG_BCMA_DRIVER_MIPS 579 + #ifdef CONFIG_BCMA_PFLASH 580 580 struct bcma_pflash { 581 581 bool present; 582 582 }; 583 + #endif 583 584 584 585 #ifdef CONFIG_BCMA_SFLASH 585 586 struct mtd_info; ··· 604 603 }; 605 604 #endif 606 605 606 + #ifdef CONFIG_BCMA_DRIVER_MIPS 607 607 struct bcma_serial_port { 608 608 void *regs; 609 609 unsigned long clockspeed; ··· 624 622 /* Fast Powerup Delay constant */ 625 623 u16 fast_pwrup_delay; 626 624 struct bcma_chipcommon_pmu pmu; 627 - #ifdef CONFIG_BCMA_DRIVER_MIPS 625 + #ifdef CONFIG_BCMA_PFLASH 628 626 struct bcma_pflash pflash; 627 + #endif 629 628 #ifdef CONFIG_BCMA_SFLASH 630 629 struct bcma_sflash sflash; 631 630 #endif ··· 634 631 struct bcma_nflash nflash; 635 632 #endif 636 633 634 + #ifdef CONFIG_BCMA_DRIVER_MIPS 637 635 int nr_serial_ports; 638 636 struct bcma_serial_port serial_ports[4]; 639 637 #endif /* CONFIG_BCMA_DRIVER_MIPS */