board-omap3evm.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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/spi/spi.h>
  25. #include <linux/spi/ads7846.h>
  26. #include <linux/i2c/twl4030.h>
  27. #include <linux/usb/otg.h>
  28. #include <mach/hardware.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/map.h>
  32. #include <plat/board.h>
  33. #include <plat/mux.h>
  34. #include <plat/usb.h>
  35. #include <plat/common.h>
  36. #include <plat/mcspi.h>
  37. #include "sdram-micron-mt46h32m32lf-6.h"
  38. #include "mmc-twl4030.h"
  39. #define OMAP3_EVM_TS_GPIO 175
  40. #define OMAP3EVM_ETHR_START 0x2c000000
  41. #define OMAP3EVM_ETHR_SIZE 1024
  42. #define OMAP3EVM_ETHR_ID_REV 0x50
  43. #define OMAP3EVM_ETHR_GPIO_IRQ 176
  44. #define OMAP3EVM_SMC911X_CS 5
  45. static u8 omap3_evm_version;
  46. u8 get_omap3_evm_rev(void)
  47. {
  48. return omap3_evm_version;
  49. }
  50. EXPORT_SYMBOL(get_omap3_evm_rev);
  51. static void __init omap3_evm_get_revision(void)
  52. {
  53. void __iomem *ioaddr;
  54. unsigned int smsc_id;
  55. /* Ethernet PHY ID is stored at ID_REV register */
  56. ioaddr = ioremap_nocache(OMAP3EVM_ETHR_START, SZ_1K);
  57. if (!ioaddr)
  58. return;
  59. smsc_id = readl(ioaddr + OMAP3EVM_ETHR_ID_REV) & 0xFFFF0000;
  60. iounmap(ioaddr);
  61. switch (smsc_id) {
  62. /*SMSC9115 chipset*/
  63. case 0x01150000:
  64. omap3_evm_version = OMAP3EVM_BOARD_GEN_1;
  65. break;
  66. /*SMSC 9220 chipset*/
  67. case 0x92200000:
  68. default:
  69. omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
  70. }
  71. }
  72. static struct resource omap3evm_smc911x_resources[] = {
  73. [0] = {
  74. .start = OMAP3EVM_ETHR_START,
  75. .end = (OMAP3EVM_ETHR_START + OMAP3EVM_ETHR_SIZE - 1),
  76. .flags = IORESOURCE_MEM,
  77. },
  78. [1] = {
  79. .start = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
  80. .end = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
  81. .flags = IORESOURCE_IRQ,
  82. },
  83. };
  84. static struct platform_device omap3evm_smc911x_device = {
  85. .name = "smc911x",
  86. .id = -1,
  87. .num_resources = ARRAY_SIZE(omap3evm_smc911x_resources),
  88. .resource = &omap3evm_smc911x_resources[0],
  89. };
  90. static inline void __init omap3evm_init_smc911x(void)
  91. {
  92. int eth_cs;
  93. struct clk *l3ck;
  94. unsigned int rate;
  95. eth_cs = OMAP3EVM_SMC911X_CS;
  96. l3ck = clk_get(NULL, "l3_ck");
  97. if (IS_ERR(l3ck))
  98. rate = 100000000;
  99. else
  100. rate = clk_get_rate(l3ck);
  101. if (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ, "SMC911x irq") < 0) {
  102. printk(KERN_ERR "Failed to request GPIO%d for smc911x IRQ\n",
  103. OMAP3EVM_ETHR_GPIO_IRQ);
  104. return;
  105. }
  106. gpio_direction_input(OMAP3EVM_ETHR_GPIO_IRQ);
  107. }
  108. static struct twl4030_hsmmc_info mmc[] = {
  109. {
  110. .mmc = 1,
  111. .wires = 4,
  112. .gpio_cd = -EINVAL,
  113. .gpio_wp = 63,
  114. },
  115. {} /* Terminator */
  116. };
  117. static struct gpio_led gpio_leds[] = {
  118. {
  119. .name = "omap3evm::ledb",
  120. /* normally not visible (board underside) */
  121. .default_trigger = "default-on",
  122. .gpio = -EINVAL, /* gets replaced */
  123. .active_low = true,
  124. },
  125. };
  126. static struct gpio_led_platform_data gpio_led_info = {
  127. .leds = gpio_leds,
  128. .num_leds = ARRAY_SIZE(gpio_leds),
  129. };
  130. static struct platform_device leds_gpio = {
  131. .name = "leds-gpio",
  132. .id = -1,
  133. .dev = {
  134. .platform_data = &gpio_led_info,
  135. },
  136. };
  137. static int omap3evm_twl_gpio_setup(struct device *dev,
  138. unsigned gpio, unsigned ngpio)
  139. {
  140. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  141. omap_cfg_reg(L8_34XX_GPIO63);
  142. mmc[0].gpio_cd = gpio + 0;
  143. twl4030_mmc_init(mmc);
  144. /*
  145. * Most GPIOs are for USB OTG. Some are mostly sent to
  146. * the P2 connector; notably LEDA for the LCD backlight.
  147. */
  148. /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
  149. gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
  150. platform_device_register(&leds_gpio);
  151. return 0;
  152. }
  153. static struct twl4030_gpio_platform_data omap3evm_gpio_data = {
  154. .gpio_base = OMAP_MAX_GPIO_LINES,
  155. .irq_base = TWL4030_GPIO_IRQ_BASE,
  156. .irq_end = TWL4030_GPIO_IRQ_END,
  157. .use_leds = true,
  158. .setup = omap3evm_twl_gpio_setup,
  159. };
  160. static struct twl4030_usb_data omap3evm_usb_data = {
  161. .usb_mode = T2_USB_MODE_ULPI,
  162. };
  163. static int board_keymap[] = {
  164. KEY(0, 0, KEY_LEFT),
  165. KEY(0, 1, KEY_RIGHT),
  166. KEY(0, 2, KEY_A),
  167. KEY(0, 3, KEY_B),
  168. KEY(1, 0, KEY_DOWN),
  169. KEY(1, 1, KEY_UP),
  170. KEY(1, 2, KEY_E),
  171. KEY(1, 3, KEY_F),
  172. KEY(2, 0, KEY_ENTER),
  173. KEY(2, 1, KEY_I),
  174. KEY(2, 2, KEY_J),
  175. KEY(2, 3, KEY_K),
  176. KEY(3, 0, KEY_M),
  177. KEY(3, 1, KEY_N),
  178. KEY(3, 2, KEY_O),
  179. KEY(3, 3, KEY_P)
  180. };
  181. static struct matrix_keymap_data board_map_data = {
  182. .keymap = board_keymap,
  183. .keymap_size = ARRAY_SIZE(board_keymap),
  184. };
  185. static struct twl4030_keypad_data omap3evm_kp_data = {
  186. .keymap_data = &board_map_data,
  187. .rows = 4,
  188. .cols = 4,
  189. .rep = 1,
  190. };
  191. static struct twl4030_madc_platform_data omap3evm_madc_data = {
  192. .irq_line = 1,
  193. };
  194. static struct twl4030_codec_audio_data omap3evm_audio_data = {
  195. .audio_mclk = 26000000,
  196. };
  197. static struct twl4030_codec_data omap3evm_codec_data = {
  198. .audio_mclk = 26000000,
  199. .audio = &omap3evm_audio_data,
  200. };
  201. static struct twl4030_platform_data omap3evm_twldata = {
  202. .irq_base = TWL4030_IRQ_BASE,
  203. .irq_end = TWL4030_IRQ_END,
  204. /* platform_data for children goes here */
  205. .keypad = &omap3evm_kp_data,
  206. .madc = &omap3evm_madc_data,
  207. .usb = &omap3evm_usb_data,
  208. .gpio = &omap3evm_gpio_data,
  209. .codec = &omap3evm_codec_data,
  210. };
  211. static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = {
  212. {
  213. I2C_BOARD_INFO("twl4030", 0x48),
  214. .flags = I2C_CLIENT_WAKE,
  215. .irq = INT_34XX_SYS_NIRQ,
  216. .platform_data = &omap3evm_twldata,
  217. },
  218. };
  219. static int __init omap3_evm_i2c_init(void)
  220. {
  221. omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo,
  222. ARRAY_SIZE(omap3evm_i2c_boardinfo));
  223. omap_register_i2c_bus(2, 400, NULL, 0);
  224. omap_register_i2c_bus(3, 400, NULL, 0);
  225. return 0;
  226. }
  227. static struct platform_device omap3_evm_lcd_device = {
  228. .name = "omap3evm_lcd",
  229. .id = -1,
  230. };
  231. static struct omap_lcd_config omap3_evm_lcd_config __initdata = {
  232. .ctrl_name = "internal",
  233. };
  234. static void ads7846_dev_init(void)
  235. {
  236. if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0)
  237. printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
  238. gpio_direction_input(OMAP3_EVM_TS_GPIO);
  239. omap_set_gpio_debounce(OMAP3_EVM_TS_GPIO, 1);
  240. omap_set_gpio_debounce_time(OMAP3_EVM_TS_GPIO, 0xa);
  241. }
  242. static int ads7846_get_pendown_state(void)
  243. {
  244. return !gpio_get_value(OMAP3_EVM_TS_GPIO);
  245. }
  246. struct ads7846_platform_data ads7846_config = {
  247. .x_max = 0x0fff,
  248. .y_max = 0x0fff,
  249. .x_plate_ohms = 180,
  250. .pressure_max = 255,
  251. .debounce_max = 10,
  252. .debounce_tol = 3,
  253. .debounce_rep = 1,
  254. .get_pendown_state = ads7846_get_pendown_state,
  255. .keep_vref_on = 1,
  256. .settle_delay_usecs = 150,
  257. };
  258. static struct omap2_mcspi_device_config ads7846_mcspi_config = {
  259. .turbo_mode = 0,
  260. .single_channel = 1, /* 0: slave, 1: master */
  261. };
  262. struct spi_board_info omap3evm_spi_board_info[] = {
  263. [0] = {
  264. .modalias = "ads7846",
  265. .bus_num = 1,
  266. .chip_select = 0,
  267. .max_speed_hz = 1500000,
  268. .controller_data = &ads7846_mcspi_config,
  269. .irq = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
  270. .platform_data = &ads7846_config,
  271. },
  272. };
  273. static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
  274. { OMAP_TAG_LCD, &omap3_evm_lcd_config },
  275. };
  276. static void __init omap3_evm_init_irq(void)
  277. {
  278. omap_board_config = omap3_evm_config;
  279. omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
  280. omap2_init_common_hw(mt46h32m32lf6_sdrc_params, NULL);
  281. omap_init_irq();
  282. omap_gpio_init();
  283. omap3evm_init_smc911x();
  284. }
  285. static struct platform_device *omap3_evm_devices[] __initdata = {
  286. &omap3_evm_lcd_device,
  287. &omap3evm_smc911x_device,
  288. };
  289. static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
  290. .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  291. .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
  292. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  293. .phy_reset = true,
  294. .reset_gpio_port[0] = -EINVAL,
  295. .reset_gpio_port[1] = 135,
  296. .reset_gpio_port[2] = -EINVAL
  297. };
  298. static void __init omap3_evm_init(void)
  299. {
  300. omap3_evm_get_revision();
  301. omap3_evm_i2c_init();
  302. platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices));
  303. spi_register_board_info(omap3evm_spi_board_info,
  304. ARRAY_SIZE(omap3evm_spi_board_info));
  305. omap_serial_init();
  306. #ifdef CONFIG_NOP_USB_XCEIV
  307. /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */
  308. usb_nop_xceiv_register();
  309. #endif
  310. usb_musb_init();
  311. /* Setup EHCI phy reset padconfig */
  312. omap_cfg_reg(AF4_34XX_GPIO135_OUT);
  313. usb_ehci_init(&ehci_pdata);
  314. ads7846_dev_init();
  315. }
  316. static void __init omap3_evm_map_io(void)
  317. {
  318. omap2_set_globals_343x();
  319. omap2_map_common_io();
  320. }
  321. MACHINE_START(OMAP3EVM, "OMAP3 EVM")
  322. /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
  323. .phys_io = 0x48000000,
  324. .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
  325. .boot_params = 0x80000100,
  326. .map_io = omap3_evm_map_io,
  327. .init_irq = omap3_evm_init_irq,
  328. .init_machine = omap3_evm_init,
  329. .timer = &omap_timer,
  330. MACHINE_END