blob: 2d0e997515308d931bb683d5f58ae8bd624ed5c3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*======================================================================
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#include <linux/module.h>
34#include <linux/init.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010035#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include <pcmcia/cs_types.h>
38#include <pcmcia/cs.h>
39#include <pcmcia/ss.h>
40
Pavel Machek77bb86a2005-10-30 23:39:02 +000041#include <asm/hardware/scoop.h>
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include "sa1100_generic.h"
44
Pavel Machek77bb86a2005-10-30 23:39:02 +000045int __init pcmcia_collie_init(struct device *dev);
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047static int (*sa11x0_pcmcia_hw_init[])(struct device *dev) = {
48#ifdef CONFIG_SA1100_ASSABET
49 pcmcia_assabet_init,
50#endif
51#ifdef CONFIG_SA1100_CERF
52 pcmcia_cerf_init,
53#endif
54#ifdef CONFIG_SA1100_H3600
55 pcmcia_h3600_init,
56#endif
57#ifdef CONFIG_SA1100_SHANNON
58 pcmcia_shannon_init,
59#endif
60#ifdef CONFIG_SA1100_SIMPAD
61 pcmcia_simpad_init,
62#endif
Pavel Machek77bb86a2005-10-30 23:39:02 +000063#ifdef CONFIG_SA1100_COLLIE
64 pcmcia_collie_init,
65#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070066};
67
Ming Lei7a192ec2009-02-06 23:40:12 +080068static int sa11x0_drv_pcmcia_probe(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070069{
70 int i, ret = -ENODEV;
71
72 /*
73 * Initialise any "on-board" PCMCIA sockets.
74 */
75 for (i = 0; i < ARRAY_SIZE(sa11x0_pcmcia_hw_init); i++) {
Ming Lei7a192ec2009-02-06 23:40:12 +080076 ret = sa11x0_pcmcia_hw_init[i](&dev->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 if (ret == 0)
78 break;
79 }
80
81 return ret;
82}
83
Ming Lei7a192ec2009-02-06 23:40:12 +080084static int sa11x0_drv_pcmcia_remove(struct platform_device *dev)
85{
86 return soc_common_drv_pcmcia_remove(&dev->dev);
87}
88
89static int sa11x0_drv_pcmcia_suspend(struct platform_device *dev,
90 pm_message_t state)
91{
Rafael J. Wysocki827b4642009-09-29 00:10:41 +020092 return pcmcia_socket_dev_suspend(&dev->dev);
Ming Lei7a192ec2009-02-06 23:40:12 +080093}
94
95static int sa11x0_drv_pcmcia_resume(struct platform_device *dev)
96{
97 return pcmcia_socket_dev_resume(&dev->dev);
98}
99
100static struct platform_driver sa11x0_pcmcia_driver = {
101 .driver = {
102 .name = "sa11x0-pcmcia",
103 .owner = THIS_MODULE,
104 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 .probe = sa11x0_drv_pcmcia_probe,
Ming Lei7a192ec2009-02-06 23:40:12 +0800106 .remove = sa11x0_drv_pcmcia_remove,
107 .suspend = sa11x0_drv_pcmcia_suspend,
108 .resume = sa11x0_drv_pcmcia_resume,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109};
110
111/* sa11x0_pcmcia_init()
112 * ^^^^^^^^^^^^^^^^^^^^
113 *
114 * This routine performs low-level PCMCIA initialization and then
115 * registers this socket driver with Card Services.
116 *
117 * Returns: 0 on success, -ve error code on failure
118 */
119static int __init sa11x0_pcmcia_init(void)
120{
Ming Lei7a192ec2009-02-06 23:40:12 +0800121 return platform_driver_register(&sa11x0_pcmcia_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122}
123
124/* sa11x0_pcmcia_exit()
125 * ^^^^^^^^^^^^^^^^^^^^
126 * Invokes the low-level kernel service to free IRQs associated with this
127 * socket controller and reset GPIO edge detection.
128 */
129static void __exit sa11x0_pcmcia_exit(void)
130{
Ming Lei7a192ec2009-02-06 23:40:12 +0800131 platform_driver_unregister(&sa11x0_pcmcia_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132}
133
134MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>");
135MODULE_DESCRIPTION("Linux PCMCIA Card Services: SA-11x0 Socket Controller");
136MODULE_LICENSE("Dual MPL/GPL");
137
Richard Purdief36598a2005-09-03 19:39:25 +0100138fs_initcall(sa11x0_pcmcia_init);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139module_exit(sa11x0_pcmcia_exit);