Commit b393c696 authored by Eric Miao's avatar Eric Miao

[ARM] pxa: move PCMCIA definitions out of pxa-regs.h into pxa2xx_base.c

Move the processor specific initialization (largely resources initialization)
out of soc_common_drv_pcmcia_probe() into dedicated sa11xx_drv_pcmcia_probe()
and __pxa2xx_drv_pcmcia_probe().

By doing this, we are now able to move the PCMCIA related definitions out of
pxa-regs.h and back into pxa2xx_base.c.

As a result, remove that reference of _PCMCIA1IO in arch/arm/mach-pxa/viper.c.
Signed-off-by: default avatarEric Miao <eric.miao@marvell.com>
parent 5742964e
...@@ -27,44 +27,6 @@ ...@@ -27,44 +27,6 @@
#define PXA_CS5_PHYS 0x14000000 #define PXA_CS5_PHYS 0x14000000
/*
* Personal Computer Memory Card International Association (PCMCIA) sockets
*/
#define PCMCIAPrtSp 0x04000000 /* PCMCIA Partition Space [byte] */
#define PCMCIASp (4*PCMCIAPrtSp) /* PCMCIA Space [byte] */
#define PCMCIAIOSp PCMCIAPrtSp /* PCMCIA I/O Space [byte] */
#define PCMCIAAttrSp PCMCIAPrtSp /* PCMCIA Attribute Space [byte] */
#define PCMCIAMemSp PCMCIAPrtSp /* PCMCIA Memory Space [byte] */
#define PCMCIA0Sp PCMCIASp /* PCMCIA 0 Space [byte] */
#define PCMCIA0IOSp PCMCIAIOSp /* PCMCIA 0 I/O Space [byte] */
#define PCMCIA0AttrSp PCMCIAAttrSp /* PCMCIA 0 Attribute Space [byte] */
#define PCMCIA0MemSp PCMCIAMemSp /* PCMCIA 0 Memory Space [byte] */
#define PCMCIA1Sp PCMCIASp /* PCMCIA 1 Space [byte] */
#define PCMCIA1IOSp PCMCIAIOSp /* PCMCIA 1 I/O Space [byte] */
#define PCMCIA1AttrSp PCMCIAAttrSp /* PCMCIA 1 Attribute Space [byte] */
#define PCMCIA1MemSp PCMCIAMemSp /* PCMCIA 1 Memory Space [byte] */
#define _PCMCIA(Nb) /* PCMCIA [0..1] */ \
(0x20000000 + (Nb)*PCMCIASp)
#define _PCMCIAIO(Nb) _PCMCIA (Nb) /* PCMCIA I/O [0..1] */
#define _PCMCIAAttr(Nb) /* PCMCIA Attribute [0..1] */ \
(_PCMCIA (Nb) + 2*PCMCIAPrtSp)
#define _PCMCIAMem(Nb) /* PCMCIA Memory [0..1] */ \
(_PCMCIA (Nb) + 3*PCMCIAPrtSp)
#define _PCMCIA0 _PCMCIA (0) /* PCMCIA 0 */
#define _PCMCIA0IO _PCMCIAIO (0) /* PCMCIA 0 I/O */
#define _PCMCIA0Attr _PCMCIAAttr (0) /* PCMCIA 0 Attribute */
#define _PCMCIA0Mem _PCMCIAMem (0) /* PCMCIA 0 Memory */
#define _PCMCIA1 _PCMCIA (1) /* PCMCIA 1 */
#define _PCMCIA1IO _PCMCIAIO (1) /* PCMCIA 1 I/O */
#define _PCMCIA1Attr _PCMCIAAttr (1) /* PCMCIA 1 Attribute */
#define _PCMCIA1Mem _PCMCIAMem (1) /* PCMCIA 1 Memory */
/* /*
* Real Time Clock * Real Time Clock
*/ */
......
...@@ -953,7 +953,7 @@ static struct map_desc viper_io_desc[] __initdata = { ...@@ -953,7 +953,7 @@ static struct map_desc viper_io_desc[] __initdata = {
}, },
{ {
.virtual = VIPER_PC104IO_BASE, .virtual = VIPER_PC104IO_BASE,
.pfn = __phys_to_pfn(_PCMCIA1IO), .pfn = __phys_to_pfn(0x30000000),
.length = 0x00800000, .length = 0x00800000,
.type = MT_DEVICE, .type = MT_DEVICE,
}, },
......
...@@ -38,6 +38,44 @@ ...@@ -38,6 +38,44 @@
#include "soc_common.h" #include "soc_common.h"
#include "pxa2xx_base.h" #include "pxa2xx_base.h"
/*
* Personal Computer Memory Card International Association (PCMCIA) sockets
*/
#define PCMCIAPrtSp 0x04000000 /* PCMCIA Partition Space [byte] */
#define PCMCIASp (4*PCMCIAPrtSp) /* PCMCIA Space [byte] */
#define PCMCIAIOSp PCMCIAPrtSp /* PCMCIA I/O Space [byte] */
#define PCMCIAAttrSp PCMCIAPrtSp /* PCMCIA Attribute Space [byte] */
#define PCMCIAMemSp PCMCIAPrtSp /* PCMCIA Memory Space [byte] */
#define PCMCIA0Sp PCMCIASp /* PCMCIA 0 Space [byte] */
#define PCMCIA0IOSp PCMCIAIOSp /* PCMCIA 0 I/O Space [byte] */
#define PCMCIA0AttrSp PCMCIAAttrSp /* PCMCIA 0 Attribute Space [byte] */
#define PCMCIA0MemSp PCMCIAMemSp /* PCMCIA 0 Memory Space [byte] */
#define PCMCIA1Sp PCMCIASp /* PCMCIA 1 Space [byte] */
#define PCMCIA1IOSp PCMCIAIOSp /* PCMCIA 1 I/O Space [byte] */
#define PCMCIA1AttrSp PCMCIAAttrSp /* PCMCIA 1 Attribute Space [byte] */
#define PCMCIA1MemSp PCMCIAMemSp /* PCMCIA 1 Memory Space [byte] */
#define _PCMCIA(Nb) /* PCMCIA [0..1] */ \
(0x20000000 + (Nb) * PCMCIASp)
#define _PCMCIAIO(Nb) _PCMCIA(Nb) /* PCMCIA I/O [0..1] */
#define _PCMCIAAttr(Nb) /* PCMCIA Attribute [0..1] */ \
(_PCMCIA(Nb) + 2 * PCMCIAPrtSp)
#define _PCMCIAMem(Nb) /* PCMCIA Memory [0..1] */ \
(_PCMCIA(Nb) + 3 * PCMCIAPrtSp)
#define _PCMCIA0 _PCMCIA(0) /* PCMCIA 0 */
#define _PCMCIA0IO _PCMCIAIO(0) /* PCMCIA 0 I/O */
#define _PCMCIA0Attr _PCMCIAAttr(0) /* PCMCIA 0 Attribute */
#define _PCMCIA0Mem _PCMCIAMem(0) /* PCMCIA 0 Memory */
#define _PCMCIA1 _PCMCIA(1) /* PCMCIA 1 */
#define _PCMCIA1IO _PCMCIAIO(1) /* PCMCIA 1 I/O */
#define _PCMCIA1Attr _PCMCIAAttr(1) /* PCMCIA 1 Attribute */
#define _PCMCIA1Mem _PCMCIAMem(1) /* PCMCIA 1 Memory */
#define MCXX_SETUP_MASK (0x7f) #define MCXX_SETUP_MASK (0x7f)
#define MCXX_ASST_MASK (0x1f) #define MCXX_ASST_MASK (0x1f)
...@@ -182,23 +220,67 @@ static void pxa2xx_configure_sockets(struct device *dev) ...@@ -182,23 +220,67 @@ static void pxa2xx_configure_sockets(struct device *dev)
MECR &= ~MECR_NOS; MECR &= ~MECR_NOS;
} }
static const char *skt_names[] = {
"PCMCIA socket 0",
"PCMCIA socket 1",
};
#define SKT_DEV_INFO_SIZE(n) \
(sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket))
int __pxa2xx_drv_pcmcia_probe(struct device *dev) int __pxa2xx_drv_pcmcia_probe(struct device *dev)
{ {
int ret; int i, ret;
struct pcmcia_low_level *ops; struct pcmcia_low_level *ops;
struct skt_dev_info *sinfo;
struct soc_pcmcia_socket *skt;
if (!dev || !dev->platform_data) if (!dev || !dev->platform_data)
return -ENODEV; return -ENODEV;
ops = (struct pcmcia_low_level *)dev->platform_data; ops = (struct pcmcia_low_level *)dev->platform_data;
sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL);
if (!sinfo)
return -ENOMEM;
sinfo->nskt = ops->nr;
/* Initialize processor specific parameters */
for (i = 0; i < ops->nr; i++) {
skt = &sinfo->skt[i];
skt->nr = i;
skt->irq = NO_IRQ;
skt->res_skt.start = _PCMCIA(skt->nr);
skt->res_skt.end = _PCMCIA(skt->nr) + PCMCIASp - 1;
skt->res_skt.name = skt_names[skt->nr];
skt->res_skt.flags = IORESOURCE_MEM;
skt->res_io.start = _PCMCIAIO(skt->nr);
skt->res_io.end = _PCMCIAIO(skt->nr) + PCMCIAIOSp - 1;
skt->res_io.name = "io";
skt->res_io.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
skt->res_mem.start = _PCMCIAMem(skt->nr);
skt->res_mem.end = _PCMCIAMem(skt->nr) + PCMCIAMemSp - 1;
skt->res_mem.name = "memory";
skt->res_mem.flags = IORESOURCE_MEM;
skt->res_attr.start = _PCMCIAAttr(skt->nr);
skt->res_attr.end = _PCMCIAAttr(skt->nr) + PCMCIAAttrSp - 1;
skt->res_attr.name = "attribute";
skt->res_attr.flags = IORESOURCE_MEM;
}
/* Provide our PXA2xx specific timing routines. */ /* Provide our PXA2xx specific timing routines. */
ops->set_timing = pxa2xx_pcmcia_set_timing; ops->set_timing = pxa2xx_pcmcia_set_timing;
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ
ops->frequency_change = pxa2xx_pcmcia_frequency_change; ops->frequency_change = pxa2xx_pcmcia_frequency_change;
#endif #endif
ret = soc_common_drv_pcmcia_probe(dev, ops, ops->first, ops->nr); ret = soc_common_drv_pcmcia_probe(dev, ops, sinfo);
if (!ret) if (!ret)
pxa2xx_configure_sockets(dev); pxa2xx_configure_sockets(dev);
......
...@@ -163,9 +163,55 @@ sa1100_pcmcia_show_timing(struct soc_pcmcia_socket *skt, char *buf) ...@@ -163,9 +163,55 @@ sa1100_pcmcia_show_timing(struct soc_pcmcia_socket *skt, char *buf)
return p - buf; return p - buf;
} }
static const char *skt_names[] = {
"PCMCIA socket 0",
"PCMCIA socket 1",
};
#define SKT_DEV_INFO_SIZE(n) \
(sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket))
int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
int first, int nr) int first, int nr)
{ {
struct skt_dev_info *sinfo;
struct soc_pcmcia_socket *skt;
int i;
sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
if (!sinfo)
return -ENOMEM;
sinfo->nskt = nr;
/* Initiliaze processor specific parameters */
for (i = 0; i < nr; i++) {
skt = &sinfo->skt[i];
skt->nr = first + i;
skt->irq = NO_IRQ;
skt->res_skt.start = _PCMCIA(skt->nr);
skt->res_skt.end = _PCMCIA(skt->nr) + PCMCIASp - 1;
skt->res_skt.name = skt_names[skt->nr];
skt->res_skt.flags = IORESOURCE_MEM;
skt->res_io.start = _PCMCIAIO(skt->nr);
skt->res_io.end = _PCMCIAIO(skt->nr) + PCMCIAIOSp - 1;
skt->res_io.name = "io";
skt->res_io.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
skt->res_mem.start = _PCMCIAMem(skt->nr);
skt->res_mem.end = _PCMCIAMem(skt->nr) + PCMCIAMemSp - 1;
skt->res_mem.name = "memory";
skt->res_mem.flags = IORESOURCE_MEM;
skt->res_attr.start = _PCMCIAAttr(skt->nr);
skt->res_attr.end = _PCMCIAAttr(skt->nr) + PCMCIAAttrSp - 1;
skt->res_attr.name = "attribute";
skt->res_attr.flags = IORESOURCE_MEM;
}
/* /*
* set default MECR calculation if the board specific * set default MECR calculation if the board specific
* code did not specify one... * code did not specify one...
...@@ -180,7 +226,7 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, ...@@ -180,7 +226,7 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
ops->frequency_change = sa1100_pcmcia_frequency_change; ops->frequency_change = sa1100_pcmcia_frequency_change;
#endif #endif
return soc_common_drv_pcmcia_probe(dev, ops, first, nr); return soc_common_drv_pcmcia_probe(dev, ops, sinfo);
} }
EXPORT_SYMBOL(sa11xx_drv_pcmcia_probe); EXPORT_SYMBOL(sa11xx_drv_pcmcia_probe);
......
...@@ -49,11 +49,6 @@ ...@@ -49,11 +49,6 @@
#include "soc_common.h" #include "soc_common.h"
/* FIXME: platform dependent resource declaration has to move out of this file */
#ifdef CONFIG_ARCH_PXA
#include <mach/pxa-regs.h>
#endif
#ifdef CONFIG_PCMCIA_DEBUG #ifdef CONFIG_PCMCIA_DEBUG
static int pc_debug; static int pc_debug;
...@@ -581,19 +576,6 @@ EXPORT_SYMBOL(soc_pcmcia_enable_irqs); ...@@ -581,19 +576,6 @@ EXPORT_SYMBOL(soc_pcmcia_enable_irqs);
LIST_HEAD(soc_pcmcia_sockets); LIST_HEAD(soc_pcmcia_sockets);
static DEFINE_MUTEX(soc_pcmcia_sockets_lock); static DEFINE_MUTEX(soc_pcmcia_sockets_lock);
static const char *skt_names[] = {
"PCMCIA socket 0",
"PCMCIA socket 1",
};
struct skt_dev_info {
int nskt;
struct soc_pcmcia_socket skt[0];
};
#define SKT_DEV_INFO_SIZE(n) \
(sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket))
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ
static int static int
soc_pcmcia_notifier(struct notifier_block *nb, unsigned long val, void *data) soc_pcmcia_notifier(struct notifier_block *nb, unsigned long val, void *data)
...@@ -637,26 +619,18 @@ static int soc_pcmcia_cpufreq_register(void) { return 0; } ...@@ -637,26 +619,18 @@ static int soc_pcmcia_cpufreq_register(void) { return 0; }
static void soc_pcmcia_cpufreq_unregister(void) {} static void soc_pcmcia_cpufreq_unregister(void) {}
#endif #endif
int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr) int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
struct skt_dev_info *sinfo)
{ {
struct skt_dev_info *sinfo;
struct soc_pcmcia_socket *skt; struct soc_pcmcia_socket *skt;
int ret, i; int ret, i;
mutex_lock(&soc_pcmcia_sockets_lock); mutex_lock(&soc_pcmcia_sockets_lock);
sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
if (!sinfo) {
ret = -ENOMEM;
goto out;
}
sinfo->nskt = nr;
/* /*
* Initialise the per-socket structure. * Initialise the per-socket structure.
*/ */
for (i = 0; i < nr; i++) { for (i = 0; i < sinfo->nskt; i++) {
skt = &sinfo->skt[i]; skt = &sinfo->skt[i];
skt->socket.ops = &soc_common_pcmcia_operations; skt->socket.ops = &soc_common_pcmcia_operations;
...@@ -668,43 +642,21 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops ...@@ -668,43 +642,21 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops
skt->poll_timer.data = (unsigned long)skt; skt->poll_timer.data = (unsigned long)skt;
skt->poll_timer.expires = jiffies + SOC_PCMCIA_POLL_PERIOD; skt->poll_timer.expires = jiffies + SOC_PCMCIA_POLL_PERIOD;
skt->nr = first + i;
skt->irq = NO_IRQ;
skt->dev = dev; skt->dev = dev;
skt->ops = ops; skt->ops = ops;
skt->res_skt.start = _PCMCIA(skt->nr);
skt->res_skt.end = _PCMCIA(skt->nr) + PCMCIASp - 1;
skt->res_skt.name = skt_names[skt->nr];
skt->res_skt.flags = IORESOURCE_MEM;
ret = request_resource(&iomem_resource, &skt->res_skt); ret = request_resource(&iomem_resource, &skt->res_skt);
if (ret) if (ret)
goto out_err_1; goto out_err_1;
skt->res_io.start = _PCMCIAIO(skt->nr);
skt->res_io.end = _PCMCIAIO(skt->nr) + PCMCIAIOSp - 1;
skt->res_io.name = "io";
skt->res_io.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
ret = request_resource(&skt->res_skt, &skt->res_io); ret = request_resource(&skt->res_skt, &skt->res_io);
if (ret) if (ret)
goto out_err_2; goto out_err_2;
skt->res_mem.start = _PCMCIAMem(skt->nr);
skt->res_mem.end = _PCMCIAMem(skt->nr) + PCMCIAMemSp - 1;
skt->res_mem.name = "memory";
skt->res_mem.flags = IORESOURCE_MEM;
ret = request_resource(&skt->res_skt, &skt->res_mem); ret = request_resource(&skt->res_skt, &skt->res_mem);
if (ret) if (ret)
goto out_err_3; goto out_err_3;
skt->res_attr.start = _PCMCIAAttr(skt->nr);
skt->res_attr.end = _PCMCIAAttr(skt->nr) + PCMCIAAttrSp - 1;
skt->res_attr.name = "attribute";
skt->res_attr.flags = IORESOURCE_MEM;
ret = request_resource(&skt->res_skt, &skt->res_attr); ret = request_resource(&skt->res_skt, &skt->res_attr);
if (ret) if (ret)
goto out_err_4; goto out_err_4;
......
...@@ -58,6 +58,11 @@ struct soc_pcmcia_socket { ...@@ -58,6 +58,11 @@ struct soc_pcmcia_socket {
struct list_head node; struct list_head node;
}; };
struct skt_dev_info {
int nskt;
struct soc_pcmcia_socket skt[0];
};
struct pcmcia_state { struct pcmcia_state {
unsigned detect: 1, unsigned detect: 1,
ready: 1, ready: 1,
...@@ -132,7 +137,7 @@ extern void soc_common_pcmcia_get_timing(struct soc_pcmcia_socket *, struct soc_ ...@@ -132,7 +137,7 @@ extern void soc_common_pcmcia_get_timing(struct soc_pcmcia_socket *, struct soc_
extern struct list_head soc_pcmcia_sockets; extern struct list_head soc_pcmcia_sockets;
extern int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr); extern int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, struct skt_dev_info *sinfo);
extern int soc_common_drv_pcmcia_remove(struct device *dev); extern int soc_common_drv_pcmcia_remove(struct device *dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment