aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/sa1111_generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pcmcia/sa1111_generic.c')
-rw-r--r--drivers/pcmcia/sa1111_generic.c65
1 files changed, 53 insertions, 12 deletions
diff --git a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c
index 4be4e172ffa1..de6bc333d299 100644
--- a/drivers/pcmcia/sa1111_generic.c
+++ b/drivers/pcmcia/sa1111_generic.c
@@ -28,23 +28,20 @@ static struct pcmcia_irqs irqs[] = {
28 { 1, IRQ_S1_BVD1_STSCHG, "SA1111 CF BVD1" }, 28 { 1, IRQ_S1_BVD1_STSCHG, "SA1111 CF BVD1" },
29}; 29};
30 30
31int sa1111_pcmcia_hw_init(struct soc_pcmcia_socket *skt) 31static int sa1111_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
32{ 32{
33 if (skt->irq == NO_IRQ)
34 skt->irq = skt->nr ? IRQ_S1_READY_NINT : IRQ_S0_READY_NINT;
35
36 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); 33 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
37} 34}
38 35
39void sa1111_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) 36static void sa1111_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
40{ 37{
41 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); 38 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
42} 39}
43 40
44void sa1111_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state) 41void sa1111_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
45{ 42{
46 struct sa1111_dev *sadev = SA1111_DEV(skt->dev); 43 struct sa1111_pcmcia_socket *s = to_skt(skt);
47 unsigned long status = sa1111_readl(sadev->mapbase + SA1111_PCSR); 44 unsigned long status = sa1111_readl(s->dev->mapbase + SA1111_PCSR);
48 45
49 switch (skt->nr) { 46 switch (skt->nr) {
50 case 0: 47 case 0:
@@ -71,7 +68,7 @@ void sa1111_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_sta
71 68
72int sa1111_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state) 69int sa1111_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
73{ 70{
74 struct sa1111_dev *sadev = SA1111_DEV(skt->dev); 71 struct sa1111_pcmcia_socket *s = to_skt(skt);
75 unsigned int pccr_skt_mask, pccr_set_mask, val; 72 unsigned int pccr_skt_mask, pccr_set_mask, val;
76 unsigned long flags; 73 unsigned long flags;
77 74
@@ -100,10 +97,10 @@ int sa1111_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_s
100 pccr_set_mask |= PCCR_S0_FLT|PCCR_S1_FLT; 97 pccr_set_mask |= PCCR_S0_FLT|PCCR_S1_FLT;
101 98
102 local_irq_save(flags); 99 local_irq_save(flags);
103 val = sa1111_readl(sadev->mapbase + SA1111_PCCR); 100 val = sa1111_readl(s->dev->mapbase + SA1111_PCCR);
104 val &= ~pccr_skt_mask; 101 val &= ~pccr_skt_mask;
105 val |= pccr_set_mask & pccr_skt_mask; 102 val |= pccr_set_mask & pccr_skt_mask;
106 sa1111_writel(val, sadev->mapbase + SA1111_PCCR); 103 sa1111_writel(val, s->dev->mapbase + SA1111_PCCR);
107 local_irq_restore(flags); 104 local_irq_restore(flags);
108 105
109 return 0; 106 return 0;
@@ -114,15 +111,51 @@ void sa1111_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
114 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs)); 111 soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
115} 112}
116 113
117void sa1111_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) 114static void sa1111_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
118{ 115{
119 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs)); 116 soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
120} 117}
121 118
119int sa1111_pcmcia_add(struct sa1111_dev *dev, struct pcmcia_low_level *ops,
120 int (*add)(struct soc_pcmcia_socket *))
121{
122 struct sa1111_pcmcia_socket *s;
123 int i, ret = 0;
124
125 ops->hw_init = sa1111_pcmcia_hw_init;
126 ops->hw_shutdown = sa1111_pcmcia_hw_shutdown;
127 ops->socket_state = sa1111_pcmcia_socket_state;
128 ops->socket_suspend = sa1111_pcmcia_socket_suspend;
129
130 for (i = 0; i < ops->nr; i++) {
131 s = kzalloc(sizeof(*s), GFP_KERNEL);
132 if (!s)
133 return -ENOMEM;
134
135 s->soc.nr = ops->first + i;
136 s->soc.ops = ops;
137 s->soc.socket.owner = ops->owner;
138 s->soc.socket.dev.parent = &dev->dev;
139 s->soc.socket.pci_irq = s->soc.nr ? IRQ_S1_READY_NINT : IRQ_S0_READY_NINT;
140 s->dev = dev;
141
142 ret = add(&s->soc);
143 if (ret == 0) {
144 s->next = dev_get_drvdata(&dev->dev);
145 dev_set_drvdata(&dev->dev, s);
146 } else
147 kfree(s);
148 }
149
150 return ret;
151}
152
122static int pcmcia_probe(struct sa1111_dev *dev) 153static int pcmcia_probe(struct sa1111_dev *dev)
123{ 154{
124 void __iomem *base; 155 void __iomem *base;
125 156
157 dev_set_drvdata(&dev->dev, NULL);
158
126 if (!request_mem_region(dev->res.start, 512, 159 if (!request_mem_region(dev->res.start, 512,
127 SA1111_DRIVER_NAME(dev))) 160 SA1111_DRIVER_NAME(dev)))
128 return -EBUSY; 161 return -EBUSY;
@@ -152,7 +185,15 @@ static int pcmcia_probe(struct sa1111_dev *dev)
152 185
153static int __devexit pcmcia_remove(struct sa1111_dev *dev) 186static int __devexit pcmcia_remove(struct sa1111_dev *dev)
154{ 187{
155 soc_common_drv_pcmcia_remove(&dev->dev); 188 struct sa1111_pcmcia_socket *next, *s = dev_get_drvdata(&dev->dev);
189
190 dev_set_drvdata(&dev->dev, NULL);
191
192 for (; next = s->next, s; s = next) {
193 soc_pcmcia_remove_one(&s->soc);
194 kfree(s);
195 }
196
156 release_mem_region(dev->res.start, 512); 197 release_mem_region(dev->res.start, 512);
157 return 0; 198 return 0;
158} 199}