board-palmz71.c 8.9 KB

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