board-palmz71.c 7.7 KB

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