2 * GSM driver for HTC Magician
4 * Copyright (C) 2006, Philipp Zabel
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive for
11 #include <linux/module.h>
12 #include <linux/err.h>
13 #include <linux/delay.h>
14 #include <linux/platform_device.h>
16 #include <asm/arch/magician.h>
17 #include <asm/mach-types.h>
19 #include <asm/arch/hardware.h>
20 #include <asm/arch/pxa-regs.h>
21 #include <asm/arch/serial.h>
22 #include <asm/arch/magician_cpld.h>
24 extern struct platform_device magician_cpld
;
26 static void magician_gsm_reset()
28 printk ("GSM Reset\n");
30 pxa_gpio_mode (10 | GPIO_IN
);
31 pxa_gpio_mode (108 | GPIO_IN
);
33 /* FIXME: clear 40, is this OK, or a bug in wince? */
34 GPCR(GPIO40_FFDTR
) = GPIO_bit(GPIO40_FFDTR
);
36 GPCR(11) = GPIO_bit(11);
37 GPCR(87) = GPIO_bit(87);
39 /* stop display to avoid interference? */
40 GPCR(GPIO74_LCD_FCLK
) = GPIO_bit(GPIO74_LCD_FCLK
);
42 magician_egpio_enable (&magician_cpld
, EGPIO_NR_MAGICIAN_GSM_POWER
);
45 GPSR(GPIO74_LCD_FCLK
) = GPIO_bit(GPIO74_LCD_FCLK
);
47 GPCR(GPIO74_LCD_FCLK
) = GPIO_bit(GPIO74_LCD_FCLK
);
49 if (GPLR0
& 0x800) printk ("GSM: GPLR bit 11 already set\n");
50 GPSR(11) = GPIO_bit(11);
52 /* FIXME: disable+reenable 86, is this OK? */
53 GPCR(86) = GPIO_bit(86); // ??
54 GPSR(86) = GPIO_bit(86); // GSM_RESET
55 GPSR(26) = GPIO_bit(26);
57 GPCR(86) = GPIO_bit(86);
61 pxa_gpio_mode (GPIO36_FFDCD_MD); // alt 1 in
62 pxa_gpio_mode (GPIO39_FFTXD_MD); // alt 2 out
63 pxa_gpio_mode (GPIO43_BTTXD_MD); // alt 2 out
64 pxa_gpio_mode (GPIO41_FFRTS_MD); // alt 2 out
65 pxa_gpio_mode (GPIO45_BTRTS_MD); // alt 2 out
68 if (PGSR0
& 0x800) printk ("GSM: PGSR bit 11 set\n");
72 void magician_gsm_off()
75 GPCR(11) = GPIO_bit(11);
76 GPCR(GPIO74_LCD_FCLK
) = GPIO_bit(GPIO74_LCD_FCLK
);
77 GPCR(87) = GPIO_bit(87);
78 GPCR(86) = GPIO_bit(86); // GSM_RESET
79 GPCR(26) = GPIO_bit(26); // GSM_POWER
80 // pxa_cken_set (CKEN6_FFUART, 0);
81 // pxa_cken_set (CKEN7_BTUART, 0);
83 pxa_gpio_mode (10 | GPIO_OUT
);
84 GPCR(10) = GPIO_bit(10);
85 pxa_gpio_mode (108 | GPIO_OUT
);
86 GPCR(108) = GPIO_bit(108);
88 pxa_gpio_mode (GPIO34_FFRXD | GPIO_OUT);
89 GPCR(34) = GPIO_bit(34);
90 pxa_gpio_mode (GPIO35_FFCTS | GPIO_OUT);
91 GPCR(35) = GPIO_bit(35);
92 pxa_gpio_mode (GPIO36_FFDCD | GPIO_OUT);
93 GPCR(36) = GPIO_bit(36);
94 pxa_gpio_mode (GPIO39_FFTXD | GPIO_OUT);
95 GPCR(39) = GPIO_bit(39);
96 pxa_gpio_mode (GPIO41_FFRTS | GPIO_OUT);
97 GPCR(41) = GPIO_bit(41);
98 pxa_gpio_mode (GPIO42_BTRXD | GPIO_OUT);
99 GPCR(42) = GPIO_bit(42);
100 pxa_gpio_mode (GPIO43_BTTXD | GPIO_OUT);
101 GPCR(43) = GPIO_bit(43);
102 pxa_gpio_mode (GPIO44_BTCTS | GPIO_OUT);
103 GPCR(44) = GPIO_bit(44);
104 pxa_gpio_mode (GPIO45_BTRTS | GPIO_OUT);
105 GPCR(45) = GPIO_bit(45);
107 PGSR0
&= ~0x800; // 11 off during suspend
108 magician_egpio_disable(&magician_cpld
, EGPIO_NR_MAGICIAN_GSM_POWER
);
111 static void magician_phone_configure (int state
)
115 case PXA_UART_CFG_PRE_STARTUP
:
116 printk( KERN_NOTICE
"magician configure phone: PRE_STARTUP\n");
117 magician_gsm_reset();
118 GPCR(11) = GPIO_bit(11); /* ready to talk */
121 case PXA_UART_CFG_POST_STARTUP
:
122 printk( KERN_NOTICE
"magician configure phone: POST_STARTUP\n");
125 case PXA_UART_CFG_PRE_SHUTDOWN
:
126 printk( KERN_NOTICE
"magician configure phone: PRE_SHUTDOWN\n");
135 struct magician_phone_funcs
{
136 void (*configure
) (int state
, int suspend
);
139 static int magician_phone_probe (struct platform_device
*dev
)
141 struct magician_phone_funcs
*funcs
= (struct magician_phone_funcs
*) dev
->dev
.platform_data
;
143 /* configure phone UART */
144 // pxa_gpio_mode( GPIO_NR_HTCSABLE_PHONE_RXD_MD );
145 // pxa_gpio_mode( GPIO_NR_HTCSABLE_PHONE_TXD_MD );
146 // pxa_gpio_mode( GPIO_NR_HTCSABLE_PHONE_UART_CTS_MD );
147 // pxa_gpio_mode( GPIO_NR_HTCSABLE_PHONE_UART_RTS_MD );
149 funcs
->configure
= magician_phone_configure
;
154 static int magician_phone_remove (struct platform_device
*dev
)
156 struct magician_phone_funcs
*funcs
= (struct magician_phone_funcs
*) dev
->dev
.platform_data
;
158 funcs
->configure
= NULL
;
163 static struct platform_driver phone_driver
= {
164 .probe
= magician_phone_probe
,
165 .remove
= magician_phone_remove
,
167 .name
= "magician-phone",
171 static __init
int magician_phone_init(void)
173 if (!machine_is_magician())
175 printk(KERN_NOTICE
"magician Phone Driver\n");
177 return platform_driver_register(&phone_driver
);
180 static __exit
void magician_phone_exit(void)
182 platform_driver_unregister(&phone_driver
);
185 module_init(magician_phone_init
);
186 module_exit(magician_phone_exit
);
188 MODULE_AUTHOR("Philipp Zabel");
189 MODULE_DESCRIPTION("HTC Magician GSM driver");
190 MODULE_LICENSE("GPL");