Skip to contentSkip to conversation

rockchip: cosmetics, a fix and first steps on the rk3188

PATCH New Heiko Stuebner 3 participants 36 messages Jul 15, 2016 – Jul 20, 2016

Subsystems (6)
lore
Share & tools
lore

Heiko Stuebner

author maintainer
#0 lore raw

cover rockchip: cosmetics, a fix and first steps on the rk3188

I've made some nice progress on using mainline uboot on the rk3188 and would like to dump some first results.

Right now I can use uboot on the rk3188 with the Rockchip binary ddr init, similar to what barebox does and can even netboot a kernel image using a usb ethernet adapter [0] .

While working on this I found quite some cosmetic stuff that shouldn't persist to make extending easier. So while I don't know what the policy is for my standalone pinctrl and clock drivers (without the actual board) at least the cosmetics + fix might get in at least.

[0] https://github.com/mmind/u-boot-rockchip/commits/rk3188-netboot

Heiko Stuebner (9):
cosmetic: rockchip: rk3288: pinctrl: fix config symbol naming
cosmetic: rockchip: rk3036: pinctrl: fix config symbol naming
cosmetic: rockchip: sort socs according to numbers
cosmetic: rockchip: rk3288: rename rkclk_configure_cpu
rockchip: rk3288: fix FREF_MIN_HZ constant
rockchip: rk3188: Add header files for PMU and GRF
rockchip: rk3188: Add pinctrl driver
rockchip: rk3188: Bring in rk3066/rk3188 clock bindings
rockchip: rk3188: Add clock driver

 arch/arm/include/asm/arch-rockchip/clock.h      |   2 +-
 arch/arm/include/asm/arch-rockchip/cru_rk3188.h | 186 +++++++
 arch/arm/include/asm/arch-rockchip/grf_rk3188.h | 589 +++++++++++++++++++++++
 arch/arm/include/asm/arch-rockchip/pmu_rk3188.h |  36 ++
 arch/arm/mach-rockchip/Kconfig                  |  20 +-
 arch/arm/mach-rockchip/Makefile                 |   4 +-
 arch/arm/mach-rockchip/rk3288/sdram_rk3288.c    |   2 +-
 configs/chromebook_jerry_defconfig              |   2 +-
 configs/evb-rk3036_defconfig                    |   2 +-
 configs/firefly-rk3288_defconfig                |   2 +-
 configs/kylin-rk3036_defconfig                  |   2 +-
 configs/rock2_defconfig                         |   2 +-
 configs/sandbox_defconfig                       |   4 +-
 configs/sandbox_noblk_defconfig                 |   4 +-
 drivers/clk/Makefile                            |   1 +
 drivers/clk/clk_rk3188.c                        | 464 ++++++++++++++++++
 drivers/clk/clk_rk3288.c                        |   4 +-
 drivers/pinctrl/Kconfig                         |  23 +-
 drivers/pinctrl/rockchip/Makefile               |   5 +-
 drivers/pinctrl/rockchip/pinctrl_rk3188.c       | 614 ++++++++++++++++++++++++
 include/dt-bindings/clock/rk3066a-cru.h         |  40 ++
 include/dt-bindings/clock/rk3188-cru-common.h   | 256 ++++++++++
 include/dt-bindings/clock/rk3188-cru.h          |  56 +++
 23 files changed, 2286 insertions(+), 34 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3188.h
 create mode 100644 arch/arm/include/asm/arch-rockchip/grf_rk3188.h
 create mode 100644 arch/arm/include/asm/arch-rockchip/pmu_rk3188.h
 create mode 100644 drivers/clk/clk_rk3188.c
 create mode 100644 drivers/pinctrl/rockchip/pinctrl_rk3188.c
 create mode 100644 include/dt-bindings/clock/rk3066a-cru.h
 create mode 100644 include/dt-bindings/clock/rk3188-cru-common.h
 create mode 100644 include/dt-bindings/clock/rk3188-cru.h
Signature · 1 line
2.8.0.rc3
author maintainer
#1 lore raw

PATCH 1/9 cosmetic: rockchip: rk3288: pinctrl: fix config symbol naming

The rk3288 pinctrl is very specific to this soc, so should not hog the generic rockchip naming.

---
 configs/chromebook_jerry_defconfig | 2 +-
 configs/firefly-rk3288_defconfig   | 2 +-
 configs/rock2_defconfig            | 2 +-
 configs/sandbox_defconfig          | 2 +-
 configs/sandbox_noblk_defconfig    | 2 +-
 drivers/pinctrl/Kconfig            | 6 +++---
 drivers/pinctrl/rockchip/Makefile  | 2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)
configs/chromebook_jerry_defconfig +1 -1
index d5bc515..fd5314a 100644
@@ -53,7 +53,7 @@ CONFIG_ROCKCHIP_DWMMC=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 # CONFIG_SPL_PINCTRL_FULL is not set
-CONFIG_ROCKCHIP_PINCTRL=y
+CONFIG_ROCKCHIP_RK3288_PINCTRL=y
 CONFIG_DM_PMIC=y
 # CONFIG_SPL_PMIC_CHILDREN is not set
 CONFIG_PMIC_RK808=y
configs/firefly-rk3288_defconfig +1 -1
index bdafc71..4122000 100644
@@ -46,7 +46,7 @@ CONFIG_ROCKCHIP_DWMMC=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 # CONFIG_SPL_PINCTRL_FULL is not set
-CONFIG_ROCKCHIP_PINCTRL=y
+CONFIG_ROCKCHIP_RK3288_PINCTRL=y
 CONFIG_DM_PMIC=y
 # CONFIG_SPL_PMIC_CHILDREN is not set
 CONFIG_PMIC_ACT8846=y
configs/rock2_defconfig +1 -1
index 3e16b80..3b6d7d9 100644
@@ -44,7 +44,7 @@ CONFIG_ROCKCHIP_DWMMC=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 # CONFIG_SPL_PINCTRL_FULL is not set
-CONFIG_ROCKCHIP_PINCTRL=y
+CONFIG_ROCKCHIP_RK3288_PINCTRL=y
 CONFIG_DM_PMIC=y
 # CONFIG_SPL_PMIC_CHILDREN is not set
 CONFIG_PMIC_ACT8846=y
configs/sandbox_defconfig +1 -1
index 6a1874a..a5bb759 100644
@@ -119,7 +119,7 @@ CONFIG_DM_PCI_COMPAT=y
 CONFIG_PCI_SANDBOX=y
 CONFIG_PINCTRL=y
 CONFIG_PINCONF=y
-CONFIG_ROCKCHIP_PINCTRL=y
+CONFIG_ROCKCHIP_RK3288_PINCTRL=y
 CONFIG_ROCKCHIP_3036_PINCTRL=y
 CONFIG_PINCTRL_SANDBOX=y
 CONFIG_DM_PMIC=y
configs/sandbox_noblk_defconfig +1 -1
index 60c7339..2928da4 100644
@@ -112,7 +112,7 @@ CONFIG_DM_PCI_COMPAT=y
 CONFIG_PCI_SANDBOX=y
 CONFIG_PINCTRL=y
 CONFIG_PINCONF=y
-CONFIG_ROCKCHIP_PINCTRL=y
+CONFIG_ROCKCHIP_RK3288_PINCTRL=y
 CONFIG_ROCKCHIP_3036_PINCTRL=y
 CONFIG_PINCTRL_SANDBOX=y
 CONFIG_DM_PMIC=y
drivers/pinctrl/Kconfig +3 -3
index 1785e3b..85dddd3 100644
@@ -123,12 +123,12 @@ config QCA953X_PINCTRL
 	  both the GPIO definitions and pin control functions for each
 	  available multiplex function.
 
-config ROCKCHIP_PINCTRL
+config ROCKCHIP_RK3288_PINCTRL
 	bool "Rockchip pin control driver"
 	depends on DM
 	help
-	  Support pin multiplexing control on Rockchip SoCs. The driver is
-	  controlled by a device tree node which contains both the GPIO
+	  Support pin multiplexing control on Rockchip rk3288 SoCs. The driver
+	  is controlled by a device tree node which contains both the GPIO
 	  definitions and pin control functions for each available multiplex
 	  function.
 
drivers/pinctrl/rockchip/Makefile +1 -1
index 6fa7d00..6a84961 100644
@@ -5,5 +5,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_ROCKCHIP_PINCTRL) += pinctrl_rk3288.o
+obj-$(CONFIG_ROCKCHIP_RK3288_PINCTRL) += pinctrl_rk3288.o
 obj-$(CONFIG_ROCKCHIP_3036_PINCTRL) += pinctrl_rk3036.o
Signature · 1 line
2.8.0.rc3
#2 lore raw

PATCH 1/9 cosmetic: rockchip: rk3288: pinctrl: fix config symbol naming

Quoted 4 lines · Heiko Stuebner

The rk3288 pinctrl is very specific to this soc, so should not hog the generic rockchip naming.

Quoted 9 lines
---
 configs/chromebook_jerry_defconfig | 2 +-
 configs/firefly-rk3288_defconfig   | 2 +-
 configs/rock2_defconfig            | 2 +-
 configs/sandbox_defconfig          | 2 +-
 configs/sandbox_noblk_defconfig    | 2 +-
 drivers/pinctrl/Kconfig            | 6 +++---
 drivers/pinctrl/rockchip/Makefile  | 2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)
#3 lore raw

PATCH 1/9 cosmetic: rockchip: rk3288: pinctrl: fix config symbol naming

Quoted 15 lines · Simon Glass
Quoted 4 lines · Heiko Stuebner

The rk3288 pinctrl is very specific to this soc, so should not hog the generic rockchip naming.

Quoted 9 lines
---
 configs/chromebook_jerry_defconfig | 2 +-
 configs/firefly-rk3288_defconfig   | 2 +-
 configs/rock2_defconfig            | 2 +-
 configs/sandbox_defconfig          | 2 +-
 configs/sandbox_noblk_defconfig    | 2 +-
 drivers/pinctrl/Kconfig            | 6 +++---
 drivers/pinctrl/rockchip/Makefile  | 2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)
Quoted 1 line

Applied to u-boot-rockchip, thanks!

author maintainer
#4 lore raw

PATCH 2/9 cosmetic: rockchip: rk3036: pinctrl: fix config symbol naming

In reply to Heiko Stuebner

Rockchip socs are always named rkxxxx in all places, as also shown by the naming of the rk3036 pinctrl file itself. Therefore also name the config symbol according to this scheme.

---
 configs/evb-rk3036_defconfig      | 2 +-
 configs/kylin-rk3036_defconfig    | 2 +-
 configs/sandbox_defconfig         | 2 +-
 configs/sandbox_noblk_defconfig   | 2 +-
 drivers/pinctrl/Kconfig           | 2 +-
 drivers/pinctrl/rockchip/Makefile | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
configs/evb-rk3036_defconfig +1 -1
index 9894fff..2d5e5e0 100644
@@ -32,7 +32,7 @@ CONFIG_SYSRESET=y
 CONFIG_DM_MMC=y
 CONFIG_ROCKCHIP_DWMMC=y
 CONFIG_PINCTRL=y
-CONFIG_ROCKCHIP_3036_PINCTRL=y
+CONFIG_ROCKCHIP_RK3036_PINCTRL=y
 CONFIG_RAM=y
 # CONFIG_SPL_SERIAL_PRESENT is not set
 CONFIG_DEBUG_UART=y
configs/kylin-rk3036_defconfig +1 -1
index 0ff6c6b..51196aa 100644
@@ -32,7 +32,7 @@ CONFIG_SYSRESET=y
 CONFIG_DM_MMC=y
 CONFIG_ROCKCHIP_DWMMC=y
 CONFIG_PINCTRL=y
-CONFIG_ROCKCHIP_3036_PINCTRL=y
+CONFIG_ROCKCHIP_RK3036_PINCTRL=y
 CONFIG_RAM=y
 CONFIG_USE_PRIVATE_LIBGCC=y
 CONFIG_CMD_DHRYSTONE=y
configs/sandbox_defconfig +1 -1
index a5bb759..7ea9d31 100644
@@ -120,7 +120,7 @@ CONFIG_PCI_SANDBOX=y
 CONFIG_PINCTRL=y
 CONFIG_PINCONF=y
 CONFIG_ROCKCHIP_RK3288_PINCTRL=y
-CONFIG_ROCKCHIP_3036_PINCTRL=y
+CONFIG_ROCKCHIP_RK3036_PINCTRL=y
 CONFIG_PINCTRL_SANDBOX=y
 CONFIG_DM_PMIC=y
 CONFIG_PMIC_ACT8846=y
configs/sandbox_noblk_defconfig +1 -1
index 2928da4..503845b 100644
@@ -113,7 +113,7 @@ CONFIG_PCI_SANDBOX=y
 CONFIG_PINCTRL=y
 CONFIG_PINCONF=y
 CONFIG_ROCKCHIP_RK3288_PINCTRL=y
