Skip to contentSkip to conversation

rockchip: rk3288: Change method of loading u-boot

PATCH Superseded Ziyuan Xu 2 participants 5 messages Jun 27, 2016 – Jul 12, 2016

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Ziyuan Xu

author
#0 lore raw

PATCH v3 1/1 rockchip: rk3288: Change method of loading u-boot

From: Xu Ziyuan <[email protected]>

If we would like to boot from SD card, we have to implement mmc driver in SPL stage, and get a slightly large spl binrary. RK3288's bootrom code has the ability to load spl and u-boot, then boot.

If CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM is enabled, the spl will return to bootrom in board_init_f(), then bootrom load u-boot binrary.

This patch does that.

Loading sequence after rework:
bootrom ==> spl ==> bootrom ==> u-boot

---

Changes in v3:
- Add CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM for enabling this feature
- Update doc/README.rockchip to instruct how to use it
- Detailed commit message

Changes in v2:
- Add sdcard iomux initlization in board_init() to fix sdmmc command sending timeout issue when booting from eMMC

 arch/arm/mach-rockchip/Makefile                    |  1 +
 arch/arm/mach-rockchip/board.c                     | 33 ++++++++++++++++++++++
 arch/arm/mach-rockchip/rk3036/Makefile             |  1 -
 arch/arm/mach-rockchip/rk3288-board-spl.c          |  5 +++-
 .../mach-rockchip/{rk3036 => }/save_boot_param.S   |  2 +-
 doc/README.rockchip                                | 14 +++++++++
 include/configs/rk3288_common.h                    |  4 +++
 7 files changed, 57 insertions(+), 3 deletions(-)
 rename arch/arm/mach-rockchip/{rk3036 => }/save_boot_param.S (90%)
arch/arm/mach-rockchip/Makefile +1 -0
index 55567cb..8e0c0ab 100644
@@ -7,6 +7,7 @@
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-spl.o
 obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
+obj-y += save_boot_param.o
 else
 obj-$(CONFIG_ROCKCHIP_RK3288) += board.o
 endif
arch/arm/mach-rockchip/board.c +33 -0
index 816540e..bcb2c9e 100644
@@ -10,12 +10,45 @@
 #include <ram.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
+#include <asm/arch/periph.h>
+#include <asm/gpio.h>
+#include <dm/pinctrl.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 int board_init(void)
 {
+#ifdef CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM
+	struct udevice *pinctrl;
+	int ret;
+
+    /*
+     * We need to implement sdcard iomux here for the further
+     * initlization, otherwise, it'll hit sdcard command sending
+     * timeout exception.
+     */
+	ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
+	if (ret) {
+		debug("%s: Cannot find pinctrl device\n", __func__);
+		goto err;
+	}
+	ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD);
+	if (ret) {
+		debug("%s: Failed to set up SD card\n", __func__);
+		goto err;
+	}
+
+	return 0;
+err:
+	printf("board_init: Error %d\n", ret);
+
+	/* No way to report error here */
+	hang();
+
+	return -1;
+#else
 	return 0;
+#endif
 }
 
 int dram_init(void)
arch/arm/mach-rockchip/rk3036/Makefile +0 -1
index 97d299d..6095777 100644
@@ -10,4 +10,3 @@ obj-y += syscon_rk3036.o
 endif
 
 obj-y += sdram_rk3036.o
-obj-y += save_boot_param.o
arch/arm/mach-rockchip/rk3288-board-spl.c +4 -1
index e133cca..5de060c 100644
@@ -149,7 +149,7 @@ static int configure_emmc(struct udevice *pinctrl)
 	return 0;
 }
 #endif
-
+extern void back_to_bootrom(void);
 void board_init_f(ulong dummy)
 {
 	struct udevice *pinctrl;
@@ -204,6 +204,9 @@ void board_init_f(ulong dummy)
 		debug("DRAM init failed: %d\n", ret);
 		return;
 	}
+#ifdef CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM
+	back_to_bootrom();
+#endif
 }
 
 static int setup_led(void)
