Commit b393c69652333be31ad7a8205761c0d5b7f3e167

Authored by Eric Miao
1 parent 5742964e91

[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: Eric Miao <eric.miao@marvell.com>

Showing 6 changed files with 141 additions and 94 deletions Side-by-side Diff

arch/arm/mach-pxa/include/mach/pxa-regs.h
... ... @@ -28,44 +28,6 @@
28 28  
29 29  
30 30 /*
31   - * Personal Computer Memory Card International Association (PCMCIA) sockets
32   - */
33   -
34   -#define PCMCIAPrtSp 0x04000000 /* PCMCIA Partition Space [byte] */
35   -#define PCMCIASp (4*PCMCIAPrtSp) /* PCMCIA Space [byte] */
36   -#define PCMCIAIOSp PCMCIAPrtSp /* PCMCIA I/O Space [byte] */
37   -#define PCMCIAAttrSp PCMCIAPrtSp /* PCMCIA Attribute Space [byte] */
38   -#define PCMCIAMemSp PCMCIAPrtSp /* PCMCIA Memory Space [byte] */
39   -
40   -#define PCMCIA0Sp PCMCIASp /* PCMCIA 0 Space [byte] */
41   -#define PCMCIA0IOSp PCMCIAIOSp /* PCMCIA 0 I/O Space [byte] */
42   -#define PCMCIA0AttrSp PCMCIAAttrSp /* PCMCIA 0 Attribute Space [byte] */
43   -#define PCMCIA0MemSp PCMCIAMemSp /* PCMCIA 0 Memory Space [byte] */
44   -
45   -#define PCMCIA1Sp PCMCIASp /* PCMCIA 1 Space [byte] */
46   -#define PCMCIA1IOSp PCMCIAIOSp /* PCMCIA 1 I/O Space [byte] */
47   -#define PCMCIA1AttrSp PCMCIAAttrSp /* PCMCIA 1 Attribute Space [byte] */
48   -#define PCMCIA1MemSp PCMCIAMemSp /* PCMCIA 1 Memory Space [byte] */
49   -
50   -#define _PCMCIA(Nb) /* PCMCIA [0..1] */ \
51   - (0x20000000 + (Nb)*PCMCIASp)
52   -#define _PCMCIAIO(Nb) _PCMCIA (Nb) /* PCMCIA I/O [0..1] */
53   -#define _PCMCIAAttr(Nb) /* PCMCIA Attribute [0..1] */ \
54   - (_PCMCIA (Nb) + 2*PCMCIAPrtSp)
55   -#define _PCMCIAMem(Nb) /* PCMCIA Memory [0..1] */ \
56   - (_PCMCIA (Nb) + 3*PCMCIAPrtSp)
57   -
58   -#define _PCMCIA0 _PCMCIA (0) /* PCMCIA 0 */
59   -#define _PCMCIA0IO _PCMCIAIO (0) /* PCMCIA 0 I/O */
60   -#define _PCMCIA0Attr _PCMCIAAttr (0) /* PCMCIA 0 Attribute */
61   -#define _PCMCIA0Mem _PCMCIAMem (0) /* PCMCIA 0 Memory */
62   -
63   -#define _PCMCIA1 _PCMCIA (1) /* PCMCIA 1 */
64   -#define _PCMCIA1IO _PCMCIAIO (1) /* PCMCIA 1 I/O */
65   -#define _PCMCIA1Attr _PCMCIAAttr (1) /* PCMCIA 1 Attribute */
66   -#define _PCMCIA1Mem _PCMCIAMem (1) /* PCMCIA 1 Memory */
67   -
68   -/*
69 31 * Real Time Clock
70 32 */
71 33  
arch/arm/mach-pxa/viper.c
... ... @@ -953,7 +953,7 @@
953 953 },
954 954 {
955 955 .virtual = VIPER_PC104IO_BASE,
956   - .pfn = __phys_to_pfn(_PCMCIA1IO),
  956 + .pfn = __phys_to_pfn(0x30000000),
957 957 .length = 0x00800000,
958 958 .type = MT_DEVICE,
959 959 },
drivers/pcmcia/pxa2xx_base.c
... ... @@ -38,7 +38,45 @@
38 38 #include "soc_common.h"
39 39 #include "pxa2xx_base.h"
40 40  
  41 +/*
  42 + * Personal Computer Memory Card International Association (PCMCIA) sockets
  43 + */
