2 * linux/arch/arm/mach-pxa/ra_alpha.c
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * Copyright (c) 2003 by M&N Logistik-Lösungen Online GmbH
9 * Copyright (c) 2003 Stefan Eletzhofer <stefan.eletzhofer@inquant.de>
11 * written by Stefan Eletzhofer, based on Holger Schurigs ramses code.
14 #include <linux/init.h>
15 #include <linux/major.h>
16 #include <linux/device.h>
18 #include <linux/interrupt.h>
19 #include <linux/sched.h>
20 #include <linux/root_dev.h>
22 #include <linux/delay.h>
24 #include <asm/types.h>
25 #include <asm/setup.h>
26 #include <asm/memory.h>
27 #include <asm/mach-types.h>
28 #include <asm/hardware.h>
30 #include <asm/arch/bitfield.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <asm/mach/irq.h>
35 #include <asm/arch/pxapcmcia.h>
39 /******************************************************************/
41 /******************************************************************/
43 static struct resource smc91x_resources
[] = {
45 .start
= RA_ALPHA_ETH_PHYS
,
46 .end
= RA_ALPHA_ETH_PHYS
+ RA_ALPHA_ETH_SIZE
,
47 .flags
= IORESOURCE_MEM
,
50 .start
= RA_ALPHA_IRQ_ETH
,
51 .end
= RA_ALPHA_IRQ_ETH
,
52 .flags
= IORESOURCE_IRQ
,
56 static struct platform_device smc91x_device
= {
59 .num_resources
= ARRAY_SIZE(smc91x_resources
),
60 .resource
= smc91x_resources
,
63 /******************************************************************/
65 /******************************************************************/
67 static void ra_alpha_cf_rst( int flag
)
71 _DBG( "flag=%d", flag
);
73 local_irq_save(flags
);
75 GPSR(RA_ALPHA_GPIO_CF_RST
) |= RA_ALPHA_GPIO_CF_RST
;
77 GPCR(RA_ALPHA_GPIO_CF_RST
) |= RA_ALPHA_GPIO_CF_RST
;
79 local_irq_restore(flags
);
82 static int ra_alpha_pcmcia_hw_init(struct pxa2xx_pcmcia_socket
*skt
)
86 skt
->irq
= RA_ALPHA_IRQ_CF
;
88 local_irq_save(flags
);
89 pxa_gpio_mode( RA_ALPHA_GPIO_IRQ_CF
| GPIO_IN
);
90 pxa_gpio_mode( RA_ALPHA_GPIO_CF_RST
| GPIO_OUT
);
91 local_irq_restore(flags
);
93 _DBG( "socket nr=%d, irq=%d", skt
->nr
, skt
->irq
);
99 * Release all resources.
101 static void ra_alpha_pcmcia_hw_shutdown(struct pxa2xx_pcmcia_socket
*skt
)
103 _DBG( "skt=%p, nr=%d, irq=%d", skt
, skt
->nr
, skt
->irq
);
108 ra_alpha_pcmcia_socket_state(struct pxa2xx_pcmcia_socket
*skt
, struct pcmcia_state
*state
)
110 state
->detect
= 1; /* RotAlign CF is non-hozplugged and always inserted */
111 state
->ready
= (GPLR(RA_ALPHA_GPIO_IRQ_CF
) & RA_ALPHA_GPIO_IRQ_CF
) ? 1 : 0;
115 state
->vs_3v
= 1; /* Can only apply 3.3V */
120 ra_alpha_pcmcia_configure_socket(struct pxa2xx_pcmcia_socket
*skt
, const socket_state_t
*state
)
122 /* Silently ignore Vpp, output enable, speaker enable. */
123 _DBG( "socket nr=%d, irq=%d", skt
->nr
, skt
->irq
);
125 ra_alpha_cf_rst( ( state
->flags
& SS_RESET
) == SS_RESET
);
131 * Enable card status IRQs on (re-)initialisation. This can
132 * be called at initialisation, power management event, or
135 static void ra_alpha_pcmcia_socket_init(struct pxa2xx_pcmcia_socket
*skt
)
137 /* FIXME: Do a reset of the CF card here? */
138 _DBG( "skt=%p, nr=%d, irq=%d", skt
, skt
->nr
, skt
->irq
);
143 * Disable card status IRQs on suspend.
145 static void ra_alpha_pcmcia_socket_suspend(struct pxa2xx_pcmcia_socket
*skt
)
147 _DBG( "skt=%p, nr=%d, irq=%d", skt
, skt
->nr
, skt
->irq
);
148 ra_alpha_cf_rst( 1 );
151 static struct pcmcia_low_level ra_alpha_pcmcia_ops
= {
152 .owner
= THIS_MODULE
,
154 /* only have one socket and I want to start at 1, not 0 */
158 .hw_init
= ra_alpha_pcmcia_hw_init
,
159 .hw_shutdown
= ra_alpha_pcmcia_hw_shutdown
,
161 .socket_state
= ra_alpha_pcmcia_socket_state
,
162 .configure_socket
= ra_alpha_pcmcia_configure_socket
,
164 .socket_init
= ra_alpha_pcmcia_socket_init
,
165 .socket_suspend
= ra_alpha_pcmcia_socket_suspend
,
168 static struct platform_device pcmcia_device
= {
169 .name
= "pxa2xx-pcmcia",
172 .platform_data
= &ra_alpha_pcmcia_ops
176 /******************************************************************/
178 /******************************************************************/
180 static struct platform_device
*devices
[] __initdata
= {
186 static void __init
ra_alpha_init(void)
189 printk("ra_alpha_init()\n");
191 ret
= platform_add_devices(devices
, ARRAY_SIZE(devices
));
192 _DBG( "platform_add_devices=%d", ret
);
195 static void __init
ra_alpha_init_irq(void)
198 set_irq_type(RA_ALPHA_IRQ_ETH
, RA_ALPHA_IRQT_ETH
);
202 fixup_ra_alpha(struct machine_desc
*desc
, struct tag
*tags
, char **cmdline
, struct meminfo
*mi
)
204 // TODO: should be done in the bootloader!
206 SET_BANK (0, 0xa0000000, 64*1024*1024);
209 static struct map_desc ra_alpha_io_desc
[] __initdata
= {
210 /* virtual physical length type */
211 { RA_ALPHA_ETH_BASE
, RA_ALPHA_ETH_PHYS
, RA_ALPHA_ETH_SIZE
, MT_DEVICE
},
212 { RA_ALPHA_CPLD_VIRT
, RA_ALPHA_CPLD_PHYS
, RA_ALPHA_CPLD_SIZE
, MT_DEVICE
},
215 static void __init
ra_alpha_map_io(void)
220 pxa_gpio_mode(RA_ALPHA_GPIO_IRQ_ETH
|GPIO_IN
);
223 pxa_gpio_mode(RA_ALPHA_GPIO_n3V3_ON
|GPIO_OUT
);
224 pxa_gpio_mode(RA_ALPHA_GPIO_5V4_ON
|GPIO_OUT
);
225 pxa_gpio_mode(RA_ALPHA_GPIO_nUSBH_ON
|GPIO_OUT
);
226 pxa_gpio_mode(RA_ALPHA_GPIO_CORE_FAST1
|GPIO_OUT
);
227 pxa_gpio_mode(RA_ALPHA_GPIO_CORE_FAST2
|GPIO_OUT
);
228 pxa_gpio_mode(RA_ALPHA_GPIO_nMSP_RST
|GPIO_OUT
);
230 iotable_init(ra_alpha_io_desc
, ARRAY_SIZE(ra_alpha_io_desc
));
233 MACHINE_START(RA_ALPHA
, "PT RotAlign Alpha")
234 MAINTAINER("Stefan Eletzhofer <stefan.eletzhofer@inquant.de>")
235 BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
236 BOOT_PARAMS(0xa0000100)
237 FIXUP(fixup_ra_alpha
)
238 MAPIO(ra_alpha_map_io
)
239 INITIRQ(ra_alpha_init_irq
)
240 INIT_MACHINE(ra_alpha_init
)