Skip to contentSkip to conversation

rockchip: rk3188: fixups and armclk speedup

PATCH New Heiko Stuebner 2 participants 32 messages Mar 20, 2017 – Apr 1, 2017

Subsystems (5)
lore
Share & tools
lore

Heiko Stuebner

author maintainer
#0 lore raw

cover rockchip: rk3188: fixups and armclk speedup

The ARMCLK starts at 24MHz on the rk3188 which makes u-boot startup unnecessary slow. We can easily switch to 600MHz without involving the pmic and thus do this in the SPL to also make the rc4-decoding of the U-Boot image faster.

Some smaller fixes also turned up while adding the ARMCLK-support.

It's currently based on Simon's spl-working branch and Kever's spl_early_init patch, as that includes the last missing rk3188 patches and also keeps uboot starting on rk3188.

Tested on a rk3188 radxarock.

Heiko Stuebner (8):
rockchip: rk3188: sdram: Set correct sdram base
rockchip: rk3188: Decode the actual amount of ram
rockchip: rk3188: Cleanup some SPL/TPL rename leftovers
rockchip: clk: rk3188: Allow configuration of the armclk
rockchip: rk3188: Setup the armclk in spl
rockchip: rk3188: Switch to new i2c IP blocks
rockchip: i2c: Add compatibles for Rockchip Cortex-A9 socs
rockchip: Enable pmic options and act8846 driver on rk3188 rock boards

 arch/arm/include/asm/arch-rockchip/cru_rk3188.h |  1 +
 arch/arm/mach-rockchip/rk3188-board-spl.c       | 45 ++++++++++++++++++
 arch/arm/mach-rockchip/rk3188-board-tpl.c       |  6 +--
 arch/arm/mach-rockchip/rk3188-board.c           | 18 ++++++-
 arch/arm/mach-rockchip/rk3188/sdram_rk3188.c    |  2 +-
 configs/rock_defconfig                          |  4 ++
 drivers/clk/rockchip/clk_rk3188.c               | 63 +++++++++++++++++++++++++
 drivers/i2c/rk_i2c.c                            |  2 +
 8 files changed, 135 insertions(+), 6 deletions(-)
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

PATCH 1/8 rockchip: rk3188: sdram: Set correct sdram base

Right now we're setting the wrong value of 0 as base in the ram_info struct, which is obviously wrong for the rk3188. So instead set the correct value we already have in CONFIG_SYS_SDRAM_BASE.

---
 arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-rockchip/rk3188/sdram_rk3188.c +1 -1
index 461cfcdc83..fea8007265 100644
@@ -955,7 +955,7 @@ static int rk3188_dmc_probe(struct udevice *dev)
 	if (ret)
 		return ret;
 #endif
-	priv->info.base = 0;
+	priv->info.base = CONFIG_SYS_SDRAM_BASE;
 	priv->info.size = sdram_size_mb(priv->pmu) << 20;
 
 	return 0;
Signature · 1 line
2.11.0
#2 lore raw

PATCH 1/8 rockchip: rk3188: sdram: Set correct sdram base

Quoted 8 lines · Heiko Stuebner

Right now we're setting the wrong value of 0 as base in the ram_info struct, which is obviously wrong for the rk3188. So instead set the correct value we already have in CONFIG_SYS_SDRAM_BASE.

---
 arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#3 lore raw

PATCH 1/8 rockchip: rk3188: sdram: Set correct sdram base

Quoted 11 lines · Simon Glass
Quoted 8 lines · Heiko Stuebner

Right now we're setting the wrong value of 0 as base in the ram_info struct, which is obviously wrong for the rk3188. So instead set the correct value we already have in CONFIG_SYS_SDRAM_BASE.

---
 arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-rockchip, thanks!

author maintainer
#4 lore raw

PATCH 2/8 rockchip: rk3188: Decode the actual amount of ram

In reply to Heiko Stuebner

There was still a static ram value set in the rk3188-board from the time where we didn't have actual sdram init code.
Now the sdram init leaves the ram information in SYS_REG2 and we can decode it similarly to the rk3288.

Right now we have two duplicates of that code, which is still ok and doesn't really count as common code yet, but if we get a third copy at some point from a newer soc, we should think about moving that to a more general position.

---
 arch/arm/mach-rockchip/rk3188-board.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/rk3188-board.c +16 -2
index 16f38559af..c370156e4c 100644
@@ -56,8 +56,22 @@ err:
 
 int dram_init(void)
 {
-	/* FIXME: read back ram size from sys_reg2 */
-	gd->ram_size = 0x40000000;
+	struct ram_info ram;
+	struct udevice *dev;
+	int ret;
+
+	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
+	if (ret) {
+		debug("DRAM init failed: %d\n", ret);
+		return ret;
+	}
+	ret = ram_get_info(dev, &ram);
+	if (ret) {
+		debug("Cannot get DRAM size: %d\n", ret);
+		return ret;
+	}
+	debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
+	gd->ram_size = ram.size;
 
 	return 0;
 }
Signature · 1 line
2.11.0
#5 lore raw

PATCH 2/8 rockchip: rk3188: Decode the actual amount of ram

Quoted 10 lines · Heiko Stuebner

There was still a static ram value set in the rk3188-board from the time where we didn't have actual sdram init code.
Now the sdram init leaves the ram information in SYS_REG2 and we can decode it similarly to the rk3288.

Right now we have two duplicates of that code, which is still ok and doesn't really count as common code yet, but if we get a third copy at some point from a newer soc, we should think about moving that to a more general position.

Quoted 4 lines
---
 arch/arm/mach-rockchip/rk3188-board.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
#6 lore raw

PATCH 2/8 rockchip: rk3188: Decode the actual amount of ram

Quoted 11 lines · Simon Glass
Quoted 10 lines · Heiko Stuebner

