Skip to contentSkip to conversation

Support OF_PLATDATA in TPL, enable RK3368 DRAM init and add RK3368-uQ7

PATCH New Philipp Tomsich 6 participants 75 messages Jul 18, 2017 – Jul 24, 2017

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

cover Support OF_PLATDATA in TPL, enable RK3368 DRAM init and add RK3368-uQ7

Here's a series that has a lot going on, but I didn't want to split it to allow everyone to understand the motivation between some of the changes to the SPL/TPL framework. The short summary of this is "enablement for DRAM init on the RK3368 with everything else that's necessary to do it using OF_PLATDATA in TPL".

Enabling the RK3368 created a few more challenges that I'd expected:
- I needed different stack locations, text addresses and sizes for TPL and SPL
- the TPL stage was to use OF_PLATDATA and SPL was to use full OF_CONTROL
- with the RK3368 TPL stage, there was a need to extend the back-to-bootrom support for Rockchip to AArch64
- I wanted to start folding some of the Rockchip specific SPL support (i.e. back-to-bootrom) back into the general SPL framework to allow using it as a general boot method

So I ended up separating quite a bit of features between SPL and TPL while keeping things transparent to the few other boards using TPL (at least I hope that things are transparent, as we didn't have any of those in our lab to test on)...

Tested with: RK3368-uQ7, Debian 9, Linux 4.13-rc1.

Just one final remark: the DMC driver for the RK3368 currently covers the configuration we use on the RK3368-uQ7 (i.e. 32bit wide, 2 ranks) and is stress-tested (including 8-way SPEC runs) at all 3 supported speeds. I've built a bit of infrastructure (e.g. the way the memory-schedule is determined) that I hope will be a useful starting-point in unifying the drivers for the various closely related DRAM controllers (e.g. for the RK3288) for Rockchip devices in the future.

Klaus Goger (1):
rockchip: board: puma_rk3399: rename ATF firmware

Philipp Tomsich (51):
spl: add a 'return to bootrom' boot method
spl: configure 'return to bootrom' separately for SPL and TPL
rockchip: back-to-bootrom: add 'back-to-bootrom' support for AArch64
rockchip: back-to-bootrom: split BACK_TO_BOOTROM for TPL/SPL
rockchip: back-to-bootrom: simplify the #ifdef-check for LIBGENERIC in
TPL/SPL
spl: dm: Kconfig: use more specific prereqs for SPL_REGMAP and
SPL_SYSCON
spl: dm: Kconfig: split REGMAP/SYSCON support for TPL from SPL
spl: dm: Kconfig: SPL_RAM depends on SPL_DM
spl: dm: Kconfig: introduce TPL_RAM (in analogy to SPL_RAM)
spl: dm: Kconfig: SPL_CLK depens on SPL_DM
spl: dm: Kconfig: split CLK support for SPL and TPL
spl: dm: Kconfig: split OF_CONTROL and OF_PLATDATA between SPL and TPL
spl: dm: use CONFIG_IS_ENABLED to test for the DM option
armv8: remove unused low-level modules from TPL
armv8: spl: Support separate stack for TPL
spl: allow a separate TEXT_BASE, LDSCRIPT and MAX_SIZE for TPL
spl: Kconfig: split SYS_MALLOC_SIMPLE for TPL and SPL
lib: spl: differentiate between TPL and SPL for
libfdt/of_control/of_platdata
spl: consistently use $(SPL_TPL_) to select features for SPL and TPL
builds
spl: add TPL_DRIVER_MISC_SUPPORT option
drivers: spl: consistently use the $(SPL_TPL_) macro
rockchip: Makefile: allow selective inclusion of sdram_common.o from
TPL/SPL/U-Boot
rockchip: rk3368: improve Kconfig text for the RK3368
rockchip: rk3368: mkimage: add support for the RK3368
rockchip: rk3368: pmugrf: add definitions for os_reg[0..3]
rockchip: rk3368: define CONFIG_SYS_SDRAM_BASE
rockchip: rk3368: spl: define COUNTER_FREQUENCY to 24MHz
rockchip: rk3368: spl: add memory layout for TPL and SPL
rockchip: rk3368: syscon: MSCH/PMUGRF/GRF support for OF_PLATDATA
rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_
rockchip: pinctrl: rk3368: add GMAC (RGMII only) support
rockchip: pinctrl: rk3368: add support for configuring the MMC pins
rockchip: clk: rk3368: implement bandwidth adjust for PLLs
rockchip: clk: rk3368: support OF_PLATDATA for the RK3368 clk driver
rockchip: clk: rk3368: do not change CPLL/GPLL before returning to
BROM
rockchip: clk: rk3368: implement DPLL (DRAM PLL) support
rockchip: clk: rk3368: define DMA1_SRST_REQ and DMA2_SRST_REQ
rockchip: clk: rk3368: implement MMC/SD clock reparenting
rockchip: clk: rk3368: support configuring the DRAM PLL (from TPL)
rockchip: clk: rk3368: add support for GMAC (SLCK_MAC) clock
rockchip: clk: rk3368: mark 'priv' __maybe_unused in

    rk3368_clk_set_rate()
  net: gmac_rockchip: Add support for the RK3368 GMAC
  rockchip: Makefile: streamline SPL/TPL configuration
  rockchip: rk3368: add DRAM controller driver with DRAM initialisation
  rockchip: dts: rk3368: add DMC node in rk3368.dtsi
  rockchip: rk3368: spl: enable SPL_FRAMEWORK in rk3368_common.h
  rockchip: rk3368: spl: add TPL support
  rockchip: rk3368: spl: add SPL support
  rockchip: rk3368: spl: mark SPL and TPL as supported for
    ROCKCHIP_RK3368
  rockchip: board: lion-rk3368: add support for the RK3368-uQ7
  rockchip: board: puma-rk3399: fix warnings in
    puma_rk3399/fit_spl_atf.its
 Makefile                                           |   2 +-
 arch/arm/cpu/armv8/Makefile                        |   4 +-
 arch/arm/dts/Makefile                              |   1 +
 arch/arm/dts/rk3368-lion.dts                       | 209 +++++
 arch/arm/dts/rk3368.dtsi                           |  26 +-
 arch/arm/include/asm/arch-rockchip/cru_rk3368.h    |  15 +-
 arch/arm/include/asm/arch-rockchip/ddr_rk3368.h    | 187 ++++
 arch/arm/include/asm/arch-rockchip/grf_rk3368.h    | 615 +++++++------
 arch/arm/include/asm/spl.h                         |   1 +
 arch/arm/lib/crt0_64.S                             |   4 +-
 arch/arm/mach-rockchip/Kconfig                     |  37 +-
 arch/arm/mach-rockchip/Makefile                    |  51 +-
 arch/arm/mach-rockchip/bootrom.c                   |   4 +-
 arch/arm/mach-rockchip/rk3188-board-spl.c          |   5 +-
 arch/arm/mach-rockchip/rk3188-board.c              |   2 +-
 arch/arm/mach-rockchip/rk3288-board-spl.c          |   4 +-
 arch/arm/mach-rockchip/rk3288-board.c              |   4 +-
 arch/arm/mach-rockchip/rk3368-board-spl.c          |  91 ++
 arch/arm/mach-rockchip/rk3368-board-tpl.c          | 158 ++++
 arch/arm/mach-rockchip/rk3368/Kconfig              |  21 +
 arch/arm/mach-rockchip/rk3368/Makefile             |   1 -
 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c       |  60 --
 arch/arm/mach-rockchip/rk3368/syscon_rk3368.c      |  35 +
 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds       |  13 +
 arch/arm/mach-rockchip/rk3399-board-spl.c          |   4 +-
 arch/arm/mach-rockchip/save_boot_param.S           |  37 +
 board/theobroma-systems/lion_rk3368/Kconfig        |  15 +
 board/theobroma-systems/lion_rk3368/MAINTAINERS    |  10 +
 board/theobroma-systems/lion_rk3368/Makefile       |   7 +
 board/theobroma-systems/lion_rk3368/README         |  60 ++
 .../theobroma-systems/lion_rk3368/fit_spl_atf.its  |  51 ++
 board/theobroma-systems/lion_rk3368/lion_rk3368.c  |  25 +
 board/theobroma-systems/puma_rk3399/README         |   2 +-
 .../theobroma-systems/puma_rk3399/fit_spl_atf.its  |  20 +-
 common/Makefile                                    |   8 +-
 common/spl/Kconfig                                 |  39 +
 common/spl/Makefile                                |  35 +-
 common/spl/spl.c                                   |   5 +-
 common/spl/spl_bootrom.c                           |  27 +
 configs/evb-rk3288_defconfig                       |   2 +-
 configs/fennec-rk3288_defconfig                    |   2 +-
 configs/firefly-rk3288_defconfig                   |   2 +-
 configs/lion-rk3368_defconfig                      |  79 ++
 configs/miqi-rk3288_defconfig                      |   2 +-
 configs/popmetal-rk3288_defconfig                  |   2 +-
 configs/rock2_defconfig                            |   2 +-
 configs/rock_defconfig                             |   2 +-
 configs/tinker-rk3288_defconfig                    |   2 +-
 doc/README.rockchip                                |   2 +-
 .../clock/rockchip,rk3368-dmc.txt                  |  67 ++
 drivers/Makefile                                   |  36 +-
 drivers/clk/Kconfig                                |  12 +-
 drivers/clk/Makefile                               |   2 +-
 drivers/clk/rockchip/clk_rk3368.c                  | 222 ++++-
 drivers/core/Kconfig                               |  23 +-
 drivers/core/Makefile                              |   4 +-
 drivers/net/gmac_rockchip.c                        |  54 ++
 drivers/pinctrl/rockchip/pinctrl_rk3368.c          | 101 ++-
 drivers/ram/Kconfig                                |  11 +-
 drivers/ram/Makefile                               |   2 +
 drivers/ram/rockchip/Makefile                      |   7 +
 drivers/ram/rockchip/dmc-rk3368.c                  | 990 +++++++++++++++++++++
 dts/Kconfig                                        |  29 +
 include/configs/lion_rk3368.h                      |  19 +
 include/configs/rk3188_common.h                    |   2 +-
 include/configs/rk3288_common.h                    |   2 +-
 include/configs/rk3368_common.h                    |  15 +
 include/configs/rock.h                             |   2 +-
 include/configs/rockchip-common.h                  |   2 +-
 include/dt-bindings/memory/rk3368-dmc.h            |  30 +
 include/linux/kconfig.h                            |  13 +
 include/spl.h                                      |  10 +
 lib/Makefile                                       |  10 +-
 scripts/Makefile.spl                               |  14 +-
 scripts/config_whitelist.txt                       |   4 +
 tools/rkcommon.c                                   |   1 +
 76 files changed, 3142 insertions(+), 534 deletions(-)
 create mode 100644 arch/arm/dts/rk3368-lion.dts
 create mode 100644 arch/arm/include/asm/arch-rockchip/ddr_rk3368.h
 create mode 100644 arch/arm/mach-rockchip/rk3368-board-spl.c
 create mode 100644 arch/arm/mach-rockchip/rk3368-board-tpl.c
 delete mode 100644 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c
 create mode 100644 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds
 create mode 100644 board/theobroma-systems/lion_rk3368/Kconfig
 create mode 100644 board/theobroma-systems/lion_rk3368/MAINTAINERS
 create mode 100644 board/theobroma-systems/lion_rk3368/Makefile
 create mode 100644 board/theobroma-systems/lion_rk3368/README
 create mode 100644 board/theobroma-systems/lion_rk3368/fit_spl_atf.its
 create mode 100644 board/theobroma-systems/lion_rk3368/lion_rk3368.c
 create mode 100644 common/spl/spl_bootrom.c
 create mode 100644 configs/lion-rk3368_defconfig
 create mode 100644 doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt
 create mode 100644 drivers/ram/rockchip/Makefile
 create mode 100644 drivers/ram/rockchip/dmc-rk3368.c
 create mode 100644 include/configs/lion_rk3368.h
 create mode 100644 include/dt-bindings/memory/rk3368-dmc.h
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/52 spl: add a 'return to bootrom' boot method

Some devices (e.g. the RK3368) have only limited SRAM, but provide support for loading the next boot stage after our SPL performs basic setup (e.g. DRAM).

For target systems like these, we add a boot device BOOTROM that will invoke a board-specific hook to return to the bootrom (if supported).

---

 arch/arm/include/asm/spl.h |  1 +
 common/spl/Kconfig         | 11 +++++++++++
 common/spl/Makefile        |  1 +
 common/spl/spl_bootrom.c   | 27 +++++++++++++++++++++++++++
 include/spl.h              | 10 ++++++++++
 5 files changed, 50 insertions(+)
 create mode 100644 common/spl/spl_bootrom.c
arch/arm/include/asm/spl.h +1 -0
index 0e67470..df45511 100644
@@ -30,6 +30,7 @@ enum {
 	BOOT_DEVICE_BOARD,
 	BOOT_DEVICE_DFU,
 	BOOT_DEVICE_XIP,
+	BOOT_DEVICE_BOOTROM,
 	BOOT_DEVICE_NONE
 };
 #endif
common/spl/Kconfig +11 -0
index 4de8139..ee767b7 100644
@@ -25,6 +25,17 @@ config SPL_BOARD_INIT
 	  spl_board_init() from board_init_r(). This function should be
 	  provided by the board.
 
+config SPL_BOOTROM_SUPPORT
+        bool "Support returning to the BOOTROM"
+	help
+	  Some platforms (e.g. the Rockchip RK3368) provide support in their
+	  ROM for loading the next boot-stage after performing basic setup
+	  from the SPL stage.
+
+	  Enable this option, to return to the BOOTROM through the
+	  BOOT_DEVICE_BOOTROM (or fall-through to the next boot device in the
+	  boot device list, if not implemented for a given board)
+
 config SPL_RAW_IMAGE_SUPPORT
 	bool "Support SPL loading and booting of RAW images"
 	default n if (ARCH_MX6 && (SPL_MMC_SUPPORT || SPL_SATA_SUPPORT))
common/spl/Makefile +1 -0
index 47a64dd..189b272 100644
@@ -10,6 +10,7 @@
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_FRAMEWORK) += spl.o
+obj-$(CONFIG_SPL_BOOTROM_SUPPORT) += spl_bootrom.o
 obj-$(CONFIG_SPL_LOAD_FIT) += spl_fit.o
 obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o
 obj-$(CONFIG_SPL_XIP_SUPPORT) += spl_xip.o
common/spl/spl_bootrom.c new file +27 -0
new file mode 100644
index 0000000..6804246
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2017 Theobroma Systems Design und Consulting GmH
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <spl.h>
+
+__weak void board_return_to_bootrom(void)
+{
+}
+
+static int spl_return_to_bootrom(struct spl_image_info *spl_image,
+				 struct spl_boot_device *bootdev)
+{
+	/*
+	 * If the board implements a way to return to its ROM (with
+	 * the expectation that the next stage of will be booted by
+	 * the ROM), it will implement board_return_to_bootrom() and
+	 * should not return from it.
+	 */
+	board_return_to_bootrom();
+	return false;
+}
+
+SPL_LOAD_IMAGE_METHOD("BOOTROM", 0, BOOT_DEVICE_BOOTROM, spl_return_to_bootrom);
include/spl.h +10 -0
index ccb1404..b5c2994 100644
@@ -278,4 +278,14 @@ int spl_mmc_load_image(struct spl_image_info *spl_image,
 		       struct spl_boot_device *bootdev);
 
 void bl31_entry(void);
+
+/**
+ * board_return_to_bootrom - allow for boards to continue with the boot ROM
+ *
+ * If a board (e.g. the Rockchip RK3368 boards) provide some
+ * supporting functionality for SPL in their boot ROM and the SPL
+ * stage wants to return to the ROM code to continue booting, boards
+ * can implement 'board_return_to_bootrom'.
+ */
+void board_return_to_bootrom(void);
 #endif
Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/52 spl: configure 'return to bootrom' separately for SPL and TPL

In reply to Philipp Tomsich

On the RK3368, we want our TPL to use the 'return to bootrom' boot method (to have the bootrom load up the SPL stage) and then continue with different boot methods (MMC, SPI, etc.) from SPL.

This adds the config option needed to control the availabily of the 'return to bootrom' boot-method separately for the TPL stage.

---

 common/spl/Kconfig | 11 +++++++++++
 1 file changed, 11 insertions(+)
common/spl/Kconfig +11 -0
index ee767b7..dd94801 100644
@@ -698,6 +698,17 @@ config TPL
 
 if TPL
 
+config TPL_BOOTROM_SUPPORT
+        bool "Support returning to the BOOTROM (from TPL)"
+	help
+	  Some platforms (e.g. the Rockchip RK3368) provide support in their
+	  ROM for loading the next boot-stage after performing basic setup
+	  from the TPL stage.
+
+	  Enable this option, to return to the BOOTROM through the
+	  BOOT_DEVICE_BOOTROM (or fall-through to the next boot device in the
+	  boot device list, if not implemented for a given board)
+
 config TPL_ENV_SUPPORT
 	bool "Support an environment"
 	help
Signature · 1 line
2.1.4
#3 lore raw

PATCH 3/52 rockchip: back-to-bootrom: add 'back-to-bootrom' support for AArch64

In reply to Philipp Tomsich

The back-to-bootrom support for Rockchip is equivalent to an (assembly) implementation of setjmp/longjmp (i.e. it saves the stack-pointer, link-register and callee-saved registers). Up until now, this had only been implemented for AArch32 (i.e. ARMv7 or older), which puts the new ARMv8 devices (which boot in AArch64 mode) at a slight disadvantage.

To allow use of the 'back-to-bootrom' feature on new devices (e.g. the RK3368), this commit adds an implementation for AArch64.

---

 arch/arm/mach-rockchip/save_boot_param.S | 37 ++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
arch/arm/mach-rockchip/save_boot_param.S +37 -0
index 5e6c8db..945a9dd 100644
@@ -1,11 +1,47 @@
 /*
  * (C) Copyright 2016 Rockchip Electronics Co., Ltd
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
  *
  * SPDX-License-Identifier:     GPL-2.0+
  */
 
 #include <linux/linkage.h>
 
+#if defined(CONFIG_ARM64)
+.globl	SAVE_SP_ADDR
+SAVE_SP_ADDR:
+	.quad 0
+
+ENTRY(save_boot_params)
+	sub	sp, sp, #0x100
+	stp	x29, x30, [sp, #0x50]
+	stp	x27, x28, [sp, #0x40]
+	stp	x25, x26, [sp, #0x30]
+	stp	x23, x24, [sp, #0x20]
+	stp	x21, x22, [sp, #0x10]
+	stp	x19, x20, [sp, #0]
+	ldr	x8, =SAVE_SP_ADDR
+	mov	x9, sp
+	str	x9, [x8]
+	b	save_boot_params_ret  /* back to my caller */
+ENDPROC(save_boot_params)
+
+.globl _back_to_bootrom_s
+ENTRY(_back_to_bootrom_s)
+	ldr	x0, =SAVE_SP_ADDR
+	ldr	x0, [x0]
+	mov	sp, x0
+	ldp	x29, x30, [sp, #0x50]
+	ldp	x27, x28, [sp, #0x40]
+	ldp	x25, x26, [sp, #0x30]
+	ldp	x23, x24, [sp, #0x20]
+	ldp	x21, x22, [sp, #0x10]
+	ldp	x19, x20, [sp]
+	add	sp, sp, #0x100
+	mov	x0, xzr
+	ret
+ENDPROC(_back_to_bootrom_s)
+#else
 .globl	SAVE_SP_ADDR
 SAVE_SP_ADDR:
 	.word 0
@@ -30,3 +66,4 @@ ENTRY(_back_to_bootrom_s)
 	mov	r0, #0
 	pop	{r1-r12, pc}
 ENDPROC(_back_to_bootrom_s)
+#endif
Signature · 1 line
2.1.4
#4 lore raw

PATCH 4/52 rockchip: back-to-bootrom: split BACK_TO_BOOTROM for TPL/SPL

In reply to Philipp Tomsich

The back-to-bootrom option is rather unfortunately named
CONFIG_ROCKCHIP_SPL_BACK_TO_BOOTROM
instead of
CONFIG_SPL_ROCKCHIP_BACK_TO_BOOTROM

To make is selectable through CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BOOTROM), we need to rename it. At the same time, we introduce a TPL_ variant of the option to give us finer-grained control over when it should be used.

This change is motivated by our RK3368 boot process, which returns to the boot ROM only from the TPL stage, but not from the SPL stage.

---

 arch/arm/mach-rockchip/Kconfig            | 15 +++++++++++++--
 arch/arm/mach-rockchip/rk3188-board-spl.c |  5 ++---
 arch/arm/mach-rockchip/rk3188-board.c     |  2 +-
 arch/arm/mach-rockchip/rk3288-board-spl.c |  4 ++--
 arch/arm/mach-rockchip/rk3288-board.c     |  4 ++--
 arch/arm/mach-rockchip/rk3399-board-spl.c |  4 ++--
 configs/evb-rk3288_defconfig              |  2 +-
 configs/fennec-rk3288_defconfig           |  2 +-
 configs/firefly-rk3288_defconfig          |  2 +-
 configs/miqi-rk3288_defconfig             |  2 +-
 configs/popmetal-rk3288_defconfig         |  2 +-
 configs/rock2_defconfig                   |  2 +-
 configs/rock_defconfig                    |  2 +-
 configs/tinker-rk3288_defconfig           |  2 +-
 doc/README.rockchip                       |  2 +-
 include/configs/rk3188_common.h           |  2 +-
 include/configs/rk3288_common.h           |  2 +-
 include/configs/rock.h                    |  2 +-
 include/configs/rockchip-common.h         |  2 +-
 19 files changed, 35 insertions(+), 25 deletions(-)
arch/arm/mach-rockchip/Kconfig +13 -2
index bb44c61..523bc11 100644
@@ -99,10 +99,21 @@ config ROCKCHIP_RV1108
 	  The Rockchip RV1108 is a ARM-based SoC with a single-core Cortex-A7
 	  and a DSP.
 
-config ROCKCHIP_SPL_BACK_TO_BROM
+config SPL_ROCKCHIP_BACK_TO_BROM
 	bool "SPL returns to bootrom"
 	default y if ROCKCHIP_RK3036
 	select ROCKCHIP_BROM_HELPER
+	depends on SPL
+	help
+	  Rockchip SoCs have ability to load SPL & U-Boot binary. If enabled,
+          SPL will return to the boot rom, which will then load the U-Boot
+          binary to keep going on.
+
+config TPL_ROCKCHIP_BACK_TO_BROM
+	bool "TPL returns to bootrom"
+	default y if ROCKCHIP_RK3368
+	select ROCKCHIP_BROM_HELPER
+	depends on TPL
 	help
 	  Rockchip SoCs have ability to load SPL & U-Boot binary. If enabled,
           SPL will return to the boot rom, which will then load the U-Boot
@@ -120,7 +131,7 @@ config ROCKCHIP_BROM_HELPER
 	bool
 
 config SPL_MMC_SUPPORT
-	default y if !ROCKCHIP_SPL_BACK_TO_BROM
+	default y if !SPL_ROCKCHIP_BACK_TO_BROM
 
 source "arch/arm/mach-rockchip/rk3036/Kconfig"
 source "arch/arm/mach-rockchip/rk3188/Kconfig"
arch/arm/mach-rockchip/rk3188-board-spl.c +2 -3
index c3e174d..d3866bf 100644
@@ -167,8 +167,7 @@ void board_init_f(ulong dummy)
 	}
 
 	setup_arm_clock();
-
-#if defined(CONFIG_ROCKCHIP_SPL_BACK_TO_BROM) && !defined(CONFIG_SPL_BOARD_INIT)
+#if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM) && !defined(CONFIG_SPL_BOARD_INIT)
 	back_to_bootrom();
 #endif
 }
@@ -229,7 +228,7 @@ void spl_board_init(void)
 	}
 
 	preloader_console_init();
-#ifdef CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
+#if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM)
 	back_to_bootrom();
 #endif
 	return;
arch/arm/mach-rockchip/rk3188-board.c +1 -1
index 3e76100..622e046 100644
@@ -39,7 +39,7 @@ int board_late_init(void)
 
 int board_init(void)
 {
-#if defined(CONFIG_ROCKCHIP_SPL_BACK_TO_BROM)
+#if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM)
 	struct udevice *pinctrl;
 	int ret;
 
arch/arm/mach-rockchip/rk3288-board-spl.c +2 -2
index 5668fd2..6b7bf85 100644
@@ -249,7 +249,7 @@ void board_init_f(ulong dummy)
 		debug("DRAM init failed: %d\n", ret);
 		return;
 	}
-#if defined(CONFIG_ROCKCHIP_SPL_BACK_TO_BROM) && !defined(CONFIG_SPL_BOARD_INIT)
+#if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM) && !defined(CONFIG_SPL_BOARD_INIT)
 	back_to_bootrom();
 #endif
 }
@@ -316,7 +316,7 @@ void spl_board_init(void)
 	}
 
 	preloader_console_init();
-#ifdef CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
+#if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM)
 	back_to_bootrom();
 #endif
 	return;
arch/arm/mach-rockchip/rk3288-board.c +2 -2
index 613967c..272f079 100644
@@ -78,7 +78,7 @@ int board_late_init(void)
 	return rk_board_late_init();
 }
 
-#ifndef CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
+#if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM)
 static int veyron_init(void)
 {
 	struct udevice *dev;
@@ -115,7 +115,7 @@ static int veyron_init(void)
 
 int board_init(void)
 {
-#ifdef CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
+#if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM)
 	struct udevice *pinctrl;
 	int ret;
 
arch/arm/mach-rockchip/rk3399-board-spl.c +2 -2
index e050aff..710f7fe 100644
@@ -28,7 +28,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OF_CONTROL)
+#if CONFIG_IS_ENABLED(OF_CONTROL)
 static int spl_node_to_boot_device(int node)
 {
 	struct udevice *parent;
@@ -263,7 +263,7 @@ void spl_board_init(void)
 	}
 
 	preloader_console_init();
-#ifdef CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
+#if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM)
 	back_to_bootrom();
 #endif
 
configs/evb-rk3288_defconfig +1 -1
index 0d28311..14345be 100644
@@ -2,7 +2,7 @@ CONFIG_ARM=y
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_ROCKCHIP_RK3288=y
-CONFIG_ROCKCHIP_SPL_BACK_TO_BROM=y
+CONFIG_SPL_ROCKCHIP_BACK_TO_BROM=y
 CONFIG_TARGET_EVB_RK3288=y
 CONFIG_SPL_STACK_R_ADDR=0x80000
 CONFIG_DEFAULT_DEVICE_TREE="rk3288-evb"
configs/fennec-rk3288_defconfig +1 -1
index 3a51da8..92be959 100644
@@ -2,7 +2,7 @@ CONFIG_ARM=y
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_ROCKCHIP_RK3288=y
-CONFIG_ROCKCHIP_SPL_BACK_TO_BROM=y
+CONFIG_SPL_ROCKCHIP_BACK_TO_BROM=y
 CONFIG_TARGET_FENNEC_RK3288=y
 CONFIG_SPL_STACK_R_ADDR=0x80000
 CONFIG_DEFAULT_DEVICE_TREE="rk3288-fennec"
configs/firefly-rk3288_defconfig +1 -1
index 6f093f4..7df9d09 100644
@@ -2,7 +2,7 @@ CONFIG_ARM=y
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_ROCKCHIP_RK3288=y
-CONFIG_ROCKCHIP_SPL_BACK_TO_BROM=y
+CONFIG_SPL_ROCKCHIP_BACK_TO_BROM=y
 CONFIG_TARGET_FIREFLY_RK3288=y
 CONFIG_SPL_STACK_R_ADDR=0x80000
 CONFIG_DEFAULT_DEVICE_TREE="rk3288-firefly"
configs/miqi-rk3288_defconfig +1 -1
index c6bfa1e..29bdcdb 100644
@@ -2,7 +2,7 @@ CONFIG_ARM=y
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_ROCKCHIP_RK3288=y
-CONFIG_ROCKCHIP_SPL_BACK_TO_BROM=y
+CONFIG_SPL_ROCKCHIP_BACK_TO_BROM=y
 CONFIG_TARGET_MIQI_RK3288=y
 CONFIG_SPL_STACK_R_ADDR=0x80000
 CONFIG_DEFAULT_DEVICE_TREE="rk3288-miqi"
configs/popmetal-rk3288_defconfig +1 -1
index 6d02675..1392d6f 100644
@@ -2,7 +2,7 @@ CONFIG_ARM=y
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_ROCKCHIP_RK3288=y
-CONFIG_ROCKCHIP_SPL_BACK_TO_BROM=y
+CONFIG_SPL_ROCKCHIP_BACK_TO_BROM=y
 CONFIG_TARGET_POPMETAL_RK3288=y
 CONFIG_SPL_STACK_R_ADDR=0x80000
 CONFIG_DEFAULT_DEVICE_TREE="rk3288-popmetal"
configs/rock2_defconfig +1 -1
index eec0613..831d977 100644
@@ -2,7 +2,7 @@ CONFIG_ARM=y
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_ROCKCHIP_RK3288=y
-CONFIG_ROCKCHIP_SPL_BACK_TO_BROM=y
+CONFIG_SPL_ROCKCHIP_BACK_TO_BROM=y
 CONFIG_TARGET_ROCK2=y
 CONFIG_SPL_STACK_R_ADDR=0x80000
 CONFIG_DEFAULT_DEVICE_TREE="rk3288-rock2-square"
configs/rock_defconfig +1 -1
index 5d9b63b..b7fb07f 100644
@@ -4,7 +4,7 @@ CONFIG_ARM=y
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_ROCKCHIP_RK3188=y
-CONFIG_ROCKCHIP_SPL_BACK_TO_BROM=y
+CONFIG_SPL_ROCKCHIP_BACK_TO_BROM=y
 CONFIG_TARGET_ROCK=y
 CONFIG_SPL_STACK_R_ADDR=0x60080000
 CONFIG_DEFAULT_DEVICE_TREE="rk3188-radxarock"
configs/tinker-rk3288_defconfig +1 -1
index c46bacc..b2124b1 100644
@@ -2,7 +2,7 @@ CONFIG_ARM=y
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_ROCKCHIP_RK3288=y
-CONFIG_ROCKCHIP_SPL_BACK_TO_BROM=y
+CONFIG_SPL_ROCKCHIP_BACK_TO_BROM=y
 CONFIG_TARGET_TINKER_RK3288=y
 CONFIG_SPL_STACK_R_ADDR=0x80000
 CONFIG_DEFAULT_DEVICE_TREE="rk3288-tinker"
doc/README.rockchip +1 -1
index dbeb8be..12fec38 100644
@@ -130,7 +130,7 @@ load a second-level bootloader(ie. U-BOOT) as soon as it returns to bootrom.
 Therefore RK3288 has another loading sequence like RK3036. The option of
 U-Boot is controlled with this setting in U-Boot:
 
-	#define CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
+	#define CONFIG_SPL_ROCKCHIP_BACK_TO_BROM
 
 You can create the image via the following operations:
 
include/configs/rk3188_common.h +1 -1
index 3ee9abd..8a01936 100644
@@ -26,7 +26,7 @@
 
 #define CONFIG_SYS_NS16550_MEM32
 
-#ifdef CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
+#ifdef CONFIG_SPL_ROCKCHIP_BACK_TO_BROM
 /* Bootrom will load u-boot binary to 0x60000000 once return from SPL */
 #define CONFIG_SYS_TEXT_BASE		0x60000000
 #else
include/configs/rk3288_common.h +1 -1
index 488d679..ade6caf 100644
@@ -24,7 +24,7 @@
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SYS_NS16550_MEM32
 
-#ifdef CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
+#ifdef CONFIG_SPL_ROCKCHIP_BACK_TO_BROM
 /* Bootrom will load u-boot binary to 0x0 once return from SPL */
 #define CONFIG_SYS_TEXT_BASE		0x00000000
 #else
include/configs/rock.h +1 -1
index de5291c..e76dc73 100644
@@ -13,7 +13,7 @@
 #define CONFIG_ENV_IS_IN_MMC
 #define CONFIG_SYS_MMC_ENV_DEV 0
 
-#ifdef CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
+#ifdef CONFIG_SPL_ROCKCHIP_BACK_TO_BROM
 /* SPL @ 32k for 34k
  * u-boot directly after @ 68k for 400k or so
  * ENV @ 992k
include/configs/rockchip-common.h +1 -1
index 715290d..ce5b1a2 100644
@@ -41,7 +41,7 @@
 #endif
 
 #if !defined(CONFIG_ENV_OFFSET)
-#ifdef CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
+#ifdef CONFIG_SPL_ROCKCHIP_BACK_TO_BROM
 /* SPL @ 32k for 34k
  * u-boot directly after @ 68k for 400k or so
  * ENV @ 992k
Signature · 1 line
2.1.4
#5 lore raw

PATCH 5/52 rockchip: back-to-bootrom: simplify the #ifdef-check for LIBGENERIC in TPL/SPL

In reply to Philipp Tomsich

With the finer-grained control over LIBGENERIC_SUPPORT for TPL/SPL (i.e. with the newly introduced distinction between TPL_LIBGENERIC_SUPPORT and SPL_LIBGENERIC_SUPPORT), we can simplify the #ifdef-check to simply use CONFIG_IS_ENABELD.

---

 arch/arm/mach-rockchip/bootrom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/bootrom.c +2 -2
index da36f92..4d38ed6 100644
@@ -9,8 +9,8 @@
 
 void back_to_bootrom(void)
 {
-#if defined(CONFIG_SPL_LIBGENERIC_SUPPORT) && !defined(CONFIG_TPL_BUILD)
-	printf("Returning to boot ROM...");
+#if CONFIG_IS_ENABLED(LIBGENERIC_SUPPORT)
+	printf("Returning to boot ROM...\n");
 #endif
 	_back_to_bootrom_s();
 }
Signature · 1 line
2.1.4
#6 lore raw

PATCH 6/52 spl: dm: Kconfig: use more specific prereqs for SPL_REGMAP and SPL_SYSCON

In reply to Philipp Tomsich

SPL_REGMAP and SPL_SYSCON were marked as depending on DM, when a stricter dependency of SPL_DM was possible. This commit makes the prereq more specific.

---

 drivers/core/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/core/Kconfig +2 -2
index fb5c4e8..01e6d71 100644
@@ -97,7 +97,7 @@ config REGMAP
 
 config SPL_REGMAP
 	bool "Support register maps in SPL"
-	depends on DM
+	depends on SPL_DM
 	help
 	  Hardware peripherals tend to have one or more sets of registers
 	  which can be accessed to control the hardware. A register map
@@ -116,7 +116,7 @@ config SYSCON
 
 config SPL_SYSCON
 	bool "Support system controllers in SPL"
-	depends on REGMAP
+	depends on SPL_REGMAP
 	help
 	  Many SoCs have a number of system controllers which are dealt with
 	  as a group by a single driver. Some common functionality is provided
Signature · 1 line
2.1.4
#7 lore raw

PATCH 7/52 spl: dm: Kconfig: split REGMAP/SYSCON support for TPL from SPL

In reply to Philipp Tomsich

This change introduces TPL variants of the REGMAP and SYSCON config options (i.e. TPL_REGMAP and TPL_SYSCON in analogy to SPL_REGMAP and SPL_SYSCON) in preparation of a finer-grained feature selection for building feature-rich TPL variants.

---

 drivers/core/Kconfig  | 19 +++++++++++++++++++
 drivers/core/Makefile |  4 ++--
 2 files changed, 21 insertions(+), 2 deletions(-)
drivers/core/Kconfig +19 -0
index 01e6d71..6b5796b 100644
@@ -105,6 +105,16 @@ config SPL_REGMAP
 	  support any bus type (I2C, SPI) but so far this only supports
 	  direct memory access.
 
+config TPL_REGMAP
+	bool "Support register maps in TPL"
+	depends on TPL_DM
+	help
+	  Hardware peripherals tend to have one or more sets of registers
+	  which can be accessed to control the hardware. A register map
+	  models this with a simple read/write interface. It can in principle
+	  support any bus type (I2C, SPI) but so far this only supports
+	  direct memory access.
+
 config SYSCON
 	bool "Support system controllers"
 	depends on REGMAP
@@ -123,6 +133,15 @@ config SPL_SYSCON
 	  by this uclass, including accessing registers via regmap and
 	  assigning a unique number to each.
 
+config TPL_SYSCON
+	bool "Support system controllers in TPL"
+	depends on TPL_REGMAP
+	help
+	  Many SoCs have a number of system controllers which are dealt with
+	  as a group by a single driver. Some common functionality is provided
+	  by this uclass, including accessing registers via regmap and
+	  assigning a unique number to each.
+
 config DEVRES
 	bool "Managed device resources"
 	depends on DM
drivers/core/Makefile +2 -2
index 435cf98..dcfb1b0 100644
@@ -9,8 +9,8 @@ obj-$(CONFIG_DEVRES) += devres.o
 obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE)	+= device-remove.o
 obj-$(CONFIG_$(SPL_)SIMPLE_BUS)	+= simple-bus.o
 obj-$(CONFIG_DM)	+= dump.o
-obj-$(CONFIG_$(SPL_)REGMAP)	+= regmap.o
-obj-$(CONFIG_$(SPL_)SYSCON)	+= syscon-uclass.o
+obj-$(CONFIG_$(SPL_TPL_)REGMAP)	+= regmap.o
+obj-$(CONFIG_$(SPL_TPL_)SYSCON)	+= syscon-uclass.o
 obj-$(CONFIG_OF_LIVE) += of_access.o of_addr.o
 ifndef CONFIG_DM_DEV_READ_INLINE
 obj-$(CONFIG_OF_CONTROL) += read.o
Signature · 1 line
2.1.4
#8 lore raw

PATCH 8/52 spl: dm: Kconfig: SPL_RAM depends on SPL_DM

In reply to Philipp Tomsich

This commit models the dependency from SPL_RAM to SPL_DM in Kconfig.

---

 drivers/ram/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ram/Kconfig +1 -1
index 61afd7a..e75c23f 100644
@@ -10,7 +10,7 @@ config RAM
 
 config SPL_RAM
 	bool "Enable RAM support in SPL"
-	depends on RAM
+	depends on RAM && SPL_DM
 	help
 	  The RAM subsystem adds a small amount of overhead to the image.
 	  If this is acceptable and you have a need to use RAM drivers in
Signature · 1 line
2.1.4
#9 lore raw

PATCH 9/52 spl: dm: Kconfig: introduce TPL_RAM (in analogy to SPL_RAM)

In reply to Philipp Tomsich

To allow finer grained selection of features for TPL, we introduce TPL_RAM (in analogy to SPL_RAM).

---

 drivers/ram/Kconfig | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/ram/Kconfig +9 -0
index e75c23f..836be25 100644
@@ -17,6 +17,15 @@ config SPL_RAM
 	  SPL, enable this option. It might provide a cleaner interface to
 	  setting up RAM (e.g. SDRAM / DDR) within SPL.
 
+config TPL_RAM
+	bool "Enable RAM support in SPL"
+	depends on RAM && TPL_DM
+	help
+	  The RAM subsystem adds a small amount of overhead to the image.
+	  If this is acceptable and you have a need to use RAM drivers in
+	  TPL, enable this option. It might provide a cleaner interface to
+	  setting up RAM (e.g. SDRAM / DDR) within TPL.
+
 config STM32_SDRAM
 	bool "Enable STM32 SDRAM support"
 	depends on RAM
Signature · 1 line
2.1.4
#10 lore raw

PATCH 10/52 spl: dm: Kconfig: SPL_CLK depens on SPL_DM

In reply to Philipp Tomsich

SPL_CLK should also depend on SPL_DM (and not just on CLK). Add the additional dependency.

---

 drivers/clk/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/Kconfig +1 -1
index 44da716..9c13587 100644
@@ -12,7 +12,7 @@ config CLK
 
 config SPL_CLK
 	bool "Enable clock support in SPL"
-	depends on CLK
+	depends on CLK && SPL_DM
 	help
 	  The clock subsystem adds a small amount of overhead to the image.
 	  If this is acceptable and you have a need to use clock drivers in
Signature · 1 line
2.1.4
#11 lore raw

PATCH 11/52 spl: dm: Kconfig: split CLK support for SPL and TPL

In reply to Philipp Tomsich

Introduce TPL_CLK to allow finer-grained selection of TPL features for feature-rich (i.e. DM-based) TPL stages.

---

 drivers/clk/Kconfig  | 10 ++++++++++
 drivers/clk/Makefile |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/clk/Kconfig +10 -0
index 9c13587..b40bde2 100644
@@ -20,6 +20,16 @@ config SPL_CLK
 	  setting up clocks within SPL, and allows the same drivers to be
 	  used as U-Boot proper.
 
+config TPL_CLK
+	bool "Enable clock support in TPL"
+	depends on CLK && TPL_DM
+	help
+	  The clock subsystem adds a small amount of overhead to the image.
+	  If this is acceptable and you have a need to use clock drivers in
+	  SPL, enable this option. It might provide a cleaner interface to
+	  setting up clocks within TPL, and allows the same drivers to be
+	  used as U-Boot proper.
+
 config CLK_BCM6345
 	bool "Clock controller driver for BCM6345"
 	depends on CLK && ARCH_BMIPS
drivers/clk/Makefile +1 -1
index 2746a80..844bc4e 100644
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier:      GPL-2.0+
 #
 
-obj-$(CONFIG_CLK) += clk-uclass.o clk_fixed_rate.o
+obj-$(CONFIG_$(SPL_TPL_)CLK) += clk-uclass.o clk_fixed_rate.o
 obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
 obj-$(CONFIG_SANDBOX) += clk_sandbox.o
 obj-$(CONFIG_SANDBOX) += clk_sandbox_test.o
Signature · 1 line
2.1.4
#12 lore raw

PATCH 12/52 spl: dm: Kconfig: split OF_CONTROL and OF_PLATDATA between SPL and TPL

In reply to Philipp Tomsich

For the RK3368, we want to use OF_PLATDATA in TPL, but full OF_CONTROL in SPL: this requires the introduction of a new family of configuration options to decouple SPL_OF_CONTROL and SPL_OF_PLATDATA from TPL.

Consequently, Makefile.spl needs to be adjusted to test for these configuration items through the $(SPL_TPL_) macro instead of hard-coding the SPL variant.

---

 Makefile             |  2 +-
 dts/Kconfig          | 29 +++++++++++++++++++++++++++++
 scripts/Makefile.spl |  4 ++--
 3 files changed, 32 insertions(+), 3 deletions(-)
Makefile +1 -1
index 119ad49..d5cdf2a 100644
@@ -1378,7 +1378,7 @@ u-boot.lds: $(LDSCRIPT) prepare FORCE
 spl/u-boot-spl.bin: spl/u-boot-spl
 	@:
 spl/u-boot-spl: tools prepare \
-		$(if $(CONFIG_OF_SEPARATE)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb)
+		$(if $(CONFIG_OF_SEPARATE)$(CONFIG_$(SPL_TPL_)OF_PLATDATA),dts/dt.dtb)
 	$(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all
 
 spl/sunxi-spl.bin: spl/u-boot-spl
dts/Kconfig +29 -0
index b3009af..bbadc32 100644
@@ -32,6 +32,14 @@ config SPL_OF_CONTROL
 	  which is not enough to support device tree. Enable this option to
 	  allow such boards to be supported by U-Boot SPL.
 
+config TPL_OF_CONTROL
+	bool "Enable run-time configuration via Device Tree in TPL"
+	depends on TPL && OF_CONTROL
+	help
+	  Some boards use device tree in U-Boot but only have 4KB of SRAM
+	  which is not enough to support device tree. Enable this option to
+	  allow such boards to be supported by U-Boot TPL.
+
 config OF_LIVE
 	bool "Enable use of a live tree"
 	depends on OF_CONTROL
@@ -135,4 +143,25 @@ config SPL_OF_PLATDATA
 	  declarations for each node. See README.platdata for more
 	  information.
 
+config TPL_OF_PLATDATA
+	bool "Generate platform data for use in TPL"
+	depends on TPL_OF_CONTROL
+	help
+	  For very constrained SPL environments the overhead of decoding
+	  device tree nodes and converting their contents into platform data
+	  is too large. This overhead includes libfdt code as well as the
+	  device tree contents itself. The latter is fairly compact, but the
+	  former can add 3KB or more to a Thumb 2 Image.
+
+	  This option enables generation of platform data from the device
+	  tree as C code. This code creates devices using U_BOOT_DEVICE()
+	  declarations. The benefit is that it allows driver code to access
+	  the platform data directly in C structures, avoidin the libfdt
+	  overhead.
+
+	  This option works by generating C structure declarations for each
+	  compatible string, then adding platform data and U_BOOT_DEVICE
+	  declarations for each node. See README.platdata for more
+	  information.
+
 endmenu
scripts/Makefile.spl +2 -2
index ac3c2c7..3e35cd6 100644
@@ -98,7 +98,7 @@ endif
 
 u-boot-spl-init := $(head-y)
 u-boot-spl-main := $(libs-y)
-ifdef CONFIG_SPL_OF_PLATDATA
+ifdef CONFIG_$(SPL_TPL_)OF_PLATDATA
 u-boot-spl-platdata := $(obj)/dts/dt-platdata.o
 endif
 
@@ -202,7 +202,7 @@ cmd_cat = cat $(filter-out $(PHONY), $^) > $@
 quiet_cmd_copy = COPY    $@
       cmd_copy = cp $< $@
 
-ifeq ($(CONFIG_SPL_OF_CONTROL)$(CONFIG_OF_SEPARATE)$(CONFIG_SPL_OF_PLATDATA),yy)
+ifeq ($(CONFIG_$(SPL_TPL_)OF_CONTROL)$(CONFIG_OF_SEPARATE)$(CONFIG_$(SPL_TPL_)OF_PLATDATA),yy)
 $(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN)-nodtb.bin \
 		$(if $(CONFIG_SPL_SEPARATE_BSS),,$(obj)/$(SPL_BIN)-pad.bin) \
 		$(obj)/$(SPL_BIN).dtb FORCE
Signature · 1 line
2.1.4
#13 lore raw

PATCH 13/52 spl: dm: use CONFIG_IS_ENABLED to test for the DM option

In reply to Philipp Tomsich

Even though there's now a TPL_DM configuration option, the spl logic still checks for SPL_DM and thus does not pick up the proper config option.

This introduces the use of CONFIG_IS_ENABLED(DM) in spl.c to always pick up the desired configuration option instead of having a hard-coded check for the SPL variant.

---

 common/spl/spl.c        |  5 +++--
 include/linux/kconfig.h | 13 +++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)
common/spl/spl.c +3 -2
index db55d26..233e4fe 100644
@@ -6,6 +6,7 @@
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
+
 #include <common.h>
 #include <dm.h>
 #include <spl.h>
@@ -243,7 +244,7 @@ static int spl_common_init(bool setup_malloc)
 			return ret;
 		}
 	}
-	if (IS_ENABLED(CONFIG_SPL_DM)) {
+	if (CONFIG_IS_ENABLED(DM)) {
 		bootstage_start(BOOTSTATE_ID_ACCUM_DM_SPL, "dm_spl");
 		/* With CONFIG_SPL_OF_PLATDATA, bring in all devices */
 		ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA));
@@ -425,7 +426,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	      gd->malloc_ptr / 1024);
 #endif
 
-	if (IS_ENABLED(CONFIG_SPL_ATF_SUPPORT)) {
+	if (CONFIG_IS_ENABLED(ATF_SUPPORT)) {
 		debug("loaded - jumping to U-Boot via ATF BL31.\n");
 		bl31_entry();
 	}
include/linux/kconfig.h +13 -0
index 486fb94..fbfc718 100644
@@ -51,12 +51,25 @@
 #define _IS_SPL 1
 #endif
 
+#ifdef CONFIG_TPL_BUILD
+#define _IS_TPL 1
+#endif
+
+#if defined(CONFIG_TPL_BUILD)
+#define config_val(cfg) _config_val(_IS_TPL, cfg)
+#define _config_val(x, cfg) __config_val(x, cfg)
+#define __config_val(x, cfg) ___config_val(__ARG_PLACEHOLDER_##x, cfg)
+#define ___config_val(arg1_or_junk, cfg)  \
+	____config_val(arg1_or_junk CONFIG_TPL_##cfg, CONFIG_##cfg)
+#define ____config_val(__ignored, val, ...) val
+#else
 #define config_val(cfg) _config_val(_IS_SPL, cfg)
 #define _config_val(x, cfg) __config_val(x, cfg)
 #define __config_val(x, cfg) ___config_val(__ARG_PLACEHOLDER_##x, cfg)
 #define ___config_val(arg1_or_junk, cfg)  \
 	____config_val(arg1_or_junk CONFIG_SPL_##cfg, CONFIG_##cfg)
 #define ____config_val(__ignored, val, ...) val
+#endif
 
 /*
  * CONFIG_VAL(FOO) evaluates to the value of
Signature · 1 line
2.1.4
#14 lore raw

PATCH 14/52 armv8: remove unused low-level modules from TPL

In reply to Philipp Tomsich

TPL builds today don't need to call into firmware or set up the MMU (if this changes, it should be controlled through a config option whether to include this or not), but include the needed support code for this anyway.

Even for a feature-rich TPL (including DM support as for the RK3368), this equates to a size difference of approx. 10% in TPL binary size:
- without this change:
text data bss dec hex filename
23635 3112 24 26771 6893 tpl/u-boot-tpl
- with this change:
text data bss dec hex filename
21583 3112 24 24719 608f tpl/u-boot-tpl

---

 arch/arm/cpu/armv8/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/cpu/armv8/Makefile +3 -1
index c447085..e831471 100644
@@ -9,12 +9,14 @@ extra-y	:= start.o
 
 obj-y	+= cpu.o
 obj-y	+= generic_timer.o
+ifndef CONFIG_TPL_BUILD
 obj-y	+= cache_v8.o
-obj-y	+= exceptions.o
 obj-y	+= cache.o
 obj-y	+= tlb.o
 obj-y	+= transition.o
 obj-y	+= fwcall.o
+endif
+obj-y	+= exceptions.o
 obj-y	+= cpu-dt.o
 obj-$(CONFIG_ARM_SMCCC)		+= smccc-call.o
 
Signature · 1 line
2.1.4
#15 lore raw

PATCH 15/52 armv8: spl: Support separate stack for TPL

In reply to Philipp Tomsich

To allow a TPL and SPL to run from different addresses/memories, we need to split setup of the TPL and SPL stacks. To do so, we introduce CONFIG_TPL_STACK (not listed in Kconfig) which can be used to override the initial stack pointer for TPL.

To provide backward compatibility for existing boards, this is added as an optional configuration item and the normal search order (i.e. SPL_STACK, then SYS_STACK) apply if not defined.

---

 arch/arm/lib/crt0_64.S       | 4 +++-
 scripts/config_whitelist.txt | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)
arch/arm/lib/crt0_64.S +3 -1
index 57e728f..177b5bf 100644
@@ -69,7 +69,9 @@ ENTRY(_main)
 /*
  * Set up initial C runtime environment and call board_init_f(0).
  */
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_STACK)
+#if defined(CONFIG_TPL_BUILD) && defined(CONFIG_TPL_STACK)
+	ldr	x0, =(CONFIG_TPL_STACK)
+#elif defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_STACK)
 	ldr	x0, =(CONFIG_SPL_STACK)
 #else
 	ldr	x0, =(CONFIG_SYS_INIT_SP_ADDR)
scripts/config_whitelist.txt +1 -0
index 1ab6101..34aadc5 100644
@@ -4997,6 +4997,7 @@ CONFIG_TI_SPI_MMAP
 CONFIG_TMU_TIMER
 CONFIG_TPL_DRIVERS_MISC_SUPPORT
 CONFIG_TPL_PAD_TO
+CONFIG_TPL_STACK
 CONFIG_TPM_TIS_BASE_ADDRESS
 CONFIG_TPS6586X_POWER
 CONFIG_TQM834X
Signature · 1 line
2.1.4
#16 lore raw

PATCH 16/52 spl: allow a separate TEXT_BASE, LDSCRIPT and MAX_SIZE for TPL

In reply to Philipp Tomsich

For the bringup of the RK3368, we need to support TPL and SPL running from different addresses... which requires both stages to use a distinct TEXT_BASE.

This commit adds support for having a separate LDSCRIPT for TPL (which is expected to make use of the TPL_MAX_SIZE define) and for having a the option of defining TPL_TEXT_BASE and having the TPL stage linked against this address.

Note that the handling of the TEXT_BASE is designed to not interfere with the previous assumption that SPL_TEXT_BASE should be used for TPL as well, unless TPL_TEXT_BASE is defined. For this reason, the test in Makefile.spl uses the following (seemingly redundant checks):
1. looks for $(SPL_TPL_)TEXT_BASE
2. looks for SPL_TEXT_BASE (even when building in TPL)

---

 scripts/Makefile.spl         | 10 ++++++++--
 scripts/config_whitelist.txt |  3 +++
 2 files changed, 11 insertions(+), 2 deletions(-)
scripts/Makefile.spl +8 -2
index 3e35cd6..4a9a58f 100644
@@ -103,9 +103,9 @@ u-boot-spl-platdata := $(obj)/dts/dt-platdata.o
 endif
 
 # Linker Script
-ifdef CONFIG_SPL_LDSCRIPT
+ifdef CONFIG_$(SPL_TPL_)LDSCRIPT
 # need to strip off double quotes
-LDSCRIPT := $(addprefix $(srctree)/,$(CONFIG_SPL_LDSCRIPT:"%"=%))
+LDSCRIPT := $(addprefix $(srctree)/,$(CONFIG_$(SPL_TPL_)LDSCRIPT:"%"=%))
 endif
 
 ifeq ($(wildcard $(LDSCRIPT)),)
@@ -293,9 +293,15 @@ LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
 # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
 LDFLAGS_$(SPL_BIN) += $(call ld-option, --no-dynamic-linker)
 
+# First try the best-match (i.e. SPL_TEXT_BASE for SPL, TPL_TEXT_BASE for TPL)
+ifneq ($(CONFIG_$(SPL_TPL_)TEXT_BASE),)
+LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_$(SPL_TPL_)TEXT_BASE)
+else
+# And then fall back to just testing for SPL_TEXT_BASE, even if in TPL mode
 ifneq ($(CONFIG_SPL_TEXT_BASE),)
 LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
 endif
+endif
 
 MKIMAGEFLAGS_$(SPL_BIN).sfp = -T socfpgaimage
 $(obj)/$(SPL_BIN).sfp: $(obj)/$(SPL_BIN).bin FORCE
scripts/config_whitelist.txt +3 -0
index 34aadc5..d8d00f5 100644
@@ -4996,8 +4996,11 @@ CONFIG_TI_KSNAV
 CONFIG_TI_SPI_MMAP
 CONFIG_TMU_TIMER
 CONFIG_TPL_DRIVERS_MISC_SUPPORT
+CONFIG_TPL_LDSCRIPT
+CONFIG_TPL_MAX_SIZE
 CONFIG_TPL_PAD_TO
 CONFIG_TPL_STACK
+CONFIG_TPL_TEXT_BASE
 CONFIG_TPM_TIS_BASE_ADDRESS
 CONFIG_TPS6586X_POWER
 CONFIG_TQM834X
Signature · 1 line
2.1.4
#17 lore raw

PATCH 17/52 spl: Kconfig: split SYS_MALLOC_SIMPLE for TPL and SPL

In reply to Philipp Tomsich

As include/malloc.h already checks for SYS_MALLOC_SIMPLE using the CONFIG_IS_ENABLED macro, we need to move to having separate entries as we switch to fully separate configuration for SPL and TPL.

---

 common/spl/Kconfig | 9 +++++++++
 1 file changed, 9 insertions(+)
common/spl/Kconfig +9 -0
index dd94801..f49b958 100644
@@ -62,6 +62,15 @@ config SPL_SYS_MALLOC_SIMPLE
 	  this will make the SPL binary smaller at the cost of more heap
 	  usage as the *_simple malloc functions do not re-use free-ed mem.
 
+config TPL_SYS_MALLOC_SIMPLE
+	bool
+	prompt "Only use malloc_simple functions in the TPL"
+	help
+	  Say Y here to only use the *_simple malloc functions from
+	  malloc_simple.c, rather then using the versions from dlmalloc.c;
+	  this will make the TPL binary smaller at the cost of more heap
+	  usage as the *_simple malloc functions do not re-use free-ed mem.
+
 config SPL_STACK_R
 	bool "Enable SDRAM location for SPL stack"
 	help
Signature · 1 line
2.1.4
#18 lore raw

PATCH 18/52 lib: spl: differentiate between TPL and SPL for libfdt/of_control/of_platdata

In reply to Philipp Tomsich

This splits the compilation of code modules for TPL and SPL for OF_CONTROL (and related) features between TPL and SPL. The typical use-case of this is a TPL stage that uses OF_PLATDATA at TPL and provides full OF_CONTROL at SPL (e.g. on the RK3368).

---

 lib/Makefile | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
lib/Makefile +5 -5
index eacc7d6..2eef1eb 100644
@@ -49,11 +49,11 @@ obj-$(CONFIG_RSA) += rsa/
 obj-$(CONFIG_SHA1) += sha1.o
 obj-$(CONFIG_SHA256) += sha256.o
 
-obj-$(CONFIG_SPL_SAVEENV) += qsort.o
-obj-$(CONFIG_$(SPL_)OF_LIBFDT) += libfdt/
-ifneq ($(CONFIG_SPL_BUILD)$(CONFIG_SPL_OF_PLATDATA),yy)
-obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o
-obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec.o
+obj-$(CONFIG_$(SPL_TPL_)SAVEENV) += qsort.o
+obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += libfdt/
+ifneq ($(CONFIG_$(SPL_TPL_)BUILD)$(CONFIG_$(SPL_TPL_)OF_PLATDATA),yy)
+obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += fdtdec_common.o
+obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += fdtdec.o
 endif
 
 ifdef CONFIG_SPL_BUILD
Signature · 1 line
2.1.4
#19 lore raw

PATCH 19/52 spl: consistently use $(SPL_TPL_) to select features for SPL and TPL builds

In reply to Philipp Tomsich

To allow for a finer-grained control of features for TPL and SPL builds all modules/boot-methods/etc. need to be consistently selected based on the $(SPL_TPL_) macros.

This allows splitting the associated config-options in Kconfig: we don't split the Kconfig options here and now, as this should happen on an as-needed basis, whenever someone needs a feature/boot-method/etc. in their TPL.

---

 common/Makefile     |  8 ++++----
 common/spl/Makefile | 36 ++++++++++++++++++------------------
 2 files changed, 22 insertions(+), 22 deletions(-)
common/Makefile +4 -4
index 539cf98..14345de 100644
@@ -53,7 +53,7 @@ obj-$(CONFIG_ENV_IS_IN_UBI) += env_ubi.o
 obj-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o
 
 obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
-obj-$(CONFIG_$(SPL_)OF_LIBFDT) += fdt_support.o
+obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
 
 obj-$(CONFIG_MII) += miiphyutil.o
 obj-$(CONFIG_CMD_MII) += miiphyutil.o
@@ -148,9 +148,9 @@ obj-y += malloc_simple.o
 endif
 obj-y += image.o
 obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o
-obj-$(CONFIG_$(SPL_)OF_LIBFDT) += image-fdt.o
-obj-$(CONFIG_$(SPL_)FIT) += image-fit.o
-obj-$(CONFIG_$(SPL_)FIT_SIGNATURE) += image-sig.o
+obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
+obj-$(CONFIG_$(SPL_TPL_)FIT) += image-fit.o
+obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += image-sig.o
 obj-$(CONFIG_IO_TRACE) += iotrace.o
 obj-y += memsize.o
 obj-y += stdio.o
common/spl/Makefile +18 -18
index 189b272..112b3e6 100644
@@ -10,24 +10,24 @@
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_FRAMEWORK) += spl.o
-obj-$(CONFIG_SPL_BOOTROM_SUPPORT) += spl_bootrom.o
-obj-$(CONFIG_SPL_LOAD_FIT) += spl_fit.o
-obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o
-obj-$(CONFIG_SPL_XIP_SUPPORT) += spl_xip.o
-obj-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTROM_SUPPORT) += spl_bootrom.o
+obj-$(CONFIG_$(SPL_TPL_)LOAD_FIT) += spl_fit.o
+obj-$(CONFIG_$(SPL_TPL_)SPL_NOR_SUPPORT) += spl_nor.o
+obj-$(CONFIG_$(SPL_TPL_)SPL_XIP_SUPPORT) += spl_xip.o
+obj-$(CONFIG_$(SPL_TPL_)SPL_YMODEM_SUPPORT) += spl_ymodem.o
 ifndef CONFIG_SPL_UBI
-obj-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o
-obj-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o
+obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += spl_nand.o
+obj-$(CONFIG_$(SPL_TPL_)ONENAND_SUPPORT) += spl_onenand.o
 endif
-obj-$(CONFIG_SPL_UBI) += spl_ubi.o
-obj-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o
-obj-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o
-obj-$(CONFIG_SPL_ATF_SUPPORT) += spl_atf.o
-obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o
-obj-$(CONFIG_SPL_FAT_SUPPORT) += spl_fat.o
-obj-$(CONFIG_SPL_EXT_SUPPORT) += spl_ext.o
-obj-$(CONFIG_SPL_SATA_SUPPORT) += spl_sata.o
-obj-$(CONFIG_SPL_DFU_SUPPORT) += spl_dfu.o
-obj-$(CONFIG_SPL_SPI_LOAD) += spl_spi.o
-obj-$(CONFIG_SPL_RAM_SUPPORT) += spl_ram.o
+obj-$(CONFIG_$(SPL_TPL_)UBI) += spl_ubi.o
+obj-$(CONFIG_$(SPL_TPL_)NET_SUPPORT) += spl_net.o
+obj-$(CONFIG_$(SPL_TPL_)MMC_SUPPORT) += spl_mmc.o
+obj-$(CONFIG_$(SPL_TPL_)ATF_SUPPORT) += spl_atf.o
+obj-$(CONFIG_$(SPL_TPL_)USB_SUPPORT) += spl_usb.o
+obj-$(CONFIG_$(SPL_TPL_)FAT_SUPPORT) += spl_fat.o
+obj-$(CONFIG_$(SPL_TPL_)EXT_SUPPORT) += spl_ext.o
+obj-$(CONFIG_$(SPL_TPL_)SATA_SUPPORT) += spl_sata.o
+obj-$(CONFIG_$(SPL_TPL_)DFU_SUPPORT) += spl_dfu.o
+obj-$(CONFIG_$(SPL_TPL_)SPI_LOAD) += spl_spi.o
+obj-$(CONFIG_$(SPL_TPL_)RAM_SUPPORT) += spl_ram.o
 endif
Signature · 1 line
2.1.4
#20 lore raw

PATCH 20/52 spl: add TPL_DRIVER_MISC_SUPPORT option

In reply to Philipp Tomsich

This adds the TPL_DRIVER_MISC_SUPPORT option to allow activation of DRIVER_MISC_SUPPORT for devices that need it in the TPL stage.

---

 common/spl/Kconfig | 8 ++++++++
 1 file changed, 8 insertions(+)
common/spl/Kconfig +8 -0
index f49b958..def8107 100644
@@ -718,6 +718,14 @@ config TPL_BOOTROM_SUPPORT
 	  BOOT_DEVICE_BOOTROM (or fall-through to the next boot device in the
 	  boot device list, if not implemented for a given board)
 
+config TPL_DRIVERS_MISC_SUPPORT
+	bool "Support misc drivers in TPL"
+	help
+	  Enable miscellaneous drivers in TPL. These drivers perform various
+	  tasks that don't fall nicely into other categories, Enable this
+	  option to build the drivers in drivers/misc as part of an TPL
+	  build, for those that support building in TPL (not all drivers do).
+
 config TPL_ENV_SUPPORT
 	bool "Support an environment"
 	help
Signature · 1 line
2.1.4
#21 lore raw

PATCH 21/52 drivers: spl: consistently use the $(SPL_TPL_) macro

In reply to Philipp Tomsich

To simplify drivers/Makefile a bit when using TPL/SPL, we consistently use the $(SPL_TPL_) macro to test for drivers that have separate configuration symbols for the full U-boot, SPL and TPL stages. Instead of explicitly repeating them in two separate if-guarded sections of the Makefile, we can now simply list these options once.

---

 drivers/Makefile | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)
drivers/Makefile +16 -20
index 058bccb..2bd769f 100644
@@ -2,33 +2,34 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_$(SPL_TPL_)DM)	+= core/
-obj-$(CONFIG_$(SPL_)CLK)	+= clk/
-obj-$(CONFIG_$(SPL_)LED)	+= led/
-obj-$(CONFIG_$(SPL_)PHY)	+= phy/
-obj-$(CONFIG_$(SPL_)PINCTRL)	+= pinctrl/
-obj-$(CONFIG_$(SPL_)RAM)	+= ram/
+obj-$(CONFIG_$(SPL_TPL_)CLK) += clk/
+obj-$(CONFIG_$(SPL_TPL_)DM) += core/
+obj-$(CONFIG_$(SPL_TPL_)DRIVERS_MISC_SUPPORT) += misc/ sysreset/ firmware/
+obj-$(CONFIG_$(SPL_TPL_)I2C_SUPPORT) += i2c/
+obj-$(CONFIG_$(SPL_TPL_)LED) += led/
+obj-$(CONFIG_$(SPL_TPL_)MMC_SUPPORT) += mmc/
+obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/
+obj-$(CONFIG_$(SPL_TPL_)PHY) += phy/
+obj-$(CONFIG_$(SPL_TPL_)PINCTRL) += pinctrl/
+obj-$(CONFIG_$(SPL_TPL_)RAM) += ram/
+obj-$(CONFIG_$(SPL_TPL_)SERIAL_SUPPORT) += serial/
+obj-$(CONFIG_$(SPL_TPL_)SPI_FLASH_SUPPORT) += mtd/spi/
+obj-$(CONFIG_$(SPL_TPL_)SPI_SUPPORT) += spi/
 
+ifndef CONFIG_TPL_BUILD
 ifdef CONFIG_SPL_BUILD
 
 obj-$(CONFIG_SPL_CPU_SUPPORT) += cpu/
 obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/
-obj-$(CONFIG_SPL_I2C_SUPPORT) += i2c/
 obj-$(CONFIG_SPL_GPIO_SUPPORT) += gpio/
-obj-$(CONFIG_SPL_MMC_SUPPORT) += mmc/
 obj-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += ddr/fsl/
 obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/
 obj-$(CONFIG_ARMADA_XP) += ddr/marvell/axp/
 obj-$(CONFIG_ALTERA_SDRAM) += ddr/altera/
-obj-$(CONFIG_SPL_SERIAL_SUPPORT) += serial/
-obj-$(CONFIG_SPL_SPI_SUPPORT) += spi/
 obj-$(CONFIG_SPL_POWER_SUPPORT) += power/ power/pmic/
 obj-$(CONFIG_SPL_POWER_SUPPORT) += power/regulator/
-obj-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += misc/ sysreset/ firmware/
 obj-$(CONFIG_SPL_MTD_SUPPORT) += mtd/
-obj-$(CONFIG_SPL_NAND_SUPPORT) += mtd/nand/
 obj-$(CONFIG_SPL_ONENAND_SUPPORT) += mtd/onenand/
-obj-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += mtd/spi/
 obj-$(CONFIG_SPL_UBI) += mtd/ubispl/
 obj-$(CONFIG_SPL_DMA_SUPPORT) += dma/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/
@@ -48,18 +49,13 @@ obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/
 obj-$(CONFIG_SPL_SATA_SUPPORT) += block/
 obj-$(CONFIG_SPL_USB_HOST_SUPPORT) += block/
 obj-$(CONFIG_SPL_MMC_SUPPORT) += block/
+
+endif
 endif
 
 ifdef CONFIG_TPL_BUILD
 
-obj-$(CONFIG_TPL_I2C_SUPPORT) += i2c/
-obj-$(CONFIG_TPL_DRIVERS_MISC_SUPPORT) += misc/ sysreset/ firmware/
-obj-$(CONFIG_TPL_MMC_SUPPORT) += mmc/
 obj-$(CONFIG_TPL_MPC8XXX_INIT_DDR_SUPPORT) += ddr/fsl/
-obj-$(CONFIG_TPL_NAND_SUPPORT) += mtd/nand/
-obj-$(CONFIG_TPL_SERIAL_SUPPORT) += serial/
-obj-$(CONFIG_TPL_SPI_FLASH_SUPPORT) += mtd/spi/
-obj-$(CONFIG_TPL_SPI_SUPPORT) += spi/
 
 endif
 
Signature · 1 line
2.1.4
#22 lore raw

PATCH 22/52 rockchip: Makefile: allow selective inclusion of sdram_common.o from TPL/SPL/U-Boot

In reply to Philipp Tomsich

The utility functions in sdram_common.c will be useful both for some SPL implementations (and if unused, the linked will discard these anyway) and for the full U-Boot stage.

This changes selects sdram_common.o through the $(SPL_TPL_) macro to allow better control of its inclusion through the CONFIG_ROM, CONFIG_SPL_RAM or CONFIG_TPL_RAM options.

---

 arch/arm/mach-rockchip/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/arm/mach-rockchip/Makefile +1 -3
index cb8d3ef..8a3cb9f 100644
@@ -5,6 +5,7 @@
 #
 
 obj-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o
+obj-$(CONFIG_$(SPL_TPL_)RAM) += sdram_common.o
 
 ifdef CONFIG_TPL_BUILD
 obj-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board-tpl.o
@@ -21,9 +22,6 @@ obj-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board.o
 obj-$(CONFIG_ROCKCHIP_RK322X) += rk322x-board.o
 obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board.o
 obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board.o
-ifdef CONFIG_RAM
-obj-y += sdram_common.o
-endif
 endif
 ifndef CONFIG_ARM64
 obj-y += rk_timer.o
Signature · 1 line
2.1.4
#23 lore raw

PATCH 23/52 rockchip: rk3368: improve Kconfig text for the RK3368

In reply to Philipp Tomsich

The RK3368 option in Kconfig referred to the RK3328 (copy-and-paste) and had a few typos and unnecessarily used UTF-8 characters. While fixing this, I also reformatted and further clarified the text (e.g. made the grouping into a a big and little cluster of 4 cores each explicit).

---

 arch/arm/mach-rockchip/Kconfig | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
arch/arm/mach-rockchip/Kconfig +9 -6
index 523bc11..2ad4943 100644
@@ -69,12 +69,15 @@ config ROCKCHIP_RK3368
 	select ARM64
 	select SYS_NS16550
 	help
-	  The Rockchip RK3328 is a ARM-based SoC with a octa-core Cortex-A53.
-	  including NEON and GPU, 512KB L2 cache for big cluster and 256 KB
-	  L2 cache for little cluser, PowerVR G6110 based graphics, one video
-	  output processor supporting LVDS、HDMI、eDP, several DDR3 options
-	  and video codec support. Peripherals include Gigabit Ethernet,
-	  USB2 host and OTG, SDIO, I2S, UARTs, SPI, I2C and PWMs.
+	  The Rockchip RK3368 is a ARM-based SoC with a octa-core (organised
+	  into a big and little cluster with 4 cores each) Cortex-A53 including
+	  AdvSIMD, 512KB L2 cache (for the big cluster) and 256 KB L2 cache
+	  (for the little cluster), PowerVR G6110 based graphics, one video
+	  output processor supporting LVDS/HDMI/eDP, several DDR3 options and
+	  video codec support.
+
+	  On-chip peripherals include Gigabit Ethernet, USB2 host and OTG, SDIO,
+	  I2S, UARTs, SPI, I2C and PWMs.
 
 config ROCKCHIP_RK3399
 	bool "Support Rockchip RK3399"
Signature · 1 line
2.1.4
#24 lore raw

PATCH 24/52 rockchip: rk3368: mkimage: add support for the RK3368

In reply to Philipp Tomsich

This commit adds support for RK3368 SoC in mkimage.

---

 tools/rkcommon.c | 1 +
 1 file changed, 1 insertion(+)
tools/rkcommon.c +1 -0
index 25b0340..04e8272 100644
@@ -77,6 +77,7 @@ static struct spl_info spl_infos[] = {
 	{ "rk322x", "RK32", 0x8000 - 0x1000, false, false },
 	{ "rk3288", "RK32", 0x8000, false, false },
 	{ "rk3328", "RK32", 0x8000 - 0x1000, false, false },
+	{ "rk3368", "RK33", 0x8000 - 0x1000, false, true },
 	{ "rk3399", "RK33", 0x30000 - 0x2000, false, true },
 	{ "rv1108", "RK11", 0x1800, false, false},
 };
Signature · 1 line
2.1.4
#25 lore raw

PATCH 25/52 rockchip: rk3368: pmugrf: add definitions for os_reg[0..3]

In reply to Philipp Tomsich

On the RK3368 we use a TPL-stage similar to Rockchip's DDR init (i.e. it initialises DRAM, leaves some info for the next stage and returns to the BootROM). To allow compatibility with Rockchip's DDR init code, we use the same register os_reg2 in pmugrf for passing this info (i.e. DRAM size and configuration) between stages.

This change adds the definitions for os_reg[0] through os_reg[3] to the pmugrf structure for the RK3368.

---

 arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-rockchip/grf_rk3368.h +3 -2
index 93c4e7d..a438f5d 100644
@@ -92,10 +92,11 @@ struct rk3368_pmu_grf {
 	u32 gpio0d_drv;
 	u32 gpio0l_sr;
 	u32 gpio0h_sr;
-	u32 reserved[(0x200 - 0x34) / 4 - 1];
+	u32 reserved[0x72];
 	u32 os_reg[4];
 };
-check_member(rk3368_pmu_grf, os_reg[3], 0x20c);
+check_member(rk3368_pmu_grf, gpio0h_sr, 0x34);
+check_member(rk3368_pmu_grf, os_reg[0], 0x200);
 
 /*GRF_GPIO0C_IOMUX*/
 enum {
Signature · 1 line
2.1.4
#26 lore raw

PATCH 26/52 rockchip: rk3368: define CONFIG_SYS_SDRAM_BASE

In reply to Philipp Tomsich

With the new common SDRAM code for Rockchip, we need to define CONFIG_SYS_SDRAM_BASE to correctly indicate the start of the physical address range mapping onto DRAM.

---

 include/configs/rk3368_common.h | 1 +
 1 file changed, 1 insertion(+)
include/configs/rk3368_common.h +1 -0
index b0c858c..488f8c5 100644
@@ -15,6 +15,7 @@
 #define CONFIG_SYS_SDRAM_BASE		0
 #define SDRAM_MAX_SIZE			0xff000000
 #define CONFIG_NR_DRAM_BANKS		1
+#define CONFIG_SYS_SDRAM_BASE		0
 #define CONFIG_SYS_MAXARGS		16
 #define CONFIG_BAUDRATE			115200
 #define CONFIG_SYS_MALLOC_LEN		(32 << 20)
Signature · 1 line
2.1.4
maintainer
#27 lore raw

PATCH 26/52 rockchip: rk3368: define CONFIG_SYS_SDRAM_BASE

Am Dienstag, 18. Juli 2017, 22:36:06 CEST schrieb Philipp Tomsich:

Quoted 15 lines

With the new common SDRAM code for Rockchip, we need to define CONFIG_SYS_SDRAM_BASE to correctly indicate the start of the physical address range mapping onto DRAM.

---

 include/configs/rk3368_common.h | 1 +
 1 file changed, 1 insertion(+)
include/configs/rk3368_common.h +0 -0
index b0c858c..488f8c5 100644

include/configs/rk3368_common.h line 15

Quoted 1 line
include/configs/rk3368_common.h +0 -0
@@ -15,6 +15,7 @@
 #define CONFIG_SYS_SDRAM_BASE		0

^^ isn't that already defined here?

Quoted 7 lines
include/configs/rk3368_common.h +1 -0
 #define SDRAM_MAX_SIZE			0xff000000
 #define CONFIG_NR_DRAM_BANKS		1
+#define CONFIG_SYS_SDRAM_BASE		0
 #define CONFIG_SYS_MAXARGS		16
 #define CONFIG_BAUDRATE			115200
 #define CONFIG_SYS_MALLOC_LEN		(32 << 20)
#28 lore raw

PATCH 27/52 rockchip: rk3368: spl: define COUNTER_FREQUENCY to 24MHz

In reply to Philipp Tomsich

The BootROM of the RK3368 Boot ROM does not initialise cntfrq_el0. This change defines COUNTER_FREQUENCY, which is used by the AArch64 init code in arch/arm/cpu/armv8/start.S to set up cntfrq_el0.

If the counter-frequency is not correctly set up, the calculation of delays using the ARMv8 generic timer can not work correctly.

---

 include/configs/rk3368_common.h | 2 ++
 1 file changed, 2 insertions(+)
include/configs/rk3368_common.h +2 -0
index 488f8c5..7ab3b46 100644
@@ -22,6 +22,8 @@
 #define CONFIG_SYS_CBSIZE		1024
 #define CONFIG_SKIP_LOWLEVEL_INIT
 
+#define COUNTER_FREQUENCY               24000000
+
 #define CONFIG_SYS_NS16550_MEM32
 
 #define CONFIG_SYS_TEXT_BASE		0x00200000
Signature · 1 line
2.1.4
#29 lore raw

PATCH 28/52 rockchip: rk3368: spl: add memory layout for TPL and SPL

In reply to Philipp Tomsich

For the RK3368, we use a multi-stage boot-process consisting of the following:
1. TPL: initalises DRAM, returns to boot-ROM (which then loads the next stage and transfers control to it)
2. SPL: a full-features SPL stage including OF_CONTROL and FIT image loading, which fetches the ATF, DTB and full U-Boot and then transfers control to the ATF (using the BL31 parameter block to indicate the location of BL33/U-Boot)
3. ATF: sets up the secure world and exits to BL33 (i.e. a full U-Boot) in the normal world
4. full U-Boot

TPL/SPL and the full U-Boot are built from this tree and need to run from distinct text addresses and with distinct initial stack pointer addresses.

This commit sets up the configuration to run:
- TPL from the SRAM at 0xff8c0000 (note that the first 0x1000 are reserved for use by the boot-ROM and contain the SP when the TPL is entered)
- SPL from DRAM at 0x0
- U-Boot from DRAM at 0x200000

---

 include/configs/rk3368_common.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
include/configs/rk3368_common.h +11 -0
index 7ab3b46..8ffc293 100644
@@ -30,6 +30,17 @@
 #define CONFIG_SYS_INIT_SP_ADDR		0x00300000
 #define CONFIG_SYS_LOAD_ADDR		0x00280000
 
+#define CONFIG_SPL_TEXT_BASE            0x00000000
+#define CONFIG_SPL_MAX_SIZE             0x40000
+#define CONFIG_SPL_BSS_START_ADDR       0x400000
+#define CONFIG_SPL_BSS_MAX_SIZE         0x20000
+
+#define CONFIG_TPL_LDSCRIPT \
+	  "arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds"
+#define CONFIG_TPL_TEXT_BASE		0xff8c1000
+#define CONFIG_TPL_MAX_SIZE		0x7000
+#define CONFIG_TPL_STACK		0xff8cffff
+
 #define CONFIG_BOUNCE_BUFFER
 
 #ifndef CONFIG_SPL_BUILD
Signature · 1 line
2.1.4
#30 lore raw

PATCH 29/52 rockchip: rk3368: syscon: MSCH/PMUGRF/GRF support for OF_PLATDATA

In reply to Philipp Tomsich

The RK3368 has both a limited SPL size (just 0x7000 bytes) and the added challenge of booting in AArch64, which increases the code size for SPL (particularily when using the LP64 programming model). For this reason we expect the RK3368 to always use OF_PLATDATA for its SPL stage.

This change adds support for the MSCH, PMUGRF and GRF register regions in syscon, which are necessary for initialising the RK3368's DRAM controller.

---

 arch/arm/mach-rockchip/rk3368/syscon_rk3368.c | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
arch/arm/mach-rockchip/rk3368/syscon_rk3368.c +35 -0
index 03e97eb..90a993e 100644
@@ -1,6 +1,8 @@
 /*
  * (C) Copyright 2017 Rockchip Electronics Co., Ltd
  * Author: Andy Yan <[email protected]>
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
+ *
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
@@ -14,6 +16,8 @@ static const struct udevice_id rk3368_syscon_ids[] = {
 	  .data = ROCKCHIP_SYSCON_GRF },
 	{ .compatible = "rockchip,rk3368-pmugrf",
 	  .data = ROCKCHIP_SYSCON_PMUGRF },
+	{ .compatible = "rockchip,rk3368-msch",
+	  .data = ROCKCHIP_SYSCON_MSCH },
 	{ }
 };
 
@@ -22,3 +26,34 @@ U_BOOT_DRIVER(syscon_rk3368) = {
 	.id = UCLASS_SYSCON,
 	.of_match = rk3368_syscon_ids,
 };
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+static int rk3368_syscon_bind_of_platdata(struct udevice *dev)
+{
+	dev->driver_data = dev->driver->of_match->data;
+	debug("syscon: %s %d\n", dev->name, (uint)dev->driver_data);
+
+	return 0;
+}
+
+U_BOOT_DRIVER(rockchip_rk3368_grf) = {
+	.name = "rockchip_rk3368_grf",
+	.id = UCLASS_SYSCON,
+	.of_match = rk3368_syscon_ids,
+	.bind = rk3368_syscon_bind_of_platdata,
+};
+
+U_BOOT_DRIVER(rockchip_rk3368_pmugrf) = {
+	.name = "rockchip_rk3368_pmugrf",
+	.id = UCLASS_SYSCON,
+	.of_match = rk3368_syscon_ids + 1,
+	.bind = rk3368_syscon_bind_of_platdata,
+};
+
+U_BOOT_DRIVER(rockchip_rk3368_msch) = {
+	.name = "rockchip_rk3368_msch",
+	.id = UCLASS_SYSCON,
+	.of_match = rk3368_syscon_ids + 2,
+	.bind = rk3368_syscon_bind_of_platdata,
+};
+#endif
Signature · 1 line
2.1.4
#31 lore raw

PATCH 29/52 rockchip: rk3368: syscon: MSCH/PMUGRF/GRF support for OF_PLATDATA

Hi Philipp:

Quoted 5 lines · Philipp Tomsich

The RK3368 has both a limited SPL size (just 0x7000 bytes) and the added challenge of booting in AArch64, which increases the code size for SPL (particularily when using the LP64 programming model). For this reason we expect the RK3368 to always use OF_PLATDATA for its SPL stage.

According to your previous patch, maybe you mean TPL here?

Quoted 67 lines

This change adds support for the MSCH, PMUGRF and GRF register regions in syscon, which are necessary for initialising the RK3368's DRAM controller.

---

  arch/arm/mach-rockchip/rk3368/syscon_rk3368.c | 35 +++++++++++++++++++++++++++
  1 file changed, 35 insertions(+)
arch/arm/mach-rockchip/rk3368/syscon_rk3368.c +35 -0
index 03e97eb..90a993e 100644
@@ -1,6 +1,8 @@
  /*
   * (C) Copyright 2017 Rockchip Electronics Co., Ltd
   * Author: Andy Yan <[email protected]>
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
+ *
   * SPDX-License-Identifier:	GPL-2.0+
   */
 
@@ -14,6 +16,8 @@ static const struct udevice_id rk3368_syscon_ids[] = {
  	  .data = ROCKCHIP_SYSCON_GRF },
  	{ .compatible = "rockchip,rk3368-pmugrf",
  	  .data = ROCKCHIP_SYSCON_PMUGRF },
+	{ .compatible = "rockchip,rk3368-msch",
+	  .data = ROCKCHIP_SYSCON_MSCH },
  	{ }
  };
 
@@ -22,3 +26,34 @@ U_BOOT_DRIVER(syscon_rk3368) = {
  	.id = UCLASS_SYSCON,
  	.of_match = rk3368_syscon_ids,
  };
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+static int rk3368_syscon_bind_of_platdata(struct udevice *dev)
+{
+	dev->driver_data = dev->driver->of_match->data;
+	debug("syscon: %s %d\n", dev->name, (uint)dev->driver_data);
+
+	return 0;
+}
+
+U_BOOT_DRIVER(rockchip_rk3368_grf) = {
+	.name = "rockchip_rk3368_grf",
+	.id = UCLASS_SYSCON,
+	.of_match = rk3368_syscon_ids,
+	.bind = rk3368_syscon_bind_of_platdata,
+};
+
+U_BOOT_DRIVER(rockchip_rk3368_pmugrf) = {
+	.name = "rockchip_rk3368_pmugrf",
+	.id = UCLASS_SYSCON,
+	.of_match = rk3368_syscon_ids + 1,
+	.bind = rk3368_syscon_bind_of_platdata,
+};
+
+U_BOOT_DRIVER(rockchip_rk3368_msch) = {
+	.name = "rockchip_rk3368_msch",
+	.id = UCLASS_SYSCON,
+	.of_match = rk3368_syscon_ids + 2,
+	.bind = rk3368_syscon_bind_of_platdata,
+};
+#endif
#32 lore raw

PATCH 30/52 rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_

In reply to Philipp Tomsich

The RK3368 GRF header was still defines with a shifted-mask but with non-shifted function selectors for the IOMUX defines. As the RK3368 support is still fresh enough to allow a quick rename, we do this now before having more code use this.

As some of the downstream drivers (e.g. the Designware GMAC wrapper) may need to include the grf-header of multiple devices, we rename the various defines for the RK3368 by prefixing them with the device name. This avoids future trouble during driver integration.

---

 arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 617 +++++++++++++-----------
 drivers/pinctrl/rockchip/pinctrl_rk3368.c       |  17 +-
 2 files changed, 334 insertions(+), 300 deletions(-)
arch/arm/include/asm/arch-rockchip/grf_rk3368.h +326 -291
index a438f5d..a97dc1e 100644
@@ -1,4 +1,6 @@
-/* (C) Copyright 2016 Rockchip Electronics Co., Ltd
+/*
+ * (C) Copyright 2016 Rockchip Electronics Co., Ltd
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
  *
  * SPDX-License-Identifier:     GPL-2.0+
  */
@@ -100,315 +102,318 @@ check_member(rk3368_pmu_grf, os_reg[0], 0x200);
 
 /*GRF_GPIO0C_IOMUX*/
 enum {
-	GPIO0C7_SHIFT		= 14,
-	GPIO0C7_MASK		= 3 << GPIO0C7_SHIFT,
-	GPIO0C7_GPIO		= 0,
-	GPIO0C7_LCDC_D19,
-	GPIO0C7_TRACE_D9,
-	GPIO0C7_UART1_RTSN,
-
-	GPIO0C6_SHIFT           = 12,
-	GPIO0C6_MASK            = 3 << GPIO0C6_SHIFT,
-	GPIO0C6_GPIO            = 0,
-	GPIO0C6_LCDC_D18,
-	GPIO0C6_TRACE_D8,
-	GPIO0C6_UART1_CTSN,
-
-	GPIO0C5_SHIFT           = 10,
-	GPIO0C5_MASK            = 3 << GPIO0C5_SHIFT,
-	GPIO0C5_GPIO            = 0,
-	GPIO0C5_LCDC_D17,
-	GPIO0C5_TRACE_D7,
-	GPIO0C5_UART1_SOUT,
-
-	GPIO0C4_SHIFT           = 8,
-	GPIO0C4_MASK            = 3 << GPIO0C4_SHIFT,
-	GPIO0C4_GPIO            = 0,
-	GPIO0C4_LCDC_D16,
-	GPIO0C4_TRACE_D6,
-	GPIO0C4_UART1_SIN,
-
-	GPIO0C3_SHIFT           = 6,
-	GPIO0C3_MASK            = 3 << GPIO0C3_SHIFT,
-	GPIO0C3_GPIO            = 0,
-	GPIO0C3_LCDC_D15,
-	GPIO0C3_TRACE_D5,
-	GPIO0C3_MCU_JTAG_TDO,
-
-	GPIO0C2_SHIFT           = 4,
-	GPIO0C2_MASK            = 3 << GPIO0C2_SHIFT,
-	GPIO0C2_GPIO            = 0,
-	GPIO0C2_LCDC_D14,
-	GPIO0C2_TRACE_D4,
-	GPIO0C2_MCU_JTAG_TDI,
-
-	GPIO0C1_SHIFT           = 2,
-	GPIO0C1_MASK            = 3 << GPIO0C1_SHIFT,
-	GPIO0C1_GPIO            = 0,
-	GPIO0C1_LCDC_D13,
-	GPIO0C1_TRACE_D3,
-	GPIO0C1_MCU_JTAG_TRTSN,
-
-	GPIO0C0_SHIFT           = 0,
-	GPIO0C0_MASK            = 3 << GPIO0C0_SHIFT,
-	GPIO0C0_GPIO            = 0,
-	GPIO0C0_LCDC_D12,
-	GPIO0C0_TRACE_D2,
-	GPIO0C0_MCU_JTAG_TDO,
+	RK3368_GPIO0C7_MASK	       = GENMASK(15, 14),
+	RK3368_GPIO0C7_GPIO	       = 0,
+	RK3368_GPIO0C7_LCDC_D19        = (1 << 14),
+	RK3368_GPIO0C7_TRACE_D9        = (2 << 14),
+	RK3368_GPIO0C7_UART1_RTSN      = (3 << 14),
+
+	RK3368_GPIO0C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0C6_GPIO            = 0,
+	RK3368_GPIO0C6_LCDC_D18        = (1 << 12),
+	RK3368_GPIO0C6_TRACE_D8        = (2 << 12),
+	RK3368_GPIO0C6_UART1_CTSN      = (3 << 12),
+
+	RK3368_GPIO0C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0C5_GPIO            = 0,
+	RK3368_GPIO0C5_LCDC_D17        = (1 << 10),
+	RK3368_GPIO0C5_TRACE_D7        = (2 << 10),
+	RK3368_GPIO0C5_UART1_SOUT      = (3 << 10),
+
+	RK3368_GPIO0C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0C4_GPIO            = 0,
+	RK3368_GPIO0C4_LCDC_D16        = (1 << 8),
+	RK3368_GPIO0C4_TRACE_D6        = (2 << 8),
+	RK3368_GPIO0C4_UART1_SIN       = (3 << 8),
+
+	RK3368_GPIO0C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0C3_GPIO            = 0,
+	RK3368_GPIO0C3_LCDC_D15        = (1 << 6),
+	RK3368_GPIO0C3_TRACE_D5        = (2 << 6),
+	RK3368_GPIO0C3_MCU_JTAG_TDO    = (3 << 6),
+
+	RK3368_GPIO0C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0C2_GPIO            = 0,
+	RK3368_GPIO0C2_LCDC_D14        = (1 << 4),
+	RK3368_GPIO0C2_TRACE_D4        = (2 << 4),
+	RK3368_GPIO0C2_MCU_JTAG_TDI    = (3 << 4),
+
+	RK3368_GPIO0C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0C1_GPIO            = 0,
+	RK3368_GPIO0C1_LCDC_D13        = (1 << 2),
+	RK3368_GPIO0C1_TRACE_D3        = (2 << 2),
+	RK3368_GPIO0C1_MCU_JTAG_TRTSN  = (3 << 2),
+
+	RK3368_GPIO0C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0C0_GPIO            = 0,
+	RK3368_GPIO0C0_LCDC_D12        = (1 << 0),
+	RK3368_GPIO0C0_TRACE_D2        = (2 << 0),
+	RK3368_GPIO0C0_MCU_JTAG_TDO    = (3 << 0),
 };
 
 /*GRF_GPIO0D_IOMUX*/
 enum {
-	GPIO0D7_SHIFT           = 14,
-	GPIO0D7_MASK            = 3 << GPIO0D7_SHIFT,
-	GPIO0D7_GPIO            = 0,
-	GPIO0D7_LCDC_DCLK,
-	GPIO0D7_TRACE_CTL,
-	GPIO0D7_PMU_DEBUG5,
-
-	GPIO0D6_SHIFT           = 12,
-	GPIO0D6_MASK            = 3 << GPIO0D6_SHIFT,
-	GPIO0D6_GPIO            = 0,
-	GPIO0D6_LCDC_DEN,
-	GPIO0D6_TRACE_CLK,
-	GPIO0D6_PMU_DEBUG4,
-
-	GPIO0D5_SHIFT           = 10,
-	GPIO0D5_MASK            = 3 << GPIO0D5_SHIFT,
-	GPIO0D5_GPIO            = 0,
-	GPIO0D5_LCDC_VSYNC,
-	GPIO0D5_TRACE_D15,
-	GPIO0D5_PMU_DEBUG3,
-
-	GPIO0D4_SHIFT           = 8,
-	GPIO0D4_MASK            = 3 << GPIO0D4_SHIFT,
-	GPIO0D4_GPIO            = 0,
-	GPIO0D4_LCDC_HSYNC,
-	GPIO0D4_TRACE_D14,
-	GPIO0D4_PMU_DEBUG2,
-
-	GPIO0D3_SHIFT           = 6,
-	GPIO0D3_MASK            = 3 << GPIO0D3_SHIFT,
-	GPIO0D3_GPIO            = 0,
-	GPIO0D3_LCDC_D23,
-	GPIO0D3_TRACE_D13,
-	GPIO0D3_UART4_SIN,
-
-	GPIO0D2_SHIFT           = 4,
-	GPIO0D2_MASK            = 3 << GPIO0D2_SHIFT,
-	GPIO0D2_GPIO            = 0,
-	GPIO0D2_LCDC_D22,
-	GPIO0D2_TRACE_D12,
-	GPIO0D2_UART4_SOUT,
-
-	GPIO0D1_SHIFT           = 2,
-	GPIO0D1_MASK            = 3 << GPIO0D1_SHIFT,
-	GPIO0D1_GPIO            = 0,
-	GPIO0D1_LCDC_D21,
-	GPIO0D1_TRACE_D11,
-	GPIO0D1_UART4_RTSN,
-
-	GPIO0D0_SHIFT           = 0,
-	GPIO0D0_MASK            = 3 << GPIO0D0_SHIFT,
-	GPIO0D0_GPIO            = 0,
-	GPIO0D0_LCDC_D20,
-	GPIO0D0_TRACE_D10,
-	GPIO0D0_UART4_CTSN,
+	RK3368_GPIO0D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO0D7_GPIO            = 0,
+	RK3368_GPIO0D7_LCDC_DCLK       = (1 << 14),
+	RK3368_GPIO0D7_TRACE_CTL       = (2 << 14),
+	RK3368_GPIO0D7_PMU_DEBUG5      = (3 << 14),
+
+	RK3368_GPIO0D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0D6_GPIO            = 0,
+	RK3368_GPIO0D6_LCDC_DEN        = (1 << 12),
+	RK3368_GPIO0D6_TRACE_CLK       = (2 << 12),
+	RK3368_GPIO0D6_PMU_DEBUG4      = (3 << 12),
+
+	RK3368_GPIO0D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0D5_GPIO            = 0,
+	GPIO0D5_LCDC_VSYNC             = (1 << 10),
+	RK3368_GPIO0D5_TRACE_D15       = (2 << 10),
+	RK3368_GPIO0D5_PMU_DEBUG3      = (3 << 10),
+
+	RK3368_GPIO0D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0D4_GPIO            = 0,
+	RK3368_GPIO0D4_LCDC_HSYNC      = (1 << 8),
+	RK3368_GPIO0D4_TRACE_D14       = (2 << 8),
+	RK3368_GPIO0D4_PMU_DEBUG2      = (3 << 8),
+
+	RK3368_GPIO0D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0D3_GPIO            = 0,
+	RK3368_GPIO0D3_LCDC_D23        = (1 << 6),
+	RK3368_GPIO0D3_TRACE_D13       = (2 << 6),
+	RK3368_GPIO0D3_UART4_SIN       = (3 << 6),
+
+	RK3368_GPIO0D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0D2_GPIO            = 0,
+	RK3368_GPIO0D2_LCDC_D22        = (1 << 4),
+	RK3368_GPIO0D2_TRACE_D12       = (2 << 4),
+	RK3368_GPIO0D2_UART4_SOUT      = (3 << 4),
+
+	RK3368_GPIO0D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0D1_GPIO            = 0,
+	RK3368_GPIO0D1_LCDC_D21        = (1 << 2),
+	RK3368_GPIO0D1_TRACE_D11       = (2 << 2),
+	RK3368_GPIO0D1_UART4_RTSN      = (3 << 2),
+
+	RK3368_GPIO0D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0D0_GPIO            = 0,
+	RK3368_GPIO0D0_LCDC_D20        = (1 << 0),
+	RK3368_GPIO0D0_TRACE_D10       = (2 << 0),
+	RK3368_GPIO0D0_UART4_CTSN      = (3 << 0),
 };
 
 /*GRF_GPIO2A_IOMUX*/
 enum {
-	GPIO2A7_SHIFT           = 14,
-	GPIO2A7_MASK            = 3 << GPIO2A7_SHIFT,
-	GPIO2A7_GPIO            = 0,
-	GPIO2A7_SDMMC0_D2,
-	GPIO2A7_JTAG_TCK,
-
-	GPIO2A6_SHIFT           = 12,
-	GPIO2A6_MASK            = 3 << GPIO2A6_SHIFT,
-	GPIO2A6_GPIO            = 0,
-	GPIO2A6_SDMMC0_D1,
-	GPIO2A6_UART2_SIN,
-
-	GPIO2A5_SHIFT           = 10,
-	GPIO2A5_MASK            = 3 << GPIO2A5_SHIFT,
-	GPIO2A5_GPIO            = 0,
-	GPIO2A5_SDMMC0_D0,
-	GPIO2A5_UART2_SOUT,
-
-	GPIO2A4_SHIFT           = 8,
-	GPIO2A4_MASK            = 3 << GPIO2A4_SHIFT,
-	GPIO2A4_GPIO            = 0,
-	GPIO2A4_FLASH_DQS,
-	GPIO2A4_EMMC_CLKO,
-
-	GPIO2A3_SHIFT           = 6,
-	GPIO2A3_MASK            = 3 << GPIO2A3_SHIFT,
-	GPIO2A3_GPIO            = 0,
-	GPIO2A3_FLASH_CSN3,
-	GPIO2A3_EMMC_RSTNO,
-
-	GPIO2A2_SHIFT           = 4,
-	GPIO2A2_MASK            = 3 << GPIO2A2_SHIFT,
-	GPIO2A2_GPIO           = 0,
-	GPIO2A2_FLASH_CSN2,
-
-	GPIO2A1_SHIFT           = 2,
-	GPIO2A1_MASK            = 3 << GPIO2A1_SHIFT,
-	GPIO2A1_GPIO            = 0,
-	GPIO2A1_FLASH_CSN1,
-
-	GPIO2A0_SHIFT           = 0,
-	GPIO2A0_MASK            = 3 << GPIO2A0_SHIFT,
-	GPIO2A0_GPIO            = 0,
-	GPIO2A0_FLASH_CSN0,
+	RK3368_GPIO2A7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2A7_GPIO            = 0,
+	RK3368_GPIO2A7_SDMMC0_D2       = (1 << 14),
+	RK3368_GPIO2A7_JTAG_TCK        = (2 << 14),
+
+	RK3368_GPIO2A6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2A6_GPIO            = 0,
+	RK3368_GPIO2A6_SDMMC0_D1       = (1 << 12),
+	RK3368_GPIO2A6_UART2_SIN       = (2 << 12),
+
+	RK3368_GPIO2A5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2A5_GPIO            = 0,
+	RK3368_GPIO2A5_SDMMC0_D0       = (1 << 10),
+	RK3368_GPIO2A5_UART2_SOUT      = (2 << 10),
+
+	RK3368_GPIO2A4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2A4_RK3368_GPIO     = 0,
+	RK3368_GPIO2A4_FLASH_DQS       = (1 << 8),
+	RK3368_GPIO2A4_EMMC_CLKOUT     = (2 << 8),
+
+	RK3368_GPIO2A3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2A3_GPIO            = 0,
+	RK3368_GPIO2A3_FLASH_CSN3      = (1 << 6),
+	RK3368_GPIO2A3_EMMC_RSTNOUT    = (2 << 6),
+
+	RK3368_GPIO2A2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2A2_GPIO            = 0,
+	RK3368_GPIO2A2_FLASH_CSN2      = (1 << 4),
+
+	RK3368_GPIO2A1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2A1_GPIO            = 0,
+	RK3368_GPIO2A1_FLASH_CSN1      = (1 << 2),
+
+	RK3368_GPIO2A0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2A0_GPIO            = 0,
+	RK3368_GPIO2A0_FLASH_CSN0      = (1 << 0),
 };
 
-/*GRF_GPIO2D_IOMUX*/
+/*GRF_RK3368_GPIO2D_IOMUX*/
 enum {
-	GPIO2D7_SHIFT           = 14,
-	GPIO2D7_MASK            = 3 << GPIO2D7_SHIFT,
-	GPIO2D7_GPIO            = 0,
-	GPIO2D7_SDIO0_D3,
-
-	GPIO2D6_SHIFT           = 12,
-	GPIO2D6_MASK            = 3 << GPIO2D6_SHIFT,
-	GPIO2D6_GPIO            = 0,
-	GPIO2D6_SDIO0_D2,
-
-	GPIO2D5_SHIFT           = 10,
-	GPIO2D5_MASK            = 3 << GPIO2D5_SHIFT,
-	GPIO2D5_GPIO            = 0,
-	GPIO2D5_SDIO0_D1,
-
-	GPIO2D4_SHIFT           = 8,
-	GPIO2D4_MASK            = 3 << GPIO2D4_SHIFT,
-	GPIO2D4_GPIO            = 0,
-	GPIO2D4_SDIO0_D0,
-
-	GPIO2D3_SHIFT           = 6,
-	GPIO2D3_MASK            = 3 << GPIO2D3_SHIFT,
-	GPIO2D3_GPIO            = 0,
-	GPIO2D3_UART0_RTS0,
-
-	GPIO2D2_SHIFT           = 4,
-	GPIO2D2_MASK            = 3 << GPIO2D2_SHIFT,
-	GPIO2D2_GPIO            = 0,
-	GPIO2D2_UART0_CTS0,
-
-	GPIO2D1_SHIFT           = 2,
-	GPIO2D1_MASK            = 3 << GPIO2D1_SHIFT,
-	GPIO2D1_GPIO            = 0,
-	GPIO2D1_UART0_SOUT,
-
-	GPIO2D0_SHIFT           = 0,
-	GPIO2D0_MASK            = 3 << GPIO2D0_SHIFT,
-	GPIO2D0_GPIO            = 0,
-	GPIO2D0_UART0_SIN,
+	RK3368_GPIO2D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2D7_GPIO            = 0,
+	RK3368_GPIO2D7_SDIO0_D3        = (1 << 14),
+
+	RK3368_GPIO2D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2D6_GPIO            = 0,
+	RK3368_GPIO2D6_SDIO0_D2        = (1 << 12),
+
+	RK3368_GPIO2D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2D5_GPIO            = 0,
+	RK3368_GPIO2D5_SDIO0_D1        = (1 << 10),
+
+	RK3368_GPIO2D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2D4_GPIO            = 0,
+	RK3368_GPIO2D4_SDIO0_D0        = (1 << 8),
+
+	RK3368_GPIO2D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2D3_GPIO            = 0,
+	RK3368_GPIO2D3_UART0_RTS0      = (1 << 6),
+
+	RK3368_GPIO2D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2D2_GPIO            = 0,
+	RK3368_GPIO2D2_UART0_CTS0      = (1 << 4),
+
+	RK3368_GPIO2D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2D1_GPIO            = 0,
+	RK3368_GPIO2D1_UART0_SOUT      = (1 << 2),
+
+	RK3368_GPIO2D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2D0_GPIO            = 0,
+	RK3368_GPIO2D0_UART0_SIN       = (1 << 0),
+};
+
+/* GRF_GPIO1C_IOMUX */
+enum {
+	RK3368_GPIO1C7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO1C7_GPIO            = 0,
+	RK3368_GPIO1C7_EMMC_DATA5      = (2 << 14),
+
+	RK3368_GPIO1C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO1C6_GPIO            = 0,
+	RK3368_GPIO1C6_EMMC_DATA4      = (2 << 12),
+
+	RK3368_GPIO1C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO1C5_GPIO            = 0,
+	RK3368_GPIO1C5_EMMC_DATA3      = (2 << 10),
+
+	RK3368_GPIO1C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO1C4_GPIO            = 0,
+	RK3368_GPIO1C4_EMMC_DATA2      = (2 << 8),
+
+	RK3368_GPIO1C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1C3_GPIO            = 0,
+	RK3368_GPIO1C3_EMMC_DATA1      = (2 << 6),
+
+	RK3368_GPIO1C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1C2_GPIO            = 0,
+	RK3368_GPIO1C2_EMMC_DATA0      = (2 << 4),
+};
+
+/* GRF_GPIO1D_IOMUX*/
+enum {
+	RK3368_GPIO1D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1D3_GPIO            = 0,
+	RK3368_GPIO1D3_EMMC_PWREN      = (2 << 6),
+
+	RK3368_GPIO1D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1D2_GPIO            = 0,
+	RK3368_GPIO1D2_EMMC_CMD        = (2 << 4),
+
+	RK3368_GPIO1D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO1D1_GPIO            = 0,
+	RK3368_GPIO1D1_EMMC_DATA7      = (2 << 2),
+
+	RK3368_GPIO1D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO1D0_GPIO            = 0,
+	RK3368_GPIO1D0_EMMC_DATA6      = (2 << 0),
+};
+
+
+/*GRF_GPIO3B_IOMUX*/
+enum {
+	RK3368_GPIO3B7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO3B7_GPIO            = 0,
+	RK3368_GPIO3B7_MAC_RXD0        = (1 << 14),
+
+	RK3368_GPIO3B6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3B6_GPIO            = 0,
+	RK3368_GPIO3B6_MAC_TXD3        = (1 << 12),
+
+	RK3368_GPIO3B5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3B5_GPIO            = 0,
+	RK3368_GPIO3B5_MAC_TXEN        = (1 << 10),
+
+	RK3368_GPIO3B4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3B4_GPIO            = 0,
+	RK3368_GPIO3B4_MAC_COL         = (1 << 8),
+
+	RK3368_GPIO3B3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3B3_GPIO            = 0,
+	RK3368_GPIO3B3_MAC_CRS         = (1 << 6),
+
+	RK3368_GPIO3B2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3B2_GPIO            = 0,
+	RK3368_GPIO3B2_MAC_TXD2        = (1 << 4),
+
+	RK3368_GPIO3B1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3B1_GPIO            = 0,
+	RK3368_GPIO3B1_MAC_TXD1        = (1 << 2),
+
+	RK3368_GPIO3B0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3B0_GPIO            = 0,
+	RK3368_GPIO3B0_MAC_TXD0        = (1 << 0),
+	RK3368_GPIO3B0_PWM0            = (2 << 0),
 };
 
 /*GRF_GPIO3C_IOMUX*/
 enum {
-	GPIO3C7_SHIFT           = 14,
-	GPIO3C7_MASK            = 3 << GPIO3C7_SHIFT,
-	GPIO3C7_GPIO            = 0,
-	GPIO3C7_EDPHDMI_CECINOUT,
-	GPIO3C7_ISP_FLASHTRIGIN,
-
-	GPIO3C6_SHIFT           = 12,
-	GPIO3C6_MASK            = 3 << GPIO3C6_SHIFT,
-	GPIO3C6_GPIO            = 0,
-	GPIO3C6_MAC_CLK,
-	GPIO3C6_ISP_SHUTTERTRIG,
-
-	GPIO3C5_SHIFT           = 10,
-	GPIO3C5_MASK            = 3 << GPIO3C5_SHIFT,
-	GPIO3C5_GPIO            = 0,
-	GPIO3C5_MAC_RXER,
-	GPIO3C5_ISP_PRELIGHTTRIG,
-
-	GPIO3C4_SHIFT           = 8,
-	GPIO3C4_MASK            = 3 << GPIO3C4_SHIFT,
-	GPIO3C4_GPIO            = 0,
-	GPIO3C4_MAC_RXDV,
-	GPIO3C4_ISP_FLASHTRIGOUT,
-
-	GPIO3C3_SHIFT           = 6,
-	GPIO3C3_MASK            = 3 << GPIO3C3_SHIFT,
-	GPIO3C3_GPIO            = 0,
-	GPIO3C3_MAC_RXDV,
-	GPIO3C3_EMMC_RSTNO,
-
-	GPIO3C2_SHIFT           = 4,
-	GPIO3C2_MASK            = 3 << GPIO3C2_SHIFT,
-	GPIO3C2_MAC_MDC            = 0,
-	GPIO3C2_ISP_SHUTTEREN,
-
-	GPIO3C1_SHIFT           = 2,
-	GPIO3C1_MASK            = 3 << GPIO3C1_SHIFT,
-	GPIO3C1_GPIO            = 0,
-	GPIO3C1_MAC_RXD2,
-	GPIO3C1_UART3_RTSN,
-
-	GPIO3C0_SHIFT           = 0,
-	GPIO3C0_MASK            = 3 << GPIO3C0_SHIFT,
-	GPIO3C0_GPIO            = 0,
-	GPIO3C0_MAC_RXD1,
-	GPIO3C0_UART3_CTSN,
-	GPIO3C0_GPS_RFCLK,
+	RK3368_GPIO3C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3C6_GPIO            = 0,
+	RK3368_GPIO3C6_MAC_CLK         = (1 << 12),
+
+	RK3368_GPIO3C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3C5_GPIO            = 0,
+	RK3368_GPIO3C5_MAC_RXEN        = (1 << 10),
+
+	RK3368_GPIO3C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3C4_GPIO            = 0,
+	RK3368_GPIO3C4_MAC_RXDV        = (1 << 8),
+
+	RK3368_GPIO3C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3C3_GPIO            = 0,
+	RK3368_GPIO3C3_MAC_MDC         = (1 << 6),
+
+	RK3368_GPIO3C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3C2_GPIO            = 0,
+	RK3368_GPIO3C2_MAC_RXD3        = (1 << 4),
+
+	RK3368_GPIO3C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3C1_GPIO            = 0,
+	RK3368_GPIO3C1_MAC_RXD2        = (1 << 2),
+
+	RK3368_GPIO3C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3C0_GPIO            = 0,
+	RK3368_GPIO3C0_MAC_RXD1        = (1 << 0),
 };
 
 /*GRF_GPIO3D_IOMUX*/
 enum {
-	GPIO3D7_SHIFT           = 14,
-	GPIO3D7_MASK            = 3 << GPIO3D7_SHIFT,
-	GPIO3D7_GPIO            = 0,
-	GPIO3D7_SC_VCC18V,
-	GPIO3D7_I2C2_SDA,
-	GPIO3D7_GPUJTAG_TCK,
-
-	GPIO3D6_SHIFT           = 12,
-	GPIO3D6_MASK            = 3 << GPIO3D6_SHIFT,
-	GPIO3D6_GPIO            = 0,
-	GPIO3D6_IR_TX,
-	GPIO3D6_UART3_SOUT,
-	GPIO3D6_PWM3,
-
-	GPIO3D5_SHIFT           = 10,
-	GPIO3D5_MASK            = 3 << GPIO3D5_SHIFT,
-	GPIO3D5_GPIO            = 0,
-	GPIO3D5_IR_RX,
-	GPIO3D5_UART3_SIN,
-
-	GPIO3D4_SHIFT           = 8,
-	GPIO3D4_MASK            = 3 << GPIO3D4_SHIFT,
-	GPIO3D4_GPIO            = 0,
-	GPIO3D4_MAC_TXCLKOUT,
-	GPIO3D4_SPI1_CSN1,
-
-	GPIO3D3_SHIFT           = 6,
-	GPIO3D3_MASK            = 3 << GPIO3D3_SHIFT,
-	GPIO3D3_GPIO            = 0,
-	GPIO3D3_HDMII2C_SCL,
-	GPIO3D3_I2C5_SCL,
-
-	GPIO3D2_SHIFT           = 4,
-	GPIO3D2_MASK            = 3 << GPIO3D2_SHIFT,
-	GPIO3D2_GPIO            = 0,
-	GPIO3D2_HDMII2C_SDA,
-	GPIO3D2_I2C5_SDA,
-
-	GPIO3D1_SHIFT           = 2,
-	GPIO3D1_MASK            = 3 << GPIO3D1_SHIFT,
-	GPIO3D1_GPIO            = 0,
-	GPIO3D1_MAC_RXCLKIN,
-	GPIO3D1_I2C4_SCL,
-
-	GPIO3D0_SHIFT           = 0,
-	GPIO3D0_MASK            = 3 << GPIO3D0_SHIFT,
-	GPIO3D0_GPIO            = 0,
-	GPIO3D0_MAC_MDIO,
-	GPIO3D0_I2C4_SDA,
+	RK3368_GPIO3D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3D4_GPIO            = 0,
+	RK3368_GPIO3D4_MAC_TXCLK       = (1 << 8),
+
+	RK3368_GPIO3D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3D1_GPIO            = 0,
+	RK3368_GPIO3D1_MAC_RXCLK       = (1 << 2),
+
+	RK3368_GPIO3D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3D0_GPIO            = 0,
+	RK3368_GPIO3D0_MAC_MDIO        = (1 << 0),
+};
+
+/* GRF_SOC_CON0 */
+enum {
+	NOC_RSP_ERR_STALL = BIT(9),
+	MOBILE_DDR_SEL = BIT(4),
+	DDR0_16BIT_EN = BIT(3),
+	MSCH0_MAINDDR3_DDR3 = BIT(2),
+	MSCH0_MAINPARTIALPOP = BIT(1),
+	UPCTL_C_ACTIVE = BIT(0),
 };
 
 /*GRF_SOC_CON11/12/13*/
@@ -440,4 +445,34 @@ enum {
 	MCU_CODE_BASE_BIT31_BIT28_SHIFT		= 0,
 	MCU_CODE_BASE_BIT31_BIT28_MASK		= GENMASK(3, 0),
 };
+
+/*GRF_SOC_CON15*/
+enum {
+	RK3368_GMAC_PHY_INTF_SEL_RGMII = 1 << 9,
+	RK3368_GMAC_PHY_INTF_SEL_MASK = GENMASK(11, 9),
+	RK3368_RMII_MODE_MASK  = BIT(6),
+	RK3368_RMII_MODE       = BIT(6),
+	RK3368_GMAC_CLK_SEL_2_5M = 2 << 4,
+	RK3368_GMAC_CLK_SEL_25M = 3 << 4,
+	RK3368_GMAC_CLK_SEL_125M = 0 << 4,
+	RK3368_GMAC_CLK_SEL_MASK = GENMASK(5, 4),
+};
+
+/* GRF_SOC_CON16 */
+enum {
+	RK3368_RXCLK_DLY_ENA_GMAC_MASK = BIT(15),
+	RK3368_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(15),
+
+	RK3368_TXCLK_DLY_ENA_GMAC_MASK = BIT(7),
+	RK3368_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(7),
+
+	RK3368_CLK_RX_DL_CFG_GMAC_SHIFT = 8,
+	RK3368_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(14, 8),
+
+	RK3368_CLK_TX_DL_CFG_GMAC_SHIFT = 0,
+	RK3368_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
+};
+
 #endif
drivers/pinctrl/rockchip/pinctrl_rk3368.c +8 -9
index bdf0758..b77c5ab 100644
@@ -30,9 +30,9 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
 	switch (uart_id) {
 	case PERIPH_ID_UART2:
 		rk_clrsetreg(&grf->gpio2a_iomux,
-			     GPIO2A6_MASK | GPIO2A5_MASK,
-			     GPIO2A6_UART2_SIN << GPIO2A6_SHIFT |
-			     GPIO2A5_UART2_SOUT << GPIO2A5_SHIFT);
+			     RK3368_GPIO2A6_MASK | RK3368_GPIO2A5_MASK,
+			     RK3368_GPIO2A6_UART2_SIN |
+			     RK3368_GPIO2A5_UART2_SOUT);
 		break;
 	case PERIPH_ID_UART0:
 		break;
@@ -42,12 +42,11 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
 		break;
 	case PERIPH_ID_UART4:
 		rk_clrsetreg(&pmugrf->gpio0d_iomux,
-			     GPIO0D0_MASK | GPIO0D1_MASK |
-			     GPIO0D2_MASK | GPIO0D3_MASK,
-			     GPIO0D0_GPIO << GPIO0D0_SHIFT |
-			     GPIO0D1_GPIO << GPIO0D1_SHIFT |
-			     GPIO0D2_UART4_SOUT << GPIO0D2_SHIFT |
-			     GPIO0D3_UART4_SIN << GPIO0D3_SHIFT);
+			     RK3368_GPIO0D0_MASK | RK3368_GPIO0D1_MASK |
+			     RK3368_GPIO0D2_MASK | RK3368_GPIO0D3_MASK,
+			     RK3368_GPIO0D0_GPIO | RK3368_GPIO0D1_GPIO |
+			     RK3368_GPIO0D2_UART4_SOUT |
+			     RK3368_GPIO0D3_UART4_SIN);
 		break;
 	default:
 		debug("uart id = %d iomux error!\n", uart_id);
Signature · 1 line
2.1.4
#33 lore raw

PATCH 30/52 rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_

Hi Philipp:

Quoted 9 lines · Philipp Tomsich

The RK3368 GRF header was still defines with a shifted-mask but with non-shifted function selectors for the IOMUX defines. As the RK3368 support is still fresh enough to allow a quick rename, we do this now before having more code use this.

As some of the downstream drivers (e.g. the Designware GMAC wrapper) may need to include the grf-header of multiple devices, we rename the various defines for the RK3368 by prefixing them with the device name. This avoids future trouble during driver integration.

Is that really necessary to add such a prefix for all the register
definition, just to fit the GMAC dirver?
Maybe the gmac driver can define the platform specific macro in its own code like dwmac-rk in the kernel. Then we can keep the register header file a little tidy.

Quoted 698 lines

---

  arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 617 +++++++++++++-----------
  drivers/pinctrl/rockchip/pinctrl_rk3368.c       |  17 +-
  2 files changed, 334 insertions(+), 300 deletions(-)
arch/arm/include/asm/arch-rockchip/grf_rk3368.h +326 -291
index a438f5d..a97dc1e 100644
@@ -1,4 +1,6 @@
-/* (C) Copyright 2016 Rockchip Electronics Co., Ltd
+/*
+ * (C) Copyright 2016 Rockchip Electronics Co., Ltd
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
   *
   * SPDX-License-Identifier:     GPL-2.0+
   */
@@ -100,315 +102,318 @@ check_member(rk3368_pmu_grf, os_reg[0], 0x200);
 
  /*GRF_GPIO0C_IOMUX*/
  enum {
-	GPIO0C7_SHIFT		= 14,
-	GPIO0C7_MASK		= 3 << GPIO0C7_SHIFT,
-	GPIO0C7_GPIO		= 0,
-	GPIO0C7_LCDC_D19,
-	GPIO0C7_TRACE_D9,
-	GPIO0C7_UART1_RTSN,
-
-	GPIO0C6_SHIFT           = 12,
-	GPIO0C6_MASK            = 3 << GPIO0C6_SHIFT,
-	GPIO0C6_GPIO            = 0,
-	GPIO0C6_LCDC_D18,
-	GPIO0C6_TRACE_D8,
-	GPIO0C6_UART1_CTSN,
-
-	GPIO0C5_SHIFT           = 10,
-	GPIO0C5_MASK            = 3 << GPIO0C5_SHIFT,
-	GPIO0C5_GPIO            = 0,
-	GPIO0C5_LCDC_D17,
-	GPIO0C5_TRACE_D7,
-	GPIO0C5_UART1_SOUT,
-
-	GPIO0C4_SHIFT           = 8,
-	GPIO0C4_MASK            = 3 << GPIO0C4_SHIFT,
-	GPIO0C4_GPIO            = 0,
-	GPIO0C4_LCDC_D16,
-	GPIO0C4_TRACE_D6,
-	GPIO0C4_UART1_SIN,
-
-	GPIO0C3_SHIFT           = 6,
-	GPIO0C3_MASK            = 3 << GPIO0C3_SHIFT,
-	GPIO0C3_GPIO            = 0,
-	GPIO0C3_LCDC_D15,
-	GPIO0C3_TRACE_D5,
-	GPIO0C3_MCU_JTAG_TDO,
-
-	GPIO0C2_SHIFT           = 4,
-	GPIO0C2_MASK            = 3 << GPIO0C2_SHIFT,
-	GPIO0C2_GPIO            = 0,
-	GPIO0C2_LCDC_D14,
-	GPIO0C2_TRACE_D4,
-	GPIO0C2_MCU_JTAG_TDI,
-
-	GPIO0C1_SHIFT           = 2,
-	GPIO0C1_MASK            = 3 << GPIO0C1_SHIFT,
-	GPIO0C1_GPIO            = 0,
-	GPIO0C1_LCDC_D13,
-	GPIO0C1_TRACE_D3,
-	GPIO0C1_MCU_JTAG_TRTSN,
-
-	GPIO0C0_SHIFT           = 0,
-	GPIO0C0_MASK            = 3 << GPIO0C0_SHIFT,
-	GPIO0C0_GPIO            = 0,
-	GPIO0C0_LCDC_D12,
-	GPIO0C0_TRACE_D2,
-	GPIO0C0_MCU_JTAG_TDO,
+	RK3368_GPIO0C7_MASK	       = GENMASK(15, 14),
+	RK3368_GPIO0C7_GPIO	       = 0,
+	RK3368_GPIO0C7_LCDC_D19        = (1 << 14),
+	RK3368_GPIO0C7_TRACE_D9        = (2 << 14),
+	RK3368_GPIO0C7_UART1_RTSN      = (3 << 14),
+
+	RK3368_GPIO0C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0C6_GPIO            = 0,
+	RK3368_GPIO0C6_LCDC_D18        = (1 << 12),
+	RK3368_GPIO0C6_TRACE_D8        = (2 << 12),
+	RK3368_GPIO0C6_UART1_CTSN      = (3 << 12),
+
+	RK3368_GPIO0C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0C5_GPIO            = 0,
+	RK3368_GPIO0C5_LCDC_D17        = (1 << 10),
+	RK3368_GPIO0C5_TRACE_D7        = (2 << 10),
+	RK3368_GPIO0C5_UART1_SOUT      = (3 << 10),
+
+	RK3368_GPIO0C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0C4_GPIO            = 0,
+	RK3368_GPIO0C4_LCDC_D16        = (1 << 8),
+	RK3368_GPIO0C4_TRACE_D6        = (2 << 8),
+	RK3368_GPIO0C4_UART1_SIN       = (3 << 8),
+
+	RK3368_GPIO0C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0C3_GPIO            = 0,
+	RK3368_GPIO0C3_LCDC_D15        = (1 << 6),
+	RK3368_GPIO0C3_TRACE_D5        = (2 << 6),
+	RK3368_GPIO0C3_MCU_JTAG_TDO    = (3 << 6),
+
+	RK3368_GPIO0C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0C2_GPIO            = 0,
+	RK3368_GPIO0C2_LCDC_D14        = (1 << 4),
+	RK3368_GPIO0C2_TRACE_D4        = (2 << 4),
+	RK3368_GPIO0C2_MCU_JTAG_TDI    = (3 << 4),
+
+	RK3368_GPIO0C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0C1_GPIO            = 0,
+	RK3368_GPIO0C1_LCDC_D13        = (1 << 2),
+	RK3368_GPIO0C1_TRACE_D3        = (2 << 2),
+	RK3368_GPIO0C1_MCU_JTAG_TRTSN  = (3 << 2),
+
+	RK3368_GPIO0C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0C0_GPIO            = 0,
+	RK3368_GPIO0C0_LCDC_D12        = (1 << 0),
+	RK3368_GPIO0C0_TRACE_D2        = (2 << 0),
+	RK3368_GPIO0C0_MCU_JTAG_TDO    = (3 << 0),
  };
 
  /*GRF_GPIO0D_IOMUX*/
  enum {
-	GPIO0D7_SHIFT           = 14,
-	GPIO0D7_MASK            = 3 << GPIO0D7_SHIFT,
-	GPIO0D7_GPIO            = 0,
-	GPIO0D7_LCDC_DCLK,
-	GPIO0D7_TRACE_CTL,
-	GPIO0D7_PMU_DEBUG5,
-
-	GPIO0D6_SHIFT           = 12,
-	GPIO0D6_MASK            = 3 << GPIO0D6_SHIFT,
-	GPIO0D6_GPIO            = 0,
-	GPIO0D6_LCDC_DEN,
-	GPIO0D6_TRACE_CLK,
-	GPIO0D6_PMU_DEBUG4,
-
-	GPIO0D5_SHIFT           = 10,
-	GPIO0D5_MASK            = 3 << GPIO0D5_SHIFT,
-	GPIO0D5_GPIO            = 0,
-	GPIO0D5_LCDC_VSYNC,
-	GPIO0D5_TRACE_D15,
-	GPIO0D5_PMU_DEBUG3,
-
-	GPIO0D4_SHIFT           = 8,
-	GPIO0D4_MASK            = 3 << GPIO0D4_SHIFT,
-	GPIO0D4_GPIO            = 0,
-	GPIO0D4_LCDC_HSYNC,
-	GPIO0D4_TRACE_D14,
-	GPIO0D4_PMU_DEBUG2,
-
-	GPIO0D3_SHIFT           = 6,
-	GPIO0D3_MASK            = 3 << GPIO0D3_SHIFT,
-	GPIO0D3_GPIO            = 0,
-	GPIO0D3_LCDC_D23,
-	GPIO0D3_TRACE_D13,
-	GPIO0D3_UART4_SIN,
-
-	GPIO0D2_SHIFT           = 4,
-	GPIO0D2_MASK            = 3 << GPIO0D2_SHIFT,
-	GPIO0D2_GPIO            = 0,
-	GPIO0D2_LCDC_D22,
-	GPIO0D2_TRACE_D12,
-	GPIO0D2_UART4_SOUT,
-
-	GPIO0D1_SHIFT           = 2,
-	GPIO0D1_MASK            = 3 << GPIO0D1_SHIFT,
-	GPIO0D1_GPIO            = 0,
-	GPIO0D1_LCDC_D21,
-	GPIO0D1_TRACE_D11,
-	GPIO0D1_UART4_RTSN,
-
-	GPIO0D0_SHIFT           = 0,
-	GPIO0D0_MASK            = 3 << GPIO0D0_SHIFT,
-	GPIO0D0_GPIO            = 0,
-	GPIO0D0_LCDC_D20,
-	GPIO0D0_TRACE_D10,
-	GPIO0D0_UART4_CTSN,
+	RK3368_GPIO0D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO0D7_GPIO            = 0,
+	RK3368_GPIO0D7_LCDC_DCLK       = (1 << 14),
+	RK3368_GPIO0D7_TRACE_CTL       = (2 << 14),
+	RK3368_GPIO0D7_PMU_DEBUG5      = (3 << 14),
+
+	RK3368_GPIO0D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0D6_GPIO            = 0,
+	RK3368_GPIO0D6_LCDC_DEN        = (1 << 12),
+	RK3368_GPIO0D6_TRACE_CLK       = (2 << 12),
+	RK3368_GPIO0D6_PMU_DEBUG4      = (3 << 12),
+
+	RK3368_GPIO0D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0D5_GPIO            = 0,
+	GPIO0D5_LCDC_VSYNC             = (1 << 10),
+	RK3368_GPIO0D5_TRACE_D15       = (2 << 10),
+	RK3368_GPIO0D5_PMU_DEBUG3      = (3 << 10),
+
+	RK3368_GPIO0D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0D4_GPIO            = 0,
+	RK3368_GPIO0D4_LCDC_HSYNC      = (1 << 8),
+	RK3368_GPIO0D4_TRACE_D14       = (2 << 8),
+	RK3368_GPIO0D4_PMU_DEBUG2      = (3 << 8),
+
+	RK3368_GPIO0D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0D3_GPIO            = 0,
+	RK3368_GPIO0D3_LCDC_D23        = (1 << 6),
+	RK3368_GPIO0D3_TRACE_D13       = (2 << 6),
+	RK3368_GPIO0D3_UART4_SIN       = (3 << 6),
+
+	RK3368_GPIO0D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0D2_GPIO            = 0,
+	RK3368_GPIO0D2_LCDC_D22        = (1 << 4),
+	RK3368_GPIO0D2_TRACE_D12       = (2 << 4),
+	RK3368_GPIO0D2_UART4_SOUT      = (3 << 4),
+
+	RK3368_GPIO0D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0D1_GPIO            = 0,
+	RK3368_GPIO0D1_LCDC_D21        = (1 << 2),
+	RK3368_GPIO0D1_TRACE_D11       = (2 << 2),
+	RK3368_GPIO0D1_UART4_RTSN      = (3 << 2),
+
+	RK3368_GPIO0D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0D0_GPIO            = 0,
+	RK3368_GPIO0D0_LCDC_D20        = (1 << 0),
+	RK3368_GPIO0D0_TRACE_D10       = (2 << 0),
+	RK3368_GPIO0D0_UART4_CTSN      = (3 << 0),
  };
 
  /*GRF_GPIO2A_IOMUX*/
  enum {
-	GPIO2A7_SHIFT           = 14,
-	GPIO2A7_MASK            = 3 << GPIO2A7_SHIFT,
-	GPIO2A7_GPIO            = 0,
-	GPIO2A7_SDMMC0_D2,
-	GPIO2A7_JTAG_TCK,
-
-	GPIO2A6_SHIFT           = 12,
-	GPIO2A6_MASK            = 3 << GPIO2A6_SHIFT,
-	GPIO2A6_GPIO            = 0,
-	GPIO2A6_SDMMC0_D1,
-	GPIO2A6_UART2_SIN,
-
-	GPIO2A5_SHIFT           = 10,
-	GPIO2A5_MASK            = 3 << GPIO2A5_SHIFT,
-	GPIO2A5_GPIO            = 0,
-	GPIO2A5_SDMMC0_D0,
-	GPIO2A5_UART2_SOUT,
-
-	GPIO2A4_SHIFT           = 8,
-	GPIO2A4_MASK            = 3 << GPIO2A4_SHIFT,
-	GPIO2A4_GPIO            = 0,
-	GPIO2A4_FLASH_DQS,
-	GPIO2A4_EMMC_CLKO,
-
-	GPIO2A3_SHIFT           = 6,
-	GPIO2A3_MASK            = 3 << GPIO2A3_SHIFT,
-	GPIO2A3_GPIO            = 0,
-	GPIO2A3_FLASH_CSN3,
-	GPIO2A3_EMMC_RSTNO,
-
-	GPIO2A2_SHIFT           = 4,
-	GPIO2A2_MASK            = 3 << GPIO2A2_SHIFT,
-	GPIO2A2_GPIO           = 0,
-	GPIO2A2_FLASH_CSN2,
-
-	GPIO2A1_SHIFT           = 2,
-	GPIO2A1_MASK            = 3 << GPIO2A1_SHIFT,
-	GPIO2A1_GPIO            = 0,
-	GPIO2A1_FLASH_CSN1,
-
-	GPIO2A0_SHIFT           = 0,
-	GPIO2A0_MASK            = 3 << GPIO2A0_SHIFT,
-	GPIO2A0_GPIO            = 0,
-	GPIO2A0_FLASH_CSN0,
+	RK3368_GPIO2A7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2A7_GPIO            = 0,
+	RK3368_GPIO2A7_SDMMC0_D2       = (1 << 14),
+	RK3368_GPIO2A7_JTAG_TCK        = (2 << 14),
+
+	RK3368_GPIO2A6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2A6_GPIO            = 0,
+	RK3368_GPIO2A6_SDMMC0_D1       = (1 << 12),
+	RK3368_GPIO2A6_UART2_SIN       = (2 << 12),
+
+	RK3368_GPIO2A5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2A5_GPIO            = 0,
+	RK3368_GPIO2A5_SDMMC0_D0       = (1 << 10),
+	RK3368_GPIO2A5_UART2_SOUT      = (2 << 10),
+
+	RK3368_GPIO2A4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2A4_RK3368_GPIO     = 0,
+	RK3368_GPIO2A4_FLASH_DQS       = (1 << 8),
+	RK3368_GPIO2A4_EMMC_CLKOUT     = (2 << 8),
+
+	RK3368_GPIO2A3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2A3_GPIO            = 0,
+	RK3368_GPIO2A3_FLASH_CSN3      = (1 << 6),
+	RK3368_GPIO2A3_EMMC_RSTNOUT    = (2 << 6),
+
+	RK3368_GPIO2A2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2A2_GPIO            = 0,
+	RK3368_GPIO2A2_FLASH_CSN2      = (1 << 4),
+
+	RK3368_GPIO2A1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2A1_GPIO            = 0,
+	RK3368_GPIO2A1_FLASH_CSN1      = (1 << 2),
+
+	RK3368_GPIO2A0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2A0_GPIO            = 0,
+	RK3368_GPIO2A0_FLASH_CSN0      = (1 << 0),
  };
 
-/*GRF_GPIO2D_IOMUX*/
+/*GRF_RK3368_GPIO2D_IOMUX*/
  enum {
-	GPIO2D7_SHIFT           = 14,
-	GPIO2D7_MASK            = 3 << GPIO2D7_SHIFT,
-	GPIO2D7_GPIO            = 0,
-	GPIO2D7_SDIO0_D3,
-
-	GPIO2D6_SHIFT           = 12,
-	GPIO2D6_MASK            = 3 << GPIO2D6_SHIFT,
-	GPIO2D6_GPIO            = 0,
-	GPIO2D6_SDIO0_D2,
-
-	GPIO2D5_SHIFT           = 10,
-	GPIO2D5_MASK            = 3 << GPIO2D5_SHIFT,
-	GPIO2D5_GPIO            = 0,
-	GPIO2D5_SDIO0_D1,
-
-	GPIO2D4_SHIFT           = 8,
-	GPIO2D4_MASK            = 3 << GPIO2D4_SHIFT,
-	GPIO2D4_GPIO            = 0,
-	GPIO2D4_SDIO0_D0,
-
-	GPIO2D3_SHIFT           = 6,
-	GPIO2D3_MASK            = 3 << GPIO2D3_SHIFT,
-	GPIO2D3_GPIO            = 0,
-	GPIO2D3_UART0_RTS0,
-
-	GPIO2D2_SHIFT           = 4,
-	GPIO2D2_MASK            = 3 << GPIO2D2_SHIFT,
-	GPIO2D2_GPIO            = 0,
-	GPIO2D2_UART0_CTS0,
-
-	GPIO2D1_SHIFT           = 2,
-	GPIO2D1_MASK            = 3 << GPIO2D1_SHIFT,
-	GPIO2D1_GPIO            = 0,
-	GPIO2D1_UART0_SOUT,
-
-	GPIO2D0_SHIFT           = 0,
-	GPIO2D0_MASK            = 3 << GPIO2D0_SHIFT,
-	GPIO2D0_GPIO            = 0,
-	GPIO2D0_UART0_SIN,
+	RK3368_GPIO2D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2D7_GPIO            = 0,
+	RK3368_GPIO2D7_SDIO0_D3        = (1 << 14),
+
+	RK3368_GPIO2D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2D6_GPIO            = 0,
+	RK3368_GPIO2D6_SDIO0_D2        = (1 << 12),
+
+	RK3368_GPIO2D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2D5_GPIO            = 0,
+	RK3368_GPIO2D5_SDIO0_D1        = (1 << 10),
+
+	RK3368_GPIO2D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2D4_GPIO            = 0,
+	RK3368_GPIO2D4_SDIO0_D0        = (1 << 8),
+
+	RK3368_GPIO2D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2D3_GPIO            = 0,
+	RK3368_GPIO2D3_UART0_RTS0      = (1 << 6),
+
+	RK3368_GPIO2D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2D2_GPIO            = 0,
+	RK3368_GPIO2D2_UART0_CTS0      = (1 << 4),
+
+	RK3368_GPIO2D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2D1_GPIO            = 0,
+	RK3368_GPIO2D1_UART0_SOUT      = (1 << 2),
+
+	RK3368_GPIO2D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2D0_GPIO            = 0,
+	RK3368_GPIO2D0_UART0_SIN       = (1 << 0),
+};
+
+/* GRF_GPIO1C_IOMUX */
+enum {
+	RK3368_GPIO1C7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO1C7_GPIO            = 0,
+	RK3368_GPIO1C7_EMMC_DATA5      = (2 << 14),
+
+	RK3368_GPIO1C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO1C6_GPIO            = 0,
+	RK3368_GPIO1C6_EMMC_DATA4      = (2 << 12),
+
+	RK3368_GPIO1C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO1C5_GPIO            = 0,
+	RK3368_GPIO1C5_EMMC_DATA3      = (2 << 10),
+
+	RK3368_GPIO1C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO1C4_GPIO            = 0,
+	RK3368_GPIO1C4_EMMC_DATA2      = (2 << 8),
+
+	RK3368_GPIO1C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1C3_GPIO            = 0,
+	RK3368_GPIO1C3_EMMC_DATA1      = (2 << 6),
+
+	RK3368_GPIO1C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1C2_GPIO            = 0,
+	RK3368_GPIO1C2_EMMC_DATA0      = (2 << 4),
+};
+
+/* GRF_GPIO1D_IOMUX*/
+enum {
+	RK3368_GPIO1D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1D3_GPIO            = 0,
+	RK3368_GPIO1D3_EMMC_PWREN      = (2 << 6),
+
+	RK3368_GPIO1D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1D2_GPIO            = 0,
+	RK3368_GPIO1D2_EMMC_CMD        = (2 << 4),
+
+	RK3368_GPIO1D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO1D1_GPIO            = 0,
+	RK3368_GPIO1D1_EMMC_DATA7      = (2 << 2),
+
+	RK3368_GPIO1D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO1D0_GPIO            = 0,
+	RK3368_GPIO1D0_EMMC_DATA6      = (2 << 0),
+};
+
+
+/*GRF_GPIO3B_IOMUX*/
+enum {
+	RK3368_GPIO3B7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO3B7_GPIO            = 0,
+	RK3368_GPIO3B7_MAC_RXD0        = (1 << 14),
+
+	RK3368_GPIO3B6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3B6_GPIO            = 0,
+	RK3368_GPIO3B6_MAC_TXD3        = (1 << 12),
+
+	RK3368_GPIO3B5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3B5_GPIO            = 0,
+	RK3368_GPIO3B5_MAC_TXEN        = (1 << 10),
+
+	RK3368_GPIO3B4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3B4_GPIO            = 0,
+	RK3368_GPIO3B4_MAC_COL         = (1 << 8),
+
+	RK3368_GPIO3B3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3B3_GPIO            = 0,
+	RK3368_GPIO3B3_MAC_CRS         = (1 << 6),
+
+	RK3368_GPIO3B2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3B2_GPIO            = 0,
+	RK3368_GPIO3B2_MAC_TXD2        = (1 << 4),
+
+	RK3368_GPIO3B1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3B1_GPIO            = 0,
+	RK3368_GPIO3B1_MAC_TXD1        = (1 << 2),
+
+	RK3368_GPIO3B0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3B0_GPIO            = 0,
+	RK3368_GPIO3B0_MAC_TXD0        = (1 << 0),
+	RK3368_GPIO3B0_PWM0            = (2 << 0),
  };
 
  /*GRF_GPIO3C_IOMUX*/
  enum {
-	GPIO3C7_SHIFT           = 14,
-	GPIO3C7_MASK            = 3 << GPIO3C7_SHIFT,
-	GPIO3C7_GPIO            = 0,
-	GPIO3C7_EDPHDMI_CECINOUT,
-	GPIO3C7_ISP_FLASHTRIGIN,
-
-	GPIO3C6_SHIFT           = 12,
-	GPIO3C6_MASK            = 3 << GPIO3C6_SHIFT,
-	GPIO3C6_GPIO            = 0,
-	GPIO3C6_MAC_CLK,
-	GPIO3C6_ISP_SHUTTERTRIG,
-
-	GPIO3C5_SHIFT           = 10,
-	GPIO3C5_MASK            = 3 << GPIO3C5_SHIFT,
-	GPIO3C5_GPIO            = 0,
-	GPIO3C5_MAC_RXER,
-	GPIO3C5_ISP_PRELIGHTTRIG,
-
-	GPIO3C4_SHIFT           = 8,
-	GPIO3C4_MASK            = 3 << GPIO3C4_SHIFT,
-	GPIO3C4_GPIO            = 0,
-	GPIO3C4_MAC_RXDV,
-	GPIO3C4_ISP_FLASHTRIGOUT,
-
-	GPIO3C3_SHIFT           = 6,
-	GPIO3C3_MASK            = 3 << GPIO3C3_SHIFT,
-	GPIO3C3_GPIO            = 0,
-	GPIO3C3_MAC_RXDV,
-	GPIO3C3_EMMC_RSTNO,
-
-	GPIO3C2_SHIFT           = 4,
-	GPIO3C2_MASK            = 3 << GPIO3C2_SHIFT,
-	GPIO3C2_MAC_MDC            = 0,
-	GPIO3C2_ISP_SHUTTEREN,
-
-	GPIO3C1_SHIFT           = 2,
-	GPIO3C1_MASK            = 3 << GPIO3C1_SHIFT,
-	GPIO3C1_GPIO            = 0,
-	GPIO3C1_MAC_RXD2,
-	GPIO3C1_UART3_RTSN,
-
-	GPIO3C0_SHIFT           = 0,
-	GPIO3C0_MASK            = 3 << GPIO3C0_SHIFT,
-	GPIO3C0_GPIO            = 0,
-	GPIO3C0_MAC_RXD1,
-	GPIO3C0_UART3_CTSN,
-	GPIO3C0_GPS_RFCLK,
+	RK3368_GPIO3C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3C6_GPIO            = 0,
+	RK3368_GPIO3C6_MAC_CLK         = (1 << 12),
+
+	RK3368_GPIO3C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3C5_GPIO            = 0,
+	RK3368_GPIO3C5_MAC_RXEN        = (1 << 10),
+
+	RK3368_GPIO3C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3C4_GPIO            = 0,
+	RK3368_GPIO3C4_MAC_RXDV        = (1 << 8),
+
+	RK3368_GPIO3C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3C3_GPIO            = 0,
+	RK3368_GPIO3C3_MAC_MDC         = (1 << 6),
+
+	RK3368_GPIO3C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3C2_GPIO            = 0,
+	RK3368_GPIO3C2_MAC_RXD3        = (1 << 4),
+
+	RK3368_GPIO3C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3C1_GPIO            = 0,
+	RK3368_GPIO3C1_MAC_RXD2        = (1 << 2),
+
+	RK3368_GPIO3C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3C0_GPIO            = 0,
+	RK3368_GPIO3C0_MAC_RXD1        = (1 << 0),
  };
 
  /*GRF_GPIO3D_IOMUX*/
  enum {
-	GPIO3D7_SHIFT           = 14,
-	GPIO3D7_MASK            = 3 << GPIO3D7_SHIFT,
-	GPIO3D7_GPIO            = 0,
-	GPIO3D7_SC_VCC18V,
-	GPIO3D7_I2C2_SDA,
-	GPIO3D7_GPUJTAG_TCK,
-
-	GPIO3D6_SHIFT           = 12,
-	GPIO3D6_MASK            = 3 << GPIO3D6_SHIFT,
-	GPIO3D6_GPIO            = 0,
-	GPIO3D6_IR_TX,
-	GPIO3D6_UART3_SOUT,
-	GPIO3D6_PWM3,
-
-	GPIO3D5_SHIFT           = 10,
-	GPIO3D5_MASK            = 3 << GPIO3D5_SHIFT,
-	GPIO3D5_GPIO            = 0,
-	GPIO3D5_IR_RX,
-	GPIO3D5_UART3_SIN,
-
-	GPIO3D4_SHIFT           = 8,
-	GPIO3D4_MASK            = 3 << GPIO3D4_SHIFT,
-	GPIO3D4_GPIO            = 0,
-	GPIO3D4_MAC_TXCLKOUT,
-	GPIO3D4_SPI1_CSN1,
-
-	GPIO3D3_SHIFT           = 6,
-	GPIO3D3_MASK            = 3 << GPIO3D3_SHIFT,
-	GPIO3D3_GPIO            = 0,
-	GPIO3D3_HDMII2C_SCL,
-	GPIO3D3_I2C5_SCL,
-
-	GPIO3D2_SHIFT           = 4,
-	GPIO3D2_MASK            = 3 << GPIO3D2_SHIFT,
-	GPIO3D2_GPIO            = 0,
-	GPIO3D2_HDMII2C_SDA,
-	GPIO3D2_I2C5_SDA,
-
-	GPIO3D1_SHIFT           = 2,
-	GPIO3D1_MASK            = 3 << GPIO3D1_SHIFT,
-	GPIO3D1_GPIO            = 0,
-	GPIO3D1_MAC_RXCLKIN,
-	GPIO3D1_I2C4_SCL,
-
-	GPIO3D0_SHIFT           = 0,
-	GPIO3D0_MASK            = 3 << GPIO3D0_SHIFT,
-	GPIO3D0_GPIO            = 0,
-	GPIO3D0_MAC_MDIO,
-	GPIO3D0_I2C4_SDA,
+	RK3368_GPIO3D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3D4_GPIO            = 0,
+	RK3368_GPIO3D4_MAC_TXCLK       = (1 << 8),
+
+	RK3368_GPIO3D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3D1_GPIO            = 0,
+	RK3368_GPIO3D1_MAC_RXCLK       = (1 << 2),
+
+	RK3368_GPIO3D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3D0_GPIO            = 0,
+	RK3368_GPIO3D0_MAC_MDIO        = (1 << 0),
+};
+
+/* GRF_SOC_CON0 */
+enum {
+	NOC_RSP_ERR_STALL = BIT(9),
+	MOBILE_DDR_SEL = BIT(4),
+	DDR0_16BIT_EN = BIT(3),
+	MSCH0_MAINDDR3_DDR3 = BIT(2),
+	MSCH0_MAINPARTIALPOP = BIT(1),
+	UPCTL_C_ACTIVE = BIT(0),
  };
 
  /*GRF_SOC_CON11/12/13*/
@@ -440,4 +445,34 @@ enum {
  	MCU_CODE_BASE_BIT31_BIT28_SHIFT		= 0,
  	MCU_CODE_BASE_BIT31_BIT28_MASK		= GENMASK(3, 0),
  };
+
+/*GRF_SOC_CON15*/
+enum {
+	RK3368_GMAC_PHY_INTF_SEL_RGMII = 1 << 9,
+	RK3368_GMAC_PHY_INTF_SEL_MASK = GENMASK(11, 9),
+	RK3368_RMII_MODE_MASK  = BIT(6),
+	RK3368_RMII_MODE       = BIT(6),
+	RK3368_GMAC_CLK_SEL_2_5M = 2 << 4,
+	RK3368_GMAC_CLK_SEL_25M = 3 << 4,
+	RK3368_GMAC_CLK_SEL_125M = 0 << 4,
+	RK3368_GMAC_CLK_SEL_MASK = GENMASK(5, 4),
+};
+
+/* GRF_SOC_CON16 */
+enum {
+	RK3368_RXCLK_DLY_ENA_GMAC_MASK = BIT(15),
+	RK3368_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(15),
+
+	RK3368_TXCLK_DLY_ENA_GMAC_MASK = BIT(7),
+	RK3368_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(7),
+
+	RK3368_CLK_RX_DL_CFG_GMAC_SHIFT = 8,
+	RK3368_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(14, 8),
+
+	RK3368_CLK_TX_DL_CFG_GMAC_SHIFT = 0,
+	RK3368_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
+};
+
  #endif
drivers/pinctrl/rockchip/pinctrl_rk3368.c +8 -9
index bdf0758..b77c5ab 100644
@@ -30,9 +30,9 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
  	switch (uart_id) {
  	case PERIPH_ID_UART2:
  		rk_clrsetreg(&grf->gpio2a_iomux,
-			     GPIO2A6_MASK | GPIO2A5_MASK,
-			     GPIO2A6_UART2_SIN << GPIO2A6_SHIFT |
-			     GPIO2A5_UART2_SOUT << GPIO2A5_SHIFT);
+			     RK3368_GPIO2A6_MASK | RK3368_GPIO2A5_MASK,
+			     RK3368_GPIO2A6_UART2_SIN |
+			     RK3368_GPIO2A5_UART2_SOUT);
  		break;
  	case PERIPH_ID_UART0:
  		break;
@@ -42,12 +42,11 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
  		break;
  	case PERIPH_ID_UART4:
  		rk_clrsetreg(&pmugrf->gpio0d_iomux,
-			     GPIO0D0_MASK | GPIO0D1_MASK |
-			     GPIO0D2_MASK | GPIO0D3_MASK,
-			     GPIO0D0_GPIO << GPIO0D0_SHIFT |
-			     GPIO0D1_GPIO << GPIO0D1_SHIFT |
-			     GPIO0D2_UART4_SOUT << GPIO0D2_SHIFT |
-			     GPIO0D3_UART4_SIN << GPIO0D3_SHIFT);
+			     RK3368_GPIO0D0_MASK | RK3368_GPIO0D1_MASK |
+			     RK3368_GPIO0D2_MASK | RK3368_GPIO0D3_MASK,
+			     RK3368_GPIO0D0_GPIO | RK3368_GPIO0D1_GPIO |
+			     RK3368_GPIO0D2_UART4_SOUT |
+			     RK3368_GPIO0D3_UART4_SIN);
  		break;
  	default:
  		debug("uart id = %d iomux error!\n", uart_id);
#34 lore raw

PATCH 30/52 rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_

Quoted 12 lines · Andy Yan

Hi Philipp:

Quoted 5 lines · Philipp Tomsich

The RK3368 GRF header was still defines with a shifted-mask but with non-shifted function selectors for the IOMUX defines. As the RK3368 support is still fresh enough to allow a quick rename, we do this now before having more code use this.

Quoted 7 lines
Quoted 4 lines

As some of the downstream drivers (e.g. the Designware GMAC wrapper) may need to include the grf-header of multiple devices, we rename the various defines for the RK3368 by prefixing them with the device name. This avoids future trouble during driver integration.

Is that really necessary to add such a prefix for all the register definition, just to fit the GMAC dirver?
Maybe the gmac driver can define the platform specific macro in its own code like dwmac-rk in the kernel. Then we can keep the register header file a little tidy.

The problem is not the GMAC driver (although it was the motivation for doing this change), but rather how easy it is to pick up the wrong grf-file and refer to the wrong definitions/values… the conflicts are not through the GMAC-specifc defines but rather through things like the IOMUX masks or (before I moved this to the DDR-driver) things like the defines to enable DRAM in GRF.

Until we find a way to consistently structure things in such a way that
(a) common constructs can be shared (e.g. the masks in the IOMUX)
(b) specific definitions (e.g. the pin-out for a specific device) is not visible outside of its driver
I prefer the names to explicitly refer to each device.

That said, the longer-term plan (especially with a larger number of devices being supported) needs to include a consistent rework of how (and where) we manage all these definitions from the grf-header files.

Quoted 694 lines
Quoted 692 lines

---

 arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 617 +++++++++++++-----------
 drivers/pinctrl/rockchip/pinctrl_rk3368.c       |  17 +-
 2 files changed, 334 insertions(+), 300 deletions(-)
arch/arm/include/asm/arch-rockchip/grf_rk3368.h +326 -290
index a438f5d..a97dc1e 100644
@@ -1,4 +1,6 @@
-/* (C) Copyright 2016 Rockchip Electronics Co., Ltd
+/*
+ * (C) Copyright 2016 Rockchip Electronics Co., Ltd
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
  *
  * SPDX-License-Identifier:     GPL-2.0+
  */
@@ -100,315 +102,318 @@ check_member(rk3368_pmu_grf, os_reg[0], 0x200);
   /*GRF_GPIO0C_IOMUX*/
 enum {
-	GPIO0C7_SHIFT		= 14,
-	GPIO0C7_MASK		= 3 << GPIO0C7_SHIFT,
-	GPIO0C7_GPIO		= 0,
-	GPIO0C7_LCDC_D19,
-	GPIO0C7_TRACE_D9,
-	GPIO0C7_UART1_RTSN,
-
-	GPIO0C6_SHIFT           = 12,
-	GPIO0C6_MASK            = 3 << GPIO0C6_SHIFT,
-	GPIO0C6_GPIO            = 0,
-	GPIO0C6_LCDC_D18,
-	GPIO0C6_TRACE_D8,
-	GPIO0C6_UART1_CTSN,
-
-	GPIO0C5_SHIFT           = 10,
-	GPIO0C5_MASK            = 3 << GPIO0C5_SHIFT,
-	GPIO0C5_GPIO            = 0,
-	GPIO0C5_LCDC_D17,
-	GPIO0C5_TRACE_D7,
-	GPIO0C5_UART1_SOUT,
-
-	GPIO0C4_SHIFT           = 8,
-	GPIO0C4_MASK            = 3 << GPIO0C4_SHIFT,
-	GPIO0C4_GPIO            = 0,
-	GPIO0C4_LCDC_D16,
-	GPIO0C4_TRACE_D6,
-	GPIO0C4_UART1_SIN,
-
-	GPIO0C3_SHIFT           = 6,
-	GPIO0C3_MASK            = 3 << GPIO0C3_SHIFT,
-	GPIO0C3_GPIO            = 0,
-	GPIO0C3_LCDC_D15,
-	GPIO0C3_TRACE_D5,
-	GPIO0C3_MCU_JTAG_TDO,
-
-	GPIO0C2_SHIFT           = 4,
-	GPIO0C2_MASK            = 3 << GPIO0C2_SHIFT,
-	GPIO0C2_GPIO            = 0,
-	GPIO0C2_LCDC_D14,
-	GPIO0C2_TRACE_D4,
-	GPIO0C2_MCU_JTAG_TDI,
-
-	GPIO0C1_SHIFT           = 2,
-	GPIO0C1_MASK            = 3 << GPIO0C1_SHIFT,
-	GPIO0C1_GPIO            = 0,
-	GPIO0C1_LCDC_D13,
-	GPIO0C1_TRACE_D3,
-	GPIO0C1_MCU_JTAG_TRTSN,
-
-	GPIO0C0_SHIFT           = 0,
-	GPIO0C0_MASK            = 3 << GPIO0C0_SHIFT,
-	GPIO0C0_GPIO            = 0,
-	GPIO0C0_LCDC_D12,
-	GPIO0C0_TRACE_D2,
-	GPIO0C0_MCU_JTAG_TDO,
+	RK3368_GPIO0C7_MASK	       = GENMASK(15, 14),
+	RK3368_GPIO0C7_GPIO	       = 0,
+	RK3368_GPIO0C7_LCDC_D19        = (1 << 14),
+	RK3368_GPIO0C7_TRACE_D9        = (2 << 14),
+	RK3368_GPIO0C7_UART1_RTSN      = (3 << 14),
+
+	RK3368_GPIO0C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0C6_GPIO            = 0,
+	RK3368_GPIO0C6_LCDC_D18        = (1 << 12),
+	RK3368_GPIO0C6_TRACE_D8        = (2 << 12),
+	RK3368_GPIO0C6_UART1_CTSN      = (3 << 12),
+
+	RK3368_GPIO0C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0C5_GPIO            = 0,
+	RK3368_GPIO0C5_LCDC_D17        = (1 << 10),
+	RK3368_GPIO0C5_TRACE_D7        = (2 << 10),
+	RK3368_GPIO0C5_UART1_SOUT      = (3 << 10),
+
+	RK3368_GPIO0C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0C4_GPIO            = 0,
+	RK3368_GPIO0C4_LCDC_D16        = (1 << 8),
+	RK3368_GPIO0C4_TRACE_D6        = (2 << 8),
+	RK3368_GPIO0C4_UART1_SIN       = (3 << 8),
+
+	RK3368_GPIO0C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0C3_GPIO            = 0,
+	RK3368_GPIO0C3_LCDC_D15        = (1 << 6),
+	RK3368_GPIO0C3_TRACE_D5        = (2 << 6),
+	RK3368_GPIO0C3_MCU_JTAG_TDO    = (3 << 6),
+
+	RK3368_GPIO0C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0C2_GPIO            = 0,
+	RK3368_GPIO0C2_LCDC_D14        = (1 << 4),
+	RK3368_GPIO0C2_TRACE_D4        = (2 << 4),
+	RK3368_GPIO0C2_MCU_JTAG_TDI    = (3 << 4),
+
+	RK3368_GPIO0C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0C1_GPIO            = 0,
+	RK3368_GPIO0C1_LCDC_D13        = (1 << 2),
+	RK3368_GPIO0C1_TRACE_D3        = (2 << 2),
+	RK3368_GPIO0C1_MCU_JTAG_TRTSN  = (3 << 2),
+
+	RK3368_GPIO0C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0C0_GPIO            = 0,
+	RK3368_GPIO0C0_LCDC_D12        = (1 << 0),
+	RK3368_GPIO0C0_TRACE_D2        = (2 << 0),
+	RK3368_GPIO0C0_MCU_JTAG_TDO    = (3 << 0),
 };
   /*GRF_GPIO0D_IOMUX*/
 enum {
-	GPIO0D7_SHIFT           = 14,
-	GPIO0D7_MASK            = 3 << GPIO0D7_SHIFT,
-	GPIO0D7_GPIO            = 0,
-	GPIO0D7_LCDC_DCLK,
-	GPIO0D7_TRACE_CTL,
-	GPIO0D7_PMU_DEBUG5,
-
-	GPIO0D6_SHIFT           = 12,
-	GPIO0D6_MASK            = 3 << GPIO0D6_SHIFT,
-	GPIO0D6_GPIO            = 0,
-	GPIO0D6_LCDC_DEN,
-	GPIO0D6_TRACE_CLK,
-	GPIO0D6_PMU_DEBUG4,
-
-	GPIO0D5_SHIFT           = 10,
-	GPIO0D5_MASK            = 3 << GPIO0D5_SHIFT,
-	GPIO0D5_GPIO            = 0,
-	GPIO0D5_LCDC_VSYNC,
-	GPIO0D5_TRACE_D15,
-	GPIO0D5_PMU_DEBUG3,
-
-	GPIO0D4_SHIFT           = 8,
-	GPIO0D4_MASK            = 3 << GPIO0D4_SHIFT,
-	GPIO0D4_GPIO            = 0,
-	GPIO0D4_LCDC_HSYNC,
-	GPIO0D4_TRACE_D14,
-	GPIO0D4_PMU_DEBUG2,
-
-	GPIO0D3_SHIFT           = 6,
-	GPIO0D3_MASK            = 3 << GPIO0D3_SHIFT,
-	GPIO0D3_GPIO            = 0,
-	GPIO0D3_LCDC_D23,
-	GPIO0D3_TRACE_D13,
-	GPIO0D3_UART4_SIN,
-
-	GPIO0D2_SHIFT           = 4,
-	GPIO0D2_MASK            = 3 << GPIO0D2_SHIFT,
-	GPIO0D2_GPIO            = 0,
-	GPIO0D2_LCDC_D22,
-	GPIO0D2_TRACE_D12,
-	GPIO0D2_UART4_SOUT,
-
-	GPIO0D1_SHIFT           = 2,
-	GPIO0D1_MASK            = 3 << GPIO0D1_SHIFT,
-	GPIO0D1_GPIO            = 0,
-	GPIO0D1_LCDC_D21,
-	GPIO0D1_TRACE_D11,
-	GPIO0D1_UART4_RTSN,
-
-	GPIO0D0_SHIFT           = 0,
-	GPIO0D0_MASK            = 3 << GPIO0D0_SHIFT,
-	GPIO0D0_GPIO            = 0,
-	GPIO0D0_LCDC_D20,
-	GPIO0D0_TRACE_D10,
-	GPIO0D0_UART4_CTSN,
+	RK3368_GPIO0D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO0D7_GPIO            = 0,
+	RK3368_GPIO0D7_LCDC_DCLK       = (1 << 14),
+	RK3368_GPIO0D7_TRACE_CTL       = (2 << 14),
+	RK3368_GPIO0D7_PMU_DEBUG5      = (3 << 14),
+
+	RK3368_GPIO0D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0D6_GPIO            = 0,
+	RK3368_GPIO0D6_LCDC_DEN        = (1 << 12),
+	RK3368_GPIO0D6_TRACE_CLK       = (2 << 12),
+	RK3368_GPIO0D6_PMU_DEBUG4      = (3 << 12),
+
+	RK3368_GPIO0D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0D5_GPIO            = 0,
+	GPIO0D5_LCDC_VSYNC             = (1 << 10),
+	RK3368_GPIO0D5_TRACE_D15       = (2 << 10),
+	RK3368_GPIO0D5_PMU_DEBUG3      = (3 << 10),
+
+	RK3368_GPIO0D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0D4_GPIO            = 0,
+	RK3368_GPIO0D4_LCDC_HSYNC      = (1 << 8),
+	RK3368_GPIO0D4_TRACE_D14       = (2 << 8),
+	RK3368_GPIO0D4_PMU_DEBUG2      = (3 << 8),
+
+	RK3368_GPIO0D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0D3_GPIO            = 0,
+	RK3368_GPIO0D3_LCDC_D23        = (1 << 6),
+	RK3368_GPIO0D3_TRACE_D13       = (2 << 6),
+	RK3368_GPIO0D3_UART4_SIN       = (3 << 6),
+
+	RK3368_GPIO0D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0D2_GPIO            = 0,
+	RK3368_GPIO0D2_LCDC_D22        = (1 << 4),
+	RK3368_GPIO0D2_TRACE_D12       = (2 << 4),
+	RK3368_GPIO0D2_UART4_SOUT      = (3 << 4),
+
+	RK3368_GPIO0D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0D1_GPIO            = 0,
+	RK3368_GPIO0D1_LCDC_D21        = (1 << 2),
+	RK3368_GPIO0D1_TRACE_D11       = (2 << 2),
+	RK3368_GPIO0D1_UART4_RTSN      = (3 << 2),
+
+	RK3368_GPIO0D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0D0_GPIO            = 0,
+	RK3368_GPIO0D0_LCDC_D20        = (1 << 0),
+	RK3368_GPIO0D0_TRACE_D10       = (2 << 0),
+	RK3368_GPIO0D0_UART4_CTSN      = (3 << 0),
 };
   /*GRF_GPIO2A_IOMUX*/
 enum {
-	GPIO2A7_SHIFT           = 14,
-	GPIO2A7_MASK            = 3 << GPIO2A7_SHIFT,
-	GPIO2A7_GPIO            = 0,
-	GPIO2A7_SDMMC0_D2,
-	GPIO2A7_JTAG_TCK,
-
-	GPIO2A6_SHIFT           = 12,
-	GPIO2A6_MASK            = 3 << GPIO2A6_SHIFT,
-	GPIO2A6_GPIO            = 0,
-	GPIO2A6_SDMMC0_D1,
-	GPIO2A6_UART2_SIN,
-
-	GPIO2A5_SHIFT           = 10,
-	GPIO2A5_MASK            = 3 << GPIO2A5_SHIFT,
-	GPIO2A5_GPIO            = 0,
-	GPIO2A5_SDMMC0_D0,
-	GPIO2A5_UART2_SOUT,
-
-	GPIO2A4_SHIFT           = 8,
-	GPIO2A4_MASK            = 3 << GPIO2A4_SHIFT,
-	GPIO2A4_GPIO            = 0,
-	GPIO2A4_FLASH_DQS,
-	GPIO2A4_EMMC_CLKO,
-
-	GPIO2A3_SHIFT           = 6,
-	GPIO2A3_MASK            = 3 << GPIO2A3_SHIFT,
-	GPIO2A3_GPIO            = 0,
-	GPIO2A3_FLASH_CSN3,
-	GPIO2A3_EMMC_RSTNO,
-
-	GPIO2A2_SHIFT           = 4,
-	GPIO2A2_MASK            = 3 << GPIO2A2_SHIFT,
-	GPIO2A2_GPIO           = 0,
-	GPIO2A2_FLASH_CSN2,
-
-	GPIO2A1_SHIFT           = 2,
-	GPIO2A1_MASK            = 3 << GPIO2A1_SHIFT,
-	GPIO2A1_GPIO            = 0,
-	GPIO2A1_FLASH_CSN1,
-
-	GPIO2A0_SHIFT           = 0,
-	GPIO2A0_MASK            = 3 << GPIO2A0_SHIFT,
-	GPIO2A0_GPIO            = 0,
-	GPIO2A0_FLASH_CSN0,
+	RK3368_GPIO2A7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2A7_GPIO            = 0,
+	RK3368_GPIO2A7_SDMMC0_D2       = (1 << 14),
+	RK3368_GPIO2A7_JTAG_TCK        = (2 << 14),
+
+	RK3368_GPIO2A6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2A6_GPIO            = 0,
+	RK3368_GPIO2A6_SDMMC0_D1       = (1 << 12),
+	RK3368_GPIO2A6_UART2_SIN       = (2 << 12),
+
+	RK3368_GPIO2A5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2A5_GPIO            = 0,
+	RK3368_GPIO2A5_SDMMC0_D0       = (1 << 10),
+	RK3368_GPIO2A5_UART2_SOUT      = (2 << 10),
+
+	RK3368_GPIO2A4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2A4_RK3368_GPIO     = 0,
+	RK3368_GPIO2A4_FLASH_DQS       = (1 << 8),
+	RK3368_GPIO2A4_EMMC_CLKOUT     = (2 << 8),
+
+	RK3368_GPIO2A3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2A3_GPIO            = 0,
+	RK3368_GPIO2A3_FLASH_CSN3      = (1 << 6),
+	RK3368_GPIO2A3_EMMC_RSTNOUT    = (2 << 6),
+
+	RK3368_GPIO2A2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2A2_GPIO            = 0,
+	RK3368_GPIO2A2_FLASH_CSN2      = (1 << 4),
+
+	RK3368_GPIO2A1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2A1_GPIO            = 0,
+	RK3368_GPIO2A1_FLASH_CSN1      = (1 << 2),
+
+	RK3368_GPIO2A0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2A0_GPIO            = 0,
+	RK3368_GPIO2A0_FLASH_CSN0      = (1 << 0),
 };
 -/*GRF_GPIO2D_IOMUX*/
+/*GRF_RK3368_GPIO2D_IOMUX*/
 enum {
-	GPIO2D7_SHIFT           = 14,
-	GPIO2D7_MASK            = 3 << GPIO2D7_SHIFT,
-	GPIO2D7_GPIO            = 0,
-	GPIO2D7_SDIO0_D3,
-
-	GPIO2D6_SHIFT           = 12,
-	GPIO2D6_MASK            = 3 << GPIO2D6_SHIFT,
-	GPIO2D6_GPIO            = 0,
-	GPIO2D6_SDIO0_D2,
-
-	GPIO2D5_SHIFT           = 10,
-	GPIO2D5_MASK            = 3 << GPIO2D5_SHIFT,
-	GPIO2D5_GPIO            = 0,
-	GPIO2D5_SDIO0_D1,
-
-	GPIO2D4_SHIFT           = 8,
-	GPIO2D4_MASK            = 3 << GPIO2D4_SHIFT,
-	GPIO2D4_GPIO            = 0,
-	GPIO2D4_SDIO0_D0,
-
-	GPIO2D3_SHIFT           = 6,
-	GPIO2D3_MASK            = 3 << GPIO2D3_SHIFT,
-	GPIO2D3_GPIO            = 0,
-	GPIO2D3_UART0_RTS0,
-
-	GPIO2D2_SHIFT           = 4,
-	GPIO2D2_MASK            = 3 << GPIO2D2_SHIFT,
-	GPIO2D2_GPIO            = 0,
-	GPIO2D2_UART0_CTS0,
-
-	GPIO2D1_SHIFT           = 2,
-	GPIO2D1_MASK            = 3 << GPIO2D1_SHIFT,
-	GPIO2D1_GPIO            = 0,
-	GPIO2D1_UART0_SOUT,
-
-	GPIO2D0_SHIFT           = 0,
-	GPIO2D0_MASK            = 3 << GPIO2D0_SHIFT,
-	GPIO2D0_GPIO            = 0,
-	GPIO2D0_UART0_SIN,
+	RK3368_GPIO2D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2D7_GPIO            = 0,
+	RK3368_GPIO2D7_SDIO0_D3        = (1 << 14),
+
+	RK3368_GPIO2D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2D6_GPIO            = 0,
+	RK3368_GPIO2D6_SDIO0_D2        = (1 << 12),
+
+	RK3368_GPIO2D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2D5_GPIO            = 0,
+	RK3368_GPIO2D5_SDIO0_D1        = (1 << 10),
+
+	RK3368_GPIO2D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2D4_GPIO            = 0,
+	RK3368_GPIO2D4_SDIO0_D0        = (1 << 8),
+
+	RK3368_GPIO2D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2D3_GPIO            = 0,
+	RK3368_GPIO2D3_UART0_RTS0      = (1 << 6),
+
+	RK3368_GPIO2D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2D2_GPIO            = 0,
+	RK3368_GPIO2D2_UART0_CTS0      = (1 << 4),
+
+	RK3368_GPIO2D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2D1_GPIO            = 0,
+	RK3368_GPIO2D1_UART0_SOUT      = (1 << 2),
+
+	RK3368_GPIO2D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2D0_GPIO            = 0,
+	RK3368_GPIO2D0_UART0_SIN       = (1 << 0),
+};
+
+/* GRF_GPIO1C_IOMUX */
+enum {
+	RK3368_GPIO1C7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO1C7_GPIO            = 0,
+	RK3368_GPIO1C7_EMMC_DATA5      = (2 << 14),
+
+	RK3368_GPIO1C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO1C6_GPIO            = 0,
+	RK3368_GPIO1C6_EMMC_DATA4      = (2 << 12),
+
+	RK3368_GPIO1C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO1C5_GPIO            = 0,
+	RK3368_GPIO1C5_EMMC_DATA3      = (2 << 10),
+
+	RK3368_GPIO1C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO1C4_GPIO            = 0,
+	RK3368_GPIO1C4_EMMC_DATA2      = (2 << 8),
+
+	RK3368_GPIO1C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1C3_GPIO            = 0,
+	RK3368_GPIO1C3_EMMC_DATA1      = (2 << 6),
+
+	RK3368_GPIO1C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1C2_GPIO            = 0,
+	RK3368_GPIO1C2_EMMC_DATA0      = (2 << 4),
+};
+
+/* GRF_GPIO1D_IOMUX*/
+enum {
+	RK3368_GPIO1D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1D3_GPIO            = 0,
+	RK3368_GPIO1D3_EMMC_PWREN      = (2 << 6),
+
+	RK3368_GPIO1D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1D2_GPIO            = 0,
+	RK3368_GPIO1D2_EMMC_CMD        = (2 << 4),
+
+	RK3368_GPIO1D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO1D1_GPIO            = 0,
+	RK3368_GPIO1D1_EMMC_DATA7      = (2 << 2),
+
+	RK3368_GPIO1D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO1D0_GPIO            = 0,
+	RK3368_GPIO1D0_EMMC_DATA6      = (2 << 0),
+};
+
+
+/*GRF_GPIO3B_IOMUX*/
+enum {
+	RK3368_GPIO3B7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO3B7_GPIO            = 0,
+	RK3368_GPIO3B7_MAC_RXD0        = (1 << 14),
+
+	RK3368_GPIO3B6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3B6_GPIO            = 0,
+	RK3368_GPIO3B6_MAC_TXD3        = (1 << 12),
+
+	RK3368_GPIO3B5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3B5_GPIO            = 0,
+	RK3368_GPIO3B5_MAC_TXEN        = (1 << 10),
+
+	RK3368_GPIO3B4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3B4_GPIO            = 0,
+	RK3368_GPIO3B4_MAC_COL         = (1 << 8),
+
+	RK3368_GPIO3B3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3B3_GPIO            = 0,
+	RK3368_GPIO3B3_MAC_CRS         = (1 << 6),
+
+	RK3368_GPIO3B2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3B2_GPIO            = 0,
+	RK3368_GPIO3B2_MAC_TXD2        = (1 << 4),
+
+	RK3368_GPIO3B1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3B1_GPIO            = 0,
+	RK3368_GPIO3B1_MAC_TXD1        = (1 << 2),
+
+	RK3368_GPIO3B0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3B0_GPIO            = 0,
+	RK3368_GPIO3B0_MAC_TXD0        = (1 << 0),
+	RK3368_GPIO3B0_PWM0            = (2 << 0),
 };
   /*GRF_GPIO3C_IOMUX*/
 enum {
-	GPIO3C7_SHIFT           = 14,
-	GPIO3C7_MASK            = 3 << GPIO3C7_SHIFT,
-	GPIO3C7_GPIO            = 0,
-	GPIO3C7_EDPHDMI_CECINOUT,
-	GPIO3C7_ISP_FLASHTRIGIN,
-
-	GPIO3C6_SHIFT           = 12,
-	GPIO3C6_MASK            = 3 << GPIO3C6_SHIFT,
-	GPIO3C6_GPIO            = 0,
-	GPIO3C6_MAC_CLK,
-	GPIO3C6_ISP_SHUTTERTRIG,
-
-	GPIO3C5_SHIFT           = 10,
-	GPIO3C5_MASK            = 3 << GPIO3C5_SHIFT,
-	GPIO3C5_GPIO            = 0,
-	GPIO3C5_MAC_RXER,
-	GPIO3C5_ISP_PRELIGHTTRIG,
-
-	GPIO3C4_SHIFT           = 8,
-	GPIO3C4_MASK            = 3 << GPIO3C4_SHIFT,
-	GPIO3C4_GPIO            = 0,
-	GPIO3C4_MAC_RXDV,
-	GPIO3C4_ISP_FLASHTRIGOUT,
-
-	GPIO3C3_SHIFT           = 6,
-	GPIO3C3_MASK            = 3 << GPIO3C3_SHIFT,
-	GPIO3C3_GPIO            = 0,
-	GPIO3C3_MAC_RXDV,
-	GPIO3C3_EMMC_RSTNO,
-
-	GPIO3C2_SHIFT           = 4,
-	GPIO3C2_MASK            = 3 << GPIO3C2_SHIFT,
-	GPIO3C2_MAC_MDC            = 0,
-	GPIO3C2_ISP_SHUTTEREN,
-
-	GPIO3C1_SHIFT           = 2,
-	GPIO3C1_MASK            = 3 << GPIO3C1_SHIFT,
-	GPIO3C1_GPIO            = 0,
-	GPIO3C1_MAC_RXD2,
-	GPIO3C1_UART3_RTSN,
-
-	GPIO3C0_SHIFT           = 0,
-	GPIO3C0_MASK            = 3 << GPIO3C0_SHIFT,
-	GPIO3C0_GPIO            = 0,
-	GPIO3C0_MAC_RXD1,
-	GPIO3C0_UART3_CTSN,
-	GPIO3C0_GPS_RFCLK,
+	RK3368_GPIO3C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3C6_GPIO            = 0,
+	RK3368_GPIO3C6_MAC_CLK         = (1 << 12),
+
+	RK3368_GPIO3C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3C5_GPIO            = 0,
+	RK3368_GPIO3C5_MAC_RXEN        = (1 << 10),
+
+	RK3368_GPIO3C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3C4_GPIO            = 0,
+	RK3368_GPIO3C4_MAC_RXDV        = (1 << 8),
+
+	RK3368_GPIO3C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3C3_GPIO            = 0,
+	RK3368_GPIO3C3_MAC_MDC         = (1 << 6),
+
+	RK3368_GPIO3C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3C2_GPIO            = 0,
+	RK3368_GPIO3C2_MAC_RXD3        = (1 << 4),
+
+	RK3368_GPIO3C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3C1_GPIO            = 0,
+	RK3368_GPIO3C1_MAC_RXD2        = (1 << 2),
+
+	RK3368_GPIO3C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3C0_GPIO            = 0,
+	RK3368_GPIO3C0_MAC_RXD1        = (1 << 0),
 };
   /*GRF_GPIO3D_IOMUX*/
 enum {
-	GPIO3D7_SHIFT           = 14,
-	GPIO3D7_MASK            = 3 << GPIO3D7_SHIFT,
-	GPIO3D7_GPIO            = 0,
-	GPIO3D7_SC_VCC18V,
-	GPIO3D7_I2C2_SDA,
-	GPIO3D7_GPUJTAG_TCK,
-
-	GPIO3D6_SHIFT           = 12,
-	GPIO3D6_MASK            = 3 << GPIO3D6_SHIFT,
-	GPIO3D6_GPIO            = 0,
-	GPIO3D6_IR_TX,
-	GPIO3D6_UART3_SOUT,
-	GPIO3D6_PWM3,
-
-	GPIO3D5_SHIFT           = 10,
-	GPIO3D5_MASK            = 3 << GPIO3D5_SHIFT,
-	GPIO3D5_GPIO            = 0,
-	GPIO3D5_IR_RX,
-	GPIO3D5_UART3_SIN,
-
-	GPIO3D4_SHIFT           = 8,
-	GPIO3D4_MASK            = 3 << GPIO3D4_SHIFT,
-	GPIO3D4_GPIO            = 0,
-	GPIO3D4_MAC_TXCLKOUT,
-	GPIO3D4_SPI1_CSN1,
-
-	GPIO3D3_SHIFT           = 6,
-	GPIO3D3_MASK            = 3 << GPIO3D3_SHIFT,
-	GPIO3D3_GPIO            = 0,
-	GPIO3D3_HDMII2C_SCL,
-	GPIO3D3_I2C5_SCL,
-
-	GPIO3D2_SHIFT           = 4,
-	GPIO3D2_MASK            = 3 << GPIO3D2_SHIFT,
-	GPIO3D2_GPIO            = 0,
-	GPIO3D2_HDMII2C_SDA,
-	GPIO3D2_I2C5_SDA,
-
-	GPIO3D1_SHIFT           = 2,
-	GPIO3D1_MASK            = 3 << GPIO3D1_SHIFT,
-	GPIO3D1_GPIO            = 0,
-	GPIO3D1_MAC_RXCLKIN,
-	GPIO3D1_I2C4_SCL,
-
-	GPIO3D0_SHIFT           = 0,
-	GPIO3D0_MASK            = 3 << GPIO3D0_SHIFT,
-	GPIO3D0_GPIO            = 0,
-	GPIO3D0_MAC_MDIO,
-	GPIO3D0_I2C4_SDA,
+	RK3368_GPIO3D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3D4_GPIO            = 0,
+	RK3368_GPIO3D4_MAC_TXCLK       = (1 << 8),
+
+	RK3368_GPIO3D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3D1_GPIO            = 0,
+	RK3368_GPIO3D1_MAC_RXCLK       = (1 << 2),
+
+	RK3368_GPIO3D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3D0_GPIO            = 0,
+	RK3368_GPIO3D0_MAC_MDIO        = (1 << 0),
+};
+
+/* GRF_SOC_CON0 */
+enum {
+	NOC_RSP_ERR_STALL = BIT(9),
+	MOBILE_DDR_SEL = BIT(4),
+	DDR0_16BIT_EN = BIT(3),
+	MSCH0_MAINDDR3_DDR3 = BIT(2),
+	MSCH0_MAINPARTIALPOP = BIT(1),
+	UPCTL_C_ACTIVE = BIT(0),
 };
   /*GRF_SOC_CON11/12/13*/
@@ -440,4 +445,34 @@ enum {
 	MCU_CODE_BASE_BIT31_BIT28_SHIFT		= 0,
 	MCU_CODE_BASE_BIT31_BIT28_MASK		= GENMASK(3, 0),
 };
+
+/*GRF_SOC_CON15*/
+enum {
+	RK3368_GMAC_PHY_INTF_SEL_RGMII = 1 << 9,
+	RK3368_GMAC_PHY_INTF_SEL_MASK = GENMASK(11, 9),
+	RK3368_RMII_MODE_MASK  = BIT(6),
+	RK3368_RMII_MODE       = BIT(6),
+	RK3368_GMAC_CLK_SEL_2_5M = 2 << 4,
+	RK3368_GMAC_CLK_SEL_25M = 3 << 4,
+	RK3368_GMAC_CLK_SEL_125M = 0 << 4,
+	RK3368_GMAC_CLK_SEL_MASK = GENMASK(5, 4),
+};
+
+/* GRF_SOC_CON16 */
+enum {
+	RK3368_RXCLK_DLY_ENA_GMAC_MASK = BIT(15),
+	RK3368_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(15),
+
+	RK3368_TXCLK_DLY_ENA_GMAC_MASK = BIT(7),
+	RK3368_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(7),
+
+	RK3368_CLK_RX_DL_CFG_GMAC_SHIFT = 8,
+	RK3368_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(14, 8),
+
+	RK3368_CLK_TX_DL_CFG_GMAC_SHIFT = 0,
+	RK3368_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
+};
+
 #endif
drivers/pinctrl/rockchip/pinctrl_rk3368.c +8 -9
index bdf0758..b77c5ab 100644
@@ -30,9 +30,9 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
 	switch (uart_id) {
 	case PERIPH_ID_UART2:
 		rk_clrsetreg(&grf->gpio2a_iomux,
-			     GPIO2A6_MASK | GPIO2A5_MASK,
-			     GPIO2A6_UART2_SIN << GPIO2A6_SHIFT |
-			     GPIO2A5_UART2_SOUT << GPIO2A5_SHIFT);
+			     RK3368_GPIO2A6_MASK | RK3368_GPIO2A5_MASK,
+			     RK3368_GPIO2A6_UART2_SIN |
+			     RK3368_GPIO2A5_UART2_SOUT);
 		break;
 	case PERIPH_ID_UART0:
 		break;
@@ -42,12 +42,11 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
 		break;
 	case PERIPH_ID_UART4:
 		rk_clrsetreg(&pmugrf->gpio0d_iomux,
-			     GPIO0D0_MASK | GPIO0D1_MASK |
-			     GPIO0D2_MASK | GPIO0D3_MASK,
-			     GPIO0D0_GPIO << GPIO0D0_SHIFT |
-			     GPIO0D1_GPIO << GPIO0D1_SHIFT |
-			     GPIO0D2_UART4_SOUT << GPIO0D2_SHIFT |
-			     GPIO0D3_UART4_SIN << GPIO0D3_SHIFT);
+			     RK3368_GPIO0D0_MASK | RK3368_GPIO0D1_MASK |
+			     RK3368_GPIO0D2_MASK | RK3368_GPIO0D3_MASK,
+			     RK3368_GPIO0D0_GPIO | RK3368_GPIO0D1_GPIO |
+			     RK3368_GPIO0D2_UART4_SOUT |
+			     RK3368_GPIO0D3_UART4_SIN);
 		break;
 	default:
 		debug("uart id = %d iomux error!\n", uart_id);
#35 lore raw

PATCH 30/52 rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_

Hi Philipp:

Quoted 23 lines · Dr. Philipp Tomsich
Quoted 11 lines · Andy Yan

Hi Philipp:

Quoted 5 lines · Philipp Tomsich

The RK3368 GRF header was still defines with a shifted-mask but with non-shifted function selectors for the IOMUX defines. As the RK3368 support is still fresh enough to allow a quick rename, we do this now before having more code use this.

Quoted 6 lines
Quoted 4 lines

As some of the downstream drivers (e.g. the Designware GMAC wrapper) may need to include the grf-header of multiple devices, we rename the various defines for the RK3368 by prefixing them with the device name. This avoids future trouble during driver integration.

Is that really necessary to add such a prefix for all the register definition, just to fit the GMAC dirver?
Maybe the gmac driver can define the platform specific macro in its own code like dwmac-rk in the kernel. Then we can keep the register header file a little tidy.

The problem is not the GMAC driver (although it was the motivation for doing this change), but rather how easy it is to pick up the wrong grf-file and refer to the wrong definitions/values… the conflicts are not through the GMAC-specifc defines but rather through things like the IOMUX masks or (before I moved this to the DDR-driver) things like the defines to enable DRAM in GRF.

Quoted 8 lines

Until we find a way to consistently structure things in such a way that
(a) common constructs can be shared (e.g. the masks in the IOMUX)
(b) specific definitions (e.g. the pin-out for a specific device) is not visible outside of its driver
I prefer the names to explicitly refer to each device.

That said, the longer-term plan (especially with a larger number of devices being supported) needs to include a consistent rework of how (and where) we manage all these definitions from the grf-header files.

It's true that many devices use GRF, we also face this condition in the kernel land.And all the drivers in kernel handle this device specific definition in the driver itself(by of_device_id->data or MACRO). And there is also no need to use the grf constructs, the common syscon api will provide you the grf base address. I think this keeps things simple, we don't need to rely on too much of the grf or cru header, maybe some day we can remove the header file, just as clean as the kernel. On the other hand, add such a prefix of rk3368 breaks the consistency with other rockchip devices.

Quoted 696 lines
Quoted 693 lines
Quoted 692 lines

---

  arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 617 +++++++++++++-----------
  drivers/pinctrl/rockchip/pinctrl_rk3368.c       |  17 +-
  2 files changed, 334 insertions(+), 300 deletions(-)
arch/arm/include/asm/arch-rockchip/grf_rk3368.h +326 -290
index a438f5d..a97dc1e 100644
@@ -1,4 +1,6 @@
-/* (C) Copyright 2016 Rockchip Electronics Co., Ltd
+/*
+ * (C) Copyright 2016 Rockchip Electronics Co., Ltd
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
   *
   * SPDX-License-Identifier:     GPL-2.0+
   */
@@ -100,315 +102,318 @@ check_member(rk3368_pmu_grf, os_reg[0], 0x200);
    /*GRF_GPIO0C_IOMUX*/
  enum {
-	GPIO0C7_SHIFT		= 14,
-	GPIO0C7_MASK		= 3 << GPIO0C7_SHIFT,
-	GPIO0C7_GPIO		= 0,
-	GPIO0C7_LCDC_D19,
-	GPIO0C7_TRACE_D9,
-	GPIO0C7_UART1_RTSN,
-
-	GPIO0C6_SHIFT           = 12,
-	GPIO0C6_MASK            = 3 << GPIO0C6_SHIFT,
-	GPIO0C6_GPIO            = 0,
-	GPIO0C6_LCDC_D18,
-	GPIO0C6_TRACE_D8,
-	GPIO0C6_UART1_CTSN,
-
-	GPIO0C5_SHIFT           = 10,
-	GPIO0C5_MASK            = 3 << GPIO0C5_SHIFT,
-	GPIO0C5_GPIO            = 0,
-	GPIO0C5_LCDC_D17,
-	GPIO0C5_TRACE_D7,
-	GPIO0C5_UART1_SOUT,
-
-	GPIO0C4_SHIFT           = 8,
-	GPIO0C4_MASK            = 3 << GPIO0C4_SHIFT,
-	GPIO0C4_GPIO            = 0,
-	GPIO0C4_LCDC_D16,
-	GPIO0C4_TRACE_D6,
-	GPIO0C4_UART1_SIN,
-
-	GPIO0C3_SHIFT           = 6,
-	GPIO0C3_MASK            = 3 << GPIO0C3_SHIFT,
-	GPIO0C3_GPIO            = 0,
-	GPIO0C3_LCDC_D15,
-	GPIO0C3_TRACE_D5,
-	GPIO0C3_MCU_JTAG_TDO,
-
-	GPIO0C2_SHIFT           = 4,
-	GPIO0C2_MASK            = 3 << GPIO0C2_SHIFT,
-	GPIO0C2_GPIO            = 0,
-	GPIO0C2_LCDC_D14,
-	GPIO0C2_TRACE_D4,
-	GPIO0C2_MCU_JTAG_TDI,
-
-	GPIO0C1_SHIFT           = 2,
-	GPIO0C1_MASK            = 3 << GPIO0C1_SHIFT,
-	GPIO0C1_GPIO            = 0,
-	GPIO0C1_LCDC_D13,
-	GPIO0C1_TRACE_D3,
-	GPIO0C1_MCU_JTAG_TRTSN,
-
-	GPIO0C0_SHIFT           = 0,
-	GPIO0C0_MASK            = 3 << GPIO0C0_SHIFT,
-	GPIO0C0_GPIO            = 0,
-	GPIO0C0_LCDC_D12,
-	GPIO0C0_TRACE_D2,
-	GPIO0C0_MCU_JTAG_TDO,
+	RK3368_GPIO0C7_MASK	       = GENMASK(15, 14),
+	RK3368_GPIO0C7_GPIO	       = 0,
+	RK3368_GPIO0C7_LCDC_D19        = (1 << 14),
+	RK3368_GPIO0C7_TRACE_D9        = (2 << 14),
+	RK3368_GPIO0C7_UART1_RTSN      = (3 << 14),
+
+	RK3368_GPIO0C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0C6_GPIO            = 0,
+	RK3368_GPIO0C6_LCDC_D18        = (1 << 12),
+	RK3368_GPIO0C6_TRACE_D8        = (2 << 12),
+	RK3368_GPIO0C6_UART1_CTSN      = (3 << 12),
+
+	RK3368_GPIO0C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0C5_GPIO            = 0,
+	RK3368_GPIO0C5_LCDC_D17        = (1 << 10),
+	RK3368_GPIO0C5_TRACE_D7        = (2 << 10),
+	RK3368_GPIO0C5_UART1_SOUT      = (3 << 10),
+
+	RK3368_GPIO0C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0C4_GPIO            = 0,
+	RK3368_GPIO0C4_LCDC_D16        = (1 << 8),
+	RK3368_GPIO0C4_TRACE_D6        = (2 << 8),
+	RK3368_GPIO0C4_UART1_SIN       = (3 << 8),
+
+	RK3368_GPIO0C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0C3_GPIO            = 0,
+	RK3368_GPIO0C3_LCDC_D15        = (1 << 6),
+	RK3368_GPIO0C3_TRACE_D5        = (2 << 6),
+	RK3368_GPIO0C3_MCU_JTAG_TDO    = (3 << 6),
+
+	RK3368_GPIO0C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0C2_GPIO            = 0,
+	RK3368_GPIO0C2_LCDC_D14        = (1 << 4),
+	RK3368_GPIO0C2_TRACE_D4        = (2 << 4),
+	RK3368_GPIO0C2_MCU_JTAG_TDI    = (3 << 4),
+
+	RK3368_GPIO0C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0C1_GPIO            = 0,
+	RK3368_GPIO0C1_LCDC_D13        = (1 << 2),
+	RK3368_GPIO0C1_TRACE_D3        = (2 << 2),
+	RK3368_GPIO0C1_MCU_JTAG_TRTSN  = (3 << 2),
+
+	RK3368_GPIO0C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0C0_GPIO            = 0,
+	RK3368_GPIO0C0_LCDC_D12        = (1 << 0),
+	RK3368_GPIO0C0_TRACE_D2        = (2 << 0),
+	RK3368_GPIO0C0_MCU_JTAG_TDO    = (3 << 0),
  };
    /*GRF_GPIO0D_IOMUX*/
  enum {
-	GPIO0D7_SHIFT           = 14,
-	GPIO0D7_MASK            = 3 << GPIO0D7_SHIFT,
-	GPIO0D7_GPIO            = 0,
-	GPIO0D7_LCDC_DCLK,
-	GPIO0D7_TRACE_CTL,
-	GPIO0D7_PMU_DEBUG5,
-
-	GPIO0D6_SHIFT           = 12,
-	GPIO0D6_MASK            = 3 << GPIO0D6_SHIFT,
-	GPIO0D6_GPIO            = 0,
-	GPIO0D6_LCDC_DEN,
-	GPIO0D6_TRACE_CLK,
-	GPIO0D6_PMU_DEBUG4,
-
-	GPIO0D5_SHIFT           = 10,
-	GPIO0D5_MASK            = 3 << GPIO0D5_SHIFT,
-	GPIO0D5_GPIO            = 0,
-	GPIO0D5_LCDC_VSYNC,
-	GPIO0D5_TRACE_D15,
-	GPIO0D5_PMU_DEBUG3,
-
-	GPIO0D4_SHIFT           = 8,
-	GPIO0D4_MASK            = 3 << GPIO0D4_SHIFT,
-	GPIO0D4_GPIO            = 0,
-	GPIO0D4_LCDC_HSYNC,
-	GPIO0D4_TRACE_D14,
-	GPIO0D4_PMU_DEBUG2,
-
-	GPIO0D3_SHIFT           = 6,
-	GPIO0D3_MASK            = 3 << GPIO0D3_SHIFT,
-	GPIO0D3_GPIO            = 0,
-	GPIO0D3_LCDC_D23,
-	GPIO0D3_TRACE_D13,
-	GPIO0D3_UART4_SIN,
-
-	GPIO0D2_SHIFT           = 4,
-	GPIO0D2_MASK            = 3 << GPIO0D2_SHIFT,
-	GPIO0D2_GPIO            = 0,
-	GPIO0D2_LCDC_D22,
-	GPIO0D2_TRACE_D12,
-	GPIO0D2_UART4_SOUT,
-
-	GPIO0D1_SHIFT           = 2,
-	GPIO0D1_MASK            = 3 << GPIO0D1_SHIFT,
-	GPIO0D1_GPIO            = 0,
-	GPIO0D1_LCDC_D21,
-	GPIO0D1_TRACE_D11,
-	GPIO0D1_UART4_RTSN,
-
-	GPIO0D0_SHIFT           = 0,
-	GPIO0D0_MASK            = 3 << GPIO0D0_SHIFT,
-	GPIO0D0_GPIO            = 0,
-	GPIO0D0_LCDC_D20,
-	GPIO0D0_TRACE_D10,
-	GPIO0D0_UART4_CTSN,
+	RK3368_GPIO0D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO0D7_GPIO            = 0,
+	RK3368_GPIO0D7_LCDC_DCLK       = (1 << 14),
+	RK3368_GPIO0D7_TRACE_CTL       = (2 << 14),
+	RK3368_GPIO0D7_PMU_DEBUG5      = (3 << 14),
+
+	RK3368_GPIO0D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0D6_GPIO            = 0,
+	RK3368_GPIO0D6_LCDC_DEN        = (1 << 12),
+	RK3368_GPIO0D6_TRACE_CLK       = (2 << 12),
+	RK3368_GPIO0D6_PMU_DEBUG4      = (3 << 12),
+
+	RK3368_GPIO0D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0D5_GPIO            = 0,
+	GPIO0D5_LCDC_VSYNC             = (1 << 10),
+	RK3368_GPIO0D5_TRACE_D15       = (2 << 10),
+	RK3368_GPIO0D5_PMU_DEBUG3      = (3 << 10),
+
+	RK3368_GPIO0D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0D4_GPIO            = 0,
+	RK3368_GPIO0D4_LCDC_HSYNC      = (1 << 8),
+	RK3368_GPIO0D4_TRACE_D14       = (2 << 8),
+	RK3368_GPIO0D4_PMU_DEBUG2      = (3 << 8),
+
+	RK3368_GPIO0D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0D3_GPIO            = 0,
+	RK3368_GPIO0D3_LCDC_D23        = (1 << 6),
+	RK3368_GPIO0D3_TRACE_D13       = (2 << 6),
+	RK3368_GPIO0D3_UART4_SIN       = (3 << 6),
+
+	RK3368_GPIO0D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0D2_GPIO            = 0,
+	RK3368_GPIO0D2_LCDC_D22        = (1 << 4),
+	RK3368_GPIO0D2_TRACE_D12       = (2 << 4),
+	RK3368_GPIO0D2_UART4_SOUT      = (3 << 4),
+
+	RK3368_GPIO0D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0D1_GPIO            = 0,
+	RK3368_GPIO0D1_LCDC_D21        = (1 << 2),
+	RK3368_GPIO0D1_TRACE_D11       = (2 << 2),
+	RK3368_GPIO0D1_UART4_RTSN      = (3 << 2),
+
+	RK3368_GPIO0D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0D0_GPIO            = 0,
+	RK3368_GPIO0D0_LCDC_D20        = (1 << 0),
+	RK3368_GPIO0D0_TRACE_D10       = (2 << 0),
+	RK3368_GPIO0D0_UART4_CTSN      = (3 << 0),
  };
    /*GRF_GPIO2A_IOMUX*/
  enum {
-	GPIO2A7_SHIFT           = 14,
-	GPIO2A7_MASK            = 3 << GPIO2A7_SHIFT,
-	GPIO2A7_GPIO            = 0,
-	GPIO2A7_SDMMC0_D2,
-	GPIO2A7_JTAG_TCK,
-
-	GPIO2A6_SHIFT           = 12,
-	GPIO2A6_MASK            = 3 << GPIO2A6_SHIFT,
-	GPIO2A6_GPIO            = 0,
-	GPIO2A6_SDMMC0_D1,
-	GPIO2A6_UART2_SIN,
-
-	GPIO2A5_SHIFT           = 10,
-	GPIO2A5_MASK            = 3 << GPIO2A5_SHIFT,
-	GPIO2A5_GPIO            = 0,
-	GPIO2A5_SDMMC0_D0,
-	GPIO2A5_UART2_SOUT,
-
-	GPIO2A4_SHIFT           = 8,
-	GPIO2A4_MASK            = 3 << GPIO2A4_SHIFT,
-	GPIO2A4_GPIO            = 0,
-	GPIO2A4_FLASH_DQS,
-	GPIO2A4_EMMC_CLKO,
-
-	GPIO2A3_SHIFT           = 6,
-	GPIO2A3_MASK            = 3 << GPIO2A3_SHIFT,
-	GPIO2A3_GPIO            = 0,
-	GPIO2A3_FLASH_CSN3,
-	GPIO2A3_EMMC_RSTNO,
-
-	GPIO2A2_SHIFT           = 4,
-	GPIO2A2_MASK            = 3 << GPIO2A2_SHIFT,
-	GPIO2A2_GPIO           = 0,
-	GPIO2A2_FLASH_CSN2,
-
-	GPIO2A1_SHIFT           = 2,
-	GPIO2A1_MASK            = 3 << GPIO2A1_SHIFT,
-	GPIO2A1_GPIO            = 0,
-	GPIO2A1_FLASH_CSN1,
-
-	GPIO2A0_SHIFT           = 0,
-	GPIO2A0_MASK            = 3 << GPIO2A0_SHIFT,
-	GPIO2A0_GPIO            = 0,
-	GPIO2A0_FLASH_CSN0,
+	RK3368_GPIO2A7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2A7_GPIO            = 0,
+	RK3368_GPIO2A7_SDMMC0_D2       = (1 << 14),
+	RK3368_GPIO2A7_JTAG_TCK        = (2 << 14),
+
+	RK3368_GPIO2A6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2A6_GPIO            = 0,
+	RK3368_GPIO2A6_SDMMC0_D1       = (1 << 12),
+	RK3368_GPIO2A6_UART2_SIN       = (2 << 12),
+
+	RK3368_GPIO2A5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2A5_GPIO            = 0,
+	RK3368_GPIO2A5_SDMMC0_D0       = (1 << 10),
+	RK3368_GPIO2A5_UART2_SOUT      = (2 << 10),
+
+	RK3368_GPIO2A4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2A4_RK3368_GPIO     = 0,
+	RK3368_GPIO2A4_FLASH_DQS       = (1 << 8),
+	RK3368_GPIO2A4_EMMC_CLKOUT     = (2 << 8),
+
+	RK3368_GPIO2A3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2A3_GPIO            = 0,
+	RK3368_GPIO2A3_FLASH_CSN3      = (1 << 6),
+	RK3368_GPIO2A3_EMMC_RSTNOUT    = (2 << 6),
+
+	RK3368_GPIO2A2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2A2_GPIO            = 0,
+	RK3368_GPIO2A2_FLASH_CSN2      = (1 << 4),
+
+	RK3368_GPIO2A1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2A1_GPIO            = 0,
+	RK3368_GPIO2A1_FLASH_CSN1      = (1 << 2),
+
+	RK3368_GPIO2A0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2A0_GPIO            = 0,
+	RK3368_GPIO2A0_FLASH_CSN0      = (1 << 0),
  };
  -/*GRF_GPIO2D_IOMUX*/
+/*GRF_RK3368_GPIO2D_IOMUX*/
  enum {
-	GPIO2D7_SHIFT           = 14,
-	GPIO2D7_MASK            = 3 << GPIO2D7_SHIFT,
-	GPIO2D7_GPIO            = 0,
-	GPIO2D7_SDIO0_D3,
-
-	GPIO2D6_SHIFT           = 12,
-	GPIO2D6_MASK            = 3 << GPIO2D6_SHIFT,
-	GPIO2D6_GPIO            = 0,
-	GPIO2D6_SDIO0_D2,
-
-	GPIO2D5_SHIFT           = 10,
-	GPIO2D5_MASK            = 3 << GPIO2D5_SHIFT,
-	GPIO2D5_GPIO            = 0,
-	GPIO2D5_SDIO0_D1,
-
-	GPIO2D4_SHIFT           = 8,
-	GPIO2D4_MASK            = 3 << GPIO2D4_SHIFT,
-	GPIO2D4_GPIO            = 0,
-	GPIO2D4_SDIO0_D0,
-
-	GPIO2D3_SHIFT           = 6,
-	GPIO2D3_MASK            = 3 << GPIO2D3_SHIFT,
-	GPIO2D3_GPIO            = 0,
-	GPIO2D3_UART0_RTS0,
-
-	GPIO2D2_SHIFT           = 4,
-	GPIO2D2_MASK            = 3 << GPIO2D2_SHIFT,
-	GPIO2D2_GPIO            = 0,
-	GPIO2D2_UART0_CTS0,
-
-	GPIO2D1_SHIFT           = 2,
-	GPIO2D1_MASK            = 3 << GPIO2D1_SHIFT,
-	GPIO2D1_GPIO            = 0,
-	GPIO2D1_UART0_SOUT,
-
-	GPIO2D0_SHIFT           = 0,
-	GPIO2D0_MASK            = 3 << GPIO2D0_SHIFT,
-	GPIO2D0_GPIO            = 0,
-	GPIO2D0_UART0_SIN,
+	RK3368_GPIO2D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2D7_GPIO            = 0,
+	RK3368_GPIO2D7_SDIO0_D3        = (1 << 14),
+
+	RK3368_GPIO2D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2D6_GPIO            = 0,
+	RK3368_GPIO2D6_SDIO0_D2        = (1 << 12),
+
+	RK3368_GPIO2D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2D5_GPIO            = 0,
+	RK3368_GPIO2D5_SDIO0_D1        = (1 << 10),
+
+	RK3368_GPIO2D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2D4_GPIO            = 0,
+	RK3368_GPIO2D4_SDIO0_D0        = (1 << 8),
+
+	RK3368_GPIO2D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2D3_GPIO            = 0,
+	RK3368_GPIO2D3_UART0_RTS0      = (1 << 6),
+
+	RK3368_GPIO2D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2D2_GPIO            = 0,
+	RK3368_GPIO2D2_UART0_CTS0      = (1 << 4),
+
+	RK3368_GPIO2D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2D1_GPIO            = 0,
+	RK3368_GPIO2D1_UART0_SOUT      = (1 << 2),
+
+	RK3368_GPIO2D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2D0_GPIO            = 0,
+	RK3368_GPIO2D0_UART0_SIN       = (1 << 0),
+};
+
+/* GRF_GPIO1C_IOMUX */
+enum {
+	RK3368_GPIO1C7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO1C7_GPIO            = 0,
+	RK3368_GPIO1C7_EMMC_DATA5      = (2 << 14),
+
+	RK3368_GPIO1C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO1C6_GPIO            = 0,
+	RK3368_GPIO1C6_EMMC_DATA4      = (2 << 12),
+
+	RK3368_GPIO1C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO1C5_GPIO            = 0,
+	RK3368_GPIO1C5_EMMC_DATA3      = (2 << 10),
+
+	RK3368_GPIO1C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO1C4_GPIO            = 0,
+	RK3368_GPIO1C4_EMMC_DATA2      = (2 << 8),
+
+	RK3368_GPIO1C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1C3_GPIO            = 0,
+	RK3368_GPIO1C3_EMMC_DATA1      = (2 << 6),
+
+	RK3368_GPIO1C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1C2_GPIO            = 0,
+	RK3368_GPIO1C2_EMMC_DATA0      = (2 << 4),
+};
+
+/* GRF_GPIO1D_IOMUX*/
+enum {
+	RK3368_GPIO1D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1D3_GPIO            = 0,
+	RK3368_GPIO1D3_EMMC_PWREN      = (2 << 6),
+
+	RK3368_GPIO1D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1D2_GPIO            = 0,
+	RK3368_GPIO1D2_EMMC_CMD        = (2 << 4),
+
+	RK3368_GPIO1D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO1D1_GPIO            = 0,
+	RK3368_GPIO1D1_EMMC_DATA7      = (2 << 2),
+
+	RK3368_GPIO1D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO1D0_GPIO            = 0,
+	RK3368_GPIO1D0_EMMC_DATA6      = (2 << 0),
+};
+
+
+/*GRF_GPIO3B_IOMUX*/
+enum {
+	RK3368_GPIO3B7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO3B7_GPIO            = 0,
+	RK3368_GPIO3B7_MAC_RXD0        = (1 << 14),
+
+	RK3368_GPIO3B6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3B6_GPIO            = 0,
+	RK3368_GPIO3B6_MAC_TXD3        = (1 << 12),
+
+	RK3368_GPIO3B5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3B5_GPIO            = 0,
+	RK3368_GPIO3B5_MAC_TXEN        = (1 << 10),
+
+	RK3368_GPIO3B4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3B4_GPIO            = 0,
+	RK3368_GPIO3B4_MAC_COL         = (1 << 8),
+
+	RK3368_GPIO3B3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3B3_GPIO            = 0,
+	RK3368_GPIO3B3_MAC_CRS         = (1 << 6),
+
+	RK3368_GPIO3B2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3B2_GPIO            = 0,
+	RK3368_GPIO3B2_MAC_TXD2        = (1 << 4),
+
+	RK3368_GPIO3B1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3B1_GPIO            = 0,
+	RK3368_GPIO3B1_MAC_TXD1        = (1 << 2),
+
+	RK3368_GPIO3B0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3B0_GPIO            = 0,
+	RK3368_GPIO3B0_MAC_TXD0        = (1 << 0),
+	RK3368_GPIO3B0_PWM0            = (2 << 0),
  };
    /*GRF_GPIO3C_IOMUX*/
  enum {
-	GPIO3C7_SHIFT           = 14,
-	GPIO3C7_MASK            = 3 << GPIO3C7_SHIFT,
-	GPIO3C7_GPIO            = 0,
-	GPIO3C7_EDPHDMI_CECINOUT,
-	GPIO3C7_ISP_FLASHTRIGIN,
-
-	GPIO3C6_SHIFT           = 12,
-	GPIO3C6_MASK            = 3 << GPIO3C6_SHIFT,
-	GPIO3C6_GPIO            = 0,
-	GPIO3C6_MAC_CLK,
-	GPIO3C6_ISP_SHUTTERTRIG,
-
-	GPIO3C5_SHIFT           = 10,
-	GPIO3C5_MASK            = 3 << GPIO3C5_SHIFT,
-	GPIO3C5_GPIO            = 0,
-	GPIO3C5_MAC_RXER,
-	GPIO3C5_ISP_PRELIGHTTRIG,
-
-	GPIO3C4_SHIFT           = 8,
-	GPIO3C4_MASK            = 3 << GPIO3C4_SHIFT,
-	GPIO3C4_GPIO            = 0,
-	GPIO3C4_MAC_RXDV,
-	GPIO3C4_ISP_FLASHTRIGOUT,
-
-	GPIO3C3_SHIFT           = 6,
-	GPIO3C3_MASK            = 3 << GPIO3C3_SHIFT,
-	GPIO3C3_GPIO            = 0,
-	GPIO3C3_MAC_RXDV,
-	GPIO3C3_EMMC_RSTNO,
-
-	GPIO3C2_SHIFT           = 4,
-	GPIO3C2_MASK            = 3 << GPIO3C2_SHIFT,
-	GPIO3C2_MAC_MDC            = 0,
-	GPIO3C2_ISP_SHUTTEREN,
-
-	GPIO3C1_SHIFT           = 2,
-	GPIO3C1_MASK            = 3 << GPIO3C1_SHIFT,
-	GPIO3C1_GPIO            = 0,
-	GPIO3C1_MAC_RXD2,
-	GPIO3C1_UART3_RTSN,
-
-	GPIO3C0_SHIFT           = 0,
-	GPIO3C0_MASK            = 3 << GPIO3C0_SHIFT,
-	GPIO3C0_GPIO            = 0,
-	GPIO3C0_MAC_RXD1,
-	GPIO3C0_UART3_CTSN,
-	GPIO3C0_GPS_RFCLK,
+	RK3368_GPIO3C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3C6_GPIO            = 0,
+	RK3368_GPIO3C6_MAC_CLK         = (1 << 12),
+
+	RK3368_GPIO3C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3C5_GPIO            = 0,
+	RK3368_GPIO3C5_MAC_RXEN        = (1 << 10),
+
+	RK3368_GPIO3C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3C4_GPIO            = 0,
+	RK3368_GPIO3C4_MAC_RXDV        = (1 << 8),
+
+	RK3368_GPIO3C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3C3_GPIO            = 0,
+	RK3368_GPIO3C3_MAC_MDC         = (1 << 6),
+
+	RK3368_GPIO3C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3C2_GPIO            = 0,
+	RK3368_GPIO3C2_MAC_RXD3        = (1 << 4),
+
+	RK3368_GPIO3C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3C1_GPIO            = 0,
+	RK3368_GPIO3C1_MAC_RXD2        = (1 << 2),
+
+	RK3368_GPIO3C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3C0_GPIO            = 0,
+	RK3368_GPIO3C0_MAC_RXD1        = (1 << 0),
  };
    /*GRF_GPIO3D_IOMUX*/
  enum {
-	GPIO3D7_SHIFT           = 14,
-	GPIO3D7_MASK            = 3 << GPIO3D7_SHIFT,
-	GPIO3D7_GPIO            = 0,
-	GPIO3D7_SC_VCC18V,
-	GPIO3D7_I2C2_SDA,
-	GPIO3D7_GPUJTAG_TCK,
-
-	GPIO3D6_SHIFT           = 12,
-	GPIO3D6_MASK            = 3 << GPIO3D6_SHIFT,
-	GPIO3D6_GPIO            = 0,
-	GPIO3D6_IR_TX,
-	GPIO3D6_UART3_SOUT,
-	GPIO3D6_PWM3,
-
-	GPIO3D5_SHIFT           = 10,
-	GPIO3D5_MASK            = 3 << GPIO3D5_SHIFT,
-	GPIO3D5_GPIO            = 0,
-	GPIO3D5_IR_RX,
-	GPIO3D5_UART3_SIN,
-
-	GPIO3D4_SHIFT           = 8,
-	GPIO3D4_MASK            = 3 << GPIO3D4_SHIFT,
-	GPIO3D4_GPIO            = 0,
-	GPIO3D4_MAC_TXCLKOUT,
-	GPIO3D4_SPI1_CSN1,
-
-	GPIO3D3_SHIFT           = 6,
-	GPIO3D3_MASK            = 3 << GPIO3D3_SHIFT,
-	GPIO3D3_GPIO            = 0,
-	GPIO3D3_HDMII2C_SCL,
-	GPIO3D3_I2C5_SCL,
-
-	GPIO3D2_SHIFT           = 4,
-	GPIO3D2_MASK            = 3 << GPIO3D2_SHIFT,
-	GPIO3D2_GPIO            = 0,
-	GPIO3D2_HDMII2C_SDA,
-	GPIO3D2_I2C5_SDA,
-
-	GPIO3D1_SHIFT           = 2,
-	GPIO3D1_MASK            = 3 << GPIO3D1_SHIFT,
-	GPIO3D1_GPIO            = 0,
-	GPIO3D1_MAC_RXCLKIN,
-	GPIO3D1_I2C4_SCL,
-
-	GPIO3D0_SHIFT           = 0,
-	GPIO3D0_MASK            = 3 << GPIO3D0_SHIFT,
-	GPIO3D0_GPIO            = 0,
-	GPIO3D0_MAC_MDIO,
-	GPIO3D0_I2C4_SDA,
+	RK3368_GPIO3D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3D4_GPIO            = 0,
+	RK3368_GPIO3D4_MAC_TXCLK       = (1 << 8),
+
+	RK3368_GPIO3D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3D1_GPIO            = 0,
+	RK3368_GPIO3D1_MAC_RXCLK       = (1 << 2),
+
+	RK3368_GPIO3D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3D0_GPIO            = 0,
+	RK3368_GPIO3D0_MAC_MDIO        = (1 << 0),
+};
+
+/* GRF_SOC_CON0 */
+enum {
+	NOC_RSP_ERR_STALL = BIT(9),
+	MOBILE_DDR_SEL = BIT(4),
+	DDR0_16BIT_EN = BIT(3),
+	MSCH0_MAINDDR3_DDR3 = BIT(2),
+	MSCH0_MAINPARTIALPOP = BIT(1),
+	UPCTL_C_ACTIVE = BIT(0),
  };
    /*GRF_SOC_CON11/12/13*/
@@ -440,4 +445,34 @@ enum {
  	MCU_CODE_BASE_BIT31_BIT28_SHIFT		= 0,
  	MCU_CODE_BASE_BIT31_BIT28_MASK		= GENMASK(3, 0),
  };
+
+/*GRF_SOC_CON15*/
+enum {
+	RK3368_GMAC_PHY_INTF_SEL_RGMII = 1 << 9,
+	RK3368_GMAC_PHY_INTF_SEL_MASK = GENMASK(11, 9),
+	RK3368_RMII_MODE_MASK  = BIT(6),
+	RK3368_RMII_MODE       = BIT(6),
+	RK3368_GMAC_CLK_SEL_2_5M = 2 << 4,
+	RK3368_GMAC_CLK_SEL_25M = 3 << 4,
+	RK3368_GMAC_CLK_SEL_125M = 0 << 4,
+	RK3368_GMAC_CLK_SEL_MASK = GENMASK(5, 4),
+};
+
+/* GRF_SOC_CON16 */
+enum {
+	RK3368_RXCLK_DLY_ENA_GMAC_MASK = BIT(15),
+	RK3368_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(15),
+
+	RK3368_TXCLK_DLY_ENA_GMAC_MASK = BIT(7),
+	RK3368_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(7),
+
+	RK3368_CLK_RX_DL_CFG_GMAC_SHIFT = 8,
+	RK3368_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(14, 8),
+
+	RK3368_CLK_TX_DL_CFG_GMAC_SHIFT = 0,
+	RK3368_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
+};
+
  #endif
drivers/pinctrl/rockchip/pinctrl_rk3368.c +8 -9
index bdf0758..b77c5ab 100644
@@ -30,9 +30,9 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
  	switch (uart_id) {
  	case PERIPH_ID_UART2:
  		rk_clrsetreg(&grf->gpio2a_iomux,
-			     GPIO2A6_MASK | GPIO2A5_MASK,
-			     GPIO2A6_UART2_SIN << GPIO2A6_SHIFT |
-			     GPIO2A5_UART2_SOUT << GPIO2A5_SHIFT);
+			     RK3368_GPIO2A6_MASK | RK3368_GPIO2A5_MASK,
+			     RK3368_GPIO2A6_UART2_SIN |
+			     RK3368_GPIO2A5_UART2_SOUT);
  		break;
  	case PERIPH_ID_UART0:
  		break;
@@ -42,12 +42,11 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
  		break;
  	case PERIPH_ID_UART4:
  		rk_clrsetreg(&pmugrf->gpio0d_iomux,
-			     GPIO0D0_MASK | GPIO0D1_MASK |
-			     GPIO0D2_MASK | GPIO0D3_MASK,
-			     GPIO0D0_GPIO << GPIO0D0_SHIFT |
-			     GPIO0D1_GPIO << GPIO0D1_SHIFT |
-			     GPIO0D2_UART4_SOUT << GPIO0D2_SHIFT |
-			     GPIO0D3_UART4_SIN << GPIO0D3_SHIFT);
+			     RK3368_GPIO0D0_MASK | RK3368_GPIO0D1_MASK |
+			     RK3368_GPIO0D2_MASK | RK3368_GPIO0D3_MASK,
+			     RK3368_GPIO0D0_GPIO | RK3368_GPIO0D1_GPIO |
+			     RK3368_GPIO0D2_UART4_SOUT |
+			     RK3368_GPIO0D3_UART4_SIN);
  		break;
  	default:
  		debug("uart id = %d iomux error!\n", uart_id);
#36 lore raw

PATCH 30/52 rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_

Quoted 30 lines · Andy Yan

Hi Philipp:

Quoted 23 lines · Dr. Philipp Tomsich
Quoted 11 lines · Andy Yan

Hi Philipp:

Quoted 5 lines · Philipp Tomsich

The RK3368 GRF header was still defines with a shifted-mask but with non-shifted function selectors for the IOMUX defines. As the RK3368 support is still fresh enough to allow a quick rename, we do this now before having more code use this.

Quoted 6 lines
Quoted 4 lines

As some of the downstream drivers (e.g. the Designware GMAC wrapper) may need to include the grf-header of multiple devices, we rename the various defines for the RK3368 by prefixing them with the device name. This avoids future trouble during driver integration.

Is that really necessary to add such a prefix for all the register definition, just to fit the GMAC dirver?
Maybe the gmac driver can define the platform specific macro in its own code like dwmac-rk in the kernel. Then we can keep the register header file a little tidy.

The problem is not the GMAC driver (although it was the motivation for doing this change), but rather how easy it is to pick up the wrong grf-file and refer to the wrong definitions/values… the conflicts are not through the GMAC-specifc defines but rather through things like the IOMUX masks or (before I moved this to the DDR-driver) things like the defines to enable DRAM in GRF.

Quoted 8 lines
Quoted 7 lines

Until we find a way to consistently structure things in such a way that
(a) common constructs can be shared (e.g. the masks in the IOMUX)
(b) specific definitions (e.g. the pin-out for a specific device) is not visible outside of its driver
I prefer the names to explicitly refer to each device.
That said, the longer-term plan (especially with a larger number of devices
being supported) needs to include a consistent rework of how (and where)
we manage all these definitions from the grf-header files.

It's true that many devices use GRF, we also face this condition in the kernel land.And all the drivers in kernel handle this device specific definition in the driver itself(by of_device_id->data or MACRO). And there is also no need to use the grf constructs, the common syscon api will provide you the grf base address. I think this keeps things simple, we don't need to rely on too much of the grf or cru header, maybe some day we can remove the header file, just as clean as the kernel.

The problem is not the base-address of GRF, but rather the need to pull in the register structure (so we can refer to individual registers by name instead of by hard-coded offset): as we pull this in today, the definitions for the various IOMUX entries will also be pulled in, which will cause duplicate definitions.

Quoted 1 line

On the other hand, add such a prefix of rk3368 breaks the consistency with other rockchip devices.

I do agree that we need to clean this up across all the boards and drivers supported today. As of today, I can not resolve this on a RK3368-only basis, as I’d need to clean up the RK3288 at the same time (and don’t want to do this in a RK3368-focused series that already has way too much going on).

Let’s try to clean this up for the next (i.e. the one after this) merge window. Once we have bit-definitions out of the grf-header, I’ll remove the RK3368_ prefixes...

Quoted 693 lines
Quoted 693 lines
Quoted 693 lines
Quoted 693 lines

---

 arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 617 +++++++++++++-----------
 drivers/pinctrl/rockchip/pinctrl_rk3368.c       |  17 +-
 2 files changed, 334 insertions(+), 300 deletions(-)
arch/arm/include/asm/arch-rockchip/grf_rk3368.h +326 -290
index a438f5d..a97dc1e 100644
@@ -1,4 +1,6 @@
-/* (C) Copyright 2016 Rockchip Electronics Co., Ltd
+/*
+ * (C) Copyright 2016 Rockchip Electronics Co., Ltd
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
  *
  * SPDX-License-Identifier:     GPL-2.0+
  */
@@ -100,315 +102,318 @@ check_member(rk3368_pmu_grf, os_reg[0], 0x200);
   /*GRF_GPIO0C_IOMUX*/
 enum {
-	GPIO0C7_SHIFT		= 14,
-	GPIO0C7_MASK		= 3 << GPIO0C7_SHIFT,
-	GPIO0C7_GPIO		= 0,
-	GPIO0C7_LCDC_D19,
-	GPIO0C7_TRACE_D9,
-	GPIO0C7_UART1_RTSN,
-
-	GPIO0C6_SHIFT           = 12,
-	GPIO0C6_MASK            = 3 << GPIO0C6_SHIFT,
-	GPIO0C6_GPIO            = 0,
-	GPIO0C6_LCDC_D18,
-	GPIO0C6_TRACE_D8,
-	GPIO0C6_UART1_CTSN,
-
-	GPIO0C5_SHIFT           = 10,
-	GPIO0C5_MASK            = 3 << GPIO0C5_SHIFT,
-	GPIO0C5_GPIO            = 0,
-	GPIO0C5_LCDC_D17,
-	GPIO0C5_TRACE_D7,
-	GPIO0C5_UART1_SOUT,
-
-	GPIO0C4_SHIFT           = 8,
-	GPIO0C4_MASK            = 3 << GPIO0C4_SHIFT,
-	GPIO0C4_GPIO            = 0,
-	GPIO0C4_LCDC_D16,
-	GPIO0C4_TRACE_D6,
-	GPIO0C4_UART1_SIN,
-
-	GPIO0C3_SHIFT           = 6,
-	GPIO0C3_MASK            = 3 << GPIO0C3_SHIFT,
-	GPIO0C3_GPIO            = 0,
-	GPIO0C3_LCDC_D15,
-	GPIO0C3_TRACE_D5,
-	GPIO0C3_MCU_JTAG_TDO,
-
-	GPIO0C2_SHIFT           = 4,
-	GPIO0C2_MASK            = 3 << GPIO0C2_SHIFT,
-	GPIO0C2_GPIO            = 0,
-	GPIO0C2_LCDC_D14,
-	GPIO0C2_TRACE_D4,
-	GPIO0C2_MCU_JTAG_TDI,
-
-	GPIO0C1_SHIFT           = 2,
-	GPIO0C1_MASK            = 3 << GPIO0C1_SHIFT,
-	GPIO0C1_GPIO            = 0,
-	GPIO0C1_LCDC_D13,
-	GPIO0C1_TRACE_D3,
-	GPIO0C1_MCU_JTAG_TRTSN,
-
-	GPIO0C0_SHIFT           = 0,
-	GPIO0C0_MASK            = 3 << GPIO0C0_SHIFT,
-	GPIO0C0_GPIO            = 0,
-	GPIO0C0_LCDC_D12,
-	GPIO0C0_TRACE_D2,
-	GPIO0C0_MCU_JTAG_TDO,
+	RK3368_GPIO0C7_MASK	       = GENMASK(15, 14),
+	RK3368_GPIO0C7_GPIO	       = 0,
+	RK3368_GPIO0C7_LCDC_D19        = (1 << 14),
+	RK3368_GPIO0C7_TRACE_D9        = (2 << 14),
+	RK3368_GPIO0C7_UART1_RTSN      = (3 << 14),
+
+	RK3368_GPIO0C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0C6_GPIO            = 0,
+	RK3368_GPIO0C6_LCDC_D18        = (1 << 12),
+	RK3368_GPIO0C6_TRACE_D8        = (2 << 12),
+	RK3368_GPIO0C6_UART1_CTSN      = (3 << 12),
+
+	RK3368_GPIO0C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0C5_GPIO            = 0,
+	RK3368_GPIO0C5_LCDC_D17        = (1 << 10),
+	RK3368_GPIO0C5_TRACE_D7        = (2 << 10),
+	RK3368_GPIO0C5_UART1_SOUT      = (3 << 10),
+
+	RK3368_GPIO0C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0C4_GPIO            = 0,
+	RK3368_GPIO0C4_LCDC_D16        = (1 << 8),
+	RK3368_GPIO0C4_TRACE_D6        = (2 << 8),
+	RK3368_GPIO0C4_UART1_SIN       = (3 << 8),
+
+	RK3368_GPIO0C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0C3_GPIO            = 0,
+	RK3368_GPIO0C3_LCDC_D15        = (1 << 6),
+	RK3368_GPIO0C3_TRACE_D5        = (2 << 6),
+	RK3368_GPIO0C3_MCU_JTAG_TDO    = (3 << 6),
+
+	RK3368_GPIO0C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0C2_GPIO            = 0,
+	RK3368_GPIO0C2_LCDC_D14        = (1 << 4),
+	RK3368_GPIO0C2_TRACE_D4        = (2 << 4),
+	RK3368_GPIO0C2_MCU_JTAG_TDI    = (3 << 4),
+
+	RK3368_GPIO0C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0C1_GPIO            = 0,
+	RK3368_GPIO0C1_LCDC_D13        = (1 << 2),
+	RK3368_GPIO0C1_TRACE_D3        = (2 << 2),
+	RK3368_GPIO0C1_MCU_JTAG_TRTSN  = (3 << 2),
+
+	RK3368_GPIO0C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0C0_GPIO            = 0,
+	RK3368_GPIO0C0_LCDC_D12        = (1 << 0),
+	RK3368_GPIO0C0_TRACE_D2        = (2 << 0),
+	RK3368_GPIO0C0_MCU_JTAG_TDO    = (3 << 0),
 };
   /*GRF_GPIO0D_IOMUX*/
 enum {
-	GPIO0D7_SHIFT           = 14,
-	GPIO0D7_MASK            = 3 << GPIO0D7_SHIFT,
-	GPIO0D7_GPIO            = 0,
-	GPIO0D7_LCDC_DCLK,
-	GPIO0D7_TRACE_CTL,
-	GPIO0D7_PMU_DEBUG5,
-
-	GPIO0D6_SHIFT           = 12,
-	GPIO0D6_MASK            = 3 << GPIO0D6_SHIFT,
-	GPIO0D6_GPIO            = 0,
-	GPIO0D6_LCDC_DEN,
-	GPIO0D6_TRACE_CLK,
-	GPIO0D6_PMU_DEBUG4,
-
-	GPIO0D5_SHIFT           = 10,
-	GPIO0D5_MASK            = 3 << GPIO0D5_SHIFT,
-	GPIO0D5_GPIO            = 0,
-	GPIO0D5_LCDC_VSYNC,
-	GPIO0D5_TRACE_D15,
-	GPIO0D5_PMU_DEBUG3,
-
-	GPIO0D4_SHIFT           = 8,
-	GPIO0D4_MASK            = 3 << GPIO0D4_SHIFT,
-	GPIO0D4_GPIO            = 0,
-	GPIO0D4_LCDC_HSYNC,
-	GPIO0D4_TRACE_D14,
-	GPIO0D4_PMU_DEBUG2,
-
-	GPIO0D3_SHIFT           = 6,
-	GPIO0D3_MASK            = 3 << GPIO0D3_SHIFT,
-	GPIO0D3_GPIO            = 0,
-	GPIO0D3_LCDC_D23,
-	GPIO0D3_TRACE_D13,
-	GPIO0D3_UART4_SIN,
-
-	GPIO0D2_SHIFT           = 4,
-	GPIO0D2_MASK            = 3 << GPIO0D2_SHIFT,
-	GPIO0D2_GPIO            = 0,
-	GPIO0D2_LCDC_D22,
-	GPIO0D2_TRACE_D12,
-	GPIO0D2_UART4_SOUT,
-
-	GPIO0D1_SHIFT           = 2,
-	GPIO0D1_MASK            = 3 << GPIO0D1_SHIFT,
-	GPIO0D1_GPIO            = 0,
-	GPIO0D1_LCDC_D21,
-	GPIO0D1_TRACE_D11,
-	GPIO0D1_UART4_RTSN,
-
-	GPIO0D0_SHIFT           = 0,
-	GPIO0D0_MASK            = 3 << GPIO0D0_SHIFT,
-	GPIO0D0_GPIO            = 0,
-	GPIO0D0_LCDC_D20,
-	GPIO0D0_TRACE_D10,
-	GPIO0D0_UART4_CTSN,
+	RK3368_GPIO0D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO0D7_GPIO            = 0,
+	RK3368_GPIO0D7_LCDC_DCLK       = (1 << 14),
+	RK3368_GPIO0D7_TRACE_CTL       = (2 << 14),
+	RK3368_GPIO0D7_PMU_DEBUG5      = (3 << 14),
+
+	RK3368_GPIO0D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0D6_GPIO            = 0,
+	RK3368_GPIO0D6_LCDC_DEN        = (1 << 12),
+	RK3368_GPIO0D6_TRACE_CLK       = (2 << 12),
+	RK3368_GPIO0D6_PMU_DEBUG4      = (3 << 12),
+
+	RK3368_GPIO0D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0D5_GPIO            = 0,
+	GPIO0D5_LCDC_VSYNC             = (1 << 10),
+	RK3368_GPIO0D5_TRACE_D15       = (2 << 10),
+	RK3368_GPIO0D5_PMU_DEBUG3      = (3 << 10),
+
+	RK3368_GPIO0D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0D4_GPIO            = 0,
+	RK3368_GPIO0D4_LCDC_HSYNC      = (1 << 8),
+	RK3368_GPIO0D4_TRACE_D14       = (2 << 8),
+	RK3368_GPIO0D4_PMU_DEBUG2      = (3 << 8),
+
+	RK3368_GPIO0D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0D3_GPIO            = 0,
+	RK3368_GPIO0D3_LCDC_D23        = (1 << 6),
+	RK3368_GPIO0D3_TRACE_D13       = (2 << 6),
+	RK3368_GPIO0D3_UART4_SIN       = (3 << 6),
+
+	RK3368_GPIO0D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0D2_GPIO            = 0,
+	RK3368_GPIO0D2_LCDC_D22        = (1 << 4),
+	RK3368_GPIO0D2_TRACE_D12       = (2 << 4),
+	RK3368_GPIO0D2_UART4_SOUT      = (3 << 4),
+
+	RK3368_GPIO0D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0D1_GPIO            = 0,
+	RK3368_GPIO0D1_LCDC_D21        = (1 << 2),
+	RK3368_GPIO0D1_TRACE_D11       = (2 << 2),
+	RK3368_GPIO0D1_UART4_RTSN      = (3 << 2),
+
+	RK3368_GPIO0D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0D0_GPIO            = 0,
+	RK3368_GPIO0D0_LCDC_D20        = (1 << 0),
+	RK3368_GPIO0D0_TRACE_D10       = (2 << 0),
+	RK3368_GPIO0D0_UART4_CTSN      = (3 << 0),
 };
   /*GRF_GPIO2A_IOMUX*/
 enum {
-	GPIO2A7_SHIFT           = 14,
-	GPIO2A7_MASK            = 3 << GPIO2A7_SHIFT,
-	GPIO2A7_GPIO            = 0,
-	GPIO2A7_SDMMC0_D2,
-	GPIO2A7_JTAG_TCK,
-
-	GPIO2A6_SHIFT           = 12,
-	GPIO2A6_MASK            = 3 << GPIO2A6_SHIFT,
-	GPIO2A6_GPIO            = 0,
-	GPIO2A6_SDMMC0_D1,
-	GPIO2A6_UART2_SIN,
-
-	GPIO2A5_SHIFT           = 10,
-	GPIO2A5_MASK            = 3 << GPIO2A5_SHIFT,
-	GPIO2A5_GPIO            = 0,
-	GPIO2A5_SDMMC0_D0,
-	GPIO2A5_UART2_SOUT,
-
-	GPIO2A4_SHIFT           = 8,
-	GPIO2A4_MASK            = 3 << GPIO2A4_SHIFT,
-	GPIO2A4_GPIO            = 0,
-	GPIO2A4_FLASH_DQS,
-	GPIO2A4_EMMC_CLKO,
-
-	GPIO2A3_SHIFT           = 6,
-	GPIO2A3_MASK            = 3 << GPIO2A3_SHIFT,
-	GPIO2A3_GPIO            = 0,
-	GPIO2A3_FLASH_CSN3,
-	GPIO2A3_EMMC_RSTNO,
-
-	GPIO2A2_SHIFT           = 4,
-	GPIO2A2_MASK            = 3 << GPIO2A2_SHIFT,
-	GPIO2A2_GPIO           = 0,
-	GPIO2A2_FLASH_CSN2,
-
-	GPIO2A1_SHIFT           = 2,
-	GPIO2A1_MASK            = 3 << GPIO2A1_SHIFT,
-	GPIO2A1_GPIO            = 0,
-	GPIO2A1_FLASH_CSN1,
-
-	GPIO2A0_SHIFT           = 0,
-	GPIO2A0_MASK            = 3 << GPIO2A0_SHIFT,
-	GPIO2A0_GPIO            = 0,
-	GPIO2A0_FLASH_CSN0,
+	RK3368_GPIO2A7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2A7_GPIO            = 0,
+	RK3368_GPIO2A7_SDMMC0_D2       = (1 << 14),
+	RK3368_GPIO2A7_JTAG_TCK        = (2 << 14),
+
+	RK3368_GPIO2A6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2A6_GPIO            = 0,
+	RK3368_GPIO2A6_SDMMC0_D1       = (1 << 12),
+	RK3368_GPIO2A6_UART2_SIN       = (2 << 12),
+
+	RK3368_GPIO2A5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2A5_GPIO            = 0,
+	RK3368_GPIO2A5_SDMMC0_D0       = (1 << 10),
+	RK3368_GPIO2A5_UART2_SOUT      = (2 << 10),
+
+	RK3368_GPIO2A4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2A4_RK3368_GPIO     = 0,
+	RK3368_GPIO2A4_FLASH_DQS       = (1 << 8),
+	RK3368_GPIO2A4_EMMC_CLKOUT     = (2 << 8),
+
+	RK3368_GPIO2A3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2A3_GPIO            = 0,
+	RK3368_GPIO2A3_FLASH_CSN3      = (1 << 6),
+	RK3368_GPIO2A3_EMMC_RSTNOUT    = (2 << 6),
+
+	RK3368_GPIO2A2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2A2_GPIO            = 0,
+	RK3368_GPIO2A2_FLASH_CSN2      = (1 << 4),
+
+	RK3368_GPIO2A1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2A1_GPIO            = 0,
+	RK3368_GPIO2A1_FLASH_CSN1      = (1 << 2),
+
+	RK3368_GPIO2A0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2A0_GPIO            = 0,
+	RK3368_GPIO2A0_FLASH_CSN0      = (1 << 0),
 };
 -/*GRF_GPIO2D_IOMUX*/
+/*GRF_RK3368_GPIO2D_IOMUX*/
 enum {
-	GPIO2D7_SHIFT           = 14,
-	GPIO2D7_MASK            = 3 << GPIO2D7_SHIFT,
-	GPIO2D7_GPIO            = 0,
-	GPIO2D7_SDIO0_D3,
-
-	GPIO2D6_SHIFT           = 12,
-	GPIO2D6_MASK            = 3 << GPIO2D6_SHIFT,
-	GPIO2D6_GPIO            = 0,
-	GPIO2D6_SDIO0_D2,
-
-	GPIO2D5_SHIFT           = 10,
-	GPIO2D5_MASK            = 3 << GPIO2D5_SHIFT,
-	GPIO2D5_GPIO            = 0,
-	GPIO2D5_SDIO0_D1,
-
-	GPIO2D4_SHIFT           = 8,
-	GPIO2D4_MASK            = 3 << GPIO2D4_SHIFT,
-	GPIO2D4_GPIO            = 0,
-	GPIO2D4_SDIO0_D0,
-
-	GPIO2D3_SHIFT           = 6,
-	GPIO2D3_MASK            = 3 << GPIO2D3_SHIFT,
-	GPIO2D3_GPIO            = 0,
-	GPIO2D3_UART0_RTS0,
-
-	GPIO2D2_SHIFT           = 4,
-	GPIO2D2_MASK            = 3 << GPIO2D2_SHIFT,
-	GPIO2D2_GPIO            = 0,
-	GPIO2D2_UART0_CTS0,
-
-	GPIO2D1_SHIFT           = 2,
-	GPIO2D1_MASK            = 3 << GPIO2D1_SHIFT,
-	GPIO2D1_GPIO            = 0,
-	GPIO2D1_UART0_SOUT,
-
-	GPIO2D0_SHIFT           = 0,
-	GPIO2D0_MASK            = 3 << GPIO2D0_SHIFT,
-	GPIO2D0_GPIO            = 0,
-	GPIO2D0_UART0_SIN,
+	RK3368_GPIO2D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2D7_GPIO            = 0,
+	RK3368_GPIO2D7_SDIO0_D3        = (1 << 14),
+
+	RK3368_GPIO2D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2D6_GPIO            = 0,
+	RK3368_GPIO2D6_SDIO0_D2        = (1 << 12),
+
+	RK3368_GPIO2D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2D5_GPIO            = 0,
+	RK3368_GPIO2D5_SDIO0_D1        = (1 << 10),
+
+	RK3368_GPIO2D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2D4_GPIO            = 0,
+	RK3368_GPIO2D4_SDIO0_D0        = (1 << 8),
+
+	RK3368_GPIO2D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2D3_GPIO            = 0,
+	RK3368_GPIO2D3_UART0_RTS0      = (1 << 6),
+
+	RK3368_GPIO2D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2D2_GPIO            = 0,
+	RK3368_GPIO2D2_UART0_CTS0      = (1 << 4),
+
+	RK3368_GPIO2D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2D1_GPIO            = 0,
+	RK3368_GPIO2D1_UART0_SOUT      = (1 << 2),
+
+	RK3368_GPIO2D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2D0_GPIO            = 0,
+	RK3368_GPIO2D0_UART0_SIN       = (1 << 0),
+};
+
+/* GRF_GPIO1C_IOMUX */
+enum {
+	RK3368_GPIO1C7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO1C7_GPIO            = 0,
+	RK3368_GPIO1C7_EMMC_DATA5      = (2 << 14),
+
+	RK3368_GPIO1C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO1C6_GPIO            = 0,
+	RK3368_GPIO1C6_EMMC_DATA4      = (2 << 12),
+
+	RK3368_GPIO1C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO1C5_GPIO            = 0,
+	RK3368_GPIO1C5_EMMC_DATA3      = (2 << 10),
+
+	RK3368_GPIO1C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO1C4_GPIO            = 0,
+	RK3368_GPIO1C4_EMMC_DATA2      = (2 << 8),
+
+	RK3368_GPIO1C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1C3_GPIO            = 0,
+	RK3368_GPIO1C3_EMMC_DATA1      = (2 << 6),
+
+	RK3368_GPIO1C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1C2_GPIO            = 0,
+	RK3368_GPIO1C2_EMMC_DATA0      = (2 << 4),
+};
+
+/* GRF_GPIO1D_IOMUX*/
+enum {
+	RK3368_GPIO1D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1D3_GPIO            = 0,
+	RK3368_GPIO1D3_EMMC_PWREN      = (2 << 6),
+
+	RK3368_GPIO1D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1D2_GPIO            = 0,
+	RK3368_GPIO1D2_EMMC_CMD        = (2 << 4),
+
+	RK3368_GPIO1D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO1D1_GPIO            = 0,
+	RK3368_GPIO1D1_EMMC_DATA7      = (2 << 2),
+
+	RK3368_GPIO1D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO1D0_GPIO            = 0,
+	RK3368_GPIO1D0_EMMC_DATA6      = (2 << 0),
+};
+
+
+/*GRF_GPIO3B_IOMUX*/
+enum {
+	RK3368_GPIO3B7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO3B7_GPIO            = 0,
+	RK3368_GPIO3B7_MAC_RXD0        = (1 << 14),
+
+	RK3368_GPIO3B6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3B6_GPIO            = 0,
+	RK3368_GPIO3B6_MAC_TXD3        = (1 << 12),
+
+	RK3368_GPIO3B5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3B5_GPIO            = 0,
+	RK3368_GPIO3B5_MAC_TXEN        = (1 << 10),
+
+	RK3368_GPIO3B4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3B4_GPIO            = 0,
+	RK3368_GPIO3B4_MAC_COL         = (1 << 8),
+
+	RK3368_GPIO3B3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3B3_GPIO            = 0,
+	RK3368_GPIO3B3_MAC_CRS         = (1 << 6),
+
+	RK3368_GPIO3B2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3B2_GPIO            = 0,
+	RK3368_GPIO3B2_MAC_TXD2        = (1 << 4),
+
+	RK3368_GPIO3B1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3B1_GPIO            = 0,
+	RK3368_GPIO3B1_MAC_TXD1        = (1 << 2),
+
+	RK3368_GPIO3B0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3B0_GPIO            = 0,
+	RK3368_GPIO3B0_MAC_TXD0        = (1 << 0),
+	RK3368_GPIO3B0_PWM0            = (2 << 0),
 };
   /*GRF_GPIO3C_IOMUX*/
 enum {
-	GPIO3C7_SHIFT           = 14,
-	GPIO3C7_MASK            = 3 << GPIO3C7_SHIFT,
-	GPIO3C7_GPIO            = 0,
-	GPIO3C7_EDPHDMI_CECINOUT,
-	GPIO3C7_ISP_FLASHTRIGIN,
-
-	GPIO3C6_SHIFT           = 12,
-	GPIO3C6_MASK            = 3 << GPIO3C6_SHIFT,
-	GPIO3C6_GPIO            = 0,
-	GPIO3C6_MAC_CLK,
-	GPIO3C6_ISP_SHUTTERTRIG,
-
-	GPIO3C5_SHIFT           = 10,
-	GPIO3C5_MASK            = 3 << GPIO3C5_SHIFT,
-	GPIO3C5_GPIO            = 0,
-	GPIO3C5_MAC_RXER,
-	GPIO3C5_ISP_PRELIGHTTRIG,
-
-	GPIO3C4_SHIFT           = 8,
-	GPIO3C4_MASK            = 3 << GPIO3C4_SHIFT,
-	GPIO3C4_GPIO            = 0,
-	GPIO3C4_MAC_RXDV,
-	GPIO3C4_ISP_FLASHTRIGOUT,
-
-	GPIO3C3_SHIFT           = 6,
-	GPIO3C3_MASK            = 3 << GPIO3C3_SHIFT,
-	GPIO3C3_GPIO            = 0,
-	GPIO3C3_MAC_RXDV,
-	GPIO3C3_EMMC_RSTNO,
-
-	GPIO3C2_SHIFT           = 4,
-	GPIO3C2_MASK            = 3 << GPIO3C2_SHIFT,
-	GPIO3C2_MAC_MDC            = 0,
-	GPIO3C2_ISP_SHUTTEREN,
-
-	GPIO3C1_SHIFT           = 2,
-	GPIO3C1_MASK            = 3 << GPIO3C1_SHIFT,
-	GPIO3C1_GPIO            = 0,
-	GPIO3C1_MAC_RXD2,
-	GPIO3C1_UART3_RTSN,
-
-	GPIO3C0_SHIFT           = 0,
-	GPIO3C0_MASK            = 3 << GPIO3C0_SHIFT,
-	GPIO3C0_GPIO            = 0,
-	GPIO3C0_MAC_RXD1,
-	GPIO3C0_UART3_CTSN,
-	GPIO3C0_GPS_RFCLK,
+	RK3368_GPIO3C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3C6_GPIO            = 0,
+	RK3368_GPIO3C6_MAC_CLK         = (1 << 12),
+
+	RK3368_GPIO3C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3C5_GPIO            = 0,
+	RK3368_GPIO3C5_MAC_RXEN        = (1 << 10),
+
+	RK3368_GPIO3C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3C4_GPIO            = 0,
+	RK3368_GPIO3C4_MAC_RXDV        = (1 << 8),
+
+	RK3368_GPIO3C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3C3_GPIO            = 0,
+	RK3368_GPIO3C3_MAC_MDC         = (1 << 6),
+
+	RK3368_GPIO3C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3C2_GPIO            = 0,
+	RK3368_GPIO3C2_MAC_RXD3        = (1 << 4),
+
+	RK3368_GPIO3C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3C1_GPIO            = 0,
+	RK3368_GPIO3C1_MAC_RXD2        = (1 << 2),
+
+	RK3368_GPIO3C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3C0_GPIO            = 0,
+	RK3368_GPIO3C0_MAC_RXD1        = (1 << 0),
 };
   /*GRF_GPIO3D_IOMUX*/
 enum {
-	GPIO3D7_SHIFT           = 14,
-	GPIO3D7_MASK            = 3 << GPIO3D7_SHIFT,
-	GPIO3D7_GPIO            = 0,
-	GPIO3D7_SC_VCC18V,
-	GPIO3D7_I2C2_SDA,
-	GPIO3D7_GPUJTAG_TCK,
-
-	GPIO3D6_SHIFT           = 12,
-	GPIO3D6_MASK            = 3 << GPIO3D6_SHIFT,
-	GPIO3D6_GPIO            = 0,
-	GPIO3D6_IR_TX,
-	GPIO3D6_UART3_SOUT,
-	GPIO3D6_PWM3,
-
-	GPIO3D5_SHIFT           = 10,
-	GPIO3D5_MASK            = 3 << GPIO3D5_SHIFT,
-	GPIO3D5_GPIO            = 0,
-	GPIO3D5_IR_RX,
-	GPIO3D5_UART3_SIN,
-
-	GPIO3D4_SHIFT           = 8,
-	GPIO3D4_MASK            = 3 << GPIO3D4_SHIFT,
-	GPIO3D4_GPIO            = 0,
-	GPIO3D4_MAC_TXCLKOUT,
-	GPIO3D4_SPI1_CSN1,
-
-	GPIO3D3_SHIFT           = 6,
-	GPIO3D3_MASK            = 3 << GPIO3D3_SHIFT,
-	GPIO3D3_GPIO            = 0,
-	GPIO3D3_HDMII2C_SCL,
-	GPIO3D3_I2C5_SCL,
-
-	GPIO3D2_SHIFT           = 4,
-	GPIO3D2_MASK            = 3 << GPIO3D2_SHIFT,
-	GPIO3D2_GPIO            = 0,
-	GPIO3D2_HDMII2C_SDA,
-	GPIO3D2_I2C5_SDA,
-
-	GPIO3D1_SHIFT           = 2,
-	GPIO3D1_MASK            = 3 << GPIO3D1_SHIFT,
-	GPIO3D1_GPIO            = 0,
-	GPIO3D1_MAC_RXCLKIN,
-	GPIO3D1_I2C4_SCL,
-
-	GPIO3D0_SHIFT           = 0,
-	GPIO3D0_MASK            = 3 << GPIO3D0_SHIFT,
-	GPIO3D0_GPIO            = 0,
-	GPIO3D0_MAC_MDIO,
-	GPIO3D0_I2C4_SDA,
+	RK3368_GPIO3D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3D4_GPIO            = 0,
+	RK3368_GPIO3D4_MAC_TXCLK       = (1 << 8),
+
+	RK3368_GPIO3D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3D1_GPIO            = 0,
+	RK3368_GPIO3D1_MAC_RXCLK       = (1 << 2),
+
+	RK3368_GPIO3D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3D0_GPIO            = 0,
+	RK3368_GPIO3D0_MAC_MDIO        = (1 << 0),
+};
+
+/* GRF_SOC_CON0 */
+enum {
+	NOC_RSP_ERR_STALL = BIT(9),
+	MOBILE_DDR_SEL = BIT(4),
+	DDR0_16BIT_EN = BIT(3),
+	MSCH0_MAINDDR3_DDR3 = BIT(2),
+	MSCH0_MAINPARTIALPOP = BIT(1),
+	UPCTL_C_ACTIVE = BIT(0),
 };
   /*GRF_SOC_CON11/12/13*/
@@ -440,4 +445,34 @@ enum {
 	MCU_CODE_BASE_BIT31_BIT28_SHIFT		= 0,
 	MCU_CODE_BASE_BIT31_BIT28_MASK		= GENMASK(3, 0),
 };
+
+/*GRF_SOC_CON15*/
+enum {
+	RK3368_GMAC_PHY_INTF_SEL_RGMII = 1 << 9,
+	RK3368_GMAC_PHY_INTF_SEL_MASK = GENMASK(11, 9),
+	RK3368_RMII_MODE_MASK  = BIT(6),
+	RK3368_RMII_MODE       = BIT(6),
+	RK3368_GMAC_CLK_SEL_2_5M = 2 << 4,
+	RK3368_GMAC_CLK_SEL_25M = 3 << 4,
+	RK3368_GMAC_CLK_SEL_125M = 0 << 4,
+	RK3368_GMAC_CLK_SEL_MASK = GENMASK(5, 4),
+};
+
+/* GRF_SOC_CON16 */
+enum {
+	RK3368_RXCLK_DLY_ENA_GMAC_MASK = BIT(15),
+	RK3368_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(15),
+
+	RK3368_TXCLK_DLY_ENA_GMAC_MASK = BIT(7),
+	RK3368_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(7),
+
+	RK3368_CLK_RX_DL_CFG_GMAC_SHIFT = 8,
+	RK3368_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(14, 8),
+
+	RK3368_CLK_TX_DL_CFG_GMAC_SHIFT = 0,
+	RK3368_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
+};
+
 #endif
drivers/pinctrl/rockchip/pinctrl_rk3368.c +8 -9
index bdf0758..b77c5ab 100644
@@ -30,9 +30,9 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
 	switch (uart_id) {
 	case PERIPH_ID_UART2:
 		rk_clrsetreg(&grf->gpio2a_iomux,
-			     GPIO2A6_MASK | GPIO2A5_MASK,
-			     GPIO2A6_UART2_SIN << GPIO2A6_SHIFT |
-			     GPIO2A5_UART2_SOUT << GPIO2A5_SHIFT);
+			     RK3368_GPIO2A6_MASK | RK3368_GPIO2A5_MASK,
+			     RK3368_GPIO2A6_UART2_SIN |
+			     RK3368_GPIO2A5_UART2_SOUT);
 		break;
 	case PERIPH_ID_UART0:
 		break;
@@ -42,12 +42,11 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
 		break;
 	case PERIPH_ID_UART4:
 		rk_clrsetreg(&pmugrf->gpio0d_iomux,
-			     GPIO0D0_MASK | GPIO0D1_MASK |
-			     GPIO0D2_MASK | GPIO0D3_MASK,
-			     GPIO0D0_GPIO << GPIO0D0_SHIFT |
-			     GPIO0D1_GPIO << GPIO0D1_SHIFT |
-			     GPIO0D2_UART4_SOUT << GPIO0D2_SHIFT |
-			     GPIO0D3_UART4_SIN << GPIO0D3_SHIFT);
+			     RK3368_GPIO0D0_MASK | RK3368_GPIO0D1_MASK |
+			     RK3368_GPIO0D2_MASK | RK3368_GPIO0D3_MASK,
+			     RK3368_GPIO0D0_GPIO | RK3368_GPIO0D1_GPIO |
+			     RK3368_GPIO0D2_UART4_SOUT |
+			     RK3368_GPIO0D3_UART4_SIN);
 		break;
 	default:
 		debug("uart id = %d iomux error!\n", uart_id);
#37 lore raw

PATCH 30/52 rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_

Hi Philipp,

Quoted 36 lines · Dr. Philipp Tomsich
Quoted 36 lines · Andy Yan

Hi Philipp:

Quoted 30 lines · Dr. Philipp Tomsich
Quoted 11 lines · Andy Yan

Hi Philipp:

Quoted 5 lines · Philipp Tomsich

The RK3368 GRF header was still defines with a shifted-mask but with non-shifted function selectors for the IOMUX defines. As the RK3368 support is still fresh enough to allow a quick rename, we do this now before having more code use this.

Quoted 6 lines
Quoted 4 lines

As some of the downstream drivers (e.g. the Designware GMAC wrapper) may need to include the grf-header of multiple devices, we rename the various defines for the RK3368 by prefixing them with the device name. This avoids future trouble during driver integration.

Is that really necessary to add such a prefix for all the register definition, just to fit the GMAC dirver?
Maybe the gmac driver can define the platform specific macro in its own code like dwmac-rk in the kernel. Then we can keep the register header file a little tidy.

The problem is not the GMAC driver (although it was the motivation for doing this change), but rather how easy it is to pick up the wrong grf-file and refer to the wrong definitions/values… the conflicts are not through the GMAC-specifc defines but rather through things like the IOMUX masks or (before I moved this to the DDR-driver) things like the defines to enable DRAM in GRF.

Until we find a way to consistently structure things in such a way that
(a) common constructs can be shared (e.g. the masks in the IOMUX)
(b) specific definitions (e.g. the pin-out for a specific device) is not visible outside of its driver
I prefer the names to explicitly refer to each device.
That said, the longer-term plan (especially with a larger number of devices
being supported) needs to include a consistent rework of how (and where)
we manage all these definitions from the grf-header files.

Quoted 5 lines
Quoted 1 line

It's true that many devices use GRF, we also face this condition in the kernel land.And all the drivers in kernel handle this device specific definition in the driver itself(by of_device_id->data or MACRO). And there is also no need to use the grf constructs, the common syscon api will provide you the grf base address. I think this keeps things simple, we don't need to rely on too much of the grf or cru header, maybe some day we can remove the header file, just as clean as the kernel.

The problem is not the base-address of GRF, but rather the need to pull in the register structure (so we can refer to individual registers by name instead of by hard-coded offset): as we pull this in today, the definitions for the various IOMUX entries will also be pulled in, which will cause duplicate definitions.

I really don't like the idea of add the prefix, which end with longer MACRO but no other improve.
I think the GRF is used mostly for the IOMUX, in this case the better solution is
port the kernel rockchip-pinctrl driver in uboot, which not rely on the dtsi instead of header file.

If we do this, we can remove most of the GRF header definition for IOMUX, I can ask David Wu
to do this, but maybe few weeks later.

Thanks,
- Kever

Quoted 703 lines
Quoted 2 lines

On the other hand, add such a prefix of rk3368 breaks the consistency with other rockchip devices.

I do agree that we need to clean this up across all the boards and drivers supported today. As of today, I can not resolve this on a RK3368-only basis, as I’d need to clean up the RK3288 at the same time (and don’t want to do this in a RK3368-focused series that already has way too much going on).

Let’s try to clean this up for the next (i.e. the one after this) merge window. Once we have bit-definitions out of the grf-header, I’ll remove the RK3368_ prefixes...

Quoted 691 lines
Quoted 691 lines
Quoted 691 lines
Quoted 691 lines

---

  arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 617 +++++++++++++-----------
  drivers/pinctrl/rockchip/pinctrl_rk3368.c       |  17 +-
  2 files changed, 334 insertions(+), 300 deletions(-)
arch/arm/include/asm/arch-rockchip/grf_rk3368.h +326 -290
index a438f5d..a97dc1e 100644
@@ -1,4 +1,6 @@
-/* (C) Copyright 2016 Rockchip Electronics Co., Ltd
+/*
+ * (C) Copyright 2016 Rockchip Electronics Co., Ltd
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
   *
   * SPDX-License-Identifier:     GPL-2.0+
   */
@@ -100,315 +102,318 @@ check_member(rk3368_pmu_grf, os_reg[0], 0x200);
    /*GRF_GPIO0C_IOMUX*/
  enum {
-	GPIO0C7_SHIFT		= 14,
-	GPIO0C7_MASK		= 3 << GPIO0C7_SHIFT,
-	GPIO0C7_GPIO		= 0,
-	GPIO0C7_LCDC_D19,
-	GPIO0C7_TRACE_D9,
-	GPIO0C7_UART1_RTSN,
-
-	GPIO0C6_SHIFT           = 12,
-	GPIO0C6_MASK            = 3 << GPIO0C6_SHIFT,
-	GPIO0C6_GPIO            = 0,
-	GPIO0C6_LCDC_D18,
-	GPIO0C6_TRACE_D8,
-	GPIO0C6_UART1_CTSN,
-
-	GPIO0C5_SHIFT           = 10,
-	GPIO0C5_MASK            = 3 << GPIO0C5_SHIFT,
-	GPIO0C5_GPIO            = 0,
-	GPIO0C5_LCDC_D17,
-	GPIO0C5_TRACE_D7,
-	GPIO0C5_UART1_SOUT,
-
-	GPIO0C4_SHIFT           = 8,
-	GPIO0C4_MASK            = 3 << GPIO0C4_SHIFT,
-	GPIO0C4_GPIO            = 0,
-	GPIO0C4_LCDC_D16,
-	GPIO0C4_TRACE_D6,
-	GPIO0C4_UART1_SIN,
-
-	GPIO0C3_SHIFT           = 6,
-	GPIO0C3_MASK            = 3 << GPIO0C3_SHIFT,
-	GPIO0C3_GPIO            = 0,
-	GPIO0C3_LCDC_D15,
-	GPIO0C3_TRACE_D5,
-	GPIO0C3_MCU_JTAG_TDO,
-
-	GPIO0C2_SHIFT           = 4,
-	GPIO0C2_MASK            = 3 << GPIO0C2_SHIFT,
-	GPIO0C2_GPIO            = 0,
-	GPIO0C2_LCDC_D14,
-	GPIO0C2_TRACE_D4,
-	GPIO0C2_MCU_JTAG_TDI,
-
-	GPIO0C1_SHIFT           = 2,
-	GPIO0C1_MASK            = 3 << GPIO0C1_SHIFT,
-	GPIO0C1_GPIO            = 0,
-	GPIO0C1_LCDC_D13,
-	GPIO0C1_TRACE_D3,
-	GPIO0C1_MCU_JTAG_TRTSN,
-
-	GPIO0C0_SHIFT           = 0,
-	GPIO0C0_MASK            = 3 << GPIO0C0_SHIFT,
-	GPIO0C0_GPIO            = 0,
-	GPIO0C0_LCDC_D12,
-	GPIO0C0_TRACE_D2,
-	GPIO0C0_MCU_JTAG_TDO,
+	RK3368_GPIO0C7_MASK	       = GENMASK(15, 14),
+	RK3368_GPIO0C7_GPIO	       = 0,
+	RK3368_GPIO0C7_LCDC_D19        = (1 << 14),
+	RK3368_GPIO0C7_TRACE_D9        = (2 << 14),
+	RK3368_GPIO0C7_UART1_RTSN      = (3 << 14),
+
+	RK3368_GPIO0C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0C6_GPIO            = 0,
+	RK3368_GPIO0C6_LCDC_D18        = (1 << 12),
+	RK3368_GPIO0C6_TRACE_D8        = (2 << 12),
+	RK3368_GPIO0C6_UART1_CTSN      = (3 << 12),
+
+	RK3368_GPIO0C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0C5_GPIO            = 0,
+	RK3368_GPIO0C5_LCDC_D17        = (1 << 10),
+	RK3368_GPIO0C5_TRACE_D7        = (2 << 10),
+	RK3368_GPIO0C5_UART1_SOUT      = (3 << 10),
+
+	RK3368_GPIO0C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0C4_GPIO            = 0,
+	RK3368_GPIO0C4_LCDC_D16        = (1 << 8),
+	RK3368_GPIO0C4_TRACE_D6        = (2 << 8),
+	RK3368_GPIO0C4_UART1_SIN       = (3 << 8),
+
+	RK3368_GPIO0C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0C3_GPIO            = 0,
+	RK3368_GPIO0C3_LCDC_D15        = (1 << 6),
+	RK3368_GPIO0C3_TRACE_D5        = (2 << 6),
+	RK3368_GPIO0C3_MCU_JTAG_TDO    = (3 << 6),
+
+	RK3368_GPIO0C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0C2_GPIO            = 0,
+	RK3368_GPIO0C2_LCDC_D14        = (1 << 4),
+	RK3368_GPIO0C2_TRACE_D4        = (2 << 4),
+	RK3368_GPIO0C2_MCU_JTAG_TDI    = (3 << 4),
+
+	RK3368_GPIO0C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0C1_GPIO            = 0,
+	RK3368_GPIO0C1_LCDC_D13        = (1 << 2),
+	RK3368_GPIO0C1_TRACE_D3        = (2 << 2),
+	RK3368_GPIO0C1_MCU_JTAG_TRTSN  = (3 << 2),
+
+	RK3368_GPIO0C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0C0_GPIO            = 0,
+	RK3368_GPIO0C0_LCDC_D12        = (1 << 0),
+	RK3368_GPIO0C0_TRACE_D2        = (2 << 0),
+	RK3368_GPIO0C0_MCU_JTAG_TDO    = (3 << 0),
  };
    /*GRF_GPIO0D_IOMUX*/
  enum {
-	GPIO0D7_SHIFT           = 14,
-	GPIO0D7_MASK            = 3 << GPIO0D7_SHIFT,
-	GPIO0D7_GPIO            = 0,
-	GPIO0D7_LCDC_DCLK,
-	GPIO0D7_TRACE_CTL,
-	GPIO0D7_PMU_DEBUG5,
-
-	GPIO0D6_SHIFT           = 12,
-	GPIO0D6_MASK            = 3 << GPIO0D6_SHIFT,
-	GPIO0D6_GPIO            = 0,
-	GPIO0D6_LCDC_DEN,
-	GPIO0D6_TRACE_CLK,
-	GPIO0D6_PMU_DEBUG4,
-
-	GPIO0D5_SHIFT           = 10,
-	GPIO0D5_MASK            = 3 << GPIO0D5_SHIFT,
-	GPIO0D5_GPIO            = 0,
-	GPIO0D5_LCDC_VSYNC,
-	GPIO0D5_TRACE_D15,
-	GPIO0D5_PMU_DEBUG3,
-
-	GPIO0D4_SHIFT           = 8,
-	GPIO0D4_MASK            = 3 << GPIO0D4_SHIFT,
-	GPIO0D4_GPIO            = 0,
-	GPIO0D4_LCDC_HSYNC,
-	GPIO0D4_TRACE_D14,
-	GPIO0D4_PMU_DEBUG2,
-
-	GPIO0D3_SHIFT           = 6,
-	GPIO0D3_MASK            = 3 << GPIO0D3_SHIFT,
-	GPIO0D3_GPIO            = 0,
-	GPIO0D3_LCDC_D23,
-	GPIO0D3_TRACE_D13,
-	GPIO0D3_UART4_SIN,
-
-	GPIO0D2_SHIFT           = 4,
-	GPIO0D2_MASK            = 3 << GPIO0D2_SHIFT,
-	GPIO0D2_GPIO            = 0,
-	GPIO0D2_LCDC_D22,
-	GPIO0D2_TRACE_D12,
-	GPIO0D2_UART4_SOUT,
-
-	GPIO0D1_SHIFT           = 2,
-	GPIO0D1_MASK            = 3 << GPIO0D1_SHIFT,
-	GPIO0D1_GPIO            = 0,
-	GPIO0D1_LCDC_D21,
-	GPIO0D1_TRACE_D11,
-	GPIO0D1_UART4_RTSN,
-
-	GPIO0D0_SHIFT           = 0,
-	GPIO0D0_MASK            = 3 << GPIO0D0_SHIFT,
-	GPIO0D0_GPIO            = 0,
-	GPIO0D0_LCDC_D20,
-	GPIO0D0_TRACE_D10,
-	GPIO0D0_UART4_CTSN,
+	RK3368_GPIO0D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO0D7_GPIO            = 0,
+	RK3368_GPIO0D7_LCDC_DCLK       = (1 << 14),
+	RK3368_GPIO0D7_TRACE_CTL       = (2 << 14),
+	RK3368_GPIO0D7_PMU_DEBUG5      = (3 << 14),
+
+	RK3368_GPIO0D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0D6_GPIO            = 0,
+	RK3368_GPIO0D6_LCDC_DEN        = (1 << 12),
+	RK3368_GPIO0D6_TRACE_CLK       = (2 << 12),
+	RK3368_GPIO0D6_PMU_DEBUG4      = (3 << 12),
+
+	RK3368_GPIO0D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0D5_GPIO            = 0,
+	GPIO0D5_LCDC_VSYNC             = (1 << 10),
+	RK3368_GPIO0D5_TRACE_D15       = (2 << 10),
+	RK3368_GPIO0D5_PMU_DEBUG3      = (3 << 10),
+
+	RK3368_GPIO0D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0D4_GPIO            = 0,
+	RK3368_GPIO0D4_LCDC_HSYNC      = (1 << 8),
+	RK3368_GPIO0D4_TRACE_D14       = (2 << 8),
+	RK3368_GPIO0D4_PMU_DEBUG2      = (3 << 8),
+
+	RK3368_GPIO0D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0D3_GPIO            = 0,
+	RK3368_GPIO0D3_LCDC_D23        = (1 << 6),
+	RK3368_GPIO0D3_TRACE_D13       = (2 << 6),
+	RK3368_GPIO0D3_UART4_SIN       = (3 << 6),
+
+	RK3368_GPIO0D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0D2_GPIO            = 0,
+	RK3368_GPIO0D2_LCDC_D22        = (1 << 4),
+	RK3368_GPIO0D2_TRACE_D12       = (2 << 4),
+	RK3368_GPIO0D2_UART4_SOUT      = (3 << 4),
+
+	RK3368_GPIO0D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0D1_GPIO            = 0,
+	RK3368_GPIO0D1_LCDC_D21        = (1 << 2),
+	RK3368_GPIO0D1_TRACE_D11       = (2 << 2),
+	RK3368_GPIO0D1_UART4_RTSN      = (3 << 2),
+
+	RK3368_GPIO0D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0D0_GPIO            = 0,
+	RK3368_GPIO0D0_LCDC_D20        = (1 << 0),
+	RK3368_GPIO0D0_TRACE_D10       = (2 << 0),
+	RK3368_GPIO0D0_UART4_CTSN      = (3 << 0),
  };
    /*GRF_GPIO2A_IOMUX*/
  enum {
-	GPIO2A7_SHIFT           = 14,
-	GPIO2A7_MASK            = 3 << GPIO2A7_SHIFT,
-	GPIO2A7_GPIO            = 0,
-	GPIO2A7_SDMMC0_D2,
-	GPIO2A7_JTAG_TCK,
-
-	GPIO2A6_SHIFT           = 12,
-	GPIO2A6_MASK            = 3 << GPIO2A6_SHIFT,
-	GPIO2A6_GPIO            = 0,
-	GPIO2A6_SDMMC0_D1,
-	GPIO2A6_UART2_SIN,
-
-	GPIO2A5_SHIFT           = 10,
-	GPIO2A5_MASK            = 3 << GPIO2A5_SHIFT,
-	GPIO2A5_GPIO            = 0,
-	GPIO2A5_SDMMC0_D0,
-	GPIO2A5_UART2_SOUT,
-
-	GPIO2A4_SHIFT           = 8,
-	GPIO2A4_MASK            = 3 << GPIO2A4_SHIFT,
-	GPIO2A4_GPIO            = 0,
-	GPIO2A4_FLASH_DQS,
-	GPIO2A4_EMMC_CLKO,
-
-	GPIO2A3_SHIFT           = 6,
-	GPIO2A3_MASK            = 3 << GPIO2A3_SHIFT,
-	GPIO2A3_GPIO            = 0,
-	GPIO2A3_FLASH_CSN3,
-	GPIO2A3_EMMC_RSTNO,
-
-	GPIO2A2_SHIFT           = 4,
-	GPIO2A2_MASK            = 3 << GPIO2A2_SHIFT,
-	GPIO2A2_GPIO           = 0,
-	GPIO2A2_FLASH_CSN2,
-
-	GPIO2A1_SHIFT           = 2,
-	GPIO2A1_MASK            = 3 << GPIO2A1_SHIFT,
-	GPIO2A1_GPIO            = 0,
-	GPIO2A1_FLASH_CSN1,
-
-	GPIO2A0_SHIFT           = 0,
-	GPIO2A0_MASK            = 3 << GPIO2A0_SHIFT,
-	GPIO2A0_GPIO            = 0,
-	GPIO2A0_FLASH_CSN0,
+	RK3368_GPIO2A7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2A7_GPIO            = 0,
+	RK3368_GPIO2A7_SDMMC0_D2       = (1 << 14),
+	RK3368_GPIO2A7_JTAG_TCK        = (2 << 14),
+
+	RK3368_GPIO2A6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2A6_GPIO            = 0,
+	RK3368_GPIO2A6_SDMMC0_D1       = (1 << 12),
+	RK3368_GPIO2A6_UART2_SIN       = (2 << 12),
+
+	RK3368_GPIO2A5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2A5_GPIO            = 0,
+	RK3368_GPIO2A5_SDMMC0_D0       = (1 << 10),
+	RK3368_GPIO2A5_UART2_SOUT      = (2 << 10),
+
+	RK3368_GPIO2A4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2A4_RK3368_GPIO     = 0,
+	RK3368_GPIO2A4_FLASH_DQS       = (1 << 8),
+	RK3368_GPIO2A4_EMMC_CLKOUT     = (2 << 8),
+
+	RK3368_GPIO2A3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2A3_GPIO            = 0,
+	RK3368_GPIO2A3_FLASH_CSN3      = (1 << 6),
+	RK3368_GPIO2A3_EMMC_RSTNOUT    = (2 << 6),
+
+	RK3368_GPIO2A2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2A2_GPIO            = 0,
+	RK3368_GPIO2A2_FLASH_CSN2      = (1 << 4),
+
+	RK3368_GPIO2A1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2A1_GPIO            = 0,
+	RK3368_GPIO2A1_FLASH_CSN1      = (1 << 2),
+
+	RK3368_GPIO2A0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2A0_GPIO            = 0,
+	RK3368_GPIO2A0_FLASH_CSN0      = (1 << 0),
  };
  -/*GRF_GPIO2D_IOMUX*/
+/*GRF_RK3368_GPIO2D_IOMUX*/
  enum {
-	GPIO2D7_SHIFT           = 14,
-	GPIO2D7_MASK            = 3 << GPIO2D7_SHIFT,
-	GPIO2D7_GPIO            = 0,
-	GPIO2D7_SDIO0_D3,
-
-	GPIO2D6_SHIFT           = 12,
-	GPIO2D6_MASK            = 3 << GPIO2D6_SHIFT,
-	GPIO2D6_GPIO            = 0,
-	GPIO2D6_SDIO0_D2,
-
-	GPIO2D5_SHIFT           = 10,
-	GPIO2D5_MASK            = 3 << GPIO2D5_SHIFT,
-	GPIO2D5_GPIO            = 0,
-	GPIO2D5_SDIO0_D1,
-
-	GPIO2D4_SHIFT           = 8,
-	GPIO2D4_MASK            = 3 << GPIO2D4_SHIFT,
-	GPIO2D4_GPIO            = 0,
-	GPIO2D4_SDIO0_D0,
-
-	GPIO2D3_SHIFT           = 6,
-	GPIO2D3_MASK            = 3 << GPIO2D3_SHIFT,
-	GPIO2D3_GPIO            = 0,
-	GPIO2D3_UART0_RTS0,
-
-	GPIO2D2_SHIFT           = 4,
-	GPIO2D2_MASK            = 3 << GPIO2D2_SHIFT,
-	GPIO2D2_GPIO            = 0,
-	GPIO2D2_UART0_CTS0,
-
-	GPIO2D1_SHIFT           = 2,
-	GPIO2D1_MASK            = 3 << GPIO2D1_SHIFT,
-	GPIO2D1_GPIO            = 0,
-	GPIO2D1_UART0_SOUT,
-
-	GPIO2D0_SHIFT           = 0,
-	GPIO2D0_MASK            = 3 << GPIO2D0_SHIFT,
-	GPIO2D0_GPIO            = 0,
-	GPIO2D0_UART0_SIN,
+	RK3368_GPIO2D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2D7_GPIO            = 0,
+	RK3368_GPIO2D7_SDIO0_D3        = (1 << 14),
+
+	RK3368_GPIO2D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2D6_GPIO            = 0,
+	RK3368_GPIO2D6_SDIO0_D2        = (1 << 12),
+
+	RK3368_GPIO2D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2D5_GPIO            = 0,
+	RK3368_GPIO2D5_SDIO0_D1        = (1 << 10),
+
+	RK3368_GPIO2D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2D4_GPIO            = 0,
+	RK3368_GPIO2D4_SDIO0_D0        = (1 << 8),
+
+	RK3368_GPIO2D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2D3_GPIO            = 0,
+	RK3368_GPIO2D3_UART0_RTS0      = (1 << 6),
+
+	RK3368_GPIO2D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2D2_GPIO            = 0,
+	RK3368_GPIO2D2_UART0_CTS0      = (1 << 4),
+
+	RK3368_GPIO2D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2D1_GPIO            = 0,
+	RK3368_GPIO2D1_UART0_SOUT      = (1 << 2),
+
+	RK3368_GPIO2D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2D0_GPIO            = 0,
+	RK3368_GPIO2D0_UART0_SIN       = (1 << 0),
+};
+
+/* GRF_GPIO1C_IOMUX */
+enum {
+	RK3368_GPIO1C7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO1C7_GPIO            = 0,
+	RK3368_GPIO1C7_EMMC_DATA5      = (2 << 14),
+
+	RK3368_GPIO1C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO1C6_GPIO            = 0,
+	RK3368_GPIO1C6_EMMC_DATA4      = (2 << 12),
+
+	RK3368_GPIO1C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO1C5_GPIO            = 0,
+	RK3368_GPIO1C5_EMMC_DATA3      = (2 << 10),
+
+	RK3368_GPIO1C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO1C4_GPIO            = 0,
+	RK3368_GPIO1C4_EMMC_DATA2      = (2 << 8),
+
+	RK3368_GPIO1C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1C3_GPIO            = 0,
+	RK3368_GPIO1C3_EMMC_DATA1      = (2 << 6),
+
+	RK3368_GPIO1C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1C2_GPIO            = 0,
+	RK3368_GPIO1C2_EMMC_DATA0      = (2 << 4),
+};
+
+/* GRF_GPIO1D_IOMUX*/
+enum {
+	RK3368_GPIO1D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1D3_GPIO            = 0,
+	RK3368_GPIO1D3_EMMC_PWREN      = (2 << 6),
+
+	RK3368_GPIO1D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1D2_GPIO            = 0,
+	RK3368_GPIO1D2_EMMC_CMD        = (2 << 4),
+
+	RK3368_GPIO1D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO1D1_GPIO            = 0,
+	RK3368_GPIO1D1_EMMC_DATA7      = (2 << 2),
+
+	RK3368_GPIO1D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO1D0_GPIO            = 0,
+	RK3368_GPIO1D0_EMMC_DATA6      = (2 << 0),
+};
+
+
+/*GRF_GPIO3B_IOMUX*/
+enum {
+	RK3368_GPIO3B7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO3B7_GPIO            = 0,
+	RK3368_GPIO3B7_MAC_RXD0        = (1 << 14),
+
+	RK3368_GPIO3B6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3B6_GPIO            = 0,
+	RK3368_GPIO3B6_MAC_TXD3        = (1 << 12),
+
+	RK3368_GPIO3B5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3B5_GPIO            = 0,
+	RK3368_GPIO3B5_MAC_TXEN        = (1 << 10),
+
+	RK3368_GPIO3B4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3B4_GPIO            = 0,
+	RK3368_GPIO3B4_MAC_COL         = (1 << 8),
+
+	RK3368_GPIO3B3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3B3_GPIO            = 0,
+	RK3368_GPIO3B3_MAC_CRS         = (1 << 6),
+
+	RK3368_GPIO3B2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3B2_GPIO            = 0,
+	RK3368_GPIO3B2_MAC_TXD2        = (1 << 4),
+
+	RK3368_GPIO3B1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3B1_GPIO            = 0,
+	RK3368_GPIO3B1_MAC_TXD1        = (1 << 2),
+
+	RK3368_GPIO3B0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3B0_GPIO            = 0,
+	RK3368_GPIO3B0_MAC_TXD0        = (1 << 0),
+	RK3368_GPIO3B0_PWM0            = (2 << 0),
  };
    /*GRF_GPIO3C_IOMUX*/
  enum {
-	GPIO3C7_SHIFT           = 14,
-	GPIO3C7_MASK            = 3 << GPIO3C7_SHIFT,
-	GPIO3C7_GPIO            = 0,
-	GPIO3C7_EDPHDMI_CECINOUT,
-	GPIO3C7_ISP_FLASHTRIGIN,
-
-	GPIO3C6_SHIFT           = 12,
-	GPIO3C6_MASK            = 3 << GPIO3C6_SHIFT,
-	GPIO3C6_GPIO            = 0,
-	GPIO3C6_MAC_CLK,
-	GPIO3C6_ISP_SHUTTERTRIG,
-
-	GPIO3C5_SHIFT           = 10,
-	GPIO3C5_MASK            = 3 << GPIO3C5_SHIFT,
-	GPIO3C5_GPIO            = 0,
-	GPIO3C5_MAC_RXER,
-	GPIO3C5_ISP_PRELIGHTTRIG,
-
-	GPIO3C4_SHIFT           = 8,
-	GPIO3C4_MASK            = 3 << GPIO3C4_SHIFT,
-	GPIO3C4_GPIO            = 0,
-	GPIO3C4_MAC_RXDV,
-	GPIO3C4_ISP_FLASHTRIGOUT,
-
-	GPIO3C3_SHIFT           = 6,
-	GPIO3C3_MASK            = 3 << GPIO3C3_SHIFT,
-	GPIO3C3_GPIO            = 0,
-	GPIO3C3_MAC_RXDV,
-	GPIO3C3_EMMC_RSTNO,
-
-	GPIO3C2_SHIFT           = 4,
-	GPIO3C2_MASK            = 3 << GPIO3C2_SHIFT,
-	GPIO3C2_MAC_MDC            = 0,
-	GPIO3C2_ISP_SHUTTEREN,
-
-	GPIO3C1_SHIFT           = 2,
-	GPIO3C1_MASK            = 3 << GPIO3C1_SHIFT,
-	GPIO3C1_GPIO            = 0,
-	GPIO3C1_MAC_RXD2,
-	GPIO3C1_UART3_RTSN,
-
-	GPIO3C0_SHIFT           = 0,
-	GPIO3C0_MASK            = 3 << GPIO3C0_SHIFT,
-	GPIO3C0_GPIO            = 0,
-	GPIO3C0_MAC_RXD1,
-	GPIO3C0_UART3_CTSN,
-	GPIO3C0_GPS_RFCLK,
+	RK3368_GPIO3C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3C6_GPIO            = 0,
+	RK3368_GPIO3C6_MAC_CLK         = (1 << 12),
+
+	RK3368_GPIO3C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3C5_GPIO            = 0,
+	RK3368_GPIO3C5_MAC_RXEN        = (1 << 10),
+
+	RK3368_GPIO3C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3C4_GPIO            = 0,
+	RK3368_GPIO3C4_MAC_RXDV        = (1 << 8),
+
+	RK3368_GPIO3C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3C3_GPIO            = 0,
+	RK3368_GPIO3C3_MAC_MDC         = (1 << 6),
+
+	RK3368_GPIO3C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3C2_GPIO            = 0,
+	RK3368_GPIO3C2_MAC_RXD3        = (1 << 4),
+
+	RK3368_GPIO3C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3C1_GPIO            = 0,
+	RK3368_GPIO3C1_MAC_RXD2        = (1 << 2),
+
+	RK3368_GPIO3C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3C0_GPIO            = 0,
+	RK3368_GPIO3C0_MAC_RXD1        = (1 << 0),
  };
    /*GRF_GPIO3D_IOMUX*/
  enum {
-	GPIO3D7_SHIFT           = 14,
-	GPIO3D7_MASK            = 3 << GPIO3D7_SHIFT,
-	GPIO3D7_GPIO            = 0,
-	GPIO3D7_SC_VCC18V,
-	GPIO3D7_I2C2_SDA,
-	GPIO3D7_GPUJTAG_TCK,
-
-	GPIO3D6_SHIFT           = 12,
-	GPIO3D6_MASK            = 3 << GPIO3D6_SHIFT,
-	GPIO3D6_GPIO            = 0,
-	GPIO3D6_IR_TX,
-	GPIO3D6_UART3_SOUT,
-	GPIO3D6_PWM3,
-
-	GPIO3D5_SHIFT           = 10,
-	GPIO3D5_MASK            = 3 << GPIO3D5_SHIFT,
-	GPIO3D5_GPIO            = 0,
-	GPIO3D5_IR_RX,
-	GPIO3D5_UART3_SIN,
-
-	GPIO3D4_SHIFT           = 8,
-	GPIO3D4_MASK            = 3 << GPIO3D4_SHIFT,
-	GPIO3D4_GPIO            = 0,
-	GPIO3D4_MAC_TXCLKOUT,
-	GPIO3D4_SPI1_CSN1,
-
-	GPIO3D3_SHIFT           = 6,
-	GPIO3D3_MASK            = 3 << GPIO3D3_SHIFT,
-	GPIO3D3_GPIO            = 0,
-	GPIO3D3_HDMII2C_SCL,
-	GPIO3D3_I2C5_SCL,
-
-	GPIO3D2_SHIFT           = 4,
-	GPIO3D2_MASK            = 3 << GPIO3D2_SHIFT,
-	GPIO3D2_GPIO            = 0,
-	GPIO3D2_HDMII2C_SDA,
-	GPIO3D2_I2C5_SDA,
-
-	GPIO3D1_SHIFT           = 2,
-	GPIO3D1_MASK            = 3 << GPIO3D1_SHIFT,
-	GPIO3D1_GPIO            = 0,
-	GPIO3D1_MAC_RXCLKIN,
-	GPIO3D1_I2C4_SCL,
-
-	GPIO3D0_SHIFT           = 0,
-	GPIO3D0_MASK            = 3 << GPIO3D0_SHIFT,
-	GPIO3D0_GPIO            = 0,
-	GPIO3D0_MAC_MDIO,
-	GPIO3D0_I2C4_SDA,
+	RK3368_GPIO3D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3D4_GPIO            = 0,
+	RK3368_GPIO3D4_MAC_TXCLK       = (1 << 8),
+
+	RK3368_GPIO3D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3D1_GPIO            = 0,
+	RK3368_GPIO3D1_MAC_RXCLK       = (1 << 2),
+
+	RK3368_GPIO3D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3D0_GPIO            = 0,
+	RK3368_GPIO3D0_MAC_MDIO        = (1 << 0),
+};
+
+/* GRF_SOC_CON0 */
+enum {
+	NOC_RSP_ERR_STALL = BIT(9),
+	MOBILE_DDR_SEL = BIT(4),
+	DDR0_16BIT_EN = BIT(3),
+	MSCH0_MAINDDR3_DDR3 = BIT(2),
+	MSCH0_MAINPARTIALPOP = BIT(1),
+	UPCTL_C_ACTIVE = BIT(0),
  };
    /*GRF_SOC_CON11/12/13*/
@@ -440,4 +445,34 @@ enum {
  	MCU_CODE_BASE_BIT31_BIT28_SHIFT		= 0,
  	MCU_CODE_BASE_BIT31_BIT28_MASK		= GENMASK(3, 0),
  };
+
+/*GRF_SOC_CON15*/
+enum {
+	RK3368_GMAC_PHY_INTF_SEL_RGMII = 1 << 9,
+	RK3368_GMAC_PHY_INTF_SEL_MASK = GENMASK(11, 9),
+	RK3368_RMII_MODE_MASK  = BIT(6),
+	RK3368_RMII_MODE       = BIT(6),
+	RK3368_GMAC_CLK_SEL_2_5M = 2 << 4,
+	RK3368_GMAC_CLK_SEL_25M = 3 << 4,
+	RK3368_GMAC_CLK_SEL_125M = 0 << 4,
+	RK3368_GMAC_CLK_SEL_MASK = GENMASK(5, 4),
+};
+
+/* GRF_SOC_CON16 */
+enum {
+	RK3368_RXCLK_DLY_ENA_GMAC_MASK = BIT(15),
+	RK3368_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(15),
+
+	RK3368_TXCLK_DLY_ENA_GMAC_MASK = BIT(7),
+	RK3368_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(7),
+
+	RK3368_CLK_RX_DL_CFG_GMAC_SHIFT = 8,
+	RK3368_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(14, 8),
+
+	RK3368_CLK_TX_DL_CFG_GMAC_SHIFT = 0,
+	RK3368_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
+};
+
  #endif
drivers/pinctrl/rockchip/pinctrl_rk3368.c +8 -9
index bdf0758..b77c5ab 100644
@@ -30,9 +30,9 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
  	switch (uart_id) {
  	case PERIPH_ID_UART2:
  		rk_clrsetreg(&grf->gpio2a_iomux,
-			     GPIO2A6_MASK | GPIO2A5_MASK,
-			     GPIO2A6_UART2_SIN << GPIO2A6_SHIFT |
-			     GPIO2A5_UART2_SOUT << GPIO2A5_SHIFT);
+			     RK3368_GPIO2A6_MASK | RK3368_GPIO2A5_MASK,
+			     RK3368_GPIO2A6_UART2_SIN |
+			     RK3368_GPIO2A5_UART2_SOUT);
  		break;
  	case PERIPH_ID_UART0:
  		break;
@@ -42,12 +42,11 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
  		break;
  	case PERIPH_ID_UART4:
  		rk_clrsetreg(&pmugrf->gpio0d_iomux,
-			     GPIO0D0_MASK | GPIO0D1_MASK |
-			     GPIO0D2_MASK | GPIO0D3_MASK,
-			     GPIO0D0_GPIO << GPIO0D0_SHIFT |
-			     GPIO0D1_GPIO << GPIO0D1_SHIFT |
-			     GPIO0D2_UART4_SOUT << GPIO0D2_SHIFT |
-			     GPIO0D3_UART4_SIN << GPIO0D3_SHIFT);
+			     RK3368_GPIO0D0_MASK | RK3368_GPIO0D1_MASK |
+			     RK3368_GPIO0D2_MASK | RK3368_GPIO0D3_MASK,
+			     RK3368_GPIO0D0_GPIO | RK3368_GPIO0D1_GPIO |
+			     RK3368_GPIO0D2_UART4_SOUT |
+			     RK3368_GPIO0D3_UART4_SIN);
  		break;
  	default:
  		debug("uart id = %d iomux error!\n", uart_id);
#38 lore raw

PATCH 30/52 rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_

Quoted 49 lines · Kever Yang

Hi Philipp,

Quoted 36 lines · Dr. Philipp Tomsich
Quoted 36 lines · Andy Yan

Hi Philipp:

Quoted 30 lines · Dr. Philipp Tomsich
Quoted 11 lines · Andy Yan

Hi Philipp:

Quoted 5 lines · Philipp Tomsich

The RK3368 GRF header was still defines with a shifted-mask but with non-shifted function selectors for the IOMUX defines. As the RK3368 support is still fresh enough to allow a quick rename, we do this now before having more code use this.

Quoted 6 lines
Quoted 4 lines

As some of the downstream drivers (e.g. the Designware GMAC wrapper) may need to include the grf-header of multiple devices, we rename the various defines for the RK3368 by prefixing them with the device name. This avoids future trouble during driver integration.

Is that really necessary to add such a prefix for all the register definition, just to fit the GMAC dirver?
Maybe the gmac driver can define the platform specific macro in its own code like dwmac-rk in the kernel. Then we can keep the register header file a little tidy.

The problem is not the GMAC driver (although it was the motivation for doing this change), but rather how easy it is to pick up the wrong grf-file and refer to the wrong definitions/values… the conflicts are not through the GMAC-specifc defines but rather through things like the IOMUX masks or (before I moved this to the DDR-driver) things like the defines to enable DRAM in GRF.

Until we find a way to consistently structure things in such a way that
(a) common constructs can be shared (e.g. the masks in the IOMUX)
(b) specific definitions (e.g. the pin-out for a specific device) is not visible outside of its driver
I prefer the names to explicitly refer to each device.
That said, the longer-term plan (especially with a larger number of devices
being supported) needs to include a consistent rework of how (and where)
we manage all these definitions from the grf-header files.

Quoted 5 lines
Quoted 1 line

It's true that many devices use GRF, we also face this condition in the kernel land.And all the drivers in kernel handle this device specific definition in the driver itself(by of_device_id->data or MACRO). And there is also no need to use the grf constructs, the common syscon api will provide you the grf base address. I think this keeps things simple, we don't need to rely on too much of the grf or cru header, maybe some day we can remove the header file, just as clean as the kernel.

The problem is not the base-address of GRF, but rather the need to pull in the register structure (so we can refer to individual registers by name instead of by hard-coded offset): as we pull this in today, the definitions for the various IOMUX entries will also be pulled in, which will cause duplicate definitions.

Quoted 6 lines

I really don't like the idea of add the prefix, which end with longer MACRO but no other improve. I think the GRF is used mostly for the IOMUX, in this case the better solution is port the kernel rockchip-pinctrl driver in uboot, which not rely on the dtsi instead of header file.

If we do this, we can remove most of the GRF header definition for IOMUX, I can ask David Wu to do this, but maybe few weeks later.

As indicated earlier: this is a temporary solution (although we have a local saying that "nothing is more permanent than a temporary solution”) and should remain limited to the RK3368 until we can clean this up across all boards.

Pulling this into the pinctrl drivers is an excellent choice.
Please watch out for board_debug_uart_init(…), which also directly accesses the IOMUX constants and will need to be restructured together with pinctrl drivers.

Thanks!
—Philipp.

Quoted 704 lines

Thanks,
- Kever

Quoted 702 lines
Quoted 2 lines

On the other hand, add such a prefix of rk3368 breaks the consistency with other rockchip devices.

I do agree that we need to clean this up across all the boards and drivers supported today. As of today, I can not resolve this on a RK3368-only basis, as I’d need to clean up the RK3288 at the same time (and don’t want to do this in a RK3368-focused series that already has way too much going on).

Let’s try to clean this up for the next (i.e. the one after this) merge window. Once we have bit-definitions out of the grf-header, I’ll remove the RK3368_ prefixes...

Quoted 691 lines
Quoted 691 lines
Quoted 691 lines
Quoted 691 lines

---

 arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 617 +++++++++++++-----------
 drivers/pinctrl/rockchip/pinctrl_rk3368.c       |  17 +-
 2 files changed, 334 insertions(+), 300 deletions(-)
arch/arm/include/asm/arch-rockchip/grf_rk3368.h +326 -290
index a438f5d..a97dc1e 100644
@@ -1,4 +1,6 @@
-/* (C) Copyright 2016 Rockchip Electronics Co., Ltd
+/*
+ * (C) Copyright 2016 Rockchip Electronics Co., Ltd
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
  *
  * SPDX-License-Identifier:     GPL-2.0+
  */
@@ -100,315 +102,318 @@ check_member(rk3368_pmu_grf, os_reg[0], 0x200);
   /*GRF_GPIO0C_IOMUX*/
 enum {
-	GPIO0C7_SHIFT		= 14,
-	GPIO0C7_MASK		= 3 << GPIO0C7_SHIFT,
-	GPIO0C7_GPIO		= 0,
-	GPIO0C7_LCDC_D19,
-	GPIO0C7_TRACE_D9,
-	GPIO0C7_UART1_RTSN,
-
-	GPIO0C6_SHIFT           = 12,
-	GPIO0C6_MASK            = 3 << GPIO0C6_SHIFT,
-	GPIO0C6_GPIO            = 0,
-	GPIO0C6_LCDC_D18,
-	GPIO0C6_TRACE_D8,
-	GPIO0C6_UART1_CTSN,
-
-	GPIO0C5_SHIFT           = 10,
-	GPIO0C5_MASK            = 3 << GPIO0C5_SHIFT,
-	GPIO0C5_GPIO            = 0,
-	GPIO0C5_LCDC_D17,
-	GPIO0C5_TRACE_D7,
-	GPIO0C5_UART1_SOUT,
-
-	GPIO0C4_SHIFT           = 8,
-	GPIO0C4_MASK            = 3 << GPIO0C4_SHIFT,
-	GPIO0C4_GPIO            = 0,
-	GPIO0C4_LCDC_D16,
-	GPIO0C4_TRACE_D6,
-	GPIO0C4_UART1_SIN,
-
-	GPIO0C3_SHIFT           = 6,
-	GPIO0C3_MASK            = 3 << GPIO0C3_SHIFT,
-	GPIO0C3_GPIO            = 0,
-	GPIO0C3_LCDC_D15,
-	GPIO0C3_TRACE_D5,
-	GPIO0C3_MCU_JTAG_TDO,
-
-	GPIO0C2_SHIFT           = 4,
-	GPIO0C2_MASK            = 3 << GPIO0C2_SHIFT,
-	GPIO0C2_GPIO            = 0,
-	GPIO0C2_LCDC_D14,
-	GPIO0C2_TRACE_D4,
-	GPIO0C2_MCU_JTAG_TDI,
-
-	GPIO0C1_SHIFT           = 2,
-	GPIO0C1_MASK            = 3 << GPIO0C1_SHIFT,
-	GPIO0C1_GPIO            = 0,
-	GPIO0C1_LCDC_D13,
-	GPIO0C1_TRACE_D3,
-	GPIO0C1_MCU_JTAG_TRTSN,
-
-	GPIO0C0_SHIFT           = 0,
-	GPIO0C0_MASK            = 3 << GPIO0C0_SHIFT,
-	GPIO0C0_GPIO            = 0,
-	GPIO0C0_LCDC_D12,
-	GPIO0C0_TRACE_D2,
-	GPIO0C0_MCU_JTAG_TDO,
+	RK3368_GPIO0C7_MASK	       = GENMASK(15, 14),
+	RK3368_GPIO0C7_GPIO	       = 0,
+	RK3368_GPIO0C7_LCDC_D19        = (1 << 14),
+	RK3368_GPIO0C7_TRACE_D9        = (2 << 14),
+	RK3368_GPIO0C7_UART1_RTSN      = (3 << 14),
+
+	RK3368_GPIO0C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0C6_GPIO            = 0,
+	RK3368_GPIO0C6_LCDC_D18        = (1 << 12),
+	RK3368_GPIO0C6_TRACE_D8        = (2 << 12),
+	RK3368_GPIO0C6_UART1_CTSN      = (3 << 12),
+
+	RK3368_GPIO0C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0C5_GPIO            = 0,
+	RK3368_GPIO0C5_LCDC_D17        = (1 << 10),
+	RK3368_GPIO0C5_TRACE_D7        = (2 << 10),
+	RK3368_GPIO0C5_UART1_SOUT      = (3 << 10),
+
+	RK3368_GPIO0C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0C4_GPIO            = 0,
+	RK3368_GPIO0C4_LCDC_D16        = (1 << 8),
+	RK3368_GPIO0C4_TRACE_D6        = (2 << 8),
+	RK3368_GPIO0C4_UART1_SIN       = (3 << 8),
+
+	RK3368_GPIO0C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0C3_GPIO            = 0,
+	RK3368_GPIO0C3_LCDC_D15        = (1 << 6),
+	RK3368_GPIO0C3_TRACE_D5        = (2 << 6),
+	RK3368_GPIO0C3_MCU_JTAG_TDO    = (3 << 6),
+
+	RK3368_GPIO0C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0C2_GPIO            = 0,
+	RK3368_GPIO0C2_LCDC_D14        = (1 << 4),
+	RK3368_GPIO0C2_TRACE_D4        = (2 << 4),
+	RK3368_GPIO0C2_MCU_JTAG_TDI    = (3 << 4),
+
+	RK3368_GPIO0C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0C1_GPIO            = 0,
+	RK3368_GPIO0C1_LCDC_D13        = (1 << 2),
+	RK3368_GPIO0C1_TRACE_D3        = (2 << 2),
+	RK3368_GPIO0C1_MCU_JTAG_TRTSN  = (3 << 2),
+
+	RK3368_GPIO0C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0C0_GPIO            = 0,
+	RK3368_GPIO0C0_LCDC_D12        = (1 << 0),
+	RK3368_GPIO0C0_TRACE_D2        = (2 << 0),
+	RK3368_GPIO0C0_MCU_JTAG_TDO    = (3 << 0),
 };
   /*GRF_GPIO0D_IOMUX*/
 enum {
-	GPIO0D7_SHIFT           = 14,
-	GPIO0D7_MASK            = 3 << GPIO0D7_SHIFT,
-	GPIO0D7_GPIO            = 0,
-	GPIO0D7_LCDC_DCLK,
-	GPIO0D7_TRACE_CTL,
-	GPIO0D7_PMU_DEBUG5,
-
-	GPIO0D6_SHIFT           = 12,
-	GPIO0D6_MASK            = 3 << GPIO0D6_SHIFT,
-	GPIO0D6_GPIO            = 0,
-	GPIO0D6_LCDC_DEN,
-	GPIO0D6_TRACE_CLK,
-	GPIO0D6_PMU_DEBUG4,
-
-	GPIO0D5_SHIFT           = 10,
-	GPIO0D5_MASK            = 3 << GPIO0D5_SHIFT,
-	GPIO0D5_GPIO            = 0,
-	GPIO0D5_LCDC_VSYNC,
-	GPIO0D5_TRACE_D15,
-	GPIO0D5_PMU_DEBUG3,
-
-	GPIO0D4_SHIFT           = 8,
-	GPIO0D4_MASK            = 3 << GPIO0D4_SHIFT,
-	GPIO0D4_GPIO            = 0,
-	GPIO0D4_LCDC_HSYNC,
-	GPIO0D4_TRACE_D14,
-	GPIO0D4_PMU_DEBUG2,
-
-	GPIO0D3_SHIFT           = 6,
-	GPIO0D3_MASK            = 3 << GPIO0D3_SHIFT,
-	GPIO0D3_GPIO            = 0,
-	GPIO0D3_LCDC_D23,
-	GPIO0D3_TRACE_D13,
-	GPIO0D3_UART4_SIN,
-
-	GPIO0D2_SHIFT           = 4,
-	GPIO0D2_MASK            = 3 << GPIO0D2_SHIFT,
-	GPIO0D2_GPIO            = 0,
-	GPIO0D2_LCDC_D22,
-	GPIO0D2_TRACE_D12,
-	GPIO0D2_UART4_SOUT,
-
-	GPIO0D1_SHIFT           = 2,
-	GPIO0D1_MASK            = 3 << GPIO0D1_SHIFT,
-	GPIO0D1_GPIO            = 0,
-	GPIO0D1_LCDC_D21,
-	GPIO0D1_TRACE_D11,
-	GPIO0D1_UART4_RTSN,
-
-	GPIO0D0_SHIFT           = 0,
-	GPIO0D0_MASK            = 3 << GPIO0D0_SHIFT,
-	GPIO0D0_GPIO            = 0,
-	GPIO0D0_LCDC_D20,
-	GPIO0D0_TRACE_D10,
-	GPIO0D0_UART4_CTSN,
+	RK3368_GPIO0D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO0D7_GPIO            = 0,
+	RK3368_GPIO0D7_LCDC_DCLK       = (1 << 14),
+	RK3368_GPIO0D7_TRACE_CTL       = (2 << 14),
+	RK3368_GPIO0D7_PMU_DEBUG5      = (3 << 14),
+
+	RK3368_GPIO0D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO0D6_GPIO            = 0,
+	RK3368_GPIO0D6_LCDC_DEN        = (1 << 12),
+	RK3368_GPIO0D6_TRACE_CLK       = (2 << 12),
+	RK3368_GPIO0D6_PMU_DEBUG4      = (3 << 12),
+
+	RK3368_GPIO0D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO0D5_GPIO            = 0,
+	GPIO0D5_LCDC_VSYNC             = (1 << 10),
+	RK3368_GPIO0D5_TRACE_D15       = (2 << 10),
+	RK3368_GPIO0D5_PMU_DEBUG3      = (3 << 10),
+
+	RK3368_GPIO0D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO0D4_GPIO            = 0,
+	RK3368_GPIO0D4_LCDC_HSYNC      = (1 << 8),
+	RK3368_GPIO0D4_TRACE_D14       = (2 << 8),
+	RK3368_GPIO0D4_PMU_DEBUG2      = (3 << 8),
+
+	RK3368_GPIO0D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO0D3_GPIO            = 0,
+	RK3368_GPIO0D3_LCDC_D23        = (1 << 6),
+	RK3368_GPIO0D3_TRACE_D13       = (2 << 6),
+	RK3368_GPIO0D3_UART4_SIN       = (3 << 6),
+
+	RK3368_GPIO0D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO0D2_GPIO            = 0,
+	RK3368_GPIO0D2_LCDC_D22        = (1 << 4),
+	RK3368_GPIO0D2_TRACE_D12       = (2 << 4),
+	RK3368_GPIO0D2_UART4_SOUT      = (3 << 4),
+
+	RK3368_GPIO0D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO0D1_GPIO            = 0,
+	RK3368_GPIO0D1_LCDC_D21        = (1 << 2),
+	RK3368_GPIO0D1_TRACE_D11       = (2 << 2),
+	RK3368_GPIO0D1_UART4_RTSN      = (3 << 2),
+
+	RK3368_GPIO0D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO0D0_GPIO            = 0,
+	RK3368_GPIO0D0_LCDC_D20        = (1 << 0),
+	RK3368_GPIO0D0_TRACE_D10       = (2 << 0),
+	RK3368_GPIO0D0_UART4_CTSN      = (3 << 0),
 };
   /*GRF_GPIO2A_IOMUX*/
 enum {
-	GPIO2A7_SHIFT           = 14,
-	GPIO2A7_MASK            = 3 << GPIO2A7_SHIFT,
-	GPIO2A7_GPIO            = 0,
-	GPIO2A7_SDMMC0_D2,
-	GPIO2A7_JTAG_TCK,
-
-	GPIO2A6_SHIFT           = 12,
-	GPIO2A6_MASK            = 3 << GPIO2A6_SHIFT,
-	GPIO2A6_GPIO            = 0,
-	GPIO2A6_SDMMC0_D1,
-	GPIO2A6_UART2_SIN,
-
-	GPIO2A5_SHIFT           = 10,
-	GPIO2A5_MASK            = 3 << GPIO2A5_SHIFT,
-	GPIO2A5_GPIO            = 0,
-	GPIO2A5_SDMMC0_D0,
-	GPIO2A5_UART2_SOUT,
-
-	GPIO2A4_SHIFT           = 8,
-	GPIO2A4_MASK            = 3 << GPIO2A4_SHIFT,
-	GPIO2A4_GPIO            = 0,
-	GPIO2A4_FLASH_DQS,
-	GPIO2A4_EMMC_CLKO,
-
-	GPIO2A3_SHIFT           = 6,
-	GPIO2A3_MASK            = 3 << GPIO2A3_SHIFT,
-	GPIO2A3_GPIO            = 0,
-	GPIO2A3_FLASH_CSN3,
-	GPIO2A3_EMMC_RSTNO,
-
-	GPIO2A2_SHIFT           = 4,
-	GPIO2A2_MASK            = 3 << GPIO2A2_SHIFT,
-	GPIO2A2_GPIO           = 0,
-	GPIO2A2_FLASH_CSN2,
-
-	GPIO2A1_SHIFT           = 2,
-	GPIO2A1_MASK            = 3 << GPIO2A1_SHIFT,
-	GPIO2A1_GPIO            = 0,
-	GPIO2A1_FLASH_CSN1,
-
-	GPIO2A0_SHIFT           = 0,
-	GPIO2A0_MASK            = 3 << GPIO2A0_SHIFT,
-	GPIO2A0_GPIO            = 0,
-	GPIO2A0_FLASH_CSN0,
+	RK3368_GPIO2A7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2A7_GPIO            = 0,
+	RK3368_GPIO2A7_SDMMC0_D2       = (1 << 14),
+	RK3368_GPIO2A7_JTAG_TCK        = (2 << 14),
+
+	RK3368_GPIO2A6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2A6_GPIO            = 0,
+	RK3368_GPIO2A6_SDMMC0_D1       = (1 << 12),
+	RK3368_GPIO2A6_UART2_SIN       = (2 << 12),
+
+	RK3368_GPIO2A5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2A5_GPIO            = 0,
+	RK3368_GPIO2A5_SDMMC0_D0       = (1 << 10),
+	RK3368_GPIO2A5_UART2_SOUT      = (2 << 10),
+
+	RK3368_GPIO2A4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2A4_RK3368_GPIO     = 0,
+	RK3368_GPIO2A4_FLASH_DQS       = (1 << 8),
+	RK3368_GPIO2A4_EMMC_CLKOUT     = (2 << 8),
+
+	RK3368_GPIO2A3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2A3_GPIO            = 0,
+	RK3368_GPIO2A3_FLASH_CSN3      = (1 << 6),
+	RK3368_GPIO2A3_EMMC_RSTNOUT    = (2 << 6),
+
+	RK3368_GPIO2A2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2A2_GPIO            = 0,
+	RK3368_GPIO2A2_FLASH_CSN2      = (1 << 4),
+
+	RK3368_GPIO2A1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2A1_GPIO            = 0,
+	RK3368_GPIO2A1_FLASH_CSN1      = (1 << 2),
+
+	RK3368_GPIO2A0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2A0_GPIO            = 0,
+	RK3368_GPIO2A0_FLASH_CSN0      = (1 << 0),
 };
 -/*GRF_GPIO2D_IOMUX*/
+/*GRF_RK3368_GPIO2D_IOMUX*/
 enum {
-	GPIO2D7_SHIFT           = 14,
-	GPIO2D7_MASK            = 3 << GPIO2D7_SHIFT,
-	GPIO2D7_GPIO            = 0,
-	GPIO2D7_SDIO0_D3,
-
-	GPIO2D6_SHIFT           = 12,
-	GPIO2D6_MASK            = 3 << GPIO2D6_SHIFT,
-	GPIO2D6_GPIO            = 0,
-	GPIO2D6_SDIO0_D2,
-
-	GPIO2D5_SHIFT           = 10,
-	GPIO2D5_MASK            = 3 << GPIO2D5_SHIFT,
-	GPIO2D5_GPIO            = 0,
-	GPIO2D5_SDIO0_D1,
-
-	GPIO2D4_SHIFT           = 8,
-	GPIO2D4_MASK            = 3 << GPIO2D4_SHIFT,
-	GPIO2D4_GPIO            = 0,
-	GPIO2D4_SDIO0_D0,
-
-	GPIO2D3_SHIFT           = 6,
-	GPIO2D3_MASK            = 3 << GPIO2D3_SHIFT,
-	GPIO2D3_GPIO            = 0,
-	GPIO2D3_UART0_RTS0,
-
-	GPIO2D2_SHIFT           = 4,
-	GPIO2D2_MASK            = 3 << GPIO2D2_SHIFT,
-	GPIO2D2_GPIO            = 0,
-	GPIO2D2_UART0_CTS0,
-
-	GPIO2D1_SHIFT           = 2,
-	GPIO2D1_MASK            = 3 << GPIO2D1_SHIFT,
-	GPIO2D1_GPIO            = 0,
-	GPIO2D1_UART0_SOUT,
-
-	GPIO2D0_SHIFT           = 0,
-	GPIO2D0_MASK            = 3 << GPIO2D0_SHIFT,
-	GPIO2D0_GPIO            = 0,
-	GPIO2D0_UART0_SIN,
+	RK3368_GPIO2D7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO2D7_GPIO            = 0,
+	RK3368_GPIO2D7_SDIO0_D3        = (1 << 14),
+
+	RK3368_GPIO2D6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO2D6_GPIO            = 0,
+	RK3368_GPIO2D6_SDIO0_D2        = (1 << 12),
+
+	RK3368_GPIO2D5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO2D5_GPIO            = 0,
+	RK3368_GPIO2D5_SDIO0_D1        = (1 << 10),
+
+	RK3368_GPIO2D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO2D4_GPIO            = 0,
+	RK3368_GPIO2D4_SDIO0_D0        = (1 << 8),
+
+	RK3368_GPIO2D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO2D3_GPIO            = 0,
+	RK3368_GPIO2D3_UART0_RTS0      = (1 << 6),
+
+	RK3368_GPIO2D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO2D2_GPIO            = 0,
+	RK3368_GPIO2D2_UART0_CTS0      = (1 << 4),
+
+	RK3368_GPIO2D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO2D1_GPIO            = 0,
+	RK3368_GPIO2D1_UART0_SOUT      = (1 << 2),
+
+	RK3368_GPIO2D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO2D0_GPIO            = 0,
+	RK3368_GPIO2D0_UART0_SIN       = (1 << 0),
+};
+
+/* GRF_GPIO1C_IOMUX */
+enum {
+	RK3368_GPIO1C7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO1C7_GPIO            = 0,
+	RK3368_GPIO1C7_EMMC_DATA5      = (2 << 14),
+
+	RK3368_GPIO1C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO1C6_GPIO            = 0,
+	RK3368_GPIO1C6_EMMC_DATA4      = (2 << 12),
+
+	RK3368_GPIO1C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO1C5_GPIO            = 0,
+	RK3368_GPIO1C5_EMMC_DATA3      = (2 << 10),
+
+	RK3368_GPIO1C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO1C4_GPIO            = 0,
+	RK3368_GPIO1C4_EMMC_DATA2      = (2 << 8),
+
+	RK3368_GPIO1C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1C3_GPIO            = 0,
+	RK3368_GPIO1C3_EMMC_DATA1      = (2 << 6),
+
+	RK3368_GPIO1C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1C2_GPIO            = 0,
+	RK3368_GPIO1C2_EMMC_DATA0      = (2 << 4),
+};
+
+/* GRF_GPIO1D_IOMUX*/
+enum {
+	RK3368_GPIO1D3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO1D3_GPIO            = 0,
+	RK3368_GPIO1D3_EMMC_PWREN      = (2 << 6),
+
+	RK3368_GPIO1D2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO1D2_GPIO            = 0,
+	RK3368_GPIO1D2_EMMC_CMD        = (2 << 4),
+
+	RK3368_GPIO1D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO1D1_GPIO            = 0,
+	RK3368_GPIO1D1_EMMC_DATA7      = (2 << 2),
+
+	RK3368_GPIO1D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO1D0_GPIO            = 0,
+	RK3368_GPIO1D0_EMMC_DATA6      = (2 << 0),
+};
+
+
+/*GRF_GPIO3B_IOMUX*/
+enum {
+	RK3368_GPIO3B7_MASK            = GENMASK(15, 14),
+	RK3368_GPIO3B7_GPIO            = 0,
+	RK3368_GPIO3B7_MAC_RXD0        = (1 << 14),
+
+	RK3368_GPIO3B6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3B6_GPIO            = 0,
+	RK3368_GPIO3B6_MAC_TXD3        = (1 << 12),
+
+	RK3368_GPIO3B5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3B5_GPIO            = 0,
+	RK3368_GPIO3B5_MAC_TXEN        = (1 << 10),
+
+	RK3368_GPIO3B4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3B4_GPIO            = 0,
+	RK3368_GPIO3B4_MAC_COL         = (1 << 8),
+
+	RK3368_GPIO3B3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3B3_GPIO            = 0,
+	RK3368_GPIO3B3_MAC_CRS         = (1 << 6),
+
+	RK3368_GPIO3B2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3B2_GPIO            = 0,
+	RK3368_GPIO3B2_MAC_TXD2        = (1 << 4),
+
+	RK3368_GPIO3B1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3B1_GPIO            = 0,
+	RK3368_GPIO3B1_MAC_TXD1        = (1 << 2),
+
+	RK3368_GPIO3B0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3B0_GPIO            = 0,
+	RK3368_GPIO3B0_MAC_TXD0        = (1 << 0),
+	RK3368_GPIO3B0_PWM0            = (2 << 0),
 };
   /*GRF_GPIO3C_IOMUX*/
 enum {
-	GPIO3C7_SHIFT           = 14,
-	GPIO3C7_MASK            = 3 << GPIO3C7_SHIFT,
-	GPIO3C7_GPIO            = 0,
-	GPIO3C7_EDPHDMI_CECINOUT,
-	GPIO3C7_ISP_FLASHTRIGIN,
-
-	GPIO3C6_SHIFT           = 12,
-	GPIO3C6_MASK            = 3 << GPIO3C6_SHIFT,
-	GPIO3C6_GPIO            = 0,
-	GPIO3C6_MAC_CLK,
-	GPIO3C6_ISP_SHUTTERTRIG,
-
-	GPIO3C5_SHIFT           = 10,
-	GPIO3C5_MASK            = 3 << GPIO3C5_SHIFT,
-	GPIO3C5_GPIO            = 0,
-	GPIO3C5_MAC_RXER,
-	GPIO3C5_ISP_PRELIGHTTRIG,
-
-	GPIO3C4_SHIFT           = 8,
-	GPIO3C4_MASK            = 3 << GPIO3C4_SHIFT,
-	GPIO3C4_GPIO            = 0,
-	GPIO3C4_MAC_RXDV,
-	GPIO3C4_ISP_FLASHTRIGOUT,
-
-	GPIO3C3_SHIFT           = 6,
-	GPIO3C3_MASK            = 3 << GPIO3C3_SHIFT,
-	GPIO3C3_GPIO            = 0,
-	GPIO3C3_MAC_RXDV,
-	GPIO3C3_EMMC_RSTNO,
-
-	GPIO3C2_SHIFT           = 4,
-	GPIO3C2_MASK            = 3 << GPIO3C2_SHIFT,
-	GPIO3C2_MAC_MDC            = 0,
-	GPIO3C2_ISP_SHUTTEREN,
-
-	GPIO3C1_SHIFT           = 2,
-	GPIO3C1_MASK            = 3 << GPIO3C1_SHIFT,
-	GPIO3C1_GPIO            = 0,
-	GPIO3C1_MAC_RXD2,
-	GPIO3C1_UART3_RTSN,
-
-	GPIO3C0_SHIFT           = 0,
-	GPIO3C0_MASK            = 3 << GPIO3C0_SHIFT,
-	GPIO3C0_GPIO            = 0,
-	GPIO3C0_MAC_RXD1,
-	GPIO3C0_UART3_CTSN,
-	GPIO3C0_GPS_RFCLK,
+	RK3368_GPIO3C6_MASK            = GENMASK(13, 12),
+	RK3368_GPIO3C6_GPIO            = 0,
+	RK3368_GPIO3C6_MAC_CLK         = (1 << 12),
+
+	RK3368_GPIO3C5_MASK            = GENMASK(11, 10),
+	RK3368_GPIO3C5_GPIO            = 0,
+	RK3368_GPIO3C5_MAC_RXEN        = (1 << 10),
+
+	RK3368_GPIO3C4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3C4_GPIO            = 0,
+	RK3368_GPIO3C4_MAC_RXDV        = (1 << 8),
+
+	RK3368_GPIO3C3_MASK            = GENMASK(7, 6),
+	RK3368_GPIO3C3_GPIO            = 0,
+	RK3368_GPIO3C3_MAC_MDC         = (1 << 6),
+
+	RK3368_GPIO3C2_MASK            = GENMASK(5, 4),
+	RK3368_GPIO3C2_GPIO            = 0,
+	RK3368_GPIO3C2_MAC_RXD3        = (1 << 4),
+
+	RK3368_GPIO3C1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3C1_GPIO            = 0,
+	RK3368_GPIO3C1_MAC_RXD2        = (1 << 2),
+
+	RK3368_GPIO3C0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3C0_GPIO            = 0,
+	RK3368_GPIO3C0_MAC_RXD1        = (1 << 0),
 };
   /*GRF_GPIO3D_IOMUX*/
 enum {
-	GPIO3D7_SHIFT           = 14,
-	GPIO3D7_MASK            = 3 << GPIO3D7_SHIFT,
-	GPIO3D7_GPIO            = 0,
-	GPIO3D7_SC_VCC18V,
-	GPIO3D7_I2C2_SDA,
-	GPIO3D7_GPUJTAG_TCK,
-
-	GPIO3D6_SHIFT           = 12,
-	GPIO3D6_MASK            = 3 << GPIO3D6_SHIFT,
-	GPIO3D6_GPIO            = 0,
-	GPIO3D6_IR_TX,
-	GPIO3D6_UART3_SOUT,
-	GPIO3D6_PWM3,
-
-	GPIO3D5_SHIFT           = 10,
-	GPIO3D5_MASK            = 3 << GPIO3D5_SHIFT,
-	GPIO3D5_GPIO            = 0,
-	GPIO3D5_IR_RX,
-	GPIO3D5_UART3_SIN,
-
-	GPIO3D4_SHIFT           = 8,
-	GPIO3D4_MASK            = 3 << GPIO3D4_SHIFT,
-	GPIO3D4_GPIO            = 0,
-	GPIO3D4_MAC_TXCLKOUT,
-	GPIO3D4_SPI1_CSN1,
-
-	GPIO3D3_SHIFT           = 6,
-	GPIO3D3_MASK            = 3 << GPIO3D3_SHIFT,
-	GPIO3D3_GPIO            = 0,
-	GPIO3D3_HDMII2C_SCL,
-	GPIO3D3_I2C5_SCL,
-
-	GPIO3D2_SHIFT           = 4,
-	GPIO3D2_MASK            = 3 << GPIO3D2_SHIFT,
-	GPIO3D2_GPIO            = 0,
-	GPIO3D2_HDMII2C_SDA,
-	GPIO3D2_I2C5_SDA,
-
-	GPIO3D1_SHIFT           = 2,
-	GPIO3D1_MASK            = 3 << GPIO3D1_SHIFT,
-	GPIO3D1_GPIO            = 0,
-	GPIO3D1_MAC_RXCLKIN,
-	GPIO3D1_I2C4_SCL,
-
-	GPIO3D0_SHIFT           = 0,
-	GPIO3D0_MASK            = 3 << GPIO3D0_SHIFT,
-	GPIO3D0_GPIO            = 0,
-	GPIO3D0_MAC_MDIO,
-	GPIO3D0_I2C4_SDA,
+	RK3368_GPIO3D4_MASK            = GENMASK(9, 8),
+	RK3368_GPIO3D4_GPIO            = 0,
+	RK3368_GPIO3D4_MAC_TXCLK       = (1 << 8),
+
+	RK3368_GPIO3D1_MASK            = GENMASK(3, 2),
+	RK3368_GPIO3D1_GPIO            = 0,
+	RK3368_GPIO3D1_MAC_RXCLK       = (1 << 2),
+
+	RK3368_GPIO3D0_MASK            = GENMASK(1, 0),
+	RK3368_GPIO3D0_GPIO            = 0,
+	RK3368_GPIO3D0_MAC_MDIO        = (1 << 0),
+};
+
+/* GRF_SOC_CON0 */
+enum {
+	NOC_RSP_ERR_STALL = BIT(9),
+	MOBILE_DDR_SEL = BIT(4),
+	DDR0_16BIT_EN = BIT(3),
+	MSCH0_MAINDDR3_DDR3 = BIT(2),
+	MSCH0_MAINPARTIALPOP = BIT(1),
+	UPCTL_C_ACTIVE = BIT(0),
 };
   /*GRF_SOC_CON11/12/13*/
@@ -440,4 +445,34 @@ enum {
 	MCU_CODE_BASE_BIT31_BIT28_SHIFT		= 0,
 	MCU_CODE_BASE_BIT31_BIT28_MASK		= GENMASK(3, 0),
 };
+
+/*GRF_SOC_CON15*/
+enum {
+	RK3368_GMAC_PHY_INTF_SEL_RGMII = 1 << 9,
+	RK3368_GMAC_PHY_INTF_SEL_MASK = GENMASK(11, 9),
+	RK3368_RMII_MODE_MASK  = BIT(6),
+	RK3368_RMII_MODE       = BIT(6),
+	RK3368_GMAC_CLK_SEL_2_5M = 2 << 4,
+	RK3368_GMAC_CLK_SEL_25M = 3 << 4,
+	RK3368_GMAC_CLK_SEL_125M = 0 << 4,
+	RK3368_GMAC_CLK_SEL_MASK = GENMASK(5, 4),
+};
+
+/* GRF_SOC_CON16 */
+enum {
+	RK3368_RXCLK_DLY_ENA_GMAC_MASK = BIT(15),
+	RK3368_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(15),
+
+	RK3368_TXCLK_DLY_ENA_GMAC_MASK = BIT(7),
+	RK3368_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
+	RK3368_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(7),
+
+	RK3368_CLK_RX_DL_CFG_GMAC_SHIFT = 8,
+	RK3368_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(14, 8),
+
+	RK3368_CLK_TX_DL_CFG_GMAC_SHIFT = 0,
+	RK3368_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
+};
+
 #endif
drivers/pinctrl/rockchip/pinctrl_rk3368.c +8 -9
index bdf0758..b77c5ab 100644
@@ -30,9 +30,9 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
 	switch (uart_id) {
 	case PERIPH_ID_UART2:
 		rk_clrsetreg(&grf->gpio2a_iomux,
-			     GPIO2A6_MASK | GPIO2A5_MASK,
-			     GPIO2A6_UART2_SIN << GPIO2A6_SHIFT |
-			     GPIO2A5_UART2_SOUT << GPIO2A5_SHIFT);
+			     RK3368_GPIO2A6_MASK | RK3368_GPIO2A5_MASK,
+			     RK3368_GPIO2A6_UART2_SIN |
+			     RK3368_GPIO2A5_UART2_SOUT);
 		break;
 	case PERIPH_ID_UART0:
 		break;
@@ -42,12 +42,11 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
 		break;
 	case PERIPH_ID_UART4:
 		rk_clrsetreg(&pmugrf->gpio0d_iomux,
-			     GPIO0D0_MASK | GPIO0D1_MASK |
-			     GPIO0D2_MASK | GPIO0D3_MASK,
-			     GPIO0D0_GPIO << GPIO0D0_SHIFT |
-			     GPIO0D1_GPIO << GPIO0D1_SHIFT |
-			     GPIO0D2_UART4_SOUT << GPIO0D2_SHIFT |
-			     GPIO0D3_UART4_SIN << GPIO0D3_SHIFT);
+			     RK3368_GPIO0D0_MASK | RK3368_GPIO0D1_MASK |
+			     RK3368_GPIO0D2_MASK | RK3368_GPIO0D3_MASK,
+			     RK3368_GPIO0D0_GPIO | RK3368_GPIO0D1_GPIO |
+			     RK3368_GPIO0D2_UART4_SOUT |
+			     RK3368_GPIO0D3_UART4_SIN);
 		break;
 	default:
 		debug("uart id = %d iomux error!\n", uart_id);
#39 lore raw

PATCH 30/52 rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_

Hi Philipp,

Quoted 54 lines · Dr. Philipp Tomsich
Quoted 54 lines · Kever Yang

Hi Philipp,

Quoted 36 lines · Dr. Philipp Tomsich
Quoted 36 lines · Andy Yan

Hi Philipp:

Quoted 30 lines · Dr. Philipp Tomsich
Quoted 11 lines · Andy Yan

Hi Philipp:

Quoted 5 lines · Philipp Tomsich

The RK3368 GRF header was still defines with a shifted-mask but with non-shifted function selectors for the IOMUX defines. As the RK3368 support is still fresh enough to allow a quick rename, we do this now before having more code use this.

Quoted 6 lines
Quoted 4 lines

As some of the downstream drivers (e.g. the Designware GMAC wrapper) may need to include the grf-header of multiple devices, we rename the various defines for the RK3368 by prefixing them with the device name. This avoids future trouble during driver integration.

Is that really necessary to add such a prefix for all the register definition, just to fit the GMAC dirver?
Maybe the gmac driver can define the platform specific macro in its own code like dwmac-rk in the kernel. Then we can keep the register header file a little tidy.

The problem is not the GMAC driver (although it was the motivation for doing this change), but rather how easy it is to pick up the wrong grf-file and refer to the wrong definitions/values… the conflicts are not through the GMAC-specifc defines but rather through things like the IOMUX masks or (before I moved this to the DDR-driver) things like the defines to enable DRAM in GRF.

Until we find a way to consistently structure things in such a way that
(a) common constructs can be shared (e.g. the masks in the IOMUX)
(b) specific definitions (e.g. the pin-out for a specific device) is not visible outside of its driver
I prefer the names to explicitly refer to each device.
That said, the longer-term plan (especially with a larger number of devices
being supported) needs to include a consistent rework of how (and where)
we manage all these definitions from the grf-header files.

Quoted 5 lines
Quoted 1 line

It's true that many devices use GRF, we also face this condition in the kernel land.And all the drivers in kernel handle this device specific definition in the driver itself(by of_device_id->data or MACRO). And there is also no need to use the grf constructs, the common syscon api will provide you the grf base address. I think this keeps things simple, we don't need to rely on too much of the grf or cru header, maybe some day we can remove the header file, just as clean as the kernel.

The problem is not the base-address of GRF, but rather the need to pull in the register structure (so we can refer to individual registers by name instead of by hard-coded offset): as we pull this in today, the definitions for the various IOMUX entries will also be pulled in, which will cause duplicate definitions.

I really don't like the idea of add the prefix, which end with longer MACRO but no other improve. I think the GRF is used mostly for the IOMUX, in this case the better solution is port the kernel rockchip-pinctrl driver in uboot, which not rely on the dtsi instead of header file.

Quoted 6 lines
Quoted 2 lines

If we do this, we can remove most of the GRF header definition for IOMUX, I can ask David Wu to do this, but maybe few weeks later.

As indicated earlier: this is a temporary solution (although we have a local saying that "nothing is more permanent than a temporary solution”) and should remain limited to the RK3368 until we can clean this up across all boards.

Can we drop the prefix for now? I do worry about the precedent this sets. If this is needed anywhere then it suggests to me that we have not split up the drivers correctly. We should not be including two different GRF headers into the same file. E.g. there should be different pinctrl drivers for each SoC.

Quoted 24 lines

Pulling this into the pinctrl drivers is an excellent choice.
Please watch out for board_debug_uart_init(…), which also directly accesses the IOMUX constants and will need to be restructured together with pinctrl drivers.

Thanks!
—Philipp.

Quoted 16 lines

Thanks,
- Kever

Quoted 14 lines
Quoted 2 lines

On the other hand, add such a prefix of rk3368 breaks the consistency with other rockchip devices.

I do agree that we need to clean this up across all the boards and drivers supported today. As of today, I can not resolve this on a RK3368-only basis, as I’d need to clean up the RK3288 at the same time (and don’t want to do this in a RK3368-focused series that already has way too much going on).

Let’s try to clean this up for the next (i.e. the one after this) merge window. Once we have bit-definitions out of the grf-header, I’ll remove the RK3368_ prefixes...

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

---

Regards,
Simon

#40 lore raw

PATCH 30/52 rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_

Quoted 68 lines · Simon Glass

Hi Philipp,

Quoted 54 lines · Dr. Philipp Tomsich
Quoted 54 lines · Kever Yang

Hi Philipp,

Quoted 36 lines · Dr. Philipp Tomsich
Quoted 36 lines · Andy Yan

Hi Philipp:

Quoted 30 lines · Dr. Philipp Tomsich
Quoted 11 lines · Andy Yan

Hi Philipp:

Quoted 5 lines · Philipp Tomsich

The RK3368 GRF header was still defines with a shifted-mask but with non-shifted function selectors for the IOMUX defines. As the RK3368 support is still fresh enough to allow a quick rename, we do this now before having more code use this.

Quoted 6 lines
Quoted 4 lines

As some of the downstream drivers (e.g. the Designware GMAC wrapper) may need to include the grf-header of multiple devices, we rename the various defines for the RK3368 by prefixing them with the device name. This avoids future trouble during driver integration.

Is that really necessary to add such a prefix for all the register definition, just to fit the GMAC dirver?
Maybe the gmac driver can define the platform specific macro in its own code like dwmac-rk in the kernel. Then we can keep the register header file a little tidy.

The problem is not the GMAC driver (although it was the motivation for doing this change), but rather how easy it is to pick up the wrong grf-file and refer to the wrong definitions/values… the conflicts are not through the GMAC-specifc defines but rather through things like the IOMUX masks or (before I moved this to the DDR-driver) things like the defines to enable DRAM in GRF.

Until we find a way to consistently structure things in such a way that
(a) common constructs can be shared (e.g. the masks in the IOMUX)
(b) specific definitions (e.g. the pin-out for a specific device) is not visible outside of its driver
I prefer the names to explicitly refer to each device.
That said, the longer-term plan (especially with a larger number of devices
being supported) needs to include a consistent rework of how (and where)
we manage all these definitions from the grf-header files.

Quoted 5 lines
Quoted 1 line

It's true that many devices use GRF, we also face this condition in the kernel land.And all the drivers in kernel handle this device specific definition in the driver itself(by of_device_id->data or MACRO). And there is also no need to use the grf constructs, the common syscon api will provide you the grf base address. I think this keeps things simple, we don't need to rely on too much of the grf or cru header, maybe some day we can remove the header file, just as clean as the kernel.

The problem is not the base-address of GRF, but rather the need to pull in the register structure (so we can refer to individual registers by name instead of by hard-coded offset): as we pull this in today, the definitions for the various IOMUX entries will also be pulled in, which will cause duplicate definitions.

I really don't like the idea of add the prefix, which end with longer MACRO but no other improve. I think the GRF is used mostly for the IOMUX, in this case the better solution is port the kernel rockchip-pinctrl driver in uboot, which not rely on the dtsi instead of header file.

Quoted 6 lines
Quoted 2 lines

If we do this, we can remove most of the GRF header definition for IOMUX, I can ask David Wu to do this, but maybe few weeks later.

As indicated earlier: this is a temporary solution (although we have a local saying that "nothing is more permanent than a temporary solution”) and should remain limited to the RK3368 until we can clean this up across all boards.

Quoted 5 lines

Can we drop the prefix for now? I do worry about the precedent this sets. If this is needed anywhere then it suggests to me that we have not split up the drivers correctly. We should not be including two different GRF headers into the same file. E.g. there should be different pinctrl drivers for each SoC.

If we drop it, we can’t get RK3368-support merged into the GMAC driver for now. Splitting the Rockchip-wrapper of the GMAC-driver doesn’t appear like a workable solution either, as this would create a new file for each chip-variant in drivers/net.

I’ll just pull the RK3368 GMAC (driver) support for now and split it off this series.

Quoted 26 lines
Quoted 4 lines

Pulling this into the pinctrl drivers is an excellent choice.
Please watch out for board_debug_uart_init(…), which also directly accesses the IOMUX constants and will need to be restructured together with pinctrl drivers.

Quoted 19 lines

Thanks!
—Philipp.

Quoted 16 lines

Thanks,
- Kever

Quoted 14 lines
Quoted 2 lines

On the other hand, add such a prefix of rk3368 breaks the consistency with other rockchip devices.

I do agree that we need to clean this up across all the boards and drivers supported today. As of today, I can not resolve this on a RK3368-only basis, as I’d need to clean up the RK3288 at the same time (and don’t want to do this in a RK3368-focused series that already has way too much going on).

Let’s try to clean this up for the next (i.e. the one after this) merge window. Once we have bit-definitions out of the grf-header, I’ll remove the RK3368_ prefixes...

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

---

Regards,
Simon

#41 lore raw

PATCH 30/52 rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_

Hi Philipp,

Quoted 74 lines · Dr. Philipp Tomsich
Quoted 68 lines · Simon Glass

Hi Philipp,

Quoted 54 lines · Dr. Philipp Tomsich
Quoted 54 lines · Kever Yang

Hi Philipp,

Quoted 36 lines · Dr. Philipp Tomsich
Quoted 36 lines · Andy Yan

Hi Philipp:

Quoted 30 lines · Dr. Philipp Tomsich
Quoted 11 lines · Andy Yan

Hi Philipp:

Quoted 5 lines · Philipp Tomsich

The RK3368 GRF header was still defines with a shifted-mask but with non-shifted function selectors for the IOMUX defines. As the RK3368 support is still fresh enough to allow a quick rename, we do this now before having more code use this.

Quoted 6 lines
Quoted 4 lines

As some of the downstream drivers (e.g. the Designware GMAC wrapper) may need to include the grf-header of multiple devices, we rename the various defines for the RK3368 by prefixing them with the device name. This avoids future trouble during driver integration.

Is that really necessary to add such a prefix for all the register definition, just to fit the GMAC dirver?
Maybe the gmac driver can define the platform specific macro in its own code like dwmac-rk in the kernel. Then we can keep the register header file a little tidy.

The problem is not the GMAC driver (although it was the motivation for doing this change), but rather how easy it is to pick up the wrong grf-file and refer to the wrong definitions/values… the conflicts are not through the GMAC-specifc defines but rather through things like the IOMUX masks or (before I moved this to the DDR-driver) things like the defines to enable DRAM in GRF.

Until we find a way to consistently structure things in such a way that
(a) common constructs can be shared (e.g. the masks in the IOMUX)
(b) specific definitions (e.g. the pin-out for a specific device) is not visible outside of its driver
I prefer the names to explicitly refer to each device.
That said, the longer-term plan (especially with a larger number of devices
being supported) needs to include a consistent rework of how (and where)
we manage all these definitions from the grf-header files.

Quoted 5 lines
Quoted 1 line

It's true that many devices use GRF, we also face this condition in the kernel land.And all the drivers in kernel handle this device specific definition in the driver itself(by of_device_id->data or MACRO). And there is also no need to use the grf constructs, the common syscon api will provide you the grf base address. I think this keeps things simple, we don't need to rely on too much of the grf or cru header, maybe some day we can remove the header file, just as clean as the kernel.

The problem is not the base-address of GRF, but rather the need to pull in the register structure (so we can refer to individual registers by name instead of by hard-coded offset): as we pull this in today, the definitions for the various IOMUX entries will also be pulled in, which will cause duplicate definitions.

I really don't like the idea of add the prefix, which end with longer MACRO but no other improve. I think the GRF is used mostly for the IOMUX, in this case the better solution is port the kernel rockchip-pinctrl driver in uboot, which not rely on the dtsi instead of header file.

Quoted 6 lines
Quoted 2 lines

If we do this, we can remove most of the GRF header definition for IOMUX, I can ask David Wu to do this, but maybe few weeks later.

As indicated earlier: this is a temporary solution (although we have a local saying that "nothing is more permanent than a temporary solution”) and should remain limited to the RK3368 until we can clean this up across all boards.

Quoted 5 lines

Can we drop the prefix for now? I do worry about the precedent this sets. If this is needed anywhere then it suggests to me that we have not split up the drivers correctly. We should not be including two different GRF headers into the same file. E.g. there should be different pinctrl drivers for each SoC.

Quoted 5 lines

If we drop it, we can’t get RK3368-support merged into the GMAC driver for now. Splitting the Rockchip-wrapper of the GMAC-driver doesn’t appear like a workable solution either, as this would create a new file for each chip-variant in drivers/net.

I’ll just pull the RK3368 GMAC (driver) support for now and split it off this series.

My view of GRF is that we should try to have a driver for the various operations that each thing needs (e.g. using the ioctl model). Imagine a world where we have a U-Boot that supports running on all available Rockchip SoCs and can boot on any board. In that case we probably want a GRF driver with operations that can be implemented by each SoC.

I have not sketched this out or tried it though. It needs more thought / prototyping.

I am concerned about #ifdefs in the code and including private SoC-specific RK header files in generic Rockchip drivers. To me that is the wrong approach.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

Pulling this into the pinctrl drivers is an excellent choice.
Please watch out for board_debug_uart_init(…), which also directly accesses the IOMUX constants and will need to be restructured together with pinctrl drivers.

Thanks!
—Philipp.

Quoted 9 lines

Thanks,
- Kever

Quoted 7 lines
Quoted 2 lines

On the other hand, add such a prefix of rk3368 breaks the consistency with other rockchip devices.

I do agree that we need to clean this up across all the boards and drivers supported today. As of today, I can not resolve this on a RK3368-only basis, as I’d need to clean up the RK3288 at the same time (and don’t want to do this in a RK3368-focused series that already has way too much going on).

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Let’s try to clean this up for the next (i.e. the one after this) merge window. Once we have bit-definitions out of the grf-header, I’ll remove the RK3368_ prefixes...

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

---

Regards,
Simon

#42 lore raw

PATCH 30/52 rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_

Quoted 93 lines · Simon Glass

Hi Philipp,

Quoted 74 lines · Dr. Philipp Tomsich
Quoted 68 lines · Simon Glass

Hi Philipp,

Quoted 54 lines · Dr. Philipp Tomsich
Quoted 54 lines · Kever Yang

Hi Philipp,

Quoted 36 lines · Dr. Philipp Tomsich
Quoted 36 lines · Andy Yan

Hi Philipp:

Quoted 30 lines · Dr. Philipp Tomsich
Quoted 11 lines · Andy Yan

Hi Philipp:

Quoted 5 lines · Philipp Tomsich

The RK3368 GRF header was still defines with a shifted-mask but with non-shifted function selectors for the IOMUX defines. As the RK3368 support is still fresh enough to allow a quick rename, we do this now before having more code use this.

Quoted 6 lines
Quoted 4 lines

As some of the downstream drivers (e.g. the Designware GMAC wrapper) may need to include the grf-header of multiple devices, we rename the various defines for the RK3368 by prefixing them with the device name. This avoids future trouble during driver integration.

Is that really necessary to add such a prefix for all the register definition, just to fit the GMAC dirver?
Maybe the gmac driver can define the platform specific macro in its own code like dwmac-rk in the kernel. Then we can keep the register header file a little tidy.

The problem is not the GMAC driver (although it was the motivation for doing this change), but rather how easy it is to pick up the wrong grf-file and refer to the wrong definitions/values… the conflicts are not through the GMAC-specifc defines but rather through things like the IOMUX masks or (before I moved this to the DDR-driver) things like the defines to enable DRAM in GRF.

Until we find a way to consistently structure things in such a way that
(a) common constructs can be shared (e.g. the masks in the IOMUX)
(b) specific definitions (e.g. the pin-out for a specific device) is not visible outside of its driver
I prefer the names to explicitly refer to each device.
That said, the longer-term plan (especially with a larger number of devices
being supported) needs to include a consistent rework of how (and where)
we manage all these definitions from the grf-header files.

Quoted 5 lines
Quoted 1 line

It's true that many devices use GRF, we also face this condition in the kernel land.And all the drivers in kernel handle this device specific definition in the driver itself(by of_device_id->data or MACRO). And there is also no need to use the grf constructs, the common syscon api will provide you the grf base address. I think this keeps things simple, we don't need to rely on too much of the grf or cru header, maybe some day we can remove the header file, just as clean as the kernel.

The problem is not the base-address of GRF, but rather the need to pull in the register structure (so we can refer to individual registers by name instead of by hard-coded offset): as we pull this in today, the definitions for the various IOMUX entries will also be pulled in, which will cause duplicate definitions.

I really don't like the idea of add the prefix, which end with longer MACRO but no other improve. I think the GRF is used mostly for the IOMUX, in this case the better solution is port the kernel rockchip-pinctrl driver in uboot, which not rely on the dtsi instead of header file.

Quoted 6 lines
Quoted 2 lines

If we do this, we can remove most of the GRF header definition for IOMUX, I can ask David Wu to do this, but maybe few weeks later.

As indicated earlier: this is a temporary solution (although we have a local saying that "nothing is more permanent than a temporary solution”) and should remain limited to the RK3368 until we can clean this up across all boards.

Quoted 5 lines

Can we drop the prefix for now? I do worry about the precedent this sets. If this is needed anywhere then it suggests to me that we have not split up the drivers correctly. We should not be including two different GRF headers into the same file. E.g. there should be different pinctrl drivers for each SoC.

Quoted 5 lines

If we drop it, we can’t get RK3368-support merged into the GMAC driver for now. Splitting the Rockchip-wrapper of the GMAC-driver doesn’t appear like a workable solution either, as this would create a new file for each chip-variant in drivers/net.

I’ll just pull the RK3368 GMAC (driver) support for now and split it off this series.

My view of GRF is that we should try to have a driver for the various operations that each thing needs (e.g. using the ioctl model). Imagine a world where we have a U-Boot that supports running on all available Rockchip SoCs and can boot on any board. In that case we probably want a GRF driver with operations that can be implemented by each SoC.

Quoted 7 lines

I have not sketched this out or tried it though. It needs more thought / prototyping.

I am concerned about #ifdefs in the code and including private SoC-specific RK header files in generic Rockchip drivers. To me that is the wrong approach.

This echoes some of my ideas, especially the litmus-test of considering an universal U-Boot for all Rockchip devices.

I currently don’t see us winning much by moving the inclusion to new drivers (as these would then need to include the RK header files). The direction that I am taking this avoids any chip-specific #ifdef as well, as the device-model offers plenty better solutions.

In fact, I had sketched out a misc-device that would provide the required functionality for the GMAC driver last week and this would have resolved my issue at hand. Yet, this seems a bit overkill, as it would add a number of misc-devices w/o gaining any simplification (i.e. each misc-device would then include the grf-header for one of the chips).

Either way, there’s one detail that I haven’t been able to fully flesh out yet:
the TPL/SPL stages use the GRF directly to set up the debug uart pin-mux. I haven’t had time to see if there’s space to pull pinctrl in to resolve this specific case—either way, it shows that there may be cases where we need to access the GRF w/o the device-model support…

My hope is that the few remaining cases of needing the GRF bits before the device-model is ready are sufficiently few to accept duplicating the bit-definitions (e.g. I’d be willing to live with this, if it’s only the debug-uart).

—Philipp.

#43 lore raw

PATCH 31/52 rockchip: pinctrl: rk3368: add GMAC (RGMII only) support

In reply to Philipp Tomsich

To add GMAC (Gigabit Ethernet) support (limited to RGMII only at this point), we need support for additional pin-configuration. This commit adds the pinctrl support for GMAC in RGMII mode:
* adds a PERIPH_ID_GMAC and the mapping from IRQ number to PERIPH_ID
* configures the RGMII pins

---

 drivers/pinctrl/rockchip/pinctrl_rk3368.c | 36 +++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
drivers/pinctrl/rockchip/pinctrl_rk3368.c +36 -0
index b77c5ab..aecd11d 100644
@@ -54,6 +54,33 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
 	}
 }
 
+#if CONFIG_IS_ENABLED(GMAC_ROCKCHIP)
+static void pinctrl_rk3368_gmac_config(struct rk3368_grf *grf, int gmac_id)
+{
+	rk_clrsetreg(&grf->gpio3b_iomux,
+		     RK3368_GPIO3B0_MASK | RK3368_GPIO3B1_MASK |
+		     RK3368_GPIO3B2_MASK | RK3368_GPIO3B5_MASK |
+		     RK3368_GPIO3B6_MASK | RK3368_GPIO3B7_MASK,
+		     RK3368_GPIO3B0_MAC_TXD0 | RK3368_GPIO3B1_MAC_TXD1 |
+		     RK3368_GPIO3B2_MAC_TXD2 | RK3368_GPIO3B5_MAC_TXEN |
+		     RK3368_GPIO3B6_MAC_TXD3 | RK3368_GPIO3B7_MAC_RXD0);
+	rk_clrsetreg(&grf->gpio3c_iomux,
+		     RK3368_GPIO3C0_MASK | RK3368_GPIO3C1_MASK |
+		     RK3368_GPIO3C2_MASK | RK3368_GPIO3C3_MASK |
+		     RK3368_GPIO3C4_MASK | RK3368_GPIO3C5_MASK |
+		     RK3368_GPIO3C6_MASK,
+		     RK3368_GPIO3C0_MAC_RXD1 | RK3368_GPIO3C1_MAC_RXD2 |
+		     RK3368_GPIO3C2_MAC_RXD3 | RK3368_GPIO3C3_MAC_MDC |
+		     RK3368_GPIO3C4_MAC_RXDV | RK3368_GPIO3C5_MAC_RXEN |
+		     RK3368_GPIO3C6_MAC_CLK);
+	rk_clrsetreg(&grf->gpio3d_iomux,
+		     RK3368_GPIO3D0_MASK | RK3368_GPIO3D1_MASK |
+		     RK3368_GPIO3D4_MASK,
+		     RK3368_GPIO3D0_MAC_MDIO | RK3368_GPIO3D1_MAC_RXCLK |
+		     RK3368_GPIO3D4_MAC_TXCLK);
+}
+#endif
+
 static int rk3368_pinctrl_request(struct udevice *dev, int func, int flags)
 {
 	struct rk3368_pinctrl_priv *priv = dev_get_priv(dev);
@@ -67,6 +94,11 @@ static int rk3368_pinctrl_request(struct udevice *dev, int func, int flags)
 	case PERIPH_ID_UART4:
 		pinctrl_rk3368_uart_config(priv, func);
 		break;
+#if CONFIG_IS_ENABLED(GMAC_ROCKCHIP)
+	case PERIPH_ID_GMAC:
+		pinctrl_rk3368_gmac_config(priv->grf, func);
+		break;
+#endif
 	default:
 		return -EINVAL;
 	}
@@ -96,6 +128,10 @@ static int rk3368_pinctrl_get_periph_id(struct udevice *dev,
 		return PERIPH_ID_UART1;
 	case 55:
 		return PERIPH_ID_UART0;
+#if CONFIG_IS_ENABLED(GMAC_ROCKCHIP)
+	case 27:
+		return PERIPH_ID_GMAC;
+#endif
 	}
 
 	return -ENOENT;
Signature · 1 line
2.1.4
#44 lore raw

PATCH 32/52 rockchip: pinctrl: rk3368: add support for configuring the MMC pins

In reply to Philipp Tomsich

The RK3368 has two SD/MMC controllers that can be used from U-Boot both during SPL and for booting an OS from the full bootloader stage. While both are configured to (mostly) sensible settings from the BROM, additional configuration for the MMC controller is needed to configure it to 8bit mode.

This adds pinctrl support for the MMC controller.

---

 drivers/pinctrl/rockchip/pinctrl_rk3368.c | 48 +++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
drivers/pinctrl/rockchip/pinctrl_rk3368.c +48 -0
index aecd11d..23950d0 100644
@@ -81,6 +81,46 @@ static void pinctrl_rk3368_gmac_config(struct rk3368_grf *grf, int gmac_id)
 }
 #endif
 
+static void pinctrl_rk3368_sdmmc_config(struct rk3368_grf *grf, int mmc_id)
+{
+	switch (mmc_id) {
+	case PERIPH_ID_EMMC:
+		debug("mmc id = %d setting registers!\n", mmc_id);
+		rk_clrsetreg(&grf->gpio1c_iomux,
+			     RK3368_GPIO1C2_MASK | RK3368_GPIO1C3_MASK |
+			     RK3368_GPIO1C4_MASK | RK3368_GPIO1C5_MASK |
+			     RK3368_GPIO1C6_MASK | RK3368_GPIO1C7_MASK,
+			     RK3368_GPIO1C2_EMMC_DATA0 |
+			     RK3368_GPIO1C3_EMMC_DATA1 |
+			     RK3368_GPIO1C4_EMMC_DATA2 |
+			     RK3368_GPIO1C5_EMMC_DATA3 |
+			     RK3368_GPIO1C6_EMMC_DATA4 |
+			     RK3368_GPIO1C7_EMMC_DATA5);
+		rk_clrsetreg(&grf->gpio1d_iomux,
+			     RK3368_GPIO1D0_MASK | RK3368_GPIO1D1_MASK |
+			     RK3368_GPIO1D2_MASK | RK3368_GPIO1D3_MASK,
+			     RK3368_GPIO1D0_EMMC_DATA6 |
+			     RK3368_GPIO1D1_EMMC_DATA7 |
+			     RK3368_GPIO1D2_EMMC_CMD |
+			     RK3368_GPIO1D3_EMMC_PWREN);
+		rk_clrsetreg(&grf->gpio2a_iomux,
+			     RK3368_GPIO2A3_MASK | RK3368_GPIO2A4_MASK,
+			     RK3368_GPIO2A3_EMMC_RSTNOUT |
+			     RK3368_GPIO2A4_EMMC_CLKOUT);
+		break;
+	case PERIPH_ID_SDCARD:
+		/*
+		 * We assume that the BROM has already set this up
+		 * correctly for us and that there's nothing to do
+		 * here.
+		 */
+		break;
+	default:
+		debug("mmc id = %d iomux error!\n", mmc_id);
+		break;
+	}
+}
+
 static int rk3368_pinctrl_request(struct udevice *dev, int func, int flags)
 {
 	struct rk3368_pinctrl_priv *priv = dev_get_priv(dev);
@@ -94,6 +134,10 @@ static int rk3368_pinctrl_request(struct udevice *dev, int func, int flags)
 	case PERIPH_ID_UART4:
 		pinctrl_rk3368_uart_config(priv, func);
 		break;
+	case PERIPH_ID_EMMC:
+	case PERIPH_ID_SDCARD:
+		pinctrl_rk3368_sdmmc_config(priv->grf, func);
+		break;
 #if CONFIG_IS_ENABLED(GMAC_ROCKCHIP)
 	case PERIPH_ID_GMAC:
 		pinctrl_rk3368_gmac_config(priv->grf, func);
@@ -128,6 +172,10 @@ static int rk3368_pinctrl_get_periph_id(struct udevice *dev,
 		return PERIPH_ID_UART1;
 	case 55:
 		return PERIPH_ID_UART0;
+	case 35:
+		return PERIPH_ID_EMMC;
+	case 32:
+		return PERIPH_ID_SDCARD;
 #if CONFIG_IS_ENABLED(GMAC_ROCKCHIP)
 	case 27:
 		return PERIPH_ID_GMAC;
Signature · 1 line
2.1.4
#45 lore raw

PATCH 33/52 rockchip: clk: rk3368: implement bandwidth adjust for PLLs

In reply to Philipp Tomsich

The RK3368 TRM recommends to configure the bandwith adjustment (CON2) for PLLs to NF/2. This implements this for all reconfigurations of PLLs and removes the 'has_bwadj' flag (as the RK3368 always has the bandwidth-adjustment feature according to its manual).

---

 drivers/clk/rockchip/clk_rk3368.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/clk/rockchip/clk_rk3368.c +12 -5
index e1d9aeb..d8f06d5 100644
@@ -1,6 +1,7 @@
 /*
  * (C) Copyright 2017 Rockchip Electronics Co., Ltd
  * Author: Andy Yan <[email protected]>
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
  * SPDX-License-Identifier:	GPL-2.0
  */
 
@@ -74,7 +75,7 @@ static uint32_t rkclk_pll_get_rate(struct rk3368_cru *cru,
 }
 
 static int rkclk_set_pll(struct rk3368_cru *cru, enum rk3368_pll_id pll_id,
-			 const struct pll_div *div, bool has_bwadj)
+			 const struct pll_div *div)
 {
 	struct rk3368_pll *pll = &cru->pll[pll_id];
 	/* All PLLs have same VCO and output frequency range restrictions*/
@@ -92,6 +93,12 @@ static int rkclk_set_pll(struct rk3368_cru *cru, enum rk3368_pll_id pll_id,
 		     ((div->nr - 1) << PLL_NR_SHIFT) |
 		     ((div->no - 1) << PLL_OD_SHIFT));
 	writel((div->nf - 1) << PLL_NF_SHIFT, &pll->con1);
+	/*
+	 * BWADJ should be set to NF / 2 to ensure the nominal bandwidth.
+	 * Compare the RK3368 TRM, section "3.6.4 PLL Bandwidth Adjustment".
+	 */
+	clrsetbits_le32(&pll->con2, PLL_BWADJ_MASK, (div->nf >> 1) - 1);
+
 	udelay(10);
 
 	/* return from reset */
@@ -111,10 +118,10 @@ static void rkclk_init(struct rk3368_cru *cru)
 {
 	u32 apllb, aplll, dpll, cpll, gpll;
 
-	rkclk_set_pll(cru, APLLB, &apll_b_init_cfg, false);
-	rkclk_set_pll(cru, APLLL, &apll_l_init_cfg, false);
-	rkclk_set_pll(cru, GPLL, &gpll_init_cfg, false);
-	rkclk_set_pll(cru, CPLL, &cpll_init_cfg, false);
+	rkclk_set_pll(cru, APLLB, &apll_b_init_cfg);
+	rkclk_set_pll(cru, APLLL, &apll_l_init_cfg);
+	rkclk_set_pll(cru, GPLL, &gpll_init_cfg);
+	rkclk_set_pll(cru, CPLL, &cpll_init_cfg);
 
 	apllb = rkclk_pll_get_rate(cru, APLLB);
 	aplll = rkclk_pll_get_rate(cru, APLLL);
Signature · 1 line
2.1.4
#46 lore raw

PATCH 34/52 rockchip: clk: rk3368: support OF_PLATDATA for the RK3368 clk driver

In reply to Philipp Tomsich

With the RK3368's limited TPL size, we'll want to use OF_PLATFDATA for the SPL stage. This implements support for OF_PLATDATA in the clock driver for the RK3368.

---

 drivers/clk/rockchip/clk_rk3368.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/clk/rockchip/clk_rk3368.c +17 -0
index d8f06d5..809ad19 100644
@@ -8,7 +8,9 @@
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <dt-structs.h>
 #include <errno.h>
+#include <mapmem.h>
 #include <syscon.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/cru_rk3368.h>
@@ -19,6 +21,12 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+struct rk3368_clk_plat {
+	struct dtd_rockchip_rk3368_cru dtd;
+};
+#endif
+
 struct pll_div {
 	u32 nr;
 	u32 nf;
@@ -254,7 +262,11 @@ static struct clk_ops rk3368_clk_ops = {
 static int rk3368_clk_probe(struct udevice *dev)
 {
 	struct rk3368_clk_priv *priv = dev_get_priv(dev);
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct rk3368_clk_plat *plat = dev_get_platdata(dev);
 
+	priv->cru = map_sysmem(plat->dtd.reg[1], plat->dtd.reg[3]);
+#endif
 	rkclk_init(priv->cru);
 
 	return 0;
@@ -262,9 +274,11 @@ static int rk3368_clk_probe(struct udevice *dev)
 
 static int rk3368_clk_ofdata_to_platdata(struct udevice *dev)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct rk3368_clk_priv *priv = dev_get_priv(dev);
 
 	priv->cru = (struct rk3368_cru *)devfdt_get_addr(dev);
+#endif
 
 	return 0;
 }
@@ -291,6 +305,9 @@ U_BOOT_DRIVER(rockchip_rk3368_cru) = {
 	.id		= UCLASS_CLK,
 	.of_match	= rk3368_clk_ids,
 	.priv_auto_alloc_size = sizeof(struct rk3368_clk_priv),
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	.platdata_auto_alloc_size = sizeof(struct rk3368_clk_plat),
+#endif
 	.ofdata_to_platdata = rk3368_clk_ofdata_to_platdata,
 	.ops		= &rk3368_clk_ops,
 	.bind		= rk3368_clk_bind,
Signature · 1 line
2.1.4
#47 lore raw

PATCH 34/52 rockchip: clk: rk3368: support OF_PLATDATA for the RK3368 clk driver

Hi Philipp:

Quoted 2 lines · Philipp Tomsich

With the RK3368's limited TPL size, we'll want to use OF_PLATFDATA for the SPL stage. This implements support for OF_PLATDATA in the clock

TPL or SPL?

Quoted 70 lines

driver for the RK3368.

---

  drivers/clk/rockchip/clk_rk3368.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/clk/rockchip/clk_rk3368.c +17 -0
index d8f06d5..809ad19 100644
@@ -8,7 +8,9 @@
  #include <common.h>
  #include <clk-uclass.h>
  #include <dm.h>
+#include <dt-structs.h>
  #include <errno.h>
+#include <mapmem.h>
  #include <syscon.h>
  #include <asm/arch/clock.h>
  #include <asm/arch/cru_rk3368.h>
@@ -19,6 +21,12 @@
 
  DECLARE_GLOBAL_DATA_PTR;
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+struct rk3368_clk_plat {
+	struct dtd_rockchip_rk3368_cru dtd;
+};
+#endif
+
  struct pll_div {
  	u32 nr;
  	u32 nf;
@@ -254,7 +262,11 @@ static struct clk_ops rk3368_clk_ops = {
  static int rk3368_clk_probe(struct udevice *dev)
  {
  	struct rk3368_clk_priv *priv = dev_get_priv(dev);
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct rk3368_clk_plat *plat = dev_get_platdata(dev);
 
+	priv->cru = map_sysmem(plat->dtd.reg[1], plat->dtd.reg[3]);
+#endif
  	rkclk_init(priv->cru);
 
  	return 0;
@@ -262,9 +274,11 @@ static int rk3368_clk_probe(struct udevice *dev)
 
  static int rk3368_clk_ofdata_to_platdata(struct udevice *dev)
  {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
  	struct rk3368_clk_priv *priv = dev_get_priv(dev);
 
  	priv->cru = (struct rk3368_cru *)devfdt_get_addr(dev);
+#endif
 
  	return 0;
  }
@@ -291,6 +305,9 @@ U_BOOT_DRIVER(rockchip_rk3368_cru) = {
  	.id		= UCLASS_CLK,
  	.of_match	= rk3368_clk_ids,
  	.priv_auto_alloc_size = sizeof(struct rk3368_clk_priv),
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	.platdata_auto_alloc_size = sizeof(struct rk3368_clk_plat),
+#endif
  	.ofdata_to_platdata = rk3368_clk_ofdata_to_platdata,
  	.ops		= &rk3368_clk_ops,
  	.bind		= rk3368_clk_bind,
#48 lore raw

PATCH 34/52 rockchip: clk: rk3368: support OF_PLATDATA for the RK3368 clk driver

Quoted 11 lines · Andy Yan

Hi Philipp:

Quoted 2 lines · Philipp Tomsich

With the RK3368's limited TPL size, we'll want to use OF_PLATFDATA for the SPL stage. This implements support for OF_PLATDATA in the clock

TPL or SPL?

Thanks for catching this.

In fact it was first done for SPL and later reused for TPL (when I split the CONFIG_IS_ENABLED for TPL and SPL). There may be more of such confused uses of TPL/SPL lurking in my commit messages...

Quoted 65 lines
Quoted 63 lines

driver for the RK3368.

---

 drivers/clk/rockchip/clk_rk3368.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/clk/rockchip/clk_rk3368.c +15 -0
index d8f06d5..809ad19 100644
@@ -8,7 +8,9 @@
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <dt-structs.h>
 #include <errno.h>
+#include <mapmem.h>
 #include <syscon.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/cru_rk3368.h>
@@ -19,6 +21,12 @@
   DECLARE_GLOBAL_DATA_PTR;
 +#if CONFIG_IS_ENABLED(OF_PLATDATA)
+struct rk3368_clk_plat {
+	struct dtd_rockchip_rk3368_cru dtd;
+};
+#endif
+
 struct pll_div {
 	u32 nr;
 	u32 nf;
@@ -254,7 +262,11 @@ static struct clk_ops rk3368_clk_ops = {
 static int rk3368_clk_probe(struct udevice *dev)
 {
 	struct rk3368_clk_priv *priv = dev_get_priv(dev);
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct rk3368_clk_plat *plat = dev_get_platdata(dev);
 +	priv->cru = map_sysmem(plat->dtd.reg[1], plat->dtd.reg[3]);
+#endif
 	rkclk_init(priv->cru);
   	return 0;
@@ -262,9 +274,11 @@ static int rk3368_clk_probe(struct udevice *dev)
   static int rk3368_clk_ofdata_to_platdata(struct udevice *dev)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct rk3368_clk_priv *priv = dev_get_priv(dev);
   	priv->cru = (struct rk3368_cru *)devfdt_get_addr(dev);
+#endif
   	return 0;
 }
@@ -291,6 +305,9 @@ U_BOOT_DRIVER(rockchip_rk3368_cru) = {
 	.id		= UCLASS_CLK,
 	.of_match	= rk3368_clk_ids,
 	.priv_auto_alloc_size = sizeof(struct rk3368_clk_priv),
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	.platdata_auto_alloc_size = sizeof(struct rk3368_clk_plat),
+#endif
 	.ofdata_to_platdata = rk3368_clk_ofdata_to_platdata,
 	.ops		= &rk3368_clk_ops,
 	.bind		= rk3368_clk_bind,
#49 lore raw

PATCH 35/52 rockchip: clk: rk3368: do not change CPLL/GPLL before returning to BROM

In reply to Philipp Tomsich

The RK3368 has a somewhat temperamental BootROM (which I learned the hard way) when it comes to reconfiguring the CPLL and GPLL (in fact, experiments show that changing the GPLL broke things for me, while changing the CPLL seems to be more benign). These should not be modified by the SPL stage, if we intend to return to the BootROM for chain booting the next stage.

This commit changes the clock initialisation to not change CPLL/GPLL before returning to the BootROM (i.e. in TPL). As it's safe to change these settings if we no longer intend to return to U-Boot, we'll run the full PLL setup a little later (i.e. in SPL).

---

 drivers/clk/rockchip/clk_rk3368.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3368.c +17 -1
index 809ad19..d05be72 100644
@@ -50,10 +50,14 @@ struct pll_div {
 		       (_nr * _no) == hz, #hz "Hz cannot be hit with PLL " \
 		       "divisors on line " __stringify(__LINE__));
 
+#if IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_TPL_BUILD)
 static const struct pll_div apll_l_init_cfg = PLL_DIVISORS(APLL_L_HZ, 12, 2);
 static const struct pll_div apll_b_init_cfg = PLL_DIVISORS(APLL_B_HZ, 1, 2);
+#if !defined(CONFIG_TPL_BUILD)
 static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 1, 2);
 static const struct pll_div cpll_init_cfg = PLL_DIVISORS(CPLL_HZ, 1, 6);
+#endif
+#endif
 
 /* Get pll rate by id */
 static uint32_t rkclk_pll_get_rate(struct rk3368_cru *cru,
@@ -82,6 +86,7 @@ static uint32_t rkclk_pll_get_rate(struct rk3368_cru *cru,
 	}
 }
 
+#if IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_TPL_BUILD)
 static int rkclk_set_pll(struct rk3368_cru *cru, enum rk3368_pll_id pll_id,
 			 const struct pll_div *div)
 {
@@ -121,15 +126,23 @@ static int rkclk_set_pll(struct rk3368_cru *cru, enum rk3368_pll_id pll_id,
 
 	return 0;
 }
+#endif
 
+#if IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_TPL_BUILD)
 static void rkclk_init(struct rk3368_cru *cru)
 {
 	u32 apllb, aplll, dpll, cpll, gpll;
 
 	rkclk_set_pll(cru, APLLB, &apll_b_init_cfg);
 	rkclk_set_pll(cru, APLLL, &apll_l_init_cfg);
+#if !defined(CONFIG_TPL_BUILD)
+	/*
+	 * If we plan to return to the boot ROM, we can't increase the
+	 * GPLL rate from the SPL stage.
+	 */
 	rkclk_set_pll(cru, GPLL, &gpll_init_cfg);
 	rkclk_set_pll(cru, CPLL, &cpll_init_cfg);
+#endif
 
 	apllb = rkclk_pll_get_rate(cru, APLLB);
 	aplll = rkclk_pll_get_rate(cru, APLLL);
@@ -140,6 +153,7 @@ static void rkclk_init(struct rk3368_cru *cru)
 	debug("%s apllb(%d) apll(%d) dpll(%d) cpll(%d) gpll(%d)\n",
 	       __func__, apllb, aplll, dpll, cpll, gpll);
 }
+#endif
 
 static ulong rk3368_mmc_get_clk(struct rk3368_cru *cru, uint clk_id)
 {
@@ -261,13 +275,15 @@ static struct clk_ops rk3368_clk_ops = {
 
 static int rk3368_clk_probe(struct udevice *dev)
 {
-	struct rk3368_clk_priv *priv = dev_get_priv(dev);
+	struct rk3368_clk_priv __maybe_unused *priv = dev_get_priv(dev);
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct rk3368_clk_plat *plat = dev_get_platdata(dev);
 
 	priv->cru = map_sysmem(plat->dtd.reg[1], plat->dtd.reg[3]);
 #endif
+#if IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_TPL_BUILD)
 	rkclk_init(priv->cru);
+#endif
 
 	return 0;
 }
Signature · 1 line
2.1.4
#50 lore raw

PATCH 36/52 rockchip: clk: rk3368: implement DPLL (DRAM PLL) support

In reply to Philipp Tomsich

To implement a TPL stage (incl. its DRAM controller setup) for the RK3368, we'll want to configure the DPLL (DRAM PLL).

This commit implements setting the DPLL (CLK_DDR) and provides PLL configuration details for the common DRAM operating speeds found on RK3368 boards.

---

 drivers/clk/rockchip/clk_rk3368.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
drivers/clk/rockchip/clk_rk3368.c +35 -0
index d05be72..33d2946 100644
@@ -250,6 +250,37 @@ static ulong rk3368_clk_get_rate(struct clk *clk)
 	return rate;
 }
 
+static ulong rk3368_ddr_set_clk(struct rk3368_cru *cru, ulong set_rate)
+{
+	const struct pll_div *dpll_cfg = NULL;
+	const ulong MHz = 1000000;
+
+	/* Fout = ((Fin /NR) * NF )/ NO */
+	static const struct pll_div dpll_1200 =
+		PLL_DIVISORS(1200 * MHz, 1, 1);
+	static const struct pll_div dpll_1332 =
+		PLL_DIVISORS(1332 * MHz, 2, 1);
+	static const struct pll_div dpll_1600 =
+		PLL_DIVISORS(1600 * MHz, 3, 2);
+
+	switch (set_rate) {
+	case 1200*MHz:
+		dpll_cfg = &dpll_1200;
+		break;
+	case 1332*MHz:
+		dpll_cfg = &dpll_1332;
+		break;
+	case 1600*MHz:
+		dpll_cfg = &dpll_1600;
+		break;
+	default:
+		error("Unsupported SDRAM frequency!,%ld\n", set_rate);
+	}
+	rkclk_set_pll(cru, DPLL, dpll_cfg);
+
+	return set_rate;
+}
+
 static ulong rk3368_clk_set_rate(struct clk *clk, ulong rate)
 {
 	struct rk3368_clk_priv *priv = dev_get_priv(clk->dev);
@@ -257,6 +288,10 @@ static ulong rk3368_clk_set_rate(struct clk *clk, ulong rate)
 
 	debug("%s id:%ld rate:%ld\n", __func__, clk->id, rate);
 	switch (clk->id) {
+	case CLK_DDR:
+		ret = rk3368_ddr_set_clk(priv->cru, rate);
+		break;
+
 	case SCLK_SDMMC:
 	case SCLK_EMMC:
 		ret = rk3368_mmc_set_clk(priv->cru, clk->id, rate);
Signature · 1 line
2.1.4
#51 lore raw

PATCH 37/52 rockchip: clk: rk3368: define DMA1_SRST_REQ and DMA2_SRST_REQ

In reply to Philipp Tomsich

On he RK3368, we need to temporarily disable security on the DMA engines during TPL and SPL to allow the MMC host to DMA into DRAM. To do so, we need to reset the two DMA engines, which in turn requires the DMA1_SRST_REQ and DMA2_SRST_REQ constants to refer to the appropriate bits in the CRU.

As the ATF correctly initialises security (and only leaves EL3 after doing so), this can not pose a security issue.

---

 arch/arm/include/asm/arch-rockchip/cru_rk3368.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/include/asm/arch-rockchip/cru_rk3368.h +4 -0
index 24a9cc0..bf09e2f 100644
@@ -102,6 +102,10 @@ enum {
 	/* SOFTRST1_CON */
 	MCU_PO_SRST_MASK		= BIT(13),
 	MCU_SYS_SRST_MASK		= BIT(12),
+	DMA1_SRST_REQ                   = BIT(2),
+
+	/* SOFTRST4_CON */
+	DMA2_SRST_REQ                   = BIT(0),
 
 	/* GLB_RST_CON */
 	PMU_GLB_SRST_CTRL_SHIFT		= 2,
Signature · 1 line
2.1.4
#52 lore raw

PATCH 38/52 rockchip: clk: rk3368: implement MMC/SD clock reparenting

In reply to Philipp Tomsich

The original clock support for MMC/SD cards on the RK3368 suffered from a tendency to select a divider less-or-equal to the the one giving the requested clock-rate: this can lead to higher-than-expected (or rather: higher than supported) clock rates for the MMC/SD communiction.

This change rewrites the MMC/SD clock generation to:
* always generate a clock less-than-or-equal to the requested clock
* support reparenting among the CPLL, GPLL and OSC24M parents to generate the highest clock that does not exceed the requested rate

In addition to this, the Linux DTS uses HCLK_MMC/HCLK_SDMMC instead of SCLK_MMC/SCLK_SDMMC: to match this (and to ensure that clock setup always works), we adjust the driver appropriately.

This includes the changes from:
- rockchip: clk: rk3368: convert MMC_PLL_SEL_* definitions to shifted-value form

---

 arch/arm/include/asm/arch-rockchip/cru_rk3368.h |   8 +-
 drivers/clk/rockchip/clk_rk3368.c               | 119 ++++++++++++++++++------
 2 files changed, 95 insertions(+), 32 deletions(-)
arch/arm/include/asm/arch-rockchip/cru_rk3368.h +4 -4
index bf09e2f..21f11e0 100644
@@ -92,10 +92,10 @@ enum {
 	/* CLKSEL51_CON */
 	MMC_PLL_SEL_SHIFT		= 8,
 	MMC_PLL_SEL_MASK		= GENMASK(9, 8),
-	MMC_PLL_SEL_CPLL		= 0,
-	MMC_PLL_SEL_GPLL,
-	MMC_PLL_SEL_USBPHY_480M,
-	MMC_PLL_SEL_24M,
+	MMC_PLL_SEL_CPLL		= (0 << MMC_PLL_SEL_SHIFT),
+	MMC_PLL_SEL_GPLL                = (1 << MMC_PLL_SEL_SHIFT),
+	MMC_PLL_SEL_USBPHY_480M         = (2 << MMC_PLL_SEL_SHIFT),
+	MMC_PLL_SEL_24M                 = (3 << MMC_PLL_SEL_SHIFT),
 	MMC_CLK_DIV_SHIFT		= 0,
 	MMC_CLK_DIV_MASK		= GENMASK(6, 0),
 
drivers/clk/rockchip/clk_rk3368.c +91 -28

192 lines not on this page · raw message

Signature · 1 line
2.1.4
#53 lore raw

PATCH 39/52 rockchip: clk: rk3368: support configuring the DRAM PLL (from TPL)

In reply to Philipp Tomsich

As part of the DRAM initialisation process (running as part of the TPL stage) on the RK3368, we need to set up the DRAM PLL.

This implements support for configuring the PLL to for 1200, 1332 or 1600 MHz (i.e. for DDR3-1200, DDR3-1333, DDR3-1600 operating modes).

---

 drivers/clk/rockchip/clk_rk3368.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/clk/rockchip/clk_rk3368.c +7 -6
index 1327116..1bed4e2 100644
@@ -308,18 +308,16 @@ static ulong rk3368_clk_get_rate(struct clk *clk)
 	return rate;
 }
 
+#if IS_ENABLED(CONFIG_TPL_BUILD)
 static ulong rk3368_ddr_set_clk(struct rk3368_cru *cru, ulong set_rate)
 {
 	const struct pll_div *dpll_cfg = NULL;
 	const ulong MHz = 1000000;
 
 	/* Fout = ((Fin /NR) * NF )/ NO */
-	static const struct pll_div dpll_1200 =
-		PLL_DIVISORS(1200 * MHz, 1, 1);
-	static const struct pll_div dpll_1332 =
-		PLL_DIVISORS(1332 * MHz, 2, 1);
-	static const struct pll_div dpll_1600 =
-		PLL_DIVISORS(1600 * MHz, 3, 2);
+	static const struct pll_div dpll_1200 = PLL_DIVISORS(1200 * MHz, 1, 1);
+	static const struct pll_div dpll_1332 =	PLL_DIVISORS(1332 * MHz, 2, 1);
+	static const struct pll_div dpll_1600 =	PLL_DIVISORS(1600 * MHz, 3, 2);
 
 	switch (set_rate) {
 	case 1200*MHz:
@@ -338,6 +336,7 @@ static ulong rk3368_ddr_set_clk(struct rk3368_cru *cru, ulong set_rate)
 
 	return set_rate;
 }
+#endif
 
 static ulong rk3368_clk_set_rate(struct clk *clk, ulong rate)
 {
@@ -346,9 +345,11 @@ static ulong rk3368_clk_set_rate(struct clk *clk, ulong rate)
 
 	debug("%s id:%ld rate:%ld\n", __func__, clk->id, rate);
 	switch (clk->id) {
+#if IS_ENABLED(CONFIG_TPL_BUILD)
 	case CLK_DDR:
 		ret = rk3368_ddr_set_clk(priv->cru, rate);
 		break;
+#endif
 #if !IS_ENABLED(CONFIG_SPL_BUILD) || CONFIG_IS_ENABLED(MMC_SUPPORT)
 	case HCLK_SDMMC:
 	case HCLK_EMMC:
Signature · 1 line
2.1.4
#54 lore raw

PATCH 40/52 rockchip: clk: rk3368: add support for GMAC (SLCK_MAC) clock

In reply to Philipp Tomsich

To enable the GMAC on the RK3368, we need to set up the clocking appropriately to generate a tx_clk for the MAC.

This adds an implementation that implements the use of the <&ext_gmac> clock (i.e. an external 125MHz clock for RGMII provided by the PHY). This is the clock setup used by the boards currently supported by U-Boot (i.e. Geekbox, Sheep and RK3368-uQ7).

This includes the change from commit
- rockchip: clk: rk3368: define GMAC_MUX_SEL_EXTCLK

---

 arch/arm/include/asm/arch-rockchip/cru_rk3368.h |  3 +++
 drivers/clk/rockchip/clk_rk3368.c               | 19 +++++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-rockchip/cru_rk3368.h +3 -0
index 21f11e0..2b1197f 100644
@@ -89,6 +89,9 @@ enum {
 	MCU_CLK_DIV_SHIFT		= 0,
 	MCU_CLK_DIV_MASK		= GENMASK(4, 0),
 
+	/* CLKSEL43_CON */
+	GMAC_MUX_SEL_EXTCLK             = BIT(8),
+
 	/* CLKSEL51_CON */
 	MMC_PLL_SEL_SHIFT		= 8,
 	MMC_PLL_SEL_MASK		= GENMASK(9, 8),
drivers/clk/rockchip/clk_rk3368.c +17 -2
index 1bed4e2..2b6c8da 100644
@@ -338,6 +338,19 @@ static ulong rk3368_ddr_set_clk(struct rk3368_cru *cru, ulong set_rate)
 }
 #endif
 
+#if CONFIG_IS_ENABLED(GMAC_ROCKCHIP)
+static ulong rk3368_gmac_set_clk(struct rk3368_cru *cru,
+				 ulong clk_id, ulong set_rate)
+{
+	/*
+	 * This models the 'assigned-clock-parents = <&ext_gmac>' from
+	 * the DTS and switches to the 'ext_gmac' clock parent.
+	 */
+	rk_setreg(&cru->clksel_con[43], GMAC_MUX_SEL_EXTCLK);
+	return set_rate;
+}
+#endif
+
 static ulong rk3368_clk_set_rate(struct clk *clk, ulong rate)
 {
 	struct rk3368_clk_priv *priv = dev_get_priv(clk->dev);
@@ -356,10 +369,12 @@ static ulong rk3368_clk_set_rate(struct clk *clk, ulong rate)
 		ret = rk3368_mmc_set_clk(clk, rate);
 		break;
 #endif
+#if CONFIG_IS_ENABLED(GMAC_ROCKCHIP)
 	case SCLK_MAC:
-		/* nothing to do, as this is an external clock */
-		ret = rate;
+		/* select the external clock */
+		ret = rk3368_gmac_set_clk(priv->cru, clk->id, rate);
 		break;
+#endif
 	default:
 		return -ENOENT;
 	}
Signature · 1 line
2.1.4
#55 lore raw

PATCH 41/52 rockchip: clk: rk3368: mark 'priv' __maybe_unused in rk3368_clk_set_rate()

In reply to Philipp Tomsich

With the clock support in rk3368_clk_set_rate() conditionalized on various feature definitions, 'priv' can remain unused (e.g. in the SPL build when only MMC is enabled).

---

 drivers/clk/rockchip/clk_rk3368.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3368.c +1 -1
index 2b6c8da..d3f6c29 100644
@@ -353,7 +353,7 @@ static ulong rk3368_gmac_set_clk(struct rk3368_cru *cru,
 
 static ulong rk3368_clk_set_rate(struct clk *clk, ulong rate)
 {
-	struct rk3368_clk_priv *priv = dev_get_priv(clk->dev);
+	__maybe_unused struct rk3368_clk_priv *priv = dev_get_priv(clk->dev);
 	ulong ret = 0;
 
 	debug("%s id:%ld rate:%ld\n", __func__, clk->id, rate);
Signature · 1 line
2.1.4
#56 lore raw

PATCH 42/52 net: gmac_rockchip: Add support for the RK3368 GMAC

In reply to Philipp Tomsich

The GMAC in the RK3368 once again is identical to the incarnation in the RK3288 and the RK3399, except for where some of the configuration and control registers are located in the GRF.

This adds the RK3368-specific logic necessary to reuse this driver.

---

 drivers/net/gmac_rockchip.c | 54 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
drivers/net/gmac_rockchip.c +54 -0
index c9f9e83..2e4a812 100644
@@ -16,6 +16,7 @@
 #include <asm/arch/clock.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/grf_rk3288.h>
+#include <asm/arch/grf_rk3368.h>
 #include <asm/arch/grf_rk3399.h>
 #include <dm/pinctrl.h>
 #include <dt-bindings/clock/rk3288-cru.h>
@@ -83,6 +84,32 @@ static int rk3288_gmac_fix_mac_speed(struct dw_eth_dev *priv)
 	return 0;
 }
 
+static int rk3368_gmac_fix_mac_speed(struct dw_eth_dev *priv)
+{
+	struct rk3368_grf *grf;
+	int clk;
+
+	switch (priv->phydev->speed) {
+	case 10:
+		clk = RK3368_GMAC_CLK_SEL_2_5M;
+		break;
+	case 100:
+		clk = RK3368_GMAC_CLK_SEL_25M;
+		break;
+	case 1000:
+		clk = RK3368_GMAC_CLK_SEL_125M;
+		break;
+	default:
+		debug("Unknown phy speed: %d\n", priv->phydev->speed);
+		return -EINVAL;
+	}
+
+	grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+	rk_clrsetreg(&grf->soc_con15, RK3368_GMAC_CLK_SEL_MASK, clk);
+
+	return 0;
+}
+
 static int rk3399_gmac_fix_mac_speed(struct dw_eth_dev *priv)
 {
 	struct rk3399_grf_regs *grf;
@@ -129,6 +156,26 @@ static void rk3288_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)
 		     pdata->tx_delay << RK3288_CLK_TX_DL_CFG_GMAC_SHIFT);
 }
 
+static void rk3368_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)
+{
+	struct rk3368_grf *grf;
+
+	grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+	rk_clrsetreg(&grf->soc_con15,
+		     RK3368_RMII_MODE_MASK | RK3368_GMAC_PHY_INTF_SEL_MASK,
+		     RK3368_GMAC_PHY_INTF_SEL_RGMII);
+
+	rk_clrsetreg(&grf->soc_con16,
+		     RK3368_RXCLK_DLY_ENA_GMAC_MASK |
+		     RK3368_TXCLK_DLY_ENA_GMAC_MASK |
+		     RK3368_CLK_RX_DL_CFG_GMAC_MASK |
+		     RK3368_CLK_TX_DL_CFG_GMAC_MASK,
+		     RK3368_RXCLK_DLY_ENA_GMAC_ENABLE |
+		     RK3368_TXCLK_DLY_ENA_GMAC_ENABLE |
+		     pdata->rx_delay << RK3368_CLK_RX_DL_CFG_GMAC_SHIFT |
+		     pdata->tx_delay << RK3368_CLK_TX_DL_CFG_GMAC_SHIFT);
+}
+
 static void rk3399_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)
 {
 	struct rk3399_grf_regs *grf;
@@ -208,6 +255,11 @@ const struct rk_gmac_ops rk3288_gmac_ops = {
 	.set_to_rgmii = rk3288_gmac_set_to_rgmii,
 };
 
+const struct rk_gmac_ops rk3368_gmac_ops = {
+	.fix_mac_speed = rk3368_gmac_fix_mac_speed,
+	.set_to_rgmii = rk3368_gmac_set_to_rgmii,
+};
+
 const struct rk_gmac_ops rk3399_gmac_ops = {
 	.fix_mac_speed = rk3399_gmac_fix_mac_speed,
 	.set_to_rgmii = rk3399_gmac_set_to_rgmii,
@@ -216,6 +268,8 @@ const struct rk_gmac_ops rk3399_gmac_ops = {
 static const struct udevice_id rockchip_gmac_ids[] = {
 	{ .compatible = "rockchip,rk3288-gmac",
 	  .data = (ulong)&rk3288_gmac_ops },
+	{ .compatible = "rockchip,rk3368-gmac",
+	  .data = (ulong)&rk3368_gmac_ops },
 	{ .compatible = "rockchip,rk3399-gmac",
 	  .data = (ulong)&rk3399_gmac_ops },
 	{ }
Signature · 1 line
2.1.4
#57 lore raw

PATCH 43/52 rockchip: Makefile: streamline SPL/TPL configuration

In reply to Philipp Tomsich

Handling TPL and SPL in the Makefile for mach-rockchip was based on nested if checks and/or if-else-if paths. This can be simplified and made more readable by using $(SPL_TPL_) and by introducing intermediate variables for the aggregation of SPL and TPL features.

---

 arch/arm/mach-rockchip/Makefile | 46 +++++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 18 deletions(-)
arch/arm/mach-rockchip/Makefile +28 -18
index 8a3cb9f..633c91e 100644
@@ -4,37 +4,47 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o
-obj-$(CONFIG_$(SPL_TPL_)RAM) += sdram_common.o
+# We don't want the bootrom-helper present in a full U-Boot build, as
+# this may have entered from ATF with the stack-pointer pointing to
+# inaccessible/protected memory (and the bootrom-helper assumes that
+# the stack-pointer is valid before switching to the U-Boot stack).
+obj-spl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o save_boot_param.o
+obj-tpl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o save_boot_param.o
+
+obj-tpl-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board-tpl.o
+
+obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
+obj-spl-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board-spl.o
+obj-spl-$(CONFIG_ROCKCHIP_RK322X) += rk322x-board-spl.o
+obj-spl-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-spl.o
+obj-spl-$(CONFIG_ROCKCHIP_RK3368) += rk3368-board-spl.o
+obj-spl-$(CONFIG_ROCKCHIP_RK3399) += rk3399-board-spl.o
 
-ifdef CONFIG_TPL_BUILD
-obj-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board-tpl.o
-obj-$(CONFIG_ROCKCHIP_BROM_HELPER) += save_boot_param.o
-else ifdef CONFIG_SPL_BUILD
-obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
-obj-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board-spl.o
-obj-$(CONFIG_ROCKCHIP_RK322X) += rk322x-board-spl.o
-obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-spl.o
-obj-$(CONFIG_ROCKCHIP_RK3399) += rk3399-board-spl.o
-obj-$(CONFIG_ROCKCHIP_BROM_HELPER) += save_boot_param.o
-else
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
 obj-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board.o
 obj-$(CONFIG_ROCKCHIP_RK322X) += rk322x-board.o
 obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board.o
 obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board.o
 endif
+
+obj-$(CONFIG_$(SPL_TPL_)RAM) += sdram_common.o
+
 ifndef CONFIG_ARM64
 obj-y += rk_timer.o
 endif
-obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036/
-
-ifndef CONFIG_TPL_BUILD
-obj-$(CONFIG_ROCKCHIP_RK3188) += rk3188/
-endif
 
+obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036/
+obj-tpl-$(CONFIG_ROCKCHIP_RK3188) += rk3188/
 obj-$(CONFIG_ROCKCHIP_RK322X) += rk322x/
 obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288/
 obj-$(CONFIG_ROCKCHIP_RK3328) += rk3328/
 obj-$(CONFIG_ROCKCHIP_RK3368) += rk3368/
 obj-$(CONFIG_ROCKCHIP_RK3399) += rk3399/
 obj-$(CONFIG_ROCKCHIP_RV1108) += rv1108/
+
+# Clear out SPL objects, in case this is a TPL build
+obj-spl-$(CONFIG_TPL_BUILD) =
+
+# Now add SPL/TPL objects back into the main build
+obj-$(CONFIG_SPL_BUILD) += $(obj-spl-y)
+obj-$(CONFIG_TPL_BUILD) += $(obj-tpl-y)
Signature · 1 line
2.1.4
#58 lore raw

PATCH 44/52 rockchip: rk3368: add DRAM controller driver with DRAM initialisation

In reply to Philipp Tomsich

This adds a DRAM controller driver for the RK3368 and places it in drivers/ddr/rockchip (where the other DM-enabled DRAM controller drivers for rockchip devices should also be moved eventually).

At this stage, only the following feature-set is supported:
- DDR3
- 32-bit configuration (i.e. fully populated)
- dual-rank (i.e. no auto-detection of ranks)
- DDR3-1600K speed-bin

This driver expects to run from a TPL stage that will later return to the RK3368 BROM. It communicates with later stages through the os_reg2 in the pmugrf (i.e. using the same mechanism as Rockchip's DDR init code).

Unlike other DMC drivers for RK32xx and RK33xx parts, the required timings are calculated within the driver based on a target frequency and a DDR3 speed-bin (only the DDR3-1600K speed-bin is support at this time).

The RK3368 also has the DDRC0_CON0 (DDR ch. 0, control-register 0) register for controlling the operation of its (single-channel) DRAM controller in the GRF block. This provides for selecting DDR3, mobile DDR modes, and control low-power operation.
As part of this change, DDRC0_CON0 is also added to the GRF structure definition (at offset 0x600).

---

 arch/arm/include/asm/arch-rockchip/ddr_rk3368.h    | 187 ++++
 arch/arm/include/asm/arch-rockchip/grf_rk3368.h    |  13 +-
 arch/arm/mach-rockchip/rk3368/Makefile             |   1 -
 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c       |  60 --
 .../clock/rockchip,rk3368-dmc.txt                  |  67 ++
 drivers/ram/Makefile                               |   2 +
 drivers/ram/rockchip/Makefile                      |   7 +
 drivers/ram/rockchip/dmc-rk3368.c                  | 990 +++++++++++++++++++++
 include/dt-bindings/memory/rk3368-dmc.h            |  30 +
 9 files changed, 1286 insertions(+), 71 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-rockchip/ddr_rk3368.h
 delete mode 100644 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c
 create mode 100644 doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt
 create mode 100644 drivers/ram/rockchip/Makefile
 create mode 100644 drivers/ram/rockchip/dmc-rk3368.c
 create mode 100644 include/dt-bindings/memory/rk3368-dmc.h
arch/arm/include/asm/arch-rockchip/ddr_rk3368.h new file +187 -0
new file mode 100644
index 0000000..4e2b233
@@ -0,0 +1,187 @@
+/*
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#ifndef __ASM_ARCH_DDR_RK3368_H__
+#define __ASM_ARCH_DDR_RK3368_H__
+
+/*
+ * The RK3368 DDR PCTL differs from the incarnation in the RK3288 only
+ * in a few details. Most notably, it has an additional field to track
+ * tREFI in controller cycles (i.e. trefi_mem_ddr3).
+ */
+struct rk3368_ddr_pctl {
+	u32 scfg;
+	u32 sctl;
+	u32 stat;
+	u32 intrstat;
+	u32 reserved0[12];
+	u32 mcmd;
+	u32 powctl;
+	u32 powstat;
+	u32 cmdtstat;
+	u32 cmdtstaten;
+	u32 reserved1[3];
+	u32 mrrcfg0;
+	u32 mrrstat0;
+	u32 mrrstat1;
+	u32 reserved2[4];
+	u32 mcfg1;
+	u32 mcfg;
+	u32 ppcfg;
+	u32 mstat;
+	u32 lpddr2zqcfg;
+	u32 reserved3;
+	u32 dtupdes;
+	u32 dtuna;
+	u32 dtune;
+	u32 dtuprd0;
+	u32 dtuprd1;
+	u32 dtuprd2;
+	u32 dtuprd3;
+	u32 dtuawdt;
+	u32 reserved4[3];
+	u32 togcnt1u;
+	u32 tinit;
+	u32 trsth;
+	u32 togcnt100n;
+	u32 trefi;
+	u32 tmrd;
+	u32 trfc;
+	u32 trp;
+	u32 trtw;
+	u32 tal;
+	u32 tcl;
+	u32 tcwl;
+	u32 tras;
+	u32 trc;
+	u32 trcd;
+	u32 trrd;
+	u32 trtp;
+	u32 twr;
+	u32 twtr;
+	u32 texsr;
+	u32 txp;
+	u32 txpdll;
+	u32 tzqcs;
+	u32 tzqcsi;
+	u32 tdqs;
+	u32 tcksre;
+	u32 tcksrx;
+	u32 tcke;
+	u32 tmod;
+	u32 trstl;
+	u32 tzqcl;
+	u32 tmrr;
+	u32 tckesr;
+	u32 tdpd;
+	u32 trefi_mem_ddr3;
+	u32 reserved5[45];
+	u32 dtuwactl;
+	u32 dturactl;
+	u32 dtucfg;
+	u32 dtuectl;
+	u32 dtuwd0;
+	u32 dtuwd1;
+	u32 dtuwd2;
+	u32 dtuwd3;
+	u32 dtuwdm;
+	u32 dturd0;
+	u32 dturd1;
+	u32 dturd2;
+	u32 dturd3;
+	u32 dtulfsrwd;
+	u32 dtulfsrrd;
+	u32 dtueaf;
+	u32 dfitctrldelay;
+	u32 dfiodtcfg;
+	u32 dfiodtcfg1;
+	u32 dfiodtrankmap;
+	u32 dfitphywrdata;
+	u32 dfitphywrlat;
+	u32 reserved7[2];
+	u32 dfitrddataen;
+	u32 dfitphyrdlat;
+	u32 reserved8[2];
+	u32 dfitphyupdtype0;
+	u32 dfitphyupdtype1;
+	u32 dfitphyupdtype2;
+	u32 dfitphyupdtype3;
+	u32 dfitctrlupdmin;
+	u32 dfitctrlupdmax;
+	u32 dfitctrlupddly;
+	u32 reserved9;
+	u32 dfiupdcfg;
+	u32 dfitrefmski;
+	u32 dfitctrlupdi;
+	u32 reserved10[4];
+	u32 dfitrcfg0;
+	u32 dfitrstat0;
+	u32 dfitrwrlvlen;
+	u32 dfitrrdlvlen;
+	u32 dfitrrdlvlgateen;
+	u32 dfiststat0;
+	u32 dfistcfg0;
+	u32 dfistcfg1;
+	u32 reserved11;
+	u32 dfitdramclken;
+	u32 dfitdramclkdis;
+	u32 dfistcfg2;
+	u32 dfistparclr;
+	u32 dfistparlog;
+	u32 reserved12[3];
+	u32 dfilpcfg0;
+	u32 reserved13[3];
+	u32 dfitrwrlvlresp0;
+	u32 dfitrwrlvlresp1;
+	u32 dfitrwrlvlresp2;
+	u32 dfitrrdlvlresp0;
+	u32 dfitrrdlvlresp1;
+	u32 dfitrrdlvlresp2;
+	u32 dfitrwrlvldelay0;
+	u32 dfitrwrlvldelay1;
+	u32 dfitrwrlvldelay2;
+	u32 dfitrrdlvldelay0;
+	u32 dfitrrdlvldelay1;
+	u32 dfitrrdlvldelay2;
+	u32 dfitrrdlvlgatedelay0;
+	u32 dfitrrdlvlgatedelay1;
+	u32 dfitrrdlvlgatedelay2;
+	u32 dfitrcmd;
+	u32 reserved14[46];
+	u32 ipvr;
+	u32 iptr;
+};
+check_member(rk3368_ddr_pctl, iptr, 0x03fc);
+
+struct rk3368_ddrphy {
+	u32 reg[0x100];
+};
+check_member(rk3368_ddrphy, reg[0xff], 0x03fc);
+
+struct rk3368_msch {
+	u32 coreid;
+	u32 revisionid;
+	u32 ddrconf;
+	u32 ddrtiming;
+	u32 ddrmode;
+	u32 readlatency;
+	u32 reserved1[8];
+	u32 activate;
+	u32 devtodev;
+};
+check_member(rk3368_msch, devtodev, 0x003c);
+
+/* GRF_SOC_CON0 */
+enum {
+	NOC_RSP_ERR_STALL = BIT(9),
+	MOBILE_DDR_SEL = BIT(4),
+	DDR0_16BIT_EN = BIT(3),
+	MSCH0_MAINDDR3_DDR3 = BIT(2),
+	MSCH0_MAINPARTIALPOP = BIT(1),
+	UPCTL_C_ACTIVE = BIT(0),
+};
+
+#endif
arch/arm/include/asm/arch-rockchip/grf_rk3368.h +3 -10
index a97dc1e..f91a5fb 100644
@@ -76,8 +76,11 @@ struct rk3368_grf {
 	u32 soc_con15;
 	u32 soc_con16;
 	u32 soc_con17;
+	u32 reserved5[0x6e];
+	u32 ddrc0_con0;
 };
 check_member(rk3368_grf, soc_con17, 0x444);
+check_member(rk3368_grf, ddrc0_con0, 0x600);
 
 struct rk3368_pmu_grf {
 	u32 gpio0a_iomux;
@@ -406,16 +409,6 @@ enum {
 	RK3368_GPIO3D0_MAC_MDIO        = (1 << 0),
 };
 
-/* GRF_SOC_CON0 */
-enum {
-	NOC_RSP_ERR_STALL = BIT(9),
-	MOBILE_DDR_SEL = BIT(4),
-	DDR0_16BIT_EN = BIT(3),
-	MSCH0_MAINDDR3_DDR3 = BIT(2),
-	MSCH0_MAINPARTIALPOP = BIT(1),
-	UPCTL_C_ACTIVE = BIT(0),
-};
-
 /*GRF_SOC_CON11/12/13*/
 enum {
 	MCU_SRAM_BASE_BIT27_BIT12_SHIFT	= 0,
arch/arm/mach-rockchip/rk3368/Makefile +0 -1
index 0390716..46798c2 100644
@@ -5,5 +5,4 @@
 #
 obj-y		+= clk_rk3368.o
 obj-y		+= rk3368.o
-obj-y 		+= sdram_rk3368.o
 obj-y 		+= syscon_rk3368.o
arch/arm/mach-rockchip/rk3368/sdram_rk3368.c deleted +0 -60

60 lines not on this page · raw message

doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt new file +67 -0

67 lines not on this page · raw message

drivers/ram/Makefile +2 -0
index c409c48..51ae6be 100644
@@ -8,3 +8,5 @@ obj-$(CONFIG_RAM) += ram-uclass.o
 obj-$(CONFIG_SANDBOX) += sandbox_ram.o
 obj-$(CONFIG_STM32_SDRAM) += stm32_sdram.o
 obj-$(CONFIG_ARCH_BMIPS) += bmips_ram.o
+
+obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
drivers/ram/rockchip/Makefile new file +7 -0
new file mode 100644
index 0000000..b09d03c
@@ -0,0 +1,7 @@
+#
+# Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
+#
+# SPDX-License-Identifier:      GPL-2.0+
+#
+
+obj-$(CONFIG_ROCKCHIP_RK3368) = dmc-rk3368.o
drivers/ram/rockchip/dmc-rk3368.c new file +990 -0

990 lines not on this page · raw message

include/dt-bindings/memory/rk3368-dmc.h new file +30 -0
new file mode 100644
index 0000000..b06ffde
@@ -0,0 +1,30 @@
+#ifndef DT_BINDINGS_RK3368_DMC_H
+#define DT_BINDINGS_RK3368_DMC_H
+
+#define DMC_MSCH_CBDR       0x0
+#define DMC_MSCH_CBRD       0x1
+#define DMC_MSCH_CRBD       0x2
+
+#define DDR3_800D 0
+#define DDR3_800E 1
+#define DDR3_1066E 2
+#define DDR3_1066F 3
+#define DDR3_1066G 4
+#define DDR3_1333F 5
+#define DDR3_1333G 6
+#define DDR3_1333H 7
+#define DDR3_1333J 8
+#define DDR3_1600G 9
+#define DDR3_1600H 10
+#define DDR3_1600J 11
+#define DDR3_1600K 12
+#define DDR3_1866J 13
+#define DDR3_1866K 14
+#define DDR3_1866L 15
+#define DDR3_1866M 16
+#define DDR3_2133K 17
+#define DDR3_2133L 18
+#define DDR3_2133M 19
+#define DDR3_2133N 20
+
+#endif
Signature · 1 line
2.1.4
#59 lore raw

PATCH 45/52 rockchip: dts: rk3368: add DMC node in rk3368.dtsi

In reply to Philipp Tomsich

For full SPL support, including DRAM initialisation, we need a few nodes from the DTS: this commit adds the DMC (DRAM controller) node, the service_msch (memory scheduler) node and marks GRF, PMUGRF and CRU as 'u-boot,dm-pre-reloc'. In addition to this, we also include the dt-binding for the DMC to allow DTS files including this DTSI to refer to the symbolic constants for the DDR3 bin and for the memory-schedule.

Note that the DMC contains both the memory regions for the (Designware) protocol controller as well as the DDR PHY.

---

 arch/arm/dts/rk3368.dtsi | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)
arch/arm/dts/rk3368.dtsi +20 -6
index 9daf765..8dd6549 100644
@@ -46,6 +46,7 @@
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/pinctrl/rockchip.h>
 #include <dt-bindings/thermal/thermal.h>
+#include <dt-bindings/memory/rk3368-dmc.h>
 
 / {
 	compatible = "rockchip,rk3368";
@@ -227,6 +228,23 @@
 		#clock-cells = <0>;
 	};
 
+	dmc: dmc at ff610000 {
+		u-boot,dm-pre-reloc;
+		compatible = "rockchip,rk3368-dmc", "syscon";
+		rockchip,cru = <&cru>;
+		rockchip,grf = <&grf>;
+		rockchip,msch = <&service_msch>;
+		reg = <0 0xff610000 0 0x400
+		       0 0xff620000 0 0x400>;
+	};
+
+	service_msch: syscon at ffac0000 {
+		u-boot,dm-pre-reloc;
+		compatible = "rockchip,rk3368-msch", "syscon";
+		reg = <0x0 0xffac0000 0x0 0x2000>;
+		status = "okay";
+	};
+
 	sdmmc: dwmmc at ff0c0000 {
 		compatible = "rockchip,rk3368-dw-mshc", "rockchip,rk3288-dw-mshc";
 		reg = <0x0 0xff0c0000 0x0 0x4000>;
@@ -546,12 +564,6 @@
 		status = "disabled";
 	};
 
-	dmc: dmc at ff610000 {
-		u-boot,dm-pre-reloc;
-		compatible = "rockchip,rk3368-dmc", "syscon";
-		reg = <0x0 0xff610000 0x0 0x1000>;
-	};
-
 	i2c0: i2c at ff650000 {
 		compatible = "rockchip,rk3368-i2c", "rockchip,rk3288-i2c";
 		reg = <0x0 0xff650000 0x0 0x1000>;
@@ -653,6 +665,7 @@
 	};
 
 	cru: clock-controller at ff760000 {
+		u-boot,dm-pre-reloc;
 		compatible = "rockchip,rk3368-cru";
 		reg = <0x0 0xff760000 0x0 0x1000>;
 		rockchip,grf = <&grf>;
@@ -661,6 +674,7 @@
 	};
 
 	grf: syscon at ff770000 {
+		u-boot,dm-pre-reloc;
 		compatible = "rockchip,rk3368-grf", "syscon";
 		reg = <0x0 0xff770000 0x0 0x1000>;
 	};
Signature · 1 line
2.1.4
#60 lore raw

PATCH 45/52 rockchip: dts: rk3368: add DMC node in rk3368.dtsi

Hi Philipp:

Quoted 67 lines · Philipp Tomsich

For full SPL support, including DRAM initialisation, we need a few nodes from the DTS: this commit adds the DMC (DRAM controller) node, the service_msch (memory scheduler) node and marks GRF, PMUGRF and CRU as 'u-boot,dm-pre-reloc'. In addition to this, we also include the dt-binding for the DMC to allow DTS files including this DTSI to refer to the symbolic constants for the DDR3 bin and for the memory-schedule.

Note that the DMC contains both the memory regions for the (Designware) protocol controller as well as the DDR PHY.

---

  arch/arm/dts/rk3368.dtsi | 26 ++++++++++++++++++++------
  1 file changed, 20 insertions(+), 6 deletions(-)
arch/arm/dts/rk3368.dtsi +18 -6
index 9daf765..8dd6549 100644
@@ -46,6 +46,7 @@
  #include <dt-bindings/interrupt-controller/arm-gic.h>
  #include <dt-bindings/pinctrl/rockchip.h>
  #include <dt-bindings/thermal/thermal.h>
+#include <dt-bindings/memory/rk3368-dmc.h>
 
  / {
  	compatible = "rockchip,rk3368";
@@ -227,6 +228,23 @@
  		#clock-cells = <0>;
  	};
 
+	dmc: dmc at ff610000 {
+		u-boot,dm-pre-reloc;
+		compatible = "rockchip,rk3368-dmc", "syscon";
+		rockchip,cru = <&cru>;
+		rockchip,grf = <&grf>;
+		rockchip,msch = <&service_msch>;
+		reg = <0 0xff610000 0 0x400
+		       0 0xff620000 0 0x400>;
+	};
+
+	service_msch: syscon at ffac0000 {
+		u-boot,dm-pre-reloc;
+		compatible = "rockchip,rk3368-msch", "syscon";
+		reg = <0x0 0xffac0000 0x0 0x2000>;
+		status = "okay";
+	};
+
  	sdmmc: dwmmc at ff0c0000 {
  		compatible = "rockchip,rk3368-dw-mshc", "rockchip,rk3288-dw-mshc";
  		reg = <0x0 0xff0c0000 0x0 0x4000>;
@@ -546,12 +564,6 @@
  		status = "disabled";
  	};
 
-	dmc: dmc at ff610000 {
-		u-boot,dm-pre-reloc;
-		compatible = "rockchip,rk3368-dmc", "syscon";
-		reg = <0x0 0xff610000 0x0 0x1000>;
-	};
-
  	i2c0: i2c at ff650000 {
  		compatible = "rockchip,rk3368-i2c", "rockchip,rk3288-i2c";
  		reg = <0x0 0xff650000 0x0 0x1000>;

arch/arm/dts/rk3368.dtsi line 668

Quoted 4 lines
arch/arm/dts/rk3368.dtsi +1 -0
@@ -653,6 +665,7 @@
  	};
 
  	cru: clock-controller at ff760000 {
+		u-boot,dm-pre-reloc;

As U-BOOT has introduced xxx-u-boot.dtsi for the U-BOOT-spceific
dt information. I think it's better to put this u-boot needed things in rk3368-u-boot.dtsi. It will make things easier when we need to sync the dts with upstream kernel.

Quoted 11 lines
arch/arm/dts/rk3368.dtsi +1 -0
  		compatible = "rockchip,rk3368-cru";
  		reg = <0x0 0xff760000 0x0 0x1000>;
  		rockchip,grf = <&grf>;
@@ -661,6 +674,7 @@
  	};
 
  	grf: syscon at ff770000 {
+		u-boot,dm-pre-reloc;
  		compatible = "rockchip,rk3368-grf", "syscon";
  		reg = <0x0 0xff770000 0x0 0x1000>;
  	};
#61 lore raw

PATCH 46/52 rockchip: rk3368: spl: enable SPL_FRAMEWORK in rk3368_common.h

In reply to Philipp Tomsich

To build TPL and SPL stages for the RK3368, we will also need to enable the SPL_FRAMEWORK.

---

 include/configs/rk3368_common.h | 1 +
 1 file changed, 1 insertion(+)
include/configs/rk3368_common.h +1 -0
index 8ffc293..2a3876e 100644
@@ -24,6 +24,7 @@
 
 #define COUNTER_FREQUENCY               24000000
 
+#define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SYS_NS16550_MEM32
 
 #define CONFIG_SYS_TEXT_BASE		0x00200000
Signature · 1 line
2.1.4
#62 lore raw

PATCH 47/52 rockchip: rk3368: spl: add TPL support

In reply to Philipp Tomsich

This adds the TPL support for the RK3368, including the u-boot-tpl.lds.

---

 arch/arm/mach-rockchip/Makefile              |   1 +
 arch/arm/mach-rockchip/rk3368-board-tpl.c    | 158 +++++++++++++++++++++++++++
 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds |  13 +++
 3 files changed, 172 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/rk3368-board-tpl.c
 create mode 100644 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds
arch/arm/mach-rockchip/Makefile +1 -0
index 633c91e..960f40f 100644
@@ -12,6 +12,7 @@ obj-spl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o save_boot_param.o
 obj-tpl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o save_boot_param.o
 
 obj-tpl-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board-tpl.o
+obj-tpl-$(CONFIG_ROCKCHIP_RK3368) += rk3368-board-tpl.o
 
 obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
 obj-spl-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board-spl.o
arch/arm/mach-rockchip/rk3368-board-tpl.c new file +158 -0

158 lines not on this page · raw message

arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds new file +13 -0
new file mode 100644
index 0000000..cc59844
@@ -0,0 +1,13 @@
+/*
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#undef CONFIG_SPL_TEXT_BASE
+#define CONFIG_SPL_TEXT_BASE CONFIG_TPL_TEXT_BASE
+
+#undef CONFIG_SPL_MAX_SIZE
+#define CONFIG_SPL_MAX_SIZE CONFIG_TPL_MAX_SIZE
+
+#include "../../cpu/armv8/u-boot-spl.lds"
Signature · 1 line
2.1.4
#63 lore raw

PATCH 48/52 rockchip: rk3368: spl: add SPL support

In reply to Philipp Tomsich

Adds SPL support for the RK3368 (assuming that our TPL stage has initialised DRAM and set up the memory firewall).

This includes an implementation of board_debug_uart_init().

---

 arch/arm/mach-rockchip/rk3368-board-spl.c | 91 +++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/rk3368-board-spl.c
arch/arm/mach-rockchip/rk3368-board-spl.c new file +91 -0
new file mode 100644
index 0000000..eefe3bf
@@ -0,0 +1,91 @@
+/*
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include <debug_uart.h>
+#include <dm.h>
+#include <ram.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/bootrom.h>
+#include <asm/arch/cru_rk3368.h>
+#include <asm/arch/grf_rk3368.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/timer.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * The ARMv8 generic timer uses the STIMER1 as its clock-source.
+ * Set up the STIMER1 to free-running (i.e. auto-reload) to start
+ * the generic timer counting (if we don't do this, udelay will not
+ * work and block indefinitively).
+ */
+static void secure_timer_init(void)
+{
+	struct rk_timer * const stimer1 =
+		(struct rk_timer * const)0xff830020;
+	const u32 TIMER_EN = BIT(0);
+
+	writel(~0u, &stimer1->timer_load_count0);
+	writel(~0u, &stimer1->timer_load_count1);
+	writel(TIMER_EN, &stimer1->timer_ctrl_reg);
+}
+
+void board_debug_uart_init(void)
+{
+	struct rk3368_grf * const grf =
+		(struct rk3368_grf * const)0xff770000;
+
+#if defined(CONFIG_DEBUG_UART_BASE) && (CONFIG_DEBUG_UART_BASE == 0xff180000)
+	/* Enable early UART0 on the RK3368 */
+	rk_clrsetreg(&grf->gpio2d_iomux,
+		     RK3368_GPIO2D0_MASK, RK3368_GPIO2D0_UART0_SIN);
+	rk_clrsetreg(&grf->gpio2d_iomux,
+		     RK3368_GPIO2D1_MASK, RK3368_GPIO2D1_UART0_SOUT);
+#endif
+}
+
+void board_init_f(ulong dummy)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = spl_early_init();
+	if (ret) {
+		debug("spl_early_init() failed: %d\n", ret);
+		hang();
+	}
+
+	/* Make sure the ARMv8 generic timer counts */
+	secure_timer_init();
+
+	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
+	if (ret) {
+		debug("DRAM init failed: %d\n", ret);
+		return;
+	}
+}
+
+u32 spl_boot_mode(const u32 boot_device)
+{
+	return MMCSD_MODE_RAW;
+}
+
+u32 spl_boot_device(void)
+{
+	return BOOT_DEVICE_MMC1;
+}
+
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name)
+{
+	/* Just empty function now - can't decide what to choose */
+	debug("%s: %s\n", __func__, name);
+
+	return 0;
+}
+#endif
Signature · 1 line
2.1.4
#64 lore raw

PATCH 49/52 rockchip: rk3368: spl: mark SPL and TPL as supported for ROCKCHIP_RK3368

In reply to Philipp Tomsich

With SPL and TPL support for the RK3368 in place, mark SPL and TPL as supported from Kconfig for the RK3368. As this is primarily tested on the RK3368-uQ7, we'll leave it to board's individual defconfig to enable.

Also enable DEBUG_UART_BOARD_INIT for the RK3368, so we get output during the early boot-up, as we turn on TPL and SPL.

---

 arch/arm/mach-rockchip/Kconfig | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/mach-rockchip/Kconfig +7 -0
index 2ad4943..fd08897 100644
@@ -67,6 +67,13 @@ config ROCKCHIP_RK3328
 config ROCKCHIP_RK3368
 	bool "Support Rockchip RK3368"
 	select ARM64
+	select SUPPORT_SPL
+	select SUPPORT_TPL
+	select SPL_SEPARATE_BSS
+	select SPL_SERIAL_SUPPORT
+	select TPL_SERIAL_SUPPORT
+	select ENABLE_ARM_SOC_BOOT0_HOOK
+	select DEBUG_UART_BOARD_INIT
 	select SYS_NS16550
 	help
 	  The Rockchip RK3368 is a ARM-based SoC with a octa-core (organised
Signature · 1 line
2.1.4
#65 lore raw

PATCH 50/52 rockchip: board: lion-rk3368: add support for the RK3368-uQ7

In reply to Philipp Tomsich

The RK3368-uQ7 (codenamed 'Lion') is a micro-Qseven (40mm x 70mm, MXM-230 edge connector compatible with the Qseven specification) form-factor system-on-module based on the octo-core Rockchip RK3368. It is designed, supported and manufactured by Theobroma Systems.

It provides the following features:
- 8x Cortex-A53 (in 2 clusters of 4 cores each)
- (on-module) up to 4GB of DDR3 memory
- (on-module) SPI-NOR flash
- (on-module) eMMC
- Gigabit Ethernet (with an on-module KSZ9031 PHY)
- USB
- HDMI
- MIPI-DSI/single-channel LVDS (muxed on the 'LVDS-A' pin-group)
- various 'slow' interfaces (e.g. UART, SPI, I2C, I2S, ...)

---

 arch/arm/dts/Makefile                              |   1 +
 arch/arm/dts/rk3368-lion.dts                       | 209 +++++++++++++++++++++
 arch/arm/mach-rockchip/rk3368/Kconfig              |  21 +++
 board/theobroma-systems/lion_rk3368/Kconfig        |  15 ++
 board/theobroma-systems/lion_rk3368/MAINTAINERS    |  10 +
 board/theobroma-systems/lion_rk3368/Makefile       |   7 +
 board/theobroma-systems/lion_rk3368/README         |  60 ++++++
 .../theobroma-systems/lion_rk3368/fit_spl_atf.its  |  51 +++++
 board/theobroma-systems/lion_rk3368/lion_rk3368.c  |  25 +++
 configs/lion-rk3368_defconfig                      |  79 ++++++++
 include/configs/lion_rk3368.h                      |  19 ++
 11 files changed, 497 insertions(+)
 create mode 100644 arch/arm/dts/rk3368-lion.dts
 create mode 100644 board/theobroma-systems/lion_rk3368/Kconfig
 create mode 100644 board/theobroma-systems/lion_rk3368/MAINTAINERS
 create mode 100644 board/theobroma-systems/lion_rk3368/Makefile
 create mode 100644 board/theobroma-systems/lion_rk3368/README
 create mode 100644 board/theobroma-systems/lion_rk3368/fit_spl_atf.its
 create mode 100644 board/theobroma-systems/lion_rk3368/lion_rk3368.c
 create mode 100644 configs/lion-rk3368_defconfig
 create mode 100644 include/configs/lion_rk3368.h
arch/arm/dts/Makefile +1 -0
index fd28290..5a22bb1 100644
@@ -42,6 +42,7 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += \
 	rk3288-veyron-mickey.dtb \
 	rk3288-veyron-minnie.dtb \
 	rk3328-evb.dtb \
+	rk3368-lion.dtb \
 	rk3368-sheep.dtb \
 	rk3368-geekbox.dtb \
 	rk3368-px5-evb.dtb \
arch/arm/dts/rk3368-lion.dts new file +209 -0

209 lines not on this page · raw message

arch/arm/mach-rockchip/rk3368/Kconfig +21 -0
index 6d32068..f8189f1 100644
@@ -3,6 +3,26 @@ if ROCKCHIP_RK3368
 choice
 	prompt "RK3368 board"
 
+config TARGET_LION_RK3368
+        bool "Theobroma Systems RK3368-uQ7 (Lion) module"
+	help
+	  The RK3368-uQ7 is a micro-Qseven form-factor (40mm x 70mm,
+	  MXM-230 connector) system-on-module designed by Theobroma
+	  Systems for industrial applications.
+
+	  It provides the following features:
+	   - 8x Cortex-A53 (in 2 clusters of 4 cores each)
+	   - (on-module) up to 4GB of DDR3 memory
+	   - (on-module) SPI-NOR flash
+	   - (on-module) eMMC
+	   - Gigabit Ethernet (with an on-module KSZ9031 PHY)
+	   - USB
+	   - HDMI
+	   - MIPI-DSI/single-channel LVDS (muxed on the 'LVDS-A' pin-group)
+	   - various 'slow' interfaces (e.g. UART, SPI, I2C, I2S, ...)
+	   - on-module STM32 providing CAN, RTC and fan-control
+	   - (optional on-module) EAL4+-certified security module
+
 config TARGET_SHEEP
 	bool "Sheep board"
 	help
@@ -25,6 +45,7 @@ endchoice
 config SYS_SOC
 	default "rockchip"
 
+source "board/theobroma-systems/lion_rk3368/Kconfig"
 source "board/rockchip/sheep_rk3368/Kconfig"
 source "board/geekbuying/geekbox/Kconfig"
 source "board/rockchip/evb_px5/Kconfig"
board/theobroma-systems/lion_rk3368/Kconfig new file +15 -0
new file mode 100644
index 0000000..d7aa487
@@ -0,0 +1,15 @@
+if TARGET_LION_RK3368
+
+config SYS_BOARD
+	default "lion_rk3368"
+
+config SYS_VENDOR
+	default "theobroma-systems"
+
+config SYS_CONFIG_NAME
+	default "lion_rk3368"
+
+config BOARD_SPECIFIC_OPTIONS # dummy
+	def_bool y
+
+endif
board/theobroma-systems/lion_rk3368/MAINTAINERS new file +10 -0
new file mode 100644
index 0000000..857f784
@@ -0,0 +1,10 @@
+LION-RK3368 (RK3368-uQ7 system-on-module)
+M:	Philipp Tomsich <[email protected]>
+M:	Klaus Goger <[email protected]>
+S:	Maintained
+F:	board/theobroma-systems/lion_rk3368
+F:	include/configs/lion_rk3368.h
+F:	arch/arm/dts/rk3368-lion.dts
+F:	configs/lion-rk3368_defconfig
+W:	https://www.theobroma-systems.com/rk3368-uq7/tech-specs
+T:	git git://git.theobroma-systems.com/lion-u-boot.git
board/theobroma-systems/lion_rk3368/Makefile new file +7 -0
new file mode 100644
index 0000000..f13a20b
@@ -0,0 +1,7 @@
+#
+# Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y += lion_rk3368.o
board/theobroma-systems/lion_rk3368/README new file +60 -0

60 lines not on this page · raw message

board/theobroma-systems/lion_rk3368/fit_spl_atf.its new file +51 -0

51 lines not on this page · raw message

board/theobroma-systems/lion_rk3368/lion_rk3368.c new file +25 -0
new file mode 100644
index 0000000..73b1488
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+#include <common.h>
+#include <dm.h>
+#include <ram.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/grf_rk3368.h>
+#include <asm/arch/timer.h>
+#include <syscon.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int mach_cpu_init(void)
+{
+	return 0;
+}
+
+int board_init(void)
+{
+	return 0;
+}
configs/lion-rk3368_defconfig new file +79 -0

79 lines not on this page · raw message

include/configs/lion_rk3368.h new file +19 -0
new file mode 100644
index 0000000..1f25b31
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#ifndef __CONFIGS_LION_RK3368_H
+#define __CONFIGS_LION_RK3368_H
+
+#include <configs/rk3368_common.h>
+
+#define CONFIG_SYS_MMC_ENV_DEV		0
+#define KERNEL_LOAD_ADDR		0x280000
+#define DTB_LOAD_ADDR			0x5600000
+#define INITRD_LOAD_ADDR		0x5bf0000
+#define CONFIG_ENV_IS_NOWHERE
+#define CONFIG_ENV_SIZE			0x2000
+
+#endif
Signature · 1 line
2.1.4
#66 lore raw

PATCH 51/52 rockchip: board: puma-rk3399: fix warnings in puma_rk3399/fit_spl_atf.its

In reply to Philipp Tomsich

The ITS file generated warnings due to @<num> designations in the naming
which cause DTC to complain as follows:
Warning (unit_address_vs_reg): Node /images/uboot at 1 has a unit name, but no reg property Warning (unit_address_vs_reg): Node /images/atf at 1 has a unit name, but no reg property Warning (unit_address_vs_reg): Node /images/pmu at 1 has a unit name, but no reg property Warning (unit_address_vs_reg): Node /images/fdt at 1 has a unit name, but no reg property Warning (unit_address_vs_reg): Node /configurations/conf at 1 has a unit name, but no reg property

This removes the @<num> part from the names, as we only have a single image for each payload aspect (and only a single configuration) anyway.

---

 board/theobroma-systems/puma_rk3399/fit_spl_atf.its | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
board/theobroma-systems/puma_rk3399/fit_spl_atf.its +9 -9
index f93c251..0519fad 100644
@@ -13,7 +13,7 @@
 	#address-cells = <1>;
 
 	images {
-		uboot at 1 {
+		uboot {
 			description = "U-Boot (64-bit)";
 			data = /incbin/("../../../u-boot-nodtb.bin");
 			type = "standalone";
@@ -21,7 +21,7 @@
 			compression = "none";
 			load = <0x00200000>;
 		};
-		atf at 1 {
+		atf {
 			description = "ARM Trusted Firmware";
 			data = /incbin/("../../../bl31.bin");
 			type = "firmware";
@@ -30,14 +30,14 @@
 			load = <0x00001000>;
 			entry = <0x00001000>;
 		};
-		pmu at 1 {
+		pmu {
 		        description = "Cortex-M0 firmware";
 			data = /incbin/("../../../rk3399m0.bin");
 			type = "pmu-firmware";
 			compression = "none";
 			load = <0xff8c0000>;
                 };
-		fdt at 1 {
+		fdt {
 			description = "RK3399-Q7 (Puma) flat device-tree";
 			data = /incbin/("../../../u-boot.dtb");
 			type = "flat_dt";
@@ -46,12 +46,12 @@
 	};
 
 	configurations {
-		default = "conf at 1";
-		conf at 1 {
+		default = "conf";
+		conf {
 			description = "Theobroma Systems RK3399-Q7 (Puma) SoM";
-			firmware = "uboot at 1";
-			loadables = "atf at 1";
-			fdt = "fdt at 1";
+			firmware = "uboot";
+			loadables = "atf";
+			fdt = "fdt";
 		};
 	};
 };
Signature · 1 line
2.1.4
#67 lore raw

PATCH 52/52 rockchip: board: puma_rk3399: rename ATF firmware

In reply to Philipp Tomsich

From: Klaus Goger <[email protected]>

Prefix the bl31 firmware needed to build uboot.itb so it can coexist in the build area with ATFs from other boards (i.e. lion_rk3368).

---

 board/theobroma-systems/puma_rk3399/README          | 2 +-
 board/theobroma-systems/puma_rk3399/fit_spl_atf.its | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
board/theobroma-systems/puma_rk3399/README +1 -1
index 250e345..214281a 100644
@@ -37,7 +37,7 @@ Compile the ATF
 
   > cd arm-trusted-firmware
   > make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31
-  > cp build/rk3399/release/bl31.bin ../u-boot
+  > cp build/rk3399/release/bl31.bin ../u-boot/bl31-rk3399.bin
 
 Compile the M0 firmware
 =======================
board/theobroma-systems/puma_rk3399/fit_spl_atf.its +1 -1
index 0519fad..520f846 100644
@@ -23,7 +23,7 @@
 		};
 		atf {
 			description = "ARM Trusted Firmware";
-			data = /incbin/("../../../bl31.bin");
+			data = /incbin/("../../../bl31-rk3399.bin");
 			type = "firmware";
 			arch = "arm64";
 			compression = "none";
Signature · 1 line
2.1.4
#68 lore raw

cover Support OF_PLATDATA in TPL, enable RK3368 DRAM init and add RK3368-uQ7

In reply to Philipp Tomsich

Hi:

Quoted 6 lines · Philipp Tomsich

Here's a series that has a lot going on, but I didn't want to split it to allow everyone to understand the motivation between some of the changes to the SPL/TPL framework. The short summary of this is "enablement for DRAM init on the RK3368 with everything else that's necessary to do it using OF_PLATDATA in TPL".

Quoted 9 lines

Enabling the RK3368 created a few more challenges that I'd expected:
- I needed different stack locations, text addresses and sizes for TPL and SPL
- the TPL stage was to use OF_PLATDATA and SPL was to use full OF_CONTROL
- with the RK3368 TPL stage, there was a need to extend the back-to-bootrom support for Rockchip to AArch64
- I wanted to start folding some of the Rockchip specific SPL support (i.e. back-to-bootrom) back into the general SPL framework to allow using it as a general boot method

I have a confusion here: according to the README.TPL, TPL is Third Program Loader, which loaded by the SPL. So I think it should run after the SPL. But from RK3188 and RK3368 TPL implementation , they all run before SPL.Maybe it is my misunderstanding, hope to get some guidance.:-)

Quoted 180 lines

So I ended up separating quite a bit of features between SPL and TPL while keeping things transparent to the few other boards using TPL (at least I hope that things are transparent, as we didn't have any of those in our lab to test on)...

Tested with: RK3368-uQ7, Debian 9, Linux 4.13-rc1.

Just one final remark: the DMC driver for the RK3368 currently covers the configuration we use on the RK3368-uQ7 (i.e. 32bit wide, 2 ranks) and is stress-tested (including 8-way SPEC runs) at all 3 supported speeds. I've built a bit of infrastructure (e.g. the way the memory-schedule is determined) that I hope will be a useful starting-point in unifying the drivers for the various closely related DRAM controllers (e.g. for the RK3288) for Rockchip devices in the future.

Klaus Goger (1):
rockchip: board: puma_rk3399: rename ATF firmware

Philipp Tomsich (51):
spl: add a 'return to bootrom' boot method
spl: configure 'return to bootrom' separately for SPL and TPL
rockchip: back-to-bootrom: add 'back-to-bootrom' support for AArch64
rockchip: back-to-bootrom: split BACK_TO_BOOTROM for TPL/SPL
rockchip: back-to-bootrom: simplify the #ifdef-check for LIBGENERIC in
TPL/SPL
spl: dm: Kconfig: use more specific prereqs for SPL_REGMAP and
SPL_SYSCON
spl: dm: Kconfig: split REGMAP/SYSCON support for TPL from SPL
spl: dm: Kconfig: SPL_RAM depends on SPL_DM
spl: dm: Kconfig: introduce TPL_RAM (in analogy to SPL_RAM)
spl: dm: Kconfig: SPL_CLK depens on SPL_DM
spl: dm: Kconfig: split CLK support for SPL and TPL
spl: dm: Kconfig: split OF_CONTROL and OF_PLATDATA between SPL and TPL
spl: dm: use CONFIG_IS_ENABLED to test for the DM option
armv8: remove unused low-level modules from TPL
armv8: spl: Support separate stack for TPL
spl: allow a separate TEXT_BASE, LDSCRIPT and MAX_SIZE for TPL
spl: Kconfig: split SYS_MALLOC_SIMPLE for TPL and SPL
lib: spl: differentiate between TPL and SPL for
libfdt/of_control/of_platdata
spl: consistently use $(SPL_TPL_) to select features for SPL and TPL
builds
spl: add TPL_DRIVER_MISC_SUPPORT option
drivers: spl: consistently use the $(SPL_TPL_) macro
rockchip: Makefile: allow selective inclusion of sdram_common.o from
TPL/SPL/U-Boot
rockchip: rk3368: improve Kconfig text for the RK3368
rockchip: rk3368: mkimage: add support for the RK3368
rockchip: rk3368: pmugrf: add definitions for os_reg[0..3]
rockchip: rk3368: define CONFIG_SYS_SDRAM_BASE
rockchip: rk3368: spl: define COUNTER_FREQUENCY to 24MHz
rockchip: rk3368: spl: add memory layout for TPL and SPL
rockchip: rk3368: syscon: MSCH/PMUGRF/GRF support for OF_PLATDATA
rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_
rockchip: pinctrl: rk3368: add GMAC (RGMII only) support
rockchip: pinctrl: rk3368: add support for configuring the MMC pins
rockchip: clk: rk3368: implement bandwidth adjust for PLLs
rockchip: clk: rk3368: support OF_PLATDATA for the RK3368 clk driver
rockchip: clk: rk3368: do not change CPLL/GPLL before returning to
BROM
rockchip: clk: rk3368: implement DPLL (DRAM PLL) support
rockchip: clk: rk3368: define DMA1_SRST_REQ and DMA2_SRST_REQ
rockchip: clk: rk3368: implement MMC/SD clock reparenting
rockchip: clk: rk3368: support configuring the DRAM PLL (from TPL)
rockchip: clk: rk3368: add support for GMAC (SLCK_MAC) clock
rockchip: clk: rk3368: mark 'priv' __maybe_unused in

     rk3368_clk_set_rate()
   net: gmac_rockchip: Add support for the RK3368 GMAC
   rockchip: Makefile: streamline SPL/TPL configuration
   rockchip: rk3368: add DRAM controller driver with DRAM initialisation
   rockchip: dts: rk3368: add DMC node in rk3368.dtsi
   rockchip: rk3368: spl: enable SPL_FRAMEWORK in rk3368_common.h
   rockchip: rk3368: spl: add TPL support
   rockchip: rk3368: spl: add SPL support
   rockchip: rk3368: spl: mark SPL and TPL as supported for
     ROCKCHIP_RK3368
   rockchip: board: lion-rk3368: add support for the RK3368-uQ7
   rockchip: board: puma-rk3399: fix warnings in
     puma_rk3399/fit_spl_atf.its
  Makefile                                           |   2 +-
  arch/arm/cpu/armv8/Makefile                        |   4 +-
  arch/arm/dts/Makefile                              |   1 +
  arch/arm/dts/rk3368-lion.dts                       | 209 +++++
  arch/arm/dts/rk3368.dtsi                           |  26 +-
  arch/arm/include/asm/arch-rockchip/cru_rk3368.h    |  15 +-
  arch/arm/include/asm/arch-rockchip/ddr_rk3368.h    | 187 ++++
  arch/arm/include/asm/arch-rockchip/grf_rk3368.h    | 615 +++++++------
  arch/arm/include/asm/spl.h                         |   1 +
  arch/arm/lib/crt0_64.S                             |   4 +-
  arch/arm/mach-rockchip/Kconfig                     |  37 +-
  arch/arm/mach-rockchip/Makefile                    |  51 +-
  arch/arm/mach-rockchip/bootrom.c                   |   4 +-
  arch/arm/mach-rockchip/rk3188-board-spl.c          |   5 +-
  arch/arm/mach-rockchip/rk3188-board.c              |   2 +-
  arch/arm/mach-rockchip/rk3288-board-spl.c          |   4 +-
  arch/arm/mach-rockchip/rk3288-board.c              |   4 +-
  arch/arm/mach-rockchip/rk3368-board-spl.c          |  91 ++
  arch/arm/mach-rockchip/rk3368-board-tpl.c          | 158 ++++
  arch/arm/mach-rockchip/rk3368/Kconfig              |  21 +
  arch/arm/mach-rockchip/rk3368/Makefile             |   1 -
  arch/arm/mach-rockchip/rk3368/sdram_rk3368.c       |  60 --
  arch/arm/mach-rockchip/rk3368/syscon_rk3368.c      |  35 +
  arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds       |  13 +
  arch/arm/mach-rockchip/rk3399-board-spl.c          |   4 +-
  arch/arm/mach-rockchip/save_boot_param.S           |  37 +
  board/theobroma-systems/lion_rk3368/Kconfig        |  15 +
  board/theobroma-systems/lion_rk3368/MAINTAINERS    |  10 +
  board/theobroma-systems/lion_rk3368/Makefile       |   7 +
  board/theobroma-systems/lion_rk3368/README         |  60 ++
  .../theobroma-systems/lion_rk3368/fit_spl_atf.its  |  51 ++
  board/theobroma-systems/lion_rk3368/lion_rk3368.c  |  25 +
  board/theobroma-systems/puma_rk3399/README         |   2 +-
  .../theobroma-systems/puma_rk3399/fit_spl_atf.its  |  20 +-
  common/Makefile                                    |   8 +-
  common/spl/Kconfig                                 |  39 +
  common/spl/Makefile                                |  35 +-
  common/spl/spl.c                                   |   5 +-
  common/spl/spl_bootrom.c                           |  27 +
  configs/evb-rk3288_defconfig                       |   2 +-
  configs/fennec-rk3288_defconfig                    |   2 +-
  configs/firefly-rk3288_defconfig                   |   2 +-
  configs/lion-rk3368_defconfig                      |  79 ++
  configs/miqi-rk3288_defconfig                      |   2 +-
  configs/popmetal-rk3288_defconfig                  |   2 +-
  configs/rock2_defconfig                            |   2 +-
  configs/rock_defconfig                             |   2 +-
  configs/tinker-rk3288_defconfig                    |   2 +-
  doc/README.rockchip                                |   2 +-
  .../clock/rockchip,rk3368-dmc.txt                  |  67 ++
  drivers/Makefile                                   |  36 +-
  drivers/clk/Kconfig                                |  12 +-
  drivers/clk/Makefile                               |   2 +-
  drivers/clk/rockchip/clk_rk3368.c                  | 222 ++++-
  drivers/core/Kconfig                               |  23 +-
  drivers/core/Makefile                              |   4 +-
  drivers/net/gmac_rockchip.c                        |  54 ++
  drivers/pinctrl/rockchip/pinctrl_rk3368.c          | 101 ++-
  drivers/ram/Kconfig                                |  11 +-
  drivers/ram/Makefile                               |   2 +
  drivers/ram/rockchip/Makefile                      |   7 +
  drivers/ram/rockchip/dmc-rk3368.c                  | 990 +++++++++++++++++++++
  dts/Kconfig                                        |  29 +
  include/configs/lion_rk3368.h                      |  19 +
  include/configs/rk3188_common.h                    |   2 +-
  include/configs/rk3288_common.h                    |   2 +-
  include/configs/rk3368_common.h                    |  15 +
  include/configs/rock.h                             |   2 +-
  include/configs/rockchip-common.h                  |   2 +-
  include/dt-bindings/memory/rk3368-dmc.h            |  30 +
  include/linux/kconfig.h                            |  13 +
  include/spl.h                                      |  10 +
  lib/Makefile                                       |  10 +-
  scripts/Makefile.spl                               |  14 +-
  scripts/config_whitelist.txt                       |   4 +
  tools/rkcommon.c                                   |   1 +
  76 files changed, 3142 insertions(+), 534 deletions(-)

create mode 100644 arch/arm/dts/rk3368-lion.dts
create mode 100644 arch/arm/include/asm/arch-rockchip/ddr_rk3368.h create mode 100644 arch/arm/mach-rockchip/rk3368-board-spl.c create mode 100644 arch/arm/mach-rockchip/rk3368-board-tpl.c delete mode 100644 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c create mode 100644 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds create mode 100644 board/theobroma-systems/lion_rk3368/Kconfig create mode 100644 board/theobroma-systems/lion_rk3368/MAINTAINERS create mode 100644 board/theobroma-systems/lion_rk3368/Makefile create mode 100644 board/theobroma-systems/lion_rk3368/README create mode 100644 board/theobroma-systems/lion_rk3368/fit_spl_atf.its create mode 100644 board/theobroma-systems/lion_rk3368/lion_rk3368.c create mode 100644 common/spl/spl_bootrom.c
create mode 100644 configs/lion-rk3368_defconfig
create mode 100644 doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt create mode 100644 drivers/ram/rockchip/Makefile
create mode 100644 drivers/ram/rockchip/dmc-rk3368.c
create mode 100644 include/configs/lion_rk3368.h
create mode 100644 include/dt-bindings/memory/rk3368-dmc.h

#69 lore raw

cover Support OF_PLATDATA in TPL, enable RK3368 DRAM init and add RK3368-uQ7

Quoted 23 lines · Andy Yan

Hi:

Quoted 6 lines · Philipp Tomsich

Here's a series that has a lot going on, but I didn't want to split it to allow everyone to understand the motivation between some of the changes to the SPL/TPL framework. The short summary of this is "enablement for DRAM init on the RK3368 with everything else that's necessary to do it using OF_PLATDATA in TPL".

Quoted 9 lines

Enabling the RK3368 created a few more challenges that I'd expected:
- I needed different stack locations, text addresses and sizes for TPL and SPL
- the TPL stage was to use OF_PLATDATA and SPL was to use full OF_CONTROL
- with the RK3368 TPL stage, there was a need to extend the back-to-bootrom support for Rockchip to AArch64
- I wanted to start folding some of the Rockchip specific SPL support (i.e. back-to-bootrom) back into the general SPL framework to allow using it as a general boot method

Quoted 1 line

I have a confusion here: according to the README.TPL, TPL is Third Program Loader, which loaded by the SPL. So I think it should run after the SPL. But from RK3188 and RK3368 TPL implementation , they all run before SPL.Maybe it is my misunderstanding, hope to get some guidance.:-)

I think you are right and most Rockchip boards have been using this the wrong way around.

With the fine-grained configurability that I created for the RK3368, it will be easy enough to switch this around on the RK3368. However, this will then also be done for the other RK3xxx devices to restore consistency.

I would prefer to first add the RK3368 support with the “backwards TPL/SPL” (i.e. TPL before SPL) to remain consistent with current mach-rockchip usage of the TPL/SPL terminology. Once this is merged, we can then switch this around for each board individually.

Quoted 179 lines
Quoted 179 lines

So I ended up separating quite a bit of features between SPL and TPL while keeping things transparent to the few other boards using TPL (at least I hope that things are transparent, as we didn't have any of those in our lab to test on)...

Tested with: RK3368-uQ7, Debian 9, Linux 4.13-rc1.

Just one final remark: the DMC driver for the RK3368 currently covers the configuration we use on the RK3368-uQ7 (i.e. 32bit wide, 2 ranks) and is stress-tested (including 8-way SPEC runs) at all 3 supported speeds. I've built a bit of infrastructure (e.g. the way the memory-schedule is determined) that I hope will be a useful starting-point in unifying the drivers for the various closely related DRAM controllers (e.g. for the RK3288) for Rockchip devices in the future.

Klaus Goger (1):
rockchip: board: puma_rk3399: rename ATF firmware

Philipp Tomsich (51):
spl: add a 'return to bootrom' boot method
spl: configure 'return to bootrom' separately for SPL and TPL
rockchip: back-to-bootrom: add 'back-to-bootrom' support for AArch64
rockchip: back-to-bootrom: split BACK_TO_BOOTROM for TPL/SPL
rockchip: back-to-bootrom: simplify the #ifdef-check for LIBGENERIC in
TPL/SPL
spl: dm: Kconfig: use more specific prereqs for SPL_REGMAP and
SPL_SYSCON
spl: dm: Kconfig: split REGMAP/SYSCON support for TPL from SPL
spl: dm: Kconfig: SPL_RAM depends on SPL_DM
spl: dm: Kconfig: introduce TPL_RAM (in analogy to SPL_RAM)
spl: dm: Kconfig: SPL_CLK depens on SPL_DM
spl: dm: Kconfig: split CLK support for SPL and TPL
spl: dm: Kconfig: split OF_CONTROL and OF_PLATDATA between SPL and TPL
spl: dm: use CONFIG_IS_ENABLED to test for the DM option
armv8: remove unused low-level modules from TPL
armv8: spl: Support separate stack for TPL
spl: allow a separate TEXT_BASE, LDSCRIPT and MAX_SIZE for TPL
spl: Kconfig: split SYS_MALLOC_SIMPLE for TPL and SPL
lib: spl: differentiate between TPL and SPL for
libfdt/of_control/of_platdata
spl: consistently use $(SPL_TPL_) to select features for SPL and TPL
builds
spl: add TPL_DRIVER_MISC_SUPPORT option
drivers: spl: consistently use the $(SPL_TPL_) macro
rockchip: Makefile: allow selective inclusion of sdram_common.o from
TPL/SPL/U-Boot
rockchip: rk3368: improve Kconfig text for the RK3368
rockchip: rk3368: mkimage: add support for the RK3368
rockchip: rk3368: pmugrf: add definitions for os_reg[0..3]
rockchip: rk3368: define CONFIG_SYS_SDRAM_BASE
rockchip: rk3368: spl: define COUNTER_FREQUENCY to 24MHz
rockchip: rk3368: spl: add memory layout for TPL and SPL
rockchip: rk3368: syscon: MSCH/PMUGRF/GRF support for OF_PLATDATA
rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_
rockchip: pinctrl: rk3368: add GMAC (RGMII only) support
rockchip: pinctrl: rk3368: add support for configuring the MMC pins
rockchip: clk: rk3368: implement bandwidth adjust for PLLs
rockchip: clk: rk3368: support OF_PLATDATA for the RK3368 clk driver
rockchip: clk: rk3368: do not change CPLL/GPLL before returning to
BROM
rockchip: clk: rk3368: implement DPLL (DRAM PLL) support
rockchip: clk: rk3368: define DMA1_SRST_REQ and DMA2_SRST_REQ
rockchip: clk: rk3368: implement MMC/SD clock reparenting
rockchip: clk: rk3368: support configuring the DRAM PLL (from TPL)
rockchip: clk: rk3368: add support for GMAC (SLCK_MAC) clock
rockchip: clk: rk3368: mark 'priv' __maybe_unused in

    rk3368_clk_set_rate()
  net: gmac_rockchip: Add support for the RK3368 GMAC
  rockchip: Makefile: streamline SPL/TPL configuration
  rockchip: rk3368: add DRAM controller driver with DRAM initialisation
  rockchip: dts: rk3368: add DMC node in rk3368.dtsi
  rockchip: rk3368: spl: enable SPL_FRAMEWORK in rk3368_common.h
  rockchip: rk3368: spl: add TPL support
  rockchip: rk3368: spl: add SPL support
  rockchip: rk3368: spl: mark SPL and TPL as supported for
    ROCKCHIP_RK3368
  rockchip: board: lion-rk3368: add support for the RK3368-uQ7
  rockchip: board: puma-rk3399: fix warnings in
    puma_rk3399/fit_spl_atf.its
 Makefile                                           |   2 +-
 arch/arm/cpu/armv8/Makefile                        |   4 +-
 arch/arm/dts/Makefile                              |   1 +
 arch/arm/dts/rk3368-lion.dts                       | 209 +++++
 arch/arm/dts/rk3368.dtsi                           |  26 +-
 arch/arm/include/asm/arch-rockchip/cru_rk3368.h    |  15 +-
 arch/arm/include/asm/arch-rockchip/ddr_rk3368.h    | 187 ++++
 arch/arm/include/asm/arch-rockchip/grf_rk3368.h    | 615 +++++++------
 arch/arm/include/asm/spl.h                         |   1 +
 arch/arm/lib/crt0_64.S                             |   4 +-
 arch/arm/mach-rockchip/Kconfig                     |  37 +-
 arch/arm/mach-rockchip/Makefile                    |  51 +-
 arch/arm/mach-rockchip/bootrom.c                   |   4 +-
 arch/arm/mach-rockchip/rk3188-board-spl.c          |   5 +-
 arch/arm/mach-rockchip/rk3188-board.c              |   2 +-
 arch/arm/mach-rockchip/rk3288-board-spl.c          |   4 +-
 arch/arm/mach-rockchip/rk3288-board.c              |   4 +-
 arch/arm/mach-rockchip/rk3368-board-spl.c          |  91 ++
 arch/arm/mach-rockchip/rk3368-board-tpl.c          | 158 ++++
 arch/arm/mach-rockchip/rk3368/Kconfig              |  21 +
 arch/arm/mach-rockchip/rk3368/Makefile             |   1 -
 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c       |  60 --
 arch/arm/mach-rockchip/rk3368/syscon_rk3368.c      |  35 +
 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds       |  13 +
 arch/arm/mach-rockchip/rk3399-board-spl.c          |   4 +-
 arch/arm/mach-rockchip/save_boot_param.S           |  37 +
 board/theobroma-systems/lion_rk3368/Kconfig        |  15 +
 board/theobroma-systems/lion_rk3368/MAINTAINERS    |  10 +
 board/theobroma-systems/lion_rk3368/Makefile       |   7 +
 board/theobroma-systems/lion_rk3368/README         |  60 ++
 .../theobroma-systems/lion_rk3368/fit_spl_atf.its  |  51 ++
 board/theobroma-systems/lion_rk3368/lion_rk3368.c  |  25 +
 board/theobroma-systems/puma_rk3399/README         |   2 +-
 .../theobroma-systems/puma_rk3399/fit_spl_atf.its  |  20 +-
 common/Makefile                                    |   8 +-
 common/spl/Kconfig                                 |  39 +
 common/spl/Makefile                                |  35 +-
 common/spl/spl.c                                   |   5 +-
 common/spl/spl_bootrom.c                           |  27 +
 configs/evb-rk3288_defconfig                       |   2 +-
 configs/fennec-rk3288_defconfig                    |   2 +-
 configs/firefly-rk3288_defconfig                   |   2 +-
 configs/lion-rk3368_defconfig                      |  79 ++
 configs/miqi-rk3288_defconfig                      |   2 +-
 configs/popmetal-rk3288_defconfig                  |   2 +-
 configs/rock2_defconfig                            |   2 +-
 configs/rock_defconfig                             |   2 +-
 configs/tinker-rk3288_defconfig                    |   2 +-
 doc/README.rockchip                                |   2 +-
 .../clock/rockchip,rk3368-dmc.txt                  |  67 ++
 drivers/Makefile                                   |  36 +-
 drivers/clk/Kconfig                                |  12 +-
 drivers/clk/Makefile                               |   2 +-
 drivers/clk/rockchip/clk_rk3368.c                  | 222 ++++-
 drivers/core/Kconfig                               |  23 +-
 drivers/core/Makefile                              |   4 +-
 drivers/net/gmac_rockchip.c                        |  54 ++
 drivers/pinctrl/rockchip/pinctrl_rk3368.c          | 101 ++-
 drivers/ram/Kconfig                                |  11 +-
 drivers/ram/Makefile                               |   2 +
 drivers/ram/rockchip/Makefile                      |   7 +
 drivers/ram/rockchip/dmc-rk3368.c                  | 990 +++++++++++++++++++++
 dts/Kconfig                                        |  29 +
 include/configs/lion_rk3368.h                      |  19 +
 include/configs/rk3188_common.h                    |   2 +-
 include/configs/rk3288_common.h                    |   2 +-
 include/configs/rk3368_common.h                    |  15 +
 include/configs/rock.h                             |   2 +-
 include/configs/rockchip-common.h                  |   2 +-
 include/dt-bindings/memory/rk3368-dmc.h            |  30 +
 include/linux/kconfig.h                            |  13 +
 include/spl.h                                      |  10 +
 lib/Makefile                                       |  10 +-
 scripts/Makefile.spl                               |  14 +-
 scripts/config_whitelist.txt                       |   4 +
 tools/rkcommon.c                                   |   1 +
 76 files changed, 3142 insertions(+), 534 deletions(-)
 create mode 100644 arch/arm/dts/rk3368-lion.dts
 create mode 100644 arch/arm/include/asm/arch-rockchip/ddr_rk3368.h
 create mode 100644 arch/arm/mach-rockchip/rk3368-board-spl.c
 create mode 100644 arch/arm/mach-rockchip/rk3368-board-tpl.c
 delete mode 100644 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c
 create mode 100644 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds
 create mode 100644 board/theobroma-systems/lion_rk3368/Kconfig
 create mode 100644 board/theobroma-systems/lion_rk3368/MAINTAINERS
 create mode 100644 board/theobroma-systems/lion_rk3368/Makefile
 create mode 100644 board/theobroma-systems/lion_rk3368/README
 create mode 100644 board/theobroma-systems/lion_rk3368/fit_spl_atf.its
 create mode 100644 board/theobroma-systems/lion_rk3368/lion_rk3368.c
 create mode 100644 common/spl/spl_bootrom.c
 create mode 100644 configs/lion-rk3368_defconfig
 create mode 100644 doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt
 create mode 100644 drivers/ram/rockchip/Makefile
 create mode 100644 drivers/ram/rockchip/dmc-rk3368.c
 create mode 100644 include/configs/lion_rk3368.h
 create mode 100644 include/dt-bindings/memory/rk3368-dmc.h
#70 lore raw

cover Support OF_PLATDATA in TPL, enable RK3368 DRAM init and add RK3368-uQ7

Hi Philipp:

Quoted 21 lines · Dr. Philipp Tomsich
Quoted 21 lines · Andy Yan

Hi:

Quoted 15 lines · Philipp Tomsich

Here's a series that has a lot going on, but I didn't want to split it to allow everyone to understand the motivation between some of the changes to the SPL/TPL framework. The short summary of this is "enablement for DRAM init on the RK3368 with everything else that's necessary to do it using OF_PLATDATA in TPL".

Enabling the RK3368 created a few more challenges that I'd expected:
- I needed different stack locations, text addresses and sizes for TPL and SPL
- the TPL stage was to use OF_PLATDATA and SPL was to use full OF_CONTROL
- with the RK3368 TPL stage, there was a need to extend the back-to-bootrom support for Rockchip to AArch64
- I wanted to start folding some of the Rockchip specific SPL support (i.e. back-to-bootrom) back into the general SPL framework to allow using it as a general boot method

Quoted 2 lines
Quoted 1 line

I have a confusion here: according to the README.TPL, TPL is Third Program Loader, which loaded by the SPL. So I think it should run after the SPL. But from RK3188 and RK3368 TPL implementation , they all run before SPL.Maybe it is my misunderstanding, hope to get some guidance.:-)

I think you are right and most Rockchip boards have been using this the wrong way around.

Only RK3188 uses TPL now.

Quoted 189 lines

With the fine-grained configurability that I created for the RK3368, it will be easy enough to switch this around on the RK3368. However, this will then also be done for the other RK3xxx devices to restore consistency.

I would prefer to first add the RK3368 support with the “backwards TPL/SPL” (i.e. TPL before SPL) to remain consistent with current mach-rockchip usage of the TPL/SPL terminology. Once this is merged, we can then switch this around for each board individually.

Quoted 179 lines
Quoted 179 lines

So I ended up separating quite a bit of features between SPL and TPL while keeping things transparent to the few other boards using TPL (at least I hope that things are transparent, as we didn't have any of those in our lab to test on)...

Tested with: RK3368-uQ7, Debian 9, Linux 4.13-rc1.

Just one final remark: the DMC driver for the RK3368 currently covers the configuration we use on the RK3368-uQ7 (i.e. 32bit wide, 2 ranks) and is stress-tested (including 8-way SPEC runs) at all 3 supported speeds. I've built a bit of infrastructure (e.g. the way the memory-schedule is determined) that I hope will be a useful starting-point in unifying the drivers for the various closely related DRAM controllers (e.g. for the RK3288) for Rockchip devices in the future.

Klaus Goger (1):
rockchip: board: puma_rk3399: rename ATF firmware

Philipp Tomsich (51):
spl: add a 'return to bootrom' boot method
spl: configure 'return to bootrom' separately for SPL and TPL
rockchip: back-to-bootrom: add 'back-to-bootrom' support for AArch64
rockchip: back-to-bootrom: split BACK_TO_BOOTROM for TPL/SPL
rockchip: back-to-bootrom: simplify the #ifdef-check for LIBGENERIC in
TPL/SPL
spl: dm: Kconfig: use more specific prereqs for SPL_REGMAP and
SPL_SYSCON
spl: dm: Kconfig: split REGMAP/SYSCON support for TPL from SPL
spl: dm: Kconfig: SPL_RAM depends on SPL_DM
spl: dm: Kconfig: introduce TPL_RAM (in analogy to SPL_RAM)
spl: dm: Kconfig: SPL_CLK depens on SPL_DM
spl: dm: Kconfig: split CLK support for SPL and TPL
spl: dm: Kconfig: split OF_CONTROL and OF_PLATDATA between SPL and TPL
spl: dm: use CONFIG_IS_ENABLED to test for the DM option
armv8: remove unused low-level modules from TPL
armv8: spl: Support separate stack for TPL
spl: allow a separate TEXT_BASE, LDSCRIPT and MAX_SIZE for TPL
spl: Kconfig: split SYS_MALLOC_SIMPLE for TPL and SPL
lib: spl: differentiate between TPL and SPL for
libfdt/of_control/of_platdata
spl: consistently use $(SPL_TPL_) to select features for SPL and TPL
builds
spl: add TPL_DRIVER_MISC_SUPPORT option
drivers: spl: consistently use the $(SPL_TPL_) macro
rockchip: Makefile: allow selective inclusion of sdram_common.o from
TPL/SPL/U-Boot
rockchip: rk3368: improve Kconfig text for the RK3368
rockchip: rk3368: mkimage: add support for the RK3368
rockchip: rk3368: pmugrf: add definitions for os_reg[0..3]
rockchip: rk3368: define CONFIG_SYS_SDRAM_BASE
rockchip: rk3368: spl: define COUNTER_FREQUENCY to 24MHz
rockchip: rk3368: spl: add memory layout for TPL and SPL
rockchip: rk3368: syscon: MSCH/PMUGRF/GRF support for OF_PLATDATA
rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_
rockchip: pinctrl: rk3368: add GMAC (RGMII only) support
rockchip: pinctrl: rk3368: add support for configuring the MMC pins
rockchip: clk: rk3368: implement bandwidth adjust for PLLs
rockchip: clk: rk3368: support OF_PLATDATA for the RK3368 clk driver
rockchip: clk: rk3368: do not change CPLL/GPLL before returning to
BROM
rockchip: clk: rk3368: implement DPLL (DRAM PLL) support
rockchip: clk: rk3368: define DMA1_SRST_REQ and DMA2_SRST_REQ
rockchip: clk: rk3368: implement MMC/SD clock reparenting
rockchip: clk: rk3368: support configuring the DRAM PLL (from TPL)
rockchip: clk: rk3368: add support for GMAC (SLCK_MAC) clock
rockchip: clk: rk3368: mark 'priv' __maybe_unused in

     rk3368_clk_set_rate()
   net: gmac_rockchip: Add support for the RK3368 GMAC
   rockchip: Makefile: streamline SPL/TPL configuration
   rockchip: rk3368: add DRAM controller driver with DRAM initialisation
   rockchip: dts: rk3368: add DMC node in rk3368.dtsi
   rockchip: rk3368: spl: enable SPL_FRAMEWORK in rk3368_common.h
   rockchip: rk3368: spl: add TPL support
   rockchip: rk3368: spl: add SPL support
   rockchip: rk3368: spl: mark SPL and TPL as supported for
     ROCKCHIP_RK3368
   rockchip: board: lion-rk3368: add support for the RK3368-uQ7
   rockchip: board: puma-rk3399: fix warnings in
     puma_rk3399/fit_spl_atf.its
  Makefile                                           |   2 +-
  arch/arm/cpu/armv8/Makefile                        |   4 +-
  arch/arm/dts/Makefile                              |   1 +
  arch/arm/dts/rk3368-lion.dts                       | 209 +++++
  arch/arm/dts/rk3368.dtsi                           |  26 +-
  arch/arm/include/asm/arch-rockchip/cru_rk3368.h    |  15 +-
  arch/arm/include/asm/arch-rockchip/ddr_rk3368.h    | 187 ++++
  arch/arm/include/asm/arch-rockchip/grf_rk3368.h    | 615 +++++++------
  arch/arm/include/asm/spl.h                         |   1 +
  arch/arm/lib/crt0_64.S                             |   4 +-
  arch/arm/mach-rockchip/Kconfig                     |  37 +-
  arch/arm/mach-rockchip/Makefile                    |  51 +-
  arch/arm/mach-rockchip/bootrom.c                   |   4 +-
  arch/arm/mach-rockchip/rk3188-board-spl.c          |   5 +-
  arch/arm/mach-rockchip/rk3188-board.c              |   2 +-
  arch/arm/mach-rockchip/rk3288-board-spl.c          |   4 +-
  arch/arm/mach-rockchip/rk3288-board.c              |   4 +-
  arch/arm/mach-rockchip/rk3368-board-spl.c          |  91 ++
  arch/arm/mach-rockchip/rk3368-board-tpl.c          | 158 ++++
  arch/arm/mach-rockchip/rk3368/Kconfig              |  21 +
  arch/arm/mach-rockchip/rk3368/Makefile             |   1 -
  arch/arm/mach-rockchip/rk3368/sdram_rk3368.c       |  60 --
  arch/arm/mach-rockchip/rk3368/syscon_rk3368.c      |  35 +
  arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds       |  13 +
  arch/arm/mach-rockchip/rk3399-board-spl.c          |   4 +-
  arch/arm/mach-rockchip/save_boot_param.S           |  37 +
  board/theobroma-systems/lion_rk3368/Kconfig        |  15 +
  board/theobroma-systems/lion_rk3368/MAINTAINERS    |  10 +
  board/theobroma-systems/lion_rk3368/Makefile       |   7 +
  board/theobroma-systems/lion_rk3368/README         |  60 ++
  .../theobroma-systems/lion_rk3368/fit_spl_atf.its  |  51 ++
  board/theobroma-systems/lion_rk3368/lion_rk3368.c  |  25 +
  board/theobroma-systems/puma_rk3399/README         |   2 +-
  .../theobroma-systems/puma_rk3399/fit_spl_atf.its  |  20 +-
  common/Makefile                                    |   8 +-
  common/spl/Kconfig                                 |  39 +
  common/spl/Makefile                                |  35 +-
  common/spl/spl.c                                   |   5 +-
  common/spl/spl_bootrom.c                           |  27 +
  configs/evb-rk3288_defconfig                       |   2 +-
  configs/fennec-rk3288_defconfig                    |   2 +-
  configs/firefly-rk3288_defconfig                   |   2 +-
  configs/lion-rk3368_defconfig                      |  79 ++
  configs/miqi-rk3288_defconfig                      |   2 +-
  configs/popmetal-rk3288_defconfig                  |   2 +-
  configs/rock2_defconfig                            |   2 +-
  configs/rock_defconfig                             |   2 +-
  configs/tinker-rk3288_defconfig                    |   2 +-
  doc/README.rockchip                                |   2 +-
  .../clock/rockchip,rk3368-dmc.txt                  |  67 ++
  drivers/Makefile                                   |  36 +-
  drivers/clk/Kconfig                                |  12 +-
  drivers/clk/Makefile                               |   2 +-
  drivers/clk/rockchip/clk_rk3368.c                  | 222 ++++-
  drivers/core/Kconfig                               |  23 +-
  drivers/core/Makefile                              |   4 +-
  drivers/net/gmac_rockchip.c                        |  54 ++
  drivers/pinctrl/rockchip/pinctrl_rk3368.c          | 101 ++-
  drivers/ram/Kconfig                                |  11 +-
  drivers/ram/Makefile                               |   2 +
  drivers/ram/rockchip/Makefile                      |   7 +
  drivers/ram/rockchip/dmc-rk3368.c                  | 990 +++++++++++++++++++++
  dts/Kconfig                                        |  29 +
  include/configs/lion_rk3368.h                      |  19 +
  include/configs/rk3188_common.h                    |   2 +-
  include/configs/rk3288_common.h                    |   2 +-
  include/configs/rk3368_common.h                    |  15 +
  include/configs/rock.h                             |   2 +-
  include/configs/rockchip-common.h                  |   2 +-
  include/dt-bindings/memory/rk3368-dmc.h            |  30 +
  include/linux/kconfig.h                            |  13 +
  include/spl.h                                      |  10 +
  lib/Makefile                                       |  10 +-
  scripts/Makefile.spl                               |  14 +-
  scripts/config_whitelist.txt                       |   4 +
  tools/rkcommon.c                                   |   1 +
  76 files changed, 3142 insertions(+), 534 deletions(-)

create mode 100644 arch/arm/dts/rk3368-lion.dts
create mode 100644 arch/arm/include/asm/arch-rockchip/ddr_rk3368.h create mode 100644 arch/arm/mach-rockchip/rk3368-board-spl.c create mode 100644 arch/arm/mach-rockchip/rk3368-board-tpl.c delete mode 100644 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c create mode 100644 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds create mode 100644 board/theobroma-systems/lion_rk3368/Kconfig create mode 100644 board/theobroma-systems/lion_rk3368/MAINTAINERS create mode 100644 board/theobroma-systems/lion_rk3368/Makefile create mode 100644 board/theobroma-systems/lion_rk3368/README create mode 100644 board/theobroma-systems/lion_rk3368/fit_spl_atf.its create mode 100644 board/theobroma-systems/lion_rk3368/lion_rk3368.c create mode 100644 common/spl/spl_bootrom.c
create mode 100644 configs/lion-rk3368_defconfig
create mode 100644 doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt create mode 100644 drivers/ram/rockchip/Makefile
create mode 100644 drivers/ram/rockchip/dmc-rk3368.c
create mode 100644 include/configs/lion_rk3368.h
create mode 100644 include/dt-bindings/memory/rk3368-dmc.h

maintainer
#71 lore raw

cover Support OF_PLATDATA in TPL, enable RK3368 DRAM init and add RK3368-uQ7

Am Montag, 24. Juli 2017, 16:38:52 CEST schrieb Andy Yan:

Quoted 38 lines

Hi Philipp:

Quoted 35 lines · Dr. Philipp Tomsich
Quoted 25 lines · Andy Yan

Hi:

Quoted 20 lines · Philipp Tomsich

Here's a series that has a lot going on, but I didn't want to split it to allow everyone to understand the motivation between some of the changes to the SPL/TPL framework. The short summary of this is "enablement for DRAM init on the RK3368 with everything else that's necessary to do it using OF_PLATDATA in TPL".

Enabling the RK3368 created a few more challenges that I'd expected:
- I needed different stack locations, text addresses and sizes for

TPL and SPL

- the TPL stage was to use OF_PLATDATA and SPL was to use full OF_CONTROL
- with the RK3368 TPL stage, there was a need to extend the back-to-bootrom

support for Rockchip to AArch64

- I wanted to start folding some of the Rockchip specific SPL support

Quoted 8 lines
Quoted 2 lines

(i.e. back-to-bootrom) back into the general SPL framework to allow using it as a general boot method

I have a confusion here: according to the README.TPL, TPL is Third Program Loader, which loaded by the SPL. So I think it should run after the SPL. But from RK3188 and RK3368 TPL implementation , they all run before SPL.Maybe it is my misunderstanding, hope to get some guidance.:-)>

I think you are right and most Rockchip boards have been using this the wrong way around.

Actually at first I also had the ordering of SPL -> TPL -> uboot for rk3188 but after discussions with Simon and Tom Rini, the opinion was that TPL stands for "tiny" program loader and should run before the full SPL.

So I switched that stuff around on rk3188.

Heiko

Quoted 209 lines

Only RK3188 uses TPL now.

Quoted 207 lines

With the fine-grained configurability that I created for the RK3368, it will be easy enough to switch this around on the RK3368. However, this will then also be done for the other RK3xxx devices to restore consistency.

I would prefer to first add the RK3368 support with the “backwards TPL/SPL” (i.e. TPL before SPL) to remain consistent with current mach-rockchip usage of the TPL/SPL terminology. Once this is merged, we can then switch this around for each board individually.>

Quoted 198 lines
Quoted 198 lines

So I ended up separating quite a bit of features between SPL and TPL while keeping things transparent to the few other boards using TPL (at least I hope that things are transparent, as we didn't have any of those in our lab to test on)...

Tested with: RK3368-uQ7, Debian 9, Linux 4.13-rc1.

Just one final remark: the DMC driver for the RK3368 currently covers the configuration we use on the RK3368-uQ7 (i.e. 32bit wide, 2 ranks) and is stress-tested (including 8-way SPEC runs) at all 3 supported speeds. I've built a bit of infrastructure (e.g. the way the memory-schedule is determined) that I hope will be a useful starting-point in unifying the drivers for the various closely related DRAM controllers (e.g. for the RK3288) for Rockchip devices in the future.

Klaus Goger (1):
rockchip: board: puma_rk3399: rename ATF firmware

Philipp Tomsich (51):
spl: add a 'return to bootrom' boot method
spl: configure 'return to bootrom' separately for SPL and TPL
rockchip: back-to-bootrom: add 'back-to-bootrom' support for AArch64
rockchip: back-to-bootrom: split BACK_TO_BOOTROM for TPL/SPL
rockchip: back-to-bootrom: simplify the #ifdef-check for LIBGENERIC in

TPL/SPL

spl: dm: Kconfig: use more specific prereqs for SPL_REGMAP and

SPL_SYSCON

spl: dm: Kconfig: split REGMAP/SYSCON support for TPL from SPL
spl: dm: Kconfig: SPL_RAM depends on SPL_DM
spl: dm: Kconfig: introduce TPL_RAM (in analogy to SPL_RAM)
spl: dm: Kconfig: SPL_CLK depens on SPL_DM
spl: dm: Kconfig: split CLK support for SPL and TPL
spl: dm: Kconfig: split OF_CONTROL and OF_PLATDATA between SPL and TPL
spl: dm: use CONFIG_IS_ENABLED to test for the DM option
armv8: remove unused low-level modules from TPL
armv8: spl: Support separate stack for TPL
spl: allow a separate TEXT_BASE, LDSCRIPT and MAX_SIZE for TPL
spl: Kconfig: split SYS_MALLOC_SIMPLE for TPL and SPL
lib: spl: differentiate between TPL and SPL for

libfdt/of_control/of_platdata

   spl: consistently use $(SPL_TPL_) to select features for SPL and TPL

builds

spl: add TPL_DRIVER_MISC_SUPPORT option
drivers: spl: consistently use the $(SPL_TPL_) macro
rockchip: Makefile: allow selective inclusion of sdram_common.o from

TPL/SPL/U-Boot

rockchip: rk3368: improve Kconfig text for the RK3368
rockchip: rk3368: mkimage: add support for the RK3368
rockchip: rk3368: pmugrf: add definitions for os_reg[0..3]
rockchip: rk3368: define CONFIG_SYS_SDRAM_BASE
rockchip: rk3368: spl: define COUNTER_FREQUENCY to 24MHz
rockchip: rk3368: spl: add memory layout for TPL and SPL
rockchip: rk3368: syscon: MSCH/PMUGRF/GRF support for OF_PLATDATA
rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_
rockchip: pinctrl: rk3368: add GMAC (RGMII only) support
rockchip: pinctrl: rk3368: add support for configuring the MMC pins
rockchip: clk: rk3368: implement bandwidth adjust for PLLs
rockchip: clk: rk3368: support OF_PLATDATA for the RK3368 clk driver
rockchip: clk: rk3368: do not change CPLL/GPLL before returning to

BROM

rockchip: clk: rk3368: implement DPLL (DRAM PLL) support
rockchip: clk: rk3368: define DMA1_SRST_REQ and DMA2_SRST_REQ
rockchip: clk: rk3368: implement MMC/SD clock reparenting
rockchip: clk: rk3368: support configuring the DRAM PLL (from TPL)
rockchip: clk: rk3368: add support for GMAC (SLCK_MAC) clock
rockchip: clk: rk3368: mark 'priv' __maybe_unused in

     rk3368_clk_set_rate()

net: gmac_rockchip: Add support for the RK3368 GMAC
rockchip: Makefile: streamline SPL/TPL configuration
rockchip: rk3368: add DRAM controller driver with DRAM initialisation
rockchip: dts: rk3368: add DMC node in rk3368.dtsi
rockchip: rk3368: spl: enable SPL_FRAMEWORK in rk3368_common.h
rockchip: rk3368: spl: add TPL support
rockchip: rk3368: spl: add SPL support
rockchip: rk3368: spl: mark SPL and TPL as supported for

     ROCKCHIP_RK3368

rockchip: board: lion-rk3368: add support for the RK3368-uQ7
rockchip: board: puma-rk3399: fix warnings in

     puma_rk3399/fit_spl_atf.its
  Makefile                                           |   2 +-
  arch/arm/cpu/armv8/Makefile                        |   4 +-
  arch/arm/dts/Makefile                              |   1 +
  arch/arm/dts/rk3368-lion.dts                       | 209 +++++
  arch/arm/dts/rk3368.dtsi                           |  26 +-
  arch/arm/include/asm/arch-rockchip/cru_rk3368.h    |  15 +-
  arch/arm/include/asm/arch-rockchip/ddr_rk3368.h    | 187 ++++
  arch/arm/include/asm/arch-rockchip/grf_rk3368.h    | 615 +++++++------
  arch/arm/include/asm/spl.h                         |   1 +
  arch/arm/lib/crt0_64.S                             |   4 +-
  arch/arm/mach-rockchip/Kconfig                     |  37 +-
  arch/arm/mach-rockchip/Makefile                    |  51 +-
  arch/arm/mach-rockchip/bootrom.c                   |   4 +-
  arch/arm/mach-rockchip/rk3188-board-spl.c          |   5 +-
  arch/arm/mach-rockchip/rk3188-board.c              |   2 +-
  arch/arm/mach-rockchip/rk3288-board-spl.c          |   4 +-
  arch/arm/mach-rockchip/rk3288-board.c              |   4 +-
  arch/arm/mach-rockchip/rk3368-board-spl.c          |  91 ++
  arch/arm/mach-rockchip/rk3368-board-tpl.c          | 158 ++++
  arch/arm/mach-rockchip/rk3368/Kconfig              |  21 +
  arch/arm/mach-rockchip/rk3368/Makefile             |   1 -
  arch/arm/mach-rockchip/rk3368/sdram_rk3368.c       |  60 --
  arch/arm/mach-rockchip/rk3368/syscon_rk3368.c      |  35 +
  arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds       |  13 +
  arch/arm/mach-rockchip/rk3399-board-spl.c          |   4 +-
  arch/arm/mach-rockchip/save_boot_param.S           |  37 +
  board/theobroma-systems/lion_rk3368/Kconfig        |  15 +
  board/theobroma-systems/lion_rk3368/MAINTAINERS    |  10 +
  board/theobroma-systems/lion_rk3368/Makefile       |   7 +
  board/theobroma-systems/lion_rk3368/README         |  60 ++
  .../theobroma-systems/lion_rk3368/fit_spl_atf.its  |  51 ++
  board/theobroma-systems/lion_rk3368/lion_rk3368.c  |  25 +
  board/theobroma-systems/puma_rk3399/README         |   2 +-
  .../theobroma-systems/puma_rk3399/fit_spl_atf.its  |  20 +-
  common/Makefile                                    |   8 +-
  common/spl/Kconfig                                 |  39 +
  common/spl/Makefile                                |  35 +-
  common/spl/spl.c                                   |   5 +-
  common/spl/spl_bootrom.c                           |  27 +
  configs/evb-rk3288_defconfig                       |   2 +-
  configs/fennec-rk3288_defconfig                    |   2 +-
  configs/firefly-rk3288_defconfig                   |   2 +-
  configs/lion-rk3368_defconfig                      |  79 ++
  configs/miqi-rk3288_defconfig                      |   2 +-
  configs/popmetal-rk3288_defconfig                  |   2 +-
  configs/rock2_defconfig                            |   2 +-
  configs/rock_defconfig                             |   2 +-
  configs/tinker-rk3288_defconfig                    |   2 +-
  doc/README.rockchip                                |   2 +-
  .../clock/rockchip,rk3368-dmc.txt                  |  67 ++
  drivers/Makefile                                   |  36 +-
  drivers/clk/Kconfig                                |  12 +-
  drivers/clk/Makefile                               |   2 +-
  drivers/clk/rockchip/clk_rk3368.c                  | 222 ++++-
  drivers/core/Kconfig                               |  23 +-
  drivers/core/Makefile                              |   4 +-
  drivers/net/gmac_rockchip.c                        |  54 ++
  drivers/pinctrl/rockchip/pinctrl_rk3368.c          | 101 ++-
  drivers/ram/Kconfig                                |  11 +-
  drivers/ram/Makefile                               |   2 +
  drivers/ram/rockchip/Makefile                      |   7 +
  drivers/ram/rockchip/dmc-rk3368.c                  | 990
  +++++++++++++++++++++ dts/Kconfig                                    
     |  29 +
  include/configs/lion_rk3368.h                      |  19 +
  include/configs/rk3188_common.h                    |   2 +-
  include/configs/rk3288_common.h                    |   2 +-
  include/configs/rk3368_common.h                    |  15 +
  include/configs/rock.h                             |   2 +-
  include/configs/rockchip-common.h                  |   2 +-
  include/dt-bindings/memory/rk3368-dmc.h            |  30 +
  include/linux/kconfig.h                            |  13 +
  include/spl.h                                      |  10 +
  lib/Makefile                                       |  10 +-
  scripts/Makefile.spl                               |  14 +-
  scripts/config_whitelist.txt                       |   4 +
  tools/rkcommon.c                                   |   1 +
  76 files changed, 3142 insertions(+), 534 deletions(-)

create mode 100644 arch/arm/dts/rk3368-lion.dts
create mode 100644 arch/arm/include/asm/arch-rockchip/ddr_rk3368.h create mode 100644 arch/arm/mach-rockchip/rk3368-board-spl.c create mode 100644 arch/arm/mach-rockchip/rk3368-board-tpl.c delete mode 100644 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c create mode 100644 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds create mode 100644 board/theobroma-systems/lion_rk3368/Kconfig create mode 100644 board/theobroma-systems/lion_rk3368/MAINTAINERS create mode 100644 board/theobroma-systems/lion_rk3368/Makefile create mode 100644 board/theobroma-systems/lion_rk3368/README create mode 100644 board/theobroma-systems/lion_rk3368/fit_spl_atf.its create mode 100644 board/theobroma-systems/lion_rk3368/lion_rk3368.c create mode 100644 common/spl/spl_bootrom.c
create mode 100644 configs/lion-rk3368_defconfig
create mode 100644 doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt create mode 100644 drivers/ram/rockchip/Makefile
create mode 100644 drivers/ram/rockchip/dmc-rk3368.c create mode 100644 include/configs/lion_rk3368.h
create mode 100644 include/dt-bindings/memory/rk3368-dmc.h

#72 lore raw

cover Support OF_PLATDATA in TPL, enable RK3368 DRAM init and add RK3368-uQ7

Quoted 40 lines · Heiko Stübner

Am Montag, 24. Juli 2017, 16:38:52 CEST schrieb Andy Yan:

Quoted 36 lines

Hi Philipp:

Quoted 33 lines · Dr. Philipp Tomsich
Quoted 33 lines · Andy Yan

Hi:

Quoted 16 lines · Philipp Tomsich

Here's a series that has a lot going on, but I didn't want to split it to allow everyone to understand the motivation between some of the changes to the SPL/TPL framework. The short summary of this is "enablement for DRAM init on the RK3368 with everything else that's necessary to do it using OF_PLATDATA in TPL".

Enabling the RK3368 created a few more challenges that I'd expected:
- I needed different stack locations, text addresses and sizes for

TPL and SPL

- the TPL stage was to use OF_PLATDATA and SPL was to use full OF_CONTROL
- with the RK3368 TPL stage, there was a need to extend the back-to-bootrom

Quoted 6 lines

support for Rockchip to AArch64

- I wanted to start folding some of the Rockchip specific SPL support

(i.e. back-to-bootrom) back into the general SPL framework to allow using it as a general boot method

I have a confusion here: according to the README.TPL, TPL is Third Program Loader, which loaded by the SPL. So I think it should run after the SPL. But from RK3188 and RK3368 TPL implementation , they all run before SPL.Maybe it is my misunderstanding, hope to get some guidance.:-)>

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

I think you are right and most Rockchip boards have been using this the wrong way around.

Actually at first I also had the ordering of SPL -> TPL -> uboot for rk3188 but after discussions with Simon and Tom Rini, the opinion was that TPL stands for "tiny" program loader and should run before the full SPL.

So I switched that stuff around on rk3188.

Thanks for the background.

A documentation-fix will be much easier than changing the order across all our Rockchip board … and I’ll include it in the next version of this series.

Quoted 212 lines

Heiko

Quoted 209 lines

Only RK3188 uses TPL now.

Quoted 207 lines

With the fine-grained configurability that I created for the RK3368, it will be easy enough to switch this around on the RK3368. However, this will then also be done for the other RK3xxx devices to restore consistency.

I would prefer to first add the RK3368 support with the “backwards TPL/SPL” (i.e. TPL before SPL) to remain consistent with current mach-rockchip usage of the TPL/SPL terminology. Once this is merged, we can then switch this around for each board individually.>

Quoted 198 lines
Quoted 198 lines

So I ended up separating quite a bit of features between SPL and TPL while keeping things transparent to the few other boards using TPL (at least I hope that things are transparent, as we didn't have any of those in our lab to test on)...

Tested with: RK3368-uQ7, Debian 9, Linux 4.13-rc1.

Just one final remark: the DMC driver for the RK3368 currently covers the configuration we use on the RK3368-uQ7 (i.e. 32bit wide, 2 ranks) and is stress-tested (including 8-way SPEC runs) at all 3 supported speeds. I've built a bit of infrastructure (e.g. the way the memory-schedule is determined) that I hope will be a useful starting-point in unifying the drivers for the various closely related DRAM controllers (e.g. for the RK3288) for Rockchip devices in the future.

Klaus Goger (1):
rockchip: board: puma_rk3399: rename ATF firmware

Philipp Tomsich (51):
spl: add a 'return to bootrom' boot method
spl: configure 'return to bootrom' separately for SPL and TPL
rockchip: back-to-bootrom: add 'back-to-bootrom' support for AArch64
rockchip: back-to-bootrom: split BACK_TO_BOOTROM for TPL/SPL
rockchip: back-to-bootrom: simplify the #ifdef-check for LIBGENERIC in

TPL/SPL

spl: dm: Kconfig: use more specific prereqs for SPL_REGMAP and

SPL_SYSCON

spl: dm: Kconfig: split REGMAP/SYSCON support for TPL from SPL
spl: dm: Kconfig: SPL_RAM depends on SPL_DM
spl: dm: Kconfig: introduce TPL_RAM (in analogy to SPL_RAM)
spl: dm: Kconfig: SPL_CLK depens on SPL_DM
spl: dm: Kconfig: split CLK support for SPL and TPL
spl: dm: Kconfig: split OF_CONTROL and OF_PLATDATA between SPL and TPL
spl: dm: use CONFIG_IS_ENABLED to test for the DM option
armv8: remove unused low-level modules from TPL
armv8: spl: Support separate stack for TPL
spl: allow a separate TEXT_BASE, LDSCRIPT and MAX_SIZE for TPL
spl: Kconfig: split SYS_MALLOC_SIMPLE for TPL and SPL
lib: spl: differentiate between TPL and SPL for

libfdt/of_control/of_platdata

  spl: consistently use $(SPL_TPL_) to select features for SPL and TPL

builds

spl: add TPL_DRIVER_MISC_SUPPORT option
drivers: spl: consistently use the $(SPL_TPL_) macro
rockchip: Makefile: allow selective inclusion of sdram_common.o from

TPL/SPL/U-Boot

rockchip: rk3368: improve Kconfig text for the RK3368
rockchip: rk3368: mkimage: add support for the RK3368
rockchip: rk3368: pmugrf: add definitions for os_reg[0..3]
rockchip: rk3368: define CONFIG_SYS_SDRAM_BASE
rockchip: rk3368: spl: define COUNTER_FREQUENCY to 24MHz
rockchip: rk3368: spl: add memory layout for TPL and SPL
rockchip: rk3368: syscon: MSCH/PMUGRF/GRF support for OF_PLATDATA
rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_
rockchip: pinctrl: rk3368: add GMAC (RGMII only) support
rockchip: pinctrl: rk3368: add support for configuring the MMC pins
rockchip: clk: rk3368: implement bandwidth adjust for PLLs
rockchip: clk: rk3368: support OF_PLATDATA for the RK3368 clk driver
rockchip: clk: rk3368: do not change CPLL/GPLL before returning to

BROM

rockchip: clk: rk3368: implement DPLL (DRAM PLL) support
rockchip: clk: rk3368: define DMA1_SRST_REQ and DMA2_SRST_REQ
rockchip: clk: rk3368: implement MMC/SD clock reparenting
rockchip: clk: rk3368: support configuring the DRAM PLL (from TPL)
rockchip: clk: rk3368: add support for GMAC (SLCK_MAC) clock
rockchip: clk: rk3368: mark 'priv' __maybe_unused in

    rk3368_clk_set_rate()

net: gmac_rockchip: Add support for the RK3368 GMAC
rockchip: Makefile: streamline SPL/TPL configuration
rockchip: rk3368: add DRAM controller driver with DRAM initialisation
rockchip: dts: rk3368: add DMC node in rk3368.dtsi
rockchip: rk3368: spl: enable SPL_FRAMEWORK in rk3368_common.h
rockchip: rk3368: spl: add TPL support
rockchip: rk3368: spl: add SPL support
rockchip: rk3368: spl: mark SPL and TPL as supported for

    ROCKCHIP_RK3368

rockchip: board: lion-rk3368: add support for the RK3368-uQ7
rockchip: board: puma-rk3399: fix warnings in

    puma_rk3399/fit_spl_atf.its
 Makefile                                           |   2 +-
 arch/arm/cpu/armv8/Makefile                        |   4 +-
 arch/arm/dts/Makefile                              |   1 +
 arch/arm/dts/rk3368-lion.dts                       | 209 +++++
 arch/arm/dts/rk3368.dtsi                           |  26 +-
 arch/arm/include/asm/arch-rockchip/cru_rk3368.h    |  15 +-
 arch/arm/include/asm/arch-rockchip/ddr_rk3368.h    | 187 ++++
 arch/arm/include/asm/arch-rockchip/grf_rk3368.h    | 615 +++++++------
 arch/arm/include/asm/spl.h                         |   1 +
 arch/arm/lib/crt0_64.S                             |   4 +-
 arch/arm/mach-rockchip/Kconfig                     |  37 +-
 arch/arm/mach-rockchip/Makefile                    |  51 +-
 arch/arm/mach-rockchip/bootrom.c                   |   4 +-
 arch/arm/mach-rockchip/rk3188-board-spl.c          |   5 +-
 arch/arm/mach-rockchip/rk3188-board.c              |   2 +-
 arch/arm/mach-rockchip/rk3288-board-spl.c          |   4 +-
 arch/arm/mach-rockchip/rk3288-board.c              |   4 +-
 arch/arm/mach-rockchip/rk3368-board-spl.c          |  91 ++
 arch/arm/mach-rockchip/rk3368-board-tpl.c          | 158 ++++
 arch/arm/mach-rockchip/rk3368/Kconfig              |  21 +
 arch/arm/mach-rockchip/rk3368/Makefile             |   1 -
 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c       |  60 --
 arch/arm/mach-rockchip/rk3368/syscon_rk3368.c      |  35 +
 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds       |  13 +
 arch/arm/mach-rockchip/rk3399-board-spl.c          |   4 +-
 arch/arm/mach-rockchip/save_boot_param.S           |  37 +
 board/theobroma-systems/lion_rk3368/Kconfig        |  15 +
 board/theobroma-systems/lion_rk3368/MAINTAINERS    |  10 +
 board/theobroma-systems/lion_rk3368/Makefile       |   7 +
 board/theobroma-systems/lion_rk3368/README         |  60 ++
 .../theobroma-systems/lion_rk3368/fit_spl_atf.its  |  51 ++
 board/theobroma-systems/lion_rk3368/lion_rk3368.c  |  25 +
 board/theobroma-systems/puma_rk3399/README         |   2 +-
 .../theobroma-systems/puma_rk3399/fit_spl_atf.its  |  20 +-
 common/Makefile                                    |   8 +-
 common/spl/Kconfig                                 |  39 +
 common/spl/Makefile                                |  35 +-
 common/spl/spl.c                                   |   5 +-
 common/spl/spl_bootrom.c                           |  27 +
 configs/evb-rk3288_defconfig                       |   2 +-
 configs/fennec-rk3288_defconfig                    |   2 +-
 configs/firefly-rk3288_defconfig                   |   2 +-
 configs/lion-rk3368_defconfig                      |  79 ++
 configs/miqi-rk3288_defconfig                      |   2 +-
 configs/popmetal-rk3288_defconfig                  |   2 +-
 configs/rock2_defconfig                            |   2 +-
 configs/rock_defconfig                             |   2 +-
 configs/tinker-rk3288_defconfig                    |   2 +-
 doc/README.rockchip                                |   2 +-
 .../clock/rockchip,rk3368-dmc.txt                  |  67 ++
 drivers/Makefile                                   |  36 +-
 drivers/clk/Kconfig                                |  12 +-
 drivers/clk/Makefile                               |   2 +-
 drivers/clk/rockchip/clk_rk3368.c                  | 222 ++++-
 drivers/core/Kconfig                               |  23 +-
 drivers/core/Makefile                              |   4 +-
 drivers/net/gmac_rockchip.c                        |  54 ++
 drivers/pinctrl/rockchip/pinctrl_rk3368.c          | 101 ++-
 drivers/ram/Kconfig                                |  11 +-
 drivers/ram/Makefile                               |   2 +
 drivers/ram/rockchip/Makefile                      |   7 +
 drivers/ram/rockchip/dmc-rk3368.c                  | 990
 +++++++++++++++++++++ dts/Kconfig                                    
    |  29 +
 include/configs/lion_rk3368.h                      |  19 +
 include/configs/rk3188_common.h                    |   2 +-
 include/configs/rk3288_common.h                    |   2 +-
 include/configs/rk3368_common.h                    |  15 +
 include/configs/rock.h                             |   2 +-
 include/configs/rockchip-common.h                  |   2 +-
 include/dt-bindings/memory/rk3368-dmc.h            |  30 +
 include/linux/kconfig.h                            |  13 +
 include/spl.h                                      |  10 +
 lib/Makefile                                       |  10 +-
 scripts/Makefile.spl                               |  14 +-
 scripts/config_whitelist.txt                       |   4 +
 tools/rkcommon.c                                   |   1 +
 76 files changed, 3142 insertions(+), 534 deletions(-)
 create mode 100644 arch/arm/dts/rk3368-lion.dts
 create mode 100644 arch/arm/include/asm/arch-rockchip/ddr_rk3368.h
 create mode 100644 arch/arm/mach-rockchip/rk3368-board-spl.c
 create mode 100644 arch/arm/mach-rockchip/rk3368-board-tpl.c
 delete mode 100644 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c
 create mode 100644 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds
 create mode 100644 board/theobroma-systems/lion_rk3368/Kconfig
 create mode 100644 board/theobroma-systems/lion_rk3368/MAINTAINERS
 create mode 100644 board/theobroma-systems/lion_rk3368/Makefile
 create mode 100644 board/theobroma-systems/lion_rk3368/README
 create mode 100644 board/theobroma-systems/lion_rk3368/fit_spl_atf.its
 create mode 100644 board/theobroma-systems/lion_rk3368/lion_rk3368.c
 create mode 100644 common/spl/spl_bootrom.c
 create mode 100644 configs/lion-rk3368_defconfig
 create mode 100644
 doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt
 create mode 100644 drivers/ram/rockchip/Makefile
 create mode 100644 drivers/ram/rockchip/dmc-rk3368.c
 create mode 100644 include/configs/lion_rk3368.h
 create mode 100644 include/dt-bindings/memory/rk3368-dmc.h
#73 lore raw

cover Support OF_PLATDATA in TPL, enable RK3368 DRAM init and add RK3368-uQ7

In reply to Heiko Stübner
Quoted 37 lines · Heiko Stübner

Am Montag, 24. Juli 2017, 16:38:52 CEST schrieb Andy Yan:

Quoted 36 lines

Hi Philipp:

Quoted 33 lines · Dr. Philipp Tomsich
Quoted 33 lines · Andy Yan

Hi:

Quoted 16 lines · Philipp Tomsich

Here's a series that has a lot going on, but I didn't want to split it to allow everyone to understand the motivation between some of the changes to the SPL/TPL framework. The short summary of this is "enablement for DRAM init on the RK3368 with everything else that's necessary to do it using OF_PLATDATA in TPL".

Enabling the RK3368 created a few more challenges that I'd expected:
- I needed different stack locations, text addresses and sizes for

TPL and SPL

- the TPL stage was to use OF_PLATDATA and SPL was to use full OF_CONTROL
- with the RK3368 TPL stage, there was a need to extend the back-to-bootrom

Quoted 6 lines

support for Rockchip to AArch64

- I wanted to start folding some of the Rockchip specific SPL support

(i.e. back-to-bootrom) back into the general SPL framework to allow using it as a general boot method

I have a confusion here: according to the README.TPL, TPL is Third Program Loader, which loaded by the SPL. So I think it should run after the SPL. But from RK3188 and RK3368 TPL implementation , they all run before SPL.Maybe it is my misunderstanding, hope to get some guidance.:-)>

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

I think you are right and most Rockchip boards have been using this the wrong way around.

Actually at first I also had the ordering of SPL -> TPL -> uboot for rk3188 but after discussions with Simon and Tom Rini, the opinion was that TPL stands for "tiny" program loader and should run before the full SPL.

Has something changed since:

http://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/tpl-presentation.pdf

I've always thought that we do have SPL -> TPL -> u-boot -> Linux

If there was a change, then:

1. The TPL name is a bit misleading (considering the above presentation/status)

2. IMHO the code running before SPL (to do some _real_ early init) should be named more descriptive like PreSPL.

Quoted 218 lines

So I switched that stuff around on rk3188.

Heiko

Quoted 209 lines

Only RK3188 uses TPL now.

Quoted 207 lines

With the fine-grained configurability that I created for the RK3368, it will be easy enough to switch this around on the RK3368. However, this will then also be done for the other RK3xxx devices to restore consistency.

I would prefer to first add the RK3368 support with the “backwards TPL/SPL” (i.e. TPL before SPL) to remain consistent with current mach-rockchip usage of the TPL/SPL terminology. Once this is merged, we can then switch this around for each board individually.>

Quoted 198 lines
Quoted 198 lines

So I ended up separating quite a bit of features between SPL and TPL while keeping things transparent to the few other boards using TPL (at least I hope that things are transparent, as we didn't have any of those in our lab to test on)...

Tested with: RK3368-uQ7, Debian 9, Linux 4.13-rc1.

Just one final remark: the DMC driver for the RK3368 currently covers the configuration we use on the RK3368-uQ7 (i.e. 32bit wide, 2 ranks) and is stress-tested (including 8-way SPEC runs) at all 3 supported speeds. I've built a bit of infrastructure (e.g. the way the memory-schedule is determined) that I hope will be a useful starting-point in unifying the drivers for the various closely related DRAM controllers (e.g. for the RK3288) for Rockchip devices in the future.

Klaus Goger (1):
rockchip: board: puma_rk3399: rename ATF firmware

Philipp Tomsich (51):
spl: add a 'return to bootrom' boot method
spl: configure 'return to bootrom' separately for SPL and TPL
rockchip: back-to-bootrom: add 'back-to-bootrom' support for AArch64
rockchip: back-to-bootrom: split BACK_TO_BOOTROM for TPL/SPL
rockchip: back-to-bootrom: simplify the #ifdef-check for LIBGENERIC in

TPL/SPL

spl: dm: Kconfig: use more specific prereqs for SPL_REGMAP and

SPL_SYSCON

spl: dm: Kconfig: split REGMAP/SYSCON support for TPL from SPL
spl: dm: Kconfig: SPL_RAM depends on SPL_DM
spl: dm: Kconfig: introduce TPL_RAM (in analogy to SPL_RAM)
spl: dm: Kconfig: SPL_CLK depens on SPL_DM
spl: dm: Kconfig: split CLK support for SPL and TPL
spl: dm: Kconfig: split OF_CONTROL and OF_PLATDATA between SPL and TPL
spl: dm: use CONFIG_IS_ENABLED to test for the DM option
armv8: remove unused low-level modules from TPL
armv8: spl: Support separate stack for TPL
spl: allow a separate TEXT_BASE, LDSCRIPT and MAX_SIZE for TPL
spl: Kconfig: split SYS_MALLOC_SIMPLE for TPL and SPL
lib: spl: differentiate between TPL and SPL for

libfdt/of_control/of_platdata

   spl: consistently use $(SPL_TPL_) to select features for SPL and TPL

builds

spl: add TPL_DRIVER_MISC_SUPPORT option
drivers: spl: consistently use the $(SPL_TPL_) macro
rockchip: Makefile: allow selective inclusion of sdram_common.o from

TPL/SPL/U-Boot

rockchip: rk3368: improve Kconfig text for the RK3368
rockchip: rk3368: mkimage: add support for the RK3368
rockchip: rk3368: pmugrf: add definitions for os_reg[0..3]
rockchip: rk3368: define CONFIG_SYS_SDRAM_BASE
rockchip: rk3368: spl: define COUNTER_FREQUENCY to 24MHz
rockchip: rk3368: spl: add memory layout for TPL and SPL
rockchip: rk3368: syscon: MSCH/PMUGRF/GRF support for OF_PLATDATA
rockchip: rk3368: grf: use shifted-constants and prefix with RK3368_
rockchip: pinctrl: rk3368: add GMAC (RGMII only) support
rockchip: pinctrl: rk3368: add support for configuring the MMC pins
rockchip: clk: rk3368: implement bandwidth adjust for PLLs
rockchip: clk: rk3368: support OF_PLATDATA for the RK3368 clk driver
rockchip: clk: rk3368: do not change CPLL/GPLL before returning to

BROM

rockchip: clk: rk3368: implement DPLL (DRAM PLL) support
rockchip: clk: rk3368: define DMA1_SRST_REQ and DMA2_SRST_REQ
rockchip: clk: rk3368: implement MMC/SD clock reparenting
rockchip: clk: rk3368: support configuring the DRAM PLL (from TPL)
rockchip: clk: rk3368: add support for GMAC (SLCK_MAC) clock
rockchip: clk: rk3368: mark 'priv' __maybe_unused in

     rk3368_clk_set_rate()

net: gmac_rockchip: Add support for the RK3368 GMAC
rockchip: Makefile: streamline SPL/TPL configuration
rockchip: rk3368: add DRAM controller driver with DRAM initialisation
rockchip: dts: rk3368: add DMC node in rk3368.dtsi
rockchip: rk3368: spl: enable SPL_FRAMEWORK in rk3368_common.h
rockchip: rk3368: spl: add TPL support
rockchip: rk3368: spl: add SPL support
rockchip: rk3368: spl: mark SPL and TPL as supported for

     ROCKCHIP_RK3368

rockchip: board: lion-rk3368: add support for the RK3368-uQ7
rockchip: board: puma-rk3399: fix warnings in

     puma_rk3399/fit_spl_atf.its
  Makefile                                           |   2 +-
  arch/arm/cpu/armv8/Makefile                        |   4 +-
  arch/arm/dts/Makefile                              |   1 +
  arch/arm/dts/rk3368-lion.dts                       | 209 +++++
  arch/arm/dts/rk3368.dtsi                           |  26 +-
  arch/arm/include/asm/arch-rockchip/cru_rk3368.h    |  15 +-
  arch/arm/include/asm/arch-rockchip/ddr_rk3368.h    | 187 ++++
  arch/arm/include/asm/arch-rockchip/grf_rk3368.h    | 615 +++++++------
  arch/arm/include/asm/spl.h                         |   1 +
  arch/arm/lib/crt0_64.S                             |   4 +-
  arch/arm/mach-rockchip/Kconfig                     |  37 +-
  arch/arm/mach-rockchip/Makefile                    |  51 +-
  arch/arm/mach-rockchip/bootrom.c                   |   4 +-
  arch/arm/mach-rockchip/rk3188-board-spl.c          |   5 +-
  arch/arm/mach-rockchip/rk3188-board.c              |   2 +-
  arch/arm/mach-rockchip/rk3288-board-spl.c          |   4 +-
  arch/arm/mach-rockchip/rk3288-board.c              |   4 +-
  arch/arm/mach-rockchip/rk3368-board-spl.c          |  91 ++
  arch/arm/mach-rockchip/rk3368-board-tpl.c          | 158 ++++
  arch/arm/mach-rockchip/rk3368/Kconfig              |  21 +
  arch/arm/mach-rockchip/rk3368/Makefile             |   1 -
  arch/arm/mach-rockchip/rk3368/sdram_rk3368.c       |  60 --
  arch/arm/mach-rockchip/rk3368/syscon_rk3368.c      |  35 +
  arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds       |  13 +
  arch/arm/mach-rockchip/rk3399-board-spl.c          |   4 +-
  arch/arm/mach-rockchip/save_boot_param.S           |  37 +
  board/theobroma-systems/lion_rk3368/Kconfig        |  15 +
  board/theobroma-systems/lion_rk3368/MAINTAINERS    |  10 +
  board/theobroma-systems/lion_rk3368/Makefile       |   7 +
  board/theobroma-systems/lion_rk3368/README         |  60 ++
  .../theobroma-systems/lion_rk3368/fit_spl_atf.its  |  51 ++
  board/theobroma-systems/lion_rk3368/lion_rk3368.c  |  25 +
  board/theobroma-systems/puma_rk3399/README         |   2 +-
  .../theobroma-systems/puma_rk3399/fit_spl_atf.its  |  20 +-
  common/Makefile                                    |   8 +-
  common/spl/Kconfig                                 |  39 +
  common/spl/Makefile                                |  35 +-
  common/spl/spl.c                                   |   5 +-
  common/spl/spl_bootrom.c                           |  27 +
  configs/evb-rk3288_defconfig                       |   2 +-
  configs/fennec-rk3288_defconfig                    |   2 +-
  configs/firefly-rk3288_defconfig                   |   2 +-
  configs/lion-rk3368_defconfig                      |  79 ++
  configs/miqi-rk3288_defconfig                      |   2 +-
  configs/popmetal-rk3288_defconfig                  |   2 +-
  configs/rock2_defconfig                            |   2 +-
  configs/rock_defconfig                             |   2 +-
  configs/tinker-rk3288_defconfig                    |   2 +-
  doc/README.rockchip                                |   2 +-
  .../clock/rockchip,rk3368-dmc.txt                  |  67 ++
  drivers/Makefile                                   |  36 +-
  drivers/clk/Kconfig                                |  12 +-
  drivers/clk/Makefile                               |   2 +-
  drivers/clk/rockchip/clk_rk3368.c                  | 222 ++++-
  drivers/core/Kconfig                               |  23 +-
  drivers/core/Makefile                              |   4 +-
  drivers/net/gmac_rockchip.c                        |  54 ++
  drivers/pinctrl/rockchip/pinctrl_rk3368.c          | 101 ++-
  drivers/ram/Kconfig                                |  11 +-
  drivers/ram/Makefile                               |   2 +
  drivers/ram/rockchip/Makefile                      |   7 +
  drivers/ram/rockchip/dmc-rk3368.c                  | 990
  +++++++++++++++++++++ dts/Kconfig
     |  29 +
  include/configs/lion_rk3368.h                      |  19 +
  include/configs/rk3188_common.h                    |   2 +-
  include/configs/rk3288_common.h                    |   2 +-
  include/configs/rk3368_common.h                    |  15 +
  include/configs/rock.h                             |   2 +-
  include/configs/rockchip-common.h                  |   2 +-
  include/dt-bindings/memory/rk3368-dmc.h            |  30 +
  include/linux/kconfig.h                            |  13 +
  include/spl.h                                      |  10 +
  lib/Makefile                                       |  10 +-
  scripts/Makefile.spl                               |  14 +-
  scripts/config_whitelist.txt                       |   4 +
  tools/rkcommon.c                                   |   1 +
  76 files changed, 3142 insertions(+), 534 deletions(-)

create mode 100644 arch/arm/dts/rk3368-lion.dts
create mode 100644 arch/arm/include/asm/arch-rockchip/ddr_rk3368.h create mode 100644 arch/arm/mach-rockchip/rk3368-board-spl.c create mode 100644 arch/arm/mach-rockchip/rk3368-board-tpl.c delete mode 100644 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c create mode 100644 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds create mode 100644 board/theobroma-systems/lion_rk3368/Kconfig create mode 100644 board/theobroma-systems/lion_rk3368/MAINTAINERS create mode 100644 board/theobroma-systems/lion_rk3368/Makefile create mode 100644 board/theobroma-systems/lion_rk3368/README create mode 100644 board/theobroma-systems/lion_rk3368/fit_spl_atf.its create mode 100644 board/theobroma-systems/lion_rk3368/lion_rk3368.c create mode 100644 common/spl/spl_bootrom.c
create mode 100644 configs/lion-rk3368_defconfig
create mode 100644 doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt create mode 100644 drivers/ram/rockchip/Makefile
create mode 100644 drivers/ram/rockchip/dmc-rk3368.c create mode 100644 include/configs/lion_rk3368.h
create mode 100644 include/dt-bindings/memory/rk3368-dmc.h

Signature · 9 lines
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
maintainer
#74 lore raw

cover Support OF_PLATDATA in TPL, enable RK3368 DRAM init and add RK3368-uQ7

Hi Łukasz,

Am Montag, 24. Juli 2017, 11:23:05 CEST schrieb Łukasz Majewski:

Quoted 55 lines · Heiko Stübner
Quoted 40 lines

Am Montag, 24. Juli 2017, 16:38:52 CEST schrieb Andy Yan:

Quoted 39 lines

Hi Philipp:

Quoted 36 lines · Dr. Philipp Tomsich
Quoted 35 lines · Andy Yan

Hi:

Quoted 16 lines · Philipp Tomsich

Here's a series that has a lot going on, but I didn't want to split it to allow everyone to understand the motivation between some of the changes to the SPL/TPL framework. The short summary of this is "enablement for DRAM init on the RK3368 with everything else that's necessary to do it using OF_PLATDATA in TPL".

Enabling the RK3368 created a few more challenges that I'd expected:
- I needed different stack locations, text addresses and sizes for

TPL and SPL

- the TPL stage was to use OF_PLATDATA and SPL was to use full OF_CONTROL
- with the RK3368 TPL stage, there was a need to extend the back-to-bootrom

Quoted 8 lines

support for Rockchip to AArch64

- I wanted to start folding some of the Rockchip specific SPL support

(i.e. back-to-bootrom) back into the general SPL framework to allow
using it as a general boot method

I have a confusion here: according to the README.TPL, TPL is Third Program Loader, which loaded by the SPL. So I think it should run after the SPL. But from RK3188 and RK3368 TPL implementation , they all run before SPL.Maybe it is my misunderstanding, hope to get some guidance.:-)>

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

I think you are right and most Rockchip boards have been using this the wrong way around.

Actually at first I also had the ordering of SPL -> TPL -> uboot for rk3188
but after discussions with Simon and Tom Rini, the opinion was that TPL stands for "tiny" program loader and should run before the full SPL.

Has something changed since:

http://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/tpl-presentation.pdf

I've always thought that we do have SPL -> TPL -> u-boot -> Linux

Quoted 7 lines

If there was a change, then:

1. The TPL name is a bit misleading (considering the above presentation/status)

2. IMHO the code running before SPL (to do some _real_ early init) should be named more descriptive like PreSPL.

I've gone back and looked up the previous discussion. It was part of a thread where we only included Tom later on to clarify spl/tpl usage, so there is no list-reference, but I guess I can just quote the part:

----------------- 8< -------------------
Am Donnerstag, 26. Januar 2017, 12:57:40 CEST schrieben Tom Rini:

Quoted 35 lines · Simon Glass
Quoted 34 lines

+Tom for question below.

Hi Heiko,

Quoted 15 lines · Heiko Stübner

Hi,

Am Samstag, 17. Dezember 2016, 09:57:51 schrieb Simon Glass:

Quoted 3 lines

I cannot see the .S code in that tree. If it is a few instructions then it is fine. But if it is a lot of code I question why it cannot be written mostly in C?

The .S was just my question to Kever how he envisioned this "preloader" being implemented. Right now all my parts are fully C-based.

Quoted 4 lines

Using TPL seems OK to me. But from my understanding TPL runs before SPL. So the sequence should be: TPL -> SPL -> U-Boot. This makes some sense because SPL is a more full-featured loader, and TPL is just a mini-loader to get the SPL running.

Quoted 4 lines

hmm, I think SPL -> TPL -> U-Boot would be the correct order :-) Based on the TPL being the "tertiary program loader" where the SPL only is the "secondary program loader" and based on the slides from 2013 in [0].>

That seems wrong to me. A secondary load loads the primary loader, which surely means that the tertiary should load the secondary, i.e.

I think it should be:
2 loads 1 (SPL loads U-Boot)
3 loads 2 which loads 1 (TPL loads SPL which loads U-Boot)

The alternative is:
2 loads 3 which loads 1

Quoted 7 lines
Quoted 4 lines

which seems really odd.

Note that PowerPC appears to use TPL->SPL->U-Boot when I last looked at it. Of course I could be wrong.

Yes, naming is hard. TPL (which is maybe better thought of as Tiny not Tertiary) loads SPL loads U-Boot.

----------------- 8< -------------------

Heiko