Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Hardware definitions for Compaq iPAQ H3xxx Handheld Computers |
| 3 | * |
| 4 | * Copyright 2000,1 Compaq Computer Corporation. |
| 5 | * |
| 6 | * Use consistent with the GNU GPL is permitted, |
| 7 | * provided that this copyright notice is |
| 8 | * preserved in its entirety in all copies and derived works. |
| 9 | * |
| 10 | * COMPAQ COMPUTER CORPORATION MAKES NO WARRANTIES, EXPRESSED OR IMPLIED, |
| 11 | * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS |
| 12 | * FITNESS FOR ANY PARTICULAR PURPOSE. |
| 13 | * |
| 14 | * Author: Jamey Hicks. |
| 15 | * |
| 16 | * History: |
| 17 | * |
| 18 | * 2001-10-?? Andrew Christian Added support for iPAQ H3800 |
| 19 | * and abstracted EGPIO interface. |
| 20 | * |
| 21 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <linux/module.h> |
| 23 | #include <linux/init.h> |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/tty.h> |
| 26 | #include <linux/pm.h> |
| 27 | #include <linux/device.h> |
| 28 | #include <linux/mtd/mtd.h> |
| 29 | #include <linux/mtd/partitions.h> |
| 30 | #include <linux/serial_core.h> |
Russell King | 0831e3e | 2009-10-06 14:35:16 +0100 | [diff] [blame] | 31 | #include <linux/gpio.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | #include <asm/irq.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 34 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <asm/mach-types.h> |
| 36 | #include <asm/setup.h> |
| 37 | |
| 38 | #include <asm/mach/irq.h> |
| 39 | #include <asm/mach/arch.h> |
| 40 | #include <asm/mach/flash.h> |
| 41 | #include <asm/mach/irda.h> |
| 42 | #include <asm/mach/map.h> |
| 43 | #include <asm/mach/serial_sa1100.h> |
| 44 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 45 | #include <mach/h3600.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 46 | #include <mach/h3600_gpio.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 48 | #include "generic.h" |
| 49 | |
Dmitry Artamonow | 607b067 | 2009-03-15 19:14:27 +0100 | [diff] [blame] | 50 | void (*assign_h3600_egpio)(enum ipaq_egpio_type x, int level); |
| 51 | EXPORT_SYMBOL(assign_h3600_egpio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Russell King | 0831e3e | 2009-10-06 14:35:16 +0100 | [diff] [blame] | 53 | struct gpio_default_state { |
| 54 | int gpio; |
| 55 | int mode; |
| 56 | const char *name; |
| 57 | }; |
| 58 | |
| 59 | #define GPIO_MODE_IN -1 |
| 60 | #define GPIO_MODE_OUT0 0 |
| 61 | #define GPIO_MODE_OUT1 1 |
| 62 | |
| 63 | static void h3xxx_init_gpio(struct gpio_default_state *s, size_t n) |
| 64 | { |
| 65 | while (n--) { |
| 66 | const char *name = s->name; |
| 67 | int err; |
| 68 | |
| 69 | if (!name) |
| 70 | name = "[init]"; |
| 71 | err = gpio_request(s->gpio, name); |
| 72 | if (err) { |
| 73 | printk(KERN_ERR "gpio%u: unable to request: %d\n", |
| 74 | s->gpio, err); |
| 75 | continue; |
| 76 | } |
| 77 | if (s->mode >= 0) { |
| 78 | err = gpio_direction_output(s->gpio, s->mode); |
| 79 | } else { |
| 80 | err = gpio_direction_input(s->gpio); |
| 81 | } |
| 82 | if (err) { |
| 83 | printk(KERN_ERR "gpio%u: unable to set direction: %d\n", |
| 84 | s->gpio, err); |
| 85 | continue; |
| 86 | } |
| 87 | if (!s->name) |
| 88 | gpio_free(s->gpio); |
| 89 | s++; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 94 | /* |
| 95 | * H3xxx flash support |
| 96 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | static struct mtd_partition h3xxx_partitions[] = { |
| 98 | { |
| 99 | .name = "H3XXX boot firmware", |
| 100 | .size = 0x00040000, |
| 101 | .offset = 0, |
| 102 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 103 | }, { |
Dmitry Artamonow | f110b3f | 2009-03-15 19:09:50 +0100 | [diff] [blame] | 104 | .name = "H3XXX rootfs", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | .size = MTDPART_SIZ_FULL, |
| 106 | .offset = 0x00040000, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | } |
| 108 | }; |
| 109 | |
| 110 | static void h3xxx_set_vpp(int vpp) |
| 111 | { |
| 112 | assign_h3600_egpio(IPAQ_EGPIO_VPP_ON, vpp); |
| 113 | } |
| 114 | |
| 115 | static struct flash_platform_data h3xxx_flash_data = { |
| 116 | .map_name = "cfi_probe", |
| 117 | .set_vpp = h3xxx_set_vpp, |
| 118 | .parts = h3xxx_partitions, |
| 119 | .nr_parts = ARRAY_SIZE(h3xxx_partitions), |
| 120 | }; |
| 121 | |
| 122 | static struct resource h3xxx_flash_resource = { |
| 123 | .start = SA1100_CS0_PHYS, |
| 124 | .end = SA1100_CS0_PHYS + SZ_32M - 1, |
| 125 | .flags = IORESOURCE_MEM, |
| 126 | }; |
| 127 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
| 129 | /* |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 130 | * H3xxx uart support |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | */ |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 132 | static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | { |
| 134 | if (port->mapbase == _Ser3UTCR0) { |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 135 | gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | } |
| 137 | } |
| 138 | |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 139 | static u_int h3xxx_uart_get_mctrl(struct uart_port *port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | { |
| 141 | u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; |
| 142 | |
| 143 | if (port->mapbase == _Ser3UTCR0) { |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 144 | /* |
| 145 | * DCD and CTS bits are inverted in GPLR by RS232 transceiver |
| 146 | */ |
| 147 | if (gpio_get_value(H3XXX_GPIO_COM_DCD)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | ret &= ~TIOCM_CD; |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 149 | if (gpio_get_value(H3XXX_GPIO_COM_CTS)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | ret &= ~TIOCM_CTS; |
| 151 | } |
| 152 | |
| 153 | return ret; |
| 154 | } |
| 155 | |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 156 | static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | { |
Dmitry Artamonow | 2a151a0 | 2009-11-27 11:10:58 +0100 | [diff] [blame] | 158 | if (port->mapbase == _Ser3UTCR0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | assign_h3600_egpio(IPAQ_EGPIO_RS232_ON, !state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | /* |
| 163 | * Enable/Disable wake up events for this serial port. |
| 164 | * Obviously, we only support this on the normal COM port. |
| 165 | */ |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 166 | static int h3xxx_uart_set_wake(struct uart_port *port, u_int enable) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | { |
| 168 | int err = -EINVAL; |
| 169 | |
| 170 | if (port->mapbase == _Ser3UTCR0) { |
| 171 | if (enable) |
| 172 | PWER |= PWER_GPIO23 | PWER_GPIO25; /* DCD and CTS */ |
| 173 | else |
| 174 | PWER &= ~(PWER_GPIO23 | PWER_GPIO25); /* DCD and CTS */ |
| 175 | err = 0; |
| 176 | } |
| 177 | return err; |
| 178 | } |
| 179 | |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 180 | static struct sa1100_port_fns h3xxx_port_fns __initdata = { |
| 181 | .set_mctrl = h3xxx_uart_set_mctrl, |
| 182 | .get_mctrl = h3xxx_uart_get_mctrl, |
| 183 | .pm = h3xxx_uart_pm, |
| 184 | .set_wake = h3xxx_uart_set_wake, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | }; |
| 186 | |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 187 | |
Dmitry Artamonow | e55b20e | 2009-11-27 11:06:46 +0100 | [diff] [blame] | 188 | static void __init h3xxx_mach_init(void) |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 189 | { |
| 190 | sa1100_register_uart_fns(&h3xxx_port_fns); |
| 191 | sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1); |
| 192 | } |
| 193 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | static struct map_desc h3600_io_desc[] __initdata = { |
Deepak Saxena | 92519d8 | 2005-10-28 15:19:04 +0100 | [diff] [blame] | 195 | { /* static memory bank 2 CS#2 */ |
| 196 | .virtual = H3600_BANK_2_VIRT, |
| 197 | .pfn = __phys_to_pfn(SA1100_CS2_PHYS), |
| 198 | .length = 0x02800000, |
| 199 | .type = MT_DEVICE |
| 200 | }, { /* static memory bank 4 CS#4 */ |
| 201 | .virtual = H3600_BANK_4_VIRT, |
| 202 | .pfn = __phys_to_pfn(SA1100_CS4_PHYS), |
| 203 | .length = 0x00800000, |
| 204 | .type = MT_DEVICE |
| 205 | }, { /* EGPIO 0 CS#5 */ |
| 206 | .virtual = H3600_EGPIO_VIRT, |
| 207 | .pfn = __phys_to_pfn(H3600_EGPIO_PHYS), |
| 208 | .length = 0x01000000, |
| 209 | .type = MT_DEVICE |
| 210 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | }; |
| 212 | |
| 213 | /* |
| 214 | * Common map_io initialization |
| 215 | */ |
| 216 | |
| 217 | static void __init h3xxx_map_io(void) |
| 218 | { |
| 219 | sa1100_map_io(); |
| 220 | iotable_init(h3600_io_desc, ARRAY_SIZE(h3600_io_desc)); |
| 221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | sa1100_register_uart(0, 3); /* Common serial port */ |
| 223 | // sa1100_register_uart(1, 1); /* Microcontroller on 3100/3600 */ |
| 224 | |
| 225 | /* Ensure those pins are outputs and driving low */ |
| 226 | PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM; |
| 227 | PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); |
| 228 | |
| 229 | /* Configure suspend conditions */ |
| 230 | PGSR = 0; |
Russell King | 0fb85a5 | 2009-10-06 16:40:24 +0100 | [diff] [blame] | 231 | PWER = PWER_GPIO0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | PCFR = PCFR_OPDE; |
| 233 | PSDR = 0; |
| 234 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | /************************* H3100 *************************/ |
| 238 | |
| 239 | #ifdef CONFIG_SA1100_H3100 |
| 240 | |
| 241 | #define H3100_EGPIO (*(volatile unsigned int *)H3600_EGPIO_VIRT) |
| 242 | static unsigned int h3100_egpio = 0; |
| 243 | |
| 244 | static void h3100_control_egpio(enum ipaq_egpio_type x, int setp) |
| 245 | { |
| 246 | unsigned int egpio = 0; |
| 247 | long gpio = 0; |
| 248 | unsigned long flags; |
| 249 | |
| 250 | switch (x) { |
| 251 | case IPAQ_EGPIO_LCD_POWER: |
| 252 | egpio |= EGPIO_H3600_LCD_ON; |
| 253 | gpio |= GPIO_H3100_LCD_3V_ON; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | break; |
| 255 | case IPAQ_EGPIO_LCD_ENABLE: |
| 256 | break; |
| 257 | case IPAQ_EGPIO_CODEC_NRESET: |
| 258 | egpio |= EGPIO_H3600_CODEC_NRESET; |
| 259 | break; |
| 260 | case IPAQ_EGPIO_AUDIO_ON: |
| 261 | gpio |= GPIO_H3100_AUD_PWR_ON |
| 262 | | GPIO_H3100_AUD_ON; |
| 263 | break; |
| 264 | case IPAQ_EGPIO_QMUTE: |
| 265 | gpio |= GPIO_H3100_QMUTE; |
| 266 | break; |
| 267 | case IPAQ_EGPIO_OPT_NVRAM_ON: |
| 268 | egpio |= EGPIO_H3600_OPT_NVRAM_ON; |
| 269 | break; |
| 270 | case IPAQ_EGPIO_OPT_ON: |
| 271 | egpio |= EGPIO_H3600_OPT_ON; |
| 272 | break; |
| 273 | case IPAQ_EGPIO_CARD_RESET: |
| 274 | egpio |= EGPIO_H3600_CARD_RESET; |
| 275 | break; |
| 276 | case IPAQ_EGPIO_OPT_RESET: |
| 277 | egpio |= EGPIO_H3600_OPT_RESET; |
| 278 | break; |
| 279 | case IPAQ_EGPIO_IR_ON: |
| 280 | gpio |= GPIO_H3100_IR_ON; |
| 281 | break; |
| 282 | case IPAQ_EGPIO_IR_FSEL: |
| 283 | gpio |= GPIO_H3100_IR_FSEL; |
| 284 | break; |
| 285 | case IPAQ_EGPIO_RS232_ON: |
| 286 | egpio |= EGPIO_H3600_RS232_ON; |
| 287 | break; |
| 288 | case IPAQ_EGPIO_VPP_ON: |
| 289 | egpio |= EGPIO_H3600_VPP_ON; |
| 290 | break; |
| 291 | } |
| 292 | |
| 293 | if (egpio || gpio) { |
| 294 | local_irq_save(flags); |
| 295 | if (setp) { |
| 296 | h3100_egpio |= egpio; |
| 297 | GPSR = gpio; |
| 298 | } else { |
| 299 | h3100_egpio &= ~egpio; |
| 300 | GPCR = gpio; |
| 301 | } |
| 302 | H3100_EGPIO = h3100_egpio; |
| 303 | local_irq_restore(flags); |
| 304 | } |
| 305 | } |
| 306 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | #define H3100_DIRECT_EGPIO (GPIO_H3100_BT_ON \ |
| 308 | | GPIO_H3100_GPIO3 \ |
| 309 | | GPIO_H3100_QMUTE \ |
| 310 | | GPIO_H3100_LCD_3V_ON \ |
| 311 | | GPIO_H3100_AUD_ON \ |
| 312 | | GPIO_H3100_AUD_PWR_ON \ |
| 313 | | GPIO_H3100_IR_ON \ |
| 314 | | GPIO_H3100_IR_FSEL) |
Dmitry Artamonow | cf5a87d | 2009-11-27 11:58:35 +0100 | [diff] [blame^] | 315 | /* |
| 316 | * helper for sa1100fb |
| 317 | */ |
| 318 | static void h3100_lcd_power(int enable) |
| 319 | { |
| 320 | assign_h3600_egpio(IPAQ_EGPIO_LCD_POWER, enable); |
| 321 | } |
| 322 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | |
| 324 | static void __init h3100_map_io(void) |
| 325 | { |
| 326 | h3xxx_map_io(); |
| 327 | |
Dmitry Artamonow | cf5a87d | 2009-11-27 11:58:35 +0100 | [diff] [blame^] | 328 | sa1100fb_lcd_power = h3100_lcd_power; |
| 329 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | /* Initialize h3100-specific values here */ |
| 331 | GPCR = 0x0fffffff; /* All outputs are set low by default */ |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 332 | GPDR = GPIO_H3600_L3_CLOCK | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA | |
| 334 | GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 | |
| 335 | H3100_DIRECT_EGPIO; |
| 336 | |
| 337 | /* Older bootldrs put GPIO2-9 in alternate mode on the |
| 338 | assumption that they are used for video */ |
| 339 | GAFR &= ~H3100_DIRECT_EGPIO; |
| 340 | |
| 341 | H3100_EGPIO = h3100_egpio; |
Dmitry Artamonow | 607b067 | 2009-03-15 19:14:27 +0100 | [diff] [blame] | 342 | assign_h3600_egpio = h3100_control_egpio; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | } |
| 344 | |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 345 | /* |
| 346 | * This turns the IRDA power on or off on the Compaq H3100 |
| 347 | */ |
| 348 | static int h3100_irda_set_power(struct device *dev, unsigned int state) |
| 349 | { |
Russell King | 9c196f0 | 2009-10-06 14:36:05 +0100 | [diff] [blame] | 350 | gpio_set_value(H3100_GPIO_IR_ON, state); |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 351 | return 0; |
| 352 | } |
| 353 | |
| 354 | static void h3100_irda_set_speed(struct device *dev, unsigned int speed) |
| 355 | { |
Russell King | 9c196f0 | 2009-10-06 14:36:05 +0100 | [diff] [blame] | 356 | gpio_set_value(H3100_GPIO_IR_FSEL, !(speed < 4000000)); |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | static struct irda_platform_data h3100_irda_data = { |
| 360 | .set_power = h3100_irda_set_power, |
| 361 | .set_speed = h3100_irda_set_speed, |
| 362 | }; |
| 363 | |
Russell King | 9c196f0 | 2009-10-06 14:36:05 +0100 | [diff] [blame] | 364 | static struct gpio_default_state h3100_default_gpio[] = { |
| 365 | { H3100_GPIO_IR_ON, GPIO_MODE_OUT0, "IrDA power" }, |
| 366 | { H3100_GPIO_IR_FSEL, GPIO_MODE_OUT0, "IrDA fsel" }, |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 367 | { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" }, |
| 368 | { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" }, |
| 369 | { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" }, |
Russell King | 9c196f0 | 2009-10-06 14:36:05 +0100 | [diff] [blame] | 370 | }; |
| 371 | |
Dmitry Artamonow | e55b20e | 2009-11-27 11:06:46 +0100 | [diff] [blame] | 372 | static void __init h3100_mach_init(void) |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 373 | { |
Russell King | 9c196f0 | 2009-10-06 14:36:05 +0100 | [diff] [blame] | 374 | h3xxx_init_gpio(h3100_default_gpio, ARRAY_SIZE(h3100_default_gpio)); |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 375 | h3xxx_mach_init(); |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 376 | sa11x0_register_irda(&h3100_irda_data); |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 377 | } |
| 378 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | MACHINE_START(H3100, "Compaq iPAQ H3100") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 380 | .phys_io = 0x80000000, |
| 381 | .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc, |
| 382 | .boot_params = 0xc0000100, |
| 383 | .map_io = h3100_map_io, |
| 384 | .init_irq = sa1100_init_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | .timer = &sa1100_timer, |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 386 | .init_machine = h3100_mach_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | MACHINE_END |
| 388 | |
| 389 | #endif /* CONFIG_SA1100_H3100 */ |
| 390 | |
| 391 | /************************* H3600 *************************/ |
| 392 | |
| 393 | #ifdef CONFIG_SA1100_H3600 |
| 394 | |
| 395 | #define H3600_EGPIO (*(volatile unsigned int *)H3600_EGPIO_VIRT) |
| 396 | static unsigned int h3600_egpio = EGPIO_H3600_RS232_ON; |
| 397 | |
| 398 | static void h3600_control_egpio(enum ipaq_egpio_type x, int setp) |
| 399 | { |
| 400 | unsigned int egpio = 0; |
| 401 | unsigned long flags; |
| 402 | |
| 403 | switch (x) { |
| 404 | case IPAQ_EGPIO_LCD_POWER: |
| 405 | egpio |= EGPIO_H3600_LCD_ON | |
| 406 | EGPIO_H3600_LCD_PCI | |
| 407 | EGPIO_H3600_LCD_5V_ON | |
| 408 | EGPIO_H3600_LVDD_ON; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | break; |
| 410 | case IPAQ_EGPIO_LCD_ENABLE: |
| 411 | break; |
| 412 | case IPAQ_EGPIO_CODEC_NRESET: |
| 413 | egpio |= EGPIO_H3600_CODEC_NRESET; |
| 414 | break; |
| 415 | case IPAQ_EGPIO_AUDIO_ON: |
| 416 | egpio |= EGPIO_H3600_AUD_AMP_ON | |
| 417 | EGPIO_H3600_AUD_PWR_ON; |
| 418 | break; |
| 419 | case IPAQ_EGPIO_QMUTE: |
| 420 | egpio |= EGPIO_H3600_QMUTE; |
| 421 | break; |
| 422 | case IPAQ_EGPIO_OPT_NVRAM_ON: |
| 423 | egpio |= EGPIO_H3600_OPT_NVRAM_ON; |
| 424 | break; |
| 425 | case IPAQ_EGPIO_OPT_ON: |
| 426 | egpio |= EGPIO_H3600_OPT_ON; |
| 427 | break; |
| 428 | case IPAQ_EGPIO_CARD_RESET: |
| 429 | egpio |= EGPIO_H3600_CARD_RESET; |
| 430 | break; |
| 431 | case IPAQ_EGPIO_OPT_RESET: |
| 432 | egpio |= EGPIO_H3600_OPT_RESET; |
| 433 | break; |
| 434 | case IPAQ_EGPIO_IR_ON: |
| 435 | egpio |= EGPIO_H3600_IR_ON; |
| 436 | break; |
| 437 | case IPAQ_EGPIO_IR_FSEL: |
| 438 | egpio |= EGPIO_H3600_IR_FSEL; |
| 439 | break; |
| 440 | case IPAQ_EGPIO_RS232_ON: |
| 441 | egpio |= EGPIO_H3600_RS232_ON; |
| 442 | break; |
| 443 | case IPAQ_EGPIO_VPP_ON: |
| 444 | egpio |= EGPIO_H3600_VPP_ON; |
| 445 | break; |
| 446 | } |
| 447 | |
| 448 | if (egpio) { |
| 449 | local_irq_save(flags); |
| 450 | if (setp) |
| 451 | h3600_egpio |= egpio; |
| 452 | else |
| 453 | h3600_egpio &= ~egpio; |
| 454 | H3600_EGPIO = h3600_egpio; |
| 455 | local_irq_restore(flags); |
| 456 | } |
| 457 | } |
| 458 | |
Dmitry Artamonow | cf5a87d | 2009-11-27 11:58:35 +0100 | [diff] [blame^] | 459 | /* |
| 460 | * helper for sa1100fb |
| 461 | */ |
| 462 | static void h3600_lcd_power(int enable) |
| 463 | { |
| 464 | assign_h3600_egpio(IPAQ_EGPIO_LCD_POWER, enable); |
| 465 | } |
| 466 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | static void __init h3600_map_io(void) |
| 468 | { |
| 469 | h3xxx_map_io(); |
| 470 | |
Dmitry Artamonow | cf5a87d | 2009-11-27 11:58:35 +0100 | [diff] [blame^] | 471 | sa1100fb_lcd_power = h3600_lcd_power; |
| 472 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | /* Initialize h3600-specific values here */ |
| 474 | |
| 475 | GPCR = 0x0fffffff; /* All outputs are set low by default */ |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 476 | GPDR = GPIO_H3600_L3_CLOCK | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA | |
Dmitry Artamonow | d0e6041 | 2009-11-27 11:11:00 +0100 | [diff] [blame] | 478 | GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | |
| 480 | H3600_EGPIO = h3600_egpio; /* Maintains across sleep? */ |
Dmitry Artamonow | 607b067 | 2009-03-15 19:14:27 +0100 | [diff] [blame] | 481 | assign_h3600_egpio = h3600_control_egpio; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | } |
| 483 | |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 484 | /* |
| 485 | * This turns the IRDA power on or off on the Compaq H3600 |
| 486 | */ |
| 487 | static int h3600_irda_set_power(struct device *dev, unsigned int state) |
| 488 | { |
| 489 | assign_h3600_egpio(IPAQ_EGPIO_IR_ON, state); |
| 490 | return 0; |
| 491 | } |
| 492 | |
| 493 | static void h3600_irda_set_speed(struct device *dev, unsigned int speed) |
| 494 | { |
| 495 | assign_h3600_egpio(IPAQ_EGPIO_IR_FSEL, !(speed < 4000000)); |
| 496 | } |
| 497 | |
| 498 | static struct irda_platform_data h3600_irda_data = { |
| 499 | .set_power = h3600_irda_set_power, |
| 500 | .set_speed = h3600_irda_set_speed, |
| 501 | }; |
| 502 | |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 503 | static struct gpio_default_state h3600_default_gpio[] = { |
| 504 | { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" }, |
| 505 | { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" }, |
| 506 | { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" }, |
| 507 | }; |
| 508 | |
Dmitry Artamonow | e55b20e | 2009-11-27 11:06:46 +0100 | [diff] [blame] | 509 | static void __init h3600_mach_init(void) |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 510 | { |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 511 | h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio)); |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 512 | h3xxx_mach_init(); |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 513 | sa11x0_register_irda(&h3600_irda_data); |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 514 | } |
| 515 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | MACHINE_START(H3600, "Compaq iPAQ H3600") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 517 | .phys_io = 0x80000000, |
| 518 | .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc, |
| 519 | .boot_params = 0xc0000100, |
| 520 | .map_io = h3600_map_io, |
| 521 | .init_irq = sa1100_init_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | .timer = &sa1100_timer, |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 523 | .init_machine = h3600_mach_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | MACHINE_END |
| 525 | |
| 526 | #endif /* CONFIG_SA1100_H3600 */ |
| 527 | |