]> git.sur5r.net Git - u-boot/blobdiff - board/ti/am335x/board.c
Merge branch 'master' of git://git.denx.de/u-boot-sunxi
[u-boot] / board / ti / am335x / board.c
index 0a16529b5f810d0a3dff9b0798454f414b5b3ba4..147ff0b2f00278cbf684d52f0f75b7ea5f490617 100644 (file)
@@ -1,11 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * board.c
  *
  * Board functions for TI AM335X based boards
  *
  * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -243,14 +242,16 @@ static struct emif_regs ddr3_icev2_emif_reg_data = {
 #ifdef CONFIG_SPL_OS_BOOT
 int spl_start_uboot(void)
 {
+#ifdef CONFIG_SPL_SERIAL_SUPPORT
        /* break into full u-boot on 'c' */
        if (serial_tstc() && serial_getc() == 'c')
                return 1;
+#endif
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
        env_init();
-       env_relocate_spec();
-       if (getenv_yesno("boot_os") != 1)
+       env_load();
+       if (env_get_yesno("boot_os") != 1)
                return 1;
 #endif
 
@@ -264,7 +265,7 @@ const struct dpll_params *get_dpll_ddr_params(void)
 
        if (board_is_evm_sk())
                return &dpll_ddr3_303MHz[ind];
-       else if (board_is_bone_lt() || board_is_icev2())
+       else if (board_is_pb() || board_is_bone_lt() || board_is_icev2())
                return &dpll_ddr3_400MHz[ind];
        else if (board_is_evm_15_or_later())
                return &dpll_ddr3_303MHz[ind];
@@ -295,7 +296,7 @@ const struct dpll_params *get_dpll_mpu_params(void)
        if (bone_not_connected_to_ac_power())
                freq = MPUPLL_M_600;
 
-       if (board_is_bone_lt())
+       if (board_is_pb() || board_is_bone_lt())
                freq = MPUPLL_M_1000;
 
        switch (freq) {
@@ -341,7 +342,7 @@ static void scale_vcores_bone(int freq)
         * Override what we have detected since we know if we have
         * a Beaglebone Black it supports 1GHz.
         */
-       if (board_is_bone_lt())
+       if (board_is_pb() || board_is_bone_lt())
                freq = MPUPLL_M_1000;
 
        switch (freq) {
@@ -542,7 +543,7 @@ void sdram_init(void)
        if (board_is_evm_sk())
                config_ddr(303, &ioregs_evmsk, &ddr3_data,
                           &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0);
-       else if (board_is_bone_lt())
+       else if (board_is_pb() || board_is_bone_lt())
                config_ddr(400, &ioregs_bonelt,
                           &ddr3_beagleblack_data,
                           &ddr3_beagleblack_cmd_ctrl_data,
@@ -563,8 +564,8 @@ void sdram_init(void)
 }
 #endif
 
-#if !defined(CONFIG_SPL_BUILD) || \
-       (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
+#if defined(CONFIG_CLOCK_SYNTHESIZER) && (!defined(CONFIG_SPL_BUILD) || \
+       (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD)))
 static void request_and_set_gpio(int gpio, char *name, int val)
 {
        int ret;
@@ -621,8 +622,8 @@ int board_init(void)
        gpmc_init();
 #endif
 
-#if !defined(CONFIG_SPL_BUILD) || \
-       (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
+#if defined(CONFIG_CLOCK_SYNTHESIZER) && (!defined(CONFIG_SPL_BUILD) || \
+       (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD)))
        if (board_is_icev2()) {
                int rv;
                u32 reg;
@@ -731,7 +732,7 @@ int board_late_init(void)
         * on HS devices.
         */
        if (get_device_type() == HS_DEVICE)
-               setenv("boot_fit", "1");
+               env_set("boot_fit", "1");
 #endif
 
 #if !defined(CONFIG_SPL_BUILD)
@@ -745,11 +746,11 @@ int board_late_init(void)
        mac_addr[4] = mac_lo & 0xFF;
        mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-       if (!getenv("ethaddr")) {
+       if (!env_get("ethaddr")) {
                printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
                if (is_valid_ethaddr(mac_addr))
-                       eth_setenv_enetaddr("ethaddr", mac_addr);
+                       eth_env_set_enetaddr("ethaddr", mac_addr);
        }
 
        mac_lo = readl(&cdev->macid1l);
@@ -761,12 +762,22 @@ int board_late_init(void)
        mac_addr[4] = mac_lo & 0xFF;
        mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-       if (!getenv("eth1addr")) {
+       if (!env_get("eth1addr")) {
                if (is_valid_ethaddr(mac_addr))
-                       eth_setenv_enetaddr("eth1addr", mac_addr);
+                       eth_env_set_enetaddr("eth1addr", mac_addr);
        }
 #endif
 
+       if (!env_get("serial#")) {
+               char *board_serial = env_get("board_serial");
+               char *ethaddr = env_get("ethaddr");
+
+               if (!board_serial || !strncmp(board_serial, "unknown", 7))
+                       env_set("serial#", ethaddr);
+               else
+                       env_set("serial#", board_serial);
+       }
+
        return 0;
 }
 #endif
@@ -815,7 +826,7 @@ static struct cpsw_platform_data cpsw_data = {
 };
 #endif
 
-#if ((defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USBETH_SUPPORT)) &&\
+#if ((defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USB_ETHER)) &&\
        defined(CONFIG_SPL_BUILD)) || \
        ((defined(CONFIG_DRIVER_TI_CPSW) || \
          defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET)) && \
@@ -836,7 +847,7 @@ int board_eth_init(bd_t *bis)
 {
        int rv, n = 0;
 #if defined(CONFIG_USB_ETHER) && \
-       (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT))
+       (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USB_ETHER))
        uint8_t mac_addr[6];
        uint32_t mac_hi, mac_lo;
 
@@ -906,9 +917,9 @@ int board_eth_init(bd_t *bis)
        }
 #endif
 #if defined(CONFIG_USB_ETHER) && \
-       (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT))
+       (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USB_ETHER))
        if (is_valid_ethaddr(mac_addr))
-               eth_setenv_enetaddr("usbnet_devaddr", mac_addr);
+               eth_env_set_enetaddr("usbnet_devaddr", mac_addr);
 
        rv = usb_eth_initialize(bis);
        if (rv < 0)
@@ -931,6 +942,8 @@ int board_fit_config_name_match(const char *name)
                return 0;
        else if (board_is_bone_lt() && !strcmp(name, "am335x-boneblack"))
                return 0;
+       else if (board_is_pb() && !strcmp(name, "am335x-pocketbeagle"))
+               return 0;
        else if (board_is_evm_sk() && !strcmp(name, "am335x-evmsk"))
                return 0;
        else if (board_is_bbg1() && !strcmp(name, "am335x-bonegreen"))