Merge tag 'u-boot-at91-fixes-2022.04-a' of https://source.denx.de/u-boot/custodians...
[platform/kernel/u-boot.git] / board / sunxi / board.c
index 4f5747c..82c52b2 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <common.h>
+#include <clock_legacy.h>
 #include <dm.h>
 #include <env.h>
 #include <hang.h>
@@ -27,6 +28,7 @@
 #include <asm/arch/dram.h>
 #include <asm/arch/mmc.h>
 #include <asm/arch/prcm.h>
+#include <asm/arch/pmic_bus.h>
 #include <asm/arch/spl.h>
 #include <asm/global_data.h>
 #include <linux/delay.h>
@@ -196,7 +198,7 @@ int board_init(void)
 
        gd->bd->bi_boot_params = (PHYS_SDRAM_0 + 0x100);
 
-#ifndef CONFIG_ARM64
+#if !defined(CONFIG_ARM64) && !defined(CONFIG_MACH_SUNIV)
        asm volatile("mrc p15, 0, %0, c0, c1, 1" : "=r"(id_pfr1));
        debug("id_pfr1: 0x%08x\n", id_pfr1);
        /* Generic Timer Extension available? */
@@ -223,7 +225,7 @@ int board_init(void)
 #endif
                }
        }
-#endif /* !CONFIG_ARM64 */
+#endif /* !CONFIG_ARM64 && !CONFIG_MACH_SUNIV */
 
        ret = axp_gpio_init();
        if (ret)
@@ -601,6 +603,16 @@ void sunxi_board_init(void)
        defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
        power_failed = axp_init();
 
+       if (IS_ENABLED(CONFIG_AXP_DISABLE_BOOT_ON_POWERON) && !power_failed) {
+               u8 boot_reason;
+
+               pmic_bus_read(AXP_POWER_STATUS, &boot_reason);
+               if (boot_reason & AXP_POWER_STATUS_ALDO_IN) {
+                       printf("Power on by plug-in, shutting down.\n");
+                       pmic_bus_write(0x32, BIT(7));
+               }
+       }
+
 #if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \
        defined CONFIG_AXP818_POWER
        power_failed |= axp_set_dcdc1(CONFIG_AXP_DCDC1_VOLT);
@@ -667,7 +679,7 @@ void sunxi_board_init(void)
         * assured it's being powered with suitable core voltage
         */
        if (!power_failed)
-               clock_set_pll1(CONFIG_SYS_CLK_FREQ);
+               clock_set_pll1(get_board_sys_clk());
        else
                printf("Failed to set core voltage! Can't set CPU frequency\n");
 }
@@ -698,13 +710,7 @@ int g_dnl_board_usb_cable_connected(void)
                return ret;
        }
 
-       ret = sun4i_usb_phy_vbus_detect(&phy);
-       if (ret == 1) {
-               pr_err("A charger is plugged into the OTG\n");
-               return -ENODEV;
-       }
-
-       return ret;
+       return sun4i_usb_phy_vbus_detect(&phy);
 }
 #endif
 
@@ -917,10 +923,12 @@ int ft_board_setup(void *blob, struct bd_info *bd)
        int __maybe_unused r;
 
        /*
-        * Call setup_environment again in case the boot fdt has
-        * ethernet aliases the u-boot copy does not have.
+        * Call setup_environment and fdt_fixup_ethernet again
+        * in case the boot fdt has ethernet aliases the u-boot
+        * copy does not have.
         */
        setup_environment(blob);
+       fdt_fixup_ethernet(blob);
 
        bluetooth_dt_fixup(blob);