hh.org updates
[hh.org.git] / arch / arm / mach-pxa / aximx5 / aximx5.c
blob409a471b505024c31de22673704b380030abbc44
1 /*
2 * Machine initialization for Dell Axim X5
4 * Authors: Martin Demin <demo@twincar.sk>,
5 * Andrew Zabolotny <zap@homelink.ru>
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file COPYING in the main directory of this archive for
9 * more details.
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/interrupt.h>
15 #include <linux/platform_device.h>
16 #include <linux/lcd.h>
17 #include <linux/backlight.h>
18 #include <asm/mach-types.h>
19 #include <asm/hardware.h>
20 #include <asm/mach/arch.h>
21 #include <asm/mach/map.h>
23 #include <asm/arch/pxa-regs.h>
24 #include <asm/arch/serial.h>
25 #include <asm/arch/aximx5-init.h>
26 #include <asm/arch/aximx5-gpio.h>
28 #include "../generic.h"
30 #include "../drivers/soc/mq11xx.h"
32 /* Uncomment the following line to get serial console via SIR work from
33 * the very early booting stage. This is not useful for end-user.
35 #define EARLY_SIR_CONSOLE
37 #define IR_TRANSCEIVER_ON \
38 mq_regs->SPI.blue_gpio_mode = \
39 (mq_regs->SPI.blue_gpio_mode | (1 << 3) | (3 << 14))
40 #define IR_TRANSCEIVER_OFF \
41 mq_regs->SPI.blue_gpio_mode = \
42 (mq_regs->SPI.blue_gpio_mode & ~(1 << 3)) | (3 << 14)
44 static struct mediaq11xx_regs *mq_regs;
46 static void aximx5_irda_configure (int state)
48 /* Switch STUART RX/TX pins to SIR */
49 pxa_gpio_mode(GPIO46_STRXD_MD);
50 pxa_gpio_mode(GPIO47_STTXD_MD);
51 /* make sure FIR ICP is off */
52 ICCR0 = 0;
54 switch (state) {
55 case PXA_UART_CFG_POST_STARTUP:
56 /* configure STUART to for SIR */
57 STISR = STISR_XMODE | STISR_RCVEIR | STISR_RXPL;
58 IR_TRANSCEIVER_ON;
59 break;
60 case PXA_UART_CFG_PRE_SHUTDOWN:
61 STISR = 0;
62 IR_TRANSCEIVER_OFF;
63 break;
64 default:
65 break;
69 static void aximx5_irda_set_txrx (int txrx)
71 unsigned old_stisr = STISR;
72 unsigned new_stisr = old_stisr;
74 if (txrx & PXA_SERIAL_TX) {
75 /* Ignore RX if TX is set */
76 txrx &= PXA_SERIAL_TX;
77 new_stisr |= STISR_XMITIR;
78 } else
79 new_stisr &= ~STISR_XMITIR;
81 if (txrx & PXA_SERIAL_RX)
82 new_stisr |= STISR_RCVEIR;
83 else
84 new_stisr &= ~STISR_RCVEIR;
86 if (new_stisr != old_stisr) {
87 while (!(STLSR & LSR_TEMT)) ;
88 IR_TRANSCEIVER_OFF;
89 STISR = new_stisr;
90 IR_TRANSCEIVER_ON;
94 static int aximx5_irda_get_txrx (void)
96 return ((STISR & STISR_XMITIR) ? PXA_SERIAL_TX : 0) |
97 ((STISR & STISR_RCVEIR) ? PXA_SERIAL_RX : 0);
100 static struct platform_pxa_serial_funcs aximx5_serial_funcs = {
101 .configure = aximx5_irda_configure,
102 .set_txrx = aximx5_irda_set_txrx,
103 .get_txrx = aximx5_irda_get_txrx,
106 static struct map_desc aximx5_io_desc[] __initdata = {
107 { 0xf3800000, 0x14040000, 0x00002000, MT_DEVICE },
110 static void __init aximx5_map_io(void)
112 pxa_map_io();
114 /* Configure power management stuff. */
115 PGSR0 = GPSRx_SleepValue;
116 PGSR1 = GPSRy_SleepValue;
117 PGSR2 = GPSRz_SleepValue;
119 /* Wake up on CF/SD card insertion, Power and Record buttons,
120 AC adapter plug/unplug */
121 PWER = PWER_GPIO0 | PWER_GPIO6 | PWER_GPIO7 | PWER_GPIO10
122 | PWER_RTC | PWER_GPIO4;
123 PFER = PWER_GPIO0 | PWER_GPIO4 | PWER_RTC;
124 PRER = PWER_GPIO4 | PWER_GPIO10;
125 PCFR = PCFR_OPDE;
127 /* Set up GPIO direction and alternate function registers */
128 GAFR0_L = GAFR0x_InitValue;
129 GAFR0_U = GAFR1x_InitValue;
130 GAFR1_L = GAFR0y_InitValue;
131 GAFR1_U = GAFR1y_InitValue;
132 GAFR2_L = GAFR0z_InitValue;
133 GAFR2_U = GAFR1z_InitValue;
135 GPDR0 = GPDRx_InitValue;
136 GPDR1 = GPDRy_InitValue;
137 GPDR2 = GPDRz_InitValue;
139 GPSR0 = GPSRx_InitValue;
140 GPSR1 = GPSRy_InitValue;
141 GPSR2 = GPSRz_InitValue;
143 GPCR0 = ~GPSRx_InitValue;
144 GPCR1 = ~GPSRy_InitValue;
145 GPCR2 = ~GPSRz_InitValue;
147 /* If serial cable is connected, enable RS-232 transceiver power
148 (transceiver is powered via the DCD line) */
149 if (!GET_AXIMX5_GPIO (CRADLE_DETECT_N) &&
150 AXIMX5_CONNECTOR_IS_SERIAL (AXIMX5_CONNECTOR_TYPE))
151 SET_AXIMX5_GPIO (RS232_DCD, 1);
153 /* Enable SIR on ttyS2 (STUART) */
154 iotable_init (aximx5_io_desc, ARRAY_SIZE(aximx5_io_desc));
155 mq_regs = (struct mediaq11xx_regs *)0xf3800000;
156 stuart_device.dev.platform_data = &aximx5_serial_funcs;
157 #ifdef EARLY_SIR_CONSOLE
158 aximx5_irda_configure (1);
159 aximx5_irda_set_txrx (PXA_SERIAL_TX);
160 #endif
163 static void __init aximx5_init (void)
167 MACHINE_START(AXIMX5, "Dell Axim X5")
168 /* Maintainer Martin Demin <demo@twincar.sk> Andrew Zabolotny <zap@homelink.ru> */
169 .phys_io = 0x40000000,
170 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
171 .boot_params = 0xa0000100,
172 .map_io = aximx5_map_io,
173 .init_irq = pxa_init_irq,
174 .timer = &pxa_timer,
175 .init_machine = aximx5_init,
176 MACHINE_END