blob: 00a80467b491f5aa3a98e693eb797a774fdbc27d [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>
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050039
40#define DM644X_EVM_PHY_MASK (0x2)
41#define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
Kevin Hilman7c6337e2007-04-30 19:37:19 +010042
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050043#define DAVINCI_CFC_ATA_BASE 0x01C66000
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050044
45#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050046#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050047#define DAVINCI_ASYNC_EMIF_DATA_CE1_BASE 0x04000000
48#define DAVINCI_ASYNC_EMIF_DATA_CE2_BASE 0x06000000
49#define DAVINCI_ASYNC_EMIF_DATA_CE3_BASE 0x08000000
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050050
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050051#define LXT971_PHY_ID (0x001378e2)
52#define LXT971_PHY_MASK (0xfffffff0)
Kevin Hilman7c6337e2007-04-30 19:37:19 +010053
David Brownell7bff3c42008-09-07 23:43:02 -070054static struct mtd_partition davinci_evm_norflash_partitions[] = {
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050055 /* bootloader (UBL, U-Boot, etc) in first 5 sectors */
Kevin Hilman7c6337e2007-04-30 19:37:19 +010056 {
57 .name = "bootloader",
58 .offset = 0,
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050059 .size = 5 * SZ_64K,
Kevin Hilman7c6337e2007-04-30 19:37:19 +010060 .mask_flags = MTD_WRITEABLE, /* force read-only */
61 },
62 /* bootloader params in the next 1 sectors */
63 {
64 .name = "params",
65 .offset = MTDPART_OFS_APPEND,
66 .size = SZ_64K,
67 .mask_flags = 0,
68 },
69 /* kernel */
70 {
71 .name = "kernel",
72 .offset = MTDPART_OFS_APPEND,
73 .size = SZ_2M,
74 .mask_flags = 0
75 },
76 /* file system */
77 {
78 .name = "filesystem",
79 .offset = MTDPART_OFS_APPEND,
80 .size = MTDPART_SIZ_FULL,
81 .mask_flags = 0
82 }
83};
84
David Brownell7bff3c42008-09-07 23:43:02 -070085static struct physmap_flash_data davinci_evm_norflash_data = {
Kevin Hilman7c6337e2007-04-30 19:37:19 +010086 .width = 2,
David Brownell7bff3c42008-09-07 23:43:02 -070087 .parts = davinci_evm_norflash_partitions,
88 .nr_parts = ARRAY_SIZE(davinci_evm_norflash_partitions),
Kevin Hilman7c6337e2007-04-30 19:37:19 +010089};
90
91/* NOTE: CFI probe will correctly detect flash part as 32M, but EMIF
92 * limits addresses to 16M, so using addresses past 16M will wrap */
David Brownell7bff3c42008-09-07 23:43:02 -070093static struct resource davinci_evm_norflash_resource = {
94 .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
95 .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
Kevin Hilman7c6337e2007-04-30 19:37:19 +010096 .flags = IORESOURCE_MEM,
97};
98
David Brownell7bff3c42008-09-07 23:43:02 -070099static struct platform_device davinci_evm_norflash_device = {
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100100 .name = "physmap-flash",
101 .id = 0,
102 .dev = {
David Brownell7bff3c42008-09-07 23:43:02 -0700103 .platform_data = &davinci_evm_norflash_data,
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100104 },
105 .num_resources = 1,
David Brownell7bff3c42008-09-07 23:43:02 -0700106 .resource = &davinci_evm_norflash_resource,
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100107};
108
David Brownell3e9c18e2009-04-15 14:19:21 -0500109/* DM644x EVM includes a 64 MByte small-page NAND flash (16K blocks).
110 * It may used instead of the (default) NOR chip to boot, using TI's
111 * tools to install the secondary boot loader (UBL) and U-Boot.
112 */
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500113struct mtd_partition davinci_evm_nandflash_partition[] = {
David Brownell3e9c18e2009-04-15 14:19:21 -0500114 /* Bootloader layout depends on whose u-boot is installed, but we
115 * can hide all the details.
116 * - block 0 for u-boot environment ... in mainline u-boot
117 * - block 1 for UBL (plus up to four backup copies in blocks 2..5)
118 * - blocks 6...? for u-boot
119 * - blocks 16..23 for u-boot environment ... in TI's u-boot
120 */
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500121 {
David Brownell3e9c18e2009-04-15 14:19:21 -0500122 .name = "bootloader",
123 .offset = 0,
124 .size = SZ_256K + SZ_128K,
125 .mask_flags = MTD_WRITEABLE, /* force read-only */
126 },
127 /* Kernel */
128 {
129 .name = "kernel",
130 .offset = MTDPART_OFS_APPEND,
131 .size = SZ_4M,
132 .mask_flags = 0,
133 },
134 /* File system (older GIT kernels started this on the 5MB mark) */
135 {
136 .name = "filesystem",
137 .offset = MTDPART_OFS_APPEND,
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500138 .size = MTDPART_SIZ_FULL,
139 .mask_flags = 0,
140 }
David Brownell3e9c18e2009-04-15 14:19:21 -0500141 /* A few blocks at end hold a flash BBT ... created by TI's CCS
142 * using flashwriter_nand.out, but ignored by TI's versions of
143 * Linux and u-boot. We boot faster by using them.
144 */
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500145};
David Brownell7bff3c42008-09-07 23:43:02 -0700146
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500147static struct davinci_nand_pdata davinci_evm_nandflash_data = {
148 .parts = davinci_evm_nandflash_partition,
149 .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition),
150 .ecc_mode = NAND_ECC_HW,
David Brownell3e9c18e2009-04-15 14:19:21 -0500151 .options = NAND_USE_FLASH_BBT,
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500152};
153
154static struct resource davinci_evm_nandflash_resource[] = {
155 {
156 .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
157 .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
158 .flags = IORESOURCE_MEM,
159 }, {
160 .start = DAVINCI_ASYNC_EMIF_CONTROL_BASE,
161 .end = DAVINCI_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
162 .flags = IORESOURCE_MEM,
163 },
164};
165
166static struct platform_device davinci_evm_nandflash_device = {
167 .name = "davinci_nand",
168 .id = 0,
169 .dev = {
170 .platform_data = &davinci_evm_nandflash_data,
171 },
172 .num_resources = ARRAY_SIZE(davinci_evm_nandflash_resource),
173 .resource = davinci_evm_nandflash_resource,
174};
175
David Brownell3e9c18e2009-04-15 14:19:21 -0500176static u64 davinci_fb_dma_mask = DMA_BIT_MASK(32);
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500177
178static struct platform_device davinci_fb_device = {
179 .name = "davincifb",
180 .id = -1,
181 .dev = {
182 .dma_mask = &davinci_fb_dma_mask,
David Brownell3e9c18e2009-04-15 14:19:21 -0500183 .coherent_dma_mask = DMA_BIT_MASK(32),
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500184 },
185 .num_resources = 0,
186};
187
Muralidharan Karicheriab8e8df2009-09-16 11:53:18 -0400188static struct tvp514x_platform_data tvp5146_pdata = {
189 .clk_polarity = 0,
190 .hs_polarity = 1,
191 .vs_polarity = 1
192};
193
194#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
195/* Inputs available at the TVP5146 */
196static struct v4l2_input tvp5146_inputs[] = {
197 {
198 .index = 0,
199 .name = "Composite",
200 .type = V4L2_INPUT_TYPE_CAMERA,
201 .std = TVP514X_STD_ALL,
202 },
203 {
204 .index = 1,
205 .name = "S-Video",
206 .type = V4L2_INPUT_TYPE_CAMERA,
207 .std = TVP514X_STD_ALL,
208 },
209};
210
211/*
212 * this is the route info for connecting each input to decoder
213 * ouput that goes to vpfe. There is a one to one correspondence
214 * with tvp5146_inputs
215 */
216static struct vpfe_route tvp5146_routes[] = {
217 {
218 .input = INPUT_CVBS_VI2B,
219 .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
220 },
221 {
222 .input = INPUT_SVIDEO_VI2C_VI1C,
223 .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
224 },
225};
226
227static struct vpfe_subdev_info vpfe_sub_devs[] = {
228 {
229 .name = "tvp5146",
230 .grp_id = 0,
231 .num_inputs = ARRAY_SIZE(tvp5146_inputs),
232 .inputs = tvp5146_inputs,
233 .routes = tvp5146_routes,
234 .can_route = 1,
235 .ccdc_if_params = {
236 .if_type = VPFE_BT656,
237 .hdpol = VPFE_PINPOL_POSITIVE,
238 .vdpol = VPFE_PINPOL_POSITIVE,
239 },
240 .board_info = {
241 I2C_BOARD_INFO("tvp5146", 0x5d),
242 .platform_data = &tvp5146_pdata,
243 },
244 },
245};
246
247static struct vpfe_config vpfe_cfg = {
248 .num_subdevs = ARRAY_SIZE(vpfe_sub_devs),
249 .sub_devs = vpfe_sub_devs,
250 .card_name = "DM6446 EVM",
251 .ccdc = "DM6446 CCDC",
252};
253
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500254static struct platform_device rtc_dev = {
255 .name = "rtc_davinci_evm",
256 .id = -1,
257};
David Brownell7bff3c42008-09-07 23:43:02 -0700258
259static struct resource ide_resources[] = {
260 {
261 .start = DAVINCI_CFC_ATA_BASE,
262 .end = DAVINCI_CFC_ATA_BASE + 0x7ff,
263 .flags = IORESOURCE_MEM,
264 },
265 {
266 .start = IRQ_IDE,
267 .end = IRQ_IDE,
268 .flags = IORESOURCE_IRQ,
269 },
270};
271
Kevin Hilmana029b702009-05-07 14:25:48 +0100272static u64 ide_dma_mask = DMA_BIT_MASK(32);
David Brownell7bff3c42008-09-07 23:43:02 -0700273
274static struct platform_device ide_dev = {
275 .name = "palm_bk3710",
276 .id = -1,
277 .resource = ide_resources,
278 .num_resources = ARRAY_SIZE(ide_resources),
279 .dev = {
280 .dma_mask = &ide_dma_mask,
Kevin Hilmana029b702009-05-07 14:25:48 +0100281 .coherent_dma_mask = DMA_BIT_MASK(32),
David Brownell7bff3c42008-09-07 23:43:02 -0700282 },
283};
284
Kevin Hilman61aa0732009-07-15 08:47:48 -0700285static struct snd_platform_data dm644x_evm_snd_data;
Chaithrika U S25acf552009-06-05 06:28:08 -0400286
David Brownell7bff3c42008-09-07 23:43:02 -0700287/*----------------------------------------------------------------------*/
288
289/*
290 * I2C GPIO expanders
291 */
292
293#define PCF_Uxx_BASE(x) (DAVINCI_N_GPIO + ((x) * 8))
294
295
296/* U2 -- LEDs */
297
298static struct gpio_led evm_leds[] = {
299 { .name = "DS8", .active_low = 1,
300 .default_trigger = "heartbeat", },
301 { .name = "DS7", .active_low = 1, },
302 { .name = "DS6", .active_low = 1, },
303 { .name = "DS5", .active_low = 1, },
304 { .name = "DS4", .active_low = 1, },
305 { .name = "DS3", .active_low = 1, },
306 { .name = "DS2", .active_low = 1,
307 .default_trigger = "mmc0", },
308 { .name = "DS1", .active_low = 1,
309 .default_trigger = "ide-disk", },
310};
311
312static const struct gpio_led_platform_data evm_led_data = {
313 .num_leds = ARRAY_SIZE(evm_leds),
314 .leds = evm_leds,
315};
316
317static struct platform_device *evm_led_dev;
318
319static int
320evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
321{
322 struct gpio_led *leds = evm_leds;
323 int status;
324
325 while (ngpio--) {
326 leds->gpio = gpio++;
327 leds++;
328 }
329
330 /* what an extremely annoying way to be forced to handle
331 * device unregistration ...
332 */
333 evm_led_dev = platform_device_alloc("leds-gpio", 0);
334 platform_device_add_data(evm_led_dev,
335 &evm_led_data, sizeof evm_led_data);
336
337 evm_led_dev->dev.parent = &client->dev;
338 status = platform_device_add(evm_led_dev);
339 if (status < 0) {
340 platform_device_put(evm_led_dev);
341 evm_led_dev = NULL;
342 }
343 return status;
344}
345
346static int
347evm_led_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
348{
349 if (evm_led_dev) {
350 platform_device_unregister(evm_led_dev);
351 evm_led_dev = NULL;
352 }
353 return 0;
354}
355
356static struct pcf857x_platform_data pcf_data_u2 = {
357 .gpio_base = PCF_Uxx_BASE(0),
358 .setup = evm_led_setup,
359 .teardown = evm_led_teardown,
360};
361
362
363/* U18 - A/V clock generator and user switch */
364
365static int sw_gpio;
366
367static ssize_t
368sw_show(struct device *d, struct device_attribute *a, char *buf)
369{
370 char *s = gpio_get_value_cansleep(sw_gpio) ? "on\n" : "off\n";
371
372 strcpy(buf, s);
373 return strlen(s);
374}
375
376static DEVICE_ATTR(user_sw, S_IRUGO, sw_show, NULL);
377
378static int
379evm_u18_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
380{
381 int status;
382
383 /* export dip switch option */
384 sw_gpio = gpio + 7;
385 status = gpio_request(sw_gpio, "user_sw");
386 if (status == 0)
387 status = gpio_direction_input(sw_gpio);
388 if (status == 0)
389 status = device_create_file(&client->dev, &dev_attr_user_sw);
390 else
391 gpio_free(sw_gpio);
392 if (status != 0)
393 sw_gpio = -EINVAL;
394
395 /* audio PLL: 48 kHz (vs 44.1 or 32), single rate (vs double) */
396 gpio_request(gpio + 3, "pll_fs2");
397 gpio_direction_output(gpio + 3, 0);
398
399 gpio_request(gpio + 2, "pll_fs1");
400 gpio_direction_output(gpio + 2, 0);
401
402 gpio_request(gpio + 1, "pll_sr");
403 gpio_direction_output(gpio + 1, 0);
404
405 return 0;
406}
407
408static int
409evm_u18_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
410{
411 gpio_free(gpio + 1);
412 gpio_free(gpio + 2);
413 gpio_free(gpio + 3);
414
415 if (sw_gpio > 0) {
416 device_remove_file(&client->dev, &dev_attr_user_sw);
417 gpio_free(sw_gpio);
418 }
419 return 0;
420}
421
422static struct pcf857x_platform_data pcf_data_u18 = {
423 .gpio_base = PCF_Uxx_BASE(1),
424 .n_latch = (1 << 3) | (1 << 2) | (1 << 1),
425 .setup = evm_u18_setup,
426 .teardown = evm_u18_teardown,
427};
428
429
430/* U35 - various I/O signals used to manage USB, CF, ATA, etc */
431
432static int
433evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
434{
435 /* p0 = nDRV_VBUS (initial: don't supply it) */
436 gpio_request(gpio + 0, "nDRV_VBUS");
437 gpio_direction_output(gpio + 0, 1);
438
439 /* p1 = VDDIMX_EN */
440 gpio_request(gpio + 1, "VDDIMX_EN");
441 gpio_direction_output(gpio + 1, 1);
442
443 /* p2 = VLYNQ_EN */
444 gpio_request(gpio + 2, "VLYNQ_EN");
445 gpio_direction_output(gpio + 2, 1);
446
447 /* p3 = n3V3_CF_RESET (initial: stay in reset) */
448 gpio_request(gpio + 3, "nCF_RESET");
449 gpio_direction_output(gpio + 3, 0);
450
451 /* (p4 unused) */
452
453 /* p5 = 1V8_WLAN_RESET (initial: stay in reset) */
454 gpio_request(gpio + 5, "WLAN_RESET");
455 gpio_direction_output(gpio + 5, 1);
456
457 /* p6 = nATA_SEL (initial: select) */
458 gpio_request(gpio + 6, "nATA_SEL");
459 gpio_direction_output(gpio + 6, 0);
460
461 /* p7 = nCF_SEL (initial: deselect) */
462 gpio_request(gpio + 7, "nCF_SEL");
463 gpio_direction_output(gpio + 7, 1);
464
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500465 /* irlml6401 switches over 1A, in under 8 msec;
466 * now it can be managed by nDRV_VBUS ...
467 */
David Brownell34f32c92009-02-20 13:45:17 -0800468 setup_usb(500, 8);
469
David Brownell7bff3c42008-09-07 23:43:02 -0700470 return 0;
471}
472
473static int
474evm_u35_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
475{
476 gpio_free(gpio + 7);
477 gpio_free(gpio + 6);
478 gpio_free(gpio + 5);
479 gpio_free(gpio + 3);
480 gpio_free(gpio + 2);
481 gpio_free(gpio + 1);
482 gpio_free(gpio + 0);
483 return 0;
484}
485
486static struct pcf857x_platform_data pcf_data_u35 = {
487 .gpio_base = PCF_Uxx_BASE(2),
488 .setup = evm_u35_setup,
489 .teardown = evm_u35_teardown,
490};
491
492/*----------------------------------------------------------------------*/
493
494/* Most of this EEPROM is unused, but U-Boot uses some data:
495 * - 0x7f00, 6 bytes Ethernet Address
496 * - 0x0039, 1 byte NTSC vs PAL (bit 0x80 == PAL)
497 * - ... newer boards may have more
498 */
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500499
David Brownell7bff3c42008-09-07 23:43:02 -0700500static struct at24_platform_data eeprom_info = {
501 .byte_len = (256*1024) / 8,
502 .page_size = 64,
503 .flags = AT24_FLAG_ADDR16,
Mark A. Greerb14dc0f2009-04-15 12:41:27 -0700504 .setup = davinci_get_mac_addr,
505 .context = (void *)0x7f00,
David Brownell7bff3c42008-09-07 23:43:02 -0700506};
507
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500508/*
509 * MSP430 supports RTC, card detection, input from IR remote, and
510 * a bit more. It triggers interrupts on GPIO(7) from pressing
511 * buttons on the IR remote, and for card detect switches.
512 */
513static struct i2c_client *dm6446evm_msp;
514
515static int dm6446evm_msp_probe(struct i2c_client *client,
516 const struct i2c_device_id *id)
517{
518 dm6446evm_msp = client;
519 return 0;
520}
521
522static int dm6446evm_msp_remove(struct i2c_client *client)
523{
524 dm6446evm_msp = NULL;
525 return 0;
526}
527
528static const struct i2c_device_id dm6446evm_msp_ids[] = {
529 { "dm6446evm_msp", 0, },
530 { /* end of list */ },
531};
532
533static struct i2c_driver dm6446evm_msp_driver = {
534 .driver.name = "dm6446evm_msp",
535 .id_table = dm6446evm_msp_ids,
536 .probe = dm6446evm_msp_probe,
537 .remove = dm6446evm_msp_remove,
538};
539
540static int dm6444evm_msp430_get_pins(void)
541{
542 static const char txbuf[2] = { 2, 4, };
543 char buf[4];
544 struct i2c_msg msg[2] = {
545 {
546 .addr = dm6446evm_msp->addr,
547 .flags = 0,
548 .len = 2,
549 .buf = (void __force *)txbuf,
550 },
551 {
552 .addr = dm6446evm_msp->addr,
553 .flags = I2C_M_RD,
554 .len = 4,
555 .buf = buf,
556 },
557 };
558 int status;
559
560 if (!dm6446evm_msp)
561 return -ENXIO;
562
563 /* Command 4 == get input state, returns port 2 and port3 data
564 * S Addr W [A] len=2 [A] cmd=4 [A]
565 * RS Addr R [A] [len=4] A [cmd=4] A [port2] A [port3] N P
566 */
567 status = i2c_transfer(dm6446evm_msp->adapter, msg, 2);
568 if (status < 0)
569 return status;
570
571 dev_dbg(&dm6446evm_msp->dev,
572 "PINS: %02x %02x %02x %02x\n",
573 buf[0], buf[1], buf[2], buf[3]);
574
575 return (buf[3] << 8) | buf[2];
576}
577
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700578static int dm6444evm_mmc_get_cd(int module)
579{
580 int status = dm6444evm_msp430_get_pins();
581
582 return (status < 0) ? status : !(status & BIT(1));
583}
584
585static int dm6444evm_mmc_get_ro(int module)
586{
587 int status = dm6444evm_msp430_get_pins();
588
589 return (status < 0) ? status : status & BIT(6 + 8);
590}
591
592static struct davinci_mmc_config dm6446evm_mmc_config = {
593 .get_cd = dm6444evm_mmc_get_cd,
594 .get_ro = dm6444evm_mmc_get_ro,
595 .wires = 4,
596 .version = MMC_CTLR_VERSION_1
597};
598
David Brownell7bff3c42008-09-07 23:43:02 -0700599static struct i2c_board_info __initdata i2c_info[] = {
600 {
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500601 I2C_BOARD_INFO("dm6446evm_msp", 0x23),
602 },
603 {
David Brownell7bff3c42008-09-07 23:43:02 -0700604 I2C_BOARD_INFO("pcf8574", 0x38),
605 .platform_data = &pcf_data_u2,
606 },
607 {
608 I2C_BOARD_INFO("pcf8574", 0x39),
609 .platform_data = &pcf_data_u18,
610 },
611 {
612 I2C_BOARD_INFO("pcf8574", 0x3a),
613 .platform_data = &pcf_data_u35,
614 },
615 {
616 I2C_BOARD_INFO("24c256", 0x50),
617 .platform_data = &eeprom_info,
618 },
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300619 {
620 I2C_BOARD_INFO("tlv320aic33", 0x1b),
621 },
David Brownell7bff3c42008-09-07 23:43:02 -0700622};
623
624/* The msp430 uses a slow bitbanged I2C implementation (ergo 20 KHz),
625 * which requires 100 usec of idle bus after i2c writes sent to it.
626 */
627static struct davinci_i2c_platform_data i2c_pdata = {
628 .bus_freq = 20 /* kHz */,
629 .bus_delay = 100 /* usec */,
630};
631
632static void __init evm_init_i2c(void)
633{
634 davinci_init_i2c(&i2c_pdata);
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500635 i2c_add_driver(&dm6446evm_msp_driver);
David Brownell7bff3c42008-09-07 23:43:02 -0700636 i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
637}
638
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100639static struct platform_device *davinci_evm_devices[] __initdata = {
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500640 &davinci_fb_device,
641 &rtc_dev,
642};
643
644static struct davinci_uart_config uart_config __initdata = {
645 .enabled_uarts = (1 << 0),
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100646};
647
648static void __init
649davinci_evm_map_io(void)
650{
Muralidharan Karicheriab8e8df2009-09-16 11:53:18 -0400651 /* setup input configuration for VPFE input devices */
652 dm644x_set_vpfe_config(&vpfe_cfg);
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500653 dm644x_init();
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100654}
655
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500656static int davinci_phy_fixup(struct phy_device *phydev)
657{
658 unsigned int control;
659 /* CRITICAL: Fix for increasing PHY signal drive strength for
660 * TX lockup issue. On DaVinci EVM, the Intel LXT971 PHY
661 * signal strength was low causing TX to fail randomly. The
662 * fix is to Set bit 11 (Increased MII drive strength) of PHY
663 * register 26 (Digital Config register) on this phy. */
664 control = phy_read(phydev, 26);
665 phy_write(phydev, 26, (control | 0x800));
666 return 0;
667}
668
669#if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
670 defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE)
671#define HAS_ATA 1
672#else
673#define HAS_ATA 0
674#endif
675
676#if defined(CONFIG_MTD_PHYSMAP) || \
677 defined(CONFIG_MTD_PHYSMAP_MODULE)
678#define HAS_NOR 1
679#else
680#define HAS_NOR 0
681#endif
682
683#if defined(CONFIG_MTD_NAND_DAVINCI) || \
684 defined(CONFIG_MTD_NAND_DAVINCI_MODULE)
685#define HAS_NAND 1
686#else
687#define HAS_NAND 0
688#endif
689
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100690static __init void davinci_evm_init(void)
691{
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500692 struct clk *aemif_clk;
Mark A. Greer972412b2009-04-15 12:40:56 -0700693 struct davinci_soc_info *soc_info = &davinci_soc_info;
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500694
695 aemif_clk = clk_get(NULL, "aemif");
696 clk_enable(aemif_clk);
697
698 if (HAS_ATA) {
699 if (HAS_NAND || HAS_NOR)
700 pr_warning("WARNING: both IDE and Flash are "
701 "enabled, but they share AEMIF pins.\n"
702 "\tDisable IDE for NAND/NOR support.\n");
703 davinci_cfg_reg(DM644X_HPIEN_DISABLE);
704 davinci_cfg_reg(DM644X_ATAEN);
705 davinci_cfg_reg(DM644X_HDIREN);
706 platform_device_register(&ide_dev);
707 } else if (HAS_NAND || HAS_NOR) {
708 davinci_cfg_reg(DM644X_HPIEN_DISABLE);
709 davinci_cfg_reg(DM644X_ATAEN_DISABLE);
710
711 /* only one device will be jumpered and detected */
712 if (HAS_NAND) {
713 platform_device_register(&davinci_evm_nandflash_device);
714 evm_leds[7].default_trigger = "nand-disk";
715 if (HAS_NOR)
716 pr_warning("WARNING: both NAND and NOR flash "
717 "are enabled; disable one of them.\n");
718 } else if (HAS_NOR)
719 platform_device_register(&davinci_evm_norflash_device);
720 }
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100721
722 platform_add_devices(davinci_evm_devices,
723 ARRAY_SIZE(davinci_evm_devices));
David Brownell7bff3c42008-09-07 23:43:02 -0700724 evm_init_i2c();
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500725
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700726 davinci_setup_mmc(0, &dm6446evm_mmc_config);
727
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500728 davinci_serial_init(&uart_config);
Chaithrika U S25acf552009-06-05 06:28:08 -0400729 dm644x_init_asp(&dm644x_evm_snd_data);
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500730
Mark A. Greer972412b2009-04-15 12:40:56 -0700731 soc_info->emac_pdata->phy_mask = DM644X_EVM_PHY_MASK;
732 soc_info->emac_pdata->mdio_max_freq = DM644X_EVM_MDIO_FREQUENCY;
Kevin Hilmanac7b75b2009-05-07 06:19:40 -0700733
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500734 /* Register the fixup for PHY on DaVinci */
735 phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK,
736 davinci_phy_fixup);
737
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100738}
739
740static __init void davinci_evm_irq_init(void)
741{
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100742 davinci_irq_init();
743}
744
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500745MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM")
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100746 /* Maintainer: MontaVista Software <source@mvista.com> */
747 .phys_io = IO_PHYS,
Kevin Hilmanac7643e2008-09-15 04:09:14 -0700748 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
Kevin Hilman7c6337e2007-04-30 19:37:19 +0100749 .boot_params = (DAVINCI_DDR_BASE + 0x100),
750 .map_io = davinci_evm_map_io,
751 .init_irq = davinci_evm_irq_init,
752 .timer = &davinci_timer,
753 .init_machine = davinci_evm_init,
754MACHINE_END