board-palmz71.c 7.9 KB

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