diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-08-06 13:10:25 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-08-06 13:10:25 -0400 |
commit | f165eb77f49cb6f6e86e2f2f09183904b2965d19 (patch) | |
tree | db166579758930f52a1a625eb872bd96bd7ff88e /drivers | |
parent | fc1caf6eafb30ea185720e29f7f5eccca61ecd60 (diff) | |
parent | a6cd7eb374647b572ae9e7dbfe49871e6996e8e0 (diff) |
Merge branch 'devel' of git://git.kernel.org/pub/scm/linux/kernel/git/ycmiao/pxa-linux-2.6 into devel-stable
Conflicts:
arch/arm/mach-pxa/palmt5.c
arch/arm/mach-pxa/palmtreo.c
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ata/Kconfig | 11 | ||||
-rw-r--r-- | drivers/ata/Makefile | 2 | ||||
-rw-r--r-- | drivers/ata/pata_pxa.c | 411 | ||||
-rw-r--r-- | drivers/pcmcia/Kconfig | 2 | ||||
-rw-r--r-- | drivers/pcmcia/Makefile | 1 | ||||
-rw-r--r-- | drivers/pcmcia/pxa2xx_balloon3.c | 158 | ||||
-rw-r--r-- | drivers/power/wm97xx_battery.c | 16 |
7 files changed, 584 insertions, 17 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index aa85a98d3a4f..25e030f9a3e6 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -642,6 +642,17 @@ config PATA_VIA | |||
642 | 642 | ||
643 | If unsure, say N. | 643 | If unsure, say N. |
644 | 644 | ||
645 | config PATA_PXA | ||
646 | tristate "PXA DMA-capable PATA support" | ||
647 | depends on ARCH_PXA | ||
648 | help | ||
649 | This option enables support for harddrive attached to PXA CPU's bus. | ||
650 | |||
651 | NOTE: This driver utilizes PXA DMA controller, in case your hardware | ||
652 | is not capable of doing MWDMA, use pata_platform instead. | ||
653 | |||
654 | If unsure, say N. | ||
655 | |||
645 | config PATA_WINBOND | 656 | config PATA_WINBOND |
646 | tristate "Winbond SL82C105 PATA support" | 657 | tristate "Winbond SL82C105 PATA support" |
647 | depends on PCI | 658 | depends on PCI |
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index 7ef89d73df63..e87d644b8ed2 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile | |||
@@ -89,6 +89,8 @@ obj-$(CONFIG_PATA_RB532) += pata_rb532_cf.o | |||
89 | obj-$(CONFIG_PATA_RZ1000) += pata_rz1000.o | 89 | obj-$(CONFIG_PATA_RZ1000) += pata_rz1000.o |
90 | obj-$(CONFIG_PATA_WINBOND_VLB) += pata_winbond.o | 90 | obj-$(CONFIG_PATA_WINBOND_VLB) += pata_winbond.o |
91 | 91 | ||
92 | obj-$(CONFIG_PATA_PXA) += pata_pxa.o | ||
93 | |||
92 | # Should be last but two libata driver | 94 | # Should be last but two libata driver |
93 | obj-$(CONFIG_PATA_ACPI) += pata_acpi.o | 95 | obj-$(CONFIG_PATA_ACPI) += pata_acpi.o |
94 | # Should be last but one libata driver | 96 | # Should be last but one libata driver |
diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c new file mode 100644 index 000000000000..1898c6ed4b4e --- /dev/null +++ b/drivers/ata/pata_pxa.c | |||
@@ -0,0 +1,411 @@ | |||
1 | /* | ||
2 | * Generic PXA PATA driver | ||
3 | * | ||
4 | * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2, or (at your option) | ||
9 | * any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; see the file COPYING. If not, write to | ||
18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/blkdev.h> | ||
25 | #include <linux/ata.h> | ||
26 | #include <linux/libata.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/gpio.h> | ||
29 | #include <linux/slab.h> | ||
30 | #include <linux/completion.h> | ||
31 | |||
32 | #include <scsi/scsi_host.h> | ||
33 | |||
34 | #include <mach/pxa2xx-regs.h> | ||
35 | #include <mach/pata_pxa.h> | ||
36 | #include <mach/dma.h> | ||
37 | |||
38 | #define DRV_NAME "pata_pxa" | ||
39 | #define DRV_VERSION "0.1" | ||
40 | |||
41 | struct pata_pxa_data { | ||
42 | uint32_t dma_channel; | ||
43 | struct pxa_dma_desc *dma_desc; | ||
44 | dma_addr_t dma_desc_addr; | ||
45 | uint32_t dma_desc_id; | ||
46 | |||
47 | /* DMA IO physical address */ | ||
48 | uint32_t dma_io_addr; | ||
49 | /* PXA DREQ<0:2> pin selector */ | ||
50 | uint32_t dma_dreq; | ||
51 | /* DMA DCSR register value */ | ||
52 | uint32_t dma_dcsr; | ||
53 | |||
54 | struct completion dma_done; | ||
55 | }; | ||
56 | |||
57 | /* | ||
58 | * Setup the DMA descriptors. The size is transfer capped at 4k per descriptor, | ||
59 | * if the transfer is longer, it is split into multiple chained descriptors. | ||
60 | */ | ||
61 | static void pxa_load_dmac(struct scatterlist *sg, struct ata_queued_cmd *qc) | ||
62 | { | ||
63 | struct pata_pxa_data *pd = qc->ap->private_data; | ||
64 | |||
65 | uint32_t cpu_len, seg_len; | ||
66 | dma_addr_t cpu_addr; | ||
67 | |||
68 | cpu_addr = sg_dma_address(sg); | ||
69 | cpu_len = sg_dma_len(sg); | ||
70 | |||
71 | do { | ||
72 | seg_len = (cpu_len > 0x1000) ? 0x1000 : cpu_len; | ||
73 | |||
74 | pd->dma_desc[pd->dma_desc_id].ddadr = pd->dma_desc_addr + | ||
75 | ((pd->dma_desc_id + 1) * sizeof(struct pxa_dma_desc)); | ||
76 | |||
77 | pd->dma_desc[pd->dma_desc_id].dcmd = DCMD_BURST32 | | ||
78 | DCMD_WIDTH2 | (DCMD_LENGTH & seg_len); | ||
79 | |||
80 | if (qc->tf.flags & ATA_TFLAG_WRITE) { | ||
81 | pd->dma_desc[pd->dma_desc_id].dsadr = cpu_addr; | ||
82 | pd->dma_desc[pd->dma_desc_id].dtadr = pd->dma_io_addr; | ||
83 | pd->dma_desc[pd->dma_desc_id].dcmd |= DCMD_INCSRCADDR | | ||
84 | DCMD_FLOWTRG; | ||
85 | } else { | ||
86 | pd->dma_desc[pd->dma_desc_id].dsadr = pd->dma_io_addr; | ||
87 | pd->dma_desc[pd->dma_desc_id].dtadr = cpu_addr; | ||
88 | pd->dma_desc[pd->dma_desc_id].dcmd |= DCMD_INCTRGADDR | | ||
89 | DCMD_FLOWSRC; | ||
90 | } | ||
91 | |||
92 | cpu_len -= seg_len; | ||
93 | cpu_addr += seg_len; | ||
94 | pd->dma_desc_id++; | ||
95 | |||
96 | } while (cpu_len); | ||
97 | |||
98 | /* Should not happen */ | ||
99 | if (seg_len & 0x1f) | ||
100 | DALGN |= (1 << pd->dma_dreq); | ||
101 | } | ||
102 | |||
103 | /* | ||
104 | * Prepare taskfile for submission. | ||
105 | */ | ||
106 | static void pxa_qc_prep(struct ata_queued_cmd *qc) | ||
107 | { | ||
108 | struct pata_pxa_data *pd = qc->ap->private_data; | ||
109 | int si = 0; | ||
110 | struct scatterlist *sg; | ||
111 | |||
112 | if (!(qc->flags & ATA_QCFLAG_DMAMAP)) | ||
113 | return; | ||
114 | |||
115 | pd->dma_desc_id = 0; | ||
116 | |||
117 | DCSR(pd->dma_channel) = 0; | ||
118 | DALGN &= ~(1 << pd->dma_dreq); | ||
119 | |||
120 | for_each_sg(qc->sg, sg, qc->n_elem, si) | ||
121 | pxa_load_dmac(sg, qc); | ||
122 | |||
123 | pd->dma_desc[pd->dma_desc_id - 1].ddadr = DDADR_STOP; | ||
124 | |||
125 | /* Fire IRQ only at the end of last block */ | ||
126 | pd->dma_desc[pd->dma_desc_id - 1].dcmd |= DCMD_ENDIRQEN; | ||
127 | |||
128 | DDADR(pd->dma_channel) = pd->dma_desc_addr; | ||
129 | DRCMR(pd->dma_dreq) = DRCMR_MAPVLD | pd->dma_channel; | ||
130 | |||
131 | } | ||
132 | |||
133 | /* | ||
134 | * Configure the DMA controller, load the DMA descriptors, but don't start the | ||
135 | * DMA controller yet. Only issue the ATA command. | ||
136 | */ | ||
137 | static void pxa_bmdma_setup(struct ata_queued_cmd *qc) | ||
138 | { | ||
139 | qc->ap->ops->sff_exec_command(qc->ap, &qc->tf); | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * Execute the DMA transfer. | ||
144 | */ | ||
145 | static void pxa_bmdma_start(struct ata_queued_cmd *qc) | ||
146 | { | ||
147 | struct pata_pxa_data *pd = qc->ap->private_data; | ||
148 | init_completion(&pd->dma_done); | ||
149 | DCSR(pd->dma_channel) = DCSR_RUN; | ||
150 | } | ||
151 | |||
152 | /* | ||
153 | * Wait until the DMA transfer completes, then stop the DMA controller. | ||
154 | */ | ||
155 | static void pxa_bmdma_stop(struct ata_queued_cmd *qc) | ||
156 | { | ||
157 | struct pata_pxa_data *pd = qc->ap->private_data; | ||
158 | |||
159 | if ((DCSR(pd->dma_channel) & DCSR_RUN) && | ||
160 | wait_for_completion_timeout(&pd->dma_done, HZ)) | ||
161 | dev_err(qc->ap->dev, "Timeout waiting for DMA completion!"); | ||
162 | |||
163 | DCSR(pd->dma_channel) = 0; | ||
164 | } | ||
165 | |||
166 | /* | ||
167 | * Read DMA status. The bmdma_stop() will take care of properly finishing the | ||
168 | * DMA transfer so we always have DMA-complete interrupt here. | ||
169 | */ | ||
170 | static unsigned char pxa_bmdma_status(struct ata_port *ap) | ||
171 | { | ||
172 | struct pata_pxa_data *pd = ap->private_data; | ||
173 | unsigned char ret = ATA_DMA_INTR; | ||
174 | |||
175 | if (pd->dma_dcsr & DCSR_BUSERR) | ||
176 | ret |= ATA_DMA_ERR; | ||
177 | |||
178 | return ret; | ||
179 | } | ||
180 | |||
181 | /* | ||
182 | * No IRQ register present so we do nothing. | ||
183 | */ | ||
184 | static void pxa_irq_clear(struct ata_port *ap) | ||
185 | { | ||
186 | } | ||
187 | |||
188 | /* | ||
189 | * Check for ATAPI DMA. ATAPI DMA is unsupported by this driver. It's still | ||
190 | * unclear why ATAPI has DMA issues. | ||
191 | */ | ||
192 | static int pxa_check_atapi_dma(struct ata_queued_cmd *qc) | ||
193 | { | ||
194 | return -EOPNOTSUPP; | ||
195 | } | ||
196 | |||
197 | static struct scsi_host_template pxa_ata_sht = { | ||
198 | ATA_BMDMA_SHT(DRV_NAME), | ||
199 | }; | ||
200 | |||
201 | static struct ata_port_operations pxa_ata_port_ops = { | ||
202 | .inherits = &ata_bmdma_port_ops, | ||
203 | .cable_detect = ata_cable_40wire, | ||
204 | |||
205 | .bmdma_setup = pxa_bmdma_setup, | ||
206 | .bmdma_start = pxa_bmdma_start, | ||
207 | .bmdma_stop = pxa_bmdma_stop, | ||
208 | .bmdma_status = pxa_bmdma_status, | ||
209 | |||
210 | .check_atapi_dma = pxa_check_atapi_dma, | ||
211 | |||
212 | .sff_irq_clear = pxa_irq_clear, | ||
213 | |||
214 | .qc_prep = pxa_qc_prep, | ||
215 | }; | ||
216 | |||
217 | /* | ||
218 | * DMA interrupt handler. | ||
219 | */ | ||
220 | static void pxa_ata_dma_irq(int dma, void *port) | ||
221 | { | ||
222 | struct ata_port *ap = port; | ||
223 | struct pata_pxa_data *pd = ap->private_data; | ||
224 | |||
225 | pd->dma_dcsr = DCSR(dma); | ||
226 | DCSR(dma) = pd->dma_dcsr; | ||
227 | |||
228 | if (pd->dma_dcsr & DCSR_STOPSTATE) | ||
229 | complete(&pd->dma_done); | ||
230 | } | ||
231 | |||
232 | static int __devinit pxa_ata_probe(struct platform_device *pdev) | ||
233 | { | ||
234 | struct ata_host *host; | ||
235 | struct ata_port *ap; | ||
236 | struct pata_pxa_data *data; | ||
237 | struct resource *cmd_res; | ||
238 | struct resource *ctl_res; | ||
239 | struct resource *dma_res; | ||
240 | struct resource *irq_res; | ||
241 | struct pata_pxa_pdata *pdata = pdev->dev.platform_data; | ||
242 | int ret = 0; | ||
243 | |||
244 | /* | ||
245 | * Resource validation, three resources are needed: | ||
246 | * - CMD port base address | ||
247 | * - CTL port base address | ||
248 | * - DMA port base address | ||
249 | * - IRQ pin | ||
250 | */ | ||
251 | if (pdev->num_resources != 4) { | ||
252 | dev_err(&pdev->dev, "invalid number of resources\n"); | ||
253 | return -EINVAL; | ||
254 | } | ||
255 | |||
256 | /* | ||
257 | * CMD port base address | ||
258 | */ | ||
259 | cmd_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
260 | if (unlikely(cmd_res == NULL)) | ||
261 | return -EINVAL; | ||
262 | |||
263 | /* | ||
264 | * CTL port base address | ||
265 | */ | ||
266 | ctl_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
267 | if (unlikely(ctl_res == NULL)) | ||
268 | return -EINVAL; | ||
269 | |||
270 | /* | ||
271 | * DMA port base address | ||
272 | */ | ||
273 | dma_res = platform_get_resource(pdev, IORESOURCE_DMA, 0); | ||
274 | if (unlikely(dma_res == NULL)) | ||
275 | return -EINVAL; | ||
276 | |||
277 | /* | ||
278 | * IRQ pin | ||
279 | */ | ||
280 | irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
281 | if (unlikely(irq_res == NULL)) | ||
282 | return -EINVAL; | ||
283 | |||
284 | /* | ||
285 | * Allocate the host | ||
286 | */ | ||
287 | host = ata_host_alloc(&pdev->dev, 1); | ||
288 | if (!host) | ||
289 | return -ENOMEM; | ||
290 | |||
291 | ap = host->ports[0]; | ||
292 | ap->ops = &pxa_ata_port_ops; | ||
293 | ap->pio_mask = ATA_PIO4; | ||
294 | ap->mwdma_mask = ATA_MWDMA2; | ||
295 | ap->flags = ATA_FLAG_MMIO; | ||
296 | |||
297 | ap->ioaddr.cmd_addr = devm_ioremap(&pdev->dev, cmd_res->start, | ||
298 | resource_size(cmd_res)); | ||
299 | ap->ioaddr.ctl_addr = devm_ioremap(&pdev->dev, ctl_res->start, | ||
300 | resource_size(ctl_res)); | ||
301 | ap->ioaddr.bmdma_addr = devm_ioremap(&pdev->dev, dma_res->start, | ||
302 | resource_size(dma_res)); | ||
303 | |||
304 | /* | ||
305 | * Adjust register offsets | ||
306 | */ | ||
307 | ap->ioaddr.altstatus_addr = ap->ioaddr.ctl_addr; | ||
308 | ap->ioaddr.data_addr = ap->ioaddr.cmd_addr + | ||
309 | (ATA_REG_DATA << pdata->reg_shift); | ||
310 | ap->ioaddr.error_addr = ap->ioaddr.cmd_addr + | ||
311 | (ATA_REG_ERR << pdata->reg_shift); | ||
312 | ap->ioaddr.feature_addr = ap->ioaddr.cmd_addr + | ||
313 | (ATA_REG_FEATURE << pdata->reg_shift); | ||
314 | ap->ioaddr.nsect_addr = ap->ioaddr.cmd_addr + | ||
315 | (ATA_REG_NSECT << pdata->reg_shift); | ||
316 | ap->ioaddr.lbal_addr = ap->ioaddr.cmd_addr + | ||
317 | (ATA_REG_LBAL << pdata->reg_shift); | ||
318 | ap->ioaddr.lbam_addr = ap->ioaddr.cmd_addr + | ||
319 | (ATA_REG_LBAM << pdata->reg_shift); | ||
320 | ap->ioaddr.lbah_addr = ap->ioaddr.cmd_addr + | ||
321 | (ATA_REG_LBAH << pdata->reg_shift); | ||
322 | ap->ioaddr.device_addr = ap->ioaddr.cmd_addr + | ||
323 | (ATA_REG_DEVICE << pdata->reg_shift); | ||
324 | ap->ioaddr.status_addr = ap->ioaddr.cmd_addr + | ||
325 | (ATA_REG_STATUS << pdata->reg_shift); | ||
326 | ap->ioaddr.command_addr = ap->ioaddr.cmd_addr + | ||
327 | (ATA_REG_CMD << pdata->reg_shift); | ||
328 | |||
329 | /* | ||
330 | * Allocate and load driver's internal data structure | ||
331 | */ | ||
332 | data = devm_kzalloc(&pdev->dev, sizeof(struct pata_pxa_data), | ||
333 | GFP_KERNEL); | ||
334 | if (!data) | ||
335 | return -ENOMEM; | ||
336 | |||
337 | ap->private_data = data; | ||
338 | data->dma_dreq = pdata->dma_dreq; | ||
339 | data->dma_io_addr = dma_res->start; | ||
340 | |||
341 | /* | ||
342 | * Allocate space for the DMA descriptors | ||
343 | */ | ||
344 | data->dma_desc = dmam_alloc_coherent(&pdev->dev, PAGE_SIZE, | ||
345 | &data->dma_desc_addr, GFP_KERNEL); | ||
346 | if (!data->dma_desc) | ||
347 | return -EINVAL; | ||
348 | |||
349 | /* | ||
350 | * Request the DMA channel | ||
351 | */ | ||
352 | data->dma_channel = pxa_request_dma(DRV_NAME, DMA_PRIO_LOW, | ||
353 | pxa_ata_dma_irq, ap); | ||
354 | if (data->dma_channel < 0) | ||
355 | return -EBUSY; | ||
356 | |||
357 | /* | ||
358 | * Stop and clear the DMA channel | ||
359 | */ | ||
360 | DCSR(data->dma_channel) = 0; | ||
361 | |||
362 | /* | ||
363 | * Activate the ATA host | ||
364 | */ | ||
365 | ret = ata_host_activate(host, irq_res->start, ata_sff_interrupt, | ||
366 | pdata->irq_flags, &pxa_ata_sht); | ||
367 | if (ret) | ||
368 | pxa_free_dma(data->dma_channel); | ||
369 | |||
370 | return ret; | ||
371 | } | ||
372 | |||
373 | static int __devexit pxa_ata_remove(struct platform_device *pdev) | ||
374 | { | ||
375 | struct ata_host *host = dev_get_drvdata(&pdev->dev); | ||
376 | struct pata_pxa_data *data = host->ports[0]->private_data; | ||
377 | |||
378 | pxa_free_dma(data->dma_channel); | ||
379 | |||
380 | ata_host_detach(host); | ||
381 | |||
382 | return 0; | ||
383 | } | ||
384 | |||
385 | static struct platform_driver pxa_ata_driver = { | ||
386 | .probe = pxa_ata_probe, | ||
387 | .remove = __devexit_p(pxa_ata_remove), | ||
388 | .driver = { | ||
389 | .name = DRV_NAME, | ||
390 | .owner = THIS_MODULE, | ||
391 | }, | ||
392 | }; | ||
393 | |||
394 | static int __init pxa_ata_init(void) | ||
395 | { | ||
396 | return platform_driver_register(&pxa_ata_driver); | ||
397 | } | ||
398 | |||
399 | static void __exit pxa_ata_exit(void) | ||
400 | { | ||
401 | platform_driver_unregister(&pxa_ata_driver); | ||
402 | } | ||
403 | |||
404 | module_init(pxa_ata_init); | ||
405 | module_exit(pxa_ata_exit); | ||
406 | |||
407 | MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); | ||
408 | MODULE_DESCRIPTION("DMA-capable driver for PATA on PXA CPU"); | ||
409 | MODULE_LICENSE("GPL"); | ||
410 | MODULE_VERSION(DRV_VERSION); | ||
411 | MODULE_ALIAS("platform:" DRV_NAME); | ||
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index c988514eb551..c80a7a6e7698 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig | |||
@@ -215,7 +215,7 @@ config PCMCIA_PXA2XX | |||
215 | depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \ | 215 | depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \ |
216 | || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ | 216 | || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ |
217 | || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2 \ | 217 | || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2 \ |
218 | || MACH_VPAC270) | 218 | || MACH_VPAC270 || MACH_BALLOON3) |
219 | select PCMCIA_SOC_COMMON | 219 | select PCMCIA_SOC_COMMON |
220 | help | 220 | help |
221 | Say Y here to include support for the PXA2xx PCMCIA controller | 221 | Say Y here to include support for the PXA2xx PCMCIA controller |
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index d006e8beab9c..6a6077325527 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile | |||
@@ -70,6 +70,7 @@ pxa2xx-obj-$(CONFIG_MACH_PALMLD) += pxa2xx_palmld.o | |||
70 | pxa2xx-obj-$(CONFIG_MACH_E740) += pxa2xx_e740.o | 70 | pxa2xx-obj-$(CONFIG_MACH_E740) += pxa2xx_e740.o |
71 | pxa2xx-obj-$(CONFIG_MACH_STARGATE2) += pxa2xx_stargate2.o | 71 | pxa2xx-obj-$(CONFIG_MACH_STARGATE2) += pxa2xx_stargate2.o |
72 | pxa2xx-obj-$(CONFIG_MACH_VPAC270) += pxa2xx_vpac270.o | 72 | pxa2xx-obj-$(CONFIG_MACH_VPAC270) += pxa2xx_vpac270.o |
73 | pxa2xx-obj-$(CONFIG_MACH_BALLOON3) += pxa2xx_balloon3.o | ||
73 | 74 | ||
74 | obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y) | 75 | obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y) |
75 | 76 | ||
diff --git a/drivers/pcmcia/pxa2xx_balloon3.c b/drivers/pcmcia/pxa2xx_balloon3.c new file mode 100644 index 000000000000..dbbdd0063202 --- /dev/null +++ b/drivers/pcmcia/pxa2xx_balloon3.c | |||
@@ -0,0 +1,158 @@ | |||
1 | /* | ||
2 | * linux/drivers/pcmcia/pxa2xx_balloon3.c | ||
3 | * | ||
4 | * Balloon3 PCMCIA specific routines. | ||
5 | * | ||
6 | * Author: Nick Bane | ||
7 | * Created: June, 2006 | ||
8 | * Copyright: Toby Churchill Ltd | ||
9 | * Derived from pxa2xx_mainstone.c, by Nico Pitre | ||
10 | * | ||
11 | * Various modification by Marek Vasut <marek.vasut@gmail.com> | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License version 2 as | ||
15 | * published by the Free Software Foundation. | ||
16 | */ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/gpio.h> | ||
20 | #include <linux/errno.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/irq.h> | ||
24 | #include <linux/io.h> | ||
25 | |||
26 | #include <mach/balloon3.h> | ||
27 | |||
28 | #include "soc_common.h" | ||
29 | |||
30 | /* | ||
31 | * These are a list of interrupt sources that provokes a polled | ||
32 | * check of status | ||
33 | */ | ||
34 | static struct pcmcia_irqs irqs[] = { | ||
35 | { 0, BALLOON3_S0_CD_IRQ, "PCMCIA0 CD" }, | ||
36 | { 0, BALLOON3_BP_NSTSCHG_IRQ, "PCMCIA0 STSCHG" }, | ||
37 | }; | ||
38 | |||
39 | static int balloon3_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | ||
40 | { | ||
41 | uint16_t ver; | ||
42 | int ret; | ||
43 | static void __iomem *fpga_ver; | ||
44 | |||
45 | ver = __raw_readw(BALLOON3_FPGA_VER); | ||
46 | if (ver > 0x0201) | ||
47 | pr_warn("The FPGA code, version 0x%04x, is newer than rel-0.3. " | ||
48 | "PCMCIA/CF support might be broken in this version!", | ||
49 | ver); | ||
50 | |||
51 | skt->socket.pci_irq = BALLOON3_BP_CF_NRDY_IRQ; | ||
52 | return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
53 | } | ||
54 | |||
55 | static void balloon3_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) | ||
56 | { | ||
57 | soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
58 | } | ||
59 | |||
60 | static unsigned long balloon3_pcmcia_status[2] = { | ||
61 | BALLOON3_CF_nSTSCHG_BVD1, | ||
62 | BALLOON3_CF_nSTSCHG_BVD1 | ||
63 | }; | ||
64 | |||
65 | static void balloon3_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | ||
66 | struct pcmcia_state *state) | ||
67 | { | ||
68 | uint16_t status; | ||
69 | int flip; | ||
70 | |||
71 | /* This actually reads the STATUS register */ | ||
72 | status = __raw_readw(BALLOON3_CF_STATUS_REG); | ||
73 | flip = (status ^ balloon3_pcmcia_status[skt->nr]) | ||
74 | & BALLOON3_CF_nSTSCHG_BVD1; | ||
75 | /* | ||
76 | * Workaround for STSCHG which can't be deasserted: | ||
77 | * We therefore disable/enable corresponding IRQs | ||
78 | * as needed to avoid IRQ locks. | ||
79 | */ | ||
80 | if (flip) { | ||
81 | balloon3_pcmcia_status[skt->nr] = status; | ||
82 | if (status & BALLOON3_CF_nSTSCHG_BVD1) | ||
83 | enable_irq(BALLOON3_BP_NSTSCHG_IRQ); | ||
84 | else | ||
85 | disable_irq(BALLOON3_BP_NSTSCHG_IRQ); | ||
86 | } | ||
87 | |||
88 | state->detect = !gpio_get_value(BALLOON3_GPIO_S0_CD); | ||
89 | state->ready = !!(status & BALLOON3_CF_nIRQ); | ||
90 | state->bvd1 = !!(status & BALLOON3_CF_nSTSCHG_BVD1); | ||
91 | state->bvd2 = 0; /* not available */ | ||
92 | state->vs_3v = 1; /* Always true its a CF card */ | ||
93 | state->vs_Xv = 0; /* not available */ | ||
94 | state->wrprot = 0; /* not available */ | ||
95 | } | ||
96 | |||
97 | static int balloon3_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | ||
98 | const socket_state_t *state) | ||
99 | { | ||
100 | __raw_writew((state->flags & SS_RESET) ? BALLOON3_CF_RESET : 0, | ||
101 | BALLOON3_CF_CONTROL_REG); | ||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | static void balloon3_pcmcia_socket_init(struct soc_pcmcia_socket *skt) | ||
106 | { | ||
107 | } | ||
108 | |||
109 | static void balloon3_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) | ||
110 | { | ||
111 | } | ||
112 | |||
113 | static struct pcmcia_low_level balloon3_pcmcia_ops = { | ||
114 | .owner = THIS_MODULE, | ||
115 | .hw_init = balloon3_pcmcia_hw_init, | ||
116 | .hw_shutdown = balloon3_pcmcia_hw_shutdown, | ||
117 | .socket_state = balloon3_pcmcia_socket_state, | ||
118 | .configure_socket = balloon3_pcmcia_configure_socket, | ||
119 | .socket_init = balloon3_pcmcia_socket_init, | ||
120 | .socket_suspend = balloon3_pcmcia_socket_suspend, | ||
121 | .first = 0, | ||
122 | .nr = 1, | ||
123 | }; | ||
124 | |||
125 | static struct platform_device *balloon3_pcmcia_device; | ||
126 | |||
127 | static int __init balloon3_pcmcia_init(void) | ||
128 | { | ||
129 | int ret; | ||
130 | |||
131 | balloon3_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); | ||
132 | if (!balloon3_pcmcia_device) | ||
133 | return -ENOMEM; | ||
134 | |||
135 | ret = platform_device_add_data(balloon3_pcmcia_device, | ||
136 | &balloon3_pcmcia_ops, sizeof(balloon3_pcmcia_ops)); | ||
137 | |||
138 | if (!ret) | ||
139 | ret = platform_device_add(balloon3_pcmcia_device); | ||
140 | |||
141 | if (ret) | ||
142 | platform_device_put(balloon3_pcmcia_device); | ||
143 | |||
144 | return ret; | ||
145 | } | ||
146 | |||
147 | static void __exit balloon3_pcmcia_exit(void) | ||
148 | { | ||
149 | platform_device_unregister(balloon3_pcmcia_device); | ||
150 | } | ||
151 | |||
152 | module_init(balloon3_pcmcia_init); | ||
153 | module_exit(balloon3_pcmcia_exit); | ||
154 | |||
155 | MODULE_LICENSE("GPL"); | ||
156 | MODULE_AUTHOR("Nick Bane <nick@cecomputing.co.uk>"); | ||
157 | MODULE_ALIAS("platform:pxa2xx-pcmcia"); | ||
158 | MODULE_DESCRIPTION("Balloon3 board CF/PCMCIA driver"); | ||
diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/wm97xx_battery.c index 4e8afce0c818..5071d85ec12d 100644 --- a/drivers/power/wm97xx_battery.c +++ b/drivers/power/wm97xx_battery.c | |||
@@ -29,7 +29,6 @@ static DEFINE_MUTEX(bat_lock); | |||
29 | static struct work_struct bat_work; | 29 | static struct work_struct bat_work; |
30 | static struct mutex work_lock; | 30 | static struct mutex work_lock; |
31 | static int bat_status = POWER_SUPPLY_STATUS_UNKNOWN; | 31 | static int bat_status = POWER_SUPPLY_STATUS_UNKNOWN; |
32 | static struct wm97xx_batt_info *gpdata; | ||
33 | static enum power_supply_property *prop; | 32 | static enum power_supply_property *prop; |
34 | 33 | ||
35 | static unsigned long wm97xx_read_bat(struct power_supply *bat_ps) | 34 | static unsigned long wm97xx_read_bat(struct power_supply *bat_ps) |
@@ -172,12 +171,6 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev) | |||
172 | struct wm97xx_pdata *wmdata = dev->dev.platform_data; | 171 | struct wm97xx_pdata *wmdata = dev->dev.platform_data; |
173 | struct wm97xx_batt_pdata *pdata; | 172 | struct wm97xx_batt_pdata *pdata; |
174 | 173 | ||
175 | if (gpdata) { | ||
176 | dev_err(&dev->dev, "Do not pass platform_data through " | ||
177 | "wm97xx_bat_set_pdata!\n"); | ||
178 | return -EINVAL; | ||
179 | } | ||
180 | |||
181 | if (!wmdata) { | 174 | if (!wmdata) { |
182 | dev_err(&dev->dev, "No platform data supplied\n"); | 175 | dev_err(&dev->dev, "No platform data supplied\n"); |
183 | return -EINVAL; | 176 | return -EINVAL; |
@@ -308,15 +301,6 @@ static void __exit wm97xx_bat_exit(void) | |||
308 | platform_driver_unregister(&wm97xx_bat_driver); | 301 | platform_driver_unregister(&wm97xx_bat_driver); |
309 | } | 302 | } |
310 | 303 | ||
311 | /* The interface is deprecated, as well as linux/wm97xx_batt.h */ | ||
312 | void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data); | ||
313 | |||
314 | void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data) | ||
315 | { | ||
316 | gpdata = data; | ||
317 | } | ||
318 | EXPORT_SYMBOL_GPL(wm97xx_bat_set_pdata); | ||
319 | |||
320 | module_init(wm97xx_bat_init); | 304 | module_init(wm97xx_bat_init); |
321 | module_exit(wm97xx_bat_exit); | 305 | module_exit(wm97xx_bat_exit); |
322 | 306 | ||