board-dm644x-evm.c 18 KB

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