Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-sa1100 / h3600.c
CommitLineData
1da177e4 1/*
6e23fcb3 2 * Support for Compaq iPAQ H3600 handheld computer
1da177e4 3 *
6e23fcb3
DA
4 * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks)
5 * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru>
1da177e4 6 *
6e23fcb3
DA
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.
1da177e4
LT
10 *
11 */
6e23fcb3 12
1da177e4
LT
13#include <linux/init.h>
14#include <linux/kernel.h>
0831e3e4 15#include <linux/gpio.h>
1da177e4 16
1da177e4 17#include <asm/mach-types.h>
1da177e4 18#include <asm/mach/arch.h>
1da177e4 19#include <asm/mach/irda.h>
1da177e4 20
8715b29d 21#include <mach/h3xxx.h>
1da177e4
LT
22
23#include "generic.h"
24
cf5a87d8
DA
25/*
26 * helper for sa1100fb
27 */
28static void h3600_lcd_power(int enable)
29{
729fae44
DA
30 if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power")) {
31 pr_err("%s: can't request H3XXX_EGPIO_LCD_ON\n", __func__);
22f97405 32 goto err1;
729fae44
DA
33 }
34 if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control")) {
35 pr_err("%s: can't request H3XXX_EGPIO_LCD_PCI\n", __func__);
22f97405 36 goto err2;
729fae44
DA
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__);
22f97405 40 goto err3;
729fae44
DA
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__);
22f97405 44 goto err4;
729fae44 45 }
22f97405
DA
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);
53err4: gpio_free(H3600_EGPIO_LCD_5V_ON);
54err3: gpio_free(H3600_EGPIO_LCD_PCI);
55err2: gpio_free(H3XXX_EGPIO_LCD_ON);
56err1: return;
cf5a87d8
DA
57}
58
1da177e4
LT
59static void __init h3600_map_io(void)
60{
61 h3xxx_map_io();
62
cf5a87d8 63 sa1100fb_lcd_power = h3600_lcd_power;
1da177e4
LT
64}
65
a5d176a1
RK
66/*
67 * This turns the IRDA power on or off on the Compaq H3600
68 */
69static int h3600_irda_set_power(struct device *dev, unsigned int state)
70{
22f97405 71 gpio_set_value(H3600_EGPIO_IR_ON, state);
a5d176a1
RK
72 return 0;
73}
74
75static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
76{
22f97405
DA
77 gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000));
78}
79
80static 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
96err3: gpio_free(H3600_EGPIO_IR_FSEL);
97err2: gpio_free(H3600_EGPIO_IR_ON);
98err1: return err;
99}
100
101static void h3600_irda_shutdown(struct device *dev)
102{
103 gpio_free(H3600_EGPIO_IR_ON);
104 gpio_free(H3600_EGPIO_IR_FSEL);
a5d176a1
RK
105}
106
107static struct irda_platform_data h3600_irda_data = {
108 .set_power = h3600_irda_set_power,
109 .set_speed = h3600_irda_set_speed,
22f97405
DA
110 .startup = h3600_irda_startup,
111 .shutdown = h3600_irda_shutdown,
a5d176a1
RK
112};
113
6e21ee6a
RK
114static 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
e55b20e8 120static void __init h3600_mach_init(void)
898e810e 121{
6e21ee6a 122 h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio));
898e810e 123 h3xxx_mach_init();
a5d176a1 124 sa11x0_register_irda(&h3600_irda_data);
898e810e
RK
125}
126
1da177e4 127MACHINE_START(H3600, "Compaq iPAQ H3600")
e9dea0c6
RK
128 .boot_params = 0xc0000100,
129 .map_io = h3600_map_io,
130 .init_irq = sa1100_init_irq,
1da177e4 131 .timer = &sa1100_timer,
898e810e 132 .init_machine = h3600_mach_init,
1da177e4
LT
133MACHINE_END
134