linux-davinci git: update leopard patch since he have an offical machine ID now :)
[vuplus_openembedded] / packages / linux / linux-davinci / dm355-leopard / 0001-dm355-leopard-add-board-file-based-on-board-dm355-e.patch
1 From a04a493ead5afb10aafe2c0cf57bf9e3bf7aa844 Mon Sep 17 00:00:00 2001
2 From: Koen Kooi <koen@openembedded.org>
3 Date: Thu, 12 Mar 2009 14:15:42 -0300
4 Subject: [PATCH] dm355-leopard: add board file based on board-dm355-evm.c
5
6 ---
7  arch/arm/mach-davinci/Kconfig               |    8 +
8  arch/arm/mach-davinci/Makefile              |    2 +
9  arch/arm/mach-davinci/board-dm355-leopard.c |  295 +++++++++++++++++++++++++++
10  3 files changed, 305 insertions(+), 0 deletions(-)
11  create mode 100644 arch/arm/mach-davinci/board-dm355-leopard.c
12
13 diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
14 index 0010f2d..85424b8 100644
15 --- a/arch/arm/mach-davinci/Kconfig
16 +++ b/arch/arm/mach-davinci/Kconfig
17 @@ -50,6 +50,14 @@ config MACH_SFFSDR
18           Say Y here to select the Lyrtech Small Form Factor
19           Software Defined Radio (SFFSDR) board.
20  
21 +config MACH_DM355_LEOPARD
22 +       bool "TI DM355 Leopard board"
23 +       default n
24 +       depends on ARCH_DAVINCI_DM355
25 +       help
26 +         Configure this option to specify the whether the board used
27 +         for development is a DM355 Leopard board.
28 +
29  config DAVINCI_MUX
30         bool "DAVINCI multiplexing support"
31         depends on ARCH_DAVINCI
32 diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile
33 index 6783681..96ef484 100644
34 --- a/arch/arm/mach-davinci/Makefile
35 +++ b/arch/arm/mach-davinci/Makefile
36 @@ -19,3 +19,5 @@ obj-$(CONFIG_MACH_DAVINCI_EVM)        += board-dm644x-evm.o
37  obj-$(CONFIG_MACH_DAVINCI_DM646X_EVM)  += board-dm646x-evm.o
38  obj-$(CONFIG_MACH_DAVINCI_DM355_EVM)   += board-dm355-evm.o
39  obj-$(CONFIG_MACH_SFFSDR)              += board-sffsdr.o
40 +obj-$(CONFIG_MACH_DM355_LEOPARD)       += board-dm355-leopard.o
41 +
42 diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c b/arch/arm/mach-davinci/board-dm355-leopard.c
43 new file mode 100644
44 index 0000000..a1e97e8
45 --- /dev/null
46 +++ b/arch/arm/mach-davinci/board-dm355-leopard.c
47 @@ -0,0 +1,295 @@
48 +/*
49 + * TI DM355 leopard board support
50 + *
51 + * Based on board-dm355-evm.c
52 + *
53 + * This file is licensed under the terms of the GNU General Public 
54 + * License version 2. This program is licensed "as is" without any
55 + * warranty of any kind, whether express or implied.
56 + */
57 +#include <linux/kernel.h>
58 +#include <linux/module.h>
59 +#include <linux/init.h>
60 +#include <linux/dma-mapping.h>
61 +#include <linux/platform_device.h>
62 +#include <linux/mtd/mtd.h>
63 +#include <linux/mtd/partitions.h>
64 +#include <linux/mtd/nand.h>
65 +#include <linux/i2c.h>
66 +#include <linux/io.h>
67 +#include <linux/gpio.h>
68 +#include <linux/clk.h>
69 +#include <linux/spi/spi.h>
70 +#include <linux/spi/eeprom.h>
71 +
72 +#include <asm/setup.h>
73 +#include <asm/mach-types.h>
74 +#include <asm/mach/arch.h>
75 +#include <asm/mach/map.h>
76 +#include <asm/mach/flash.h>
77 +
78 +#include <mach/hardware.h>
79 +#include <mach/dm355.h>
80 +#include <mach/psc.h>
81 +#include <mach/common.h>
82 +#include <mach/emac.h>
83 +#include <mach/i2c.h>
84 +#include <mach/serial.h>
85 +#include <mach/nand.h>
86 +#include <mach/mmc.h>
87 +
88 +#define DAVINCI_ASYNC_EMIF_CONTROL_BASE                0x01e10000
89 +#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE       0x02000000
90 +
91 +/* NOTE:  this is geared for the standard config, with a socketed
92 + * 2 GByte Micron NAND (MT29F16G08FAA) using 128KB sectors.  If you
93 + * swap chips, maybe with a different block size, partitioning may
94 + * need to be changed.
95 + */
96 +#define NAND_BLOCK_SIZE                SZ_128K
97 +
98 +static struct mtd_partition davinci_nand_partitions[] = {
99 +       {
100 +               /* UBL (a few copies) plus U-Boot */
101 +               .name           = "bootloader",
102 +               .offset         = 0,
103 +               .size           = 15 * NAND_BLOCK_SIZE,
104 +               .mask_flags     = MTD_WRITEABLE, /* force read-only */
105 +       }, {
106 +               /* U-Boot environment */
107 +               .name           = "params",
108 +               .offset         = MTDPART_OFS_APPEND,
109 +               .size           = 1 * NAND_BLOCK_SIZE,
110 +               .mask_flags     = 0,
111 +       }, {
112 +               .name           = "kernel",
113 +               .offset         = MTDPART_OFS_APPEND,
114 +               .size           = SZ_4M,
115 +               .mask_flags     = 0,
116 +       }, {
117 +               .name           = "filesystem1",
118 +               .offset         = MTDPART_OFS_APPEND,
119 +               .size           = SZ_512M,
120 +               .mask_flags     = 0,
121 +       }, {
122 +               .name           = "filesystem2",
123 +               .offset         = MTDPART_OFS_APPEND,
124 +               .size           = MTDPART_SIZ_FULL,
125 +               .mask_flags     = 0,
126 +       }
127 +       /* two blocks with bad block table (and mirror) at the end */
128 +};
129 +
130 +static struct davinci_nand_pdata davinci_nand_data = {
131 +       .mask_chipsel           = BIT(14),
132 +       .parts                  = davinci_nand_partitions,
133 +       .nr_parts               = ARRAY_SIZE(davinci_nand_partitions),
134 +       .ecc_mode               = NAND_ECC_HW_SYNDROME,
135 +       .options                = NAND_USE_FLASH_BBT,
136 +};
137 +
138 +static struct resource davinci_nand_resources[] = {
139 +       {
140 +               .start          = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
141 +               .end            = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_32M - 1,
142 +               .flags          = IORESOURCE_MEM,
143 +       }, {
144 +               .start          = DAVINCI_ASYNC_EMIF_CONTROL_BASE,
145 +               .end            = DAVINCI_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
146 +               .flags          = IORESOURCE_MEM,
147 +       },
148 +};
149 +
150 +static struct platform_device davinci_nand_device = {
151 +       .name                   = "davinci_nand",
152 +       .id                     = 0,
153 +
154 +       .num_resources          = ARRAY_SIZE(davinci_nand_resources),
155 +       .resource               = davinci_nand_resources,
156 +
157 +       .dev                    = {
158 +               .platform_data  = &davinci_nand_data,
159 +       },
160 +};
161 +
162 +static struct davinci_i2c_platform_data i2c_pdata = {
163 +       .bus_freq       = 400   /* kHz */,
164 +       .bus_delay      = 0     /* usec */,
165 +};
166 +
167 +static int dm355leopard_mmc_gpios = -EINVAL;
168 +
169 +static void dm355leopard_mmcsd_gpios(unsigned gpio)
170 +{
171 +       gpio_request(gpio + 0, "mmc0_ro");
172 +       gpio_request(gpio + 1, "mmc0_cd");
173 +       gpio_request(gpio + 2, "mmc1_ro");
174 +       gpio_request(gpio + 3, "mmc1_cd");
175 +
176 +       /* we "know" these are input-only so we don't
177 +        * need to call gpio_direction_input()
178 +        */
179 +
180 +       dm355leopard_mmc_gpios = gpio;
181 +}
182 +
183 +static struct i2c_board_info dm355leopard_i2c_info[] = {
184 +       { I2C_BOARD_INFO("dm355leopard_msp", 0x25),
185 +               .platform_data = dm355leopard_mmcsd_gpios,
186 +               /* plus irq */ },
187 +       /* { I2C_BOARD_INFO("tlv320aic3x", 0x1b), }, */
188 +       /* { I2C_BOARD_INFO("tvp5146", 0x5d), }, */
189 +};
190 +
191 +static void __init leopard_init_i2c(void)
192 +{
193 +       davinci_init_i2c(&i2c_pdata);
194 +
195 +       gpio_request(5, "dm355leopard_msp");
196 +       gpio_direction_input(5);
197 +       dm355leopard_i2c_info[0].irq = gpio_to_irq(5);
198 +
199 +       i2c_register_board_info(1, dm355leopard_i2c_info,
200 +                       ARRAY_SIZE(dm355leopard_i2c_info));
201 +}
202 +
203 +static struct resource dm355leopard_dm9000_rsrc[] = {
204 +       {
205 +               /* addr */
206 +               .start  = 0x04014000,
207 +               .end    = 0x04014001,
208 +               .flags  = IORESOURCE_MEM,
209 +       }, {
210 +               /* data */
211 +               .start  = 0x04014002,
212 +               .end    = 0x04014003,
213 +               .flags  = IORESOURCE_MEM,
214 +       }, {
215 +               .flags  = IORESOURCE_IRQ
216 +                       | IORESOURCE_IRQ_HIGHEDGE /* rising (active high) */,
217 +       },
218 +};
219 +
220 +static struct platform_device dm355leopard_dm9000 = {
221 +       .name           = "dm9000",
222 +       .id             = -1,
223 +       .resource       = dm355leopard_dm9000_rsrc,
224 +       .num_resources  = ARRAY_SIZE(dm355leopard_dm9000_rsrc),
225 +};
226 +
227 +static struct platform_device *davinci_leopard_devices[] __initdata = {
228 +       &dm355leopard_dm9000,
229 +       &davinci_nand_device,
230 +};
231 +
232 +static struct davinci_uart_config uart_config __initdata = {
233 +       .enabled_uarts = (1 << 0),
234 +};
235 +
236 +static void __init dm355_leopard_map_io(void)
237 +{
238 +       davinci_map_common_io();
239 +       dm355_init();
240 +}
241 +
242 +static int dm355leopard_mmc_get_cd(int module)
243 +{
244 +       if (!gpio_is_valid(dm355leopard_mmc_gpios))
245 +               return -ENXIO;
246 +       /* low == card present */
247 +       return !gpio_get_value_cansleep(dm355leopard_mmc_gpios + 2 * module + 1);
248 +}
249 +
250 +static int dm355leopard_mmc_get_ro(int module)
251 +{
252 +       if (!gpio_is_valid(dm355leopard_mmc_gpios))
253 +               return -ENXIO;
254 +       /* high == card's write protect switch active */
255 +       return gpio_get_value_cansleep(dm355leopard_mmc_gpios + 2 * module + 0);
256 +}
257 +
258 +static struct davinci_mmc_config dm355leopard_mmc_config = {
259 +       .get_cd         = dm355leopard_mmc_get_cd,
260 +       .get_ro         = dm355leopard_mmc_get_ro,
261 +       .wires          = 4,
262 +       .max_freq       = 50000000,
263 +       .caps           = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
264 +};
265 +
266 +/* Don't connect anything to J10 unless you're only using USB host
267 + * mode *and* have to do so with some kind of gender-bender.  If
268 + * you have proper Mini-B or Mini-A cables (or Mini-A adapters)
269 + * the ID pin won't need any help.
270 + */
271 +#ifdef CONFIG_USB_MUSB_PERIPHERAL
272 +#define USB_ID_VALUE   0       /* ID pulled high; *should* float */
273 +#else
274 +#define USB_ID_VALUE   1       /* ID pulled low */
275 +#endif
276 +
277 +static struct spi_eeprom at25640a = {
278 +       .byte_len       = SZ_64K / 8,
279 +       .name           = "at25640a",
280 +       .page_size      = 32,
281 +       .flags          = EE_ADDR2,
282 +};
283 +
284 +static struct spi_board_info dm355_leopard_spi_info[] __initconst = {
285 +       {
286 +               .modalias       = "at25",
287 +               .platform_data  = &at25640a,
288 +               .max_speed_hz   = 10 * 1000 * 1000,     /* at 3v3 */
289 +               .bus_num        = 0,
290 +               .chip_select    = 0,
291 +               .mode           = SPI_MODE_0,
292 +       },
293 +};
294 +
295 +static __init void dm355_leopard_init(void)
296 +{
297 +       struct clk *aemif;
298 +
299 +       gpio_request(1, "dm9000");
300 +       gpio_direction_input(1);
301 +       dm355leopard_dm9000_rsrc[2].start = gpio_to_irq(1);
302 +
303 +       aemif = clk_get(&dm355leopard_dm9000.dev, "aemif");
304 +       clk_enable(aemif);
305 +       clk_put(aemif);
306 +
307 +       platform_add_devices(davinci_leopard_devices,
308 +                            ARRAY_SIZE(davinci_leopard_devices));
309 +       leopard_init_i2c();
310 +       davinci_serial_init(&uart_config);
311 +
312 +       /* NOTE:  NAND flash timings set by the UBL are slower than
313 +        * needed by MT29F16G08FAA chips ... EMIF.A1CR is 0x40400204
314 +        * but could be 0x0400008c for about 25% faster page reads.
315 +        */
316 +
317 +       gpio_request(2, "usb_id_toggle");
318 +       gpio_direction_output(2, USB_ID_VALUE);
319 +       /* irlml6401 switches over 1A in under 8 msec */
320 +       setup_usb(500, 8);
321 +
322 +       davinci_setup_mmc(0, &dm355leopard_mmc_config);
323 +       davinci_setup_mmc(1, &dm355leopard_mmc_config);
324 +
325 +       dm355_init_spi0(BIT(0), dm355_leopard_spi_info,
326 +                       ARRAY_SIZE(dm355_leopard_spi_info));
327 +}
328 +
329 +static __init void dm355_leopard_irq_init(void)
330 +{
331 +       davinci_irq_init();
332 +}
333 +
334 +MACHINE_START(DM355_LEOPARD, "DaVinci DM355 leopard")
335 +       .phys_io      = IO_PHYS,
336 +       .io_pg_offst  = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
337 +       .boot_params  = (0x80000100),
338 +       .map_io       = dm355_leopard_map_io,
339 +       .init_irq     = dm355_leopard_irq_init,
340 +       .timer        = &davinci_timer,
341 +       .init_machine = dm355_leopard_init,
342 +MACHINE_END
343 -- 
344 1.6.1.2
345