All of lore.kernel.org
 help / color / mirror / Atom feed
* + pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch added to -mm tree
@ 2008-05-20  6:08 akpm
  2008-05-20  7:51 ` Bryan Wu
  0 siblings, 1 reply; 9+ messages in thread
From: akpm @ 2008-05-20  6:08 UTC (permalink / raw)
  To: mm-commits; +Cc: michael.hennerich, cooloney


The patch titled
     PCMCIA: add support the CF PCMCIA driver for Blackfin
has been added to the -mm tree.  Its filename is
     pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/

------------------------------------------------------
Subject: PCMCIA: add support the CF PCMCIA driver for Blackfin
From: Michael Hennerich <michael.hennerich@analog.com>

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/pcmcia/Kconfig          |    7 
 drivers/pcmcia/Makefile         |    1 
 drivers/pcmcia/bfin_cf_pcmcia.c |  341 ++++++++++++++++++++++++++++++
 include/pcmcia/cs_types.h       |    2 
 4 files changed, 350 insertions(+), 1 deletion(-)

diff -puN drivers/pcmcia/Kconfig~pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2 drivers/pcmcia/Kconfig
--- a/drivers/pcmcia/Kconfig~pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2
+++ a/drivers/pcmcia/Kconfig
@@ -263,6 +263,13 @@ config OMAP_CF
 	  Say Y here to support the CompactFlash controller on OMAP.
 	  Note that this doesn't support "True IDE" mode.
 
+config BFIN_CFPCMCIA
+	tristate "Blackfin CompactFlash PCMCIA Driver"
+	depends on PCMCIA && BLACKFIN
+	help
+	  Say Y here to support the CompactFlash PCMCIA driver for Blackfin.
+
+
 config AT91_CF
 	tristate "AT91 CompactFlash Controller"
 	depends on PCMCIA && ARCH_AT91RM9200
diff -puN drivers/pcmcia/Makefile~pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2 drivers/pcmcia/Makefile
--- a/drivers/pcmcia/Makefile~pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2
+++ a/drivers/pcmcia/Makefile
@@ -36,6 +36,7 @@ obj-$(CONFIG_PCMCIA_AU1X00)			+= au1x00_
 obj-$(CONFIG_PCMCIA_VRC4171)			+= vrc4171_card.o
 obj-$(CONFIG_PCMCIA_VRC4173)			+= vrc4173_cardu.o
 obj-$(CONFIG_OMAP_CF)				+= omap_cf.o
+obj-$(CONFIG_BFIN_CFPCMCIA)			+= bfin_cf_pcmcia.o
 obj-$(CONFIG_AT91_CF)				+= at91_cf.o
 obj-$(CONFIG_ELECTRA_CF)			+= electra_cf.o
 
diff -puN /dev/null drivers/pcmcia/bfin_cf_pcmcia.c
--- /dev/null
+++ a/drivers/pcmcia/bfin_cf_pcmcia.c
@@ -0,0 +1,341 @@
+/*
+ * file: drivers/pcmcia/bfin_cf.c
+ * author: Michael Hennerich (hennerich@blackfin.uclinux.org)
+ *
+ * based on: drivers/pcmcia/omap_cf.c
+ * omap_cf.c -- OMAP 16xx CompactFlash controller driver
+ *
+ * Copyright (c) 2005 David Brownell
+ * Copyright (c) 2006-2008 Michael Hennerich Analog Devices Inc.
+ *
+ * bugs:         enter bugs at http://blackfin.uclinux.org/
+ *
+ * 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, 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; see the file copying.
+ * if not, write to the free software foundation,
+ * 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 <linux/irq.h>
+
+#include <pcmcia/ss.h>
+#include <pcmcia/cisreg.h>
+#include <asm/io.h>
+#include <asm/gpio.h>
+
+#define	SZ_1K	0x00000400
+#define	SZ_8K	0x00002000
+#define	SZ_2K	(2 * SZ_1K)
+
+#define	POLL_INTERVAL	(2 * HZ)
+
+#define	CF_ATASEL_ENA 	0x20311802	/* Inverts RESET */
+#define	CF_ATASEL_DIS 	0x20311800
+
+#define bfin_cf_present(pfx) (gpio_get_value(pfx))
+
+/*--------------------------------------------------------------------------*/
+
+static const char driver_name[] = "bfin_cf_pcmcia";
+
+struct bfin_cf_socket {
+	struct pcmcia_socket socket;
+
+	struct timer_list timer;
+	unsigned present:1;
+	unsigned active:1;
+
+	struct platform_device *pdev;
+	unsigned long phys_cf_io;
+	unsigned long phys_cf_attr;
+	u_int irq;
+	u_short cd_pfx;
+};
+
+/*--------------------------------------------------------------------------*/
+static int bfin_cf_reset(void)
+{
+	outw(0, CF_ATASEL_ENA);
+	mdelay(200);
+	outw(0, CF_ATASEL_DIS);
+
+	return 0;
+}
+
+static int bfin_cf_ss_init(struct pcmcia_socket *s)
+{
+	return 0;
+}
+
+/* the timer is primarily to kick this socket's pccardd */
+static void bfin_cf_timer(unsigned long _cf)
+{
+	struct bfin_cf_socket *cf = (void *)_cf;
+	unsigned short present = bfin_cf_present(cf->cd_pfx);
+
+	if (present != cf->present) {
+		cf->present = present;
+		pr_debug("%s: card %s\n", driver_name,
+			 present ? "present" : "gone");
+		pcmcia_parse_events(&cf->socket, SS_DETECT);
+	}
+
+	if (cf->active)
+		mod_timer(&cf->timer, jiffies + POLL_INTERVAL);
+}
+
+static int bfin_cf_get_status(struct pcmcia_socket *s, u_int * sp)
+{
+	struct bfin_cf_socket *cf;
+
+	if (!sp)
+		return -EINVAL;
+
+	cf = container_of(s, struct bfin_cf_socket, socket);
+
+	if (bfin_cf_present(cf->cd_pfx)) {
+		*sp = SS_READY | SS_DETECT | SS_POWERON | SS_3VCARD;
+		s->irq.AssignedIRQ = 0;
+		s->pci_irq = cf->irq;
+
+	} else
+		*sp = 0;
+	return 0;
+}
+
+static int
+bfin_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s)
+{
+
+	struct bfin_cf_socket *cf;
+	cf = container_of(sock, struct bfin_cf_socket, socket);
+
+	switch (s->Vcc) {
+	case 0:
+	case 33:
+		break;
+	case 50:
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (s->flags & SS_RESET) {
+		disable_irq(cf->irq);
+		bfin_cf_reset();
+		enable_irq(cf->irq);
+	}
+
+	pr_debug("%s: Vcc %d, io_irq %d, flags %04x csc %04x\n",
+		 driver_name, s->Vcc, s->io_irq, s->flags, s->csc_mask);
+
+	return 0;
+}
+
+static int bfin_cf_ss_suspend(struct pcmcia_socket *s)
+{
+	pr_debug("%s: %s\n", driver_name, __FUNCTION__);
+	return bfin_cf_set_socket(s, &dead_socket);
+}
+
+/* regions are 2K each:  mem, attrib, io (and reserved-for-ide) */
+
+static int bfin_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
+{
+	struct bfin_cf_socket *cf;
+
+	cf = container_of(s, struct bfin_cf_socket, socket);
+	io->flags &= MAP_ACTIVE | MAP_ATTRIB | MAP_16BIT;
+	io->start = cf->phys_cf_io;
+	io->stop = io->start + SZ_2K - 1;
+	return 0;
+}
+
+static int
+bfin_cf_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *map)
+{
+	struct bfin_cf_socket *cf;
+
+	if (map->card_start)
+		return -EINVAL;
+	cf = container_of(s, struct bfin_cf_socket, socket);
+	map->static_start = cf->phys_cf_io;
+	map->flags &= MAP_ACTIVE | MAP_ATTRIB | MAP_16BIT;
+	if (map->flags & MAP_ATTRIB)
+		map->static_start = cf->phys_cf_attr;
+
+	return 0;
+}
+
+static struct pccard_operations bfin_cf_ops = {
+	.init = bfin_cf_ss_init,
+	.suspend = bfin_cf_ss_suspend,
+	.get_status = bfin_cf_get_status,
+	.set_socket = bfin_cf_set_socket,
+	.set_io_map = bfin_cf_set_io_map,
+	.set_mem_map = bfin_cf_set_mem_map,
+};
+
+/*--------------------------------------------------------------------------*/
+
+static int __init bfin_cf_probe(struct platform_device *pdev)
+{
+	struct bfin_cf_socket *cf;
+	struct resource *io_mem, *attr_mem;
+	int irq;
+	unsigned short cd_pfx;
+	int status = 0;
+
+	printk(KERN_INFO "Blackfin CompactFlash/PCMCIA Socket Driver\n");
+
+	irq = platform_get_irq(pdev, 0);
+	if (!irq)
+		return -EINVAL;
+
+	cd_pfx = platform_get_irq(pdev, 1);	/*Card Detect GPIO PIN */
+	if (cd_pfx > MAX_BLACKFIN_GPIOS)
+		return -EINVAL;
+
+	if (gpio_request(cd_pfx, "pcmcia: CD")) {
+		printk(KERN_ERR
+		       "BF5xx flash: Failed ro request Card Detect GPIO_%d\n",
+		       cd_pfx);
+		return -EBUSY;
+	}
+	gpio_direction_input(cd_pfx);
+
+	cf = kzalloc(sizeof *cf, GFP_KERNEL);
+	if (!cf)
+		return -ENOMEM;
+
+	cf->cd_pfx = cd_pfx;
+
+	init_timer(&cf->timer);
+	cf->timer.function = bfin_cf_timer;
+	cf->timer.data = (unsigned long)cf;
+
+	cf->pdev = pdev;
+	platform_set_drvdata(pdev, cf);
+
+	cf->irq = irq;
+	cf->socket.pci_irq = irq;
+
+	set_irq_type(irq, IRQF_TRIGGER_LOW);
+
+	io_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	attr_mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+
+	if (!io_mem || !attr_mem)
+		goto fail0;
+
+	cf->phys_cf_io = io_mem->start;
+	cf->phys_cf_attr = attr_mem->start;
+
+	/* pcmcia layer only remaps "real" memory */
+	cf->socket.io_offset = (unsigned long)
+	    ioremap(cf->phys_cf_io, SZ_2K);
+
+	if (!cf->socket.io_offset)
+		goto fail0;
+
+	pr_info("%s: on irq %d\n", driver_name, irq);
+
+	pr_debug("%s: %s\n", driver_name,
+		 bfin_cf_present(cf->cd_pfx) ? "present" : "(not present)");
+
+	cf->socket.owner = THIS_MODULE;
+	cf->socket.dev.parent = &pdev->dev;
+	cf->socket.ops = &bfin_cf_ops;
+	cf->socket.resource_ops = &pccard_static_ops;
+	cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP
+	    | SS_CAP_MEM_ALIGN;
+	cf->socket.map_size = SZ_2K;
+
+	status = pcmcia_register_socket(&cf->socket);
+	if (status < 0)
+		goto fail2;
+
+	cf->active = 1;
+	mod_timer(&cf->timer, jiffies + POLL_INTERVAL);
+	return 0;
+
+fail2:
+	iounmap((void __iomem *)cf->socket.io_offset);
+	release_mem_region(cf->phys_cf_io, SZ_8K);
+
+fail0:
+	kfree(cf);
+	platform_set_drvdata(pdev, NULL);
+
+	return status;
+}
+
+static int __devexit bfin_cf_remove(struct platform_device *pdev)
+{
+	struct bfin_cf_socket *cf = platform_get_drvdata(pdev);
+
+	gpio_free(cf->cd_pfx);
+	cf->active = 0;
+	pcmcia_unregister_socket(&cf->socket);
+	del_timer_sync(&cf->timer);
+	iounmap((void __iomem *)cf->socket.io_offset);
+	release_mem_region(cf->phys_cf_io, SZ_8K);
+	platform_set_drvdata(pdev, NULL);
+	kfree(cf);
+	return 0;
+}
+
+static int bfin_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
+{
+	return pcmcia_socket_dev_suspend(&pdev->dev, mesg);
+}
+
+static int bfin_cf_resume(struct platform_device *pdev)
+{
+	return pcmcia_socket_dev_resume(&pdev->dev);
+}
+
+static struct platform_driver bfin_cf_driver = {
+	.driver = {
+		   .name = (char *)driver_name,
+		   .owner = THIS_MODULE,
+		   },
+	.probe = bfin_cf_probe,
+	.remove = __devexit_p(bfin_cf_remove),
+	.suspend = bfin_cf_suspend,
+	.resume = bfin_cf_resume,
+};
+
+static int __init bfin_cf_init(void)
+{
+	return platform_driver_register(&bfin_cf_driver);
+}
+
+static void __exit bfin_cf_exit(void)
+{
+	platform_driver_unregister(&bfin_cf_driver);
+}
+
+module_init(bfin_cf_init);
+module_exit(bfin_cf_exit);
+
+MODULE_DESCRIPTION("BFIN CF/PCMCIA Driver");
+MODULE_LICENSE("GPL");
diff -puN include/pcmcia/cs_types.h~pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2 include/pcmcia/cs_types.h
--- a/include/pcmcia/cs_types.h~pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2
+++ a/include/pcmcia/cs_types.h
@@ -21,7 +21,7 @@
 #include <sys/types.h>
 #endif
 
-#if defined(__arm__) || defined(__mips__) || defined(__avr32__)
+#if defined(__arm__) || defined(__mips__) || defined(__avr32__) || defined(bfin)
 /* This (ioaddr_t) is exposed to userspace & hence cannot be changed. */
 typedef u_int   ioaddr_t;
 #else
_

Patches currently in -mm which might be from michael.hennerich@analog.com are

input-touchscreen-driver-add-support-ad7877-touchscreen-driver.patch
pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch
mtd-m25p80-fix-bug-atmel-spi-flash-fails-to-be-copied-to.patch


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch added to -mm tree
  2008-05-20  6:08 + pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch added to -mm tree akpm
@ 2008-05-20  7:51 ` Bryan Wu
  2008-05-20  8:02   ` Andrew Morton
  2008-05-21 23:34   ` Mike Frysinger
  0 siblings, 2 replies; 9+ messages in thread
