2005-04-16 22:20:36 +00:00
|
|
|
/*======================================================================
|
|
|
|
|
|
|
|
Device driver for the PCMCIA control functionality of StrongARM
|
|
|
|
SA-1100 microprocessors.
|
|
|
|
|
|
|
|
The contents of this file are subject to the Mozilla Public
|
|
|
|
License Version 1.1 (the "License"); you may not use this file
|
|
|
|
except in compliance with the License. You may obtain a copy of
|
|
|
|
the License at http://www.mozilla.org/MPL/
|
|
|
|
|
|
|
|
Software distributed under the License is distributed on an "AS
|
|
|
|
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
implied. See the License for the specific language governing
|
|
|
|
rights and limitations under the License.
|
|
|
|
|
|
|
|
The initial developer of the original code is John G. Dorsey
|
|
|
|
<john+@cs.cmu.edu>. Portions created by John G. Dorsey are
|
|
|
|
Copyright (C) 1999 John G. Dorsey. All Rights Reserved.
|
|
|
|
|
|
|
|
Alternatively, the contents of this file may be used under the
|
|
|
|
terms of the GNU Public License version 2 (the "GPL"), in which
|
|
|
|
case the provisions of the GPL are applicable instead of the
|
|
|
|
above. If you wish to allow the use of your version of this file
|
|
|
|
only under the terms of the GPL and not to allow others to use
|
|
|
|
your version of this file under the MPL, indicate your decision
|
|
|
|
by deleting the provisions above and replace them with the notice
|
|
|
|
and other provisions required by the GPL. If you do not delete
|
|
|
|
the provisions above, a recipient may use your version of this
|
|
|
|
file under either the MPL or the GPL.
|
|
|
|
|
|
|
|
======================================================================*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
2016-08-31 07:49:47 +00:00
|
|
|
#include <linux/gpio/consumer.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/init.h>
|
2016-08-31 07:49:47 +00:00
|
|
|
#include <linux/regulator/consumer.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2005-10-29 18:07:23 +00:00
|
|
|
#include <linux/platform_device.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <pcmcia/ss.h>
|
|
|
|
|
2005-10-30 23:39:02 +00:00
|
|
|
#include <asm/hardware/scoop.h>
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "sa1100_generic.h"
|
|
|
|
|
2016-08-31 07:49:47 +00:00
|
|
|
static const char *sa11x0_cf_gpio_names[] = {
|
|
|
|
[SOC_STAT_CD] = "detect",
|
|
|
|
[SOC_STAT_BVD1] = "bvd1",
|
|
|
|
[SOC_STAT_BVD2] = "bvd2",
|
|
|
|
[SOC_STAT_RDY] = "ready",
|
|
|
|
};
|
|
|
|
|
|
|
|
static int sa11x0_cf_hw_init(struct soc_pcmcia_socket *skt)
|
|
|
|
{
|
|
|
|
struct device *dev = skt->socket.dev.parent;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
skt->gpio_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
|
|
|
|
if (IS_ERR(skt->gpio_reset))
|
|
|
|
return PTR_ERR(skt->gpio_reset);
|
|
|
|
|
|
|
|
skt->gpio_bus_enable = devm_gpiod_get_optional(dev, "bus-enable",
|
|
|
|
GPIOD_OUT_HIGH);
|
|
|
|
if (IS_ERR(skt->gpio_bus_enable))
|
|
|
|
return PTR_ERR(skt->gpio_bus_enable);
|
|
|
|
|
|
|
|
skt->vcc.reg = devm_regulator_get_optional(dev, "vcc");
|
|
|
|
if (IS_ERR(skt->vcc.reg))
|
|
|
|
return PTR_ERR(skt->vcc.reg);
|
|
|
|
|
|
|
|
if (!skt->vcc.reg)
|
|
|
|
dev_warn(dev,
|
|
|
|
"no Vcc regulator provided, ignoring Vcc controls\n");
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(sa11x0_cf_gpio_names); i++) {
|
|
|
|
skt->stat[i].name = sa11x0_cf_gpio_names[i];
|
|
|
|
skt->stat[i].desc = devm_gpiod_get_optional(dev,
|
|
|
|
sa11x0_cf_gpio_names[i], GPIOD_IN);
|
|
|
|
if (IS_ERR(skt->stat[i].desc))
|
|
|
|
return PTR_ERR(skt->stat[i].desc);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sa11x0_cf_configure_socket(struct soc_pcmcia_socket *skt,
|
|
|
|
const socket_state_t *state)
|
|
|
|
{
|
|
|
|
return soc_pcmcia_regulator_set(skt, &skt->vcc, state->Vcc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pcmcia_low_level sa11x0_cf_ops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.hw_init = sa11x0_cf_hw_init,
|
|
|
|
.socket_state = soc_common_cf_socket_state,
|
|
|
|
.configure_socket = sa11x0_cf_configure_socket,
|
|
|
|
};
|
|
|
|
|
2005-10-30 23:39:02 +00:00
|
|
|
int __init pcmcia_collie_init(struct device *dev);
|
|
|
|
|
2016-08-31 07:49:47 +00:00
|
|
|
static int (*sa11x0_pcmcia_legacy_hw_init[])(struct device *dev) = {
|
ARM: sa1100: remove unused board files
The Cerf, H3100, Badge4, Hackkit, LART, NanoEngine, PLEB, Shannon and
Simpad machines were all marked as unused as there are no known users
left. Remove all of these, along with references to them in defconfig
files and drivers.
Four machines remain now: Assabet, Collie (Zaurus SL5500), iPAQ H3600
and Jornada 720, each of which had one person still using them, with
Collie also being supported in Qemu.
Cc: Peter Chubb <peter.chubb@unsw.edu.au>
Cc: Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Lee Jones <lee@kernel.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-09-29 13:26:06 +00:00
|
|
|
#ifdef CONFIG_SA1100_H3600
|
2005-04-16 22:20:36 +00:00
|
|
|
pcmcia_h3600_init,
|
|
|
|
#endif
|
2005-10-30 23:39:02 +00:00
|
|
|
#ifdef CONFIG_SA1100_COLLIE
|
|
|
|
pcmcia_collie_init,
|
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2016-08-31 07:49:47 +00:00
|
|
|
static int sa11x0_drv_pcmcia_legacy_probe(struct platform_device *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int i, ret = -ENODEV;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialise any "on-board" PCMCIA sockets.
|
|
|
|
*/
|
2016-08-31 07:49:47 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(sa11x0_pcmcia_legacy_hw_init); i++) {
|
|
|
|
ret = sa11x0_pcmcia_legacy_hw_init[i](&dev->dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ret == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-07-14 21:45:34 +00:00
|
|
|
static void sa11x0_drv_pcmcia_legacy_remove(struct platform_device *dev)
|
2009-02-06 15:40:12 +00:00
|
|
|
{
|
2009-03-26 22:21:18 +00:00
|
|
|
struct skt_dev_info *sinfo = platform_get_drvdata(dev);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
platform_set_drvdata(dev, NULL);
|
|
|
|
|
|
|
|
for (i = 0; i < sinfo->nskt; i++)
|
|
|
|
soc_pcmcia_remove_one(&sinfo->skt[i]);
|
2016-08-31 07:49:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int sa11x0_drv_pcmcia_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct soc_pcmcia_socket *skt;
|
|
|
|
struct device *dev = &pdev->dev;
|
|
|
|
|
|
|
|
if (pdev->id == -1)
|
|
|
|
return sa11x0_drv_pcmcia_legacy_probe(pdev);
|
|
|
|
|
|
|
|
skt = devm_kzalloc(dev, sizeof(*skt), GFP_KERNEL);
|
|
|
|
if (!skt)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
platform_set_drvdata(pdev, skt);
|
|
|
|
|
|
|
|
skt->nr = pdev->id;
|
|
|
|
skt->clk = devm_clk_get(dev, NULL);
|
|
|
|
if (IS_ERR(skt->clk))
|
|
|
|
return PTR_ERR(skt->clk);
|
|
|
|
|
|
|
|
sa11xx_drv_pcmcia_ops(&sa11x0_cf_ops);
|
|
|
|
soc_pcmcia_init_one(skt, &sa11x0_cf_ops, dev);
|
|
|
|
|
|
|
|
return sa11xx_drv_pcmcia_add_one(skt);
|
|
|
|
}
|
|
|
|
|
2023-12-08 16:08:11 +00:00
|
|
|
static void sa11x0_drv_pcmcia_remove(struct platform_device *dev)
|
2016-08-31 07:49:47 +00:00
|
|
|
{
|
|
|
|
struct soc_pcmcia_socket *skt;
|
|
|
|
|
2022-07-14 21:45:34 +00:00
|
|
|
if (dev->id == -1) {
|
|
|
|
sa11x0_drv_pcmcia_legacy_remove(dev);
|
2023-12-08 16:08:11 +00:00
|
|
|
return;
|
2022-07-14 21:45:34 +00:00
|
|
|
}
|
2016-08-31 07:49:47 +00:00
|
|
|
|
|
|
|
skt = platform_get_drvdata(dev);
|
|
|
|
|
|
|
|
soc_pcmcia_remove_one(skt);
|
2009-02-06 15:40:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver sa11x0_pcmcia_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "sa11x0-pcmcia",
|
|
|
|
},
|
2005-04-16 22:20:36 +00:00
|
|
|
.probe = sa11x0_drv_pcmcia_probe,
|
2024-12-01 23:12:43 +00:00
|
|
|
.remove = sa11x0_drv_pcmcia_remove,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* sa11x0_pcmcia_init()
|
|
|
|
* ^^^^^^^^^^^^^^^^^^^^
|
|
|
|
*
|
|
|
|
* This routine performs low-level PCMCIA initialization and then
|
|
|
|
* registers this socket driver with Card Services.
|
|
|
|
*
|
|
|
|
* Returns: 0 on success, -ve error code on failure
|
|
|
|
*/
|
|
|
|
static int __init sa11x0_pcmcia_init(void)
|
|
|
|
{
|
2009-02-06 15:40:12 +00:00
|
|
|
return platform_driver_register(&sa11x0_pcmcia_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sa11x0_pcmcia_exit()
|
|
|
|
* ^^^^^^^^^^^^^^^^^^^^
|
|
|
|
* Invokes the low-level kernel service to free IRQs associated with this
|
|
|
|
* socket controller and reset GPIO edge detection.
|
|
|
|
*/
|
|
|
|
static void __exit sa11x0_pcmcia_exit(void)
|
|
|
|
{
|
2009-02-06 15:40:12 +00:00
|
|
|
platform_driver_unregister(&sa11x0_pcmcia_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>");
|
|
|
|
MODULE_DESCRIPTION("Linux PCMCIA Card Services: SA-11x0 Socket Controller");
|
|
|
|
MODULE_LICENSE("Dual MPL/GPL");
|
|
|
|
|
2005-09-03 18:39:25 +00:00
|
|
|
fs_initcall(sa11x0_pcmcia_init);
|
2005-04-16 22:20:36 +00:00
|
|
|
module_exit(sa11x0_pcmcia_exit);
|