board-palmz71.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-omap1/board-palmz71.c
  4. *
  5. * Modified from board-generic.c
  6. *
  7. * Support for the Palm Zire71 PDA.
  8. *
  9. * Original version : Laurent Gonzalez
  10. *
  11. * Modified for zire71 : Marek Vasut
  12. */
  13. #include <linux/delay.h>
  14. #include <linux/gpio.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/notifier.h>
  19. #include <linux/clk.h>
  20. #include <linux/irq.h>
  21. #include <linux/input.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/partitions.h>
  25. #include <linux/mtd/physmap.h>
  26. #include <linux/omapfb.h>
  27. #include <linux/spi/spi.h>
  28. #include <linux/spi/ads7846.h>
  29. #include <linux/platform_data/omap1_bl.h>
  30. #include <linux/platform_data/keypad-omap.h>
  31. #include <linux/omap-dma.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include "tc.h"
  36. #include "flash.h"
  37. #include "mux.h"
  38. #include "hardware.h"
  39. #include "usb.h"
  40. #include "common.h"
  41. #define PALMZ71_USBDETECT_GPIO 0
  42. #define PALMZ71_PENIRQ_GPIO 6
  43. #define PALMZ71_MMC_WP_GPIO 8
  44. #define PALMZ71_HDQ_GPIO 11
  45. #define PALMZ71_HOTSYNC_GPIO OMAP_MPUIO(1)
  46. #define PALMZ71_CABLE_GPIO OMAP_MPUIO(2)
  47. #define PALMZ71_SLIDER_GPIO OMAP_MPUIO(3)
  48. #define PALMZ71_MMC_IN_GPIO OMAP_MPUIO(4)
  49. static const unsigned int palmz71_keymap[] = {
  50. KEY(0, 0, KEY_F1),
  51. KEY(1, 0, KEY_F2),
  52. KEY(2, 0, KEY_F3),
  53. KEY(3, 0, KEY_F4),
  54. KEY(4, 0, KEY_POWER),
  55. KEY(0, 1, KEY_LEFT),
  56. KEY(1, 1, KEY_DOWN),
  57. KEY(2, 1, KEY_UP),
  58. KEY(3, 1, KEY_RIGHT),
  59. KEY(4, 1, KEY_ENTER),
  60. KEY(0, 2, KEY_CAMERA),
  61. };
  62. static const struct matrix_keymap_data palmz71_keymap_data = {
  63. .keymap = palmz71_keymap,
  64. .keymap_size = ARRAY_SIZE(palmz71_keymap),
  65. };
  66. static struct omap_kp_platform_data palmz71_kp_data = {
  67. .rows = 8,
  68. .cols = 8,
  69. .keymap_data = &palmz71_keymap_data,
  70. .rep = true,
  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 physmap_flash_data palmz71_rom_data = {
  110. .width = 2,
  111. .set_vpp = omap1_set_vpp,
  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 = "physmap-flash",
  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 platform_device palmz71_spi_device = {
  134. .name = "spi_palmz71",
  135. .id = -1,
  136. };
  137. static struct omap_backlight_config palmz71_backlight_config = {
  138. .default_intensity = 0xa0,
  139. };
  140. static struct platform_device palmz71_backlight_device = {
  141. .name = "omap-bl",
  142. .id = -1,
  143. .dev = {
  144. .platform_data = &palmz71_backlight_config,
  145. },
  146. };
  147. static struct platform_device *devices[] __initdata = {
  148. &palmz71_rom_device,
  149. &palmz71_kp_device,
  150. &palmz71_lcd_device,
  151. &palmz71_spi_device,
  152. &palmz71_backlight_device,
  153. };
  154. static int
  155. palmz71_get_pendown_state(void)
  156. {
  157. return !gpio_get_value(PALMZ71_PENIRQ_GPIO);
  158. }
  159. static const struct ads7846_platform_data palmz71_ts_info = {
  160. .model = 7846,
  161. .vref_delay_usecs = 100, /* internal, no capacitor */
  162. .x_plate_ohms = 419,
  163. .y_plate_ohms = 486,
  164. .get_pendown_state = palmz71_get_pendown_state,
  165. };
  166. static struct spi_board_info __initdata palmz71_boardinfo[] = { {
  167. /* MicroWire (bus 2) CS0 has an ads7846e */
  168. .modalias = "ads7846",
  169. .platform_data = &palmz71_ts_info,
  170. .max_speed_hz = 120000 /* max sample rate at 3V */
  171. * 26 /* command + data + overhead */,
  172. .bus_num = 2,
  173. .chip_select = 0,
  174. } };
  175. static struct omap_usb_config palmz71_usb_config __initdata = {
  176. .register_dev = 1, /* Mini-B only receptacle */
  177. .hmc_mode = 0,
  178. .pins[0] = 2,
  179. };
  180. static const struct omap_lcd_config palmz71_lcd_config __initconst = {
  181. .ctrl_name = "internal",
  182. };
  183. static irqreturn_t
  184. palmz71_powercable(int irq, void *dev_id)
  185. {
  186. if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) {
  187. printk(KERN_INFO "PM: Power cable connected\n");
  188. irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
  189. IRQ_TYPE_EDGE_FALLING);
  190. } else {
  191. printk(KERN_INFO "PM: Power cable disconnected\n");
  192. irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
  193. IRQ_TYPE_EDGE_RISING);
  194. }
  195. return IRQ_HANDLED;
  196. }
  197. static void __init
  198. omap_mpu_wdt_mode(int mode)
  199. {
  200. if (mode)
  201. omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
  202. else {
  203. omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
  204. omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
  205. }
  206. }
  207. static void __init
  208. palmz71_gpio_setup(int early)
  209. {
  210. if (early) {
  211. /* Only set GPIO1 so we have a working serial */
  212. gpio_direction_output(1, 1);
  213. } else {
  214. /* Set MMC/SD host WP pin as input */
  215. if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) {
  216. printk(KERN_ERR "Could not reserve WP GPIO!\n");
  217. return;
  218. }
  219. gpio_direction_input(PALMZ71_MMC_WP_GPIO);
  220. /* Monitor the Power-cable-connected signal */
  221. if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) {
  222. printk(KERN_ERR
  223. "Could not reserve cable signal GPIO!\n");
  224. return;
  225. }
  226. gpio_direction_input(PALMZ71_USBDETECT_GPIO);
  227. if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
  228. palmz71_powercable, 0, "palmz71-cable", NULL))
  229. printk(KERN_ERR
  230. "IRQ request for power cable failed!\n");
  231. palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), NULL);
  232. }
  233. }
  234. static void __init
  235. omap_palmz71_init(void)
  236. {
  237. /* mux pins for uarts */
  238. omap_cfg_reg(UART1_TX);
  239. omap_cfg_reg(UART1_RTS);
  240. omap_cfg_reg(UART2_TX);
  241. omap_cfg_reg(UART2_RTS);
  242. omap_cfg_reg(UART3_TX);
  243. omap_cfg_reg(UART3_RX);
  244. palmz71_gpio_setup(1);
  245. omap_mpu_wdt_mode(0);
  246. platform_add_devices(devices, ARRAY_SIZE(devices));
  247. palmz71_boardinfo[0].irq = gpio_to_irq(PALMZ71_PENIRQ_GPIO);
  248. spi_register_board_info(palmz71_boardinfo,
  249. ARRAY_SIZE(palmz71_boardinfo));
  250. omap1_usb_init(&palmz71_usb_config);
  251. omap_serial_init();
  252. omap_register_i2c_bus(1, 100, NULL, 0);
  253. palmz71_gpio_setup(0);
  254. omapfb_set_lcd_config(&palmz71_lcd_config);
  255. }
  256. MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
  257. .atag_offset = 0x100,
  258. .map_io = omap15xx_map_io,
  259. .init_early = omap1_init_early,
  260. .init_irq = omap1_init_irq,
  261. .handle_irq = omap1_handle_irq,
  262. .init_machine = omap_palmz71_init,
  263. .init_late = omap1_init_late,
  264. .init_time = omap1_timer_init,
  265. .restart = omap1_restart,
  266. MACHINE_END