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
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>
24 #include <linux/bootmem.h>
25 #include <linux/platform_device.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>
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 */
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
) {
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
);
117 blueangel_get_boardid(void)
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
++);
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)
146 blueangel_get_boardid();
149 PGSR0
= GPSRx_SleepValue
;
150 PGSR1
= GPSRy_SleepValue
;
151 PGSR2
= GPSRz_SleepValue
;
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
);
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 */
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;
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
;
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", };
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",
248 .platform_data
= &blueangel_asic3_keys_data
,
253 static struct platform_device
*blueangel_asic3_devices
[] __initdata
= {
256 #ifdef CONFIG_MACH_BLUEANGEL_BACKLIGHT
259 &blueangel_asic3_keys
,
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
= {
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 */
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 */
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 */
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 */
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
= {
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 */
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 */
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 */
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 */
350 .child_platform_devs
= blueangel_asic3_devices
,
351 .num_child_platform_devs
= ARRAY_SIZE(blueangel_asic3_devices
),
354 static struct resource asic3_resources
[] = {
356 .start
= BLUEANGEL_ASIC3_GPIO_PHYS
,
357 .end
= BLUEANGEL_ASIC3_GPIO_PHYS
+ 0xfffff,
358 .flags
= IORESOURCE_MEM
,
361 .start
= IRQ_NR_BLUEANGEL_ASIC3
,
362 .end
= IRQ_NR_BLUEANGEL_ASIC3
,
363 .flags
= IORESOURCE_IRQ
,
366 .start
= BLUEANGEL_ASIC3_MMC_PHYS
,
367 .end
= BLUEANGEL_ASIC3_MMC_PHYS
+ IPAQ_ASIC3_MAP_SIZE
,
368 .flags
= IORESOURCE_MEM
,
371 .start
= IRQ_GPIO(GPIO_NR_BLUEANGEL_SD_IRQ_N
),
372 .flags
= IORESOURCE_IRQ
,
376 struct platform_device blueangel_asic3
= {
379 .num_resources
= ARRAY_SIZE(asic3_resources
),
380 .resource
= asic3_resources
,
382 EXPORT_SYMBOL(blueangel_asic3
);
387 static struct platform_device blueangel_led
= {
388 .name
= "htcblueangel-led",
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
= {
411 .platform_data
= &blueangel_pxa_keys_data
,
419 static struct platform_device
*devices
[] __initdata
= {
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
)
435 blueangel_asic3
.dev
.platform_data
=&asic3_platform_data_6
;
439 blueangel_asic3
.dev
.platform_data
=&asic3_platform_data_o
;
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
,
457 .init_machine
= blueangel_init
,