Merge tag 'u-boot-stm32-20200117' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm
[oweals/u-boot.git] / board / toradex / apalis_imx6 / apalis_imx6.c
index b502d4ef1359db3bd622ea1c5f6dc334a1326ecc..3f85f1ac89b5b18d08371e248df086f31dba64cf 100644 (file)
@@ -7,7 +7,9 @@
  */
 
 #include <common.h>
+#include <cpu_func.h>
 #include <dm.h>
+#include <init.h>
 
 #include <ahci.h>
 #include <asm/arch/clock.h>
@@ -26,8 +28,8 @@
 #include <dm/device-internal.h>
 #include <dm/platform_data/serial_mxc.h>
 #include <dwc_ahsata.h>
-#include <environment.h>
-#include <fsl_esdhc.h>
+#include <env.h>
+#include <fsl_esdhc_imx.h>
 #include <imx_thermal.h>
 #include <micrel.h>
 #include <miiphy.h>
@@ -88,7 +90,7 @@ iomux_v3_cfg_t const uart1_pads_dte[] = {
        MX6_PAD_CSI0_DAT11__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
 };
 
-#if defined(CONFIG_FSL_ESDHC) && defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_FSL_ESDHC_IMX) && defined(CONFIG_SPL_BUILD)
 /* Apalis MMC1 */
 iomux_v3_cfg_t const usdhc1_pads[] = {
        MX6_PAD_SD1_CLK__SD1_CLK   | MUX_PAD_CTRL(USDHC_PAD_CTRL),
@@ -131,7 +133,7 @@ iomux_v3_cfg_t const usdhc3_pads[] = {
        MX6_PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
        MX6_PAD_SD3_RST__GPIO7_IO08 | MUX_PAD_CTRL(WEAK_PULLUP) | MUX_MODE_SION,
 };
-#endif /* CONFIG_FSL_ESDHC & CONFIG_SPL_BUILD */
+#endif /* CONFIG_FSL_ESDHC_IMX & CONFIG_SPL_BUILD */
 
 int mx6_rgmii_rework(struct phy_device *phydev)
 {
@@ -176,22 +178,6 @@ iomux_v3_cfg_t const enet_pads[] = {
 #      define GPIO_ENET_PHY_RESET IMX_GPIO_NR(1, 25)
 };
 
-static void setup_iomux_enet(void)
-{
-       imx_iomux_v3_setup_multiple_pads(enet_pads, ARRAY_SIZE(enet_pads));
-}
-
-static int reset_enet_phy(struct mii_dev *bus)
-{
-       /* Reset KSZ9031 PHY */
-       gpio_request(GPIO_ENET_PHY_RESET, "ETH_RESET#");
-       gpio_direction_output(GPIO_ENET_PHY_RESET, 0);
-       mdelay(10);
-       gpio_set_value(GPIO_ENET_PHY_RESET, 1);
-
-       return 0;
-}
-
 /* mux the Apalis GPIO pins, so they can be used from the U-Boot cmdline */
 iomux_v3_cfg_t const gpio_pads[] = {
        /* Apalis GPIO1 - GPIO8 */
@@ -285,7 +271,7 @@ int board_ehci_hcd_init(int port)
 }
 #endif
 
-#if defined(CONFIG_FSL_ESDHC) && defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_FSL_ESDHC_IMX) && defined(CONFIG_SPL_BUILD)
 /* use the following sequence: eMMC, MMC1, SD1 */
 struct fsl_esdhc_cfg usdhc_cfg[CONFIG_SYS_FSL_USDHC_NUM] = {
        {USDHC3_BASE_ADDR},
@@ -355,7 +341,7 @@ int board_mmc_init(bd_t *bis)
 
        return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
 }
-#endif /* CONFIG_FSL_ESDHC & CONFIG_SPL_BUILD */
+#endif /* CONFIG_FSL_ESDHC_IMX & CONFIG_SPL_BUILD */
 
 int board_phy_config(struct phy_device *phydev)
 {
@@ -366,41 +352,6 @@ int board_phy_config(struct phy_device *phydev)
        return 0;
 }
 
-int board_eth_init(bd_t *bis)
-{
-       uint32_t base = IMX_FEC_BASE;
-       struct mii_dev *bus = NULL;
-       struct phy_device *phydev = NULL;
-       int ret;
-
-       setup_iomux_enet();
-
-#ifdef CONFIG_FEC_MXC
-       bus = fec_get_miibus(base, -1);
-       if (!bus)
-               return 0;
-
-       bus->reset = reset_enet_phy;
-       /* scan PHY 4,5,6,7 */
-       phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII);
-       if (!phydev) {
-               free(bus);
-               puts("no PHY found\n");
-               return 0;
-       }
-
-       printf("using PHY at %d\n", phydev->addr);
-       ret = fec_probe(bis, -1, base, bus, phydev);
-       if (ret) {
-               printf("FEC MXC: %s:failed\n", __func__);
-               free(phydev);
-               free(bus);
-       }
-#endif /* CONFIG_FEC_MXC */
-
-       return 0;
-}
-
 static iomux_v3_cfg_t const pwr_intb_pads[] = {
        /*
         * the bootrom sets the iomux to vselect, potentially connecting
@@ -1116,6 +1067,16 @@ void board_init_f(ulong dummy)
        board_init_r(NULL, 0);
 }
 
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name)
+{
+       if (!strcmp(name, "imx6-apalis"))
+               return 0;
+
+       return -1;
+}
+#endif
+
 void reset_cpu(ulong addr)
 {
 }