hh.org updates
[hh.org.git] / arch / arm / mach-pxa / htcuniversal / htcuniversal_phone.c
blob8f06a4ba4ede7935c21421590b8c7c664991f7df
2 /* Phone interface driver for Qualcomm MSM6250 on HTC Universal
4 * Copyright (c) 2005 SDG Systems, LLC
6 * 2005-04-21 Todd Blumer Created.
7 */
9 #include <linux/module.h>
10 #include <linux/kernel.h>
11 #include <linux/delay.h>
12 #include <linux/platform_device.h>
13 #include <linux/soc/asic3_base.h>
15 #include <asm/hardware.h>
16 #include <asm/arch/serial.h>
17 #include <asm/hardware/ipaq-asic3.h>
18 #include <asm/arch/htcuniversal-gpio.h>
19 #include <asm/arch/htcuniversal-asic.h>
21 #include "htcuniversal_phone.h"
23 static void phone_reset(void)
25 asic3_set_gpio_out_b(&htcuniversal_asic3.dev, 1<<GPIOB_BB_RESET2, 0);
27 SET_HTCUNIVERSAL_GPIO(PHONE_RESET,0);
28 asic3_set_gpio_out_d(&htcuniversal_asic3.dev, 1<<GPIOD_BB_RESET1, 0);
29 mdelay(1);
30 asic3_set_gpio_out_d(&htcuniversal_asic3.dev, 1<<GPIOD_BB_RESET1, 1<<GPIOD_BB_RESET1);
31 mdelay(20);
32 SET_HTCUNIVERSAL_GPIO(PHONE_RESET,1);
33 mdelay(200);
34 asic3_set_gpio_out_d(&htcuniversal_asic3.dev, 1<<GPIOD_BB_RESET1, 0);
37 static void phone_off(void)
39 asic3_set_gpio_out_d(&htcuniversal_asic3.dev, 1<<GPIOD_BB_RESET1, 1<<GPIOD_BB_RESET1);
40 mdelay(2000);
41 asic3_set_gpio_out_d(&htcuniversal_asic3.dev, 1<<GPIOD_BB_RESET1, 0);
43 asic3_set_gpio_out_b(&htcuniversal_asic3.dev, 1<<GPIOB_BB_RESET2, 1<<GPIOB_BB_RESET2);
44 SET_HTCUNIVERSAL_GPIO(PHONE_OFF,0);
47 static void
48 htcuniversal_phone_configure( int state )
50 int tries;
51 unsigned short statusb;
53 printk( KERN_NOTICE "htcuniversal configure phone: %d\n", state );
54 switch (state) {
56 case PXA_UART_CFG_PRE_STARTUP:
57 break;
59 case PXA_UART_CFG_POST_STARTUP:
60 /* pre-serial-up hardware configuration */
62 SET_HTCUNIVERSAL_GPIO(PHONE_START,0); /* "bootloader" */
63 SET_HTCUNIVERSAL_GPIO(PHONE_UNKNOWN,0); /* not used */
64 SET_HTCUNIVERSAL_GPIO(PHONE_OFF,0); // /* PHONE_OFF */
66 phone_reset();
68 SET_HTCUNIVERSAL_GPIO(PHONE_START,1); /* phone */
70 phone_reset();
74 tries = 0;
75 do {
76 mdelay(10);
77 statusb = asic3_get_gpio_status_b( &htcuniversal_asic3.dev );
78 } while ( (statusb & (1<<GPIOB_UMTS_DCD)) == 0 && tries++ < 200);
80 printk("UMTS_DCD tries=%d of 200\n",tries);
82 tries = 0;
83 do {
84 SET_HTCUNIVERSAL_GPIO(PHONE_OFF,1);
85 mdelay(10);
86 SET_HTCUNIVERSAL_GPIO(PHONE_OFF,0);
87 mdelay(20);
88 statusb = asic3_get_gpio_status_b( &htcuniversal_asic3.dev );
89 } while ( (statusb & (1<<GPIOB_BB_READY)) == 0 && tries++ < 200);
91 printk("BB_READY tries=%d of 200\n",tries);
93 break;
95 case PXA_UART_CFG_PRE_SHUTDOWN:
97 phone_off();
99 break;
101 default:
102 break;
107 static int
108 htcuniversal_phone_probe( struct platform_device *dev )
110 struct htcuniversal_phone_funcs *funcs = dev->dev.platform_data;
112 /* configure phone UART */
113 pxa_gpio_mode( GPIO_NR_HTCUNIVERSAL_PHONE_RXD_MD );
114 pxa_gpio_mode( GPIO_NR_HTCUNIVERSAL_PHONE_TXD_MD );
115 pxa_gpio_mode( GPIO_NR_HTCUNIVERSAL_PHONE_UART_CTS_MD );
116 pxa_gpio_mode( GPIO_NR_HTCUNIVERSAL_PHONE_UART_RTS_MD );
118 funcs->configure = htcuniversal_phone_configure;
120 return 0;
123 static int
124 htcuniversal_phone_remove( struct platform_device *dev )
126 struct htcuniversal_phone_funcs *funcs = dev->dev.platform_data;
128 funcs->configure = NULL;
130 return 0;
133 static struct platform_driver phone_driver = {
134 .driver = {
135 .name = "htcuniversal_phone",
137 .probe = htcuniversal_phone_probe,
138 .remove = htcuniversal_phone_remove,
141 static int __init
142 htcuniversal_phone_init( void )
144 printk(KERN_NOTICE "htcuniversal Phone Driver\n");
145 return platform_driver_register( &phone_driver );
148 static void __exit
149 htcuniversal_phone_exit( void )
151 platform_driver_unregister( &phone_driver );
154 module_init( htcuniversal_phone_init );
155 module_exit( htcuniversal_phone_exit );
157 MODULE_AUTHOR("Todd Blumer, SDG Systems, LLC");
158 MODULE_DESCRIPTION("HTC Universal Phone Support Driver");
159 MODULE_LICENSE("GPL");
161 /* vim600: set noexpandtab sw=8 ts=8 :*/