There was still a static ram value set in the rk3188-board from the time where we didn't have actual sdram init code.
Now the sdram init leaves the ram information in SYS_REG2 and we can decode it similarly to the rk3288.

Right now we have two duplicates of that code, which is still ok and doesn't really count as common code yet, but if we get a third copy at some point from a newer soc, we should think about moving that to a more general position.

Quoted 6 lines
Quoted 4 lines
---
 arch/arm/mach-rockchip/rk3188-board.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

Applied to u-boot-rockchip, thanks!

author maintainer
#7 lore raw

PATCH 3/8 rockchip: rk3188: Cleanup some SPL/TPL rename leftovers

In reply to Heiko Stuebner

In the beginning, we did SPL -> TPL -> U-Boot, but after clarification of the real ordering swapped SPL and TPL.
It seems some renames were forgotten and may confuse future readers, so also swap these to reflect the actual ordering.

---
 arch/arm/mach-rockchip/rk3188-board-tpl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-rockchip/rk3188-board-tpl.c +3 -3
index 442bfe7aa7..b458ef6ea8 100644
@@ -17,7 +17,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static int rk3188_num_entries __attribute__ ((section(".data")));
 
 #define PMU_BASE	0x20004000
-#define TPL_ENTRY	0x10080C00
+#define SPL_ENTRY	0x10080C00
 
 static void jump_to_spl(void)
 {
@@ -25,9 +25,9 @@ static void jump_to_spl(void)
 
 	struct rk3188_pmu * const pmu = (void *)PMU_BASE;
 	image_entry_noargs_t tpl_entry =
-		(image_entry_noargs_t)(unsigned long)TPL_ENTRY;
+		(image_entry_noargs_t)(unsigned long)SPL_ENTRY;
 
-	/* Store the SAVE_SP_ADDR in a location shared with TPL. */
+	/* Store the SAVE_SP_ADDR in a location shared with SPL. */
 	writel(SAVE_SP_ADDR, &pmu->sys_reg[2]);
 	tpl_entry();
 }
Signature · 1 line
2.11.0
#8 lore raw

PATCH 3/8 rockchip: rk3188: Cleanup some SPL/TPL rename leftovers

Quoted 9 lines · Heiko Stuebner

In the beginning, we did SPL -> TPL -> U-Boot, but after clarification of the real ordering swapped SPL and TPL.
It seems some renames were forgotten and may confuse future readers, so also swap these to reflect the actual ordering.

---
 arch/arm/mach-rockchip/rk3188-board-tpl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
#9 lore raw

PATCH 3/8 rockchip: rk3188: Cleanup some SPL/TPL rename leftovers

Quoted 6 lines · Simon Glass
Quoted 5 lines · Heiko Stuebner

In the beginning, we did SPL -> TPL -> U-Boot, but after clarification of the real ordering swapped SPL and TPL.
It seems some renames were forgotten and may confuse future readers, so also swap these to reflect the actual ordering.

Quoted 6 lines
Quoted 4 lines
---
 arch/arm/mach-rockchip/rk3188-board-tpl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Applied to u-boot-rockchip, thanks!

author maintainer
#10 lore raw

PATCH 4/8 rockchip: clk: rk3188: Allow configuration of the armclk

In reply to Heiko Stuebner

The armclk starts in slow mode (24MHz) on the rk3188, which makes the whole startup take a lot of time. We therefore want to at least move to the safe 600MHz value we can use with default pmic settings.
This is also the freqency the proprietary sdram-init leaves the cpu at.

For boards that have pmic control later in u-boot, we also add the option to set the maximum frequency of 1.6GHz, if they so desire.

---
 arch/arm/include/asm/arch-rockchip/cru_rk3188.h |  1 +
 drivers/clk/rockchip/clk_rk3188.c               | 63 +++++++++++++++++++++++++
 2 files changed, 64 insertions(+)
arch/arm/include/asm/arch-rockchip/cru_rk3188.h +1 -0
index 74f0fedcc6..f5d6420d04 100644
@@ -9,6 +9,7 @@
 #define OSC_HZ		(24 * 1000 * 1000)
 
 #define APLL_HZ		(1608 * 1000000)
+#define APLL_SAFE_HZ	(600 * 1000000)
 #define GPLL_HZ		(594 * 1000000)
 #define CPLL_HZ		(384 * 1000000)
 
drivers/clk/rockchip/clk_rk3188.c +63 -0

75 lines not on this page · raw message

Signature · 1 line
2.11.0
#11 lore raw

PATCH 4/8 rockchip: clk: rk3188: Allow configuration of the armclk

Quoted 5 lines · Heiko Stuebner

The armclk starts in slow mode (24MHz) on the rk3188, which makes the whole startup take a lot of time. We therefore want to at least move to the safe 600MHz value we can use with default pmic settings.
This is also the freqency the proprietary sdram-init leaves the cpu at.

Quoted 8 lines

For boards that have pmic control later in u-boot, we also add the option to set the maximum frequency of 1.6GHz, if they so desire.

---
 arch/arm/include/asm/arch-rockchip/cru_rk3188.h |  1 +
 drivers/clk/rockchip/clk_rk3188.c               | 63 +++++++++++++++++++++++++
 2 files changed, 64 insertions(+)
#12 lore raw

PATCH 4/8 rockchip: clk: rk3188: Allow configuration of the armclk

Quoted 9 lines · Simon Glass
Quoted 8 lines · Heiko Stuebner

The armclk starts in slow mode (24MHz) on the rk3188, which makes the whole startup take a lot of time. We therefore want to at least move to the safe 600MHz value we can use with default pmic settings.
This is also the freqency the proprietary sdram-init leaves the cpu at.

For boards that have pmic control later in u-boot, we also add the option to set the maximum frequency of 1.6GHz, if they so desire.

Quoted 7 lines
Quoted 5 lines
---
 arch/arm/include/asm/arch-rockchip/cru_rk3188.h |  1 +
 drivers/clk/rockchip/clk_rk3188.c               | 63 +++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