From: Bryan Wu @ 2008-05-20  7:51 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, michael.hennerich

Thanks Andrew,

Need I resend out the a new patch which fold these 3 patches together.
it is easier for you to maintain.

Regards,
-Bryan

On Tue, May 20, 2008 at 2:08 PM,  <akpm@linux-foundation.org> wrote:
>
> The patch titled
>     PCMCIA: add support the CF PCMCIA driver for Blackfin
> has been added to the -mm tree.  Its filename is
>     pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch
>
> Before you just go and hit "reply", please:
>   a) Consider who else should be cc'ed
>   b) Prefer to cc a suitable mailing list as well
>   c) Ideally: find the original patch on the mailing list and do a
>      reply-to-all to that, adding suitable additional cc's
>
> *** Remember to use Documentation/SubmitChecklist when testing your code ***
>
> See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
> out what to do about this
>
> The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/
>
> ------------------------------------------------------
> Subject: PCMCIA: add support the CF PCMCIA driver for Blackfin
> From: Michael Hennerich <michael.hennerich@analog.com>
>
> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
> Signed-off-by: Bryan Wu <cooloney@kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
>  drivers/pcmcia/Kconfig          |    7
>  drivers/pcmcia/Makefile         |    1
>  drivers/pcmcia/bfin_cf_pcmcia.c |  341 ++++++++++++++++++++++++++++++
>  include/pcmcia/cs_types.h       |    2
>  4 files changed, 350 insertions(+), 1 deletion(-)
>
> diff -puN drivers/pcmcia/Kconfig~pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2 drivers/pcmcia/Kconfig
> --- a/drivers/pcmcia/Kconfig~pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2
> +++ a/drivers/pcmcia/Kconfig
> @@ -263,6 +263,13 @@ config OMAP_CF
>          Say Y here to support the CompactFlash controller on OMAP.
>          Note that this doesn't support "True IDE" mode.
>
> +config BFIN_CFPCMCIA
> +       tristate "Blackfin CompactFlash PCMCIA Driver"
> +       depends on PCMCIA && BLACKFIN
> +       help
> +         Say Y here to support the CompactFlash PCMCIA driver for Blackfin.
> +
> +
>  config AT91_CF
>        tristate "AT91 CompactFlash Controller"
>        depends on PCMCIA && ARCH_AT91RM9200
> diff -puN drivers/pcmcia/Makefile~pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2 drivers/pcmcia/Makefile
> --- a/drivers/pcmcia/Makefile~pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2
> +++ a/drivers/pcmcia/Makefile
> @@ -36,6 +36,7 @@ obj-$(CONFIG_PCMCIA_AU1X00)                   += au1x00_
>  obj-$(CONFIG_PCMCIA_VRC4171)                   += vrc4171_card.o
>  obj-$(CONFIG_PCMCIA_VRC4173)                   += vrc4173_cardu.o
>  obj-$(CONFIG_OMAP_CF)                          += omap_cf.o
> +obj-$(CONFIG_BFIN_CFPCMCIA)                    += bfin_cf_pcmcia.o
>  obj-$(CONFIG_AT91_CF)                          += at91_cf.o
>  obj-$(CONFIG_ELECTRA_CF)                       += electra_cf.o
>
> diff -puN /dev/null drivers/pcmcia/bfin_cf_pcmcia.c
> --- /dev/null
> +++ a/drivers/pcmcia/bfin_cf_pcmcia.c
> @@ -0,0 +1,341 @@
> +/*
> + * file: drivers/pcmcia/bfin_cf.c
> + * author: Michael Hennerich (hennerich@blackfin.uclinux.org)
> + *
> + * based on: drivers/pcmcia/omap_cf.c
> + * omap_cf.c -- OMAP 16xx CompactFlash controller driver
> + *
> + * Copyright (c) 2005 David Brownell
> + * Copyright (c) 2006-2008 Michael Hennerich Analog Devices Inc.
> + *
> + * bugs:         enter bugs at http://blackfin.uclinux.org/
> + *
> + * 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, 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; see the file copying.
> + * if not, write to the free software foundation,
> + * 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 <linux/irq.h>
> +
> +#include <pcmcia/ss.h>
> +#include <pcmcia/cisreg.h>
> +#include <asm/io.h>
> +#include <asm/gpio.h>
> +
> +#define        SZ_1K   0x00000400
> +#define        SZ_8K   0x00002000
> +#define        SZ_2K   (2 * SZ_1K)
> +
> +#define        POLL_INTERVAL   (2 * HZ)
> +
> +#define        CF_ATASEL_ENA   0x20311802      /* Inverts RESET */
> +#define        CF_ATASEL_DIS   0x20311800
> +
> +#define bfin_cf_present(pfx) (gpio_get_value(pfx))
> +
> +/*--------------------------------------------------------------------------*/
> +
> +static const char driver_name[] = "bfin_cf_pcmcia";
> +
> +struct bfin_cf_socket {
> +       struct pcmcia_socket socket;
> +
> +       struct timer_list timer;
> +       unsigned present:1;
> +       unsigned active:1;
> +
> +       struct platform_device *pdev;
> +       unsigned long phys_cf_io;
> +       unsigned long phys_cf_attr;
> +       u_int irq;
> +       u_short cd_pfx;
> +};
> +
> +/*--------------------------------------------------------------------------*/
> +static int bfin_cf_reset(void)
> +{
> +       outw(0, CF_ATASEL_ENA);
> +       mdelay(200);
> +       outw(0, CF_ATASEL_DIS);
> +
> +       return 0;
> +}
> +
> +static int bfin_cf_ss_init(struct pcmcia_socket *s)
> +{
> +       return 0;
> +}
> +
> +/* the timer is primarily to kick this socket's pccardd */
> +static void bfin_cf_timer(unsigned long _cf)
> +{
> +       struct bfin_cf_socket *cf = (void *)_cf;
> +       unsigned short present = bfin_cf_present(cf->cd_pfx);
> +
> +       if (present != cf->present) {
> +               cf->present = present;
> +               pr_debug("%s: card %s\n", driver_name,
> +                        present ? "present" : "gone");
> +               pcmcia_parse_events(&cf->socket, SS_DETECT);
> +       }
> +
> +       if (cf->active)
> +               mod_timer(&cf->timer, jiffies + POLL_INTERVAL);
> +}
> +
> +static int bfin_cf_get_status(struct pcmcia_socket *s, u_int * sp)
> +{
> +       struct bfin_cf_socket *cf;
> +
> +       if (!sp)
> +               return -EINVAL;
> +
> +       cf = container_of(s, struct bfin_cf_socket, socket);
> +
> +       if (bfin_cf_present(cf->cd_pfx)) {
> +               *sp = SS_READY | SS_DETECT | SS_POWERON | SS_3VCARD;
> +               s->irq.AssignedIRQ = 0;
> +               s->pci_irq = cf->irq;
> +
> +       } else
> +               *sp = 0;
> +       return 0;
> +}
> +
> +static int
> +bfin_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s)
> +{
> +
> +       struct bfin_cf_socket *cf;
> +       cf = container_of(sock, struct bfin_cf_socket, socket);
> +
> +       switch (s->Vcc) {
> +       case 0:
> +       case 33:
> +               break;
> +       case 50:
> +               break;
> +       default:
> +               return -EINVAL;
> +       }
> +
> +       if (s->flags & SS_RESET) {
> +               disable_irq(cf->irq);
> +               bfin_cf_reset();
> +               enable_irq(cf->irq);
> +       }
> +
> +       pr_debug("%s: Vcc %d, io_irq %d, flags %04x csc %04x\n",
> +                driver_name, s->Vcc, s->io_irq, s->flags, s->csc_mask);
> +
> +       return 0;
> +}
> +
> +static int bfin_cf_ss_suspend(struct pcmcia_socket *s)
> +{
> +       pr_debug("%s: %s\n", driver_name, __FUNCTION__);
> +       return bfin_cf_set_socket(s, &dead_socket);
> +}
> +
> +/* regions are 2K each:  mem, attrib, io (and reserved-for-ide) */
> +
> +static int bfin_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
> +{
> +       struct bfin_cf_socket *cf;
> +
> +       cf = container_of(s, struct bfin_cf_socket, socket);
> +       io->flags &= MAP_ACTIVE | MAP_ATTRIB | MAP_16BIT;
> +       io->start = cf->phys_cf_io;
> +       io->stop = io->start + SZ_2K - 1;
> +       return 0;
> +}
> +
> +static int
> +bfin_cf_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *map)
> +{
> +       struct bfin_cf_socket *cf;
> +
> +       if (map->card_start)
> +               return -EINVAL;
> +       cf = container_of(s, struct bfin_cf_socket, socket);
> +       map->static_start = cf->phys_cf_io;
> +       map->flags &= MAP_ACTIVE | MAP_ATTRIB | MAP_16BIT;
> +       if (map->flags & MAP_ATTRIB)
> +               map->static_start = cf->phys_cf_attr;
> +
> +       return 0;
> +}
> +
> +static struct pccard_operations bfin_cf_ops = {
> +       .init = bfin_cf_ss_init,
> +       .suspend = bfin_cf_ss_suspend,
> +       .get_status = bfin_cf_get_status,
> +       .set_socket = bfin_cf_set_socket,
> +       .set_io_map = bfin_cf_set_io_map,
> +       .set_mem_map = bfin_cf_set_mem_map,
> +};
> +
> +/*--------------------------------------------------------------------------*/
> +
> +static int __init bfin_cf_probe(struct platform_device *pdev)
> +{
> +       struct bfin_cf_socket *cf;
> +       struct resource *io_mem, *attr_mem;
> +       int irq;
> +       unsigned short cd_pfx;
> +       int status = 0;
> +
> +       printk(KERN_INFO "Blackfin CompactFlash/PCMCIA Socket Driver\n");
> +
> +       irq = platform_get_irq(pdev, 0);
> +       if (!irq)
> +               return -EINVAL;
> +
> +       cd_pfx = platform_get_irq(pdev, 1);     /*Card Detect GPIO PIN */
> +       if (cd_pfx > MAX_BLACKFIN_GPIOS)
> +               return -EINVAL;
> +
> +       if (gpio_request(cd_pfx, "pcmcia: CD")) {
> +               printk(KERN_ERR
> +                      "BF5xx flash: Failed ro request Card Detect GPIO_%d\n",
> +                      cd_pfx);
> +               return -EBUSY;
> +       }
> +       gpio_direction_input(cd_pfx);
> +
> +       cf = kzalloc(sizeof *cf, GFP_KERNEL);
> +       if (!cf)
> +               return -ENOMEM;
> +
> +       cf->cd_pfx = cd_pfx;
> +
> +       init_timer(&cf->timer);
> +       cf->timer.function = bfin_cf_timer;
> +       cf->timer.data = (unsigned long)cf;
> +
> +       cf->pdev = pdev;
> +       platform_set_drvdata(pdev, cf);
> +
> +       cf->irq = irq;
> +       cf->socket.pci_irq = irq;
> +
> +       set_irq_type(irq, IRQF_TRIGGER_LOW);
> +
> +       io_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +       attr_mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> +
> +       if (!io_mem || !attr_mem)
> +               goto fail0;
> +
> +       cf->phys_cf_io = io_mem->start;
> +       cf->phys_cf_attr = attr_mem->start;
> +
> +       /* pcmcia layer only remaps "real" memory */
> +       cf->socket.io_offset = (unsigned long)
> +           ioremap(cf->phys_cf_io, SZ_2K);
> +
> +       if (!cf->socket.io_offset)
> +               goto fail0;
> +
> +       pr_info("%s: on irq %d\n", driver_name, irq);
> +
> +       pr_debug("%s: %s\n", driver_name,
> +                bfin_cf_present(cf->cd_pfx) ? "present" : "(not present)");
> +
> +       cf->socket.owner = THIS_MODULE;
> +       cf->socket.dev.parent = &pdev->dev;
> +       cf->socket.ops = &bfin_cf_ops;
> +       cf->socket.resource_ops = &pccard_static_ops;
> +       cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP
> +           | SS_CAP_MEM_ALIGN;
> +       cf->socket.map_size = SZ_2K;
> +
> +       status = pcmcia_register_socket(&cf->socket);
> +       if (status < 0)
> +               goto fail2;
> +
> +       cf->active = 1;
> +       mod_timer(&cf->timer, jiffies + POLL_INTERVAL);
> +       return 0;
> +
> +fail2:
> +       iounmap((void __iomem *)cf->socket.io_offset);
> +       release_mem_region(cf->phys_cf_io, SZ_8K);
> +
> +fail0:
> +       kfree(cf);
> +       platform_set_drvdata(pdev, NULL);
> +
> +       return status;
> +}
> +
> +static int __devexit bfin_cf_remove(struct platform_device *pdev)
> +{
> +       struct bfin_cf_socket *cf = platform_get_drvdata(pdev);
> +
> +       gpio_free(cf->cd_pfx);
> +       cf->active = 0;
> +       pcmcia_unregister_socket(&cf->socket);
> +       del_timer_sync(&cf->timer);
> +       iounmap((void __iomem *)cf->socket.io_offset);
> +       release_mem_region(cf->phys_cf_io, SZ_8K);
> +       platform_set_drvdata(pdev, NULL);
> +       kfree(cf);
> +       return 0;
> +}
> +
> +static int bfin_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
> +{
> +       return pcmcia_socket_dev_suspend(&pdev->dev, mesg);
> +}
> +
> +static int bfin_cf_resume(struct platform_device *pdev)
> +{
> +       return pcmcia_socket_dev_resume(&pdev->dev);
> +}
> +
> +static struct platform_driver bfin_cf_driver = {
> +       .driver = {
> +                  .name = (char *)driver_name,
> +                  .owner = THIS_MODULE,
> +                  },
> +       .probe = bfin_cf_probe,
> +       .remove = __devexit_p(bfin_cf_remove),
> +       .suspend = bfin_cf_suspend,
> +       .resume = bfin_cf_resume,
> +};
> +
> +static int __init bfin_cf_init(void)
> +{
> +       return platform_driver_register(&bfin_cf_driver);
> +}
> +
> +static void __exit bfin_cf_exit(void)
> +{
> +       platform_driver_unregister(&bfin_cf_driver);
> +}
> +
> +module_init(bfin_cf_init);
> +module_exit(bfin_cf_exit);
> +
> +MODULE_DESCRIPTION("BFIN CF/PCMCIA Driver");
> +MODULE_LICENSE("GPL");
> diff -puN include/pcmcia/cs_types.h~pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2 include/pcmcia/cs_types.h
> --- a/include/pcmcia/cs_types.h~pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2
> +++ a/include/pcmcia/cs_types.h
> @@ -21,7 +21,7 @@
>  #include <sys/types.h>
>  #endif
>
> -#if defined(__arm__) || defined(__mips__) || defined(__avr32__)
> +#if defined(__arm__) || defined(__mips__) || defined(__avr32__) || defined(bfin)
>  /* This (ioaddr_t) is exposed to userspace & hence cannot be changed. */
>  typedef u_int   ioaddr_t;
>  #else
> _
>
> Patches currently in -mm which might be from michael.hennerich@analog.com are
>
> input-touchscreen-driver-add-support-ad7877-touchscreen-driver.patch
> pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch
> mtd-m25p80-fix-bug-atmel-spi-flash-fails-to-be-copied-to.patch
>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch added to -mm tree
  2008-05-20  7:51 ` Bryan Wu
@ 2008-05-20  8:02   ` Andrew Morton
  2008-05-21  0:41     ` Mike Frysinger
  2008-05-21 23:34   ` Mike Frysinger
  1 sibling, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2008-05-20  8:02 UTC (permalink / raw)
  To: Bryan Wu; +Cc: linux-kernel, michael.hennerich

