mbox series

[0/4] address several S32G2/S32G3 SoC based boards particularities

Message ID 20240705134647.3524969-1-ciprianmarian.costea@oss.nxp.com
Headers show
Series address several S32G2/S32G3 SoC based boards particularities | expand

Message

Ciprian Marian Costea July 5, 2024, 1:46 p.m. UTC
This patchset addresses several S32G2/S32G3 SoC based boards
uSDHC controller particularities such as:
- GPIO card detect wake mechanism is not available
- Changing the pinctrl state in suspend routine is not supported

It also fixes a clocking usage issue on 'clk_get_rate',
in case of 'per' clock.

Ciprian Costea (4):
  mmc: sdhci-esdhc-imx: disable card detect wake for S32G based
    platforms
  mmc: sdhci-esdhc-imx: obtain the 'per' clock rate after its enablement
  mmc: sdhci-esdhc-imx: add option to not change pinctrl state in
    suspend
  MAINTAINERS: add 's32@nxp.com' as relevant mailing list for
    'sdhci-esdhc-imx' driver

 MAINTAINERS                        |  1 +
 drivers/mmc/host/sdhci-esdhc-imx.c | 28 ++++++++++++++++++++++------
 2 files changed, 23 insertions(+), 6 deletions(-)

Comments

Bough Chen July 8, 2024, 2:26 a.m. UTC | #1
> -----Original Message-----
> From: Ciprian Marian Costea (OSS) <ciprianmarian.costea@oss.nxp.com>
> Sent: 2024年7月5日 21:47
> To: Bough Chen <haibo.chen@nxp.com>; Adrian Hunter
> <adrian.hunter@intel.com>; Ulf Hansson <ulf.hansson@linaro.org>; Shawn Guo
> <shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>;
> Pengutronix Kernel Team <kernel@pengutronix.de>; Fabio Estevam
> <festevam@gmail.com>
> Cc: linux-kernel@vger.kernel.org; linux-mmc@vger.kernel.org;
> imx@lists.linux.dev; linux-arm-kernel@lists.infradead.org; dl-S32
> <S32@nxp.com>; Ciprian Marian Costea (OSS)
> <ciprianmarian.costea@oss.nxp.com>
> Subject: [PATCH 1/4] mmc: sdhci-esdhc-imx: disable card detect wake for S32G
> based platforms
> 
> In case of S32G based platforms, GPIO CD used for card detect wake mechanism
> is not available.
> 
> For this scenario the newly introduced flag 'ESDHC_FLAG_SKIP_CD_WAKE' is
> used.

From my side,
Reviewed-by: Haibo Chen <haibo.chen@nxp.com>

But better to wait the comments from Adrian and Ulf.

