[brcm63xx] update livebox board support (#8677)
[openwrt.git] / target / linux / brcm63xx / patches-3.3 / 308-MIPS-BCM63XX-move-flash-registration-out-of-board_bc.patch
1 From b620329db3d6646a172a599b0e960baca081fff1 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Sat, 12 Nov 2011 11:17:32 +0100
4 Subject: [PATCH 25/79] MIPS: BCM63XX: move flash registration out of
5  board_bcm963xx.c
6
7 board_bcm963xx.c is already large enough.
8
9 Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
10 ---
11  arch/mips/bcm63xx/Makefile                         |    4 +-
12  arch/mips/bcm63xx/boards/board_bcm963xx.c          |   49 +-------------
13  arch/mips/bcm63xx/dev-flash.c                      |   68 ++++++++++++++++++++
14  .../include/asm/mach-bcm63xx/bcm63xx_dev_flash.h   |    6 ++
15  4 files changed, 78 insertions(+), 49 deletions(-)
16  create mode 100644 arch/mips/bcm63xx/dev-flash.c
17  create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
18
19 --- a/arch/mips/bcm63xx/Makefile
20 +++ b/arch/mips/bcm63xx/Makefile
21 @@ -1,6 +1,6 @@
22  obj-y          += clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \
23 -                  dev-dsp.o dev-enet.o dev-pcmcia.o dev-spi.o dev-trng.o \
24 -                  dev-uart.o dev-wdt.o
25 +                  dev-dsp.o dev-enet.o dev-flash.o dev-pcmcia.o dev-spi.o \
26 +                  dev-trng.o dev-uart.o dev-wdt.o
27  obj-$(CONFIG_EARLY_PRINTK)     += early_printk.o
28  
29  obj-y          += boards/
30 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
31 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
32 @@ -11,9 +11,6 @@
33  #include <linux/kernel.h>
34  #include <linux/string.h>
35  #include <linux/platform_device.h>
36 -#include <linux/mtd/mtd.h>
37 -#include <linux/mtd/partitions.h>
38 -#include <linux/mtd/physmap.h>
39  #include <linux/ssb/ssb.h>
40  #include <linux/gpio_keys.h>
41  #include <linux/input.h>
42 @@ -27,6 +24,7 @@
43  #include <bcm63xx_dev_pci.h>
44  #include <bcm63xx_dev_enet.h>
45  #include <bcm63xx_dev_dsp.h>
46 +#include <bcm63xx_dev_flash.h>
47  #include <bcm63xx_dev_pcmcia.h>
48  #include <bcm63xx_dev_spi.h>
49  #include <board_bcm963xx.h>
50 @@ -866,40 +864,6 @@ void __init board_setup(void)
51                 panic("unexpected CPU for bcm963xx board");
52  }
53  
54 -static struct mtd_partition mtd_partitions[] = {
55 -       {
56 -               .name           = "cfe",
57 -               .offset         = 0x0,
58 -               .size           = 0x40000,
59 -       }
60 -};
61 -
62 -static const char *bcm63xx_part_types[] = { "bcm63xxpart", NULL };
63 -
64 -static struct physmap_flash_data flash_data = {
65 -       .width                  = 2,
66 -       .nr_parts               = ARRAY_SIZE(mtd_partitions),
67 -       .parts                  = mtd_partitions,
68 -       .part_probe_types       = bcm63xx_part_types,
69 -};
70 -
71 -static struct resource mtd_resources[] = {
72 -       {
73 -               .start          = 0,    /* filled at runtime */
74 -               .end            = 0,    /* filled at runtime */
75 -               .flags          = IORESOURCE_MEM,
76 -       }
77 -};
78 -
79 -static struct platform_device mtd_dev = {
80 -       .name                   = "physmap-flash",
81 -       .resource               = mtd_resources,
82 -       .num_resources          = ARRAY_SIZE(mtd_resources),
83 -       .dev                    = {
84 -               .platform_data  = &flash_data,
85 -       },
86 -};
87 -
88  static struct gpio_led_platform_data bcm63xx_led_data;
89  
90  static struct platform_device bcm63xx_gpio_leds = {
91 @@ -923,7 +887,6 @@ static struct platform_device bcm63xx_gp
92   */
93  int __init board_register_devices(void)
94  {
95 -       u32 val;
96         int button_count = 0;
97         int led_count = 0;
98  
99 @@ -968,14 +931,7 @@ int __init board_register_devices(void)
100         if (board.num_spis)
101                 spi_register_board_info(board.spis, board.num_spis);
102  
103 -       /* read base address of boot chip select (0) */
104 -       val = bcm_mpi_readl(MPI_CSBASE_REG(0));
105 -       val &= MPI_CSBASE_BASE_MASK;
106 -
107 -       mtd_resources[0].start = val;
108 -       mtd_resources[0].end = 0x1FFFFFFF;
109 -
110 -       platform_device_register(&mtd_dev);
111 +       bcm63xx_flash_register();
112  
113         /* count number of LEDs defined by this device */
114         while (led_count < ARRAY_SIZE(board.leds) && board.leds[led_count].name)
115 --- /dev/null
116 +++ b/arch/mips/bcm63xx/dev-flash.c
117 @@ -0,0 +1,68 @@
118 +/*
119 + * Broadcom BCM63xx flash registration
120 + *
121 + * This file is subject to the terms and conditions of the GNU General Public
122 + * License.  See the file "COPYING" in the main directory of this archive
123 + * for more details.
124 + *
125 + * Copyright (C) 2009 Florian Fainelli <florian@openwrt.org>
126 + */
127 +
128 +#include <linux/init.h>
129 +#include <linux/kernel.h>
130 +#include <linux/platform_device.h>
131 +#include <linux/mtd/mtd.h>
132 +#include <linux/mtd/partitions.h>
133 +#include <linux/mtd/physmap.h>
134 +
135 +#include <bcm63xx_cpu.h>
136 +#include <bcm63xx_dev_flash.h>
137 +#include <bcm63xx_regs.h>
138 +#include <bcm63xx_io.h>
139 +
140 +static struct mtd_partition mtd_partitions[] = {
141 +       {
142 +               .name           = "cfe",
143 +               .offset         = 0x0,
144 +               .size           = 0x40000,
145 +       }
146 +};
147 +
148 +static const char *bcm63xx_part_types[] = { "bcm63xxpart", NULL };
149 +
150 +static struct physmap_flash_data flash_data = {
151 +       .width                  = 2,
152 +       .parts                  = mtd_partitions,
153 +       .part_probe_types       = bcm63xx_part_types,
154 +};
155 +
156 +static struct resource mtd_resources[] = {
157 +       {
158 +               .start          = 0,    /* filled at runtime */
159 +               .end            = 0,    /* filled at runtime */
160 +               .flags          = IORESOURCE_MEM,
161 +       }
162 +};
163 +
164 +static struct platform_device mtd_dev = {
165 +       .name                   = "physmap-flash",
166 +       .resource               = mtd_resources,
167 +       .num_resources          = ARRAY_SIZE(mtd_resources),
168 +       .dev                    = {
169 +               .platform_data  = &flash_data,
170 +       },
171 +};
172 +
173 +int __init bcm63xx_flash_register(void)
174 +{
175 +       u32 val;
176 +
177 +       /* read base address of boot chip select (0) */
178 +       val = bcm_mpi_readl(MPI_CSBASE_REG(0));
179 +       val &= MPI_CSBASE_BASE_MASK;
180 +
181 +       mtd_resources[0].start = val;
182 +       mtd_resources[0].end = 0x1FFFFFFF;
183 +
184 +       return platform_device_register(&mtd_dev);
185 +}
186 --- /dev/null
187 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
188 @@ -0,0 +1,6 @@
189 +#ifndef __BCM63XX_FLASH_H
190 +#define __BCM63XX_FLASH_H
191 +
192 +int __init bcm63xx_flash_register(void);
193 +
194 +#endif /* __BCM63XX_FLASH_H */