Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Dmitry Artamonow | 6e23fcb | 2009-11-27 12:11:48 +0100 | [diff] [blame] | 2 | * Support for Compaq iPAQ H3600 handheld computer |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
Dmitry Artamonow | 6e23fcb | 2009-11-27 12:11:48 +0100 | [diff] [blame] | 4 | * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks) |
| 5 | * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
Dmitry Artamonow | 6e23fcb | 2009-11-27 12:11:48 +0100 | [diff] [blame] | 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 11 | */ |
Dmitry Artamonow | 6e23fcb | 2009-11-27 12:11:48 +0100 | [diff] [blame] | 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/init.h> |
| 14 | #include <linux/kernel.h> |
Russell King | 0831e3e | 2009-10-06 14:35:16 +0100 | [diff] [blame] | 15 | #include <linux/gpio.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <asm/mach-types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm/mach/arch.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <asm/mach/irda.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
Dmitry Artamonow | 8715b29 | 2009-11-27 12:09:25 +0100 | [diff] [blame] | 21 | #include <mach/h3xxx.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
| 23 | #include "generic.h" |
| 24 | |
Dmitry Artamonow | cf5a87d | 2009-11-27 11:58:35 +0100 | [diff] [blame] | 25 | /* |
| 26 | * helper for sa1100fb |
| 27 | */ |
| 28 | static void h3600_lcd_power(int enable) |
| 29 | { |
Dmitry Artamonow | 729fae4 | 2009-11-27 12:22:32 +0100 | [diff] [blame] | 30 | if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power")) { |
| 31 | pr_err("%s: can't request H3XXX_EGPIO_LCD_ON\n", __func__); |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 32 | goto err1; |
Dmitry Artamonow | 729fae4 | 2009-11-27 12:22:32 +0100 | [diff] [blame] | 33 | } |
| 34 | if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control")) { |
| 35 | pr_err("%s: can't request H3XXX_EGPIO_LCD_PCI\n", __func__); |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 36 | goto err2; |
Dmitry Artamonow | 729fae4 | 2009-11-27 12:22:32 +0100 | [diff] [blame] | 37 | } |
| 38 | if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v")) { |
| 39 | pr_err("%s: can't request H3XXX_EGPIO_LCD_5V_ON\n", __func__); |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 40 | goto err3; |
Dmitry Artamonow | 729fae4 | 2009-11-27 12:22:32 +0100 | [diff] [blame] | 41 | } |
| 42 | if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v")) { |
| 43 | pr_err("%s: can't request H3600_EGPIO_LVDD_ON\n", __func__); |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 44 | goto err4; |
Dmitry Artamonow | 729fae4 | 2009-11-27 12:22:32 +0100 | [diff] [blame] | 45 | } |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 46 | |
| 47 | gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable); |
| 48 | gpio_direction_output(H3600_EGPIO_LCD_PCI, enable); |
| 49 | gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable); |
| 50 | gpio_direction_output(H3600_EGPIO_LVDD_ON, enable); |
| 51 | |
| 52 | gpio_free(H3600_EGPIO_LVDD_ON); |
| 53 | err4: gpio_free(H3600_EGPIO_LCD_5V_ON); |
| 54 | err3: gpio_free(H3600_EGPIO_LCD_PCI); |
| 55 | err2: gpio_free(H3XXX_EGPIO_LCD_ON); |
| 56 | err1: return; |
Dmitry Artamonow | cf5a87d | 2009-11-27 11:58:35 +0100 | [diff] [blame] | 57 | } |
| 58 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | static void __init h3600_map_io(void) |
| 60 | { |
| 61 | h3xxx_map_io(); |
| 62 | |
Dmitry Artamonow | cf5a87d | 2009-11-27 11:58:35 +0100 | [diff] [blame] | 63 | sa1100fb_lcd_power = h3600_lcd_power; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 66 | /* |
| 67 | * This turns the IRDA power on or off on the Compaq H3600 |
| 68 | */ |
| 69 | static int h3600_irda_set_power(struct device *dev, unsigned int state) |
| 70 | { |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 71 | gpio_set_value(H3600_EGPIO_IR_ON, state); |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | static void h3600_irda_set_speed(struct device *dev, unsigned int speed) |
| 76 | { |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 77 | gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000)); |
| 78 | } |
| 79 | |
| 80 | static int h3600_irda_startup(struct device *dev) |
| 81 | { |
| 82 | int err = gpio_request(H3600_EGPIO_IR_ON, "IrDA power"); |
| 83 | if (err) |
| 84 | goto err1; |
| 85 | err = gpio_direction_output(H3600_EGPIO_IR_ON, 0); |
| 86 | if (err) |
| 87 | goto err2; |
| 88 | err = gpio_request(H3600_EGPIO_IR_FSEL, "IrDA fsel"); |
| 89 | if (err) |
| 90 | goto err2; |
| 91 | err = gpio_direction_output(H3600_EGPIO_IR_FSEL, 0); |
| 92 | if (err) |
| 93 | goto err3; |
| 94 | return 0; |
| 95 | |
| 96 | err3: gpio_free(H3600_EGPIO_IR_FSEL); |
| 97 | err2: gpio_free(H3600_EGPIO_IR_ON); |
| 98 | err1: return err; |
| 99 | } |
| 100 | |
| 101 | static void h3600_irda_shutdown(struct device *dev) |
| 102 | { |
| 103 | gpio_free(H3600_EGPIO_IR_ON); |
| 104 | gpio_free(H3600_EGPIO_IR_FSEL); |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | static struct irda_platform_data h3600_irda_data = { |
| 108 | .set_power = h3600_irda_set_power, |
| 109 | .set_speed = h3600_irda_set_speed, |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 110 | .startup = h3600_irda_startup, |
| 111 | .shutdown = h3600_irda_shutdown, |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 112 | }; |
| 113 | |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 114 | static struct gpio_default_state h3600_default_gpio[] = { |
| 115 | { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" }, |
| 116 | { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" }, |
| 117 | { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" }, |
| 118 | }; |
| 119 | |
Dmitry Artamonow | e55b20e | 2009-11-27 11:06:46 +0100 | [diff] [blame] | 120 | static void __init h3600_mach_init(void) |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 121 | { |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 122 | h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio)); |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 123 | h3xxx_mach_init(); |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 124 | sa11x0_register_irda(&h3600_irda_data); |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 125 | } |
| 126 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | MACHINE_START(H3600, "Compaq iPAQ H3600") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 128 | .phys_io = 0x80000000, |
| 129 | .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc, |
| 130 | .boot_params = 0xc0000100, |
| 131 | .map_io = h3600_map_io, |
| 132 | .init_irq = sa1100_init_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | .timer = &sa1100_timer, |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 134 | .init_machine = h3600_mach_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | MACHINE_END |
| 136 | |