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 | |
Russell King | e1b7a72 | 2012-01-14 11:50:04 +0000 | [diff] [blame] | 17 | #include <video/sa1100fb.h> |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <asm/mach-types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <asm/mach/arch.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <asm/mach/irda.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Dmitry Artamonow | 8715b29 | 2009-11-27 12:09:25 +0100 | [diff] [blame] | 23 | #include <mach/h3xxx.h> |
Rob Herring | f314f33 | 2012-02-24 00:06:51 +0100 | [diff] [blame] | 24 | #include <mach/irqs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | #include "generic.h" |
| 27 | |
Dmitry Artamonow | cf5a87d | 2009-11-27 11:58:35 +0100 | [diff] [blame] | 28 | /* |
| 29 | * helper for sa1100fb |
| 30 | */ |
| 31 | static void h3600_lcd_power(int enable) |
| 32 | { |
Dmitry Artamonow | 729fae4 | 2009-11-27 12:22:32 +0100 | [diff] [blame] | 33 | if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power")) { |
| 34 | pr_err("%s: can't request H3XXX_EGPIO_LCD_ON\n", __func__); |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 35 | goto err1; |
Dmitry Artamonow | 729fae4 | 2009-11-27 12:22:32 +0100 | [diff] [blame] | 36 | } |
| 37 | if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control")) { |
| 38 | pr_err("%s: can't request H3XXX_EGPIO_LCD_PCI\n", __func__); |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 39 | goto err2; |
Dmitry Artamonow | 729fae4 | 2009-11-27 12:22:32 +0100 | [diff] [blame] | 40 | } |
| 41 | if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v")) { |
| 42 | 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] | 43 | goto err3; |
Dmitry Artamonow | 729fae4 | 2009-11-27 12:22:32 +0100 | [diff] [blame] | 44 | } |
| 45 | if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v")) { |
| 46 | pr_err("%s: can't request H3600_EGPIO_LVDD_ON\n", __func__); |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 47 | goto err4; |
Dmitry Artamonow | 729fae4 | 2009-11-27 12:22:32 +0100 | [diff] [blame] | 48 | } |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 49 | |
| 50 | gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable); |
| 51 | gpio_direction_output(H3600_EGPIO_LCD_PCI, enable); |
| 52 | gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable); |
| 53 | gpio_direction_output(H3600_EGPIO_LVDD_ON, enable); |
| 54 | |
| 55 | gpio_free(H3600_EGPIO_LVDD_ON); |
| 56 | err4: gpio_free(H3600_EGPIO_LCD_5V_ON); |
| 57 | err3: gpio_free(H3600_EGPIO_LCD_PCI); |
| 58 | err2: gpio_free(H3XXX_EGPIO_LCD_ON); |
| 59 | err1: return; |
Dmitry Artamonow | cf5a87d | 2009-11-27 11:58:35 +0100 | [diff] [blame] | 60 | } |
| 61 | |
Russell King | e1b7a72 | 2012-01-14 11:50:04 +0000 | [diff] [blame] | 62 | static const struct sa1100fb_rgb h3600_rgb_16 = { |
| 63 | .red = { .offset = 12, .length = 4, }, |
| 64 | .green = { .offset = 7, .length = 4, }, |
| 65 | .blue = { .offset = 1, .length = 4, }, |
| 66 | .transp = { .offset = 0, .length = 0, }, |
| 67 | }; |
| 68 | |
| 69 | static struct sa1100fb_mach_info h3600_lcd_info = { |
| 70 | .pixclock = 174757, .bpp = 16, |
| 71 | .xres = 320, .yres = 240, |
| 72 | |
| 73 | .hsync_len = 3, .vsync_len = 3, |
| 74 | .left_margin = 12, .upper_margin = 10, |
| 75 | .right_margin = 17, .lower_margin = 1, |
| 76 | |
| 77 | .cmap_static = 1, |
| 78 | |
| 79 | .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act, |
| 80 | .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2), |
| 81 | |
| 82 | .rgb[RGB_16] = &h3600_rgb_16, |
Russell King | 086ada5 | 2012-01-14 12:03:22 +0000 | [diff] [blame] | 83 | |
| 84 | .lcd_power = h3600_lcd_power, |
Russell King | e1b7a72 | 2012-01-14 11:50:04 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | static void __init h3600_map_io(void) |
| 89 | { |
| 90 | h3xxx_map_io(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | } |
| 92 | |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 93 | /* |
| 94 | * This turns the IRDA power on or off on the Compaq H3600 |
| 95 | */ |
| 96 | static int h3600_irda_set_power(struct device *dev, unsigned int state) |
| 97 | { |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 98 | gpio_set_value(H3600_EGPIO_IR_ON, state); |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 99 | return 0; |
| 100 | } |
| 101 | |
| 102 | static void h3600_irda_set_speed(struct device *dev, unsigned int speed) |
| 103 | { |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 104 | gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000)); |
| 105 | } |
| 106 | |
| 107 | static int h3600_irda_startup(struct device *dev) |
| 108 | { |
| 109 | int err = gpio_request(H3600_EGPIO_IR_ON, "IrDA power"); |
| 110 | if (err) |
| 111 | goto err1; |
| 112 | err = gpio_direction_output(H3600_EGPIO_IR_ON, 0); |
| 113 | if (err) |
| 114 | goto err2; |
| 115 | err = gpio_request(H3600_EGPIO_IR_FSEL, "IrDA fsel"); |
| 116 | if (err) |
| 117 | goto err2; |
| 118 | err = gpio_direction_output(H3600_EGPIO_IR_FSEL, 0); |
| 119 | if (err) |
| 120 | goto err3; |
| 121 | return 0; |
| 122 | |
| 123 | err3: gpio_free(H3600_EGPIO_IR_FSEL); |
| 124 | err2: gpio_free(H3600_EGPIO_IR_ON); |
| 125 | err1: return err; |
| 126 | } |
| 127 | |
| 128 | static void h3600_irda_shutdown(struct device *dev) |
| 129 | { |
| 130 | gpio_free(H3600_EGPIO_IR_ON); |
| 131 | gpio_free(H3600_EGPIO_IR_FSEL); |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | static struct irda_platform_data h3600_irda_data = { |
| 135 | .set_power = h3600_irda_set_power, |
| 136 | .set_speed = h3600_irda_set_speed, |
Dmitry Artamonow | 22f9740 | 2009-11-27 12:02:28 +0100 | [diff] [blame] | 137 | .startup = h3600_irda_startup, |
| 138 | .shutdown = h3600_irda_shutdown, |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 139 | }; |
| 140 | |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 141 | static struct gpio_default_state h3600_default_gpio[] = { |
| 142 | { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" }, |
| 143 | { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" }, |
| 144 | { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" }, |
| 145 | }; |
| 146 | |
Dmitry Artamonow | e55b20e | 2009-11-27 11:06:46 +0100 | [diff] [blame] | 147 | static void __init h3600_mach_init(void) |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 148 | { |
Russell King | 6e21ee6 | 2009-10-06 15:16:27 +0100 | [diff] [blame] | 149 | h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio)); |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 150 | h3xxx_mach_init(); |
Russell King | e1b7a72 | 2012-01-14 11:50:04 +0000 | [diff] [blame] | 151 | |
Russell King | e1b7a72 | 2012-01-14 11:50:04 +0000 | [diff] [blame] | 152 | sa11x0_register_lcd(&h3600_lcd_info); |
Russell King | a5d176a | 2009-10-06 14:22:23 +0100 | [diff] [blame] | 153 | sa11x0_register_irda(&h3600_irda_data); |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 154 | } |
| 155 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | MACHINE_START(H3600, "Compaq iPAQ H3600") |
Nicolas Pitre | 17f4425 | 2011-07-05 22:38:17 -0400 | [diff] [blame] | 157 | .atag_offset = 0x100, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 158 | .map_io = h3600_map_io, |
Rob Herring | f314f33 | 2012-02-24 00:06:51 +0100 | [diff] [blame] | 159 | .nr_irqs = SA1100_NR_IRQS, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 160 | .init_irq = sa1100_init_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | .timer = &sa1100_timer, |
Russell King | 898e810 | 2009-10-06 14:19:44 +0100 | [diff] [blame] | 162 | .init_machine = h3600_mach_init, |
Russell King | d9ca583 | 2011-11-05 10:28:50 +0000 | [diff] [blame] | 163 | .restart = sa11x0_restart, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | MACHINE_END |
| 165 | |