[U-Boot] [PATCH v4 00/66] Support OF_PLATDATA in TPL, enable RK3368 DRAM init and add RK3368-uQ7

Philipp Tomsich philipp.tomsich at theobroma-systems.com
Wed Aug 2 20:33:55 UTC 2017


This update has everyone's comments included and even reworks for
Simon's request to retain the _SHIFT macros.  I'll start applying this
together with the DM timer series (to get rid of the hardcoded address
needed for the secure timer init) to the Rockchip tree tomorrow, so it
can be included in this week's pull-request.




Here's the (hopefully final) updated series to enable the RK3368 which
addresses the concerns regarding the prefixing of GRF bit-definitions
with a RK3368-prefix: while I had intended to temporarily pull the
GMAC support to get around the underlying issue, moving the
bit-definitions into the pinctrl-driver's implementation turned out to
rather straightforward (and there's little use in having these
definitions visible outside of the pinctrl driver anyway).

Thanks to everyone, who took the time to comment/discuss the initial
version.

This series (still) 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.


Changes in v4:
- removes spurious change to (the armv8) Makefile
- restore the symbolic constant for the shift-values in the IOMUX
  enums
- use symbolic constants for shift amount in IOMUX for SPI pinctrl
- fixes a broken sentence in a comment
- updates pctl and phy reset sequences per feedback from typ at rock-chips.com
- use imply for SPL/TPL preselects where SPL/TPL may not be enabled
  to avoid warning on applying a defconfig (thanks to Andy for reporting)
- (added) sets TPL_LDSCRIPT via Kconfig
- use 'select if' for SPL/TPL presets that need SPL/TPL to avoid errors
  on defconfig, if SPL/TPL is not enabled (thanks to Andy for noticing)
- migrate to Kconfig, so we don't need these in each defconfig

Changes in v3:
- (new patch) added fix-up of SPL/TPL confusion in help text
- change to use function-sections (instead of disabling at the
  Makefile-level for TPL builds) per Tom's suggestion
- commit message now correctly refers to TPL
- adds SGRF syscon support with OF_PLATDATA (to allow access to the
  SGRF address range from TPL)
- correctly states the location of the driver in the commit message
- removes the '#define DEBUG'
- uses the syscon API to access GRF and SGRF to avoid using hard-coded
  addresses
- (after rebase) update defconfig
- (after rebase and defconfig update) lion_rk3368.h: remove
  CONFIG_ENV_IS_NOWHERE
- moves remaining 'u-boot,dm-pre-reloc' to -u-boot.dtsi
- marks sgrf-node as pre-reloc
- defines SPL_LDSCRIPT and TPL_LDSCRIPT via defconfig
- moves SPL_LDSCRIPT and TPL_LDSCRIPT into Kconfig, as requested by
  by Tom; this gets rid of the whitelist-entry for SPL_LDSCRIPT (which
  qualifies as a preexisting condition) and of the newly created one
  for TPL_LDSCRIPT
- moves TPL_STACK, TPL_MAX_SIZE and TPL_TEXT_BASE to Kconfig
- changes the test to CONFIG_TPL_NEEDS_SEPARATE_STACK, as TPL_STACK
  will be a hex-value now (and this always be defined)
- changes Kconfig, so RK3368 will notify the SPL configuration of
  its need to have the TPL text-base, stack-pointer and max-size
  configured
- runs moveconfig.py TPL_STACK TPL_TEXT_BASE TPL_MAX_SIZE

Changes in v2:
- dropped the RK3368_ prefix for the GRF constants
- removed the RK3368-prefix on bit-definitions for GMAC pinctrl
- removed the RK3368 prefix on the SD/MMC pin definitions
- moved bit-definitions pertinent to pinctrl (i.e. the various IOMUX
  definitions) to the rk3368 pinctrl driver implementation
- added SPI clock setup
- moves the bit-definitions (for GRF registers) specific to the GMAC
  into the GMAC driver: these include interface speed selection and
  configuring the RGMII output mode
- removes a 'u-boot,dm-pre-reloc' from dmc-node in rk3368.dtsi
- copies the enum for the IOMUX config of the debug UART into the TPL
  support code, as the various constants are otherwise private to the
  pinctrl code (and we can't include pinctrl in the TPL stage due to
  size constraints/dependencies)
- added in v2
- reuses the support for configuring the boot order using the
  u-boot,spl-boot-order property
- drops the initialisation of the debug_uart
- adds pinctrl-configuration for the preloader UART
- marks pinctrl-node as 'u-boot,dm-pre-reloc' to ensure MMC2 (eMMC)
  works in the SPL stage
- makes uart0 as 'u-boot,dm-pre-reloc' to allow initialising the
  preloader console (instead of relying solely on the debug UART)
- adds support for SPI1 (and the on-module SPI flash)
- splits the a 'u-boot.dtsi' off the DTS file
- updates the defconfig for SPI and SPI flash support

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

