palmz72.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Hardware definitions for Palm Zire72
  4. *
  5. * Authors:
  6. * Vladimir "Farcaller" Pouzanov <[email protected]>
  7. * Sergey Lapin <[email protected]>
  8. * Alex Osborne <[email protected]>
  9. * Jan Herman <[email protected]>
  10. *
  11. * Rewrite for mainline:
  12. * Marek Vasut <[email protected]>
  13. *
  14. * (find more info at www.hackndev.com)
  15. */
  16. #include <linux/platform_device.h>
  17. #include <linux/syscore_ops.h>
  18. #include <linux/delay.h>
  19. #include <linux/irq.h>
  20. #include <linux/gpio_keys.h>
  21. #include <linux/input.h>
  22. #include <linux/pda_power.h>
  23. #include <linux/pwm_backlight.h>
  24. #include <linux/gpio.h>
  25. #include <linux/wm97xx.h>
  26. #include <linux/power_supply.h>
  27. #include <linux/platform_data/i2c-gpio.h>
  28. #include <linux/gpio/machine.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/suspend.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include "pxa27x.h"
  34. #include <linux/platform_data/asoc-pxa.h>
  35. #include "palmz72.h"
  36. #include <linux/platform_data/mmc-pxamci.h>
  37. #include <linux/platform_data/video-pxafb.h>
  38. #include <linux/platform_data/irda-pxaficp.h>
  39. #include <linux/platform_data/keypad-pxa27x.h>
  40. #include "udc.h"
  41. #include <linux/platform_data/asoc-palm27x.h>
  42. #include "palm27x.h"
  43. #include "pm.h"
  44. #include <linux/platform_data/media/camera-pxa.h>
  45. #include "generic.h"
  46. #include "devices.h"
  47. /******************************************************************************
  48. * Pin configuration
  49. ******************************************************************************/
  50. static unsigned long palmz72_pin_config[] __initdata = {
  51. /* MMC */
  52. GPIO32_MMC_CLK,
  53. GPIO92_MMC_DAT_0,
  54. GPIO109_MMC_DAT_1,
  55. GPIO110_MMC_DAT_2,
  56. GPIO111_MMC_DAT_3,
  57. GPIO112_MMC_CMD,
  58. GPIO14_GPIO, /* SD detect */
  59. GPIO115_GPIO, /* SD RO */
  60. GPIO98_GPIO, /* SD power */
  61. /* AC97 */
  62. GPIO28_AC97_BITCLK,
  63. GPIO29_AC97_SDATA_IN_0,
  64. GPIO30_AC97_SDATA_OUT,
  65. GPIO31_AC97_SYNC,
  66. GPIO89_AC97_SYSCLK,
  67. GPIO113_AC97_nRESET,
  68. /* IrDA */
  69. GPIO49_GPIO, /* ir disable */
  70. GPIO46_FICP_RXD,
  71. GPIO47_FICP_TXD,
  72. /* PWM */
  73. GPIO16_PWM0_OUT,
  74. /* USB */
  75. GPIO15_GPIO, /* usb detect */
  76. GPIO95_GPIO, /* usb pullup */
  77. /* Matrix keypad */
  78. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  79. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  80. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  81. GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  82. GPIO103_KP_MKOUT_0,
  83. GPIO104_KP_MKOUT_1,
  84. GPIO105_KP_MKOUT_2,
  85. /* LCD */
  86. GPIOxx_LCD_TFT_16BPP,
  87. GPIO20_GPIO, /* bl power */
  88. GPIO21_GPIO, /* LCD border switch */
  89. GPIO22_GPIO, /* LCD border color */
  90. GPIO96_GPIO, /* lcd power */
  91. /* PXA Camera */
  92. GPIO81_CIF_DD_0,
  93. GPIO48_CIF_DD_5,
  94. GPIO50_CIF_DD_3,
  95. GPIO51_CIF_DD_2,
  96. GPIO52_CIF_DD_4,
  97. GPIO53_CIF_MCLK,
  98. GPIO54_CIF_PCLK,
  99. GPIO55_CIF_DD_1,
  100. GPIO84_CIF_FV,
  101. GPIO85_CIF_LV,
  102. GPIO93_CIF_DD_6,
  103. GPIO108_CIF_DD_7,
  104. GPIO56_GPIO, /* OV9640 Powerdown */
  105. GPIO57_GPIO, /* OV9640 Reset */
  106. GPIO91_GPIO, /* OV9640 Power */
  107. /* I2C */
  108. GPIO117_GPIO, /* I2C_SCL */
  109. GPIO118_GPIO, /* I2C_SDA */
  110. /* Misc. */
  111. GPIO0_GPIO | WAKEUP_ON_LEVEL_HIGH, /* power detect */
  112. GPIO88_GPIO, /* green led */
  113. GPIO27_GPIO, /* WM9712 IRQ */
  114. };
  115. /******************************************************************************
  116. * GPIO keyboard
  117. ******************************************************************************/
  118. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  119. static const unsigned int palmz72_matrix_keys[] = {
  120. KEY(0, 0, KEY_POWER),
  121. KEY(0, 1, KEY_F1),
  122. KEY(0, 2, KEY_ENTER),
  123. KEY(1, 0, KEY_F2),
  124. KEY(1, 1, KEY_F3),
  125. KEY(1, 2, KEY_F4),
  126. KEY(2, 0, KEY_UP),
  127. KEY(2, 2, KEY_DOWN),
  128. KEY(3, 0, KEY_RIGHT),
  129. KEY(3, 2, KEY_LEFT),
  130. };
  131. static struct matrix_keymap_data almz72_matrix_keymap_data = {
  132. .keymap = palmz72_matrix_keys,
  133. .keymap_size = ARRAY_SIZE(palmz72_matrix_keys),
  134. };
  135. static struct pxa27x_keypad_platform_data palmz72_keypad_platform_data = {
  136. .matrix_key_rows = 4,
  137. .matrix_key_cols = 3,
  138. .matrix_keymap_data = &almz72_matrix_keymap_data,
  139. .debounce_interval = 30,
  140. };
  141. static void __init palmz72_kpc_init(void)
  142. {
  143. pxa_set_keypad_info(&palmz72_keypad_platform_data);
  144. }
  145. #else
  146. static inline void palmz72_kpc_init(void) {}
  147. #endif
  148. /******************************************************************************
  149. * LEDs
  150. ******************************************************************************/
  151. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  152. static struct gpio_led gpio_leds[] = {
  153. {
  154. .name = "palmz72:green:led",
  155. .default_trigger = "none",
  156. .gpio = GPIO_NR_PALMZ72_LED_GREEN,
  157. },
  158. };
  159. static struct gpio_led_platform_data gpio_led_info = {
  160. .leds = gpio_leds,
  161. .num_leds = ARRAY_SIZE(gpio_leds),
  162. };
  163. static struct platform_device palmz72_leds = {
  164. .name = "leds-gpio",
  165. .id = -1,
  166. .dev = {
  167. .platform_data = &gpio_led_info,
  168. }
  169. };
  170. static void __init palmz72_leds_init(void)
  171. {
  172. platform_device_register(&palmz72_leds);
  173. }
  174. #else
  175. static inline void palmz72_leds_init(void) {}
  176. #endif
  177. #ifdef CONFIG_PM
  178. /* We have some black magic here
  179. * PalmOS ROM on recover expects special struct physical address
  180. * to be transferred via PSPR. Using this struct PalmOS restores
  181. * its state after sleep. As for Linux, we need to setup it the
  182. * same way. More than that, PalmOS ROM changes some values in memory.
  183. * For now only one location is found, which needs special treatment.
  184. * Thanks to Alex Osborne, Andrzej Zaborowski, and lots of other people
  185. * for reading backtraces for me :)
  186. */
  187. #define PALMZ72_SAVE_DWORD ((unsigned long *)0xc0000050)
  188. static struct palmz72_resume_info palmz72_resume_info = {
  189. .magic0 = 0xb4e6,
  190. .magic1 = 1,
  191. /* reset state, MMU off etc */
  192. .arm_control = 0,
  193. .aux_control = 0,
  194. .ttb = 0,
  195. .domain_access = 0,
  196. .process_id = 0,
  197. };
  198. static unsigned long store_ptr;
  199. /* syscore_ops for Palm Zire 72 PM */
  200. static int palmz72_pm_suspend(void)
  201. {
  202. /* setup the resume_info struct for the original bootloader */
  203. palmz72_resume_info.resume_addr = (u32) cpu_resume;
  204. /* Storing memory touched by ROM */
  205. store_ptr = *PALMZ72_SAVE_DWORD;
  206. /* Setting PSPR to a proper value */
  207. PSPR = __pa_symbol(&palmz72_resume_info);
  208. return 0;
  209. }
  210. static void palmz72_pm_resume(void)
  211. {
  212. *PALMZ72_SAVE_DWORD = store_ptr;
  213. }
  214. static struct syscore_ops palmz72_pm_syscore_ops = {
  215. .suspend = palmz72_pm_suspend,
  216. .resume = palmz72_pm_resume,
  217. };
  218. static int __init palmz72_pm_init(void)
  219. {
  220. if (machine_is_palmz72()) {
  221. register_syscore_ops(&palmz72_pm_syscore_ops);
  222. return 0;
  223. }
  224. return -ENODEV;
  225. }
  226. device_initcall(palmz72_pm_init);
  227. #endif
  228. static struct gpiod_lookup_table palmz72_mci_gpio_table = {
  229. .dev_id = "pxa2xx-mci.0",
  230. .table = {
  231. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_DETECT_N,
  232. "cd", GPIO_ACTIVE_LOW),
  233. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_RO,
  234. "wp", GPIO_ACTIVE_LOW),
  235. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_POWER_N,
  236. "power", GPIO_ACTIVE_LOW),
  237. { },
  238. },
  239. };
  240. /******************************************************************************
  241. * Machine init
  242. ******************************************************************************/
  243. static void __init palmz72_init(void)
  244. {
  245. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config));
  246. pxa_set_ffuart_info(NULL);
  247. pxa_set_btuart_info(NULL);
  248. pxa_set_stuart_info(NULL);
  249. palm27x_mmc_init(&palmz72_mci_gpio_table);
  250. palm27x_lcd_init(-1, &palm_320x320_lcd_mode);
  251. palm27x_udc_init(GPIO_NR_PALMZ72_USB_DETECT_N,
  252. GPIO_NR_PALMZ72_USB_PULLUP, 0);
  253. palm27x_irda_init(GPIO_NR_PALMZ72_IR_DISABLE);
  254. palm27x_ac97_init(PALMZ72_BAT_MIN_VOLTAGE, PALMZ72_BAT_MAX_VOLTAGE,
  255. -1, 113);
  256. palm27x_pwm_init(-1, -1);
  257. palm27x_power_init(-1, -1);
  258. palm27x_pmic_init();
  259. palmz72_kpc_init();
  260. palmz72_leds_init();
  261. }
  262. MACHINE_START(PALMZ72, "Palm Zire72")
  263. .atag_offset = 0x100,
  264. .map_io = pxa27x_map_io,
  265. .nr_irqs = PXA_NR_IRQS,
  266. .init_irq = pxa27x_init_irq,
  267. .handle_irq = pxa27x_handle_irq,
  268. .init_time = pxa_timer_init,
  269. .init_machine = palmz72_init,
  270. .restart = pxa_restart,
  271. MACHINE_END