board-palmz71.c 7.8 KB

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