41 44  
  45 +#define PCMCIAPrtSp 0x04000000 /* PCMCIA Partition Space [byte] */
  46 +#define PCMCIASp (4*PCMCIAPrtSp) /* PCMCIA Space [byte] */
  47 +#define PCMCIAIOSp PCMCIAPrtSp /* PCMCIA I/O Space [byte] */
  48 +#define PCMCIAAttrSp PCMCIAPrtSp /* PCMCIA Attribute Space [byte] */
  49 +#define PCMCIAMemSp PCMCIAPrtSp /* PCMCIA Memory Space [byte] */
  50 +
  51 +#define PCMCIA0Sp PCMCIASp /* PCMCIA 0 Space [byte] */
  52 +#define PCMCIA0IOSp PCMCIAIOSp /* PCMCIA 0 I/O Space [byte] */
  53 +#define PCMCIA0AttrSp PCMCIAAttrSp /* PCMCIA 0 Attribute Space [byte] */
  54 +#define PCMCIA0MemSp PCMCIAMemSp /* PCMCIA 0 Memory Space [byte] */
  55 +
  56 +#define PCMCIA1Sp PCMCIASp /* PCMCIA 1 Space [byte] */
  57 +#define PCMCIA1IOSp PCMCIAIOSp /* PCMCIA 1 I/O Space [byte] */
  58 +#define PCMCIA1AttrSp PCMCIAAttrSp /* PCMCIA 1 Attribute Space [byte] */
  59 +#define PCMCIA1MemSp PCMCIAMemSp /* PCMCIA 1 Memory Space [byte] */
  60 +
  61 +#define _PCMCIA(Nb) /* PCMCIA [0..1] */ \
  62 + (0x20000000 + (Nb) * PCMCIASp)
  63 +#define _PCMCIAIO(Nb) _PCMCIA(Nb) /* PCMCIA I/O [0..1] */
  64 +#define _PCMCIAAttr(Nb) /* PCMCIA Attribute [0..1] */ \
  65 + (_PCMCIA(Nb) + 2 * PCMCIAPrtSp)
  66 +#define _PCMCIAMem(Nb) /* PCMCIA Memory [0..1] */ \
  67 + (_PCMCIA(Nb) + 3 * PCMCIAPrtSp)
  68 +
  69 +#define _PCMCIA0 _PCMCIA(0) /* PCMCIA 0 */
  70 +#define _PCMCIA0IO _PCMCIAIO(0) /* PCMCIA 0 I/O */
  71 +#define _PCMCIA0Attr _PCMCIAAttr(0) /* PCMCIA 0 Attribute */
  72 +#define _PCMCIA0Mem _PCMCIAMem(0) /* PCMCIA 0 Memory */
  73 +
  74 +#define _PCMCIA1 _PCMCIA(1) /* PCMCIA 1 */
  75 +#define _PCMCIA1IO _PCMCIAIO(1) /* PCMCIA 1 I/O */
  76 +#define _PCMCIA1Attr _PCMCIAAttr(1) /* PCMCIA 1 Attribute */
  77 +#define _PCMCIA1Mem _PCMCIAMem(1) /* PCMCIA 1 Memory */
  78 +
  79 +
42 80 #define MCXX_SETUP_MASK (0x7f)
43 81 #define MCXX_ASST_MASK (0x1f)
44 82 #define MCXX_HOLD_MASK (0x3f)
45 83  
46 84  
47 85  
48 86  
... ... @@ -182,23 +220,67 @@
182 220 MECR &= ~MECR_NOS;
183 221 }
184 222  
  223 +static const char *skt_names[] = {
  224 + "PCMCIA socket 0",
  225 + "PCMCIA socket 1",
  226 +};
  227 +
  228 +#define SKT_DEV_INFO_SIZE(n) \
  229 + (sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket))
  230 +
185 231 int __pxa2xx_drv_pcmcia_probe(struct device *dev)
186 232 {
187   - int ret;
  233 + int i, ret;
188 234 struct pcmcia_low_level *ops;
  235 + struct skt_dev_info *sinfo;
  236 + struct soc_pcmcia_socket *skt;
189 237  
190 238 if (!dev || !dev->platform_data)
191 239 return -ENODEV;
192 240  
193 241 ops = (struct pcmcia_low_level *)dev->platform_data;
194 242  
  243 + sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL);
  244 + if (!sinfo)
  245 + return -ENOMEM;
  246 +
  247 + sinfo->nskt = ops->nr;
  248 +
  249 + /* Initialize processor specific parameters */
  250 + for (i = 0; i < ops->nr; i++) {
  251 + skt = &sinfo->skt[i];
  252 +
  253 + skt->nr = i;
  254 + skt->irq = NO_IRQ;
  255 +
  256 + skt->res_skt.start = _PCMCIA(skt->nr);
  257 + skt->res_skt.end = _PCMCIA(skt->nr) + PCMCIASp - 1;
  258 + skt->res_skt.name = skt_names[skt->nr];
  259 + skt->res_skt.flags = IORESOURCE_MEM;
  260 +
  261 + skt->res_io.start = _PCMCIAIO(skt->nr);
  262 + skt->res_io.end = _PCMCIAIO(skt->nr) + PCMCIAIOSp - 1;
  263 + skt->res_io.name = "io";
  264 + skt->res_io.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
  265 +
  266 + skt->res_mem.start = _PCMCIAMem(skt->nr);
  267 + skt->res_mem.end = _PCMCIAMem(skt->nr) + PCMCIAMemSp - 1;
  268 + skt->res_mem.name = "memory";
  269 + skt->res_mem.flags = IORESOURCE_MEM;
  270 +
  271 + skt->res_attr.start = _PCMCIAAttr(skt->nr);
  272 + skt->res_attr.end = _PCMCIAAttr(skt->nr) + PCMCIAAttrSp - 1;
  273 + skt->res_attr.name = "attribute";
  274 + skt->res_attr.flags = IORESOURCE_MEM;
  275 + }
  276 +
