patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / pcmcia / sa1100_generic.c
1 /*======================================================================
2
3     Device driver for the PCMCIA control functionality of StrongARM
4     SA-1100 microprocessors.
5
6     The contents of this file are subject to the Mozilla Public
7     License Version 1.1 (the "License"); you may not use this file
8     except in compliance with the License. You may obtain a copy of
9     the License at http://www.mozilla.org/MPL/
10
11     Software distributed under the License is distributed on an "AS
12     IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13     implied. See the License for the specific language governing
14     rights and limitations under the License.
15
16     The initial developer of the original code is John G. Dorsey
17     <john+@cs.cmu.edu>.  Portions created by John G. Dorsey are
18     Copyright (C) 1999 John G. Dorsey.  All Rights Reserved.
19
20     Alternatively, the contents of this file may be used under the
21     terms of the GNU Public License version 2 (the "GPL"), in which
22     case the provisions of the GPL are applicable instead of the
23     above.  If you wish to allow the use of your version of this file
24     only under the terms of the GPL and not to allow others to use
25     your version of this file under the MPL, indicate your decision
26     by deleting the provisions above and replace them with the notice
27     and other provisions required by the GPL.  If you do not delete
28     the provisions above, a recipient may use your version of this
29     file under either the MPL or the GPL.
30     
31 ======================================================================*/
32 /*
33  * Please see linux/Documentation/arm/SA1100/PCMCIA for more information
34  * on the low-level kernel interface.
35  */
36
37 #include <linux/module.h>
38 #include <linux/init.h>
39 #include <linux/config.h>
40
41 #include <pcmcia/version.h>
42 #include <pcmcia/cs_types.h>
43 #include <pcmcia/cs.h>
44 #include <pcmcia/ss.h>
45
46 #include "sa1100_generic.h"
47
48 static int (*sa11x0_pcmcia_hw_init[])(struct device *dev) = {
49 #ifdef CONFIG_SA1100_ASSABET
50         pcmcia_assabet_init,
51 #endif
52 #ifdef CONFIG_SA1100_CERF
53         pcmcia_cerf_init,
54 #endif
55 #ifdef CONFIG_SA1100_FLEXANET
56         pcmcia_flexanet_init,
57 #endif
58 #ifdef CONFIG_SA1100_FREEBIRD
59         pcmcia_freebird_init,
60 #endif
61 #ifdef CONFIG_SA1100_GRAPHICSCLIENT
62         pcmcia_gcplus_init,
63 #endif
64 #ifdef CONFIG_SA1100_H3600
65         pcmcia_h3600_init,
66 #endif
67 #ifdef CONFIG_SA1100_PANGOLIN
68         pcmcia_pangolin_init,
69 #endif
70 #ifdef CONFIG_SA1100_SHANNON
71         pcmcia_shannon_init,
72 #endif
73 #ifdef CONFIG_SA1100_SIMPAD
74         pcmcia_simpad_init,
75 #endif
76 #ifdef CONFIG_SA1100_STORK
77         pcmcia_stork_init,
78 #endif
79 #ifdef CONFIG_SA1100_TRIZEPS
80         pcmcia_trizeps_init,
81 #endif
82 #ifdef CONFIG_SA1100_YOPY
83         pcmcia_yopy_init,
84 #endif
85 };
86
87 static int sa11x0_drv_pcmcia_probe(struct device *dev)
88 {
89         int i, ret = -ENODEV;
90
91         /*
92          * Initialise any "on-board" PCMCIA sockets.
93          */
94         for (i = 0; i < ARRAY_SIZE(sa11x0_pcmcia_hw_init); i++) {
95                 ret = sa11x0_pcmcia_hw_init[i](dev);
96                 if (ret == 0)
97                         break;
98         }
99
100         return ret;
101 }
102
103 static int sa11x0_drv_pcmcia_suspend(struct device *dev, u32 state, u32 level)
104 {
105         int ret = 0;
106         if (level == SUSPEND_SAVE_STATE)
107                 ret = pcmcia_socket_dev_suspend(dev, state);
108         return ret;
109 }
110
111 static int sa11x0_drv_pcmcia_resume(struct device *dev, u32 level)
112 {
113         int ret = 0;
114         if (level == RESUME_RESTORE_STATE)
115                 ret = pcmcia_socket_dev_resume(dev);
116         return ret;
117 }
118
119 static struct device_driver sa11x0_pcmcia_driver = {
120         .probe          = sa11x0_drv_pcmcia_probe,
121         .remove         = soc_common_drv_pcmcia_remove,
122         .name           = "sa11x0-pcmcia",
123         .bus            = &platform_bus_type,
124         .suspend        = sa11x0_drv_pcmcia_suspend,
125         .resume         = sa11x0_drv_pcmcia_resume,
126 };
127
128 /* sa11x0_pcmcia_init()
129  * ^^^^^^^^^^^^^^^^^^^^
130  *
131  * This routine performs low-level PCMCIA initialization and then
132  * registers this socket driver with Card Services.
133  *
134  * Returns: 0 on success, -ve error code on failure
135  */
136 static int __init sa11x0_pcmcia_init(void)
137 {
138         return driver_register(&sa11x0_pcmcia_driver);
139 }
140
141 /* sa11x0_pcmcia_exit()
142  * ^^^^^^^^^^^^^^^^^^^^
143  * Invokes the low-level kernel service to free IRQs associated with this
144  * socket controller and reset GPIO edge detection.
145  */
146 static void __exit sa11x0_pcmcia_exit(void)
147 {
148         driver_unregister(&sa11x0_pcmcia_driver);
149 }
150
151 MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>");
152 MODULE_DESCRIPTION("Linux PCMCIA Card Services: SA-11x0 Socket Controller");
153 MODULE_LICENSE("Dual MPL/GPL");
154
155 module_init(sa11x0_pcmcia_init);
156 module_exit(sa11x0_pcmcia_exit);