diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/pcmcia/au1000_xxs1500.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/pcmcia/au1000_xxs1500.c')
-rw-r--r-- | drivers/pcmcia/au1000_xxs1500.c | 191 |
1 files changed, 191 insertions, 0 deletions
diff --git a/drivers/pcmcia/au1000_xxs1500.c b/drivers/pcmcia/au1000_xxs1500.c new file mode 100644 index 000000000000..1dfc77653660 --- /dev/null +++ b/drivers/pcmcia/au1000_xxs1500.c | |||
@@ -0,0 +1,191 @@ | |||
1 | /* | ||
2 | * | ||
3 | * MyCable board specific pcmcia routines. | ||
4 | * | ||
5 | * Copyright 2003 MontaVista Software Inc. | ||
6 | * Author: Pete Popov, MontaVista Software, Inc. | ||
7 | * ppopov@mvista.com or source@mvista.com | ||
8 | * | ||
9 | * ######################################################################## | ||
10 | * | ||
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. | ||
14 | * | ||
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. | ||
19 | * | ||
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. | ||
23 | * | ||
24 | * ######################################################################## | ||
25 | * | ||
26 | * | ||
27 | */ | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/config.h> | ||
31 | #include <linux/delay.h> | ||
32 | #include <linux/ioport.h> | ||
33 | #include <linux/kernel.h> | ||
34 | #include <linux/tqueue.h> | ||
35 | #include <linux/timer.h> | ||
36 | #include <linux/mm.h> | ||
37 | #include <linux/proc_fs.h> | ||
38 | #include <linux/version.h> | ||
39 | #include <linux/types.h> | ||
40 | |||
41 | #include <pcmcia/version.h> | ||
42 | #include <pcmcia/cs_types.h> | ||
43 | #include <pcmcia/cs.h> | ||
44 | #include <pcmcia/ss.h> | ||
45 | #include <pcmcia/bulkmem.h> | ||
46 | #include <pcmcia/cistpl.h> | ||
47 | #include <pcmcia/bus_ops.h> | ||
48 | #include "cs_internal.h" | ||
49 | |||
50 | #include <asm/io.h> | ||
51 | #include <asm/irq.h> | ||
52 | #include <asm/system.h> | ||
53 | |||
54 | #include <asm/au1000.h> | ||
55 | #include <asm/au1000_pcmcia.h> | ||
56 | #include <asm/xxs1500.h> | ||
57 | |||
58 | #if 0 | ||
59 | #define DEBUG(x,args...) printk(__FUNCTION__ ": " x,##args) | ||
60 | #else | ||
61 | #define DEBUG(x,args...) | ||
62 | #endif | ||
63 | |||
64 | static int xxs1500_pcmcia_init(struct pcmcia_init *init) | ||
65 | { | ||
66 | return PCMCIA_NUM_SOCKS; | ||
67 | } | ||
68 | |||
69 | static int xxs1500_pcmcia_shutdown(void) | ||
70 | { | ||
71 | /* turn off power */ | ||
72 | au_writel(au_readl(GPIO2_PINSTATE) | (1<<14)|(1<<30), | ||
73 | GPIO2_OUTPUT); | ||
74 | au_sync_delay(100); | ||
75 | |||
76 | /* assert reset */ | ||
77 | au_writel(au_readl(GPIO2_PINSTATE) | (1<<4)|(1<<20), | ||
78 | GPIO2_OUTPUT); | ||
79 | au_sync_delay(100); | ||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | |||
84 | static int | ||
85 | xxs1500_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state) | ||
86 | { | ||
87 | u32 inserted; u32 vs; | ||
88 | unsigned long gpio, gpio2; | ||
89 | |||
90 | if(sock > PCMCIA_MAX_SOCK) return -1; | ||
91 | |||
92 | gpio = au_readl(SYS_PINSTATERD); | ||
93 | gpio2 = au_readl(GPIO2_PINSTATE); | ||
94 | |||
95 | vs = gpio2 & ((1<<8) | (1<<9)); | ||
96 | inserted = (!(gpio & 0x1) && !(gpio & 0x2)); | ||
97 | |||
98 | state->ready = 0; | ||
99 | state->vs_Xv = 0; | ||
100 | state->vs_3v = 0; | ||
101 | state->detect = 0; | ||
102 | |||
103 | if (inserted) { | ||
104 | switch (vs) { | ||
105 | case 0: | ||
106 | case 1: | ||
107 | case 2: | ||
108 | state->vs_3v=1; | ||
109 | break; | ||
110 | case 3: /* 5V */ | ||
111 | default: | ||
112 | /* return without setting 'detect' */ | ||
113 | printk(KERN_ERR "au1x00_cs: unsupported VS\n", | ||
114 | vs); | ||
115 | return; | ||
116 | } | ||
117 | state->detect = 1; | ||
118 | } | ||
119 | |||
120 | if (state->detect) { | ||
121 | state->ready = 1; | ||
122 | } | ||
123 | |||
124 | state->bvd1= gpio2 & (1<<10); | ||
125 | state->bvd2 = gpio2 & (1<<11); | ||
126 | state->wrprot=0; | ||
127 | return 1; | ||
128 | } | ||
129 | |||
130 | |||
131 | static int xxs1500_pcmcia_get_irq_info(struct pcmcia_irq_info *info) | ||
132 | { | ||
133 | |||
134 | if(info->sock > PCMCIA_MAX_SOCK) return -1; | ||
135 | info->irq = PCMCIA_IRQ; | ||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | |||
140 | static int | ||
141 | xxs1500_pcmcia_configure_socket(const struct pcmcia_configure *configure) | ||
142 | { | ||
143 | |||
144 | if(configure->sock > PCMCIA_MAX_SOCK) return -1; | ||
145 | |||
146 | DEBUG("Vcc %dV Vpp %dV, reset %d\n", | ||
147 | configure->vcc, configure->vpp, configure->reset); | ||
148 | |||
149 | switch(configure->vcc){ | ||
150 | case 33: /* Vcc 3.3V */ | ||
151 | /* turn on power */ | ||
152 | DEBUG("turn on power\n"); | ||
153 | au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<14))|(1<<30), | ||
154 | GPIO2_OUTPUT); | ||
155 | au_sync_delay(100); | ||
156 | break; | ||
157 | case 50: /* Vcc 5V */ | ||
158 | default: /* what's this ? */ | ||
159 | printk(KERN_ERR "au1x00_cs: unsupported VCC\n"); | ||
160 | case 0: /* Vcc 0 */ | ||
161 | /* turn off power */ | ||
162 | au_sync_delay(100); | ||
163 | au_writel(au_readl(GPIO2_PINSTATE) | (1<<14)|(1<<30), | ||
164 | GPIO2_OUTPUT); | ||
165 | break; | ||
166 | } | ||
167 | |||
168 | if (!configure->reset) { | ||
169 | DEBUG("deassert reset\n"); | ||
170 | au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<4))|(1<<20), | ||
171 | GPIO2_OUTPUT); | ||
172 | au_sync_delay(100); | ||
173 | au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<5))|(1<<21), | ||
174 | GPIO2_OUTPUT); | ||
175 | } | ||
176 | else { | ||
177 | DEBUG("assert reset\n"); | ||
178 | au_writel(au_readl(GPIO2_PINSTATE) | (1<<4)|(1<<20), | ||
179 | GPIO2_OUTPUT); | ||
180 | } | ||
181 | au_sync_delay(100); | ||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | struct pcmcia_low_level xxs1500_pcmcia_ops = { | ||
186 | xxs1500_pcmcia_init, | ||
187 | xxs1500_pcmcia_shutdown, | ||
188 | xxs1500_pcmcia_socket_state, | ||
189 | xxs1500_pcmcia_get_irq_info, | ||
190 | xxs1500_pcmcia_configure_socket | ||
191 | }; | ||