board-omap3pandora.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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/i2c/twl4030.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/map.h>
  28. #include <mach/board.h>
  29. #include <mach/common.h>
  30. #include <mach/gpio.h>
  31. #include <mach/hardware.h>
  32. #include <mach/mcspi.h>
  33. #define OMAP3_PANDORA_TS_GPIO 94
  34. static struct omap_uart_config omap3pandora_uart_config __initdata = {
  35. .enabled_uarts = (1 << 2), /* UART3 */
  36. };
  37. static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
  38. .gpio_base = OMAP_MAX_GPIO_LINES,
  39. .irq_base = TWL4030_GPIO_IRQ_BASE,
  40. .irq_end = TWL4030_GPIO_IRQ_END,
  41. };
  42. static struct twl4030_usb_data omap3pandora_usb_data = {
  43. .usb_mode = T2_USB_MODE_ULPI,
  44. };
  45. static struct twl4030_platform_data omap3pandora_twldata = {
  46. .irq_base = TWL4030_IRQ_BASE,
  47. .irq_end = TWL4030_IRQ_END,
  48. .gpio = &omap3pandora_gpio_data,
  49. .usb = &omap3pandora_usb_data,
  50. };
  51. static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
  52. {
  53. I2C_BOARD_INFO("tps65950", 0x48),
  54. .flags = I2C_CLIENT_WAKE,
  55. .irq = INT_34XX_SYS_NIRQ,
  56. .platform_data = &omap3pandora_twldata,
  57. },
  58. };
  59. static int __init omap3pandora_i2c_init(void)
  60. {
  61. omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
  62. ARRAY_SIZE(omap3pandora_i2c_boardinfo));
  63. /* i2c2 pins are not connected */
  64. omap_register_i2c_bus(3, 400, NULL, 0);
  65. return 0;
  66. }
  67. static void __init omap3pandora_init_irq(void)
  68. {
  69. omap2_init_common_hw();
  70. omap_init_irq();
  71. omap_gpio_init();
  72. }
  73. static void __init omap3pandora_ads7846_init(void)
  74. {
  75. int gpio = OMAP3_PANDORA_TS_GPIO;
  76. int ret;
  77. ret = gpio_request(gpio, "ads7846_pen_down");
  78. if (ret < 0) {
  79. printk(KERN_ERR "Failed to request GPIO %d for "
  80. "ads7846 pen down IRQ\n", gpio);
  81. return;
  82. }
  83. gpio_direction_input(gpio);
  84. }
  85. static int ads7846_get_pendown_state(void)
  86. {
  87. return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
  88. }
  89. static struct ads7846_platform_data ads7846_config = {
  90. .x_max = 0x0fff,
  91. .y_max = 0x0fff,
  92. .x_plate_ohms = 180,
  93. .pressure_max = 255,
  94. .debounce_max = 10,
  95. .debounce_tol = 3,
  96. .debounce_rep = 1,
  97. .get_pendown_state = ads7846_get_pendown_state,
  98. .keep_vref_on = 1,
  99. };
  100. static struct omap2_mcspi_device_config ads7846_mcspi_config = {
  101. .turbo_mode = 0,
  102. .single_channel = 1, /* 0: slave, 1: master */
  103. };
  104. static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
  105. {
  106. .modalias = "ads7846",
  107. .bus_num = 1,
  108. .chip_select = 0,
  109. .max_speed_hz = 1500000,
  110. .controller_data = &ads7846_mcspi_config,
  111. .irq = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
  112. .platform_data = &ads7846_config,
  113. }
  114. };
  115. static struct platform_device omap3pandora_lcd_device = {
  116. .name = "pandora_lcd",
  117. .id = -1,
  118. };
  119. static struct omap_lcd_config omap3pandora_lcd_config __initdata = {
  120. .ctrl_name = "internal",
  121. };
  122. static struct omap_board_config_kernel omap3pandora_config[] __initdata = {
  123. { OMAP_TAG_UART, &omap3pandora_uart_config },
  124. { OMAP_TAG_LCD, &omap3pandora_lcd_config },
  125. };
  126. static struct platform_device *omap3pandora_devices[] __initdata = {
  127. &omap3pandora_lcd_device,
  128. };
  129. static void __init omap3pandora_init(void)
  130. {
  131. omap3pandora_i2c_init();
  132. platform_add_devices(omap3pandora_devices,
  133. ARRAY_SIZE(omap3pandora_devices));
  134. omap_board_config = omap3pandora_config;
  135. omap_board_config_size = ARRAY_SIZE(omap3pandora_config);
  136. omap_serial_init();
  137. spi_register_board_info(omap3pandora_spi_board_info,
  138. ARRAY_SIZE(omap3pandora_spi_board_info));
  139. omap3pandora_ads7846_init();
  140. }
  141. static void __init omap3pandora_map_io(void)
  142. {
  143. omap2_set_globals_343x();
  144. omap2_map_common_io();
  145. }
  146. MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
  147. .phys_io = 0x48000000,
  148. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  149. .boot_params = 0x80000100,
  150. .map_io = omap3pandora_map_io,
  151. .init_irq = omap3pandora_init_irq,
  152. .init_machine = omap3pandora_init,
  153. .timer = &omap_timer,
  154. MACHINE_END