diff mbox

[U-Boot,v2,18/20] tegra: i2c: Add function to find DVC bus

Message ID 1326490535-3461-19-git-send-email-sjg@chromium.org
State Superseded, archived
Headers show

Commit Message

Simon Glass Jan. 13, 2012, 9:35 p.m. UTC
Add tegra_i2c_get_dvc_bus_num() to obtain the I2C bus number of DVC bus.
This allows us to talk to the PMU.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Add patch to find DVC bus number

 arch/arm/include/asm/arch-tegra2/tegra2_i2c.h |    7 +++++++
 drivers/i2c/tegra2_i2c.c                      |   14 ++++++++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)

Comments

Heiko Schocher Jan. 15, 2012, 7:28 a.m. UTC | #1
Hello Simon,

Simon Glass wrote:
> Add tegra_i2c_get_dvc_bus_num() to obtain the I2C bus number of DVC bus.
> This allows us to talk to the PMU.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> Changes in v2:
> - Add patch to find DVC bus number
> 
>  arch/arm/include/asm/arch-tegra2/tegra2_i2c.h |    7 +++++++
>  drivers/i2c/tegra2_i2c.c                      |   14 ++++++++++++++
>  2 files changed, 21 insertions(+), 0 deletions(-)

just one minor comment, beside of this:

Acked-by: Heiko Schocher <hs@denx.de>

> diff --git a/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h b/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
> index 86f6a01..4816cc7 100644
> --- a/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
> +++ b/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
> @@ -157,4 +157,11 @@ struct i2c_ctlr {
>  #define I2C_INT_ARBITRATION_LOST_SHIFT	2
>  #define I2C_INT_ARBITRATION_LOST_MASK	(1 << I2C_INT_ARBITRATION_LOST_SHIFT)
>  
> +/**

wrong comment style ...

bye,
Heiko
Simon Glass Feb. 3, 2012, 11:29 p.m. UTC | #2
Hi Heiko,

On Jan 14, 2012 11:28 PM, "Heiko Schocher" <hs@denx.de> wrote:
>
> Hello Simon,
>
> Simon Glass wrote:
> > Add tegra_i2c_get_dvc_bus_num() to obtain the I2C bus number of DVC bus.
> > This allows us to talk to the PMU.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> > Changes in v2:
> > - Add patch to find DVC bus number
> >
> >  arch/arm/include/asm/arch-tegra2/tegra2_i2c.h |    7 +++++++
> >  drivers/i2c/tegra2_i2c.c                      |   14 ++++++++++++++
> >  2 files changed, 21 insertions(+), 0 deletions(-)
>
> just one minor comment, beside of this:
>
> Acked-by: Heiko Schocher <hs@denx.de>
>
> > diff --git a/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
b/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
> > index 86f6a01..4816cc7 100644
> > --- a/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
> > +++ b/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
> > @@ -157,4 +157,11 @@ struct i2c_ctlr {
> >  #define I2C_INT_ARBITRATION_LOST_SHIFT       2
> >  #define I2C_INT_ARBITRATION_LOST_MASK        (1 <<
I2C_INT_ARBITRATION_LOST_SHIFT)
> >
> > +/**
>
> wrong comment style ...

I am trying to follow the Doxygen convention. Many editors like this also
and display the parameters etc. nicely highlighted. Does yours? Hoping it
encourages more function prototype comments in U-Boot and reduce the time I
need to spend wading through code to see what a function is supposed to do.

regards,
Simon

>
> bye,
> Heiko
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Heiko Schocher Feb. 6, 2012, 7:11 a.m. UTC | #3
Hello Simon,

Simon Glass wrote:
> Hi Heiko,
> 
> On Jan 14, 2012 11:28 PM, "Heiko Schocher" <hs@denx.de> wrote:
>> Hello Simon,
>>
>> Simon Glass wrote:
>>> Add tegra_i2c_get_dvc_bus_num() to obtain the I2C bus number of DVC bus.
>>> This allows us to talk to the PMU.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>> Changes in v2:
>>> - Add patch to find DVC bus number
>>>
>>>  arch/arm/include/asm/arch-tegra2/tegra2_i2c.h |    7 +++++++
>>>  drivers/i2c/tegra2_i2c.c                      |   14 ++++++++++++++
>>>  2 files changed, 21 insertions(+), 0 deletions(-)
>> just one minor comment, beside of this:
>>
>> Acked-by: Heiko Schocher <hs@denx.de>
>>
>>> diff --git a/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
> b/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
>>> index 86f6a01..4816cc7 100644
>>> --- a/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
>>> +++ b/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
>>> @@ -157,4 +157,11 @@ struct i2c_ctlr {
>>>  #define I2C_INT_ARBITRATION_LOST_SHIFT       2
>>>  #define I2C_INT_ARBITRATION_LOST_MASK        (1 <<
> I2C_INT_ARBITRATION_LOST_SHIFT)
>>> +/**
>> wrong comment style ...
> 
> I am trying to follow the Doxygen convention. Many editors like this also
> and display the parameters etc. nicely highlighted. Does yours? Hoping it
> encourages more function prototype comments in U-Boot and reduce the time I
> need to spend wading through code to see what a function is supposed to do.

added Wolfgang to cc:

Do we want to accept this? If so, it must be documented somewhere!

bye,
Heiko
diff mbox

Patch

diff --git a/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h b/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
index 86f6a01..4816cc7 100644
--- a/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
+++ b/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
@@ -157,4 +157,11 @@  struct i2c_ctlr {
 #define I2C_INT_ARBITRATION_LOST_SHIFT	2
 #define I2C_INT_ARBITRATION_LOST_MASK	(1 << I2C_INT_ARBITRATION_LOST_SHIFT)
 
+/**
+ * Returns the bus number of the DVC controller
+ *
+ * @return number of bus, or -1 if there is no DVC active
+ */
+int tegra_i2c_get_dvc_bus_num(void);
+
 #endif
diff --git a/drivers/i2c/tegra2_i2c.c b/drivers/i2c/tegra2_i2c.c
index b57a050..b42d9ac 100644
--- a/drivers/i2c/tegra2_i2c.c
+++ b/drivers/i2c/tegra2_i2c.c
@@ -549,3 +549,17 @@  int i2c_set_bus_num(unsigned int bus)
 	return 0;
 }
 #endif
+
+int tegra_i2c_get_dvc_bus_num(void)
+{
+	int i;
+
+	for (i = 0; i < CONFIG_SYS_MAX_I2C_BUS; i++) {
+		struct i2c_bus *bus = &i2c_controllers[i];
+
+		if (bus->inited && bus->is_dvc)
+			return i;
+	}
+
+	return -1;
+}