board-dm646x-evm.c 18 KB

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