hh.org updates
[hh.org.git] / arch / arm / mach-pxa / asus730 / a730.c
blob2daa6d0341be2733e6feb126a70d4a8f61331d0b
1 /*
2 * Machine definition for Asus MyPal A730.
4 * Use consistent with the GNU GPL is permitted,
5 * provided that this copyright notice is
6 * preserved in its entirety in all copies and derived works.
8 * 2005-03-07 Markus Wagner Started a730.c, based on hx4700.c
9 * 2006-01-19 Nickolay Kopitonenko USB Client proper initialization
10 * 2006-03-29 Serge Nikolaenko USB ohci platform init
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/ioport.h>
17 #include <linux/device.h>
19 //#include <linux/mtd/map.h>
21 #include <asm/mach-types.h>
22 #include <asm/hardware.h>
23 #include <asm/mach/arch.h>
24 #include <asm/mach/map.h>
25 #include <asm/mach/irq.h>
26 #include <asm/apm.h>
27 #include <asm/arch/asus730-init.h>
28 #include <asm/arch/asus730-gpio.h>
29 #include <asm/arch/pxa-regs.h>
30 #include <asm/arch/ohci.h>
31 #include <asm/arch/udc.h>
32 #include <asm/arch/pxafb.h>
33 #include <asm/arch/audio.h>
34 #include <asm/irq.h>
35 #include <asm/arch/mmc.h>
36 #include <linux/delay.h>
38 #include <linux/platform_device.h>
40 #include "../generic.h"
42 static struct pxafb_mach_info asus730_fb_info = {
43 .pixclock = 52000,
44 .bpp = 16,
45 .xres = 480,
46 .yres = 640,
47 .hsync_len = 4,
48 .vsync_len = 4,
49 .left_margin = 77,
50 .upper_margin = 0,
51 .right_margin = 144,
52 .lower_margin = 0,
53 .sync = 0,
54 //.lccr0 = (LCCR0_PAS),
55 .lccr0 = (LCCR0_Act | LCCR0_Sngl | LCCR0_Color),
56 .lccr3 = 0,
57 //.pxafb_backlight_power = a730_backlight_power,
58 //.pxafb_lcd_power = a730_lcd_power,
61 static struct platform_device a730_device = {
62 .name = "a730",
63 .id = 0,
66 static struct platform_device a730_power = {
67 .name = "a730-power",
70 static struct platform_device a730_keys = {
71 .name = "a730-keys",
74 static struct platform_device a730_lcd = {
75 .name = "a730-lcd",
78 extern struct platform_device a730_bl;
80 static struct platform_device a730_bt = {
81 .name = "a730-bt",
84 static struct platform_device a730_pcmcia = {
85 .name = "a730-pcmcia",
88 static struct platform_device a730_mmc = {
89 .name = "a730-mmc",
92 static pxa2xx_audio_ops_t a730_audio_ops = {
94 .startup = a730_audio_startup,
95 .shutdown = mst_audio_shutdown,
96 .suspend = mst_audio_suspend,
97 .resume = mst_audio_resume,
101 static struct platform_device a730_ac97 = {
102 .name = "pxa2xx-ac97",
103 .id = -1,
104 .dev = {
105 .platform_data = &a730_audio_ops
109 static struct platform_device *a730_devices[] __initdata = {
110 &a730_lcd,
111 &a730_bl,
112 &a730_device,
113 &a730_power,
114 &a730_keys,
115 &a730_bt,
116 &a730_pcmcia,
117 &a730_mmc,
118 &a730_ac97,
121 /* Serial cable */
122 static void check_serial_cable( void )
124 /* XXX: Should this be handled better? */
125 int connected = GET_A730_GPIO( COM_DCD );
126 /* Toggle rs232 transceiver power according to connected status */
127 SET_A730_GPIO( RS232_ON, connected);
128 SET_A730_GPIO( COM_CTS, connected );
129 SET_A730_GPIO( COM_TXD, connected );
130 SET_A730_GPIO( COM_DTR, connected );
131 SET_A730_GPIO( COM_RTS, connected );
134 static int a730_udc_is_connected (void)
136 int ret = GET_A730_GPIO(USB_CABLE_DETECT_N);
137 printk ("%s: %s %d\n",__FILE__,__PRETTY_FUNCTION__,ret);
138 return ret;
141 static void a730_udc_command (int cmd)
143 switch (cmd) {
144 case PXA2XX_UDC_CMD_DISCONNECT:
145 SET_A730_GPIO(USB_PULL_UP, 0);
146 //SET_A730_GPIO(USB_PUEN, 0);
147 break;
148 case PXA2XX_UDC_CMD_CONNECT:
149 SET_A730_GPIO(USB_PULL_UP, 1);
150 //SET_A730_GPIO(USB_PUEN, 1);
151 break;
155 static int a730_ohci_init(struct device *dev)
157 // UHCHCON = (UHCHCON_HCFS_USBOPERATIONAL | /*UHCHCON_PLE |*/ UHCHCON_CLE | UHCHCON_CBSR41);//0x97 (USBOPERATIONAL | CLE(may be not set?) | PLE | CBSR=0x3)
158 // UHCINTE = (UHCINT_MIE | UHCINT_RHSC | UHCINT_UE | UHCINT_WDH | UHCINT_SO);//0x80000053;// (MIE | RHSC | UE | WDH | SO)
159 // UHCINTD = (UHCINT_MIE | UHCINT_RHSC | UHCINT_UE | UHCINT_WDH | UHCINT_SO);//0x80000053;// (MIE | RHSC | UE | WDH | SO)
160 // UHCFMI = 0x27782edf;
161 // //UHCFMR = 0x2d6b;// (no need to set ?)
162 // //UHCFMN = 0xd1bc;// (no need to set ?)
163 // //intel says typical val is 0x3e67. wince sets to 0x2a2f
164 // UHCPERS = 0x3e67;//0x2a2f
165 // UHCLS = 0x628;// (lsthreshold=0x628)
166 // UHCRHDA = 0x4001a02;// (numberdownstreamports=1 | psm=1 | overcurrentprotection=1 | noovercurrentprotection=1 | powerontopowergoodtime(bit26)=1)
167 // UHCRHDB = 0x0;
168 // UHCRHS = 0x0;
169 // UHCRHPS1 = 0x100;// (port power on)
170 // UHCRHPS2 = 0x100;// (port power on)
171 // UHCRHPS3 = 0x100;// (port power on)
172 // UHCSTAT = 0x0;
173 // UHCHR = (UHCHR_PCPL | UHCHR_CGR);//0x84 (power control polarity low | clock generation reset inactive)
174 // UHCHIE = 0x0;
175 // UHCHIT = 0x0;
177 return 0;
180 static void a730_ohci_exit(struct device *dev)
184 static struct pxaohci_platform_data a730_ohci_platform_data = {
185 .init = a730_ohci_init,
186 .exit = a730_ohci_exit,
187 .port_mode = /*PMM_NPS_MODE,//*/PMM_PERPORT_MODE,
190 static struct pxa2xx_udc_mach_info a730_udc_info = {
191 .udc_is_connected = a730_udc_is_connected,
192 .udc_command = a730_udc_command,
195 /* Initialization code */
196 static void __init a730_map_io(void)
198 pxa_map_io();
200 PWER = PWER_RTC | PWER_GPIO0 | PWER_GPIO1 | PWER_GPIO10 | PWER_GPIO12 | PWER_GPIO(17) | PWER_GPIO13 | PWER_WEP1 | /*PWER_USBC |*/ (0x1 << 24 /*wakeup enable for standby or sleep*/ | (0x1 << 16 /* CF card */));
201 PFER = PWER_GPIO1 | PWER_GPIO12 | PWER_GPIO10;
202 PRER = PWER_GPIO0 | PWER_GPIO12;
204 /*printk("PGSR0 0x%x - 0x%x\n", PGSR0, GPSRx_SleepValue);
205 printk("PGSR1 0x%x - 0x%x\n", PGSR1, GPSRy_SleepValue);
206 printk("PGSR2 0x%x - 0x%x\n", PGSR2, GPSRz_SleepValue);
208 printk("GAFR0_L 0x%x - 0x%x\n", GAFR0_L, GAFR0x_InitValue);
209 printk("GAFR0_U 0x%x - 0x%x\n", GAFR0_U, GAFR1x_InitValue);
210 printk("GAFR1_L 0x%x - 0x%x\n", GAFR1_L, GAFR0y_InitValue);
211 printk("GAFR1_U 0x%x - 0x%x\n", GAFR1_U, GAFR1y_InitValue);
212 printk("GAFR2_L 0x%x - 0x%x\n", GAFR2_L, GAFR0z_InitValue);
213 printk("GAFR2_U 0x%x - 0x%x\n", GAFR2_U, GAFR1z_InitValue);
215 printk("GPDR0 0x%x - 0x%x\n", GPDR0, GPDRx_InitValue);
216 printk("GPDR1 0x%x - 0x%x\n", GPDR1, GPDRy_InitValue);
217 printk("GPDR2 0x%x - 0x%x\n", GPDR2, GPDRz_InitValue);
219 printk("GPSR0 0x%x - 0x%x\n", GPSR0, GPSRx_InitValue);
220 printk("GPSR1 0x%x - 0x%x\n", GPSR1, GPSRy_InitValue);
221 printk("GPSR2 0x%x - 0x%x\n", GPSR2, GPSRz_InitValue);
223 printk("GPCR0 0x%x - 0x%x\n", GPCR0, ~GPSRx_InitValue);
224 printk("GPCR1 0x%x - 0x%x\n", GPCR1, ~GPSRy_InitValue);
225 printk("GPCR2 0x%x - 0x%x\n", GPCR2, ~GPSRz_InitValue);*/
227 /* Configure power management stuff. */
228 PGSR0 = GPSRx_SleepValue;
229 PGSR1 = GPSRy_SleepValue;
230 PGSR2 = GPSRz_SleepValue;
232 /* Set up GPIO direction and alternate function registers */
233 GAFR0_L = GAFR0x_InitValue;
234 GAFR0_U = GAFR1x_InitValue;
235 GAFR1_L = GAFR0y_InitValue;
236 GAFR1_U = GAFR1y_InitValue;
237 GAFR2_L = GAFR0z_InitValue;
238 GAFR2_U = GAFR1z_InitValue;
240 /*GPDR0 = GPDRx_InitValue;
241 GPDR1 = GPDRy_InitValue;
242 GPDR2 = GPDRz_InitValue;*/
244 /* GPSR0 = GPSRx_InitValue;
245 GPSR1 = GPSRy_InitValue;
246 GPSR2 = GPSRz_InitValue;
248 GPCR0 = ~GPSRx_InitValue;
249 GPCR1 = ~GPSRy_InitValue;
250 GPCR2 = ~GPSRz_InitValue;*/
252 check_serial_cable();
255 static void __init a730_init_irq(void)
257 pxa_init_irq();
259 #ifdef CONFIG_PM
260 extern int a730_suspend(struct device *dev, pm_message_t state);
261 extern int a730_resume(struct device *dev);
262 #endif
264 static int a730_probe(struct device *dev)
266 return !machine_is_a730();
269 extern u32 pca9535_read_input(void);
271 static void a730_apm_get_power_status(struct apm_power_info *info)
273 u32 data;
275 if (!info) return;
277 data = pca9535_read_input();
279 if ((data & 0x2) && (data & 0x4000)) info->ac_line_status = APM_AC_OFFLINE;
280 else info->ac_line_status = APM_AC_ONLINE;
282 //TODO:battery
284 info->time = 0;
285 info->units = 0;
288 static struct device_driver a730_driver = {
289 .name = "a730",
290 .bus = &platform_bus_type,
291 .probe = a730_probe,
292 #ifdef CONFIG_PM
293 .suspend = a730_suspend,
294 .resume = a730_resume,
295 #endif
298 static int a730_hw_init(void)
300 GCR &= ~(GCR_PRIRDY_IEN | GCR_SECRDY_IEN);
302 //USB host
303 //CKEN |= CKEN10_USBHOST;
304 //udelay(15);
305 //UHCHR &= ~UHCHR_FHR;
308 extern void a730_ll_pm_init (void);
310 static void __init a730_init (void)
312 //pxa_gpio_mode(GPIO_NR_A730_AC97_SYSCLK | GPIO_ALT_FN_1_OUT);
313 a730_hw_init();
315 set_pxa_fb_info(&asus730_fb_info);
316 pxa_set_udc_info(&a730_udc_info);
317 // pxa_set_ohci_info(&a730_ohci_platform_data);
318 #ifdef CONFIG_PM
319 apm_get_power_status = &a730_apm_get_power_status;
320 a730_ll_pm_init();
321 #endif
322 driver_register(&a730_driver);
323 platform_add_devices(a730_devices, ARRAY_SIZE(a730_devices));
326 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
328 MACHINE_START(A730, "Asus MyPal A730(W)")
329 /* "Markus1108wagner@t-online.de" */
330 .phys_io = 0x40000000,
331 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
332 .boot_params = 0xa0000100,
333 .map_io = a730_map_io,
334 .init_irq = a730_init_irq,
335 .timer = &pxa_timer,
336 .init_machine = a730_init,
337 MACHINE_END