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