MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / pcmcia / sa1100_adsbitsy.c
blob1bed35370e9807838cc0d212ba6d55fbab36c9e7
1 /*
2 * drivers/pcmcia/sa1100_adsbitsy.c
4 * PCMCIA implementation routines for ADS Bitsy
6 * 9/18/01 Woojung
7 * Fixed wrong PCMCIA voltage setting
9 * 7/5/01 Woojung Huh <whuh@applieddata.net>
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/sched.h>
15 #include <linux/device.h>
16 #include <linux/init.h>
18 #include <asm/hardware.h>
19 #include <asm/mach-types.h>
21 #include "sa1111_generic.h"
23 static int adsbitsy_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
25 /* Set GPIO_A<3:0> to be outputs for PCMCIA/CF power controller: */
26 PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
28 /* Disable Power 3.3V/5V for PCMCIA/CF */
29 PA_DWR |= GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3;
31 /* Why? */
32 MECR = 0x09430943;
34 return sa1111_pcmcia_init(skt);
37 static int
38 adsbitsy_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
40 unsigned int pa_dwr_mask, pa_dwr_set;
41 int ret;
43 switch (skt->nr) {
44 case 0:
45 pa_dwr_mask = GPIO_GPIO0 | GPIO_GPIO1;
47 switch (state->Vcc) {
48 default:
49 case 0: pa_dwr_set = GPIO_GPIO0 | GPIO_GPIO1; break;
50 case 33: pa_dwr_set = GPIO_GPIO1; break;
51 case 50: pa_dwr_set = GPIO_GPIO0; break;
53 break;
55 case 1:
56 pa_dwr_mask = GPIO_GPIO2 | GPIO_GPIO3;
58 switch (state->Vcc) {
59 default:
60 case 0: pa_dwr_set = 0; break;
61 case 33: pa_dwr_set = GPIO_GPIO2; break;
62 case 50: pa_dwr_set = GPIO_GPIO3; break;
65 default:
66 return -1;
69 if (state->Vpp != state->Vcc && state->Vpp != 0) {
70 printk(KERN_ERR "%s(): CF slot cannot support VPP %u\n",
71 __FUNCTION__, state->Vpp);
72 return -1;
75 ret = sa1111_pcmcia_configure_socket(skt, state);
76 if (ret == 0) {
77 unsigned long flags;
79 local_irq_save(flags);
80 PA_DWR = (PA_DWR & ~pa_dwr_mask) | pa_dwr_set;
81 local_irq_restore(flags);
84 return ret;
87 static struct pcmcia_low_level adsbitsy_pcmcia_ops = {
88 .owner = THIS_MODULE,
89 .hw_init = adsbitsy_pcmcia_hw_init,
90 .hw_shutdown = sa1111_pcmcia_hw_shutdown,
91 .socket_state = sa1111_pcmcia_socket_state,
92 .configure_socket = adsbitsy_pcmcia_configure_socket,
93 .socket_init = sa1111_pcmcia_socket_init,
94 .socket_suspend = sa1111_pcmcia_socket_suspend,
97 int __init pcmcia_adsbitsy_init(struct device *dev)
99 int ret = -ENODEV;
100 if (machine_is_adsbitsy())
101 ret = sa11xx_drv_pcmcia_probe(dev, &adsbitsy_pcmcia_ops, 0, 2);
102 return ret;