i2c-core: Some style cleanups
[sfrench/cifs-2.6.git] / arch / arm / mach-pxa / eseries.c
1 /*
2  * Hardware definitions for the Toshiba eseries PDAs
3  *
4  * Copyright (c) 2003 Ian Molton <spyro@f2s.com>
5  *
6  * This file is licensed under
7  * the terms of the GNU General Public License version 2. This program
8  * is licensed "as is" without any warranty of any kind, whether express
9  * or implied.
10  *
11  */
12
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/gpio.h>
16 #include <linux/delay.h>
17 #include <linux/platform_device.h>
18
19 #include <asm/setup.h>
20 #include <asm/mach/arch.h>
21 #include <asm/mach-types.h>
22
23 #include <mach/mfp-pxa25x.h>
24 #include <mach/hardware.h>
25 #include <mach/eseries-gpio.h>
26 #include <mach/udc.h>
27 #include <mach/irda.h>
28
29 #include "generic.h"
30 #include "clock.h"
31
32 /* Only e800 has 128MB RAM */
33 void __init eseries_fixup(struct machine_desc *desc,
34         struct tag *tags, char **cmdline, struct meminfo *mi)
35 {
36         mi->nr_banks=1;
37         mi->bank[0].start = 0xa0000000;
38         mi->bank[0].node = 0;
39         if (machine_is_e800())
40                 mi->bank[0].size = (128*1024*1024);
41         else
42                 mi->bank[0].size = (64*1024*1024);
43 }
44
45 struct pxa2xx_udc_mach_info e7xx_udc_mach_info = {
46         .gpio_vbus   = GPIO_E7XX_USB_DISC,
47         .gpio_pullup = GPIO_E7XX_USB_PULLUP,
48         .gpio_pullup_inverted = 1
49 };
50
51 static void e7xx_irda_transceiver_mode(struct device *dev, int mode)
52 {
53         if (mode & IR_OFF) {
54                 gpio_set_value(GPIO_E7XX_IR_OFF, 1);
55                 pxa2xx_transceiver_mode(dev, mode);
56         } else {
57                 pxa2xx_transceiver_mode(dev, mode);
58                 gpio_set_value(GPIO_E7XX_IR_OFF, 0);
59         }
60 }
61
62 int e7xx_irda_init(void)
63 {
64         int ret;
65
66         ret = gpio_request(GPIO_E7XX_IR_OFF, "IrDA power");
67         if (ret)
68                 goto out;
69
70         ret = gpio_direction_output(GPIO_E7XX_IR_OFF, 0);
71         if (ret)
72                 goto out;
73
74         e7xx_irda_transceiver_mode(NULL, IR_SIRMODE | IR_OFF);
75 out:
76         return ret;
77 }
78
79 static void e7xx_irda_shutdown(struct device *dev)
80 {
81         e7xx_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
82         gpio_free(GPIO_E7XX_IR_OFF);
83 }
84
85 struct pxaficp_platform_data e7xx_ficp_platform_data = {
86         .transceiver_cap  = IR_SIRMODE | IR_OFF,
87         .transceiver_mode = e7xx_irda_transceiver_mode,
88         .shutdown = e7xx_irda_shutdown,
89 };
90
91 int eseries_tmio_enable(struct platform_device *dev)
92 {
93         /* Reset - bring SUSPEND high before PCLR */
94         gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 0);
95         gpio_set_value(GPIO_ESERIES_TMIO_PCLR, 0);
96         msleep(1);
97         gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 1);
98         msleep(1);
99         gpio_set_value(GPIO_ESERIES_TMIO_PCLR, 1);
100         msleep(1);
101         return 0;
102 }
103
104 int eseries_tmio_disable(struct platform_device *dev)
105 {
106         gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 0);
107         gpio_set_value(GPIO_ESERIES_TMIO_PCLR, 0);
108         return 0;
109 }
110
111 int eseries_tmio_suspend(struct platform_device *dev)
112 {
113         gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 0);
114         return 0;
115 }
116
117 int eseries_tmio_resume(struct platform_device *dev)
118 {
119         gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 1);
120         msleep(1);
121         return 0;
122 }
123
124 void eseries_get_tmio_gpios(void)
125 {
126         gpio_request(GPIO_ESERIES_TMIO_SUSPEND, NULL);
127         gpio_request(GPIO_ESERIES_TMIO_PCLR, NULL);
128         gpio_direction_output(GPIO_ESERIES_TMIO_SUSPEND, 0);
129         gpio_direction_output(GPIO_ESERIES_TMIO_PCLR, 0);
130 }
131
132 /* TMIO controller uses the same resources on all e-series machines. */
133 struct resource eseries_tmio_resources[] = {
134         [0] = {
135                 .start  = PXA_CS4_PHYS,
136                 .end    = PXA_CS4_PHYS + 0x1fffff,
137                 .flags  = IORESOURCE_MEM,
138         },
139         [1] = {
140                 .start  = IRQ_GPIO(GPIO_ESERIES_TMIO_IRQ),
141                 .end    = IRQ_GPIO(GPIO_ESERIES_TMIO_IRQ),
142                 .flags  = IORESOURCE_IRQ,
143         },
144 };
145
146 /* Some e-series hardware cannot control the 32K clock */
147 static void clk_32k_dummy(struct clk *clk)
148 {
149 }
150
151 static const struct clkops clk_32k_dummy_ops = {
152         .enable         = clk_32k_dummy,
153         .disable        = clk_32k_dummy,
154 };
155
156 static struct clk tmio_dummy_clk = {
157         .ops    = &clk_32k_dummy_ops,
158         .rate   = 32768,
159 };
160
161 static struct clk_lookup eseries_clkregs[] = {
162         INIT_CLKREG(&tmio_dummy_clk, NULL, "CLK_CK32K"),
163 };
164
165 void eseries_register_clks(void)
166 {
167         clks_register(eseries_clkregs, ARRAY_SIZE(eseries_clkregs));
168 }
169