arch/arm/mach-rockchip/save_boot_param.S renamed from arch/arm/mach-rockchip/rk3036/save_boot_param.S +1 -1
similarity index 90%
rename from arch/arm/mach-rockchip/rk3036/save_boot_param.S
rename to arch/arm/mach-rockchip/save_boot_param.S
index 778ec83..85b407b 100644
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2015 Google, Inc
+ * (C) Copyright 2016 Rockchip Electronics Co., Ltd
  *
  * SPDX-License-Identifier:     GPL-2.0+
  */
doc/README.rockchip +14 -0
index e0572c8..4c6a04e 100644
@@ -119,6 +119,20 @@ something like:
    Hit any key to stop autoboot:  0
    =>
 
+The rockchip bootrom could load and boot an initial spl, then continue to
+load a second level bootloader(ie. u-boot) as soon as it return 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_RK3288_SPL_BACKTO_BROM
+
+You can create the image via the following operations:
+
+   ./firefly-rk3288/tools/mkimage -n rk3288 -T rksd -d \
+	firefly-rk3288/spl/u-boot-spl-dtb.bin out && \
+   cat firefly-rk3288/u-boot-dtb.bin >> out && \
+   sudo dd if=out of=/dev/sdc seek=64
+
 If you have an HDMI cable attached you should see a video console.
 
 For evb_rk3036 board:
include/configs/rk3288_common.h +4 -0
index 9d50d83..3574d57 100644
@@ -33,7 +33,11 @@
 #define CONFIG_SYS_NS16550_MEM32
 #define CONFIG_SPL_BOARD_INIT
 
+#ifndef CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM
 #define CONFIG_SYS_TEXT_BASE		0x00100000
+#else
+#define CONFIG_SYS_TEXT_BASE		0x00000000
+#endif
 #define CONFIG_SYS_INIT_SP_ADDR		0x00100000
 #define CONFIG_SYS_LOAD_ADDR		0x00800800
 #define CONFIG_SPL_STACK		0xff718000
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 1/1 rockchip: rk3288: Change method of loading u-boot

Hi Ziyuan,

Quoted 17 lines · Ziyuan Xu

From: Xu Ziyuan <[email protected]>

If we would like to boot from SD card, we have to implement mmc driver in SPL stage, and get a slightly large spl binrary. RK3288's bootrom code has the ability to load spl and u-boot, then boot.

If CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM is enabled, the spl will return to bootrom in board_init_f(), then bootrom load u-boot binrary.

This patch does that.

Loading sequence after rework:
bootrom ==> spl ==> bootrom ==> u-boot

---

Quoted 8 lines

Changes in v3:
- Add CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM for enabling this feature
- Update doc/README.rockchip to instruct how to use it
- Detailed commit message

Changes in v2:
- Add sdcard iomux initlization in board_init() to fix sdmmc command sending timeout issue when booting from eMMC

I'm going to apply this, but please can you send a follow-up patch (to u-boot-rockchip/testing) to fix the nits below?

Quoted 30 lines
 arch/arm/mach-rockchip/Makefile                    |  1 +
 arch/arm/mach-rockchip/board.c                     | 33 ++++++++++++++++++++++
 arch/arm/mach-rockchip/rk3036/Makefile             |  1 -
 arch/arm/mach-rockchip/rk3288-board-spl.c          |  5 +++-
 .../mach-rockchip/{rk3036 => }/save_boot_param.S   |  2 +-
 doc/README.rockchip                                | 14 +++++++++
 include/configs/rk3288_common.h                    |  4 +++
 7 files changed, 57 insertions(+), 3 deletions(-)
 rename arch/arm/mach-rockchip/{rk3036 => }/save_boot_param.S (90%)
arch/arm/mach-rockchip/Makefile +1 -0
index 55567cb..8e0c0ab 100644
@@ -7,6 +7,7 @@
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-spl.o
 obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
+obj-y += save_boot_param.o
 else
 obj-$(CONFIG_ROCKCHIP_RK3288) += board.o
 endif