-CONFIG_ROCKCHIP_3036_PINCTRL=y
+CONFIG_ROCKCHIP_RK3036_PINCTRL=y
 CONFIG_PINCTRL_SANDBOX=y
 CONFIG_DM_PMIC=y
 CONFIG_PMIC_ACT8846=y
drivers/pinctrl/Kconfig +1 -1
index 85dddd3..951a922 100644
@@ -132,7 +132,7 @@ config ROCKCHIP_RK3288_PINCTRL
 	  definitions and pin control functions for each available multiplex
 	  function.
 
-config ROCKCHIP_3036_PINCTRL
+config ROCKCHIP_RK3036_PINCTRL
 	bool "Rockchip rk3036 pin control driver"
 	depends on DM
 	help
drivers/pinctrl/rockchip/Makefile +1 -1
index 6a84961..0b2e95e 100644
@@ -6,4 +6,4 @@
 #
 
 obj-$(CONFIG_ROCKCHIP_RK3288_PINCTRL) += pinctrl_rk3288.o
-obj-$(CONFIG_ROCKCHIP_3036_PINCTRL) += pinctrl_rk3036.o
+obj-$(CONFIG_ROCKCHIP_RK3036_PINCTRL) += pinctrl_rk3036.o
Signature · 1 line
2.8.0.rc3
#5 lore raw

PATCH 2/9 cosmetic: rockchip: rk3036: pinctrl: fix config symbol naming

Quoted 5 lines · Heiko Stuebner

Rockchip socs are always named rkxxxx in all places, as also shown by the naming of the rk3036 pinctrl file itself. Therefore also name the config symbol according to this scheme.

Quoted 8 lines
---
 configs/evb-rk3036_defconfig      | 2 +-
 configs/kylin-rk3036_defconfig    | 2 +-
 configs/sandbox_defconfig         | 2 +-
 configs/sandbox_noblk_defconfig   | 2 +-
 drivers/pinctrl/Kconfig           | 2 +-
 drivers/pinctrl/rockchip/Makefile | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
#6 lore raw

PATCH 2/9 cosmetic: rockchip: rk3036: pinctrl: fix config symbol naming

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

Rockchip socs are always named rkxxxx in all places, as also shown by the naming of the rk3036 pinctrl file itself. Therefore also name the config symbol according to this scheme.

Quoted 8 lines
---
 configs/evb-rk3036_defconfig      | 2 +-
 configs/kylin-rk3036_defconfig    | 2 +-
 configs/sandbox_defconfig         | 2 +-
 configs/sandbox_noblk_defconfig   | 2 +-
 drivers/pinctrl/Kconfig           | 2 +-
 drivers/pinctrl/rockchip/Makefile | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
Quoted 1 line

Applied to u-boot-rockchip, thanks!

author maintainer
#7 lore raw

PATCH 3/9 cosmetic: rockchip: sort socs according to numbers

In reply to Heiko Stuebner

Having some sort of ordering proofed helpful in a lot of other places already. So for a larger number of rockchip socs it might be helpful as well instead of an ever increasing unsorted list.

---
 arch/arm/mach-rockchip/Kconfig    | 20 ++++++++++----------
 arch/arm/mach-rockchip/Makefile   |  4 ++--
 drivers/pinctrl/Kconfig           | 16 ++++++++--------
 drivers/pinctrl/rockchip/Makefile |  2 +-
 4 files changed, 21 insertions(+), 21 deletions(-)
arch/arm/mach-rockchip/Kconfig +10 -10
index 86b77f8..a3faafe 100644
@@ -1,5 +1,14 @@
 if ARCH_ROCKCHIP
 
+config ROCKCHIP_RK3036
+	bool "Support Rockchip RK3036"
+	select CPU_V7
+	help
+	  The Rockchip RK3036 is a ARM-based SoC with a dual-core Cortex-A7
+	  including NEON and GPU, Mali-400 graphics, several DDR3 options
+	  and video codec support. Peripherals include Gigabit Ethernet,
+	  USB2 host and OTG, SDIO, I2S, UART, SPI, I2C and PWMs.
+
 config ROCKCHIP_RK3288
 	bool "Support Rockchip RK3288"
 	select CPU_V7
@@ -10,15 +19,6 @@ config ROCKCHIP_RK3288
 	  and video codec support. Peripherals include Gigabit Ethernet,
 	  USB2 host and OTG, SDIO, I2S, UART,s, SPI, I2C and PWMs.
 
-config ROCKCHIP_RK3036
-	bool "Support Rockchip RK3036"
-	select CPU_V7
-	help
-	  The Rockchip RK3036 is a ARM-based SoC with a dual-core Cortex-A7
-	  including NEON and GPU, Mali-400 graphics, several DDR3 options
-	  and video codec support. Peripherals include Gigabit Ethernet,
-	  USB2 host and OTG, SDIO, I2S, UART, SPI, I2C and PWMs.
-
 config ROCKCHIP_SPL_BACK_TO_BROM
 	bool "SPL returns to bootrom"
 	default y if ROCKCHIP_RK3036
@@ -27,6 +27,6 @@ config ROCKCHIP_SPL_BACK_TO_BROM
           SPL will return to the boot rom, which will then load the U-Boot
           binary to keep going on.
 
-source "arch/arm/mach-rockchip/rk3288/Kconfig"
 source "arch/arm/mach-rockchip/rk3036/Kconfig"
+source "arch/arm/mach-rockchip/rk3288/Kconfig"
 endif
arch/arm/mach-rockchip/Makefile +2 -2
index 6763af4..722b582 100644
@@ -5,8 +5,8 @@
 #
 
 ifdef CONFIG_SPL_BUILD
-obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-spl.o
 obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
+obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-spl.o
 obj-$(CONFIG_ROCKCHIP_SPL_BACK_TO_BROM) += save_boot_param.o
 else
 obj-$(CONFIG_ROCKCHIP_RK3288) += board.o
@@ -14,5 +14,5 @@ endif
 ifndef CONFIG_ARM64
 obj-y += rk_timer.o
 endif
-obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288/
 obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036/
+obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288/
drivers/pinctrl/Kconfig +8 -8
index 951a922..2972dba 100644
@@ -123,21 +123,21 @@ config QCA953X_PINCTRL
 	  both the GPIO definitions and pin control functions for each
 	  available multiplex function.
 
-config ROCKCHIP_RK3288_PINCTRL
-	bool "Rockchip pin control driver"
+config ROCKCHIP_RK3036_PINCTRL
+	bool "Rockchip rk3036 pin control driver"
 	depends on DM
 	help
-	  Support pin multiplexing control on Rockchip rk3288 SoCs. The driver
-	  is controlled by a device tree node which contains both the GPIO
+	  Support pin multiplexing control on Rockchip rk3036 SoCs. The driver is
+	  controlled by a device tree node which contains both the GPIO
 	  definitions and pin control functions for each available multiplex
 	  function.
 
-config ROCKCHIP_RK3036_PINCTRL
-	bool "Rockchip rk3036 pin control driver"
+config ROCKCHIP_RK3288_PINCTRL
+	bool "Rockchip pin control driver"
 	depends on DM
 	help
-	  Support pin multiplexing control on Rockchip rk3036 SoCs. The driver is
-	  controlled by a device tree node which contains both the GPIO
+	  Support pin multiplexing control on Rockchip rk3288 SoCs. The driver
+	  is controlled by a device tree node which contains both the GPIO
 	  definitions and pin control functions for each available multiplex
 	  function.
 
drivers/pinctrl/rockchip/Makefile +1 -1
index 0b2e95e..64e9587 100644
@@ -5,5 +5,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_ROCKCHIP_RK3288_PINCTRL) += pinctrl_rk3288.o
 obj-$(CONFIG_ROCKCHIP_RK3036_PINCTRL) += pinctrl_rk3036.o
+obj-$(CONFIG_ROCKCHIP_RK3288_PINCTRL) += pinctrl_rk3288.o
Signature · 1 line
2.8.0.rc3
#8 lore raw

PATCH 3/9 cosmetic: rockchip: sort socs according to numbers

Am 16.07.2016 um 00:17 schrieb Heiko Stuebner:

Quoted 1 line

Having some sort of ordering proofed helpful in a lot of other places

"proved"

Quoted 10 lines

already. So for a larger number of rockchip socs it might be helpful as well instead of an ever increasing unsorted list.

---
 arch/arm/mach-rockchip/Kconfig    | 20 ++++++++++----------
 arch/arm/mach-rockchip/Makefile   |  4 ++--
 drivers/pinctrl/Kconfig           | 16 ++++++++--------
 drivers/pinctrl/rockchip/Makefile |  2 +-
 4 files changed, 21 insertions(+), 21 deletions(-)

Makes perfect sense to me,

Thanks,
Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 N?rnberg, Germany
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
#9 lore raw

PATCH 3/9 cosmetic: rockchip: sort socs according to numbers

In reply to Heiko Stuebner
Quoted 11 lines · Heiko Stuebner

Having some sort of ordering proofed helpful in a lot of other places already. So for a larger number of rockchip socs it might be helpful as well instead of an ever increasing unsorted list.

---
 arch/arm/mach-rockchip/Kconfig    | 20 ++++++++++----------
 arch/arm/mach-rockchip/Makefile   |  4 ++--
 drivers/pinctrl/Kconfig           | 16 ++++++++--------
 drivers/pinctrl/rockchip/Makefile |  2 +-
 4 files changed, 21 insertions(+), 21 deletions(-)
#10 lore raw

PATCH 3/9 cosmetic: rockchip: sort socs according to numbers

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

Having some sort of ordering proofed helpful in a lot of other places already. So for a larger number of rockchip socs it might be helpful as well instead of an ever increasing unsorted list.

---
 arch/arm/mach-rockchip/Kconfig    | 20 ++++++++++----------
 arch/arm/mach-rockchip/Makefile   |  4 ++--
 drivers/pinctrl/Kconfig           | 16 ++++++++--------
 drivers/pinctrl/rockchip/Makefile |  2 +-
 4 files changed, 21 insertions(+), 21 deletions(-)
Quoted 1 line

Applied to u-boot-rockchip, thanks!

author maintainer
#11 lore raw

PATCH 4/9 cosmetic: rockchip: rk3288: rename rkclk_configure_cpu

In reply to Heiko Stuebner

The function is very specific to the rk3288 in its arguments referencing the rk3288 cru and grf and every other rockchip soc has differing cru and grf registers. So make that function naming explicit.

---
 arch/arm/include/asm/arch-rockchip/clock.h   | 2 +-
 arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 2 +-
 drivers/clk/clk_rk3288.c                     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-rockchip/clock.h +1 -1
index 317e512..4bebd62 100644
@@ -65,6 +65,6 @@ void *rockchip_get_cru(void);
 struct rk3288_cru;
 struct rk3288_grf;
 
-void rkclk_configure_cpu(struct rk3288_cru *cru, struct rk3288_grf *grf);
+void rk3288_clk_configure_cpu(struct rk3288_cru *cru, struct rk3288_grf *grf);
 
 #endif
arch/arm/mach-rockchip/rk3288/sdram_rk3288.c +1 -1
index b36b6af..fc0f2f3 100644
@@ -784,7 +784,7 @@ static int veyron_init(struct dram_info *priv)
 		return ret;
 	udelay(100);/* Must wait for voltage to stabilize, 2mV/us */
 
-	rkclk_configure_cpu(priv->cru, priv->grf);
+	rk3288_clk_configure_cpu(priv->cru, priv->grf);
 
 	return 0;
 }
drivers/clk/clk_rk3288.c +1 -1
index 679f010..dece4bc 100644
@@ -447,7 +447,7 @@ static void rkclk_init(struct rk3288_cru *cru, struct rk3288_grf *grf)
 }
 #endif
 
