Merge git://git.denx.de/u-boot-tegra
[oweals/u-boot.git] / board / theobroma-systems / puma_rk3399 / puma-rk3399.c
index 36e9cd7f842a7caf422844d7e3f15de3429f500c..c6f8eed0c98821ab10941cfecc02ae994986bdae 100644 (file)
@@ -9,20 +9,11 @@
 #include <ram.h>
 #include <dm/pinctrl.h>
 #include <dm/uclass-internal.h>
-#include <misc.h>
 #include <asm/setup.h>
 #include <asm/arch/periph.h>
 #include <power/regulator.h>
 #include <u-boot/sha256.h>
 
-#define RK3399_CPUID_OFF  0x7
-#define RK3399_CPUID_LEN  0x10
-
-DECLARE_GLOBAL_DATA_PTR;
-
-#define RK3399_CPUID_OFF  0x7
-#define RK3399_CPUID_LEN  0x10
-
 DECLARE_GLOBAL_DATA_PTR;
 
 int board_init(void)
@@ -72,13 +63,13 @@ static void setup_macaddr(void)
 {
 #if CONFIG_IS_ENABLED(CMD_NET)
        int ret;
-       const char *cpuid = getenv("cpuid#");
+       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 (getenv("ethaddr"))
+       if (env_get("ethaddr"))
                return;
 
        if (!cpuid) {
@@ -98,7 +89,7 @@ static void setup_macaddr(void)
        /* 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_setenv_enetaddr("ethaddr", mac_addr);
+       eth_env_set_enetaddr("ethaddr", mac_addr);
 #endif
 
        return;
@@ -107,11 +98,14 @@ static void setup_macaddr(void)
 static void setup_serial(void)
 {
 #if CONFIG_IS_ENABLED(ROCKCHIP_EFUSE)
+       const u32 cpuid_offset = 0x7;
+       const u32 cpuid_length = 0x10;
+
        struct udevice *dev;
        int ret, i;
-       u8 cpuid[RK3399_CPUID_LEN];
-       u8 low[RK3399_CPUID_LEN/2], high[RK3399_CPUID_LEN/2];
-       char cpuid_str[RK3399_CPUID_LEN * 2 + 1];
+       u8 cpuid[cpuid_length];
+       u8 low[cpuid_length/2], high[cpuid_length/2];
+       char cpuid_str[cpuid_length * 2 + 1];
        u64 serialno;
        char serialno_str[16];
 
@@ -124,7 +118,7 @@ static void setup_serial(void)
        }
 
        /* read the cpu_id range from the efuses */
-       ret = misc_read(dev, RK3399_CPUID_OFF, &cpuid, sizeof(cpuid));
+       ret = misc_read(dev, cpuid_offset, &cpuid, sizeof(cpuid));
        if (ret) {
                debug("%s: reading cpuid from the efuses failed\n",
                      __func__);
@@ -150,8 +144,8 @@ static void setup_serial(void)
        serialno |= (u64)crc32_no_comp(serialno, high, 8) << 32;
        snprintf(serialno_str, sizeof(serialno_str), "%llx", serialno);
 
-       setenv("cpuid#", cpuid_str);
-       setenv("serial#", serialno_str);
+       env_set("cpuid#", cpuid_str);
+       env_set("serial#", serialno_str);
 #endif
 
        return;
@@ -171,7 +165,7 @@ void get_board_serial(struct tag_serialnr *serialnr)
        char *serial_string;
        u64 serial = 0;
 
-       serial_string = getenv("serial#");
+       serial_string = env_get("serial#");
 
        if (serial_string)
                serial = simple_strtoull(serial_string, NULL, 16);