arch/arm/mach-rockchip/board.c +0 -0
index 816540e..bcb2c9e 100644
@@ -10,12 +10,45 @@
 #include <ram.h>
 #include <asm/io.h>

arch/arm/mach-rockchip/board.c line 21

Quoted 10 lines
arch/arm/mach-rockchip/board.c +4 -0
 #include <asm/arch/clock.h>
+#include <asm/arch/periph.h>
+#include <asm/gpio.h>
+#include <dm/pinctrl.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 int board_init(void)
 {
+#ifdef CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM

How about CONFIG_ROCKCHIP_SPL_BACK_TO_BROM?

I think this could be implemented for any SoC.

Also please add this to Kconfig as we should not be adding new CONFIG options that are not in Kconfig.

Quoted 84 lines
arch/arm/mach-rockchip/board.c +29 -0
+       struct udevice *pinctrl;
+       int ret;
+
+    /*
+     * We need to implement sdcard iomux here for the further
+     * initlization, otherwise, it'll hit sdcard command sending
+     * timeout exception.
+     */
+       ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
+       if (ret) {
+               debug("%s: Cannot find pinctrl device\n", __func__);
+               goto err;
+       }
+       ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD);
+       if (ret) {
+               debug("%s: Failed to set up SD card\n", __func__);
+               goto err;
+       }
+
+       return 0;
+err:
+       printf("board_init: Error %d\n", ret);
+
+       /* No way to report error here */
+       hang();
+
+       return -1;
+#else
        return 0;
+#endif
 }
 
 int dram_init(void)
arch/arm/mach-rockchip/rk3036/Makefile +0 -1
index 97d299d..6095777 100644
@@ -10,4 +10,3 @@ obj-y += syscon_rk3036.o
 endif
 
 obj-y += sdram_rk3036.o
-obj-y += save_boot_param.o
arch/arm/mach-rockchip/rk3288-board-spl.c +4 -1
index e133cca..5de060c 100644
@@ -149,7 +149,7 @@ static int configure_emmc(struct udevice *pinctrl)
        return 0;
 }
 #endif
-
+extern void back_to_bootrom(void);
 void board_init_f(ulong dummy)
 {
        struct udevice *pinctrl;
@@ -204,6 +204,9 @@ void board_init_f(ulong dummy)
                debug("DRAM init failed: %d\n", ret);
                return;
        }
+#ifdef CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM
+       back_to_bootrom();
+#endif
 }
 
 static int setup_led(void)
arch/arm/mach-rockchip/save_boot_param.S renamed from arch/arm/mach-rockchip/rk3036/save_boot_param.S +1 -1
similarity index 90%
rename from arch/arm/mach-rockchip/rk3036/save_boot_param.S
rename to arch/arm/mach-rockchip/save_boot_param.S
index 778ec83..85b407b 100644
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2015 Google, Inc
+ * (C) Copyright 2016 Rockchip Electronics Co., Ltd
  *
  * SPDX-License-Identifier:     GPL-2.0+
  */
doc/README.rockchip +0 -0
index e0572c8..4c6a04e 100644

doc/README.rockchip something like: · line 122

Quoted 4 lines
doc/README.rockchip +1 -0
@@ -119,6 +119,20 @@ something like:
    Hit any key to stop autoboot:  0
    =>
 
+The rockchip bootrom could load and boot an initial spl, then continue to

s/could/can/

doc/README.rockchip something like: · line 123

Quoted 1 line
doc/README.rockchip +1 -0
+load a second level bootloader(ie. u-boot) as soon as it return to bootrom.

second-level

U-Boot

s/return/returns

doc/README.rockchip something like: · line 127

Quoted 4 lines
doc/README.rockchip +4 -0
+Therefore RK3288 has another loading sequence like RK3036. The option of
+U-Boot is controlled with this setting in U-Boot:
+
+       #define CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM

If you make this a generic Rockchip option then it should be enabled for RK3036 by default.

