2006-02-21 03:56:52 -07:00
|
|
|
/*
|
|
|
|
* at91_cf.c -- AT91 CompactFlash controller driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 David Brownell
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/interrupt.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 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2012-01-09 18:37:25 -07:00
|
|
|
#include <linux/gpio.h>
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
#include <pcmcia/ss.h>
|
|
|
|
|
2008-08-05 09:14:15 -06:00
|
|
|
#include <mach/hardware.h>
|
2006-02-21 03:56:52 -07:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/sizes.h>
|
|
|
|
|
2008-08-05 09:14:15 -06:00
|
|
|
#include <mach/board.h>
|
|
|
|
#include <mach/at91rm9200_mc.h>
|
2012-02-12 21:58:53 -07:00
|
|
|
#include <mach/at91_ramc.h>
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A0..A10 work in each range; A23 indicates I/O space; A25 is CFRNW;
|
|
|
|
* some other bit in {A24,A22..A11} is nREG to flag memory access
|
|
|
|
* (vs attributes). So more than 2KB/region would just be waste.
|
2006-11-06 06:56:07 -07:00
|
|
|
* Note: These are offsets from the physical base address.
|
2006-02-21 03:56:52 -07:00
|
|
|
*/
|
2006-11-06 06:56:07 -07:00
|
|
|
#define CF_ATTR_PHYS (0)
|
|
|
|
#define CF_IO_PHYS (1 << 23)
|
|
|
|
#define CF_MEM_PHYS (0x017ff800)
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
static const char driver_name[] = "at91_cf";
|
|
|
|
|
|
|
|
struct at91_cf_socket {
|
|
|
|
struct pcmcia_socket socket;
|
|
|
|
|
|
|
|
unsigned present:1;
|
|
|
|
|
|
|
|
struct platform_device *pdev;
|
|
|
|
struct at91_cf_data *board;
|
2006-11-06 06:56:07 -07:00
|
|
|
|
|
|
|
unsigned long phys_baseaddr;
|
2006-02-21 03:56:52 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline int at91_cf_present(struct at91_cf_socket *cf)
|
|
|
|
{
|
2008-02-04 23:27:42 -07:00
|
|
|
return !gpio_get_value(cf->board->det_pin);
|
2006-02-21 03:56:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
static int at91_cf_ss_init(struct pcmcia_socket *s)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 07:55:46 -06:00
|
|
|
static irqreturn_t at91_cf_irq(int irq, void *_cf)
|
2006-02-21 03:56:52 -07:00
|
|
|
{
|
2006-10-06 13:00:58 -06:00
|
|
|
struct at91_cf_socket *cf = _cf;
|
2006-02-21 03:56:52 -07:00
|
|
|
|
2012-01-09 18:37:25 -07:00
|
|
|
if (irq == gpio_to_irq(cf->board->det_pin)) {
|
2006-02-21 03:56:52 -07:00
|
|
|
unsigned present = at91_cf_present(cf);
|
|
|
|
|
|
|
|
/* kick pccard as needed */
|
|
|
|
if (present != cf->present) {
|
|
|
|
cf->present = present;
|
2006-04-14 19:05:38 -06:00
|
|
|
pr_debug("%s: card %s\n", driver_name,
|
|
|
|
present ? "present" : "gone");
|
2006-02-21 03:56:52 -07:00
|
|
|
pcmcia_parse_events(&cf->socket, SS_DETECT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int at91_cf_get_status(struct pcmcia_socket *s, u_int *sp)
|
|
|
|
{
|
|
|
|
struct at91_cf_socket *cf;
|
|
|
|
|
|
|
|
if (!sp)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
cf = container_of(s, struct at91_cf_socket, socket);
|
|
|
|
|
2006-04-14 19:05:38 -06:00
|
|
|
/* NOTE: CF is always 3VCARD */
|
2006-02-21 03:56:52 -07:00
|
|
|
if (at91_cf_present(cf)) {
|
2012-01-09 18:37:25 -07:00
|
|
|
int rdy = gpio_is_valid(cf->board->irq_pin); /* RDY/nIRQ */
|
|
|
|
int vcc = gpio_is_valid(cf->board->vcc_pin);
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
*sp = SS_DETECT | SS_3VCARD;
|
2008-02-04 23:27:42 -07:00
|
|
|
if (!rdy || gpio_get_value(rdy))
|
2006-02-21 03:56:52 -07:00
|
|
|
*sp |= SS_READY;
|
2008-02-04 23:27:42 -07:00
|
|
|
if (!vcc || gpio_get_value(vcc))
|
2006-02-21 03:56:52 -07:00
|
|
|
*sp |= SS_POWERON;
|
|
|
|
} else
|
|
|
|
*sp = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-14 19:05:38 -06:00
|
|
|
static int
|
|
|
|
at91_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s)
|
2006-02-21 03:56:52 -07:00
|
|
|
{
|
|
|
|
struct at91_cf_socket *cf;
|
|
|
|
|
|
|
|
cf = container_of(sock, struct at91_cf_socket, socket);
|
|
|
|
|
|
|
|
/* switch Vcc if needed and possible */
|
2012-01-09 18:37:25 -07:00
|
|
|
if (gpio_is_valid(cf->board->vcc_pin)) {
|
2006-02-21 03:56:52 -07:00
|
|
|
switch (s->Vcc) {
|
|
|
|
case 0:
|
2008-02-04 23:27:42 -07:00
|
|
|
gpio_set_value(cf->board->vcc_pin, 0);
|
2006-02-21 03:56:52 -07:00
|
|
|
break;
|
|
|
|
case 33:
|
2008-02-04 23:27:42 -07:00
|
|
|
gpio_set_value(cf->board->vcc_pin, 1);
|
2006-02-21 03:56:52 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* toggle reset if needed */
|
2008-02-04 23:27:42 -07:00
|
|
|
gpio_set_value(cf->board->rst_pin, s->flags & SS_RESET);
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
pr_debug("%s: Vcc %d, io_irq %d, flags %04x csc %04x\n",
|
|
|
|
driver_name, s->Vcc, s->io_irq, s->flags, s->csc_mask);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int at91_cf_ss_suspend(struct pcmcia_socket *s)
|
|
|
|
{
|
|
|
|
return at91_cf_set_socket(s, &dead_socket);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we already mapped the I/O region */
|
|
|
|
static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
|
|
|
|
{
|
|
|
|
struct at91_cf_socket *cf;
|
|
|
|
u32 csr;
|
|
|
|
|
|
|
|
cf = container_of(s, struct at91_cf_socket, socket);
|
|
|
|
io->flags &= (MAP_ACTIVE | MAP_16BIT | MAP_AUTOSZ);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use 16 bit accesses unless/until we need 8-bit i/o space.
|
|
|
|
*/
|
2012-02-12 21:58:53 -07:00
|
|
|
csr = at91_ramc_read(0, AT91_SMC_CSR(cf->board->chipselect)) & ~AT91_SMC_DBW;
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: this CF controller ignores IOIS16, so we can't really do
|
|
|
|
* MAP_AUTOSZ. The 16bit mode allows single byte access on either
|
|
|
|
* D0-D7 (even addr) or D8-D15 (odd), so it's close enough for many
|
|
|
|
* purposes (and handles ide-cs).
|
|
|
|
*
|
|
|
|
* The 8bit mode is needed for odd byte access on D0-D7. It seems
|
|
|
|
* some cards only like that way to get at the odd byte, despite
|
|
|
|
* CF 3.0 spec table 35 also giving the D8-D15 option.
|
|
|
|
*/
|
2006-11-06 06:56:07 -07:00
|
|
|
if (!(io->flags & (MAP_16BIT | MAP_AUTOSZ))) {
|
2006-02-21 03:56:52 -07:00
|
|
|
csr |= AT91_SMC_DBW_8;
|
|
|
|
pr_debug("%s: 8bit i/o bus\n", driver_name);
|
|
|
|
} else {
|
|
|
|
csr |= AT91_SMC_DBW_16;
|
|
|
|
pr_debug("%s: 16bit i/o bus\n", driver_name);
|
|
|
|
}
|
2012-02-12 21:58:53 -07:00
|
|
|
at91_ramc_write(0, AT91_SMC_CSR(cf->board->chipselect), csr);
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
io->start = cf->socket.io_offset;
|
|
|
|
io->stop = io->start + SZ_2K - 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* pcmcia layer maps/unmaps mem regions */
|
2006-04-14 19:05:38 -06:00
|
|
|
static int
|
|
|
|
at91_cf_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *map)
|
2006-02-21 03:56:52 -07:00
|
|
|
{
|
|
|
|
struct at91_cf_socket *cf;
|
|
|
|
|
|
|
|
if (map->card_start)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
cf = container_of(s, struct at91_cf_socket, socket);
|
|
|
|
|
2006-11-06 06:56:07 -07:00
|
|
|
map->flags &= (MAP_ACTIVE | MAP_ATTRIB | MAP_16BIT);
|
2006-02-21 03:56:52 -07:00
|
|
|
if (map->flags & MAP_ATTRIB)
|
2006-11-06 06:56:07 -07:00
|
|
|
map->static_start = cf->phys_baseaddr + CF_ATTR_PHYS;
|
2006-02-21 03:56:52 -07:00
|
|
|
else
|
2006-11-06 06:56:07 -07:00
|
|
|
map->static_start = cf->phys_baseaddr + CF_MEM_PHYS;
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pccard_operations at91_cf_ops = {
|
|
|
|
.init = at91_cf_ss_init,
|
|
|
|
.suspend = at91_cf_ss_suspend,
|
|
|
|
.get_status = at91_cf_get_status,
|
|
|
|
.set_socket = at91_cf_set_socket,
|
|
|
|
.set_io_map = at91_cf_set_io_map,
|
|
|
|
.set_mem_map = at91_cf_set_mem_map,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
2006-04-19 07:37:48 -06:00
|
|
|
static int __init at91_cf_probe(struct platform_device *pdev)
|
2006-02-21 03:56:52 -07:00
|
|
|
{
|
|
|
|
struct at91_cf_socket *cf;
|
2006-04-19 07:37:48 -06:00
|
|
|
struct at91_cf_data *board = pdev->dev.platform_data;
|
2006-04-14 19:05:38 -06:00
|
|
|
struct resource *io;
|
2006-02-21 03:56:52 -07:00
|
|
|
int status;
|
|
|
|
|
2012-01-09 18:37:25 -07:00
|
|
|
if (!board || !gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin))
|
2006-02-21 03:56:52 -07:00
|
|
|
return -ENODEV;
|
|
|
|
|
2006-04-14 19:05:38 -06:00
|
|
|
io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
if (!io)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2006-12-13 01:34:52 -07:00
|
|
|
cf = kzalloc(sizeof *cf, GFP_KERNEL);
|
2006-02-21 03:56:52 -07:00
|
|
|
if (!cf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
cf->board = board;
|
|
|
|
cf->pdev = pdev;
|
2006-11-06 06:56:07 -07:00
|
|
|
cf->phys_baseaddr = io->start;
|
2006-04-19 07:37:48 -06:00
|
|
|
platform_set_drvdata(pdev, cf);
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
/* must be a GPIO; ergo must trigger on both edges */
|
2008-02-04 23:27:42 -07:00
|
|
|
status = gpio_request(board->det_pin, "cf_det");
|
2006-02-21 03:56:52 -07:00
|
|
|
if (status < 0)
|
|
|
|
goto fail0;
|
2012-01-09 18:37:25 -07:00
|
|
|
status = request_irq(gpio_to_irq(board->det_pin), at91_cf_irq, 0, driver_name, cf);
|
2008-02-04 23:27:42 -07:00
|
|
|
if (status < 0)
|
|
|
|
goto fail00;
|
2006-04-19 07:37:48 -06:00
|
|
|
device_init_wakeup(&pdev->dev, 1);
|
2006-02-21 03:56:52 -07:00
|
|
|
|
2008-02-04 23:27:42 -07:00
|
|
|
status = gpio_request(board->rst_pin, "cf_rst");
|
|
|
|
if (status < 0)
|
|
|
|
goto fail0a;
|
|
|
|
|
2012-01-09 18:37:25 -07:00
|
|
|
if (gpio_is_valid(board->vcc_pin)) {
|
2008-02-04 23:27:42 -07:00
|
|
|
status = gpio_request(board->vcc_pin, "cf_vcc");
|
|
|
|
if (status < 0)
|
|
|
|
goto fail0b;
|
|
|
|
}
|
|
|
|
|
2006-02-21 03:56:52 -07:00
|
|
|
/*
|
|
|
|
* The card driver will request this irq later as needed.
|
|
|
|
* but it causes lots of "irqNN: nobody cared" messages
|
|
|
|
* unless we report that we handle everything (sigh).
|
|
|
|
* (Note: DK board doesn't wire the IRQ pin...)
|
|
|
|
*/
|
2012-01-09 18:37:25 -07:00
|
|
|
if (gpio_is_valid(board->irq_pin)) {
|
2008-02-04 23:27:42 -07:00
|
|
|
status = gpio_request(board->irq_pin, "cf_irq");
|
|
|
|
if (status < 0)
|
|
|
|
goto fail0c;
|
2012-01-09 18:37:25 -07:00
|
|
|
status = request_irq(gpio_to_irq(board->irq_pin), at91_cf_irq,
|
2006-07-01 20:29:38 -06:00
|
|
|
IRQF_SHARED, driver_name, cf);
|
2006-02-21 03:56:52 -07:00
|
|
|
if (status < 0)
|
2008-02-04 23:27:42 -07:00
|
|
|
goto fail0d;
|
2012-01-09 18:37:25 -07:00
|
|
|
cf->socket.pci_irq = gpio_to_irq(board->irq_pin);
|
2006-04-14 19:05:38 -06:00
|
|
|
} else
|
2008-08-19 21:49:52 -06:00
|
|
|
cf->socket.pci_irq = nr_irqs + 1;
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
/* pcmcia layer only remaps "real" memory not iospace */
|
2008-02-04 23:27:42 -07:00
|
|
|
cf->socket.io_offset = (unsigned long)
|
|
|
|
ioremap(cf->phys_baseaddr + CF_IO_PHYS, SZ_2K);
|
2006-11-06 06:56:07 -07:00
|
|
|
if (!cf->socket.io_offset) {
|
|
|
|
status = -ENXIO;
|
2006-02-21 03:56:52 -07:00
|
|
|
goto fail1;
|
2006-11-06 06:56:07 -07:00
|
|
|
}
|
2006-02-21 03:56:52 -07:00
|
|
|
|
2006-12-04 03:26:36 -07:00
|
|
|
/* reserve chip-select regions */
|
2011-06-09 10:13:32 -06:00
|
|
|
if (!request_mem_region(io->start, resource_size(io), driver_name)) {
|
2006-11-06 06:56:07 -07:00
|
|
|
status = -ENXIO;
|
2006-02-21 03:56:52 -07:00
|
|
|
goto fail1;
|
2006-11-06 06:56:07 -07:00
|
|
|
}
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
pr_info("%s: irqs det #%d, io #%d\n", driver_name,
|
2012-01-09 18:37:25 -07:00
|
|
|
gpio_to_irq(board->det_pin), gpio_to_irq(board->irq_pin));
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
cf->socket.owner = THIS_MODULE;
|
2007-02-13 23:39:27 -07:00
|
|
|
cf->socket.dev.parent = &pdev->dev;
|
2006-02-21 03:56:52 -07:00
|
|
|
cf->socket.ops = &at91_cf_ops;
|
|
|
|
cf->socket.resource_ops = &pccard_static_ops;
|
|
|
|
cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP
|
|
|
|
| SS_CAP_MEM_ALIGN;
|
|
|
|
cf->socket.map_size = SZ_2K;
|
2006-04-14 19:05:38 -06:00
|
|
|
cf->socket.io[0].res = io;
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
status = pcmcia_register_socket(&cf->socket);
|
|
|
|
if (status < 0)
|
|
|
|
goto fail2;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail2:
|
2011-06-09 10:13:32 -06:00
|
|
|
release_mem_region(io->start, resource_size(io));
|
2006-02-21 03:56:52 -07:00
|
|
|
fail1:
|
2006-10-20 15:44:18 -06:00
|
|
|
if (cf->socket.io_offset)
|
|
|
|
iounmap((void __iomem *) cf->socket.io_offset);
|
2012-01-09 18:37:25 -07:00
|
|
|
if (gpio_is_valid(board->irq_pin)) {
|
|
|
|
free_irq(gpio_to_irq(board->irq_pin), cf);
|
2008-02-04 23:27:42 -07:00
|
|
|
fail0d:
|
|
|
|
gpio_free(board->irq_pin);
|
|
|
|
}
|
|
|
|
fail0c:
|
2012-01-09 18:37:25 -07:00
|
|
|
if (gpio_is_valid(board->vcc_pin))
|
2008-02-04 23:27:42 -07:00
|
|
|
gpio_free(board->vcc_pin);
|
|
|
|
fail0b:
|
|
|
|
gpio_free(board->rst_pin);
|
2006-02-21 03:56:52 -07:00
|
|
|
fail0a:
|
2006-07-01 14:39:55 -06:00
|
|
|
device_init_wakeup(&pdev->dev, 0);
|
2012-01-09 18:37:25 -07:00
|
|
|
free_irq(gpio_to_irq(board->det_pin), cf);
|
2008-02-04 23:27:42 -07:00
|
|
|
fail00:
|
|
|
|
gpio_free(board->det_pin);
|
2006-02-21 03:56:52 -07:00
|
|
|
fail0:
|
|
|
|
kfree(cf);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2006-04-19 07:37:48 -06:00
|
|
|
static int __exit at91_cf_remove(struct platform_device *pdev)
|
2006-02-21 03:56:52 -07:00
|
|
|
{
|
2006-04-19 07:37:48 -06:00
|
|
|
struct at91_cf_socket *cf = platform_get_drvdata(pdev);
|
|
|
|
struct at91_cf_data *board = cf->board;
|
2006-04-14 19:05:38 -06:00
|
|
|
struct resource *io = cf->socket.io[0].res;
|
2006-02-21 03:56:52 -07:00
|
|
|
|
|
|
|
pcmcia_unregister_socket(&cf->socket);
|
2011-06-09 10:13:32 -06:00
|
|
|
release_mem_region(io->start, resource_size(io));
|
2008-02-04 23:27:42 -07:00
|
|
|
iounmap((void __iomem *) cf->socket.io_offset);
|
2012-01-09 18:37:25 -07:00
|
|
|
if (gpio_is_valid(board->irq_pin)) {
|
|
|
|
free_irq(gpio_to_irq(board->irq_pin), cf);
|
2008-02-04 23:27:42 -07:00
|
|
|
gpio_free(board->irq_pin);
|
|
|
|
}
|
2012-01-09 18:37:25 -07:00
|
|
|
if (gpio_is_valid(board->vcc_pin))
|
2008-02-04 23:27:42 -07:00
|
|
|
gpio_free(board->vcc_pin);
|
|
|
|
gpio_free(board->rst_pin);
|
2006-04-19 07:37:48 -06:00
|
|
|
device_init_wakeup(&pdev->dev, 0);
|
2012-01-09 18:37:25 -07:00
|
|
|
free_irq(gpio_to_irq(board->det_pin), cf);
|
2008-02-04 23:27:42 -07:00
|
|
|
gpio_free(board->det_pin);
|
2006-02-21 03:56:52 -07:00
|
|
|
kfree(cf);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-19 07:37:48 -06:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
|
|
|
static int at91_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
|
|
|
|
{
|
|
|
|
struct at91_cf_socket *cf = platform_get_drvdata(pdev);
|
|
|
|
struct at91_cf_data *board = cf->board;
|
|
|
|
|
2006-07-01 14:39:55 -06:00
|
|
|
if (device_may_wakeup(&pdev->dev)) {
|
2012-01-09 18:37:25 -07:00
|
|
|
enable_irq_wake(gpio_to_irq(board->det_pin));
|
|
|
|
if (gpio_is_valid(board->irq_pin))
|
|
|
|
enable_irq_wake(gpio_to_irq(board->irq_pin));
|
2006-04-19 07:37:48 -06:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int at91_cf_resume(struct platform_device *pdev)
|
|
|
|
{
|
2007-05-31 01:40:44 -06:00
|
|
|
struct at91_cf_socket *cf = platform_get_drvdata(pdev);
|
|
|
|
struct at91_cf_data *board = cf->board;
|
|
|
|
|
|
|
|
if (device_may_wakeup(&pdev->dev)) {
|
2012-01-09 18:37:25 -07:00
|
|
|
disable_irq_wake(gpio_to_irq(board->det_pin));
|
|
|
|
if (gpio_is_valid(board->irq_pin))
|
|
|
|
disable_irq_wake(gpio_to_irq(board->irq_pin));
|
2007-05-31 01:40:44 -06:00
|
|
|
}
|
|
|
|
|
2006-04-19 07:37:48 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define at91_cf_suspend NULL
|
|
|
|
#define at91_cf_resume NULL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static struct platform_driver at91_cf_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = (char *) driver_name,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
2006-02-21 03:56:52 -07:00
|
|
|
.remove = __exit_p(at91_cf_remove),
|
2006-04-19 07:37:48 -06:00
|
|
|
.suspend = at91_cf_suspend,
|
|
|
|
.resume = at91_cf_resume,
|
2006-02-21 03:56:52 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
static int __init at91_cf_init(void)
|
|
|
|
{
|
2007-05-06 15:48:42 -06:00
|
|
|
return platform_driver_probe(&at91_cf_driver, at91_cf_probe);
|
2006-02-21 03:56:52 -07:00
|
|
|
}
|
|
|
|
module_init(at91_cf_init);
|
|
|
|
|
|
|
|
static void __exit at91_cf_exit(void)
|
|
|
|
{
|
2006-04-19 07:37:48 -06:00
|
|
|
platform_driver_unregister(&at91_cf_driver);
|
2006-02-21 03:56:52 -07:00
|
|
|
}
|
|
|
|
module_exit(at91_cf_exit);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("AT91 Compact Flash Driver");
|
|
|
|
MODULE_AUTHOR("David Brownell");
|
|
|
|
MODULE_LICENSE("GPL");
|
2008-04-15 15:34:34 -06:00
|
|
|
MODULE_ALIAS("platform:at91_cf");
|