ACPI: Disable MWAIT via DMI on broken Compal board
[linux-2.6/mini2440.git] / drivers / pcmcia / au1000_xxs1500.c
blob8a9b18cee847e980881c1f0536925fca0bbcc52f
1 /*
3 * MyCable board specific pcmcia routines.
5 * Copyright 2003 MontaVista Software Inc.
6 * Author: Pete Popov, MontaVista Software, Inc.
7 * ppopov@mvista.com or source@mvista.com
9 * ########################################################################
11 * This program is free software; you can distribute it and/or modify it
12 * under the terms of the GNU General Public License (Version 2) as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
24 * ########################################################################
28 #include <linux/module.h>
29 #include <linux/init.h>
30 #include <linux/delay.h>
31 #include <linux/ioport.h>
32 #include <linux/kernel.h>
33 #include <linux/tqueue.h>
34 #include <linux/timer.h>
35 #include <linux/mm.h>
36 #include <linux/proc_fs.h>
37 #include <linux/types.h>
39 #include <pcmcia/cs_types.h>
40 #include <pcmcia/cs.h>
41 #include <pcmcia/ss.h>
42 #include <pcmcia/cistpl.h>
43 #include <pcmcia/bus_ops.h>
44 #include "cs_internal.h"
46 #include <asm/io.h>
47 #include <asm/irq.h>
48 #include <asm/system.h>
50 #include <asm/au1000.h>
51 #include <asm/au1000_pcmcia.h>
53 #define PCMCIA_MAX_SOCK 0
54 #define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
55 #define PCMCIA_IRQ AU1000_GPIO_4
57 #if 0
58 #define DEBUG(x, args...) printk(__func__ ": " x, ##args)
59 #else
60 #define DEBUG(x,args...)
61 #endif
63 static int xxs1500_pcmcia_init(struct pcmcia_init *init)
65 return PCMCIA_NUM_SOCKS;
68 static int xxs1500_pcmcia_shutdown(void)
70 /* turn off power */
71 au_writel(au_readl(GPIO2_PINSTATE) | (1<<14)|(1<<30),
72 GPIO2_OUTPUT);
73 au_sync_delay(100);
75 /* assert reset */
76 au_writel(au_readl(GPIO2_PINSTATE) | (1<<4)|(1<<20),
77 GPIO2_OUTPUT);
78 au_sync_delay(100);
79 return 0;
83 static int
84 xxs1500_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state)
86 u32 inserted; u32 vs;
87 unsigned long gpio, gpio2;
89 if(sock > PCMCIA_MAX_SOCK) return -1;
91 gpio = au_readl(SYS_PINSTATERD);
92 gpio2 = au_readl(GPIO2_PINSTATE);
94 vs = gpio2 & ((1<<8) | (1<<9));
95 inserted = (!(gpio & 0x1) && !(gpio & 0x2));
97 state->ready = 0;
98 state->vs_Xv = 0;
99 state->vs_3v = 0;
100 state->detect = 0;
102 if (inserted) {
103 switch (vs) {
104 case 0:
105 case 1:
106 case 2:
107 state->vs_3v=1;
108 break;
109 case 3: /* 5V */
110 default:
111 /* return without setting 'detect' */
112 printk(KERN_ERR "au1x00_cs: unsupported VS\n",
113 vs);
114 return;
116 state->detect = 1;
119 if (state->detect) {
120 state->ready = 1;
123 state->bvd1= gpio2 & (1<<10);
124 state->bvd2 = gpio2 & (1<<11);
125 state->wrprot=0;
126 return 1;
130 static int xxs1500_pcmcia_get_irq_info(struct pcmcia_irq_info *info)
133 if(info->sock > PCMCIA_MAX_SOCK) return -1;
134 info->irq = PCMCIA_IRQ;
135 return 0;
139 static int
140 xxs1500_pcmcia_configure_socket(const struct pcmcia_configure *configure)
143 if(configure->sock > PCMCIA_MAX_SOCK) return -1;
145 DEBUG("Vcc %dV Vpp %dV, reset %d\n",
146 configure->vcc, configure->vpp, configure->reset);
148 switch(configure->vcc){
149 case 33: /* Vcc 3.3V */
150 /* turn on power */
151 DEBUG("turn on power\n");
152 au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<14))|(1<<30),
153 GPIO2_OUTPUT);
154 au_sync_delay(100);
155 break;
156 case 50: /* Vcc 5V */
157 default: /* what's this ? */
158 printk(KERN_ERR "au1x00_cs: unsupported VCC\n");
159 case 0: /* Vcc 0 */
160 /* turn off power */
161 au_sync_delay(100);
162 au_writel(au_readl(GPIO2_PINSTATE) | (1<<14)|(1<<30),
163 GPIO2_OUTPUT);
164 break;
167 if (!configure->reset) {
168 DEBUG("deassert reset\n");
169 au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<4))|(1<<20),
170 GPIO2_OUTPUT);
171 au_sync_delay(100);
172 au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<5))|(1<<21),
173 GPIO2_OUTPUT);
175 else {
176 DEBUG("assert reset\n");
177 au_writel(au_readl(GPIO2_PINSTATE) | (1<<4)|(1<<20),
178 GPIO2_OUTPUT);
180 au_sync_delay(100);
181 return 0;
184 struct pcmcia_low_level xxs1500_pcmcia_ops = {
185 xxs1500_pcmcia_init,
186 xxs1500_pcmcia_shutdown,
187 xxs1500_pcmcia_socket_state,
188 xxs1500_pcmcia_get_irq_info,
189 xxs1500_pcmcia_configure_socket