board-ldp.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. /*
  2. * linux/arch/arm/mach-omap2/board-ldp.c
  3. *
  4. * Copyright (C) 2008 Texas Instruments Inc.
  5. * Nishant Kamat <nskamat@ti.com>
  6. *
  7. * Modified from mach-omap2/board-3430sdp.c
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/delay.h>
  17. #include <linux/input.h>
  18. #include <linux/input/matrix_keypad.h>
  19. #include <linux/gpio_keys.h>
  20. #include <linux/workqueue.h>
  21. #include <linux/err.h>
  22. #include <linux/clk.h>
  23. #include <linux/spi/spi.h>
  24. #include <linux/spi/ads7846.h>
  25. #include <linux/regulator/machine.h>
  26. #include <linux/i2c/twl4030.h>
  27. #include <linux/io.h>
  28. #include <linux/smsc911x.h>
  29. #include <mach/hardware.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include <mach/mcspi.h>
  34. #include <mach/gpio.h>
  35. #include <mach/board.h>
  36. #include <mach/common.h>
  37. #include <mach/gpmc.h>
  38. #include <asm/delay.h>
  39. #include <mach/control.h>
  40. #include <mach/usb.h>
  41. #include "mmc-twl4030.h"
  42. #define LDP_SMSC911X_CS 1
  43. #define LDP_SMSC911X_GPIO 152
  44. #define DEBUG_BASE 0x08000000
  45. #define LDP_ETHR_START DEBUG_BASE
  46. static struct resource ldp_smsc911x_resources[] = {
  47. [0] = {
  48. .start = LDP_ETHR_START,
  49. .end = LDP_ETHR_START + SZ_4K,
  50. .flags = IORESOURCE_MEM,
  51. },
  52. [1] = {
  53. .start = 0,
  54. .end = 0,
  55. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  56. },
  57. };
  58. static struct smsc911x_platform_config ldp_smsc911x_config = {
  59. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  60. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  61. .flags = SMSC911X_USE_32BIT,
  62. .phy_interface = PHY_INTERFACE_MODE_MII,
  63. };
  64. static struct platform_device ldp_smsc911x_device = {
  65. .name = "smsc911x",
  66. .id = -1,
  67. .num_resources = ARRAY_SIZE(ldp_smsc911x_resources),
  68. .resource = ldp_smsc911x_resources,
  69. .dev = {
  70. .platform_data = &ldp_smsc911x_config,
  71. },
  72. };
  73. static int board_keymap[] = {
  74. KEY(0, 0, KEY_1),
  75. KEY(1, 0, KEY_2),
  76. KEY(2, 0, KEY_3),
  77. KEY(0, 1, KEY_4),
  78. KEY(1, 1, KEY_5),
  79. KEY(2, 1, KEY_6),
  80. KEY(3, 1, KEY_F5),
  81. KEY(0, 2, KEY_7),
  82. KEY(1, 2, KEY_8),
  83. KEY(2, 2, KEY_9),
  84. KEY(3, 2, KEY_F6),
  85. KEY(0, 3, KEY_F7),
  86. KEY(1, 3, KEY_0),
  87. KEY(2, 3, KEY_F8),
  88. PERSISTENT_KEY(4, 5),
  89. KEY(4, 4, KEY_VOLUMEUP),
  90. KEY(5, 5, KEY_VOLUMEDOWN),
  91. 0
  92. };
  93. static struct matrix_keymap_data board_map_data = {
  94. .keymap = board_keymap,
  95. .keymap_size = ARRAY_SIZE(board_keymap),
  96. };
  97. static struct twl4030_keypad_data ldp_kp_twl4030_data = {
  98. .keymap_data = &board_map_data,
  99. .rows = 6,
  100. .cols = 6,
  101. .rep = 1,
  102. };
  103. static struct gpio_keys_button ldp_gpio_keys_buttons[] = {
  104. [0] = {
  105. .code = KEY_ENTER,
  106. .gpio = 101,
  107. .desc = "enter sw",
  108. .active_low = 1,
  109. .debounce_interval = 30,
  110. },
  111. [1] = {
  112. .code = KEY_F1,
  113. .gpio = 102,
  114. .desc = "func 1",
  115. .active_low = 1,
  116. .debounce_interval = 30,
  117. },
  118. [2] = {
  119. .code = KEY_F2,
  120. .gpio = 103,
  121. .desc = "func 2",
  122. .active_low = 1,
  123. .debounce_interval = 30,
  124. },
  125. [3] = {
  126. .code = KEY_F3,
  127. .gpio = 104,
  128. .desc = "func 3",
  129. .active_low = 1,
  130. .debounce_interval = 30,
  131. },
  132. [4] = {
  133. .code = KEY_F4,
  134. .gpio = 105,
  135. .desc = "func 4",
  136. .active_low = 1,
  137. .debounce_interval = 30,
  138. },
  139. [5] = {
  140. .code = KEY_LEFT,
  141. .gpio = 106,
  142. .desc = "left sw",
  143. .active_low = 1,
  144. .debounce_interval = 30,
  145. },
  146. [6] = {
  147. .code = KEY_RIGHT,
  148. .gpio = 107,
  149. .desc = "right sw",
  150. .active_low = 1,
  151. .debounce_interval = 30,
  152. },
  153. [7] = {
  154. .code = KEY_UP,
  155. .gpio = 108,
  156. .desc = "up sw",
  157. .active_low = 1,
  158. .debounce_interval = 30,
  159. },
  160. [8] = {
  161. .code = KEY_DOWN,
  162. .gpio = 109,
  163. .desc = "down sw",
  164. .active_low = 1,
  165. .debounce_interval = 30,
  166. },
  167. };
  168. static struct gpio_keys_platform_data ldp_gpio_keys = {
  169. .buttons = ldp_gpio_keys_buttons,
  170. .nbuttons = ARRAY_SIZE(ldp_gpio_keys_buttons),
  171. .rep = 1,
  172. };
  173. static struct platform_device ldp_gpio_keys_device = {
  174. .name = "gpio-keys",
  175. .id = -1,
  176. .dev = {
  177. .platform_data = &ldp_gpio_keys,
  178. },
  179. };
  180. static int ts_gpio;
  181. /**
  182. * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
  183. *
  184. * @return - void. If request gpio fails then Flag KERN_ERR.
  185. */
  186. static void ads7846_dev_init(void)
  187. {
  188. if (gpio_request(ts_gpio, "ads7846 irq") < 0) {
  189. printk(KERN_ERR "can't get ads746 pen down GPIO\n");
  190. return;
  191. }
  192. gpio_direction_input(ts_gpio);
  193. omap_set_gpio_debounce(ts_gpio, 1);
  194. omap_set_gpio_debounce_time(ts_gpio, 0xa);
  195. }
  196. static int ads7846_get_pendown_state(void)
  197. {
  198. return !gpio_get_value(ts_gpio);
  199. }
  200. static struct ads7846_platform_data tsc2046_config __initdata = {
  201. .get_pendown_state = ads7846_get_pendown_state,
  202. .keep_vref_on = 1,
  203. };
  204. static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
  205. .turbo_mode = 0,
  206. .single_channel = 1, /* 0: slave, 1: master */
  207. };
  208. static struct spi_board_info ldp_spi_board_info[] __initdata = {
  209. [0] = {
  210. /*
  211. * TSC2046 operates at a max freqency of 2MHz, so
  212. * operate slightly below at 1.5MHz
  213. */
  214. .modalias = "ads7846",
  215. .bus_num = 1,
  216. .chip_select = 0,
  217. .max_speed_hz = 1500000,
  218. .controller_data = &tsc2046_mcspi_config,
  219. .irq = 0,
  220. .platform_data = &tsc2046_config,
  221. },
  222. };
  223. static inline void __init ldp_init_smsc911x(void)
  224. {
  225. int eth_cs;
  226. unsigned long cs_mem_base;
  227. int eth_gpio = 0;
  228. eth_cs = LDP_SMSC911X_CS;
  229. if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
  230. printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
  231. return;
  232. }
  233. ldp_smsc911x_resources[0].start = cs_mem_base + 0x0;
  234. ldp_smsc911x_resources[0].end = cs_mem_base + 0xff;
  235. udelay(100);
  236. eth_gpio = LDP_SMSC911X_GPIO;
  237. ldp_smsc911x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
  238. if (gpio_request(eth_gpio, "smsc911x irq") < 0) {
  239. printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
  240. eth_gpio);
  241. return;
  242. }
  243. gpio_direction_input(eth_gpio);
  244. }
  245. static struct platform_device ldp_lcd_device = {
  246. .name = "ldp_lcd",
  247. .id = -1,
  248. };
  249. static struct omap_lcd_config ldp_lcd_config __initdata = {
  250. .ctrl_name = "internal",
  251. };
  252. static struct omap_board_config_kernel ldp_config[] __initdata = {
  253. { OMAP_TAG_LCD, &ldp_lcd_config },
  254. };
  255. static void __init omap_ldp_init_irq(void)
  256. {
  257. omap_board_config = ldp_config;
  258. omap_board_config_size = ARRAY_SIZE(ldp_config);
  259. omap2_init_common_hw(NULL, NULL);
  260. omap_init_irq();
  261. omap_gpio_init();
  262. ldp_init_smsc911x();
  263. }
  264. static struct twl4030_usb_data ldp_usb_data = {
  265. .usb_mode = T2_USB_MODE_ULPI,
  266. };
  267. static struct twl4030_gpio_platform_data ldp_gpio_data = {
  268. .gpio_base = OMAP_MAX_GPIO_LINES,
  269. .irq_base = TWL4030_GPIO_IRQ_BASE,
  270. .irq_end = TWL4030_GPIO_IRQ_END,
  271. };
  272. static struct twl4030_madc_platform_data ldp_madc_data = {
  273. .irq_line = 1,
  274. };
  275. static struct regulator_consumer_supply ldp_vmmc1_supply = {
  276. .supply = "vmmc",
  277. };
  278. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  279. static struct regulator_init_data ldp_vmmc1 = {
  280. .constraints = {
  281. .min_uV = 1850000,
  282. .max_uV = 3150000,
  283. .valid_modes_mask = REGULATOR_MODE_NORMAL
  284. | REGULATOR_MODE_STANDBY,
  285. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  286. | REGULATOR_CHANGE_MODE
  287. | REGULATOR_CHANGE_STATUS,
  288. },
  289. .num_consumer_supplies = 1,
  290. .consumer_supplies = &ldp_vmmc1_supply,
  291. };
  292. static struct twl4030_platform_data ldp_twldata = {
  293. .irq_base = TWL4030_IRQ_BASE,
  294. .irq_end = TWL4030_IRQ_END,
  295. /* platform_data for children goes here */
  296. .madc = &ldp_madc_data,
  297. .usb = &ldp_usb_data,
  298. .vmmc1 = &ldp_vmmc1,
  299. .gpio = &ldp_gpio_data,
  300. .keypad = &ldp_kp_twl4030_data,
  301. };
  302. static struct i2c_board_info __initdata ldp_i2c_boardinfo[] = {
  303. {
  304. I2C_BOARD_INFO("twl4030", 0x48),
  305. .flags = I2C_CLIENT_WAKE,
  306. .irq = INT_34XX_SYS_NIRQ,
  307. .platform_data = &ldp_twldata,
  308. },
  309. };
  310. static int __init omap_i2c_init(void)
  311. {
  312. omap_register_i2c_bus(1, 2600, ldp_i2c_boardinfo,
  313. ARRAY_SIZE(ldp_i2c_boardinfo));
  314. omap_register_i2c_bus(2, 400, NULL, 0);
  315. omap_register_i2c_bus(3, 400, NULL, 0);
  316. return 0;
  317. }
  318. static struct twl4030_hsmmc_info mmc[] __initdata = {
  319. {
  320. .mmc = 1,
  321. .wires = 4,
  322. .gpio_cd = -EINVAL,
  323. .gpio_wp = -EINVAL,
  324. },
  325. {} /* Terminator */
  326. };
  327. static struct platform_device *ldp_devices[] __initdata = {
  328. &ldp_smsc911x_device,
  329. &ldp_lcd_device,
  330. &ldp_gpio_keys_device,
  331. };
  332. static void __init omap_ldp_init(void)
  333. {
  334. omap_i2c_init();
  335. platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
  336. ts_gpio = 54;
  337. ldp_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
  338. spi_register_board_info(ldp_spi_board_info,
  339. ARRAY_SIZE(ldp_spi_board_info));
  340. ads7846_dev_init();
  341. omap_serial_init();
  342. usb_musb_init();
  343. twl4030_mmc_init(mmc);
  344. /* link regulators to MMC adapters */
  345. ldp_vmmc1_supply.dev = mmc[0].dev;
  346. }
  347. static void __init omap_ldp_map_io(void)
  348. {
  349. omap2_set_globals_343x();
  350. omap2_map_common_io();
  351. }
  352. MACHINE_START(OMAP_LDP, "OMAP LDP board")
  353. .phys_io = 0x48000000,
  354. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  355. .boot_params = 0x80000100,
  356. .map_io = omap_ldp_map_io,
  357. .init_irq = omap_ldp_init_irq,
  358. .init_machine = omap_ldp_init,
  359. .timer = &omap_timer,
  360. MACHINE_END