On Tue, 20 May 2008 15:51:13 +0800 "Bryan Wu" <cooloney@kernel.org> wrote:
>

eek, scary top-posting.

> Need I resend out the a new patch which fold these 3 patches together.
> it is easier for you to maintain.

Nope,  I keep the patches separate and then fold them prior to sending
to Linus.

I marked this as for-2.6.26 as it's clearly non-injurious to existing stuff.

This:

> -#if defined(__arm__) || defined(__mips__) || defined(__avr32__)
> +#if defined(__arm__) || defined(__mips__) || defined(__avr32__) || defined(bfin)

should probably be using CONFIG_foo but that might not work if it's to
be preprocessed by userspace.  I didn't look.  Plus that'd be
off-topic.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch added to -mm tree
  2008-05-20  8:02   ` Andrew Morton
@ 2008-05-21  0:41     ` Mike Frysinger
  2008-05-21 23:11       ` Andrew Morton
  0 siblings, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2008-05-21  0:41 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Bryan Wu, linux-kernel, michael.hennerich

On Tue, May 20, 2008 at 4:02 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Tue, 20 May 2008 15:51:13 +0800 "Bryan Wu" <cooloney@kernel.org> wrote:
>> Need I resend out the a new patch which fold these 3 patches together.
>> it is easier for you to maintain.
>
> Nope,  I keep the patches separate and then fold them prior to sending
> to Linus.
>
> I marked this as for-2.6.26 as it's clearly non-injurious to existing stuff.
>
> This:
>
>> -#if defined(__arm__) || defined(__mips__) || defined(__avr32__)
>> +#if defined(__arm__) || defined(__mips__) || defined(__avr32__) || defined(bfin)
>
> should probably be using CONFIG_foo but that might not work if it's to
> be preprocessed by userspace.  I didn't look.  Plus that'd be
> off-topic.

it should be defined(__bfin__) at least.  perhaps i should add that
check to checkpatch.pl as well ...
-mike

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch added to -mm tree
  2008-05-21  0:41     ` Mike Frysinger