-void rkclk_configure_cpu(struct rk3288_cru *cru, struct rk3288_grf *grf)
+void rk3288_clk_configure_cpu(struct rk3288_cru *cru, struct rk3288_grf *grf)
 {
 	/* pll enter slow-mode */
 	rk_clrsetreg(&cru->cru_mode_con,
Signature · 1 line
2.8.0.rc3
#12 lore raw

PATCH 4/9 cosmetic: rockchip: rk3288: rename rkclk_configure_cpu

Quoted 11 lines · Heiko Stuebner

The function is very specific to the rk3288 in its arguments referencing the rk3288 cru and grf and every other rockchip soc has differing cru and grf registers. So make that function naming explicit.

---
 arch/arm/include/asm/arch-rockchip/clock.h   | 2 +-
 arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 2 +-
 drivers/clk/clk_rk3288.c                     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
#13 lore raw

PATCH 4/9 cosmetic: rockchip: rk3288: rename rkclk_configure_cpu

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

The function is very specific to the rk3288 in its arguments referencing the rk3288 cru and grf and every other rockchip soc has differing cru and grf registers. So make that function naming explicit.

Quoted 8 lines
Quoted 6 lines
---
 arch/arm/include/asm/arch-rockchip/clock.h   | 2 +-
 arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 2 +-
 drivers/clk/clk_rk3288.c                     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Applied to u-boot-rockchip, thanks!

author maintainer
#14 lore raw

PATCH 5/9 rockchip: rk3288: fix FREF_MIN_HZ constant

In reply to Heiko Stuebner

According to the TRM the minimum FREF frequency is 269kHz not MHz. Adapt the constant accordingly.

---
 drivers/clk/clk_rk3288.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk_rk3288.c +1 -1
index dece4bc..a41cf8b 100644
@@ -47,7 +47,7 @@ enum {
 	OUTPUT_MAX_HZ	= 2200U * 1000000,
 	OUTPUT_MIN_HZ	= 27500000,
 	FREF_MAX_HZ	= 2200U * 1000000,
-	FREF_MIN_HZ	= 269 * 1000000,
+	FREF_MIN_HZ	= 269 * 1000,
 };
 
 enum {
Signature · 1 line
2.8.0.rc3
#16 lore raw

PATCH 5/9 rockchip: rk3288: fix FREF_MIN_HZ constant

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

According to the TRM the minimum FREF frequency is 269kHz not MHz. Adapt the constant accordingly.

---
 drivers/clk/clk_rk3288.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-rockchip, thanks!

author maintainer
#17 lore raw

PATCH 6/9 rockchip: rk3188: Add header files for PMU and GRF

In reply to Heiko Stuebner

PMU is the power management unit and GRF is the general register file. Both are heavily used in U-Boot. Add header files with register definitions.

---
 arch/arm/include/asm/arch-rockchip/grf_rk3188.h | 589 ++++++++++++++++++++++++
 arch/arm/include/asm/arch-rockchip/pmu_rk3188.h |  36 ++
 2 files changed, 625 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/grf_rk3188.h
 create mode 100644 arch/arm/include/asm/arch-rockchip/pmu_rk3188.h
arch/arm/include/asm/arch-rockchip/grf_rk3188.h new file +589 -0
new file mode 100644
index 0000000..1a4f944
@@ -0,0 +1,589 @@
+/*
+ * Copyright (c) 2016 Heiko Stuebner <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#ifndef _ASM_ARCH_GRF_RK3188_H
+#define _ASM_ARCH_GRF_RK3188_H
+
+struct rk3188_grf_gpio_lh {
+	u32 l;
+	u32 h;
+};
+
+struct rk3188_grf {
+	struct rk3188_grf_gpio_lh gpio_dir[4];
+	struct rk3188_grf_gpio_lh gpio_do[4];
+	struct rk3188_grf_gpio_lh gpio_en[4];
+
+	u32 reserved[2];
+	u32 gpio0c_iomux;
+	u32 gpio0d_iomux;
+
+	u32 gpio1a_iomux;
+	u32 gpio1b_iomux;
+	u32 gpio1c_iomux;
+	u32 gpio1d_iomux;
+
+	u32 gpio2a_iomux;
+	u32 gpio2b_iomux;
+	u32 gpio2c_iomux;
+	u32 gpio2d_iomux;
+
+	u32 gpio3a_iomux;
+	u32 gpio3b_iomux;
+	u32 gpio3c_iomux;
+	u32 gpio3d_iomux;
+
+	u32 soc_con0;
+	u32 soc_con1;
+	u32 soc_con2;
+	u32 soc_status0;
+
+	u32 busdmac_con[3];
+	u32 peridmac_con[4];
+
+	u32 cpu_con[6];
+	u32 reserved0[2];
+
+	u32 ddrc_con0;
+	u32 ddrc_stat;
+
+	u32 io_con[5];
+	u32 soc_status1;
+
+	u32 uoc0_con[4];
+	u32 uoc1_con[4];
+	u32 uoc2_con[2];
+	u32 reserved1;
+	u32 uoc3_con[2];
+	u32 hsic_stat;
+	u32 os_reg[8];
+
+	u32 gpio0_p[3];
+	u32 gpio1_p[3][4];
+
+	u32 flash_data_p;
+	u32 flash_cmd_p;
+};
+check_member(rk3188_grf, flash_cmd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EN_MASK	= 1,
+
+	DTO_LB_SHIFT		= 11,
+	DTO_LB_MASK		= 3,
+
+	DTO_TE_SHIFT		= 9,
+	DTO_TE_MASK		= 3,
+
+	DTO_PDR_SHIFT		= 7,
+	DTO_PDR_MASK		= 3,
+
+	DTO_PDD_SHIFT		= 5,
+	DTO_PDD_MASK		= 3,
+
+	DTO_IOM_SHIFT		= 3,
+	DTO_IOM_MASK		= 3,
+
+	DTO_OE_SHIFT		= 1,
+	DTO_OE_MASK		= 3,
+
+	ATO_AE_SHIFT		= 0,
+	ATO_AE_MASK		= 1,
+};
+#endif
arch/arm/include/asm/arch-rockchip/pmu_rk3188.h new file +36 -0
new file mode 100644
index 0000000..d82a678
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 Heiko Stuebner <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _ASM_ARCH_PMU_RK3188_H
+#define _ASM_ARCH_PMU_RK3188_H
+
+struct rk3188_pmu {
+	u32 wakeup_cfg[2];
+	u32 pwrdn_con;
+	u32 pwrdn_st;
+
+	u32 int_con;
+	u32 int_st;
+	u32 misc_con;
+
+	u32 osc_cnt;
+	u32 pll_cnt;
+	u32 pmu_cnt;
+	u32 ddrio_pwron_cnt;
+	u32 wakeup_rst_clr_cnt;
+	u32 scu_pwrdwn_cnt;
+	u32 scu_pwrup_cnt;
+	u32 misc_con1;
+	u32 gpio0_con;
+
+	u32 sys_reg[4];
+	u32 reserved0[4];
+	u32 stop_int_dly;
+	u32 gpio0_p[2];
+};
+check_member(rk3188_pmu, gpio0_p[1], 0x0068);
+
+#endif
Signature · 1 line
2.8.0.rc3
#18 lore raw

PATCH 6/9 rockchip: rk3188: Add header files for PMU and GRF

Hi Heiko,

Quoted 10 lines · Heiko Stuebner

PMU is the power management unit and GRF is the general register file. Both are heavily used in U-Boot. Add header files with register definitions.

---
 arch/arm/include/asm/arch-rockchip/grf_rk3188.h | 589 ++++++++++++++++++++++++
 arch/arm/include/asm/arch-rockchip/pmu_rk3188.h |  36 ++
 2 files changed, 625 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/grf_rk3188.h
 create mode 100644 arch/arm/include/asm/arch-rockchip/pmu_rk3188.h

It's unfortunate that I got the mask value wrong. It should be:

      SW_ADDR16_EN_SHIFT      = 4,
      SW_ADDR16_EN_MASK       = 1 << SW_ADDR16_EN_SHIFT,

since that makes the C code simpler in the common case. It also makes it an actual mask.

- Simon

author maintainer
#19 lore raw

PATCH 7/9 rockchip: rk3188: Add pinctrl driver

In reply to Heiko Stuebner

Add a driver which supports pin multiplexing setup for the most commonly used peripherals.

---
 drivers/pinctrl/Kconfig                   |   9 +
 drivers/pinctrl/rockchip/Makefile         |   1 +
 drivers/pinctrl/rockchip/pinctrl_rk3188.c | 614 ++++++++++++++++++++++++++++++
 3 files changed, 624 insertions(+)
 create mode 100644 drivers/pinctrl/rockchip/pinctrl_rk3188.c
drivers/pinctrl/Kconfig +9 -0
index 2972dba..0d8ee19 100644
@@ -141,6 +141,15 @@ config ROCKCHIP_RK3288_PINCTRL
 	  definitions and pin control functions for each available multiplex
 	  function.
 
+config ROCKCHIP_RK3188_PINCTRL
+	bool "Rockchip pin control driver"
+	depends on DM
+	help
+	  Support pin multiplexing control on Rockchip rk3188 SoCs. The driver
+	  is controlled by a device tree node which contains both the GPIO
+	  definitions and pin control functions for each available multiplex
+	  function.
+
 config PINCTRL_SANDBOX
 	bool "Sandbox pinctrl driver"
 	depends on SANDBOX
drivers/pinctrl/rockchip/Makefile +1 -0
index 64e9587..7768628 100644
@@ -6,4 +6,5 @@
 #
 
 obj-$(CONFIG_ROCKCHIP_RK3036_PINCTRL) += pinctrl_rk3036.o
+obj-$(CONFIG_ROCKCHIP_RK3188_PINCTRL) += pinctrl_rk3188.o
 obj-$(CONFIG_ROCKCHIP_RK3288_PINCTRL) += pinctrl_rk3288.o
drivers/pinctrl/rockchip/pinctrl_rk3188.c new file +613 -0

613 lines not on this page · raw message

Signature · 1 line
2.8.0.rc3
#20 lore raw

PATCH 7/9 rockchip: rk3188: Add pinctrl driver

Hi Heiko,

Quoted 10 lines · Heiko Stuebner

Add a driver which supports pin multiplexing setup for the most commonly used peripherals.

---
 drivers/pinctrl/Kconfig                   |   9 +
 drivers/pinctrl/rockchip/Makefile         |   1 +
 drivers/pinctrl/rockchip/pinctrl_rk3188.c | 614 ++++++++++++++++++++++++++++++
 3 files changed, 624 insertions(+)
 create mode 100644 drivers/pinctrl/rockchip/pinctrl_rk3188.c

But is it possible to use some common code with the rk3288 driver? Things like rk3288_pinctrl_set_pins()?

- Simon

author maintainer
#21 lore raw

PATCH 7/9 rockchip: rk3188: Add pinctrl driver

Hi Simon,

Am Sonntag, 17. Juli 2016, 08:13:51 schrieb Simon Glass:

Quoted 13 lines · Heiko Stuebner
Quoted 11 lines

Add a driver which supports pin multiplexing setup for the most commonly used peripherals.

---

 drivers/pinctrl/Kconfig                   |   9 +
 drivers/pinctrl/rockchip/Makefile         |   1 +
 drivers/pinctrl/rockchip/pinctrl_rk3188.c | 614
 ++++++++++++++++++++++++++++++ 3 files changed, 624 insertions(+)
 create mode 100644 drivers/pinctrl/rockchip/pinctrl_rk3188.c
Quoted 4 lines

But is it possible to use some common code with the rk3288 driver? Things like rk3288_pinctrl_set_pins()?

I don't really think that will fly.

The iomux area always sees a lot of creativity when the GRF gets designed.

For example on the rk3288 you have gpio0 iomux + pull + etc in the pmu and all other banks in the grf. On the rk3188 the iomux is contained completely in the grf but the pull setting of the first _12_ pins are living in the pmu - and even their ordering is inverted - see the whole if(flags) part in the rk3188 pinctrl driver.

The rk3399 introduces even more funny things. So I don't see where we would save without adding all the indirection the linux driver currently has.

Heiko

#22 lore raw

PATCH 7/9 rockchip: rk3188: Add pinctrl driver

Hi Heiko,

Quoted 25 lines · Heiko St?bner

Hi Simon,

Am Sonntag, 17. Juli 2016, 08:13:51 schrieb Simon Glass:

Quoted 13 lines · Heiko Stuebner
Quoted 11 lines

Add a driver which supports pin multiplexing setup for the most commonly used peripherals.

---

 drivers/pinctrl/Kconfig                   |   9 +
 drivers/pinctrl/rockchip/Makefile         |   1 +
 drivers/pinctrl/rockchip/pinctrl_rk3188.c | 614
 ++++++++++++++++++++++++++++++ 3 files changed, 624 insertions(+)
 create mode 100644 drivers/pinctrl/rockchip/pinctrl_rk3188.c
Quoted 4 lines

But is it possible to use some common code with the rk3288 driver? Things like rk3288_pinctrl_set_pins()?

I don't really think that will fly.

The iomux area always sees a lot of creativity when the GRF gets designed.

Quoted 8 lines

For example on the rk3288 you have gpio0 iomux + pull + etc in the pmu and all other banks in the grf. On the rk3188 the iomux is contained completely in the grf but the pull setting of the first _12_ pins are living in the pmu - and even their ordering is inverted - see the whole if(flags) part in the rk3188 pinctrl driver.

The rk3399 introduces even more funny things. So I don't see where we would save without adding all the indirection the linux driver currently has.

That's fine, thanks for the info.

Regards,
Simon

author maintainer
#23 lore raw

PATCH 8/9 rockchip: rk3188: Bring in rk3066/rk3188 clock bindings

In reply to Heiko Stuebner

Bring in required device clock binding files from Linux.
The clock trees for rk3066 and rk3188 are largely similar, which makes them share the common parts in a shared header. While we focus on rk3188 for now, bring in both headers already for completeness sake.

---
 include/dt-bindings/clock/rk3066a-cru.h       |  40 ++++
 include/dt-bindings/clock/rk3188-cru-common.h | 256 ++++++++++++++++++++++++++
 include/dt-bindings/clock/rk3188-cru.h        |  56 ++++++
 3 files changed, 352 insertions(+)
 create mode 100644 include/dt-bindings/clock/rk3066a-cru.h
 create mode 100644 include/dt-bindings/clock/rk3188-cru-common.h
 create mode 100644 include/dt-bindings/clock/rk3188-cru.h
include/dt-bindings/clock/rk3066a-cru.h new file +40 -0
new file mode 100644
index 0000000..d3a9824
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014 MundoReader S.L.
+ * Author: Heiko Stuebner <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _DT_BINDINGS_CLK_ROCKCHIP_RK3066A_H
+#define _DT_BINDINGS_CLK_ROCKCHIP_RK3066A_H
+
+#include <dt-bindings/clock/rk3188-cru-common.h>
+
+/* soft-reset indices */
+#define SRST_SRST1		0
+#define SRST_SRST2		1
+
+#define SRST_L2MEM		18
+#define SRST_I2S0		23
+#define SRST_I2S1		24
+#define SRST_I2S2		25
+#define SRST_TIMER2		29
+
+#define SRST_GPIO4		36
+#define SRST_GPIO6		38
+
+#define SRST_TSADC		92
+
+#define SRST_HDMI		96
+#define SRST_HDMI_APB		97
+#define SRST_CIF1		111
+
+#endif
include/dt-bindings/clock/rk3188-cru-common.h new file +256 -0

256 lines not on this page · raw message

include/dt-bindings/clock/rk3188-cru.h new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
2.8.0.rc3
#24 lore raw

PATCH 8/9 rockchip: rk3188: Bring in rk3066/rk3188 clock bindings

Hi Heiko,

Quoted 24 lines · Heiko Stuebner

Bring in required device clock binding files from Linux.
The clock trees for rk3066 and rk3188 are largely similar, which makes them share the common parts in a shared header. While we focus on rk3188 for now, bring in both headers already for completeness sake.

---
 include/dt-bindings/clock/rk3066a-cru.h       |  40 ++++
 include/dt-bindings/clock/rk3188-cru-common.h | 256 ++++++++++++++++++++++++++
 include/dt-bindings/clock/rk3188-cru.h        |  56 ++++++
 3 files changed, 352 insertions(+)
 create mode 100644 include/dt-bindings/clock/rk3066a-cru.h
 create mode 100644 include/dt-bindings/clock/rk3188-cru-common.h
 create mode 100644 include/dt-bindings/clock/rk3188-cru.h
include/dt-bindings/clock/rk3066a-cru.h new file +3 -0
new file mode 100644
index 0000000..d3a9824
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014 MundoReader S.L.
+ * Author: Heiko Stuebner <[email protected]>

include/dt-bindings/clock/rk3066a-cru.h line 13

Quoted 10 lines
include/dt-bindings/clock/rk3066a-cru.h new file +10 -0
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.

Can you please use SPDX?

Regards,
Simon

author maintainer
#25 lore raw

PATCH 9/9 rockchip: rk3188: Add clock driver

In reply to Heiko Stuebner

Add a driver for setting up and modifying the various PLLs and peripheral clocks on the RK3188.

---
 arch/arm/include/asm/arch-rockchip/cru_rk3188.h | 186 ++++++++++
 drivers/clk/Makefile                            |   1 +
 drivers/clk/clk_rk3188.c                        | 464 ++++++++++++++++++++++++
 3 files changed, 651 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3188.h
 create mode 100644 drivers/clk/clk_rk3188.c
arch/arm/include/asm/arch-rockchip/cru_rk3188.h new file +183 -0
new file mode 100644
index 0000000..1073613
@@ -0,0 +1,183 @@
+/*
+ * (C) Copyright 2016 Heiko Stuebner <[email protected]>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+#ifndef _ASM_ARCH_CRU_RK3188_H
+#define _ASM_ARCH_CRU_RK3188_H
+
+#define OSC_HZ		(24 * 1000 * 1000)
+
+#define APLL_HZ		(1608 * 1000000)
+#define GPLL_HZ		(594 * 1000000)
+#define CPLL_HZ		(384 * 1000000)
+
+/* The SRAM is clocked off aclk_cpu, so we want to max it out for boot speed */
+#define CPU_ACLK_HZ	297000000
+#define CPU_HCLK_HZ	148500000
+#define CPU_PCLK_HZ	74250000
+#define CPU_H2P_HZ	74250000
+
+#define PERI_ACLK_HZ	148500000
+#define PERI_HCLK_HZ	148500000
+#define PERI_PCLK_HZ	74250000
+
+struct rk3188_cru {
+	struct rk3188_pll {
+		u32 con0;
+		u32 con1;
+		u32 con2;
+		u32 con3;
+	} pll[4];
+	u32 cru_mode_con;
+	u32 cru_clksel_con[35];
+	u32 cru_clkgate_con[10];
+	u32 reserved1[2];
+	u32 cru_glb_srst_fst_value;
+	u32 cru_glb_srst_snd_value;
+	u32 reserved2[2];
+	u32 cru_softrst_con[9];
+	u32 cru_misc_con;
+	u32 reserved3[2];
+	u32 cru_glb_cnt_th;
+};
+check_member(rk3188_cru, cru_glb_cnt_th, 0x0140);
+
+/* CRU_CLKSEL0_CON */
+enum {
+	/* a9_core_div: core = core_src / (a9_core_div + 1) */
+	A9_CORE_DIV_SHIFT	= 9,
+	A9_CORE_DIV_MASK	= 0x1f,
+	CORE_PLL_SHIFT		= 8,
+	CORE_PLL_MASK		= 1,
+	CORE_PLL_SELECT_APLL	= 0,
+	CORE_PLL_SELECT_GPLL,
+
+	/* core peri div: core:core_peri = 2:1, 4:1, 8:1 or 16:1 */
+	CORE_PERI_DIV_SHIFT	= 6,
+	CORE_PERI_DIV_MASK	= 3,
+
+	/* aclk_cpu pll selection */
+	CPU_ACLK_PLL_SHIFT	= 5,
+	CPU_ACLK_PLL_MASK	= 1,
+	CPU_ACLK_PLL_SELECT_APLL	= 0,
+	CPU_ACLK_PLL_SELECT_GPLL,
+
+	/* a9_cpu_div: aclk_cpu = cpu_src / (a9_cpu_div + 1) */
+	A9_CPU_DIV_SHIFT	= 0,
+	A9_CPU_DIV_MASK		= 0x1f,
+};
+
+/* CRU_CLKSEL1_CON */
+enum {
+	/* ahb2apb_pclk_div: hclk_cpu:pclk_cpu = 1:1, 2:1 or 4:1 */
+	AHB2APB_DIV_SHIFT	= 14,
+	AHB2APB_DIV_MASK	= 3,
+
+	/* cpu_pclk_div: aclk_cpu:pclk_cpu = 1:1, 2:1, 4:1 or 8:1 */
+	CPU_PCLK_DIV_SHIFT	= 12,
+	CPU_PCLK_DIV_MASK	= 3,
+
+	/* cpu_hclk_div: aclk_cpu:hclk_cpu = 1:1, 2:1 or 4:1 */
+	CPU_HCLK_DIV_SHIFT	= 8,
+	CPU_HCLK_DIV_MASK	= 3,
+
+	/* core_aclk_div: cire:aclk_core = 1:1, 2:1, 3:1, 4:1 or 8:1 */
+	CORE_ACLK_DIV_SHIFT	= 3,
+	CORE_ACLK_DIV_MASK	= 7,
+};
+
+/* CRU_CLKSEL10_CON */
+enum {
+	PERI_SEL_PLL_MASK	= 1,
+	PERI_SEL_PLL_SHIFT	= 15,
+	PERI_SEL_CPLL		= 0,
+	PERI_SEL_GPLL,
+
+	/* peri pclk div: aclk_bus:pclk_bus = 1:1, 2:1, 4:1 or 8:1 */
+	PERI_PCLK_DIV_SHIFT	= 12,
+	PERI_PCLK_DIV_MASK	= 3,
+
+	/* peripheral bus hclk div:aclk_bus: hclk_bus = 1:1, 2:1 or 4:1 */
+	PERI_HCLK_DIV_SHIFT	= 8,
+	PERI_HCLK_DIV_MASK	= 3,
+
+	/* peri aclk div: aclk_peri = periph_src / (peri_aclk_div + 1) */
+	PERI_ACLK_DIV_SHIFT	= 0,
+	PERI_ACLK_DIV_MASK	= 0x1f,
+};
+/* CRU_CLKSEL11_CON */
+enum {
+	HSICPHY_DIV_SHIFT	= 8,
+	HSICPHY_DIV_MASK	= 0x3f,
+
+	MMC0_DIV_SHIFT		= 0,
+	MMC0_DIV_MASK		= 0x3f,
+};
+
+/* CRU_CLKSEL12_CON */
+enum {
+	UART_PLL_SHIFT		= 15,
+	UART_PLL_MASK		= 1,
+	UART_PLL_SELECT_GENERAL	= 0,
+	UART_PLL_SELECT_CODEC,
+
+	EMMC_DIV_SHIFT		= 8,
+	EMMC_DIV_MASK		= 0x3f,
+
+	SDIO_DIV_SHIFT		= 0,
+	SDIO_DIV_MASK		= 0x3f,
+};
+
+/* CRU_CLKSEL25_CON */
+enum {
+	SPI1_DIV_SHIFT		= 8,
+	SPI1_DIV_MASK		= 0x7f,
+
+	SPI0_DIV_SHIFT		= 0,
+	SPI0_DIV_MASK		= 0x7f,
+};
+
+/* CRU_MODE_CON */
+enum {
+	GPLL_MODE_SHIFT		= 12,
+	GPLL_MODE_MASK		= 3,
+	GPLL_MODE_SLOW		= 0,
+	GPLL_MODE_NORMAL,
+	GPLL_MODE_DEEP,
+
+	CPLL_MODE_SHIFT		= 8,
+	CPLL_MODE_MASK		= 3,
+	CPLL_MODE_SLOW		= 0,
+	CPLL_MODE_NORMAL,
+	CPLL_MODE_DEEP,
+
+	DPLL_MODE_SHIFT		= 4,
+	DPLL_MODE_MASK		= 3,
+	DPLL_MODE_SLOW		= 0,
+	DPLL_MODE_NORMAL,
+	DPLL_MODE_DEEP,
+
+	APLL_MODE_SHIFT		= 0,
+	APLL_MODE_MASK		= 3,
+	APLL_MODE_SLOW		= 0,
+	APLL_MODE_NORMAL,
+	APLL_MODE_DEEP,
+};
+
+/* CRU_APLL_CON0 */
+enum {
+	CLKR_SHIFT		= 8,
+	CLKR_MASK		= 0x3f,
+
+	CLKOD_SHIFT		= 0,
+	CLKOD_MASK		= 0x3f,
+};
+
+/* CRU_APLL_CON1 */
+enum {
+	CLKF_SHIFT		= 0,
+	CLKF_MASK		= 0x1fff,
+};
+
+#endif
drivers/clk/Makefile +1 -0
index f7a8891..9455729 100644
@@ -7,6 +7,7 @@
 
 obj-$(CONFIG_CLK) += clk-uclass.o clk_fixed_rate.o
 obj-$(CONFIG_ROCKCHIP_RK3036) += clk_rk3036.o
+obj-$(CONFIG_ROCKCHIP_RK3188) += clk_rk3188.o
 obj-$(CONFIG_ROCKCHIP_RK3288) += clk_rk3288.o
 obj-$(CONFIG_SANDBOX) += clk_sandbox.o
 obj-$(CONFIG_SANDBOX) += clk_sandbox_test.o
drivers/clk/clk_rk3188.c new file +465 -0

465 lines not on this page · raw message

Signature · 1 line
2.8.0.rc3
#26 lore raw

PATCH 9/9 rockchip: rk3188: Add clock driver

Hi Heiko,

Quoted 11 lines · Heiko Stuebner

Add a driver for setting up and modifying the various PLLs and peripheral clocks on the RK3188.

---
 arch/arm/include/asm/arch-rockchip/cru_rk3188.h | 186 ++++++++++
 drivers/clk/Makefile                            |   1 +
 drivers/clk/clk_rk3188.c                        | 464 ++++++++++++++++++++++++
 3 files changed, 651 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3188.h
 create mode 100644 drivers/clk/clk_rk3188.c

Could you add a patch to move these files into a drivers/clk/rockchip directory?

Quoted 85 lines

new file mode 100644
index 0000000..4c28393

drivers/clk/clk_rk3188.c new file +80 -0
@@ -0,0 +1,465 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ * (C) Copyright 2016 Heiko Stuebner <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <syscon.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/cru_rk3188.h>
+#include <asm/arch/grf_rk3188.h>
+#include <asm/arch/hardware.h>
+#include <dt-bindings/clock/rk3188-cru.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/uclass-internal.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct rk3188_clk_priv {
+       struct rk3188_grf *grf;
+       struct rk3188_cru *cru;
+       ulong rate;
+       bool has_bwadj;
+};
+
+struct pll_div {
+       u32 nr;
+       u32 nf;
+       u32 no;
+};
+
+enum {
+       VCO_MAX_HZ      = 2200U * 1000000,
+       VCO_MIN_HZ      = 440 * 1000000,
+       OUTPUT_MAX_HZ   = 2200U * 1000000,
+       OUTPUT_MIN_HZ   = 30 * 1000000,
+       FREF_MAX_HZ     = 2200U * 1000000,
+       FREF_MIN_HZ     = 30 * 1000,
+};
+
+enum {
+       /* PLL CON0 */
+       PLL_OD_MASK             = 0x0f,
+
+       /* PLL CON1 */
+       PLL_NF_MASK             = 0x1fff,
+
+       /* PLL CON2 */
+       PLL_BWADJ_MASK          = 0x0fff,
+
+       /* PLL CON3 */
+       PLL_RESET_SHIFT         = 5,
+
+       /* GRF_SOC_STATUS0 */
+       SOCSTS_DPLL_LOCK        = 1 << 5,
+       SOCSTS_APLL_LOCK        = 1 << 6,
+       SOCSTS_CPLL_LOCK        = 1 << 7,
+       SOCSTS_GPLL_LOCK        = 1 << 8,
+};
+
+#define RATE_TO_DIV(input_rate, output_rate) \
+       ((input_rate) / (output_rate) - 1);
+
+#define DIV_TO_RATE(input_rate, div)   ((input_rate) / ((div) + 1))
+
+#define PLL_DIVISORS(hz, _nr, _no) {\
+       .nr = _nr, .nf = (u32)((u64)hz * _nr * _no / OSC_HZ), .no = _no};\
+       _Static_assert(((u64)hz * _nr * _no / OSC_HZ) * OSC_HZ /\
+                      (_nr * _no) == hz, #hz "Hz cannot be hit with PLL "\
+                      "divisors on line " __stringify(__LINE__));
+
+/* Keep divisors as low as possible to reduce jitter and power usage */
+static const struct pll_div apll_init_cfg = PLL_DIVISORS(APLL_HZ, 1, 1);
+static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 2, 2);

