more debug output
[linux-2.4.git] / drivers / pcmcia / au1000_hydrogen3.c
1 /*
2  *
3  * Alchemy Semi Hydrogen III board specific pcmcia routines.
4  *
5  * based on:
6  *
7  * Alchemy Semi Hyd1100 board specific pcmcia routines.
8  *
9  * Copyright 2002 MontaVista Software Inc.
10  * Author: MontaVista Software, Inc.
11  *              ppopov@mvista.com or source@mvista.com
12  *
13  * ########################################################################
14  *
15  *  This program is free software; you can distribute it and/or modify it
16  *  under the terms of the GNU General Public License (Version 2) as
17  *  published by the Free Software Foundation.
18  *
19  *  This program is distributed in the hope it will be useful, but WITHOUT
20  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22  *  for more details.
23  *
24  *  You should have received a copy of the GNU General Public License along
25  *  with this program; if not, write to the Free Software Foundation, Inc.,
26  *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
27  *
28  * ########################################################################
29  *
30  * 
31  */
32 #include <linux/module.h>
33 #include <linux/init.h>
34 #include <linux/config.h>
35 #include <linux/delay.h>
36 #include <linux/ioport.h>
37 #include <linux/kernel.h>
38 #include <linux/tqueue.h>
39 #include <linux/timer.h>
40 #include <linux/mm.h>
41 #include <linux/proc_fs.h>
42 #include <linux/version.h>
43 #include <linux/types.h>
44
45 #include <pcmcia/version.h>
46 #include <pcmcia/cs_types.h>
47 #include <pcmcia/cs.h>
48 #include <pcmcia/ss.h>
49 #include <pcmcia/bulkmem.h>
50 #include <pcmcia/cistpl.h>
51 #include <pcmcia/bus_ops.h>
52 #include "cs_internal.h"
53
54 #include <asm/io.h>
55 #include <asm/irq.h>
56 #include <asm/system.h>
57
58 #include <asm/au1000.h>
59 #include <asm/au1000_pcmcia.h>
60
61 #include <asm/db1x00.h>
62
63 #define PCMCIA_MAX_SOCK 0
64 //#include <asm/hyd1100.h>
65
66
67 static int hydrogen3_pcmcia_init(struct pcmcia_init *init)
68 {
69         // power up
70         writel(0x00020002, GPIO2_OUTPUT); // GPIO_201 CF_PWR
71         return 1; // one slot
72 }
73
74 static int hydrogen3_pcmcia_shutdown(void)
75 {
76         // power down
77         writel(0x00020000, GPIO2_OUTPUT); // GPIO_201 CF_PWR
78         return 0; 
79 }
80
81 static int 
82 hydrogen3_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state)
83 {
84         u32 inserted;
85         inserted = (readl(SYS_PINSTATERD) & (1<<22)) ? 0 : 1; // GPIO_22 is CF_DETECT
86
87         state->ready = 0;
88         state->vs_Xv = 0;
89         state->vs_3v = 0;
90         state->detect = 0;
91
92         if (inserted)
93         {
94                 state->vs_3v=1;
95                 state->detect = 1;
96                 state->ready = 1;
97         }
98
99         state->bvd1=1;
100         state->bvd2=1;
101         state->wrprot=0; 
102         return 1;
103 }
104
105
106 static int hydrogen3_pcmcia_get_irq_info(struct pcmcia_irq_info *info)
107 {
108
109         if(info->sock > PCMCIA_MAX_SOCK) return -1;
110
111         if(info->sock == 0)
112                 info->irq = AU1000_GPIO_21;
113         else 
114                 info->irq = -1;
115
116         return 0;
117 }
118
119
120 static int 
121 hydrogen3_pcmcia_configure_socket(const struct pcmcia_configure *configure)
122 {
123         if(configure->sock > PCMCIA_MAX_SOCK) return -1;
124
125         au_sync_delay(300);
126
127         if (!configure->reset) {
128                 // de-assert reset
129                 writel(0x00010000, GPIO2_OUTPUT); // GPIO_200 CF_RESET
130                 au_sync_delay(100);
131         }
132         else {
133                 // assert reset
134                 writel(0x00010001, GPIO2_OUTPUT); // GPIO_200 CF_RESET
135                 au_sync_delay(300);
136         }
137         return 0;
138 }
139
140 struct pcmcia_low_level au1x00_pcmcia_ops = { 
141         hydrogen3_pcmcia_init,
142         hydrogen3_pcmcia_shutdown,
143         hydrogen3_pcmcia_socket_state,
144         hydrogen3_pcmcia_get_irq_info,
145         hydrogen3_pcmcia_configure_socket
146 };
147
148 struct pcmcia_low_level *
149 hydrogen3_get_pcmcia_ops(void)
150 {
151         return &au1x00_pcmcia_ops;
152 };