Re: [PATCH] mmc: Disabler for Ricoh MMC controller

2007-10-02 Thread Pierre Ossman
On Tue, 02 Oct 2007 17:14:34 +1000
Benjamin Herrenschmidt <[EMAIL PROTECTED]> wrote:

> 
> Hrm... allright, tho having this "disabler" driver is butt ugly
> too ... especially since it needs to whack registers in another
> function, that's really quirkland :-)
> 

Well, that issue would remain even if we put it into sdhci.c. Perhaps
something can be done when sdhci is split into multiple parts, but not
right now.

Rgds
Pierre


signature.asc
Description: PGP signature


Re: [PATCH] mmc: Disabler for Ricoh MMC controller

2007-10-02 Thread Benjamin Herrenschmidt

On Mon, 2007-10-01 at 22:01 -0700, Philip Langdale wrote:
> Benjamin Herrenschmidt wrote:
> > On Tue, 2007-10-02 at 14:44 +1000, Benjamin Herrenschmidt wrote:
> >> On Mon, 2007-10-01 at 20:23 -0700, Philip Langdale wrote:
> >>> Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to disable 
> >>> the
> >>> MMC controller on the multi-function Ricoh R5C832. The MMC controller 
> >>> needs
> >>> to be disabled or it will steal MMC cards from the SD controller where 
> >>> they
> >>> would otherwise be supported by the Linux SDHCI driver.
> >> Why can't that be a quirk instead ?
> > 
> > That is, a global quirk or a quirk in the SDHCI driver...
> 
> Pierre doesn't want a quirk.

Hrm... allright, tho having this "disabler" driver is butt ugly too ...
especially since it needs to whack registers in another function, that's
really quirkland :-)

Oh well...

Ben.


-
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] mmc: Disabler for Ricoh MMC controller

2007-10-02 Thread Benjamin Herrenschmidt

On Mon, 2007-10-01 at 22:01 -0700, Philip Langdale wrote:
 Benjamin Herrenschmidt wrote:
  On Tue, 2007-10-02 at 14:44 +1000, Benjamin Herrenschmidt wrote:
  On Mon, 2007-10-01 at 20:23 -0700, Philip Langdale wrote:
  Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to disable 
  the
  MMC controller on the multi-function Ricoh R5C832. The MMC controller 
  needs
  to be disabled or it will steal MMC cards from the SD controller where 
  they
  would otherwise be supported by the Linux SDHCI driver.
  Why can't that be a quirk instead ?
  
  That is, a global quirk or a quirk in the SDHCI driver...
 
 Pierre doesn't want a quirk.

Hrm... allright, tho having this disabler driver is butt ugly too ...
especially since it needs to whack registers in another function, that's
really quirkland :-)

Oh well...

Ben.


-
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] mmc: Disabler for Ricoh MMC controller

2007-10-02 Thread Pierre Ossman
On Tue, 02 Oct 2007 17:14:34 +1000
Benjamin Herrenschmidt [EMAIL PROTECTED] wrote:

 
 Hrm... allright, tho having this disabler driver is butt ugly
 too ... especially since it needs to whack registers in another
 function, that's really quirkland :-)
 

Well, that issue would remain even if we put it into sdhci.c. Perhaps
something can be done when sdhci is split into multiple parts, but not
right now.

Rgds
Pierre


signature.asc
Description: PGP signature


Re: [PATCH] mmc: Disabler for Ricoh MMC controller

2007-10-01 Thread Philip Langdale
Benjamin Herrenschmidt wrote:
> On Tue, 2007-10-02 at 14:44 +1000, Benjamin Herrenschmidt wrote:
>> On Mon, 2007-10-01 at 20:23 -0700, Philip Langdale wrote:
>>> Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to disable the
>>> MMC controller on the multi-function Ricoh R5C832. The MMC controller needs
>>> to be disabled or it will steal MMC cards from the SD controller where they
>>> would otherwise be supported by the Linux SDHCI driver.
>> Why can't that be a quirk instead ?
> 
> That is, a global quirk or a quirk in the SDHCI driver...

Pierre doesn't want a quirk.

--phil
-
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] mmc: Disabler for Ricoh MMC controller

2007-10-01 Thread Benjamin Herrenschmidt

On Tue, 2007-10-02 at 14:44 +1000, Benjamin Herrenschmidt wrote:
> On Mon, 2007-10-01 at 20:23 -0700, Philip Langdale wrote:
> > Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to disable the
> > MMC controller on the multi-function Ricoh R5C832. The MMC controller needs
> > to be disabled or it will steal MMC cards from the SD controller where they
> > would otherwise be supported by the Linux SDHCI driver.
> 
> Why can't that be a quirk instead ?

That is, a global quirk or a quirk in the SDHCI driver...

