diff options
Diffstat (limited to 'arch/arm/boards/mnt-reform/lowlevel.c')
-rw-r--r-- | arch/arm/boards/mnt-reform/lowlevel.c | 86 |
1 files changed, 21 insertions, 65 deletions
diff --git a/arch/arm/boards/mnt-reform/lowlevel.c b/arch/arm/boards/mnt-reform/lowlevel.c index 268dfb611a..9f951508df 100644 --- a/arch/arm/boards/mnt-reform/lowlevel.c +++ b/arch/arm/boards/mnt-reform/lowlevel.c @@ -6,19 +6,21 @@ #include <asm/barebox-arm.h> #include <common.h> #include <debug_ll.h> +#include <mach/imx/debug_ll.h> #include <firmware.h> -#include <i2c/i2c-early.h> -#include <mach/atf.h> -#include <mach/esdctl.h> -#include <mach/generic.h> -#include <mach/imx-gpio.h> -#include <mach/imx8m-ccm-regs.h> -#include <mach/imx8mq-regs.h> -#include <mach/iomux-mx8mq.h> -#include <mach/xload.h> +#include <pbl/i2c.h> +#include <pbl/pmic.h> +#include <mach/imx/atf.h> +#include <mach/imx/esdctl.h> +#include <mach/imx/generic.h> +#include <mach/imx/imx-gpio.h> +#include <mach/imx/imx8m-ccm-regs.h> +#include <mach/imx/imx8mq-regs.h> +#include <mach/imx/iomux-mx8mq.h> +#include <mach/imx/xload.h> #include <soc/imx8m/ddr.h> -extern char __dtb_imx8mq_mnt_reform2_start[]; +extern char __dtb_z_imx8mq_mnt_reform2_start[]; #define UART_PAD_CTRL MUX_PAD_CTRL(MX8MQ_PAD_CTL_DSE_65R) @@ -36,7 +38,7 @@ static void mnt_reform_setup_uart(void) putc_ll('>'); } -static void i2c_mux_set(void *i2c, u8 channel) +static void i2c_mux_set(struct pbl_i2c *i2c, u8 channel) { int ret; u8 buf[1]; @@ -50,29 +52,14 @@ static void i2c_mux_set(void *i2c, u8 channel) buf[0] = 1 << channel; - ret = i2c_fsl_xfer(i2c, msgs, ARRAY_SIZE(msgs)); + ret = pbl_i2c_xfer(i2c, msgs, ARRAY_SIZE(msgs)); if (ret != 1) pr_err("failed to set i2c mux\n"); } -static void i2c_regulator_set_voltage(void *i2c, u8 reg, u8 voffs) +static void i2c_regulator_set_voltage(struct pbl_i2c *i2c, u8 reg, u8 voffs) { - int ret; - u8 buf[2]; - struct i2c_msg msgs[] = { - { - .addr = 0x60, - .buf = buf, - .len = 2, - }, - }; - - buf[0] = reg; - buf[1] = 0x80 + voffs; - - ret = i2c_fsl_xfer(i2c, msgs, ARRAY_SIZE(msgs)); - if (ret != 1) - pr_err("failed to set voltage\n"); + pmic_reg_write8(i2c, 0x60, reg, 0x80 + voffs); } #define I2C_PAD_CTRL MUX_PAD_CTRL(MX8MQ_PAD_CTL_DSE_45R | \ @@ -81,7 +68,7 @@ static void i2c_regulator_set_voltage(void *i2c, u8 reg, u8 voffs) static void mnt_reform_init_power(void) { - void *i2c; + struct pbl_i2c *i2c; imx8mq_setup_pad(IMX8MQ_PAD_I2C1_SCL__I2C1_SCL | I2C_PAD_CTRL); imx8mq_setup_pad(IMX8MQ_PAD_I2C1_SDA__I2C1_SDA | I2C_PAD_CTRL); @@ -130,50 +117,19 @@ static __noreturn noinline void mnt_reform_start(void) * The TF-A will then jump to DRAM in EL2. */ if (current_el() == 3) { - size_t bl31_size; - const u8 *bl31; - enum bootsource src; - int instance; - mnt_reform_setup_uart(); mnt_reform_init_power(); - imx8mq_ddr_init(&mnt_reform_dram_timing); - - imx8mq_get_boot_source(&src, &instance); - switch (src) { - case BOOTSOURCE_MMC: - imx8m_esdhc_load_image(instance, false); - break; - case BOOTSOURCE_SERIAL: - imx8m_esdhc_load_image(1, false); - break; - default: - printf("Unhandled bootsource BOOTSOURCE_%d\n", src); - hang(); - } - - /* - * On completion the TF-A will jump to MX8M_ATF_BL33_BASE_ADDR - * in EL2. Copy the image there, but replace the PBL part of - * that image with ourselves. On a high assurance boot only the - * currently running code is validated and contains the checksum - * for the piggy data, so we need to ensure that we are running - * the same code in DRAM. - */ - memcpy((void *)MX8M_ATF_BL33_BASE_ADDR, - __image_start, barebox_pbl_size); - - get_builtin_firmware(imx8mq_bl31_bin, &bl31, &bl31_size); - - imx8mq_atf_load_bl31(bl31, bl31_size); + imx8mq_ddr_init(&mnt_reform_dram_timing, DRAM_TYPE_LPDDR4); + + imx8mq_load_and_start_image_via_tfa(); } /* * Standard entry we hit once we initialized both DDR and ATF */ - imx8mq_barebox_entry(__dtb_imx8mq_mnt_reform2_start); + imx8mq_barebox_entry(__dtb_z_imx8mq_mnt_reform2_start); } ENTRY_FUNCTION(start_mnt_reform, r0, r1, r2) |