Merge https://gitlab.denx.de/u-boot/custodians/u-boot-spi into next
[platform/kernel/u-boot.git] / board / ti / am57xx / board.c
index 52f5e95..511858a 100644 (file)
@@ -9,7 +9,11 @@
 
 #include <common.h>
 #include <env.h>
+#include <fdt_support.h>
+#include <image.h>
 #include <init.h>
+#include <malloc.h>
+#include <net.h>
 #include <palmas.h>
 #include <sata.h>
 #include <serial.h>
@@ -34,6 +38,7 @@
 #include <ti-usb-phy-uboot.h>
 #include <mmc.h>
 #include <dm/uclass.h>
+#include <hang.h>
 
 #include "../common/board_detect.h"
 #include "mux_data.h"
@@ -54,6 +59,11 @@ static int board_bootmode_has_emmc(void);
 #define board_is_am574x_idk()  board_ti_is("AM574IDK")
 #define board_is_am572x_idk()  board_ti_is("AM572IDK")
 #define board_is_am571x_idk()  board_ti_is("AM571IDK")
+#define board_is_bbai()                board_ti_is("BBONE-AI")
+
+#define board_is_ti_idk()      board_is_am574x_idk() || \
+                               board_is_am572x_idk() || \
+                               board_is_am571x_idk()
 
 #ifdef CONFIG_DRIVER_TI_CPSW
 #include <cpsw.h>
@@ -62,8 +72,7 @@ static int board_bootmode_has_emmc(void);
 DECLARE_GLOBAL_DATA_PTR;
 
 #define GPIO_ETH_LCD           GPIO_TO_PIN(2, 22)
-/* GPIO 7_11 */
-#define GPIO_DDR_VTT_EN 203
+#define GPIO_DDR_VTT_EN                GPIO_TO_PIN(7, 11)
 
 /* Touch screen controller to identify the LCD */
 #define OSD_TS_FT_BUS_ADDRESS  0
@@ -103,12 +112,19 @@ static const struct dmm_lisa_map_regs am574x_idk_lisa_regs = {
        .is_ma_present  = 0x1
 };
 
+static const struct dmm_lisa_map_regs bbai_lisa_regs = {
+       .dmm_lisa_map_3 = 0x80640100,
+       .is_ma_present  = 0x1
+};
+
 void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
 {
        if (board_is_am571x_idk())
                *dmm_lisa_regs = &am571x_idk_lisa_regs;
        else if (board_is_am574x_idk())
                *dmm_lisa_regs = &am574x_idk_lisa_regs;
+       else if (board_is_bbai())
+               *dmm_lisa_regs = &bbai_lisa_regs;
        else
                *dmm_lisa_regs = &beagle_x15_lisa_regs;
 }
@@ -553,6 +569,8 @@ void do_board_detect(void)
                bname = "AM572x IDK";
        else if (board_is_am571x_idk())
                bname = "AM571x IDK";
+       else if (board_is_bbai())
+               bname = "BeagleBone AI";
 
        if (bname)
                snprintf(sysinfo.board_string, SYSINFO_BOARD_NAME_MAX_LEN,
@@ -587,6 +605,8 @@ static void setup_board_eeprom_env(void)
                name = "am572x_idk";
        } else if (board_is_am571x_idk()) {
                name = "am571x_idk";
+       } else if (board_is_bbai()) {
+               name = "am5729_beagleboneai";
        } else {
                printf("Unidentified board claims %s in eeprom header\n",
                       board_ti_get_name());
@@ -650,7 +670,7 @@ void am57x_idk_lcd_detect(void)
        struct udevice *dev;
 
        /* Only valid for IDKs */
-       if (board_is_x15() || board_is_am572x_evm())
+       if (!board_is_ti_idk())
                return;
 
        /* Only AM571x IDK has gpio control detect.. so check that */
@@ -693,6 +713,18 @@ void am57x_idk_lcd_detect(void)
        }
 out:
        env_set("idk_lcd", idk_lcd);
+
+       /*
+        * On AM571x_IDK, no Display with J51 set to LCD is considered as an
+        * invalid configuration and we prevent boot to get user attention.
+        */
+       if (board_is_am571x_idk() && am571x_idk_needs_lcd() &&
+           !strncmp(idk_lcd, "no", 2)) {
+               printf("%s: Invalid HW configuration: display not detected/supported but J51 is set. Remove J51 to boot without display.\n",
+                      __func__);
+               hang();
+       }
+
        return;
 }
 
@@ -748,6 +780,9 @@ int board_late_init(void)
        /* Just probe the potentially supported cdce913 device */
        uclass_get_device(UCLASS_CLK, 0, &dev);
 
+       if (board_is_bbai())
+               env_set("console", "ttyS0,115200n8");
+
 #if !defined(CONFIG_SPL_BUILD)
        board_ti_set_ethaddr(2);
 #endif
@@ -795,6 +830,11 @@ void recalibrate_iodelay(void)
                pconf_sz = ARRAY_SIZE(core_padconf_array_essential_am571x_idk);
                iod = iodelay_cfg_array_am571x_idk;
                iod_sz = ARRAY_SIZE(iodelay_cfg_array_am571x_idk);
+       } else if (board_is_bbai()) {
+               pconf = core_padconf_array_essential_bbai;
+               pconf_sz = ARRAY_SIZE(core_padconf_array_essential_bbai);
+               iod = iodelay_cfg_array_bbai;
+               iod_sz = ARRAY_SIZE(iodelay_cfg_array_bbai);
        } else {
                /* Common for X15/GPEVM */
                pconf = core_padconf_array_essential_x15;
@@ -1123,6 +1163,8 @@ int board_fit_config_name_match(const char *name)
                return 0;
        } else if (board_is_am571x_idk() && !strcmp(name, "am571x-idk")) {
                return 0;
+       } else if (board_is_bbai() && !strcmp(name, "am5729-beagleboneai")) {
+               return 0;
        }
 
        return -1;