hh.org updates
[hh.org.git] / arch / arm / mach-pxa / h1900 / h1900.c
blobd548d64646d34936ad6549af76327e3606ec600a
1 /*
2 * Platform code for the iPAQ h1910/h1915
4 * Copyright 2000-2003 Hewlett-Packard Company.
5 * Copyright (C) 2005 Pawel Kolodziejski
7 * Use consistent with the GNU GPL is permitted,
8 * provided that this copyright notice is
9 * preserved in its entirety in all copies and derived works.
11 * COMPAQ COMPUTER CORPORATION MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
12 * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
13 * FITNESS FOR ANY PARTICULAR PURPOSE.
15 * Authors: Jamey Hicks <jamey.hicks at hp.com>, Joshua Wise <joshua at joshuawise.com>.
17 * History:
19 * 2003-08-28 Joshua Wise Ported to kernel 2.6
20 * 2003-05-14 Joshua Wise Adapted for the HP iPAQ H1900
21 * 2002-08-23 Jamey Hicks Adapted for use with PXA250-based iPAQs
22 * 2001-10-?? Andrew Christian Added support for iPAQ H3800
23 * and abstracted EGPIO interface.
27 #include <linux/module.h>
28 #include <linux/init.h>
29 #include <linux/kernel.h>
30 #include <linux/tty.h>
31 #include <linux/sched.h>
32 #include <linux/delay.h>
33 #include <linux/pm.h>
34 #include <linux/bootmem.h>
35 #include <linux/lcd.h>
36 #include <linux/backlight.h>
37 #include <linux/fb.h>
38 #include <linux/soc/asic3_base.h>
39 #include <linux/platform_device.h>
41 #include <asm/irq.h>
42 #include <asm/mach-types.h>
43 #include <asm/hardware.h>
44 #include <asm/setup.h>
45 #include <asm/io.h>
47 #include <asm/mach/irq.h>
48 #include <asm/mach/arch.h>
49 #include <asm/mach/map.h>
50 #include <asm/mach/irda.h>
51 #include <asm/arch/h1900-asic.h>
52 #include <asm/arch/h1900-gpio.h>
53 #include <asm/arch/ipaq.h>
54 #include <asm/arch/udc.h>
55 #include <asm/arch/pxafb.h>
56 #include <asm/arch/irda.h>
58 #include <asm/arch/pxa-regs.h>
59 #include <asm/arch/irq.h>
60 #include <asm/types.h>
61 #include <asm/apm.h>
63 #include "../generic.h"
65 void h1900_ll_pm_init(void);
67 static struct platform_device h1900_lcd = { .name = "h1900-lcd", };
68 static struct platform_device h1900_buttons = { .name = "h1900-buttons", };
69 static struct platform_device h1900_ssp = { .name = "h1900-ssp", };
70 static struct platform_device h1900_power = { .name = "h1900-power", };
72 extern struct platform_device h1900_asic3;
74 static struct platform_device *child_devices[] __initdata = {
75 &h1900_lcd,
76 &h1900_buttons,
77 &h1900_power,
80 static struct asic3_platform_data h1900_asic3_platform_data = {
81 .gpio_a = {
82 .dir = 0xffff,
83 .init = 0x0000,
84 .sleep_mask = 0xffff,
85 .sleep_out = 0x0000,
86 .batt_fault_out = 0x0000,
87 .alt_function = 0x0000,
88 .sleep_conf = 0x000c,
90 .gpio_b = {
91 .dir = 0xffff,
92 .init = 0x0000,
93 .sleep_mask = 0xffff,
94 .sleep_out = 0x0000,
95 .batt_fault_out = 0x0000,
96 .alt_function = 0x0000,
97 .sleep_conf = 0x000c,
99 .gpio_c = {
100 .dir = 0xffff,
101 .init = 0x01f0,
102 .sleep_mask = 0xffff,
103 .sleep_out = 0x0000,
104 .batt_fault_out = 0x0000,
105 .alt_function = 0x0003,
106 .sleep_conf = 0x000c,
108 .gpio_d = {
109 .dir = 0xff83,
110 .init = 0x0000,
111 .sleep_mask = 0xff83,
112 .sleep_out = 0x0000,
113 .batt_fault_out = 0x0100,
114 .alt_function = 0x0000,
115 .sleep_conf = 0x000c,
117 .child_platform_devs = child_devices,
118 .num_child_platform_devs = ARRAY_SIZE(child_devices),
121 static struct platform_device *core_devices[] __initdata = {
122 &h1900_asic3,
123 &h1900_ssp,
126 static struct resource h1900_asic3_resources[] = {
127 [0] = {
128 .start = 0x0c000000,
129 .end = 0x0c000000 + IPAQ_ASIC3_MAP_SIZE,
130 .flags = IORESOURCE_MEM,
132 [1] = {
133 .start = IRQ_GPIO(GPIO_NR_H1900_ASIC_IRQ_1_N),
134 .flags = IORESOURCE_IRQ,
136 [2] = {
137 .start = 0x10000000,
138 .end = 0x10000000 + IPAQ_ASIC3_MAP_SIZE,
139 .flags = IORESOURCE_MEM,
141 [3] = {
142 .start = IRQ_GPIO(GPIO_NR_H1900_SD_IRQ_N),
143 .flags = IORESOURCE_IRQ,
147 struct platform_device h1900_asic3 = {
148 .name = "asic3",
149 .id = 0,
150 .num_resources = ARRAY_SIZE(h1900_asic3_resources),
151 .resource = h1900_asic3_resources,
152 .dev = { .platform_data = &h1900_asic3_platform_data, },
154 EXPORT_SYMBOL(h1900_asic3);
156 #define asic3 &h1900_asic3.dev
158 static void h1900_irda_transceiver_mode(struct device *dev, int mode) {}
160 static struct pxaficp_platform_data h1900_ficp_platform_data = {
161 .transceiver_cap = IR_SIRMODE,
162 .transceiver_mode = h1900_irda_transceiver_mode,
165 static void h1900_init_pxa_gpio(void)
167 PGSR0 = 0x01020000;
168 PGSR1 = 0x00420102;
169 PGSR2 = 0x0001C000;
171 GPSR0 = 0x01030000;
172 GPSR1 = 0x00430102;
173 GPSR2 = 0x0001C000;
175 GPCR0 = 0xD2D09000;
176 GPCR1 = 0xFC3484F9;
177 GPCR2 = 0x00003FFF;
179 GAFR0_L = 0x00000000;
180 GAFR0_U = 0x5A1A8012;
181 GAFR1_L = 0x60000009;
182 GAFR1_U = 0xAAA10008;
183 GAFR2_L = 0xAAAAAAAA;
184 GAFR2_U = 0x00000002;
186 GRER0 = 0x00000000;
187 GRER1 = 0x00000000;
188 GRER2 = 0x00000000;
189 GFER0 = 0x00000000;
190 GFER1 = 0x00000000;
191 GFER2 = 0x00000000;
192 GEDR0 = 0x00000000;
193 GEDR1 = 0x00000000;
194 GEDR2 = 0x00000000;
196 GPDR0 = 0xD3D39000;
197 GPDR1 = 0xFC7785FF;
198 GPDR2 = 0x0001FFFF;
200 PWER = PWER_RTC | PWER_GPIO0 | PWER_GPIO3 | PWER_GPIO4;
201 PFER = PWER_GPIO0 | PWER_GPIO4;
202 PRER = PWER_GPIO4;
203 PEDR = 0;
204 PCFR = PCFR_OPDE;
207 void h1900_set_led(int color, int duty_time, int cycle_time)
209 if (color == H1900_RED_LED) {
210 asic3_set_led(asic3, 0, duty_time, cycle_time);
211 asic3_set_led(asic3, 1, 0, cycle_time);
214 if (color == H1900_GREEN_LED) {
215 asic3_set_led(asic3, 1, duty_time, cycle_time);
216 asic3_set_led(asic3, 0, 0, cycle_time);
219 if (color == H1900_YELLOW_LED) {
220 asic3_set_led(asic3, 1, duty_time, cycle_time);
221 asic3_set_led(asic3, 0, duty_time, cycle_time);
225 int h1900_backlight_set_power(struct backlight_device *bl, int level);
226 int h1900_lcd_set_power(struct lcd_device *lm, int level);
228 static void h1900_lcd_power(int level)
230 h1900_lcd_set_power(NULL, level);
233 static void h1900_backlight_power(int level)
235 h1900_backlight_set_power(NULL, level);
238 static struct pxafb_mach_info h1900_fb_info = {
239 .pixclock = 221039,
240 .bpp = 16,
241 .xres = 240,
242 .yres = 320,
243 .hsync_len = 3,
244 .vsync_len = 5,
245 .left_margin = 25,
246 .upper_margin = 6,
247 .right_margin = 22,
248 .lower_margin = 11,
249 .sync = 0,
250 .lccr0 = (LCCR0_PAS),
251 .pxafb_lcd_power = (void *)h1900_lcd_power,
252 .pxafb_backlight_power = (void *)h1900_backlight_power,
255 static int h1900_udc_is_connected(void)
257 return (!(GPLR(GPIO_NR_H1900_USB_DETECT2_N) & GPIO_bit(GPIO_NR_H1900_USB_DETECT2_N)));
260 static void h1900_udc_command(int cmd)
262 switch (cmd) {
263 case PXA2XX_UDC_CMD_DISCONNECT:
264 asic3_set_gpio_out_d(asic3, GPIO4_H1900_USB, 0);
265 break;
266 case PXA2XX_UDC_CMD_CONNECT:
267 asic3_set_gpio_out_d(asic3, GPIO4_H1900_USB, GPIO4_H1900_USB);
268 break;
269 default:
270 printk("_udc_control: unknown command!\n");
271 break;
275 struct pxa2xx_udc_mach_info h1900_udc_mach_info = {
276 .udc_is_connected = h1900_udc_is_connected,
277 .udc_command = h1900_udc_command,
280 static void __init h1900_init(void)
282 h1900_init_pxa_gpio();
284 pxa_set_ficp_info(&h1900_ficp_platform_data);
285 pxa_set_udc_info(&h1900_udc_mach_info);
286 set_pxa_fb_info(&h1900_fb_info);
287 h1900_ll_pm_init();
289 platform_add_devices(core_devices, ARRAY_SIZE(core_devices));
292 MACHINE_START(H1900, "HP iPAQ H1910")
293 /* Maintainer: Pawel Kolodziejski */
294 .phys_io = 0x40000000,
295 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
296 .boot_params = 0xa0000100,
297 .map_io = pxa_map_io,
298 .init_irq = pxa_init_irq,
299 .timer = &pxa_timer,
300 .init_machine = h1900_init,
301 MACHINE_END