board-palmz71.c 9.2 KB

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