board-palmz71.c 7.9 KB

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