Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | #include <linux/module.h> |
| 34 | #include <linux/init.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 35 | #include <linux/slab.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 36 | #include <linux/platform_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #include <pcmcia/ss.h> |
| 39 | |
Pavel Machek | 77bb86a | 2005-10-30 23:39:02 +0000 | [diff] [blame] | 40 | #include <asm/hardware/scoop.h> |
| 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include "sa1100_generic.h" |
| 43 | |
Pavel Machek | 77bb86a | 2005-10-30 23:39:02 +0000 | [diff] [blame] | 44 | int __init pcmcia_collie_init(struct device *dev); |
| 45 | |
Uwe Kleine-König | 37fac4b | 2011-04-06 16:31:02 +0200 | [diff] [blame] | 46 | static int (*sa11x0_pcmcia_hw_init[])(struct device *dev) __devinitdata = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #ifdef CONFIG_SA1100_ASSABET |
| 48 | pcmcia_assabet_init, |
| 49 | #endif |
| 50 | #ifdef CONFIG_SA1100_CERF |
| 51 | pcmcia_cerf_init, |
| 52 | #endif |
Dmitry Artamonow | e7435f8 | 2009-11-27 12:13:47 +0100 | [diff] [blame] | 53 | #if defined(CONFIG_SA1100_H3100) || defined(CONFIG_SA1100_H3600) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | pcmcia_h3600_init, |
| 55 | #endif |
Marcelo Roberto Jimenez | fa87672 | 2010-10-18 22:41:29 +0100 | [diff] [blame] | 56 | #ifdef CONFIG_SA1100_NANOENGINE |
| 57 | pcmcia_nanoengine_init, |
| 58 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | #ifdef CONFIG_SA1100_SHANNON |
| 60 | pcmcia_shannon_init, |
| 61 | #endif |
| 62 | #ifdef CONFIG_SA1100_SIMPAD |
| 63 | pcmcia_simpad_init, |
| 64 | #endif |
Pavel Machek | 77bb86a | 2005-10-30 23:39:02 +0000 | [diff] [blame] | 65 | #ifdef CONFIG_SA1100_COLLIE |
| 66 | pcmcia_collie_init, |
| 67 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
Uwe Kleine-König | 5b85e04 | 2010-11-04 10:46:14 +0100 | [diff] [blame] | 70 | static int __devinit sa11x0_drv_pcmcia_probe(struct platform_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
| 72 | int i, ret = -ENODEV; |
| 73 | |
| 74 | /* |
| 75 | * Initialise any "on-board" PCMCIA sockets. |
| 76 | */ |
| 77 | for (i = 0; i < ARRAY_SIZE(sa11x0_pcmcia_hw_init); i++) { |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 78 | ret = sa11x0_pcmcia_hw_init[i](&dev->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | if (ret == 0) |
| 80 | break; |
| 81 | } |
| 82 | |
| 83 | return ret; |
| 84 | } |
| 85 | |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 86 | static int sa11x0_drv_pcmcia_remove(struct platform_device *dev) |
| 87 | { |
Russell King - ARM Linux | be85458 | 2009-03-26 22:21:18 +0000 | [diff] [blame] | 88 | struct skt_dev_info *sinfo = platform_get_drvdata(dev); |
| 89 | int i; |
| 90 | |
| 91 | platform_set_drvdata(dev, NULL); |
| 92 | |
| 93 | for (i = 0; i < sinfo->nskt; i++) |
| 94 | soc_pcmcia_remove_one(&sinfo->skt[i]); |
| 95 | |
| 96 | kfree(sinfo); |
| 97 | return 0; |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 98 | } |
| 99 | |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 100 | static struct platform_driver sa11x0_pcmcia_driver = { |
| 101 | .driver = { |
| 102 | .name = "sa11x0-pcmcia", |
| 103 | .owner = THIS_MODULE, |
| 104 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | .probe = sa11x0_drv_pcmcia_probe, |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 106 | .remove = sa11x0_drv_pcmcia_remove, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | /* sa11x0_pcmcia_init() |
| 110 | * ^^^^^^^^^^^^^^^^^^^^ |
| 111 | * |
| 112 | * This routine performs low-level PCMCIA initialization and then |
| 113 | * registers this socket driver with Card Services. |
| 114 | * |
| 115 | * Returns: 0 on success, -ve error code on failure |
| 116 | */ |
| 117 | static int __init sa11x0_pcmcia_init(void) |
| 118 | { |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 119 | return platform_driver_register(&sa11x0_pcmcia_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | /* sa11x0_pcmcia_exit() |
| 123 | * ^^^^^^^^^^^^^^^^^^^^ |
| 124 | * Invokes the low-level kernel service to free IRQs associated with this |
| 125 | * socket controller and reset GPIO edge detection. |
| 126 | */ |
| 127 | static void __exit sa11x0_pcmcia_exit(void) |
| 128 | { |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 129 | platform_driver_unregister(&sa11x0_pcmcia_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>"); |
| 133 | MODULE_DESCRIPTION("Linux PCMCIA Card Services: SA-11x0 Socket Controller"); |
| 134 | MODULE_LICENSE("Dual MPL/GPL"); |
| 135 | |
Richard Purdie | f36598a | 2005-09-03 19:39:25 +0100 | [diff] [blame] | 136 | fs_initcall(sa11x0_pcmcia_init); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | module_exit(sa11x0_pcmcia_exit); |