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
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>
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>
47 #include <asm/system.h>
49 #include <asm/au1000.h>
50 #include <asm/au1000_pcmcia.h>
52 #define PCMCIA_MAX_SOCK 0
53 #define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
54 #define PCMCIA_IRQ AU1000_GPIO_4
57 #define DEBUG(x, args...) printk(__func__ ": " x, ##args)
59 #define DEBUG(x,args...)
62 static int xxs1500_pcmcia_init(struct pcmcia_init
*init
)
64 return PCMCIA_NUM_SOCKS
;
67 static int xxs1500_pcmcia_shutdown(void)
70 au_writel(au_readl(GPIO2_PINSTATE
) | (1<<14)|(1<<30),
75 au_writel(au_readl(GPIO2_PINSTATE
) | (1<<4)|(1<<20),
83 xxs1500_pcmcia_socket_state(unsigned sock
, struct pcmcia_state
*state
)
86 unsigned long gpio
, gpio2
;
88 if(sock
> PCMCIA_MAX_SOCK
) return -1;
90 gpio
= au_readl(SYS_PINSTATERD
);
91 gpio2
= au_readl(GPIO2_PINSTATE
);
93 vs
= gpio2
& ((1<<8) | (1<<9));
94 inserted
= (!(gpio
& 0x1) && !(gpio
& 0x2));
110 /* return without setting 'detect' */
111 printk(KERN_ERR
"au1x00_cs: unsupported VS\n",
122 state
->bvd1
= gpio2
& (1<<10);
123 state
->bvd2
= gpio2
& (1<<11);
129 static int xxs1500_pcmcia_get_irq_info(struct pcmcia_irq_info
*info
)
132 if(info
->sock
> PCMCIA_MAX_SOCK
) return -1;
133 info
->irq
= PCMCIA_IRQ
;
139 xxs1500_pcmcia_configure_socket(const struct pcmcia_configure
*configure
)
142 if(configure
->sock
> PCMCIA_MAX_SOCK
) return -1;
144 DEBUG("Vcc %dV Vpp %dV, reset %d\n",
145 configure
->vcc
, configure
->vpp
, configure
->reset
);
147 switch(configure
->vcc
){
148 case 33: /* Vcc 3.3V */
150 DEBUG("turn on power\n");
151 au_writel((au_readl(GPIO2_PINSTATE
) & ~(1<<14))|(1<<30),
155 case 50: /* Vcc 5V */
156 default: /* what's this ? */
157 printk(KERN_ERR
"au1x00_cs: unsupported VCC\n");
161 au_writel(au_readl(GPIO2_PINSTATE
) | (1<<14)|(1<<30),
166 if (!configure
->reset
) {
167 DEBUG("deassert reset\n");
168 au_writel((au_readl(GPIO2_PINSTATE
) & ~(1<<4))|(1<<20),
171 au_writel((au_readl(GPIO2_PINSTATE
) & ~(1<<5))|(1<<21),
175 DEBUG("assert reset\n");
176 au_writel(au_readl(GPIO2_PINSTATE
) | (1<<4)|(1<<20),
183 struct pcmcia_low_level xxs1500_pcmcia_ops
= {
185 xxs1500_pcmcia_shutdown
,
186 xxs1500_pcmcia_socket_state
,
187 xxs1500_pcmcia_get_irq_info
,
188 xxs1500_pcmcia_configure_socket