Applied to u-boot-rockchip, thanks!

author maintainer
#13 lore raw

PATCH 5/8 rockchip: rk3188: Setup the armclk in spl

In reply to Heiko Stuebner

The armclk starts in slow mode (24MHz) on the rk3188, which results in U-Boot startup taking a lot of time (U-Boot itself, but also the rc4 decoding done in the bootrom).

With default pmic settings we can always reach a safe frequency of 600MHz which is also the frequency the proprietary loader left the armclk at, without needing access to the systems pmic.

---
 arch/arm/mach-rockchip/rk3188-board-spl.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
arch/arm/mach-rockchip/rk3188-board-spl.c +24 -0
index af4623fdb0..affd959f86 100644
@@ -4,6 +4,7 @@
  * SPDX-License-Identifier:     GPL-2.0+
  */
 
+#include <clk.h>
 #include <common.h>
 #include <debug_uart.h>
 #include <dm.h>
@@ -76,6 +77,27 @@ u32 spl_boot_mode(const u32 boot_device)
 	return MMCSD_MODE_RAW;
 }
 
+static int setup_arm_clock(void)
+{
+	struct udevice *dev;
+	struct clk clk;
+	int ret;
+
+	ret = rockchip_get_clk(&dev);
+	if (ret)
+		return ret;
+
+	clk.id = CLK_ARM;
+	ret = clk_request(dev, &clk);
+	if (ret < 0)
+		return ret;
+
+	ret = clk_set_rate(&clk, 600000000);
+
+	clk_free(&clk);
+	return ret;
+}
+
 void board_init_f(ulong dummy)
 {
 	struct udevice *pinctrl, *dev;
@@ -144,6 +166,8 @@ void board_init_f(ulong dummy)
 		return;
 	}
 
+	setup_arm_clock();
+
 #if defined(CONFIG_ROCKCHIP_SPL_BACK_TO_BROM) && !defined(CONFIG_SPL_BOARD_INIT)
 	back_to_bootrom();
 #endif
Signature · 1 line
2.11.0
#14 lore raw

PATCH 5/8 rockchip: rk3188: Setup the armclk in spl

Quoted 4 lines · Heiko Stuebner

The armclk starts in slow mode (24MHz) on the rk3188, which results in U-Boot startup taking a lot of time (U-Boot itself, but also the rc4 decoding done in the bootrom).

Quoted 8 lines

With default pmic settings we can always reach a safe frequency of 600MHz which is also the frequency the proprietary loader left the armclk at, without needing access to the systems pmic.

---
 arch/arm/mach-rockchip/rk3188-board-spl.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
#15 lore raw

PATCH 5/8 rockchip: rk3188: Setup the armclk in spl

Quoted 9 lines · Simon Glass
Quoted 8 lines · Heiko Stuebner

The armclk starts in slow mode (24MHz) on the rk3188, which results in U-Boot startup taking a lot of time (U-Boot itself, but also the rc4 decoding done in the bootrom).

With default pmic settings we can always reach a safe frequency of 600MHz which is also the frequency the proprietary loader left the armclk at, without needing access to the systems pmic.

Quoted 6 lines
Quoted 4 lines
---
 arch/arm/mach-rockchip/rk3188-board-spl.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Applied to u-boot-rockchip, thanks!

author maintainer
#16 lore raw

PATCH 6/8 rockchip: rk3188: Switch to new i2c IP blocks

In reply to Heiko Stuebner

The rk3066/rk3188 introduced new i2c IP blocks but kept the old ones around just in case. The default also points to these old controllers.

The "new" blocks proved stable and nobody ever used the old ones anywhere, not in the kernel and not in U-Boot, so to be able to reuse the already existing driver make the rk3188 switch to the new ones in U-Boot as well.

---
 arch/arm/mach-rockchip/rk3188-board-spl.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
arch/arm/mach-rockchip/rk3188-board-spl.c +21 -0
index affd959f86..14847a7b1b 100644
@@ -17,6 +17,7 @@
 #include <asm/io.h>
 #include <asm/arch/bootrom.h>
 #include <asm/arch/clock.h>
+#include <asm/arch/grf_rk3188.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/periph.h>
 #include <asm/arch/pmu_rk3188.h>
