提交 0ce7625f 编写于 作者: R Richard Purdie 提交者: Russell King

[ARM] 2882/1: pxa2xx_sharpsl: Update PCMCIA driver to support variety of new hardware

Patch from Richard Purdie

This patch updates the PCMCIA pxa2xx_sharpsl driver to support multiple scoop
devices by adding a scoop to pcmcia slot mapping structure. It adds platform
support for poodle, is known to work on spitz (which is dual slot) and
should also support collie with a minor amount of further work.
Signed-off-by: NRichard Purdie <rpurdie@rpsys.net>
Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
上级 027da01d
...@@ -17,6 +17,12 @@ ...@@ -17,6 +17,12 @@
#define SCOOP_REG(d,adr) (*(volatile unsigned short*)(d +(adr))) #define SCOOP_REG(d,adr) (*(volatile unsigned short*)(d +(adr)))
/* PCMCIA to Scoop linkage structures for pxa2xx_sharpsl.c
There is no easy way to link multiple scoop devices into one
single entity for the pxa2xx_pcmcia device */
int scoop_num;
struct scoop_pcmcia_dev *scoop_devs;
struct scoop_dev { struct scoop_dev {
void *base; void *base;
spinlock_t scoop_lock; spinlock_t scoop_lock;
......
...@@ -60,6 +60,15 @@ static struct scoop_config corgi_scoop_setup = { ...@@ -60,6 +60,15 @@ static struct scoop_config corgi_scoop_setup = {
.io_out = CORGI_SCOOP_IO_OUT, .io_out = CORGI_SCOOP_IO_OUT,
}; };
static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = {
{
.dev = &corgiscoop_device.dev,
.irq = CORGI_IRQ_GPIO_CF_IRQ,
.cd_irq = CORGI_IRQ_GPIO_CF_CD,
.cd_irq_str = "PCMCIA0 CD",
},
};
struct platform_device corgiscoop_device = { struct platform_device corgiscoop_device = {
.name = "sharp-scoop", .name = "sharp-scoop",
.id = -1, .id = -1,
...@@ -241,6 +250,9 @@ static void __init corgi_init(void) ...@@ -241,6 +250,9 @@ static void __init corgi_init(void)
pxa_set_udc_info(&udc_info); pxa_set_udc_info(&udc_info);
pxa_set_mci_info(&corgi_mci_platform_data); pxa_set_mci_info(&corgi_mci_platform_data);
scoop_num = 1;
scoop_devs = &corgi_pcmcia_scoop[0];
platform_add_devices(devices, ARRAY_SIZE(devices)); platform_add_devices(devices, ARRAY_SIZE(devices));
} }
......
...@@ -62,6 +62,15 @@ struct platform_device poodle_scoop_device = { ...@@ -62,6 +62,15 @@ struct platform_device poodle_scoop_device = {
.resource = poodle_scoop_resources, .resource = poodle_scoop_resources,
}; };
static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
{
.dev = &poodle_scoop_device.dev,
.irq = POODLE_IRQ_GPIO_CF_IRQ,
.cd_irq = POODLE_IRQ_GPIO_CF_CD,
.cd_irq_str = "PCMCIA0 CD",
},
};
/* LoCoMo device */ /* LoCoMo device */
static struct resource locomo_resources[] = { static struct resource locomo_resources[] = {
...@@ -147,6 +156,9 @@ static void __init poodle_init(void) ...@@ -147,6 +156,9 @@ static void __init poodle_init(void)
set_pxa_fb_info(&poodle_fb_info); set_pxa_fb_info(&poodle_fb_info);
scoop_num = 1;
scoop_devs = &poodle_pcmcia_scoop[0];
ret = platform_add_devices(devices, ARRAY_SIZE(devices)); ret = platform_add_devices(devices, ARRAY_SIZE(devices));
if (ret) { if (ret) {
printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n"); printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
......
...@@ -20,27 +20,18 @@ ...@@ -20,27 +20,18 @@
#include <asm/hardware.h> #include <asm/hardware.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/hardware/scoop.h> #include <asm/hardware/scoop.h>
#include <asm/arch/corgi.h>
#include <asm/arch/pxa-regs.h> #include <asm/arch/pxa-regs.h>
#include "soc_common.h" #include "soc_common.h"
#define NO_KEEP_VS 0x0001 #define NO_KEEP_VS 0x0001
static unsigned char keep_vs; static void sharpsl_pcmcia_init_reset(struct scoop_pcmcia_dev *scoopdev)
static unsigned char keep_rd;
static struct pcmcia_irqs irqs[] = {
{ 0, CORGI_IRQ_GPIO_CF_CD, "PCMCIA0 CD"},
};
static void sharpsl_pcmcia_init_reset(void)
{ {
reset_scoop(&corgiscoop_device.dev); reset_scoop(scoopdev->dev);
keep_vs = NO_KEEP_VS; scoopdev->keep_vs = NO_KEEP_VS;
keep_rd = 0; scoopdev->keep_rd = 0;
} }
static int sharpsl_pcmcia_hw_init(struct soc_pcmcia_socket *skt) static int sharpsl_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
...@@ -71,29 +62,35 @@ static int sharpsl_pcmcia_hw_init(struct soc_pcmcia_socket *skt) ...@@ -71,29 +62,35 @@ static int sharpsl_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
pxa_gpio_mode(GPIO57_nIOIS16_MD); pxa_gpio_mode(GPIO57_nIOIS16_MD);
/* Register interrupts */ /* Register interrupts */
ret = soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); if (scoop_devs[skt->nr].cd_irq >= 0) {
struct pcmcia_irqs cd_irq;
if (ret) {
printk(KERN_ERR "Request for Compact Flash IRQ failed\n"); cd_irq.sock = skt->nr;
return ret; cd_irq.irq = scoop_devs[skt->nr].cd_irq;
cd_irq.str = scoop_devs[skt->nr].cd_irq_str;
ret = soc_pcmcia_request_irqs(skt, &cd_irq, 1);
if (ret) {
printk(KERN_ERR "Request for Compact Flash IRQ failed\n");
return ret;
}
} }
/* Enable interrupt */ skt->irq = scoop_devs[skt->nr].irq;
write_scoop_reg(&corgiscoop_device.dev, SCOOP_IMR, 0x00C0);
write_scoop_reg(&corgiscoop_device.dev, SCOOP_MCR, 0x0101);
keep_vs = NO_KEEP_VS;
skt->irq = CORGI_IRQ_GPIO_CF_IRQ;
return 0; return 0;
} }
static void sharpsl_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) static void sharpsl_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
{ {
soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); if (scoop_devs[skt->nr].cd_irq >= 0) {
struct pcmcia_irqs cd_irq;
/* CF_BUS_OFF */ cd_irq.sock = skt->nr;
sharpsl_pcmcia_init_reset(); cd_irq.irq = scoop_devs[skt->nr].cd_irq;
cd_irq.str = scoop_devs[skt->nr].cd_irq_str;
soc_pcmcia_free_irqs(skt, &cd_irq, 1);
}
} }
...@@ -101,31 +98,32 @@ static void sharpsl_pcmcia_socket_state(struct soc_pcmcia_socket *skt, ...@@ -101,31 +98,32 @@ static void sharpsl_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
struct pcmcia_state *state) struct pcmcia_state *state)
{ {
unsigned short cpr, csr; unsigned short cpr, csr;
struct device *scoop = scoop_devs[skt->nr].dev;
cpr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_CPR); cpr = read_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_CPR);
write_scoop_reg(&corgiscoop_device.dev, SCOOP_IRM, 0x00FF); write_scoop_reg(scoop, SCOOP_IRM, 0x00FF);
write_scoop_reg(&corgiscoop_device.dev, SCOOP_ISR, 0x0000); write_scoop_reg(scoop, SCOOP_ISR, 0x0000);
write_scoop_reg(&corgiscoop_device.dev, SCOOP_IRM, 0x0000); write_scoop_reg(scoop, SCOOP_IRM, 0x0000);
csr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_CSR); csr = read_scoop_reg(scoop, SCOOP_CSR);
if (csr & 0x0004) { if (csr & 0x0004) {
/* card eject */ /* card eject */
write_scoop_reg(&corgiscoop_device.dev, SCOOP_CDR, 0x0000); write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
keep_vs = NO_KEEP_VS; scoop_devs[skt->nr].keep_vs = NO_KEEP_VS;
} }
else if (!(keep_vs & NO_KEEP_VS)) { else if (!(scoop_devs[skt->nr].keep_vs & NO_KEEP_VS)) {
/* keep vs1,vs2 */ /* keep vs1,vs2 */
write_scoop_reg(&corgiscoop_device.dev, SCOOP_CDR, 0x0000); write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
csr |= keep_vs; csr |= scoop_devs[skt->nr].keep_vs;
} }
else if (cpr & 0x0003) { else if (cpr & 0x0003) {
/* power on */ /* power on */
write_scoop_reg(&corgiscoop_device.dev, SCOOP_CDR, 0x0000); write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
keep_vs = (csr & 0x00C0); scoop_devs[skt->nr].keep_vs = (csr & 0x00C0);
} }
else { else {
/* card detect */ /* card detect */
write_scoop_reg(&corgiscoop_device.dev, SCOOP_CDR, 0x0002); write_scoop_reg(scoop, SCOOP_CDR, 0x0002);
} }
state->detect = (csr & 0x0004) ? 0 : 1; state->detect = (csr & 0x0004) ? 0 : 1;
...@@ -147,6 +145,7 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, ...@@ -147,6 +145,7 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
const socket_state_t *state) const socket_state_t *state)
{ {
unsigned long flags; unsigned long flags;
struct device *scoop = scoop_devs[skt->nr].dev;
unsigned short cpr, ncpr, ccr, nccr, mcr, nmcr, imr, nimr; unsigned short cpr, ncpr, ccr, nccr, mcr, nmcr, imr, nimr;
...@@ -166,10 +165,10 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, ...@@ -166,10 +165,10 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
local_irq_save(flags); local_irq_save(flags);
nmcr = (mcr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_MCR)) & ~0x0010; nmcr = (mcr = read_scoop_reg(scoop, SCOOP_MCR)) & ~0x0010;
ncpr = (cpr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_CPR)) & ~0x0083; ncpr = (cpr = read_scoop_reg(scoop, SCOOP_CPR)) & ~0x0083;
nccr = (ccr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_CCR)) & ~0x0080; nccr = (ccr = read_scoop_reg(scoop, SCOOP_CCR)) & ~0x0080;
nimr = (imr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_IMR)) & ~0x003E; nimr = (imr = read_scoop_reg(scoop, SCOOP_IMR)) & ~0x003E;
ncpr |= (state->Vcc == 33) ? 0x0001 : ncpr |= (state->Vcc == 33) ? 0x0001 :
(state->Vcc == 50) ? 0x0002 : 0; (state->Vcc == 50) ? 0x0002 : 0;
...@@ -184,22 +183,22 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, ...@@ -184,22 +183,22 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
((skt->status&SS_WRPROT) ? 0x0008 : 0); ((skt->status&SS_WRPROT) ? 0x0008 : 0);
if (!(ncpr & 0x0003)) { if (!(ncpr & 0x0003)) {
keep_rd = 0; scoop_devs[skt->nr].keep_rd = 0;
} else if (!keep_rd) { } else if (!scoop_devs[skt->nr].keep_rd) {
if (nccr & 0x0080) if (nccr & 0x0080)
keep_rd = 1; scoop_devs[skt->nr].keep_rd = 1;
else else
nccr |= 0x0080; nccr |= 0x0080;
} }
if (mcr != nmcr) if (mcr != nmcr)
write_scoop_reg(&corgiscoop_device.dev, SCOOP_MCR, nmcr); write_scoop_reg(scoop, SCOOP_MCR, nmcr);
if (cpr != ncpr) if (cpr != ncpr)
write_scoop_reg(&corgiscoop_device.dev, SCOOP_CPR, ncpr); write_scoop_reg(scoop, SCOOP_CPR, ncpr);
if (ccr != nccr) if (ccr != nccr)
write_scoop_reg(&corgiscoop_device.dev, SCOOP_CCR, nccr); write_scoop_reg(scoop, SCOOP_CCR, nccr);
if (imr != nimr) if (imr != nimr)
write_scoop_reg(&corgiscoop_device.dev, SCOOP_IMR, nimr); write_scoop_reg(scoop, SCOOP_IMR, nimr);
local_irq_restore(flags); local_irq_restore(flags);
...@@ -208,10 +207,18 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, ...@@ -208,10 +207,18 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
static void sharpsl_pcmcia_socket_init(struct soc_pcmcia_socket *skt) static void sharpsl_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
{ {
sharpsl_pcmcia_init_reset(&scoop_devs[skt->nr]);
/* Enable interrupt */
write_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_IMR, 0x00C0);
write_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_MCR, 0x0101);
scoop_devs[skt->nr].keep_vs = NO_KEEP_VS;
} }
static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
{ {
/* CF_BUS_OFF */
sharpsl_pcmcia_init_reset(&scoop_devs[skt->nr]);
} }
static struct pcmcia_low_level sharpsl_pcmcia_ops = { static struct pcmcia_low_level sharpsl_pcmcia_ops = {
...@@ -223,7 +230,7 @@ static struct pcmcia_low_level sharpsl_pcmcia_ops = { ...@@ -223,7 +230,7 @@ static struct pcmcia_low_level sharpsl_pcmcia_ops = {
.socket_init = sharpsl_pcmcia_socket_init, .socket_init = sharpsl_pcmcia_socket_init,
.socket_suspend = sharpsl_pcmcia_socket_suspend, .socket_suspend = sharpsl_pcmcia_socket_suspend,
.first = 0, .first = 0,
.nr = 1, .nr = 0,
}; };
static struct platform_device *sharpsl_pcmcia_device; static struct platform_device *sharpsl_pcmcia_device;
...@@ -232,12 +239,15 @@ static int __init sharpsl_pcmcia_init(void) ...@@ -232,12 +239,15 @@ static int __init sharpsl_pcmcia_init(void)
{ {
int ret; int ret;
sharpsl_pcmcia_ops.nr=scoop_num;
sharpsl_pcmcia_device = kmalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL); sharpsl_pcmcia_device = kmalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL);
if (!sharpsl_pcmcia_device) if (!sharpsl_pcmcia_device)
return -ENOMEM; return -ENOMEM;
memset(sharpsl_pcmcia_device, 0, sizeof(*sharpsl_pcmcia_device)); memset(sharpsl_pcmcia_device, 0, sizeof(*sharpsl_pcmcia_device));
sharpsl_pcmcia_device->name = "pxa2xx-pcmcia"; sharpsl_pcmcia_device->name = "pxa2xx-pcmcia";
sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops; sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops;
sharpsl_pcmcia_device->dev.parent=scoop_devs[0].dev;
ret = platform_device_register(sharpsl_pcmcia_device); ret = platform_device_register(sharpsl_pcmcia_device);
if (ret) if (ret)
......
...@@ -40,6 +40,19 @@ struct scoop_config { ...@@ -40,6 +40,19 @@ struct scoop_config {
unsigned short io_dir; unsigned short io_dir;
}; };
/* Structure for linking scoop devices to PCMCIA sockets */
struct scoop_pcmcia_dev {
struct device *dev; /* Pointer to this socket's scoop device */
int irq; /* irq for socket */
int cd_irq;
const char *cd_irq_str;
unsigned char keep_vs;
unsigned char keep_rd;
};
extern int scoop_num;
extern struct scoop_pcmcia_dev *scoop_devs;
void reset_scoop(struct device *dev); void reset_scoop(struct device *dev);
unsigned short set_scoop_gpio(struct device *dev, unsigned short bit); unsigned short set_scoop_gpio(struct device *dev, unsigned short bit);
unsigned short reset_scoop_gpio(struct device *dev, unsigned short bit); unsigned short reset_scoop_gpio(struct device *dev, unsigned short bit);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册