From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751871AbcASLHo (ORCPT ); Tue, 19 Jan 2016 06:07:44 -0500 Received: from lucky1.263xmail.com ([211.157.147.132]:59895 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750954AbcASLHg (ORCPT ); Tue, 19 Jan 2016 06:07:36 -0500 X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: wxt@rock-chips.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <94d191610372fd5b2b723b36e24ed89b> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Subject: Re: [PATCH] mmc: dw_mmc-rockchip: add pinctrl support To: Heiko Stuebner References: <1453197165-20194-1-git-send-email-shawn.lin@rock-chips.com> <7857448.fZE0EdmvdR@phil> Cc: shawn.lin@rock-chips.com, Jaehoon Chung , Ulf Hansson , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, wxt@rock-chips.com From: Shawn Lin Message-ID: <569E18E4.7050509@rock-chips.com> Date: Tue, 19 Jan 2016 19:07:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <7857448.fZE0EdmvdR@phil> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/1/19 18:07, Heiko Stuebner wrote: > Hi Shawn, > > Am Dienstag, 19. Januar 2016, 17:52:45 schrieb Shawn Lin: >> We find rk3368 fail to enumerate sd card since >> the default state is gpio function. Meahwhile, lots of >> rockchip platform dts file assign pinctrl to dw_mmc but actually >> dw_mmc never use it. Fortunately, those platforms' default io >> state is sdmmc function, but no always right for all. >> >> Cc: Heiko Stuebner >> Signed-off-by: Shawn Lin > > I do believe any issue you see, must come from somewhere else, because the > driver-core does in drivers/base/dd.c really_probe(): > pinctrl_bind_pins() yes, pinctrl_bind_pins does turn pinctrl state. But I try debug a little more and seems somewhere else switch the state before dw_mmc probe. Now I *guess* that may relate to our ATF or MCU firmware since rk3368's sdmmc io can also be used as mcu_jtag for system debug. I need to double check that point, thanks. Hi Caesar, does your patch able to consider adding SDMMC/CPU_JTAG/MCU_JTAG managment for rk3368 as well? > which in turn already does the needed pinctrl state handling. > > So that default-state should be set up even before the dwmmc probe function > is called. > > The sharing between sdmmc and uart2 pins is the same on the rk3036 and so > far Caesar seems to have been able to switch the pin-state to sdmmc without > touching the dw_mmc driver itself. > > > Heiko > > >> --- >> >> drivers/mmc/host/dw_mmc-rockchip.c | 15 +++++++++++++++ >> 1 file changed, 15 insertions(+) >> >> diff --git a/drivers/mmc/host/dw_mmc-rockchip.c >> b/drivers/mmc/host/dw_mmc-rockchip.c index d9c92f3..308b424 100644 >> --- a/drivers/mmc/host/dw_mmc-rockchip.c >> +++ b/drivers/mmc/host/dw_mmc-rockchip.c >> @@ -9,6 +9,7 @@ >> >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -21,6 +22,8 @@ >> #define RK3288_CLKGEN_DIV 2 >> >> struct dw_mci_rockchip_priv_data { >> + struct pinctrl *pinctrl; >> + struct pinctrl_state *pins_default; >> struct clk *drv_clk; >> struct clk *sample_clk; >> int default_sample_phase; >> @@ -78,6 +81,10 @@ static void dw_mci_rk3288_set_ios(struct dw_mci *host, >> struct mmc_ios *ios) /* Make sure we use phases which we can enumerate >> with */ >> if (!IS_ERR(priv->sample_clk)) >> clk_set_phase(priv->sample_clk, priv->default_sample_phase); >> + >> + /* Make sure we use correct pinctrl which we can enumerate with */ >> + if (!IS_ERR(priv->pinctrl) && !IS_ERR(priv->pins_default)) >> + pinctrl_select_state(priv->pinctrl, priv->pins_default); >> } >> >> #define NUM_PHASES 360 >> @@ -223,6 +230,14 @@ static int dw_mci_rk3288_parse_dt(struct dw_mci >> *host) if (IS_ERR(priv->sample_clk)) >> dev_dbg(host->dev, "ciu_sample not available\n"); >> >> + priv->pinctrl = devm_pinctrl_get(host->dev); >> + if (!IS_ERR(priv->pinctrl)) { >> + priv->pins_default = pinctrl_lookup_state(priv->pinctrl, >> + "default"); >> + if (IS_ERR(priv->pins_default)) >> + dev_dbg(host->dev, "pinctrl not available\n"); >> + } >> + >> host->priv = priv; >> >> return 0; > > > > -- Best Regards Shawn Lin