Philipp Tomsich (65):
  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: use TPL_SYS_MALLOC_F_LEN for TPL
  spl: dm: Kconfig: fix help text for SPL/TPL confusion
  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 depends 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: move low-level assembly functions into function-sections
  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: 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: syscon: SGRF support for OF_PLATDATA
  rockchip: rk3368: grf: use shifted-constants
  rockchip: rk3368: dts: add sgrf node
  rockchip: pinctrl: rk3368: add GMAC (RGMII only) support
  rockchip: pinctrl: rk3368: add support for configuring the MMC pins
  rockchip: pinctrl: rk3368: move IOMUX bit-definitions to pinctrl
    driver
  rockchip: pinctrl: rk3368: add SPI support
  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()
  rockchip: clk: rk3368: add support for configuring the SPI clocks
  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: rk3368: dts: add DMC node in rk3368.dtsi
  rockchip: rk3368: spl: enable SPL_FRAMEWORK in rk3368_common.h
  rockchip: rk3368: spl: add TPL support
  rockchip: spl: make spl-boot-order code reusable (split from rk3399)
  rockchip: rk3368: spl: add SPL support
  rockchip: rk3368: spl: mark SPL and TPL as supported for
    ROCKCHIP_RK3368
  rockchip: spi: enable support for the rk_spi driver for the RK3368
  rockchip: board: lion-rk3368: add support for the RK3368-uQ7
  spl: Kconfig: migrate $(SPL_TPL_)LDSCRIPT to Kconfig
  rockchip: Kconfig: preset TPL_LDSCRIPT via Kconfig for the RK3368
  spl: support TPL_STACK, TPL_MAX_SIZE and TPL_TEXT_BASE via Kconfig
  armv8: TPL_STACK will always be defined, so test
    CONFIG_TPL_NEEDS_SEPARATE_STACK
  rockchip: rk3368: mark TPL as not inheriting its stack, text-base and
    size from SPL
  moveconfig: migrate TPL_STACK, TPL_TEXT_BASE and TPL_MAX_SIZE
  rockchip: board: puma-rk3399: fix warnings in
    puma_rk3399/fit_spl_atf.its

 Kconfig                                            |   12 +-
 Makefile                                           |    2 +-
 arch/arm/cpu/armv8/cache.S                         |   22 +
 arch/arm/cpu/armv8/tlb.S                           |    4 +-
 arch/arm/cpu/armv8/transition.S                    |    6 +
 arch/arm/dts/Makefile                              |    1 +
 arch/arm/dts/rk3368-lion-u-boot.dtsi               |   88 ++
 arch/arm/dts/rk3368-lion.dts                       |  195 ++++
 arch/arm/dts/rk3368.dtsi                           |   28 +-
 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    |  326 +------
 arch/arm/include/asm/spl.h                         |    1 +
 arch/arm/lib/crt0_64.S                             |    4 +-
 arch/arm/mach-rockchip/Kconfig                     |   55 +-
 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          |   98 ++
 arch/arm/mach-rockchip/rk3368-board-tpl.c          |  177 ++++
 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      |   44 +
 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds       |   13 +
 arch/arm/mach-rockchip/rk3399-board-spl.c          |  106 +--
 arch/arm/mach-rockchip/save_boot_param.S           |   37 +
 arch/arm/mach-rockchip/spl-boot-order.c            |  108 +++
 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                                 |  106 ++-
 common/spl/Makefile                                |   35 +-
 common/spl/spl.c                                   |    7 +-
 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                      |   92 ++
 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                  |  302 +++++-
 drivers/core/Kconfig                               |   23 +-
 drivers/core/Makefile                              |    4 +-
 drivers/net/gmac_rockchip.c                        |   78 ++
 drivers/pinctrl/rockchip/pinctrl_rk3368.c          |  577 ++++++++++-
 drivers/ram/Kconfig                                |   11 +-
 drivers/ram/Makefile                               |    2 +
 drivers/ram/rockchip/Makefile                      |    7 +
 drivers/ram/rockchip/dmc-rk3368.c                  | 1007 ++++++++++++++++++++
 drivers/spi/rk_spi.c                               |    9 +
 dts/Kconfig                                        |   29 +
 include/configs/lion_rk3368.h                      |   18 +
 include/configs/rk3188_common.h                    |    2 +-
 include/configs/rk3288_common.h                    |    2 +-
 include/configs/rk3368_common.h                    |    8 +
 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                               |   19 +-
 scripts/config_whitelist.txt                       |    2 -
 tools/rkcommon.c                                   |    1 +
 82 files changed, 3783 insertions(+), 666 deletions(-)
 create mode 100644 arch/arm/dts/rk3368-lion-u-boot.dtsi
 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 arch/arm/mach-rockchip/spl-boot-order.c
 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

-- 
2.1.4



More information about the U-Boot mailing list