aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/bcm63xx/dev-flash.c
diff options
context:
space:
mode:
authorJonas Gorski <jonas.gorski@gmail.com>2012-07-24 10:33:11 -0400
committerRalf Baechle <ralf@linux-mips.org>2012-07-24 10:33:11 -0400
commitaaf3fedb56c95b419eda4c5392e03ad9b82c4847 (patch)
tree85a25757c0b049af11e7306cb72c9989e81c0c98 /arch/mips/bcm63xx/dev-flash.c
parent4b897d5483da5c3f3c4d52440a994aad574b62b4 (diff)
MIPS: BCM63XX: Add flash type detection
On BCM6358 and BCM6368 the attached flash type is exposed through a bootstrapping register. Use it for auto detecting the flash type on those and default to parallel flash for earlier SoCs. Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com> Cc: linux-mips@linux-mips.org Cc: Maxime Bizon <mbizon@freebox.fr> Cc: Florian Fainelli <florian@openwrt.org> Cc: Kevin Cernekee <cernekee@gmail.com> Patchwork: https://patchwork.linux-mips.org/patch/3954/ Reviewed-by: Florian Fainelli <florian@openwrt.org> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/bcm63xx/dev-flash.c')
-rw-r--r--arch/mips/bcm63xx/dev-flash.c60
1 files changed, 54 insertions, 6 deletions
diff --git a/arch/mips/bcm63xx/dev-flash.c b/arch/mips/bcm63xx/dev-flash.c
index af5273868baa..1051faedab2d 100644
--- a/arch/mips/bcm63xx/dev-flash.c
+++ b/arch/mips/bcm63xx/dev-flash.c
@@ -7,6 +7,7 @@
7 * 7 *
8 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> 8 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
9 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org> 9 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
10 * Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
10 */ 11 */
11 12
12#include <linux/init.h> 13#include <linux/init.h>
@@ -54,16 +55,63 @@ static struct platform_device mtd_dev = {
54 }, 55 },
55}; 56};
56 57
58static int __init bcm63xx_detect_flash_type(void)
59{
60 u32 val;
61
62 switch (bcm63xx_get_cpu_id()) {
63 case BCM6338_CPU_ID:
64 case BCM6345_CPU_ID:
65 case BCM6348_CPU_ID:
66 /* no way to auto detect so assume parallel */
67 return BCM63XX_FLASH_TYPE_PARALLEL;
68 case BCM6358_CPU_ID:
69 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
70 if (val & STRAPBUS_6358_BOOT_SEL_PARALLEL)
71 return BCM63XX_FLASH_TYPE_PARALLEL;
72 else
73 return BCM63XX_FLASH_TYPE_SERIAL;
74 case BCM6368_CPU_ID:
75 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
76 switch (val & STRAPBUS_6368_BOOT_SEL_MASK) {
77 case STRAPBUS_6368_BOOT_SEL_NAND:
78 return BCM63XX_FLASH_TYPE_NAND;
79 case STRAPBUS_6368_BOOT_SEL_SERIAL:
80 return BCM63XX_FLASH_TYPE_SERIAL;
81 case STRAPBUS_6368_BOOT_SEL_PARALLEL:
82 return BCM63XX_FLASH_TYPE_PARALLEL;
83 }
84 default:
85 return -EINVAL;
86 }
87}
88
57int __init bcm63xx_flash_register(void) 89int __init bcm63xx_flash_register(void)
58{ 90{
91 int flash_type;
59 u32 val; 92 u32 val;
60 93
61 /* read base address of boot chip select (0) */ 94 flash_type = bcm63xx_detect_flash_type();
62 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
63 val &= MPI_CSBASE_BASE_MASK;
64 95
65 mtd_resources[0].start = val; 96 switch (flash_type) {
66 mtd_resources[0].end = 0x1FFFFFFF; 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 val &= MPI_CSBASE_BASE_MASK;
67 101
68 return platform_device_register(&mtd_dev); 102 mtd_resources[0].start = val;
103 mtd_resources[0].end = 0x1FFFFFFF;
104
105 return platform_device_register(&mtd_dev);
106 case BCM63XX_FLASH_TYPE_SERIAL:
107 pr_warn("unsupported serial flash detected\n");
108 return -ENODEV;
109 case BCM63XX_FLASH_TYPE_NAND:
110 pr_warn("unsupported NAND flash detected\n");
111 return -ENODEV;
112 default:
113 pr_err("flash detection failed for BCM%x: %d\n",
114 bcm63xx_get_cpu_id(), flash_type);
115 return -ENODEV;
116 }
69} 117}