3 * Alchemy Semi Pb1000 boards specific pcmcia routines.
5 * Copyright 2002 MontaVista Software Inc.
6 * Author: 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
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 #include <linux/module.h>
25 #include <linux/init.h>
26 #include <linux/delay.h>
27 #include <linux/ioport.h>
28 #include <linux/kernel.h>
29 #include <linux/timer.h>
31 #include <linux/proc_fs.h>
32 #include <linux/types.h>
34 #include <pcmcia/ss.h>
35 #include <pcmcia/cistpl.h>
39 #include <asm/system.h>
41 #include <asm/au1000.h>
42 #include <asm/au1000_pcmcia.h>
44 #define debug(fmt, arg...) do { } while (0)
46 #include <asm/pb1000.h>
47 #define PCMCIA_IRQ AU1000_GPIO_15
49 static int pb1x00_pcmcia_init(struct pcmcia_init *init)
52 pcr = PCR_SLOT_0_RST | PCR_SLOT_1_RST;
54 au_writel(0x8000, PB1000_MDR); /* clear pcmcia interrupt */
56 au_writel(0x4000, PB1000_MDR); /* enable pcmcia interrupt */
59 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,0);
60 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,1);
61 au_writel(pcr, PB1000_PCR);
64 return PCMCIA_NUM_SOCKS;
67 static int pb1x00_pcmcia_shutdown(void)
70 pcr = PCR_SLOT_0_RST | PCR_SLOT_1_RST;
71 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,0);
72 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,1);
73 au_writel(pcr, PB1000_PCR);
79 pb1x00_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state)
81 u32 inserted0, inserted1;
84 vs0 = vs1 = (u16)au_readl(PB1000_ACR1);
85 inserted0 = !(vs0 & (ACR1_SLOT_0_CD1 | ACR1_SLOT_0_CD2));
86 inserted1 = !(vs1 & (ACR1_SLOT_1_CD1 | ACR1_SLOT_1_CD2));
87 vs0 = (vs0 >> 4) & 0x3;
88 vs1 = (vs1 >> 12) & 0x3;
105 /* return without setting 'detect' */
106 printk(KERN_ERR "pb1x00 bad VS (%d)\n",
123 /* return without setting 'detect' */
124 printk(KERN_ERR "pb1x00 bad VS (%d)\n",
143 static int pb1x00_pcmcia_get_irq_info(struct pcmcia_irq_info *info)
146 if(info->sock > PCMCIA_MAX_SOCK) return -1;
149 * Even in the case of the Pb1000, both sockets are connected
150 * to the same irq line.
152 info->irq = PCMCIA_IRQ;
159 pb1x00_pcmcia_configure_socket(const struct pcmcia_configure *configure)
163 if(configure->sock > PCMCIA_MAX_SOCK) return -1;
165 pcr = au_readl(PB1000_PCR);
167 if (configure->sock == 0) {
168 pcr &= ~(PCR_SLOT_0_VCC0 | PCR_SLOT_0_VCC1 |
169 PCR_SLOT_0_VPP0 | PCR_SLOT_0_VPP1);
172 pcr &= ~(PCR_SLOT_1_VCC0 | PCR_SLOT_1_VCC1 |
173 PCR_SLOT_1_VPP0 | PCR_SLOT_1_VPP1);
176 pcr &= ~PCR_SLOT_0_RST;
177 debug("Vcc %dV Vpp %dV, pcr %x\n",
178 configure->vcc, configure->vpp, pcr);
179 switch(configure->vcc){
181 switch(configure->vpp) {
183 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_GND,
187 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_12V,
191 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_5V,
195 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_3V,
199 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,
201 printk("%s: bad Vcc/Vpp (%d:%d)\n",
208 case 50: /* Vcc 5V */
209 switch(configure->vpp) {
211 pcr |= SET_VCC_VPP(VCC_5V,VPP_GND,
215 pcr |= SET_VCC_VPP(VCC_5V,VPP_5V,
219 pcr |= SET_VCC_VPP(VCC_5V,VPP_12V,
223 pcr |= SET_VCC_VPP(VCC_5V,VPP_3V,
227 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,
229 printk("%s: bad Vcc/Vpp (%d:%d)\n",
236 case 33: /* Vcc 3.3V */
237 switch(configure->vpp) {
239 pcr |= SET_VCC_VPP(VCC_3V,VPP_GND,
243 pcr |= SET_VCC_VPP(VCC_3V,VPP_5V,
247 pcr |= SET_VCC_VPP(VCC_3V,VPP_12V,
251 pcr |= SET_VCC_VPP(VCC_3V,VPP_3V,
255 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,
257 printk("%s: bad Vcc/Vpp (%d:%d)\n",
264 default: /* what's this ? */
265 pcr |= SET_VCC_VPP(VCC_HIZ,VPP_HIZ,configure->sock);
266 printk(KERN_ERR "%s: bad Vcc %d\n",
267 __func__, configure->vcc);
271 if (configure->sock == 0) {
272 pcr &= ~(PCR_SLOT_0_RST);
273 if (configure->reset)
274 pcr |= PCR_SLOT_0_RST;
277 pcr &= ~(PCR_SLOT_1_RST);
278 if (configure->reset)
279 pcr |= PCR_SLOT_1_RST;
281 au_writel(pcr, PB1000_PCR);
288 struct pcmcia_low_level pb1x00_pcmcia_ops = {
290 pb1x00_pcmcia_shutdown,
291 pb1x00_pcmcia_socket_state,
292 pb1x00_pcmcia_get_irq_info,
293 pb1x00_pcmcia_configure_socket