board-palmz71.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /*
  2. * linux/arch/arm/mach-omap1/board-palmz71.c
  3. *
  4. * Modified from board-generic.c
  5. *
  6. * Support for the Palm Zire71 PDA.
  7. *
  8. * Original version : Laurent Gonzalez
  9. *
  10. * Modified for zire71 : Marek Vasut
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. */
  16. #include <linux/delay.h>
  17. #include <linux/gpio.h>
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/notifier.h>
  22. #include <linux/clk.h>
  23. #include <linux/irq.h>
  24. #include <linux/input.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/mtd/mtd.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <linux/mtd/physmap.h>
  29. #include <linux/omapfb.h>
  30. #include <linux/spi/spi.h>
  31. #include <linux/spi/ads7846.h>
  32. #include <linux/platform_data/omap1_bl.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include "flash.h"
  37. #include <mach/mux.h>
  38. #include <linux/omap-dma.h>
  39. #include <mach/tc.h>
  40. #include <linux/platform_data/keypad-omap.h>
  41. #include <mach/hardware.h>
  42. #include <mach/usb.h>
  43. #include "common.h"
  44. #define PALMZ71_USBDETECT_GPIO 0
  45. #define PALMZ71_PENIRQ_GPIO 6
  46. #define PALMZ71_MMC_WP_GPIO 8
  47. #define PALMZ71_HDQ_GPIO 11
  48. #define PALMZ71_HOTSYNC_GPIO OMAP_MPUIO(1)
  49. #define PALMZ71_CABLE_GPIO OMAP_MPUIO(2)
  50. #define PALMZ71_SLIDER_GPIO OMAP_MPUIO(3)
  51. #define PALMZ71_MMC_IN_GPIO OMAP_MPUIO(4)
  52. static const unsigned int palmz71_keymap[] = {
  53. KEY(0, 0, KEY_F1),
  54. KEY(1, 0, KEY_F2),
  55. KEY(2, 0, KEY_F3),
  56. KEY(3, 0, KEY_F4),
  57. KEY(4, 0, KEY_POWER),
  58. KEY(0, 1, KEY_LEFT),
  59. KEY(1, 1, KEY_DOWN),
  60. KEY(2, 1, KEY_UP),
  61. KEY(3, 1, KEY_RIGHT),
  62. KEY(4, 1, KEY_ENTER),
  63. KEY(0, 2, KEY_CAMERA),
  64. };
  65. static const struct matrix_keymap_data palmz71_keymap_data = {
  66. .keymap = palmz71_keymap,
  67. .keymap_size = ARRAY_SIZE(palmz71_keymap),
  68. };
  69. static struct omap_kp_platform_data palmz71_kp_data = {
  70. .rows = 8,
  71. .cols = 8,
  72. .keymap_data = &palmz71_keymap_data,
  73. .rep = true,
  74. .delay = 80,
  75. };
  76. static struct resource palmz71_kp_resources[] = {
  77. [0] = {
  78. .start = INT_KEYBOARD,
  79. .end = INT_KEYBOARD,
  80. .flags = IORESOURCE_IRQ,
  81. },
  82. };
  83. static struct platform_device palmz71_kp_device = {
  84. .name = "omap-keypad",
  85. .id = -1,
  86. .dev = {
  87. .platform_data = &palmz71_kp_data,
  88. },
  89. .num_resources = ARRAY_SIZE(palmz71_kp_resources),
  90. .resource = palmz71_kp_resources,
  91. };
  92. static struct mtd_partition palmz71_rom_partitions[] = {
  93. /* PalmOS "Small ROM", contains the bootloader and the debugger */
  94. {
  95. .name = "smallrom",
  96. .offset = 0,
  97. .size = 0xa000,
  98. .mask_flags = MTD_WRITEABLE,
  99. },
  100. /* PalmOS "Big ROM", a filesystem with all the OS code and data */
  101. {
  102. .name = "bigrom",
  103. .offset = SZ_128K,
  104. /*
  105. * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
  106. * 0x7b0000 bytes in the English-only ("enUS") version.
  107. */
  108. .size = 0x7b0000,
  109. .mask_flags = MTD_WRITEABLE,
  110. },
  111. };
  112. static struct physmap_flash_data palmz71_rom_data = {
  113. .width = 2,
  114. .set_vpp = omap1_set_vpp,
  115. .parts = palmz71_rom_partitions,
  116. .nr_parts = ARRAY_SIZE(palmz71_rom_partitions),
  117. };
  118. static struct resource palmz71_rom_resource = {
  119. .start = OMAP_CS0_PHYS,
  120. .end = OMAP_CS0_PHYS + SZ_8M - 1,
  121. .flags = IORESOURCE_MEM,
  122. };
  123. static struct platform_device palmz71_rom_device = {
  124. .name = "physmap-flash",
  125. .id = -1,
  126. .dev = {
  127. .platform_data = &palmz71_rom_data,
  128. },
  129. .num_resources = 1,
  130. .resource = &palmz71_rom_resource,
  131. };
  132. static struct platform_device palmz71_lcd_device = {
  133. .name = "lcd_palmz71",
  134. .id = -1,
  135. };
  136. static struct platform_device palmz71_spi_device = {
  137. .name = "spi_palmz71",
  138. .id = -1,
  139. };
  140. static struct omap_backlight_config palmz71_backlight_config = {
  141. .default_intensity = 0xa0,
  142. };
  143. static struct platform_device palmz71_backlight_device = {
  144. .name = "omap-bl",
  145. .id = -1,
  146. .dev = {
  147. .platform_data = &palmz71_backlight_config,
  148. },
  149. };
  150. static struct platform_device *devices[] __initdata = {
  151. &palmz71_rom_device,
  152. &palmz71_kp_device,
  153. &palmz71_lcd_device,
  154. &palmz71_spi_device,
  155. &palmz71_backlight_device,
  156. };
  157. static int
  158. palmz71_get_pendown_state(void)
  159. {
  160. return !gpio_get_value(PALMZ71_PENIRQ_GPIO);
  161. }
  162. static const struct ads7846_platform_data palmz71_ts_info = {
  163. .model = 7846,
  164. .vref_delay_usecs = 100, /* internal, no capacitor */
  165. .x_plate_ohms = 419,
  166. .y_plate_ohms = 486,
  167. .get_pendown_state = palmz71_get_pendown_state,
  168. };
  169. static struct spi_board_info __initdata palmz71_boardinfo[] = { {
  170. /* MicroWire (bus 2) CS0 has an ads7846e */
  171. .modalias = "ads7846",
  172. .platform_data = &palmz71_ts_info,
  173. .max_speed_hz = 120000 /* max sample rate at 3V */
  174. * 26 /* command + data + overhead */,
  175. .bus_num = 2,
  176. .chip_select = 0,
  177. } };
  178. static struct omap_usb_config palmz71_usb_config __initdata = {
  179. .register_dev = 1, /* Mini-B only receptacle */
  180. .hmc_mode = 0,
  181. .pins[0] = 2,
  182. };
  183. static const struct omap_lcd_config palmz71_lcd_config __initconst = {
  184. .ctrl_name = "internal",
  185. };
  186. static irqreturn_t
  187. palmz71_powercable(int irq, void *dev_id)
  188. {
  189. if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) {
  190. printk(KERN_INFO "PM: Power cable connected\n");
  191. irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
  192. IRQ_TYPE_EDGE_FALLING);
  193. } else {
  194. printk(KERN_INFO "PM: Power cable disconnected\n");
  195. irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
  196. IRQ_TYPE_EDGE_RISING);
  197. }
  198. return IRQ_HANDLED;
  199. }
  200. static void __init
  201. omap_mpu_wdt_mode(int mode)
  202. {
  203. if (mode)
  204. omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
  205. else {
  206. omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
  207. omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
  208. }
  209. }
  210. static void __init
  211. palmz71_gpio_setup(int early)
  212. {
  213. if (early) {
  214. /* Only set GPIO1 so we have a working serial */
  215. gpio_direction_output(1, 1);
  216. } else {
  217. /* Set MMC/SD host WP pin as input */
  218. if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) {
  219. printk(KERN_ERR "Could not reserve WP GPIO!\n");
  220. return;
  221. }
  222. gpio_direction_input(PALMZ71_MMC_WP_GPIO);
  223. /* Monitor the Power-cable-connected signal */
  224. if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) {
  225. printk(KERN_ERR
  226. "Could not reserve cable signal GPIO!\n");
  227. return;
  228. }
  229. gpio_direction_input(PALMZ71_USBDETECT_GPIO);
  230. if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
  231. palmz71_powercable, 0, "palmz71-cable", NULL))
  232. printk(KERN_ERR
  233. "IRQ request for power cable failed!\n");
  234. palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), NULL);
  235. }
  236. }
  237. static void __init
  238. omap_palmz71_init(void)
  239. {
  240. /* mux pins for uarts */
  241. omap_cfg_reg(UART1_TX);
  242. omap_cfg_reg(UART1_RTS);
  243. omap_cfg_reg(UART2_TX);
  244. omap_cfg_reg(UART2_RTS);
  245. omap_cfg_reg(UART3_TX);
  246. omap_cfg_reg(UART3_RX);
  247. palmz71_gpio_setup(1);
  248. omap_mpu_wdt_mode(0);
  249. platform_add_devices(devices, ARRAY_SIZE(devices));
  250. palmz71_boardinfo[0].irq = gpio_to_irq(PALMZ71_PENIRQ_GPIO);
  251. spi_register_board_info(palmz71_boardinfo,
  252. ARRAY_SIZE(palmz71_boardinfo));
  253. omap1_usb_init(&palmz71_usb_config);
  254. omap_serial_init();
  255. omap_register_i2c_bus(1, 100, NULL, 0);
  256. palmz71_gpio_setup(0);
  257. omapfb_set_lcd_config(&palmz71_lcd_config);
  258. }
  259. MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
  260. .atag_offset = 0x100,
  261. .map_io = omap15xx_map_io,
  262. .init_early = omap1_init_early,
  263. .init_irq = omap1_init_irq,
  264. .handle_irq = omap1_handle_irq,
  265. .init_machine = omap_palmz71_init,
  266. .init_late = omap1_init_late,
  267. .init_time = omap1_timer_init,
  268. .restart = omap1_restart,
  269. MACHINE_END