Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap1/board-palmtt.c |
| 3 | * |
| 4 | * Modified from board-palmtt2.c |
| 5 | * |
| 6 | * Modified and amended for Palm Tungsten|T |
| 7 | * by Marek Vasut <marek.vasut@gmail.com> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/delay.h> |
Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 15 | #include <linux/gpio.h> |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 16 | #include <linux/kernel.h> |
| 17 | #include <linux/init.h> |
| 18 | #include <linux/platform_device.h> |
| 19 | #include <linux/notifier.h> |
| 20 | #include <linux/clk.h> |
| 21 | #include <linux/input.h> |
| 22 | #include <linux/interrupt.h> |
| 23 | #include <linux/mtd/mtd.h> |
| 24 | #include <linux/mtd/partitions.h> |
Ladislav Michl | 561b036 | 2010-02-15 10:03:32 -0800 | [diff] [blame] | 25 | #include <linux/mtd/physmap.h> |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 26 | #include <linux/leds.h> |
Tomi Valkeinen | ddba6c7 | 2011-09-20 15:23:13 +0300 | [diff] [blame] | 27 | #include <linux/omapfb.h> |
Tony Lindgren | 2e3ee9f | 2012-02-24 10:34:34 -0800 | [diff] [blame] | 28 | #include <linux/spi/spi.h> |
| 29 | #include <linux/spi/ads7846.h> |
Igor Grinberg | cc01272 | 2012-08-29 02:18:54 +0300 | [diff] [blame] | 30 | #include <linux/platform_data/omap1_bl.h> |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 31 | |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 32 | #include <asm/mach-types.h> |
| 33 | #include <asm/mach/arch.h> |
| 34 | #include <asm/mach/map.h> |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 35 | |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 36 | #include <plat/led.h> |
Tony Lindgren | 578fad4 | 2012-09-20 11:41:37 -0700 | [diff] [blame] | 37 | #include <mach/flash.h> |
Tony Lindgren | 70c494c | 2012-09-19 10:46:56 -0700 | [diff] [blame] | 38 | #include <mach/mux.h> |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 39 | #include <plat/dma.h> |
| 40 | #include <plat/tc.h> |
Tony Lindgren | 2f7cd57 | 2012-09-20 11:41:59 -0700 | [diff] [blame] | 41 | #include <mach/irda.h> |
Arnd Bergmann | 2203747 | 2012-08-24 15:21:06 +0200 | [diff] [blame] | 42 | #include <linux/platform_data/keypad-omap.h> |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 43 | |
Tony Lindgren | 2e3ee9f | 2012-02-24 10:34:34 -0800 | [diff] [blame] | 44 | #include <mach/hardware.h> |
Tony Lindgren | b924b20 | 2012-06-04 00:56:15 -0700 | [diff] [blame] | 45 | #include <mach/usb.h> |
Tony Lindgren | 2e3ee9f | 2012-02-24 10:34:34 -0800 | [diff] [blame] | 46 | |
| 47 | #include "common.h" |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 48 | |
Tony Lindgren | b283081 | 2009-03-23 18:07:35 -0700 | [diff] [blame] | 49 | #define PALMTT_USBDETECT_GPIO 0 |
| 50 | #define PALMTT_CABLE_GPIO 1 |
| 51 | #define PALMTT_LED_GPIO 3 |
| 52 | #define PALMTT_PENIRQ_GPIO 6 |
| 53 | #define PALMTT_MMC_WP_GPIO 8 |
| 54 | #define PALMTT_HDQ_GPIO 11 |
| 55 | |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 56 | static const unsigned int palmtt_keymap[] = { |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 57 | KEY(0, 0, KEY_ESC), |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 58 | KEY(1, 0, KEY_SPACE), |
| 59 | KEY(2, 0, KEY_LEFTCTRL), |
| 60 | KEY(3, 0, KEY_TAB), |
| 61 | KEY(4, 0, KEY_ENTER), |
| 62 | KEY(0, 1, KEY_LEFT), |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 63 | KEY(1, 1, KEY_DOWN), |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 64 | KEY(2, 1, KEY_UP), |
| 65 | KEY(3, 1, KEY_RIGHT), |
| 66 | KEY(0, 2, KEY_SLEEP), |
| 67 | KEY(4, 2, KEY_Y), |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | static struct mtd_partition palmtt_partitions[] = { |
| 71 | { |
| 72 | .name = "write8k", |
| 73 | .offset = 0, |
| 74 | .size = SZ_8K, |
| 75 | .mask_flags = 0, |
| 76 | }, |
| 77 | { |
| 78 | .name = "PalmOS-BootLoader(ro)", |
| 79 | .offset = SZ_8K, |
| 80 | .size = 7 * SZ_8K, |
| 81 | .mask_flags = MTD_WRITEABLE, |
| 82 | }, |
| 83 | { |
| 84 | .name = "u-boot", |
| 85 | .offset = MTDPART_OFS_APPEND, |
| 86 | .size = 8 * SZ_8K, |
| 87 | .mask_flags = 0, |
| 88 | }, |
| 89 | { |
| 90 | .name = "PalmOS-FS(ro)", |
| 91 | .offset = MTDPART_OFS_APPEND, |
| 92 | .size = 7 * SZ_1M + 4 * SZ_64K - 16 * SZ_8K, |
| 93 | .mask_flags = MTD_WRITEABLE, |
| 94 | }, |
| 95 | { |
| 96 | .name = "u-boot(rez)", |
| 97 | .offset = MTDPART_OFS_APPEND, |
| 98 | .size = SZ_128K, |
| 99 | .mask_flags = 0 |
| 100 | }, |
| 101 | { |
| 102 | .name = "empty", |
| 103 | .offset = MTDPART_OFS_APPEND, |
| 104 | .size = MTDPART_SIZ_FULL, |
| 105 | .mask_flags = 0 |
| 106 | } |
| 107 | }; |
| 108 | |
Ladislav Michl | 561b036 | 2010-02-15 10:03:32 -0800 | [diff] [blame] | 109 | static struct physmap_flash_data palmtt_flash_data = { |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 110 | .width = 2, |
Ladislav Michl | 561b036 | 2010-02-15 10:03:32 -0800 | [diff] [blame] | 111 | .set_vpp = omap1_set_vpp, |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 112 | .parts = palmtt_partitions, |
| 113 | .nr_parts = ARRAY_SIZE(palmtt_partitions), |
| 114 | }; |
| 115 | |
| 116 | static struct resource palmtt_flash_resource = { |
| 117 | .start = OMAP_CS0_PHYS, |
| 118 | .end = OMAP_CS0_PHYS + SZ_8M - 1, |
| 119 | .flags = IORESOURCE_MEM, |
| 120 | }; |
| 121 | |
| 122 | static struct platform_device palmtt_flash_device = { |
Ladislav Michl | 561b036 | 2010-02-15 10:03:32 -0800 | [diff] [blame] | 123 | .name = "physmap-flash", |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 124 | .id = 0, |
| 125 | .dev = { |
| 126 | .platform_data = &palmtt_flash_data, |
| 127 | }, |
| 128 | .num_resources = 1, |
| 129 | .resource = &palmtt_flash_resource, |
| 130 | }; |
| 131 | |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 132 | static struct resource palmtt_kp_resources[] = { |
| 133 | [0] = { |
| 134 | .start = INT_KEYBOARD, |
| 135 | .end = INT_KEYBOARD, |
| 136 | .flags = IORESOURCE_IRQ, |
| 137 | }, |
| 138 | }; |
| 139 | |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 140 | static const struct matrix_keymap_data palmtt_keymap_data = { |
| 141 | .keymap = palmtt_keymap, |
| 142 | .keymap_size = ARRAY_SIZE(palmtt_keymap), |
| 143 | }; |
| 144 | |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 145 | static struct omap_kp_platform_data palmtt_kp_data = { |
| 146 | .rows = 6, |
| 147 | .cols = 3, |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 148 | .keymap_data = &palmtt_keymap_data, |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 149 | }; |
| 150 | |
| 151 | static struct platform_device palmtt_kp_device = { |
| 152 | .name = "omap-keypad", |
| 153 | .id = -1, |
| 154 | .dev = { |
| 155 | .platform_data = &palmtt_kp_data, |
| 156 | }, |
| 157 | .num_resources = ARRAY_SIZE(palmtt_kp_resources), |
| 158 | .resource = palmtt_kp_resources, |
| 159 | }; |
| 160 | |
| 161 | static struct platform_device palmtt_lcd_device = { |
| 162 | .name = "lcd_palmtt", |
| 163 | .id = -1, |
| 164 | }; |
| 165 | static struct omap_irda_config palmtt_irda_config = { |
| 166 | .transceiver_cap = IR_SIRMODE, |
| 167 | .rx_channel = OMAP_DMA_UART3_RX, |
| 168 | .tx_channel = OMAP_DMA_UART3_TX, |
| 169 | .dest_start = UART3_THR, |
| 170 | .src_start = UART3_RHR, |
| 171 | .tx_trigger = 0, |
| 172 | .rx_trigger = 0, |
| 173 | }; |
| 174 | |
| 175 | static struct resource palmtt_irda_resources[] = { |
| 176 | [0] = { |
| 177 | .start = INT_UART3, |
| 178 | .end = INT_UART3, |
| 179 | .flags = IORESOURCE_IRQ, |
| 180 | }, |
| 181 | }; |
| 182 | |
| 183 | static struct platform_device palmtt_irda_device = { |
| 184 | .name = "omapirda", |
| 185 | .id = -1, |
| 186 | .dev = { |
| 187 | .platform_data = &palmtt_irda_config, |
| 188 | }, |
| 189 | .num_resources = ARRAY_SIZE(palmtt_irda_resources), |
| 190 | .resource = palmtt_irda_resources, |
| 191 | }; |
| 192 | |
| 193 | static struct platform_device palmtt_spi_device = { |
| 194 | .name = "spi_palmtt", |
| 195 | .id = -1, |
| 196 | }; |
| 197 | |
| 198 | static struct omap_backlight_config palmtt_backlight_config = { |
| 199 | .default_intensity = 0xa0, |
| 200 | }; |
| 201 | |
| 202 | static struct platform_device palmtt_backlight_device = { |
| 203 | .name = "omap-bl", |
| 204 | .id = -1, |
| 205 | .dev = { |
| 206 | .platform_data= &palmtt_backlight_config, |
| 207 | }, |
| 208 | }; |
| 209 | |
| 210 | static struct omap_led_config palmtt_led_config[] = { |
| 211 | { |
| 212 | .cdev = { |
| 213 | .name = "palmtt:led0", |
| 214 | }, |
| 215 | .gpio = PALMTT_LED_GPIO, |
| 216 | }, |
| 217 | }; |
| 218 | |
| 219 | static struct omap_led_platform_data palmtt_led_data = { |
| 220 | .nr_leds = ARRAY_SIZE(palmtt_led_config), |
| 221 | .leds = palmtt_led_config, |
| 222 | }; |
| 223 | |
| 224 | static struct platform_device palmtt_led_device = { |
| 225 | .name = "omap-led", |
| 226 | .id = -1, |
| 227 | .dev = { |
| 228 | .platform_data = &palmtt_led_data, |
| 229 | }, |
| 230 | }; |
| 231 | |
| 232 | static struct platform_device *palmtt_devices[] __initdata = { |
| 233 | &palmtt_flash_device, |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 234 | &palmtt_kp_device, |
| 235 | &palmtt_lcd_device, |
| 236 | &palmtt_irda_device, |
| 237 | &palmtt_spi_device, |
| 238 | &palmtt_backlight_device, |
| 239 | &palmtt_led_device, |
| 240 | }; |
| 241 | |
| 242 | static int palmtt_get_pendown_state(void) |
| 243 | { |
David Brownell | 0b84b5c | 2008-12-10 17:35:25 -0800 | [diff] [blame] | 244 | return !gpio_get_value(6); |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | static const struct ads7846_platform_data palmtt_ts_info = { |
| 248 | .model = 7846, |
| 249 | .vref_delay_usecs = 100, /* internal, no capacitor */ |
| 250 | .x_plate_ohms = 419, |
| 251 | .y_plate_ohms = 486, |
| 252 | .get_pendown_state = palmtt_get_pendown_state, |
| 253 | }; |
| 254 | |
| 255 | static struct spi_board_info __initdata palmtt_boardinfo[] = { |
| 256 | { |
| 257 | /* MicroWire (bus 2) CS0 has an ads7846e */ |
| 258 | .modalias = "ads7846", |
| 259 | .platform_data = &palmtt_ts_info, |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 260 | .max_speed_hz = 120000 /* max sample rate at 3V */ |
| 261 | * 26 /* command + data + overhead */, |
| 262 | .bus_num = 2, |
| 263 | .chip_select = 0, |
| 264 | } |
| 265 | }; |
| 266 | |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 267 | static struct omap_usb_config palmtt_usb_config __initdata = { |
| 268 | .register_dev = 1, |
| 269 | .hmc_mode = 0, |
| 270 | .pins[0] = 2, |
| 271 | }; |
| 272 | |
| 273 | static struct omap_lcd_config palmtt_lcd_config __initdata = { |
| 274 | .ctrl_name = "internal", |
| 275 | }; |
| 276 | |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 277 | static void __init omap_mpu_wdt_mode(int mode) { |
| 278 | if (mode) |
| 279 | omap_writew(0x8000, OMAP_WDT_TIMER_MODE); |
| 280 | else { |
| 281 | omap_writew(0x00f5, OMAP_WDT_TIMER_MODE); |
| 282 | omap_writew(0x00a0, OMAP_WDT_TIMER_MODE); |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | static void __init omap_palmtt_init(void) |
| 287 | { |
Janusz Krzysztofik | c33da3a | 2009-10-22 14:47:42 -0700 | [diff] [blame] | 288 | /* mux pins for uarts */ |
| 289 | omap_cfg_reg(UART1_TX); |
| 290 | omap_cfg_reg(UART1_RTS); |
| 291 | omap_cfg_reg(UART2_TX); |
| 292 | omap_cfg_reg(UART2_RTS); |
| 293 | omap_cfg_reg(UART3_TX); |
| 294 | omap_cfg_reg(UART3_RX); |
| 295 | |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 296 | omap_mpu_wdt_mode(0); |
| 297 | |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 298 | platform_add_devices(palmtt_devices, ARRAY_SIZE(palmtt_devices)); |
| 299 | |
Tarun Kanti DebBarma | 46a0a54 | 2012-03-29 08:41:01 -0700 | [diff] [blame] | 300 | palmtt_boardinfo[0].irq = gpio_to_irq(6); |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 301 | spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo)); |
| 302 | omap_serial_init(); |
Tony Lindgren | dd0cdd8 | 2010-07-05 16:31:30 +0300 | [diff] [blame] | 303 | omap1_usb_init(&palmtt_usb_config); |
Jarkko Nikula | 1ed16a8 | 2007-11-07 06:54:32 +0200 | [diff] [blame] | 304 | omap_register_i2c_bus(1, 100, NULL, 0); |
Tomi Valkeinen | ddba6c7 | 2011-09-20 15:23:13 +0300 | [diff] [blame] | 305 | |
| 306 | omapfb_set_lcd_config(&palmtt_lcd_config); |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 307 | } |
| 308 | |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 309 | MACHINE_START(OMAP_PALMTT, "OMAP1510 based Palm Tungsten|T") |
Nicolas Pitre | 246e389 | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 310 | .atag_offset = 0x100, |
Tony Lindgren | 7b88e62 | 2011-10-05 15:14:02 -0700 | [diff] [blame] | 311 | .map_io = omap15xx_map_io, |
| 312 | .init_early = omap1_init_early, |
Russell King | 71ee7da | 2010-05-23 10:18:16 +0100 | [diff] [blame] | 313 | .reserve = omap_reserve, |
Tony Lindgren | 7b88e62 | 2011-10-05 15:14:02 -0700 | [diff] [blame] | 314 | .init_irq = omap1_init_irq, |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 315 | .init_machine = omap_palmtt_init, |
Shawn Guo | 82c3bd0 | 2012-04-26 13:49:29 +0800 | [diff] [blame] | 316 | .init_late = omap1_init_late, |
Tony Lindgren | e74984e | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 317 | .timer = &omap1_timer, |
Russell King | baa9588 | 2011-11-05 17:06:28 +0000 | [diff] [blame] | 318 | .restart = omap1_restart, |
Marek Vasut | dc563b4 | 2006-12-06 17:14:07 -0800 | [diff] [blame] | 319 | MACHINE_END |