diff options
-rw-r--r-- | arch/mips/bcm63xx/dev-flash.c | 60 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h | 6 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h | 9 |
3 files changed, 69 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 | ||
58 | static 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 | |||
57 | int __init bcm63xx_flash_register(void) | 89 | int __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 | } |
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h index 8dcb54108c45..354b8481ec4a 100644 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h | |||
@@ -1,6 +1,12 @@ | |||
1 | #ifndef __BCM63XX_FLASH_H | 1 | #ifndef __BCM63XX_FLASH_H |
2 | #define __BCM63XX_FLASH_H | 2 | #define __BCM63XX_FLASH_H |
3 | 3 | ||
4 | enum { | ||
5 | BCM63XX_FLASH_TYPE_PARALLEL, | ||
6 | BCM63XX_FLASH_TYPE_SERIAL, | ||
7 | BCM63XX_FLASH_TYPE_NAND, | ||
8 | }; | ||
9 | |||
4 | int __init bcm63xx_flash_register(void); | 10 | int __init bcm63xx_flash_register(void); |
5 | 11 | ||
6 | #endif /* __BCM63XX_FLASH_H */ | 12 | #endif /* __BCM63XX_FLASH_H */ |
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h index 6a8df5635e79..849fd97e7798 100644 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h | |||
@@ -507,6 +507,15 @@ | |||
507 | #define GPIO_BASEMODE_6368_MASK 0x7 | 507 | #define GPIO_BASEMODE_6368_MASK 0x7 |
508 | /* those bits must be kept as read in gpio basemode register*/ | 508 | /* those bits must be kept as read in gpio basemode register*/ |
509 | 509 | ||
510 | #define GPIO_STRAPBUS_REG 0x40 | ||
511 | #define STRAPBUS_6358_BOOT_SEL_PARALLEL (1 << 1) | ||
512 | #define STRAPBUS_6358_BOOT_SEL_SERIAL (0 << 1) | ||
513 | #define STRAPBUS_6368_BOOT_SEL_MASK 0x3 | ||
514 | #define STRAPBUS_6368_BOOT_SEL_NAND 0 | ||
515 | #define STRAPBUS_6368_BOOT_SEL_SERIAL 1 | ||
516 | #define STRAPBUS_6368_BOOT_SEL_PARALLEL 3 | ||
517 | |||
518 | |||
510 | /************************************************************************* | 519 | /************************************************************************* |
511 | * _REG relative to RSET_ENET | 520 | * _REG relative to RSET_ENET |
512 | *************************************************************************/ | 521 | *************************************************************************/ |