Quoted 16 lines
doc/README.rockchip +8 -0
+
+You can create the image via the following operations:
+
+   ./firefly-rk3288/tools/mkimage -n rk3288 -T rksd -d \
+       firefly-rk3288/spl/u-boot-spl-dtb.bin out && \
+   cat firefly-rk3288/u-boot-dtb.bin >> out && \
+   sudo dd if=out of=/dev/sdc seek=64
+
 If you have an HDMI cable attached you should see a video console.
 
 For evb_rk3036 board:
include/configs/rk3288_common.h +0 -0
index 9d50d83..3574d57 100644

include/configs/rk3288_common.h line 40

Quoted 8 lines
include/configs/rk3288_common.h +4 -0
@@ -33,7 +33,11 @@
 #define CONFIG_SYS_NS16550_MEM32
 #define CONFIG_SPL_BOARD_INIT
 
+#ifndef CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM
 #define CONFIG_SYS_TEXT_BASE           0x00100000
+#else
+#define CONFIG_SYS_TEXT_BASE           0x00000000
+#endif

Can you flip that to an ifdef?

Also please add a comment as to why it needs to be 0.

Quoted 7 lines
include/configs/rk3288_common.h +0 -1
 #define CONFIG_SYS_INIT_SP_ADDR                0x00100000
 #define CONFIG_SYS_LOAD_ADDR           0x00800800
 #define CONFIG_SPL_STACK               0xff718000
--

1.9.1

Regards,
Simon

author
#2 lore raw

PATCH v3 1/1 rockchip: rk3288: Change method of loading u-boot

hi Simon,

Quoted 25 lines · Simon Glass

Hi Ziyuan,

Quoted 22 lines · Ziyuan Xu

From: Xu Ziyuan <[email protected]>

If we would like to boot from SD card, we have to implement mmc driver in SPL stage, and get a slightly large spl binrary. RK3288's bootrom code has the ability to load spl and u-boot, then boot.

If CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM is enabled, the spl will return to bootrom in board_init_f(), then bootrom load u-boot binrary.

This patch does that.

Loading sequence after rework:
bootrom ==> spl ==> bootrom ==> u-boot

---

Changes in v3:
- Add CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM for enabling this feature
- Update doc/README.rockchip to instruct how to use it
- Detailed commit message

Quoted 7 lines
Quoted 3 lines

Changes in v2:
- Add sdcard iomux initlization in board_init() to fix sdmmc command sending timeout issue when booting from eMMC

I'm going to apply this, but please can you send a follow-up patch (to u-boot-rockchip/testing) to fix the nits below?

This patch had already apply to u-boot/rockchip, I can't revise commit' nits.
I had revise the glitches according to your opinion. May I send patch V4, and you revert the former commit?

Quoted 191 lines
Quoted 30 lines
  arch/arm/mach-rockchip/Makefile                    |  1 +
  arch/arm/mach-rockchip/board.c                     | 33 ++++++++++++++++++++++
  arch/arm/mach-rockchip/rk3036/Makefile             |  1 -
  arch/arm/mach-rockchip/rk3288-board-spl.c          |  5 +++-
  .../mach-rockchip/{rk3036 => }/save_boot_param.S   |  2 +-
  doc/README.rockchip                                | 14 +++++++++
  include/configs/rk3288_common.h                    |  4 +++
  7 files changed, 57 insertions(+), 3 deletions(-)

rename arch/arm/mach-rockchip/{rk3036 => }/save_boot_param.S (90%)

arch/arm/mach-rockchip/Makefile +1 -0
index 55567cb..8e0c0ab 100644
@@ -7,6 +7,7 @@
  ifdef CONFIG_SPL_BUILD
  obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-spl.o
  obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
+obj-y += save_boot_param.o
  else
  obj-$(CONFIG_ROCKCHIP_RK3288) += board.o
  endif
arch/arm/mach-rockchip/board.c +0 -0
index 816540e..bcb2c9e 100644
@@ -10,12 +10,45 @@
  #include <ram.h>
  #include <asm/io.h>

arch/arm/mach-rockchip/board.c line 21

Quoted 10 lines
arch/arm/mach-rockchip/board.c +4 -0
  #include <asm/arch/clock.h>
