diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2022-06-29 09:00:56 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-06-29 09:00:56 +0200 |
commit | 8828e1226981b6a31b12a643768cac63fae3576e (patch) | |
tree | e9b631fb54e5c97d1a9e8237f1dc080750b43992 | |
parent | 4708257d5e1345088aa2b3f2f76bb8bb37f7368d (diff) | |
parent | 3367ebc55ebe92e21c9a9045e1eab35593cfcf57 (diff) | |
download | barebox-8828e1226981b6a31b12a643768cac63fae3576e.tar.gz barebox-8828e1226981b6a31b12a643768cac63fae3576e.tar.xz |
Merge branch 'for-next/imx'
-rw-r--r-- | arch/arm/boards/nxp-imx8mq-evk/board.c | 2 | ||||
-rw-r--r-- | arch/arm/dts/imx8mm-evk.dts | 4 | ||||
-rw-r--r-- | arch/arm/dts/imx8mq-mnt-reform2.dts | 164 | ||||
-rw-r--r-- | arch/arm/mach-imx/boot.c | 10 | ||||
-rw-r--r-- | scripts/imx/imx-usb-loader.c | 88 |
5 files changed, 46 insertions, 222 deletions
diff --git a/arch/arm/boards/nxp-imx8mq-evk/board.c b/arch/arm/boards/nxp-imx8mq-evk/board.c index c28107cb17..8d88bfe8c2 100644 --- a/arch/arm/boards/nxp-imx8mq-evk/board.c +++ b/arch/arm/boards/nxp-imx8mq-evk/board.c @@ -40,7 +40,7 @@ static int nxp_imx8mq_evk_init(void) barebox_set_hostname("imx8mq-evk"); flags = bootsource_get_instance() == 0 ? BBU_HANDLER_FLAG_DEFAULT : 0; - imx8m_bbu_internal_mmc_register_handler("eMMC", "/dev/mmc0.barebox", flags); + imx8m_bbu_internal_mmcboot_register_handler("eMMC", "/dev/mmc0", flags); flags = bootsource_get_instance() == 1 ? BBU_HANDLER_FLAG_DEFAULT : 0; imx8m_bbu_internal_mmc_register_handler("SD", "/dev/mmc1.barebox", flags); diff --git a/arch/arm/dts/imx8mm-evk.dts b/arch/arm/dts/imx8mm-evk.dts index 304f150307..6c06ad7e47 100644 --- a/arch/arm/dts/imx8mm-evk.dts +++ b/arch/arm/dts/imx8mm-evk.dts @@ -24,8 +24,8 @@ }; }; -&fec1 { - phy-reset-gpios = <&gpio4 22 GPIO_ACTIVE_LOW>; +®_usdhc2_vmmc { + off-on-delay-us = <20000>; }; &usdhc2 { diff --git a/arch/arm/dts/imx8mq-mnt-reform2.dts b/arch/arm/dts/imx8mq-mnt-reform2.dts index 5a65324b3c..deb31abe54 100644 --- a/arch/arm/dts/imx8mq-mnt-reform2.dts +++ b/arch/arm/dts/imx8mq-mnt-reform2.dts @@ -6,17 +6,12 @@ /dts-v1/; -#include <arm64/freescale/imx8mq.dtsi> +#include <arm64/freescale/imx8mq-mnt-reform2.dts> #include "imx8mq.dtsi" #include "imx8mq-ddrc.dtsi" / { - model = "MNT Reform2"; - compatible = "mntre,reform2", "fsl,imx8mq"; - chosen { - stdout-path = &uart1; - environment-emmc { compatible = "barebox,environment"; device-path = &usdhc1, "partname:barebox-environment"; @@ -29,86 +24,13 @@ status = "disabled"; }; }; - - pcie1_refclk: pcie1-refclk { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <100000000>; - }; -}; - -&fec1 { - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_fec1>; - phy-mode = "rgmii-id"; - phy-handle = <ðphy0>; - status = "okay"; - - mdio { - #address-cells = <1>; - #size-cells = <0>; - - ethphy0: ethernet-phy@4 { - compatible = "ethernet-phy-ieee802.3-c22"; - reg = <4>; - interrupts = <&gpio1 11 IRQ_TYPE_LEVEL_LOW>; - reset-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>; - }; - }; }; &ocotp { barebox,provide-mac-address = <&fec1 0x640>; }; -&pcie1 { - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_pcie1>; - reset-gpio = <&gpio3 23 GPIO_ACTIVE_LOW>; - clocks = <&clk IMX8MQ_CLK_PCIE2_ROOT>, - <&clk IMX8MQ_CLK_PCIE2_AUX>, - <&clk IMX8MQ_CLK_PCIE2_PHY>, - <&pcie1_refclk>; - clock-names = "pcie", "pcie_aux", "pcie_phy", "pcie_bus"; - status = "okay"; -}; - -&uart1 { - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_uart1>; - status = "okay"; -}; - -&usb3_phy0 { - status = "okay"; -}; - -&usb3_phy1 { - status = "okay"; -}; - -&usb_dwc3_0 { - status = "okay"; - dr_mode = "host"; -}; - -&usb_dwc3_1 { - status = "okay"; - dr_mode = "host"; -}; - &usdhc1 { - assigned-clocks = <&clk IMX8MQ_CLK_USDHC1>; - assigned-clock-rates = <400000000>; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_usdhc1>; - bus-width = <8>; - no-mmc-hs400; - non-removable; - no-sd; - no-sdio; - status = "okay"; - #address-cells = <1>; #size-cells = <1>; @@ -124,14 +46,6 @@ }; &usdhc2 { - assigned-clocks = <&clk IMX8MQ_CLK_USDHC2>; - assigned-clock-rates = <200000000>; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_usdhc2>; - bus-width = <4>; - no-1-8-v; - status = "okay"; - #address-cells = <1>; #size-cells = <1>; @@ -145,79 +59,3 @@ reg = <0xe0000 0x20000>; }; }; - -&wdog1 { - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_wdog>; - fsl,ext-reset-output; - status = "okay"; -}; - -&iomuxc { - pinctrl_fec1: fec1grp { - fsl,pins = < - MX8MQ_IOMUXC_ENET_MDC_ENET1_MDC 0x3 - MX8MQ_IOMUXC_ENET_MDIO_ENET1_MDIO 0x23 - MX8MQ_IOMUXC_ENET_TX_CTL_ENET1_RGMII_TX_CTL 0x1f - MX8MQ_IOMUXC_ENET_TXC_ENET1_RGMII_TXC 0x1f - MX8MQ_IOMUXC_ENET_TD0_ENET1_RGMII_TD0 0x1f - MX8MQ_IOMUXC_ENET_TD1_ENET1_RGMII_TD1 0x1f - MX8MQ_IOMUXC_ENET_TD2_ENET1_RGMII_TD2 0x1f - MX8MQ_IOMUXC_ENET_TD3_ENET1_RGMII_TD3 0x1f - MX8MQ_IOMUXC_ENET_RX_CTL_ENET1_RGMII_RX_CTL 0x91 - MX8MQ_IOMUXC_ENET_RXC_ENET1_RGMII_RXC 0xd1 - MX8MQ_IOMUXC_ENET_RD0_ENET1_RGMII_RD0 0x91 - MX8MQ_IOMUXC_ENET_RD1_ENET1_RGMII_RD1 0x91 - MX8MQ_IOMUXC_ENET_RD2_ENET1_RGMII_RD2 0x91 - MX8MQ_IOMUXC_ENET_RD3_ENET1_RGMII_RD3 0xd1 - MX8MQ_IOMUXC_GPIO1_IO09_GPIO1_IO9 0x1 - MX8MQ_IOMUXC_GPIO1_IO11_GPIO1_IO11 0x1 - >; - }; - - pinctrl_pcie1: pcie1grp { - fsl,pins = < - MX8MQ_IOMUXC_SAI5_RXD2_GPIO3_IO23 0x16 - >; - }; - - pinctrl_uart1: uart1grp { - fsl,pins = < - MX8MQ_IOMUXC_UART1_RXD_UART1_DCE_RX 0x45 - MX8MQ_IOMUXC_UART1_TXD_UART1_DCE_TX 0x45 - >; - }; - - pinctrl_usdhc1: usdhc1grp { - fsl,pins = < - MX8MQ_IOMUXC_SD1_CLK_USDHC1_CLK 0x83 - MX8MQ_IOMUXC_SD1_CMD_USDHC1_CMD 0xc3 - MX8MQ_IOMUXC_SD1_DATA0_USDHC1_DATA0 0xc3 - MX8MQ_IOMUXC_SD1_DATA1_USDHC1_DATA1 0xc3 - MX8MQ_IOMUXC_SD1_DATA2_USDHC1_DATA2 0xc3 - MX8MQ_IOMUXC_SD1_DATA3_USDHC1_DATA3 0xc3 - MX8MQ_IOMUXC_SD1_DATA4_USDHC1_DATA4 0xc3 - MX8MQ_IOMUXC_SD1_DATA5_USDHC1_DATA5 0xc3 - MX8MQ_IOMUXC_SD1_DATA6_USDHC1_DATA6 0xc3 - MX8MQ_IOMUXC_SD1_DATA7_USDHC1_DATA7 0xc3 - MX8MQ_IOMUXC_SD1_RESET_B_GPIO2_IO10 0x41 - >; - }; - - pinctrl_usdhc2: usdhc2grp { - fsl,pins = < - MX8MQ_IOMUXC_SD2_CLK_USDHC2_CLK 0x03 - MX8MQ_IOMUXC_SD2_CMD_USDHC2_CMD 0xc3 - MX8MQ_IOMUXC_SD2_DATA0_USDHC2_DATA0 0xc3 - MX8MQ_IOMUXC_SD2_DATA1_USDHC2_DATA1 0xc3 - MX8MQ_IOMUXC_SD2_DATA2_USDHC2_DATA2 0xc3 - MX8MQ_IOMUXC_SD2_DATA3_USDHC2_DATA3 0xc - >; - }; - - pinctrl_wdog: wdog1grp { - fsl,pins = < - MX8MQ_IOMUXC_GPIO1_IO02_WDOG1_WDOG_B 0xc6 - >; - }; -}; diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c index 63afdf1ef4..16a377341c 100644 --- a/arch/arm/mach-imx/boot.c +++ b/arch/arm/mach-imx/boot.c @@ -285,6 +285,8 @@ void imx53_get_boot_source(enum bootsource *src, int *instance) default: if (imx53_bootsource_nand(cfg1)) *src = BOOTSOURCE_NAND; + else + *src = BOOTSOURCE_UNKNOWN; break; } @@ -464,6 +466,8 @@ void imx6_get_boot_source(enum bootsource *src, int *instance) default: if (imx53_bootsource_nand(bootmode)) *src = BOOTSOURCE_NAND; + else + *src = BOOTSOURCE_UNKNOWN; break; } } @@ -522,10 +526,12 @@ static void __imx7_get_boot_source(enum bootsource *src, int *instance, case 5: *src = BOOTSOURCE_NOR; break; - case 15: + case 14: /* observed on i.MX8MP for USB "serial" booting */ + case 15: /* observed on i.MX8MM for USB "serial" booting */ *src = BOOTSOURCE_SERIAL; break; default: + *src = BOOTSOURCE_UNKNOWN; break; } } @@ -629,6 +635,8 @@ void vf610_get_boot_source(enum bootsource *src, int *instance) default: if (imx53_bootsource_nand(sbmr1)) *src = BOOTSOURCE_NAND; + else + *src = BOOTSOURCE_UNKNOWN; break; } } diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c index d8b2842989..69df9bbe92 100644 --- a/scripts/imx/imx-usb-loader.c +++ b/scripts/imx/imx-usb-loader.c @@ -55,7 +55,7 @@ int verbose; static struct libusb_device_handle *usb_dev_handle; -static struct usb_id *usb_id; +static const struct mach_id *mach_id; struct mach_id { struct mach_id * next; @@ -82,11 +82,6 @@ struct usb_work { unsigned char plug; }; -struct usb_id { - const struct mach_id *mach_id; - struct usb_work *work; -}; - static const struct mach_id imx_ids[] = { { .vid = 0x066f, @@ -455,8 +450,8 @@ static void dump_bytes(const void *src, unsigned cnt, unsigned addr) static int transfer(int report, unsigned char *p, unsigned cnt, int *last_trans) { int err; - if (cnt > usb_id->mach_id->max_transfer) - cnt = usb_id->mach_id->max_transfer; + if (cnt > mach_id->max_transfer) + cnt = mach_id->max_transfer; if (verbose > 4) { printf("report=%i\n", report); @@ -464,7 +459,7 @@ static int transfer(int report, unsigned char *p, unsigned cnt, int *last_trans) dump_bytes(p, cnt, 0); } - if (usb_id->mach_id->mode == MODE_BULK) { + if (mach_id->mode == MODE_BULK) { *last_trans = 0; err = libusb_bulk_transfer(usb_dev_handle, (report < 3) ? 1 : 2 + EP_IN, p, cnt, last_trans, 1000); @@ -550,7 +545,7 @@ static int do_status(void) break; } - if (usb_id->mach_id->mode == MODE_HID) { + if (mach_id->mode == MODE_HID) { err = transfer(4, tmp, sizeof(tmp), &last_trans); if (err) printf("4 in err=%i, last_trans=%i %02x %02x %02x %02x\n", @@ -758,7 +753,7 @@ static int load_file(void *buf, unsigned len, unsigned dladdr, retry = 0; - if (usb_id->mach_id->mode == MODE_BULK) { + if (mach_id->mode == MODE_BULK) { err = transfer(3, tmp, sizeof(tmp), &last_trans); if (err) printf("in err=%i, last_trans=%i %02x %02x %02x %02x\n", @@ -769,7 +764,7 @@ static int load_file(void *buf, unsigned len, unsigned dladdr, cnt = len; while (1) { - int now = get_min(cnt, usb_id->mach_id->max_transfer); + int now = get_min(cnt, mach_id->max_transfer); if (!now) break; @@ -787,7 +782,7 @@ static int load_file(void *buf, unsigned len, unsigned dladdr, if (mode_barebox) return transfer_size; - if (usb_id->mach_id->mode == MODE_HID) { + if (mach_id->mode == MODE_HID) { err = transfer(3, tmp, sizeof(tmp), &last_trans); if (err) printf("3 in err=%i, last_trans=%i %02x %02x %02x %02x\n", @@ -1181,7 +1176,7 @@ static int is_header(const unsigned char *p) const struct imx_flash_header_v2 *hdr = (const struct imx_flash_header_v2 *)p; - switch (usb_id->mach_id->header_type) { + switch (mach_id->header_type) { case HDR_MX51: if (ohdr->app_code_barker == 0xb1) return 1; @@ -1201,7 +1196,7 @@ static int perform_dcd(unsigned char *p, const unsigned char *file_start, struct imx_flash_header_v2 *hdr = (struct imx_flash_header_v2 *)p; int ret = 0; - switch (usb_id->mach_id->header_type) { + switch (mach_id->header_type) { case HDR_MX51: ret = write_dcd_table_old(ohdr, file_start, cnt); ohdr->dcd_block_len = 0; @@ -1218,11 +1213,11 @@ static int perform_dcd(unsigned char *p, const unsigned char *file_start, } static int get_dl_start(const unsigned char *p, const unsigned char *file_start, - unsigned cnt, unsigned *max_length, unsigned *plugin, + unsigned cnt, size_t *firststage_len, unsigned *plugin, unsigned *header_addr) { const unsigned char *file_end = file_start + cnt; - switch (usb_id->mach_id->header_type) { + switch (mach_id->header_type) { case HDR_MX51: { struct imx_flash_header *ohdr = (struct imx_flash_header *)p; @@ -1233,7 +1228,7 @@ static int get_dl_start(const unsigned char *p, const unsigned char *file_start, *header_addr = ohdr->dcd_ptr_ptr - offsetof(struct imx_flash_header, dcd); *plugin = 0; if (err >= 0) - *max_length = dcd_end[0] | (dcd_end[1] << 8) | (dcd_end[2] << 16) | (dcd_end[3] << 24); + *firststage_len = dcd_end[0] | (dcd_end[1] << 8) | (dcd_end[2] << 16) | (dcd_end[3] << 24); break; } @@ -1249,7 +1244,7 @@ static int get_dl_start(const unsigned char *p, const unsigned char *file_start, return -1; } - *max_length = ((struct imx_boot_data *)bd)->size; + *firststage_len = ((struct imx_boot_data *)bd)->size; *plugin = ((struct imx_boot_data *)bd)->plugin; ((struct imx_boot_data *)bd)->plugin = 0; @@ -1263,7 +1258,7 @@ static int get_payload_start(const unsigned char *p, uint32_t *ofs) { struct imx_flash_header_v2 *hdr = (struct imx_flash_header_v2 *)p; - switch (usb_id->mach_id->header_type) { + switch (mach_id->header_type) { case HDR_MX51: return -EINVAL; @@ -1276,7 +1271,7 @@ static int get_payload_start(const unsigned char *p, uint32_t *ofs) } static int process_header(struct usb_work *curr, unsigned char *buf, int cnt, - unsigned *p_max_length, unsigned *p_plugin, + size_t *p_firststage_len, unsigned *p_plugin, unsigned *p_header_addr) { int ret; @@ -1291,7 +1286,7 @@ static int process_header(struct usb_work *curr, unsigned char *buf, int cnt, if (!is_header(p)) continue; - ret = get_dl_start(p, buf, cnt, p_max_length, p_plugin, p_header_addr); + ret = get_dl_start(p, buf, cnt, p_firststage_len, p_plugin, p_header_addr); if (ret < 0) { printf("!!get_dl_start returned %i\n", ret); return ret; @@ -1308,7 +1303,7 @@ static int process_header(struct usb_work *curr, unsigned char *buf, int cnt, if (*p_plugin && (!curr->plug) && (!header_cnt)) { header_cnt++; - header_max = header_offset + *p_max_length + 0x400; + header_max = header_offset + *p_firststage_len + 0x400; if (header_max > cnt - 32) header_max = cnt - 32; printf("header_max=%x\n", header_max); @@ -1334,18 +1329,17 @@ static int do_irom_download(struct usb_work *curr, int verify) unsigned char *buf = NULL; unsigned char *image; unsigned char *verify_buffer = NULL; - unsigned max_length; + size_t firststage_len; unsigned plugin = 0; unsigned header_addr = 0; - unsigned total_size = 0; buf = read_file(curr->filename, &fsize); if (!buf) return -errno; - max_length = fsize; + firststage_len = fsize; - ret = process_header(curr, buf, fsize, &max_length, &plugin, &header_addr); + ret = process_header(curr, buf, fsize, &firststage_len, &plugin, &header_addr); if (ret < 0) goto cleanup; @@ -1357,14 +1351,10 @@ static int do_irom_download(struct usb_work *curr, int verify) goto cleanup; } + /* skip over the imx-image-part */ image = buf + header_offset; fsize -= header_offset; - if (fsize > max_length) { - total_size = fsize; - fsize = max_length; - } - type = FT_APP; if (verify) { @@ -1378,16 +1368,16 @@ static int do_irom_download(struct usb_work *curr, int verify) memcpy(verify_buffer, image, 64); - if ((type == FT_APP) && (usb_id->mach_id->mode != MODE_HID)) { + if ((type == FT_APP) && (mach_id->mode != MODE_HID)) { type = FT_LOAD_ONLY; verify = 2; } } - printf("loading binary file(%s) to 0x%08x, fsize=%zu type=%d...\n", - curr->filename, header_addr, fsize, type); + printf("loading binary file(%s) to 0x%08x, firststage_len=%zu type=%d, hdroffset=%u...\n", + curr->filename, header_addr, firststage_len, type, header_offset); - ret = load_file(image, fsize, header_addr, type, false); + ret = load_file(image, firststage_len, header_addr, type, false); if (ret < 0) goto cleanup; @@ -1417,7 +1407,7 @@ static int do_irom_download(struct usb_work *curr, int verify) } } - if (usb_id->mach_id->mode == MODE_HID && type == FT_APP) { + if (mach_id->mode == MODE_HID && type == FT_APP) { printf("jumping to 0x%08x\n", header_addr); ret = sdp_jump_address(header_addr); @@ -1425,7 +1415,7 @@ static int do_irom_download(struct usb_work *curr, int verify) return ret; } - if (total_size) { + if (firststage_len < fsize) { uint32_t ofs; ret = get_payload_start(image, &ofs); @@ -1433,9 +1423,9 @@ static int do_irom_download(struct usb_work *curr, int verify) printf("Cannot get offset of payload\n"); goto cleanup; } - printf("Loading full image\n"); + printf("Loading full image from offset %u\n", ofs); printf("Note: This needs board support on the other end\n"); - load_file(image + ofs, total_size - ofs, 0, 0, true); + load_file(image + ofs, fsize - ofs, 0, 0, true); } ret = 0; @@ -1480,7 +1470,7 @@ static int mxs_load_file(libusb_device_handle *dev, uint8_t *data, int size) cnt = size; while (1) { - int now = get_min(cnt, usb_id->mach_id->max_transfer); + int now = get_min(cnt, mach_id->max_transfer); if (!now) break; @@ -1538,7 +1528,6 @@ static void usage(const char *prgname) int main(int argc, char *argv[]) { - const struct mach_id *mach; libusb_device **devs; libusb_device *dev; int r; @@ -1610,7 +1599,7 @@ int main(int argc, char *argv[]) goto out; } - dev = find_imx_dev(devs, &mach, devpath, devtype); + dev = find_imx_dev(devs, &mach_id, devpath, devtype); if (!dev) { fprintf(stderr, "no supported device found\n"); goto out; @@ -1629,15 +1618,7 @@ int main(int argc, char *argv[]) goto out; } - usb_id = malloc(sizeof(*usb_id)); - if (!usb_id) { - perror("malloc"); - exit(1); - } - - usb_id->mach_id = mach; - - if (mach->dev_type == DEV_MXS) { + if (mach_id->dev_type == DEV_MXS) { ret = mxs_work(&w); goto out; } @@ -1662,9 +1643,6 @@ int main(int argc, char *argv[]) ret = 0; out: - if (usb_id) - free(usb_id); - if (usb_dev_handle) libusb_close(usb_dev_handle); |