public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Petlozu Pravareshwar <petlozup@nvidia.com>
Cc: jonathanh@nvidia.com, p.zabel@pengutronix.de,
	dmitry.osipenko@collabora.com, ulf.hansson@linaro.org,
	kkartik@nvidia.com, cai.huoqing@linux.dev, spatra@nvidia.com,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] soc/tegra: pmc: Add IO Pad table for tegra234
Date: Thu, 18 Aug 2022 17:13:54 +0200	[thread overview]
Message-ID: <Yv5XMt5M7IGm4/Gx@orome> (raw)
In-Reply-To: <20220808201420.3451111-1-petlozup@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 2804 bytes --]

On Mon, Aug 08, 2022 at 08:14:20PM +0000, Petlozu Pravareshwar wrote:
> Add IO PAD table for tegra234 to allow configuring dpd mode
> and switching the pins to 1.8V or 3.3V as needed.
> 
> In tegra234, DPD registers are reorganized such that there is
> a DPD_REQ register and a DPD_STATUS register per pad group.
> This change accordingly updates the PMC driver.
> 
> Signed-off-by: Petlozu Pravareshwar <petlozup@nvidia.com>
> ---
>  drivers/soc/tegra/pmc.c | 109 ++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 105 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
> index 5611d14d3ba2..34d36a28f7d6 100644
> --- a/drivers/soc/tegra/pmc.c
> +++ b/drivers/soc/tegra/pmc.c
> @@ -266,11 +266,22 @@ struct tegra_powergate {
>  	struct reset_control *reset;
>  };
>  
> +enum tegra_dpd_reg {
> +	TEGRA_PMC_IO_INVALID_DPD,
> +	TEGRA_PMC_IO_CSI_DPD,
> +	TEGRA_PMC_IO_DISP_DPD,
> +	TEGRA_PMC_IO_QSPI_DPD,
> +	TEGRA_PMC_IO_UFS_DPD,
> +	TEGRA_PMC_IO_EDP_DPD,
> +	TEGRA_PMC_IO_SDMMC1_HV_DPD,
> +};
> +
>  struct tegra_io_pad_soc {
>  	enum tegra_io_pad id;
>  	unsigned int dpd;
>  	unsigned int voltage;
>  	const char *name;
> +	enum tegra_dpd_reg reg_index;
>  };
>  
>  struct tegra_pmc_regs {
> @@ -284,6 +295,8 @@ struct tegra_pmc_regs {
>  	unsigned int rst_source_mask;
>  	unsigned int rst_level_shift;
>  	unsigned int rst_level_mask;
> +	const unsigned int *reorg_dpd_req;
> +	const unsigned int *reorg_dpd_status;
>  };
>  
>  struct tegra_wake_event {
> @@ -364,6 +377,7 @@ struct tegra_pmc_soc {
>  	bool has_blink_output;
>  	bool has_usb_sleepwalk;
>  	bool supports_core_domain;
> +	bool has_reorg_hw_dpd_reg_impl;
>  };
>  
>  /**
> @@ -1546,6 +1560,14 @@ static int tegra_io_pad_get_dpd_register_bit(struct tegra_pmc *pmc,
>  	if (pad->dpd == UINT_MAX)
>  		return -ENOTSUPP;
>  
> +	if (pmc->soc->has_reorg_hw_dpd_reg_impl) {
> +		*mask = BIT(pad->dpd);
> +		*status = pmc->soc->regs->reorg_dpd_status[pad->reg_index];
> +		*request = pmc->soc->regs->reorg_dpd_req[pad->reg_index];
> +
> +		goto done;
> +	}
> +
>  	*mask = BIT(pad->dpd % 32);
>  
>  	if (pad->dpd < 32) {
> @@ -1556,6 +1578,7 @@ static int tegra_io_pad_get_dpd_register_bit(struct tegra_pmc *pmc,
>  		*request = pmc->soc->regs->dpd2_req;
>  	}
>  
> +done:
>  	return 0;
>  }
>  

All of this looks "bolted on". Can we not instead rework the existing
register definitions to work with the new dpd_status and dpd_request
arrays? It means that we'd probably need a bit of duplication of data
since we would no longer programmatically determine the register offsets
like we used to, but it would save the extra flag and make the code much
more readable, in my opinion.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-08-18 15:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08 20:14 [PATCH v2] soc/tegra: pmc: Add IO Pad table for tegra234 Petlozu Pravareshwar
2022-08-18 15:13 ` Thierry Reding [this message]
2022-08-24 18:21   ` Petlozu Pravareshwar

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=Yv5XMt5M7IGm4/Gx@orome \
    --to=thierry.reding@gmail.com \
    --cc=cai.huoqing@linux.dev \
    --cc=dmitry.osipenko@collabora.com \
    --cc=jonathanh@nvidia.com \
    --cc=kkartik@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=petlozup@nvidia.com \
    --cc=spatra@nvidia.com \
    --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