linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: George Hilliard <thirtythreeforty@gmail.com>
To: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org, Neil Brown <neil@brown.name>,
	George Hilliard <thirtythreeforty@gmail.com>
Subject: [PATCH 05/10] staging: mt7621-mmc: Use pinctrl subsystem to select SDXC pin mode
Date: Tue, 19 Feb 2019 22:17:49 -0700	[thread overview]
Message-ID: <20190220051754.12195-6-thirtythreeforty@gmail.com> (raw)
In-Reply-To: <20190220051754.12195-1-thirtythreeforty@gmail.com>

The driver previously grabbed the SD pins for itself, ignoring the pin
controller.  Replace this direct register access with appropriate calls
to the pinctrl subsystem.

This also allows this driver to work on related devices that have a
different pin controller mapping, such as the MT7688.  The hardcoded
bit index was incorrect on that device.

This change could break SD controller functionality on existing devices
whose device trees do not specify a pin controller and state for the SD
node.

Signed-off-by: George Hilliard <thirtythreeforty@gmail.com>
---
 drivers/staging/mt7621-mmc/sd.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index a7c7ec0d7bbb..97ed7510e96d 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -38,6 +38,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/interrupt.h>
 
 #include <linux/mmc/host.h>
@@ -1599,6 +1600,8 @@ static int msdc_drv_probe(struct platform_device *pdev)
 	struct msdc_host *host;
 	struct msdc_hw *hw;
 	int ret;
+	struct pinctrl *pctrl;
+	struct pinctrl_state *pins_default;
 
 	hw = &msdc0_hw;
 
@@ -1671,6 +1674,25 @@ static int msdc_drv_probe(struct platform_device *pdev)
 
 	host->mrq = NULL;
 
+	/* Read pin control settings from device tree */
+	pctrl = devm_pinctrl_get(&pdev->dev);
+	if (IS_ERR(pctrl)) {
+		ret = PTR_ERR(pctrl);
+		dev_err(&pdev->dev, "Cannot find pinctrl in device tree\n");
+		goto host_free;
+	}
+
+	pins_default = pinctrl_lookup_state(pctrl, PINCTRL_STATE_DEFAULT);
+	if (IS_ERR(pins_default)) {
+		ret = PTR_ERR(pins_default);
+		dev_err(&pdev->dev, "Cannot find pinctrl state default\n");
+		goto host_free;
+	}
+
+	ret = pinctrl_select_state(pctrl, pins_default);
+	if (ret < 0)
+		dev_warn(&pdev->dev, "Cannot select pinctrl state\n");
+
 	dma_coerce_mask_and_coherent(mmc_dev(mmc), DMA_BIT_MASK(32));
 
 	/* using dma_alloc_coherent*/  /* todo: using 1, for all 4 slots */
@@ -1822,12 +1844,6 @@ static struct platform_driver mt_msdc_driver = {
 static int __init mt_msdc_init(void)
 {
 	int ret;
-	u32 reg;
-
-	// Set the pins for sdxc to sdxc mode
-	//FIXME: this should be done by pinctl and not by the sd driver
-	reg = readl((void __iomem *)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3 << 18);
-	writel(reg, (void __iomem *)(RALINK_SYSCTL_BASE + 0x60));
 
 	ret = platform_driver_register(&mt_msdc_driver);
 	if (ret) {
-- 
2.20.1


  parent reply	other threads:[~2019-02-20  5:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-20  5:17 mt7621-mmc driver improvements George Hilliard
2019-02-20  5:17 ` [PATCH 01/10] staging: mt7621-mmc: fix unused variable compiler warning George Hilliard
2019-02-20  5:17 ` [PATCH 02/10] staging: mt7621-mmc: Remove obsolete comments George Hilliard
2019-02-20  5:17 ` [PATCH 03/10] staging: mt7621-mmc: Remove references to nonexistent mt7621_spi_ops George Hilliard
2019-02-20  5:17 ` [PATCH 04/10] staging: mt7621-mmc: Fix warning when reloading module with debug msgs enabled George Hilliard
2019-02-20  5:17 ` George Hilliard [this message]
2019-02-20 11:27   ` [PATCH 05/10] staging: mt7621-mmc: Use pinctrl subsystem to select SDXC pin mode Jonas Gorski
2019-02-20  5:17 ` [PATCH 06/10] staging: mt7621-mmc: Bill the caller for I/O time George Hilliard
2019-02-20  5:17 ` [PATCH 07/10] staging: mt7621-mmc: Initialize completions a single time during probe George Hilliard
2019-02-20  5:17 ` [PATCH 08/10] staging: mt7621-mmc: Check for nonzero number of scatterlist entries George Hilliard
2019-02-20  5:17 ` [PATCH 09/10] staging: mt7621-mmc: Remove redundant host->mmc->f_max write George Hilliard
2019-02-20  5:17 ` [PATCH 10/10] staging: mt7621-mmc: Immediately notify mmc layer of card change detection George Hilliard

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=20190220051754.12195-6-thirtythreeforty@gmail.com \
    --to=thirtythreeforty@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=neil@brown.name \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).