Best Regards
Haibo Chen
> 
> Signed-off-by: Ciprian Costea <ciprianmarian.costea@oss.nxp.com>
> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c
> b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 40a6e2f8145a..21d984a77be8 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -201,6 +201,9 @@
>  /* ERR004536 is not applicable for the IP  */
>  #define ESDHC_FLAG_SKIP_ERR004536	BIT(17)
> 
> +/* The IP does not have GPIO CD wake capabilities */
> +#define ESDHC_FLAG_SKIP_CD_WAKE		BIT(18)
> +
>  enum wp_types {
>  	ESDHC_WP_NONE,		/* no WP, neither controller nor gpio */
>  	ESDHC_WP_CONTROLLER,	/* mmc controller internal WP */
> @@ -298,7 +301,7 @@ static struct esdhc_soc_data usdhc_s32g2_data = {
>  	.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_MAN_TUNING
>  			| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
>  			| ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES
> -			| ESDHC_FLAG_SKIP_ERR004536,
> +			| ESDHC_FLAG_SKIP_ERR004536 |
> ESDHC_FLAG_SKIP_CD_WAKE,
>  };
> 
>  static struct esdhc_soc_data usdhc_imx7ulp_data = { @@ -1726,7 +1729,8
> @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
>  		host->mmc->caps |= MMC_CAP_1_8V_DDR | MMC_CAP_3_3V_DDR;
> 
>  		/* GPIO CD can be set as a wakeup source */
> -		host->mmc->caps |= MMC_CAP_CD_WAKE;
> +		if (!(imx_data->socdata->flags & ESDHC_FLAG_SKIP_CD_WAKE))
> +			host->mmc->caps |= MMC_CAP_CD_WAKE;
> 
>  		if (!(imx_data->socdata->flags & ESDHC_FLAG_HS200))
>  			host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200;
> --
> 2.45.2
Bough Chen July 8, 2024, 2:33 a.m. UTC | #2
> -----Original Message-----
> From: Ciprian Marian Costea (OSS) <ciprianmarian.costea@oss.nxp.com>
> Sent: 2024年7月5日 21:47
> To: Bough Chen <haibo.chen@nxp.com>; Adrian Hunter
> <adrian.hunter@intel.com>; Ulf Hansson <ulf.hansson@linaro.org>; Shawn Guo
> <shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>;
> Pengutronix Kernel Team <kernel@pengutronix.de>; Fabio Estevam
> <festevam@gmail.com>
> Cc: linux-kernel@vger.kernel.org; linux-mmc@vger.kernel.org;
> imx@lists.linux.dev; linux-arm-kernel@lists.infradead.org; dl-S32
> <S32@nxp.com>; Ciprian Marian Costea (OSS)
> <ciprianmarian.costea@oss.nxp.com>
> Subject: [PATCH 3/4] mmc: sdhci-esdhc-imx: add option to not change pinctrl
> state in suspend
> 
> On some boards such as S32G based, changing the pinctrl state in suspend
> routine may not be supported.

If so, why not dop the "sleep" pinctrl in device tree file?

Best Regards
Haibo Chen
> 
> For this scenario the newly introduced flag 'ESDHC_FLAG_SKIP_PINCTRL_SLEEP'
> is used.
> 
> Signed-off-by: Ciprian Costea <ciprianmarian.costea@oss.nxp.com>
> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c
> b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 8f0bc6dca2b0..c3ff7fccd051 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -204,6 +204,9 @@
>  /* The IP does not have GPIO CD wake capabilities */
>  #define ESDHC_FLAG_SKIP_CD_WAKE		BIT(18)
> 
> +/* The IP does not support transition to pinctrl sleep state */ #define
> +ESDHC_FLAG_SKIP_PINCTRL_SLEEP  BIT(19)
> +
>  enum wp_types {
>  	ESDHC_WP_NONE,		/* no WP, neither controller nor gpio */
>  	ESDHC_WP_CONTROLLER,	/* mmc controller internal WP */
> @@ -301,7 +304,8 @@ static struct esdhc_soc_data usdhc_s32g2_data = {
>  	.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_MAN_TUNING
>  			| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
>  			| ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES
> -			| ESDHC_FLAG_SKIP_ERR004536 |
> ESDHC_FLAG_SKIP_CD_WAKE,
> +			| ESDHC_FLAG_SKIP_ERR004536 |
> ESDHC_FLAG_SKIP_CD_WAKE
> +			| ESDHC_FLAG_SKIP_PINCTRL_SLEEP,
>  };
> 
>  static struct esdhc_soc_data usdhc_imx7ulp_data = { @@ -1884,9 +1888,11
> @@ static int sdhci_esdhc_suspend(struct device *dev)
>  	if (ret)
>  		return ret;
> 
> -	ret = pinctrl_pm_select_sleep_state(dev);
> -	if (ret)
> -		return ret;
> +	if (!(imx_data->socdata->flags & ESDHC_FLAG_SKIP_PINCTRL_SLEEP)) {
> +		ret = pinctrl_pm_select_sleep_state(dev);
> +		if (ret)
> +			return ret;
> +	}
> 
>  	ret = mmc_gpio_set_cd_wake(host->mmc, true);
> 
> --
> 2.45.2
Ciprian Marian Costea July 8, 2024, 11:42 a.m. UTC | #3
On 7/8/2024 5:33 AM, Bough Chen wrote:
>> -----Original Message-----
>> From: Ciprian Marian Costea (OSS) <ciprianmarian.costea@oss.nxp.com>
>> Sent: 2024年7月5日 21:47
>> To: Bough Chen <haibo.chen@nxp.com>; Adrian Hunter
>> <adrian.hunter@intel.com>; Ulf Hansson <ulf.hansson@linaro.org>; Shawn Guo
>> <shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>;
>> Pengutronix Kernel Team <kernel@pengutronix.de>; Fabio Estevam
>> <festevam@gmail.com>
>> Cc: linux-kernel@vger.kernel.org; linux-mmc@vger.kernel.org;
>> imx@lists.linux.dev; linux-arm-kernel@lists.infradead.org; dl-S32
>> <S32@nxp.com>; Ciprian Marian Costea (OSS)
>> <ciprianmarian.costea@oss.nxp.com>
>> Subject: [PATCH 3/4] mmc: sdhci-esdhc-imx: add option to not change pinctrl
>> state in suspend
>>
>> On some boards such as S32G based, changing the pinctrl state in suspend
>> routine may not be supported.
> 
> If so, why not dop the "sleep" pinctrl in device tree file?
> 
> Best Regards
> Haibo Chen

Thanks for this suggestion. I verified and pinctrl node is not yet 
upstream'ed for S32G2/S32G3 SoC.
Indeed, 'pinctrl_pm_select_sleep_state' would not report any errors in 
case 'sleep' pinctrl is not defined in the device tree file.
I will drop this commit in version 2 of this patchset.

Best Regards,
Ciprian

>>
>> For this scenario the newly introduced flag 'ESDHC_FLAG_SKIP_PINCTRL_SLEEP'
>> is used.
>>
>> Signed-off-by: Ciprian Costea <ciprianmarian.costea@oss.nxp.com>
>> ---
>>   drivers/mmc/host/sdhci-esdhc-imx.c | 14 ++++++++++----
>>   1 file changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c
>> b/drivers/mmc/host/sdhci-esdhc-imx.c
>> index 8f0bc6dca2b0..c3ff7fccd051 100644
>> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
>> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
>> @@ -204,6 +204,9 @@
>>   /* The IP does not have GPIO CD wake capabilities */
>>   #define ESDHC_FLAG_SKIP_CD_WAKE		BIT(18)
>>
>> +/* The IP does not support transition to pinctrl sleep state */ #define
>> +ESDHC_FLAG_SKIP_PINCTRL_SLEEP  BIT(19)
>> +
>>   enum wp_types {
>>   	ESDHC_WP_NONE,		/* no WP, neither controller nor gpio */
>>   	ESDHC_WP_CONTROLLER,	/* mmc controller internal WP */
>> @@ -301,7 +304,8 @@ static struct esdhc_soc_data usdhc_s32g2_data = {
>>   	.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_MAN_TUNING
>>   			| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
>>   			| ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES
>> -			| ESDHC_FLAG_SKIP_ERR004536 |
>> ESDHC_FLAG_SKIP_CD_WAKE,
>> +			| ESDHC_FLAG_SKIP_ERR004536 |
>> ESDHC_FLAG_SKIP_CD_WAKE
>> +			| ESDHC_FLAG_SKIP_PINCTRL_SLEEP,
>>   };
>>
>>   static struct esdhc_soc_data usdhc_imx7ulp_data = { @@ -1884,9 +1888,11
>> @@ static int sdhci_esdhc_suspend(struct device *dev)
>>   	if (ret)
>>   		return ret;
>>
>> -	ret = pinctrl_pm_select_sleep_state(dev);
>> -	if (ret)
>> -		return ret;
>> +	if (!(imx_data->socdata->flags & ESDHC_FLAG_SKIP_PINCTRL_SLEEP)) {
>> +		ret = pinctrl_pm_select_sleep_state(dev);
>> +		if (ret)
>> +			return ret;
>> +	}
>>
>>   	ret = mmc_gpio_set_cd_wake(host->mmc, true);
>>
>> --
>> 2.45.2
>