diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2017-11-13 08:21:07 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-11-13 08:21:07 +0100 |
commit | 4db085e845a24c528e1d7511b123c998f63a5688 (patch) | |
tree | 28e5b79af23ca767c48c5b5719a4171b0c5440dd | |
parent | df605b19fdeab6333c0bf2e49953dfa3ae28e002 (diff) | |
parent | f4c9a52bd9ff659f035e95eed946d37f4f94dfef (diff) | |
download | barebox-4db085e845a24c528e1d7511b123c998f63a5688.tar.gz barebox-4db085e845a24c528e1d7511b123c998f63a5688.tar.xz |
Merge branch 'for-next/imx'
-rw-r--r-- | arch/arm/boards/tqma6x/board.c | 2 | ||||
-rw-r--r-- | arch/arm/dts/imx25.dtsi | 8 | ||||
-rw-r--r-- | arch/arm/mach-imx/imx-bbu-internal.c | 113 | ||||
-rw-r--r-- | arch/arm/mach-imx/include/mach/bbu.h | 10 | ||||
-rw-r--r-- | drivers/usb/imx/chipidea-imx.c | 4 |
5 files changed, 119 insertions, 18 deletions
diff --git a/arch/arm/boards/tqma6x/board.c b/arch/arm/boards/tqma6x/board.c index 8946a27b69..ecf8fa06af 100644 --- a/arch/arm/boards/tqma6x/board.c +++ b/arch/arm/boards/tqma6x/board.c @@ -105,7 +105,7 @@ static int tqma6x_env_init(void) imx6_bbu_internal_spi_i2c_register_handler("spiflash", "/dev/m25p0.barebox", BBU_HANDLER_FLAG_DEFAULT); - imx6_bbu_internal_mmc_register_handler("emmc", "/dev/mmc2.boot0", 0); + imx6_bbu_internal_mmcboot_register_handler("emmc", "mmc2", 0); device_detect_by_name("mmc2"); diff --git a/arch/arm/dts/imx25.dtsi b/arch/arm/dts/imx25.dtsi index 13fbcc4f8d..2e069e6f03 100644 --- a/arch/arm/dts/imx25.dtsi +++ b/arch/arm/dts/imx25.dtsi @@ -29,3 +29,11 @@ &usbmisc { status = "okay"; }; + +&usbotg { + over-current-active-high; +}; + +&usbhost1 { + over-current-active-high; +}; diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c index 51ec8b8270..e346387131 100644 --- a/arch/arm/mach-imx/imx-bbu-internal.c +++ b/arch/arm/mach-imx/imx-bbu-internal.c @@ -29,6 +29,7 @@ #include <linux/mtd/mtd-abi.h> #include <linux/stat.h> #include <ioctl.h> +#include <environment.h> #include <mach/bbu.h> #define FLASH_HEADER_OFFSET_MMC 0x400 @@ -49,29 +50,30 @@ struct imx_internal_bbu_handler { * DOS partition table on the device */ static int imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler, - struct bbu_data *data, void *buf, int image_len) + const char *devicefile, struct bbu_data *data, + void *buf, int image_len) { int fd, ret; - fd = open(data->devicefile, O_RDWR | O_CREAT); + fd = open(devicefile, O_RDWR | O_CREAT); if (fd < 0) return fd; if (imx_handler->flags & IMX_INTERNAL_FLAG_ERASE) { debug("%s: unprotecting %s from 0 to 0x%08x\n", __func__, - data->devicefile, image_len); + devicefile, image_len); ret = protect(fd, image_len, 0, 0); if (ret && ret != -ENOSYS) { - printf("unprotecting %s failed with %s\n", data->devicefile, + printf("unprotecting %s failed with %s\n", devicefile, strerror(-ret)); goto err_close; } debug("%s: erasing %s from 0 to 0x%08x\n", __func__, - data->devicefile, image_len); + devicefile, image_len); ret = erase(fd, image_len, 0); if (ret) { - printf("erasing %s failed with %s\n", data->devicefile, + printf("erasing %s failed with %s\n", devicefile, strerror(-ret)); goto err_close; } @@ -102,10 +104,10 @@ static int imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler, if (imx_handler->flags & IMX_INTERNAL_FLAG_ERASE) { debug("%s: protecting %s from 0 to 0x%08x\n", __func__, - data->devicefile, image_len); + devicefile, image_len); ret = protect(fd, image_len, 0, 1); if (ret && ret != -ENOSYS) { - printf("protecting %s failed with %s\n", data->devicefile, + printf("protecting %s failed with %s\n", devicefile, strerror(-ret)); } } @@ -118,7 +120,7 @@ err_close: return ret; } -static int imx_bbu_check_prereq(struct bbu_data *data) +static int imx_bbu_check_prereq(const char *devicefile, struct bbu_data *data) { int ret; @@ -131,8 +133,8 @@ static int imx_bbu_check_prereq(struct bbu_data *data) if (ret) return ret; - if (!strncmp(data->devicefile, "/dev/", 5)) - device_detect_by_name(data->devicefile + 5); + if (!strncmp(devicefile, "/dev/", 5)) + device_detect_by_name(devicefile + 5); return 0; } @@ -150,13 +152,13 @@ static int imx_bbu_internal_v1_update(struct bbu_handler *handler, struct bbu_da container_of(handler, struct imx_internal_bbu_handler, handler); int ret; - ret = imx_bbu_check_prereq(data); + ret = imx_bbu_check_prereq(data->devicefile, data); if (ret) return ret; printf("updating to %s\n", data->devicefile); - ret = imx_bbu_write_device(imx_handler, data, data->image, data->len); + ret = imx_bbu_write_device(imx_handler, data->devicefile, data, data->image, data->len); return ret; } @@ -348,7 +350,7 @@ static int imx_bbu_internal_v2_update(struct bbu_handler *handler, struct bbu_da int ret; uint32_t *barker; - ret = imx_bbu_check_prereq(data); + ret = imx_bbu_check_prereq(data->devicefile, data); if (ret) return ret; @@ -362,7 +364,61 @@ static int imx_bbu_internal_v2_update(struct bbu_handler *handler, struct bbu_da if (imx_handler->flags & IMX_INTERNAL_FLAG_NAND) ret = imx_bbu_internal_v2_write_nand_dbbt(imx_handler, data); else - ret = imx_bbu_write_device(imx_handler, data, data->image, data->len); + ret = imx_bbu_write_device(imx_handler, data->devicefile, data, + data->image, data->len); + + return ret; +} + +static int imx_bbu_internal_v2_mmcboot_update(struct bbu_handler *handler, + struct bbu_data *data) +{ + struct imx_internal_bbu_handler *imx_handler = + container_of(handler, struct imx_internal_bbu_handler, handler); + int ret; + uint32_t *barker; + char *bootpartvar; + const char *bootpart; + char *devicefile; + + barker = data->image + imx_handler->flash_header_offset; + + if (*barker != IVT_BARKER) { + printf("Board does not provide DCD data and this image is no imximage\n"); + return -EINVAL; + } + + ret = asprintf(&bootpartvar, "%s.boot", data->devicefile); + if (ret < 0) + return ret; + + bootpart = getenv(bootpartvar); + + if (!strcmp(bootpart, "boot0")) { + bootpart = "boot1"; + } else { + bootpart = "boot0"; + } + + ret = asprintf(&devicefile, "/dev/%s.%s", data->devicefile, bootpart); + if (ret < 0) + goto free_bootpartvar; + + ret = imx_bbu_check_prereq(devicefile, data); + if (ret) + goto free_devicefile; + + ret = imx_bbu_write_device(imx_handler, devicefile, data, data->image, data->len); + + if (!ret) + /* on success switch boot source */ + ret = setenv(bootpartvar, bootpart); + +free_devicefile: + free(devicefile); + +free_bootpartvar: + free(bootpartvar); return ret; } @@ -373,11 +429,12 @@ static int imx_bbu_external_update(struct bbu_handler *handler, struct bbu_data container_of(handler, struct imx_internal_bbu_handler, handler); int ret; - ret = imx_bbu_check_prereq(data); + ret = imx_bbu_check_prereq(data->devicefile, data); if (ret) return ret; - return imx_bbu_write_device(imx_handler, data, data->image, data->len); + return imx_bbu_write_device(imx_handler, data->devicefile, data, + data->image, data->len); } static struct imx_internal_bbu_handler *__init_handler(const char *name, char *devicefile, @@ -496,6 +553,28 @@ int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile, } /* + * Register a handler that writes to the non-active boot partition of an mmc + * medium and on success activates the written-to partition. So the machine can + * still boot even after a failed try to write a boot image. + * + * Pass "devicefile" without partition name and /dev/ prefix. e.g. just "mmc2". + * Note that no further partitioning of the boot partition is supported up to + * now. + */ +int imx6_bbu_internal_mmcboot_register_handler(const char *name, char *devicefile, + unsigned long flags) +{ + struct imx_internal_bbu_handler *imx_handler; + + imx_handler = __init_handler(name, devicefile, flags); + imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC; + + imx_handler->handler.handler = imx_bbu_internal_v2_mmcboot_update; + + return __register_handler(imx_handler); +} + +/* * Register a i.MX53 internal boot update handler for i2c/spi * EEPROMs / flashes. Nearly the same as MMC/SD, but we do not need to * keep a partition table. We have to erase the device beforehand though. diff --git a/arch/arm/mach-imx/include/mach/bbu.h b/arch/arm/mach-imx/include/mach/bbu.h index 8039091395..15bdbe1bec 100644 --- a/arch/arm/mach-imx/include/mach/bbu.h +++ b/arch/arm/mach-imx/include/mach/bbu.h @@ -24,6 +24,9 @@ int imx53_bbu_internal_nand_register_handler(const char *name, int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile, unsigned long flags); +int imx6_bbu_internal_mmcboot_register_handler(const char *name, char *devicefile, + unsigned long flags); + int imx6_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile, unsigned long flags); @@ -62,6 +65,13 @@ static inline int imx6_bbu_internal_mmc_register_handler(const char *name, char return -ENOSYS; } +static inline int imx6_bbu_internal_mmcboot_register_handler(const char *name, + char *devicefile, + unsigned long flags) +{ + return -ENOSYS; +} + static inline int imx6_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile, unsigned long flags) { diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c index 39593c40fb..505f5eb35d 100644 --- a/drivers/usb/imx/chipidea-imx.c +++ b/drivers/usb/imx/chipidea-imx.c @@ -155,6 +155,10 @@ static int imx_chipidea_probe_dt(struct imx_chipidea *ci) "disable-over-current", NULL)) ci->flags |= MXC_EHCI_DISABLE_OVERCURRENT; + else if (!of_find_property(ci->dev->device_node, + "over-current-active-high", NULL)) + ci->flags |= MXC_EHCI_OC_PIN_ACTIVE_LOW; + return 0; } |