board-palmz71.c 7.9 KB

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