diff --git a/Documentation/user/usb.rst b/Documentation/user/usb.rst index 99158a2..8602a8f 100644 --- a/Documentation/user/usb.rst +++ b/Documentation/user/usb.rst @@ -110,8 +110,10 @@ - fastboot boot - fastboot reboot -**NOTE** ``fastboot erase`` is not yet implemented. This means flashing MTD partitions -does not yet work. +``fastboot flash`` additionally supports image types UBI and Barebox. For UBI +Images and a MTD device as target, ubiformat is called. For a Barebox image +with an available barebox update handler for the fastboot exported device, the +barebox_update is called. The barebox Fastboot gadget supports the following non standard extensions: @@ -126,6 +128,53 @@ command returns successfully when the barebox command was successful and it fails when the barebox command fails. +**Example booting kernel/devicetree/initrd with fastboot** + +In Barebox start the fastboot gadget: + +.. code-block:: sh + + usbgadget -A /kernel(kernel)c,/initrd(initrd)c,/devicetree(devicetree)c + +On the host you can use this script to start a kernel with kernel, devicetree +and initrd: + +.. code-block:: sh + + #!/bin/bash + + set -e + set -v + + if [ "$#" -lt 3 ] + then + echo "USAGE: $0
[]" + exit 0 + fi + + kernel=$1 + dt=$2 + initrd=$3 + + shift 3 + + fastboot -i 7531 flash kernel $kernel + fastboot -i 7531 flash devicetree $dt + fastboot -i 7531 flash initrd $initrd + + + fastboot -i 7531 oem exec 'global linux.bootargs.fa'$ct'=rdinit=/sbin/init' + if [ $# -gt 0 ] + then + ct=1 + for i in $* + do + fastboot -i 7531 oem exec 'global linux.bootargs.fa'$ct'='"\"$i\"" + ct=$(($ct + 1)) + done + fi + timeout -k 5 3 fastboot -i 7531 oem exec -- bootm -o /devicetree -r /initrd /kernel + USB Composite Multifunction Gadget ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/arch/arm/boards/edb93xx/edb93xx.c b/arch/arm/boards/edb93xx/edb93xx.c index c314320..0fb93d2 100644 --- a/arch/arm/boards/edb93xx/edb93xx.c +++ b/arch/arm/boards/edb93xx/edb93xx.c @@ -27,10 +27,16 @@ #include #include #include +#include #include "edb93xx.h" #define DEVCFG_U1EN (1 << 18) +static struct ep93xx_eth_platform_data ep93xx_eth_info = { + .xcv_type = PHY_INTERFACE_MODE_MII, + .phy_addr = 1, +}; + static int ep93xx_mem_init(void) { arm_add_mem_device("ram0", CONFIG_EP93XX_SDRAM_BANK0_BASE, @@ -70,7 +76,7 @@ * CS line 6, data width is 16 bit */ add_generic_device("ep93xx_eth", DEVICE_ID_DYNAMIC, NULL, 0, 0, IORESOURCE_MEM, - NULL); + &ep93xx_eth_info); armlinux_set_architecture(MACH_TYPE); diff --git a/arch/arm/configs/am335x_defconfig b/arch/arm/configs/am335x_defconfig index 7cf48b8..9196fb8 100644 --- a/arch/arm/configs/am335x_defconfig +++ b/arch/arm/configs/am335x_defconfig @@ -84,6 +84,7 @@ CONFIG_CMD_OF_NODE=y CONFIG_CMD_OF_PROPERTY=y CONFIG_CMD_OF_DISPLAY_TIMINGS=y +CONFIG_CMD_OF_FIXUP_STATUS=y CONFIG_CMD_OFTREE=y CONFIG_CMD_TIME=y CONFIG_NET=y diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index c631c33..33ae145 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig @@ -698,8 +698,8 @@ MAC to 12:34:56:78:9A:BC (2 words with address 0x22 (OCOTP_MAC0) and address 0x23 (OCOTP_MAC1)). To calculate the file offset multiply the value of the address by 4. - mw -l -d /dev/imx-ocotp 0x8C 0x00001234 - mw -l -d /dev/imx-ocotp 0x88 0x56789ABC + mw -l -d /dev/imx-ocotp 0x8C 0x00001234 + mw -l -d /dev/imx-ocotp 0x88 0x56789ABC config HAB bool diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c index ac90c53..821ce66 100644 --- a/arch/arm/mach-imx/imx-bbu-internal.c +++ b/arch/arm/mach-imx/imx-bbu-internal.c @@ -132,6 +132,9 @@ if (ret) return ret; + if (!strncmp(data->devicefile, "/dev/", 5)) + device_detect_by_name(data->devicefile + 5); + return 0; } diff --git a/commands/Kconfig b/commands/Kconfig index b4fdc86..9519a44 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -2114,6 +2114,22 @@ -s path select display-timings and register oftree fixup -f dtb work on dtb. Has no effect on -s option +config CMD_OF_FIXUP_STATUS + tristate + select OFTREE + prompt "of_fixup_status" + help + Register a fixup to enable or disable node + + Usage: of_fixup_node [-d] path + + Options: + -d disable node + path Node path or alias + + Register a fixup to enable or disable a device tree node. + Nodes are enabled on default. Disabled with -d. + config CMD_OFTREE tristate select OFTREE diff --git a/commands/Makefile b/commands/Makefile index d985341..8975d4b 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -78,6 +78,7 @@ obj-$(CONFIG_CMD_OF_NODE) += of_node.o obj-$(CONFIG_CMD_OF_DUMP) += of_dump.o obj-$(CONFIG_CMD_OF_DISPLAY_TIMINGS) += of_display_timings.o +obj-$(CONFIG_CMD_OF_FIXUP_STATUS) += of_fixup_status.o obj-$(CONFIG_CMD_MAGICVAR) += magicvar.o obj-$(CONFIG_CMD_IOMEM) += iomemport.o obj-$(CONFIG_CMD_LINUX_EXEC) += linux_exec.o diff --git a/commands/magicvar.c b/commands/magicvar.c index 6737eb5..8740784 100644 --- a/commands/magicvar.c +++ b/commands/magicvar.c @@ -24,7 +24,7 @@ } } -struct magicvar_dyn *magicvar_find(const char *name) +static struct magicvar_dyn *magicvar_find(const char *name) { struct magicvar_dyn *md; diff --git a/commands/of_fixup_status.c b/commands/of_fixup_status.c new file mode 100644 index 0000000..9a4a619 --- /dev/null +++ b/commands/of_fixup_status.c @@ -0,0 +1,74 @@ +/* + * of_fixup_status.c - Register a fixup to enable or disable nodes in the + * device tree + * + * Copyright (c) 2014-2016 PHYTEC Messtechnik GmbH + * Author: + * Teresa Remmet + * Wadim Egorov + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int do_of_fixup_status(int argc, char *argv[]) +{ + int opt; + bool status = 1; + char *node = NULL; + + while ((opt = getopt(argc, argv, "d")) > 0) { + switch (opt) { + case 'd': + status = 0; + break; + default: + return COMMAND_ERROR_USAGE; + } + } + + if (optind == argc) + return COMMAND_ERROR_USAGE; + + node = xstrdup(argv[optind]); + + of_register_set_status_fixup(node, status); + + return 0; +} + +BAREBOX_CMD_HELP_START(of_fixup_status) +BAREBOX_CMD_HELP_TEXT("Options:") +BAREBOX_CMD_HELP_OPT("-d", "disable node") +BAREBOX_CMD_HELP_OPT("path", "Node path\n") +BAREBOX_CMD_HELP_TEXT("Register a fixup to enable or disable a device tree node.") +BAREBOX_CMD_HELP_TEXT("Nodes are enabled on default. Disabled with -d.") +BAREBOX_CMD_HELP_END + +BAREBOX_CMD_START(of_fixup_status) + .cmd = do_of_fixup_status, + BAREBOX_CMD_DESC("register a fixup to enable or disable node") + BAREBOX_CMD_OPTS("[-d] path") + BAREBOX_CMD_GROUP(CMD_GRP_MISC) + BAREBOX_CMD_COMPLETE(devicetree_file_complete) + BAREBOX_CMD_HELP(cmd_of_fixup_status_help) +BAREBOX_CMD_END diff --git a/common/oftree.c b/common/oftree.c index d408f14..e98b908 100644 --- a/common/oftree.c +++ b/common/oftree.c @@ -139,6 +139,42 @@ } late_initcall(of_register_bootargs_fixup); +struct of_fixup_status_data { + const char *path; + bool status; +}; + +static int of_fixup_status(struct device_node *root, void *context) +{ + const struct of_fixup_status_data *data = context; + struct device_node *node; + + node = of_find_node_by_path_or_alias(root, data->path); + if (!node) + return -ENODEV; + + if (data->status) + return of_device_enable(node); + else + return of_device_disable(node); +} + +/** + * of_register_set_status_fixup - register fix up to set status of nodes + * Register a fixup to enable or disable a node in the devicet tree by + * passing the path or alias. + */ +int of_register_set_status_fixup(const char *path, bool status) +{ + struct of_fixup_status_data *data; + + data = xzalloc(sizeof(*data)); + data->path = path; + data->status = status; + + return of_register_fixup(of_fixup_status, (void *)data); +} + struct of_fixup { int (*fixup)(struct device_node *, void *); void *context; diff --git a/common/state.c b/common/state.c index 3e95efd..b55b150 100644 --- a/common/state.c +++ b/common/state.c @@ -999,6 +999,7 @@ return 0; out: + dev_err(&state->dev, "error fixing up device tree with boot state\n"); of_delete_node(new_node); return ret; } diff --git a/drivers/eeprom/at25.c b/drivers/eeprom/at25.c index 3e75b56..9f054d0 100644 --- a/drivers/eeprom/at25.c +++ b/drivers/eeprom/at25.c @@ -356,6 +356,7 @@ dev_dbg(dev, "%s probed\n", at25->cdev.name); devfs_create(&at25->cdev); + of_parse_partitions(&at25->cdev, dev->device_node); return 0; fail: diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index d839d7a..ab919c9 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -87,17 +87,17 @@ SMBus I/O expanders, made mostly by NXP or TI. Compatible models include: - 4 bits: pca9536, pca9537 + 4 bits: pca9536, pca9537 - 8 bits: max7310, max7315, pca6107, pca9534, pca9538, pca9554, - pca9556, pca9557, pca9574, tca6408, xra1202 + 8 bits: max7310, max7315, pca6107, pca9534, pca9538, pca9554, + pca9556, pca9557, pca9574, tca6408, xra1202 - 16 bits: max7312, max7313, pca9535, pca9539, pca9555, pca9575, - tca6416 + 16 bits: max7312, max7313, pca9535, pca9539, pca9555, pca9575, + tca6416 - 24 bits: tca6424 + 24 bits: tca6424 - 40 bits: pca9505, pca9698 + 40 bits: pca9505, pca9698 config GPIO_PL061 bool "PrimeCell PL061 GPIO support" diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c index 90c12fc..0acb9b6 100644 --- a/drivers/net/ep93xx.c +++ b/drivers/net/ep93xx.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "ep93xx.h" #define EP93XX_MAX_PKT_SIZE 1536 @@ -203,8 +204,8 @@ pr_debug("+ep93xx_eth_open\n"); - ret = phy_device_connect(edev, &priv->miibus, 0, NULL, - 0, PHY_INTERFACE_MODE_NA); + ret = phy_device_connect(edev, &priv->miibus, priv->phy_addr, NULL, + 0, priv->interface); if (ret) return ret; @@ -482,6 +483,7 @@ static int ep93xx_eth_probe(struct device_d *dev) { + struct ep93xx_eth_platform_data *pdata = (struct ep93xx_eth_platform_data *)dev->platform_data; struct eth_device *edev; struct ep93xx_eth_priv *priv; int ret = -1; @@ -504,6 +506,14 @@ edev->set_ethaddr = ep93xx_eth_set_ethaddr; edev->parent = dev; + if (pdata) { + priv->interface = pdata->xcv_type; + priv->phy_addr = pdata->phy_addr; + } else { + priv->interface = PHY_INTERFACE_MODE_NA; + priv->phy_addr = 0; + } + priv->miibus.read = ep93xx_phy_read; priv->miibus.write = ep93xx_phy_write; priv->miibus.parent = dev; @@ -589,14 +599,12 @@ pr_debug("+ep93xx_phy_read\n"); /* - * Save the current SelfCTL register value. Set MAC to suppress + * Save the current SelfCTL register value. Set MAC to send * preamble bits. Wait for any previous MII command to complete * before issuing the new command. */ self_ctl = readl(®s->selfctl); -#if defined(CONFIG_MII_SUPPRESS_PREAMBLE) /* TODO */ writel(self_ctl & ~(1 << 8), ®s->selfctl); -#endif /* defined(CONFIG_MII_SUPPRESS_PREAMBLE) */ while (readl(®s->miists) & MIISTS_BUSY) ; /* noop */ @@ -632,14 +640,12 @@ pr_debug("+ep93xx_phy_write\n"); /* - * Save the current SelfCTL register value. Set MAC to suppress + * Save the current SelfCTL register value. Set MAC to send * preamble bits. Wait for any previous MII command to complete * before issuing the new command. */ self_ctl = readl(®s->selfctl); -#if defined(CONFIG_MII_SUPPRESS_PREAMBLE) /* TODO */ writel(self_ctl & ~(1 << 8), ®s->selfctl); -#endif /* defined(CONFIG_MII_SUPPRESS_PREAMBLE) */ while (readl(®s->miists) & MIISTS_BUSY) ; /* noop */ diff --git a/drivers/net/ep93xx.h b/drivers/net/ep93xx.h index 89451b8..32ae57f 100644 --- a/drivers/net/ep93xx.h +++ b/drivers/net/ep93xx.h @@ -137,6 +137,8 @@ struct tx_descriptor_queue tx_dq; struct tx_status_queue tx_sq; + int phy_addr; + phy_interface_t interface; struct mii_bus miibus; }; diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 8ea26e3..b0bf922 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -1005,7 +1005,7 @@ struct usb_host *host = dev->host; struct ehci_priv *ehci = to_ehci(host); struct int_queue *result = NULL; - uint32_t i, toggle; + uint32_t i; struct QH *list = ehci->periodic_queue; /* @@ -1057,8 +1057,6 @@ memset(result->first, 0, sizeof(struct QH) * queuesize); memset(result->tds, 0, sizeof(struct qTD) * queuesize); - toggle = usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe)); - for (i = 0; i < queuesize; i++) { struct QH *qh = result->first + i; struct qTD *td = result->tds + i; @@ -1073,7 +1071,6 @@ qh->qh_endpt1 = cpu_to_hc32((0 << 28) | /* No NAK reload (ehci 4.9) */ (usb_maxpacket(dev, pipe) << 16) | /* MPS */ - (1 << 14) | QH_ENDPT1_EPS(ehci_encode_speed(dev->speed)) | (usb_pipeendpoint(pipe) << 8) | /* Endpoint Number */ (usb_pipedevice(pipe) << 0)); @@ -1092,7 +1089,6 @@ "communication direction is '%s'\n", usb_pipein(pipe) ? "in" : "out"); td->qt_token = cpu_to_hc32( - QT_TOKEN_DT(toggle) | (elementsize << 16) | ((usb_pipein(pipe) ? 1 : 0) << 8) | /* IN/OUT token */ 0x80); /* active */ @@ -1108,7 +1104,6 @@ cpu_to_hc32((td->qt_buffer[0] + 0x4000) & ~0xfff); *buf = buffer + i * elementsize; - toggle ^= 1; } if (ehci->periodic_schedules > 0) { @@ -1144,8 +1139,7 @@ { struct QH *cur = queue->current; struct qTD *cur_td; - uint32_t token, toggle; - unsigned long pipe = queue->pipe; + uint32_t token; /* depleted queue */ if (cur == NULL) { @@ -1162,9 +1156,6 @@ return NULL; } - toggle = QT_TOKEN_GET_DT(token); - usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), toggle); - if (!(cur->qh_link & QH_LINK_TERMINATE)) queue->current++; else @@ -1183,7 +1174,6 @@ struct usb_host *host = dev->host; struct ehci_priv *ehci = to_ehci(host); struct QH *cur = ehci->periodic_queue; - uint64_t start; if (disable_periodic(ehci) < 0) { dev_err(&dev->dev, @@ -1192,7 +1182,6 @@ } ehci->periodic_schedules--; - start = get_time_ns(); while (!(cur->qh_link & cpu_to_hc32(QH_LINK_TERMINATE))) { dev_dbg(&dev->dev, "considering %p, with qh_link %x\n", @@ -1205,12 +1194,6 @@ break; } cur = NEXT_QH(cur); - if (is_timeout_non_interruptible(start, 500 * MSECOND)) { - dev_err(&dev->dev, - "Timeout destroying interrupt endpoint queue\n"); - result = -ETIMEDOUT; - goto out; - } } if (ehci->periodic_schedules > 0) { diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index 590f54d..1ecbb8d 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -127,7 +127,8 @@ return 0; } -int ext4fs_get_indir_block(struct ext2fs_node *node, struct ext4fs_indir_block *indir, int blkno) +static int ext4fs_get_indir_block(struct ext2fs_node *node, + struct ext4fs_indir_block *indir, int blkno) { struct ext_filesystem *fs = node->data->fs; int blksz; diff --git a/fs/fat/fat.c b/fs/fat/fat.c index ece937d..49cd78f 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -1,7 +1,7 @@ /* - * ramfs.c - a malloc based filesystem + * fat.c - FAT filesystem barebox driver * - * Copyright (c) 2007 Sascha Hauer , Pengutronix + * Copyright (c) 2011 Sascha Hauer , Pengutronix * * See file CREDITS for list of people who contributed to this * project. diff --git a/include/net/ep93xx_eth.h b/include/net/ep93xx_eth.h new file mode 100644 index 0000000..0fb11d0 --- /dev/null +++ b/include/net/ep93xx_eth.h @@ -0,0 +1,26 @@ +/* + * (C) Copyright 2016 Alexander Kurz + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef __NET_EP93XX_ETH_H +#define __NET_EP93XX_ETH_H + +#include + +struct ep93xx_eth_platform_data { + phy_interface_t xcv_type; + int phy_addr; +}; + +#endif /* __NET_EP93XX_ETH_H */ diff --git a/include/of.h b/include/of.h index 75cc3c1..8c8f57a 100644 --- a/include/of.h +++ b/include/of.h @@ -249,6 +249,7 @@ int of_find_path_by_node(struct device_node *node, char **outpath, unsigned flags); int of_register_fixup(int (*fixup)(struct device_node *, void *), void *context); int of_unregister_fixup(int (*fixup)(struct device_node *, void *), void *context); +int of_register_set_status_fixup(const char *node, bool status); struct device_node *of_find_node_by_alias(struct device_node *root, const char *alias); struct device_node *of_find_node_by_path_or_alias(struct device_node *root, diff --git a/lib/process_escape_sequence.c b/lib/process_escape_sequence.c index 1bfd070..3747da1 100644 --- a/lib/process_escape_sequence.c +++ b/lib/process_escape_sequence.c @@ -18,6 +18,7 @@ */ #include #include +#include #include #include @@ -57,6 +58,11 @@ case 'h': i += snprintf(dest + i, destlen - i, "%s", barebox_get_model()); break; + case 'u': + if (IS_ENABLED(CONFIG_GLOBALVAR)) + i += snprintf(dest + i, destlen - i, "%s", + dev_get_param(&global_device, "user")); + break; case 'w': i += snprintf(dest + i, destlen - i, "%s", getcwd()); break;