drivers/clk/clk_rk3188.c line 90

Quoted 10 lines
drivers/clk/clk_rk3188.c new file +10 -0
+static const struct pll_div cpll_init_cfg = PLL_DIVISORS(CPLL_HZ, 1, 2);
+
+void *rockchip_get_cru(void)
+{
+       struct rk3188_clk_priv *priv;
+       struct udevice *dev;
+       int ret;
+
+       ret = uclass_get_device_by_name(UCLASS_CLK,
+                                       "clock-controller at 20000000", &dev);

This seems odd. Could you use uclass_get_device(UCLASS_CLK, 0, .&dev) ?

Quoted 33 lines
drivers/clk/clk_rk3188.c new file +33 -0
+       if (ret)
+               return ERR_PTR(ret);
+
+       priv = dev_get_priv(dev);
+
+       return priv->cru;
+}
+
+static int rkclk_set_pll(struct rk3188_cru *cru, enum rk_clk_id clk_id,
+                        const struct pll_div *div, bool has_bwadj)
+{
+       int pll_id = rk_pll_id(clk_id);
+       struct rk3188_pll *pll = &cru->pll[pll_id];
+       /* All PLLs have same VCO and output frequency range restrictions. */
+       uint vco_hz = OSC_HZ / 1000 * div->nf / div->nr * 1000;
+       uint output_hz = vco_hz / div->no;
+
+       debug("PLL at %x: nf=%d, nr=%d, no=%d, vco=%u Hz, output=%u Hz\n",
+             (uint)pll, div->nf, div->nr, div->no, vco_hz, output_hz);
+       assert(vco_hz >= VCO_MIN_HZ && vco_hz <= VCO_MAX_HZ &&
+              output_hz >= OUTPUT_MIN_HZ && output_hz <= OUTPUT_MAX_HZ &&
+              (div->no == 1 || !(div->no % 2)));
+
+       /* enter reset */
+       rk_setreg(&pll->con3, 1 << PLL_RESET_SHIFT);
+
+       rk_clrsetreg(&pll->con0,
+                    CLKR_MASK << CLKR_SHIFT | PLL_OD_MASK,
+                    ((div->nr - 1) << CLKR_SHIFT) | (div->no - 1));
+       rk_clrsetreg(&pll->con1, CLKF_MASK, div->nf - 1);
+
+       if (has_bwadj)
+               rk_clrsetreg(&pll->con2, PLL_BWADJ_MASK, (div->nf >> 1) - 1);

drivers/clk/clk_rk3188.c line 133

Quoted 10 lines
drivers/clk/clk_rk3188.c new file +10 -0
+
+       udelay(10);
+
+       /* return from reset */
+       rk_clrreg(&pll->con3, 1 << PLL_RESET_SHIFT);
+
+       return 0;
+}
+
+static inline unsigned int log2(unsigned int value)