@ 2008-05-21 23:11       ` Andrew Morton
  2008-05-21 23:23         ` Mike Frysinger
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2008-05-21 23:11 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: cooloney, linux-kernel, michael.hennerich

On Tue, 20 May 2008 20:41:13 -0400
"Mike Frysinger" <vapier.adi@gmail.com> wrote:

> > This:
> >
> >> -#if defined(__arm__) || defined(__mips__) || defined(__avr32__)
> >> +#if defined(__arm__) || defined(__mips__) || defined(__avr32__) || defined(bfin)
> >
> > should probably be using CONFIG_foo but that might not work if it's to
> > be preprocessed by userspace.  I didn't look.  Plus that'd be
> > off-topic.
> 
> it should be defined(__bfin__) at least.

Well I made that change, but this all has a rather untested feeling to
it.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch added to -mm tree
  2008-05-21 23:11       ` Andrew Morton
@ 2008-05-21 23:23         ` Mike Frysinger
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2008-05-21 23:23 UTC (permalink / raw)
  To: Andrew Morton; +Cc: cooloney, linux-kernel, michael.hennerich

On Wed, May 21, 2008 at 7:11 PM, Andrew Morton wrote:
> On Tue, 20 May 2008 20:41:13 -0400 "Mike Frysinger" wrote:
>> > This:
>> >
>> >> -#if defined(__arm__) || defined(__mips__) || defined(__avr32__)
>> >> +#if defined(__arm__) || defined(__mips__) || defined(__avr32__) || defined(bfin)
>> >
>> > should probably be using CONFIG_foo but that might not work if it's to
>> > be preprocessed by userspace.  I didn't look.  Plus that'd be
>> > off-topic.
>>
>> it should be defined(__bfin__) at least.
>
> Well I made that change, but this all has a rather untested feeling to
> it.

