board-dm644x-evm.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  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 <media/tvp514x.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <mach/dm644x.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. #define DM644X_EVM_PHY_MASK (0x2)
  38. #define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
  39. #define DAVINCI_CFC_ATA_BASE 0x01C66000
  40. #define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000
  41. #define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
  42. #define DAVINCI_ASYNC_EMIF_DATA_CE1_BASE 0x04000000
  43. #define DAVINCI_ASYNC_EMIF_DATA_CE2_BASE 0x06000000
  44. #define DAVINCI_ASYNC_EMIF_DATA_CE3_BASE 0x08000000
  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 = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
  86. .end = DAVINCI_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. 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_nand_pdata davinci_evm_nandflash_data = {
  136. .parts = davinci_evm_nandflash_partition,
  137. .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition),
  138. .ecc_mode = NAND_ECC_HW,
  139. .options = NAND_USE_FLASH_BBT,
  140. };
  141. static struct resource davinci_evm_nandflash_resource[] = {
  142. {
  143. .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
  144. .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
  145. .flags = IORESOURCE_MEM,
  146. }, {
  147. .start = DAVINCI_ASYNC_EMIF_CONTROL_BASE,
  148. .end = DAVINCI_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
  149. .flags = IORESOURCE_MEM,
  150. },
  151. };
  152. static struct platform_device davinci_evm_nandflash_device = {
  153. .name = "davinci_nand",
  154. .id = 0,
  155. .dev = {
  156. .platform_data = &davinci_evm_nandflash_data,
  157. },
  158. .num_resources = ARRAY_SIZE(davinci_evm_nandflash_resource),
  159. .resource = davinci_evm_nandflash_resource,
  160. };
  161. static u64 davinci_fb_dma_mask = DMA_BIT_MASK(32);
  162. static struct platform_device davinci_fb_device = {
  163. .name = "davincifb",
  164. .id = -1,
  165. .dev = {
  166. .dma_mask = &davinci_fb_dma_mask,
  167. .coherent_dma_mask = DMA_BIT_MASK(32),
  168. },
  169. .num_resources = 0,
  170. };
  171. static struct tvp514x_platform_data tvp5146_pdata = {
  172. .clk_polarity = 0,
  173. .hs_polarity = 1,
  174. .vs_polarity = 1
  175. };
  176. #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
  177. /* Inputs available at the TVP5146 */
  178. static struct v4l2_input tvp5146_inputs[] = {
  179. {
  180. .index = 0,
  181. .name = "Composite",
  182. .type = V4L2_INPUT_TYPE_CAMERA,
  183. .std = TVP514X_STD_ALL,
  184. },
  185. {
  186. .index = 1,
  187. .name = "S-Video",
  188. .type = V4L2_INPUT_TYPE_CAMERA,
  189. .std = TVP514X_STD_ALL,
  190. },
  191. };
  192. /*
  193. * this is the route info for connecting each input to decoder
  194. * ouput that goes to vpfe. There is a one to one correspondence
  195. * with tvp5146_inputs
  196. */
  197. static struct vpfe_route tvp5146_routes[] = {
  198. {
  199. .input = INPUT_CVBS_VI2B,
  200. .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  201. },
  202. {
  203. .input = INPUT_SVIDEO_VI2C_VI1C,
  204. .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  205. },
  206. };
  207. static struct vpfe_subdev_info vpfe_sub_devs[] = {
  208. {
  209. .name = "tvp5146",
  210. .grp_id = 0,
  211. .num_inputs = ARRAY_SIZE(tvp5146_inputs),
  212. .inputs = tvp5146_inputs,
  213. .routes = tvp5146_routes,
  214. .can_route = 1,
  215. .ccdc_if_params = {
  216. .if_type = VPFE_BT656,
  217. .hdpol = VPFE_PINPOL_POSITIVE,
  218. .vdpol = VPFE_PINPOL_POSITIVE,
  219. },
  220. .board_info = {
  221. I2C_BOARD_INFO("tvp5146", 0x5d),
  222. .platform_data = &tvp5146_pdata,
  223. },
  224. },
  225. };
  226. static struct vpfe_config vpfe_cfg = {
  227. .num_subdevs = ARRAY_SIZE(vpfe_sub_devs),
  228. .sub_devs = vpfe_sub_devs,
  229. .card_name = "DM6446 EVM",
  230. .ccdc = "DM6446 CCDC",
  231. };
  232. static struct platform_device rtc_dev = {
  233. .name = "rtc_davinci_evm",
  234. .id = -1,
  235. };
  236. static struct resource ide_resources[] = {
  237. {
  238. .start = DAVINCI_CFC_ATA_BASE,
  239. .end = DAVINCI_CFC_ATA_BASE + 0x7ff,
  240. .flags = IORESOURCE_MEM,
  241. },
  242. {
  243. .start = IRQ_IDE,
  244. .end = IRQ_IDE,
  245. .flags = IORESOURCE_IRQ,
  246. },
  247. };
  248. static u64 ide_dma_mask = DMA_BIT_MASK(32);
  249. static struct platform_device ide_dev = {
  250. .name = "palm_bk3710",
  251. .id = -1,
  252. .resource = ide_resources,
  253. .num_resources = ARRAY_SIZE(ide_resources),
  254. .dev = {
  255. .dma_mask = &ide_dma_mask,
  256. .coherent_dma_mask = DMA_BIT_MASK(32),
  257. },
  258. };
  259. static struct snd_platform_data dm644x_evm_snd_data;
  260. /*----------------------------------------------------------------------*/
  261. /*
  262. * I2C GPIO expanders
  263. */
  264. #define PCF_Uxx_BASE(x) (DAVINCI_N_GPIO + ((x) * 8))
  265. /* U2 -- LEDs */
  266. static struct gpio_led evm_leds[] = {
  267. { .name = "DS8", .active_low = 1,
  268. .default_trigger = "heartbeat", },
  269. { .name = "DS7", .active_low = 1, },
  270. { .name = "DS6", .active_low = 1, },
  271. { .name = "DS5", .active_low = 1, },
  272. { .name = "DS4", .active_low = 1, },
  273. { .name = "DS3", .active_low = 1, },
  274. { .name = "DS2", .active_low = 1,
  275. .default_trigger = "mmc0", },
  276. { .name = "DS1", .active_low = 1,
  277. .default_trigger = "ide-disk", },
  278. };
  279. static const struct gpio_led_platform_data evm_led_data = {
  280. .num_leds = ARRAY_SIZE(evm_leds),
  281. .leds = evm_leds,
  282. };
  283. static struct platform_device *evm_led_dev;
  284. static int
  285. evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  286. {
  287. struct gpio_led *leds = evm_leds;
  288. int status;
  289. while (ngpio--) {
  290. leds->gpio = gpio++;
  291. leds++;
  292. }
  293. /* what an extremely annoying way to be forced to handle
  294. * device unregistration ...
  295. */
  296. evm_led_dev = platform_device_alloc("leds-gpio", 0);
  297. platform_device_add_data(evm_led_dev,
  298. &evm_led_data, sizeof evm_led_data);
  299. evm_led_dev->dev.parent = &client->dev;
  300. status = platform_device_add(evm_led_dev);
  301. if (status < 0) {
  302. platform_device_put(evm_led_dev);
  303. evm_led_dev = NULL;
  304. }
  305. return status;
  306. }
  307. static int
  308. evm_led_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  309. {
  310. if (evm_led_dev) {
  311. platform_device_unregister(evm_led_dev);
  312. evm_led_dev = NULL;
  313. }
  314. return 0;
  315. }
  316. static struct pcf857x_platform_data pcf_data_u2 = {
  317. .gpio_base = PCF_Uxx_BASE(0),
  318. .setup = evm_led_setup,
  319. .teardown = evm_led_teardown,
  320. };
  321. /* U18 - A/V clock generator and user switch */
  322. static int sw_gpio;
  323. static ssize_t
  324. sw_show(struct device *d, struct device_attribute *a, char *buf)
  325. {
  326. char *s = gpio_get_value_cansleep(sw_gpio) ? "on\n" : "off\n";
  327. strcpy(buf, s);
  328. return strlen(s);
  329. }
  330. static DEVICE_ATTR(user_sw, S_IRUGO, sw_show, NULL);
  331. static int
  332. evm_u18_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  333. {
  334. int status;
  335. /* export dip switch option */
  336. sw_gpio = gpio + 7;
  337. status = gpio_request(sw_gpio, "user_sw");
  338. if (status == 0)
  339. status = gpio_direction_input(sw_gpio);
  340. if (status == 0)
  341. status = device_create_file(&client->dev, &dev_attr_user_sw);
  342. else
  343. gpio_free(sw_gpio);
  344. if (status != 0)
  345. sw_gpio = -EINVAL;
  346. /* audio PLL: 48 kHz (vs 44.1 or 32), single rate (vs double) */
  347. gpio_request(gpio + 3, "pll_fs2");
  348. gpio_direction_output(gpio + 3, 0);
  349. gpio_request(gpio + 2, "pll_fs1");
  350. gpio_direction_output(gpio + 2, 0);
  351. gpio_request(gpio + 1, "pll_sr");
  352. gpio_direction_output(gpio + 1, 0);
  353. return 0;
  354. }
  355. static int
  356. evm_u18_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  357. {
  358. gpio_free(gpio + 1);
  359. gpio_free(gpio + 2);
  360. gpio_free(gpio + 3);
  361. if (sw_gpio > 0) {
  362. device_remove_file(&client->dev, &dev_attr_user_sw);
  363. gpio_free(sw_gpio);
  364. }
  365. return 0;
  366. }
  367. static struct pcf857x_platform_data pcf_data_u18 = {
  368. .gpio_base = PCF_Uxx_BASE(1),
  369. .n_latch = (1 << 3) | (1 << 2) | (1 << 1),
  370. .setup = evm_u18_setup,
  371. .teardown = evm_u18_teardown,
  372. };
  373. /* U35 - various I/O signals used to manage USB, CF, ATA, etc */
  374. static int
  375. evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  376. {
  377. /* p0 = nDRV_VBUS (initial: don't supply it) */
  378. gpio_request(gpio + 0, "nDRV_VBUS");
  379. gpio_direction_output(gpio + 0, 1);
  380. /* p1 = VDDIMX_EN */
  381. gpio_request(gpio + 1, "VDDIMX_EN");
  382. gpio_direction_output(gpio + 1, 1);
  383. /* p2 = VLYNQ_EN */
  384. gpio_request(gpio + 2, "VLYNQ_EN");
  385. gpio_direction_output(gpio + 2, 1);
  386. /* p3 = n3V3_CF_RESET (initial: stay in reset) */
  387. gpio_request(gpio + 3, "nCF_RESET");
  388. gpio_direction_output(gpio + 3, 0);
  389. /* (p4 unused) */
  390. /* p5 = 1V8_WLAN_RESET (initial: stay in reset) */
  391. gpio_request(gpio + 5, "WLAN_RESET");
  392. gpio_direction_output(gpio + 5, 1);
  393. /* p6 = nATA_SEL (initial: select) */
  394. gpio_request(gpio + 6, "nATA_SEL");
  395. gpio_direction_output(gpio + 6, 0);
  396. /* p7 = nCF_SEL (initial: deselect) */
  397. gpio_request(gpio + 7, "nCF_SEL");
  398. gpio_direction_output(gpio + 7, 1);
  399. /* irlml6401 switches over 1A, in under 8 msec;
  400. * now it can be managed by nDRV_VBUS ...
  401. */
  402. davinci_setup_usb(1000, 8);
  403. return 0;
  404. }
  405. static int
  406. evm_u35_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  407. {
  408. gpio_free(gpio + 7);
  409. gpio_free(gpio + 6);
  410. gpio_free(gpio + 5);
  411. gpio_free(gpio + 3);
  412. gpio_free(gpio + 2);
  413. gpio_free(gpio + 1);
  414. gpio_free(gpio + 0);
  415. return 0;
  416. }
  417. static struct pcf857x_platform_data pcf_data_u35 = {
  418. .gpio_base = PCF_Uxx_BASE(2),
  419. .setup = evm_u35_setup,
  420. .teardown = evm_u35_teardown,
  421. };
  422. /*----------------------------------------------------------------------*/
  423. /* Most of this EEPROM is unused, but U-Boot uses some data:
  424. * - 0x7f00, 6 bytes Ethernet Address
  425. * - 0x0039, 1 byte NTSC vs PAL (bit 0x80 == PAL)
  426. * - ... newer boards may have more
  427. */
  428. static struct at24_platform_data eeprom_info = {
  429. .byte_len = (256*1024) / 8,
  430. .page_size = 64,
  431. .flags = AT24_FLAG_ADDR16,
  432. .setup = davinci_get_mac_addr,
  433. .context = (void *)0x7f00,
  434. };
  435. /*
  436. * MSP430 supports RTC, card detection, input from IR remote, and
  437. * a bit more. It triggers interrupts on GPIO(7) from pressing
  438. * buttons on the IR remote, and for card detect switches.
  439. */
  440. static struct i2c_client *dm6446evm_msp;
  441. static int dm6446evm_msp_probe(struct i2c_client *client,
  442. const struct i2c_device_id *id)
  443. {
  444. dm6446evm_msp = client;
  445. return 0;
  446. }
  447. static int dm6446evm_msp_remove(struct i2c_client *client)
  448. {
  449. dm6446evm_msp = NULL;
  450. return 0;
  451. }
  452. static const struct i2c_device_id dm6446evm_msp_ids[] = {
  453. { "dm6446evm_msp", 0, },
  454. { /* end of list */ },
  455. };
  456. static struct i2c_driver dm6446evm_msp_driver = {
  457. .driver.name = "dm6446evm_msp",
  458. .id_table = dm6446evm_msp_ids,
  459. .probe = dm6446evm_msp_probe,
  460. .remove = dm6446evm_msp_remove,
  461. };
  462. static int dm6444evm_msp430_get_pins(void)
  463. {
  464. static const char txbuf[2] = { 2, 4, };
  465. char buf[4];
  466. struct i2c_msg msg[2] = {
  467. {
  468. .addr = dm6446evm_msp->addr,
  469. .flags = 0,
  470. .len = 2,
  471. .buf = (void __force *)txbuf,
  472. },
  473. {
  474. .addr = dm6446evm_msp->addr,
  475. .flags = I2C_M_RD,
  476. .len = 4,
  477. .buf = buf,
  478. },
  479. };
  480. int status;
  481. if (!dm6446evm_msp)
  482. return -ENXIO;
  483. /* Command 4 == get input state, returns port 2 and port3 data
  484. * S Addr W [A] len=2 [A] cmd=4 [A]
  485. * RS Addr R [A] [len=4] A [cmd=4] A [port2] A [port3] N P
  486. */
  487. status = i2c_transfer(dm6446evm_msp->adapter, msg, 2);
  488. if (status < 0)
  489. return status;
  490. dev_dbg(&dm6446evm_msp->dev,
  491. "PINS: %02x %02x %02x %02x\n",
  492. buf[0], buf[1], buf[2], buf[3]);
  493. return (buf[3] << 8) | buf[2];
  494. }
  495. static int dm6444evm_mmc_get_cd(int module)
  496. {
  497. int status = dm6444evm_msp430_get_pins();
  498. return (status < 0) ? status : !(status & BIT(1));
  499. }
  500. static int dm6444evm_mmc_get_ro(int module)
  501. {
  502. int status = dm6444evm_msp430_get_pins();
  503. return (status < 0) ? status : status & BIT(6 + 8);
  504. }
  505. static struct davinci_mmc_config dm6446evm_mmc_config = {
  506. .get_cd = dm6444evm_mmc_get_cd,
  507. .get_ro = dm6444evm_mmc_get_ro,
  508. .wires = 4,
  509. .version = MMC_CTLR_VERSION_1
  510. };
  511. static struct i2c_board_info __initdata i2c_info[] = {
  512. {
  513. I2C_BOARD_INFO("dm6446evm_msp", 0x23),
  514. },
  515. {
  516. I2C_BOARD_INFO("pcf8574", 0x38),
  517. .platform_data = &pcf_data_u2,
  518. },
  519. {
  520. I2C_BOARD_INFO("pcf8574", 0x39),
  521. .platform_data = &pcf_data_u18,
  522. },
  523. {
  524. I2C_BOARD_INFO("pcf8574", 0x3a),
  525. .platform_data = &pcf_data_u35,
  526. },
  527. {
  528. I2C_BOARD_INFO("24c256", 0x50),
  529. .platform_data = &eeprom_info,
  530. },
  531. {
  532. I2C_BOARD_INFO("tlv320aic33", 0x1b),
  533. },
  534. };
  535. /* The msp430 uses a slow bitbanged I2C implementation (ergo 20 KHz),
  536. * which requires 100 usec of idle bus after i2c writes sent to it.
  537. */
  538. static struct davinci_i2c_platform_data i2c_pdata = {
  539. .bus_freq = 20 /* kHz */,
  540. .bus_delay = 100 /* usec */,
  541. };
  542. static void __init evm_init_i2c(void)
  543. {
  544. davinci_init_i2c(&i2c_pdata);
  545. i2c_add_driver(&dm6446evm_msp_driver);
  546. i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
  547. }
  548. static struct platform_device *davinci_evm_devices[] __initdata = {
  549. &davinci_fb_device,
  550. &rtc_dev,
  551. };
  552. static struct davinci_uart_config uart_config __initdata = {
  553. .enabled_uarts = (1 << 0),
  554. };
  555. static void __init
  556. davinci_evm_map_io(void)
  557. {
  558. /* setup input configuration for VPFE input devices */
  559. dm644x_set_vpfe_config(&vpfe_cfg);
  560. dm644x_init();
  561. }
  562. static int davinci_phy_fixup(struct phy_device *phydev)
  563. {
  564. unsigned int control;
  565. /* CRITICAL: Fix for increasing PHY signal drive strength for
  566. * TX lockup issue. On DaVinci EVM, the Intel LXT971 PHY
  567. * signal strength was low causing TX to fail randomly. The
  568. * fix is to Set bit 11 (Increased MII drive strength) of PHY
  569. * register 26 (Digital Config register) on this phy. */
  570. control = phy_read(phydev, 26);
  571. phy_write(phydev, 26, (control | 0x800));
  572. return 0;
  573. }
  574. #if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
  575. defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE)
  576. #define HAS_ATA 1
  577. #else
  578. #define HAS_ATA 0
  579. #endif
  580. #if defined(CONFIG_MTD_PHYSMAP) || \
  581. defined(CONFIG_MTD_PHYSMAP_MODULE)
  582. #define HAS_NOR 1
  583. #else
  584. #define HAS_NOR 0
  585. #endif
  586. #if defined(CONFIG_MTD_NAND_DAVINCI) || \
  587. defined(CONFIG_MTD_NAND_DAVINCI_MODULE)
  588. #define HAS_NAND 1
  589. #else
  590. #define HAS_NAND 0
  591. #endif
  592. static __init void davinci_evm_init(void)
  593. {
  594. struct clk *aemif_clk;
  595. struct davinci_soc_info *soc_info = &davinci_soc_info;
  596. aemif_clk = clk_get(NULL, "aemif");
  597. clk_enable(aemif_clk);
  598. if (HAS_ATA) {
  599. if (HAS_NAND || HAS_NOR)
  600. pr_warning("WARNING: both IDE and Flash are "
  601. "enabled, but they share AEMIF pins.\n"
  602. "\tDisable IDE for NAND/NOR support.\n");
  603. davinci_cfg_reg(DM644X_HPIEN_DISABLE);
  604. davinci_cfg_reg(DM644X_ATAEN);
  605. davinci_cfg_reg(DM644X_HDIREN);
  606. platform_device_register(&ide_dev);
  607. } else if (HAS_NAND || HAS_NOR) {
  608. davinci_cfg_reg(DM644X_HPIEN_DISABLE);
  609. davinci_cfg_reg(DM644X_ATAEN_DISABLE);
  610. /* only one device will be jumpered and detected */
  611. if (HAS_NAND) {
  612. platform_device_register(&davinci_evm_nandflash_device);
  613. evm_leds[7].default_trigger = "nand-disk";
  614. if (HAS_NOR)
  615. pr_warning("WARNING: both NAND and NOR flash "
  616. "are enabled; disable one of them.\n");
  617. } else if (HAS_NOR)
  618. platform_device_register(&davinci_evm_norflash_device);
  619. }
  620. platform_add_devices(davinci_evm_devices,
  621. ARRAY_SIZE(davinci_evm_devices));
  622. evm_init_i2c();
  623. davinci_setup_mmc(0, &dm6446evm_mmc_config);
  624. davinci_serial_init(&uart_config);
  625. dm644x_init_asp(&dm644x_evm_snd_data);
  626. soc_info->emac_pdata->phy_mask = DM644X_EVM_PHY_MASK;
  627. soc_info->emac_pdata->mdio_max_freq = DM644X_EVM_MDIO_FREQUENCY;
  628. /* Register the fixup for PHY on DaVinci */
  629. phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK,
  630. davinci_phy_fixup);
  631. }
  632. static __init void davinci_evm_irq_init(void)
  633. {
  634. davinci_irq_init();
  635. }
  636. MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM")
  637. /* Maintainer: MontaVista Software <source@mvista.com> */
  638. .phys_io = IO_PHYS,
  639. .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
  640. .boot_params = (DAVINCI_DDR_BASE + 0x100),
  641. .map_io = davinci_evm_map_io,
  642. .init_irq = davinci_evm_irq_init,
  643. .timer = &davinci_timer,
  644. .init_machine = davinci_evm_init,
  645. MACHINE_END