Hmm this should go in a common file. Perhaps bitfield.h or common.h?

Quoted 288 lines
drivers/clk/clk_rk3188.c new file +288 -0
+{
+       return fls(value) - 1;
+}
+
+static void rkclk_init(struct rk3188_cru *cru, struct rk3188_grf *grf,
+                      bool has_bwadj)
+{
+       u32 aclk_div, hclk_div, pclk_div, h2p_div;
+
+       /* pll enter slow-mode */
+       rk_clrsetreg(&cru->cru_mode_con,
+                    GPLL_MODE_MASK << GPLL_MODE_SHIFT |
+                    CPLL_MODE_MASK << CPLL_MODE_SHIFT,
+                    GPLL_MODE_SLOW << GPLL_MODE_SHIFT |
+                    CPLL_MODE_SLOW << CPLL_MODE_SHIFT);
+
+       /* init pll */
+       rkclk_set_pll(cru, CLK_GENERAL, &gpll_init_cfg, has_bwadj);
+       rkclk_set_pll(cru, CLK_CODEC, &cpll_init_cfg, has_bwadj);
+
+       /* waiting for pll lock */
+       while ((readl(&grf->soc_status0) &
+                       (SOCSTS_CPLL_LOCK | SOCSTS_GPLL_LOCK)) !=
+                       (SOCSTS_CPLL_LOCK | SOCSTS_GPLL_LOCK))
+               udelay(1);
+
+       /*
+        * cpu clock pll source selection and
+        * reparent aclk_cpu_pre from apll to gpll
+        * set up dependent divisors for PCLK/HCLK and ACLK clocks.
+        */
+       aclk_div = RATE_TO_DIV(GPLL_HZ, CPU_ACLK_HZ);
+       assert((aclk_div + 1) * CPU_ACLK_HZ == GPLL_HZ && aclk_div < 0x1f);
+
+       rk_clrsetreg(&cru->cru_clksel_con[0],
+                    CPU_ACLK_PLL_MASK << CPU_ACLK_PLL_SHIFT |
+                    A9_CPU_DIV_MASK << A9_CPU_DIV_SHIFT,
+                    CPU_ACLK_PLL_SELECT_GPLL << CPU_ACLK_PLL_SHIFT |
+                    aclk_div << A9_CPU_DIV_SHIFT);
+
+       hclk_div = log2(CPU_ACLK_HZ / CPU_HCLK_HZ);
+       assert((1 << hclk_div) * CPU_HCLK_HZ == CPU_ACLK_HZ && hclk_div < 0x3);
+       pclk_div = log2(CPU_ACLK_HZ / CPU_PCLK_HZ);
+       assert((1 << pclk_div) * CPU_PCLK_HZ == CPU_ACLK_HZ && pclk_div < 0x4);
+       h2p_div = log2(CPU_HCLK_HZ / CPU_H2P_HZ);
+       assert((1 << h2p_div) * CPU_H2P_HZ == CPU_HCLK_HZ && pclk_div < 0x3);
+
+       rk_clrsetreg(&cru->cru_clksel_con[1],
+                    AHB2APB_DIV_MASK << AHB2APB_DIV_SHIFT |
+                    CPU_PCLK_DIV_MASK << CPU_PCLK_DIV_SHIFT |
+                    CPU_HCLK_DIV_MASK << CPU_HCLK_DIV_SHIFT,
+                    h2p_div << AHB2APB_DIV_SHIFT |
+                    pclk_div << CPU_PCLK_DIV_SHIFT |
+                    hclk_div << CPU_HCLK_DIV_SHIFT);
+
+       /*
+        * peri clock pll source selection and
+        * set up dependent divisors for PCLK/HCLK and ACLK clocks.
+        */
+       aclk_div = GPLL_HZ / PERI_ACLK_HZ - 1;
+       assert((aclk_div + 1) * PERI_ACLK_HZ == GPLL_HZ && aclk_div < 0x1f);
+
+       hclk_div = log2(PERI_ACLK_HZ / PERI_HCLK_HZ);
+       assert((1 << hclk_div) * PERI_HCLK_HZ ==
+               PERI_ACLK_HZ && (hclk_div < 0x4));
+
+       pclk_div = log2(PERI_ACLK_HZ / PERI_PCLK_HZ);
+       assert((1 << pclk_div) * PERI_PCLK_HZ ==
+               PERI_ACLK_HZ && (pclk_div < 0x4));
+
+       rk_clrsetreg(&cru->cru_clksel_con[10],
+                    PERI_PCLK_DIV_MASK << PERI_PCLK_DIV_SHIFT |
+                    PERI_HCLK_DIV_MASK << PERI_HCLK_DIV_SHIFT |
+                    PERI_ACLK_DIV_MASK << PERI_ACLK_DIV_SHIFT,
+                    PERI_SEL_GPLL << PERI_SEL_PLL_SHIFT |
+                    pclk_div << PERI_PCLK_DIV_SHIFT |
+                    hclk_div << PERI_HCLK_DIV_SHIFT |
+                    aclk_div << PERI_ACLK_DIV_SHIFT);
+
+       /* PLL enter normal-mode */
+       rk_clrsetreg(&cru->cru_mode_con,
+                    GPLL_MODE_MASK << GPLL_MODE_SHIFT |
+                    CPLL_MODE_MASK << CPLL_MODE_SHIFT,
+                    GPLL_MODE_NORMAL << GPLL_MODE_SHIFT |
+                    CPLL_MODE_NORMAL << CPLL_MODE_SHIFT);
+}
+
+/* Get pll rate by id */
+static uint32_t rkclk_pll_get_rate(struct rk3188_cru *cru,
+                                  enum rk_clk_id clk_id)
+{
+       uint32_t nr, no, nf;
+       uint32_t con;
+       int pll_id = rk_pll_id(clk_id);
+       struct rk3188_pll *pll = &cru->pll[pll_id];
+       static u8 clk_shift[CLK_COUNT] = {
+               0xff, APLL_MODE_SHIFT, DPLL_MODE_SHIFT, CPLL_MODE_SHIFT,
+               GPLL_MODE_SHIFT
+       };
+       uint shift;
+
+       con = readl(&cru->cru_mode_con);
+       shift = clk_shift[clk_id];
+       switch ((con >> shift) & APLL_MODE_MASK) {
+       case APLL_MODE_SLOW:
+               return OSC_HZ;
+       case APLL_MODE_NORMAL:
+               /* normal mode */
+               con = readl(&pll->con0);
+               no = ((con >> CLKOD_SHIFT) & CLKOD_MASK) + 1;
+               nr = ((con >> CLKR_SHIFT) & CLKR_MASK) + 1;
+               con = readl(&pll->con1);
+               nf = ((con >> CLKF_SHIFT) & CLKF_MASK) + 1;
+
+               return (24 * nf / (nr * no)) * 1000000;
+       case APLL_MODE_DEEP:
+       default:
+               return 32768;
+       }
+}
+
+static ulong rockchip_mmc_get_clk(struct rk3188_cru *cru, uint gclk_rate,
+                                 int periph)
+{
+       uint div;
+       u32 con;
+
+       switch (periph) {
+       case HCLK_EMMC:
+               con = readl(&cru->cru_clksel_con[12]);
+               div = (con >> EMMC_DIV_SHIFT) & EMMC_DIV_MASK;
+               break;
+       case HCLK_SDMMC:
+               con = readl(&cru->cru_clksel_con[11]);
+               div = (con >> MMC0_DIV_SHIFT) & MMC0_DIV_MASK;
+               break;
+       case HCLK_SDIO:
+               con = readl(&cru->cru_clksel_con[12]);
+               div = (con >> SDIO_DIV_SHIFT) & SDIO_DIV_MASK;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return DIV_TO_RATE(gclk_rate, div);
+}
+
+static ulong rockchip_mmc_set_clk(struct rk3188_cru *cru, uint gclk_rate,
+                                 int  periph, uint freq)
+{
+       int src_clk_div;
+
+       debug("%s: gclk_rate=%u\n", __func__, gclk_rate);
+       src_clk_div = RATE_TO_DIV(gclk_rate, freq);
+       assert(src_clk_div <= 0x3f);
+
+       switch (periph) {
+       case HCLK_EMMC:
+               rk_clrsetreg(&cru->cru_clksel_con[12],
+                            EMMC_DIV_MASK << EMMC_DIV_SHIFT,
+                            src_clk_div << EMMC_DIV_SHIFT);
+               break;
+       case HCLK_SDMMC:
+               rk_clrsetreg(&cru->cru_clksel_con[11],
+                            MMC0_DIV_MASK << MMC0_DIV_SHIFT,
+                            src_clk_div << MMC0_DIV_SHIFT);
+               break;
+       case HCLK_SDIO:
+               rk_clrsetreg(&cru->cru_clksel_con[12],
+                            SDIO_DIV_MASK << SDIO_DIV_SHIFT,
+                            src_clk_div << SDIO_DIV_SHIFT);
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return rockchip_mmc_get_clk(cru, gclk_rate, periph);
+}
+
+static ulong rockchip_spi_get_clk(struct rk3188_cru *cru, uint gclk_rate,
+                                 int periph)
+{
+       uint div;
+       u32 con;
+
+       switch (periph) {
+       case SCLK_SPI0:
+               con = readl(&cru->cru_clksel_con[25]);
+               div = (con >> SPI0_DIV_SHIFT) & SPI0_DIV_MASK;
+               break;
+       case SCLK_SPI1:
+               con = readl(&cru->cru_clksel_con[25]);
+               div = (con >> SPI1_DIV_SHIFT) & SPI1_DIV_MASK;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return DIV_TO_RATE(gclk_rate, div);
+}
+
+static ulong rockchip_spi_set_clk(struct rk3188_cru *cru, uint gclk_rate,
+                                 int periph, uint freq)
+{
+       int src_clk_div = RATE_TO_DIV(gclk_rate, freq);
+
+       switch (periph) {
+       case SCLK_SPI0:
+               assert(src_clk_div <= SPI0_DIV_MASK);
+               rk_clrsetreg(&cru->cru_clksel_con[25],
+                            SPI0_DIV_MASK << SPI0_DIV_SHIFT,
+                            src_clk_div << SPI0_DIV_SHIFT);
+               break;
+       case SCLK_SPI1:
+               assert(src_clk_div <= SPI1_DIV_MASK);
+               rk_clrsetreg(&cru->cru_clksel_con[25],
+                            SPI1_DIV_MASK << SPI1_DIV_SHIFT,
+                            src_clk_div << SPI1_DIV_SHIFT);
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return rockchip_spi_get_clk(cru, gclk_rate, periph);
+}
+
+static ulong rk3188_clk_get_rate(struct clk *clk)
+{
+       struct rk3188_clk_priv *priv = dev_get_priv(clk->dev);
+       ulong new_rate, gclk_rate;
+
+       gclk_rate = rkclk_pll_get_rate(priv->cru, CLK_GENERAL);
+       switch (clk->id) {
+       case 1 ... 4:
+               new_rate = rkclk_pll_get_rate(priv->cru, clk->id);
+               break;
+       case HCLK_EMMC:
+       case HCLK_SDMMC:
+       case HCLK_SDIO:
+               new_rate = rockchip_mmc_get_clk(priv->cru, PERI_HCLK_HZ,
+                                               clk->id);
+               break;
+       case SCLK_SPI0:
+       case SCLK_SPI1:
+               new_rate = rockchip_spi_get_clk(priv->cru, PERI_PCLK_HZ,
+                                               clk->id);
+               break;
+       case PCLK_I2C0:
+       case PCLK_I2C1:
+       case PCLK_I2C2:
+       case PCLK_I2C3:
+       case PCLK_I2C4:
+               return gclk_rate;
+       default:
+               return -ENOENT;
+       }
+
+       return new_rate;
+}
+
+static ulong rk3188_clk_set_rate(struct clk *clk, ulong rate)
+{
+       struct rk3188_clk_priv *priv = dev_get_priv(clk->dev);
+       struct rk3188_cru *cru = priv->cru;
+       ulong new_rate;
+
+       switch (clk->id) {
+       case HCLK_EMMC:
+       case HCLK_SDMMC:
+       case HCLK_SDIO:
+               new_rate = rockchip_mmc_set_clk(cru, PERI_HCLK_HZ,
+                                               clk->id, rate);
+               break;
+       case SCLK_SPI0:
+       case SCLK_SPI1:
+               new_rate = rockchip_spi_set_clk(cru, PERI_PCLK_HZ,
+                                               clk->id, rate);
+               break;
+       default:
+               return -ENOENT;
+       }
+
+       return new_rate;
+}
+
+static struct clk_ops rk3188_clk_ops = {
+       .get_rate       = rk3188_clk_get_rate,
+       .set_rate       = rk3188_clk_set_rate,

drivers/clk/clk_rk3188.c line 431

Quoted 10 lines
drivers/clk/clk_rk3188.c new file +10 -0
+};
+
+static int rk3188_clk_probe(struct udevice *dev)
+{
+       struct rk3188_clk_priv *priv = dev_get_priv(dev);
+
+       priv->cru = (struct rk3188_cru *)dev_get_addr(dev);
+       priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+       priv->has_bwadj = of_device_is_compatible(dev, "rockchip,rk3188a-cru")
+                       ? 1 : 0;

You should add a .data member to your udevice_id array below using a two-member enum, and check dev_get_driver_data() here.

Quoted 37 lines
drivers/clk/clk_rk3188.c new file +34 -1
+
+       /* we don't have a spl yet, so call rkclk_init at the regular time */
+       rkclk_init(priv->cru, priv->grf, priv->has_bwadj);
+
+       return 0;
+}
+
+static int rk3188_clk_bind(struct udevice *dev)
+{
+       int ret;
+
+       /* The reset driver does not have a device node, so bind it here */
+       ret = device_bind_driver(gd->dm_root, "rk3188_sysreset", "reset", &dev);
+       if (ret)
+               debug("Warning: No rk3188 reset driver: ret=%d\n", ret);
+
+       return 0;
+}
+
+static const struct udevice_id rk3188_clk_ids[] = {
+       { .compatible = "rockchip,rk3188-cru" },
+       { .compatible = "rockchip,rk3188a-cru" },
+       { }
+};
+
+U_BOOT_DRIVER(clk_rk3188) = {
+       .name           = "clk_rk3188",
+       .id             = UCLASS_CLK,
+       .of_match       = rk3188_clk_ids,
+       .priv_auto_alloc_size = sizeof(struct rk3188_clk_priv),
+       .ops            = &rk3188_clk_ops,
+       .bind           = rk3188_clk_bind,
+       .probe          = rk3188_clk_probe,
+};
--

2.8.0.rc3

author maintainer
#27 lore raw

PATCH 9/9 rockchip: rk3188: Add clock driver

Am Sonntag, 17. Juli 2016, 08:13:58 schrieb Simon Glass:

Quoted 16 lines

Hi Heiko,

Quoted 4 lines · Heiko Stuebner

Add a driver for setting up and modifying the various PLLs and peripheral clocks on the RK3188.

Quoted 8 lines

---

 arch/arm/include/asm/arch-rockchip/cru_rk3188.h | 186 ++++++++++
 drivers/clk/Makefile                            |   1 +
 drivers/clk/clk_rk3188.c                        | 464
 ++++++++++++++++++++++++ 3 files changed, 651 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3188.h
 create mode 100644 drivers/clk/clk_rk3188.c
Quoted 2 lines

Could you add a patch to move these files into a drivers/clk/rockchip directory?

ok

Quoted 91 lines
Quoted 91 lines

new file mode 100644
index 0000000..4c28393

drivers/clk/clk_rk3188.c new file +75 -0
@@ -0,0 +1,465 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ * (C) Copyright 2016 Heiko Stuebner <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <syscon.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/cru_rk3188.h>
+#include <asm/arch/grf_rk3188.h>
+#include <asm/arch/hardware.h>
+#include <dt-bindings/clock/rk3188-cru.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/uclass-internal.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct rk3188_clk_priv {
+       struct rk3188_grf *grf;
+       struct rk3188_cru *cru;
+       ulong rate;
+       bool has_bwadj;
+};
+
+struct pll_div {
+       u32 nr;
+       u32 nf;
+       u32 no;
+};
+
+enum {
+       VCO_MAX_HZ      = 2200U * 1000000,
+       VCO_MIN_HZ      = 440 * 1000000,
+       OUTPUT_MAX_HZ   = 2200U * 1000000,
+       OUTPUT_MIN_HZ   = 30 * 1000000,
+       FREF_MAX_HZ     = 2200U * 1000000,
+       FREF_MIN_HZ     = 30 * 1000,
+};
+
+enum {
+       /* PLL CON0 */
+       PLL_OD_MASK             = 0x0f,
+
+       /* PLL CON1 */
+       PLL_NF_MASK             = 0x1fff,
+
+       /* PLL CON2 */
+       PLL_BWADJ_MASK          = 0x0fff,
+
+       /* PLL CON3 */
+       PLL_RESET_SHIFT         = 5,
+
+       /* GRF_SOC_STATUS0 */
+       SOCSTS_DPLL_LOCK        = 1 << 5,
+       SOCSTS_APLL_LOCK        = 1 << 6,
+       SOCSTS_CPLL_LOCK        = 1 << 7,
+       SOCSTS_GPLL_LOCK        = 1 << 8,
+};
+
+#define RATE_TO_DIV(input_rate, output_rate) \
+       ((input_rate) / (output_rate) - 1);
+
+#define DIV_TO_RATE(input_rate, div)   ((input_rate) / ((div) + 1))
+
+#define PLL_DIVISORS(hz, _nr, _no) {\
+       .nr = _nr, .nf = (u32)((u64)hz * _nr * _no / OSC_HZ), .no = _no};\
+       _Static_assert(((u64)hz * _nr * _no / OSC_HZ) * OSC_HZ /\
+                      (_nr * _no) == hz, #hz "Hz cannot be hit with PLL

"\

drivers/clk/clk_rk3188.c new file +10 -0
+                      "divisors on line " __stringify(__LINE__));
+
+/* Keep divisors as low as possible to reduce jitter and power usage */
+static const struct pll_div apll_init_cfg = PLL_DIVISORS(APLL_HZ, 1, 1);
+static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 2, 2);
+static const struct pll_div cpll_init_cfg = PLL_DIVISORS(CPLL_HZ, 1, 2);
+
+void *rockchip_get_cru(void)
+{
+       struct rk3188_clk_priv *priv;
Quoted 8 lines
Quoted 6 lines
drivers/clk/clk_rk3188.c new file +5 -0
+       struct udevice *dev;
+       int ret;
+
+       ret = uclass_get_device_by_name(UCLASS_CLK,
+                                       "clock-controller at 20000000",

&dev);

This seems odd. Could you use uclass_get_device(UCLASS_CLK, 0, .&dev) ?

Index 0 actually gets me the 24MHz oscillator fixed clock :-), which is why I switched to the by-name variant to not depend on some dts or uclass ordering. I'm wondering how that works on the other socs.

Quoted 38 lines
Quoted 38 lines
drivers/clk/clk_rk3188.c new file +14 -0
+       if (ret)
+               return ERR_PTR(ret);
+
+       priv = dev_get_priv(dev);
+
+       return priv->cru;
+}
+
+static int rkclk_set_pll(struct rk3188_cru *cru, enum rk_clk_id clk_id,
+                        const struct pll_div *div, bool has_bwadj)
+{
+       int pll_id = rk_pll_id(clk_id);
+       struct rk3188_pll *pll = &cru->pll[pll_id];
+       /* All PLLs have same VCO and output frequency range restrictions.

*/ + uint vco_hz = OSC_HZ / 1000 * div->nf / div->nr * 1000;

drivers/clk/clk_rk3188.c new file +18 -0
+       uint output_hz = vco_hz / div->no;
+
+       debug("PLL at %x: nf=%d, nr=%d, no=%d, vco=%u Hz, output=%u Hz\n",
+             (uint)pll, div->nf, div->nr, div->no, vco_hz, output_hz);
+       assert(vco_hz >= VCO_MIN_HZ && vco_hz <= VCO_MAX_HZ &&
+              output_hz >= OUTPUT_MIN_HZ && output_hz <= OUTPUT_MAX_HZ &&
+              (div->no == 1 || !(div->no % 2)));
+
+       /* enter reset */
+       rk_setreg(&pll->con3, 1 << PLL_RESET_SHIFT);
+
+       rk_clrsetreg(&pll->con0,
+                    CLKR_MASK << CLKR_SHIFT | PLL_OD_MASK,
+                    ((div->nr - 1) << CLKR_SHIFT) | (div->no - 1));
+       rk_clrsetreg(&pll->con1, CLKF_MASK, div->nf - 1);
+
+       if (has_bwadj)
+               rk_clrsetreg(&pll->con2, PLL_BWADJ_MASK, (div->nf >> 1) -

1); +

drivers/clk/clk_rk3188.c new file +3 -0
+       udelay(10);
+
+       /* return from reset */
Quoted 8 lines

drivers/clk/clk_rk3188.c line 133

Quoted 6 lines
drivers/clk/clk_rk3188.c new file +6 -0
+       rk_clrreg(&pll->con3, 1 << PLL_RESET_SHIFT);
+
+       return 0;
+}
+
+static inline unsigned int log2(unsigned int value)