both will work with Blackfin toolchains, the latter form is obviously preferred
-mike

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch added to -mm tree
  2008-05-20  7:51 ` Bryan Wu
  2008-05-20  8:02   ` Andrew Morton
@ 2008-05-21 23:34   ` Mike Frysinger
  2008-05-27 11:15     ` Hennerich, Michael
  1 sibling, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2008-05-21 23:34 UTC (permalink / raw)
  To: Bryan Wu, michael.hennerich; +Cc: akpm, Linux Kernel List

On Tue, May 20, 2008 at 3:51 AM, Bryan Wu <cooloney@kernel.org> wrote:
> On Tue, May 20, 2008 at 2:08 PM,  <akpm@linux-foundation.org> wrote:
>> +config BFIN_CFPCMCIA
>> +       tristate "Blackfin CompactFlash PCMCIA Driver"
>> +       depends on PCMCIA && BLACKFIN
>> +       help
>> +         Say Y here to support the CompactFlash PCMCIA driver for Blackfin.

please add a common statement that tells you the module name if the
user builds it as a module.

>> + * author: Michael Hennerich (hennerich@blackfin.uclinux.org)

shouldnt this be MODULE_AUTHOR() ?

>> +       u_int irq;
>> +       u_short cd_pfx;

u_int forms are weird ... i'd wonder why we have these variations
anywhere in the kernel

