diff mbox series

[v2,3/7] soc/tegra: pmc: Implement tegra_io_pad_is_powered()

Message ID 1531317693-3520-4-git-send-email-avienamo@nvidia.com
State Superseded
Headers show
Series Tegra PMC pinctrl pad configuration | expand

Commit Message

Aapo Vienamo July 11, 2018, 2:01 p.m. UTC
Implement a function to query whether a pad is in deep power down mode.

Signed-off-by: Aapo Vienamo <avienamo@nvidia.com>
Acked-by: Jon Hunter <jonathanh@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, 3:23 p.m. UTC | #1
On 11/07/18 15:01, Aapo Vienamo wrote:
> Implement a function to query whether a pad is in deep power down mode.
Can you elaborate on why this public function is needed and who will be
using this?

Cheers
Jon
Jon Hunter July 11, 2018, 3:26 p.m. UTC | #2
On 11/07/18 16:23, Jon Hunter wrote:
> 
> On 11/07/18 15:01, Aapo Vienamo wrote:
>> Implement a function to query whether a pad is in deep power down mode.
> Can you elaborate on why this public function is needed and who will be
> using this?

Or I should say does this need to be public?

Jon
Aapo Vienamo July 12, 2018, 7:52 a.m. UTC | #3
On Wed, 11 Jul 2018 16:26:42 +0100
Jon Hunter <jonathanh@nvidia.com> wrote:

> On 11/07/18 16:23, Jon Hunter wrote:
> > 
> > On 11/07/18 15:01, Aapo Vienamo wrote:  
> >> Implement a function to query whether a pad is in deep power down mode.  
> > Can you elaborate on why this public function is needed and who will be
> > using this?  
> 
> Or I should say does this need to be public?

It's only called from the pinconf callbacks and exposing it doesn't
indeed make much sense if we intend to replace direct calls to pmc.c
with pinctrl anyway. I'll make it private on the next iteration of the
series.

 -Aapo
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jon Hunter July 12, 2018, 10:10 a.m. UTC | #4
On 12/07/18 08:52, Aapo Vienamo wrote:
> On Wed, 11 Jul 2018 16:26:42 +0100
> Jon Hunter <jonathanh@nvidia.com> wrote:
> 
>> On 11/07/18 16:23, Jon Hunter wrote:
>>>
>>> On 11/07/18 15:01, Aapo Vienamo wrote:  
>>>> Implement a function to query whether a pad is in deep power down mode.  
>>> Can you elaborate on why this public function is needed and who will be
>>> using this?  
>>
>> Or I should say does this need to be public?
> 
> It's only called from the pinconf callbacks and exposing it doesn't
> indeed make much sense if we intend to replace direct calls to pmc.c
> with pinctrl anyway. I'll make it private on the next iteration of the
> series.

Yes let's make it private.

Cheers
Jon
diff mbox series

Patch

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 393ca72..fa47e7a 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 445aa66..14206e8 100644
--- a/include/soc/tegra/pmc.h
+++ b/include/soc/tegra/pmc.h
@@ -163,6 +163,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);