> > Signed-off-by: Philipl Langdale <[EMAIL PROTECTED]>
> > 
> > --- linux-2.6.22/drivers/mmc/host/Kconfig   2007-07-08 16:32:17.0 
> > -0700
> > +++ linux-ricoh/drivers/mmc/host/Kconfig2007-09-15 12:32:10.0 
> > -0700
> > @@ -35,6 +35,23 @@
> > 
> >   If unsure, say N.
> > 
> > +config MMC_RICOH_MMC
> > +   tristate "Ricoh MMC Controller Disabler  (EXPERIMENTAL)"
> > +   depends on PCI && EXPERIMENTAL && MMC_SDHCI
> > +   help
> > + This selects the disabler for the Ricoh MMC Controller. This
> > + proprietary controller is unnecessary because the SDHCI driver
> > + supports MMC cards on the SD controller, but if it is not
> > + disabled, it will steal the MMC cards away - rendering them
> > + useless. It is safe to select this driver even if you don't
> > + have a Ricoh based card reader.
> > +
> > +
> > + To compile this driver as a module, choose M here:
> > + the module will be called ricoh_mmc.
> > +
> > + If unsure, say Y.
> > +
> >  config MMC_OMAP
> > tristate "TI OMAP Multimedia Card Interface support"
> > depends on ARCH_OMAP
> > --- linux-2.6.22/drivers/mmc/host/Makefile  2007-07-08 16:32:17.0 
> > -0700
> > +++ linux-ricoh/drivers/mmc/host/Makefile   2007-09-15 12:28:49.0 
> > -0700
> > @@ -15,4 +15,5 @@
> >  obj-$(CONFIG_MMC_OMAP) += omap.o
> >  obj-$(CONFIG_MMC_AT91) += at91_mci.o
> >  obj-$(CONFIG_MMC_TIFM_SD)  += tifm_sd.o
> > +obj-$(CONFIG_MMC_RICOH_MMC)+= ricoh_mmc.o
> > 
> > --- linux-2.6.22/drivers/mmc/host/ricoh_mmc.c   1969-12-31 
> > 16:00:00.0 -0800
> > +++ linux-ricoh/drivers/mmc/host/ricoh_mmc.c2007-09-15 
> > 12:29:05.0 -0700
> > @@ -0,0 +1,156 @@
> > +/*
> > + *  ricoh_mmc.c - Dummy driver to disable the Rioch MMC controller.
> > + *
> > + *  Copyright (C) 2007 Philip Langdale, All Rights Reserved.
> > + *
> > + * 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 is a conceptually ridiculous driver, but it is required by the way
> > + * the Ricoh multi-function R5C832 works. This chip implements firewire
> > + * and four different memory card controllers. Two of those controllers are
> > + * an SDHCI controller and a proprietary MMC controller. The linux SDHCI
> > + * driver supports MMC cards but the chip detects MMC cards in hardware
> > + * and directs them to the MMC controller - so the SDHCI driver never sees
> > + * them. To get around this, we must disable the useless MMC controller.
> > + * At that point, the SDHCI controller will start seeing them. As a bonus,
> > + * a detection event occurs immediately, even if the MMC card is already
> > + * in the reader.
> > + *
> > + * The relevant registers live on the firewire function, so this is 
> > unavoidably
> > + * ugly. Such is life.
> > + */
> > +
> > +#include 
> > +
> > +#define DRIVER_NAME "ricoh-mmc"
> > +
> > +#define DBG(f, x...) \
> > +   pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x)
> > +
> > +static const struct pci_device_id pci_ids[] __devinitdata = {
> > +   {
> > +   .vendor = PCI_VENDOR_ID_RICOH,
> > +   .device = PCI_DEVICE_ID_RICOH_R5C843,
> > +   .subvendor  = PCI_ANY_ID,
> > +   .subdevice  = PCI_ANY_ID,
> > +   },
> > +   { /* end: all zeroes */ },
> > +};
> > +
> > +MODULE_DEVICE_TABLE(pci, pci_ids);
> > +
> > +static int __devinit ricoh_mmc_probe(struct pci_dev *pdev,
> > +const struct pci_device_id *ent)
> > +{
> > +   u8 rev;
> > +
> > +   struct pci_dev *fw_dev = NULL;
> > +
> > +   BUG_ON(pdev == NULL);
> > +   BUG_ON(ent == NULL);
> > +
> > +   pci_read_config_byte(pdev, PCI_CLASS_REVISION, );
> > +
> > +   printk(KERN_INFO DRIVER_NAME
> > +   ": Ricoh MMC controller found at %s [%04x:%04x] (rev %x)\n",
> > +   pci_name(pdev), (int)pdev->vendor, (int)pdev->device,
> > +   (int)rev);
> > +
> > +   while ((fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, 
> > PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) {
> > +   if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) &&
> > +   pdev->bus == fw_dev->bus) {
> > +   u8 write_enable;
> > +   

Re: [PATCH] mmc: Disabler for Ricoh MMC controller

2007-10-01 Thread Benjamin Herrenschmidt

On Mon, 2007-10-01 at 20:23 -0700, Philip Langdale wrote:
> Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to disable the
> MMC controller on the multi-function Ricoh R5C832. The MMC controller needs
> to be disabled or it will steal MMC cards from the SD controller where they
> would otherwise be supported by the Linux SDHCI driver.

Why can't that be a quirk instead ?

> Signed-off-by: Philipl Langdale <[EMAIL PROTECTED]>
> 
> --- linux-2.6.22/drivers/mmc/host/Kconfig 2007-07-08 16:32:17.0 
> -0700
> +++ linux-ricoh/drivers/mmc/host/Kconfig  2007-09-15 12:32:10.0 
> -0700
> @@ -35,6 +35,23 @@
> 
> If unsure, say N.
> 
> +config MMC_RICOH_MMC
> + tristate "Ricoh MMC Controller Disabler  (EXPERIMENTAL)"
> + depends on PCI && EXPERIMENTAL && MMC_SDHCI
> + help
> +   This selects the disabler for the Ricoh MMC Controller. This
> +   proprietary controller is unnecessary because the SDHCI driver
> +   supports MMC cards on the SD controller, but if it is not
> +   disabled, it will steal the MMC cards away - rendering them
> +   useless. It is safe to select this driver even if you don't
> +   have a Ricoh based card reader.
> +
> +
> +   To compile this driver as a module, choose M here:
> +   the module will be called ricoh_mmc.
> +
> +   If unsure, say Y.
> +
>  config MMC_OMAP
>   tristate "TI OMAP Multimedia Card Interface support"
>   depends on ARCH_OMAP
> --- linux-2.6.22/drivers/mmc/host/Makefile2007-07-08 16:32:17.0 
> -0700
> +++ linux-ricoh/drivers/mmc/host/Makefile 2007-09-15 12:28:49.0 
> -0700
> @@ -15,4 +15,5 @@
>  obj-$(CONFIG_MMC_OMAP)   += omap.o
>  obj-$(CONFIG_MMC_AT91)   += at91_mci.o
>  obj-$(CONFIG_MMC_TIFM_SD)+= tifm_sd.o
> +obj-$(CONFIG_MMC_RICOH_MMC)  += ricoh_mmc.o
> 
> --- linux-2.6.22/drivers/mmc/host/ricoh_mmc.c 1969-12-31 16:00:00.0 
> -0800
> +++ linux-ricoh/drivers/mmc/host/ricoh_mmc.c  2007-09-15 12:29:05.0 
> -0700
> @@ -0,0 +1,156 @@
> +/*
> + *  ricoh_mmc.c - Dummy driver to disable the Rioch MMC controller.
> + *
> + *  Copyright (C) 2007 Philip Langdale, All Rights Reserved.
> + *
> + * 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 is a conceptually ridiculous driver, but it is required by the way
> + * the Ricoh multi-function R5C832 works. This chip implements firewire
> + * and four different memory card controllers. Two of those controllers are
> + * an SDHCI controller and a proprietary MMC controller. The linux SDHCI
> + * driver supports MMC cards but the chip detects MMC cards in hardware
> + * and directs them to the MMC controller - so the SDHCI driver never sees
> + * them. To get around this, we must disable the useless MMC controller.
> + * At that point, the SDHCI controller will start seeing them. As a bonus,
> + * a detection event occurs immediately, even if the MMC card is already
> + * in the reader.
> + *
> + * The relevant registers live on the firewire function, so this is 
> unavoidably
> + * ugly. Such is life.
> + */
> +
> +#include 
> +
> +#define DRIVER_NAME "ricoh-mmc"
> +
> +#define DBG(f, x...) \
> + pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x)
> +
> +static const struct pci_device_id pci_ids[] __devinitdata = {
> + {
> + .vendor = PCI_VENDOR_ID_RICOH,
> + .device = PCI_DEVICE_ID_RICOH_R5C843,
> + .subvendor  = PCI_ANY_ID,
> + .subdevice  = PCI_ANY_ID,
> + },
> + { /* end: all zeroes */ },
> +};
> +
> +MODULE_DEVICE_TABLE(pci, pci_ids);
> +
> +static int __devinit ricoh_mmc_probe(struct pci_dev *pdev,
> +  const struct pci_device_id *ent)
> +{
> + u8 rev;
> +
> + struct pci_dev *fw_dev = NULL;
> +
> + BUG_ON(pdev == NULL);
> + BUG_ON(ent == NULL);
> +
> + pci_read_config_byte(pdev, PCI_CLASS_REVISION, );
> +
> + printk(KERN_INFO DRIVER_NAME
> + ": Ricoh MMC controller found at %s [%04x:%04x] (rev %x)\n",
> + pci_name(pdev), (int)pdev->vendor, (int)pdev->device,
> + (int)rev);
> +
> + while ((fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, 
> PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) {
> + if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) &&
> + pdev->bus == fw_dev->bus) {
> + u8 write_enable;
> + u8 disable;
> +
> + pci_read_config_byte(fw_dev, 0xCB, );
> + if (disable & 0x02) {
> + printk(KERN_INFO DRIVER_NAME
> +": Controller already disabled. Nothing 
> to do.\n");
> +  

[PATCH] mmc: Disabler for Ricoh MMC controller

2007-10-01 Thread Philip Langdale
Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to disable the
MMC controller on the multi-function Ricoh R5C832. The MMC controller needs
to be disabled or it will steal MMC cards from the SD controller where they
would otherwise be supported by the Linux SDHCI driver.

Signed-off-by: Philipl Langdale <[EMAIL PROTECTED]>

--- linux-2.6.22/drivers/mmc/host/Kconfig   2007-07-08 16:32:17.0 
-0700
+++ linux-ricoh/drivers/mmc/host/Kconfig2007-09-15 12:32:10.0 
-0700
@@ -35,6 +35,23 @@

  If unsure, say N.

+config MMC_RICOH_MMC
+   tristate "Ricoh MMC Controller Disabler  (EXPERIMENTAL)"
+   depends on PCI && EXPERIMENTAL && MMC_SDHCI
+   help
+ This selects the disabler for the Ricoh MMC Controller. This
+ proprietary controller is unnecessary because the SDHCI driver
+ supports MMC cards on the SD controller, but if it is not
+ disabled, it will steal the MMC cards away - rendering them
+ useless. It is safe to select this driver even if you don't
+ have a Ricoh based card reader.
+
+
+ To compile this driver as a module, choose M here:
+ the module will be called ricoh_mmc.
+
+ If unsure, say Y.
+
 config MMC_OMAP
tristate "TI OMAP Multimedia Card Interface support"
depends on ARCH_OMAP
--- linux-2.6.22/drivers/mmc/host/Makefile  2007-07-08 16:32:17.0 
-0700
+++ linux-ricoh/drivers/mmc/host/Makefile   2007-09-15 12:28:49.0 
-0700
@@ -15,4 +15,5 @@
 obj-$(CONFIG_MMC_OMAP) += omap.o
 obj-$(CONFIG_MMC_AT91) += at91_mci.o
 obj-$(CONFIG_MMC_TIFM_SD)  += tifm_sd.o
+obj-$(CONFIG_MMC_RICOH_MMC)+= ricoh_mmc.o

--- linux-2.6.22/drivers/mmc/host/ricoh_mmc.c   1969-12-31 16:00:00.0 
-0800
+++ linux-ricoh/drivers/mmc/host/ricoh_mmc.c2007-09-15 12:29:05.0 
-0700
@@ -0,0 +1,156 @@
+/*
+ *  ricoh_mmc.c - Dummy driver to disable the Rioch MMC controller.
+ *
+ *  Copyright (C) 2007 Philip Langdale, All Rights Reserved.
+ *
+ * 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 is a conceptually ridiculous driver, but it is required by the way
+ * the Ricoh multi-function R5C832 works. This chip implements firewire
+ * and four different memory card controllers. Two of those controllers are
+ * an SDHCI controller and a proprietary MMC controller. The linux SDHCI
+ * driver supports MMC cards but the chip detects MMC cards in hardware
+ * and directs them to the MMC controller - so the SDHCI driver never sees
+ * them. To get around this, we must disable the useless MMC controller.
+ * At that point, the SDHCI controller will start seeing them. As a bonus,
+ * a detection event occurs immediately, even if the MMC card is already
+ * in the reader.
+ *
+ * The relevant registers live on the firewire function, so this is unavoidably
+ * ugly. Such is life.
+ */
+
+#include 
+
+#define DRIVER_NAME "ricoh-mmc"
+
+#define DBG(f, x...) \
+   pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x)
+
+static const struct pci_device_id pci_ids[] __devinitdata = {
+   {
+   .vendor = PCI_VENDOR_ID_RICOH,
+   .device = PCI_DEVICE_ID_RICOH_R5C843,
+   .subvendor  = PCI_ANY_ID,
+   .subdevice  = PCI_ANY_ID,
+   },
+   { /* end: all zeroes */ },
+};
+
+MODULE_DEVICE_TABLE(pci, pci_ids);
+
+static int __devinit ricoh_mmc_probe(struct pci_dev *pdev,
+const struct pci_device_id *ent)
+{
+   u8 rev;
+
+   struct pci_dev *fw_dev = NULL;
+
+   BUG_ON(pdev == NULL);
+   BUG_ON(ent == NULL);
+
+   pci_read_config_byte(pdev, PCI_CLASS_REVISION, );
+
+   printk(KERN_INFO DRIVER_NAME
+   ": Ricoh MMC controller found at %s [%04x:%04x] (rev %x)\n",
+   pci_name(pdev), (int)pdev->vendor, (int)pdev->device,
+   (int)rev);
+
+   while ((fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, 
PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) {
+   if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) &&
+   pdev->bus == fw_dev->bus) {
+   u8 write_enable;
+   u8 disable;
+
+   pci_read_config_byte(fw_dev, 0xCB, );
+   if (disable & 0x02) {
+   printk(KERN_INFO DRIVER_NAME
+  ": Controller already disabled. Nothing 
to do.\n");
+   return -ENODEV;
+   }
+
+   pci_read_config_byte(fw_dev, 0xCA, _enable);
+   pci_write_config_byte(fw_dev, 0xCA, 0x57);
+   pci_write_config_byte(fw_dev, 0xCB, 

Re: [PATCH] mmc: Disabler for Ricoh MMC controller

2007-10-01 Thread Philip Langdale
Pierre Ossman wrote:
> 
> Preferably. But if you can't figure it out until it is time to merge
> things upstream, then I'll go with what we have right now.

I have not been contacted by anyone with one of those laptops so I
haven't been able to find out what's going on.

I'm updating the diff, because I forgot to terminate the pci table,
so it didn't add the alias correctly.

--phil
-
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] mmc: Disabler for Ricoh MMC controller

2007-10-01 Thread Philip Langdale
Pierre Ossman wrote:
 
 Preferably. But if you can't figure it out until it is time to merge
 things upstream, then I'll go with what we have right now.

I have not been contacted by anyone with one of those laptops so I
haven't been able to find out what's going on.

I'm updating the diff, because I forgot to terminate the pci table,
so it didn't add the alias correctly.

--phil
-
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] mmc: Disabler for Ricoh MMC controller

2007-10-01 Thread Philip Langdale
Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to disable the
MMC controller on the multi-function Ricoh R5C832. The MMC controller needs
to be disabled or it will steal MMC cards from the SD controller where they
would otherwise be supported by the Linux SDHCI driver.

Signed-off-by: Philipl Langdale [EMAIL PROTECTED]

--- linux-2.6.22/drivers/mmc/host/Kconfig   2007-07-08 16:32:17.0 
-0700
+++ linux-ricoh/drivers/mmc/host/Kconfig2007-09-15 12:32:10.0 
-0700
@@ -35,6 +35,23 @@

  If unsure, say N.

+config MMC_RICOH_MMC
+   tristate Ricoh MMC Controller Disabler  (EXPERIMENTAL)
+   depends on PCI  EXPERIMENTAL  MMC_SDHCI
+   help
+ This selects the disabler for the Ricoh MMC Controller. This
+ proprietary controller is unnecessary because the SDHCI driver
+ supports MMC cards on the SD controller, but if it is not
+ disabled, it will steal the MMC cards away - rendering them
+ useless. It is safe to select this driver even if you don't
+ have a Ricoh based card reader.
+
+
+ To compile this driver as a module, choose M here:
+ the module will be called ricoh_mmc.
+
+ If unsure, say Y.
+
 config MMC_OMAP
tristate TI OMAP Multimedia Card Interface support
depends on ARCH_OMAP
--- linux-2.6.22/drivers/mmc/host/Makefile  2007-07-08 16:32:17.0 
-0700
+++ linux-ricoh/drivers/mmc/host/Makefile   2007-09-15 12:28:49.0 
-0700
@@ -15,4 +15,5 @@
 obj-$(CONFIG_MMC_OMAP) += omap.o
 obj-$(CONFIG_MMC_AT91) += at91_mci.o
 obj-$(CONFIG_MMC_TIFM_SD)  += tifm_sd.o
+obj-$(CONFIG_MMC_RICOH_MMC)+= ricoh_mmc.o

--- linux-2.6.22/drivers/mmc/host/ricoh_mmc.c   1969-12-31 16:00:00.0 
-0800
+++ linux-ricoh/drivers/mmc/host/ricoh_mmc.c2007-09-15 12:29:05.0 
-0700
@@ -0,0 +1,156 @@
+/*
+ *  ricoh_mmc.c - Dummy driver to disable the Rioch MMC controller.
+ *
+ *  Copyright (C) 2007 Philip Langdale, All Rights Reserved.
+ *
+ * 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 is a conceptually ridiculous driver, but it is required by the way
+ * the Ricoh multi-function R5C832 works. This chip implements firewire
+ * and four different memory card controllers. Two of those controllers are
+ * an SDHCI controller and a proprietary MMC controller. The linux SDHCI
+ * driver supports MMC cards but the chip detects MMC cards in hardware
+ * and directs them to the MMC controller - so the SDHCI driver never sees
+ * them. To get around this, we must disable the useless MMC controller.
+ * At that point, the SDHCI controller will start seeing them. As a bonus,
+ * a detection event occurs immediately, even if the MMC card is already
+ * in the reader.
+ *
+ * The relevant registers live on the firewire function, so this is unavoidably
+ * ugly. Such is life.
+ */
+
+#include linux/pci.h
+
+#define DRIVER_NAME ricoh-mmc
+
+#define DBG(f, x...) \
+   pr_debug(DRIVER_NAME  [%s()]:  f, __func__,## x)
+
+static const struct pci_device_id pci_ids[] __devinitdata = {
+   {
+   .vendor = PCI_VENDOR_ID_RICOH,
+   .device = PCI_DEVICE_ID_RICOH_R5C843,
+   .subvendor  = PCI_ANY_ID,
+   .subdevice  = PCI_ANY_ID,
+   },
+   { /* end: all zeroes */ },
+};
+
+MODULE_DEVICE_TABLE(pci, pci_ids);
+
+static int __devinit ricoh_mmc_probe(struct pci_dev *pdev,
+const struct pci_device_id *ent)
+{
+   u8 rev;
+
+   struct pci_dev *fw_dev = NULL;
+
+   BUG_ON(pdev == NULL);
+   BUG_ON(ent == NULL);
+
+   pci_read_config_byte(pdev, PCI_CLASS_REVISION, rev);
+
+   printk(KERN_INFO DRIVER_NAME
+   : Ricoh MMC controller found at %s [%04x:%04x] (rev %x)\n,
+   pci_name(pdev), (int)pdev-vendor, (int)pdev-device,
+   (int)rev);
+
+   while ((fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, 
PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) {
+   if (PCI_SLOT(pdev-devfn) == PCI_SLOT(fw_dev-devfn) 
+   pdev-bus == fw_dev-bus) {
+   u8 write_enable;
+   u8 disable;
+
+   pci_read_config_byte(fw_dev, 0xCB, disable);
+   if (disable  0x02) {
+   printk(KERN_INFO DRIVER_NAME
+  : Controller already disabled. Nothing 
to do.\n);
+   return -ENODEV;
+   }
+
+   pci_read_config_byte(fw_dev, 0xCA, write_enable);
+   pci_write_config_byte(fw_dev, 0xCA, 0x57);
+   pci_write_config_byte(fw_dev, 0xCB, 

Re: [PATCH] mmc: Disabler for Ricoh MMC controller

2007-10-01 Thread Benjamin Herrenschmidt

On Mon, 2007-10-01 at 20:23 -0700, Philip Langdale wrote:
 Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to disable the
 MMC controller on the multi-function Ricoh R5C832. The MMC controller needs
 to be disabled or it will steal MMC cards from the SD controller where they
 would otherwise be supported by the Linux SDHCI driver.

Why can't that be a quirk instead ?

 Signed-off-by: Philipl Langdale [EMAIL PROTECTED]
 
 --- linux-2.6.22/drivers/mmc/host/Kconfig 2007-07-08 16:32:17.0 
 -0700
 +++ linux-ricoh/drivers/mmc/host/Kconfig  2007-09-15 12:32:10.0 
 -0700
 @@ -35,6 +35,23 @@
 
 If unsure, say N.
 
 +config MMC_RICOH_MMC
 + tristate Ricoh MMC Controller Disabler  (EXPERIMENTAL)
 + depends on PCI  EXPERIMENTAL  MMC_SDHCI
 + help
 +   This selects the disabler for the Ricoh MMC Controller. This
 +   proprietary controller is unnecessary because the SDHCI driver
 +   supports MMC cards on the SD controller, but if it is not
 +   disabled, it will steal the MMC cards away - rendering them
 +   useless. It is safe to select this driver even if you don't
 +   have a Ricoh based card reader.
 +
 +
 +   To compile this driver as a module, choose M here:
 +   the module will be called ricoh_mmc.
 +
 +   If unsure, say Y.
 +
  config MMC_OMAP
   tristate TI OMAP Multimedia Card Interface support
   depends on ARCH_OMAP
 --- linux-2.6.22/drivers/mmc/host/Makefile2007-07-08 16:32:17.0 
 -0700
 +++ linux-ricoh/drivers/mmc/host/Makefile 2007-09-15 12:28:49.0 
 -0700
 @@ -15,4 +15,5 @@
  obj-$(CONFIG_MMC_OMAP)   += omap.o
  obj-$(CONFIG_MMC_AT91)   += at91_mci.o
  obj-$(CONFIG_MMC_TIFM_SD)+= tifm_sd.o
 +obj-$(CONFIG_MMC_RICOH_MMC)  += ricoh_mmc.o
 
 --- linux-2.6.22/drivers/mmc/host/ricoh_mmc.c 1969-12-31 16:00:00.0 
 -0800
 +++ linux-ricoh/drivers/mmc/host/ricoh_mmc.c  2007-09-15 12:29:05.0 
 -0700
 @@ -0,0 +1,156 @@
 +/*
 + *  ricoh_mmc.c - Dummy driver to disable the Rioch MMC controller.
 + *
 + *  Copyright (C) 2007 Philip Langdale, All Rights Reserved.
 + *
 + * 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 is a conceptually ridiculous driver, but it is required by the way
 + * the Ricoh multi-function R5C832 works. This chip implements firewire
 + * and four different memory card controllers. Two of those controllers are
 + * an SDHCI controller and a proprietary MMC controller. The linux SDHCI
 + * driver supports MMC cards but the chip detects MMC cards in hardware
 + * and directs them to the MMC controller - so the SDHCI driver never sees
 + * them. To get around this, we must disable the useless MMC controller.
 + * At that point, the SDHCI controller will start seeing them. As a bonus,
 + * a detection event occurs immediately, even if the MMC card is already
 + * in the reader.
 + *
 + * The relevant registers live on the firewire function, so this is 
 unavoidably
 + * ugly. Such is life.
 + */
 +
 +#include linux/pci.h
 +
 +#define DRIVER_NAME ricoh-mmc
 +
 +#define DBG(f, x...) \
 + pr_debug(DRIVER_NAME  [%s()]:  f, __func__,## x)
 +
 +static const struct pci_device_id pci_ids[] __devinitdata = {
 + {
 + .vendor = PCI_VENDOR_ID_RICOH,
 + .device = PCI_DEVICE_ID_RICOH_R5C843,
 + .subvendor  = PCI_ANY_ID,
 + .subdevice  = PCI_ANY_ID,
 + },
 + { /* end: all zeroes */ },
 +};
 +
 +MODULE_DEVICE_TABLE(pci, pci_ids);
 +
 +static int __devinit ricoh_mmc_probe(struct pci_dev *pdev,
 +  const struct pci_device_id *ent)
 +{
 + u8 rev;
 +
 + struct pci_dev *fw_dev = NULL;
 +
 + BUG_ON(pdev == NULL);
 + BUG_ON(ent == NULL);
 +
 + pci_read_config_byte(pdev, PCI_CLASS_REVISION, rev);
 +
 + printk(KERN_INFO DRIVER_NAME
 + : Ricoh MMC controller found at %s [%04x:%04x] (rev %x)\n,
 + pci_name(pdev), (int)pdev-vendor, (int)pdev-device,
 + (int)rev);
 +
 + while ((fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, 
 PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) {
 + if (PCI_SLOT(pdev-devfn) == PCI_SLOT(fw_dev-devfn) 
 + pdev-bus == fw_dev-bus) {
 + u8 write_enable;
 + u8 disable;
 +
 + pci_read_config_byte(fw_dev, 0xCB, disable);
 + if (disable  0x02) {
 + printk(KERN_INFO DRIVER_NAME
 +: Controller already disabled. Nothing 
 to do.\n);
 + return -ENODEV;
 + }
 +
 + pci_read_config_byte(fw_dev, 0xCA, write_enable);

Re: [PATCH] mmc: Disabler for Ricoh MMC controller

2007-10-01 Thread Benjamin Herrenschmidt

On Tue, 2007-10-02 at 14:44 +1000, Benjamin Herrenschmidt wrote:
 On Mon, 2007-10-01 at 20:23 -0700, Philip Langdale wrote:
  Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to disable the
  MMC controller on the multi-function Ricoh R5C832. The MMC controller needs
  to be disabled or it will steal MMC cards from the SD controller where they
  would otherwise be supported by the Linux SDHCI driver.
 
 Why can't that be a quirk instead ?

That is, a global quirk or a quirk in the SDHCI driver...

  Signed-off-by: Philipl Langdale [EMAIL PROTECTED]
  
  --- linux-2.6.22/drivers/mmc/host/Kconfig   2007-07-08 16:32:17.0 
  -0700
  +++ linux-ricoh/drivers/mmc/host/Kconfig2007-09-15 12:32:10.0 
  -0700
  @@ -35,6 +35,23 @@
  
If unsure, say N.
  
  +config MMC_RICOH_MMC
  +   tristate Ricoh MMC Controller Disabler  (EXPERIMENTAL)
  +   depends on PCI  EXPERIMENTAL  MMC_SDHCI
  +   help
  + This selects the disabler for the Ricoh MMC Controller. This
  + proprietary controller is unnecessary because the SDHCI driver
  + supports MMC cards on the SD controller, but if it is not
  + disabled, it will steal the MMC cards away - rendering them
  + useless. It is safe to select this driver even if you don't
  + have a Ricoh based card reader.
  +
  +
  + To compile this driver as a module, choose M here:
  + the module will be called ricoh_mmc.
  +
  + If unsure, say Y.
  +
   config MMC_OMAP
  tristate TI OMAP Multimedia Card Interface support
  depends on ARCH_OMAP
  --- linux-2.6.22/drivers/mmc/host/Makefile  2007-07-08 16:32:17.0 
  -0700
  +++ linux-ricoh/drivers/mmc/host/Makefile   2007-09-15 12:28:49.0 
  -0700
  @@ -15,4 +15,5 @@
   obj-$(CONFIG_MMC_OMAP) += omap.o
   obj-$(CONFIG_MMC_AT91) += at91_mci.o
   obj-$(CONFIG_MMC_TIFM_SD)  += tifm_sd.o
  +obj-$(CONFIG_MMC_RICOH_MMC)+= ricoh_mmc.o
  
  --- linux-2.6.22/drivers/mmc/host/ricoh_mmc.c   1969-12-31 
  16:00:00.0 -0800
  +++ linux-ricoh/drivers/mmc/host/ricoh_mmc.c2007-09-15 
  12:29:05.0 -0700
  @@ -0,0 +1,156 @@
  +/*
  + *  ricoh_mmc.c - Dummy driver to disable the Rioch MMC controller.
  + *
  + *  Copyright (C) 2007 Philip Langdale, All Rights Reserved.
  + *
  + * 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 is a conceptually ridiculous driver, but it is required by the way
  + * the Ricoh multi-function R5C832 works. This chip implements firewire
  + * and four different memory card controllers. Two of those controllers are
  + * an SDHCI controller and a proprietary MMC controller. The linux SDHCI
  + * driver supports MMC cards but the chip detects MMC cards in hardware
  + * and directs them to the MMC controller - so the SDHCI driver never sees
  + * them. To get around this, we must disable the useless MMC controller.
  + * At that point, the SDHCI controller will start seeing them. As a bonus,
  + * a detection event occurs immediately, even if the MMC card is already
  + * in the reader.
  + *
  + * The relevant registers live on the firewire function, so this is 
  unavoidably
  + * ugly. Such is life.
  + */
  +
  +#include linux/pci.h
  +
  +#define DRIVER_NAME ricoh-mmc
  +
  +#define DBG(f, x...) \
  +   pr_debug(DRIVER_NAME  [%s()]:  f, __func__,## x)
  +
  +static const struct pci_device_id pci_ids[] __devinitdata = {
  +   {
  +   .vendor = PCI_VENDOR_ID_RICOH,
  +   .device = PCI_DEVICE_ID_RICOH_R5C843,
  +   .subvendor  = PCI_ANY_ID,
  +   .subdevice  = PCI_ANY_ID,
  +   },
  +   { /* end: all zeroes */ },
  +};
  +
  +MODULE_DEVICE_TABLE(pci, pci_ids);
  +
  +static int __devinit ricoh_mmc_probe(struct pci_dev *pdev,
  +const struct pci_device_id *ent)
  +{
  +   u8 rev;
  +
  +   struct pci_dev *fw_dev = NULL;
  +
  +   BUG_ON(pdev == NULL);
  +   BUG_ON(ent == NULL);
  +
  +   pci_read_config_byte(pdev, PCI_CLASS_REVISION, rev);
  +
  +   printk(KERN_INFO DRIVER_NAME
  +   : Ricoh MMC controller found at %s [%04x:%04x] (rev %x)\n,
  +   pci_name(pdev), (int)pdev-vendor, (int)pdev-device,
  +   (int)rev);
  +
  +   while ((fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, 
  PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) {
  +   if (PCI_SLOT(pdev-devfn) == PCI_SLOT(fw_dev-devfn) 
  +   pdev-bus == fw_dev-bus) {
  +   u8 write_enable;
  +   u8 disable;
  +
  +   pci_read_config_byte(fw_dev, 0xCB, disable);
  +   if (disable  0x02) {
  +   printk(KERN_INFO DRIVER_NAME
  +  : Controller already 

Re: [PATCH] mmc: Disabler for Ricoh MMC controller

2007-10-01 Thread Philip Langdale
Benjamin Herrenschmidt wrote:
 On Tue, 2007-10-02 at 14:44 +1000, Benjamin Herrenschmidt wrote:
 On Mon, 2007-10-01 at 20:23 -0700, Philip Langdale wrote:
 Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to disable the
 MMC controller on the multi-function Ricoh R5C832. The MMC controller needs
 to be disabled or it will steal MMC cards from the SD controller where they
 would otherwise be supported by the Linux SDHCI driver.
 Why can't that be a quirk instead ?
 
 That is, a global quirk or a quirk in the SDHCI driver...

Pierre doesn't want a quirk.

--phil
-
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] mmc: Disabler for Ricoh MMC controller

2007-09-21 Thread Pierre Ossman
On Fri, 21 Sep 2007 07:30:59 -0700
Philip Langdale <[EMAIL PROTECTED]> wrote:

> 
> This remains confusing. I went and investigated and the SD disable
> bit is 0x20. The one lspci dump from the IFL90 shows that 0x80 is
> set by default, but setting this on my laptop did not disable the
> SD controller. I will need to collect more information from owners
> to find out what's really going on.
> 
> Do you want to wait on this before taking this patch?
> 

Preferably. But if you can't figure it out until it is time to merge
things upstream, then I'll go with what we have right now.

Rgds
Pierre


signature.asc
Description: PGP signature


Re: [PATCH] mmc: Disabler for Ricoh MMC controller

2007-09-21 Thread Philip Langdale
Pierre Ossman wrote:
>>
> 
> Patch looks ok. Please try to sort out that completely disabled
> controller that was reported first though.

This remains confusing. I went and investigated and the SD disable
bit is 0x20. The one lspci dump from the IFL90 shows that 0x80 is
set by default, but setting this on my laptop did not disable the
SD controller. I will need to collect more information from owners
to find out what's really going on.

Do you want to wait on this before taking this patch?

--phil
-
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] mmc: Disabler for Ricoh MMC controller

2007-09-21 Thread Philip Langdale
Pierre Ossman wrote:

 
 Patch looks ok. Please try to sort out that completely disabled
 controller that was reported first though.

This remains confusing. I went and investigated and the SD disable
bit is 0x20. The one lspci dump from the IFL90 shows that 0x80 is
set by default, but setting this on my laptop did not disable the
SD controller. I will need to collect more information from owners
to find out what's really going on.

Do you want to wait on this before taking this patch?

--phil
-
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] mmc: Disabler for Ricoh MMC controller

2007-09-21 Thread Pierre Ossman
On Fri, 21 Sep 2007 07:30:59 -0700
Philip Langdale [EMAIL PROTECTED] wrote:

 
 This remains confusing. I went and investigated and the SD disable
 bit is 0x20. The one lspci dump from the IFL90 shows that 0x80 is
 set by default, but setting this on my laptop did not disable the
 SD controller. I will need to collect more information from owners
 to find out what's really going on.
 
 Do you want to wait on this before taking this patch?
 

Preferably. But if you can't figure it out until it is time to merge
things upstream, then I'll go with what we have right now.

Rgds
Pierre


signature.asc
Description: PGP signature


Re: [PATCH] mmc: Disabler for Ricoh MMC controller

2007-09-20 Thread Pierre Ossman
On Sat, 15 Sep 2007 12:54:08 -0700
Philip Langdale <[EMAIL PROTECTED]> wrote:

> Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to
> disable the MMC controller on the multi-function Ricoh R5C832. The
> MMC controller needs to be disabled or it will steal MMC cards from
> the SD controller where they would otherwise be supported by the
> Linux SDHCI driver.
> 
> Signed-off-by: Philipl Langdale <[EMAIL PROTECTED]>
> 

Patch looks ok. Please try to sort out that completely disabled
controller that was reported first though.

Rgds
Pierre


signature.asc
Description: PGP signature


Re: [PATCH] mmc: Disabler for Ricoh MMC controller

2007-09-20 Thread Pierre Ossman
On Sat, 15 Sep 2007 12:54:08 -0700
Philip Langdale [EMAIL PROTECTED] wrote:

 Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to
 disable the MMC controller on the multi-function Ricoh R5C832. The
 MMC controller needs to be disabled or it will steal MMC cards from
 the SD controller where they would otherwise be supported by the
 Linux SDHCI driver.
 
 Signed-off-by: Philipl Langdale [EMAIL PROTECTED]
 

Patch looks ok. Please try to sort out that completely disabled
controller that was reported first though.

Rgds
Pierre


signature.asc
Description: PGP signature


[PATCH] mmc: Disabler for Ricoh MMC controller

2007-09-15 Thread Philip Langdale
Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to disable the
MMC controller on the multi-function Ricoh R5C832. The MMC controller needs
to be disabled or it will steal MMC cards from the SD controller where they
would otherwise be supported by the Linux SDHCI driver.

Signed-off-by: Philipl Langdale <[EMAIL PROTECTED]>

--- linux-2.6.22/drivers/mmc/host/Kconfig   2007-07-08 16:32:17.0 
-0700
+++ linux-ricoh/drivers/mmc/host/Kconfig2007-09-15 12:32:10.0 
-0700
@@ -35,6 +35,23 @@

  If unsure, say N.

+config MMC_RICOH_MMC
+   tristate "Ricoh MMC Controller Disabler  (EXPERIMENTAL)"
+   depends on PCI && EXPERIMENTAL && MMC_SDHCI
+   help
+ This selects the disabler for the Ricoh MMC Controller. This
+ proprietary controller is unnecessary because the SDHCI driver
+ supports MMC cards on the SD controller, but if it is not
+ disabled, it will steal the MMC cards away - rendering them
+ useless. It is safe to select this driver even if you don't
+ have a Ricoh based card reader.
+
+
+ To compile this driver as a module, choose M here:
+ the module will be called ricoh_mmc.
+
+ If unsure, say Y.
+
 config MMC_OMAP
tristate "TI OMAP Multimedia Card Interface support"
depends on ARCH_OMAP
--- linux-2.6.22/drivers/mmc/host/Makefile  2007-07-08 16:32:17.0 
-0700
+++ linux-ricoh/drivers/mmc/host/Makefile   2007-09-15 12:28:49.0 
-0700
@@ -15,4 +15,5 @@
 obj-$(CONFIG_MMC_OMAP) += omap.o
 obj-$(CONFIG_MMC_AT91) += at91_mci.o
 obj-$(CONFIG_MMC_TIFM_SD)  += tifm_sd.o
+obj-$(CONFIG_MMC_RICOH_MMC)+= ricoh_mmc.o

--- linux-2.6.22/drivers/mmc/host/ricoh_mmc.c   1969-12-31 16:00:00.0 
-0800
+++ linux-ricoh/drivers/mmc/host/ricoh_mmc.c2007-09-15 12:29:05.0 
-0700
@@ -0,0 +1,152 @@
+/*
+ *  ricoh_mmc.c - Dummy driver to disable the Rioch MMC controller.
+ *
+ *  Copyright (C) 2007 Philip Langdale, All Rights Reserved.
+ *
+ * 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 is a conceptually ridiculous driver, but it is required by the way
+ * the Ricoh multi-function R5C832 works. This chip implements firewire
+ * and four different memory card controllers. Two of those controllers are
+ * an SDHCI controller and a proprietary MMC controller. The linux SDHCI
+ * driver supports MMC cards but the chip detects MMC cards in hardware
+ * and directs them to the MMC controller - so the SDHCI driver never sees
+ * them. To get around this, we must disable the useless MMC controller.
+ * At that point, the SDHCI controller will start seeing them. As a bonus,
+ * a detection event occurs immediately, even if the MMC card is already
+ * in the reader.
+ *
+ * The relevant registers live on the firewire function, so this is unavoidably
+ * ugly. Such is life.
+ */
+
+#include 
+
+#define DRIVER_NAME "ricoh-mmc"
+
+static const struct pci_device_id pci_ids[] __devinitdata = {
+   {
+   .vendor = PCI_VENDOR_ID_RICOH,
+   .device = PCI_DEVICE_ID_RICOH_R5C843,
+   .subvendor  = PCI_ANY_ID,
+   .subdevice  = PCI_ANY_ID,
+   },
+};
+
+MODULE_DEVICE_TABLE(pci, pci_ids);
+
+static int __devinit ricoh_mmc_probe(struct pci_dev *pdev,
+const struct pci_device_id *ent)
+{
+   u8 rev;
+
+   struct pci_dev *fw_dev = NULL;
+
+   BUG_ON(pdev == NULL);
+   BUG_ON(ent == NULL);
+
+   pci_read_config_byte(pdev, PCI_CLASS_REVISION, );
+
+   printk(KERN_INFO DRIVER_NAME
+   ": Ricoh MMC controller found at %s [%04x:%04x] (rev %x)\n",
+   pci_name(pdev), (int)pdev->vendor, (int)pdev->device,
+   (int)rev);
+
+   while ((fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, 
PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) {
+   if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) &&
+   pdev->bus == fw_dev->bus) {
+   u8 write_enable;
+   u8 disable;
+
+   pci_read_config_byte(fw_dev, 0xCB, );
+   if (disable & 0x02) {
+   printk(KERN_INFO DRIVER_NAME
+  ": Controller already disabled. Nothing 
to do.\n");
+   return -ENODEV;
+   }
+
+   pci_read_config_byte(fw_dev, 0xCA, _enable);
+   pci_write_config_byte(fw_dev, 0xCA, 0x57);
+   pci_write_config_byte(fw_dev, 0xCB, disable | 0x02);
+   pci_write_config_byte(fw_dev, 0xCA, write_enable);
+
+   

[PATCH] mmc: Disabler for Ricoh MMC controller

2007-09-15 Thread Philip Langdale
Thanks to Matt Domsch and Rezwanul Kabir at Dell, we know how to disable the
MMC controller on the multi-function Ricoh R5C832. The MMC controller needs
to be disabled or it will steal MMC cards from the SD controller where they
would otherwise be supported by the Linux SDHCI driver.

Signed-off-by: Philipl Langdale [EMAIL PROTECTED]

--- linux-2.6.22/drivers/mmc/host/Kconfig   2007-07-08 16:32:17.0 
-0700
+++ linux-ricoh/drivers/mmc/host/Kconfig2007-09-15 12:32:10.0 
-0700
@@ -35,6 +35,23 @@

  If unsure, say N.

+config MMC_RICOH_MMC
+   tristate Ricoh MMC Controller Disabler  (EXPERIMENTAL)
+   depends on PCI  EXPERIMENTAL  MMC_SDHCI
+   help
+ This selects the disabler for the Ricoh MMC Controller. This
+ proprietary controller is unnecessary because the SDHCI driver
+ supports MMC cards on the SD controller, but if it is not
+ disabled, it will steal the MMC cards away - rendering them
+ useless. It is safe to select this driver even if you don't
+ have a Ricoh based card reader.
+
+
+ To compile this driver as a module, choose M here:
+ the module will be called ricoh_mmc.
+
+ If unsure, say Y.
+
 config MMC_OMAP
tristate TI OMAP Multimedia Card Interface support
depends on ARCH_OMAP
--- linux-2.6.22/drivers/mmc/host/Makefile  2007-07-08 16:32:17.0 
-0700
+++ linux-ricoh/drivers/mmc/host/Makefile   2007-09-15 12:28:49.0 
-0700
@@ -15,4 +15,5 @@
 obj-$(CONFIG_MMC_OMAP) += omap.o
 obj-$(CONFIG_MMC_AT91) += at91_mci.o
 obj-$(CONFIG_MMC_TIFM_SD)  += tifm_sd.o
+obj-$(CONFIG_MMC_RICOH_MMC)+= ricoh_mmc.o

--- linux-2.6.22/drivers/mmc/host/ricoh_mmc.c   1969-12-31 16:00:00.0 
-0800
+++ linux-ricoh/drivers/mmc/host/ricoh_mmc.c2007-09-15 12:29:05.0 
-0700
@@ -0,0 +1,152 @@
+/*
+ *  ricoh_mmc.c - Dummy driver to disable the Rioch MMC controller.
+ *
+ *  Copyright (C) 2007 Philip Langdale, All Rights Reserved.
+ *
+ * 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 is a conceptually ridiculous driver, but it is required by the way
+ * the Ricoh multi-function R5C832 works. This chip implements firewire
+ * and four different memory card controllers. Two of those controllers are
+ * an SDHCI controller and a proprietary MMC controller. The linux SDHCI
+ * driver supports MMC cards but the chip detects MMC cards in hardware
+ * and directs them to the MMC controller - so the SDHCI driver never sees
+ * them. To get around this, we must disable the useless MMC controller.
+ * At that point, the SDHCI controller will start seeing them. As a bonus,
+ * a detection event occurs immediately, even if the MMC card is already
+ * in the reader.
+ *
+ * The relevant registers live on the firewire function, so this is unavoidably
+ * ugly. Such is life.
+ */
+
+#include linux/pci.h
+
+#define DRIVER_NAME ricoh-mmc
+
+static const struct pci_device_id pci_ids[] __devinitdata = {
+   {
+   .vendor = PCI_VENDOR_ID_RICOH,
+   .device = PCI_DEVICE_ID_RICOH_R5C843,
+   .subvendor  = PCI_ANY_ID,
+   .subdevice  = PCI_ANY_ID,
+   },
+};
+
+MODULE_DEVICE_TABLE(pci, pci_ids);
+
+static int __devinit ricoh_mmc_probe(struct pci_dev *pdev,
+const struct pci_device_id *ent)
+{
+   u8 rev;
+
+   struct pci_dev *fw_dev = NULL;
+
+   BUG_ON(pdev == NULL);
+   BUG_ON(ent == NULL);
+
+   pci_read_config_byte(pdev, PCI_CLASS_REVISION, rev);
+
+   printk(KERN_INFO DRIVER_NAME
+   : Ricoh MMC controller found at %s [%04x:%04x] (rev %x)\n,
+   pci_name(pdev), (int)pdev-vendor, (int)pdev-device,
+   (int)rev);
+
+   while ((fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, 
PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) {
+   if (PCI_SLOT(pdev-devfn) == PCI_SLOT(fw_dev-devfn) 
+   pdev-bus == fw_dev-bus) {
+   u8 write_enable;
+   u8 disable;
+
+   pci_read_config_byte(fw_dev, 0xCB, disable);
+   if (disable  0x02) {
+   printk(KERN_INFO DRIVER_NAME
+  : Controller already disabled. Nothing 
to do.\n);
+   return -ENODEV;
+   }
+
+   pci_read_config_byte(fw_dev, 0xCA, write_enable);
+   pci_write_config_byte(fw_dev, 0xCA, 0x57);
+   pci_write_config_byte(fw_dev, 0xCB, disable | 0x02);
+   pci_write_config_byte(fw_dev, 0xCA, write_enable);
+
+