board-dm644x-evm.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. /*
  2. * TI DaVinci EVM board support
  3. *
  4. * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com>
  5. *
  6. * 2007 (c) MontaVista Software, Inc. This file is licensed under
  7. * the terms of the GNU General Public License version 2. This program
  8. * is licensed "as is" without any warranty of any kind, whether express
  9. * or implied.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/dma-mapping.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/gpio.h>
  16. #include <linux/gpio/machine.h>
  17. #include <linux/i2c.h>
  18. #include <linux/platform_data/pcf857x.h>
  19. #include <linux/platform_data/at24.h>
  20. #include <linux/platform_data/gpio-davinci.h>
  21. #include <linux/mtd/mtd.h>
  22. #include <linux/mtd/rawnand.h>
  23. #include <linux/mtd/partitions.h>
  24. #include <linux/mtd/physmap.h>
  25. #include <linux/phy.h>
  26. #include <linux/clk.h>
  27. #include <linux/videodev2.h>
  28. #include <linux/v4l2-dv-timings.h>
  29. #include <linux/export.h>
  30. #include <linux/leds.h>
  31. #include <media/i2c/tvp514x.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <mach/common.h>
  35. #include <linux/platform_data/i2c-davinci.h>
  36. #include <mach/serial.h>
  37. #include <mach/mux.h>
  38. #include <linux/platform_data/mtd-davinci.h>
  39. #include <linux/platform_data/mmc-davinci.h>
  40. #include <linux/platform_data/usb-davinci.h>
  41. #include <linux/platform_data/mtd-davinci-aemif.h>
  42. #include <linux/platform_data/ti-aemif.h>
  43. #include "davinci.h"
  44. #define DM644X_EVM_PHY_ID "davinci_mdio-0:01"
  45. #define LXT971_PHY_ID (0x001378e2)
  46. #define LXT971_PHY_MASK (0xfffffff0)
  47. static struct mtd_partition davinci_evm_norflash_partitions[] = {
  48. /* bootloader (UBL, U-Boot, etc) in first 5 sectors */
  49. {
  50. .name = "bootloader",
  51. .offset = 0,
  52. .size = 5 * SZ_64K,
  53. .mask_flags = MTD_WRITEABLE, /* force read-only */
  54. },
  55. /* bootloader params in the next 1 sectors */
  56. {
  57. .name = "params",
  58. .offset = MTDPART_OFS_APPEND,
  59. .size = SZ_64K,
  60. .mask_flags = 0,
  61. },
  62. /* kernel */
  63. {
  64. .name = "kernel",
  65. .offset = MTDPART_OFS_APPEND,
  66. .size = SZ_2M,
  67. .mask_flags = 0
  68. },
  69. /* file system */
  70. {
  71. .name = "filesystem",
  72. .offset = MTDPART_OFS_APPEND,
  73. .size = MTDPART_SIZ_FULL,
  74. .mask_flags = 0
  75. }
  76. };
  77. static struct physmap_flash_data davinci_evm_norflash_data = {
  78. .width = 2,
  79. .parts = davinci_evm_norflash_partitions,
  80. .nr_parts = ARRAY_SIZE(davinci_evm_norflash_partitions),
  81. };
  82. /* NOTE: CFI probe will correctly detect flash part as 32M, but EMIF
  83. * limits addresses to 16M, so using addresses past 16M will wrap */
  84. static struct resource davinci_evm_norflash_resource = {
  85. .start = DM644X_ASYNC_EMIF_DATA_CE0_BASE,
  86. .end = DM644X_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
  87. .flags = IORESOURCE_MEM,
  88. };
  89. static struct platform_device davinci_evm_norflash_device = {
  90. .name = "physmap-flash",
  91. .id = 0,
  92. .dev = {
  93. .platform_data = &davinci_evm_norflash_data,
  94. },
  95. .num_resources = 1,
  96. .resource = &davinci_evm_norflash_resource,
  97. };
  98. /* DM644x EVM includes a 64 MByte small-page NAND flash (16K blocks).
  99. * It may used instead of the (default) NOR chip to boot, using TI's
  100. * tools to install the secondary boot loader (UBL) and U-Boot.
  101. */
  102. static struct mtd_partition davinci_evm_nandflash_partition[] = {
  103. /* Bootloader layout depends on whose u-boot is installed, but we
  104. * can hide all the details.
  105. * - block 0 for u-boot environment ... in mainline u-boot
  106. * - block 1 for UBL (plus up to four backup copies in blocks 2..5)
  107. * - blocks 6...? for u-boot
  108. * - blocks 16..23 for u-boot environment ... in TI's u-boot
  109. */
  110. {
  111. .name = "bootloader",
  112. .offset = 0,
  113. .size = SZ_256K + SZ_128K,
  114. .mask_flags = MTD_WRITEABLE, /* force read-only */
  115. },
  116. /* Kernel */
  117. {
  118. .name = "kernel",
  119. .offset = MTDPART_OFS_APPEND,
  120. .size = SZ_4M,
  121. .mask_flags = 0,
  122. },
  123. /* File system (older GIT kernels started this on the 5MB mark) */
  124. {
  125. .name = "filesystem",
  126. .offset = MTDPART_OFS_APPEND,
  127. .size = MTDPART_SIZ_FULL,
  128. .mask_flags = 0,
  129. }
  130. /* A few blocks at end hold a flash BBT ... created by TI's CCS
  131. * using flashwriter_nand.out, but ignored by TI's versions of
  132. * Linux and u-boot. We boot faster by using them.
  133. */
  134. };
  135. static struct davinci_aemif_timing davinci_evm_nandflash_timing = {
  136. .wsetup = 20,
  137. .wstrobe = 40,
  138. .whold = 20,
  139. .rsetup = 10,
  140. .rstrobe = 40,
  141. .rhold = 10,
  142. .ta = 40,
  143. };
  144. static struct davinci_nand_pdata davinci_evm_nandflash_data = {
  145. .core_chipsel = 0,
  146. .parts = davinci_evm_nandflash_partition,
  147. .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition),
  148. .ecc_mode = NAND_ECC_HW,
  149. .ecc_bits = 1,
  150. .bbt_options = NAND_BBT_USE_FLASH,
  151. .timing = &davinci_evm_nandflash_timing,
  152. };
  153. static struct resource davinci_evm_nandflash_resource[] = {
  154. {
  155. .start = DM644X_ASYNC_EMIF_DATA_CE0_BASE,
  156. .end = DM644X_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
  157. .flags = IORESOURCE_MEM,
  158. }, {
  159. .start = DM644X_ASYNC_EMIF_CONTROL_BASE,
  160. .end = DM644X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
  161. .flags = IORESOURCE_MEM,
  162. },
  163. };
  164. static struct resource davinci_evm_aemif_resource[] = {
  165. {
  166. .start = DM644X_ASYNC_EMIF_CONTROL_BASE,
  167. .end = DM644X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
  168. .flags = IORESOURCE_MEM,
  169. },
  170. };
  171. static struct aemif_abus_data davinci_evm_aemif_abus_data[] = {
  172. {
  173. .cs = 1,
  174. },
  175. };
  176. static struct platform_device davinci_evm_nandflash_devices[] = {
  177. {
  178. .name = "davinci_nand",
  179. .id = 0,
  180. .dev = {
  181. .platform_data = &davinci_evm_nandflash_data,
  182. },
  183. .num_resources = ARRAY_SIZE(davinci_evm_nandflash_resource),
  184. .resource = davinci_evm_nandflash_resource,
  185. },
  186. };
  187. static struct aemif_platform_data davinci_evm_aemif_pdata = {
  188. .abus_data = davinci_evm_aemif_abus_data,
  189. .num_abus_data = ARRAY_SIZE(davinci_evm_aemif_abus_data),
  190. .sub_devices = davinci_evm_nandflash_devices,
  191. .num_sub_devices = ARRAY_SIZE(davinci_evm_nandflash_devices),
  192. };
  193. static struct platform_device davinci_evm_aemif_device = {
  194. .name = "ti-aemif",
  195. .id = -1,
  196. .dev = {
  197. .platform_data = &davinci_evm_aemif_pdata,
  198. },
  199. .resource = davinci_evm_aemif_resource,
  200. .num_resources = ARRAY_SIZE(davinci_evm_aemif_resource),
  201. };
  202. static u64 davinci_fb_dma_mask = DMA_BIT_MASK(32);
  203. static struct platform_device davinci_fb_device = {
  204. .name = "davincifb",
  205. .id = -1,
  206. .dev = {
  207. .dma_mask = &davinci_fb_dma_mask,
  208. .coherent_dma_mask = DMA_BIT_MASK(32),
  209. },
  210. .num_resources = 0,
  211. };
  212. static struct tvp514x_platform_data dm644xevm_tvp5146_pdata = {
  213. .clk_polarity = 0,
  214. .hs_polarity = 1,
  215. .vs_polarity = 1
  216. };
  217. #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
  218. /* Inputs available at the TVP5146 */
  219. static struct v4l2_input dm644xevm_tvp5146_inputs[] = {
  220. {
  221. .index = 0,
  222. .name = "Composite",
  223. .type = V4L2_INPUT_TYPE_CAMERA,
  224. .std = TVP514X_STD_ALL,
  225. },
  226. {
  227. .index = 1,
  228. .name = "S-Video",
  229. .type = V4L2_INPUT_TYPE_CAMERA,
  230. .std = TVP514X_STD_ALL,
  231. },
  232. };
  233. /*
  234. * this is the route info for connecting each input to decoder
  235. * ouput that goes to vpfe. There is a one to one correspondence
  236. * with tvp5146_inputs
  237. */
  238. static struct vpfe_route dm644xevm_tvp5146_routes[] = {
  239. {
  240. .input = INPUT_CVBS_VI2B,
  241. .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  242. },
  243. {
  244. .input = INPUT_SVIDEO_VI2C_VI1C,
  245. .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  246. },
  247. };
  248. static struct vpfe_subdev_info dm644xevm_vpfe_sub_devs[] = {
  249. {
  250. .name = "tvp5146",
  251. .grp_id = 0,
  252. .num_inputs = ARRAY_SIZE(dm644xevm_tvp5146_inputs),
  253. .inputs = dm644xevm_tvp5146_inputs,
  254. .routes = dm644xevm_tvp5146_routes,
  255. .can_route = 1,
  256. .ccdc_if_params = {
  257. .if_type = VPFE_BT656,
  258. .hdpol = VPFE_PINPOL_POSITIVE,
  259. .vdpol = VPFE_PINPOL_POSITIVE,
  260. },
  261. .board_info = {
  262. I2C_BOARD_INFO("tvp5146", 0x5d),
  263. .platform_data = &dm644xevm_tvp5146_pdata,
  264. },
  265. },
  266. };
  267. static struct vpfe_config dm644xevm_capture_cfg = {
  268. .num_subdevs = ARRAY_SIZE(dm644xevm_vpfe_sub_devs),
  269. .i2c_adapter_id = 1,
  270. .sub_devs = dm644xevm_vpfe_sub_devs,
  271. .card_name = "DM6446 EVM",
  272. .ccdc = "DM6446 CCDC",
  273. };
  274. static struct platform_device rtc_dev = {
  275. .name = "rtc_davinci_evm",
  276. .id = -1,
  277. };
  278. /*----------------------------------------------------------------------*/
  279. #ifdef CONFIG_I2C
  280. /*
  281. * I2C GPIO expanders
  282. */
  283. #define PCF_Uxx_BASE(x) (DAVINCI_N_GPIO + ((x) * 8))
  284. /* U2 -- LEDs */
  285. static struct gpio_led evm_leds[] = {
  286. { .name = "DS8", .active_low = 1,
  287. .default_trigger = "heartbeat", },
  288. { .name = "DS7", .active_low = 1, },
  289. { .name = "DS6", .active_low = 1, },
  290. { .name = "DS5", .active_low = 1, },
  291. { .name = "DS4", .active_low = 1, },
  292. { .name = "DS3", .active_low = 1, },
  293. { .name = "DS2", .active_low = 1,
  294. .default_trigger = "mmc0", },
  295. { .name = "DS1", .active_low = 1,
  296. .default_trigger = "disk-activity", },
  297. };
  298. static const struct gpio_led_platform_data evm_led_data = {
  299. .num_leds = ARRAY_SIZE(evm_leds),
  300. .leds = evm_leds,
  301. };
  302. static struct platform_device *evm_led_dev;
  303. static int
  304. evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  305. {
  306. struct gpio_led *leds = evm_leds;
  307. int status;
  308. while (ngpio--) {
  309. leds->gpio = gpio++;
  310. leds++;
  311. }
  312. /* what an extremely annoying way to be forced to handle
  313. * device unregistration ...
  314. */
  315. evm_led_dev = platform_device_alloc("leds-gpio", 0);
  316. platform_device_add_data(evm_led_dev,
  317. &evm_led_data, sizeof evm_led_data);
  318. evm_led_dev->dev.parent = &client->dev;
  319. status = platform_device_add(evm_led_dev);
  320. if (status < 0) {
  321. platform_device_put(evm_led_dev);
  322. evm_led_dev = NULL;
  323. }
  324. return status;
  325. }
  326. static int
  327. evm_led_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  328. {
  329. if (evm_led_dev) {
  330. platform_device_unregister(evm_led_dev);
  331. evm_led_dev = NULL;
  332. }
  333. return 0;
  334. }
  335. static struct pcf857x_platform_data pcf_data_u2 = {
  336. .gpio_base = PCF_Uxx_BASE(0),
  337. .setup = evm_led_setup,
  338. .teardown = evm_led_teardown,
  339. };
  340. /* U18 - A/V clock generator and user switch */
  341. static int sw_gpio;
  342. static ssize_t
  343. sw_show(struct device *d, struct device_attribute *a, char *buf)
  344. {
  345. char *s = gpio_get_value_cansleep(sw_gpio) ? "on\n" : "off\n";
  346. strcpy(buf, s);
  347. return strlen(s);
  348. }
  349. static DEVICE_ATTR(user_sw, S_IRUGO, sw_show, NULL);
  350. static int
  351. evm_u18_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  352. {
  353. int status;
  354. /* export dip switch option */
  355. sw_gpio = gpio + 7;
  356. status = gpio_request(sw_gpio, "user_sw");
  357. if (status == 0)
  358. status = gpio_direction_input(sw_gpio);
  359. if (status == 0)
  360. status = device_create_file(&client->dev, &dev_attr_user_sw);
  361. else
  362. gpio_free(sw_gpio);
  363. if (status != 0)
  364. sw_gpio = -EINVAL;
  365. /* audio PLL: 48 kHz (vs 44.1 or 32), single rate (vs double) */
  366. gpio_request(gpio + 3, "pll_fs2");
  367. gpio_direction_output(gpio + 3, 0);
  368. gpio_request(gpio + 2, "pll_fs1");
  369. gpio_direction_output(gpio + 2, 0);
  370. gpio_request(gpio + 1, "pll_sr");
  371. gpio_direction_output(gpio + 1, 0);
  372. return 0;
  373. }
  374. static int
  375. evm_u18_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  376. {
  377. gpio_free(gpio + 1);
  378. gpio_free(gpio + 2);
  379. gpio_free(gpio + 3);
  380. if (sw_gpio > 0) {
  381. device_remove_file(&client->dev, &dev_attr_user_sw);
  382. gpio_free(sw_gpio);
  383. }
  384. return 0;
  385. }
  386. static struct pcf857x_platform_data pcf_data_u18 = {
  387. .gpio_base = PCF_Uxx_BASE(1),
  388. .n_latch = (1 << 3) | (1 << 2) | (1 << 1),
  389. .setup = evm_u18_setup,
  390. .teardown = evm_u18_teardown,
  391. };
  392. /* U35 - various I/O signals used to manage USB, CF, ATA, etc */
  393. static int
  394. evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  395. {
  396. /* p0 = nDRV_VBUS (initial: don't supply it) */
  397. gpio_request(gpio + 0, "nDRV_VBUS");
  398. gpio_direction_output(gpio + 0, 1);
  399. /* p1 = VDDIMX_EN */
  400. gpio_request(gpio + 1, "VDDIMX_EN");
  401. gpio_direction_output(gpio + 1, 1);
  402. /* p2 = VLYNQ_EN */
  403. gpio_request(gpio + 2, "VLYNQ_EN");
  404. gpio_direction_output(gpio + 2, 1);
  405. /* p3 = n3V3_CF_RESET (initial: stay in reset) */
  406. gpio_request(gpio + 3, "nCF_RESET");
  407. gpio_direction_output(gpio + 3, 0);
  408. /* (p4 unused) */
  409. /* p5 = 1V8_WLAN_RESET (initial: stay in reset) */
  410. gpio_request(gpio + 5, "WLAN_RESET");
  411. gpio_direction_output(gpio + 5, 1);
  412. /* p6 = nATA_SEL (initial: select) */
  413. gpio_request(gpio + 6, "nATA_SEL");
  414. gpio_direction_output(gpio + 6, 0);
  415. /* p7 = nCF_SEL (initial: deselect) */
  416. gpio_request(gpio + 7, "nCF_SEL");
  417. gpio_direction_output(gpio + 7, 1);
  418. return 0;
  419. }
  420. static int
  421. evm_u35_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  422. {
  423. gpio_free(gpio + 7);
  424. gpio_free(gpio + 6);
  425. gpio_free(gpio + 5);
  426. gpio_free(gpio + 3);
  427. gpio_free(gpio + 2);
  428. gpio_free(gpio + 1);
  429. gpio_free(gpio + 0);
  430. return 0;
  431. }
  432. static struct pcf857x_platform_data pcf_data_u35 = {
  433. .gpio_base = PCF_Uxx_BASE(2),
  434. .setup = evm_u35_setup,
  435. .teardown = evm_u35_teardown,
  436. };
  437. /*----------------------------------------------------------------------*/
  438. /* Most of this EEPROM is unused, but U-Boot uses some data:
  439. * - 0x7f00, 6 bytes Ethernet Address
  440. * - 0x0039, 1 byte NTSC vs PAL (bit 0x80 == PAL)
  441. * - ... newer boards may have more
  442. */
  443. static struct at24_platform_data eeprom_info = {
  444. .byte_len = (256*1024) / 8,
  445. .page_size = 64,
  446. .flags = AT24_FLAG_ADDR16,
  447. .setup = davinci_get_mac_addr,
  448. .context = (void *)0x7f00,
  449. };
  450. /*
  451. * MSP430 supports RTC, card detection, input from IR remote, and
  452. * a bit more. It triggers interrupts on GPIO(7) from pressing
  453. * buttons on the IR remote, and for card detect switches.
  454. */
  455. static struct i2c_client *dm6446evm_msp;
  456. static int dm6446evm_msp_probe(struct i2c_client *client,
  457. const struct i2c_device_id *id)
  458. {
  459. dm6446evm_msp = client;
  460. return 0;
  461. }
  462. static int dm6446evm_msp_remove(struct i2c_client *client)
  463. {
  464. dm6446evm_msp = NULL;
  465. return 0;
  466. }
  467. static const struct i2c_device_id dm6446evm_msp_ids[] = {
  468. { "dm6446evm_msp", 0, },
  469. { /* end of list */ },
  470. };
  471. static struct i2c_driver dm6446evm_msp_driver = {
  472. .driver.name = "dm6446evm_msp",
  473. .id_table = dm6446evm_msp_ids,
  474. .probe = dm6446evm_msp_probe,
  475. .remove = dm6446evm_msp_remove,
  476. };
  477. static int dm6444evm_msp430_get_pins(void)
  478. {
  479. static const char txbuf[2] = { 2, 4, };
  480. char buf[4];
  481. struct i2c_msg msg[2] = {
  482. {
  483. .flags = 0,
  484. .len = 2,
  485. .buf = (void __force *)txbuf,
  486. },
  487. {
  488. .flags = I2C_M_RD,
  489. .len = 4,
  490. .buf = buf,
  491. },
  492. };
  493. int status;
  494. if (!dm6446evm_msp)
  495. return -ENXIO;
  496. msg[0].addr = dm6446evm_msp->addr;
  497. msg[1].addr = dm6446evm_msp->addr;
  498. /* Command 4 == get input state, returns port 2 and port3 data
  499. * S Addr W [A] len=2 [A] cmd=4 [A]
  500. * RS Addr R [A] [len=4] A [cmd=4] A [port2] A [port3] N P
  501. */
  502. status = i2c_transfer(dm6446evm_msp->adapter, msg, 2);
  503. if (status < 0)
  504. return status;
  505. dev_dbg(&dm6446evm_msp->dev, "PINS: %4ph\n", buf);
  506. return (buf[3] << 8) | buf[2];
  507. }
  508. static int dm6444evm_mmc_get_cd(int module)
  509. {
  510. int status = dm6444evm_msp430_get_pins();
  511. return (status < 0) ? status : !(status & BIT(1));
  512. }
  513. static int dm6444evm_mmc_get_ro(int module)
  514. {
  515. int status = dm6444evm_msp430_get_pins();
  516. return (status < 0) ? status : status & BIT(6 + 8);
  517. }
  518. static struct davinci_mmc_config dm6446evm_mmc_config = {
  519. .get_cd = dm6444evm_mmc_get_cd,
  520. .get_ro = dm6444evm_mmc_get_ro,
  521. .wires = 4,
  522. };
  523. static struct i2c_board_info __initdata i2c_info[] = {
  524. {
  525. I2C_BOARD_INFO("dm6446evm_msp", 0x23),
  526. },
  527. {
  528. I2C_BOARD_INFO("pcf8574", 0x38),
  529. .platform_data = &pcf_data_u2,
  530. },
  531. {
  532. I2C_BOARD_INFO("pcf8574", 0x39),
  533. .platform_data = &pcf_data_u18,
  534. },
  535. {
  536. I2C_BOARD_INFO("pcf8574", 0x3a),
  537. .platform_data = &pcf_data_u35,
  538. },
  539. {
  540. I2C_BOARD_INFO("24c256", 0x50),
  541. .platform_data = &eeprom_info,
  542. },
  543. {
  544. I2C_BOARD_INFO("tlv320aic33", 0x1b),
  545. },
  546. };
  547. #define DM644X_I2C_SDA_PIN GPIO_TO_PIN(2, 12)
  548. #define DM644X_I2C_SCL_PIN GPIO_TO_PIN(2, 11)
  549. static struct gpiod_lookup_table i2c_recovery_gpiod_table = {
  550. .dev_id = "i2c_davinci.1",
  551. .table = {
  552. GPIO_LOOKUP("davinci_gpio.0", DM644X_I2C_SDA_PIN, "sda",
  553. GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
  554. GPIO_LOOKUP("davinci_gpio.0", DM644X_I2C_SCL_PIN, "scl",
  555. GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
  556. },
  557. };
  558. /* The msp430 uses a slow bitbanged I2C implementation (ergo 20 KHz),
  559. * which requires 100 usec of idle bus after i2c writes sent to it.
  560. */
  561. static struct davinci_i2c_platform_data i2c_pdata = {
  562. .bus_freq = 20 /* kHz */,
  563. .bus_delay = 100 /* usec */,
  564. .gpio_recovery = true,
  565. };
  566. static void __init evm_init_i2c(void)
  567. {
  568. gpiod_add_lookup_table(&i2c_recovery_gpiod_table);
  569. davinci_init_i2c(&i2c_pdata);
  570. i2c_add_driver(&dm6446evm_msp_driver);
  571. i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
  572. }
  573. #endif
  574. #define VENC_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
  575. /* venc standard timings */
  576. static struct vpbe_enc_mode_info dm644xevm_enc_std_timing[] = {
  577. {
  578. .name = "ntsc",
  579. .timings_type = VPBE_ENC_STD,
  580. .std_id = V4L2_STD_NTSC,
  581. .interlaced = 1,
  582. .xres = 720,
  583. .yres = 480,
  584. .aspect = {11, 10},
  585. .fps = {30000, 1001},
  586. .left_margin = 0x79,
  587. .upper_margin = 0x10,
  588. },
  589. {
  590. .name = "pal",
  591. .timings_type = VPBE_ENC_STD,
  592. .std_id = V4L2_STD_PAL,
  593. .interlaced = 1,
  594. .xres = 720,
  595. .yres = 576,
  596. .aspect = {54, 59},
  597. .fps = {25, 1},
  598. .left_margin = 0x7e,
  599. .upper_margin = 0x16,
  600. },
  601. };
  602. /* venc dv preset timings */
  603. static struct vpbe_enc_mode_info dm644xevm_enc_preset_timing[] = {
  604. {
  605. .name = "480p59_94",
  606. .timings_type = VPBE_ENC_DV_TIMINGS,
  607. .dv_timings = V4L2_DV_BT_CEA_720X480P59_94,
  608. .interlaced = 0,
  609. .xres = 720,
  610. .yres = 480,
  611. .aspect = {1, 1},
  612. .fps = {5994, 100},
  613. .left_margin = 0x80,
  614. .upper_margin = 0x20,
  615. },
  616. {
  617. .name = "576p50",
  618. .timings_type = VPBE_ENC_DV_TIMINGS,
  619. .dv_timings = V4L2_DV_BT_CEA_720X576P50,
  620. .interlaced = 0,
  621. .xres = 720,
  622. .yres = 576,
  623. .aspect = {1, 1},
  624. .fps = {50, 1},
  625. .left_margin = 0x7e,
  626. .upper_margin = 0x30,
  627. },
  628. };
  629. /*
  630. * The outputs available from VPBE + encoders. Keep the order same
  631. * as that of encoders. First those from venc followed by that from
  632. * encoders. Index in the output refers to index on a particular encoder.
  633. * Driver uses this index to pass it to encoder when it supports more
  634. * than one output. Userspace applications use index of the array to
  635. * set an output.
  636. */
  637. static struct vpbe_output dm644xevm_vpbe_outputs[] = {
  638. {
  639. .output = {
  640. .index = 0,
  641. .name = "Composite",
  642. .type = V4L2_OUTPUT_TYPE_ANALOG,
  643. .std = VENC_STD_ALL,
  644. .capabilities = V4L2_OUT_CAP_STD,
  645. },
  646. .subdev_name = DM644X_VPBE_VENC_SUBDEV_NAME,
  647. .default_mode = "ntsc",
  648. .num_modes = ARRAY_SIZE(dm644xevm_enc_std_timing),
  649. .modes = dm644xevm_enc_std_timing,
  650. },
  651. {
  652. .output = {
  653. .index = 1,
  654. .name = "Component",
  655. .type = V4L2_OUTPUT_TYPE_ANALOG,
  656. .capabilities = V4L2_OUT_CAP_DV_TIMINGS,
  657. },
  658. .subdev_name = DM644X_VPBE_VENC_SUBDEV_NAME,
  659. .default_mode = "480p59_94",
  660. .num_modes = ARRAY_SIZE(dm644xevm_enc_preset_timing),
  661. .modes = dm644xevm_enc_preset_timing,
  662. },
  663. };
  664. static struct vpbe_config dm644xevm_display_cfg = {
  665. .module_name = "dm644x-vpbe-display",
  666. .i2c_adapter_id = 1,
  667. .osd = {
  668. .module_name = DM644X_VPBE_OSD_SUBDEV_NAME,
  669. },
  670. .venc = {
  671. .module_name = DM644X_VPBE_VENC_SUBDEV_NAME,
  672. },
  673. .num_outputs = ARRAY_SIZE(dm644xevm_vpbe_outputs),
  674. .outputs = dm644xevm_vpbe_outputs,
  675. };
  676. static struct platform_device *davinci_evm_devices[] __initdata = {
  677. &davinci_fb_device,
  678. &rtc_dev,
  679. };
  680. static void __init
  681. davinci_evm_map_io(void)
  682. {
  683. dm644x_init();
  684. }
  685. static int davinci_phy_fixup(struct phy_device *phydev)
  686. {
  687. unsigned int control;
  688. /* CRITICAL: Fix for increasing PHY signal drive strength for
  689. * TX lockup issue. On DaVinci EVM, the Intel LXT971 PHY
  690. * signal strength was low causing TX to fail randomly. The
  691. * fix is to Set bit 11 (Increased MII drive strength) of PHY
  692. * register 26 (Digital Config register) on this phy. */
  693. control = phy_read(phydev, 26);
  694. phy_write(phydev, 26, (control | 0x800));
  695. return 0;
  696. }
  697. #define HAS_ATA (IS_ENABLED(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
  698. IS_ENABLED(CONFIG_PATA_BK3710))
  699. #define HAS_NOR IS_ENABLED(CONFIG_MTD_PHYSMAP)
  700. #define HAS_NAND IS_ENABLED(CONFIG_MTD_NAND_DAVINCI)
  701. static __init void davinci_evm_init(void)
  702. {
  703. int ret;
  704. struct clk *aemif_clk;
  705. struct davinci_soc_info *soc_info = &davinci_soc_info;
  706. dm644x_register_clocks();
  707. dm644x_init_devices();
  708. ret = dm644x_gpio_register();
  709. if (ret)
  710. pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
  711. aemif_clk = clk_get(NULL, "aemif");
  712. clk_prepare_enable(aemif_clk);
  713. if (HAS_ATA) {
  714. if (HAS_NAND || HAS_NOR)
  715. pr_warn("WARNING: both IDE and Flash are enabled, but they share AEMIF pins\n"
  716. "\tDisable IDE for NAND/NOR support\n");
  717. davinci_init_ide();
  718. } else if (HAS_NAND || HAS_NOR) {
  719. davinci_cfg_reg(DM644X_HPIEN_DISABLE);
  720. davinci_cfg_reg(DM644X_ATAEN_DISABLE);
  721. /* only one device will be jumpered and detected */
  722. if (HAS_NAND) {
  723. platform_device_register(&davinci_evm_aemif_device);
  724. #ifdef CONFIG_I2C
  725. evm_leds[7].default_trigger = "nand-disk";
  726. #endif
  727. if (HAS_NOR)
  728. pr_warn("WARNING: both NAND and NOR flash are enabled; disable one of them.\n");
  729. } else if (HAS_NOR)
  730. platform_device_register(&davinci_evm_norflash_device);
  731. }
  732. platform_add_devices(davinci_evm_devices,
  733. ARRAY_SIZE(davinci_evm_devices));
  734. #ifdef CONFIG_I2C
  735. evm_init_i2c();
  736. davinci_setup_mmc(0, &dm6446evm_mmc_config);
  737. #endif
  738. dm644x_init_video(&dm644xevm_capture_cfg, &dm644xevm_display_cfg);
  739. davinci_serial_init(dm644x_serial_device);
  740. dm644x_init_asp();
  741. /* irlml6401 switches over 1A, in under 8 msec */
  742. davinci_setup_usb(1000, 8);
  743. if (IS_BUILTIN(CONFIG_PHYLIB)) {
  744. soc_info->emac_pdata->phy_id = DM644X_EVM_PHY_ID;
  745. /* Register the fixup for PHY on DaVinci */
  746. phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK,
  747. davinci_phy_fixup);
  748. }
  749. }
  750. MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM")
  751. /* Maintainer: MontaVista Software <source@mvista.com> */
  752. .atag_offset = 0x100,
  753. .map_io = davinci_evm_map_io,
  754. .init_irq = davinci_irq_init,
  755. .init_time = dm644x_init_time,
  756. .init_machine = davinci_evm_init,
  757. .init_late = davinci_init_late,
  758. .dma_zone_size = SZ_128M,
  759. MACHINE_END