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
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
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.
21 +config MACH_DM355_LEOPARD
22 + bool "TI DM355 Leopard board"
24 + depends on ARCH_DAVINCI_DM355
26 + Configure this option to specify the whether the board used
27 + for development is a DM355 Leopard board.
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
42 diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c b/arch/arm/mach-davinci/board-dm355-leopard.c
44 index 0000000..a1e97e8
46 +++ b/arch/arm/mach-davinci/board-dm355-leopard.c
49 + * TI DM355 leopard board support
51 + * Based on board-dm355-evm.c
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.
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>
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>
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>
88 +#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e10000
89 +#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
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.
96 +#define NAND_BLOCK_SIZE SZ_128K
98 +static struct mtd_partition davinci_nand_partitions[] = {
100 + /* UBL (a few copies) plus U-Boot */
101 + .name = "bootloader",
103 + .size = 15 * NAND_BLOCK_SIZE,
104 + .mask_flags = MTD_WRITEABLE, /* force read-only */
106 + /* U-Boot environment */
108 + .offset = MTDPART_OFS_APPEND,
109 + .size = 1 * NAND_BLOCK_SIZE,
113 + .offset = MTDPART_OFS_APPEND,
117 + .name = "filesystem1",
118 + .offset = MTDPART_OFS_APPEND,
122 + .name = "filesystem2",
123 + .offset = MTDPART_OFS_APPEND,
124 + .size = MTDPART_SIZ_FULL,
127 + /* two blocks with bad block table (and mirror) at the end */
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,
138 +static struct resource davinci_nand_resources[] = {
140 + .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
141 + .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_32M - 1,
142 + .flags = IORESOURCE_MEM,
144 + .start = DAVINCI_ASYNC_EMIF_CONTROL_BASE,
145 + .end = DAVINCI_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
146 + .flags = IORESOURCE_MEM,
150 +static struct platform_device davinci_nand_device = {
151 + .name = "davinci_nand",
154 + .num_resources = ARRAY_SIZE(davinci_nand_resources),
155 + .resource = davinci_nand_resources,
158 + .platform_data = &davinci_nand_data,
162 +static struct davinci_i2c_platform_data i2c_pdata = {
163 + .bus_freq = 400 /* kHz */,
164 + .bus_delay = 0 /* usec */,
167 +static int dm355leopard_mmc_gpios = -EINVAL;
169 +static void dm355leopard_mmcsd_gpios(unsigned gpio)
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");
176 + /* we "know" these are input-only so we don't
177 + * need to call gpio_direction_input()
180 + dm355leopard_mmc_gpios = gpio;
183 +static struct i2c_board_info dm355leopard_i2c_info[] = {
184 + { I2C_BOARD_INFO("dm355leopard_msp", 0x25),
185 + .platform_data = dm355leopard_mmcsd_gpios,
187 + /* { I2C_BOARD_INFO("tlv320aic3x", 0x1b), }, */
188 + /* { I2C_BOARD_INFO("tvp5146", 0x5d), }, */
191 +static void __init leopard_init_i2c(void)
193 + davinci_init_i2c(&i2c_pdata);
195 + gpio_request(5, "dm355leopard_msp");
196 + gpio_direction_input(5);
197 + dm355leopard_i2c_info[0].irq = gpio_to_irq(5);
199 + i2c_register_board_info(1, dm355leopard_i2c_info,
200 + ARRAY_SIZE(dm355leopard_i2c_info));
203 +static struct resource dm355leopard_dm9000_rsrc[] = {
206 + .start = 0x04014000,
208 + .flags = IORESOURCE_MEM,
211 + .start = 0x04014002,
213 + .flags = IORESOURCE_MEM,
215 + .flags = IORESOURCE_IRQ
216 + | IORESOURCE_IRQ_HIGHEDGE /* rising (active high) */,
220 +static struct platform_device dm355leopard_dm9000 = {
223 + .resource = dm355leopard_dm9000_rsrc,
224 + .num_resources = ARRAY_SIZE(dm355leopard_dm9000_rsrc),
227 +static struct platform_device *davinci_leopard_devices[] __initdata = {
228 + &dm355leopard_dm9000,
229 + &davinci_nand_device,
232 +static struct davinci_uart_config uart_config __initdata = {
233 + .enabled_uarts = (1 << 0),
236 +static void __init dm355_leopard_map_io(void)
238 + davinci_map_common_io();
242 +static int dm355leopard_mmc_get_cd(int module)
244 + if (!gpio_is_valid(dm355leopard_mmc_gpios))
246 + /* low == card present */
247 + return !gpio_get_value_cansleep(dm355leopard_mmc_gpios + 2 * module + 1);
250 +static int dm355leopard_mmc_get_ro(int module)
252 + if (!gpio_is_valid(dm355leopard_mmc_gpios))
254 + /* high == card's write protect switch active */
255 + return gpio_get_value_cansleep(dm355leopard_mmc_gpios + 2 * module + 0);
258 +static struct davinci_mmc_config dm355leopard_mmc_config = {
259 + .get_cd = dm355leopard_mmc_get_cd,
260 + .get_ro = dm355leopard_mmc_get_ro,
262 + .max_freq = 50000000,
263 + .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
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.
271 +#ifdef CONFIG_USB_MUSB_PERIPHERAL
272 +#define USB_ID_VALUE 0 /* ID pulled high; *should* float */
274 +#define USB_ID_VALUE 1 /* ID pulled low */
277 +static struct spi_eeprom at25640a = {
278 + .byte_len = SZ_64K / 8,
279 + .name = "at25640a",
284 +static struct spi_board_info dm355_leopard_spi_info[] __initconst = {
286 + .modalias = "at25",
287 + .platform_data = &at25640a,
288 + .max_speed_hz = 10 * 1000 * 1000, /* at 3v3 */
291 + .mode = SPI_MODE_0,
295 +static __init void dm355_leopard_init(void)
299 + gpio_request(1, "dm9000");
300 + gpio_direction_input(1);
301 + dm355leopard_dm9000_rsrc[2].start = gpio_to_irq(1);
303 + aemif = clk_get(&dm355leopard_dm9000.dev, "aemif");
307 + platform_add_devices(davinci_leopard_devices,
308 + ARRAY_SIZE(davinci_leopard_devices));
309 + leopard_init_i2c();
310 + davinci_serial_init(&uart_config);
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.
317 + gpio_request(2, "usb_id_toggle");
318 + gpio_direction_output(2, USB_ID_VALUE);
319 + /* irlml6401 switches over 1A in under 8 msec */
322 + davinci_setup_mmc(0, &dm355leopard_mmc_config);
323 + davinci_setup_mmc(1, &dm355leopard_mmc_config);
325 + dm355_init_spi0(BIT(0), dm355_leopard_spi_info,
326 + ARRAY_SIZE(dm355_leopard_spi_info));
329 +static __init void dm355_leopard_irq_init(void)
331 + davinci_irq_init();
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,