board-dm646x-evm.c 19 KB

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