board-omap3pandora.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /*
  2. * board-omap3pandora.c (Pandora Handheld Console)
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  16. * 02110-1301 USA
  17. *
  18. */
  19. #include <linux/init.h>
  20. #include <linux/kernel.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/spi/spi.h>
  23. #include <linux/spi/ads7846.h>
  24. #include <linux/regulator/machine.h>
  25. #include <linux/i2c/twl4030.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <mach/board.h>
  30. #include <mach/common.h>
  31. #include <mach/gpio.h>
  32. #include <mach/hardware.h>
  33. #include <mach/mcspi.h>
  34. #include <mach/usb.h>
  35. #include "sdram-micron-mt46h32m32lf-6.h"
  36. #include "mmc-twl4030.h"
  37. #define OMAP3_PANDORA_TS_GPIO 94
  38. static struct twl4030_hsmmc_info omap3pandora_mmc[] = {
  39. {
  40. .mmc = 1,
  41. .wires = 4,
  42. .gpio_cd = -EINVAL,
  43. .gpio_wp = 126,
  44. .ext_clock = 0,
  45. },
  46. {
  47. .mmc = 2,
  48. .wires = 4,
  49. .gpio_cd = -EINVAL,
  50. .gpio_wp = 127,
  51. .ext_clock = 1,
  52. .transceiver = true,
  53. },
  54. {
  55. .mmc = 3,
  56. .wires = 4,
  57. .gpio_cd = -EINVAL,
  58. .gpio_wp = -EINVAL,
  59. },
  60. {} /* Terminator */
  61. };
  62. static struct omap_uart_config omap3pandora_uart_config __initdata = {
  63. .enabled_uarts = (1 << 2), /* UART3 */
  64. };
  65. static struct regulator_consumer_supply pandora_vmmc1_supply = {
  66. .supply = "vmmc",
  67. };
  68. static struct regulator_consumer_supply pandora_vmmc2_supply = {
  69. .supply = "vmmc",
  70. };
  71. static int omap3pandora_twl_gpio_setup(struct device *dev,
  72. unsigned gpio, unsigned ngpio)
  73. {
  74. /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
  75. omap3pandora_mmc[0].gpio_cd = gpio + 0;
  76. omap3pandora_mmc[1].gpio_cd = gpio + 1;
  77. twl4030_mmc_init(omap3pandora_mmc);
  78. /* link regulators to MMC adapters */
  79. pandora_vmmc1_supply.dev = omap3pandora_mmc[0].dev;
  80. pandora_vmmc2_supply.dev = omap3pandora_mmc[1].dev;
  81. return 0;
  82. }
  83. static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
  84. .gpio_base = OMAP_MAX_GPIO_LINES,
  85. .irq_base = TWL4030_GPIO_IRQ_BASE,
  86. .irq_end = TWL4030_GPIO_IRQ_END,
  87. .setup = omap3pandora_twl_gpio_setup,
  88. };
  89. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  90. static struct regulator_init_data pandora_vmmc1 = {
  91. .constraints = {
  92. .min_uV = 1850000,
  93. .max_uV = 3150000,
  94. .valid_modes_mask = REGULATOR_MODE_NORMAL
  95. | REGULATOR_MODE_STANDBY,
  96. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  97. | REGULATOR_CHANGE_MODE
  98. | REGULATOR_CHANGE_STATUS,
  99. },
  100. .num_consumer_supplies = 1,
  101. .consumer_supplies = &pandora_vmmc1_supply,
  102. };
  103. /* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */
  104. static struct regulator_init_data pandora_vmmc2 = {
  105. .constraints = {
  106. .min_uV = 1850000,
  107. .max_uV = 3150000,
  108. .valid_modes_mask = REGULATOR_MODE_NORMAL
  109. | REGULATOR_MODE_STANDBY,
  110. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  111. | REGULATOR_CHANGE_MODE
  112. | REGULATOR_CHANGE_STATUS,
  113. },
  114. .num_consumer_supplies = 1,
  115. .consumer_supplies = &pandora_vmmc2_supply,
  116. };
  117. static struct twl4030_usb_data omap3pandora_usb_data = {
  118. .usb_mode = T2_USB_MODE_ULPI,
  119. };
  120. static struct twl4030_platform_data omap3pandora_twldata = {
  121. .irq_base = TWL4030_IRQ_BASE,
  122. .irq_end = TWL4030_IRQ_END,
  123. .gpio = &omap3pandora_gpio_data,
  124. .usb = &omap3pandora_usb_data,
  125. .vmmc1 = &pandora_vmmc1,
  126. .vmmc2 = &pandora_vmmc2,
  127. };
  128. static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
  129. {
  130. I2C_BOARD_INFO("tps65950", 0x48),
  131. .flags = I2C_CLIENT_WAKE,
  132. .irq = INT_34XX_SYS_NIRQ,
  133. .platform_data = &omap3pandora_twldata,
  134. },
  135. };
  136. static int __init omap3pandora_i2c_init(void)
  137. {
  138. omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
  139. ARRAY_SIZE(omap3pandora_i2c_boardinfo));
  140. /* i2c2 pins are not connected */
  141. omap_register_i2c_bus(3, 400, NULL, 0);
  142. return 0;
  143. }
  144. static void __init omap3pandora_init_irq(void)
  145. {
  146. omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
  147. omap_init_irq();
  148. omap_gpio_init();
  149. }
  150. static void __init omap3pandora_ads7846_init(void)
  151. {
  152. int gpio = OMAP3_PANDORA_TS_GPIO;
  153. int ret;
  154. ret = gpio_request(gpio, "ads7846_pen_down");
  155. if (ret < 0) {
  156. printk(KERN_ERR "Failed to request GPIO %d for "
  157. "ads7846 pen down IRQ\n", gpio);
  158. return;
  159. }
  160. gpio_direction_input(gpio);
  161. }
  162. static int ads7846_get_pendown_state(void)
  163. {
  164. return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
  165. }
  166. static struct ads7846_platform_data ads7846_config = {
  167. .x_max = 0x0fff,
  168. .y_max = 0x0fff,
  169. .x_plate_ohms = 180,
  170. .pressure_max = 255,
  171. .debounce_max = 10,
  172. .debounce_tol = 3,
  173. .debounce_rep = 1,
  174. .get_pendown_state = ads7846_get_pendown_state,
  175. .keep_vref_on = 1,
  176. };
  177. static struct omap2_mcspi_device_config ads7846_mcspi_config = {
  178. .turbo_mode = 0,
  179. .single_channel = 1, /* 0: slave, 1: master */
  180. };
  181. static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
  182. {
  183. .modalias = "ads7846",
  184. .bus_num = 1,
  185. .chip_select = 0,
  186. .max_speed_hz = 1500000,
  187. .controller_data = &ads7846_mcspi_config,
  188. .irq = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
  189. .platform_data = &ads7846_config,
  190. }
  191. };
  192. static struct platform_device omap3pandora_lcd_device = {
  193. .name = "pandora_lcd",
  194. .id = -1,
  195. };
  196. static struct omap_lcd_config omap3pandora_lcd_config __initdata = {
  197. .ctrl_name = "internal",
  198. };
  199. static struct omap_board_config_kernel omap3pandora_config[] __initdata = {
  200. { OMAP_TAG_UART, &omap3pandora_uart_config },
  201. { OMAP_TAG_LCD, &omap3pandora_lcd_config },
  202. };
  203. static struct platform_device *omap3pandora_devices[] __initdata = {
  204. &omap3pandora_lcd_device,
  205. };
  206. static void __init omap3pandora_init(void)
  207. {
  208. omap3pandora_i2c_init();
  209. platform_add_devices(omap3pandora_devices,
  210. ARRAY_SIZE(omap3pandora_devices));
  211. omap_board_config = omap3pandora_config;
  212. omap_board_config_size = ARRAY_SIZE(omap3pandora_config);
  213. omap_serial_init();
  214. spi_register_board_info(omap3pandora_spi_board_info,
  215. ARRAY_SIZE(omap3pandora_spi_board_info));
  216. omap3pandora_ads7846_init();
  217. usb_musb_init();
  218. }
  219. static void __init omap3pandora_map_io(void)
  220. {
  221. omap2_set_globals_343x();
  222. omap2_map_common_io();
  223. }
  224. MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
  225. .phys_io = 0x48000000,
  226. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  227. .boot_params = 0x80000100,
  228. .map_io = omap3pandora_map_io,
  229. .init_irq = omap3pandora_init_irq,
  230. .init_machine = omap3pandora_init,
  231. .timer = &omap_timer,
  232. MACHINE_END