>> +static int __init bfin_cf_probe(struct platform_device *pdev)

should be __devinit

>> +       cd_pfx = platform_get_irq(pdev, 1);     /*Card Detect GPIO PIN */
>> +       if (cd_pfx > MAX_BLACKFIN_GPIOS)
>> +               return -EINVAL;
>> +
>> +       if (gpio_request(cd_pfx, "pcmcia: CD")) {

i dont think that MAX_BLACKFIN_GPIOS check is needed.  the
gpio_request() function should already be doing it.

>> +               printk(KERN_ERR
>> +                      "BF5xx flash: Failed ro request Card Detect GPIO_%d\n",

"BF5xx flash" ?

>> +       cf = kzalloc(sizeof *cf, GFP_KERNEL);
>> +       if (!cf)
>> +               return -ENOMEM;

we dont call gpio_free() here or in the fail0 case below.
-mike

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: + pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch added to -mm tree
  2008-05-21 23:34   ` Mike Frysinger
@ 2008-05-27 11:15     ` Hennerich, Michael
  2008-05-27 15:49       ` Bryan Wu
  0 siblings, 1 reply; 9+ messages in thread
From: Hennerich, Michael @ 2008-05-27 11:15 UTC (permalink / raw)
  To: Mike Frysinger, Bryan Wu, michael.hennerich; +Cc: akpm, Linux Kernel List



>-----Original Message-----
>From: Mike Frysinger [mailto:vapier.adi@gmail.com]
>Sent: Donnerstag, 22. Mai 2008 01:34
>To: Bryan Wu; michael.hennerich@analog.com
>Cc: akpm@linux-foundation.org; Linux Kernel List
>Subject: Re: +
pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-
>2.patch added to -mm tree
>
>On Tue, May 20, 2008 at 3:51 AM, Bryan Wu <cooloney@kernel.org> wrote:
>> On Tue, May 20, 2008 at 2:08 PM,  <akpm@linux-foundation.org> wrote:
>>> +config BFIN_CFPCMCIA
>>> +       tristate "Blackfin CompactFlash PCMCIA Driver"
>>> +       depends on PCMCIA && BLACKFIN
>>> +       help
>>> +         Say Y here to support the CompactFlash PCMCIA driver for
>Blackfin.
>
>please add a common statement that tells you the module name if the
>user builds it as a module.
>
>>> + * author: Michael Hennerich (hennerich@blackfin.uclinux.org)
>
>shouldnt this be MODULE_AUTHOR() ?

Yes.

>
>>> +       u_int irq;
>>> +       u_short cd_pfx;
>
>u_int forms are weird ... i'd wonder why we have these variations
>anywhere in the kernel

Beauty is in the eye of the beholder... 

>
>>> +static int __init bfin_cf_probe(struct platform_device *pdev)
>
>should be __devinit
>
>>> +       cd_pfx = platform_get_irq(pdev, 1);     /*Card Detect GPIO
PIN
>*/
>>> +       if (cd_pfx > MAX_BLACKFIN_GPIOS)
>>> +               return -EINVAL;
>>> +
>>> +       if (gpio_request(cd_pfx, "pcmcia: CD")) {
>
>i dont think that MAX_BLACKFIN_GPIOS check is needed.  the
>gpio_request() function should already be doing it.
>
>>> +               printk(KERN_ERR
>>> +                      "BF5xx flash: Failed ro request Card Detect
>GPIO_%d\n",
>
>"BF5xx flash" ?
>
>>> +       cf = kzalloc(sizeof *cf, GFP_KERNEL);
>>> +       if (!cf)
>>> +               return -ENOMEM;
>
>we dont call gpio_free() here or in the fail0 case below.

Fixed.

Bryan,
 are you going to send a new patch?

-Michael

>-mike

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: + pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch added to -mm tree
  2008-05-27 11:15     ` Hennerich, Michael
@ 2008-05-27 15:49       ` Bryan Wu
  0 siblings, 0 replies; 9+ messages in thread
From: Bryan Wu @ 2008-05-27 15:49 UTC (permalink / raw)
  To: Hennerich, Michael; +Cc: Mike Frysinger, akpm, Linux Kernel List

On Tue, May 27, 2008 at 7:15 PM, Hennerich, Michael
<Michael.Hennerich@analog.com> wrote:
>
>
>>-----Original Message-----
>>From: Mike Frysinger [mailto:vapier.adi@gmail.com]
>>Sent: Donnerstag, 22. Mai 2008 01:34
>>To: Bryan Wu; michael.hennerich@analog.com
>>Cc: akpm@linux-foundation.org; Linux Kernel List
>>Subject: Re: +
> pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-
>>2.patch added to -mm tree
>>
>>On Tue, May 20, 2008 at 3:51 AM, Bryan Wu <cooloney@kernel.org> wrote:
>>> On Tue, May 20, 2008 at 2:08 PM,  <akpm@linux-foundation.org> wrote:
>>>> +config BFIN_CFPCMCIA
>>>> +       tristate "Blackfin CompactFlash PCMCIA Driver"
>>>> +       depends on PCMCIA && BLACKFIN
>>>> +       help
>>>> +         Say Y here to support the CompactFlash PCMCIA driver for
>>Blackfin.
>>
>>please add a common statement that tells you the module name if the
>>user builds it as a module.
>>
>>>> + * author: Michael Hennerich (hennerich@blackfin.uclinux.org)
>>
>>shouldnt this be MODULE_AUTHOR() ?
>
> Yes.
>
>>
>>>> +       u_int irq;
>>>> +       u_short cd_pfx;
>>
>>u_int forms are weird ... i'd wonder why we have these variations
>>anywhere in the kernel
>
> Beauty is in the eye of the beholder...
>
>>
>>>> +static int __init bfin_cf_probe(struct platform_device *pdev)
>>
>>should be __devinit
>>
>>>> +       cd_pfx = platform_get_irq(pdev, 1);     /*Card Detect GPIO
> PIN
>>*/
>>>> +       if (cd_pfx > MAX_BLACKFIN_GPIOS)
>>>> +               return -EINVAL;
>>>> +
>>>> +       if (gpio_request(cd_pfx, "pcmcia: CD")) {
>>
>>i dont think that MAX_BLACKFIN_GPIOS check is needed.  the
>>gpio_request() function should already be doing it.
>>
>>>> +               printk(KERN_ERR
>>>> +                      "BF5xx flash: Failed ro request Card Detect
>>GPIO_%d\n",
>>
>>"BF5xx flash" ?
>>
>>>> +       cf = kzalloc(sizeof *cf, GFP_KERNEL);
>>>> +       if (!cf)
>>>> +               return -ENOMEM;
>>
>>we dont call gpio_free() here or in the fail0 case below.
>
> Fixed.
>
> Bryan,
>  are you going to send a new patch?
>

No problem, I will take care of it.

-Bryan

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-05-27 15:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-20  6:08 + pcmcia-add-support-the-cf-pcmcia-driver-for-blackfin-try-2.patch added to -mm tree akpm
2008-05-20  7:51 ` Bryan Wu
2008-05-20  8:02   ` Andrew Morton
2008-05-21  0:41     ` Mike Frysinger
2008-05-21 23:11       ` Andrew Morton
2008-05-21 23:23         ` Mike Frysinger
2008-05-21 23:34   ` Mike Frysinger
2008-05-27 11:15     ` Hennerich, Michael
2008-05-27 15:49       ` Bryan Wu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.