+#include <asm/arch/periph.h>
+#include <asm/gpio.h>
+#include <dm/pinctrl.h>
 
  DECLARE_GLOBAL_DATA_PTR;
 
  int board_init(void)
  {
+#ifdef CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM

How about CONFIG_ROCKCHIP_SPL_BACK_TO_BROM?

I think this could be implemented for any SoC.

Also please add this to Kconfig as we should not be adding new CONFIG options that are not in Kconfig.

Quoted 84 lines
arch/arm/mach-rockchip/board.c +29 -0
+       struct udevice *pinctrl;
+       int ret;
+
+    /*
+     * We need to implement sdcard iomux here for the further
+     * initlization, otherwise, it'll hit sdcard command sending
+     * timeout exception.
+     */
+       ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
+       if (ret) {
+               debug("%s: Cannot find pinctrl device\n", __func__);
+               goto err;
+       }
+       ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD);
+       if (ret) {
+               debug("%s: Failed to set up SD card\n", __func__);
+               goto err;
+       }
+
+       return 0;
+err:
+       printf("board_init: Error %d\n", ret);
+
+       /* No way to report error here */
+       hang();
+
+       return -1;
+#else
         return 0;
+#endif
  }
 
  int dram_init(void)
arch/arm/mach-rockchip/rk3036/Makefile +0 -1
index 97d299d..6095777 100644
@@ -10,4 +10,3 @@ obj-y += syscon_rk3036.o
  endif
 
  obj-y += sdram_rk3036.o
-obj-y += save_boot_param.o
arch/arm/mach-rockchip/rk3288-board-spl.c +4 -1
index e133cca..5de060c 100644
@@ -149,7 +149,7 @@ static int configure_emmc(struct udevice *pinctrl)
         return 0;
  }
  #endif
-
+extern void back_to_bootrom(void);
  void board_init_f(ulong dummy)
  {
         struct udevice *pinctrl;
@@ -204,6 +204,9 @@ void board_init_f(ulong dummy)
                 debug("DRAM init failed: %d\n", ret);
                 return;
         }
+#ifdef CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM
+       back_to_bootrom();
+#endif
  }
 
  static int setup_led(void)
arch/arm/mach-rockchip/save_boot_param.S renamed from arch/arm/mach-rockchip/rk3036/save_boot_param.S +1 -1
similarity index 90%
rename from arch/arm/mach-rockchip/rk3036/save_boot_param.S
rename to arch/arm/mach-rockchip/save_boot_param.S
index 778ec83..85b407b 100644
@@ -1,5 +1,5 @@
  /*
- * (C) Copyright 2015 Google, Inc
+ * (C) Copyright 2016 Rockchip Electronics Co., Ltd
   *
   * SPDX-License-Identifier:     GPL-2.0+
   */
doc/README.rockchip +0 -0
index e0572c8..4c6a04e 100644

doc/README.rockchip something like: · line 122

Quoted 4 lines
doc/README.rockchip +1 -0
@@ -119,6 +119,20 @@ something like:
     Hit any key to stop autoboot:  0
     =>
 
+The rockchip bootrom could load and boot an initial spl, then continue to

s/could/can/

doc/README.rockchip something like: · line 123

Quoted 1 line
doc/README.rockchip +1 -0
+load a second level bootloader(ie. u-boot) as soon as it return to bootrom.

second-level

U-Boot

s/return/returns

doc/README.rockchip something like: · line 127

Quoted 4 lines
doc/README.rockchip +4 -0
+Therefore RK3288 has another loading sequence like RK3036. The option of
+U-Boot is controlled with this setting in U-Boot:
+
+       #define CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM

If you make this a generic Rockchip option then it should be enabled for RK3036 by default.

Quoted 16 lines
doc/README.rockchip +8 -0
+
+You can create the image via the following operations:
+
+   ./firefly-rk3288/tools/mkimage -n rk3288 -T rksd -d \
+       firefly-rk3288/spl/u-boot-spl-dtb.bin out && \
+   cat firefly-rk3288/u-boot-dtb.bin >> out && \
+   sudo dd if=out of=/dev/sdc seek=64
+
  If you have an HDMI cable attached you should see a video console.
 
  For evb_rk3036 board:
