board-palmz71.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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 <mach/hardware.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include <plat/flash.h>
  34. #include <plat/mux.h>
  35. #include <plat/usb.h>
  36. #include <plat/dma.h>
  37. #include <plat/tc.h>
  38. #include <plat/board.h>
  39. #include <plat/irda.h>
  40. #include <plat/keypad.h>
  41. #include <plat/common.h>
  42. #include <linux/spi/spi.h>
  43. #include <linux/spi/ads7846.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 omap_irda_config palmz71_irda_config = {
  137. .transceiver_cap = IR_SIRMODE,
  138. .rx_channel = OMAP_DMA_UART3_RX,
  139. .tx_channel = OMAP_DMA_UART3_TX,
  140. .dest_start = UART3_THR,
  141. .src_start = UART3_RHR,
  142. .tx_trigger = 0,
  143. .rx_trigger = 0,
  144. };
  145. static struct resource palmz71_irda_resources[] = {
  146. [0] = {
  147. .start = INT_UART3,
  148. .end = INT_UART3,
  149. .flags = IORESOURCE_IRQ,
  150. },
  151. };
  152. static struct platform_device palmz71_irda_device = {
  153. .name = "omapirda",
  154. .id = -1,
  155. .dev = {
  156. .platform_data = &palmz71_irda_config,
  157. },
  158. .num_resources = ARRAY_SIZE(palmz71_irda_resources),
  159. .resource = palmz71_irda_resources,
  160. };
  161. static struct platform_device palmz71_spi_device = {
  162. .name = "spi_palmz71",
  163. .id = -1,
  164. };
  165. static struct omap_backlight_config palmz71_backlight_config = {
  166. .default_intensity = 0xa0,
  167. };
  168. static struct platform_device palmz71_backlight_device = {
  169. .name = "omap-bl",
  170. .id = -1,
  171. .dev = {
  172. .platform_data = &palmz71_backlight_config,
  173. },
  174. };
  175. static struct platform_device *devices[] __initdata = {
  176. &palmz71_rom_device,
  177. &palmz71_kp_device,
  178. &palmz71_lcd_device,
  179. &palmz71_irda_device,
  180. &palmz71_spi_device,
  181. &palmz71_backlight_device,
  182. };
  183. static int
  184. palmz71_get_pendown_state(void)
  185. {
  186. return !gpio_get_value(PALMZ71_PENIRQ_GPIO);
  187. }
  188. static const struct ads7846_platform_data palmz71_ts_info = {
  189. .model = 7846,
  190. .vref_delay_usecs = 100, /* internal, no capacitor */
  191. .x_plate_ohms = 419,
  192. .y_plate_ohms = 486,
  193. .get_pendown_state = palmz71_get_pendown_state,
  194. };
  195. static struct spi_board_info __initdata palmz71_boardinfo[] = { {
  196. /* MicroWire (bus 2) CS0 has an ads7846e */
  197. .modalias = "ads7846",
  198. .platform_data = &palmz71_ts_info,
  199. .irq = OMAP_GPIO_IRQ(PALMZ71_PENIRQ_GPIO),
  200. .max_speed_hz = 120000 /* max sample rate at 3V */
  201. * 26 /* command + data + overhead */,
  202. .bus_num = 2,
  203. .chip_select = 0,
  204. } };
  205. static struct omap_usb_config palmz71_usb_config __initdata = {
  206. .register_dev = 1, /* Mini-B only receptacle */
  207. .hmc_mode = 0,
  208. .pins[0] = 2,
  209. };
  210. static struct omap_lcd_config palmz71_lcd_config __initdata = {
  211. .ctrl_name = "internal",
  212. };
  213. static struct omap_board_config_kernel palmz71_config[] __initdata = {
  214. {OMAP_TAG_LCD, &palmz71_lcd_config},
  215. };
  216. static irqreturn_t
  217. palmz71_powercable(int irq, void *dev_id)
  218. {
  219. if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) {
  220. printk(KERN_INFO "PM: Power cable connected\n");
  221. irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
  222. IRQ_TYPE_EDGE_FALLING);
  223. } else {
  224. printk(KERN_INFO "PM: Power cable disconnected\n");
  225. irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
  226. IRQ_TYPE_EDGE_RISING);
  227. }
  228. return IRQ_HANDLED;
  229. }
  230. static void __init
  231. omap_mpu_wdt_mode(int mode)
  232. {
  233. if (mode)
  234. omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
  235. else {
  236. omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
  237. omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
  238. }
  239. }
  240. static void __init
  241. palmz71_gpio_setup(int early)
  242. {
  243. if (early) {
  244. /* Only set GPIO1 so we have a working serial */
  245. gpio_direction_output(1, 1);
  246. } else {
  247. /* Set MMC/SD host WP pin as input */
  248. if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) {
  249. printk(KERN_ERR "Could not reserve WP GPIO!\n");
  250. return;
  251. }
  252. gpio_direction_input(PALMZ71_MMC_WP_GPIO);
  253. /* Monitor the Power-cable-connected signal */
  254. if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) {
  255. printk(KERN_ERR
  256. "Could not reserve cable signal GPIO!\n");
  257. return;
  258. }
  259. gpio_direction_input(PALMZ71_USBDETECT_GPIO);
  260. if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
  261. palmz71_powercable, IRQF_SAMPLE_RANDOM,
  262. "palmz71-cable", 0))
  263. printk(KERN_ERR
  264. "IRQ request for power cable failed!\n");
  265. palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), 0);
  266. }
  267. }
  268. static void __init
  269. omap_palmz71_init(void)
  270. {
  271. /* mux pins for uarts */
  272. omap_cfg_reg(UART1_TX);
  273. omap_cfg_reg(UART1_RTS);
  274. omap_cfg_reg(UART2_TX);
  275. omap_cfg_reg(UART2_RTS);
  276. omap_cfg_reg(UART3_TX);
  277. omap_cfg_reg(UART3_RX);
  278. palmz71_gpio_setup(1);
  279. omap_mpu_wdt_mode(0);
  280. omap_board_config = palmz71_config;
  281. omap_board_config_size = ARRAY_SIZE(palmz71_config);
  282. platform_add_devices(devices, ARRAY_SIZE(devices));
  283. spi_register_board_info(palmz71_boardinfo,
  284. ARRAY_SIZE(palmz71_boardinfo));
  285. omap1_usb_init(&palmz71_usb_config);
  286. omap_serial_init();
  287. omap_register_i2c_bus(1, 100, NULL, 0);
  288. palmz71_gpio_setup(0);
  289. }
  290. MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
  291. .atag_offset = 0x100,
  292. .map_io = omap15xx_map_io,
  293. .init_early = omap1_init_early,
  294. .reserve = omap_reserve,
  295. .init_irq = omap1_init_irq,
  296. .init_machine = omap_palmz71_init,
  297. .timer = &omap1_timer,
  298. MACHINE_END