Driver for the CompactFlash slot on the PA Semi Electra eval board. It's a simple device sitting on localbus, with interrupts and detect/voltage control over GPIO. The driver is implemented as an of_platform driver, and adds localbus as a bus being probed by the of_platform framework. Signed-off-by: Olof Johansson <olof@lixom.net> Acked-by: Paul Mackerras <paulus@samba.org> --- Fixed the comments from Russell on last post, this should be good to merge now. Index: powerpc/drivers/pcmcia/Kconfig =================================================================== --- powerpc.orig/drivers/pcmcia/Kconfig +++ powerpc/drivers/pcmcia/Kconfig @@ -270,6 +270,13 @@ config AT91_CF Say Y here to support the CompactFlash controller on AT91 chips. Or choose M to compile the driver as a module named "at91_cf". +config ELECTRA_CF + bool "Electra CompactFlash Controller" + depends on PCMCIA=y && PPC_PASEMI + help + Say Y here to support the CompactFlash controller on the + PA Semi Electra eval board. + config PCCARD_NONSTATIC tristate Index: powerpc/drivers/pcmcia/Makefile =================================================================== --- powerpc.orig/drivers/pcmcia/Makefile +++ powerpc/drivers/pcmcia/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_PCMCIA_VRC4171) += vrc417 obj-$(CONFIG_PCMCIA_VRC4173) += vrc4173_cardu.o obj-$(CONFIG_OMAP_CF) += omap_cf.o obj-$(CONFIG_AT91_CF) += at91_cf.o +obj-$(CONFIG_ELECTRA_CF) += electra_cf.o sa11xx_core-y += soc_common.o sa11xx_base.o pxa2xx_core-y += soc_common.o pxa2xx_base.o Index: powerpc/drivers/pcmcia/electra_cf.c =================================================================== --- /dev/null +++ powerpc/drivers/pcmcia/electra_cf.c @@ -0,0 +1,382 @@ +/* + * Copyright (C) 2007 PA Semi, Inc + * + * Maintained by: Olof Johansson <olof@lixom.net> + * + * Based on drivers/pcmcia/omap_cf.c + * + * This program is free software; you can redistribute it and/or modify + * it under ...
Sorry for not coming back to you after the last posting of the patch, but I still really this bit of the code. We don't set dma ops from a driver anywhere else in the tree, so I'd really prefer if you could handle this in architecture code somewhere. Especially as dma_direct_ops and the pcmcia_bug_type shouldn't really be something exported to users. Also this code is unlogic if not buggy. Just because you have one electra bridge it doesn't mean all pcmcia is driven by it. In fact I'm pretty sure there are cardbus/pcmcia bridges that can be plugged into plain pci slots. -
Yeah, all good points. Also, I obviously missed to take out the debug printk. I'll post an updated patch separately. Thanks! -Olof -
Driver for the CompactFlash slot on the PA Semi Electra eval board. It's a simple device sitting on localbus, with interrupts and detect/voltage control over GPIO. The driver is implemented as an of_platform driver, and adds localbus as a bus being probed by the of_platform framework. Signed-off-by: Olof Johansson <olof@lixom.net> --- Chances since last post: * Comments from Christoph: - Moved bus notifier to arch code - Checking for bus (socket driver) type before changing dma ops Index: mainline/drivers/pcmcia/Kconfig =================================================================== --- mainline.orig/drivers/pcmcia/Kconfig +++ mainline/drivers/pcmcia/Kconfig @@ -270,6 +270,13 @@ config AT91_CF Say Y here to support the CompactFlash controller on AT91 chips. Or choose M to compile the driver as a module named "at91_cf". +config ELECTRA_CF + bool "Electra CompactFlash Controller" + depends on PCMCIA=y && PPC_PASEMI + help + Say Y here to support the CompactFlash controller on the + PA Semi Electra eval board. + config PCCARD_NONSTATIC tristate Index: mainline/drivers/pcmcia/Makefile =================================================================== --- mainline.orig/drivers/pcmcia/Makefile +++ mainline/drivers/pcmcia/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_PCMCIA_VRC4171) += vrc417 obj-$(CONFIG_PCMCIA_VRC4173) += vrc4173_cardu.o obj-$(CONFIG_OMAP_CF) += omap_cf.o obj-$(CONFIG_AT91_CF) += at91_cf.o +obj-$(CONFIG_ELECTRA_CF) += electra_cf.o sa11xx_core-y += soc_common.o sa11xx_base.o pxa2xx_core-y += soc_common.o pxa2xx_base.o Index: mainline/drivers/pcmcia/electra_cf.c =================================================================== --- /dev/null +++ mainline/drivers/pcmcia/electra_cf.c @@ -0,0 +1,359 @@ +/* + * Copyright (C) 2007 PA Semi, Inc + * + * Maintained by: Olof Johansson <olof@lixom.net> + * + * Based on drivers/pcmcia/omap_cf.c + * + * This program is free software; you can ...
Looks good to me. The only odd thing is the inconsistant use of #ifdef CONFIG_PCMCIA in setup.c. -
Thanks, and thanks for the review. The ifdef is needed since for CONFIG_PCMCIA=n builds, the bus notifier isn't available. I wanted to do the bus notifier registration explicitly before the of_platform bus probe to avoid later surprises due to reordered initcalls in case it was split up in it's own initcall. I could add the code under ifdef as well, but it didn't seem too critical. Once the second major board comes along I'll probably move it out to a per-board file, there's no real need for it just yet. -Olof -
Driver for the CompactFlash slot on the PA Semi Electra eval board. It's a simple device sitting on localbus, with interrupts and detect/voltage control over GPIO. The driver is implemented as an of_platform driver, and adds localbus as a bus being probed by the of_platform framework. Signed-off-by: Olof Johansson <olof@lixom.net> --- Alright, turns out I still need to declare the extern bus type, which would mean two #ifdefs in one function. Moving it out instead. I've addressed Milton's comments as well. Who's maintaining PCMCIA? MAINTAINERS only lists a mailing list, no person. Seems weird for a component that's marked as maintained. Index: mainline/drivers/pcmcia/Kconfig =================================================================== --- mainline.orig/drivers/pcmcia/Kconfig +++ mainline/drivers/pcmcia/Kconfig @@ -270,6 +270,13 @@ config AT91_CF Say Y here to support the CompactFlash controller on AT91 chips. Or choose M to compile the driver as a module named "at91_cf". +config ELECTRA_CF + bool "Electra CompactFlash Controller" + depends on PCMCIA=y && PPC_PASEMI + help + Say Y here to support the CompactFlash controller on the + PA Semi Electra eval board. + config PCCARD_NONSTATIC tristate Index: mainline/drivers/pcmcia/Makefile =================================================================== --- mainline.orig/drivers/pcmcia/Makefile +++ mainline/drivers/pcmcia/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_PCMCIA_VRC4171) += vrc417 obj-$(CONFIG_PCMCIA_VRC4173) += vrc4173_cardu.o obj-$(CONFIG_OMAP_CF) += omap_cf.o obj-$(CONFIG_AT91_CF) += at91_cf.o +obj-$(CONFIG_ELECTRA_CF) += electra_cf.o sa11xx_core-y += soc_common.o sa11xx_base.o pxa2xx_core-y += soc_common.o pxa2xx_base.o Index: mainline/drivers/pcmcia/electra_cf.c =================================================================== --- /dev/null +++ mainline/drivers/pcmcia/electra_cf.c @@ -0,0 +1,374 @@ +/* + * Copyright (C) 2007 PA ...
On Thu, 5 Jul 2007 09:49:14 -0500
Dominik Brodowski. He's having a bit of downtime at present (exams, I
think). He expects to return. Meanwhile, cc'ing me usually has some
I never know who maintains random-scruffy-ppc code like this. From a peek
in the git-whatchanged output, it appears to be yourself.
Have a few little fixies:
--- a/drivers/pcmcia/electra_cf.c~pcmcia-compactflash-driver-for-pa-semi-electra-boards-fix
+++ a/drivers/pcmcia/electra_cf.c
@@ -201,9 +201,7 @@ static int __devinit electra_cf_probe(st
if (!cf)
return -ENOMEM;
- init_timer(&cf->timer);
- cf->timer.function = electra_cf_timer;
- cf->timer.data = (unsigned long) cf;
+ setup_timer(&cf->timer, electra_cf_timer, (unsigned long)cf);
cf->irq = NO_IRQ;
cf->ofdev = ofdev;
@@ -340,16 +338,14 @@ static int __devexit electra_cf_remove(s
return 0;
}
-static struct of_device_id electra_cf_match[] =
-{
+static struct of_device_id electra_cf_match[] = {
{
.compatible = "electra-cf",
},
{},
};
-static struct of_platform_driver electra_cf_driver =
-{
+static struct of_platform_driver electra_cf_driver = {
.name = (char *)driver_name,
.match_table = electra_cf_match,
.probe = electra_cf_probe,
@@ -371,4 +367,3 @@ module_exit(electra_cf_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR ("Olof Johansson <olof@lixom.net>");
MODULE_DESCRIPTION("PA Semi Electra CF driver");
-
_
-
Driver name and device tree compatible field is not neccessarily the same, Check the top of the file. :) (Kumar started doing that, I kept it up, seems useful). And yes, we do tend to have per-platform maintainers Thanks! [...] -
Fix build of electra_cf, since the IO space setup interfaces were
changed when BenH rewrote it.
Also clean it up a bit, add 5V support, make it unloadable, remove some
dead variables, etc.
Signed-off-by: Olof Johansson <olof@lixom.net>
---
Andrew,
I did this as an incremental patch that you can just merge into the base
one that's already in -mm, but I could merge and resubmit the base patch
instead if you prefer.
(The base patch is
pcmcia-compactflash-driver-for-pa-semi-electra-boards.patch)
-Olof
Index: linux-2.6/drivers/pcmcia/electra_cf.c
===================================================================
--- linux-2.6.orig/drivers/pcmcia/electra_cf.c
+++ linux-2.6/drivers/pcmcia/electra_cf.c
@@ -28,6 +28,7 @@
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
+#include <linux/vmalloc.h>
#include <pcmcia/ss.h>
#include <asm/of_platform.h>
@@ -105,10 +106,8 @@ static int electra_cf_get_status(struct
/* NOTE CF is always 3VCARD */
if (electra_cf_present(cf)) {
- struct electra_cf_socket *cf;
-
*sp = SS_READY | SS_DETECT | SS_POWERON | SS_3VCARD;
- cf = container_of(s, struct electra_cf_socket, socket);
+
s->pci_irq = cf->irq;
} else
*sp = 0;
@@ -134,8 +133,10 @@ static int electra_cf_set_socket(struct
case 33:
gpio = (1 << cf->gpio_3v);
break;
+ case 5:
+ gpio = (1 << cf->gpio_5v);
+ break;
default:
- /* CF is 3.3V only */
return -EINVAL;
}
@@ -188,6 +189,7 @@ static int __devinit electra_cf_probe(st
int status;
const unsigned int *prop;
int err;
+ struct vm_struct *area;
err = of_address_to_resource(np, 0, &mem);
if (err)
@@ -206,22 +208,27 @@ static int __devinit electra_cf_probe(st
cf->ofdev = ofdev;
cf->mem_phys = mem.start;
- cf->mem_base = ioremap(mem.start, mem.end - mem.start);
+ cf->mem_size = PAGE_ALIGN(mem.end - mem.start);
+ cf->mem_base = ioremap(cf->mem_phys, cf->mem_size);
cf->io_size = PAGE_ALIGN(io.end - ...