Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 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 | |
| 17 | #include <linux/delay.h> |
Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 18 | #include <linux/gpio.h> |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/platform_device.h> |
| 22 | #include <linux/notifier.h> |
| 23 | #include <linux/clk.h> |
| 24 | #include <linux/irq.h> |
| 25 | #include <linux/input.h> |
| 26 | #include <linux/interrupt.h> |
| 27 | #include <linux/mtd/mtd.h> |
| 28 | #include <linux/mtd/partitions.h> |
Ladislav Michl | 561b036 | 2010-02-15 10:03:32 -0800 | [diff] [blame] | 29 | #include <linux/mtd/physmap.h> |
Tomi Valkeinen | ddba6c7 | 2011-09-20 15:23:13 +0300 | [diff] [blame] | 30 | #include <linux/omapfb.h> |
Tony Lindgren | 2e3ee9f | 2012-02-24 10:34:34 -0800 | [diff] [blame] | 31 | #include <linux/spi/spi.h> |
| 32 | #include <linux/spi/ads7846.h> |
Igor Grinberg | cc01272 | 2012-08-29 02:18:54 +0300 | [diff] [blame] | 33 | #include <linux/platform_data/omap1_bl.h> |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 34 | |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 35 | #include <asm/mach-types.h> |
| 36 | #include <asm/mach/arch.h> |
| 37 | #include <asm/mach/map.h> |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 38 | |
Ladislav Michl | 561b036 | 2010-02-15 10:03:32 -0800 | [diff] [blame] | 39 | #include <plat/flash.h> |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 40 | #include <plat/mux.h> |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 41 | #include <plat/dma.h> |
| 42 | #include <plat/tc.h> |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 43 | #include <plat/irda.h> |
Arnd Bergmann | 2203747 | 2012-08-24 15:21:06 +0200 | [diff] [blame] | 44 | #include <linux/platform_data/keypad-omap.h> |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 45 | |
Tony Lindgren | 2e3ee9f | 2012-02-24 10:34:34 -0800 | [diff] [blame] | 46 | #include <mach/hardware.h> |
Tony Lindgren | b924b20 | 2012-06-04 00:56:15 -0700 | [diff] [blame] | 47 | #include <mach/usb.h> |
Tony Lindgren | 2e3ee9f | 2012-02-24 10:34:34 -0800 | [diff] [blame] | 48 | |
| 49 | #include "common.h" |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 50 | |
Tony Lindgren | b283081 | 2009-03-23 18:07:35 -0700 | [diff] [blame] | 51 | #define PALMZ71_USBDETECT_GPIO 0 |
| 52 | #define PALMZ71_PENIRQ_GPIO 6 |
| 53 | #define PALMZ71_MMC_WP_GPIO 8 |
| 54 | #define PALMZ71_HDQ_GPIO 11 |
| 55 | |
| 56 | #define PALMZ71_HOTSYNC_GPIO OMAP_MPUIO(1) |
| 57 | #define PALMZ71_CABLE_GPIO OMAP_MPUIO(2) |
| 58 | #define PALMZ71_SLIDER_GPIO OMAP_MPUIO(3) |
| 59 | #define PALMZ71_MMC_IN_GPIO OMAP_MPUIO(4) |
| 60 | |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 61 | static const unsigned int palmz71_keymap[] = { |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 62 | KEY(0, 0, KEY_F1), |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 63 | KEY(1, 0, KEY_F2), |
| 64 | KEY(2, 0, KEY_F3), |
| 65 | KEY(3, 0, KEY_F4), |
| 66 | KEY(4, 0, KEY_POWER), |
| 67 | KEY(0, 1, KEY_LEFT), |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 68 | KEY(1, 1, KEY_DOWN), |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 69 | KEY(2, 1, KEY_UP), |
| 70 | KEY(3, 1, KEY_RIGHT), |
| 71 | KEY(4, 1, KEY_ENTER), |
| 72 | KEY(0, 2, KEY_CAMERA), |
| 73 | }; |
| 74 | |
| 75 | static const struct matrix_keymap_data palmz71_keymap_data = { |
| 76 | .keymap = palmz71_keymap, |
| 77 | .keymap_size = ARRAY_SIZE(palmz71_keymap), |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | static struct omap_kp_platform_data palmz71_kp_data = { |
| 81 | .rows = 8, |
| 82 | .cols = 8, |
Janusz Krzysztofik | da1f026 | 2010-12-20 21:09:22 +0000 | [diff] [blame] | 83 | .keymap_data = &palmz71_keymap_data, |
| 84 | .rep = true, |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 85 | .delay = 80, |
| 86 | }; |
| 87 | |
| 88 | static struct resource palmz71_kp_resources[] = { |
| 89 | [0] = { |
| 90 | .start = INT_KEYBOARD, |
| 91 | .end = INT_KEYBOARD, |
| 92 | .flags = IORESOURCE_IRQ, |
| 93 | }, |
| 94 | }; |
| 95 | |
| 96 | static struct platform_device palmz71_kp_device = { |
| 97 | .name = "omap-keypad", |
| 98 | .id = -1, |
| 99 | .dev = { |
| 100 | .platform_data = &palmz71_kp_data, |
| 101 | }, |
| 102 | .num_resources = ARRAY_SIZE(palmz71_kp_resources), |
| 103 | .resource = palmz71_kp_resources, |
| 104 | }; |
| 105 | |
| 106 | static struct mtd_partition palmz71_rom_partitions[] = { |
| 107 | /* PalmOS "Small ROM", contains the bootloader and the debugger */ |
| 108 | { |
| 109 | .name = "smallrom", |
| 110 | .offset = 0, |
| 111 | .size = 0xa000, |
| 112 | .mask_flags = MTD_WRITEABLE, |
| 113 | }, |
| 114 | /* PalmOS "Big ROM", a filesystem with all the OS code and data */ |
| 115 | { |
| 116 | .name = "bigrom", |
| 117 | .offset = SZ_128K, |
| 118 | /* |
| 119 | * 0x5f0000 bytes big in the multi-language ("EFIGS") version, |
| 120 | * 0x7b0000 bytes in the English-only ("enUS") version. |
| 121 | */ |
| 122 | .size = 0x7b0000, |
| 123 | .mask_flags = MTD_WRITEABLE, |
| 124 | }, |
| 125 | }; |
| 126 | |
Ladislav Michl | 561b036 | 2010-02-15 10:03:32 -0800 | [diff] [blame] | 127 | static struct physmap_flash_data palmz71_rom_data = { |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 128 | .width = 2, |
Ladislav Michl | 561b036 | 2010-02-15 10:03:32 -0800 | [diff] [blame] | 129 | .set_vpp = omap1_set_vpp, |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 130 | .parts = palmz71_rom_partitions, |
| 131 | .nr_parts = ARRAY_SIZE(palmz71_rom_partitions), |
| 132 | }; |
| 133 | |
| 134 | static struct resource palmz71_rom_resource = { |
| 135 | .start = OMAP_CS0_PHYS, |
| 136 | .end = OMAP_CS0_PHYS + SZ_8M - 1, |
| 137 | .flags = IORESOURCE_MEM, |
| 138 | }; |
| 139 | |
| 140 | static struct platform_device palmz71_rom_device = { |
Ladislav Michl | 561b036 | 2010-02-15 10:03:32 -0800 | [diff] [blame] | 141 | .name = "physmap-flash", |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 142 | .id = -1, |
| 143 | .dev = { |
| 144 | .platform_data = &palmz71_rom_data, |
| 145 | }, |
| 146 | .num_resources = 1, |
| 147 | .resource = &palmz71_rom_resource, |
| 148 | }; |
| 149 | |
| 150 | static struct platform_device palmz71_lcd_device = { |
| 151 | .name = "lcd_palmz71", |
| 152 | .id = -1, |
| 153 | }; |
| 154 | |
| 155 | static struct omap_irda_config palmz71_irda_config = { |
| 156 | .transceiver_cap = IR_SIRMODE, |
| 157 | .rx_channel = OMAP_DMA_UART3_RX, |
| 158 | .tx_channel = OMAP_DMA_UART3_TX, |
| 159 | .dest_start = UART3_THR, |
| 160 | .src_start = UART3_RHR, |
| 161 | .tx_trigger = 0, |
| 162 | .rx_trigger = 0, |
| 163 | }; |
| 164 | |
| 165 | static struct resource palmz71_irda_resources[] = { |
| 166 | [0] = { |
| 167 | .start = INT_UART3, |
| 168 | .end = INT_UART3, |
| 169 | .flags = IORESOURCE_IRQ, |
| 170 | }, |
| 171 | }; |
| 172 | |
| 173 | static struct platform_device palmz71_irda_device = { |
| 174 | .name = "omapirda", |
| 175 | .id = -1, |
| 176 | .dev = { |
| 177 | .platform_data = &palmz71_irda_config, |
| 178 | }, |
| 179 | .num_resources = ARRAY_SIZE(palmz71_irda_resources), |
| 180 | .resource = palmz71_irda_resources, |
| 181 | }; |
| 182 | |
| 183 | static struct platform_device palmz71_spi_device = { |
| 184 | .name = "spi_palmz71", |
| 185 | .id = -1, |
| 186 | }; |
| 187 | |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 188 | static struct omap_backlight_config palmz71_backlight_config = { |
| 189 | .default_intensity = 0xa0, |
| 190 | }; |
| 191 | |
| 192 | static struct platform_device palmz71_backlight_device = { |
| 193 | .name = "omap-bl", |
| 194 | .id = -1, |
| 195 | .dev = { |
| 196 | .platform_data = &palmz71_backlight_config, |
| 197 | }, |
| 198 | }; |
| 199 | |
| 200 | static struct platform_device *devices[] __initdata = { |
| 201 | &palmz71_rom_device, |
| 202 | &palmz71_kp_device, |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 203 | &palmz71_lcd_device, |
| 204 | &palmz71_irda_device, |
| 205 | &palmz71_spi_device, |
| 206 | &palmz71_backlight_device, |
| 207 | }; |
| 208 | |
| 209 | static int |
| 210 | palmz71_get_pendown_state(void) |
| 211 | { |
David Brownell | 0b84b5c | 2008-12-10 17:35:25 -0800 | [diff] [blame] | 212 | return !gpio_get_value(PALMZ71_PENIRQ_GPIO); |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | static const struct ads7846_platform_data palmz71_ts_info = { |
| 216 | .model = 7846, |
| 217 | .vref_delay_usecs = 100, /* internal, no capacitor */ |
| 218 | .x_plate_ohms = 419, |
| 219 | .y_plate_ohms = 486, |
| 220 | .get_pendown_state = palmz71_get_pendown_state, |
| 221 | }; |
| 222 | |
| 223 | static struct spi_board_info __initdata palmz71_boardinfo[] = { { |
| 224 | /* MicroWire (bus 2) CS0 has an ads7846e */ |
| 225 | .modalias = "ads7846", |
| 226 | .platform_data = &palmz71_ts_info, |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 227 | .max_speed_hz = 120000 /* max sample rate at 3V */ |
| 228 | * 26 /* command + data + overhead */, |
| 229 | .bus_num = 2, |
| 230 | .chip_select = 0, |
| 231 | } }; |
| 232 | |
| 233 | static struct omap_usb_config palmz71_usb_config __initdata = { |
| 234 | .register_dev = 1, /* Mini-B only receptacle */ |
| 235 | .hmc_mode = 0, |
| 236 | .pins[0] = 2, |
| 237 | }; |
| 238 | |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 239 | static struct omap_lcd_config palmz71_lcd_config __initdata = { |
| 240 | .ctrl_name = "internal", |
| 241 | }; |
| 242 | |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 243 | static irqreturn_t |
| 244 | palmz71_powercable(int irq, void *dev_id) |
| 245 | { |
David Brownell | 0b84b5c | 2008-12-10 17:35:25 -0800 | [diff] [blame] | 246 | if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) { |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 247 | printk(KERN_INFO "PM: Power cable connected\n"); |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 248 | irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO), |
| 249 | IRQ_TYPE_EDGE_FALLING); |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 250 | } else { |
| 251 | printk(KERN_INFO "PM: Power cable disconnected\n"); |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 252 | irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO), |
| 253 | IRQ_TYPE_EDGE_RISING); |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 254 | } |
| 255 | return IRQ_HANDLED; |
| 256 | } |
| 257 | |
| 258 | static void __init |
| 259 | omap_mpu_wdt_mode(int mode) |
| 260 | { |
| 261 | if (mode) |
| 262 | omap_writew(0x8000, OMAP_WDT_TIMER_MODE); |
| 263 | else { |
| 264 | omap_writew(0x00f5, OMAP_WDT_TIMER_MODE); |
| 265 | omap_writew(0x00a0, OMAP_WDT_TIMER_MODE); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | static void __init |
| 270 | palmz71_gpio_setup(int early) |
| 271 | { |
| 272 | if (early) { |
| 273 | /* Only set GPIO1 so we have a working serial */ |
David Brownell | e918edf | 2008-12-10 17:35:26 -0800 | [diff] [blame] | 274 | gpio_direction_output(1, 1); |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 275 | } else { |
| 276 | /* Set MMC/SD host WP pin as input */ |
Jarkko Nikula | f2d18fe | 2008-12-10 17:35:30 -0800 | [diff] [blame] | 277 | if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) { |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 278 | printk(KERN_ERR "Could not reserve WP GPIO!\n"); |
| 279 | return; |
| 280 | } |
David Brownell | 40e3925 | 2008-12-10 17:35:26 -0800 | [diff] [blame] | 281 | gpio_direction_input(PALMZ71_MMC_WP_GPIO); |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 282 | |
| 283 | /* Monitor the Power-cable-connected signal */ |
Jarkko Nikula | f2d18fe | 2008-12-10 17:35:30 -0800 | [diff] [blame] | 284 | if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) { |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 285 | printk(KERN_ERR |
| 286 | "Could not reserve cable signal GPIO!\n"); |
| 287 | return; |
| 288 | } |
David Brownell | 40e3925 | 2008-12-10 17:35:26 -0800 | [diff] [blame] | 289 | gpio_direction_input(PALMZ71_USBDETECT_GPIO); |
David Brownell | 15f74b0 | 2008-12-10 17:35:26 -0800 | [diff] [blame] | 290 | if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO), |
Theodore Ts'o | 9863fa6 | 2012-07-17 14:04:00 -0400 | [diff] [blame] | 291 | palmz71_powercable, 0, "palmz71-cable", NULL)) |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 292 | printk(KERN_ERR |
| 293 | "IRQ request for power cable failed!\n"); |
Paul Walmsley | a7022d6 | 2012-04-13 06:34:28 -0600 | [diff] [blame] | 294 | palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), NULL); |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 295 | } |
| 296 | } |
| 297 | |
| 298 | static void __init |
| 299 | omap_palmz71_init(void) |
| 300 | { |
Janusz Krzysztofik | c33da3a | 2009-10-22 14:47:42 -0700 | [diff] [blame] | 301 | /* mux pins for uarts */ |
| 302 | omap_cfg_reg(UART1_TX); |
| 303 | omap_cfg_reg(UART1_RTS); |
| 304 | omap_cfg_reg(UART2_TX); |
| 305 | omap_cfg_reg(UART2_RTS); |
| 306 | omap_cfg_reg(UART3_TX); |
| 307 | omap_cfg_reg(UART3_RX); |
| 308 | |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 309 | palmz71_gpio_setup(1); |
| 310 | omap_mpu_wdt_mode(0); |
| 311 | |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 312 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 313 | |
Tarun Kanti DebBarma | 46a0a54 | 2012-03-29 08:41:01 -0700 | [diff] [blame] | 314 | palmz71_boardinfo[0].irq = gpio_to_irq(PALMZ71_PENIRQ_GPIO); |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 315 | spi_register_board_info(palmz71_boardinfo, |
| 316 | ARRAY_SIZE(palmz71_boardinfo)); |
Tony Lindgren | dd0cdd8 | 2010-07-05 16:31:30 +0300 | [diff] [blame] | 317 | omap1_usb_init(&palmz71_usb_config); |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 318 | omap_serial_init(); |
Jarkko Nikula | 1ed16a8 | 2007-11-07 06:54:32 +0200 | [diff] [blame] | 319 | omap_register_i2c_bus(1, 100, NULL, 0); |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 320 | palmz71_gpio_setup(0); |
Tomi Valkeinen | ddba6c7 | 2011-09-20 15:23:13 +0300 | [diff] [blame] | 321 | |
| 322 | omapfb_set_lcd_config(&palmz71_lcd_config); |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 323 | } |
| 324 | |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 325 | MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71") |
Nicolas Pitre | 246e389 | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 326 | .atag_offset = 0x100, |
Tony Lindgren | 7b88e62 | 2011-10-05 15:14:02 -0700 | [diff] [blame] | 327 | .map_io = omap15xx_map_io, |
| 328 | .init_early = omap1_init_early, |
Russell King | 71ee7da | 2010-05-23 10:18:16 +0100 | [diff] [blame] | 329 | .reserve = omap_reserve, |
Tony Lindgren | 7b88e62 | 2011-10-05 15:14:02 -0700 | [diff] [blame] | 330 | .init_irq = omap1_init_irq, |
Russell King | 71ee7da | 2010-05-23 10:18:16 +0100 | [diff] [blame] | 331 | .init_machine = omap_palmz71_init, |
Shawn Guo | 82c3bd0 | 2012-04-26 13:49:29 +0800 | [diff] [blame] | 332 | .init_late = omap1_init_late, |
Tony Lindgren | e74984e | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 333 | .timer = &omap1_timer, |
Russell King | baa9588 | 2011-11-05 17:06:28 +0000 | [diff] [blame] | 334 | .restart = omap1_restart, |
Marek Vasut | ec70e8a | 2006-12-06 17:13:57 -0800 | [diff] [blame] | 335 | MACHINE_END |