LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Frank Seidel <fseidel@suse.de>
To: Philip Langdale <philipl@overt.org>
Cc: sdhci-devel@list.drzeus.cx, linux-kernel@vger.kernel.org,
	Pierre Ossman <drzeus@drzeus.cx>,
	Andrew de Quincey <adq_dvb@lidskialf.net>
Subject: [PATCH] mmc: Handle suspend/resume in Ricoh MMC disabler (resent refreshed)
Date: Mon, 4 Feb 2008 19:25:38 +0100	[thread overview]
Message-ID: <200802041925.39529.fseidel@suse.de> (raw)
In-Reply-To: <47A418E0.6040205@overt.org>

From: Philip Langdale <philipl@overt.org>

As pci config space is reinitialised on suspend/resume cycle, the
disabler needs to work its magic at resume time. For symmetry this
change also explicitly enables the controller at suspend time but
it's not strictly necessary.

Signed-off-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Frank Seidel <fseidel@suse.de>
---
 drivers/mmc/host/ricoh_mmc.c |   97 +++++++++++++++++++++++++++++++------------
 1 file changed, 72 insertions(+), 25 deletions(-)

--- a/drivers/mmc/host/ricoh_mmc.c
+++ b/drivers/mmc/host/ricoh_mmc.c
@@ -41,6 +41,46 @@ static const struct pci_device_id pci_id
 
 MODULE_DEVICE_TABLE(pci, pci_ids);
 
+static int ricoh_mmc_disable(struct pci_dev *fw_dev)
+{
+	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);
+
+	printk(KERN_INFO DRIVER_NAME
+	       ": Controller is now disabled.\n");
+
+	return 0;
+}
+
+static int ricoh_mmc_enable(struct pci_dev *fw_dev)
+{
+	u8 write_enable;
+	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);
+
+	printk(KERN_INFO DRIVER_NAME
+	       ": Controller is now re-enabled.\n");
+
+	return 0;
+}
+
 static int __devinit ricoh_mmc_probe(struct pci_dev *pdev,
 				     const struct pci_device_id *ent)
 {
@@ -61,26 +101,12 @@ static int __devinit ricoh_mmc_probe(str
 	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");
+			if (ricoh_mmc_disable(fw_dev) != 0) {
 				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_set_drvdata(pdev, fw_dev);
 
-			printk(KERN_INFO DRIVER_NAME
-			       ": Controller is now disabled.\n");
-
 			break;
 		}
 	}
@@ -96,30 +122,51 @@ static int __devinit ricoh_mmc_probe(str
 
 static void __devexit ricoh_mmc_remove(struct pci_dev *pdev)
 {
-	u8 write_enable;
-	u8 disable;
 	struct pci_dev *fw_dev = NULL;
 
 	fw_dev = pci_get_drvdata(pdev);
 	BUG_ON(fw_dev == NULL);
 
-	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");
+	ricoh_mmc_enable(fw_dev);
 
 	pci_set_drvdata(pdev, NULL);
 }
 
+static int ricoh_mmc_suspend (struct pci_dev *pdev, pm_message_t state)
+{
+	struct pci_dev *fw_dev = NULL;
+
+	fw_dev = pci_get_drvdata(pdev);
+	BUG_ON(fw_dev == NULL);
+
+	printk(KERN_INFO DRIVER_NAME ": Suspending.\n");
+
+	ricoh_mmc_enable(fw_dev);
+
+	return 0;
+}
+
+static int ricoh_mmc_resume (struct pci_dev *pdev)
+{
+	struct pci_dev *fw_dev = NULL;
+
+	fw_dev = pci_get_drvdata(pdev);
+	BUG_ON(fw_dev == NULL);
+
+	printk(KERN_INFO DRIVER_NAME ": Resuming.\n");
+
+	ricoh_mmc_disable(fw_dev);
+
+	return 0;
+}
+
 static struct pci_driver ricoh_mmc_driver = {
 	.name = 	DRIVER_NAME,
 	.id_table =	pci_ids,
 	.probe = 	ricoh_mmc_probe,
 	.remove =	__devexit_p(ricoh_mmc_remove),
+	.suspend =	ricoh_mmc_suspend,
+	.resume =	ricoh_mmc_resume,
 };
 
 /*****************************************************************************\

  parent reply	other threads:[~2008-02-04 18:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-31 17:38 [PATCH] mmc: extend ricoh_mmc to support Ricoh RL5c476 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   ` Frank Seidel [this message]
2008-02-04 20:17     ` [PATCH] mmc: Handle suspend/resume in Ricoh MMC disabler (resent refreshed) 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
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=200802041925.39529.fseidel@suse.de \
    --to=fseidel@suse.de \
    --cc=adq_dvb@lidskialf.net \
    --cc=drzeus@drzeus.cx \
    --cc=linux-kernel@vger.kernel.org \
    --cc=philipl@overt.org \
    --cc=sdhci-devel@list.drzeus.cx \
    --subject='Re: [PATCH] mmc: Handle suspend/resume in Ricoh MMC disabler (resent refreshed)' \
    /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).