board-dm646x-evm.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817
  1. /*
  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. * Included Files
  16. **************************************************************************/
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/leds.h>
  20. #include <linux/gpio.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/i2c.h>
  23. #include <linux/platform_data/at24.h>
  24. #include <linux/i2c/pcf857x.h>
  25. #include <media/i2c/tvp514x.h>
  26. #include <media/i2c/adv7343.h>
  27. #include <linux/mtd/mtd.h>
  28. #include <linux/mtd/nand.h>
  29. #include <linux/mtd/partitions.h>
  30. #include <linux/clk.h>
  31. #include <linux/export.h>
  32. #include <linux/platform_data/gpio-davinci.h>
  33. #include <linux/platform_data/i2c-davinci.h>
  34. #include <linux/platform_data/mtd-davinci.h>
  35. #include <linux/platform_data/mtd-davinci-aemif.h>
  36. #include <asm/mach-types.h>
  37. #include <asm/mach/arch.h>
  38. #include <mach/common.h>
  39. #include <mach/irqs.h>
  40. #include <mach/serial.h>
  41. #include <mach/clock.h>
  42. #include "davinci.h"
  43. #include "clock.h"
  44. #define NAND_BLOCK_SIZE SZ_128K
  45. /* Note: We are setting first partition as 'bootloader' constituting UBL, U-Boot
  46. * and U-Boot environment this avoids dependency on any particular combination
  47. * of UBL, U-Boot or flashing tools etc.
  48. */
  49. static struct mtd_partition davinci_nand_partitions[] = {
  50. {
  51. /* UBL, U-Boot with environment */
  52. .name = "bootloader",
  53. .offset = MTDPART_OFS_APPEND,
  54. .size = 16 * NAND_BLOCK_SIZE,
  55. .mask_flags = MTD_WRITEABLE, /* force read-only */
  56. }, {
  57. .name = "kernel",
  58. .offset = MTDPART_OFS_APPEND,
  59. .size = SZ_4M,
  60. .mask_flags = 0,
  61. }, {
  62. .name = "filesystem",
  63. .offset = MTDPART_OFS_APPEND,
  64. .size = MTDPART_SIZ_FULL,
  65. .mask_flags = 0,
  66. }
  67. };
  68. static struct davinci_aemif_timing dm6467tevm_nandflash_timing = {
  69. .wsetup = 29,
  70. .wstrobe = 24,
  71. .whold = 14,
  72. .rsetup = 19,
  73. .rstrobe = 33,
  74. .rhold = 0,
  75. .ta = 29,
  76. };
  77. static struct davinci_nand_pdata davinci_nand_data = {
  78. .mask_cle = 0x80000,
  79. .mask_ale = 0x40000,
  80. .parts = davinci_nand_partitions,
  81. .nr_parts = ARRAY_SIZE(davinci_nand_partitions),
  82. .ecc_mode = NAND_ECC_HW,
  83. .ecc_bits = 1,
  84. .options = 0,
  85. };
  86. static struct resource davinci_nand_resources[] = {
  87. {
  88. .start = DM646X_ASYNC_EMIF_CS2_SPACE_BASE,
  89. .end = DM646X_ASYNC_EMIF_CS2_SPACE_BASE + SZ_32M - 1,
  90. .flags = IORESOURCE_MEM,
  91. }, {
  92. .start = DM646X_ASYNC_EMIF_CONTROL_BASE,
  93. .end = DM646X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
  94. .flags = IORESOURCE_MEM,
  95. },
  96. };
  97. static struct platform_device davinci_nand_device = {
  98. .name = "davinci_nand",
  99. .id = 0,
  100. .num_resources = ARRAY_SIZE(davinci_nand_resources),
  101. .resource = davinci_nand_resources,
  102. .dev = {
  103. .platform_data = &davinci_nand_data,
  104. },
  105. };
  106. #define HAS_ATA IS_ENABLED(CONFIG_BLK_DEV_PALMCHIP_BK3710)
  107. #ifdef CONFIG_I2C
  108. /* CPLD Register 0 bits to control ATA */
  109. #define DM646X_EVM_ATA_RST BIT(0)
  110. #define DM646X_EVM_ATA_PWD BIT(1)
  111. /* CPLD Register 0 Client: used for I/O Control */
  112. static int cpld_reg0_probe(struct i2c_client *client,
  113. const struct i2c_device_id *id)
  114. {
  115. if (HAS_ATA) {
  116. u8 data;
  117. struct i2c_msg msg[2] = {
  118. {
  119. .addr = client->addr,
  120. .flags = I2C_M_RD,
  121. .len = 1,
  122. .buf = &data,
  123. },
  124. {
  125. .addr = client->addr,
  126. .flags = 0,
  127. .len = 1,
  128. .buf = &data,
  129. },
  130. };
  131. /* Clear ATA_RSTn and ATA_PWD bits to enable ATA operation. */
  132. i2c_transfer(client->adapter, msg, 1);
  133. data &= ~(DM646X_EVM_ATA_RST | DM646X_EVM_ATA_PWD);
  134. i2c_transfer(client->adapter, msg + 1, 1);
  135. }
  136. return 0;
  137. }
  138. static const struct i2c_device_id cpld_reg_ids[] = {
  139. { "cpld_reg0", 0, },
  140. { },
  141. };
  142. static struct i2c_driver dm6467evm_cpld_driver = {
  143. .driver.name = "cpld_reg0",
  144. .id_table = cpld_reg_ids,
  145. .probe = cpld_reg0_probe,
  146. };
  147. /* LEDS */
  148. static struct gpio_led evm_leds[] = {
  149. { .name = "DS1", .active_low = 1, },
  150. { .name = "DS2", .active_low = 1, },
  151. { .name = "DS3", .active_low = 1, },
  152. { .name = "DS4", .active_low = 1, },
  153. };
  154. static const struct gpio_led_platform_data evm_led_data = {
  155. .num_leds = ARRAY_SIZE(evm_leds),
  156. .leds = evm_leds,
  157. };
  158. static struct platform_device *evm_led_dev;
  159. static int evm_led_setup(struct i2c_client *client, int gpio,
  160. unsigned int ngpio, void *c)
  161. {
  162. struct gpio_led *leds = evm_leds;
  163. int status;
  164. while (ngpio--) {
  165. leds->gpio = gpio++;
  166. leds++;
  167. }
  168. evm_led_dev = platform_device_alloc("leds-gpio", 0);
  169. platform_device_add_data(evm_led_dev, &evm_led_data,
  170. sizeof(evm_led_data));
  171. evm_led_dev->dev.parent = &client->dev;
  172. status = platform_device_add(evm_led_dev);
  173. if (status < 0) {
  174. platform_device_put(evm_led_dev);
  175. evm_led_dev = NULL;
  176. }
  177. return status;
  178. }
  179. static int evm_led_teardown(struct i2c_client *client, int gpio,
  180. unsigned ngpio, void *c)
  181. {
  182. if (evm_led_dev) {
  183. platform_device_unregister(evm_led_dev);
  184. evm_led_dev = NULL;
  185. }
  186. return 0;
  187. }
  188. static int evm_sw_gpio[4] = { -EINVAL, -EINVAL, -EINVAL, -EINVAL };
  189. static int evm_sw_setup(struct i2c_client *client, int gpio,
  190. unsigned ngpio, void *c)
  191. {
  192. int status;
  193. int i;
  194. char label[10];
  195. for (i = 0; i < 4; ++i) {
  196. snprintf(label, 10, "user_sw%d", i);
  197. status = gpio_request(gpio, label);
  198. if (status)
  199. goto out_free;
  200. evm_sw_gpio[i] = gpio++;
  201. status = gpio_direction_input(evm_sw_gpio[i]);
  202. if (status) {
  203. gpio_free(evm_sw_gpio[i]);
  204. evm_sw_gpio[i] = -EINVAL;
  205. goto out_free;
  206. }
  207. status = gpio_export(evm_sw_gpio[i], 0);
  208. if (status) {
  209. gpio_free(evm_sw_gpio[i]);
  210. evm_sw_gpio[i] = -EINVAL;
  211. goto out_free;
  212. }
  213. }
  214. return status;
  215. out_free:
  216. for (i = 0; i < 4; ++i) {
  217. if (evm_sw_gpio[i] != -EINVAL) {
  218. gpio_free(evm_sw_gpio[i]);
  219. evm_sw_gpio[i] = -EINVAL;
  220. }
  221. }
  222. return status;
  223. }
  224. static int evm_sw_teardown(struct i2c_client *client, int gpio,
  225. unsigned ngpio, void *c)
  226. {
  227. int i;
  228. for (i = 0; i < 4; ++i) {
  229. if (evm_sw_gpio[i] != -EINVAL) {
  230. gpio_unexport(evm_sw_gpio[i]);
  231. gpio_free(evm_sw_gpio[i]);
  232. evm_sw_gpio[i] = -EINVAL;
  233. }
  234. }
  235. return 0;
  236. }
  237. static int evm_pcf_setup(struct i2c_client *client, int gpio,
  238. unsigned int ngpio, void *c)
  239. {
  240. int status;
  241. if (ngpio < 8)
  242. return -EINVAL;
  243. status = evm_sw_setup(client, gpio, 4, c);
  244. if (status)
  245. return status;
  246. return evm_led_setup(client, gpio+4, 4, c);
  247. }
  248. static int evm_pcf_teardown(struct i2c_client *client, int gpio,
  249. unsigned int ngpio, void *c)
  250. {
  251. BUG_ON(ngpio < 8);
  252. evm_sw_teardown(client, gpio, 4, c);
  253. evm_led_teardown(client, gpio+4, 4, c);
  254. return 0;
  255. }
  256. static struct pcf857x_platform_data pcf_data = {
  257. .gpio_base = DAVINCI_N_GPIO+1,
  258. .setup = evm_pcf_setup,
  259. .teardown = evm_pcf_teardown,
  260. };
  261. /* Most of this EEPROM is unused, but U-Boot uses some data:
  262. * - 0x7f00, 6 bytes Ethernet Address
  263. * - ... newer boards may have more
  264. */
  265. static struct at24_platform_data eeprom_info = {
  266. .byte_len = (256*1024) / 8,
  267. .page_size = 64,
  268. .flags = AT24_FLAG_ADDR16,
  269. .setup = davinci_get_mac_addr,
  270. .context = (void *)0x7f00,
  271. };
  272. #endif
  273. static u8 dm646x_iis_serializer_direction[] = {
  274. TX_MODE, RX_MODE, INACTIVE_MODE, INACTIVE_MODE,
  275. };
  276. static u8 dm646x_dit_serializer_direction[] = {
  277. TX_MODE,
  278. };
  279. static struct snd_platform_data dm646x_evm_snd_data[] = {
  280. {
  281. .tx_dma_offset = 0x400,
  282. .rx_dma_offset = 0x400,
  283. .op_mode = DAVINCI_MCASP_IIS_MODE,
  284. .num_serializer = ARRAY_SIZE(dm646x_iis_serializer_direction),
  285. .tdm_slots = 2,
  286. .serial_dir = dm646x_iis_serializer_direction,
  287. .asp_chan_q = EVENTQ_0,
  288. },
  289. {
  290. .tx_dma_offset = 0x400,
  291. .rx_dma_offset = 0,
  292. .op_mode = DAVINCI_MCASP_DIT_MODE,
  293. .num_serializer = ARRAY_SIZE(dm646x_dit_serializer_direction),
  294. .tdm_slots = 32,
  295. .serial_dir = dm646x_dit_serializer_direction,
  296. .asp_chan_q = EVENTQ_0,
  297. },
  298. };
  299. #ifdef CONFIG_I2C
  300. static struct i2c_client *cpld_client;
  301. static int cpld_video_probe(struct i2c_client *client,
  302. const struct i2c_device_id *id)
  303. {
  304. cpld_client = client;
  305. return 0;
  306. }
  307. static int cpld_video_remove(struct i2c_client *client)
  308. {
  309. cpld_client = NULL;
  310. return 0;
  311. }
  312. static const struct i2c_device_id cpld_video_id[] = {
  313. { "cpld_video", 0 },
  314. { }
  315. };
  316. static struct i2c_driver cpld_video_driver = {
  317. .driver = {
  318. .name = "cpld_video",
  319. },
  320. .probe = cpld_video_probe,
  321. .remove = cpld_video_remove,
  322. .id_table = cpld_video_id,
  323. };
  324. static void evm_init_cpld(void)
  325. {
  326. i2c_add_driver(&cpld_video_driver);
  327. }
  328. static struct i2c_board_info __initdata i2c_info[] = {
  329. {
  330. I2C_BOARD_INFO("24c256", 0x50),
  331. .platform_data = &eeprom_info,
  332. },
  333. {
  334. I2C_BOARD_INFO("pcf8574a", 0x38),
  335. .platform_data = &pcf_data,
  336. },
  337. {
  338. I2C_BOARD_INFO("cpld_reg0", 0x3a),
  339. },
  340. {
  341. I2C_BOARD_INFO("tlv320aic33", 0x18),
  342. },
  343. {
  344. I2C_BOARD_INFO("cpld_video", 0x3b),
  345. },
  346. };
  347. static struct davinci_i2c_platform_data i2c_pdata = {
  348. .bus_freq = 100 /* kHz */,
  349. .bus_delay = 0 /* usec */,
  350. };
  351. #define VCH2CLK_MASK (BIT_MASK(10) | BIT_MASK(9) | BIT_MASK(8))
  352. #define VCH2CLK_SYSCLK8 (BIT(9))
  353. #define VCH2CLK_AUXCLK (BIT(9) | BIT(8))
  354. #define VCH3CLK_MASK (BIT_MASK(14) | BIT_MASK(13) | BIT_MASK(12))
  355. #define VCH3CLK_SYSCLK8 (BIT(13))
  356. #define VCH3CLK_AUXCLK (BIT(14) | BIT(13))
  357. #define VIDCH2CLK (BIT(10))
  358. #define VIDCH3CLK (BIT(11))
  359. #define VIDCH1CLK (BIT(4))
  360. #define TVP7002_INPUT (BIT(4))
  361. #define TVP5147_INPUT (~BIT(4))
  362. #define VPIF_INPUT_ONE_CHANNEL (BIT(5))
  363. #define VPIF_INPUT_TWO_CHANNEL (~BIT(5))
  364. #define TVP5147_CH0 "tvp514x-0"
  365. #define TVP5147_CH1 "tvp514x-1"
  366. /* spin lock for updating above registers */
  367. static spinlock_t vpif_reg_lock;
  368. static int set_vpif_clock(int mux_mode, int hd)
  369. {
  370. unsigned long flags;
  371. unsigned int value;
  372. int val = 0;
  373. int err = 0;
  374. if (!cpld_client)
  375. return -ENXIO;
  376. /* disable the clock */
  377. spin_lock_irqsave(&vpif_reg_lock, flags);
  378. value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
  379. value |= (VIDCH3CLK | VIDCH2CLK);
  380. __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
  381. spin_unlock_irqrestore(&vpif_reg_lock, flags);
  382. val = i2c_smbus_read_byte(cpld_client);
  383. if (val < 0)
  384. return val;
  385. if (mux_mode == 1)
  386. val &= ~0x40;
  387. else
  388. val |= 0x40;
  389. err = i2c_smbus_write_byte(cpld_client, val);
  390. if (err)
  391. return err;
  392. value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));
  393. value &= ~(VCH2CLK_MASK);
  394. value &= ~(VCH3CLK_MASK);
  395. if (hd >= 1)
  396. value |= (VCH2CLK_SYSCLK8 | VCH3CLK_SYSCLK8);
  397. else
  398. value |= (VCH2CLK_AUXCLK | VCH3CLK_AUXCLK);
  399. __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));
  400. spin_lock_irqsave(&vpif_reg_lock, flags);
  401. value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
  402. /* enable the clock */
  403. value &= ~(VIDCH3CLK | VIDCH2CLK);
  404. __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
  405. spin_unlock_irqrestore(&vpif_reg_lock, flags);
  406. return 0;
  407. }
  408. static struct vpif_subdev_info dm646x_vpif_subdev[] = {
  409. {
  410. .name = "adv7343",
  411. .board_info = {
  412. I2C_BOARD_INFO("adv7343", 0x2a),
  413. },
  414. },
  415. {
  416. .name = "ths7303",
  417. .board_info = {
  418. I2C_BOARD_INFO("ths7303", 0x2c),
  419. },
  420. },
  421. };
  422. static const struct vpif_output dm6467_ch0_outputs[] = {
  423. {
  424. .output = {
  425. .index = 0,
  426. .name = "Composite",
  427. .type = V4L2_OUTPUT_TYPE_ANALOG,
  428. .capabilities = V4L2_OUT_CAP_STD,
  429. .std = V4L2_STD_ALL,
  430. },
  431. .subdev_name = "adv7343",
  432. .output_route = ADV7343_COMPOSITE_ID,
  433. },
  434. {
  435. .output = {
  436. .index = 1,
  437. .name = "Component",
  438. .type = V4L2_OUTPUT_TYPE_ANALOG,
  439. .capabilities = V4L2_OUT_CAP_DV_TIMINGS,
  440. },
  441. .subdev_name = "adv7343",
  442. .output_route = ADV7343_COMPONENT_ID,
  443. },
  444. {
  445. .output = {
  446. .index = 2,
  447. .name = "S-Video",
  448. .type = V4L2_OUTPUT_TYPE_ANALOG,
  449. .capabilities = V4L2_OUT_CAP_STD,
  450. .std = V4L2_STD_ALL,
  451. },
  452. .subdev_name = "adv7343",
  453. .output_route = ADV7343_SVIDEO_ID,
  454. },
  455. };
  456. static struct vpif_display_config dm646x_vpif_display_config = {
  457. .set_clock = set_vpif_clock,
  458. .subdevinfo = dm646x_vpif_subdev,
  459. .subdev_count = ARRAY_SIZE(dm646x_vpif_subdev),
  460. .chan_config[0] = {
  461. .outputs = dm6467_ch0_outputs,
  462. .output_count = ARRAY_SIZE(dm6467_ch0_outputs),
  463. },
  464. .card_name = "DM646x EVM",
  465. };
  466. /**
  467. * setup_vpif_input_path()
  468. * @channel: channel id (0 - CH0, 1 - CH1)
  469. * @sub_dev_name: ptr sub device name
  470. *
  471. * This will set vpif input to capture data from tvp514x or
  472. * tvp7002.
  473. */
  474. static int setup_vpif_input_path(int channel, const char *sub_dev_name)
  475. {
  476. int err = 0;
  477. int val;
  478. /* for channel 1, we don't do anything */
  479. if (channel != 0)
  480. return 0;
  481. if (!cpld_client)
  482. return -ENXIO;
  483. val = i2c_smbus_read_byte(cpld_client);
  484. if (val < 0)
  485. return val;
  486. if (!strcmp(sub_dev_name, TVP5147_CH0) ||
  487. !strcmp(sub_dev_name, TVP5147_CH1))
  488. val &= TVP5147_INPUT;
  489. else
  490. val |= TVP7002_INPUT;
  491. err = i2c_smbus_write_byte(cpld_client, val);
  492. if (err)
  493. return err;
  494. return 0;
  495. }
  496. /**
  497. * setup_vpif_input_channel_mode()
  498. * @mux_mode: mux mode. 0 - 1 channel or (1) - 2 channel
  499. *
  500. * This will setup input mode to one channel (TVP7002) or 2 channel (TVP5147)
  501. */
  502. static int setup_vpif_input_channel_mode(int mux_mode)
  503. {
  504. unsigned long flags;
  505. int err = 0;
  506. int val;
  507. u32 value;
  508. if (!cpld_client)
  509. return -ENXIO;
  510. val = i2c_smbus_read_byte(cpld_client);
  511. if (val < 0)
  512. return val;
  513. spin_lock_irqsave(&vpif_reg_lock, flags);
  514. value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));
  515. if (mux_mode) {
  516. val &= VPIF_INPUT_TWO_CHANNEL;
  517. value |= VIDCH1CLK;
  518. } else {
  519. val |= VPIF_INPUT_ONE_CHANNEL;
  520. value &= ~VIDCH1CLK;
  521. }
  522. __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));
  523. spin_unlock_irqrestore(&vpif_reg_lock, flags);
  524. err = i2c_smbus_write_byte(cpld_client, val);
  525. if (err)
  526. return err;
  527. return 0;
  528. }
  529. static struct tvp514x_platform_data tvp5146_pdata = {
  530. .clk_polarity = 0,
  531. .hs_polarity = 1,
  532. .vs_polarity = 1
  533. };
  534. #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
  535. static struct vpif_subdev_info vpif_capture_sdev_info[] = {
  536. {
  537. .name = TVP5147_CH0,
  538. .board_info = {
  539. I2C_BOARD_INFO("tvp5146", 0x5d),
  540. .platform_data = &tvp5146_pdata,
  541. },
  542. },
  543. {
  544. .name = TVP5147_CH1,
  545. .board_info = {
  546. I2C_BOARD_INFO("tvp5146", 0x5c),
  547. .platform_data = &tvp5146_pdata,
  548. },
  549. },
  550. };
  551. static const struct vpif_input dm6467_ch0_inputs[] = {
  552. {
  553. .input = {
  554. .index = 0,
  555. .name = "Composite",
  556. .type = V4L2_INPUT_TYPE_CAMERA,
  557. .capabilities = V4L2_IN_CAP_STD,
  558. .std = TVP514X_STD_ALL,
  559. },
  560. .subdev_name = TVP5147_CH0,
  561. .input_route = INPUT_CVBS_VI2B,
  562. .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  563. },
  564. };
  565. static const struct vpif_input dm6467_ch1_inputs[] = {
  566. {
  567. .input = {
  568. .index = 0,
  569. .name = "S-Video",
  570. .type = V4L2_INPUT_TYPE_CAMERA,
  571. .capabilities = V4L2_IN_CAP_STD,
  572. .std = TVP514X_STD_ALL,
  573. },
  574. .subdev_name = TVP5147_CH1,
  575. .input_route = INPUT_SVIDEO_VI2C_VI1C,
  576. .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  577. },
  578. };
  579. static struct vpif_capture_config dm646x_vpif_capture_cfg = {
  580. .setup_input_path = setup_vpif_input_path,
  581. .setup_input_channel_mode = setup_vpif_input_channel_mode,
  582. .subdev_info = vpif_capture_sdev_info,
  583. .subdev_count = ARRAY_SIZE(vpif_capture_sdev_info),
  584. .chan_config[0] = {
  585. .inputs = dm6467_ch0_inputs,
  586. .input_count = ARRAY_SIZE(dm6467_ch0_inputs),
  587. .vpif_if = {
  588. .if_type = VPIF_IF_BT656,
  589. .hd_pol = 1,
  590. .vd_pol = 1,
  591. .fid_pol = 0,
  592. },
  593. },
  594. .chan_config[1] = {
  595. .inputs = dm6467_ch1_inputs,
  596. .input_count = ARRAY_SIZE(dm6467_ch1_inputs),
  597. .vpif_if = {
  598. .if_type = VPIF_IF_BT656,
  599. .hd_pol = 1,
  600. .vd_pol = 1,
  601. .fid_pol = 0,
  602. },
  603. },
  604. };
  605. static void __init evm_init_video(void)
  606. {
  607. spin_lock_init(&vpif_reg_lock);
  608. dm646x_setup_vpif(&dm646x_vpif_display_config,
  609. &dm646x_vpif_capture_cfg);
  610. }
  611. static void __init evm_init_i2c(void)
  612. {
  613. davinci_init_i2c(&i2c_pdata);
  614. i2c_add_driver(&dm6467evm_cpld_driver);
  615. i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
  616. evm_init_cpld();
  617. evm_init_video();
  618. }
  619. #endif
  620. #define DM6467T_EVM_REF_FREQ 33000000
  621. static void __init davinci_map_io(void)
  622. {
  623. dm646x_init();
  624. if (machine_is_davinci_dm6467tevm())
  625. davinci_set_refclk_rate(DM6467T_EVM_REF_FREQ);
  626. }
  627. #define DM646X_EVM_PHY_ID "davinci_mdio-0:01"
  628. /*
  629. * The following EDMA channels/slots are not being used by drivers (for
  630. * example: Timer, GPIO, UART events etc) on dm646x, hence they are being
  631. * reserved for codecs on the DSP side.
  632. */
  633. static const s16 dm646x_dma_rsv_chans[][2] = {
  634. /* (offset, number) */
  635. { 0, 4},
  636. {13, 3},
  637. {24, 4},
  638. {30, 2},
  639. {54, 3},
  640. {-1, -1}
  641. };
  642. static const s16 dm646x_dma_rsv_slots[][2] = {
  643. /* (offset, number) */
  644. { 0, 4},
  645. {13, 3},
  646. {24, 4},
  647. {30, 2},
  648. {54, 3},
  649. {128, 384},
  650. {-1, -1}
  651. };
  652. static struct edma_rsv_info dm646x_edma_rsv[] = {
  653. {
  654. .rsv_chans = dm646x_dma_rsv_chans,
  655. .rsv_slots = dm646x_dma_rsv_slots,
  656. },
  657. };
  658. static __init void evm_init(void)
  659. {
  660. int ret;
  661. struct davinci_soc_info *soc_info = &davinci_soc_info;
  662. ret = dm646x_gpio_register();
  663. if (ret)
  664. pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
  665. #ifdef CONFIG_I2C
  666. evm_init_i2c();
  667. #endif
  668. davinci_serial_init(dm646x_serial_device);
  669. dm646x_init_mcasp0(&dm646x_evm_snd_data[0]);
  670. dm646x_init_mcasp1(&dm646x_evm_snd_data[1]);
  671. if (machine_is_davinci_dm6467tevm())
  672. davinci_nand_data.timing = &dm6467tevm_nandflash_timing;
  673. platform_device_register(&davinci_nand_device);
  674. if (davinci_aemif_setup(&davinci_nand_device))
  675. pr_warn("%s: Cannot configure AEMIF.\n", __func__);
  676. dm646x_init_edma(dm646x_edma_rsv);
  677. if (HAS_ATA)
  678. davinci_init_ide();
  679. soc_info->emac_pdata->phy_id = DM646X_EVM_PHY_ID;
  680. }
  681. MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM")
  682. .atag_offset = 0x100,
  683. .map_io = davinci_map_io,
  684. .init_irq = davinci_irq_init,
  685. .init_time = davinci_timer_init,
  686. .init_machine = evm_init,
  687. .init_late = davinci_init_late,
  688. .dma_zone_size = SZ_128M,
  689. .restart = davinci_restart,
  690. MACHINE_END
  691. MACHINE_START(DAVINCI_DM6467TEVM, "DaVinci DM6467T EVM")
  692. .atag_offset = 0x100,
  693. .map_io = davinci_map_io,
  694. .init_irq = davinci_irq_init,
  695. .init_time = davinci_timer_init,
  696. .init_machine = evm_init,
  697. .init_late = davinci_init_late,
  698. .dma_zone_size = SZ_128M,
  699. .restart = davinci_restart,
  700. MACHINE_END