Hmm this should go in a common file. Perhaps bitfield.h or common.h?

it looks like uboot is already carrying ilog2() in include/linux/log2.h ?

[...]

Quoted 11 lines
Quoted 8 lines
drivers/clk/clk_rk3188.c new file +7 -0
+static int rk3188_clk_probe(struct udevice *dev)
+{
+       struct rk3188_clk_priv *priv = dev_get_priv(dev);
+
+       priv->cru = (struct rk3188_cru *)dev_get_addr(dev);
+       priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+       priv->has_bwadj = of_device_is_compatible(dev,

"rockchip,rk3188a-cru") + ? 1 : 0;

You should add a .data member to your udevice_id array below using a two-member enum, and check dev_get_driver_data() here.

ah, nice to know. I was wondering if and how uboot was handling .data stuff but my short skimming through the sources didn't reveal that. Will change.

Heiko

#28 lore raw

PATCH 9/9 rockchip: rk3188: Add clock driver

Hi Heiko,

Quoted 122 lines · Heiko St?bner

Am Sonntag, 17. Juli 2016, 08:13:58 schrieb Simon Glass:

Quoted 16 lines

Hi Heiko,

Quoted 4 lines · Heiko Stuebner

Add a driver for setting up and modifying the various PLLs and peripheral clocks on the RK3188.

Quoted 8 lines

---

 arch/arm/include/asm/arch-rockchip/cru_rk3188.h | 186 ++++++++++
 drivers/clk/Makefile                            |   1 +
 drivers/clk/clk_rk3188.c                        | 464
 ++++++++++++++++++++++++ 3 files changed, 651 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3188.h
 create mode 100644 drivers/clk/clk_rk3188.c
Quoted 2 lines

Could you add a patch to move these files into a drivers/clk/rockchip directory?

ok

Quoted 91 lines
Quoted 91 lines

new file mode 100644
index 0000000..4c28393

drivers/clk/clk_rk3188.c new file +75 -0
@@ -0,0 +1,465 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ * (C) Copyright 2016 Heiko Stuebner <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <syscon.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/cru_rk3188.h>
+#include <asm/arch/grf_rk3188.h>
+#include <asm/arch/hardware.h>
+#include <dt-bindings/clock/rk3188-cru.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/uclass-internal.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct rk3188_clk_priv {
+       struct rk3188_grf *grf;
+       struct rk3188_cru *cru;
+       ulong rate;
+       bool has_bwadj;
+};
+
+struct pll_div {
+       u32 nr;
+       u32 nf;
+       u32 no;
+};
+
+enum {
+       VCO_MAX_HZ      = 2200U * 1000000,
+       VCO_MIN_HZ      = 440 * 1000000,
+       OUTPUT_MAX_HZ   = 2200U * 1000000,
+       OUTPUT_MIN_HZ   = 30 * 1000000,
+       FREF_MAX_HZ     = 2200U * 1000000,
+       FREF_MIN_HZ     = 30 * 1000,
+};
+
+enum {
+       /* PLL CON0 */
+       PLL_OD_MASK             = 0x0f,
+
+       /* PLL CON1 */
+       PLL_NF_MASK             = 0x1fff,
+
+       /* PLL CON2 */
+       PLL_BWADJ_MASK          = 0x0fff,
+
+       /* PLL CON3 */
+       PLL_RESET_SHIFT         = 5,
+
+       /* GRF_SOC_STATUS0 */
+       SOCSTS_DPLL_LOCK        = 1 << 5,
+       SOCSTS_APLL_LOCK        = 1 << 6,
+       SOCSTS_CPLL_LOCK        = 1 << 7,
+       SOCSTS_GPLL_LOCK        = 1 << 8,
+};
+
+#define RATE_TO_DIV(input_rate, output_rate) \
+       ((input_rate) / (output_rate) - 1);
+
+#define DIV_TO_RATE(input_rate, div)   ((input_rate) / ((div) + 1))
+
+#define PLL_DIVISORS(hz, _nr, _no) {\
+       .nr = _nr, .nf = (u32)((u64)hz * _nr * _no / OSC_HZ), .no = _no};\
+       _Static_assert(((u64)hz * _nr * _no / OSC_HZ) * OSC_HZ /\
+                      (_nr * _no) == hz, #hz "Hz cannot be hit with PLL

"\

drivers/clk/clk_rk3188.c new file +10 -0
+                      "divisors on line " __stringify(__LINE__));
+
+/* Keep divisors as low as possible to reduce jitter and power usage */
+static const struct pll_div apll_init_cfg = PLL_DIVISORS(APLL_HZ, 1, 1);
+static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 2, 2);
+static const struct pll_div cpll_init_cfg = PLL_DIVISORS(CPLL_HZ, 1, 2);
+
+void *rockchip_get_cru(void)
+{
+       struct rk3188_clk_priv *priv;
Quoted 8 lines
Quoted 6 lines
drivers/clk/clk_rk3188.c new file +5 -0
+       struct udevice *dev;
+       int ret;
+
+       ret = uclass_get_device_by_name(UCLASS_CLK,
+                                       "clock-controller at 20000000",

&dev);

This seems odd. Could you use uclass_get_device(UCLASS_CLK, 0, .&dev) ?

Quoted 3 lines

Index 0 actually gets me the 24MHz oscillator fixed clock :-), which is why I switched to the by-name variant to not depend on some dts or uclass ordering. I'm wondering how that works on the other socs.

