brcm63xx: add initial support for BCM63268
[openwrt/openwrt.git] / target / linux / brcm63xx / patches-3.10 / 415-MIPS-BCM63XX-store-the-flash-type-in-global-variable.patch
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
5
6 ---
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(-)
10
11 --- a/arch/mips/bcm63xx/dev-flash.c
12 +++ b/arch/mips/bcm63xx/dev-flash.c
13 @@ -25,6 +25,8 @@
14 #include <bcm63xx_regs.h>
15 #include <bcm63xx_io.h>
16
17 +int bcm63xx_attached_flash = -1;
18 +
19 static struct mtd_partition mtd_partitions[] = {
20 {
21 .name = "cfe",
22 @@ -86,21 +88,24 @@ static int __init bcm63xx_detect_flash_t
23 bcm63xx_spi_flash_info[0].max_speed_hz = 16666667;
24
25 if (val & STRAPBUS_6328_BOOT_SEL_SERIAL)
26 - return BCM63XX_FLASH_TYPE_SERIAL;
27 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
28 else
29 - return BCM63XX_FLASH_TYPE_NAND;
30 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
31 + break;
32 case BCM6338_CPU_ID:
33 case BCM6345_CPU_ID:
34 case BCM6348_CPU_ID:
35 /* no way to auto detect so assume parallel */
36 - return BCM63XX_FLASH_TYPE_PARALLEL;
37 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
38 + break;
39 case BCM3368_CPU_ID:
40 case BCM6358_CPU_ID:
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;
45 else
46 - return BCM63XX_FLASH_TYPE_SERIAL;
47 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
48 + break;
49 case BCM6362_CPU_ID:
50 val = bcm_misc_readl(MISC_STRAPBUS_6362_REG);
51 if (val & STRAPBUS_6362_HSSPI_CLK_FAST)
52 @@ -109,9 +114,10 @@ static int __init bcm63xx_detect_flash_t
53 bcm63xx_spi_flash_info[0].max_speed_hz = 20000000;
54
55 if (val & STRAPBUS_6362_BOOT_SEL_SERIAL)
56 - return BCM63XX_FLASH_TYPE_SERIAL;
57 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
58 else
59 - return BCM63XX_FLASH_TYPE_NAND;
60 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
61 + break;
62 case BCM6368_CPU_ID:
63 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
64 if (val & STRAPBUS_6368_SPI_CLK_FAST)
65 @@ -119,11 +125,16 @@ static int __init bcm63xx_detect_flash_t
66
67 switch (val & STRAPBUS_6368_BOOT_SEL_MASK) {
68 case STRAPBUS_6368_BOOT_SEL_NAND:
69 - return BCM63XX_FLASH_TYPE_NAND;
70 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
71 + break;
72 case STRAPBUS_6368_BOOT_SEL_SERIAL:
73 - return BCM63XX_FLASH_TYPE_SERIAL;
74 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
75 + break;
76 case STRAPBUS_6368_BOOT_SEL_PARALLEL:
77 - return BCM63XX_FLASH_TYPE_PARALLEL;
78 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
79 + break;
80 + default:
81 + return -EINVAL;
82 }
83 case BCM63268_CPU_ID:
84 val = bcm_misc_readl(MISC_STRAPBUS_63268_REG);
85 @@ -133,22 +144,24 @@ static int __init bcm63xx_detect_flash_t
86 bcm63xx_spi_flash_info[0].max_speed_hz = 20000000;
87
88 if (val & STRAPBUS_63268_BOOT_SEL_SERIAL)
89 - return BCM63XX_FLASH_TYPE_SERIAL;
90 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
91 else
92 - return BCM63XX_FLASH_TYPE_NAND;
93 + bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
94 default:
95 return -EINVAL;
96 }
97 +
98 + return 0;
99 }
100
101 int __init bcm63xx_flash_register(void)
102 {
103 - int flash_type;
104 u32 val;
105
106 - flash_type = bcm63xx_detect_flash_type();
107
108 - switch (flash_type) {
109 + bcm63xx_detect_flash_type();
110 +
111 + switch (bcm63xx_attached_flash) {
112 case BCM63XX_FLASH_TYPE_PARALLEL:
113 /* read base address of boot chip select (0) */
114 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
115 @@ -172,7 +185,7 @@ int __init bcm63xx_flash_register(void)
116 return -ENODEV;
117 default:
118 pr_err("flash detection failed for BCM%x: %d\n",
119 - bcm63xx_get_cpu_id(), flash_type);
120 + bcm63xx_get_cpu_id(), bcm63xx_attached_flash);
121 return -ENODEV;
122 }
123 }
124 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
125 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
126 @@ -7,6 +7,8 @@ enum {
127 BCM63XX_FLASH_TYPE_NAND,
128 };
129
130 +extern int bcm63xx_attached_flash;
131 +
132 int __init bcm63xx_flash_register(void);
133
134 #endif /* __BCM63XX_FLASH_H */