Skip to contentSkip to conversation

mmc: sdhci-of-arasan: Add pinctrl support to the driver

PATCH In review Manish Narani 4 participants 5 messages Nov 18, 2020 – Nov 19, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sdhci-of-arasan: Add pinctrl support to the driver

Driver should be able to handle optional pinctrl setting.

---
 drivers/mmc/host/sdhci-of-arasan.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/mmc/host/sdhci-of-arasan.c +24 -0
index 829ccef87426..f788cc9d5914 100644
@@ -23,6 +23,7 @@
 #include <linux/regmap.h>
 #include <linux/of.h>
 #include <linux/firmware/xlnx-zynqmp.h>
+#include <linux/pinctrl/consumer.h>
 
 #include "cqhci.h"
 #include "sdhci-pltfm.h"
@@ -135,6 +136,8 @@ struct sdhci_arasan_clk_data {
  * @clk_ops:		Struct for the Arasan Controller Clock Operations.
  * @soc_ctl_base:	Pointer to regmap for syscon for soc_ctl registers.
  * @soc_ctl_map:	Map to get offsets into soc_ctl registers.
+ * @pinctrl:		Per-device pin control state holder.
+ * @pins_default:	Pinctrl state for a device.
  * @quirks:		Arasan deviations from spec.
  */
 struct sdhci_arasan_data {
@@ -149,6 +152,8 @@ struct sdhci_arasan_data {
 
 	struct regmap	*soc_ctl_base;
 	const struct sdhci_arasan_soc_ctl_map *soc_ctl_map;
+	struct pinctrl	*pinctrl;
+	struct pinctrl_state *pins_default;
 	unsigned int	quirks;
 
 /* Controller does not have CD wired and will not function normally without */
@@ -1619,6 +1624,25 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
 		goto unreg_clk;
 	}
 
+	sdhci_arasan->pinctrl = devm_pinctrl_get(&pdev->dev);
+	if (!IS_ERR(sdhci_arasan->pinctrl)) {
+		sdhci_arasan->pins_default =
+			pinctrl_lookup_state(sdhci_arasan->pinctrl,
+					     PINCTRL_STATE_DEFAULT);
+		if (IS_ERR(sdhci_arasan->pins_default)) {
+			dev_err(&pdev->dev, "Missing default pinctrl config\n");
+			ret = PTR_ERR(sdhci_arasan->pins_default);
+			goto unreg_clk;
+		}
+
+		ret = pinctrl_select_state(sdhci_arasan->pinctrl,
+					   sdhci_arasan->pins_default);
+		if (ret) {
+			dev_err(&pdev->dev, "could not select default state\n");
+			goto unreg_clk;
+		}
+	}
+
 	sdhci_arasan->phy = ERR_PTR(-ENODEV);
 	if (of_device_is_compatible(pdev->dev.of_node,
 				    "arasan,sdhci-5.1")) {
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 55 lines · Manish Narani

Driver should be able to handle optional pinctrl setting.

---
 drivers/mmc/host/sdhci-of-arasan.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/mmc/host/sdhci-of-arasan.c +17 -0
index 829ccef87426..f788cc9d5914 100644
@@ -23,6 +23,7 @@
 #include <linux/regmap.h>
 #include <linux/of.h>
 #include <linux/firmware/xlnx-zynqmp.h>
+#include <linux/pinctrl/consumer.h>
 
 #include "cqhci.h"
 #include "sdhci-pltfm.h"
@@ -135,6 +136,8 @@ struct sdhci_arasan_clk_data {
  * @clk_ops:		Struct for the Arasan Controller Clock Operations.
  * @soc_ctl_base:	Pointer to regmap for syscon for soc_ctl registers.
  * @soc_ctl_map:	Map to get offsets into soc_ctl registers.
+ * @pinctrl:		Per-device pin control state holder.
+ * @pins_default:	Pinctrl state for a device.
  * @quirks:		Arasan deviations from spec.
  */
 struct sdhci_arasan_data {
@@ -149,6 +152,8 @@ struct sdhci_arasan_data {
 
 	struct regmap	*soc_ctl_base;
 	const struct sdhci_arasan_soc_ctl_map *soc_ctl_map;
+	struct pinctrl	*pinctrl;
+	struct pinctrl_state *pins_default;
 	unsigned int	quirks;
 
 /* Controller does not have CD wired and will not function normally without */
@@ -1619,6 +1624,25 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
 		goto unreg_clk;
 	}
 
+	sdhci_arasan->pinctrl = devm_pinctrl_get(&pdev->dev);
+	if (!IS_ERR(sdhci_arasan->pinctrl)) {
+		sdhci_arasan->pins_default =
+			pinctrl_lookup_state(sdhci_arasan->pinctrl,
+					     PINCTRL_STATE_DEFAULT);
+		if (IS_ERR(sdhci_arasan->pins_default)) {
+			dev_err(&pdev->dev, "Missing default pinctrl config\n");
+			ret = PTR_ERR(sdhci_arasan->pins_default);
+			goto unreg_clk;
+		}
+
+		ret = pinctrl_select_state(sdhci_arasan->pinctrl,

drivers/mmc/host/sdhci-of-arasan.c static int sdhci_arasan_probe(struct platform_device *pdev) · line 1648

Quoted 10 lines
drivers/mmc/host/sdhci-of-arasan.c +7 -0
+					   sdhci_arasan->pins_default);
+		if (ret) {
+			dev_err(&pdev->dev, "could not select default state\n");
+			goto unreg_clk;
+		}
+	}
+
 	sdhci_arasan->phy = ERR_PTR(-ENODEV);
 	if (of_device_is_compatible(pdev->dev.of_node,
 				    "arasan,sdhci-5.1")) {

Ulf: Is there any need to describe in binding doc? I mean all txt based binding have it described. But not quite sure if there is a need to describe it in yaml if only default option is supported.
And when this is optional it should be fine also for others SOC.

For patch itself.

Thanks,
Michal

#2 lore raw
In reply to Manish Narani
Quoted 51 lines · Manish Narani

Driver should be able to handle optional pinctrl setting.

---
 drivers/mmc/host/sdhci-of-arasan.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/mmc/host/sdhci-of-arasan.c +13 -0
index 829ccef87426..f788cc9d5914 100644
@@ -23,6 +23,7 @@
 #include <linux/regmap.h>
 #include <linux/of.h>
 #include <linux/firmware/xlnx-zynqmp.h>
+#include <linux/pinctrl/consumer.h>
 
 #include "cqhci.h"
 #include "sdhci-pltfm.h"
@@ -135,6 +136,8 @@ struct sdhci_arasan_clk_data {
  * @clk_ops:           Struct for the Arasan Controller Clock Operations.
  * @soc_ctl_base:      Pointer to regmap for syscon for soc_ctl registers.
  * @soc_ctl_map:       Map to get offsets into soc_ctl registers.
+ * @pinctrl:           Per-device pin control state holder.
+ * @pins_default:      Pinctrl state for a device.
  * @quirks:            Arasan deviations from spec.
  */
 struct sdhci_arasan_data {
@@ -149,6 +152,8 @@ struct sdhci_arasan_data {
 
        struct regmap   *soc_ctl_base;
        const struct sdhci_arasan_soc_ctl_map *soc_ctl_map;
+       struct pinctrl  *pinctrl;
+       struct pinctrl_state *pins_default;
        unsigned int    quirks;
 
 /* Controller does not have CD wired and will not function normally without */
@@ -1619,6 +1624,25 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
                goto unreg_clk;
        }
 
+       sdhci_arasan->pinctrl = devm_pinctrl_get(&pdev->dev);
+       if (!IS_ERR(sdhci_arasan->pinctrl)) {
+               sdhci_arasan->pins_default =
+                       pinctrl_lookup_state(sdhci_arasan->pinctrl,
+                                            PINCTRL_STATE_DEFAULT);
+               if (IS_ERR(sdhci_arasan->pins_default)) {
+                       dev_err(&pdev->dev, "Missing default pinctrl config\n");
+                       ret = PTR_ERR(sdhci_arasan->pins_default);

drivers/mmc/host/sdhci-of-arasan.c static int sdhci_arasan_probe(struct platform_device *pdev) · line 1644

Quoted 10 lines
drivers/mmc/host/sdhci-of-arasan.c +10 -0
+                       goto unreg_clk;
+               }
+
+               ret = pinctrl_select_state(sdhci_arasan->pinctrl,
+                                          sdhci_arasan->pins_default);
+               if (ret) {
+                       dev_err(&pdev->dev, "could not select default state\n");
+                       goto unreg_clk;
+               }
+       }

Isn't all this already taken care of via pinctrl_bind_pins() called by driver core during probe?

[...]

Kind regards
Uffe

#3 lore raw
Quoted 57 lines · Ulf Hansson
Quoted 56 lines · Manish Narani

Driver should be able to handle optional pinctrl setting.

---
 drivers/mmc/host/sdhci-of-arasan.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/mmc/host/sdhci-of-arasan.c +18 -0
index 829ccef87426..f788cc9d5914 100644
@@ -23,6 +23,7 @@
 #include <linux/regmap.h>
 #include <linux/of.h>
 #include <linux/firmware/xlnx-zynqmp.h>
+#include <linux/pinctrl/consumer.h>
 
 #include "cqhci.h"
 #include "sdhci-pltfm.h"
@@ -135,6 +136,8 @@ struct sdhci_arasan_clk_data {
  * @clk_ops:           Struct for the Arasan Controller Clock Operations.
  * @soc_ctl_base:      Pointer to regmap for syscon for soc_ctl registers.
  * @soc_ctl_map:       Map to get offsets into soc_ctl registers.
+ * @pinctrl:           Per-device pin control state holder.
+ * @pins_default:      Pinctrl state for a device.
  * @quirks:            Arasan deviations from spec.
  */
 struct sdhci_arasan_data {
@@ -149,6 +152,8 @@ struct sdhci_arasan_data {
 
        struct regmap   *soc_ctl_base;
        const struct sdhci_arasan_soc_ctl_map *soc_ctl_map;
+       struct pinctrl  *pinctrl;
+       struct pinctrl_state *pins_default;
        unsigned int    quirks;
 
 /* Controller does not have CD wired and will not function normally without */
@@ -1619,6 +1624,25 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
                goto unreg_clk;
        }
 
+       sdhci_arasan->pinctrl = devm_pinctrl_get(&pdev->dev);
+       if (!IS_ERR(sdhci_arasan->pinctrl)) {
+               sdhci_arasan->pins_default =
+                       pinctrl_lookup_state(sdhci_arasan->pinctrl,
+                                            PINCTRL_STATE_DEFAULT);
+               if (IS_ERR(sdhci_arasan->pins_default)) {
+                       dev_err(&pdev->dev, "Missing default pinctrl config\n");
+                       ret = PTR_ERR(sdhci_arasan->pins_default);
+                       goto unreg_clk;
+               }
+
+               ret = pinctrl_select_state(sdhci_arasan->pinctrl,
+                                          sdhci_arasan->pins_default);
Quoted 9 lines

drivers/mmc/host/sdhci-of-arasan.c static int sdhci_arasan_probe(struct platform_device *pdev) · line 1644

Quoted 5 lines
drivers/mmc/host/sdhci-of-arasan.c +5 -0
+               if (ret) {
+                       dev_err(&pdev->dev, "could not select default state\n");
+                       goto unreg_clk;
+               }
+       }

Isn't all this already taken care of via pinctrl_bind_pins() called by driver core during probe?

Thanks for the hint.
Manish: Can you please check it?

Thanks,
Michal

#4 lore raw

Hi Uffe/Michal,

Quoted 81 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: Wednesday, November 18, 2020 11:54 PM
To: Ulf Hansson <[email protected]>; Manish Narani <[email protected]>
Cc: Michal Simek <[email protected]>; Adrian Hunter <[email protected]>; Linux ARM <linux-arm- [email protected]>; [email protected]; Linux Kernel Mailing List <[email protected]>; git <[email protected]>
Subject: Re: [PATCH] mmc: sdhci-of-arasan: Add pinctrl support to the driver

Quoted 1 line · Ulf Hansson

On Wed, 18 Nov 2020 at 07:22, Manish Narani

Quoted 10 lines · <[email protected]> wrote:

Review

Quoted 10 lines

Driver should be able to handle optional pinctrl setting.

---
 drivers/mmc/host/sdhci-of-arasan.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
(quoted diff) +0 -0

b/drivers/mmc/host/sdhci-of-arasan.c

Quoted 22 lines
Quoted 22 lines

index 829ccef87426..f788cc9d5914 100644

drivers/mmc/host/sdhci-of-arasan.c +3 -0
@@ -23,6 +23,7 @@
 #include <linux/regmap.h>
 #include <linux/of.h>
 #include <linux/firmware/xlnx-zynqmp.h>
+#include <linux/pinctrl/consumer.h>
 
 #include "cqhci.h"
 #include "sdhci-pltfm.h"
@@ -135,6 +136,8 @@ struct sdhci_arasan_clk_data {
  * @clk_ops:           Struct for the Arasan Controller Clock Operations.
  * @soc_ctl_base:      Pointer to regmap for syscon for soc_ctl registers.
  * @soc_ctl_map:       Map to get offsets into soc_ctl registers.
+ * @pinctrl:           Per-device pin control state holder.
+ * @pins_default:      Pinctrl state for a device.
  * @quirks:            Arasan deviations from spec.
  */
 struct sdhci_arasan_data {
@@ -149,6 +152,8 @@ struct sdhci_arasan_data {
 
Quoted 7 lines

drivers/mmc/host/sdhci-of-arasan.c struct sdhci_arasan_data {

Quoted 7 lines
drivers/mmc/host/sdhci-of-arasan.c +2 -0
        struct regmap   *soc_ctl_base;
        const struct sdhci_arasan_soc_ctl_map *soc_ctl_map;
+       struct pinctrl  *pinctrl;
+       struct pinctrl_state *pins_default;
        unsigned int    quirks;
 
 /* Controller does not have CD wired and will not function normally

without */

Quoted 1 line

drivers/mmc/host/sdhci-of-arasan.c static int sdhci_arasan_probe(struct

Quoted 1 line
drivers/mmc/host/sdhci-of-arasan.c +0 -0
@@ -1619,6 +1624,25 @@ static int sdhci_arasan_probe(struct

platform_device *pdev)

Quoted 22 lines
Quoted 21 lines
drivers/mmc/host/sdhci-of-arasan.c +18 -0
                goto unreg_clk;
        }
 
+       sdhci_arasan->pinctrl = devm_pinctrl_get(&pdev->dev);
+       if (!IS_ERR(sdhci_arasan->pinctrl)) {
+               sdhci_arasan->pins_default =
+                       pinctrl_lookup_state(sdhci_arasan->pinctrl,
+                                            PINCTRL_STATE_DEFAULT);
+               if (IS_ERR(sdhci_arasan->pins_default)) {
+                       dev_err(&pdev->dev, "Missing default pinctrl config\n");
+                       ret = PTR_ERR(sdhci_arasan->pins_default);
+                       goto unreg_clk;
+               }
+
+               ret = pinctrl_select_state(sdhci_arasan->pinctrl,
+                                          sdhci_arasan->pins_default);
+               if (ret) {
+                       dev_err(&pdev->dev, "could not select default state\n");
+                       goto unreg_clk;
+               }
+       }
Quoted 6 lines
Quoted 3 lines

Isn't all this already taken care of via pinctrl_bind_pins() called by driver core during probe?

Thanks for the hint.
Manish: Can you please check it?

Thanks Uffe.
Yes, this is already taken care of via pinctrl_bind_pins() called during probe. This patch is not required to be merged.

Thanks,
Manish