LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Philip Langdale <philipl@overt.org>
To: Frank Seidel <fseidel@suse.de>
Cc: sdhci-devel@list.drzeus.cx, linux-kernel@vger.kernel.org,
	Pierre Ossman <drzeus@drzeus.cx>,
	Andrew de Quincey <adq_dvb@lidskialf.net>
Subject: Re: [PATCH v2] mmc: extend ricoh_mmc to support Ricoh RL5c476
Date: Mon, 4 Feb 2008 15:18:03 -0500	[thread overview]
Message-ID: <9ce88d6b23a91fe7cd32e8d56c9212fa@localhost> (raw)
In-Reply-To: <200802041925.43081.fseidel@suse.de>


On Mon, 4 Feb 2008 19:25:42 +0100, Frank Seidel <fseidel@suse.de> wrote:
> From: Frank Seidel <fseidel@suse.de>
> 
> This patch (base on current linus git tree plus Philip Langdales
> suspend/resume patch) adds support for the Ricoh RL5c476 chip:
> with this the mmc adapter that needs this disabler (R5C843) can
> also be handled correctly when it sits on a RL5c476.
> (+ minor style changes (removed spaces between function names
> and open parenthesis .. checkpatch warned from previos patch))
> 
> Signed-off-by: Frank Seidel <fseidel@suse.de>
> ---
>  drivers/mmc/host/ricoh_mmc.c |  101
> ++++++++++++++++++++++++++++++++++---------
>  1 file changed, 80 insertions(+), 21 deletions(-)
> 
> --- a/drivers/mmc/host/ricoh_mmc.c
> +++ b/drivers/mmc/host/ricoh_mmc.c
> @@ -44,19 +44,43 @@ MODULE_DEVICE_TABLE(pci, pci_ids);
>  static int ricoh_mmc_disable(struct pci_dev *fw_dev)
>  {
>  	u8 write_enable;
> +	u8 write_target;
>  	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;
> -	}
> +	if (fw_dev->device == PCI_DEVICE_ID_RICOH_RL5C476) {
> +		/* via RL5C476 */
> +
> +		pci_read_config_byte(fw_dev, 0xB7, &disable);
> +		if (disable & 0x02) {
> +			printk(KERN_INFO DRIVER_NAME
> +				": Controller already disabled. " \
> +				"Nothing to do.\n");
> +			return -ENODEV;
> +		}
> +
> +		pci_read_config_byte(fw_dev, 0x8E, &write_enable);
> +		pci_write_config_byte(fw_dev, 0x8E, 0xAA);
> +		pci_read_config_byte(fw_dev, 0x8D, &write_target);
> +		pci_write_config_byte(fw_dev, 0x8D, 0xB7);
> +		pci_write_config_byte(fw_dev, 0xB7, disable | 0x02);
> +		pci_write_config_byte(fw_dev, 0x8E, write_enable);
> +		pci_write_config_byte(fw_dev, 0x8D, write_target);
> +	} else {
> +		/* via R5C832 */
> +
> +		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);
> +		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);
> +	}
> 
>  	printk(KERN_INFO DRIVER_NAME
>  	       ": Controller is now disabled.\n");
> @@ -67,13 +91,29 @@ static int ricoh_mmc_disable(struct pci_
>  static int ricoh_mmc_enable(struct pci_dev *fw_dev)
>  {
>  	u8 write_enable;
> +	u8 write_target;
>  	u8 disable;
> 
> -	pci_read_config_byte(fw_dev, 0xCA, &write_enable);
> -	pci_read_config_byte(fw_dev, 0xCB, &disable);
> -	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);
> +	if (fw_dev->device == PCI_DEVICE_ID_RICOH_RL5C476) {
> +		/* via RL5C476 */
> +
> +		pci_read_config_byte(fw_dev, 0x8E, &write_enable);
> +		pci_write_config_byte(fw_dev, 0x8E, 0xAA);
> +		pci_read_config_byte(fw_dev, 0x8D, &write_target);
> +		pci_write_config_byte(fw_dev, 0x8D, 0xB7);
> +		pci_read_config_byte(fw_dev, 0xB7, &disable);
> +		pci_write_config_byte(fw_dev, 0xB7, disable & ~0x02);
> +		pci_write_config_byte(fw_dev, 0x8E, write_enable);
> +		pci_write_config_byte(fw_dev, 0x8D, write_target);
> +	} else {
> +		/* via R5C832 */
> +
> +		pci_read_config_byte(fw_dev, 0xCA, &write_enable);
> +		pci_read_config_byte(fw_dev, 0xCB, &disable);
> +		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);
> +	}
> 
>  	printk(KERN_INFO DRIVER_NAME
>  	       ": Controller is now re-enabled.\n");
> @@ -85,6 +125,7 @@ static int __devinit ricoh_mmc_probe(str
>  				     const struct pci_device_id *ent)
>  {
>  	u8 rev;
> +	u8 ctrlfound = 0;
> 
>  	struct pci_dev *fw_dev = NULL;
> 
> @@ -98,20 +139,38 @@ static int __devinit ricoh_mmc_probe(str
>  		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))) {
> +	while ((fw_dev =
> +		pci_get_device(PCI_VENDOR_ID_RICOH,
> +			PCI_DEVICE_ID_RICOH_RL5C476, fw_dev))) {
>  		if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) &&
>  		    pdev->bus == fw_dev->bus) {
> -			if (ricoh_mmc_disable(fw_dev) != 0) {
> +			if (ricoh_mmc_disable(fw_dev) != 0)
>  				return -ENODEV;
> -			}
> 
>  			pci_set_drvdata(pdev, fw_dev);
> 
> +			++ctrlfound;
>  			break;
>  		}
>  	}
> 
> -	if (pci_get_drvdata(pdev) == NULL) {
> +	fw_dev = NULL;
> +
> +	while (!ctrlfound &&
> +	    (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) {
> +			if (ricoh_mmc_disable(fw_dev) != 0)
> +				return -ENODEV;
> +
> +			pci_set_drvdata(pdev, fw_dev);
> +
> +			++ctrlfound;
> +		}
> +	}
> +
> +	if (!ctrlfound) {
>  		printk(KERN_WARNING DRIVER_NAME
>  		       ": Main firewire function not found. Cannot disable
> controller.\n");
>  		return -ENODEV;
> @@ -132,7 +191,7 @@ static void __devexit ricoh_mmc_remove(s
>  	pci_set_drvdata(pdev, NULL);
>  }
> 
> -static int ricoh_mmc_suspend (struct pci_dev *pdev, pm_message_t state)
> +static int ricoh_mmc_suspend(struct pci_dev *pdev, pm_message_t state)
>  {
>  	struct pci_dev *fw_dev = NULL;
> 
> @@ -146,7 +205,7 @@ static int ricoh_mmc_suspend (struct pci
>  	return 0;
>  }
> 
> -static int ricoh_mmc_resume (struct pci_dev *pdev)
> +static int ricoh_mmc_resume(struct pci_dev *pdev)
>  {
>  	struct pci_dev *fw_dev = NULL;

ACK.

Hopefully Pierre will re-emerge soon to accept this into his tree.

--phil


  reply	other threads:[~2008-02-04 20:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-31 17:38 [PATCH] " Frank Seidel
2008-02-02  7:16 ` Philip Langdale
2008-02-02  9:30   ` Frank Seidel
2008-02-04 18:25   ` Frank Seidel
2008-02-04 18:25   ` [PATCH] mmc: Handle suspend/resume in Ricoh MMC disabler (resent refreshed) Frank Seidel
2008-02-04 20:17     ` Philip Langdale
2008-02-04 18:25   ` [PATCH v2] mmc: extend ricoh_mmc to support Ricoh RL5c476 Frank Seidel
2008-02-04 20:18     ` Philip Langdale [this message]
2008-02-07  8:08     ` Pierre Ossman
2008-02-07  8:20       ` Frank Seidel
2008-02-07 17:19         ` Pierre Ossman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9ce88d6b23a91fe7cd32e8d56c9212fa@localhost \
    --to=philipl@overt.org \
    --cc=adq_dvb@lidskialf.net \
    --cc=drzeus@drzeus.cx \
    --cc=fseidel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sdhci-devel@list.drzeus.cx \
    --subject='Re: [PATCH v2] mmc: extend ricoh_mmc to support Ricoh RL5c476' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).