195 277 /* Provide our PXA2xx specific timing routines. */
196 278 ops->set_timing = pxa2xx_pcmcia_set_timing;
197 279 #ifdef CONFIG_CPU_FREQ
198 280 ops->frequency_change = pxa2xx_pcmcia_frequency_change;
199 281 #endif
200 282  
201   - ret = soc_common_drv_pcmcia_probe(dev, ops, ops->first, ops->nr);
  283 + ret = soc_common_drv_pcmcia_probe(dev, ops, sinfo);
202 284  
203 285 if (!ret)
204 286 pxa2xx_configure_sockets(dev);
drivers/pcmcia/sa11xx_base.c
... ... @@ -163,9 +163,55 @@
163 163 return p - buf;
164 164 }
165 165  
  166 +static const char *skt_names[] = {
  167 + "PCMCIA socket 0",
  168 + "PCMCIA socket 1",
  169 +};
  170 +
  171 +#define SKT_DEV_INFO_SIZE(n) \
  172 + (sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket))
  173 +
166 174 int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
167 175 int first, int nr)
168 176 {
  177 + struct skt_dev_info *sinfo;
  178 + struct soc_pcmcia_socket *skt;
  179 + int i;
  180 +
  181 + sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
  182 + if (!sinfo)
  183 + return -ENOMEM;
  184 +
  185 + sinfo->nskt = nr;
  186 +
  187 + /* Initiliaze processor specific parameters */
  188 + for (i = 0; i < nr; i++) {
  189 + skt = &sinfo->skt[i];
  190 +
  191 + skt->nr = first + i;
  192 + skt->irq = NO_IRQ;
  193 +
  194 + skt->res_skt.start = _PCMCIA(skt->nr);
  195 + skt->res_skt.end = _PCMCIA(skt->nr) + PCMCIASp - 1;
  196 + skt->res_skt.name = skt_names[skt->nr];
  197 + skt->res_skt.flags = IORESOURCE_MEM;
  198 +
  199 + skt->res_io.start = _PCMCIAIO(skt->nr);
  200 + skt->res_io.end = _PCMCIAIO(skt->nr) + PCMCIAIOSp - 1;
  201 + skt->res_io.name = "io";
  202 + skt->res_io.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
  203 +
  204 + skt->res_mem.start = _PCMCIAMem(skt->nr);
  205 + skt->res_mem.end = _PCMCIAMem(skt->nr) + PCMCIAMemSp - 1;
  206 + skt->res_mem.name = "memory";
  207 + skt->res_mem.flags = IORESOURCE_MEM;
  208 +
  209 + skt->res_attr.start = _PCMCIAAttr(skt->nr);
  210 + skt->res_attr.end = _PCMCIAAttr(skt->nr) + PCMCIAAttrSp - 1;
  211 + skt->res_attr.name = "attribute";
  212 + skt->res_attr.flags = IORESOURCE_MEM;
  213 + }
  214 +
169 215 /*
170 216 * set default MECR calculation if the board specific
171 217 * code did not specify one...
... ... @@ -180,7 +226,7 @@
180 226 ops->frequency_change = sa1100_pcmcia_frequency_change;
181 227 #endif
182 228  
183   - return soc_common_drv_pcmcia_probe(dev, ops, first, nr);
  229 + return soc_common_drv_pcmcia_probe(dev, ops, sinfo);
184 230 }
185 231 EXPORT_SYMBOL(sa11xx_drv_pcmcia_probe);
186 232  
drivers/pcmcia/soc_common.c
... ... @@ -49,11 +49,6 @@
49 49  
50 50 #include "soc_common.h"
51 51  
52   -/* FIXME: platform dependent resource declaration has to move out of this file */
53   -#ifdef CONFIG_ARCH_PXA
54   -#include <mach/pxa-regs.h>
55   -#endif
56   -
57 52 #ifdef CONFIG_PCMCIA_DEBUG
58 53  
59 54 static int pc_debug;
... ... @@ -581,19 +576,6 @@
581 576 LIST_HEAD(soc_pcmcia_sockets);
582 577 static DEFINE_MUTEX(soc_pcmcia_sockets_lock);
583 578  
584   -static const char *skt_names[] = {
585   - "PCMCIA socket 0",
586   - "PCMCIA socket 1",
587   -};
588   -
589   -struct skt_dev_info {
590   - int nskt;
591   - struct soc_pcmcia_socket skt[0];
592   -};
593   -
594   -#define SKT_DEV_INFO_SIZE(n) \
595   - (sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket))
596   -
597 579 #ifdef CONFIG_CPU_FREQ
598 580 static int
599 581 soc_pcmcia_notifier(struct notifier_block *nb, unsigned long val, void *data)
600 582  
601 583  
602 584  
... ... @@ -637,26 +619,18 @@
637 619 static void soc_pcmcia_cpufreq_unregister(void) {}
638 620 #endif
639 621  
640   -int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr)
  622 +int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
  623 + struct skt_dev_info *sinfo)
