diff options
author | Jonas Gorski <jogo@openwrt.org> | 2012-05-27 13:22:25 +0000 |
---|---|---|
committer | Jonas Gorski <jogo@openwrt.org> | 2012-05-27 13:22:25 +0000 |
commit | bf8af3c6f2cfc9ceeb63a7feba96e79c67d0b8a6 (patch) | |
tree | 97b902da5264f12b623808ded78c4adc6480d33d /target/linux/brcm63xx/patches-3.3/309-MIPS-BCM63XX-add-flash-type-detection.patch | |
parent | afb39de7d0910eab1d54d9cab0da8bff7691889b (diff) | |
download | master-187ad058-bf8af3c6f2cfc9ceeb63a7feba96e79c67d0b8a6.tar.gz master-187ad058-bf8af3c6f2cfc9ceeb63a7feba96e79c67d0b8a6.tar.bz2 master-187ad058-bf8af3c6f2cfc9ceeb63a7feba96e79c67d0b8a6.zip |
bcm63xx: add flash type detection
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31877 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/brcm63xx/patches-3.3/309-MIPS-BCM63XX-add-flash-type-detection.patch')
-rw-r--r-- | target/linux/brcm63xx/patches-3.3/309-MIPS-BCM63XX-add-flash-type-detection.patch | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/target/linux/brcm63xx/patches-3.3/309-MIPS-BCM63XX-add-flash-type-detection.patch b/target/linux/brcm63xx/patches-3.3/309-MIPS-BCM63XX-add-flash-type-detection.patch new file mode 100644 index 0000000000..d8d3e247a8 --- /dev/null +++ b/target/linux/brcm63xx/patches-3.3/309-MIPS-BCM63XX-add-flash-type-detection.patch @@ -0,0 +1,130 @@ +From 0b2451b1cdab390b0b86c60a4765208bb2724d22 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski <jonas.gorski@gmail.com> +Date: Sat, 2 Jul 2011 14:44:28 +0200 +Subject: [PATCH 26/79] 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> +--- + arch/mips/bcm63xx/dev-flash.c | 60 ++++++++++++++++++-- + .../include/asm/mach-bcm63xx/bcm63xx_dev_flash.h | 6 ++ + arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h | 9 +++ + 3 files changed, 69 insertions(+), 6 deletions(-) + +--- a/arch/mips/bcm63xx/dev-flash.c ++++ b/arch/mips/bcm63xx/dev-flash.c +@@ -6,6 +6,7 @@ + * for more details. + * + * Copyright (C) 2009 Florian Fainelli <florian@openwrt.org> ++ * Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com> + */ + + #include <linux/init.h> +@@ -53,16 +54,63 @@ static struct platform_device mtd_dev = + }, + }; + +-int __init bcm63xx_flash_register(void) ++static int __init bcm63xx_detect_flash_type(void) + { + u32 val; + +- /* read base address of boot chip select (0) */ +- val = bcm_mpi_readl(MPI_CSBASE_REG(0)); +- val &= MPI_CSBASE_BASE_MASK; ++ switch (bcm63xx_get_cpu_id()) { ++ case BCM6338_CPU_ID: ++ case BCM6345_CPU_ID: ++ case BCM6348_CPU_ID: ++ /* no way to auto detect so assume parallel */ ++ return BCM63XX_FLASH_TYPE_PARALLEL; ++ case BCM6358_CPU_ID: ++ val = bcm_gpio_readl(GPIO_STRAPBUS_REG); ++ if (val & STRAPBUS_6358_BOOT_SEL_PARALLEL) ++ return BCM63XX_FLASH_TYPE_PARALLEL; ++ else ++ return BCM63XX_FLASH_TYPE_SERIAL; ++ case BCM6368_CPU_ID: ++ val = bcm_gpio_readl(GPIO_STRAPBUS_REG); ++ switch (val & STRAPBUS_6368_BOOT_SEL_MASK) { ++ case STRAPBUS_6368_BOOT_SEL_NAND: ++ return BCM63XX_FLASH_TYPE_NAND; ++ case STRAPBUS_6368_BOOT_SEL_SERIAL: ++ return BCM63XX_FLASH_TYPE_SERIAL; ++ case STRAPBUS_6368_BOOT_SEL_PARALLEL: ++ return BCM63XX_FLASH_TYPE_PARALLEL; ++ } ++ default: ++ return -EINVAL; ++ } ++} ++ ++int __init bcm63xx_flash_register(void) ++{ ++ int flash_type; ++ u32 val; + +- mtd_resources[0].start = val; +- mtd_resources[0].end = 0x1FFFFFFF; ++ flash_type = bcm63xx_detect_flash_type(); + +- return platform_device_register(&mtd_dev); ++ switch (flash_type) { ++ case BCM63XX_FLASH_TYPE_PARALLEL: ++ /* read base address of boot chip select (0) */ ++ val = bcm_mpi_readl(MPI_CSBASE_REG(0)); ++ val &= MPI_CSBASE_BASE_MASK; ++ ++ mtd_resources[0].start = val; ++ mtd_resources[0].end = 0x1FFFFFFF; ++ ++ return platform_device_register(&mtd_dev); ++ case BCM63XX_FLASH_TYPE_SERIAL: ++ pr_warn("unsupported serial flash detected\n"); ++ return -ENODEV; ++ case BCM63XX_FLASH_TYPE_NAND: ++ pr_warn("unsupported NAND flash detected\n"); ++ return -ENODEV; ++ default: ++ pr_err("flash detection failed for BCM%x: %d", ++ bcm63xx_get_cpu_id(), flash_type); ++ return -ENODEV; ++ } + } +--- 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 @@ + #ifndef __BCM63XX_FLASH_H + #define __BCM63XX_FLASH_H + ++enum { ++ BCM63XX_FLASH_TYPE_PARALLEL, ++ BCM63XX_FLASH_TYPE_SERIAL, ++ BCM63XX_FLASH_TYPE_NAND, ++}; ++ + int __init bcm63xx_flash_register(void); + + #endif /* __BCM63XX_FLASH_H */ +--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h ++++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h +@@ -508,6 +508,15 @@ + #define GPIO_BASEMODE_6368_MASK 0x7 + /* those bits must be kept as read in gpio basemode register*/ + ++#define GPIO_STRAPBUS_REG 0x40 ++#define STRAPBUS_6358_BOOT_SEL_PARALLEL (1 << 1) ++#define STRAPBUS_6358_BOOT_SEL_SERIAL (0 << 1) ++#define STRAPBUS_6368_BOOT_SEL_MASK 0x3 ++#define STRAPBUS_6368_BOOT_SEL_NAND 0 ++#define STRAPBUS_6368_BOOT_SEL_SERIAL 1 ++#define STRAPBUS_6368_BOOT_SEL_PARALLEL 3 ++ ++ + /************************************************************************* + * _REG relative to RSET_ENET + *************************************************************************/ |