diff mbox

[v2,2/2] mmc: host: sdhci-s3c: Add support for pinctrl

Message ID 1353076097-22498-3-git-send-email-t.figa@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tomasz Figa Nov. 16, 2012, 2:28 p.m. UTC
This patch adds support for pin configuration using pinctrl subsystem
to the sdhci-s3c driver.

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
---
 .../devicetree/bindings/mmc/samsung-sdhci.txt        | 20 +++++++++++++-------
 drivers/mmc/host/sdhci-s3c.c                         | 12 ++++++++++--
 2 files changed, 23 insertions(+), 9 deletions(-)

Comments

Thomas Abraham Nov. 21, 2012, 10:58 a.m. UTC | #1
On 16 November 2012 19:58, Tomasz Figa <t.figa@samsung.com> wrote:
> This patch adds support for pin configuration using pinctrl subsystem
> to the sdhci-s3c driver.
>
> Signed-off-by: Tomasz Figa <t.figa@samsung.com>
> ---
>  .../devicetree/bindings/mmc/samsung-sdhci.txt        | 20 +++++++++++++-------
>  drivers/mmc/host/sdhci-s3c.c                         | 12 ++++++++++--
>  2 files changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/mmc/samsung-sdhci.txt b/Documentation/devicetree/bindings/mmc/samsung-sdhci.txt
> index 630a7d7..97e9e31 100644
> --- a/Documentation/devicetree/bindings/mmc/samsung-sdhci.txt
> +++ b/Documentation/devicetree/bindings/mmc/samsung-sdhci.txt
> @@ -12,10 +12,6 @@ is used. The Samsung's SDHCI controller bindings extends this as listed below.
>  [A] The property "samsung,cd-pinmux-gpio" can be used as stated in the
>      "Optional Board Specific Properties" section below.
>
> -[B] If core card-detect bindings and "samsung,cd-pinmux-gpio" property
> -    is not specified, it is assumed that there is no card detection
> -    mechanism used.
> -
>  Required SoC Specific Properties:
>  - compatible: should be one of the following
>    - "samsung,s3c6410-sdhci": For controllers compatible with s3c6410 sdhci
> @@ -24,14 +20,18 @@ Required SoC Specific Properties:
>      controller.
>
>  Required Board Specific Properties:
> -- gpios: Should specify the gpios used for clock, command and data lines. The
> -  gpio specifier format depends on the gpio controller.
> +- Samsung GPIO variant (will be completely replaced by pinctrl):
> +  - gpios: Should specify the gpios used for clock, command and data lines. The
> +    gpio specifier format depends on the gpio controller.
> +- Pinctrl variant (preferred if available):
> +  - pinctrl-0: Should specify pin control groups used for this controller.
> +  - pinctrl-names: Should contain only one value - "default".
>
>  Optional Board Specific Properties:
>  - samsung,cd-pinmux-gpio: Specifies the card detect line that is routed
>    through a pinmux to the card-detect pin of the card slot. This property
>    should be used only if none of the mmc core card-detect properties are
> -  used.
> +  used. Only for Samsung GPIO variant.
>
>  Example:
>         sdhci@12530000 {
> @@ -40,12 +40,18 @@ Example:
>                 interrupts = <0 75 0>;
>                 bus-width = <4>;
>                 cd-gpios = <&gpk2 2 2 3 3>;
> +
> +               /* Samsung GPIO variant */
>                 gpios = <&gpk2 0 2 0 3>,  /* clock line */
>                         <&gpk2 1 2 0 3>,  /* command line */
>                         <&gpk2 3 2 3 3>,  /* data line 0 */
>                         <&gpk2 4 2 3 3>,  /* data line 1 */
>                         <&gpk2 5 2 3 3>,  /* data line 2 */
>                         <&gpk2 6 2 3 3>;  /* data line 3 */
> +
> +               /* Pinctrl variant */
> +               pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_bus4>;
> +               pinctrl-names = "default";
>         };

nit: there could have been one example each for gpio and pinctrl
variant instead of putting both into one example node.

