board-ldp.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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/twl.h>
  27. #include <linux/io.h>
  28. #include <linux/smsc911x.h>
  29. #include <linux/mmc/host.h>
  30. #include <mach/hardware.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/map.h>
  34. #include <plat/mcspi.h>
  35. #include <mach/gpio.h>
  36. #include <plat/board.h>
  37. #include <plat/common.h>
  38. #include <plat/gpmc.h>
  39. #include <mach/board-zoom.h>
  40. #include <asm/delay.h>
  41. #include <plat/control.h>
  42. #include <plat/usb.h>
  43. #include "mux.h"
  44. #include "hsmmc.h"
  45. #define LDP_SMSC911X_CS 1
  46. #define LDP_SMSC911X_GPIO 152
  47. #define DEBUG_BASE 0x08000000
  48. #define LDP_ETHR_START DEBUG_BASE
  49. static struct resource ldp_smsc911x_resources[] = {
  50. [0] = {
  51. .start = LDP_ETHR_START,
  52. .end = LDP_ETHR_START + SZ_4K,
  53. .flags = IORESOURCE_MEM,
  54. },
  55. [1] = {
  56. .start = 0,
  57. .end = 0,
  58. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  59. },
  60. };
  61. static struct smsc911x_platform_config ldp_smsc911x_config = {
  62. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  63. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  64. .flags = SMSC911X_USE_32BIT,
  65. .phy_interface = PHY_INTERFACE_MODE_MII,
  66. };
  67. static struct platform_device ldp_smsc911x_device = {
  68. .name = "smsc911x",
  69. .id = -1,
  70. .num_resources = ARRAY_SIZE(ldp_smsc911x_resources),
  71. .resource = ldp_smsc911x_resources,
  72. .dev = {
  73. .platform_data = &ldp_smsc911x_config,
  74. },
  75. };
  76. static int board_keymap[] = {
  77. KEY(0, 0, KEY_1),
  78. KEY(1, 0, KEY_2),
  79. KEY(2, 0, KEY_3),
  80. KEY(0, 1, KEY_4),
  81. KEY(1, 1, KEY_5),
  82. KEY(2, 1, KEY_6),
  83. KEY(3, 1, KEY_F5),
  84. KEY(0, 2, KEY_7),
  85. KEY(1, 2, KEY_8),
  86. KEY(2, 2, KEY_9),
  87. KEY(3, 2, KEY_F6),
  88. KEY(0, 3, KEY_F7),
  89. KEY(1, 3, KEY_0),
  90. KEY(2, 3, KEY_F8),
  91. PERSISTENT_KEY(4, 5),
  92. KEY(4, 4, KEY_VOLUMEUP),
  93. KEY(5, 5, KEY_VOLUMEDOWN),
  94. 0
  95. };
  96. static struct matrix_keymap_data board_map_data = {
  97. .keymap = board_keymap,
  98. .keymap_size = ARRAY_SIZE(board_keymap),
  99. };
  100. static struct twl4030_keypad_data ldp_kp_twl4030_data = {
  101. .keymap_data = &board_map_data,
  102. .rows = 6,
  103. .cols = 6,
  104. .rep = 1,
  105. };
  106. static struct gpio_keys_button ldp_gpio_keys_buttons[] = {
  107. [0] = {
  108. .code = KEY_ENTER,
  109. .gpio = 101,
  110. .desc = "enter sw",
  111. .active_low = 1,
  112. .debounce_interval = 30,
  113. },
  114. [1] = {
  115. .code = KEY_F1,
  116. .gpio = 102,
  117. .desc = "func 1",
  118. .active_low = 1,
  119. .debounce_interval = 30,
  120. },
  121. [2] = {
  122. .code = KEY_F2,
  123. .gpio = 103,
  124. .desc = "func 2",
  125. .active_low = 1,
  126. .debounce_interval = 30,
  127. },
  128. [3] = {
  129. .code = KEY_F3,
  130. .gpio = 104,
  131. .desc = "func 3",
  132. .active_low = 1,
  133. .debounce_interval = 30,
  134. },
  135. [4] = {
  136. .code = KEY_F4,
  137. .gpio = 105,
  138. .desc = "func 4",
  139. .active_low = 1,
  140. .debounce_interval = 30,
  141. },
  142. [5] = {
  143. .code = KEY_LEFT,
  144. .gpio = 106,
  145. .desc = "left sw",
  146. .active_low = 1,
  147. .debounce_interval = 30,
  148. },
  149. [6] = {
  150. .code = KEY_RIGHT,
  151. .gpio = 107,
  152. .desc = "right sw",
  153. .active_low = 1,
  154. .debounce_interval = 30,
  155. },
  156. [7] = {
  157. .code = KEY_UP,
  158. .gpio = 108,
  159. .desc = "up sw",
  160. .active_low = 1,
  161. .debounce_interval = 30,
  162. },
  163. [8] = {
  164. .code = KEY_DOWN,
  165. .gpio = 109,
  166. .desc = "down sw",
  167. .active_low = 1,
  168. .debounce_interval = 30,
  169. },
  170. };
  171. static struct gpio_keys_platform_data ldp_gpio_keys = {
  172. .buttons = ldp_gpio_keys_buttons,
  173. .nbuttons = ARRAY_SIZE(ldp_gpio_keys_buttons),
  174. .rep = 1,
  175. };
  176. static struct platform_device ldp_gpio_keys_device = {
  177. .name = "gpio-keys",
  178. .id = -1,
  179. .dev = {
  180. .platform_data = &ldp_gpio_keys,
  181. },
  182. };
  183. static int ts_gpio;
  184. /**
  185. * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
  186. *
  187. * @return - void. If request gpio fails then Flag KERN_ERR.
  188. */
  189. static void ads7846_dev_init(void)
  190. {
  191. if (gpio_request(ts_gpio, "ads7846 irq") < 0) {
  192. printk(KERN_ERR "can't get ads746 pen down GPIO\n");
  193. return;
  194. }
  195. gpio_direction_input(ts_gpio);
  196. gpio_set_debounce(ts_gpio, 310);
  197. }
  198. static int ads7846_get_pendown_state(void)
  199. {
  200. return !gpio_get_value(ts_gpio);
  201. }
  202. static struct ads7846_platform_data tsc2046_config __initdata = {
  203. .get_pendown_state = ads7846_get_pendown_state,
  204. .keep_vref_on = 1,
  205. };
  206. static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
  207. .turbo_mode = 0,
  208. .single_channel = 1, /* 0: slave, 1: master */
  209. };
  210. static struct spi_board_info ldp_spi_board_info[] __initdata = {
  211. [0] = {
  212. /*
  213. * TSC2046 operates at a max freqency of 2MHz, so
  214. * operate slightly below at 1.5MHz
  215. */
  216. .modalias = "ads7846",
  217. .bus_num = 1,
  218. .chip_select = 0,
  219. .max_speed_hz = 1500000,
  220. .controller_data = &tsc2046_mcspi_config,
  221. .irq = 0,
  222. .platform_data = &tsc2046_config,
  223. },
  224. };
  225. static inline void __init ldp_init_smsc911x(void)
  226. {
  227. int eth_cs;
  228. unsigned long cs_mem_base;
  229. int eth_gpio = 0;
  230. eth_cs = LDP_SMSC911X_CS;
  231. if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
  232. printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
  233. return;
  234. }
  235. ldp_smsc911x_resources[0].start = cs_mem_base + 0x0;
  236. ldp_smsc911x_resources[0].end = cs_mem_base + 0xff;
  237. udelay(100);
  238. eth_gpio = LDP_SMSC911X_GPIO;
  239. ldp_smsc911x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
  240. if (gpio_request(eth_gpio, "smsc911x irq") < 0) {
  241. printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
  242. eth_gpio);
  243. return;
  244. }
  245. gpio_direction_input(eth_gpio);
  246. }
  247. static struct platform_device ldp_lcd_device = {
  248. .name = "ldp_lcd",
  249. .id = -1,
  250. };
  251. static struct omap_lcd_config ldp_lcd_config __initdata = {
  252. .ctrl_name = "internal",
  253. };
  254. static struct omap_board_config_kernel ldp_config[] __initdata = {
  255. { OMAP_TAG_LCD, &ldp_lcd_config },
  256. };
  257. static void __init omap_ldp_init_irq(void)
  258. {
  259. omap_board_config = ldp_config;
  260. omap_board_config_size = ARRAY_SIZE(ldp_config);
  261. omap2_init_common_hw(NULL, NULL);
  262. omap_init_irq();
  263. omap_gpio_init();
  264. ldp_init_smsc911x();
  265. }
  266. static struct twl4030_usb_data ldp_usb_data = {
  267. .usb_mode = T2_USB_MODE_ULPI,
  268. };
  269. static struct twl4030_gpio_platform_data ldp_gpio_data = {
  270. .gpio_base = OMAP_MAX_GPIO_LINES,
  271. .irq_base = TWL4030_GPIO_IRQ_BASE,
  272. .irq_end = TWL4030_GPIO_IRQ_END,
  273. };
  274. static struct twl4030_madc_platform_data ldp_madc_data = {
  275. .irq_line = 1,
  276. };
  277. static struct regulator_consumer_supply ldp_vmmc1_supply = {
  278. .supply = "vmmc",
  279. };
  280. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  281. static struct regulator_init_data ldp_vmmc1 = {
  282. .constraints = {
  283. .min_uV = 1850000,
  284. .max_uV = 3150000,
  285. .valid_modes_mask = REGULATOR_MODE_NORMAL
  286. | REGULATOR_MODE_STANDBY,
  287. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  288. | REGULATOR_CHANGE_MODE
  289. | REGULATOR_CHANGE_STATUS,
  290. },
  291. .num_consumer_supplies = 1,
  292. .consumer_supplies = &ldp_vmmc1_supply,
  293. };
  294. static struct twl4030_platform_data ldp_twldata = {
  295. .irq_base = TWL4030_IRQ_BASE,
  296. .irq_end = TWL4030_IRQ_END,
  297. /* platform_data for children goes here */
  298. .madc = &ldp_madc_data,
  299. .usb = &ldp_usb_data,
  300. .vmmc1 = &ldp_vmmc1,
  301. .gpio = &ldp_gpio_data,
  302. .keypad = &ldp_kp_twl4030_data,
  303. };
  304. static struct i2c_board_info __initdata ldp_i2c_boardinfo[] = {
  305. {
  306. I2C_BOARD_INFO("twl4030", 0x48),
  307. .flags = I2C_CLIENT_WAKE,
  308. .irq = INT_34XX_SYS_NIRQ,
  309. .platform_data = &ldp_twldata,
  310. },
  311. };
  312. static int __init omap_i2c_init(void)
  313. {
  314. omap_register_i2c_bus(1, 2600, ldp_i2c_boardinfo,
  315. ARRAY_SIZE(ldp_i2c_boardinfo));
  316. omap_register_i2c_bus(2, 400, NULL, 0);
  317. omap_register_i2c_bus(3, 400, NULL, 0);
  318. return 0;
  319. }
  320. static struct omap2_hsmmc_info mmc[] __initdata = {
  321. {
  322. .mmc = 1,
  323. .caps = MMC_CAP_4_BIT_DATA,
  324. .gpio_cd = -EINVAL,
  325. .gpio_wp = -EINVAL,
  326. },
  327. {} /* Terminator */
  328. };
  329. static struct platform_device *ldp_devices[] __initdata = {
  330. &ldp_smsc911x_device,
  331. &ldp_lcd_device,
  332. &ldp_gpio_keys_device,
  333. };
  334. #ifdef CONFIG_OMAP_MUX
  335. static struct omap_board_mux board_mux[] __initdata = {
  336. { .reg_offset = OMAP_MUX_TERMINATOR },
  337. };
  338. #else
  339. #define board_mux NULL
  340. #endif
  341. static struct omap_musb_board_data musb_board_data = {
  342. .interface_type = MUSB_INTERFACE_ULPI,
  343. .mode = MUSB_OTG,
  344. .power = 100,
  345. };
  346. static struct mtd_partition ldp_nand_partitions[] = {
  347. /* All the partition sizes are listed in terms of NAND block size */
  348. {
  349. .name = "X-Loader-NAND",
  350. .offset = 0,
  351. .size = 4 * (64 * 2048), /* 512KB, 0x80000 */
  352. .mask_flags = MTD_WRITEABLE, /* force read-only */
  353. },
  354. {
  355. .name = "U-Boot-NAND",
  356. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  357. .size = 10 * (64 * 2048), /* 1.25MB, 0x140000 */
  358. .mask_flags = MTD_WRITEABLE, /* force read-only */
  359. },
  360. {
  361. .name = "Boot Env-NAND",
  362. .offset = MTDPART_OFS_APPEND, /* Offset = 0x1c0000 */
  363. .size = 2 * (64 * 2048), /* 256KB, 0x40000 */
  364. },
  365. {
  366. .name = "Kernel-NAND",
  367. .offset = MTDPART_OFS_APPEND, /* Offset = 0x0200000*/
  368. .size = 240 * (64 * 2048), /* 30M, 0x1E00000 */
  369. },
  370. {
  371. .name = "File System - NAND",
  372. .offset = MTDPART_OFS_APPEND, /* Offset = 0x2000000 */
  373. .size = MTDPART_SIZ_FULL, /* 96MB, 0x6000000 */
  374. },
  375. };
  376. static void __init omap_ldp_init(void)
  377. {
  378. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  379. omap_i2c_init();
  380. platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
  381. ts_gpio = 54;
  382. ldp_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
  383. spi_register_board_info(ldp_spi_board_info,
  384. ARRAY_SIZE(ldp_spi_board_info));
  385. ads7846_dev_init();
  386. omap_serial_init();
  387. usb_musb_init(&musb_board_data);
  388. board_nand_init(ldp_nand_partitions,
  389. ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS);
  390. omap2_hsmmc_init(mmc);
  391. /* link regulators to MMC adapters */
  392. ldp_vmmc1_supply.dev = mmc[0].dev;
  393. }
  394. MACHINE_START(OMAP_LDP, "OMAP LDP board")
  395. .phys_io = 0x48000000,
  396. .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
  397. .boot_params = 0x80000100,
  398. .map_io = omap3_map_io,
  399. .reserve = omap_reserve,
  400. .init_irq = omap_ldp_init_irq,
  401. .init_machine = omap_ldp_init,
  402. .timer = &omap_timer,
  403. MACHINE_END