Re: [PATCH] pcmcia: CompactFlash driver for PA Semi Electra boards

2007-06-25 Thread Olof Johansson
On Mon, Jun 25, 2007 at 06:56:36AM +0100, Christoph Hellwig wrote:
> > +static int bus_notify(struct notifier_block *nb, unsigned long action,
> > + void *data)
> > +{
> > +   struct device *dev = data;
> > +
> > +   printk("bus notify called\n");
> > +
> > +   /* We are only intereted in device addition */
> > +   if (action != BUS_NOTIFY_ADD_DEVICE)
> > +   return 0;
> > +
> > +   /* We use the direct ops for localbus */
> > +   dev->archdata.dma_ops = _direct_ops;
> > +
> > +   return 0;
> > +}
> 
> 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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] pcmcia: CompactFlash driver for PA Semi Electra boards

2007-06-25 Thread Olof Johansson
On Mon, Jun 25, 2007 at 06:56:36AM +0100, Christoph Hellwig wrote:
  +static int bus_notify(struct notifier_block *nb, unsigned long action,
  + void *data)
  +{
  +   struct device *dev = data;
  +
  +   printk(bus notify called\n);
  +
  +   /* We are only intereted in device addition */
  +   if (action != BUS_NOTIFY_ADD_DEVICE)
  +   return 0;
  +
  +   /* We use the direct ops for localbus */
  +   dev-archdata.dma_ops = dma_direct_ops;
  +
  +   return 0;
  +}
 
 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
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] pcmcia: CompactFlash driver for PA Semi Electra boards

2007-06-24 Thread Christoph Hellwig
> +static int bus_notify(struct notifier_block *nb, unsigned long action,
> +   void *data)
> +{
> + struct device *dev = data;
> +
> + printk("bus notify called\n");
> +
> + /* We are only intereted in device addition */
> + if (action != BUS_NOTIFY_ADD_DEVICE)
> + return 0;
> +
> + /* We use the direct ops for localbus */
> + dev->archdata.dma_ops = _direct_ops;
> +
> + return 0;
> +}

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.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] pcmcia: CompactFlash driver for PA Semi Electra boards

2007-06-24 Thread Olof Johansson
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 <[EMAIL PROTECTED]>
Acked-by: Paul Mackerras <[EMAIL PROTECTED]>

