1 From f888824d352df894ab721a5ca067b0313500efe7 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Thu, 3 May 2012 12:17:54 +0200
4 Subject: [PATCH 38/59] MIPS: BCM63XX: store the flash type in global variable
7 arch/mips/bcm63xx/dev-flash.c | 36 +++++++++++++------
8 .../include/asm/mach-bcm63xx/bcm63xx_dev_flash.h | 2 +
9 2 files changed, 26 insertions(+), 12 deletions(-)
11 --- a/arch/mips/bcm63xx/dev-flash.c
12 +++ b/arch/mips/bcm63xx/dev-flash.c
14 #include <bcm63xx_regs.h>
15 #include <bcm63xx_io.h>
17 +int bcm63xx_attached_flash = -1;
19 static struct mtd_partition mtd_partitions[] = {
22 @@ -86,27 +88,31 @@ static int __init bcm63xx_detect_flash_t
23 bcm63xx_spi_flash_info[0].max_speed_hz = 16666667;
25 if (val & STRAPBUS_6328_BOOT_SEL_SERIAL)
26 - return BCM63XX_FLASH_TYPE_SERIAL;
27 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
29 - return BCM63XX_FLASH_TYPE_NAND;
30 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
35 /* no way to auto detect so assume parallel */
36 - return BCM63XX_FLASH_TYPE_PARALLEL;
37 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
41 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
42 if (val & STRAPBUS_6358_BOOT_SEL_PARALLEL)
43 - return BCM63XX_FLASH_TYPE_PARALLEL;
44 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
46 - return BCM63XX_FLASH_TYPE_SERIAL;
47 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
50 val = bcm_misc_readl(MISC_STRAPBUS_6362_REG);
51 if (val & STRAPBUS_6362_BOOT_SEL_SERIAL)
52 - return BCM63XX_FLASH_TYPE_SERIAL;
53 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
55 - return BCM63XX_FLASH_TYPE_NAND;
56 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
59 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
60 if (val & STRAPBUS_6368_SPI_CLK_FAST)
61 @@ -114,25 +120,32 @@ static int __init bcm63xx_detect_flash_t
63 switch (val & STRAPBUS_6368_BOOT_SEL_MASK) {
64 case STRAPBUS_6368_BOOT_SEL_NAND:
65 - return BCM63XX_FLASH_TYPE_NAND;
66 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
68 case STRAPBUS_6368_BOOT_SEL_SERIAL:
69 - return BCM63XX_FLASH_TYPE_SERIAL;
70 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
72 case STRAPBUS_6368_BOOT_SEL_PARALLEL:
73 - return BCM63XX_FLASH_TYPE_PARALLEL;
74 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
86 int __init bcm63xx_flash_register(void)
91 - flash_type = bcm63xx_detect_flash_type();
93 - switch (flash_type) {
94 + bcm63xx_detect_flash_type();
96 + switch (bcm63xx_attached_flash) {
97 case BCM63XX_FLASH_TYPE_PARALLEL:
98 /* read base address of boot chip select (0) */
99 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
100 @@ -156,7 +169,7 @@ int __init bcm63xx_flash_register(void)
103 pr_err("flash detection failed for BCM%x: %d\n",
104 - bcm63xx_get_cpu_id(), flash_type);
105 + bcm63xx_get_cpu_id(), bcm63xx_attached_flash);
109 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
110 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
111 @@ -7,6 +7,8 @@ enum {
112 BCM63XX_FLASH_TYPE_NAND,
115 +extern int bcm63xx_attached_flash;
117 int __init bcm63xx_flash_register(void);
119 #endif /* __BCM63XX_FLASH_H */