board-dm646x-evm.c 18 KB

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