board-omap3evm.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. /*
  2. * linux/arch/arm/mach-omap2/board-omap3evm.c
  3. *
  4. * Copyright (C) 2008 Texas Instruments
  5. *
  6. * Modified from mach-omap2/board-3430sdp.c
  7. *
  8. * Initial code: Syed Mohammed Khasim
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/delay.h>
  18. #include <linux/err.h>
  19. #include <linux/clk.h>
  20. #include <linux/gpio.h>
  21. #include <linux/input.h>
  22. #include <linux/input/matrix_keypad.h>
  23. #include <linux/leds.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/spi/spi.h>
  26. #include <linux/spi/ads7846.h>
  27. #include <linux/i2c/twl.h>
  28. #include <linux/usb/otg.h>
  29. #include <linux/smsc911x.h>
  30. #include <linux/regulator/machine.h>
  31. #include <mach/hardware.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include <plat/board.h>
  36. #include <plat/usb.h>
  37. #include <plat/common.h>
  38. #include <plat/mcspi.h>
  39. #include "mux.h"
  40. #include "sdram-micron-mt46h32m32lf-6.h"
  41. #include "mmc-twl4030.h"
  42. #define OMAP3_EVM_TS_GPIO 175
  43. #define OMAP3_EVM_EHCI_VBUS 22
  44. #define OMAP3_EVM_EHCI_SELECT 61
  45. #define OMAP3EVM_ETHR_START 0x2c000000
  46. #define OMAP3EVM_ETHR_SIZE 1024
  47. #define OMAP3EVM_ETHR_ID_REV 0x50
  48. #define OMAP3EVM_ETHR_GPIO_IRQ 176
  49. #define OMAP3EVM_SMSC911X_CS 5
  50. static u8 omap3_evm_version;
  51. u8 get_omap3_evm_rev(void)
  52. {
  53. return omap3_evm_version;
  54. }
  55. EXPORT_SYMBOL(get_omap3_evm_rev);
  56. static void __init omap3_evm_get_revision(void)
  57. {
  58. void __iomem *ioaddr;
  59. unsigned int smsc_id;
  60. /* Ethernet PHY ID is stored at ID_REV register */
  61. ioaddr = ioremap_nocache(OMAP3EVM_ETHR_START, SZ_1K);
  62. if (!ioaddr)
  63. return;
  64. smsc_id = readl(ioaddr + OMAP3EVM_ETHR_ID_REV) & 0xFFFF0000;
  65. iounmap(ioaddr);
  66. switch (smsc_id) {
  67. /*SMSC9115 chipset*/
  68. case 0x01150000:
  69. omap3_evm_version = OMAP3EVM_BOARD_GEN_1;
  70. break;
  71. /*SMSC 9220 chipset*/
  72. case 0x92200000:
  73. default:
  74. omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
  75. }
  76. }
  77. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  78. static struct resource omap3evm_smsc911x_resources[] = {
  79. [0] = {
  80. .start = OMAP3EVM_ETHR_START,
  81. .end = (OMAP3EVM_ETHR_START + OMAP3EVM_ETHR_SIZE - 1),
  82. .flags = IORESOURCE_MEM,
  83. },
  84. [1] = {
  85. .start = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
  86. .end = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
  87. .flags = (IORESOURCE_IRQ | IRQF_TRIGGER_LOW),
  88. },
  89. };
  90. static struct smsc911x_platform_config smsc911x_config = {
  91. .phy_interface = PHY_INTERFACE_MODE_MII,
  92. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  93. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  94. .flags = (SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS),
  95. };
  96. static struct platform_device omap3evm_smsc911x_device = {
  97. .name = "smsc911x",
  98. .id = -1,
  99. .num_resources = ARRAY_SIZE(omap3evm_smsc911x_resources),
  100. .resource = &omap3evm_smsc911x_resources[0],
  101. .dev = {
  102. .platform_data = &smsc911x_config,
  103. },
  104. };
  105. static inline void __init omap3evm_init_smsc911x(void)
  106. {
  107. int eth_cs;
  108. struct clk *l3ck;
  109. unsigned int rate;
  110. eth_cs = OMAP3EVM_SMSC911X_CS;
  111. l3ck = clk_get(NULL, "l3_ck");
  112. if (IS_ERR(l3ck))
  113. rate = 100000000;
  114. else
  115. rate = clk_get_rate(l3ck);
  116. if (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ, "SMSC911x irq") < 0) {
  117. printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
  118. OMAP3EVM_ETHR_GPIO_IRQ);
  119. return;
  120. }
  121. gpio_direction_input(OMAP3EVM_ETHR_GPIO_IRQ);
  122. platform_device_register(&omap3evm_smsc911x_device);
  123. }
  124. #else
  125. static inline void __init omap3evm_init_smsc911x(void) { return; }
  126. #endif
  127. static struct regulator_consumer_supply omap3evm_vmmc1_supply = {
  128. .supply = "vmmc",
  129. };
  130. static struct regulator_consumer_supply omap3evm_vsim_supply = {
  131. .supply = "vmmc_aux",
  132. };
  133. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  134. static struct regulator_init_data omap3evm_vmmc1 = {
  135. .constraints = {
  136. .min_uV = 1850000,
  137. .max_uV = 3150000,
  138. .valid_modes_mask = REGULATOR_MODE_NORMAL
  139. | REGULATOR_MODE_STANDBY,
  140. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  141. | REGULATOR_CHANGE_MODE
  142. | REGULATOR_CHANGE_STATUS,
  143. },
  144. .num_consumer_supplies = 1,
  145. .consumer_supplies = &omap3evm_vmmc1_supply,
  146. };
  147. /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
  148. static struct regulator_init_data omap3evm_vsim = {
  149. .constraints = {
  150. .min_uV = 1800000,
  151. .max_uV = 3000000,
  152. .valid_modes_mask = REGULATOR_MODE_NORMAL
  153. | REGULATOR_MODE_STANDBY,
  154. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  155. | REGULATOR_CHANGE_MODE
  156. | REGULATOR_CHANGE_STATUS,
  157. },
  158. .num_consumer_supplies = 1,
  159. .consumer_supplies = &omap3evm_vsim_supply,
  160. };
  161. static struct twl4030_hsmmc_info mmc[] = {
  162. {
  163. .mmc = 1,
  164. .wires = 4,
  165. .gpio_cd = -EINVAL,
  166. .gpio_wp = 63,
  167. },
  168. {} /* Terminator */
  169. };
  170. static struct gpio_led gpio_leds[] = {
  171. {
  172. .name = "omap3evm::ledb",
  173. /* normally not visible (board underside) */
  174. .default_trigger = "default-on",
  175. .gpio = -EINVAL, /* gets replaced */
  176. .active_low = true,
  177. },
  178. };
  179. static struct gpio_led_platform_data gpio_led_info = {
  180. .leds = gpio_leds,
  181. .num_leds = ARRAY_SIZE(gpio_leds),
  182. };
  183. static struct platform_device leds_gpio = {
  184. .name = "leds-gpio",
  185. .id = -1,
  186. .dev = {
  187. .platform_data = &gpio_led_info,
  188. },
  189. };
  190. static int omap3evm_twl_gpio_setup(struct device *dev,
  191. unsigned gpio, unsigned ngpio)
  192. {
  193. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  194. omap_mux_init_gpio(63, OMAP_PIN_INPUT);
  195. mmc[0].gpio_cd = gpio + 0;
  196. twl4030_mmc_init(mmc);
  197. /* link regulators to MMC adapters */
  198. omap3evm_vmmc1_supply.dev = mmc[0].dev;
  199. omap3evm_vsim_supply.dev = mmc[0].dev;
  200. /*
  201. * Most GPIOs are for USB OTG. Some are mostly sent to
  202. * the P2 connector; notably LEDA for the LCD backlight.
  203. */
  204. /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
  205. gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
  206. platform_device_register(&leds_gpio);
  207. return 0;
  208. }
  209. static struct twl4030_gpio_platform_data omap3evm_gpio_data = {
  210. .gpio_base = OMAP_MAX_GPIO_LINES,
  211. .irq_base = TWL4030_GPIO_IRQ_BASE,
  212. .irq_end = TWL4030_GPIO_IRQ_END,
  213. .use_leds = true,
  214. .setup = omap3evm_twl_gpio_setup,
  215. };
  216. static struct twl4030_usb_data omap3evm_usb_data = {
  217. .usb_mode = T2_USB_MODE_ULPI,
  218. };
  219. static int board_keymap[] = {
  220. KEY(0, 0, KEY_LEFT),
  221. KEY(0, 1, KEY_RIGHT),
  222. KEY(0, 2, KEY_A),
  223. KEY(0, 3, KEY_B),
  224. KEY(1, 0, KEY_DOWN),
  225. KEY(1, 1, KEY_UP),
  226. KEY(1, 2, KEY_E),
  227. KEY(1, 3, KEY_F),
  228. KEY(2, 0, KEY_ENTER),
  229. KEY(2, 1, KEY_I),
  230. KEY(2, 2, KEY_J),
  231. KEY(2, 3, KEY_K),
  232. KEY(3, 0, KEY_M),
  233. KEY(3, 1, KEY_N),
  234. KEY(3, 2, KEY_O),
  235. KEY(3, 3, KEY_P)
  236. };
  237. static struct matrix_keymap_data board_map_data = {
  238. .keymap = board_keymap,
  239. .keymap_size = ARRAY_SIZE(board_keymap),
  240. };
  241. static struct twl4030_keypad_data omap3evm_kp_data = {
  242. .keymap_data = &board_map_data,
  243. .rows = 4,
  244. .cols = 4,
  245. .rep = 1,
  246. };
  247. static struct twl4030_madc_platform_data omap3evm_madc_data = {
  248. .irq_line = 1,
  249. };
  250. static struct twl4030_codec_audio_data omap3evm_audio_data = {
  251. .audio_mclk = 26000000,
  252. };
  253. static struct twl4030_codec_data omap3evm_codec_data = {
  254. .audio_mclk = 26000000,
  255. .audio = &omap3evm_audio_data,
  256. };
  257. static struct twl4030_platform_data omap3evm_twldata = {
  258. .irq_base = TWL4030_IRQ_BASE,
  259. .irq_end = TWL4030_IRQ_END,
  260. /* platform_data for children goes here */
  261. .keypad = &omap3evm_kp_data,
  262. .madc = &omap3evm_madc_data,
  263. .usb = &omap3evm_usb_data,
  264. .gpio = &omap3evm_gpio_data,
  265. .codec = &omap3evm_codec_data,
  266. };
  267. static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = {
  268. {
  269. I2C_BOARD_INFO("twl4030", 0x48),
  270. .flags = I2C_CLIENT_WAKE,
  271. .irq = INT_34XX_SYS_NIRQ,
  272. .platform_data = &omap3evm_twldata,
  273. },
  274. };
  275. static int __init omap3_evm_i2c_init(void)
  276. {
  277. /*
  278. * REVISIT: These entries can be set in omap3evm_twl_data
  279. * after a merge with MFD tree
  280. */
  281. omap3evm_twldata.vmmc1 = &omap3evm_vmmc1;
  282. omap3evm_twldata.vsim = &omap3evm_vsim;
  283. omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo,
  284. ARRAY_SIZE(omap3evm_i2c_boardinfo));
  285. omap_register_i2c_bus(2, 400, NULL, 0);
  286. omap_register_i2c_bus(3, 400, NULL, 0);
  287. return 0;
  288. }
  289. static struct platform_device omap3_evm_lcd_device = {
  290. .name = "omap3evm_lcd",
  291. .id = -1,
  292. };
  293. static struct omap_lcd_config omap3_evm_lcd_config __initdata = {
  294. .ctrl_name = "internal",
  295. };
  296. static void ads7846_dev_init(void)
  297. {
  298. if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0)
  299. printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
  300. gpio_direction_input(OMAP3_EVM_TS_GPIO);
  301. omap_set_gpio_debounce(OMAP3_EVM_TS_GPIO, 1);
  302. omap_set_gpio_debounce_time(OMAP3_EVM_TS_GPIO, 0xa);
  303. }
  304. static int ads7846_get_pendown_state(void)
  305. {
  306. return !gpio_get_value(OMAP3_EVM_TS_GPIO);
  307. }
  308. struct ads7846_platform_data ads7846_config = {
  309. .x_max = 0x0fff,
  310. .y_max = 0x0fff,
  311. .x_plate_ohms = 180,
  312. .pressure_max = 255,
  313. .debounce_max = 10,
  314. .debounce_tol = 3,
  315. .debounce_rep = 1,
  316. .get_pendown_state = ads7846_get_pendown_state,
  317. .keep_vref_on = 1,
  318. .settle_delay_usecs = 150,
  319. };
  320. static struct omap2_mcspi_device_config ads7846_mcspi_config = {
  321. .turbo_mode = 0,
  322. .single_channel = 1, /* 0: slave, 1: master */
  323. };
  324. struct spi_board_info omap3evm_spi_board_info[] = {
  325. [0] = {
  326. .modalias = "ads7846",
  327. .bus_num = 1,
  328. .chip_select = 0,
  329. .max_speed_hz = 1500000,
  330. .controller_data = &ads7846_mcspi_config,
  331. .irq = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
  332. .platform_data = &ads7846_config,
  333. },
  334. };
  335. static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
  336. { OMAP_TAG_LCD, &omap3_evm_lcd_config },
  337. };
  338. static void __init omap3_evm_init_irq(void)
  339. {
  340. omap_board_config = omap3_evm_config;
  341. omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
  342. omap2_init_common_hw(mt46h32m32lf6_sdrc_params, NULL);
  343. omap_init_irq();
  344. omap_gpio_init();
  345. }
  346. static struct platform_device *omap3_evm_devices[] __initdata = {
  347. &omap3_evm_lcd_device,
  348. };
  349. static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
  350. .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  351. .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
  352. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  353. .phy_reset = true,
  354. /* PHY reset GPIO will be runtime programmed based on EVM version */
  355. .reset_gpio_port[0] = -EINVAL,
  356. .reset_gpio_port[1] = -EINVAL,
  357. .reset_gpio_port[2] = -EINVAL
  358. };
  359. #ifdef CONFIG_OMAP_MUX
  360. static struct omap_board_mux board_mux[] __initdata = {
  361. { .reg_offset = OMAP_MUX_TERMINATOR },
  362. };
  363. #else
  364. #define board_mux NULL
  365. #endif
  366. static void __init omap3_evm_init(void)
  367. {
  368. omap3_evm_get_revision();
  369. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  370. omap3_evm_i2c_init();
  371. platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices));
  372. spi_register_board_info(omap3evm_spi_board_info,
  373. ARRAY_SIZE(omap3evm_spi_board_info));
  374. omap_serial_init();
  375. #ifdef CONFIG_NOP_USB_XCEIV
  376. /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */
  377. usb_nop_xceiv_register();
  378. #endif
  379. if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2) {
  380. /* enable EHCI VBUS using GPIO22 */
  381. omap_mux_init_gpio(22, OMAP_PIN_INPUT_PULLUP);
  382. gpio_request(OMAP3_EVM_EHCI_VBUS, "enable EHCI VBUS");
  383. gpio_direction_output(OMAP3_EVM_EHCI_VBUS, 0);
  384. gpio_set_value(OMAP3_EVM_EHCI_VBUS, 1);
  385. /* Select EHCI port on main board */
  386. omap_mux_init_gpio(61, OMAP_PIN_INPUT_PULLUP);
  387. gpio_request(OMAP3_EVM_EHCI_SELECT, "select EHCI port");
  388. gpio_direction_output(OMAP3_EVM_EHCI_SELECT, 0);
  389. gpio_set_value(OMAP3_EVM_EHCI_SELECT, 0);
  390. /* setup EHCI phy reset config */
  391. omap_mux_init_gpio(21, OMAP_PIN_INPUT_PULLUP);
  392. ehci_pdata.reset_gpio_port[1] = 21;
  393. } else {
  394. /* setup EHCI phy reset on MDC */
  395. omap_mux_init_gpio(135, OMAP_PIN_OUTPUT);
  396. ehci_pdata.reset_gpio_port[1] = 135;
  397. }
  398. usb_musb_init();
  399. usb_ehci_init(&ehci_pdata);
  400. ads7846_dev_init();
  401. omap3evm_init_smsc911x();
  402. }
  403. static void __init omap3_evm_map_io(void)
  404. {
  405. omap2_set_globals_343x();
  406. omap2_map_common_io();
  407. }
  408. MACHINE_START(OMAP3EVM, "OMAP3 EVM")
  409. /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
  410. .phys_io = 0x48000000,
  411. .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
  412. .boot_params = 0x80000100,
  413. .map_io = omap3_evm_map_io,
  414. .init_irq = omap3_evm_init_irq,
  415. .init_machine = omap3_evm_init,
  416. .timer = &omap_timer,
  417. MACHINE_END