board-dm644x-evm.c 20 KB

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