]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/arm/mach-davinci/board-dm355-evm.c
davinci: make it easier to identify SoC init failures
[net-next-2.6.git] / arch / arm / mach-davinci / board-dm355-evm.c
CommitLineData
95a3477f
KH
1/*
2 * TI DaVinci EVM board support
3 *
4 * Author: Kevin Hilman, Deep Root Systems, LLC
5 *
6 * 2007 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11#include <linux/kernel.h>
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/dma-mapping.h>
15#include <linux/platform_device.h>
16#include <linux/mtd/mtd.h>
17#include <linux/mtd/partitions.h>
18#include <linux/mtd/nand.h>
19#include <linux/i2c.h>
20#include <linux/io.h>
21#include <linux/gpio.h>
22#include <linux/clk.h>
51e68e27
MK
23#include <linux/videodev2.h>
24#include <media/tvp514x.h>
95a3477f
KH
25#include <linux/spi/spi.h>
26#include <linux/spi/eeprom.h>
27
28#include <asm/setup.h>
29#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32#include <asm/mach/flash.h>
33
34#include <mach/hardware.h>
35#include <mach/dm355.h>
36#include <mach/psc.h>
37#include <mach/common.h>
38#include <mach/i2c.h>
39#include <mach/serial.h>
40#include <mach/nand.h>
2dbf56ae 41#include <mach/mmc.h>
95a3477f
KH
42
43#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e10000
44#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
45
46/* NOTE: this is geared for the standard config, with a socketed
47 * 2 GByte Micron NAND (MT29F16G08FAA) using 128KB sectors. If you
48 * swap chips, maybe with a different block size, partitioning may
49 * need to be changed.
50 */
51#define NAND_BLOCK_SIZE SZ_128K
52
53static struct mtd_partition davinci_nand_partitions[] = {
54 {
55 /* UBL (a few copies) plus U-Boot */
56 .name = "bootloader",
57 .offset = 0,
58 .size = 15 * NAND_BLOCK_SIZE,
59 .mask_flags = MTD_WRITEABLE, /* force read-only */
60 }, {
61 /* U-Boot environment */
62 .name = "params",
63 .offset = MTDPART_OFS_APPEND,
64 .size = 1 * NAND_BLOCK_SIZE,
65 .mask_flags = 0,
66 }, {
67 .name = "kernel",
68 .offset = MTDPART_OFS_APPEND,
69 .size = SZ_4M,
70 .mask_flags = 0,
71 }, {
72 .name = "filesystem1",
73 .offset = MTDPART_OFS_APPEND,
74 .size = SZ_512M,
75 .mask_flags = 0,
76 }, {
77 .name = "filesystem2",
78 .offset = MTDPART_OFS_APPEND,
79 .size = MTDPART_SIZ_FULL,
80 .mask_flags = 0,
81 }
82 /* two blocks with bad block table (and mirror) at the end */
83};
84
85static struct davinci_nand_pdata davinci_nand_data = {
86 .mask_chipsel = BIT(14),
87 .parts = davinci_nand_partitions,
88 .nr_parts = ARRAY_SIZE(davinci_nand_partitions),
74c987a0 89 .ecc_mode = NAND_ECC_HW,
95a3477f 90 .options = NAND_USE_FLASH_BBT,
74c987a0 91 .ecc_bits = 4,
95a3477f
KH
92};
93
94static struct resource davinci_nand_resources[] = {
95 {
96 .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
97 .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_32M - 1,
98 .flags = IORESOURCE_MEM,
99 }, {
100 .start = DAVINCI_ASYNC_EMIF_CONTROL_BASE,
101 .end = DAVINCI_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
102 .flags = IORESOURCE_MEM,
103 },
104};
105
106static struct platform_device davinci_nand_device = {
107 .name = "davinci_nand",
108 .id = 0,
109
110 .num_resources = ARRAY_SIZE(davinci_nand_resources),
111 .resource = davinci_nand_resources,
112
113 .dev = {
114 .platform_data = &davinci_nand_data,
115 },
116};
117
118static struct davinci_i2c_platform_data i2c_pdata = {
119 .bus_freq = 400 /* kHz */,
120 .bus_delay = 0 /* usec */,
121};
122
61aa0732 123static struct snd_platform_data dm355_evm_snd_data;
25acf553 124
95a3477f
KH
125static int dm355evm_mmc_gpios = -EINVAL;
126
127static void dm355evm_mmcsd_gpios(unsigned gpio)
128{
129 gpio_request(gpio + 0, "mmc0_ro");
130 gpio_request(gpio + 1, "mmc0_cd");
131 gpio_request(gpio + 2, "mmc1_ro");
132 gpio_request(gpio + 3, "mmc1_cd");
133
134 /* we "know" these are input-only so we don't
135 * need to call gpio_direction_input()
136 */
137
138 dm355evm_mmc_gpios = gpio;
139}
140
141static struct i2c_board_info dm355evm_i2c_info[] = {
51e68e27 142 { I2C_BOARD_INFO("dm355evm_msp", 0x25),
95a3477f 143 .platform_data = dm355evm_mmcsd_gpios,
51e68e27
MK
144 },
145 /* { plus irq }, */
1a7ff8ff 146 { I2C_BOARD_INFO("tlv320aic33", 0x1b), },
95a3477f
KH
147};
148
149static void __init evm_init_i2c(void)
150{
151 davinci_init_i2c(&i2c_pdata);
152
153 gpio_request(5, "dm355evm_msp");
154 gpio_direction_input(5);
155 dm355evm_i2c_info[0].irq = gpio_to_irq(5);
156
157 i2c_register_board_info(1, dm355evm_i2c_info,
158 ARRAY_SIZE(dm355evm_i2c_info));
159}
160
161static struct resource dm355evm_dm9000_rsrc[] = {
162 {
163 /* addr */
164 .start = 0x04014000,
165 .end = 0x04014001,
166 .flags = IORESOURCE_MEM,
167 }, {
168 /* data */
169 .start = 0x04014002,
170 .end = 0x04014003,
171 .flags = IORESOURCE_MEM,
172 }, {
173 .flags = IORESOURCE_IRQ
174 | IORESOURCE_IRQ_HIGHEDGE /* rising (active high) */,
175 },
176};
177
178static struct platform_device dm355evm_dm9000 = {
179 .name = "dm9000",
180 .id = -1,
181 .resource = dm355evm_dm9000_rsrc,
182 .num_resources = ARRAY_SIZE(dm355evm_dm9000_rsrc),
183};
184
51e68e27
MK
185static struct tvp514x_platform_data tvp5146_pdata = {
186 .clk_polarity = 0,
187 .hs_polarity = 1,
188 .vs_polarity = 1
189};
190
191#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
192/* Inputs available at the TVP5146 */
193static struct v4l2_input tvp5146_inputs[] = {
194 {
195 .index = 0,
196 .name = "Composite",
197 .type = V4L2_INPUT_TYPE_CAMERA,
198 .std = TVP514X_STD_ALL,
199 },
200 {
201 .index = 1,
202 .name = "S-Video",
203 .type = V4L2_INPUT_TYPE_CAMERA,
204 .std = TVP514X_STD_ALL,
205 },
206};
207
208/*
209 * this is the route info for connecting each input to decoder
210 * ouput that goes to vpfe. There is a one to one correspondence
211 * with tvp5146_inputs
212 */
213static struct vpfe_route tvp5146_routes[] = {
214 {
215 .input = INPUT_CVBS_VI2B,
216 .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
217 },
218 {
219 .input = INPUT_SVIDEO_VI2C_VI1C,
220 .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
221 },
222};
223
224static struct vpfe_subdev_info vpfe_sub_devs[] = {
225 {
226 .name = "tvp5146",
227 .grp_id = 0,
228 .num_inputs = ARRAY_SIZE(tvp5146_inputs),
229 .inputs = tvp5146_inputs,
230 .routes = tvp5146_routes,
231 .can_route = 1,
232 .ccdc_if_params = {
233 .if_type = VPFE_BT656,
234 .hdpol = VPFE_PINPOL_POSITIVE,
235 .vdpol = VPFE_PINPOL_POSITIVE,
236 },
237 .board_info = {
238 I2C_BOARD_INFO("tvp5146", 0x5d),
239 .platform_data = &tvp5146_pdata,
240 },
241 }
242};
243
244static struct vpfe_config vpfe_cfg = {
245 .num_subdevs = ARRAY_SIZE(vpfe_sub_devs),
246 .sub_devs = vpfe_sub_devs,
247 .card_name = "DM355 EVM",
248 .ccdc = "DM355 CCDC",
249};
250
95a3477f
KH
251static struct platform_device *davinci_evm_devices[] __initdata = {
252 &dm355evm_dm9000,
253 &davinci_nand_device,
254};
255
256static struct davinci_uart_config uart_config __initdata = {
257 .enabled_uarts = (1 << 0),
258};
259
260static void __init dm355_evm_map_io(void)
261{
51e68e27
MK
262 /* setup input configuration for VPFE input devices */
263 dm355_set_vpfe_config(&vpfe_cfg);
95a3477f
KH
264 dm355_init();
265}
266
2dbf56ae
KH
267static int dm355evm_mmc_get_cd(int module)
268{
269 if (!gpio_is_valid(dm355evm_mmc_gpios))
270 return -ENXIO;
271 /* low == card present */
272 return !gpio_get_value_cansleep(dm355evm_mmc_gpios + 2 * module + 1);
273}
274
275static int dm355evm_mmc_get_ro(int module)
276{
277 if (!gpio_is_valid(dm355evm_mmc_gpios))
278 return -ENXIO;
279 /* high == card's write protect switch active */
280 return gpio_get_value_cansleep(dm355evm_mmc_gpios + 2 * module + 0);
281}
282
283static struct davinci_mmc_config dm355evm_mmc_config = {
284 .get_cd = dm355evm_mmc_get_cd,
285 .get_ro = dm355evm_mmc_get_ro,
286 .wires = 4,
287 .max_freq = 50000000,
288 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
289 .version = MMC_CTLR_VERSION_1,
290};
291
95a3477f
KH
292/* Don't connect anything to J10 unless you're only using USB host
293 * mode *and* have to do so with some kind of gender-bender. If
294 * you have proper Mini-B or Mini-A cables (or Mini-A adapters)
295 * the ID pin won't need any help.
296 */
297#ifdef CONFIG_USB_MUSB_PERIPHERAL
298#define USB_ID_VALUE 0 /* ID pulled high; *should* float */
299#else
300#define USB_ID_VALUE 1 /* ID pulled low */
301#endif
302
303static struct spi_eeprom at25640a = {
304 .byte_len = SZ_64K / 8,
305 .name = "at25640a",
306 .page_size = 32,
307 .flags = EE_ADDR2,
308};
309
310static struct spi_board_info dm355_evm_spi_info[] __initconst = {
311 {
312 .modalias = "at25",
313 .platform_data = &at25640a,
314 .max_speed_hz = 10 * 1000 * 1000, /* at 3v3 */
315 .bus_num = 0,
316 .chip_select = 0,
317 .mode = SPI_MODE_0,
318 },
319};
320
321static __init void dm355_evm_init(void)
322{
323 struct clk *aemif;
324
325 gpio_request(1, "dm9000");
326 gpio_direction_input(1);
327 dm355evm_dm9000_rsrc[2].start = gpio_to_irq(1);
328
329 aemif = clk_get(&dm355evm_dm9000.dev, "aemif");
330 if (IS_ERR(aemif))
331 WARN("%s: unable to get AEMIF clock\n", __func__);
332 else
333 clk_enable(aemif);
334
335 platform_add_devices(davinci_evm_devices,
336 ARRAY_SIZE(davinci_evm_devices));
337 evm_init_i2c();
338 davinci_serial_init(&uart_config);
339
340 /* NOTE: NAND flash timings set by the UBL are slower than
341 * needed by MT29F16G08FAA chips ... EMIF.A1CR is 0x40400204
342 * but could be 0x0400008c for about 25% faster page reads.
343 */
344
345 gpio_request(2, "usb_id_toggle");
346 gpio_direction_output(2, USB_ID_VALUE);
347 /* irlml6401 switches over 1A in under 8 msec */
348 setup_usb(500, 8);
349
2dbf56ae
KH
350 davinci_setup_mmc(0, &dm355evm_mmc_config);
351 davinci_setup_mmc(1, &dm355evm_mmc_config);
352
95a3477f
KH
353 dm355_init_spi0(BIT(0), dm355_evm_spi_info,
354 ARRAY_SIZE(dm355_evm_spi_info));
25acf553
C
355
356 /* DM335 EVM uses ASP1; line-out is a stereo mini-jack */
357 dm355_init_asp1(ASP1_TX_EVT_EN | ASP1_RX_EVT_EN, &dm355_evm_snd_data);
95a3477f
KH
358}
359
360static __init void dm355_evm_irq_init(void)
361{
362 davinci_irq_init();
363}
364
365MACHINE_START(DAVINCI_DM355_EVM, "DaVinci DM355 EVM")
366 .phys_io = IO_PHYS,
367 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
368 .boot_params = (0x80000100),
369 .map_io = dm355_evm_map_io,
370 .init_irq = dm355_evm_irq_init,
371 .timer = &davinci_timer,
372 .init_machine = dm355_evm_init,
373MACHINE_END