hh.org updates
[hh.org.git] / arch / arm / mach-pxa / htcblueangel / blueangel.c
blob1bc345c1e119eb6af27c983397ffa2dd8e9af05c
1 /*
2 * Hardware definitions for HTC Blueangel
4 * Copyright 2004 Xanadux.org
6 * Use consistent with the GNU GPL is permitted,
7 * provided that this copyright notice is
8 * preserved in its entirety in all copies and derived works.
10 * Authors: w4xy@xanadux.org
12 * History:
14 * 2004-02-07 W4XY Initial port heavily based on h1900.c
17 #include <linux/module.h>
18 #include <linux/init.h>
19 #include <linux/tty.h>
20 #include <linux/sched.h>
21 #include <linux/input.h>
22 #include <linux/input_pda.h>
23 #include <linux/pm.h>
24 #include <linux/bootmem.h>
25 #include <linux/platform_device.h>
27 #include <asm/irq.h>
28 #include <asm/mach-types.h>
29 #include <asm/hardware.h>
30 #include <asm/setup.h>
31 #include <asm/types.h>
32 #include <asm/delay.h>
34 #include <asm/mach/irq.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37 #include <asm/arch/pxa-regs.h>
38 #include <asm/arch/irq.h>
39 #include <asm/arch/ipaq.h>
40 #include <asm/arch/pxafb.h>
41 #include <asm/arch/udc.h>
43 #include <asm/hardware/ipaq-ops.h>
44 #include <asm/hardware/ipaq-asic3.h>
45 #include <asm/hardware/gpio_keys.h>
46 #include <asm/hardware/asic3_keys.h>
47 #include <asm/arch/htcblueangel-gpio.h>
48 #include <asm/arch/htcblueangel-asic.h>
49 #include <linux/serial_core.h>
50 #include <asm-arm/arch-pxa/serial.h>
52 #include "../generic.h"
54 #include <linux/lcd.h>
55 #include <linux/backlight.h>
56 #include <linux/fb.h>
57 #include <linux/soc/asic3_base.h>
60 struct ipaq_model_ops ipaq_model_ops;
61 EXPORT_SYMBOL(ipaq_model_ops);
63 extern struct platform_device blueangel_asic3;
64 extern struct platform_device blueangel_tsc2200;
65 struct platform_pxa_serial_funcs pxa_serial_funcs [] = {
66 {}, /* No special FFUART options */
67 {}, /* No special BTUART options */
68 {}, /* No special STUART options */
69 {}, /* No special HWUART options */
72 static struct ipaq_model_ops blueangel_model_ops __initdata = {
73 .generic_name = "blueangel",
77 static void __init blueangel_init_irq( void )
79 /* Initialize standard IRQs */
80 pxa_init_irq();
83 static void ser_stuart_gpio_config(int enable)
85 printk("ser_stuart_gpio_config %d\n", enable);
86 if (enable == PXA_UART_CFG_PRE_STARTUP) {
87 STISR=0;
91 static void ser_hwuart_gpio_config(int enable)
93 printk("ser_hwuart_gpio_config %d\n", enable);
94 if (enable == PXA_UART_CFG_PRE_STARTUP) {
95 GPDR(GPIO42_HWRXD) &= ~(GPIO_bit(GPIO42_HWRXD));
96 GPDR(GPIO43_HWTXD) |= GPIO_bit(GPIO43_HWTXD);
97 GPDR(GPIO44_HWCTS) &= ~(GPIO_bit(GPIO44_HWCTS));
98 GPDR(GPIO45_HWRTS) |= GPIO_bit(GPIO45_HWRTS);
99 pxa_gpio_mode(GPIO42_HWRXD_MD);
100 pxa_gpio_mode(GPIO43_HWTXD_MD);
101 pxa_gpio_mode(GPIO44_HWCTS_MD);
102 pxa_gpio_mode(GPIO45_HWRTS_MD);
103 asic3_set_gpio_dir_a(&blueangel_asic3.dev, GPIOA_BT_PWR1_ON, GPIOA_BT_PWR1_ON);
104 asic3_set_gpio_out_a(&blueangel_asic3.dev, GPIOA_BT_PWR1_ON, GPIOA_BT_PWR1_ON);
105 asic3_set_gpio_dir_b(&blueangel_asic3.dev, GPIOB_BT_PWR2_ON, GPIOB_BT_PWR2_ON);
106 asic3_set_gpio_out_b(&blueangel_asic3.dev, GPIOB_BT_PWR2_ON, GPIOB_BT_PWR2_ON);
107 } else if (enable == PXA_UART_CFG_POST_SHUTDOWN) {
108 asic3_set_gpio_out_a(&blueangel_asic3.dev, GPIOA_BT_PWR1_ON, 0);
109 asic3_set_gpio_out_b(&blueangel_asic3.dev, GPIOB_BT_PWR2_ON, 0);
113 int blueangel_boardid;
114 EXPORT_SYMBOL(blueangel_boardid);
116 static void
117 blueangel_get_boardid(void)
119 int i;
121 int save_gpdr=GPDR(GPIO_NR_BLUEANGEL_BOARDID3);
122 GPDR(GPIO_NR_BLUEANGEL_BOARDID3) &= ~(GPIO_bit(GPIO_NR_BLUEANGEL_BOARDID3));
123 for (i = 0 ; i < 1000; i++);
124 blueangel_boardid=0;
125 if (GPLR(GPIO_NR_BLUEANGEL_BOARDID0) & GPIO_bit(GPIO_NR_BLUEANGEL_BOARDID0))
126 blueangel_boardid |= 1;
127 if (GPLR(GPIO_NR_BLUEANGEL_BOARDID1) & GPIO_bit(GPIO_NR_BLUEANGEL_BOARDID1))
128 blueangel_boardid |= 2;
129 if (GPLR(GPIO_NR_BLUEANGEL_BOARDID2) & GPIO_bit(GPIO_NR_BLUEANGEL_BOARDID2))
130 blueangel_boardid |= 4;
131 if (GPLR(GPIO_NR_BLUEANGEL_BOARDID3) & GPIO_bit(GPIO_NR_BLUEANGEL_BOARDID3))
132 blueangel_boardid |= 8;
133 GPDR(GPIO_NR_BLUEANGEL_BOARDID3)=save_gpdr;
134 printk("Blue Angel Board ID 0x%x\n", blueangel_boardid);
135 system_rev=blueangel_boardid;
139 * Common map_io initialization
141 static void __init blueangel_map_io(void)
143 int i;
145 pxa_map_io();
146 blueangel_get_boardid();
148 #if 0
149 PGSR0 = GPSRx_SleepValue;
150 PGSR1 = GPSRy_SleepValue;
151 PGSR2 = GPSRz_SleepValue;
152 #endif
154 STISR=0; /* Disable UART mode of STUART */
155 printk("CKEN=0x%x CKEN11_USB=0x%x\n", CKEN, CKEN11_USB);
156 pxa_set_cken(CKEN11_USB, 1);
157 printk("CKEN=0x%x\n", CKEN);
158 #if 0
160 GAFR0_L = 0x98000000;
161 GAFR0_U = 0x494A8110;
162 GAFR1_L = 0x699A8159;
163 GAFR1_U = 0x0005AAAA;
164 GAFR2_L = 0xA0000000;
165 GAFR2_U = 0x00000002;
167 /* don't do these for now because one of them turns the screen to mush */
168 /* reason: the ATI chip gets reset / LCD gets disconnected:
169 * a fade-to-white means that the ati 3200 registers are set incorrectly */
170 GPCR0 = 0xFF00FFFF;
171 GPCR1 = 0xFFFFFFFF;
172 GPCR2 = 0xFFFFFFFF;
174 GPSR0 = 0x444F88EF;
175 GPSR1 = 0x57BF7306;
176 GPSR2 = 0x03FFE008;
177 PGSR0 = 0x40DF88EF;
178 PGSR1 = 0x53BF7206;
179 PGSR2 = 0x03FFE000;
180 GPDR0 = 0xD7E9A042;
181 GPDR1 = 0xFCFFABA3;
182 GPDR2 = 0x000FEFFE;
183 GPSR0 = 0x444F88EF;
184 GPSR1 = 0xD7BF7306;
185 GPSR2 = 0x03FFE008;
186 GRER0 = 0x00000000;
187 GRER1 = 0x00000000;
188 GRER2 = 0x00000000;
189 GFER0 = 0x00000000;
190 GFER1 = 0x00000000;
191 GFER2 = 0x00000000;
192 #endif
195 pxa_serial_funcs[2].configure = ser_stuart_gpio_config;
196 pxa_serial_funcs[3].configure = ser_hwuart_gpio_config;
197 stuart_device.dev.platform_data = &pxa_serial_funcs[2];
198 hwuart_device.dev.platform_data = &pxa_serial_funcs[3];
200 /* disable all ongoing DMA */
201 for(i = 0; i < 16; i++) DCSR(i) = 7;
203 #if 0
204 /* Add wakeup on AC plug/unplug (and resume button) */
205 PWER = PWER_RTC | PWER_GPIO4 | PWER_GPIO0;
206 PFER = PWER_RTC | PWER_GPIO4 | PWER_GPIO0;
207 PRER = PWER_GPIO4 | PWER_GPIO0;
208 PCFR = PCFR_OPDE;
209 #endif
211 ipaq_model_ops = blueangel_model_ops;
215 * All the asic3 dependant devices
218 extern struct platform_device blueangel_bl;
219 static struct platform_device blueangel_lcd = { .name = "blueangel-lcd", };
220 static struct platform_device blueangel_udc = { .name = "blueangel-udc", };
221 static struct platform_device blueangel_leds = { .name = "blueangel-leds", };
224 * ASIC3 buttons
227 static struct asic3_keys_button blueangel_asic3_keys_table[] = {
228 {KEY_RECORD, BLUEANGEL_RECORD_BTN_IRQ, 1, "Record Button"},
229 {KEY_VOLUMEUP, BLUEANGEL_VOL_UP_BTN_IRQ, 1, "Volume Up Button"},
230 {KEY_VOLUMEDOWN, BLUEANGEL_VOL_DOWN_BTN_IRQ, 1, "Volume Down Button"},
231 {KEY_CAMERA, BLUEANGEL_CAMERA_BTN_IRQ, 1, "Camera Button"},
232 {KEY_MENU, BLUEANGEL_WINDOWS_BTN_IRQ, 1, "Windows Button"},
233 {KEY_EMAIL, BLUEANGEL_MAIL_BTN_IRQ, 1, "Mail Button"},
234 {KEY_WWW, BLUEANGEL_WWW_BTN_IRQ, 1, "Internet Button"},
235 {KEY_KPENTER, BLUEANGEL_OK_BTN_IRQ, 1, "Ok Button"},
239 static struct asic3_keys_platform_data blueangel_asic3_keys_data = {
240 .buttons = blueangel_asic3_keys_table,
241 .nbuttons = ARRAY_SIZE(blueangel_asic3_keys_table),
242 .asic3_dev = &blueangel_asic3.dev,
245 static struct platform_device blueangel_asic3_keys = {
246 .name = "asic3-keys",
247 .dev = {
248 .platform_data = &blueangel_asic3_keys_data,
253 static struct platform_device *blueangel_asic3_devices[] __initdata = {
254 &blueangel_lcd,
255 &blueangel_udc,
256 #ifdef CONFIG_MACH_BLUEANGEL_BACKLIGHT
257 &blueangel_bl,
258 #endif
259 &blueangel_asic3_keys,
260 &blueangel_leds,
265 * the ASIC3 should really only be referenced via the asic3_base
266 * module. it contains functions something like asic3_gpio_b_out()
267 * which should really be used rather than macros.
270 static struct asic3_platform_data asic3_platform_data_6 = {
271 .gpio_a = {
272 .dir = 0xbffd,
273 .init = 0x0110,
274 .sleep_out = 0x0010,
275 .batt_fault_out = 0x0010,
276 .sleep_mask = 0xffff,
277 .sleep_conf = 0x0008,
278 .alt_function = 0x9800, /* Caution: need to be set to a correct value */
280 .gpio_b = {
281 .dir = 0xfffc,
282 .init = 0x48f8,
283 .sleep_out = 0x0000,
284 .batt_fault_out = 0x0000,
285 .sleep_mask = 0xffff,
286 .sleep_conf = 0x000c,
287 .alt_function = 0x0000, /* Caution: need to be set to a correct value */
289 .gpio_c = {
290 .dir = 0xfff7,
291 .init = 0xc344,
292 .sleep_out = 0x04c4,
293 .batt_fault_out = 0x0484,
294 .sleep_mask = 0xffff,
295 .sleep_conf = 0x000c,
296 .alt_function = 0x003b, /* Caution: need to be set to a correct value */
298 .gpio_d = {
299 .dir = 0x0040,
300 .init = 0x3e1b,
301 .sleep_out = 0x3e1b,
302 .batt_fault_out = 0x3e1b,
303 .sleep_mask = 0x0000,
304 .sleep_conf = 0x000c,
305 .alt_function = 0x0000, /* Caution: need to be set to a correct value */
307 .bus_shift=1,
308 .child_platform_devs = blueangel_asic3_devices,
309 .num_child_platform_devs = ARRAY_SIZE(blueangel_asic3_devices),
312 static struct asic3_platform_data asic3_platform_data_o = {
313 .gpio_a = {
314 .dir = 0xbffd,
315 .init = 0x0110,
316 .sleep_out = 0x0010,
317 .batt_fault_out = 0x0010,
318 .sleep_mask = 0xffff,
319 .sleep_conf = 0x0008,
320 .alt_function = 0x9800, /* Caution: need to be set to a correct value */
322 .gpio_b = {
323 .dir = 0xfffc,
324 .init = 0x40fc,
325 .sleep_out = 0x0000,
326 .batt_fault_out = 0x0000,
327 .sleep_mask = 0xffff,
328 .sleep_conf = 0x000c,
329 .alt_function = 0x0000, /* Caution: need to be set to a correct value */
331 .gpio_c = {
332 .dir = 0xfff7,
333 .init = 0xc344,
334 .sleep_out = 0x04c4,
335 .batt_fault_out = 0x0484,
336 .sleep_mask = 0xffff,
337 .sleep_conf = 0x000c,
338 .alt_function = 0x003b, /* Caution: need to be set to a correct value */
340 .gpio_d = {
341 .dir = 0x0040,
342 .init = 0x3e1b,
343 .sleep_out = 0x3e1b,
344 .batt_fault_out = 0x3e1b,
345 .sleep_mask = 0x0000,
346 .sleep_conf = 0x000c,
347 .alt_function = 0x0000, /* Caution: need to be set to a correct value */
349 .bus_shift=1,
350 .child_platform_devs = blueangel_asic3_devices,
351 .num_child_platform_devs = ARRAY_SIZE(blueangel_asic3_devices),
354 static struct resource asic3_resources[] = {
355 [0] = {
356 .start = BLUEANGEL_ASIC3_GPIO_PHYS,
357 .end = BLUEANGEL_ASIC3_GPIO_PHYS + 0xfffff,
358 .flags = IORESOURCE_MEM,
360 [1] = {
361 .start = IRQ_NR_BLUEANGEL_ASIC3,
362 .end = IRQ_NR_BLUEANGEL_ASIC3,
363 .flags = IORESOURCE_IRQ,
365 [2] = {
366 .start = BLUEANGEL_ASIC3_MMC_PHYS,
367 .end = BLUEANGEL_ASIC3_MMC_PHYS + IPAQ_ASIC3_MAP_SIZE,
368 .flags = IORESOURCE_MEM,
370 [3] = {
371 .start = IRQ_GPIO(GPIO_NR_BLUEANGEL_SD_IRQ_N),
372 .flags = IORESOURCE_IRQ,
376 struct platform_device blueangel_asic3 = {
377 .name = "asic3",
378 .id = 0,
379 .num_resources = ARRAY_SIZE(asic3_resources),
380 .resource = asic3_resources,
382 EXPORT_SYMBOL(blueangel_asic3);
385 * Magician LEDs
387 static struct platform_device blueangel_led = {
388 .name = "htcblueangel-led",
389 .id = -1,
397 * GPIO buttons
399 static struct gpio_keys_button blueangel_button_table[] = {
400 { _KEY_POWER, GPIO_NR_BLUEANGEL_POWER_BUTTON_N, 1 },
403 static struct gpio_keys_platform_data blueangel_pxa_keys_data = {
404 .buttons = blueangel_button_table,
405 .nbuttons = ARRAY_SIZE(blueangel_button_table),
408 static struct platform_device blueangel_pxa_keys = {
409 .name = "gpio-keys",
410 .dev = {
411 .platform_data = &blueangel_pxa_keys_data,
419 static struct platform_device *devices[] __initdata = {
420 &blueangel_asic3,
421 &blueangel_led,
422 &blueangel_tsc2200,
423 &blueangel_pxa_keys,
426 void blueangel_hereiam(void) {
427 // asic3_set_gpio_out_b(&blueangel_asic3.dev, 0x8, 0xfb0);
430 static void __init blueangel_init(void)
432 switch (blueangel_boardid)
434 case 6:
435 blueangel_asic3.dev.platform_data=&asic3_platform_data_6;
436 break;
437 case 4:
438 case 5:
439 blueangel_asic3.dev.platform_data=&asic3_platform_data_o;
440 break;
441 default:
442 blueangel_asic3.dev.platform_data=&asic3_platform_data_o;
445 platform_add_devices (devices, ARRAY_SIZE (devices));
449 MACHINE_START(BLUEANGEL, "HTC Blueangel")
450 /* Maintainer xanadux.org */
451 .phys_io = 0x40000000,
452 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
453 .boot_params = 0xa0000100,
454 .map_io = blueangel_map_io,
455 .init_irq = blueangel_init_irq,
456 .timer = &pxa_timer,
457 .init_machine = blueangel_init,
458 MACHINE_END