2005-10-29 04:46:13 +04:00
|
|
|
/*
|
|
|
|
* m8xx_pcmcia.c - Linux PCMCIA socket driver for the mpc8xx series.
|
|
|
|
*
|
2006-12-13 09:40:18 +03:00
|
|
|
* (C) 1999-2000 Magnus Damm <damm@opensource.se>
|
2005-10-29 04:46:13 +04:00
|
|
|
* (C) 2001-2002 Montavista Software, Inc.
|
|
|
|
* <mlocke@mvista.com>
|
|
|
|
*
|
|
|
|
* Support for two slots by Cyclades Corporation
|
|
|
|
* <oliver.kurth@cyclades.de>
|
|
|
|
* Further fixes, v2.6 kernel port
|
|
|
|
* <marcelo.tosatti@cyclades.com>
|
2005-12-08 18:56:12 +03:00
|
|
|
*
|
2007-07-09 22:37:35 +04:00
|
|
|
* Some fixes, additions (C) 2005-2007 Montavista Software, Inc.
|
2005-12-08 18:56:12 +03:00
|
|
|
* <vbordug@ru.mvista.com>
|
2005-10-29 04:46:13 +04:00
|
|
|
*
|
|
|
|
* "The ExCA standard specifies that socket controllers should provide
|
|
|
|
* two IO and five memory windows per socket, which can be independently
|
|
|
|
* configured and positioned in the host address space and mapped to
|
|
|
|
* arbitrary segments of card address space. " - David A Hinds. 1999
|
|
|
|
*
|
|
|
|
* This controller does _not_ meet the ExCA standard.
|
|
|
|
*
|
|
|
|
* m8xx pcmcia controller brief info:
|
|
|
|
* + 8 windows (attrib, mem, i/o)
|
|
|
|
* + up to two slots (SLOT_A and SLOT_B)
|
|
|
|
* + inputpins, outputpins, event and mask registers.
|
|
|
|
* - no offset register. sigh.
|
|
|
|
*
|
|
|
|
* Because of the lacking offset register we must map the whole card.
|
|
|
|
* We assign each memory window PCMCIA_MEM_WIN_SIZE address space.
|
|
|
|
* Make sure there is (PCMCIA_MEM_WIN_SIZE * PCMCIA_MEM_WIN_NO
|
|
|
|
* * PCMCIA_SOCKETS_NO) bytes at PCMCIA_MEM_WIN_BASE.
|
|
|
|
* The i/o windows are dynamically allocated at PCMCIA_IO_WIN_BASE.
|
|
|
|
* They are maximum 64KByte each...
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/fcntl.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/interrupt.h>
|
2007-07-09 22:37:35 +04:00
|
|
|
#include <linux/fsl_devices.h>
|
2007-10-19 10:40:25 +04:00
|
|
|
#include <linux/bitops.h>
|
2008-05-23 10:31:08 +04:00
|
|
|
#include <linux/of_device.h>
|
|
|
|
#include <linux/of_platform.h>
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/time.h>
|
2005-10-29 04:46:13 +04:00
|
|
|
#include <asm/mpc8xx.h>
|
|
|
|
#include <asm/8xx_immap.h>
|
|
|
|
#include <asm/irq.h>
|
2007-07-09 22:37:35 +04:00
|
|
|
#include <asm/fs_pd.h>
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
#include <pcmcia/ss.h>
|
|
|
|
|
|
|
|
#define pcmcia_info(args...) printk(KERN_INFO "m8xx_pcmcia: "args)
|
|
|
|
#define pcmcia_error(args...) printk(KERN_ERR "m8xx_pcmcia: "args)
|
|
|
|
|
|
|
|
static const char *version = "Version 0.06, Aug 2005";
|
|
|
|
MODULE_LICENSE("Dual MPL/GPL");
|
|
|
|
|
|
|
|
#if !defined(CONFIG_PCMCIA_SLOT_A) && !defined(CONFIG_PCMCIA_SLOT_B)
|
|
|
|
|
|
|
|
/* The ADS board use SLOT_A */
|
|
|
|
#ifdef CONFIG_ADS
|
|
|
|
#define CONFIG_PCMCIA_SLOT_A
|
|
|
|
#define CONFIG_BD_IS_MHZ
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* The FADS series are a mess */
|
|
|
|
#ifdef CONFIG_FADS
|
|
|
|
#if defined(CONFIG_MPC860T) || defined(CONFIG_MPC860) || defined(CONFIG_MPC821)
|
|
|
|
#define CONFIG_PCMCIA_SLOT_A
|
|
|
|
#else
|
|
|
|
#define CONFIG_PCMCIA_SLOT_B
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2005-12-08 18:56:12 +03:00
|
|
|
#if defined(CONFIG_MPC885ADS)
|
|
|
|
#define CONFIG_PCMCIA_SLOT_A
|
|
|
|
#define PCMCIA_GLITCHY_CD
|
|
|
|
#endif
|
|
|
|
|
2005-10-29 04:46:13 +04:00
|
|
|
/* Cyclades ACS uses both slots */
|
|
|
|
#ifdef CONFIG_PRxK
|
|
|
|
#define CONFIG_PCMCIA_SLOT_A
|
|
|
|
#define CONFIG_PCMCIA_SLOT_B
|
|
|
|
#endif
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
#endif /* !defined(CONFIG_PCMCIA_SLOT_A) && !defined(CONFIG_PCMCIA_SLOT_B) */
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
#if defined(CONFIG_PCMCIA_SLOT_A) && defined(CONFIG_PCMCIA_SLOT_B)
|
|
|
|
|
|
|
|
#define PCMCIA_SOCKETS_NO 2
|
|
|
|
/* We have only 8 windows, dualsocket support will be limited. */
|
|
|
|
#define PCMCIA_MEM_WIN_NO 2
|
|
|
|
#define PCMCIA_IO_WIN_NO 2
|
|
|
|
#define PCMCIA_SLOT_MSG "SLOT_A and SLOT_B"
|
|
|
|
|
|
|
|
#elif defined(CONFIG_PCMCIA_SLOT_A) || defined(CONFIG_PCMCIA_SLOT_B)
|
|
|
|
|
|
|
|
#define PCMCIA_SOCKETS_NO 1
|
|
|
|
/* full support for one slot */
|
|
|
|
#define PCMCIA_MEM_WIN_NO 5
|
|
|
|
#define PCMCIA_IO_WIN_NO 2
|
|
|
|
|
|
|
|
/* define _slot_ to be able to optimize macros */
|
|
|
|
|
|
|
|
#ifdef CONFIG_PCMCIA_SLOT_A
|
|
|
|
#define _slot_ 0
|
|
|
|
#define PCMCIA_SLOT_MSG "SLOT_A"
|
|
|
|
#else
|
|
|
|
#define _slot_ 1
|
|
|
|
#define PCMCIA_SLOT_MSG "SLOT_B"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else
|
|
|
|
#error m8xx_pcmcia: Bad configuration!
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
#define PCMCIA_MEM_WIN_BASE 0xe0000000 /* base address for memory window 0 */
|
|
|
|
#define PCMCIA_MEM_WIN_SIZE 0x04000000 /* each memory window is 64 MByte */
|
|
|
|
#define PCMCIA_IO_WIN_BASE _IO_BASE /* base address for io window 0 */
|
2005-10-29 04:46:13 +04:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
static int pcmcia_schlvl;
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2006-06-27 13:53:55 +04:00
|
|
|
static DEFINE_SPINLOCK(events_lock);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
#define PCMCIA_SOCKET_KEY_5V 1
|
|
|
|
#define PCMCIA_SOCKET_KEY_LV 2
|
|
|
|
|
|
|
|
/* look up table for pgcrx registers */
|
2007-07-09 22:37:35 +04:00
|
|
|
static u32 *m8xx_pgcrx[2];
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This structure is used to address each window in the PCMCIA controller.
|
|
|
|
*
|
|
|
|
* Keep in mind that we assume that pcmcia_win[n+1] is mapped directly
|
|
|
|
* after pcmcia_win[n]...
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct pcmcia_win {
|
2007-07-17 15:03:37 +04:00
|
|
|
u32 br;
|
|
|
|
u32 or;
|
2005-10-29 04:46:13 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For some reason the hardware guys decided to make both slots share
|
|
|
|
* some registers.
|
|
|
|
*
|
|
|
|
* Could someone invent object oriented hardware ?
|
|
|
|
*
|
|
|
|
* The macros are used to get the right bit from the registers.
|
|
|
|
* SLOT_A : slot = 0
|
|
|
|
* SLOT_B : slot = 1
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define M8XX_PCMCIA_VS1(slot) (0x80000000 >> (slot << 4))
|
|
|
|
#define M8XX_PCMCIA_VS2(slot) (0x40000000 >> (slot << 4))
|
|
|
|
#define M8XX_PCMCIA_VS_MASK(slot) (0xc0000000 >> (slot << 4))
|
|
|
|
#define M8XX_PCMCIA_VS_SHIFT(slot) (30 - (slot << 4))
|
|
|
|
|
|
|
|
#define M8XX_PCMCIA_WP(slot) (0x20000000 >> (slot << 4))
|
|
|
|
#define M8XX_PCMCIA_CD2(slot) (0x10000000 >> (slot << 4))
|
|
|
|
#define M8XX_PCMCIA_CD1(slot) (0x08000000 >> (slot << 4))
|
|
|
|
#define M8XX_PCMCIA_BVD2(slot) (0x04000000 >> (slot << 4))
|
|
|
|
#define M8XX_PCMCIA_BVD1(slot) (0x02000000 >> (slot << 4))
|
|
|
|
#define M8XX_PCMCIA_RDY(slot) (0x01000000 >> (slot << 4))
|
|
|
|
#define M8XX_PCMCIA_RDY_L(slot) (0x00800000 >> (slot << 4))
|
|
|
|
#define M8XX_PCMCIA_RDY_H(slot) (0x00400000 >> (slot << 4))
|
|
|
|
#define M8XX_PCMCIA_RDY_R(slot) (0x00200000 >> (slot << 4))
|
|
|
|
#define M8XX_PCMCIA_RDY_F(slot) (0x00100000 >> (slot << 4))
|
|
|
|
#define M8XX_PCMCIA_MASK(slot) (0xFFFF0000 >> (slot << 4))
|
|
|
|
|
|
|
|
#define M8XX_PCMCIA_POR_VALID 0x00000001
|
|
|
|
#define M8XX_PCMCIA_POR_WRPROT 0x00000002
|
|
|
|
#define M8XX_PCMCIA_POR_ATTRMEM 0x00000010
|
|
|
|
#define M8XX_PCMCIA_POR_IO 0x00000018
|
|
|
|
#define M8XX_PCMCIA_POR_16BIT 0x00000040
|
|
|
|
|
|
|
|
#define M8XX_PGCRX(slot) m8xx_pgcrx[slot]
|
|
|
|
|
|
|
|
#define M8XX_PGCRX_CXOE 0x00000080
|
|
|
|
#define M8XX_PGCRX_CXRESET 0x00000040
|
|
|
|
|
|
|
|
/* we keep one lookup table per socket to check flags */
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
#define PCMCIA_EVENTS_MAX 5 /* 4 max at a time + termination */
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
struct event_table {
|
|
|
|
u32 regbit;
|
|
|
|
u32 eventbit;
|
|
|
|
};
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
static const char driver_name[] = "m8xx-pcmcia";
|
|
|
|
|
2005-10-29 04:46:13 +04:00
|
|
|
struct socket_info {
|
2007-07-17 15:03:37 +04:00
|
|
|
void (*handler) (void *info, u32 events);
|
|
|
|
void *info;
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
u32 slot;
|
2007-07-09 22:37:35 +04:00
|
|
|
pcmconf8xx_t *pcmcia;
|
|
|
|
u32 bus_freq;
|
|
|
|
int hwirq;
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
socket_state_t state;
|
|
|
|
struct pccard_mem_map mem_win[PCMCIA_MEM_WIN_NO];
|
2007-07-17 15:03:37 +04:00
|
|
|
struct pccard_io_map io_win[PCMCIA_IO_WIN_NO];
|
2005-10-29 04:46:13 +04:00
|
|
|
struct event_table events[PCMCIA_EVENTS_MAX];
|
|
|
|
struct pcmcia_socket socket;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct socket_info socket[PCMCIA_SOCKETS_NO];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Search this table to see if the windowsize is
|
|
|
|
* supported...
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define M8XX_SIZES_NO 32
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
static const u32 m8xx_size_to_gray[M8XX_SIZES_NO] = {
|
2005-10-29 04:46:13 +04:00
|
|
|
0x00000001, 0x00000002, 0x00000008, 0x00000004,
|
|
|
|
0x00000080, 0x00000040, 0x00000010, 0x00000020,
|
|
|
|
0x00008000, 0x00004000, 0x00001000, 0x00002000,
|
|
|
|
0x00000100, 0x00000200, 0x00000800, 0x00000400,
|
|
|
|
|
|
|
|
0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
|
|
|
|
0x01000000, 0x02000000, 0xffffffff, 0x04000000,
|
|
|
|
0x00010000, 0x00020000, 0x00080000, 0x00040000,
|
|
|
|
0x00800000, 0x00400000, 0x00100000, 0x00200000
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
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 17:55:46 +04:00
|
|
|
static irqreturn_t m8xx_interrupt(int irq, void *dev);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
#define PCMCIA_BMT_LIMIT (15*4) /* Bus Monitor Timeout value */
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
/* FADS Boards from Motorola */
|
|
|
|
|
|
|
|
#if defined(CONFIG_FADS)
|
|
|
|
|
|
|
|
#define PCMCIA_BOARD_MSG "FADS"
|
|
|
|
|
|
|
|
static int voltage_set(int slot, int vcc, int vpp)
|
|
|
|
{
|
|
|
|
u32 reg = 0;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
switch (vcc) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 33:
|
|
|
|
reg |= BCSR1_PCCVCC0;
|
|
|
|
break;
|
|
|
|
case 50:
|
|
|
|
reg |= BCSR1_PCCVCC1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 1;
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
switch (vpp) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 33:
|
|
|
|
case 50:
|
|
|
|
if (vcc == vpp)
|
|
|
|
reg |= BCSR1_PCCVPP1;
|
|
|
|
else
|
2005-10-29 04:46:13 +04:00
|
|
|
return 1;
|
2007-07-17 15:03:37 +04:00
|
|
|
break;
|
|
|
|
case 120:
|
|
|
|
if ((vcc == 33) || (vcc == 50))
|
|
|
|
reg |= BCSR1_PCCVPP0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 1;
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* first, turn off all power */
|
2007-07-17 15:03:37 +04:00
|
|
|
out_be32((u32 *) BCSR1,
|
|
|
|
in_be32((u32 *) BCSR1) & ~(BCSR1_PCCVCC_MASK |
|
|
|
|
BCSR1_PCCVPP_MASK));
|
2005-12-08 18:56:12 +03:00
|
|
|
|
|
|
|
/* enable new powersettings */
|
2007-07-17 15:03:37 +04:00
|
|
|
out_be32((u32 *) BCSR1, in_be32((u32 *) BCSR1) | reg);
|
2005-12-08 18:56:12 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
|
|
|
|
|
|
|
|
static void hardware_enable(int slot)
|
|
|
|
{
|
2007-07-17 15:03:37 +04:00
|
|
|
out_be32((u32 *) BCSR1, in_be32((u32 *) BCSR1) & ~BCSR1_PCCEN);
|
2005-12-08 18:56:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void hardware_disable(int slot)
|
|
|
|
{
|
2007-07-17 15:03:37 +04:00
|
|
|
out_be32((u32 *) BCSR1, in_be32((u32 *) BCSR1) | BCSR1_PCCEN);
|
2005-12-08 18:56:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* MPC885ADS Boards */
|
|
|
|
|
|
|
|
#if defined(CONFIG_MPC885ADS)
|
|
|
|
|
|
|
|
#define PCMCIA_BOARD_MSG "MPC885ADS"
|
2007-07-09 22:37:35 +04:00
|
|
|
#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
|
2005-12-08 18:56:12 +03:00
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
static inline void hardware_enable(int slot)
|
2005-12-08 18:56:12 +03:00
|
|
|
{
|
2007-07-17 15:03:37 +04:00
|
|
|
m8xx_pcmcia_ops.hw_ctrl(slot, 1);
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
static inline void hardware_disable(int slot)
|
2005-10-29 04:46:13 +04:00
|
|
|
{
|
2007-07-09 22:37:35 +04:00
|
|
|
m8xx_pcmcia_ops.hw_ctrl(slot, 0);
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
static inline int voltage_set(int slot, int vcc, int vpp)
|
2005-10-29 04:46:13 +04:00
|
|
|
{
|
2007-07-09 22:37:35 +04:00
|
|
|
return m8xx_pcmcia_ops.voltage_set(slot, vcc, vpp);
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_PRxK)
|
|
|
|
#include <asm/cpld.h>
|
|
|
|
extern volatile fpga_pc_regs *fpga_pc;
|
|
|
|
|
|
|
|
#define PCMCIA_BOARD_MSG "MPC855T"
|
|
|
|
|
|
|
|
static int voltage_set(int slot, int vcc, int vpp)
|
|
|
|
{
|
|
|
|
u8 reg = 0;
|
|
|
|
u8 regread;
|
|
|
|
cpld_regs *ccpld = get_cpld();
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
switch (vcc) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 33:
|
|
|
|
reg |= PCMCIA_VCC_33;
|
|
|
|
break;
|
|
|
|
case 50:
|
|
|
|
reg |= PCMCIA_VCC_50;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 1;
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
switch (vpp) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 33:
|
|
|
|
case 50:
|
|
|
|
if (vcc == vpp)
|
|
|
|
reg |= PCMCIA_VPP_VCC;
|
|
|
|
else
|
2005-10-29 04:46:13 +04:00
|
|
|
return 1;
|
2007-07-17 15:03:37 +04:00
|
|
|
break;
|
|
|
|
case 120:
|
|
|
|
if ((vcc == 33) || (vcc == 50))
|
|
|
|
reg |= PCMCIA_VPP_12;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 1;
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
reg = reg >> (slot << 2);
|
|
|
|
regread = in_8(&ccpld->fpga_pc_ctl);
|
2007-07-17 15:03:37 +04:00
|
|
|
if (reg !=
|
|
|
|
(regread & ((PCMCIA_VCC_MASK | PCMCIA_VPP_MASK) >> (slot << 2)))) {
|
2005-10-29 04:46:13 +04:00
|
|
|
/* enable new powersettings */
|
2007-07-17 15:03:37 +04:00
|
|
|
regread =
|
|
|
|
regread & ~((PCMCIA_VCC_MASK | PCMCIA_VPP_MASK) >>
|
|
|
|
(slot << 2));
|
2005-10-29 04:46:13 +04:00
|
|
|
out_8(&ccpld->fpga_pc_ctl, reg | regread);
|
|
|
|
msleep(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define socket_get(_slot_) PCMCIA_SOCKET_KEY_LV
|
2007-07-17 15:03:37 +04:00
|
|
|
#define hardware_enable(_slot_) /* No hardware to enable */
|
|
|
|
#define hardware_disable(_slot_) /* No hardware to disable */
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
#endif /* CONFIG_PRxK */
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
static u32 pending_events[PCMCIA_SOCKETS_NO];
|
2006-06-27 13:53:55 +04:00
|
|
|
static DEFINE_SPINLOCK(pending_event_lock);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
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 17:55:46 +04:00
|
|
|
static irqreturn_t m8xx_interrupt(int irq, void *dev)
|
2005-10-29 04:46:13 +04:00
|
|
|
{
|
|
|
|
struct socket_info *s;
|
|
|
|
struct event_table *e;
|
|
|
|
unsigned int i, events, pscr, pipr, per;
|
2007-07-17 15:03:37 +04:00
|
|
|
pcmconf8xx_t *pcmcia = socket[0].pcmcia;
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: Interrupt!\n");
|
2005-10-29 04:46:13 +04:00
|
|
|
/* get interrupt sources */
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
pscr = in_be32(&pcmcia->pcmc_pscr);
|
|
|
|
pipr = in_be32(&pcmcia->pcmc_pipr);
|
|
|
|
per = in_be32(&pcmcia->pcmc_per);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
for (i = 0; i < PCMCIA_SOCKETS_NO; i++) {
|
2005-10-29 04:46:13 +04:00
|
|
|
s = &socket[i];
|
|
|
|
e = &s->events[0];
|
|
|
|
events = 0;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
while (e->regbit) {
|
|
|
|
if (pscr & e->regbit)
|
2005-10-29 04:46:13 +04:00
|
|
|
events |= e->eventbit;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
e++;
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* report only if both card detect signals are the same
|
|
|
|
* not too nice done,
|
|
|
|
* we depend on that CD2 is the bit to the left of CD1...
|
|
|
|
*/
|
2007-07-17 15:03:37 +04:00
|
|
|
if (events & SS_DETECT)
|
|
|
|
if (((pipr & M8XX_PCMCIA_CD2(i)) >> 1) ^
|
|
|
|
(pipr & M8XX_PCMCIA_CD1(i))) {
|
2005-10-29 04:46:13 +04:00
|
|
|
events &= ~SS_DETECT;
|
|
|
|
}
|
|
|
|
#ifdef PCMCIA_GLITCHY_CD
|
|
|
|
/*
|
|
|
|
* I've experienced CD problems with my ADS board.
|
|
|
|
* We make an extra check to see if there was a
|
|
|
|
* real change of Card detection.
|
|
|
|
*/
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if ((events & SS_DETECT) &&
|
|
|
|
((pipr &
|
|
|
|
(M8XX_PCMCIA_CD2(i) | M8XX_PCMCIA_CD1(i))) == 0) &&
|
|
|
|
(s->state.Vcc | s->state.Vpp)) {
|
2005-10-29 04:46:13 +04:00
|
|
|
events &= ~SS_DETECT;
|
|
|
|
/*printk( "CD glitch workaround - CD = 0x%08x!\n",
|
2007-07-17 15:03:37 +04:00
|
|
|
(pipr & (M8XX_PCMCIA_CD2(i)
|
|
|
|
| M8XX_PCMCIA_CD1(i)))); */
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* call the handler */
|
|
|
|
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: slot %u: events = 0x%02x, pscr = 0x%08x, "
|
2007-07-17 15:03:37 +04:00
|
|
|
"pipr = 0x%08x\n", i, events, pscr, pipr);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (events) {
|
2005-10-29 04:46:13 +04:00
|
|
|
spin_lock(&pending_event_lock);
|
|
|
|
pending_events[i] |= events;
|
|
|
|
spin_unlock(&pending_event_lock);
|
|
|
|
/*
|
|
|
|
* Turn off RDY_L bits in the PER mask on
|
|
|
|
* CD interrupt receival.
|
|
|
|
*
|
|
|
|
* They can generate bad interrupts on the
|
|
|
|
* ACS4,8,16,32. - marcelo
|
|
|
|
*/
|
|
|
|
per &= ~M8XX_PCMCIA_RDY_L(0);
|
|
|
|
per &= ~M8XX_PCMCIA_RDY_L(1);
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
out_be32(&pcmcia->pcmc_per, per);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
if (events)
|
|
|
|
pcmcia_parse_events(&socket[i].socket, events);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear the interrupt sources */
|
2007-07-09 22:37:35 +04:00
|
|
|
out_be32(&pcmcia->pcmc_pscr, pscr);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: Interrupt done.\n");
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 m8xx_get_graycode(u32 size)
|
|
|
|
{
|
|
|
|
u32 k;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
for (k = 0; k < M8XX_SIZES_NO; k++)
|
|
|
|
if (m8xx_size_to_gray[k] == size)
|
2005-10-29 04:46:13 +04:00
|
|
|
break;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if ((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
|
2005-10-29 04:46:13 +04:00
|
|
|
k = -1;
|
|
|
|
|
|
|
|
return k;
|
|
|
|
}
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
static u32 m8xx_get_speed(u32 ns, u32 is_io, u32 bus_freq)
|
2005-10-29 04:46:13 +04:00
|
|
|
{
|
|
|
|
u32 reg, clocks, psst, psl, psht;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (!ns) {
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We get called with IO maps setup to 0ns
|
|
|
|
* if not specified by the user.
|
|
|
|
* They should be 255ns.
|
|
|
|
*/
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (is_io)
|
2005-10-29 04:46:13 +04:00
|
|
|
ns = 255;
|
|
|
|
else
|
2007-07-17 15:03:37 +04:00
|
|
|
ns = 100; /* fast memory if 0 */
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In PSST, PSL, PSHT fields we tell the controller
|
|
|
|
* timing parameters in CLKOUT clock cycles.
|
|
|
|
* CLKOUT is the same as GCLK2_50.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* how we want to adjust the timing - in percent */
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
#define ADJ 180 /* 80 % longer accesstime - to be sure */
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
clocks = ((bus_freq / 1000) * ns) / 1000;
|
2007-07-17 15:03:37 +04:00
|
|
|
clocks = (clocks * ADJ) / (100 * 1000);
|
|
|
|
if (clocks >= PCMCIA_BMT_LIMIT) {
|
|
|
|
printk("Max access time limit reached\n");
|
|
|
|
clocks = PCMCIA_BMT_LIMIT - 1;
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
psst = clocks / 7; /* setup time */
|
|
|
|
psht = clocks / 7; /* hold time */
|
|
|
|
psl = (clocks * 5) / 7; /* strobe length */
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
psst += clocks - (psst + psht + psl);
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
reg = psst << 12;
|
|
|
|
reg |= psl << 7;
|
2005-10-29 04:46:13 +04:00
|
|
|
reg |= psht << 16;
|
|
|
|
|
|
|
|
return reg;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int m8xx_get_status(struct pcmcia_socket *sock, unsigned int *value)
|
|
|
|
{
|
|
|
|
int lsock = container_of(sock, struct socket_info, socket)->slot;
|
|
|
|
struct socket_info *s = &socket[lsock];
|
|
|
|
unsigned int pipr, reg;
|
2007-07-09 22:37:35 +04:00
|
|
|
pcmconf8xx_t *pcmcia = s->pcmcia;
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
pipr = in_be32(&pcmcia->pcmc_pipr);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
*value = ((pipr & (M8XX_PCMCIA_CD1(lsock)
|
|
|
|
| M8XX_PCMCIA_CD2(lsock))) == 0) ? SS_DETECT : 0;
|
2005-10-29 04:46:13 +04:00
|
|
|
*value |= (pipr & M8XX_PCMCIA_WP(lsock)) ? SS_WRPROT : 0;
|
|
|
|
|
|
|
|
if (s->state.flags & SS_IOCARD)
|
|
|
|
*value |= (pipr & M8XX_PCMCIA_BVD1(lsock)) ? SS_STSCHG : 0;
|
|
|
|
else {
|
|
|
|
*value |= (pipr & M8XX_PCMCIA_RDY(lsock)) ? SS_READY : 0;
|
|
|
|
*value |= (pipr & M8XX_PCMCIA_BVD1(lsock)) ? SS_BATDEAD : 0;
|
|
|
|
*value |= (pipr & M8XX_PCMCIA_BVD2(lsock)) ? SS_BATWARN : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->state.Vcc | s->state.Vpp)
|
|
|
|
*value |= SS_POWERON;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Voltage detection:
|
|
|
|
* This driver only supports 16-Bit pc-cards.
|
|
|
|
* Cardbus is not handled here.
|
|
|
|
*
|
|
|
|
* To determine what voltage to use we must read the VS1 and VS2 pin.
|
|
|
|
* Depending on what socket type is present,
|
|
|
|
* different combinations mean different things.
|
|
|
|
*
|
|
|
|
* Card Key Socket Key VS1 VS2 Card Vcc for CIS parse
|
|
|
|
*
|
|
|
|
* 5V 5V, LV* NC NC 5V only 5V (if available)
|
|
|
|
*
|
|
|
|
* 5V 5V, LV* GND NC 5 or 3.3V as low as possible
|
|
|
|
*
|
|
|
|
* 5V 5V, LV* GND GND 5, 3.3, x.xV as low as possible
|
|
|
|
*
|
|
|
|
* LV* 5V - - shall not fit into socket
|
|
|
|
*
|
|
|
|
* LV* LV* GND NC 3.3V only 3.3V
|
|
|
|
*
|
|
|
|
* LV* LV* NC GND x.xV x.xV (if avail.)
|
|
|
|
*
|
|
|
|
* LV* LV* GND GND 3.3 or x.xV as low as possible
|
|
|
|
*
|
|
|
|
* *LV means Low Voltage
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* That gives us the following table:
|
|
|
|
*
|
|
|
|
* Socket VS1 VS2 Voltage
|
|
|
|
*
|
|
|
|
* 5V NC NC 5V
|
|
|
|
* 5V NC GND none (should not be possible)
|
|
|
|
* 5V GND NC >= 3.3V
|
|
|
|
* 5V GND GND >= x.xV
|
|
|
|
*
|
|
|
|
* LV NC NC 5V (if available)
|
|
|
|
* LV NC GND x.xV (if available)
|
|
|
|
* LV GND NC 3.3V
|
|
|
|
* LV GND GND >= x.xV
|
|
|
|
*
|
|
|
|
* So, how do I determine if I have a 5V or a LV
|
|
|
|
* socket on my board? Look at the socket!
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Socket with 5V key:
|
|
|
|
* ++--------------------------------------------+
|
|
|
|
* || |
|
|
|
|
* || ||
|
|
|
|
* || ||
|
|
|
|
* | |
|
|
|
|
* +---------------------------------------------+
|
|
|
|
*
|
|
|
|
* Socket with LV key:
|
|
|
|
* ++--------------------------------------------+
|
|
|
|
* || |
|
|
|
|
* | ||
|
|
|
|
* | ||
|
|
|
|
* | |
|
|
|
|
* +---------------------------------------------+
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* With other words - LV only cards does not fit
|
|
|
|
* into the 5V socket!
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* read out VS1 and VS2 */
|
|
|
|
|
|
|
|
reg = (pipr & M8XX_PCMCIA_VS_MASK(lsock))
|
2007-07-17 15:03:37 +04:00
|
|
|
>> M8XX_PCMCIA_VS_SHIFT(lsock);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (socket_get(lsock) == PCMCIA_SOCKET_KEY_LV) {
|
|
|
|
switch (reg) {
|
2005-10-29 04:46:13 +04:00
|
|
|
case 1:
|
|
|
|
*value |= SS_3VCARD;
|
2007-07-17 15:03:37 +04:00
|
|
|
break; /* GND, NC - 3.3V only */
|
2005-10-29 04:46:13 +04:00
|
|
|
case 2:
|
|
|
|
*value |= SS_XVCARD;
|
2007-07-17 15:03:37 +04:00
|
|
|
break; /* NC. GND - x.xV only */
|
2005-10-29 04:46:13 +04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: GetStatus(%d) = %#2.2x\n", lsock, *value);
|
2005-10-29 04:46:13 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
static int m8xx_set_socket(struct pcmcia_socket *sock, socket_state_t * state)
|
2005-10-29 04:46:13 +04:00
|
|
|
{
|
|
|
|
int lsock = container_of(sock, struct socket_info, socket)->slot;
|
|
|
|
struct socket_info *s = &socket[lsock];
|
|
|
|
struct event_table *e;
|
|
|
|
unsigned int reg;
|
|
|
|
unsigned long flags;
|
2007-07-09 22:37:35 +04:00
|
|
|
pcmconf8xx_t *pcmcia = socket[0].pcmcia;
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, "
|
2007-07-17 15:03:37 +04:00
|
|
|
"io_irq %d, csc_mask %#2.2x)\n", lsock, state->flags,
|
|
|
|
state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
/* First, set voltage - bail out if invalid */
|
2007-07-17 15:03:37 +04:00
|
|
|
if (voltage_set(lsock, state->Vcc, state->Vpp))
|
2005-10-29 04:46:13 +04:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Take care of reset... */
|
2007-07-17 15:03:37 +04:00
|
|
|
if (state->flags & SS_RESET)
|
|
|
|
out_be32(M8XX_PGCRX(lsock), in_be32(M8XX_PGCRX(lsock)) | M8XX_PGCRX_CXRESET); /* active high */
|
2005-10-29 04:46:13 +04:00
|
|
|
else
|
2007-07-17 15:03:37 +04:00
|
|
|
out_be32(M8XX_PGCRX(lsock),
|
|
|
|
in_be32(M8XX_PGCRX(lsock)) & ~M8XX_PGCRX_CXRESET);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
/* ... and output enable. */
|
|
|
|
|
|
|
|
/* The CxOE signal is connected to a 74541 on the ADS.
|
|
|
|
I guess most other boards used the ADS as a reference.
|
|
|
|
I tried to control the CxOE signal with SS_OUTPUT_ENA,
|
|
|
|
but the reset signal seems connected via the 541.
|
|
|
|
If the CxOE is left high are some signals tristated and
|
2008-02-03 18:26:02 +03:00
|
|
|
no pullups are present -> the cards act weird.
|
2005-10-29 04:46:13 +04:00
|
|
|
So right now the buffers are enabled if the power is on. */
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (state->Vcc || state->Vpp)
|
|
|
|
out_be32(M8XX_PGCRX(lsock), in_be32(M8XX_PGCRX(lsock)) & ~M8XX_PGCRX_CXOE); /* active low */
|
2005-10-29 04:46:13 +04:00
|
|
|
else
|
2007-07-17 15:03:37 +04:00
|
|
|
out_be32(M8XX_PGCRX(lsock),
|
|
|
|
in_be32(M8XX_PGCRX(lsock)) | M8XX_PGCRX_CXOE);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We'd better turn off interrupts before
|
|
|
|
* we mess with the events-table..
|
|
|
|
*/
|
|
|
|
|
|
|
|
spin_lock_irqsave(&events_lock, flags);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Play around with the interrupt mask to be able to
|
|
|
|
* give the events the generic pcmcia driver wants us to.
|
|
|
|
*/
|
|
|
|
|
|
|
|
e = &s->events[0];
|
|
|
|
reg = 0;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (state->csc_mask & SS_DETECT) {
|
2005-10-29 04:46:13 +04:00
|
|
|
e->eventbit = SS_DETECT;
|
|
|
|
reg |= e->regbit = (M8XX_PCMCIA_CD2(lsock)
|
|
|
|
| M8XX_PCMCIA_CD1(lsock));
|
|
|
|
e++;
|
|
|
|
}
|
2007-07-17 15:03:37 +04:00
|
|
|
if (state->flags & SS_IOCARD) {
|
2005-10-29 04:46:13 +04:00
|
|
|
/*
|
|
|
|
* I/O card
|
|
|
|
*/
|
2007-07-17 15:03:37 +04:00
|
|
|
if (state->csc_mask & SS_STSCHG) {
|
2005-10-29 04:46:13 +04:00
|
|
|
e->eventbit = SS_STSCHG;
|
|
|
|
reg |= e->regbit = M8XX_PCMCIA_BVD1(lsock);
|
|
|
|
e++;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If io_irq is non-zero we should enable irq.
|
|
|
|
*/
|
2007-07-17 15:03:37 +04:00
|
|
|
if (state->io_irq) {
|
2007-07-09 22:37:35 +04:00
|
|
|
out_be32(M8XX_PGCRX(lsock),
|
2007-07-17 15:03:37 +04:00
|
|
|
in_be32(M8XX_PGCRX(lsock)) |
|
|
|
|
mk_int_int_mask(s->hwirq) << 24);
|
2005-10-29 04:46:13 +04:00
|
|
|
/*
|
|
|
|
* Strange thing here:
|
|
|
|
* The manual does not tell us which interrupt
|
|
|
|
* the sources generate.
|
|
|
|
* Anyhow, I found out that RDY_L generates IREQLVL.
|
|
|
|
*
|
|
|
|
* We use level triggerd interrupts, and they don't
|
|
|
|
* have to be cleared in PSCR in the interrupt handler.
|
|
|
|
*/
|
|
|
|
reg |= M8XX_PCMCIA_RDY_L(lsock);
|
2007-07-17 15:03:37 +04:00
|
|
|
} else
|
|
|
|
out_be32(M8XX_PGCRX(lsock),
|
|
|
|
in_be32(M8XX_PGCRX(lsock)) & 0x00ffffff);
|
|
|
|
} else {
|
2005-10-29 04:46:13 +04:00
|
|
|
/*
|
|
|
|
* Memory card
|
|
|
|
*/
|
2007-07-17 15:03:37 +04:00
|
|
|
if (state->csc_mask & SS_BATDEAD) {
|
2005-10-29 04:46:13 +04:00
|
|
|
e->eventbit = SS_BATDEAD;
|
|
|
|
reg |= e->regbit = M8XX_PCMCIA_BVD1(lsock);
|
|
|
|
e++;
|
|
|
|
}
|
2007-07-17 15:03:37 +04:00
|
|
|
if (state->csc_mask & SS_BATWARN) {
|
2005-10-29 04:46:13 +04:00
|
|
|
e->eventbit = SS_BATWARN;
|
|
|
|
reg |= e->regbit = M8XX_PCMCIA_BVD2(lsock);
|
|
|
|
e++;
|
|
|
|
}
|
|
|
|
/* What should I trigger on - low/high,raise,fall? */
|
2007-07-17 15:03:37 +04:00
|
|
|
if (state->csc_mask & SS_READY) {
|
2005-10-29 04:46:13 +04:00
|
|
|
e->eventbit = SS_READY;
|
2007-07-17 15:03:37 +04:00
|
|
|
reg |= e->regbit = 0; //??
|
2005-10-29 04:46:13 +04:00
|
|
|
e++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
e->regbit = 0; /* terminate list */
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear the status changed .
|
|
|
|
* Port A and Port B share the same port.
|
|
|
|
* Writing ones will clear the bits.
|
|
|
|
*/
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
out_be32(&pcmcia->pcmc_pscr, reg);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Write the mask.
|
|
|
|
* Port A and Port B share the same port.
|
|
|
|
* Need for read-modify-write.
|
|
|
|
* Ones will enable the interrupt.
|
|
|
|
*/
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
reg |=
|
|
|
|
in_be32(&pcmcia->
|
|
|
|
pcmc_per) & (M8XX_PCMCIA_MASK(0) | M8XX_PCMCIA_MASK(1));
|
2007-07-09 22:37:35 +04:00
|
|
|
out_be32(&pcmcia->pcmc_per, reg);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&events_lock, flags);
|
|
|
|
|
|
|
|
/* copy the struct and modify the copy */
|
|
|
|
|
|
|
|
s->state = *state;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int m8xx_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *io)
|
|
|
|
{
|
|
|
|
int lsock = container_of(sock, struct socket_info, socket)->slot;
|
|
|
|
|
|
|
|
struct socket_info *s = &socket[lsock];
|
|
|
|
struct pcmcia_win *w;
|
|
|
|
unsigned int reg, winnr;
|
2007-07-09 22:37:35 +04:00
|
|
|
pcmconf8xx_t *pcmcia = s->pcmcia;
|
|
|
|
|
2005-10-29 04:46:13 +04:00
|
|
|
#define M8XX_SIZE (io->stop - io->start + 1)
|
|
|
|
#define M8XX_BASE (PCMCIA_IO_WIN_BASE + io->start)
|
|
|
|
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: SetIOMap(%d, %d, %#2.2x, %d ns, "
|
2009-10-19 13:42:13 +04:00
|
|
|
"%#4.4llx-%#4.4llx)\n", lsock, io->map, io->flags,
|
|
|
|
io->speed, (unsigned long long)io->start,
|
|
|
|
(unsigned long long)io->stop);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
if ((io->map >= PCMCIA_IO_WIN_NO) || (io->start > 0xffff)
|
|
|
|
|| (io->stop > 0xffff) || (io->stop < io->start))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if ((reg = m8xx_get_graycode(M8XX_SIZE)) == -1)
|
2005-10-29 04:46:13 +04:00
|
|
|
return -EINVAL;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (io->flags & MAP_ACTIVE) {
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: io->flags & MAP_ACTIVE\n");
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
winnr = (PCMCIA_MEM_WIN_NO * PCMCIA_SOCKETS_NO)
|
2007-07-17 15:03:37 +04:00
|
|
|
+ (lsock * PCMCIA_IO_WIN_NO) + io->map;
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
/* setup registers */
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
w = (void *)&pcmcia->pcmc_pbr0;
|
2005-10-29 04:46:13 +04:00
|
|
|
w += winnr;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
out_be32(&w->or, 0); /* turn off window first */
|
2005-10-29 04:46:13 +04:00
|
|
|
out_be32(&w->br, M8XX_BASE);
|
|
|
|
|
|
|
|
reg <<= 27;
|
2007-07-17 15:03:37 +04:00
|
|
|
reg |= M8XX_PCMCIA_POR_IO | (lsock << 2);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
reg |= m8xx_get_speed(io->speed, 1, s->bus_freq);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (io->flags & MAP_WRPROT)
|
2005-10-29 04:46:13 +04:00
|
|
|
reg |= M8XX_PCMCIA_POR_WRPROT;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
/*if(io->flags & (MAP_16BIT | MAP_AUTOSZ)) */
|
|
|
|
if (io->flags & MAP_16BIT)
|
2005-10-29 04:46:13 +04:00
|
|
|
reg |= M8XX_PCMCIA_POR_16BIT;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (io->flags & MAP_ACTIVE)
|
2005-10-29 04:46:13 +04:00
|
|
|
reg |= M8XX_PCMCIA_POR_VALID;
|
|
|
|
|
|
|
|
out_be32(&w->or, reg);
|
|
|
|
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: Socket %u: Mapped io window %u at "
|
|
|
|
"%#8.8x, OR = %#8.8x.\n", lsock, io->map, w->br, w->or);
|
2005-10-29 04:46:13 +04:00
|
|
|
} else {
|
|
|
|
/* shutdown IO window */
|
|
|
|
winnr = (PCMCIA_MEM_WIN_NO * PCMCIA_SOCKETS_NO)
|
2007-07-17 15:03:37 +04:00
|
|
|
+ (lsock * PCMCIA_IO_WIN_NO) + io->map;
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
/* setup registers */
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
w = (void *)&pcmcia->pcmc_pbr0;
|
2005-10-29 04:46:13 +04:00
|
|
|
w += winnr;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
out_be32(&w->or, 0); /* turn off window */
|
|
|
|
out_be32(&w->br, 0); /* turn off base address */
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: Socket %u: Unmapped io window %u at "
|
|
|
|
"%#8.8x, OR = %#8.8x.\n", lsock, io->map, w->br, w->or);
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* copy the struct and modify the copy */
|
|
|
|
s->io_win[io->map] = *io;
|
2007-07-17 15:03:37 +04:00
|
|
|
s->io_win[io->map].flags &= (MAP_WRPROT | MAP_16BIT | MAP_ACTIVE);
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: SetIOMap exit\n");
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
static int m8xx_set_mem_map(struct pcmcia_socket *sock,
|
|
|
|
struct pccard_mem_map *mem)
|
2005-10-29 04:46:13 +04:00
|
|
|
{
|
|
|
|
int lsock = container_of(sock, struct socket_info, socket)->slot;
|
|
|
|
struct socket_info *s = &socket[lsock];
|
|
|
|
struct pcmcia_win *w;
|
|
|
|
struct pccard_mem_map *old;
|
|
|
|
unsigned int reg, winnr;
|
2007-07-09 22:37:35 +04:00
|
|
|
pcmconf8xx_t *pcmcia = s->pcmcia;
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: SetMemMap(%d, %d, %#2.2x, %d ns, "
|
2009-10-19 13:42:13 +04:00
|
|
|
"%#5.5llx, %#5.5x)\n", lsock, mem->map, mem->flags,
|
|
|
|
mem->speed, (unsigned long long)mem->static_start,
|
|
|
|
mem->card_start);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
if ((mem->map >= PCMCIA_MEM_WIN_NO)
|
2007-07-17 15:03:37 +04:00
|
|
|
// || ((mem->s) >= PCMCIA_MEM_WIN_SIZE)
|
2005-10-29 04:46:13 +04:00
|
|
|
|| (mem->card_start >= 0x04000000)
|
2007-07-17 15:03:37 +04:00
|
|
|
|| (mem->static_start & 0xfff) /* 4KByte resolution */
|
|
|
|
||(mem->card_start & 0xfff))
|
2005-10-29 04:46:13 +04:00
|
|
|
return -EINVAL;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if ((reg = m8xx_get_graycode(PCMCIA_MEM_WIN_SIZE)) == -1) {
|
|
|
|
printk("Cannot set size to 0x%08x.\n", PCMCIA_MEM_WIN_SIZE);
|
2005-10-29 04:46:13 +04:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
reg <<= 27;
|
|
|
|
|
|
|
|
winnr = (lsock * PCMCIA_MEM_WIN_NO) + mem->map;
|
|
|
|
|
|
|
|
/* Setup the window in the pcmcia controller */
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
w = (void *)&pcmcia->pcmc_pbr0;
|
2005-10-29 04:46:13 +04:00
|
|
|
w += winnr;
|
|
|
|
|
|
|
|
reg |= lsock << 2;
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
reg |= m8xx_get_speed(mem->speed, 0, s->bus_freq);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (mem->flags & MAP_ATTRIB)
|
|
|
|
reg |= M8XX_PCMCIA_POR_ATTRMEM;
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (mem->flags & MAP_WRPROT)
|
2005-10-29 04:46:13 +04:00
|
|
|
reg |= M8XX_PCMCIA_POR_WRPROT;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (mem->flags & MAP_16BIT)
|
2005-10-29 04:46:13 +04:00
|
|
|
reg |= M8XX_PCMCIA_POR_16BIT;
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (mem->flags & MAP_ACTIVE)
|
2005-10-29 04:46:13 +04:00
|
|
|
reg |= M8XX_PCMCIA_POR_VALID;
|
|
|
|
|
|
|
|
out_be32(&w->or, reg);
|
|
|
|
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: Socket %u: Mapped memory window %u at %#8.8x, "
|
2007-07-17 15:03:37 +04:00
|
|
|
"OR = %#8.8x.\n", lsock, mem->map, w->br, w->or);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (mem->flags & MAP_ACTIVE) {
|
2005-10-29 04:46:13 +04:00
|
|
|
/* get the new base address */
|
|
|
|
mem->static_start = PCMCIA_MEM_WIN_BASE +
|
2007-07-17 15:03:37 +04:00
|
|
|
(PCMCIA_MEM_WIN_SIZE * winnr)
|
|
|
|
+ mem->card_start;
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: SetMemMap(%d, %d, %#2.2x, %d ns, "
|
2009-10-19 13:42:13 +04:00
|
|
|
"%#5.5llx, %#5.5x)\n", lsock, mem->map, mem->flags,
|
|
|
|
mem->speed, (unsigned long long)mem->static_start,
|
|
|
|
mem->card_start);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
/* copy the struct and modify the copy */
|
|
|
|
|
|
|
|
old = &s->mem_win[mem->map];
|
|
|
|
|
|
|
|
*old = *mem;
|
2007-07-17 15:03:37 +04:00
|
|
|
old->flags &= (MAP_ATTRIB | MAP_WRPROT | MAP_16BIT | MAP_ACTIVE);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int m8xx_sock_init(struct pcmcia_socket *sock)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
pccard_io_map io = { 0, 0, 0, 0, 1 };
|
|
|
|
pccard_mem_map mem = { 0, 0, 0, 0, 0, 0 };
|
|
|
|
|
2009-10-23 14:56:46 +04:00
|
|
|
pr_debug("m8xx_pcmcia: sock_init(%d)\n", s);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
m8xx_set_socket(sock, &dead_socket);
|
|
|
|
for (i = 0; i < PCMCIA_IO_WIN_NO; i++) {
|
|
|
|
io.map = i;
|
|
|
|
m8xx_set_io_map(sock, &io);
|
|
|
|
}
|
|
|
|
for (i = 0; i < PCMCIA_MEM_WIN_NO; i++) {
|
|
|
|
mem.map = i;
|
|
|
|
m8xx_set_mem_map(sock, &mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
static int m8xx_sock_suspend(struct pcmcia_socket *sock)
|
2005-10-29 04:46:13 +04:00
|
|
|
{
|
|
|
|
return m8xx_set_socket(sock, &dead_socket);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pccard_operations m8xx_services = {
|
2007-07-17 15:03:37 +04:00
|
|
|
.init = m8xx_sock_init,
|
2007-07-09 22:37:35 +04:00
|
|
|
.suspend = m8xx_sock_suspend,
|
2005-10-29 04:46:13 +04:00
|
|
|
.get_status = m8xx_get_status,
|
|
|
|
.set_socket = m8xx_set_socket,
|
|
|
|
.set_io_map = m8xx_set_io_map,
|
|
|
|
.set_mem_map = m8xx_set_mem_map,
|
|
|
|
};
|
|
|
|
|
2011-02-17 12:43:24 +03:00
|
|
|
static int __init m8xx_probe(struct platform_device *ofdev)
|
2005-10-29 04:46:13 +04:00
|
|
|
{
|
|
|
|
struct pcmcia_win *w;
|
2007-07-09 22:37:35 +04:00
|
|
|
unsigned int i, m, hwirq;
|
|
|
|
pcmconf8xx_t *pcmcia;
|
|
|
|
int status;
|
2010-06-03 03:38:57 +04:00
|
|
|
struct device_node *np = ofdev->dev.of_node;
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
pcmcia_info("%s\n", version);
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
pcmcia = of_iomap(np, 0);
|
2007-07-17 15:03:37 +04:00
|
|
|
if (pcmcia == NULL)
|
2007-07-09 22:37:35 +04:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
pcmcia_schlvl = irq_of_parse_and_map(np, 0);
|
2007-07-17 15:03:37 +04:00
|
|
|
hwirq = irq_map[pcmcia_schlvl].hwirq;
|
drivers/pcmcia: Add missing iounmap
of_iomap calls ioremap, and so should be matched with an iounmap. At the
two error returns, the result of calling of_iomap is only stored in a local
variable, so these error paths need to call iounmap. Furthermore, this
function ultimately stores the result of of_iomap in an array that is local
to the file. These values should be iounmapped at some point. I have
added a corresponding call to iounmap at the end of the function
m8xx_remove.
The problem was found using the following semantic match.
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@@
type T,T1,T2;
identifier E;
statement S;
expression x1,x2,x3;
int ret;
@@
T E;
...
* E = of_iomap(...);
if (E == NULL) S
... when != iounmap(...,(T1)E,...)
when != if (E != NULL) { ... iounmap(...,(T1)E,...); ...}
when != x1 = (T1)E
when != E = x3;
when any
if (...) {
... when != iounmap(...,(T2)E,...)
when != if (E != NULL) { ... iounmap(...,(T2)E,...); ...}
when != x2 = (T2)E
(
* return;
|
* return ret;
)
}
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Vitaly Bordug <vitb@kernel.crashing.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Olof Johansson <olof@lixom.net>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-05 09:27:44 +03:00
|
|
|
if (pcmcia_schlvl < 0) {
|
|
|
|
iounmap(pcmcia);
|
2007-07-09 22:37:35 +04:00
|
|
|
return -EINVAL;
|
drivers/pcmcia: Add missing iounmap
of_iomap calls ioremap, and so should be matched with an iounmap. At the
two error returns, the result of calling of_iomap is only stored in a local
variable, so these error paths need to call iounmap. Furthermore, this
function ultimately stores the result of of_iomap in an array that is local
to the file. These values should be iounmapped at some point. I have
added a corresponding call to iounmap at the end of the function
m8xx_remove.
The problem was found using the following semantic match.
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@@
type T,T1,T2;
identifier E;
statement S;
expression x1,x2,x3;
int ret;
@@
T E;
...
* E = of_iomap(...);
if (E == NULL) S
... when != iounmap(...,(T1)E,...)
when != if (E != NULL) { ... iounmap(...,(T1)E,...); ...}
when != x1 = (T1)E
when != E = x3;
when any
if (...) {
... when != iounmap(...,(T2)E,...)
when != if (E != NULL) { ... iounmap(...,(T2)E,...); ...}
when != x2 = (T2)E
(
* return;
|
* return ret;
)
}
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Vitaly Bordug <vitb@kernel.crashing.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Olof Johansson <olof@lixom.net>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-05 09:27:44 +03:00
|
|
|
}
|
2007-07-09 22:37:35 +04:00
|
|
|
|
|
|
|
m8xx_pgcrx[0] = &pcmcia->pcmc_pgcra;
|
|
|
|
m8xx_pgcrx[1] = &pcmcia->pcmc_pgcrb;
|
|
|
|
|
2005-10-29 04:46:13 +04:00
|
|
|
pcmcia_info(PCMCIA_BOARD_MSG " using " PCMCIA_SLOT_MSG
|
2007-07-09 22:37:35 +04:00
|
|
|
" with IRQ %u (%d). \n", pcmcia_schlvl, hwirq);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
/* Configure Status change interrupt */
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
if (request_irq(pcmcia_schlvl, m8xx_interrupt, IRQF_SHARED,
|
|
|
|
driver_name, socket)) {
|
2005-10-29 04:46:13 +04:00
|
|
|
pcmcia_error("Cannot allocate IRQ %u for SCHLVL!\n",
|
|
|
|
pcmcia_schlvl);
|
drivers/pcmcia: Add missing iounmap
of_iomap calls ioremap, and so should be matched with an iounmap. At the
two error returns, the result of calling of_iomap is only stored in a local
variable, so these error paths need to call iounmap. Furthermore, this
function ultimately stores the result of of_iomap in an array that is local
to the file. These values should be iounmapped at some point. I have
added a corresponding call to iounmap at the end of the function
m8xx_remove.
The problem was found using the following semantic match.
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@@
type T,T1,T2;
identifier E;
statement S;
expression x1,x2,x3;
int ret;
@@
T E;
...
* E = of_iomap(...);
if (E == NULL) S
... when != iounmap(...,(T1)E,...)
when != if (E != NULL) { ... iounmap(...,(T1)E,...); ...}
when != x1 = (T1)E
when != E = x3;
when any
if (...) {
... when != iounmap(...,(T2)E,...)
when != if (E != NULL) { ... iounmap(...,(T2)E,...); ...}
when != x2 = (T2)E
(
* return;
|
* return ret;
)
}
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Vitaly Bordug <vitb@kernel.crashing.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Olof Johansson <olof@lixom.net>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-05 09:27:44 +03:00
|
|
|
iounmap(pcmcia);
|
2005-10-29 04:46:13 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
w = (void *)&pcmcia->pcmc_pbr0;
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
out_be32(&pcmcia->pcmc_pscr, M8XX_PCMCIA_MASK(0) | M8XX_PCMCIA_MASK(1));
|
2007-07-09 22:37:35 +04:00
|
|
|
clrbits32(&pcmcia->pcmc_per, M8XX_PCMCIA_MASK(0) | M8XX_PCMCIA_MASK(1));
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
/* connect interrupt and disable CxOE */
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
out_be32(M8XX_PGCRX(0),
|
|
|
|
M8XX_PGCRX_CXOE | (mk_int_int_mask(hwirq) << 16));
|
|
|
|
out_be32(M8XX_PGCRX(1),
|
|
|
|
M8XX_PGCRX_CXOE | (mk_int_int_mask(hwirq) << 16));
|
2005-10-29 04:46:13 +04:00
|
|
|
|
tree-wide: fix comment/printk typos
"gadget", "through", "command", "maintain", "maintain", "controller", "address",
"between", "initiali[zs]e", "instead", "function", "select", "already",
"equal", "access", "management", "hierarchy", "registration", "interest",
"relative", "memory", "offset", "already",
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-11-01 22:38:34 +03:00
|
|
|
/* initialize the fixed memory windows */
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
for (i = 0; i < PCMCIA_SOCKETS_NO; i++) {
|
2007-07-09 22:37:35 +04:00
|
|
|
for (m = 0; m < PCMCIA_MEM_WIN_NO; m++) {
|
2005-10-29 04:46:13 +04:00
|
|
|
out_be32(&w->br, PCMCIA_MEM_WIN_BASE +
|
2007-07-17 15:03:37 +04:00
|
|
|
(PCMCIA_MEM_WIN_SIZE
|
|
|
|
* (m + i * PCMCIA_MEM_WIN_NO)));
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
out_be32(&w->or, 0); /* set to not valid */
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
w++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
/* turn off voltage */
|
2005-10-29 04:46:13 +04:00
|
|
|
voltage_set(0, 0, 0);
|
|
|
|
voltage_set(1, 0, 0);
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
/* Enable external hardware */
|
2005-10-29 04:46:13 +04:00
|
|
|
hardware_enable(0);
|
|
|
|
hardware_enable(1);
|
|
|
|
|
2007-07-17 15:03:37 +04:00
|
|
|
for (i = 0; i < PCMCIA_SOCKETS_NO; i++) {
|
2005-10-29 04:46:13 +04:00
|
|
|
socket[i].slot = i;
|
|
|
|
socket[i].socket.owner = THIS_MODULE;
|
2007-07-17 15:03:37 +04:00
|
|
|
socket[i].socket.features =
|
|
|
|
SS_CAP_PCCARD | SS_CAP_MEM_ALIGN | SS_CAP_STATIC_MAP;
|
2005-10-29 04:46:13 +04:00
|
|
|
socket[i].socket.irq_mask = 0x000;
|
|
|
|
socket[i].socket.map_size = 0x1000;
|
|
|
|
socket[i].socket.io_offset = 0;
|
2007-07-09 22:37:35 +04:00
|
|
|
socket[i].socket.pci_irq = pcmcia_schlvl;
|
2005-10-29 04:46:13 +04:00
|
|
|
socket[i].socket.ops = &m8xx_services;
|
2010-01-06 13:19:25 +03:00
|
|
|
socket[i].socket.resource_ops = &pccard_iodyn_ops;
|
2005-10-29 04:46:13 +04:00
|
|
|
socket[i].socket.cb_dev = NULL;
|
2007-07-09 22:37:35 +04:00
|
|
|
socket[i].socket.dev.parent = &ofdev->dev;
|
|
|
|
socket[i].pcmcia = pcmcia;
|
|
|
|
socket[i].bus_freq = ppc_proc_freq;
|
|
|
|
socket[i].hwirq = hwirq;
|
|
|
|
|
2005-10-29 04:46:13 +04:00
|
|
|
}
|
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
for (i = 0; i < PCMCIA_SOCKETS_NO; i++) {
|
|
|
|
status = pcmcia_register_socket(&socket[i].socket);
|
|
|
|
if (status < 0)
|
|
|
|
pcmcia_error("Socket register failed\n");
|
|
|
|
}
|
2005-10-29 04:46:13 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-08-06 19:25:50 +04:00
|
|
|
static int m8xx_remove(struct platform_device *ofdev)
|
2005-10-29 04:46:13 +04:00
|
|
|
{
|
2007-07-09 22:37:35 +04:00
|
|
|
u32 m, i;
|
|
|
|
struct pcmcia_win *w;
|
|
|
|
pcmconf8xx_t *pcmcia = socket[0].pcmcia;
|
|
|
|
|
|
|
|
for (i = 0; i < PCMCIA_SOCKETS_NO; i++) {
|
2007-07-17 15:03:37 +04:00
|
|
|
w = (void *)&pcmcia->pcmc_pbr0;
|
2007-07-09 22:37:35 +04:00
|
|
|
|
|
|
|
out_be32(&pcmcia->pcmc_pscr, M8XX_PCMCIA_MASK(i));
|
|
|
|
out_be32(&pcmcia->pcmc_per,
|
2007-07-17 15:03:37 +04:00
|
|
|
in_be32(&pcmcia->pcmc_per) & ~M8XX_PCMCIA_MASK(i));
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
/* turn off interrupt and disable CxOE */
|
|
|
|
out_be32(M8XX_PGCRX(i), M8XX_PGCRX_CXOE);
|
|
|
|
|
|
|
|
/* turn off memory windows */
|
|
|
|
for (m = 0; m < PCMCIA_MEM_WIN_NO; m++) {
|
2007-07-17 15:03:37 +04:00
|
|
|
out_be32(&w->or, 0); /* set to not valid */
|
2007-07-09 22:37:35 +04:00
|
|
|
w++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* turn off voltage */
|
|
|
|
voltage_set(i, 0, 0);
|
|
|
|
|
|
|
|
/* disable external hardware */
|
|
|
|
hardware_disable(i);
|
|
|
|
}
|
2005-10-29 04:46:13 +04:00
|
|
|
for (i = 0; i < PCMCIA_SOCKETS_NO; i++)
|
|
|
|
pcmcia_unregister_socket(&socket[i].socket);
|
drivers/pcmcia: Add missing iounmap
of_iomap calls ioremap, and so should be matched with an iounmap. At the
two error returns, the result of calling of_iomap is only stored in a local
variable, so these error paths need to call iounmap. Furthermore, this
function ultimately stores the result of of_iomap in an array that is local
to the file. These values should be iounmapped at some point. I have
added a corresponding call to iounmap at the end of the function
m8xx_remove.
The problem was found using the following semantic match.
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@@
type T,T1,T2;
identifier E;
statement S;
expression x1,x2,x3;
int ret;
@@
T E;
...
* E = of_iomap(...);
if (E == NULL) S
... when != iounmap(...,(T1)E,...)
when != if (E != NULL) { ... iounmap(...,(T1)E,...); ...}
when != x1 = (T1)E
when != E = x3;
when any
if (...) {
... when != iounmap(...,(T2)E,...)
when != if (E != NULL) { ... iounmap(...,(T2)E,...); ...}
when != x2 = (T2)E
(
* return;
|
* return ret;
)
}
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Vitaly Bordug <vitb@kernel.crashing.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Olof Johansson <olof@lixom.net>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-05 09:27:44 +03:00
|
|
|
iounmap(pcmcia);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
free_irq(pcmcia_schlvl, NULL);
|
2005-10-29 04:46:13 +04:00
|
|
|
|
2007-07-09 22:37:35 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-12 10:56:13 +03:00
|
|
|
static const struct of_device_id m8xx_pcmcia_match[] = {
|
2007-07-09 22:37:35 +04:00
|
|
|
{
|
2007-07-17 15:03:37 +04:00
|
|
|
.type = "pcmcia",
|
|
|
|
.compatible = "fsl,pq-pcmcia",
|
|
|
|
},
|
2007-07-09 22:37:35 +04:00
|
|
|
{},
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(of, m8xx_pcmcia_match);
|
|
|
|
|
2011-02-17 12:43:24 +03:00
|
|
|
static struct platform_driver m8xx_pcmcia_driver = {
|
2010-04-14 03:13:02 +04:00
|
|
|
.driver = {
|
|
|
|
.name = driver_name,
|
|
|
|
.owner = THIS_MODULE,
|
2010-06-03 03:38:57 +04:00
|
|
|
.of_match_table = m8xx_pcmcia_match,
|
2010-04-14 03:13:02 +04:00
|
|
|
},
|
2007-07-17 15:03:37 +04:00
|
|
|
.probe = m8xx_probe,
|
|
|
|
.remove = m8xx_remove,
|
2007-07-09 22:37:35 +04:00
|
|
|
};
|
|
|
|
|
2011-11-27 08:53:06 +04:00
|
|
|
module_platform_driver(m8xx_pcmcia_driver);
|