board-dm646x-evm.c 17 KB

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