blob: 5ba3cb2daaa0d71bc8a57a403ab2272b1e515232 [file] [log] [blame]
Kevin Hilmane38d92f2009-04-29 17:44:58 -07001/*
2 * TI DaVinci DM646X EVM board
3 *
4 * Derived from: arch/arm/mach-davinci/board-evm.c
5 * Copyright (C) 2006 Texas Instruments.
6 *
7 * (C) 2007-2008, MontaVista Software, Inc.
8 *
9 * This file is licensed under the terms of the GNU General Public License
10 * version 2. This program is licensed "as is" without any warranty of any
11 * kind, whether express or implied.
12 *
13 */
14
15/**************************************************************************
16 * Included Files
17 **************************************************************************/
18
19#include <linux/kernel.h>
Kevin Hilmane38d92f2009-04-29 17:44:58 -070020#include <linux/init.h>
Kevin Hilmane38d92f2009-04-29 17:44:58 -070021#include <linux/leds.h>
22#include <linux/gpio.h>
Kevin Hilmane38d92f2009-04-29 17:44:58 -070023#include <linux/platform_device.h>
24#include <linux/i2c.h>
25#include <linux/i2c/at24.h>
26#include <linux/i2c/pcf857x.h>
Kevin Hilmane38d92f2009-04-29 17:44:58 -070027
Muralidharan Karicheri85609c12009-09-16 13:15:30 -040028#include <media/tvp514x.h>
29
Hemant Pedanekar50fbabf2009-09-18 23:09:29 +053030#include <linux/mtd/mtd.h>
31#include <linux/mtd/nand.h>
32#include <linux/mtd/partitions.h>
Sekhar Noric1978e12009-11-24 18:25:15 +053033#include <linux/clk.h>
Hemant Pedanekar50fbabf2009-09-18 23:09:29 +053034
Kevin Hilmane38d92f2009-04-29 17:44:58 -070035#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
Kevin Hilmane38d92f2009-04-29 17:44:58 -070037
38#include <mach/dm646x.h>
39#include <mach/common.h>
Kevin Hilmane38d92f2009-04-29 17:44:58 -070040#include <mach/serial.h>
41#include <mach/i2c.h>
Hemant Pedanekar50fbabf2009-09-18 23:09:29 +053042#include <mach/nand.h>
Nageswari Srinivasan77a92c72010-01-06 17:19:49 +053043#include <mach/clock.h>
44#include <mach/cdce949.h>
Kevin Hilmanac7b75b2009-05-07 06:19:40 -070045
Sekhar Noric1978e12009-11-24 18:25:15 +053046#include "clock.h"
47
Hemant Pedanekar50fbabf2009-09-18 23:09:29 +053048#define NAND_BLOCK_SIZE SZ_128K
49
Hemant Pedanekar50fbabf2009-09-18 23:09:29 +053050/* Note: We are setting first partition as 'bootloader' constituting UBL, U-Boot
51 * and U-Boot environment this avoids dependency on any particular combination
52 * of UBL, U-Boot or flashing tools etc.
53 */
54static struct mtd_partition davinci_nand_partitions[] = {
55 {
56 /* UBL, U-Boot with environment */
57 .name = "bootloader",
58 .offset = MTDPART_OFS_APPEND,
59 .size = 16 * NAND_BLOCK_SIZE,
60 .mask_flags = MTD_WRITEABLE, /* force read-only */
61 }, {
62 .name = "kernel",
63 .offset = MTDPART_OFS_APPEND,
64 .size = SZ_4M,
65 .mask_flags = 0,
66 }, {
67 .name = "filesystem",
68 .offset = MTDPART_OFS_APPEND,
69 .size = MTDPART_SIZ_FULL,
70 .mask_flags = 0,
71 }
72};
73
74static struct davinci_nand_pdata davinci_nand_data = {
75 .mask_cle = 0x80000,
76 .mask_ale = 0x40000,
77 .parts = davinci_nand_partitions,
78 .nr_parts = ARRAY_SIZE(davinci_nand_partitions),
79 .ecc_mode = NAND_ECC_HW,
80 .options = 0,
81};
82
Sekhar Norib73b5262009-11-24 18:25:14 +053083#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x20008000
84#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x42000000
85
Hemant Pedanekar50fbabf2009-09-18 23:09:29 +053086static struct resource davinci_nand_resources[] = {
87 {
88 .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
89 .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_32M - 1,
90 .flags = IORESOURCE_MEM,
91 }, {
92 .start = DAVINCI_ASYNC_EMIF_CONTROL_BASE,
93 .end = DAVINCI_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
94 .flags = IORESOURCE_MEM,
95 },
96};
97
98static struct platform_device davinci_nand_device = {
99 .name = "davinci_nand",
100 .id = 0,
101
102 .num_resources = ARRAY_SIZE(davinci_nand_resources),
103 .resource = davinci_nand_resources,
104
105 .dev = {
106 .platform_data = &davinci_nand_data,
107 },
108};
109
Sekhar Norib73b5262009-11-24 18:25:14 +0530110#if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
111 defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE)
112#define HAS_ATA 1
113#else
114#define HAS_ATA 0
115#endif
116
117/* CPLD Register 0 bits to control ATA */
118#define DM646X_EVM_ATA_RST BIT(0)
119#define DM646X_EVM_ATA_PWD BIT(1)
120
Hemant Pedanekar548197b2009-07-17 23:30:36 +0530121/* CPLD Register 0 Client: used for I/O Control */
122static int cpld_reg0_probe(struct i2c_client *client,
123 const struct i2c_device_id *id)
124{
125 if (HAS_ATA) {
126 u8 data;
127 struct i2c_msg msg[2] = {
128 {
129 .addr = client->addr,
130 .flags = I2C_M_RD,
131 .len = 1,
132 .buf = &data,
133 },
134 {
135 .addr = client->addr,
136 .flags = 0,
137 .len = 1,
138 .buf = &data,
139 },
140 };
141
142 /* Clear ATA_RSTn and ATA_PWD bits to enable ATA operation. */
143 i2c_transfer(client->adapter, msg, 1);
144 data &= ~(DM646X_EVM_ATA_RST | DM646X_EVM_ATA_PWD);
145 i2c_transfer(client->adapter, msg + 1, 1);
146 }
147
148 return 0;
149}
150
151static const struct i2c_device_id cpld_reg_ids[] = {
152 { "cpld_reg0", 0, },
153 { },
154};
155
156static struct i2c_driver dm6467evm_cpld_driver = {
157 .driver.name = "cpld_reg0",
158 .id_table = cpld_reg_ids,
159 .probe = cpld_reg0_probe,
160};
161
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700162/* LEDS */
163
164static struct gpio_led evm_leds[] = {
165 { .name = "DS1", .active_low = 1, },
166 { .name = "DS2", .active_low = 1, },
167 { .name = "DS3", .active_low = 1, },
168 { .name = "DS4", .active_low = 1, },
169};
170
Sekhar Nori445094f2009-11-04 17:08:42 +0530171static const struct gpio_led_platform_data evm_led_data = {
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700172 .num_leds = ARRAY_SIZE(evm_leds),
173 .leds = evm_leds,
174};
175
176static struct platform_device *evm_led_dev;
177
178static int evm_led_setup(struct i2c_client *client, int gpio,
179 unsigned int ngpio, void *c)
180{
181 struct gpio_led *leds = evm_leds;
182 int status;
183
184 while (ngpio--) {
185 leds->gpio = gpio++;
186 leds++;
187 };
188
189 evm_led_dev = platform_device_alloc("leds-gpio", 0);
190 platform_device_add_data(evm_led_dev, &evm_led_data,
191 sizeof(evm_led_data));
192
193 evm_led_dev->dev.parent = &client->dev;
194 status = platform_device_add(evm_led_dev);
195 if (status < 0) {
196 platform_device_put(evm_led_dev);
197 evm_led_dev = NULL;
198 }
199 return status;
200}
201
202static int evm_led_teardown(struct i2c_client *client, int gpio,
203 unsigned ngpio, void *c)
204{
205 if (evm_led_dev) {
206 platform_device_unregister(evm_led_dev);
207 evm_led_dev = NULL;
208 }
209 return 0;
210}
211
212static int evm_sw_gpio[4] = { -EINVAL, -EINVAL, -EINVAL, -EINVAL };
213
214static int evm_sw_setup(struct i2c_client *client, int gpio,
215 unsigned ngpio, void *c)
216{
217 int status;
218 int i;
219 char label[10];
220
221 for (i = 0; i < 4; ++i) {
222 snprintf(label, 10, "user_sw%d", i);
223 status = gpio_request(gpio, label);
224 if (status)
225 goto out_free;
226 evm_sw_gpio[i] = gpio++;
227
228 status = gpio_direction_input(evm_sw_gpio[i]);
229 if (status) {
230 gpio_free(evm_sw_gpio[i]);
231 evm_sw_gpio[i] = -EINVAL;
232 goto out_free;
233 }
234
235 status = gpio_export(evm_sw_gpio[i], 0);
236 if (status) {
237 gpio_free(evm_sw_gpio[i]);
238 evm_sw_gpio[i] = -EINVAL;
239 goto out_free;
240 }
241 }
242 return status;
243out_free:
244 for (i = 0; i < 4; ++i) {
245 if (evm_sw_gpio[i] != -EINVAL) {
246 gpio_free(evm_sw_gpio[i]);
247 evm_sw_gpio[i] = -EINVAL;
248 }
249 }
250 return status;
251}
252
253static int evm_sw_teardown(struct i2c_client *client, int gpio,
254 unsigned ngpio, void *c)
255{
256 int i;
257
258 for (i = 0; i < 4; ++i) {
259 if (evm_sw_gpio[i] != -EINVAL) {
260 gpio_unexport(evm_sw_gpio[i]);
261 gpio_free(evm_sw_gpio[i]);
262 evm_sw_gpio[i] = -EINVAL;
263 }
264 }
265 return 0;
266}
267
268static int evm_pcf_setup(struct i2c_client *client, int gpio,
269 unsigned int ngpio, void *c)
270{
271 int status;
272
273 if (ngpio < 8)
274 return -EINVAL;
275
276 status = evm_sw_setup(client, gpio, 4, c);
277 if (status)
278 return status;
279
280 return evm_led_setup(client, gpio+4, 4, c);
281}
282
283static int evm_pcf_teardown(struct i2c_client *client, int gpio,
284 unsigned int ngpio, void *c)
285{
286 BUG_ON(ngpio < 8);
287
288 evm_sw_teardown(client, gpio, 4, c);
289 evm_led_teardown(client, gpio+4, 4, c);
290
291 return 0;
292}
293
294static struct pcf857x_platform_data pcf_data = {
295 .gpio_base = DAVINCI_N_GPIO+1,
296 .setup = evm_pcf_setup,
297 .teardown = evm_pcf_teardown,
298};
299
300/* Most of this EEPROM is unused, but U-Boot uses some data:
301 * - 0x7f00, 6 bytes Ethernet Address
302 * - ... newer boards may have more
303 */
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700304
305static struct at24_platform_data eeprom_info = {
306 .byte_len = (256*1024) / 8,
307 .page_size = 64,
308 .flags = AT24_FLAG_ADDR16,
Mark A. Greerb14dc0f2009-04-15 12:41:27 -0700309 .setup = davinci_get_mac_addr,
310 .context = (void *)0x7f00,
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700311};
312
Chaithrika U S25acf552009-06-05 06:28:08 -0400313static u8 dm646x_iis_serializer_direction[] = {
314 TX_MODE, RX_MODE, INACTIVE_MODE, INACTIVE_MODE,
315};
316
317static u8 dm646x_dit_serializer_direction[] = {
318 TX_MODE,
319};
320
321static struct snd_platform_data dm646x_evm_snd_data[] = {
322 {
Chaithrika U S25acf552009-06-05 06:28:08 -0400323 .tx_dma_offset = 0x400,
324 .rx_dma_offset = 0x400,
325 .op_mode = DAVINCI_MCASP_IIS_MODE,
326 .num_serializer = ARRAY_SIZE(dm646x_iis_serializer_direction),
327 .tdm_slots = 2,
328 .serial_dir = dm646x_iis_serializer_direction,
329 .eventq_no = EVENTQ_0,
330 },
331 {
Chaithrika U S25acf552009-06-05 06:28:08 -0400332 .tx_dma_offset = 0x400,
333 .rx_dma_offset = 0,
334 .op_mode = DAVINCI_MCASP_DIT_MODE,
335 .num_serializer = ARRAY_SIZE(dm646x_dit_serializer_direction),
336 .tdm_slots = 32,
337 .serial_dir = dm646x_dit_serializer_direction,
338 .eventq_no = EVENTQ_0,
339 },
340};
341
Muralidharan Karicheri85609c12009-09-16 13:15:30 -0400342static struct i2c_client *cpld_client;
343
344static int cpld_video_probe(struct i2c_client *client,
345 const struct i2c_device_id *id)
346{
347 cpld_client = client;
348 return 0;
349}
350
351static int __devexit cpld_video_remove(struct i2c_client *client)
352{
353 cpld_client = NULL;
354 return 0;
355}
356
357static const struct i2c_device_id cpld_video_id[] = {
358 { "cpld_video", 0 },
359 { }
360};
361
362static struct i2c_driver cpld_video_driver = {
363 .driver = {
364 .name = "cpld_video",
365 },
366 .probe = cpld_video_probe,
367 .remove = cpld_video_remove,
368 .id_table = cpld_video_id,
369};
370
371static void evm_init_cpld(void)
372{
373 i2c_add_driver(&cpld_video_driver);
374}
375
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700376static struct i2c_board_info __initdata i2c_info[] = {
377 {
378 I2C_BOARD_INFO("24c256", 0x50),
379 .platform_data = &eeprom_info,
380 },
381 {
382 I2C_BOARD_INFO("pcf8574a", 0x38),
383 .platform_data = &pcf_data,
384 },
Hemant Pedanekar548197b2009-07-17 23:30:36 +0530385 {
386 I2C_BOARD_INFO("cpld_reg0", 0x3a),
387 },
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300388 {
389 I2C_BOARD_INFO("tlv320aic33", 0x18),
Muralidharan Karicheri85609c12009-09-16 13:15:30 -0400390 },
391 {
392 I2C_BOARD_INFO("cpld_video", 0x3b),
393 },
Nageswari Srinivasan77a92c72010-01-06 17:19:49 +0530394 {
395 I2C_BOARD_INFO("cdce949", 0x6c),
396 },
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700397};
398
399static struct davinci_i2c_platform_data i2c_pdata = {
400 .bus_freq = 100 /* kHz */,
401 .bus_delay = 0 /* usec */,
402};
403
Sekhar Norib73b5262009-11-24 18:25:14 +0530404#define VIDCLKCTL_OFFSET (DAVINCI_SYSTEM_MODULE_BASE + 0x38)
405#define VSCLKDIS_OFFSET (DAVINCI_SYSTEM_MODULE_BASE + 0x6c)
406#define VCH2CLK_MASK (BIT_MASK(10) | BIT_MASK(9) | BIT_MASK(8))
407#define VCH2CLK_SYSCLK8 (BIT(9))
408#define VCH2CLK_AUXCLK (BIT(9) | BIT(8))
409#define VCH3CLK_MASK (BIT_MASK(14) | BIT_MASK(13) | BIT_MASK(12))
410#define VCH3CLK_SYSCLK8 (BIT(13))
411#define VCH3CLK_AUXCLK (BIT(14) | BIT(13))
412
413#define VIDCH2CLK (BIT(10))
414#define VIDCH3CLK (BIT(11))
415#define VIDCH1CLK (BIT(4))
416#define TVP7002_INPUT (BIT(4))
417#define TVP5147_INPUT (~BIT(4))
418#define VPIF_INPUT_ONE_CHANNEL (BIT(5))
419#define VPIF_INPUT_TWO_CHANNEL (~BIT(5))
420#define TVP5147_CH0 "tvp514x-0"
421#define TVP5147_CH1 "tvp514x-1"
422
423static void __iomem *vpif_vidclkctl_reg;
424static void __iomem *vpif_vsclkdis_reg;
425/* spin lock for updating above registers */
426static spinlock_t vpif_reg_lock;
427
Muralidharan Karicheri85609c12009-09-16 13:15:30 -0400428static int set_vpif_clock(int mux_mode, int hd)
429{
430 unsigned long flags;
431 unsigned int value;
432 int val = 0;
433 int err = 0;
434
435 if (!vpif_vidclkctl_reg || !vpif_vsclkdis_reg || !cpld_client)
436 return -ENXIO;
437
438 /* disable the clock */
439 spin_lock_irqsave(&vpif_reg_lock, flags);
440 value = __raw_readl(vpif_vsclkdis_reg);
441 value |= (VIDCH3CLK | VIDCH2CLK);
442 __raw_writel(value, vpif_vsclkdis_reg);
443 spin_unlock_irqrestore(&vpif_reg_lock, flags);
444
445 val = i2c_smbus_read_byte(cpld_client);
446 if (val < 0)
447 return val;
448
449 if (mux_mode == 1)
450 val &= ~0x40;
451 else
452 val |= 0x40;
453
454 err = i2c_smbus_write_byte(cpld_client, val);
455 if (err)
456 return err;
457
458 value = __raw_readl(vpif_vidclkctl_reg);
459 value &= ~(VCH2CLK_MASK);
460 value &= ~(VCH3CLK_MASK);
461
462 if (hd >= 1)
463 value |= (VCH2CLK_SYSCLK8 | VCH3CLK_SYSCLK8);
464 else
465 value |= (VCH2CLK_AUXCLK | VCH3CLK_AUXCLK);
466
467 __raw_writel(value, vpif_vidclkctl_reg);
468
469 spin_lock_irqsave(&vpif_reg_lock, flags);
470 value = __raw_readl(vpif_vsclkdis_reg);
471 /* enable the clock */
472 value &= ~(VIDCH3CLK | VIDCH2CLK);
473 __raw_writel(value, vpif_vsclkdis_reg);
474 spin_unlock_irqrestore(&vpif_reg_lock, flags);
475
476 return 0;
477}
478
479static struct vpif_subdev_info dm646x_vpif_subdev[] = {
480 {
481 .name = "adv7343",
482 .board_info = {
483 I2C_BOARD_INFO("adv7343", 0x2a),
484 },
485 },
486 {
487 .name = "ths7303",
488 .board_info = {
489 I2C_BOARD_INFO("ths7303", 0x2c),
490 },
491 },
492};
493
494static const char *output[] = {
495 "Composite",
496 "Component",
497 "S-Video",
498};
499
500static struct vpif_display_config dm646x_vpif_display_config = {
501 .set_clock = set_vpif_clock,
502 .subdevinfo = dm646x_vpif_subdev,
503 .subdev_count = ARRAY_SIZE(dm646x_vpif_subdev),
504 .output = output,
505 .output_count = ARRAY_SIZE(output),
506 .card_name = "DM646x EVM",
507};
508
509/**
510 * setup_vpif_input_path()
511 * @channel: channel id (0 - CH0, 1 - CH1)
512 * @sub_dev_name: ptr sub device name
513 *
514 * This will set vpif input to capture data from tvp514x or
515 * tvp7002.
516 */
517static int setup_vpif_input_path(int channel, const char *sub_dev_name)
518{
519 int err = 0;
520 int val;
521
522 /* for channel 1, we don't do anything */
523 if (channel != 0)
524 return 0;
525
526 if (!cpld_client)
527 return -ENXIO;
528
529 val = i2c_smbus_read_byte(cpld_client);
530 if (val < 0)
531 return val;
532
533 if (!strcmp(sub_dev_name, TVP5147_CH0) ||
534 !strcmp(sub_dev_name, TVP5147_CH1))
535 val &= TVP5147_INPUT;
536 else
537 val |= TVP7002_INPUT;
538
539 err = i2c_smbus_write_byte(cpld_client, val);
540 if (err)
541 return err;
542 return 0;
543}
544
545/**
546 * setup_vpif_input_channel_mode()
547 * @mux_mode: mux mode. 0 - 1 channel or (1) - 2 channel
548 *
549 * This will setup input mode to one channel (TVP7002) or 2 channel (TVP5147)
550 */
551static int setup_vpif_input_channel_mode(int mux_mode)
552{
553 unsigned long flags;
554 int err = 0;
555 int val;
556 u32 value;
557
558 if (!vpif_vsclkdis_reg || !cpld_client)
559 return -ENXIO;
560
561 val = i2c_smbus_read_byte(cpld_client);
562 if (val < 0)
563 return val;
564
565 spin_lock_irqsave(&vpif_reg_lock, flags);
566 value = __raw_readl(vpif_vsclkdis_reg);
567 if (mux_mode) {
568 val &= VPIF_INPUT_TWO_CHANNEL;
569 value |= VIDCH1CLK;
570 } else {
571 val |= VPIF_INPUT_ONE_CHANNEL;
572 value &= ~VIDCH1CLK;
573 }
574 __raw_writel(value, vpif_vsclkdis_reg);
575 spin_unlock_irqrestore(&vpif_reg_lock, flags);
576
577 err = i2c_smbus_write_byte(cpld_client, val);
578 if (err)
579 return err;
580
581 return 0;
582}
583
584static struct tvp514x_platform_data tvp5146_pdata = {
585 .clk_polarity = 0,
586 .hs_polarity = 1,
587 .vs_polarity = 1
588};
589
590#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
591
592static struct vpif_subdev_info vpif_capture_sdev_info[] = {
593 {
594 .name = TVP5147_CH0,
595 .board_info = {
596 I2C_BOARD_INFO("tvp5146", 0x5d),
597 .platform_data = &tvp5146_pdata,
598 },
599 .input = INPUT_CVBS_VI2B,
600 .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
601 .can_route = 1,
602 .vpif_if = {
603 .if_type = VPIF_IF_BT656,
604 .hd_pol = 1,
605 .vd_pol = 1,
606 .fid_pol = 0,
607 },
608 },
609 {
610 .name = TVP5147_CH1,
611 .board_info = {
612 I2C_BOARD_INFO("tvp5146", 0x5c),
613 .platform_data = &tvp5146_pdata,
614 },
615 .input = INPUT_SVIDEO_VI2C_VI1C,
616 .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
617 .can_route = 1,
618 .vpif_if = {
619 .if_type = VPIF_IF_BT656,
620 .hd_pol = 1,
621 .vd_pol = 1,
622 .fid_pol = 0,
623 },
624 },
625};
626
627static const struct vpif_input dm6467_ch0_inputs[] = {
628 {
629 .input = {
630 .index = 0,
631 .name = "Composite",
632 .type = V4L2_INPUT_TYPE_CAMERA,
633 .std = TVP514X_STD_ALL,
634 },
635 .subdev_name = TVP5147_CH0,
636 },
637};
638
639static const struct vpif_input dm6467_ch1_inputs[] = {
640 {
641 .input = {
642 .index = 0,
643 .name = "S-Video",
644 .type = V4L2_INPUT_TYPE_CAMERA,
645 .std = TVP514X_STD_ALL,
646 },
647 .subdev_name = TVP5147_CH1,
648 },
649};
650
651static struct vpif_capture_config dm646x_vpif_capture_cfg = {
652 .setup_input_path = setup_vpif_input_path,
653 .setup_input_channel_mode = setup_vpif_input_channel_mode,
654 .subdev_info = vpif_capture_sdev_info,
655 .subdev_count = ARRAY_SIZE(vpif_capture_sdev_info),
656 .chan_config[0] = {
657 .inputs = dm6467_ch0_inputs,
658 .input_count = ARRAY_SIZE(dm6467_ch0_inputs),
659 },
660 .chan_config[1] = {
661 .inputs = dm6467_ch1_inputs,
662 .input_count = ARRAY_SIZE(dm6467_ch1_inputs),
663 },
664};
665
666static void __init evm_init_video(void)
667{
668 vpif_vidclkctl_reg = ioremap(VIDCLKCTL_OFFSET, 4);
669 vpif_vsclkdis_reg = ioremap(VSCLKDIS_OFFSET, 4);
670 if (!vpif_vidclkctl_reg || !vpif_vsclkdis_reg) {
671 pr_err("Can't map VPIF VIDCLKCTL or VSCLKDIS registers\n");
672 return;
673 }
674 spin_lock_init(&vpif_reg_lock);
675
676 dm646x_setup_vpif(&dm646x_vpif_display_config,
677 &dm646x_vpif_capture_cfg);
678}
679
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700680static void __init evm_init_i2c(void)
681{
682 davinci_init_i2c(&i2c_pdata);
Hemant Pedanekar548197b2009-07-17 23:30:36 +0530683 i2c_add_driver(&dm6467evm_cpld_driver);
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700684 i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
Muralidharan Karicheri85609c12009-09-16 13:15:30 -0400685 evm_init_cpld();
686 evm_init_video();
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700687}
688
Nageswari Srinivasan77a92c72010-01-06 17:19:49 +0530689#define CDCE949_XIN_RATE 27000000
690
691/* CDCE949 support - "lpsc" field is overridden to work as clock number */
692static struct clk cdce_clk_in = {
693 .name = "cdce_xin",
694 .rate = CDCE949_XIN_RATE,
695};
696
Kevin Hilmanc5641912010-01-11 08:22:23 -0800697static struct clk_lookup cdce_clks[] = {
Nageswari Srinivasan77a92c72010-01-06 17:19:49 +0530698 CLK(NULL, "xin", &cdce_clk_in),
699 CLK(NULL, NULL, NULL),
700};
701
702static void __init cdce_clk_init(void)
703{
Kevin Hilmanc5641912010-01-11 08:22:23 -0800704 struct clk_lookup *c;
Nageswari Srinivasan77a92c72010-01-06 17:19:49 +0530705 struct clk *clk;
706
Kevin Hilmanc5641912010-01-11 08:22:23 -0800707 for (c = cdce_clks; c->clk; c++) {
708 clk = c->clk;
709 clkdev_add(c);
Nageswari Srinivasan77a92c72010-01-06 17:19:49 +0530710 clk_register(clk);
711 }
712}
713
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700714static void __init davinci_map_io(void)
715{
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700716 dm646x_init();
Nageswari Srinivasan77a92c72010-01-06 17:19:49 +0530717 cdce_clk_init();
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700718}
719
Sekhar Norib73b5262009-11-24 18:25:14 +0530720static struct davinci_uart_config uart_config __initdata = {
721 .enabled_uarts = (1 << 0),
722};
723
724#define DM646X_EVM_PHY_MASK (0x2)
725#define DM646X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
726
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700727static __init void evm_init(void)
728{
Mark A. Greer972412b2009-04-15 12:40:56 -0700729 struct davinci_soc_info *soc_info = &davinci_soc_info;
730
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700731 evm_init_i2c();
732 davinci_serial_init(&uart_config);
Chaithrika U S25acf552009-06-05 06:28:08 -0400733 dm646x_init_mcasp0(&dm646x_evm_snd_data[0]);
734 dm646x_init_mcasp1(&dm646x_evm_snd_data[1]);
Mark A. Greer972412b2009-04-15 12:40:56 -0700735
Hemant Pedanekar50fbabf2009-09-18 23:09:29 +0530736 platform_device_register(&davinci_nand_device);
737
Hemant Pedanekar548197b2009-07-17 23:30:36 +0530738 if (HAS_ATA)
739 dm646x_init_ide();
740
Mark A. Greer972412b2009-04-15 12:40:56 -0700741 soc_info->emac_pdata->phy_mask = DM646X_EVM_PHY_MASK;
742 soc_info->emac_pdata->mdio_max_freq = DM646X_EVM_MDIO_FREQUENCY;
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700743}
744
745static __init void davinci_dm646x_evm_irq_init(void)
746{
747 davinci_irq_init();
748}
749
Sekhar Noric1978e12009-11-24 18:25:15 +0530750#define DM646X_EVM_REF_FREQ 27000000
751#define DM6467T_EVM_REF_FREQ 33000000
752
753void __init dm646x_board_setup_refclk(struct clk *clk)
754{
755 if (machine_is_davinci_dm6467tevm())
756 clk->rate = DM6467T_EVM_REF_FREQ;
757 else
758 clk->rate = DM646X_EVM_REF_FREQ;
759}
760
Kevin Hilmane38d92f2009-04-29 17:44:58 -0700761MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM")
762 .phys_io = IO_PHYS,
763 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
764 .boot_params = (0x80000100),
765 .map_io = davinci_map_io,
766 .init_irq = davinci_dm646x_evm_irq_init,
767 .timer = &davinci_timer,
768 .init_machine = evm_init,
769MACHINE_END
770
Sekhar Noric1978e12009-11-24 18:25:15 +0530771MACHINE_START(DAVINCI_DM6467TEVM, "DaVinci DM6467T EVM")
772 .phys_io = IO_PHYS,
773 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
774 .boot_params = (0x80000100),
775 .map_io = davinci_map_io,
776 .init_irq = davinci_dm646x_evm_irq_init,
777 .timer = &davinci_timer,
778 .init_machine = evm_init,
779MACHINE_END
780