include/configs/rk3288_common.h +0 -0
index 9d50d83..3574d57 100644

include/configs/rk3288_common.h line 40

Quoted 8 lines
include/configs/rk3288_common.h +4 -0
@@ -33,7 +33,11 @@
  #define CONFIG_SYS_NS16550_MEM32
  #define CONFIG_SPL_BOARD_INIT
 
+#ifndef CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM
  #define CONFIG_SYS_TEXT_BASE           0x00100000
+#else
+#define CONFIG_SYS_TEXT_BASE           0x00000000
+#endif

Can you flip that to an ifdef?

Also please add a comment as to why it needs to be 0.

Quoted 7 lines
include/configs/rk3288_common.h +0 -1
  #define CONFIG_SYS_INIT_SP_ADDR                0x00100000
  #define CONFIG_SYS_LOAD_ADDR           0x00800800
  #define CONFIG_SPL_STACK               0xff718000
--

1.9.1

Regards,
Simon

#3 lore raw

PATCH v3 1/1 rockchip: rk3288: Change method of loading u-boot

Hi,

Quoted 14 lines · Ziyuan Xu

hi Simon,

Quoted 9 lines · Simon Glass

Hi Ziyuan,

Quoted 5 lines · Ziyuan Xu

From: Xu Ziyuan <[email protected]>

If we would like to boot from SD card, we have to implement mmc driver in SPL stage, and get a slightly large spl binrary. RK3288's bootrom

code

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines

has the ability to load spl and u-boot, then boot.

If CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM is enabled, the spl will return to bootrom in board_init_f(), then bootrom load u-boot binrary.

This patch does that.

Loading sequence after rework:
bootrom ==> spl ==> bootrom ==> u-boot

---

Changes in v3:
- Add CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM for enabling this feature
- Update doc/README.rockchip to instruct how to use it
- Detailed commit message

Changes in v2:
- Add sdcard iomux initlization in board_init() to fix sdmmc command sending timeout issue when booting from eMMC

Quoted 6 lines
Quoted 4 lines

I'm going to apply this, but please can you send a follow-up patch (to u-boot-rockchip/testing) to fix the nits below?

This patch had already apply to u-boot/rockchip, I can't revise commit'

nits.

Quoted 1 line

I had revise the glitches according to your opinion. May I send patch V4,

and you revert the former commit?

Yes, either that or a new patch with your changes is fine.

Regards,
Simon

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

  arch/arm/mach-rockchip/Makefile                    |  1 +
  arch/arm/mach-rockchip/board.c                     | 33

++++++++++++++++++++++

Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
  arch/arm/mach-rockchip/rk3036/Makefile             |  1 -
  arch/arm/mach-rockchip/rk3288-board-spl.c          |  5 +++-
  .../mach-rockchip/{rk3036 => }/save_boot_param.S   |  2 +-
  doc/README.rockchip                                | 14 +++++++++
  include/configs/rk3288_common.h                    |  4 +++
  7 files changed, 57 insertions(+), 3 deletions(-)

rename arch/arm/mach-rockchip/{rk3036 => }/save_boot_param.S (90%)

(quoted diff) +0 -0

b/arch/arm/mach-rockchip/Makefile

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

index 55567cb..8e0c0ab 100644

arch/arm/mach-rockchip/Makefile +0 -0
@@ -7,6 +7,7 @@
Quoted 8 lines
Quoted 8 lines

Review

Quoted 8 lines
arch/arm/mach-rockchip/Makefile +1 -0
  ifdef CONFIG_SPL_BUILD
  obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-spl.o
  obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
+obj-y += save_boot_param.o
  else
  obj-$(CONFIG_ROCKCHIP_RK3288) += board.o
  endif
(quoted diff) +0 -0

b/arch/arm/mach-rockchip/board.c

Quoted 56 lines
Quoted 56 lines
Quoted 6 lines