---

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 <[EMAIL PROTECTED]>
+ *
+ * Based on drivers/pcmcia/omap_cf.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+static const char driver_name[] = "electra-cf";
+
+struct electra_cf_socket {
+   struct pcmcia_socketsocket;
+
+   struct timer_list   timer;
+   unsignedpresent:1;
+   unsignedactive:1;
+
+   struct of_device*ofdev;
+   unsigned long   mem_phys;
+   void __iomem *  mem_base;
+   unsigned long   mem_size;
+   void __iomem *  io_virt;
+   unsigned intio_base;
+   unsigned intio_size;
+   u_int   irq;
+   struct resource iomem;
+   void __iomem *  gpio_base;
+   int gpio_detect;
+   int gpio_vsense;
+   int gpio_3v;
+   int gpio_5v;
+};
+
+#definePOLL_INTERVAL   (2 * HZ)
+
+
+static int electra_cf_present(struct electra_cf_socket *cf)
+{
+   unsigned int gpio;
+
+   gpio = in_le32(cf->gpio_base+0x40);
+   return !(gpio & (1 << cf->gpio_detect));
+}
+
+static int electra_cf_ss_init(struct pcmcia_socket *s)
+{
+   return 0;
+}
+
+/* the timer is primarily to kick this socket's pccardd */
+static void electra_cf_timer(unsigned long _cf)
+{
+   struct electra_cf_socket *cf = (void *) _cf;
+   int present = electra_cf_present(cf);
+
+   if (present != cf->present) {
+   cf->present = present;
+   pcmcia_parse_events(>socket, SS_DETECT);
+   }
+
+   if (cf->active)
+   mod_timer(>timer, jiffies + POLL_INTERVAL);
+}
+
+static irqreturn_t electra_cf_irq(int irq, void *_cf)
+{
+   electra_cf_timer((unsigned long)_cf);
+   return IRQ_HANDLED;
+}
+
+static int electra_cf_get_status(struct pcmcia_socket *s, u_int *sp)
+{
+   struct electra_cf_socket *cf;
+
+   if (!sp)
+   return -EINVAL;
+
+   cf = container_of(s, struct electra_cf_socket, socket);
+
+   /* NOTE CF is always 3VCARD */
+   if 

[PATCH] pcmcia: CompactFlash driver for PA Semi Electra boards

2007-06-24 Thread Olof Johansson
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 [EMAIL PROTECTED]
Acked-by: Paul Mackerras [EMAIL PROTECTED]

---

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 [EMAIL PROTECTED]
+ *
+ * Based on drivers/pcmcia/omap_cf.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#include linux/module.h
+#include linux/kernel.h
+#include linux/sched.h
+#include linux/platform_device.h
+#include linux/errno.h
+#include linux/init.h
+#include linux/delay.h
+#include linux/interrupt.h
+
+#include pcmcia/ss.h
+#include asm/of_platform.h
+
+static const char driver_name[] = electra-cf;
+
+struct electra_cf_socket {
+   struct pcmcia_socketsocket;
+
+   struct timer_list   timer;
+   unsignedpresent:1;
+   unsignedactive:1;
+
+   struct of_device*ofdev;
+   unsigned long   mem_phys;
+   void __iomem *  mem_base;
+   unsigned long   mem_size;
+   void __iomem *  io_virt;
+   unsigned intio_base;
+   unsigned intio_size;
+   u_int   irq;
+   struct resource iomem;
+   void __iomem *  gpio_base;
+   int gpio_detect;
+   int gpio_vsense;
+   int gpio_3v;
+   int gpio_5v;
+};
+
+#definePOLL_INTERVAL   (2 * HZ)
+
+
+static int electra_cf_present(struct electra_cf_socket *cf)
+{
+   unsigned int gpio;
+
+   gpio = in_le32(cf-gpio_base+0x40);
+   return !(gpio  (1  cf-gpio_detect));
+}
+
+static int electra_cf_ss_init(struct pcmcia_socket *s)
+{
+   return 0;
+}
+
+/* the timer is primarily to kick this socket's pccardd */
+static void electra_cf_timer(unsigned long _cf)
+{
+   struct electra_cf_socket *cf = (void *) _cf;
+   int present = electra_cf_present(cf);
+
+   if (present != cf-present) {
+   cf-present = present;
+   pcmcia_parse_events(cf-socket, SS_DETECT);
+   }
+
+   if (cf-active)
+   mod_timer(cf-timer, jiffies + POLL_INTERVAL);
+}
+
+static irqreturn_t electra_cf_irq(int irq, void *_cf)
+{
+   electra_cf_timer((unsigned long)_cf);
+   return IRQ_HANDLED;
+}
+
+static int electra_cf_get_status(struct pcmcia_socket *s, u_int *sp)
+{
+   struct electra_cf_socket *cf;
+
+   if (!sp)
+   return -EINVAL;
+
+   

Re: [PATCH] pcmcia: CompactFlash driver for PA Semi Electra boards

2007-06-24 Thread Christoph Hellwig
 +static int bus_notify(struct notifier_block *nb, unsigned long action,
 +   void *data)
 +{
 + struct device *dev = data;
 +
 + printk(bus notify called\n);
 +
 + /* We are only intereted in device addition */
 + if (action != BUS_NOTIFY_ADD_DEVICE)
 + return 0;
 +
 + /* We use the direct ops for localbus */
 + dev-archdata.dma_ops = dma_direct_ops;
 +
 + return 0;
 +}

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.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/