I suspect this might have become broken by Stephen's clock changes. I had a bit of a look at this but have not resolved it yet. For example on firefly, HDMI does not work now.

There is this:

enum rk_clk_id {
CLK_OSC,
CLK_ARM,
CLK_DDR,
CLK_CODEC,
CLK_GENERAL,
CLK_NEW,

CLK_COUNT,
};

and it used to check against the platform data (see rkclk_get_clk() in v2016.05). I'll have a think about it.

Quoted 48 lines
Quoted 39 lines
Quoted 39 lines
drivers/clk/clk_rk3188.c new file +14 -0
+       if (ret)
+               return ERR_PTR(ret);
+
+       priv = dev_get_priv(dev);
+
+       return priv->cru;
+}
+
+static int rkclk_set_pll(struct rk3188_cru *cru, enum rk_clk_id clk_id,
+                        const struct pll_div *div, bool has_bwadj)
+{
+       int pll_id = rk_pll_id(clk_id);
+       struct rk3188_pll *pll = &cru->pll[pll_id];
+       /* All PLLs have same VCO and output frequency range restrictions.

*/ + uint vco_hz = OSC_HZ / 1000 * div->nf / div->nr * 1000;

drivers/clk/clk_rk3188.c new file +18 -0
+       uint output_hz = vco_hz / div->no;
+
+       debug("PLL at %x: nf=%d, nr=%d, no=%d, vco=%u Hz, output=%u Hz\n",
+             (uint)pll, div->nf, div->nr, div->no, vco_hz, output_hz);
+       assert(vco_hz >= VCO_MIN_HZ && vco_hz <= VCO_MAX_HZ &&
+              output_hz >= OUTPUT_MIN_HZ && output_hz <= OUTPUT_MAX_HZ &&
+              (div->no == 1 || !(div->no % 2)));
+
+       /* enter reset */
+       rk_setreg(&pll->con3, 1 << PLL_RESET_SHIFT);
+
+       rk_clrsetreg(&pll->con0,
+                    CLKR_MASK << CLKR_SHIFT | PLL_OD_MASK,
+                    ((div->nr - 1) << CLKR_SHIFT) | (div->no - 1));
+       rk_clrsetreg(&pll->con1, CLKF_MASK, div->nf - 1);
+
+       if (has_bwadj)
+               rk_clrsetreg(&pll->con2, PLL_BWADJ_MASK, (div->nf >> 1) -

1); +

drivers/clk/clk_rk3188.c new file +3 -0
+       udelay(10);
+
+       /* return from reset */
Quoted 8 lines

drivers/clk/clk_rk3188.c line 133

Quoted 6 lines
drivers/clk/clk_rk3188.c new file +6 -0
+       rk_clrreg(&pll->con3, 1 << PLL_RESET_SHIFT);
+
+       return 0;
+}
+
+static inline unsigned int log2(unsigned int value)

Hmm this should go in a common file. Perhaps bitfield.h or common.h?

Quoted 1 line

it looks like uboot is already carrying ilog2() in include/linux/log2.h ?

Yes.

Quoted 15 lines

[...]

Quoted 11 lines
Quoted 8 lines
drivers/clk/clk_rk3188.c new file +7 -0
+static int rk3188_clk_probe(struct udevice *dev)
+{
+       struct rk3188_clk_priv *priv = dev_get_priv(dev);
+
+       priv->cru = (struct rk3188_cru *)dev_get_addr(dev);
+       priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+       priv->has_bwadj = of_device_is_compatible(dev,

"rockchip,rk3188a-cru") + ? 1 : 0;

You should add a .data member to your udevice_id array below using a two-member enum, and check dev_get_driver_data() here.

Quoted 2 lines

ah, nice to know. I was wondering if and how uboot was handling .data stuff but my short skimming through the sources didn't reveal that. Will change.

I'm AFK for a few hours now.

Regards,
Simon

#29 lore raw

PATCH 9/9 rockchip: rk3188: Add clock driver

Hi Heiko,

Quoted 143 lines · Simon Glass

Hi Heiko,

Quoted 122 lines · Heiko St?bner

Am Sonntag, 17. Juli 2016, 08:13:58 schrieb Simon Glass:

Quoted 16 lines

Hi Heiko,

Quoted 4 lines · Heiko Stuebner

Add a driver for setting up and modifying the various PLLs and peripheral clocks on the RK3188.

Quoted 8 lines

---

 arch/arm/include/asm/arch-rockchip/cru_rk3188.h | 186 ++++++++++
 drivers/clk/Makefile                            |   1 +
 drivers/clk/clk_rk3188.c                        | 464
 ++++++++++++++++++++++++ 3 files changed, 651 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3188.h
 create mode 100644 drivers/clk/clk_rk3188.c
Quoted 2 lines

Could you add a patch to move these files into a drivers/clk/rockchip directory?

ok

Quoted 91 lines
Quoted 91 lines

new file mode 100644
index 0000000..4c28393

drivers/clk/clk_rk3188.c new file +75 -0
@@ -0,0 +1,465 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ * (C) Copyright 2016 Heiko Stuebner <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <syscon.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/cru_rk3188.h>
+#include <asm/arch/grf_rk3188.h>
+#include <asm/arch/hardware.h>
+#include <dt-bindings/clock/rk3188-cru.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/uclass-internal.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct rk3188_clk_priv {
+       struct rk3188_grf *grf;
+       struct rk3188_cru *cru;
+       ulong rate;
+       bool has_bwadj;
+};
+
+struct pll_div {
+       u32 nr;
+       u32 nf;
+       u32 no;
+};
+
+enum {
+       VCO_MAX_HZ      = 2200U * 1000000,
+       VCO_MIN_HZ      = 440 * 1000000,
+       OUTPUT_MAX_HZ   = 2200U * 1000000,
+       OUTPUT_MIN_HZ   = 30 * 1000000,
+       FREF_MAX_HZ     = 2200U * 1000000,
+       FREF_MIN_HZ     = 30 * 1000,
+};
+
+enum {
+       /* PLL CON0 */
+       PLL_OD_MASK             = 0x0f,
+
+       /* PLL CON1 */
+       PLL_NF_MASK             = 0x1fff,
+
+       /* PLL CON2 */
+       PLL_BWADJ_MASK          = 0x0fff,
+
+       /* PLL CON3 */
+       PLL_RESET_SHIFT         = 5,
+
+       /* GRF_SOC_STATUS0 */
+       SOCSTS_DPLL_LOCK        = 1 << 5,
+       SOCSTS_APLL_LOCK        = 1 << 6,
+       SOCSTS_CPLL_LOCK        = 1 << 7,
+       SOCSTS_GPLL_LOCK        = 1 << 8,
+};
+
+#define RATE_TO_DIV(input_rate, output_rate) \
+       ((input_rate) / (output_rate) - 1);
+
+#define DIV_TO_RATE(input_rate, div)   ((input_rate) / ((div) + 1))
+
+#define PLL_DIVISORS(hz, _nr, _no) {\
+       .nr = _nr, .nf = (u32)((u64)hz * _nr * _no / OSC_HZ), .no = _no};\
+       _Static_assert(((u64)hz * _nr * _no / OSC_HZ) * OSC_HZ /\
+                      (_nr * _no) == hz, #hz "Hz cannot be hit with PLL

"\

drivers/clk/clk_rk3188.c new file +10 -0
+                      "divisors on line " __stringify(__LINE__));
+
+/* Keep divisors as low as possible to reduce jitter and power usage */
+static const struct pll_div apll_init_cfg = PLL_DIVISORS(APLL_HZ, 1, 1);
+static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 2, 2);
+static const struct pll_div cpll_init_cfg = PLL_DIVISORS(CPLL_HZ, 1, 2);
+
+void *rockchip_get_cru(void)
+{
+       struct rk3188_clk_priv *priv;
Quoted 8 lines
Quoted 6 lines
drivers/clk/clk_rk3188.c new file +5 -0
+       struct udevice *dev;
+       int ret;
+
+       ret = uclass_get_device_by_name(UCLASS_CLK,
+                                       "clock-controller at 20000000",

&dev);

This seems odd. Could you use uclass_get_device(UCLASS_CLK, 0, .&dev) ?

Quoted 3 lines

Index 0 actually gets me the 24MHz oscillator fixed clock :-), which is why I switched to the by-name variant to not depend on some dts or uclass ordering. I'm wondering how that works on the other socs.