index 816540e..bcb2c9e 100644

arch/arm/mach-rockchip/board.c +0 -0
@@ -10,12 +10,45 @@
  #include <ram.h>
  #include <asm/io.h>

arch/arm/mach-rockchip/board.c line 21

Quoted 10 lines
arch/arm/mach-rockchip/board.c +4 -0
  #include <asm/arch/clock.h>
+#include <asm/arch/periph.h>
+#include <asm/gpio.h>
+#include <dm/pinctrl.h>
 
  DECLARE_GLOBAL_DATA_PTR;
 
  int board_init(void)
  {
+#ifdef CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM

How about CONFIG_ROCKCHIP_SPL_BACK_TO_BROM?

I think this could be implemented for any SoC.

Also please add this to Kconfig as we should not be adding new CONFIG options that are not in Kconfig.

Quoted 32 lines
arch/arm/mach-rockchip/board.c +29 -0
+       struct udevice *pinctrl;
+       int ret;
+
+    /*
+     * We need to implement sdcard iomux here for the further
+     * initlization, otherwise, it'll hit sdcard command sending
+     * timeout exception.
+     */
+       ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
+       if (ret) {
+               debug("%s: Cannot find pinctrl device\n", __func__);
+               goto err;
+       }
+       ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD);
+       if (ret) {
+               debug("%s: Failed to set up SD card\n", __func__);
+               goto err;
+       }
+
+       return 0;
+err:
+       printf("board_init: Error %d\n", ret);
+
+       /* No way to report error here */
+       hang();
+
+       return -1;
+#else
         return 0;
+#endif
  }
 
Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
arch/arm/mach-rockchip/board.c +0 -0
  int dram_init(void)
(quoted diff) +0 -0

b/arch/arm/mach-rockchip/rk3036/Makefile

Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines

index 97d299d..6095777 100644

arch/arm/mach-rockchip/rk3036/Makefile +0 -1
@@ -10,4 +10,3 @@ obj-y += syscon_rk3036.o
  endif
 
  obj-y += sdram_rk3036.o
-obj-y += save_boot_param.o
(quoted diff) +0 -0

b/arch/arm/mach-rockchip/rk3288-board-spl.c

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

index e133cca..5de060c 100644

arch/arm/mach-rockchip/rk3288-board-spl.c +4 -1
@@ -149,7 +149,7 @@ static int configure_emmc(struct udevice *pinctrl)
         return 0;
  }
  #endif
-
+extern void back_to_bootrom(void);
  void board_init_f(ulong dummy)
  {
         struct udevice *pinctrl;
@@ -204,6 +204,9 @@ void board_init_f(ulong dummy)
                 debug("DRAM init failed: %d\n", ret);
                 return;
         }
+#ifdef CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM
+       back_to_bootrom();
+#endif
  }
 
Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
arch/arm/mach-rockchip/rk3288-board-spl.c +0 -0
  static int setup_led(void)
(quoted diff) +0 -0

b/arch/arm/mach-rockchip/save_boot_param.S

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

similarity index 90%
rename from arch/arm/mach-rockchip/rk3036/save_boot_param.S rename to arch/arm/mach-rockchip/save_boot_param.S index 778ec83..85b407b 100644

arch/arm/mach-rockchip/save_boot_param.S renamed from arch/arm/mach-rockchip/rk3036/save_boot_param.S +1 -1
@@ -1,5 +1,5 @@
  /*
- * (C) Copyright 2015 Google, Inc
+ * (C) Copyright 2016 Rockchip Electronics Co., Ltd
   *
   * SPDX-License-Identifier:     GPL-2.0+
   */
doc/README.rockchip +0 -0
index e0572c8..4c6a04e 100644
@@ -119,6 +119,20 @@ something like:
     Hit any key to stop autoboot:  0
     =>
 
Quoted 1 line
Quoted 1 line

doc/README.rockchip something like: · line 122

Quoted 1 line
doc/README.rockchip +1 -0
+The rockchip bootrom could load and boot an initial spl, then continue

to

