palmz72.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. /*
  2. * Hardware definitions for Palm Zire72
  3. *
  4. * Authors:
  5. * Vladimir "Farcaller" Pouzanov <farcaller@gmail.com>
  6. * Sergey Lapin <slapin@ossfans.org>
  7. * Alex Osborne <bobofdoom@gmail.com>
  8. * Jan Herman <2hp@seznam.cz>
  9. *
  10. * Rewrite for mainline:
  11. * Marek Vasut <marek.vasut@gmail.com>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License version 2 as
  15. * published by the Free Software Foundation.
  16. *
  17. * (find more info at www.hackndev.com)
  18. *
  19. */
  20. #include <linux/platform_device.h>
  21. #include <linux/sysdev.h>
  22. #include <linux/delay.h>
  23. #include <linux/irq.h>
  24. #include <linux/gpio_keys.h>
  25. #include <linux/input.h>
  26. #include <linux/pda_power.h>
  27. #include <linux/pwm_backlight.h>
  28. #include <linux/gpio.h>
  29. #include <linux/wm97xx.h>
  30. #include <linux/power_supply.h>
  31. #include <linux/usb/gpio_vbus.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include <mach/pxa27x.h>
  36. #include <mach/audio.h>
  37. #include <mach/palmz72.h>
  38. #include <mach/mmc.h>
  39. #include <mach/pxafb.h>
  40. #include <mach/irda.h>
  41. #include <plat/pxa27x_keypad.h>
  42. #include <mach/udc.h>
  43. #include <mach/palmasoc.h>
  44. #include <mach/palm27x.h>
  45. #include <mach/pm.h>
  46. #include "generic.h"
  47. #include "devices.h"
  48. /******************************************************************************
  49. * Pin configuration
  50. ******************************************************************************/
  51. static unsigned long palmz72_pin_config[] __initdata = {
  52. /* MMC */
  53. GPIO32_MMC_CLK,
  54. GPIO92_MMC_DAT_0,
  55. GPIO109_MMC_DAT_1,
  56. GPIO110_MMC_DAT_2,
  57. GPIO111_MMC_DAT_3,
  58. GPIO112_MMC_CMD,
  59. GPIO14_GPIO, /* SD detect */
  60. GPIO115_GPIO, /* SD RO */
  61. GPIO98_GPIO, /* SD power */
  62. /* AC97 */
  63. GPIO28_AC97_BITCLK,
  64. GPIO29_AC97_SDATA_IN_0,
  65. GPIO30_AC97_SDATA_OUT,
  66. GPIO31_AC97_SYNC,
  67. GPIO89_AC97_SYSCLK,
  68. GPIO113_AC97_nRESET,
  69. /* IrDA */
  70. GPIO49_GPIO, /* ir disable */
  71. GPIO46_FICP_RXD,
  72. GPIO47_FICP_TXD,
  73. /* PWM */
  74. GPIO16_PWM0_OUT,
  75. /* USB */
  76. GPIO15_GPIO, /* usb detect */
  77. GPIO95_GPIO, /* usb pullup */
  78. /* Matrix keypad */
  79. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  80. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  81. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  82. GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  83. GPIO103_KP_MKOUT_0,
  84. GPIO104_KP_MKOUT_1,
  85. GPIO105_KP_MKOUT_2,
  86. /* LCD */
  87. GPIOxx_LCD_TFT_16BPP,
  88. GPIO20_GPIO, /* bl power */
  89. GPIO21_GPIO, /* LCD border switch */
  90. GPIO22_GPIO, /* LCD border color */
  91. GPIO96_GPIO, /* lcd power */
  92. /* Misc. */
  93. GPIO0_GPIO | WAKEUP_ON_LEVEL_HIGH, /* power detect */
  94. GPIO88_GPIO, /* green led */
  95. GPIO27_GPIO, /* WM9712 IRQ */
  96. };
  97. /******************************************************************************
  98. * GPIO keyboard
  99. ******************************************************************************/
  100. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  101. static unsigned int palmz72_matrix_keys[] = {
  102. KEY(0, 0, KEY_POWER),
  103. KEY(0, 1, KEY_F1),
  104. KEY(0, 2, KEY_ENTER),
  105. KEY(1, 0, KEY_F2),
  106. KEY(1, 1, KEY_F3),
  107. KEY(1, 2, KEY_F4),
  108. KEY(2, 0, KEY_UP),
  109. KEY(2, 2, KEY_DOWN),
  110. KEY(3, 0, KEY_RIGHT),
  111. KEY(3, 2, KEY_LEFT),
  112. };
  113. static struct pxa27x_keypad_platform_data palmz72_keypad_platform_data = {
  114. .matrix_key_rows = 4,
  115. .matrix_key_cols = 3,
  116. .matrix_key_map = palmz72_matrix_keys,
  117. .matrix_key_map_size = ARRAY_SIZE(palmz72_matrix_keys),
  118. .debounce_interval = 30,
  119. };
  120. static void __init palmz72_kpc_init(void)
  121. {
  122. pxa_set_keypad_info(&palmz72_keypad_platform_data);
  123. }
  124. #else
  125. static inline void palmz72_kpc_init(void) {}
  126. #endif
  127. /******************************************************************************
  128. * LEDs
  129. ******************************************************************************/
  130. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  131. static struct gpio_led gpio_leds[] = {
  132. {
  133. .name = "palmz72:green:led",
  134. .default_trigger = "none",
  135. .gpio = GPIO_NR_PALMZ72_LED_GREEN,
  136. },
  137. };
  138. static struct gpio_led_platform_data gpio_led_info = {
  139. .leds = gpio_leds,
  140. .num_leds = ARRAY_SIZE(gpio_leds),
  141. };
  142. static struct platform_device palmz72_leds = {
  143. .name = "leds-gpio",
  144. .id = -1,
  145. .dev = {
  146. .platform_data = &gpio_led_info,
  147. }
  148. };
  149. static void __init palmz72_leds_init(void)
  150. {
  151. platform_device_register(&palmz72_leds);
  152. }
  153. #else
  154. static inline void palmz72_leds_init(void) {}
  155. #endif
  156. #ifdef CONFIG_PM
  157. /* We have some black magic here
  158. * PalmOS ROM on recover expects special struct physical address
  159. * to be transferred via PSPR. Using this struct PalmOS restores
  160. * its state after sleep. As for Linux, we need to setup it the
  161. * same way. More than that, PalmOS ROM changes some values in memory.
  162. * For now only one location is found, which needs special treatment.
  163. * Thanks to Alex Osborne, Andrzej Zaborowski, and lots of other people
  164. * for reading backtraces for me :)
  165. */
  166. #define PALMZ72_SAVE_DWORD ((unsigned long *)0xc0000050)
  167. static struct palmz72_resume_info palmz72_resume_info = {
  168. .magic0 = 0xb4e6,
  169. .magic1 = 1,
  170. /* reset state, MMU off etc */
  171. .arm_control = 0,
  172. .aux_control = 0,
  173. .ttb = 0,
  174. .domain_access = 0,
  175. .process_id = 0,
  176. };
  177. static unsigned long store_ptr;
  178. /* sys_device for Palm Zire 72 PM */
  179. static int palmz72_pm_suspend(struct sys_device *dev, pm_message_t msg)
  180. {
  181. /* setup the resume_info struct for the original bootloader */
  182. palmz72_resume_info.resume_addr = (u32) cpu_resume;
  183. /* Storing memory touched by ROM */
  184. store_ptr = *PALMZ72_SAVE_DWORD;
  185. /* Setting PSPR to a proper value */
  186. PSPR = virt_to_phys(&palmz72_resume_info);
  187. return 0;
  188. }
  189. static int palmz72_pm_resume(struct sys_device *dev)
  190. {
  191. *PALMZ72_SAVE_DWORD = store_ptr;
  192. return 0;
  193. }
  194. static struct sysdev_class palmz72_pm_sysclass = {
  195. .name = "palmz72_pm",
  196. .suspend = palmz72_pm_suspend,
  197. .resume = palmz72_pm_resume,
  198. };
  199. static struct sys_device palmz72_pm_device = {
  200. .cls = &palmz72_pm_sysclass,
  201. };
  202. static int __init palmz72_pm_init(void)
  203. {
  204. int ret = -ENODEV;
  205. if (machine_is_palmz72()) {
  206. ret = sysdev_class_register(&palmz72_pm_sysclass);
  207. if (ret == 0)
  208. ret = sysdev_register(&palmz72_pm_device);
  209. }
  210. return ret;
  211. }
  212. device_initcall(palmz72_pm_init);
  213. #endif
  214. /******************************************************************************
  215. * Machine init
  216. ******************************************************************************/
  217. static void __init palmz72_init(void)
  218. {
  219. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config));
  220. pxa_set_ffuart_info(NULL);
  221. pxa_set_btuart_info(NULL);
  222. pxa_set_stuart_info(NULL);
  223. palm27x_mmc_init(GPIO_NR_PALMZ72_SD_DETECT_N, GPIO_NR_PALMZ72_SD_RO,
  224. GPIO_NR_PALMZ72_SD_POWER_N, 1);
  225. palm27x_lcd_init(-1, &palm_320x320_lcd_mode);
  226. palm27x_udc_init(GPIO_NR_PALMZ72_USB_DETECT_N,
  227. GPIO_NR_PALMZ72_USB_PULLUP, 0);
  228. palm27x_irda_init(GPIO_NR_PALMZ72_IR_DISABLE);
  229. palm27x_ac97_init(PALMZ72_BAT_MIN_VOLTAGE, PALMZ72_BAT_MAX_VOLTAGE,
  230. -1, 113);
  231. palm27x_pwm_init(-1, -1);
  232. palm27x_power_init(-1, -1);
  233. palm27x_pmic_init();
  234. palmz72_kpc_init();
  235. palmz72_leds_init();
  236. }
  237. MACHINE_START(PALMZ72, "Palm Zire72")
  238. .boot_params = 0xa0000100,
  239. .map_io = pxa27x_map_io,
  240. .init_irq = pxa27x_init_irq,
  241. .timer = &pxa_timer,
  242. .init_machine = palmz72_init
  243. MACHINE_END