I suspect this might have become broken by Stephen's clock changes. I had a bit of a look at this but have not resolved it yet. For example on firefly, HDMI does not work now.

There is this:

enum rk_clk_id {
CLK_OSC,
CLK_ARM,
CLK_DDR,
CLK_CODEC,
CLK_GENERAL,
CLK_NEW,

Quoted 7 lines

CLK_COUNT,
};

and it used to check against the platform data (see rkclk_get_clk() in v2016.05). I'll have a think about it.

Quoted 1 line

I found a problem here...please see:

http://patchwork.ozlabs.org/patch/649283/

Regards,
Simon

[...]

#30 lore raw

cover rockchip: cosmetics, a fix and first steps on the rk3188

In reply to Heiko Stuebner

Hi Heiko,

Quoted 11 lines · Heiko Stuebner

I've made some nice progress on using mainline uboot on the rk3188 and would like to dump some first results.

Right now I can use uboot on the rk3188 with the Rockchip binary ddr init, similar to what barebox does and can even netboot a kernel image using a usb ethernet adapter [0] .

While working on this I found quite some cosmetic stuff that shouldn't persist to make extending easier. So while I don't know what the policy is for my standalone pinctrl and clock drivers (without the actual board) at least the cosmetics + fix might get in at least.

Nice work!

It would be best to add the drivers with the board - otherwise they are just dead code. How far away is it?

Regards,
Simon

author maintainer
#31 lore raw

cover rockchip: cosmetics, a fix and first steps on the rk3188

Am Sonntag, 17. Juli 2016, 08:14:06 schrieb Simon Glass:

Quoted 15 lines

Hi Heiko,

Quoted 11 lines · Heiko Stuebner

I've made some nice progress on using mainline uboot on the rk3188 and would like to dump some first results.

Right now I can use uboot on the rk3188 with the Rockchip binary ddr init, similar to what barebox does and can even netboot a kernel image using a usb ethernet adapter [0] .

While working on this I found quite some cosmetic stuff that shouldn't persist to make extending easier. So while I don't know what the policy is for my standalone pinctrl and clock drivers (without the actual board) at least the cosmetics + fix might get in at least.

Quoted 4 lines

Nice work!

It would be best to add the drivers with the board - otherwise they are just dead code. How far away is it?

The big issue is the SPL. Right now I'm using Rockchip's ddr-init as spl- replacement, and I'd say this second part is nearly ready - only minor cleanups.

The memory-setup is supposed to be very much similar to the rk3288 (same dw_upctl and ddr-phy), but it looks like the very first steps are somewhat different and I haven't been able to make the spl output anything on the serial console yet ... which could stem from some difference in what the soc expects or just some dumb mistake on my part :-)

Heiko

#32 lore raw

cover rockchip: cosmetics, a fix and first steps on the rk3188

Hi Heiko,

Quoted 25 lines · Heiko St?bner

Am Sonntag, 17. Juli 2016, 08:14:06 schrieb Simon Glass:

Quoted 15 lines

Hi Heiko,

Quoted 11 lines · Heiko Stuebner

I've made some nice progress on using mainline uboot on the rk3188 and would like to dump some first results.

Right now I can use uboot on the rk3188 with the Rockchip binary ddr init, similar to what barebox does and can even netboot a kernel image using a usb ethernet adapter [0] .

While working on this I found quite some cosmetic stuff that shouldn't persist to make extending easier. So while I don't know what the policy is for my standalone pinctrl and clock drivers (without the actual board) at least the cosmetics + fix might get in at least.

Quoted 4 lines

Nice work!

It would be best to add the drivers with the board - otherwise they are just dead code. How far away is it?

The big issue is the SPL. Right now I'm using Rockchip's ddr-init as spl- replacement, and I'd say this second part is nearly ready - only minor cleanups.

Quoted 5 lines

The memory-setup is supposed to be very much similar to the rk3288 (same dw_upctl and ddr-phy), but it looks like the very first steps are somewhat different and I haven't been able to make the spl output anything on the serial console yet ... which could stem from some difference in what the soc expects or just some dumb mistake on my part :-)

That's always tricky.

You may already know this, but the EARLY_UART setting is used on rk3288 to display a character as soon as SPL starts. You might be able to do something similar. The main issue I had was getting the pinmux setting right.

As a test, you can start with booting SPL from the ddr-init binary I suspect. I have not tried it but it should work. Then the pinmux should already be set up (since ddr-init outputs to serial).

Regards,
Simon

#33 lore raw

cover rockchip: cosmetics, a fix and first steps on the rk3188

Hi Heiko,

Quoted 36 lines · Simon Glass

Hi Heiko,

Quoted 25 lines · Heiko St?bner

Am Sonntag, 17. Juli 2016, 08:14:06 schrieb Simon Glass:

Quoted 15 lines

Hi Heiko,

Quoted 11 lines · Heiko Stuebner

I've made some nice progress on using mainline uboot on the rk3188 and would like to dump some first results.

Right now I can use uboot on the rk3188 with the Rockchip binary ddr init, similar to what barebox does and can even netboot a kernel image using a usb ethernet adapter [0] .

While working on this I found quite some cosmetic stuff that shouldn't persist to make extending easier. So while I don't know what the policy is for my standalone pinctrl and clock drivers (without the actual board) at least the cosmetics + fix might get in at least.

Quoted 4 lines

Nice work!

It would be best to add the drivers with the board - otherwise they are just dead code. How far away is it?

The big issue is the SPL. Right now I'm using Rockchip's ddr-init as spl- replacement, and I'd say this second part is nearly ready - only minor cleanups.

Quoted 5 lines

The memory-setup is supposed to be very much similar to the rk3288 (same dw_upctl and ddr-phy), but it looks like the very first steps are somewhat different and I haven't been able to make the spl output anything on the serial console yet ... which could stem from some difference in what the soc expects or just some dumb mistake on my part :-)

That's always tricky.

Quoted 8 lines

You may already know this, but the EARLY_UART setting is used on rk3288 to display a character as soon as SPL starts. You might be able to do something similar. The main issue I had was getting the pinmux setting right.

As a test, you can start with booting SPL from the ddr-init binary I suspect. I have not tried it but it should work. Then the pinmux should already be set up (since ddr-init outputs to serial).

I'm going to apply the earlier patches in your series. Once you have a working board we can apply the rest (to avoid adding dead code).

Regards,
Simon

author maintainer
#34 lore raw

cover rockchip: cosmetics, a fix and first steps on the rk3188

Hi Simon,

Am Montag, 18. Juli 2016, 06:16:33 schrieb Simon Glass:

Quoted 39 lines · Simon Glass
Quoted 38 lines · Heiko St?bner
Quoted 28 lines

Am Sonntag, 17. Juli 2016, 08:14:06 schrieb Simon Glass:

Quoted 18 lines

Hi Heiko,

Quoted 8 lines · Heiko Stuebner

I've made some nice progress on using mainline uboot on the rk3188 and would like to dump some first results.

Right now I can use uboot on the rk3188 with the Rockchip binary ddr init,
similar to what barebox does and can even netboot a kernel image using a usb ethernet adapter [0] .

Quoted 6 lines

While working on this I found quite some cosmetic stuff that shouldn't persist to make extending easier. So while I don't know what the policy
is for my standalone pinctrl and clock drivers (without the actual board)
at least the cosmetics + fix might get in at least.

Quoted 4 lines

Nice work!

It would be best to add the drivers with the board - otherwise they are just dead code. How far away is it?

The big issue is the SPL. Right now I'm using Rockchip's ddr-init as spl- replacement, and I'd say this second part is nearly ready - only minor cleanups.

Quoted 6 lines

The memory-setup is supposed to be very much similar to the rk3288 (same dw_upctl and ddr-phy), but it looks like the very first steps are somewhat
different and I haven't been able to make the spl output anything on the serial console yet ... which could stem from some difference in what the soc expects or just some dumb mistake on my part :-)

That's always tricky.

Quoted 8 lines
Quoted 8 lines

You may already know this, but the EARLY_UART setting is used on rk3288 to display a character as soon as SPL starts. You might be able to do something similar. The main issue I had was getting the pinmux setting right.

As a test, you can start with booting SPL from the ddr-init binary I suspect. I have not tried it but it should work. Then the pinmux should already be set up (since ddr-init outputs to serial).

yep, changing the SPL_TEXT_BASE to the ram address and using the spl as 2nd stage brings me the expected
earlyuart running
message.

I've also dumped the sram contents after a sucessful boot using the rk ddr- init + uboot and can see that the ddr-init is sitting at the 0x800 offset in sram - including the rk31 header, so I'm pretty sure the sram-based SPL_TEXT_BASE should be 0x10080804 - yet no lifesign.

Judging by how the rk3036 declares its SPL_STACK, I guess 0x10087fff should also be right.

Quoted 2 lines

I'm going to apply the earlier patches in your series. Once you have a working board we can apply the rest (to avoid adding dead code).

great ... everything I don't need to carry over helps ;-) .

Going forward, I see both the rk3368 and rk3399 support initially not providing a spl but sitting on top of the binary ddr init + ATF. Is that also something doable for my rk3188 or do you _require_ the spl there?

I.e. bringing the support without spl forward should be fairly easy, so doing that first sounds nice, before worrying about the strange things the SPL needs.

Heiko

#35 lore raw

cover rockchip: cosmetics, a fix and first steps on the rk3188

Hi Heiko,

Quoted 70 lines · Heiko St?bner

Hi Simon,

Am Montag, 18. Juli 2016, 06:16:33 schrieb Simon Glass:

Quoted 39 lines · Simon Glass
Quoted 38 lines · Heiko St?bner
Quoted 28 lines

Am Sonntag, 17. Juli 2016, 08:14:06 schrieb Simon Glass:

Quoted 18 lines

Hi Heiko,

Quoted 8 lines · Heiko Stuebner

I've made some nice progress on using mainline uboot on the rk3188 and would like to dump some first results.

Right now I can use uboot on the rk3188 with the Rockchip binary ddr init,
similar to what barebox does and can even netboot a kernel image using a usb ethernet adapter [0] .

Quoted 6 lines

While working on this I found quite some cosmetic stuff that shouldn't persist to make extending easier. So while I don't know what the policy
is for my standalone pinctrl and clock drivers (without the actual board)
at least the cosmetics + fix might get in at least.

Quoted 4 lines

Nice work!

It would be best to add the drivers with the board - otherwise they are just dead code. How far away is it?

The big issue is the SPL. Right now I'm using Rockchip's ddr-init as spl- replacement, and I'd say this second part is nearly ready - only minor cleanups.

Quoted 6 lines

The memory-setup is supposed to be very much similar to the rk3288 (same dw_upctl and ddr-phy), but it looks like the very first steps are somewhat
different and I haven't been able to make the spl output anything on the serial console yet ... which could stem from some difference in what the soc expects or just some dumb mistake on my part :-)

That's always tricky.

Quoted 8 lines
Quoted 8 lines

You may already know this, but the EARLY_UART setting is used on rk3288 to display a character as soon as SPL starts. You might be able to do something similar. The main issue I had was getting the pinmux setting right.

As a test, you can start with booting SPL from the ddr-init binary I suspect. I have not tried it but it should work. Then the pinmux should already be set up (since ddr-init outputs to serial).

yep, changing the SPL_TEXT_BASE to the ram address and using the spl as 2nd stage brings me the expected
earlyuart running
message.

I've also dumped the sram contents after a sucessful boot using the rk ddr- init + uboot and can see that the ddr-init is sitting at the 0x800 offset in sram - including the rk31 header, so I'm pretty sure the sram-based SPL_TEXT_BASE should be 0x10080804 - yet no lifesign.

Judging by how the rk3036 declares its SPL_STACK, I guess 0x10087fff should also be right.

Quoted 2 lines

I'm going to apply the earlier patches in your series. Once you have a working board we can apply the rest (to avoid adding dead code).

great ... everything I don't need to carry over helps ;-) .

Quoted 6 lines

Going forward, I see both the rk3368 and rk3399 support initially not providing a spl but sitting on top of the binary ddr init + ATF. Is that also something doable for my rk3188 or do you _require_ the spl there?

I.e. bringing the support without spl forward should be fairly easy, so doing that first sounds nice, before worrying about the strange things the SPL needs.

That it because we don't have a good story for how to integrate ATF with SPL at present (on ARMv8). I would much prefer to avoid this on rk3188. Can you perhaps ask the Rockchip people on the list for help?

Regards,
Simon