641 624 {
642   - struct skt_dev_info *sinfo;
643 625 struct soc_pcmcia_socket *skt;
644 626 int ret, i;
645 627  
646 628 mutex_lock(&soc_pcmcia_sockets_lock);
647 629  
648   - sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
649   - if (!sinfo) {
650   - ret = -ENOMEM;
651   - goto out;
652   - }
653   -
654   - sinfo->nskt = nr;
655   -
656 630 /*
657 631 * Initialise the per-socket structure.
658 632 */
659   - for (i = 0; i < nr; i++) {
  633 + for (i = 0; i < sinfo->nskt; i++) {
660 634 skt = &sinfo->skt[i];
661 635  
662 636 skt->socket.ops = &soc_common_pcmcia_operations;
663 637  
664 638  
665 639  
666 640  
... ... @@ -668,42 +642,20 @@
668 642 skt->poll_timer.data = (unsigned long)skt;
669 643 skt->poll_timer.expires = jiffies + SOC_PCMCIA_POLL_PERIOD;
670 644  
671   - skt->nr = first + i;
672   - skt->irq = NO_IRQ;
673 645 skt->dev = dev;
674 646 skt->ops = ops;
675 647  
676   - skt->res_skt.start = _PCMCIA(skt->nr);
677   - skt->res_skt.end = _PCMCIA(skt->nr) + PCMCIASp - 1;
678   - skt->res_skt.name = skt_names[skt->nr];
679   - skt->res_skt.flags = IORESOURCE_MEM;
680   -
681 648 ret = request_resource(&iomem_resource, &skt->res_skt);
682 649 if (ret)
683 650 goto out_err_1;
684 651  
685   - skt->res_io.start = _PCMCIAIO(skt->nr);
686   - skt->res_io.end = _PCMCIAIO(skt->nr) + PCMCIAIOSp - 1;
687   - skt->res_io.name = "io";
688   - skt->res_io.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
689   -
690 652 ret = request_resource(&skt->res_skt, &skt->res_io);
691 653 if (ret)
692 654 goto out_err_2;
693 655  
694   - skt->res_mem.start = _PCMCIAMem(skt->nr);
695   - skt->res_mem.end = _PCMCIAMem(skt->nr) + PCMCIAMemSp - 1;
696   - skt->res_mem.name = "memory";
697   - skt->res_mem.flags = IORESOURCE_MEM;
698   -
699 656 ret = request_resource(&skt->res_skt, &skt->res_mem);
700 657 if (ret)
701 658 goto out_err_3;
702   -
703   - skt->res_attr.start = _PCMCIAAttr(skt->nr);
704   - skt->res_attr.end = _PCMCIAAttr(skt->nr) + PCMCIAAttrSp - 1;
705   - skt->res_attr.name = "attribute";
706   - skt->res_attr.flags = IORESOURCE_MEM;
707 659  
708 660 ret = request_resource(&skt->res_skt, &skt->res_attr);
709 661 if (ret)
drivers/pcmcia/soc_common.h
... ... @@ -58,6 +58,11 @@
58 58 struct list_head node;
59 59 };
60 60  
  61 +struct skt_dev_info {
  62 + int nskt;
  63 + struct soc_pcmcia_socket skt[0];
  64 +};
  65 +
61 66 struct pcmcia_state {
62 67 unsigned detect: 1,
63 68 ready: 1,
... ... @@ -132,7 +137,7 @@
132 137  
133 138 extern struct list_head soc_pcmcia_sockets;
134 139  
135   -extern int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr);
  140 +extern int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, struct skt_dev_info *sinfo);
136 141 extern int soc_common_drv_pcmcia_remove(struct device *dev);
137 142  
138 143