linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrice CHOTARD <patrice.chotard@st.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Russell King <linux@armlinux.org.uk>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexandre TORGUE <alexandre.torgue@st.com>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-clk <linux-clk@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Andrea Merello <andrea.merello@gmail.com>
Subject: Re: [PATCH 03/14] mmc: mmci: Add support for setting pad type via pinctrl
Date: Mon, 15 Jan 2018 17:42:18 +0000	[thread overview]
Message-ID: <c09970a6-0e6d-c26d-f41e-ab82b4cb8127@st.com> (raw)
In-Reply-To: <CAPDyKFoBTKpwSJzg5_cMei0Vzze=eQTKFBuD6mgHdYZUhqxFPw@mail.gmail.com>

Hi Ulf

On 01/15/2018 01:43 PM, Ulf Hansson wrote:
> On 12 January 2018 at 13:15,  <patrice.chotard@st.com> wrote:
>> From: Patrice Chotard <patrice.chotard@st.com>
>>
>> The STM32 variant hasn't the control bit to switch pads in opendrain mode.
>> In this case we can achieve the same result by asking to the pinmux driver
>> to configure pins for us.
>>
>> This patch make the mmci driver able to do this whenever needed.
>>
>> Signed-off-by: Andrea Merello <andrea.merello@gmail.com>
>> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
>> ---
>>   drivers/mmc/host/mmci.c | 54 ++++++++++++++++++++++++++++++++++++++++---------
>>   drivers/mmc/host/mmci.h |  5 +++++
>>   2 files changed, 50 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
>> index 7e56f85..38e8c20 100644
>> --- a/drivers/mmc/host/mmci.c
>> +++ b/drivers/mmc/host/mmci.c
>> @@ -85,6 +85,8 @@
>>    * @mmcimask1: true if variant have a MMCIMASK1 register.
>>    * @start_err: true is the variant has STARTBITERR bit inside MMCISTATUS
>>    *            register.
>> + * @opendrain: true if variant have dedicated bit for opendrain pins
>> + *            configuration.
>>    */
>>   struct variant_data {
>>          unsigned int            clkreg;
>> @@ -116,6 +118,7 @@ struct variant_data {
>>          bool                    reversed_irq_handling;
>>          bool                    mmcimask1;
>>          bool                    start_err;
>> +       bool                    opendrain;
> 
> Similar comment as for patch2.
> 
> To be consistent with how we implement support for similar variant
> variations, I would prefer to have this being a u32. Something along
> the lines of how the "busy_detect_flag" is being used.

ok

> 
> [...]
> 
>> @@ -1394,9 +1405,11 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
>>   {
>>          struct mmci_host *host = mmc_priv(mmc);
>>          struct variant_data *variant = host->variant;
>> +       struct pinctrl_state *pins;
>>          u32 pwr = 0;
>>          unsigned long flags;
>>          int ret;
>> +       bool is_opendrain;
>>
>>          if (host->plat->ios_handler &&
>>                  host->plat->ios_handler(mmc_dev(mmc), ios))
>> @@ -1455,16 +1468,31 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
>>                                  ~MCI_ST_DATA2DIREN);
>>          }
>>
>> -       if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) {
>> -               if (host->hw_designer != AMBA_VENDOR_ST)
>> -                       pwr |= MCI_ROD;
>> -               else {
>> -                       /*
>> -                        * The ST Micro variant use the ROD bit for something
>> -                        * else and only has OD (Open Drain).
>> -                        */
>> -                       pwr |= MCI_OD;
> 
> Seems like you should actually split this change into two parts.
> 
> One that adds the variant flag for the open drain bit, when then can
> clean up this code. Then a patch on top that starts using pinctrl in
> case there is no open drain bit set.
> 
> Does that sounds reasonable?

Of course

> 
>> +       if (host->variant->opendrain) {
>> +               if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) {
>> +                       if (host->hw_designer != AMBA_VENDOR_ST) {
>> +                               pwr |= MCI_ROD;
>> +                       } else {
>> +                               /*
>> +                                * The ST Micro variant use the ROD bit for
>> +                                * something else and only has OD (Open Drain).
>> +                                */
>> +                               pwr |= MCI_OD;
>> +                       }
>>                  }
>> +       } else {
>> +               /*
>> +                * If the variant cannot configure the pads by its own, then we
>> +                * expect the pinctrl to be able to do that for us
>> +                */
>> +               is_opendrain = (ios->bus_mode == MMC_BUSMODE_OPENDRAIN);
>> +               pins = pinctrl_lookup_state(host->pinctrl, is_opendrain ?
> 
> How about doing the lookup in ->probe() instead? Then just select the
> state here, if supported?

ok

> 
>> +                                       MMCI_PINCTRL_STATE_OPENDRAIN :
>> +                                       MMCI_PINCTRL_STATE_PUSHPULL);
>> +               if (IS_ERR(pins))
>> +                       dev_warn(mmc_dev(mmc), "Cannot select pin drive type via pinctrl\n");
>> +               else
>> +                       pinctrl_select_state(host->pinctrl, pins);
>>          }
>>
>>          /*
>> @@ -1609,6 +1637,14 @@ static int mmci_probe(struct amba_device *dev,
>>          host = mmc_priv(mmc);
>>          host->mmc = mmc;
>>
>> +       if (!variant->opendrain) {
>> +               host->pinctrl = devm_pinctrl_get(&dev->dev);
>> +               if (IS_ERR(host->pinctrl)) {
>> +                       dev_err(&dev->dev, "failed to get pinctrl");
>> +                       goto host_free;
>> +               }
>> +       }
>> +
>>          host->hw_designer = amba_manf(dev);
>>          host->hw_revision = amba_rev(dev);
>>          dev_dbg(mmc_dev(mmc), "designer ID = 0x%02x\n", host->hw_designer);
>> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
>> index 83160a9..de3d0b3 100644
>> --- a/drivers/mmc/host/mmci.h
>> +++ b/drivers/mmc/host/mmci.h
>> @@ -192,6 +192,10 @@
>>
>>   #define NR_SG          128
>>
>> +/* pinctrl configs */
>> +#define MMCI_PINCTRL_STATE_PUSHPULL "default"
> 
> Seems like we should be able to cope fine without having to add a
> separate define for the PUSHPULL, but rather just select the default
> state instead.

yes agree

Thanks

Patrice

> 
>> +#define MMCI_PINCTRL_STATE_OPENDRAIN "opendrain"
>> +
>>   struct clk;
>>   struct variant_data;
>>   struct dma_chan;
>> @@ -227,6 +231,7 @@ struct mmci_host {
>>          bool                    vqmmc_enabled;
>>          struct mmci_platform_data *plat;
>>          struct variant_data     *variant;
>> +       struct pinctrl          *pinctrl;
>>
>>          u8                      hw_designer;
>>          u8                      hw_revision:4;
>> --
>> 1.9.1
>>
> 
> Kind regards
> Uffe
> 

  reply	other threads:[~2018-01-15 17:42 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12 12:15 [PATCH 00/14] Add MMCI support for STM32F SoCs family patrice.chotard-qxv4g6HH51o
2018-01-12 12:15 ` [PATCH 01/14] mmc: mmci: Don't pretend all variants to have MMCIMASK1 register patrice.chotard
     [not found]   ` <1515759368-16946-2-git-send-email-patrice.chotard-qxv4g6HH51o@public.gmane.org>
2018-01-15  1:01     ` Linus Walleij
2018-01-12 12:15 ` [PATCH 02/14] mmc: mmci: Don't pretend all variants to have MCI_STARBITERR flag patrice.chotard
     [not found]   ` <1515759368-16946-3-git-send-email-patrice.chotard-qxv4g6HH51o@public.gmane.org>
2018-01-15  1:03     ` Linus Walleij
2018-01-15 12:32   ` Ulf Hansson
2018-01-15 17:27     ` Patrice CHOTARD
2018-01-12 12:15 ` [PATCH 03/14] mmc: mmci: Add support for setting pad type via pinctrl patrice.chotard
     [not found]   ` <1515759368-16946-4-git-send-email-patrice.chotard-qxv4g6HH51o@public.gmane.org>
2018-01-15  1:07     ` Linus Walleij
2018-01-15 12:43   ` Ulf Hansson
2018-01-15 17:42     ` Patrice CHOTARD [this message]
2018-01-12 12:15 ` [PATCH 04/14] mmc: mmci: Add STM32 variant patrice.chotard
2018-01-15  1:13   ` Linus Walleij
2018-01-15 17:17     ` Patrice CHOTARD
     [not found]       ` <ce14077b-2b8b-f8a7-2107-78b1d9dcab27-qxv4g6HH51o@public.gmane.org>
2018-01-16  7:38         ` Linus Walleij
2018-01-12 12:15 ` [PATCH 05/14] ARM: dts: stm32: Add SDIO controller for stm32f746 patrice.chotard
2018-01-12 12:16 ` [PATCH 06/14] ARM: dts: stm32: Add SDIO controller for stm32f429 patrice.chotard
2018-01-12 12:16 ` [PATCH 07/14] ARM: dts: stm32: Add pin map for SDIO controller on stm32f4 patrice.chotard
2018-01-12 12:16 ` [PATCH 08/14] ARM: dts: stm32: Enable SDIO controller on stm32f469 disco board patrice.chotard
2018-01-12 12:16 ` [PATCH 09/14] ARM: dts: stm32: Enable SDIO controller on stm32429i-eval board patrice.chotard
2018-01-12 12:16 ` [PATCH 10/14] ARM: stm32: Add AMBA support for STM32F4 and STM32F7 SoCs patrice.chotard
2018-01-12 12:16 ` [PATCH 11/14] ARM: configs: stm32: Enable MMC_ARMMMCI support patrice.chotard
2018-01-12 12:16 ` [PATCH 12/14] ARM: configs: stm32: Enable EXT3_FS support patrice.chotard
2018-01-12 12:16 ` [PATCH 13/14] clk: stm32: Add clk entry for SDMMC2 on stm32F769 patrice.chotard
2018-01-12 18:52   ` Stephen Boyd
2018-01-12 12:16 ` [PATCH 14/14] gpio: stmpe: i2c transfer are forbiden in atomic context patrice.chotard
     [not found]   ` <1515759368-16946-15-git-send-email-patrice.chotard-qxv4g6HH51o@public.gmane.org>
2018-01-15  9:57     ` Linus Walleij

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=c09970a6-0e6d-c26d-f41e-ab82b4cb8127@st.com \
    --to=patrice.chotard@st.com \
    --cc=alexandre.torgue@st.com \
    --cc=andrea.merello@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=ulf.hansson@linaro.org \
    /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).