[3/6] soc/tegra: pmc: Implement tegra_io_pad_is_powered()

Message ID 1531226879-11802-4-git-send-email-avienamo@nvidia.com
State New
Headers show
Series
  • Tegra PMC pinctrl pad configuration
Related show

Commit Message

Aapo Vienamo July 10, 2018, 12:47 p.m.
Implement a function to query whether a pad is in deep power down mode.

Signed-off-by: Aapo Vienamo <avienamo@nvidia.com>
---
 drivers/soc/tegra/pmc.c | 17 +++++++++++++++++
 include/soc/tegra/pmc.h |  1 +
 2 files changed, 18 insertions(+)

Comments

Jon Hunter July 11, 2018, 8:27 a.m. | #1
On 10/07/18 13:47, Aapo Vienamo wrote:
> Implement a function to query whether a pad is in deep power down mode.
> 
> Signed-off-by: Aapo Vienamo <avienamo@nvidia.com>
> ---
>  drivers/soc/tegra/pmc.c | 17 +++++++++++++++++
>  include/soc/tegra/pmc.h |  1 +
>  2 files changed, 18 insertions(+)
> 
> diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
> index 83b39cd..3f5b69fd 100644
> --- a/drivers/soc/tegra/pmc.c
> +++ b/drivers/soc/tegra/pmc.c
> @@ -1075,6 +1075,23 @@ int tegra_io_pad_power_disable(enum tegra_io_pad id)
>  }
>  EXPORT_SYMBOL(tegra_io_pad_power_disable);
>  
> +int tegra_io_pad_is_powered(enum tegra_io_pad id)
> +{
> +	unsigned long request, status;
> +	u32 mask;
> +	u32 value;

Nit-pick ... could have been on a single line.

> +	int err;
> +
> +	err = tegra_io_pad_get_dpd_register_bit(id, &request, &status, &mask);
> +	if (err)
> +		return err;
> +
> +	value = tegra_pmc_readl(status);
> +
> +	return !(value & mask);
> +}
> +EXPORT_SYMBOL(tegra_io_pad_is_powered);
> +
>  int tegra_io_pad_set_voltage(enum tegra_io_pad id,
>  			     enum tegra_io_pad_voltage voltage)
>  {
> diff --git a/include/soc/tegra/pmc.h b/include/soc/tegra/pmc.h
> index c32bf91..f88c6e2 100644
> --- a/include/soc/tegra/pmc.h
> +++ b/include/soc/tegra/pmc.h
> @@ -162,6 +162,7 @@ int tegra_powergate_sequence_power_up(unsigned int id, struct clk *clk,
>  
>  int tegra_io_pad_power_enable(enum tegra_io_pad id);
>  int tegra_io_pad_power_disable(enum tegra_io_pad id);
> +int tegra_io_pad_is_powered(enum tegra_io_pad id);
>  int tegra_io_pad_set_voltage(enum tegra_io_pad id,
>  			     enum tegra_io_pad_voltage voltage);
>  int tegra_io_pad_get_voltage(enum tegra_io_pad id);
> 

Acked-by: Jon Hunter <jonathanh@nvidia.com>

Cheers
Jon

Patch

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 83b39cd..3f5b69fd 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -1075,6 +1075,23 @@  int tegra_io_pad_power_disable(enum tegra_io_pad id)
 }
 EXPORT_SYMBOL(tegra_io_pad_power_disable);
 
+int tegra_io_pad_is_powered(enum tegra_io_pad id)
+{
+	unsigned long request, status;
+	u32 mask;
+	u32 value;
+	int err;
+
+	err = tegra_io_pad_get_dpd_register_bit(id, &request, &status, &mask);
+	if (err)
+		return err;
+
+	value = tegra_pmc_readl(status);
+
+	return !(value & mask);
+}
+EXPORT_SYMBOL(tegra_io_pad_is_powered);
+
 int tegra_io_pad_set_voltage(enum tegra_io_pad id,
 			     enum tegra_io_pad_voltage voltage)
 {
diff --git a/include/soc/tegra/pmc.h b/include/soc/tegra/pmc.h
index c32bf91..f88c6e2 100644
--- a/include/soc/tegra/pmc.h
+++ b/include/soc/tegra/pmc.h
@@ -162,6 +162,7 @@  int tegra_powergate_sequence_power_up(unsigned int id, struct clk *clk,
 
 int tegra_io_pad_power_enable(enum tegra_io_pad id);
 int tegra_io_pad_power_disable(enum tegra_io_pad id);
+int tegra_io_pad_is_powered(enum tegra_io_pad id);
 int tegra_io_pad_set_voltage(enum tegra_io_pad id,
 			     enum tegra_io_pad_voltage voltage);
 int tegra_io_pad_get_voltage(enum tegra_io_pad id);