board-dm646x-evm.c 18 KB

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