parent
b0ffeb0021
commit
7dbb132c88
@ -0,0 +1,194 @@ |
||||
From b620329db3d6646a172a599b0e960baca081fff1 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jonas.gorski@gmail.com>
|
||||
Date: Sat, 12 Nov 2011 11:17:32 +0100
|
||||
Subject: [PATCH 25/79] MIPS: BCM63XX: move flash registration out of
|
||||
board_bcm963xx.c
|
||||
|
||||
board_bcm963xx.c is already large enough.
|
||||
|
||||
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
|
||||
---
|
||||
arch/mips/bcm63xx/Makefile | 4 +-
|
||||
arch/mips/bcm63xx/boards/board_bcm963xx.c | 49 +-------------
|
||||
arch/mips/bcm63xx/dev-flash.c | 68 ++++++++++++++++++++
|
||||
.../include/asm/mach-bcm63xx/bcm63xx_dev_flash.h | 6 ++
|
||||
4 files changed, 78 insertions(+), 49 deletions(-)
|
||||
create mode 100644 arch/mips/bcm63xx/dev-flash.c
|
||||
create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
|
||||
|
||||
--- a/arch/mips/bcm63xx/Makefile
|
||||
+++ b/arch/mips/bcm63xx/Makefile
|
||||
@@ -1,6 +1,6 @@
|
||||
obj-y += clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \
|
||||
- dev-dsp.o dev-enet.o dev-pcmcia.o dev-spi.o dev-trng.o \
|
||||
- dev-uart.o dev-wdt.o
|
||||
+ dev-dsp.o dev-enet.o dev-flash.o dev-pcmcia.o dev-spi.o \
|
||||
+ dev-trng.o dev-uart.o dev-wdt.o
|
||||
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
|
||||
|
||||
obj-y += boards/
|
||||
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
@@ -11,9 +11,6 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/platform_device.h>
|
||||
-#include <linux/mtd/mtd.h>
|
||||
-#include <linux/mtd/partitions.h>
|
||||
-#include <linux/mtd/physmap.h>
|
||||
#include <linux/ssb/ssb.h>
|
||||
#include <linux/gpio_keys.h>
|
||||
#include <linux/input.h>
|
||||
@@ -26,6 +23,7 @@
|
||||
#include <bcm63xx_dev_pci.h>
|
||||
#include <bcm63xx_dev_enet.h>
|
||||
#include <bcm63xx_dev_dsp.h>
|
||||
+#include <bcm63xx_dev_flash.h>
|
||||
#include <bcm63xx_dev_pcmcia.h>
|
||||
#include <bcm63xx_dev_spi.h>
|
||||
#include <board_bcm963xx.h>
|
||||
@@ -865,40 +863,6 @@ void __init board_setup(void)
|
||||
panic("unexpected CPU for bcm963xx board");
|
||||
}
|
||||
|
||||
-static struct mtd_partition mtd_partitions[] = {
|
||||
- {
|
||||
- .name = "cfe",
|
||||
- .offset = 0x0,
|
||||
- .size = 0x40000,
|
||||
- }
|
||||
-};
|
||||
-
|
||||
-static const char *bcm63xx_part_types[] = { "bcm63xxpart", NULL };
|
||||
-
|
||||
-static struct physmap_flash_data flash_data = {
|
||||
- .width = 2,
|
||||
- .nr_parts = ARRAY_SIZE(mtd_partitions),
|
||||
- .parts = mtd_partitions,
|
||||
- .part_probe_types = bcm63xx_part_types,
|
||||
-};
|
||||
-
|
||||
-static struct resource mtd_resources[] = {
|
||||
- {
|
||||
- .start = 0, /* filled at runtime */
|
||||
- .end = 0, /* filled at runtime */
|
||||
- .flags = IORESOURCE_MEM,
|
||||
- }
|
||||
-};
|
||||
-
|
||||
-static struct platform_device mtd_dev = {
|
||||
- .name = "physmap-flash",
|
||||
- .resource = mtd_resources,
|
||||
- .num_resources = ARRAY_SIZE(mtd_resources),
|
||||
- .dev = {
|
||||
- .platform_data = &flash_data,
|
||||
- },
|
||||
-};
|
||||
-
|
||||
static struct gpio_led_platform_data bcm63xx_led_data;
|
||||
|
||||
static struct platform_device bcm63xx_gpio_leds = {
|
||||
@@ -922,7 +886,6 @@ static struct platform_device bcm63xx_gp
|
||||
*/
|
||||
int __init board_register_devices(void)
|
||||
{
|
||||
- u32 val;
|
||||
int button_count = 0;
|
||||
int led_count = 0;
|
||||
|
||||
@@ -967,14 +930,7 @@ int __init board_register_devices(void)
|
||||
if (board.num_spis)
|
||||
spi_register_board_info(board.spis, board.num_spis);
|
||||
|
||||
- /* 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;
|
||||
-
|
||||
- platform_device_register(&mtd_dev);
|
||||
+ bcm63xx_flash_register();
|
||||
|
||||
/* count number of LEDs defined by this device */
|
||||
while (led_count < ARRAY_SIZE(board.leds) && board.leds[led_count].name)
|
||||
--- /dev/null
|
||||
+++ b/arch/mips/bcm63xx/dev-flash.c
|
||||
@@ -0,0 +1,68 @@
|
||||
+/*
|
||||
+ * Broadcom BCM63xx flash registration
|
||||
+ *
|
||||
+ * This file is subject to the terms and conditions of the GNU General Public
|
||||
+ * License. See the file "COPYING" in the main directory of this archive
|
||||
+ * for more details.
|
||||
+ *
|
||||
+ * Copyright (C) 2009 Florian Fainelli <florian@openwrt.org>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/mtd/mtd.h>
|
||||
+#include <linux/mtd/partitions.h>
|
||||
+#include <linux/mtd/physmap.h>
|
||||
+
|
||||
+#include <bcm63xx_cpu.h>
|
||||
+#include <bcm63xx_dev_flash.h>
|
||||
+#include <bcm63xx_regs.h>
|
||||
+#include <bcm63xx_io.h>
|
||||
+
|
||||
+static struct mtd_partition mtd_partitions[] = {
|
||||
+ {
|
||||
+ .name = "cfe",
|
||||
+ .offset = 0x0,
|
||||
+ .size = 0x40000,
|
||||
+ }
|
||||
+};
|
||||
+
|
||||
+static const char *bcm63xx_part_types[] = { "bcm63xxpart", NULL };
|
||||
+
|
||||
+static struct physmap_flash_data flash_data = {
|
||||
+ .width = 2,
|
||||
+ .parts = mtd_partitions,
|
||||
+ .part_probe_types = bcm63xx_part_types,
|
||||
+};
|
||||
+
|
||||
+static struct resource mtd_resources[] = {
|
||||
+ {
|
||||
+ .start = 0, /* filled at runtime */
|
||||
+ .end = 0, /* filled at runtime */
|
||||
+ .flags = IORESOURCE_MEM,
|
||||
+ }
|
||||
+};
|
||||
+
|
||||
+static struct platform_device mtd_dev = {
|
||||
+ .name = "physmap-flash",
|
||||
+ .resource = mtd_resources,
|
||||
+ .num_resources = ARRAY_SIZE(mtd_resources),
|
||||
+ .dev = {
|
||||
+ .platform_data = &flash_data,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+int __init bcm63xx_flash_register(void)
|
||||
+{
|
||||
+ u32 val;
|
||||
+
|
||||
+ /* 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);
|
||||
+}
|
||||
--- /dev/null
|
||||
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
|
||||
@@ -0,0 +1,6 @@
|
||||
+#ifndef __BCM63XX_FLASH_H
|
||||
+#define __BCM63XX_FLASH_H
|
||||
+
|
||||
+int __init bcm63xx_flash_register(void);
|
||||
+
|
||||
+#endif /* __BCM63XX_FLASH_H */
|
@ -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
|
||||
*************************************************************************/
|
Loading…
Reference in new issue