blob: d028bab6f9813ae12721fc087926d77887f719be [file] [log] [blame]
Kevin Hilman7c6337e2007-04-30 19:37:19 +01001/*
2 * TI DaVinci EVM board support
3 *
4 * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com>
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>
Kevin Hilman7c6337e2007-04-30 19:37:19 +010012#include <linux/init.h>
13#include <linux/dma-mapping.h>
14#include <linux/platform_device.h>
David Brownell7bff3c42008-09-07 23:43:02 -070015#include <linux/gpio.h>
David Brownell7bff3c42008-09-07 23:43:02 -070016#include <linux/i2c.h>
17#include <linux/i2c/pcf857x.h>
18#include <linux/i2c/at24.h>
Kevin Hilman7c6337e2007-04-30 19:37:19 +010019#include <linux/mtd/mtd.h>
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050020#include <linux/mtd/nand.h>
Kevin Hilman7c6337e2007-04-30 19:37:19 +010021#include <linux/mtd/partitions.h>
22#include <linux/mtd/physmap.h>
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050023#include <linux/phy.h>
24#include <linux/clk.h>
Muralidharan Karicheriab8e8df2009-09-16 11:53:18 -040025#include <linux/videodev2.h>
26
27#include <media/tvp514x.h>
Kevin Hilman7c6337e2007-04-30 19:37:19 +010028
Kevin Hilman7c6337e2007-04-30 19:37:19 +010029#include <asm/mach-types.h>
Kevin Hilman7c6337e2007-04-30 19:37:19 +010030#include <asm/mach/arch.h>
Kevin Hilman7c6337e2007-04-30 19:37:19 +010031
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050032#include <mach/dm644x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010033#include <mach/common.h>
David Brownell7bff3c42008-09-07 23:43:02 -070034#include <mach/i2c.h>
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050035#include <mach/serial.h>
36#include <mach/mux.h>
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050037#include <mach/nand.h>
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -070038#include <mach/mmc.h>
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +040039#include <mach/usb.h>
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050040
41#define DM644X_EVM_PHY_MASK (0x2)
42#define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
Kevin Hilman7c6337e2007-04-30 19:37:19 +010043
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050044#define DAVINCI_CFC_ATA_BASE 0x01C66000
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050045
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050046#define LXT971_PHY_ID (0x001378e2)
47#define LXT971_PHY_MASK (0xfffffff0)
Kevin Hilman7c6337e2007-04-30 19:37:19 +010048
David Brownell7bff3c42008-09-07 23:43:02 -070049static struct mtd_partition davinci_evm_norflash_partitions[] = {
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050050 /* bootloader (UBL, U-Boot, etc) in first 5 sectors */
Kevin Hilman7c6337e2007-04-30 19:37:19 +010051 {
52 .name = "bootloader",
53 .offset = 0,
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050054 .size = 5 * SZ_64K,
Kevin Hilman7c6337e2007-04-30 19:37:19 +010055 .mask_flags = MTD_WRITEABLE, /* force read-only */
56 },
57 /* bootloader params in the next 1 sectors */
58 {
59 .name = "params",
60 .offset = MTDPART_OFS_APPEND,
61 .size = SZ_64K,
62 .mask_flags = 0,
63 },
64 /* kernel */
65 {
66 .name = "kernel",
67 .offset = MTDPART_OFS_APPEND,
68 .size = SZ_2M,
69 .mask_flags = 0
70 },
71 /* file system */
72 {
73 .name = "filesystem",
74 .offset = MTDPART_OFS_APPEND,
75 .size = MTDPART_SIZ_FULL,
76 .mask_flags = 0
77 }
78};
79
David Brownell7bff3c42008-09-07 23:43:02 -070080static struct physmap_flash_data davinci_evm_norflash_data = {
Kevin Hilman7c6337e2007-04-30 19:37:19 +010081 .width = 2,
David Brownell7bff3c42008-09-07 23:43:02 -070082 .parts = davinci_evm_norflash_partitions,
83 .nr_parts = ARRAY_SIZE(davinci_evm_norflash_partitions),
Kevin Hilman7c6337e2007-04-30 19:37:19 +010084};
85
86/* NOTE: CFI probe will correctly detect flash part as 32M, but EMIF
87 * limits addresses to 16M, so using addresses past 16M will wrap */
David Brownell7bff3c42008-09-07 23:43:02 -070088static struct resource davinci_evm_norflash_resource = {
Sergei Shtylyov70342172010-04-16 21:29:11 +040089 .start = DM644X_ASYNC_EMIF_DATA_CE0_BASE,
90 .end = DM644X_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
Kevin Hilman7c6337e2007-04-30 19:37:19 +010091 .flags = IORESOURCE_MEM,
92};
93
David Brownell7bff3c42008-09-07 23:43:02 -070094static struct platform_device davinci_evm_norflash_device = {
Kevin Hilman7c6337e2007-04-30 19:37:19 +010095 .name = "physmap-flash",
96 .id = 0,
97 .dev = {
David Brownell7bff3c42008-09-07 23:43:02 -070098 .platform_data = &davinci_evm_norflash_data,
Kevin Hilman7c6337e2007-04-30 19:37:19 +010099 },
100 .num_resources = 1,
David Brownell7bff3c42008-09-07 23:43:02 -0700101 .resource = &davinci_evm_norflash_resource,
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100102};
103
David Brownell3e9c18e2009-04-15 14:19:21 -0500104/* DM644x EVM includes a 64 MByte small-page NAND flash (16K blocks).
105 * It may used instead of the (default) NOR chip to boot, using TI's
106 * tools to install the secondary boot loader (UBL) and U-Boot.
107 */
Kevin Hilman28552c22010-02-25 15:36:38 -0800108static struct mtd_partition davinci_evm_nandflash_partition[] = {
David Brownell3e9c18e2009-04-15 14:19:21 -0500109 /* Bootloader layout depends on whose u-boot is installed, but we
110 * can hide all the details.
111 * - block 0 for u-boot environment ... in mainline u-boot
112 * - block 1 for UBL (plus up to four backup copies in blocks 2..5)
113 * - blocks 6...? for u-boot
114 * - blocks 16..23 for u-boot environment ... in TI's u-boot
115 */
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500116 {
David Brownell3e9c18e2009-04-15 14:19:21 -0500117 .name = "bootloader",
118 .offset = 0,
119 .size = SZ_256K + SZ_128K,
120 .mask_flags = MTD_WRITEABLE, /* force read-only */
121 },
122 /* Kernel */
123 {
124 .name = "kernel",
125 .offset = MTDPART_OFS_APPEND,
126 .size = SZ_4M,
127 .mask_flags = 0,
128 },
129 /* File system (older GIT kernels started this on the 5MB mark) */
130 {
131 .name = "filesystem",
132 .offset = MTDPART_OFS_APPEND,
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500133 .size = MTDPART_SIZ_FULL,
134 .mask_flags = 0,
135 }
David Brownell3e9c18e2009-04-15 14:19:21 -0500136 /* A few blocks at end hold a flash BBT ... created by TI's CCS
137 * using flashwriter_nand.out, but ignored by TI's versions of
138 * Linux and u-boot. We boot faster by using them.
139 */
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500140};
David Brownell7bff3c42008-09-07 23:43:02 -0700141
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500142static struct davinci_nand_pdata davinci_evm_nandflash_data = {
143 .parts = davinci_evm_nandflash_partition,
144 .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition),
145 .ecc_mode = NAND_ECC_HW,
David Brownell3e9c18e2009-04-15 14:19:21 -0500146 .options = NAND_USE_FLASH_BBT,
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500147};
148
149static struct resource davinci_evm_nandflash_resource[] = {
150 {
Sergei Shtylyov70342172010-04-16 21:29:11 +0400151 .start = DM644X_ASYNC_EMIF_DATA_CE0_BASE,
152 .end = DM644X_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500153 .flags = IORESOURCE_MEM,
154 }, {
Sergei Shtylyov70342172010-04-16 21:29:11 +0400155 .start = DM644X_ASYNC_EMIF_CONTROL_BASE,
156 .end = DM644X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500157 .flags = IORESOURCE_MEM,
158 },
159};
160
161static struct platform_device davinci_evm_nandflash_device = {
162 .name = "davinci_nand",
163 .id = 0,
164 .dev = {
165 .platform_data = &davinci_evm_nandflash_data,
166 },
167 .num_resources = ARRAY_SIZE(davinci_evm_nandflash_resource),
168 .resource = davinci_evm_nandflash_resource,
169};
170
David Brownell3e9c18e2009-04-15 14:19:21 -0500171static u64 davinci_fb_dma_mask = DMA_BIT_MASK(32);
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500172
173static struct platform_device davinci_fb_device = {
174 .name = "davincifb",
175 .id = -1,
176 .dev = {
177 .dma_mask = &davinci_fb_dma_mask,
David Brownell3e9c18e2009-04-15 14:19:21 -0500178 .coherent_dma_mask = DMA_BIT_MASK(32),
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500179 },
180 .num_resources = 0,
181};
182
Muralidharan Karicheriab8e8df2009-09-16 11:53:18 -0400183static struct tvp514x_platform_data tvp5146_pdata = {
184 .clk_polarity = 0,
185 .hs_polarity = 1,
186 .vs_polarity = 1
187};
188
189#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
190/* Inputs available at the TVP5146 */
191static struct v4l2_input tvp5146_inputs[] = {
192 {
193 .index = 0,
194 .name = "Composite",
195 .type = V4L2_INPUT_TYPE_CAMERA,
196 .std = TVP514X_STD_ALL,
197 },
198 {
199 .index = 1,
200 .name = "S-Video",
201 .type = V4L2_INPUT_TYPE_CAMERA,
202 .std = TVP514X_STD_ALL,
203 },
204};
205
206/*
207 * this is the route info for connecting each input to decoder
208 * ouput that goes to vpfe. There is a one to one correspondence
209 * with tvp5146_inputs
210 */
211static struct vpfe_route tvp5146_routes[] = {
212 {
213 .input = INPUT_CVBS_VI2B,
214 .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
215 },
216 {
217 .input = INPUT_SVIDEO_VI2C_VI1C,
218 .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
219 },
220};
221
222static struct vpfe_subdev_info vpfe_sub_devs[] = {
223 {
224 .name = "tvp5146",
225 .grp_id = 0,
226 .num_inputs = ARRAY_SIZE(tvp5146_inputs),
227 .inputs = tvp5146_inputs,
228 .routes = tvp5146_routes,
229 .can_route = 1,
230 .ccdc_if_params = {
231 .if_type = VPFE_BT656,
232 .hdpol = VPFE_PINPOL_POSITIVE,
233 .vdpol = VPFE_PINPOL_POSITIVE,
234 },
235 .board_info = {
236 I2C_BOARD_INFO("tvp5146", 0x5d),
237 .platform_data = &tvp5146_pdata,
238 },
239 },
240};
241
242static struct vpfe_config vpfe_cfg = {
243 .num_subdevs = ARRAY_SIZE(vpfe_sub_devs),
Vaibhav Hiremath077639f2009-10-13 15:08:54 +0000244 .i2c_adapter_id = 1,
Muralidharan Karicheriab8e8df2009-09-16 11:53:18 -0400245 .sub_devs = vpfe_sub_devs,
246 .card_name = "DM6446 EVM",
247 .ccdc = "DM6446 CCDC",
248};
249
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500250static struct platform_device rtc_dev = {
251 .name = "rtc_davinci_evm",
252 .id = -1,
253};
David Brownell7bff3c42008-09-07 23:43:02 -0700254
255static struct resource ide_resources[] = {
256 {
257 .start = DAVINCI_CFC_ATA_BASE,
258 .end = DAVINCI_CFC_ATA_BASE + 0x7ff,
259 .flags = IORESOURCE_MEM,
260 },
261 {
262 .start = IRQ_IDE,
263 .end = IRQ_IDE,
264 .flags = IORESOURCE_IRQ,
265 },
266};
267
Kevin Hilmana029b702009-05-07 14:25:48 +0100268static u64 ide_dma_mask = DMA_BIT_MASK(32);
David Brownell7bff3c42008-09-07 23:43:02 -0700269
270static struct platform_device ide_dev = {
271 .name = "palm_bk3710",
272 .id = -1,
273 .resource = ide_resources,
274 .num_resources = ARRAY_SIZE(ide_resources),
275 .dev = {
276 .dma_mask = &ide_dma_mask,
Kevin Hilmana029b702009-05-07 14:25:48 +0100277 .coherent_dma_mask = DMA_BIT_MASK(32),
David Brownell7bff3c42008-09-07 23:43:02 -0700278 },
279};
280
Kevin Hilman61aa0732009-07-15 08:47:48 -0700281static struct snd_platform_data dm644x_evm_snd_data;
Chaithrika U S25acf552009-06-05 06:28:08 -0400282
David Brownell7bff3c42008-09-07 23:43:02 -0700283/*----------------------------------------------------------------------*/
284
285/*
286 * I2C GPIO expanders
287 */
288
289#define PCF_Uxx_BASE(x) (DAVINCI_N_GPIO + ((x) * 8))
290
291
292/* U2 -- LEDs */
293
294static struct gpio_led evm_leds[] = {
295 { .name = "DS8", .active_low = 1,
296 .default_trigger = "heartbeat", },
297 { .name = "DS7", .active_low = 1, },
298 { .name = "DS6", .active_low = 1, },
299 { .name = "DS5", .active_low = 1, },
300 { .name = "DS4", .active_low = 1, },
301 { .name = "DS3", .active_low = 1, },
302 { .name = "DS2", .active_low = 1,
303 .default_trigger = "mmc0", },
304 { .name = "DS1", .active_low = 1,
305 .default_trigger = "ide-disk", },
306};
307
308static const struct gpio_led_platform_data evm_led_data = {
309 .num_leds = ARRAY_SIZE(evm_leds),
310 .leds = evm_leds,
311};
312
313static struct platform_device *evm_led_dev;
314
315static int
316evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
317{
318 struct gpio_led *leds = evm_leds;
319 int status;
320
321 while (ngpio--) {
322 leds->gpio = gpio++;
323 leds++;
324 }
325
326 /* what an extremely annoying way to be forced to handle
327 * device unregistration ...
328 */
329 evm_led_dev = platform_device_alloc("leds-gpio", 0);
330 platform_device_add_data(evm_led_dev,
331 &evm_led_data, sizeof evm_led_data);
332
333 evm_led_dev->dev.parent = &client->dev;
334 status = platform_device_add(evm_led_dev);
335 if (status < 0) {
336 platform_device_put(evm_led_dev);
337 evm_led_dev = NULL;
338 }
339 return status;
340}
341
342static int
343evm_led_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
344{
345 if (evm_led_dev) {
346 platform_device_unregister(evm_led_dev);
347 evm_led_dev = NULL;
348 }
349 return 0;
350}
351
352static struct pcf857x_platform_data pcf_data_u2 = {
353 .gpio_base = PCF_Uxx_BASE(0),
354 .setup = evm_led_setup,
355 .teardown = evm_led_teardown,
356};
357
358
359/* U18 - A/V clock generator and user switch */
360
361static int sw_gpio;
362
363static ssize_t
364sw_show(struct device *d, struct device_attribute *a, char *buf)
365{
366 char *s = gpio_get_value_cansleep(sw_gpio) ? "on\n" : "off\n";
367
368 strcpy(buf, s);
369 return strlen(s);
370}
371
372static DEVICE_ATTR(user_sw, S_IRUGO, sw_show, NULL);
373
374static int
375evm_u18_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
376{
377 int status;
378
379 /* export dip switch option */
380 sw_gpio = gpio + 7;
381 status = gpio_request(sw_gpio, "user_sw");
382 if (status == 0)
383 status = gpio_direction_input(sw_gpio);
384 if (status == 0)
385 status = device_create_file(&client->dev, &dev_attr_user_sw);
386 else
387 gpio_free(sw_gpio);
388 if (status != 0)
389 sw_gpio = -EINVAL;
390
391 /* audio PLL: 48 kHz (vs 44.1 or 32), single rate (vs double) */
392 gpio_request(gpio + 3, "pll_fs2");
393 gpio_direction_output(gpio + 3, 0);
394
395 gpio_request(gpio + 2, "pll_fs1");
396 gpio_direction_output(gpio + 2, 0);
397
398 gpio_request(gpio + 1, "pll_sr");
399 gpio_direction_output(gpio + 1, 0);
400
401 return 0;
402}
403
404static int
405evm_u18_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
406{
407 gpio_free(gpio + 1);
408 gpio_free(gpio + 2);
409 gpio_free(gpio + 3);
410
411 if (sw_gpio > 0) {
412 device_remove_file(&client->dev, &dev_attr_user_sw);
413 gpio_free(sw_gpio);
414 }
415 return 0;
416}
417
418static struct pcf857x_platform_data pcf_data_u18 = {
419 .gpio_base = PCF_Uxx_BASE(1),
420 .n_latch = (1 << 3) | (1 << 2) | (1 << 1),
421 .setup = evm_u18_setup,
422 .teardown = evm_u18_teardown,
423};
424
425
426/* U35 - various I/O signals used to manage USB, CF, ATA, etc */
427
428static int
429evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
430{
431 /* p0 = nDRV_VBUS (initial: don't supply it) */
432 gpio_request(gpio + 0, "nDRV_VBUS");
433 gpio_direction_output(gpio + 0, 1);
434
435 /* p1 = VDDIMX_EN */
436 gpio_request(gpio + 1, "VDDIMX_EN");
437 gpio_direction_output(gpio + 1, 1);
438
439 /* p2 = VLYNQ_EN */
440 gpio_request(gpio + 2, "VLYNQ_EN");
441 gpio_direction_output(gpio + 2, 1);
442
443 /* p3 = n3V3_CF_RESET (initial: stay in reset) */
444 gpio_request(gpio + 3, "nCF_RESET");
445 gpio_direction_output(gpio + 3, 0);
446
447 /* (p4 unused) */
448
449 /* p5 = 1V8_WLAN_RESET (initial: stay in reset) */
450 gpio_request(gpio + 5, "WLAN_RESET");
451 gpio_direction_output(gpio + 5, 1);
452
453 /* p6 = nATA_SEL (initial: select) */
454 gpio_request(gpio + 6, "nATA_SEL");
455 gpio_direction_output(gpio + 6, 0);
456
457 /* p7 = nCF_SEL (initial: deselect) */
458 gpio_request(gpio + 7, "nCF_SEL");
459 gpio_direction_output(gpio + 7, 1);
460
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500461 /* irlml6401 switches over 1A, in under 8 msec;
462 * now it can be managed by nDRV_VBUS ...
463 */
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +0400464 davinci_setup_usb(1000, 8);
David Brownell34f32c92009-02-20 13:45:17 -0800465
David Brownell7bff3c42008-09-07 23:43:02 -0700466 return 0;
467}
468
469static int
470evm_u35_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
471{
472 gpio_free(gpio + 7);
473 gpio_free(gpio + 6);
474 gpio_free(gpio + 5);
475 gpio_free(gpio + 3);
476 gpio_free(gpio + 2);
477 gpio_free(gpio + 1);
478 gpio_free(gpio + 0);
479 return 0;
480}
481
482static struct pcf857x_platform_data pcf_data_u35 = {
483 .gpio_base = PCF_Uxx_BASE(2),
484 .setup = evm_u35_setup,
485 .teardown = evm_u35_teardown,
486};
487
488/*----------------------------------------------------------------------*/
489
490/* Most of this EEPROM is unused, but U-Boot uses some data:
491 * - 0x7f00, 6 bytes Ethernet Address
492 * - 0x0039, 1 byte NTSC vs PAL (bit 0x80 == PAL)
493 * - ... newer boards may have more
494 */
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500495
David Brownell7bff3c42008-09-07 23:43:02 -0700496static struct at24_platform_data eeprom_info = {
497 .byte_len = (256*1024) / 8,
498 .page_size = 64,
499 .flags = AT24_FLAG_ADDR16,
Mark A. Greerb14dc0f2009-04-15 12:41:27 -0700500 .setup = davinci_get_mac_addr,
501 .context = (void *)0x7f00,
David Brownell7bff3c42008-09-07 23:43:02 -0700502};
503
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500504/*
505 * MSP430 supports RTC, card detection, input from IR remote, and
506 * a bit more. It triggers interrupts on GPIO(7) from pressing
507 * buttons on the IR remote, and for card detect switches.
508 */
509static struct i2c_client *dm6446evm_msp;
510
511static int dm6446evm_msp_probe(struct i2c_client *client,
512 const struct i2c_device_id *id)
513{
514 dm6446evm_msp = client;
515 return 0;
516}
517
518static int dm6446evm_msp_remove(struct i2c_client *client)
519{
520 dm6446evm_msp = NULL;
521 return 0;
522}
523
524static const struct i2c_device_id dm6446evm_msp_ids[] = {
525 { "dm6446evm_msp", 0, },
526 { /* end of list */ },
527};
528
529static struct i2c_driver dm6446evm_msp_driver = {
530 .driver.name = "dm6446evm_msp",
531 .id_table = dm6446evm_msp_ids,
532 .probe = dm6446evm_msp_probe,
533 .remove = dm6446evm_msp_remove,
534};
535
536static int dm6444evm_msp430_get_pins(void)
537{
538 static const char txbuf[2] = { 2, 4, };
539 char buf[4];
540 struct i2c_msg msg[2] = {
541 {
542 .addr = dm6446evm_msp->addr,
543 .flags = 0,
544 .len = 2,
545 .buf = (void __force *)txbuf,
546 },
547 {
548 .addr = dm6446evm_msp->addr,
549 .flags = I2C_M_RD,
550 .len = 4,
551 .buf = buf,
552 },
553 };
554 int status;
555
556 if (!dm6446evm_msp)
557 return -ENXIO;
558
559 /* Command 4 == get input state, returns port 2 and port3 data
560 * S Addr W [A] len=2 [A] cmd=4 [A]
561 * RS Addr R [A] [len=4] A [cmd=4] A [port2] A [port3] N P
562 */
563 status = i2c_transfer(dm6446evm_msp->adapter, msg, 2);
564 if (status < 0)
565 return status;
566
567 dev_dbg(&dm6446evm_msp->dev,
568 "PINS: %02x %02x %02x %02x\n",
569 buf[0], buf[1], buf[2], buf[3]);
570
571 return (buf[3] << 8) | buf[2];
572}
573
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700574static int dm6444evm_mmc_get_cd(int module)
575{
576 int status = dm6444evm_msp430_get_pins();
577
578 return (status < 0) ? status : !(status & BIT(1));
579}
580
581static int dm6444evm_mmc_get_ro(int module)
582{
583 int status = dm6444evm_msp430_get_pins();
584
585 return (status < 0) ? status : status & BIT(6 + 8);
586}
587
588static struct davinci_mmc_config dm6446evm_mmc_config = {
589 .get_cd = dm6444evm_mmc_get_cd,
590 .get_ro = dm6444evm_mmc_get_ro,
591 .wires = 4,
592 .version = MMC_CTLR_VERSION_1
593};
594
David Brownell7bff3c42008-09-07 23:43:02 -0700595static struct i2c_board_info __initdata i2c_info[] = {
596 {
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500597 I2C_BOARD_INFO("dm6446evm_msp", 0x23),
598 },
599 {
David Brownell7bff3c42008-09-07 23:43:02 -0700600 I2C_BOARD_INFO("pcf8574", 0x38),
601 .platform_data = &pcf_data_u2,
602 },
603 {
604 I2C_BOARD_INFO("pcf8574", 0x39),
605 .platform_data = &pcf_data_u18,
606 },
607 {
608 I2C_BOARD_INFO("pcf8574", 0x3a),
609 .platform_data = &pcf_data_u35,
610 },
611 {
612 I2C_BOARD_INFO("24c256", 0x50),
613 .platform_data = &eeprom_info,
614 },
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300615 {
616 I2C_BOARD_INFO("tlv320aic33", 0x1b),
617 },
David Brownell7bff3c42008-09-07 23:43:02 -0700618};
619
620/* The msp430 uses a slow bitbanged I2C implementation (ergo 20 KHz),
621 * which requires 100 usec of idle bus after i2c writes sent to it.
622 */
623static struct davinci_i2c_platform_data i2c_pdata = {
624 .bus_freq = 20 /* kHz */,
625 .bus_delay = 100 /* usec */,
Philby John00642f62010-01-11 15:53:31 +0530626 .sda_pin = 44,
627 .scl_pin = 43,
David Brownell7bff3c42008-09-07 23:43:02 -0700628};
629
630static void __init evm_init_i2c(void)
631{
632 davinci_init_i2c(&i2c_pdata);
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500633 i2c_add_driver(&dm6446evm_msp_driver);
David Brownell7bff3c42008-09-07 23:43:02 -0700634 i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
635}
636
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100637static struct platform_device *davinci_evm_devices[] __initdata = {
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500638 &davinci_fb_device,
639 &rtc_dev,
640};
641
642static struct davinci_uart_config uart_config __initdata = {
643 .enabled_uarts = (1 << 0),
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100644};
645
646static void __init
647davinci_evm_map_io(void)
648{
Muralidharan Karicheriab8e8df2009-09-16 11:53:18 -0400649 /* setup input configuration for VPFE input devices */
650 dm644x_set_vpfe_config(&vpfe_cfg);
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500651 dm644x_init();
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100652}
653
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500654static int davinci_phy_fixup(struct phy_device *phydev)
655{
656 unsigned int control;
657 /* CRITICAL: Fix for increasing PHY signal drive strength for
658 * TX lockup issue. On DaVinci EVM, the Intel LXT971 PHY
659 * signal strength was low causing TX to fail randomly. The
660 * fix is to Set bit 11 (Increased MII drive strength) of PHY
661 * register 26 (Digital Config register) on this phy. */
662 control = phy_read(phydev, 26);
663 phy_write(phydev, 26, (control | 0x800));
664 return 0;
665}
666
667#if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
668 defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE)
669#define HAS_ATA 1
670#else
671#define HAS_ATA 0
672#endif
673
674#if defined(CONFIG_MTD_PHYSMAP) || \
675 defined(CONFIG_MTD_PHYSMAP_MODULE)
676#define HAS_NOR 1
677#else
678#define HAS_NOR 0
679#endif
680
681#if defined(CONFIG_MTD_NAND_DAVINCI) || \
682 defined(CONFIG_MTD_NAND_DAVINCI_MODULE)
683#define HAS_NAND 1
684#else
685#define HAS_NAND 0
686#endif
687
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100688static __init void davinci_evm_init(void)
689{
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500690 struct clk *aemif_clk;
Mark A. Greer972412b2009-04-15 12:40:56 -0700691 struct davinci_soc_info *soc_info = &davinci_soc_info;
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500692
693 aemif_clk = clk_get(NULL, "aemif");
694 clk_enable(aemif_clk);
695
696 if (HAS_ATA) {
697 if (HAS_NAND || HAS_NOR)
698 pr_warning("WARNING: both IDE and Flash are "
699 "enabled, but they share AEMIF pins.\n"
700 "\tDisable IDE for NAND/NOR support.\n");
701 davinci_cfg_reg(DM644X_HPIEN_DISABLE);
702 davinci_cfg_reg(DM644X_ATAEN);
703 davinci_cfg_reg(DM644X_HDIREN);
704 platform_device_register(&ide_dev);
705 } else if (HAS_NAND || HAS_NOR) {
706 davinci_cfg_reg(DM644X_HPIEN_DISABLE);
707 davinci_cfg_reg(DM644X_ATAEN_DISABLE);
708
709 /* only one device will be jumpered and detected */
710 if (HAS_NAND) {
711 platform_device_register(&davinci_evm_nandflash_device);
712 evm_leds[7].default_trigger = "nand-disk";
713 if (HAS_NOR)
714 pr_warning("WARNING: both NAND and NOR flash "
715 "are enabled; disable one of them.\n");
716 } else if (HAS_NOR)
717 platform_device_register(&davinci_evm_norflash_device);
718 }
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100719
720 platform_add_devices(davinci_evm_devices,
721 ARRAY_SIZE(davinci_evm_devices));
David Brownell7bff3c42008-09-07 23:43:02 -0700722 evm_init_i2c();
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500723
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700724 davinci_setup_mmc(0, &dm6446evm_mmc_config);
725
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500726 davinci_serial_init(&uart_config);
Chaithrika U S25acf552009-06-05 06:28:08 -0400727 dm644x_init_asp(&dm644x_evm_snd_data);
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500728
Mark A. Greer972412b2009-04-15 12:40:56 -0700729 soc_info->emac_pdata->phy_mask = DM644X_EVM_PHY_MASK;
730 soc_info->emac_pdata->mdio_max_freq = DM644X_EVM_MDIO_FREQUENCY;
Kevin Hilmanac7b75b2009-05-07 06:19:40 -0700731
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500732 /* Register the fixup for PHY on DaVinci */
733 phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK,
734 davinci_phy_fixup);
735
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100736}
737
738static __init void davinci_evm_irq_init(void)
739{
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100740 davinci_irq_init();
741}
742
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500743MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM")
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100744 /* Maintainer: MontaVista Software <source@mvista.com> */
745 .phys_io = IO_PHYS,
Kevin Hilmanac7643e2008-09-15 04:09:14 -0700746 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100747 .boot_params = (DAVINCI_DDR_BASE + 0x100),
748 .map_io = davinci_evm_map_io,
749 .init_irq = davinci_evm_irq_init,
750 .timer = &davinci_timer,
751 .init_machine = davinci_evm_init,
752MACHINE_END