[U-Boot] [PATCH 0/2] arm: sunxi: twi: enable clock for sun7i

From: Olliver Schinagl o.schinagl@ultimaker.com
Paul enabled all I2C ports for sunxi but forgot the clock on twi 4 and 5 for sun7i.
And a small non code changing whitespace fix
Tested on Olimex Lime2
Olliver Schinagl (2): sunxi: twi: enable clocks on sun7i sun4i: clock: cleanup some whitespace errors
arch/arm/cpu/armv7/sunxi/clock_sun4i.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)

From: Olliver Schinagl o.schinagl@ultimaker.com
Commit 6c739c5d added code to enable i2c bus 4 and 5 on the sun7i SoC but forgot to enable the clocks for these 2 i2c busses.
This patch enables the clocks for i2c bus 4 and 5 on sun7i.
Signed-off-by: Olliver Schinagl o.schinagl@ultimaker.com --- arch/arm/cpu/armv7/sunxi/clock_sun4i.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c index 7c8eff9..ed910b1 100644 --- a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c +++ b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c @@ -67,7 +67,11 @@ int clock_twi_onoff(int port, int state) struct sunxi_ccm_reg *const ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+#ifdef CONFIG_MACH_SUN7I + if (port > 4) +#else if (port > 2) +#endif return -1;
/* set the apb clock gate for twi */

Hi Oliver,
On Fri, Dec 4, 2015 at 3:49 AM, Olliver Schinagl oliver@schinagl.nl wrote:
From: Olliver Schinagl o.schinagl@ultimaker.com
Commit 6c739c5d added code to enable i2c bus 4 and 5 on the sun7i SoC but forgot to enable the clocks for these 2 i2c busses.
This patch enables the clocks for i2c bus 4 and 5 on sun7i.
Signed-off-by: Olliver Schinagl o.schinagl@ultimaker.com
arch/arm/cpu/armv7/sunxi/clock_sun4i.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c index 7c8eff9..ed910b1 100644 --- a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c +++ b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c @@ -67,7 +67,11 @@ int clock_twi_onoff(int port, int state) struct sunxi_ccm_reg *const ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+#ifdef CONFIG_MACH_SUN7I
if (port > 4)
+#else if (port > 2) +#endif
Should the number here be a #define somewhere, or even a parameter for each version of this clock?
Thanks,

Hi Oliver,
On Fri, Dec 4, 2015 at 9:57 AM, Julian Calaby julian.calaby@gmail.com wrote:
Hi Oliver,
On Fri, Dec 4, 2015 at 3:49 AM, Olliver Schinagl oliver@schinagl.nl wrote:
From: Olliver Schinagl o.schinagl@ultimaker.com
Commit 6c739c5d added code to enable i2c bus 4 and 5 on the sun7i SoC but forgot to enable the clocks for these 2 i2c busses.
This patch enables the clocks for i2c bus 4 and 5 on sun7i.
Signed-off-by: Olliver Schinagl o.schinagl@ultimaker.com
arch/arm/cpu/armv7/sunxi/clock_sun4i.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c index 7c8eff9..ed910b1 100644 --- a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c +++ b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c @@ -67,7 +67,11 @@ int clock_twi_onoff(int port, int state) struct sunxi_ccm_reg *const ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+#ifdef CONFIG_MACH_SUN7I
if (port > 4)
+#else if (port > 2) +#endif
Should the number here be a #define somewhere, or even a parameter for each version of this clock?
Wait, this is a u-boot patch, right? If so, ignore this and sorry for the noise.
Thanks,

Hey Julian
On December 4, 2015 12:01:27 AM CET, Julian Calaby julian.calaby@gmail.com wrote:
Hi Oliver,
On Fri, Dec 4, 2015 at 9:57 AM, Julian Calaby julian.calaby@gmail.com wrote:
Hi Oliver,
On Fri, Dec 4, 2015 at 3:49 AM, Olliver Schinagl oliver@schinagl.nl
wrote:
From: Olliver Schinagl o.schinagl@ultimaker.com
Commit 6c739c5d added code to enable i2c bus 4 and 5 on the sun7i
SoC
but forgot to enable the clocks for these 2 i2c busses.
This patch enables the clocks for i2c bus 4 and 5 on sun7i.
Signed-off-by: Olliver Schinagl o.schinagl@ultimaker.com
arch/arm/cpu/armv7/sunxi/clock_sun4i.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c
b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c
index 7c8eff9..ed910b1 100644 --- a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c +++ b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c @@ -67,7 +67,11 @@ int clock_twi_onoff(int port, int state) struct sunxi_ccm_reg *const ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+#ifdef CONFIG_MACH_SUN7I
if (port > 4)
+#else if (port > 2) +#endif
Should the number here be a #define somewhere, or even a parameter
for
each version of this clock?
Wait, this is a u-boot patch, right? If so, ignore this and sorry for the noise.
It is ;) and whille you are not un-right i dont think u-boot does this via defined variables generally. But I personally do like it better with defines. If there is a v2 I will actually change it :)
Thanks,

