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 @@ -81,7 +83,8 @@ static int __init bcm63xx_detect_flash_t
24 /* only support serial flash */
25 bcm63xx_spi_flash_info[0].max_speed_hz = 62500000;
26 - return BCM63XX_FLASH_TYPE_SERIAL;
27 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
30 val = bcm_misc_readl(MISC_STRAPBUS_6328_REG);
31 if (val & STRAPBUS_6328_HSSPI_CLK_FAST)
32 @@ -90,21 +93,24 @@ static int __init bcm63xx_detect_flash_t
33 bcm63xx_spi_flash_info[0].max_speed_hz = 16666667;
35 if (val & STRAPBUS_6328_BOOT_SEL_SERIAL)
36 - return BCM63XX_FLASH_TYPE_SERIAL;
37 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
39 - return BCM63XX_FLASH_TYPE_NAND;
40 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
45 /* no way to auto detect so assume parallel */
46 - return BCM63XX_FLASH_TYPE_PARALLEL;
47 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
51 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
52 if (val & STRAPBUS_6358_BOOT_SEL_PARALLEL)
53 - return BCM63XX_FLASH_TYPE_PARALLEL;
54 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
56 - return BCM63XX_FLASH_TYPE_SERIAL;
57 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
60 val = bcm_misc_readl(MISC_STRAPBUS_6362_REG);
61 if (val & STRAPBUS_6362_HSSPI_CLK_FAST)
62 @@ -113,9 +119,10 @@ static int __init bcm63xx_detect_flash_t
63 bcm63xx_spi_flash_info[0].max_speed_hz = 20000000;
65 if (val & STRAPBUS_6362_BOOT_SEL_SERIAL)
66 - return BCM63XX_FLASH_TYPE_SERIAL;
67 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
69 - return BCM63XX_FLASH_TYPE_NAND;
70 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
73 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
74 if (val & STRAPBUS_6368_SPI_CLK_FAST)
75 @@ -123,11 +130,16 @@ static int __init bcm63xx_detect_flash_t
77 switch (val & STRAPBUS_6368_BOOT_SEL_MASK) {
78 case STRAPBUS_6368_BOOT_SEL_NAND:
79 - return BCM63XX_FLASH_TYPE_NAND;
80 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
82 case STRAPBUS_6368_BOOT_SEL_SERIAL:
83 - return BCM63XX_FLASH_TYPE_SERIAL;
84 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
86 case STRAPBUS_6368_BOOT_SEL_PARALLEL:
87 - return BCM63XX_FLASH_TYPE_PARALLEL;
88 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
94 val = bcm_misc_readl(MISC_STRAPBUS_63268_REG);
95 @@ -137,22 +149,24 @@ static int __init bcm63xx_detect_flash_t
96 bcm63xx_spi_flash_info[0].max_speed_hz = 20000000;
98 if (val & STRAPBUS_63268_BOOT_SEL_SERIAL)
99 - return BCM63XX_FLASH_TYPE_SERIAL;
100 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
102 - return BCM63XX_FLASH_TYPE_NAND;
103 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
111 int __init bcm63xx_flash_register(void)
116 - flash_type = bcm63xx_detect_flash_type();
118 - switch (flash_type) {
119 + bcm63xx_detect_flash_type();
121 + switch (bcm63xx_attached_flash) {
122 case BCM63XX_FLASH_TYPE_PARALLEL:
123 /* read base address of boot chip select (0) */
124 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
125 @@ -177,7 +191,7 @@ int __init bcm63xx_flash_register(void)
128 pr_err("flash detection failed for BCM%x: %d\n",
129 - bcm63xx_get_cpu_id(), flash_type);
130 + bcm63xx_get_cpu_id(), bcm63xx_attached_flash);
134 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
135 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
136 @@ -7,6 +7,8 @@ enum {
137 BCM63XX_FLASH_TYPE_NAND,
140 +extern int bcm63xx_attached_flash;
142 int __init bcm63xx_flash_register(void);
144 #endif /* __BCM63XX_FLASH_H */