9471b39b3b31f75f3cd2a2321b511b03809589ee
[openwrt/openwrt.git] / package / boot / uboot-sunxi / patches / 012-sun6i-fix-clock_twi_onoff.patch
1 From 730d2f3a41c5ccae71b5008fffdf697d143be68c Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Wed, 16 Mar 2016 20:44:51 +0100
4 Subject: [PATCH] sunxi: Fix clock_twi_onoff for sun6i
5
6 The clock_sun6i.c implementation was not deasserting the reset for
7 the regular i2c controllers, this commit fixes this.
8
9 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
10 Acked-by: Ian Campbell <ijc@hellion.org.uk>
11 ---
12 arch/arm/cpu/armv7/sunxi/clock_sun6i.c | 11 ++++++++---
13 1 file changed, 8 insertions(+), 3 deletions(-)
14
15 diff --git a/arch/arm/cpu/armv7/sunxi/clock_sun6i.c b/arch/arm/cpu/armv7/sunxi/clock_sun6i.c
16 index 700b605..4e1e1a4 100644
17 --- a/arch/arm/cpu/armv7/sunxi/clock_sun6i.c
18 +++ b/arch/arm/cpu/armv7/sunxi/clock_sun6i.c
19 @@ -100,13 +100,18 @@ int clock_twi_onoff(int port, int state)
20 return 0;
21 }
22
23 - /* set the apb clock gate for twi */
24 - if (state)
25 + /* set the apb clock gate and reset for twi */
26 + if (state) {
27 setbits_le32(&ccm->apb2_gate,
28 CLK_GATE_OPEN << (APB2_GATE_TWI_SHIFT+port));
29 - else
30 + setbits_le32(&ccm->apb2_reset_cfg,
31 + 1 << (APB2_RESET_TWI_SHIFT + port));
32 + } else {
33 + clrbits_le32(&ccm->apb2_reset_cfg,
34 + 1 << (APB2_RESET_TWI_SHIFT + port));
35 clrbits_le32(&ccm->apb2_gate,
36 CLK_GATE_OPEN << (APB2_GATE_TWI_SHIFT+port));
37 + }
38
39 return 0;
40 }