diff mbox

[2/2] mmc: dw_mmc: exynos: Add pinctrl support

Message ID 1360238236-17694-2-git-send-email-sachin.kamat@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Sachin Kamat Feb. 7, 2013, 11:57 a.m. UTC
Added support for pin configuration using pinctrl subsystem.

Cc: Thomas Abraham <thomas.abraham@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/mmc/host/dw_mmc-exynos.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

Comments

Linus Walleij Feb. 7, 2013, 3:30 p.m. UTC | #1
On Thu, Feb 7, 2013 at 12:57 PM, Sachin Kamat <sachin.kamat@linaro.org> wrote:

> Added support for pin configuration using pinctrl subsystem.
>
> Cc: Thomas Abraham <thomas.abraham@linaro.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>

NACK.

In the v3.9 merge window we will merge this patch:
http://marc.info/?l=linux-kernel&m=135887740715083&w=2

That should do the trick. Just define your tables properly.

Yours,
Linus Walleij
--
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
Sachin Kamat Feb. 25, 2013, 4:39 a.m. UTC | #2
On 7 February 2013 21:00, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Thu, Feb 7, 2013 at 12:57 PM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
>
>> Added support for pin configuration using pinctrl subsystem.
>>
>
> NACK.
>
> In the v3.9 merge window we will merge this patch:
> http://marc.info/?l=linux-kernel&m=135887740715083&w=2
>
> That should do the trick. Just define your tables properly.
>

Just a small clarification needed in this regard.
On systems that do not use pinctrl and need to configure the gpios, we
used to check the return value of devm_pinctrl_get_select_default()
for error and then parse the dt file for gpios and configure them if
needed. Now your latest patch "drivers/pinctrl: grab default handles
from device core" suggests not to use boilerplate code as it will
handle pinctrl configuration based on dt entries for it. So in the
case like dw_mmc (in my patch above), please suggest best way to avoid
parsing gpios from dt file in case where we have pinctrl defined.

The following 3 lines (with +) wouldn't be required according to the
patch and hence 'for' loop would get executed (which I want to avoid
as the system supports pinctrl in this case).

+       pctrl = devm_pinctrl_get_select_default(host->dev);
+       if (!IS_ERR(pctrl))
+               return 0;
+
        /* cmd + clock + bus-width pins */
        for (idx = 0; idx < NUM_PINS(bus_width); idx++) {
                gpio = of_get_gpio(slot_np, idx);
Linus Walleij Feb. 27, 2013, 11:19 p.m. UTC | #3
On Mon, Feb 25, 2013 at 5:39 AM, Sachin Kamat <sachin.kamat@linaro.org> wrote:

> Just a small clarification needed in this regard.
> On systems that do not use pinctrl and need to configure the gpios, we
> used to check the return value of devm_pinctrl_get_select_default()
> for error and then parse the dt file for gpios and configure them if
> needed.

The idea of pinctrl_get_select_default() is (as you could guess
from it's name) to get a pin ctrl handle and select the default state.

The return code from that function tells you whether that was
successful or not.

It does *NOT* tell you to go and look up GPIO values if it wasn't!

Then the function would be named
bool pinctrl_is_used_on_this_system().

Please review the recent conversation I had with Tomasz and
Heiko on this, especially this mail:
http://marc.info/?l=linux-kernel&m=136166647121345&w=2

Yours,
Linus Walleij
--
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
diff mbox

Patch

diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c
index f15b4d3..31f5f47 100644
--- a/drivers/mmc/host/dw_mmc-exynos.c
+++ b/drivers/mmc/host/dw_mmc-exynos.c
@@ -11,11 +11,13 @@ 
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/dw_mmc.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
+#include <linux/pinctrl/consumer.h>
 
 #include "dw_mmc.h"
 #include "dw_mmc-pltfm.h"
@@ -36,6 +38,8 @@ 
 #define EXYNOS4210_FIXED_CIU_CLK_DIV	2
 #define EXYNOS4412_FIXED_CIU_CLK_DIV	4
 
+static struct pinctrl	*pctrl;
+
 /* Variations in Exynos specific dw-mshc controller */
 enum dw_mci_exynos_type {
 	DW_MCI_TYPE_EXYNOS4210,
@@ -160,6 +164,10 @@  static int dw_mci_exynos_setup_bus(struct dw_mci *host,
 	if (!slot_np)
 		return -EINVAL;
 
+	pctrl = devm_pinctrl_get_select_default(host->dev);
+	if (!IS_ERR(pctrl))
+		return 0;
+
 	/* cmd + clock + bus-width pins */
 	for (idx = 0; idx < NUM_PINS(bus_width); idx++) {
 		gpio = of_get_gpio(slot_np, idx);