Hi,
On 12/03/2015 05:49 PM, Olliver Schinagl wrote:
From: Olliver Schinagl o.schinagl@ultimaker.com
Commit 6c739c5d added code to enable i2c bus 4 and 5 on the sun7i SoC but forgot to enable the clocks for these 2 i2c busses.
This patch enables the clocks for i2c bus 4 and 5 on sun7i.
Signed-off-by: Olliver Schinagl o.schinagl@ultimaker.com
arch/arm/cpu/armv7/sunxi/clock_sun4i.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c index 7c8eff9..ed910b1 100644 --- a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c +++ b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c @@ -67,7 +67,11 @@ int clock_twi_onoff(int port, int state) struct sunxi_ccm_reg *const ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+#ifdef CONFIG_MACH_SUN7I
- if (port > 4)
+#else if (port > 2) +#endif return -1;
/* set the apb clock gate for twi */
The range-check is not needed at all, since clock_twi_onoff only gets called with such high indexes when CONFIG_I2C3_ENABLE / CONFIG_I2C4_ENABLE is set and Kconfig already only allows these on sun6i / sun7i.
So I've applied a modified version of your patch which simply removes the range-check all-together.
Regards,
Hans

From: Olliver Schinagl o.schinagl@ultimaker.com
Add some spaces around operators.
Signed-off-by: Olliver Schinagl o.schinagl@ultimaker.com --- arch/arm/cpu/armv7/sunxi/clock_sun4i.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c index ed910b1..866b2d6 100644 --- a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c +++ b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c @@ -59,7 +59,7 @@ void clock_init_uart(void)
/* open the clock for uart */ setbits_le32(&ccm->apb1_gate, - CLK_GATE_OPEN << (APB1_GATE_UART_SHIFT+CONFIG_CONS_INDEX-1)); + CLK_GATE_OPEN << (APB1_GATE_UART_SHIFT+CONFIG_CONS_INDEX - 1)); }
int clock_twi_onoff(int port, int state) @@ -77,10 +77,10 @@ int clock_twi_onoff(int port, int state) /* set the apb clock gate for twi */ if (state) setbits_le32(&ccm->apb1_gate, - CLK_GATE_OPEN << (APB1_GATE_TWI_SHIFT+port)); + CLK_GATE_OPEN << (APB1_GATE_TWI_SHIFT + port)); else clrbits_le32(&ccm->apb1_gate, - CLK_GATE_OPEN << (APB1_GATE_TWI_SHIFT+port)); + CLK_GATE_OPEN << (APB1_GATE_TWI_SHIFT + port));
return 0; }

Hi,
On 12/03/2015 05:49 PM, Olliver Schinagl wrote:
From: Olliver Schinagl o.schinagl@ultimaker.com
Add some spaces around operators.
Signed-off-by: Olliver Schinagl o.schinagl@ultimaker.com
Thanks, applied.
Regards,
Hans
arch/arm/cpu/armv7/sunxi/clock_sun4i.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c index ed910b1..866b2d6 100644 --- a/arch/arm/cpu/armv7/sunxi/clock_sun4i.c +++ b/arch/arm/cpu/armv7/sunxi/clock_sun4i.c @@ -59,7 +59,7 @@ void clock_init_uart(void)
/* open the clock for uart */ setbits_le32(&ccm->apb1_gate,
CLK_GATE_OPEN << (APB1_GATE_UART_SHIFT+CONFIG_CONS_INDEX-1));
CLK_GATE_OPEN << (APB1_GATE_UART_SHIFT+CONFIG_CONS_INDEX - 1));
}
int clock_twi_onoff(int port, int state)
@@ -77,10 +77,10 @@ int clock_twi_onoff(int port, int state) /* set the apb clock gate for twi */ if (state) setbits_le32(&ccm->apb1_gate,
CLK_GATE_OPEN << (APB1_GATE_TWI_SHIFT+port));
else clrbits_le32(&ccm->apb1_gate,CLK_GATE_OPEN << (APB1_GATE_TWI_SHIFT + port));
CLK_GATE_OPEN << (APB1_GATE_TWI_SHIFT+port));
CLK_GATE_OPEN << (APB1_GATE_TWI_SHIFT + port));
return 0; }
participants (3)
-
Hans de Goede
-
Julian Calaby
-
Olliver Schinagl