]> 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 b5c4ed70b8f3e40ce10d94d63de06ed51bb2ea29..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,17 +342,9 @@ 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;
 
-       if (freq == MPUPLL_M_1000) {
-               usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1800MA;
-               mpu_vdd = TPS65217_DCDC_VOLT_SEL_1325MV;
-       } else {
-               usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA;
-               mpu_vdd = TPS65217_DCDC_VOLT_SEL_1275MV;
-       }
-
        switch (freq) {
        case MPUPLL_M_1000:
                mpu_vdd = TPS65217_DCDC_VOLT_SEL_1325MV;
@@ -359,15 +352,16 @@ static void scale_vcores_bone(int freq)
                break;
        case MPUPLL_M_800:
                mpu_vdd = TPS65217_DCDC_VOLT_SEL_1275MV;
-               usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1800MA;
+               usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA;
                break;
        case MPUPLL_M_720:
                mpu_vdd = TPS65217_DCDC_VOLT_SEL_1200MV;
-               usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1800MA;
+               usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA;
                break;
        case MPUPLL_M_600:
        case MPUPLL_M_500:
        case MPUPLL_M_300:
+       default:
                mpu_vdd = TPS65217_DCDC_VOLT_SEL_1100MV;
                usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA;
                break;
@@ -470,7 +464,7 @@ void scale_vcores(void)
        gpi2c_init();
        freq = am335x_get_efuse_mpu_max_freq(cdev);
 
-       if (board_is_bone())
+       if (board_is_beaglebonex())
                scale_vcores_bone(freq);
        else
                scale_vcores_generic(freq);
@@ -549,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,
@@ -570,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;
@@ -628,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;
@@ -738,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)
@@ -752,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);
@@ -768,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
@@ -822,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)) && \
@@ -843,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;
 
@@ -913,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)
@@ -938,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"))