>
>         Note: This example shows both SoC specific and board specific properties
> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> index 75f85fd..6161162 100644
> --- a/drivers/mmc/host/sdhci-s3c.c
> +++ b/drivers/mmc/host/sdhci-s3c.c
> @@ -24,6 +24,7 @@
>  #include <linux/of_gpio.h>
>  #include <linux/pm.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/pinctrl/consumer.h>
>
>  #include <linux/mmc/host.h>
>
> @@ -57,6 +58,7 @@ struct sdhci_s3c {
>         int                     ext_cd_irq;
>         int                     ext_cd_gpio;
>         int                     *gpios;
> +       struct pinctrl          *pctrl;
>
>         struct clk              *clk_io;
>         struct clk              *clk_bus[MAX_BUS_CLK];
> @@ -477,8 +479,9 @@ static int __devinit sdhci_s3c_parse_dt(struct device *dev,
>                 return -EINVAL;
>         }
>
> -       dev_info(dev, "assuming no card detect line available\n");
> -       pdata->cd_type = S3C_SDHCI_CD_NONE;
> +       /* assuming internal card detect that will be configured by pinctrl */
> +       pdata->cd_type = S3C_SDHCI_CD_INTERNAL;
> +       goto setup_bus;
>
>   found_cd:
>         if (pdata->cd_type == S3C_SDHCI_CD_GPIO) {
> @@ -496,6 +499,9 @@ static int __devinit sdhci_s3c_parse_dt(struct device *dev,
>         }
>
>   setup_bus:
> +       if (!IS_ERR(ourhost->pctrl))
> +               return 0;
> +
>         /* get the gpios for command, clock and data lines */
>         for (cnt = 0; cnt < NUM_GPIOS(pdata->max_width); cnt++) {
>                 gpio = of_get_gpio(node, cnt);
> @@ -574,6 +580,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
>                 goto err_pdata_io_clk;
>         }
>
> +       sc->pctrl = devm_pinctrl_get_select_default(&pdev->dev);
> +
>         if (pdev->dev.of_node) {
>                 ret = sdhci_s3c_parse_dt(&pdev->dev, host, pdata);
>                 if (ret)
> --
> 1.8.0

Acked-by: Thomas Abraham <thomas.abraham@linaro.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chris Ball Nov. 25, 2012, 7:22 p.m. UTC | #2
Hi,

On Wed, Nov 21 2012, Thomas Abraham wrote:
> nit: there could have been one example each for gpio and pinctrl
> variant instead of putting both into one example node.

Tomasz, do you want to reply to this review comment?

Thanks,

- Chris.
Tomasz Figa Nov. 25, 2012, 7:37 p.m. UTC | #3
Hi Chris,

On Sunday 25 of November 2012 14:22:44 Chris Ball wrote:
> Hi,
> 
> On Wed, Nov 21 2012, Thomas Abraham wrote:
> > nit: there could have been one example each for gpio and pinctrl
> > variant instead of putting both into one example node.
> 
> Tomasz, do you want to reply to this review comment?

Well, since Thomas already gave his Acked-by for this patch and the 
comment was only about a minor thing in the documentation, I considered it 
a thing that could be adjusted with further patch if needed.

If you will be still taking patches for 3.8 tomorrow, then I'm fine with 
preparing new version with this comment addressed.

Best regards,
Tomasz Figa

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chris Ball Nov. 25, 2012, 8:01 p.m. UTC | #4
Hi,

On Sun, Nov 25 2012, Tomasz Figa wrote:
> Hi Chris,
>
> On Sunday 25 of November 2012 14:22:44 Chris Ball wrote:
>> Hi,
>> 
>> On Wed, Nov 21 2012, Thomas Abraham wrote:
>> > nit: there could have been one example each for gpio and pinctrl
>> > variant instead of putting both into one example node.
>> 
>> Tomasz, do you want to reply to this review comment?
>
> Well, since Thomas already gave his Acked-by for this patch and the 
> comment was only about a minor thing in the documentation, I considered it 
> a thing that could be adjusted with further patch if needed.

Okay, that's reasonable -- I'll take it as-is for now.  Thanks,

- Chris.
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/mmc/samsung-sdhci.txt b/Documentation/devicetree/bindings/mmc/samsung-sdhci.txt
index 630a7d7..97e9e31 100644
--- a/Documentation/devicetree/bindings/mmc/samsung-sdhci.txt
+++ b/Documentation/devicetree/bindings/mmc/samsung-sdhci.txt
@@ -12,10 +12,6 @@  is used. The Samsung's SDHCI controller bindings extends this as listed below.
 [A] The property "samsung,cd-pinmux-gpio" can be used as stated in the
     "Optional Board Specific Properties" section below.
 
-[B] If core card-detect bindings and "samsung,cd-pinmux-gpio" property
-    is not specified, it is assumed that there is no card detection
-    mechanism used.
-
 Required SoC Specific Properties:
 - compatible: should be one of the following
   - "samsung,s3c6410-sdhci": For controllers compatible with s3c6410 sdhci
@@ -24,14 +20,18 @@  Required SoC Specific Properties:
     controller.
 
 Required Board Specific Properties:
-- gpios: Should specify the gpios used for clock, command and data lines. The
-  gpio specifier format depends on the gpio controller.
+- Samsung GPIO variant (will be completely replaced by pinctrl):
+  - gpios: Should specify the gpios used for clock, command and data lines. The
+    gpio specifier format depends on the gpio controller.
+- Pinctrl variant (preferred if available):
+  - pinctrl-0: Should specify pin control groups used for this controller.
+  - pinctrl-names: Should contain only one value - "default".
 
 Optional Board Specific Properties:
 - samsung,cd-pinmux-gpio: Specifies the card detect line that is routed
   through a pinmux to the card-detect pin of the card slot. This property
   should be used only if none of the mmc core card-detect properties are
-  used.
+  used. Only for Samsung GPIO variant.
 
 Example:
 	sdhci@12530000 {
@@ -40,12 +40,18 @@  Example:
 		interrupts = <0 75 0>;
 		bus-width = <4>;
 		cd-gpios = <&gpk2 2 2 3 3>;
+
+		/* Samsung GPIO variant */
 		gpios = <&gpk2 0 2 0 3>,  /* clock line */
 			<&gpk2 1 2 0 3>,  /* command line */
 			<&gpk2 3 2 3 3>,  /* data line 0 */
 			<&gpk2 4 2 3 3>,  /* data line 1 */
 			<&gpk2 5 2 3 3>,  /* data line 2 */
 			<&gpk2 6 2 3 3>;  /* data line 3 */
+
+		/* Pinctrl variant */
+		pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_bus4>;
+		pinctrl-names = "default";
 	};
 
 	Note: This example shows both SoC specific and board specific properties
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 75f85fd..6161162 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -24,6 +24,7 @@ 
 #include <linux/of_gpio.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
+#include <linux/pinctrl/consumer.h>
 
 #include <linux/mmc/host.h>
 
@@ -57,6 +58,7 @@  struct sdhci_s3c {
 	int			ext_cd_irq;
 	int			ext_cd_gpio;
 	int			*gpios;
+	struct pinctrl          *pctrl;
 
 	struct clk		*clk_io;
 	struct clk		*clk_bus[MAX_BUS_CLK];
@@ -477,8 +479,9 @@  static int __devinit sdhci_s3c_parse_dt(struct device *dev,
 		return -EINVAL;
 	}
 
-	dev_info(dev, "assuming no card detect line available\n");
-	pdata->cd_type = S3C_SDHCI_CD_NONE;
+	/* assuming internal card detect that will be configured by pinctrl */
+	pdata->cd_type = S3C_SDHCI_CD_INTERNAL;
+	goto setup_bus;
 
  found_cd:
 	if (pdata->cd_type == S3C_SDHCI_CD_GPIO) {
@@ -496,6 +499,9 @@  static int __devinit sdhci_s3c_parse_dt(struct device *dev,
 	}
 
  setup_bus:
+	if (!IS_ERR(ourhost->pctrl))
+		return 0;
+
 	/* get the gpios for command, clock and data lines */
 	for (cnt = 0; cnt < NUM_GPIOS(pdata->max_width); cnt++) {
 		gpio = of_get_gpio(node, cnt);
@@ -574,6 +580,8 @@  static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 		goto err_pdata_io_clk;
 	}
 
+	sc->pctrl = devm_pinctrl_get_select_default(&pdev->dev);
+
 	if (pdev->dev.of_node) {
 		ret = sdhci_s3c_parse_dt(&pdev->dev, host, pdata);
 		if (ret)