Quoted 4 lines
Quoted 4 lines

s/could/can/

Quoted 1 line
doc/README.rockchip +1 -0
+load a second level bootloader(ie. u-boot) as soon as it return to

bootrom.

Quoted 8 lines
Quoted 8 lines

second-level

U-Boot

s/return/returns

Quoted 1 line
doc/README.rockchip +1 -0
+Therefore RK3288 has another loading sequence like RK3036. The option

of

Quoted 17 lines
Quoted 17 lines

doc/README.rockchip something like: · line 127

Quoted 3 lines
doc/README.rockchip +3 -0
+U-Boot is controlled with this setting in U-Boot:
+
+       #define CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM

If you make this a generic Rockchip option then it should be enabled for RK3036 by default.

Quoted 10 lines
doc/README.rockchip +8 -0
+
+You can create the image via the following operations:
+
+   ./firefly-rk3288/tools/mkimage -n rk3288 -T rksd -d \
+       firefly-rk3288/spl/u-boot-spl-dtb.bin out && \
+   cat firefly-rk3288/u-boot-dtb.bin >> out && \
+   sudo dd if=out of=/dev/sdc seek=64
+
  If you have an HDMI cable attached you should see a video console.
 
Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
doc/README.rockchip +0 -0
  For evb_rk3036 board:
(quoted diff) +0 -0

b/include/configs/rk3288_common.h

Quoted 31 lines
Quoted 29 lines

include/configs/rk3288_common.h line 40

Quoted 12 lines

index 9d50d83..3574d57 100644

include/configs/rk3288_common.h +4 -0
@@ -33,7 +33,11 @@
  #define CONFIG_SYS_NS16550_MEM32
  #define CONFIG_SPL_BOARD_INIT
 
+#ifndef CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM
  #define CONFIG_SYS_TEXT_BASE           0x00100000
+#else
+#define CONFIG_SYS_TEXT_BASE           0x00000000
+#endif

Can you flip that to an ifdef?

Also please add a comment as to why it needs to be 0.

Quoted 7 lines
include/configs/rk3288_common.h +0 -1
  #define CONFIG_SYS_INIT_SP_ADDR                0x00100000
  #define CONFIG_SYS_LOAD_ADDR           0x00800800
  #define CONFIG_SPL_STACK               0xff718000
--

1.9.1

Regards,
Simon

#4 lore raw

PATCH v3 1/1 rockchip: rk3288: Change method of loading u-boot

In reply to Ziyuan Xu
Quoted 26 lines · Ziyuan Xu

From: Xu Ziyuan <[email protected]>

If we would like to boot from SD card, we have to implement mmc driver in SPL stage, and get a slightly large spl binrary. RK3288's bootrom code has the ability to load spl and u-boot, then boot.

If CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM is enabled, the spl will return to bootrom in board_init_f(), then bootrom load u-boot binrary.

This patch does that.

Loading sequence after rework:
bootrom ==> spl ==> bootrom ==> u-boot

---

Changes in v3:
- Add CONFIG_ROCKCHIP_RK3288_SPL_BACKTO_BROM for enabling this feature
- Update doc/README.rockchip to instruct how to use it
- Detailed commit message

Changes in v2:
- Add sdcard iomux initlization in board_init() to fix sdmmc command sending timeout issue when booting from eMMC

Quoted 10 lines
 arch/arm/mach-rockchip/Makefile                    |  1 +
 arch/arm/mach-rockchip/board.c                     | 33 ++++++++++++++++++++++
 arch/arm/mach-rockchip/rk3036/Makefile             |  1 -
 arch/arm/mach-rockchip/rk3288-board-spl.c          |  5 +++-
 .../mach-rockchip/{rk3036 => }/save_boot_param.S   |  2 +-
 doc/README.rockchip                                | 14 +++++++++
 include/configs/rk3288_common.h                    |  4 +++
 7 files changed, 57 insertions(+), 3 deletions(-)
 rename arch/arm/mach-rockchip/{rk3036 => }/save_boot_param.S (90%)

Applied to u-boot-rockchip, thanks!