@@ -102,6 +103,7 @@ void board_init_f(ulong dummy)
 {
 	struct udevice *pinctrl, *dev;
 	struct rk3188_pmu *pmu;
+	struct rk3188_grf *grf;
 	int ret;
 
 	/* Example code showing how to enable the debug UART on RK3188 */
@@ -154,6 +156,25 @@ void board_init_f(ulong dummy)
 		error("pmu syscon returned %ld\n", PTR_ERR(pmu));
 	SAVE_SP_ADDR = readl(&pmu->sys_reg[2]);
 
+	/* init common grf settings */
+	grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+	if (IS_ERR(grf)) {
+		error("grf syscon returned %ld\n", PTR_ERR(grf));
+	} else {
+		/* make i2c controllers use the new IP */
+		rk_clrsetreg(&grf->soc_con1,
+			RKI2C4_SEL_MASK << RKI2C4_SEL_SHIFT |
+			RKI2C3_SEL_MASK << RKI2C3_SEL_SHIFT |
+			RKI2C2_SEL_MASK << RKI2C2_SEL_SHIFT |
+			RKI2C1_SEL_MASK << RKI2C1_SEL_SHIFT |
+			RKI2C0_SEL_MASK << RKI2C0_SEL_SHIFT,
+			RKI2C4_SEL_MASK << RKI2C4_SEL_SHIFT |
+			RKI2C3_SEL_MASK << RKI2C3_SEL_SHIFT |
+			RKI2C2_SEL_MASK << RKI2C2_SEL_SHIFT |
+			RKI2C1_SEL_MASK << RKI2C1_SEL_SHIFT |
+			RKI2C0_SEL_MASK << RKI2C0_SEL_SHIFT);
+	}
+
 	ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
 	if (ret) {
 		debug("Pinctrl init failed: %d\n", ret);
Signature · 1 line
2.11.0
#17 lore raw

PATCH 6/8 rockchip: rk3188: Switch to new i2c IP blocks

Hi Heiko,

Quoted 44 lines · Heiko Stuebner

The rk3066/rk3188 introduced new i2c IP blocks but kept the old ones around just in case. The default also points to these old controllers.

The "new" blocks proved stable and nobody ever used the old ones anywhere, not in the kernel and not in U-Boot, so to be able to reuse the already existing driver make the rk3188 switch to the new ones in U-Boot as well.

---
 arch/arm/mach-rockchip/rk3188-board-spl.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
arch/arm/mach-rockchip/rk3188-board-spl.c +10 -0
index affd959f86..14847a7b1b 100644
@@ -17,6 +17,7 @@
 #include <asm/io.h>
 #include <asm/arch/bootrom.h>
 #include <asm/arch/clock.h>
+#include <asm/arch/grf_rk3188.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/periph.h>
 #include <asm/arch/pmu_rk3188.h>
@@ -102,6 +103,7 @@ void board_init_f(ulong dummy)
 {
        struct udevice *pinctrl, *dev;
        struct rk3188_pmu *pmu;
+       struct rk3188_grf *grf;
        int ret;
 
        /* Example code showing how to enable the debug UART on RK3188 */
@@ -154,6 +156,25 @@ void board_init_f(ulong dummy)
                error("pmu syscon returned %ld\n", PTR_ERR(pmu));
        SAVE_SP_ADDR = readl(&pmu->sys_reg[2]);
 
+       /* init common grf settings */
+       grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+       if (IS_ERR(grf)) {
+               error("grf syscon returned %ld\n", PTR_ERR(grf));
+       } else {
+               /* make i2c controllers use the new IP */
+               rk_clrsetreg(&grf->soc_con1,
+                       RKI2C4_SEL_MASK << RKI2C4_SEL_SHIFT |

arch/arm/mach-rockchip/rk3188-board-spl.c void board_init_f(ulong dummy) · line 176

Quoted 10 lines
arch/arm/mach-rockchip/rk3188-board-spl.c +10 -0
+                       RKI2C3_SEL_MASK << RKI2C3_SEL_SHIFT |
+                       RKI2C2_SEL_MASK << RKI2C2_SEL_SHIFT |
+                       RKI2C1_SEL_MASK << RKI2C1_SEL_SHIFT |
+                       RKI2C0_SEL_MASK << RKI2C0_SEL_SHIFT,
+                       RKI2C4_SEL_MASK << RKI2C4_SEL_SHIFT |
+                       RKI2C3_SEL_MASK << RKI2C3_SEL_SHIFT |
+                       RKI2C2_SEL_MASK << RKI2C2_SEL_SHIFT |
+                       RKI2C1_SEL_MASK << RKI2C1_SEL_SHIFT |
+                       RKI2C0_SEL_MASK << RKI2C0_SEL_SHIFT);
+       }

Can you move this to the pinctrl driver?

Quoted 7 lines
arch/arm/mach-rockchip/rk3188-board-spl.c +1 -1
+
        ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
        if (ret) {
                debug("Pinctrl init failed: %d\n", ret);
--

2.11.0

Regards,
Simon

author maintainer
#18 lore raw

PATCH 6/8 rockchip: rk3188: Switch to new i2c IP blocks

Am Donnerstag, 23. März 2017, 21:28:08 CET schrieb Simon Glass:

Quoted 64 lines

Hi Heiko,

Quoted 61 lines · Heiko Stuebner

The rk3066/rk3188 introduced new i2c IP blocks but kept the old ones around just in case. The default also points to these old controllers.

The "new" blocks proved stable and nobody ever used the old ones anywhere, not in the kernel and not in U-Boot, so to be able to reuse the already existing driver make the rk3188 switch to the new ones in U-Boot as well.

---

 arch/arm/mach-rockchip/rk3188-board-spl.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
(quoted diff) +0 -0

b/arch/arm/mach-rockchip/rk3188-board-spl.c index affd959f86..14847a7b1b 100644

arch/arm/mach-rockchip/rk3188-board-spl.c +1 -0
@@ -17,6 +17,7 @@
 
 #include <asm/io.h>
 #include <asm/arch/bootrom.h>
 #include <asm/arch/clock.h>
 
+#include <asm/arch/grf_rk3188.h>
 

#include <asm/arch/hardware.h>
#include <asm/arch/periph.h>
#include <asm/arch/pmu_rk3188.h>

arch/arm/mach-rockchip/rk3188-board-spl.c +1 -0
@@ -102,6 +103,7 @@ void board_init_f(ulong dummy)
 
 {
 
        struct udevice *pinctrl, *dev;
        struct rk3188_pmu *pmu;
 
+       struct rk3188_grf *grf;
        int ret;
        
        /* Example code showing how to enable the debug UART on RK3188 */
arch/arm/mach-rockchip/rk3188-board-spl.c +12 -0
@@ -154,6 +156,25 @@ void board_init_f(ulong dummy)
 
                error("pmu syscon returned %ld\n", PTR_ERR(pmu));
 
        SAVE_SP_ADDR = readl(&pmu->sys_reg[2]);
 
+       /* init common grf settings */
+       grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+       if (IS_ERR(grf)) {
+               error("grf syscon returned %ld\n", PTR_ERR(grf));
+       } else {
+               /* make i2c controllers use the new IP */
+               rk_clrsetreg(&grf->soc_con1,
+                       RKI2C4_SEL_MASK << RKI2C4_SEL_SHIFT |
+                       RKI2C3_SEL_MASK << RKI2C3_SEL_SHIFT |
+                       RKI2C2_SEL_MASK << RKI2C2_SEL_SHIFT |
+                       RKI2C1_SEL_MASK << RKI2C1_SEL_SHIFT |
+                       RKI2C0_SEL_MASK << RKI2C0_SEL_SHIFT,
Quoted 8 lines

arch/arm/mach-rockchip/rk3188-board-spl.c void board_init_f(ulong dummy) · line 176

Quoted 6 lines
arch/arm/mach-rockchip/rk3188-board-spl.c +6 -0
+                       RKI2C4_SEL_MASK << RKI2C4_SEL_SHIFT |
+                       RKI2C3_SEL_MASK << RKI2C3_SEL_SHIFT |
+                       RKI2C2_SEL_MASK << RKI2C2_SEL_SHIFT |
+                       RKI2C1_SEL_MASK << RKI2C1_SEL_SHIFT |
+                       RKI2C0_SEL_MASK << RKI2C0_SEL_SHIFT);
+       }

Can you move this to the pinctrl driver?

Are you sure that is the right approach?

This setting switches the i2c controller IP block used, while the i2c-pins are not affected by this at all. You could also use the i2c pins with the other i2c controller with the same pinctrl settings, so it feels a tiny bit strange to burden the pinctrl driver with this.

Heiko

#19 lore raw

PATCH 6/8 rockchip: rk3188: Switch to new i2c IP blocks

Hi Heiko,

Quoted 74 lines · Heiko Stübner

Am Donnerstag, 23. März 2017, 21:28:08 CET schrieb Simon Glass:

Quoted 64 lines

Hi Heiko,

Quoted 61 lines · Heiko Stuebner

The rk3066/rk3188 introduced new i2c IP blocks but kept the old ones around just in case. The default also points to these old controllers.

The "new" blocks proved stable and nobody ever used the old ones anywhere, not in the kernel and not in U-Boot, so to be able to reuse the already existing driver make the rk3188 switch to the new ones in U-Boot as well.

---

 arch/arm/mach-rockchip/rk3188-board-spl.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
(quoted diff) +0 -0

b/arch/arm/mach-rockchip/rk3188-board-spl.c index affd959f86..14847a7b1b 100644

arch/arm/mach-rockchip/rk3188-board-spl.c +1 -0
@@ -17,6 +17,7 @@
 
 #include <asm/io.h>
 #include <asm/arch/bootrom.h>
 #include <asm/arch/clock.h>
 
+#include <asm/arch/grf_rk3188.h>
 

#include <asm/arch/hardware.h>
#include <asm/arch/periph.h>
#include <asm/arch/pmu_rk3188.h>

arch/arm/mach-rockchip/rk3188-board-spl.c +1 -0
@@ -102,6 +103,7 @@ void board_init_f(ulong dummy)
 
 {
 
        struct udevice *pinctrl, *dev;
        struct rk3188_pmu *pmu;
 
+       struct rk3188_grf *grf;
        int ret;

        /* Example code showing how to enable the debug UART on RK3188 */
arch/arm/mach-rockchip/rk3188-board-spl.c +12 -0
@@ -154,6 +156,25 @@ void board_init_f(ulong dummy)
 
                error("pmu syscon returned %ld\n", PTR_ERR(pmu));
 
        SAVE_SP_ADDR = readl(&pmu->sys_reg[2]);
 
+       /* init common grf settings */
+       grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+       if (IS_ERR(grf)) {
+               error("grf syscon returned %ld\n", PTR_ERR(grf));
+       } else {
+               /* make i2c controllers use the new IP */
+               rk_clrsetreg(&grf->soc_con1,
+                       RKI2C4_SEL_MASK << RKI2C4_SEL_SHIFT |
+                       RKI2C3_SEL_MASK << RKI2C3_SEL_SHIFT |
+                       RKI2C2_SEL_MASK << RKI2C2_SEL_SHIFT |
+                       RKI2C1_SEL_MASK << RKI2C1_SEL_SHIFT |
+                       RKI2C0_SEL_MASK << RKI2C0_SEL_SHIFT,
Quoted 8 lines

arch/arm/mach-rockchip/rk3188-board-spl.c void board_init_f(ulong dummy) · line 176

Quoted 6 lines
arch/arm/mach-rockchip/rk3188-board-spl.c +6 -0
+                       RKI2C4_SEL_MASK << RKI2C4_SEL_SHIFT |
+                       RKI2C3_SEL_MASK << RKI2C3_SEL_SHIFT |
+                       RKI2C2_SEL_MASK << RKI2C2_SEL_SHIFT |
+                       RKI2C1_SEL_MASK << RKI2C1_SEL_SHIFT |
+                       RKI2C0_SEL_MASK << RKI2C0_SEL_SHIFT);
+       }

Can you move this to the pinctrl driver?

Quoted 6 lines

Are you sure that is the right approach?

This setting switches the i2c controller IP block used, while the i2c-pins are not affected by this at all. You could also use the i2c pins with the other i2c controller with the same pinctrl settings, so it feels a tiny bit strange to burden the pinctrl driver with this.

It still seems like pinctrl to me, in that you are selecting which IP block uses those pins. If you don't want it in pinctrl, perhaps this whole thing should go in the I2C driver?

Regards,
Simon

author maintainer
#20 lore raw

PATCH 6/8 rockchip: rk3188: Switch to new i2c IP blocks

Am Samstag, 25. März 2017, 19:17:33 CEST schrieb Simon Glass:

Quoted 79 lines

Hi Heiko,

Quoted 76 lines · Heiko Stübner

Am Donnerstag, 23. März 2017, 21:28:08 CET schrieb Simon Glass:

Quoted 64 lines

Hi Heiko,

Quoted 61 lines · Heiko Stuebner

The rk3066/rk3188 introduced new i2c IP blocks but kept the old ones around just in case. The default also points to these old controllers.

The "new" blocks proved stable and nobody ever used the old ones anywhere, not in the kernel and not in U-Boot, so to be able to reuse the already existing driver make the rk3188 switch to the new ones in U-Boot as well.

---

 arch/arm/mach-rockchip/rk3188-board-spl.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
(quoted diff) +0 -0

b/arch/arm/mach-rockchip/rk3188-board-spl.c index affd959f86..14847a7b1b 100644

arch/arm/mach-rockchip/rk3188-board-spl.c +1 -0
@@ -17,6 +17,7 @@
 
 #include <asm/io.h>
 #include <asm/arch/bootrom.h>
 #include <asm/arch/clock.h>
 
+#include <asm/arch/grf_rk3188.h>
 

#include <asm/arch/hardware.h>
#include <asm/arch/periph.h>
#include <asm/arch/pmu_rk3188.h>

arch/arm/mach-rockchip/rk3188-board-spl.c +1 -0
@@ -102,6 +103,7 @@ void board_init_f(ulong dummy)
 
 {
 
        struct udevice *pinctrl, *dev;
        struct rk3188_pmu *pmu;
 
+       struct rk3188_grf *grf;
        int ret;

        /* Example code showing how to enable the debug UART on RK3188 */
arch/arm/mach-rockchip/rk3188-board-spl.c +12 -0
@@ -154,6 +156,25 @@ void board_init_f(ulong dummy)
 
                error("pmu syscon returned %ld\n", PTR_ERR(pmu));
 
        SAVE_SP_ADDR = readl(&pmu->sys_reg[2]);
 
+       /* init common grf settings */
+       grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+       if (IS_ERR(grf)) {
+               error("grf syscon returned %ld\n", PTR_ERR(grf));
+       } else {
+               /* make i2c controllers use the new IP */
+               rk_clrsetreg(&grf->soc_con1,
+                       RKI2C4_SEL_MASK << RKI2C4_SEL_SHIFT |
+                       RKI2C3_SEL_MASK << RKI2C3_SEL_SHIFT |
+                       RKI2C2_SEL_MASK << RKI2C2_SEL_SHIFT |
+                       RKI2C1_SEL_MASK << RKI2C1_SEL_SHIFT |
+                       RKI2C0_SEL_MASK << RKI2C0_SEL_SHIFT,
Quoted 8 lines

arch/arm/mach-rockchip/rk3188-board-spl.c void board_init_f(ulong dummy) · line 176

Quoted 6 lines
arch/arm/mach-rockchip/rk3188-board-spl.c +6 -0
+                       RKI2C4_SEL_MASK << RKI2C4_SEL_SHIFT |
+                       RKI2C3_SEL_MASK << RKI2C3_SEL_SHIFT |
+                       RKI2C2_SEL_MASK << RKI2C2_SEL_SHIFT |
+                       RKI2C1_SEL_MASK << RKI2C1_SEL_SHIFT |
+                       RKI2C0_SEL_MASK << RKI2C0_SEL_SHIFT);
+       }

Can you move this to the pinctrl driver?

Are you sure that is the right approach?

Quoted 8 lines
Quoted 4 lines

This setting switches the i2c controller IP block used, while the i2c-pins are not affected by this at all. You could also use the i2c pins with the other i2c controller with the same pinctrl settings, so it feels a tiny bit strange to burden the pinctrl driver with this.

It still seems like pinctrl to me, in that you are selecting which IP block uses those pins. If you don't want it in pinctrl, perhaps this whole thing should go in the I2C driver?

no pinctrl is fine, and funnily enough, when I tried moving that there, I realized that the pinctrl driver had the switch to the new controller right from the beginning and I just had forgotten about it :-S, see the

	/* enable new i2c controller */
	rk_clrsetreg(&grf->soc_con1, 1 << RKI2C0_SEL_SHIFT,
				     1 << RKI2C0_SEL_SHIFT);

parts in pinctrl_rk3188.c .

So it looks like we can just drop this patch altogether :-) .

Heiko

#21 lore raw

PATCH 6/8 rockchip: rk3188: Switch to new i2c IP blocks

Quoted 93 lines · Heiko Stuebner

Am Samstag, 25. März 2017, 19:17:33 CEST schrieb Simon Glass:

Quoted 79 lines

Hi Heiko,

Quoted 76 lines · Heiko Stübner

Am Donnerstag, 23. März 2017, 21:28:08 CET schrieb Simon Glass:

Quoted 64 lines

Hi Heiko,

Quoted 61 lines · Heiko Stuebner

The rk3066/rk3188 introduced new i2c IP blocks but kept the old ones around just in case. The default also points to these old controllers.

The "new" blocks proved stable and nobody ever used the old ones anywhere, not in the kernel and not in U-Boot, so to be able to reuse the already existing driver make the rk3188 switch to the new ones in U-Boot as well.

---

 arch/arm/mach-rockchip/rk3188-board-spl.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
(quoted diff) +0 -0

b/arch/arm/mach-rockchip/rk3188-board-spl.c index affd959f86..14847a7b1b 100644

arch/arm/mach-rockchip/rk3188-board-spl.c +1 -0
@@ -17,6 +17,7 @@
 
 #include <asm/io.h>
 #include <asm/arch/bootrom.h>
 #include <asm/arch/clock.h>
 
+#include <asm/arch/grf_rk3188.h>
 

#include <asm/arch/hardware.h>
#include <asm/arch/periph.h>
#include <asm/arch/pmu_rk3188.h>

arch/arm/mach-rockchip/rk3188-board-spl.c +1 -0
@@ -102,6 +103,7 @@ void board_init_f(ulong dummy)
 
 {
 
        struct udevice *pinctrl, *dev;
        struct rk3188_pmu *pmu;
 
+       struct rk3188_grf *grf;
        int ret;

        /* Example code showing how to enable the debug UART on RK3188 */
arch/arm/mach-rockchip/rk3188-board-spl.c +12 -0
@@ -154,6 +156,25 @@ void board_init_f(ulong dummy)
 
                error("pmu syscon returned %ld\n", PTR_ERR(pmu));
 
        SAVE_SP_ADDR = readl(&pmu->sys_reg[2]);
 
+       /* init common grf settings */
+       grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+       if (IS_ERR(grf)) {
+               error("grf syscon returned %ld\n", PTR_ERR(grf));
+       } else {
+               /* make i2c controllers use the new IP */
+               rk_clrsetreg(&grf->soc_con1,
+                       RKI2C4_SEL_MASK << RKI2C4_SEL_SHIFT |
+                       RKI2C3_SEL_MASK << RKI2C3_SEL_SHIFT |
+                       RKI2C2_SEL_MASK << RKI2C2_SEL_SHIFT |
+                       RKI2C1_SEL_MASK << RKI2C1_SEL_SHIFT |
+                       RKI2C0_SEL_MASK << RKI2C0_SEL_SHIFT,
Quoted 8 lines

arch/arm/mach-rockchip/rk3188-board-spl.c void board_init_f(ulong dummy) · line 176

Quoted 6 lines
arch/arm/mach-rockchip/rk3188-board-spl.c +6 -0
+                       RKI2C4_SEL_MASK << RKI2C4_SEL_SHIFT |
+                       RKI2C3_SEL_MASK << RKI2C3_SEL_SHIFT |
+                       RKI2C2_SEL_MASK << RKI2C2_SEL_SHIFT |
+                       RKI2C1_SEL_MASK << RKI2C1_SEL_SHIFT |
+                       RKI2C0_SEL_MASK << RKI2C0_SEL_SHIFT);
+       }

Can you move this to the pinctrl driver?

Are you sure that is the right approach?

Quoted 8 lines
Quoted 4 lines

This setting switches the i2c controller IP block used, while the i2c-pins are not affected by this at all. You could also use the i2c pins with the other i2c controller with the same pinctrl settings, so it feels a tiny bit strange to burden the pinctrl driver with this.

It still seems like pinctrl to me, in that you are selecting which IP block uses those pins. If you don't want it in pinctrl, perhaps this whole thing should go in the I2C driver?

no pinctrl is fine, and funnily enough, when I tried moving that there, I realized that the pinctrl driver had the switch to the new controller right from the beginning and I just had forgotten about it :-S, see the

Quoted 7 lines
        /* enable new i2c controller */
        rk_clrsetreg(&grf->soc_con1, 1 << RKI2C0_SEL_SHIFT,
                                     1 << RKI2C0_SEL_SHIFT);

parts in pinctrl_rk3188.c .

So it looks like we can just drop this patch altogether :-) .

OK, nice, thanks!

author maintainer
#22 lore raw

PATCH 7/8 rockchip: i2c: Add compatibles for Rockchip Cortex-A9 socs

In reply to Heiko Stuebner

The Cortex-A9 socs rk3066 and rk3188 share the IP but have their own compatible values, so add them to make the i2c on these platforms accessible.

---
 drivers/i2c/rk_i2c.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i2c/rk_i2c.c +2 -0
index 7c701cbed0..af925cecdb 100644
@@ -380,6 +380,8 @@ static const struct dm_i2c_ops rockchip_i2c_ops = {
 };
 
 static const struct udevice_id rockchip_i2c_ids[] = {
+	{ .compatible = "rockchip,rk3066-i2c" },
+	{ .compatible = "rockchip,rk3188-i2c" },
 	{ .compatible = "rockchip,rk3288-i2c" },
 	{ }
 };
Signature · 1 line
2.11.0
#23 lore raw

PATCH 7/8 rockchip: i2c: Add compatibles for Rockchip Cortex-A9 socs

Quoted 8 lines · Heiko Stuebner

The Cortex-A9 socs rk3066 and rk3188 share the IP but have their own compatible values, so add them to make the i2c on these platforms accessible.

---
 drivers/i2c/rk_i2c.c | 2 ++
 1 file changed, 2 insertions(+)
#24 lore raw

PATCH 7/8 rockchip: i2c: Add compatibles for Rockchip Cortex-A9 socs

Quoted 11 lines · Simon Glass
Quoted 8 lines · Heiko Stuebner

The Cortex-A9 socs rk3066 and rk3188 share the IP but have their own compatible values, so add them to make the i2c on these platforms accessible.

---
 drivers/i2c/rk_i2c.c | 2 ++
 1 file changed, 2 insertions(+)

Applied to u-boot-rockchip, thanks!

author maintainer
#25 lore raw

PATCH 8/8 rockchip: Enable pmic options and act8846 driver on rk3188 rock boards

In reply to Heiko Stuebner

The rock board uses the already existing act8846 as pmic, so enable the driver and needed pmic options for it.

---
 configs/rock_defconfig | 4 ++++
 1 file changed, 4 insertions(+)
configs/rock_defconfig +4 -0
index 86048c8fd7..153ebb5a44 100644
@@ -46,6 +46,10 @@ CONFIG_SYSRESET=y
 CONFIG_PINCTRL=y
 # CONFIG_SPL_PINCTRL_FULL is not set
 CONFIG_ROCKCHIP_RK3188_PINCTRL=y
+CONFIG_DM_PMIC=y
+# CONFIG_SPL_PMIC_CHILDREN is not set
+CONFIG_PMIC_ACT8846=y
+CONFIG_REGULATOR_ACT8846=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_RAM=y
 CONFIG_DEBUG_UART=y
Signature · 1 line
2.11.0
author maintainer
#27 lore raw

PATCH 8/8 rockchip: Enable pmic options and act8846 driver on rk3188 rock boards

Am Donnerstag, 23. März 2017, 21:28:15 CEST schrieb Simon Glass:

Quoted 10 lines · Heiko Stuebner
Quoted 7 lines

The rock board uses the already existing act8846 as pmic, so enable the driver and needed pmic options for it.

---
 configs/rock_defconfig | 4 ++++
 1 file changed, 4 insertions(+)

just as a note, I folded that into the update Rock board patch from just now, as there is no need to have that separately.

Heiko

#28 lore raw

cover rockchip: rk3188: fixups and armclk speedup

In reply to Heiko Stuebner

Hi Heiko,

Quoted 10 lines · Heiko Stuebner

The ARMCLK starts at 24MHz on the rk3188 which makes u-boot startup unnecessary slow. We can easily switch to 600MHz without involving the pmic and thus do this in the SPL to also make the rc4-decoding of the U-Boot image faster.

Some smaller fixes also turned up while adding the ARMCLK-support.

It's currently based on Simon's spl-working branch and Kever's spl_early_init patch, as that includes the last missing rk3188 patches and also keeps uboot starting on rk3188.

This should be in mainline now so can you also please test against that?

Quoted 24 lines

Tested on a rk3188 radxarock.

Heiko Stuebner (8):
rockchip: rk3188: sdram: Set correct sdram base
rockchip: rk3188: Decode the actual amount of ram
rockchip: rk3188: Cleanup some SPL/TPL rename leftovers
rockchip: clk: rk3188: Allow configuration of the armclk
rockchip: rk3188: Setup the armclk in spl
rockchip: rk3188: Switch to new i2c IP blocks
rockchip: i2c: Add compatibles for Rockchip Cortex-A9 socs
rockchip: Enable pmic options and act8846 driver on rk3188 rock boards

 arch/arm/include/asm/arch-rockchip/cru_rk3188.h |  1 +
 arch/arm/mach-rockchip/rk3188-board-spl.c       | 45 ++++++++++++++++++
 arch/arm/mach-rockchip/rk3188-board-tpl.c       |  6 +--
 arch/arm/mach-rockchip/rk3188-board.c           | 18 ++++++-
 arch/arm/mach-rockchip/rk3188/sdram_rk3188.c    |  2 +-
 configs/rock_defconfig                          |  4 ++
 drivers/clk/rockchip/clk_rk3188.c               | 63 +++++++++++++++++++++++++
 drivers/i2c/rk_i2c.c                            |  2 +
 8 files changed, 135 insertions(+), 6 deletions(-)
Quoted 3 lines

--
2.11.0

Regards,
Simon

author maintainer
#29 lore raw

cover rockchip: rk3188: fixups and armclk speedup

Am Donnerstag, 23. März 2017, 21:28:01 CET schrieb Simon Glass:

Quoted 8 lines

Hi Heiko,

Quoted 5 lines · Heiko Stuebner

The ARMCLK starts at 24MHz on the rk3188 which makes u-boot startup unnecessary slow. We can easily switch to 600MHz without involving the pmic and thus do this in the SPL to also make the rc4-decoding of the U-Boot image faster.

Quoted 7 lines
Quoted 5 lines

Some smaller fixes also turned up while adding the ARMCLK-support.

It's currently based on Simon's spl-working branch and Kever's spl_early_init patch, as that includes the last missing rk3188 patches and also keeps uboot starting on rk3188.

This should be in mainline now so can you also please test against that?

yep, all good.

As stated in my fixup series yesterday, this should of course go on top of the final radxarock addition.

Heiko

#30 lore raw

cover rockchip: rk3188: fixups and armclk speedup

Hi Heiko,

Quoted 15 lines · Heiko Stuebner

Am Donnerstag, 23. März 2017, 21:28:01 CET schrieb Simon Glass:

Quoted 14 lines

Hi Heiko,

Quoted 10 lines · Heiko Stuebner

The ARMCLK starts at 24MHz on the rk3188 which makes u-boot startup unnecessary slow. We can easily switch to 600MHz without involving the pmic and thus do this in the SPL to also make the rc4-decoding of the U-Boot image faster.

Some smaller fixes also turned up while adding the ARMCLK-support.

It's currently based on Simon's spl-working branch and Kever's spl_early_init patch, as that includes the last missing rk3188 patches and also keeps uboot starting on rk3188.

Quoted 6 lines
Quoted 1 line

This should be in mainline now so can you also please test against that?

yep, all good.

As stated in my fixup series yesterday, this should of course go on top of the final radxarock addition.

I sent a few patches which get it building for me. Please take a look and see what you think.

Regards,
Simon

author maintainer
#31 lore raw

cover rockchip: rk3188: fixups and armclk speedup

Am Montag, 27. März 2017, 12:36:00 CEST schrieb Simon Glass:

Quoted 20 lines

Hi Heiko,

Quoted 17 lines · Heiko Stuebner

Am Donnerstag, 23. März 2017, 21:28:01 CET schrieb Simon Glass:

Quoted 15 lines

Hi Heiko,

Quoted 10 lines · Heiko Stuebner

The ARMCLK starts at 24MHz on the rk3188 which makes u-boot startup unnecessary slow. We can easily switch to 600MHz without involving the pmic and thus do this in the SPL to also make the rc4-decoding of the U-Boot image faster.

Some smaller fixes also turned up while adding the ARMCLK-support.

It's currently based on Simon's spl-working branch and Kever's spl_early_init patch, as that includes the last missing rk3188 patches and also keeps uboot starting on rk3188.

This should be in mainline now so can you also please test against that?

Quoted 7 lines
Quoted 4 lines

yep, all good.

As stated in my fixup series yesterday, this should of course go on top of the final radxarock addition.

I sent a few patches which get it building for me. Please take a look and see what you think.

Patches 1+2 look very nice, see replies.

I'm not sure about the third patch though, as I don't see it affecting the rock-tpl to much. When looking at the diassembly of the tpl-binary, the only driver-related functions still present there, are serial_post_probe and serial_pre_remove.

Yesterday I was playing around with serial options a bit but trying to disable the default DM_SERIAL seemed to create just more mayhem and would probably need even more header config settings when saving 26 bytes.