palmt5.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Hardware definitions for Palm Tungsten|T5
  4. *
  5. * Author: Marek Vasut <[email protected]>
  6. *
  7. * Based on work of:
  8. * Ales Snuparek <[email protected]>
  9. * Justin Kendrick <[email protected]>
  10. * RichardT5 <[email protected]>
  11. *
  12. * (find more info at www.hackndev.com)
  13. */
  14. #include <linux/platform_device.h>
  15. #include <linux/delay.h>
  16. #include <linux/irq.h>
  17. #include <linux/gpio_keys.h>
  18. #include <linux/input.h>
  19. #include <linux/memblock.h>
  20. #include <linux/pda_power.h>
  21. #include <linux/pwm_backlight.h>
  22. #include <linux/gpio.h>
  23. #include <linux/wm97xx.h>
  24. #include <linux/power_supply.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/map.h>
  28. #include "pxa27x.h"
  29. #include <linux/platform_data/asoc-pxa.h>
  30. #include "palmt5.h"
  31. #include <linux/platform_data/mmc-pxamci.h>
  32. #include <linux/platform_data/video-pxafb.h>
  33. #include <linux/platform_data/irda-pxaficp.h>
  34. #include <linux/platform_data/keypad-pxa27x.h>
  35. #include "udc.h"
  36. #include <linux/platform_data/asoc-palm27x.h>
  37. #include "palm27x.h"
  38. #include "generic.h"
  39. #include "devices.h"
  40. /******************************************************************************
  41. * Pin configuration
  42. ******************************************************************************/
  43. static unsigned long palmt5_pin_config[] __initdata = {
  44. /* MMC */
  45. GPIO32_MMC_CLK,
  46. GPIO92_MMC_DAT_0,
  47. GPIO109_MMC_DAT_1,
  48. GPIO110_MMC_DAT_2,
  49. GPIO111_MMC_DAT_3,
  50. GPIO112_MMC_CMD,
  51. GPIO14_GPIO, /* SD detect */
  52. GPIO114_GPIO, /* SD power */
  53. GPIO115_GPIO, /* SD r/o switch */
  54. /* AC97 */
  55. GPIO28_AC97_BITCLK,
  56. GPIO29_AC97_SDATA_IN_0,
  57. GPIO30_AC97_SDATA_OUT,
  58. GPIO31_AC97_SYNC,
  59. GPIO89_AC97_SYSCLK,
  60. GPIO95_AC97_nRESET,
  61. /* IrDA */
  62. GPIO40_GPIO, /* ir disable */
  63. GPIO46_FICP_RXD,
  64. GPIO47_FICP_TXD,
  65. /* USB */
  66. GPIO15_GPIO, /* usb detect */
  67. GPIO93_GPIO, /* usb power */
  68. /* MATRIX KEYPAD */
  69. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  70. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  71. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  72. GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  73. GPIO103_KP_MKOUT_0,
  74. GPIO104_KP_MKOUT_1,
  75. GPIO105_KP_MKOUT_2,
  76. /* LCD */
  77. GPIOxx_LCD_TFT_16BPP,
  78. /* PWM */
  79. GPIO16_PWM0_OUT,
  80. /* FFUART */
  81. GPIO34_FFUART_RXD,
  82. GPIO39_FFUART_TXD,
  83. /* MISC */
  84. GPIO10_GPIO, /* hotsync button */
  85. GPIO90_GPIO, /* power detect */
  86. GPIO107_GPIO, /* earphone detect */
  87. };
  88. /******************************************************************************
  89. * GPIO keyboard
  90. ******************************************************************************/
  91. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  92. static const unsigned int palmt5_matrix_keys[] = {
  93. KEY(0, 0, KEY_POWER),
  94. KEY(0, 1, KEY_F1),
  95. KEY(0, 2, KEY_ENTER),
  96. KEY(1, 0, KEY_F2),
  97. KEY(1, 1, KEY_F3),
  98. KEY(1, 2, KEY_F4),
  99. KEY(2, 0, KEY_UP),
  100. KEY(2, 2, KEY_DOWN),
  101. KEY(3, 0, KEY_RIGHT),
  102. KEY(3, 2, KEY_LEFT),
  103. };
  104. static struct matrix_keymap_data palmt5_matrix_keymap_data = {
  105. .keymap = palmt5_matrix_keys,
  106. .keymap_size = ARRAY_SIZE(palmt5_matrix_keys),
  107. };
  108. static struct pxa27x_keypad_platform_data palmt5_keypad_platform_data = {
  109. .matrix_key_rows = 4,
  110. .matrix_key_cols = 3,
  111. .matrix_keymap_data = &palmt5_matrix_keymap_data,
  112. .debounce_interval = 30,
  113. };
  114. static void __init palmt5_kpc_init(void)
  115. {
  116. pxa_set_keypad_info(&palmt5_keypad_platform_data);
  117. }
  118. #else
  119. static inline void palmt5_kpc_init(void) {}
  120. #endif
  121. /******************************************************************************
  122. * GPIO keys
  123. ******************************************************************************/
  124. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  125. static struct gpio_keys_button palmt5_pxa_buttons[] = {
  126. {KEY_F8, GPIO_NR_PALMT5_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
  127. };
  128. static struct gpio_keys_platform_data palmt5_pxa_keys_data = {
  129. .buttons = palmt5_pxa_buttons,
  130. .nbuttons = ARRAY_SIZE(palmt5_pxa_buttons),
  131. };
  132. static struct platform_device palmt5_pxa_keys = {
  133. .name = "gpio-keys",
  134. .id = -1,
  135. .dev = {
  136. .platform_data = &palmt5_pxa_keys_data,
  137. },
  138. };
  139. static void __init palmt5_keys_init(void)
  140. {
  141. platform_device_register(&palmt5_pxa_keys);
  142. }
  143. #else
  144. static inline void palmt5_keys_init(void) {}
  145. #endif
  146. /******************************************************************************
  147. * Machine init
  148. ******************************************************************************/
  149. static void __init palmt5_reserve(void)
  150. {
  151. memblock_reserve(0xa0200000, 0x1000);
  152. }
  153. static struct gpiod_lookup_table palmt5_mci_gpio_table = {
  154. .dev_id = "pxa2xx-mci.0",
  155. .table = {
  156. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMT5_SD_DETECT_N,
  157. "cd", GPIO_ACTIVE_LOW),
  158. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMT5_SD_READONLY,
  159. "wp", GPIO_ACTIVE_LOW),
  160. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMT5_SD_POWER,
  161. "power", GPIO_ACTIVE_HIGH),
  162. { },
  163. },
  164. };
  165. static struct gpiod_lookup_table palmt5_wm97xx_touch_gpio_table = {
  166. .dev_id = "wm97xx-touch",
  167. .table = {
  168. GPIO_LOOKUP("gpio-pxa", 27, "touch", GPIO_ACTIVE_HIGH),
  169. { },
  170. },
  171. };
  172. static void __init palmt5_init(void)
  173. {
  174. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config));
  175. pxa_set_ffuart_info(NULL);
  176. pxa_set_btuart_info(NULL);
  177. pxa_set_stuart_info(NULL);
  178. palm27x_mmc_init(&palmt5_mci_gpio_table);
  179. gpiod_add_lookup_table(&palmt5_wm97xx_touch_gpio_table);
  180. palm27x_pm_init(PALMT5_STR_BASE);
  181. palm27x_lcd_init(-1, &palm_320x480_lcd_mode);
  182. palm27x_udc_init(GPIO_NR_PALMT5_USB_DETECT_N,
  183. GPIO_NR_PALMT5_USB_PULLUP, 1);
  184. palm27x_irda_init(GPIO_NR_PALMT5_IR_DISABLE);
  185. palm27x_ac97_init(PALMT5_BAT_MIN_VOLTAGE, PALMT5_BAT_MAX_VOLTAGE,
  186. GPIO_NR_PALMT5_EARPHONE_DETECT, 95);
  187. palm27x_pwm_init(GPIO_NR_PALMT5_BL_POWER, GPIO_NR_PALMT5_LCD_POWER);
  188. palm27x_power_init(GPIO_NR_PALMT5_POWER_DETECT, -1);
  189. palm27x_pmic_init();
  190. palmt5_kpc_init();
  191. palmt5_keys_init();
  192. }
  193. MACHINE_START(PALMT5, "Palm Tungsten|T5")
  194. .atag_offset = 0x100,
  195. .map_io = pxa27x_map_io,
  196. .reserve = palmt5_reserve,
  197. .nr_irqs = PXA_NR_IRQS,
  198. .init_irq = pxa27x_init_irq,
  199. .handle_irq = pxa27x_handle_irq,
  200. .init_time = pxa_timer_init,
  201. .init_machine = palmt5_init,
  202. .restart = pxa_restart,
  203. MACHINE_END