board-dm646x-evm.c 18 KB

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