diff --git a/packages/tools/u-boot/patches/rockchip/u-boot-0001-dont-build-libfdt.patch b/packages/tools/u-boot/patches/rockchip/u-boot-0001-dont-build-libfdt.patch index 2fdfa55d68..f555f5e2dc 100644 --- a/packages/tools/u-boot/patches/rockchip/u-boot-0001-dont-build-libfdt.patch +++ b/packages/tools/u-boot/patches/rockchip/u-boot-0001-dont-build-libfdt.patch @@ -1,7 +1,7 @@ -From 726b4484a18c5fc135fc6e744d799308c33798fb Mon Sep 17 00:00:00 2001 +From 85f5dd7511d2eaea04a6ba53dc60d1879060568b Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 2 Dec 2017 11:47:07 +0100 -Subject: [PATCH 1/2] dont build libfdt +Subject: [PATCH] dont build libfdt --- Makefile | 2 +- @@ -46,7 +46,7 @@ index b86ea76bab..ea54f9098c 100644 echo '*** install it on your system, or try:'; \ echo '***'; \ diff --git a/tools/Makefile b/tools/Makefile -index a0db19d6b0..d6906a9603 100644 +index 8e1009bf6c..459c71ef1f 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -232,10 +232,6 @@ clean-dirs := lib common diff --git a/packages/tools/u-boot/patches/rockchip/u-boot-0002-rockchip-tinker-enable-rockchip-video-driver.patch b/packages/tools/u-boot/patches/rockchip/u-boot-0002-rockchip-tinker-enable-rockchip-video-driver.patch index 125ccc13f8..b6643568e5 100644 --- a/packages/tools/u-boot/patches/rockchip/u-boot-0002-rockchip-tinker-enable-rockchip-video-driver.patch +++ b/packages/tools/u-boot/patches/rockchip/u-boot-0002-rockchip-tinker-enable-rockchip-video-driver.patch @@ -1,7 +1,7 @@ -From 41e6e8066bd63aa560f272b2ef04d87735c2ec2a Mon Sep 17 00:00:00 2001 +From 39dfedae58057500912a6f933fced3edb9376b3b Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sun, 22 Oct 2017 12:48:24 +0200 -Subject: [PATCH 2/2] rockchip: tinker: enable rockchip video driver +Subject: [PATCH] rockchip: tinker: enable rockchip video driver --- configs/tinker-rk3288_defconfig | 5 +++++ diff --git a/packages/tools/u-boot/patches/rockchip/u-boot-0003-Add-rk3328-efuse-support.patch b/packages/tools/u-boot/patches/rockchip/u-boot-0003-Add-rk3328-efuse-support.patch new file mode 100644 index 0000000000..c08df9079c --- /dev/null +++ b/packages/tools/u-boot/patches/rockchip/u-boot-0003-Add-rk3328-efuse-support.patch @@ -0,0 +1,126 @@ +From dd6e1ab93a92e133c41a8665f6d8aca9450bdca8 Mon Sep 17 00:00:00 2001 +From: Kamil Trzcinski +Date: Sun, 20 Aug 2017 01:52:34 +0200 +Subject: [PATCH] Add rk3328-efuse support + +--- + arch/arm/dts/rk3328.dtsi | 25 ++++++++++++++++++++ + drivers/misc/rockchip-efuse.c | 55 +++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 80 insertions(+) + +diff --git a/arch/arm/dts/rk3328.dtsi b/arch/arm/dts/rk3328.dtsi +index 2a4c4929d7..611a0d4b21 100644 +--- a/arch/arm/dts/rk3328.dtsi ++++ b/arch/arm/dts/rk3328.dtsi +@@ -342,6 +342,31 @@ + }; + }; + ++ efuse: efuse@ff260000 { ++ compatible = "rockchip,rk3328-efuse"; ++ reg = <0x0 0xff260000 0x0 0x50>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ clocks = <&cru SCLK_EFUSE>; ++ clock-names = "pclk_efuse"; ++ rockchip,efuse-size = <0x20>; ++ ++ /* Data cells */ ++ efuse_id: id@7 { ++ reg = <0x07 0x10>; ++ }; ++ cpu_leakage: cpu-leakage@17 { ++ reg = <0x17 0x1>; ++ }; ++ logic_leakage: logic-leakage@19 { ++ reg = <0x19 0x1>; ++ }; ++ efuse_cpu_version: cpu-version@1a { ++ reg = <0x1a 0x1>; ++ bits = <3 3>; ++ }; ++ }; ++ + saradc: saradc@ff280000 { + compatible = "rockchip,rk3328-saradc", "rockchip,saradc"; + reg = <0x0 0xff280000 0x0 0x100>; +diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c +index b4ad19cfe8..81b78f9b2c 100644 +--- a/drivers/misc/rockchip-efuse.c ++++ b/drivers/misc/rockchip-efuse.c +@@ -16,6 +16,14 @@ + #include + #include + ++#define RK3328_INT_CON 0x0014 ++#define RK3328_INT_STATUS 0x0018 ++#define RK3328_DOUT 0x0020 ++#define RK3328_AUTO_CTRL 0x0024 ++#define RK3328_INT_FINISH BIT(0) ++#define RK3328_AUTO_ENB BIT(0) ++#define RK3328_AUTO_RD BIT(1) ++ + #define RK3399_A_SHIFT 16 + #define RK3399_A_MASK 0x3ff + #define RK3399_NFUSES 32 +@@ -95,6 +103,49 @@ U_BOOT_CMD( + ); + #endif + ++static int rockchip_rk3328_efuse_read(struct udevice *dev, int offset, ++ void *buf, int size) ++{ ++ struct rockchip_efuse_platdata *plat = dev_get_platdata(dev); ++ ++ unsigned int addr_start, addr_end, addr_offset; ++ u32 out_value, status; ++ u8 bytes[RK3399_NFUSES * RK3399_BYTES_PER_FUSE]; ++ int i = 0; ++ u32 addr; ++ ++ /* 128 Byte efuse, 96 Byte for secure, 32 Byte for non-secure */ ++ offset += 96; ++ ++ addr_start = offset / RK3399_BYTES_PER_FUSE; ++ addr_offset = offset % RK3399_BYTES_PER_FUSE; ++ addr_end = DIV_ROUND_UP(offset + size, RK3399_BYTES_PER_FUSE); ++ ++ /* cap to the size of the efuse block */ ++ if (addr_end > RK3399_NFUSES) ++ addr_end = RK3399_NFUSES; ++ ++ for (addr = addr_start; addr < addr_end; addr++) { ++ writel(RK3328_AUTO_RD | RK3328_AUTO_ENB | ++ ((addr & RK3399_A_MASK) << RK3399_A_SHIFT), ++ plat->base + RK3328_AUTO_CTRL); ++ udelay(10); ++ status = readl(plat->base + RK3328_INT_STATUS); ++ if (!(status & RK3328_INT_FINISH)) { ++ return -EIO; ++ } ++ out_value = readl(plat->base + RK3328_DOUT); ++ writel(RK3328_INT_FINISH, plat->base + RK3328_INT_STATUS); ++ ++ memcpy(&bytes[i], &out_value, RK3399_BYTES_PER_FUSE); ++ i += RK3399_BYTES_PER_FUSE; ++ } ++ ++ memcpy(buf, bytes + addr_offset, size); ++ ++ return 0; ++} ++ + static int rockchip_rk3399_efuse_read(struct udevice *dev, int offset, + void *buf, int size) + { +@@ -223,6 +274,10 @@ static const struct udevice_id rockchip_efuse_ids[] = { + .compatible = "rockchip,rk322x-efuse", + .data = (ulong)&rockchip_rk3288_efuse_read, + }, ++ { ++ .compatible = "rockchip,rk3328-efuse", ++ .data = (ulong)rockchip_rk3328_efuse_read, ++ }, + { + .compatible = "rockchip,rk3399-efuse", + .data = (ulong)&rockchip_rk3399_efuse_read, diff --git a/packages/tools/u-boot/patches/rockchip/u-boot-0004-Get-serial-and-ethaddr-from-efuse.patch b/packages/tools/u-boot/patches/rockchip/u-boot-0004-Get-serial-and-ethaddr-from-efuse.patch new file mode 100644 index 0000000000..42bd7f21c0 --- /dev/null +++ b/packages/tools/u-boot/patches/rockchip/u-boot-0004-Get-serial-and-ethaddr-from-efuse.patch @@ -0,0 +1,184 @@ +From 77349a847b0649e8ead1dba3a297607b2a674aaa Mon Sep 17 00:00:00 2001 +From: Kamil Trzcinski +Date: Sat, 19 Aug 2017 20:38:50 +0200 +Subject: [PATCH] Get serial and ethaddr from efuse + +--- + board/rockchip/evb_rk3328/evb-rk3328.c | 124 +++++++++++++++++++++++++++++++++ + configs/evb-rk3328_defconfig | 2 + + include/configs/rk3328_common.h | 2 + + 3 files changed, 128 insertions(+) + +diff --git a/board/rockchip/evb_rk3328/evb-rk3328.c b/board/rockchip/evb_rk3328/evb-rk3328.c +index d6fc57cd8e..1d0f7e9c95 100644 +--- a/board/rockchip/evb_rk3328/evb-rk3328.c ++++ b/board/rockchip/evb_rk3328/evb-rk3328.c +@@ -7,14 +7,20 @@ + #include + #include + #include ++#include + #include + #include + #include + #include + #include ++#include ++#include + + DECLARE_GLOBAL_DATA_PTR; + ++#define RK3328_CPUID_OFF 0x7 ++#define RK3328_CPUID_LEN 0x10 ++ + int board_init(void) + { + int ret; +@@ -80,3 +86,121 @@ int board_usb_cleanup(int index, enum usb_init_type init) + return 0; + } + #endif ++ ++static void setup_macaddr(void) ++{ ++#if CONFIG_IS_ENABLED(CMD_NET) ++ int ret; ++ const char *cpuid = env_get("cpuid#"); ++ u8 hash[SHA256_SUM_LEN]; ++ int size = sizeof(hash); ++ u8 mac_addr[6]; ++ ++ /* Only generate a MAC address, if none is set in the environment */ ++ if (env_get("ethaddr")) ++ return; ++ ++ if (!cpuid) { ++ debug("%s: could not retrieve 'cpuid#'\n", __func__); ++ return; ++ } ++ ++ ret = hash_block("sha256", (void *)cpuid, strlen(cpuid), hash, &size); ++ if (ret) { ++ debug("%s: failed to calculate SHA256\n", __func__); ++ return; ++ } ++ ++ /* Copy 6 bytes of the hash to base the MAC address on */ ++ memcpy(mac_addr, hash, 6); ++ ++ /* Make this a valid MAC address and set it */ ++ mac_addr[0] &= 0xfe; /* clear multicast bit */ ++ mac_addr[0] |= 0x02; /* set local assignment bit (IEEE802) */ ++ eth_env_set_enetaddr("ethaddr", mac_addr); ++ ++ /* Make a valid MAC address for eth1 */ ++ mac_addr[5] += 0x20; ++ mac_addr[5] &= 0xff; ++ eth_env_set_enetaddr("eth1addr", mac_addr); ++#endif ++ ++ return; ++} ++ ++static void setup_serial(void) ++{ ++#if CONFIG_IS_ENABLED(ROCKCHIP_EFUSE) ++ struct udevice *dev; ++ int ret, i; ++ u8 cpuid[RK3328_CPUID_LEN]; ++ u8 low[RK3328_CPUID_LEN/2], high[RK3328_CPUID_LEN/2]; ++ char cpuid_str[RK3328_CPUID_LEN * 2 + 1]; ++ u64 serialno; ++ char serialno_str[16]; ++ ++ /* retrieve the device */ ++ ret = uclass_get_device_by_driver(UCLASS_MISC, ++ DM_GET_DRIVER(rockchip_efuse), &dev); ++ if (ret) { ++ debug("%s: could not find efuse device\n", __func__); ++ return; ++ } ++ ++ /* read the cpu_id range from the efuses */ ++ ret = misc_read(dev, RK3328_CPUID_OFF, &cpuid, sizeof(cpuid)); ++ if (ret) { ++ debug("%s: reading cpuid from the efuses failed\n", ++ __func__); ++ return; ++ } ++ ++ memset(cpuid_str, 0, sizeof(cpuid_str)); ++ for (i = 0; i < 16; i++) ++ sprintf(&cpuid_str[i * 2], "%02x", cpuid[i]); ++ ++ debug("cpuid: %s\n", cpuid_str); ++ ++ /* ++ * Mix the cpuid bytes using the same rules as in ++ * ${linux}/drivers/soc/rockchip/rockchip-cpuinfo.c ++ */ ++ for (i = 0; i < 8; i++) { ++ low[i] = cpuid[1 + (i << 1)]; ++ high[i] = cpuid[i << 1]; ++ } ++ ++ serialno = crc32_no_comp(0, low, 8); ++ serialno |= (u64)crc32_no_comp(serialno, high, 8) << 32; ++ snprintf(serialno_str, sizeof(serialno_str), "%llx", serialno); ++ ++ env_set("cpuid#", cpuid_str); ++ env_set("serial#", serialno_str); ++#endif ++ ++ return; ++} ++ ++int misc_init_r(void) ++{ ++ setup_serial(); ++ setup_macaddr(); ++ ++ return 0; ++} ++ ++#ifdef CONFIG_SERIAL_TAG ++void get_board_serial(struct tag_serialnr *serialnr) ++{ ++ char *serial_string; ++ u64 serial = 0; ++ ++ serial_string = env_get("serial#"); ++ ++ if (serial_string) ++ serial = simple_strtoull(serial_string, NULL, 16); ++ ++ serialnr->high = (u32)(serial >> 32); ++ serialnr->low = (u32)(serial & 0xffffffff); ++} ++#endif +diff --git a/configs/evb-rk3328_defconfig b/configs/evb-rk3328_defconfig +index d4a00718c5..9107c020b7 100644 +--- a/configs/evb-rk3328_defconfig ++++ b/configs/evb-rk3328_defconfig +@@ -55,6 +55,8 @@ CONFIG_SPL_CLK=y + CONFIG_ROCKCHIP_GPIO=y + CONFIG_SYS_I2C_ROCKCHIP=y + CONFIG_DM_KEY=y ++CONFIG_MISC=y ++CONFIG_ROCKCHIP_EFUSE=y + CONFIG_MMC_DW=y + CONFIG_MMC_DW_ROCKCHIP=y + CONFIG_PHY=y +diff --git a/include/configs/rk3328_common.h b/include/configs/rk3328_common.h +index b7971782b5..a2af5a7989 100644 +--- a/include/configs/rk3328_common.h ++++ b/include/configs/rk3328_common.h +@@ -9,6 +9,8 @@ + + #include "rockchip-common.h" + ++#define CONFIG_MISC_INIT_R ++ + #define CONFIG_SYS_MALLOC_LEN (32 << 20) + #define CONFIG_SYS_CBSIZE 1024 + #define CONFIG_SKIP_LOWLEVEL_INIT diff --git a/packages/tools/u-boot/patches/rockchip/u-boot-0005-rk3328-evb-add-sdmmc-vmmc-supply.patch b/packages/tools/u-boot/patches/rockchip/u-boot-0005-rk3328-evb-add-sdmmc-vmmc-supply.patch new file mode 100644 index 0000000000..6c031af5d3 --- /dev/null +++ b/packages/tools/u-boot/patches/rockchip/u-boot-0005-rk3328-evb-add-sdmmc-vmmc-supply.patch @@ -0,0 +1,21 @@ +From b6c47bd9f6a8965ab538f168086d4fd99fcf3066 Mon Sep 17 00:00:00 2001 +From: Jonas Karlman +Date: Wed, 10 Jan 2018 19:56:16 +0100 +Subject: [PATCH] rk3328-evb: add sdmmc vmmc-supply + +--- + arch/arm/dts/rk3328-evb.dts | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/arch/arm/dts/rk3328-evb.dts b/arch/arm/dts/rk3328-evb.dts +index 4b13a8da64..586c58659d 100644 +--- a/arch/arm/dts/rk3328-evb.dts ++++ b/arch/arm/dts/rk3328-evb.dts +@@ -61,6 +61,7 @@ + num-slots = <1>; + pinctrl-names = "default"; + pinctrl-0 = <&sdmmc0_clk>, <&sdmmc0_cmd>, <&sdmmc0_dectn>, <&sdmmc0_bus4>; ++ vmmc-supply = <&vcc3v3_sdmmc>; + status = "okay"; + }; +