diff --git a/Documentation/user/bootchooser.rst b/Documentation/user/bootchooser.rst index 5baa66d..cef1d4a 100644 --- a/Documentation/user/bootchooser.rst +++ b/Documentation/user/bootchooser.rst @@ -67,7 +67,7 @@ :ref:`command_bootchooser` command. This allows for custom conditions under which a system is marked as good. In case only the booted system itself knows when it is in a good state, the -barebox-state tool from the dt-utils_ package can used to reset the remaining_attempts +barebox-state tool from the dt-utils_ package can be used to reset the remaining_attempts counter from the currently running system. .. _dt-utils: http://git.pengutronix.de/?p=tools/dt-utils.git;a=summary @@ -79,8 +79,8 @@ options not specific to any target. ``global.bootchooser.disable_on_zero_attempts`` - Boolean flag. if 1, bootchooser disables a target (sets priority to 0) whenever the - remaining attempts counter reaches 0. + Boolean flag. If set to 1, bootchooser disables a target (sets priority to 0) whenever + the remaining attempts counter reaches 0. ``global.bootchooser.default_attempts`` The default number of attempts that a target shall be tried starting, used when not overwritten with the target specific variable of the same name. @@ -89,25 +89,28 @@ of the same name. ``global.bootchooser.reset_attempts`` A space separated list of events that cause bootchooser to reset the - remaining_attempts counters of each target that has a non zero priority. possible values: - * empty: counters will never be reset`` + remaining_attempts counters of each target that has a non zero priority. Possible values: + + * empty: counters will never be reset`` * power-on: counters will be reset after power-on-reset * all-zero: counters will be reset when all targets have zero remaining attempts ``global.bootchooser.reset_priorities`` A space separated list of events that cause bootchooser to reset the priorities of all targets. Possible values: + * empty: priorities will never be reset * all-zero: priorities will be reset when all targets have zero priority ``global.bootchooser.retry`` - If 1, bootchooser retries booting until one succeeds or no more valid targets exist. + If set to 1, bootchooser retries booting until one succeeds or no more valid targets + exist. ``global.bootchooser.state_prefix`` - Variable prefix when bootchooser used with state framework as backend for storing runtime - data, see below. + Variable prefix when bootchooser is used with the state framework as backend for storing + runtime data, see below. ``global.bootchooser.targets`` Space separated list of targets that are used. For each entry in the list a corresponding - set of ``global.bootchooser.``. variables must exist. + set of ``global.bootchooser..`` variables must exist. ``global.bootchooser.last_chosen`` - bootchooser sets this to the target that was chosen on last boot (index) + bootchooser sets this to the target that was chosen on last boot (index). Using the State Framework as Backend for Runtime Variable Data -------------------------------------------------------------- @@ -178,7 +181,7 @@ - ``global.bootchooser.disable_on_zero_attempts=0`` - ``global.bootchooser.retry=1`` - ``global.boot.default="bootchooser recovery"`` -- Userspace marks as good +- Userspace marks as good. Deployment ^^^^^^^^^^ @@ -208,21 +211,22 @@ - ``global.bootchooser.disable_on_zero_attempts=0`` - ``global.bootchooser.retry=1`` - ``global.boot.default="bootchooser recovery"`` -- Userspace marks as good +- Userspace marks as good. Deployment ^^^^^^^^^^ -#. barebox or flash robot fills all slots with valid systems +#. barebox or flash robot fills all slots with valid systems. #. barebox or flash robot marks slots as good or state contains non zero - defaults for the remaining_attempts / priorities + defaults for the remaining_attempts/priorities. Recovery ^^^^^^^^ done by 'recovery' boot target which is booted after the bootchooser falls through due to the lack of bootable targets. This target can be: -- A system that will be booted as recovery -- A barebox script that will be started + +- A system that will be booted as recovery. +- A barebox script that will be started. Scenario 3 ########## @@ -238,21 +242,22 @@ - ``global.bootchooser.disable_on_zero_attempts=1`` - ``global.bootchooser.retry=1`` - ``global.boot.default="bootchooser recovery"`` -- Userspace marks as good +- Userspace marks as good. Deployment ^^^^^^^^^^ -- barebox or flash robot fills all slots with valid systems -- barebox or flash robot marks slots as good +#. barebox or flash robot fills all slots with valid systems. +#. barebox or flash robot marks slots as good. Recovery ^^^^^^^^ Done by 'recovery' boot target which is booted after the bootchooser falls through due to the lack of bootable targets. This target can be: -- A system that will be booted as recovery -- A barebox script that will be started + +- A system that will be booted as recovery. +- A barebox script that will be started. Updating systems ---------------- @@ -262,11 +267,11 @@ slots or a dedicated recovery system. For the regular slots updating is done like: - Set the priority of the inactive slot to 0. -- Update the inactive slot -- Set priority of the inactive slot to a higher value than the active slot -- Set remaining_attempts of the inactive slot to nonzero -- Reboot -- If necessary update the now inactive, not yet updated slot the same way +- Update the inactive slot. +- Set priority of the inactive slot to a higher value than the active slot. +- Set remaining_attempts of the inactive slot to nonzero. +- Reboot. +- If necessary update the now inactive, not yet updated slot the same way. One way of updating systems is using RAUC_ which integrates well with the bootchooser in barebox. diff --git a/Documentation/user/remote-control.rst b/Documentation/user/remote-control.rst index b9275ce..99c2181 100644 --- a/Documentation/user/remote-control.rst +++ b/Documentation/user/remote-control.rst @@ -112,10 +112,10 @@ barebox@Phytec phyFLEX-i.MX6 Quad Carrier-Board:/ ls . .. dev env mnt -*NOTE** To terminate resulting Barebox console session press 'Ctrl-T' +**NOTE** To terminate resulting Barebox console session press 'Ctrl-T' **NOTE** You can also send 'ping' request to the target without - closing console session by pressint 'Ctrl-P' +closing console session by pressint 'Ctrl-P' transferring files ------------------ diff --git a/arch/arm/boards/vscom-baltos/lowlevel.c b/arch/arm/boards/vscom-baltos/lowlevel.c index 87f2a74..9f829b9 100644 --- a/arch/arm/boards/vscom-baltos/lowlevel.c +++ b/arch/arm/boards/vscom-baltos/lowlevel.c @@ -126,6 +126,12 @@ { void *fdt; + /* + * Prolong global reset duration to the max. value (0xff) + * and leave power domain reset to its default value (0x10). + */ + __raw_writel(0x000010ff, AM33XX_PRM_RSTTIME); + fdt = __dtb_am335x_baltos_minimal_start; fdt -= get_runtime_offset(); diff --git a/arch/arm/dts/imx53-guf-vincell-lt.dts b/arch/arm/dts/imx53-guf-vincell-lt.dts index 67a4133..2b1b54a 100644 --- a/arch/arm/dts/imx53-guf-vincell-lt.dts +++ b/arch/arm/dts/imx53-guf-vincell-lt.dts @@ -152,7 +152,7 @@ }; pmic: dialog@48 { /* DA9053-3HHA1 PMIC */ - compatible = "dialog,da9053-aa", "dialog,da9052"; + compatible = "dlg,da9053-aa", "dlg,da9052"; reg = <0x48>; interrupt-parent = <&gpio7>; interrupts = <12 IRQ_TYPE_LEVEL_LOW>; diff --git a/arch/arm/dts/imx53-guf-vincell.dts b/arch/arm/dts/imx53-guf-vincell.dts index 2f0153e..f743f17 100644 --- a/arch/arm/dts/imx53-guf-vincell.dts +++ b/arch/arm/dts/imx53-guf-vincell.dts @@ -102,7 +102,7 @@ status = "okay"; pmic: dialog@48 { /* DA9053-3HHA1 PMIC */ - compatible = "dialog,da9053-aa", "dialog,da9052"; + compatible = "dlg,da9053-aa", "dlg,da9052"; reg = <0x48>; interrupt-parent = <&gpio7>; interrupts = <12 IRQ_TYPE_LEVEL_LOW>; diff --git a/arch/arm/dts/socfpga.dtsi b/arch/arm/dts/socfpga.dtsi index 5b141c2..274c491 100644 --- a/arch/arm/dts/socfpga.dtsi +++ b/arch/arm/dts/socfpga.dtsi @@ -25,17 +25,6 @@ clock-names = "qspi_clk"; status = "disabled"; }; - - fpgamgr@ff706000 { - compatible = "altr,socfpga-fpga-mgr"; - reg = <0xff706000 0x1000>, - <0xffb90000 0x1000>; - }; - - system_mgr: sysmgr@ffd08000 { - compatible = "altr,sys-mgr", "syscon"; - reg = <0xffd08000 0x4000>; - }; }; }; &osc2 { diff --git a/arch/arm/mach-at91/bootstrap.c b/arch/arm/mach-at91/bootstrap.c index 8502bb0..9dd575b 100644 --- a/arch/arm/mach-at91/bootstrap.c +++ b/arch/arm/mach-at91/bootstrap.c @@ -155,7 +155,8 @@ struct menu_entry *me; m = menu_alloc(); - m->display = m->name = "boot"; + m->name = "boot"; + menu_add_title(m, m->name); menu_add(m); diff --git a/arch/arm/mach-omap/include/mach/am33xx-silicon.h b/arch/arm/mach-omap/include/mach/am33xx-silicon.h index e17e609..10595d5 100644 --- a/arch/arm/mach-omap/include/mach/am33xx-silicon.h +++ b/arch/arm/mach-omap/include/mach/am33xx-silicon.h @@ -71,6 +71,7 @@ #define AM33XX_PRM_RSTCTRL (AM33XX_PRM_BASE + 0x0f00) #define AM33XX_PRM_RSTCTRL_RESET 0x1 +#define AM33XX_PRM_RSTTIME (AM33XX_PRM_BASE + 0x0f04) #define AM33XX_PRM_RSTST (AM33XX_PRM_BASE + 0x0f08) /* CTRL */ diff --git a/arch/arm/mach-socfpga/Makefile b/arch/arm/mach-socfpga/Makefile index b81d57d..dea0e07 100644 --- a/arch/arm/mach-socfpga/Makefile +++ b/arch/arm/mach-socfpga/Makefile @@ -2,4 +2,3 @@ pbl-y += init.o freeze-controller.o scan-manager.o system-manager.o pbl-y += clock-manager.o obj-$(CONFIG_ARCH_SOCFPGA_XLOAD) += xload.o -obj-$(CONFIG_ARCH_SOCFPGA_FPGA) += fpga.o diff --git a/arch/arm/mach-socfpga/xload.c b/arch/arm/mach-socfpga/xload.c index 9936269..d24944b 100644 --- a/arch/arm/mach-socfpga/xload.c +++ b/arch/arm/mach-socfpga/xload.c @@ -28,7 +28,7 @@ }, { /* sentinel */ } }; -const struct socfpga_barebox_part *barebox_parts = &default_parts; +const struct socfpga_barebox_part *barebox_parts = default_parts; enum socfpga_clks { timer, mmc, qspi_clk, uart, clk_max @@ -111,7 +111,7 @@ static __noreturn int socfpga_xload(void) { enum bootsource bootsource = bootsource_get(); - struct socfpga_barebox_part *part; + const struct socfpga_barebox_part *part; void *buf = NULL; switch (bootsource) { diff --git a/arch/mips/include/asm/debug_ll_ns16550.h b/arch/mips/include/asm/debug_ll_ns16550.h index 4a6562f..058814e 100644 --- a/arch/mips/include/asm/debug_ll_ns16550.h +++ b/arch/mips/include/asm/debug_ll_ns16550.h @@ -128,38 +128,6 @@ .endm /* - * output a 32-bit value in hex - */ -.macro debug_ll_outhexw -#ifdef CONFIG_DEBUG_LL - .set push - .set reorder - - move t6, a0 - li t5, 32 - -202: - addi t5, t5, -4 - srlv a0, t6, t5 - - /* output one hex digit */ - andi a0, a0, 15 - blt a0, 10, 203f - - addi a0, a0, ('a' - '9' - 1) - -203: - addi a0, a0, '0' - - debug_ll_outc_a0 - - bgtz t5, 202b - - .set pop -#endif /* CONFIG_DEBUG_LL */ -.endm - -/* * check character in input buffer * return value: * v0 = 0 no character in input buffer diff --git a/arch/mips/include/asm/pbl_nmon.h b/arch/mips/include/asm/pbl_nmon.h index 90e2da8..e0326bd 100644 --- a/arch/mips/include/asm/pbl_nmon.h +++ b/arch/mips/include/asm/pbl_nmon.h @@ -43,6 +43,37 @@ .set pop .endm +/* + * output a 32-bit value in hex + */ +.macro debug_ll_outhexw +#ifdef CONFIG_DEBUG_LL + .set push + .set reorder + + move t6, a0 + li t5, 32 + +202: + addi t5, t5, -4 + srlv a0, t6, t5 + + /* output one hex digit */ + andi a0, a0, 15 + blt a0, 10, 203f + + addi a0, a0, ('a' - '9' - 1) + +203: + addi a0, a0, '0' + + debug_ll_outc_a0 + + bgtz t5, 202b + + .set pop +#endif /* CONFIG_DEBUG_LL */ +.endm .macro mips_nmon .set push diff --git a/arch/mips/mach-ath79/include/mach/debug_ll.h b/arch/mips/mach-ath79/include/mach/debug_ll.h index e0c3f79..04bd3ea 100644 --- a/arch/mips/mach-ath79/include/mach/debug_ll.h +++ b/arch/mips/mach-ath79/include/mach/debug_ll.h @@ -123,38 +123,6 @@ .endm /* - * output a 32-bit value in hex - */ -.macro debug_ll_outhexw -#ifdef CONFIG_DEBUG_LL - .set push - .set reorder - - move t6, a0 - li t5, 32 - -202: - addi t5, t5, -4 - srlv a0, t6, t5 - - /* output one hex digit */ - andi a0, a0, 15 - blt a0, 10, 203f - - addi a0, a0, ('a' - '9' - 1) - -203: - addi a0, a0, '0' - - debug_ll_outc_a0 - - bgtz t5, 202b - - .set pop -#endif /* CONFIG_DEBUG_LL */ -.endm - -/* * check character in input buffer * return value: * v0 = 0 no character in input buffer diff --git a/arch/nios2/Makefile b/arch/nios2/Makefile index 681944f..3e97155 100644 --- a/arch/nios2/Makefile +++ b/arch/nios2/Makefile @@ -7,7 +7,7 @@ archprepare: maketools @$(kecho) " SYMLINK include/nios_sopc.h -> arch/nios2/boards/$(board-y)/nios_sopc.h" - @ln -fsn ../arch/nios2/boards/$(board-y)/nios_sopc.h include/nios_sopc.h + @ln -fsn $(src)/arch/nios2/boards/$(board-y)/nios_sopc.h $(obj)/include/nios_sopc.h PHONY += maketools diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c index b2164af..77fde6b 100644 --- a/arch/nios2/cpu/cpu.c +++ b/arch/nios2/cpu/cpu.c @@ -33,7 +33,7 @@ static int restart_register_feature(void) { - restart_handler_register_fn(nios2_restart_soc); + return restart_handler_register_fn(nios2_restart_soc); } coredevice_initcall(restart_register_feature); diff --git a/commands/i2c.c b/commands/i2c.c index ae7f7fc..573032a 100644 --- a/commands/i2c.c +++ b/commands/i2c.c @@ -32,7 +32,7 @@ client.adapter = adapter; printf("probing i2c%d range 0x%02x-0x%02x: ", adapter->nr, startaddr, stopaddr); - for (addr = startaddr; addr <= stopaddr; addr++) { + for (addr = startaddr; addr <= stopaddr && !ctrlc(); addr++) { client.addr = addr; ret = i2c_write_reg(&client, 0x00, ®, 0); if (ret == 0) diff --git a/commands/memcmp.c b/commands/memcmp.c index ce044df..7be0033 100644 --- a/commands/memcmp.c +++ b/commands/memcmp.c @@ -130,8 +130,8 @@ } BAREBOX_CMD_HELP_START(memcmp) -BAREBOX_CMD_HELP_TEXT("Compare memory regions specified with ADDR and ADDR2") -BAREBOX_CMD_HELP_TEXT("of size COUNT bytes. If source is a file COUNT can") +BAREBOX_CMD_HELP_TEXT("Compare memory regions specified with ADDR1 and ADDR2") +BAREBOX_CMD_HELP_TEXT("of size COUNT bytes. If source is a file, COUNT can") BAREBOX_CMD_HELP_TEXT("be left unspecified, in which case the whole file is") BAREBOX_CMD_HELP_TEXT("compared.") BAREBOX_CMD_HELP_TEXT("") diff --git a/commands/menu.c b/commands/menu.c index 72db26e..ddc9c3a 100644 --- a/commands/menu.c +++ b/commands/menu.c @@ -147,7 +147,7 @@ if (!m->name) goto free; - menu_add_title(m, strdup(cm->description)); + menu_add_title(m, cm->description); ret = menu_add(m); diff --git a/common/boot.c b/common/boot.c index 123b874..4306319 100644 --- a/common/boot.c +++ b/common/boot.c @@ -44,7 +44,7 @@ if (IS_ENABLED(CONFIG_MENU)) { bootentries->menu = menu_alloc(); - menu_add_title(bootentries->menu, basprintf("boot")); + menu_add_title(bootentries->menu, "boot"); } return bootentries; diff --git a/common/environment.c b/common/environment.c index c9cef63..0edf34b 100644 --- a/common/environment.c +++ b/common/environment.c @@ -382,7 +382,7 @@ static int envfs_check_super(struct envfs_super *super, size_t *size) { if (ENVFS_32(super->magic) != ENVFS_MAGIC) { - printf("envfs: no envfs (magic mismatch) - envfs newer written?\n"); + printf("envfs: no envfs (magic mismatch) - envfs never written?\n"); return -EIO; } diff --git a/common/globalvar.c b/common/globalvar.c index e75cac9..52808f8 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -379,10 +379,10 @@ } } -int globalvar_simple_set(struct device_d *dev, struct param_d *p, const char *val) +static int globalvar_simple_set(struct device_d *dev, struct param_d *p, const char *val) { struct device_d *rdev; - const char *pname; + const char *pname = NULL; int ret; ret = nvvar_device_dispatch(p->name, &rdev, &pname); diff --git a/common/menu.c b/common/menu.c index 64df458..e757216 100644 --- a/common/menu.c +++ b/common/menu.c @@ -526,18 +526,17 @@ * @display: NULL or pointer to the string which will be freed in this function. * If NULL or zero length string is provided, default title will be added. */ -void menu_add_title(struct menu *m, char *display) +void menu_add_title(struct menu *m, const char *display) { char *tmp, *src, *dst; int lines = 1; int i; - if (!display || !strlen(display)) { - free(display); - display = xasprintf("Menu : %s", m->name ? m->name : ""); - } + if (!display || !strlen(display)) + src = dst = tmp = xasprintf("Menu : %s", m->name ? m->name : ""); + else + src = dst = tmp = xstrdup(display); - src = dst = tmp = xstrdup(display); /* Count lines and separate single string into multiple strings */ while (*src) { if (*src == '\\') { @@ -575,6 +574,5 @@ } free(tmp); - free(display); } EXPORT_SYMBOL(menu_add_title); diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index c31b337..b416105 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -207,7 +207,6 @@ { struct ahci_port *ahci = container_of(ata, struct ahci_port, ata); u8 fis[20]; - int ret; memset(fis, 0, sizeof(fis)); @@ -216,11 +215,7 @@ fis[1] = 1 << 7; /* Command FIS. */ fis[2] = ATA_CMD_ID_ATA; /* Command byte. */ - ret = ahci_io(ahci, fis, sizeof(fis), buf, NULL, SECTOR_SIZE); - if (ret) - return ret; - - return ret; + return ahci_io(ahci, fis, sizeof(fis), buf, NULL, SECTOR_SIZE); } static int ahci_rw(struct ata_port *ata, void *rbuf, const void *wbuf, diff --git a/drivers/ata/pata-imx.c b/drivers/ata/pata-imx.c index c8098a5..4f75048 100644 --- a/drivers/ata/pata-imx.c +++ b/drivers/ata/pata-imx.c @@ -158,7 +158,6 @@ struct clk *clk; void __iomem *base; int ret; - const char *devname = NULL; ide = xzalloc(sizeof(*ide)); iores = dev_request_mem_resource(dev, 0); @@ -182,14 +181,9 @@ pata_imx_set_bus_timing(base, clk_get_rate(clk), 4); - if (IS_ENABLED(CONFIG_OFDEVICE)) { - devname = of_alias_get(dev->device_node); - if (devname) - devname = xstrdup(devname); - } ide->port.dev = dev; - ide->port.devname = devname; + ide->port.devname = xstrdup(of_alias_get(dev->device_node)); dev->priv = ide; dev->detect = pata_imx_detect; diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index a042a1a..52b7d88 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -137,6 +137,33 @@ } /** + * regmap_write_bits - write bits of a register in a map + * + * @map: The map + * @reg: The register offset of the register + * @mask: Mask indicating bits to be modified + * (1 - modified, 0 - untouched) + * @val: Bit value to be set + * + * Returns 0 for success or negative error code on failure + */ +int regmap_write_bits(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val) +{ + int ret; + unsigned int tmp, orig; + + ret = regmap_read(map, reg, &orig); + if (ret != 0) + return ret; + + tmp = orig & ~mask; + tmp |= val & mask; + + return regmap_write(map, reg, tmp); +} + +/** * regmap_bulk_read(): Read data from the device * * @map: Register map to read from diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index ab919c9..078deee 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -121,6 +121,14 @@ help Say Y or M here to build support for the Synopsys DesignWare APB GPIO block. + +config GPIO_SX150X + bool "Semtec SX150x I/O ports" + depends on I2C + help + Say Y here to build support for the Semtec Sx150x I2C GPIO + expander chip. + endmenu endif diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 8767eed..2d5142d 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -18,3 +18,4 @@ obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o obj-$(CONFIG_GPIO_TEGRA) += gpio-tegra.o obj-$(CONFIG_GPIO_DESIGNWARE) += gpio-dw.o +obj-$(CONFIG_GPIO_SX150X) += gpio-sx150x.o diff --git a/drivers/gpio/gpio-74164.c b/drivers/gpio/gpio-74164.c index 926207a..e4d413b 100644 --- a/drivers/gpio/gpio-74164.c +++ b/drivers/gpio/gpio-74164.c @@ -92,6 +92,7 @@ static struct platform_device_id gpio_74164_ids[] = { { "74hc164" }, + { "74lvc594" }, { "74hc595" }, { } }; diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c new file mode 100644 index 0000000..7b8cfb5 --- /dev/null +++ b/drivers/gpio/gpio-sx150x.c @@ -0,0 +1,274 @@ +/* + * Driver for SX150x I2C GPIO expanders + * + * This code was ported from linux-4.9 kernel driver by + * Andrey Smirnov . + * + * Orginal code with it's copyright info can be found in + * drivers/pinctrl/pinctrl-sx150x.c + * + * Note: That although linux driver was converted from being a GPIO + * subsystem to Pinctrl subsytem driver, due to Barebox's lack of + * similar provisions this driver is still a GPIO driver. + * + * 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; version 2 of the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +enum { + SX150X_123 = 0, + SX150X_456, + SX150X_789, +}; + +enum { + SX150X_MAX_REGISTER = 0xad, +}; + +struct sx150x_device_data { + u8 model; + u8 reg_dir; + u8 reg_data; + u8 ngpios; +}; + +struct sx150x_gpio { + struct device *dev; + struct i2c_client *client; + struct gpio_chip gpio; + struct regmap *regmap; + const struct sx150x_device_data *data; +}; + +static const struct sx150x_device_data sx1503q_device_data = { + .model = SX150X_123, + .reg_dir = 0x02, + .reg_data = 0x00, + .ngpios = 16, +}; + +static struct sx150x_gpio *to_sx150x_gpio(struct gpio_chip *gpio) +{ + return container_of(gpio, struct sx150x_gpio, gpio); +} + +static int sx150x_gpio_get_direction(struct gpio_chip *gpio, + unsigned int offset) +{ + struct sx150x_gpio *sx150x = to_sx150x_gpio(gpio); + unsigned int value; + int ret; + + ret = regmap_read(sx150x->regmap, sx150x->data->reg_dir, &value); + if (ret < 0) + return ret; + + return !!(value & BIT(offset)); +} + +static int sx150x_gpio_get(struct gpio_chip *gpio, unsigned int offset) +{ + struct sx150x_gpio *sx150x = to_sx150x_gpio(gpio); + unsigned int value; + int ret; + + ret = regmap_read(sx150x->regmap, sx150x->data->reg_data, &value); + if (ret < 0) + return ret; + + return !!(value & BIT(offset)); +} + +static int __sx150x_gpio_set(struct sx150x_gpio *sx150x, unsigned int offset, + int value) +{ + return regmap_write_bits(sx150x->regmap, sx150x->data->reg_data, + BIT(offset), value ? BIT(offset) : 0); +} + + +static void sx150x_gpio_set(struct gpio_chip *gpio, unsigned int offset, + int value) +{ + __sx150x_gpio_set(to_sx150x_gpio(gpio), offset, value); +} + +static int sx150x_gpio_direction_input(struct gpio_chip *gpio, + unsigned int offset) +{ + struct sx150x_gpio *sx150x = to_sx150x_gpio(gpio); + + return regmap_write_bits(sx150x->regmap, + sx150x->data->reg_dir, + BIT(offset), BIT(offset)); +} + +static int sx150x_gpio_direction_output(struct gpio_chip *gpio, + unsigned int offset, int value) +{ + struct sx150x_gpio *sx150x = to_sx150x_gpio(gpio); + int ret; + + ret = __sx150x_gpio_set(sx150x, offset, value); + if (ret < 0) + return ret; + + return regmap_write_bits(sx150x->regmap, + sx150x->data->reg_dir, + BIT(offset), 0); +} + +static int sx150x_regmap_reg_width(struct sx150x_gpio *sx150x, + unsigned int reg) +{ + return sx150x->data->ngpios; +} + +/* + * In order to mask the differences between 16 and 8 bit expander + * devices we set up a sligthly ficticious regmap that pretends to be + * a set of 16-bit registers and transparently reconstructs those + * registers via multiple I2C/SMBus reads + * + * This way the rest of the driver code, interfacing with the chip via + * regmap API, can work assuming that each GPIO pin is represented by + * a group of bits at an offset proportioan to GPIO number within a + * given register. + * + */ +static int sx150x_regmap_reg_read(void *context, unsigned int reg, + unsigned int *result) +{ + int ret, n; + struct sx150x_gpio *sx150x = context; + struct i2c_client *i2c = sx150x->client; + const int width = sx150x_regmap_reg_width(sx150x, reg); + unsigned int idx, val; + + /* + * There are four potential cases coverd by this function: + * + * 1) 8-pin chip, single configuration bit register + * + * This is trivial the code below just needs to read: + * reg [ 7 6 5 4 3 2 1 0 ] + * + * 2) 16-pin chip, single configuration bit register + * + * The read will be done as follows: + * reg [ f e d c b a 9 8 ] + * reg + 1 [ 7 6 5 4 3 2 1 0 ] + * + */ + + for (n = width, val = 0, idx = reg; n > 0; n -= 8, idx++) { + val <<= 8; + + ret = i2c_smbus_read_byte_data(i2c, idx); + if (ret < 0) + return ret; + + val |= ret; + } + + *result = val; + + return 0; +} + +static int sx150x_regmap_reg_write(void *context, unsigned int reg, + unsigned int val) +{ + int ret, n; + struct sx150x_gpio *sx150x = context; + struct i2c_client *i2c = sx150x->client; + const int width = sx150x_regmap_reg_width(sx150x, reg); + + n = width - 8; + do { + const u8 byte = (val >> n) & 0xff; + + ret = i2c_smbus_write_byte_data(i2c, reg, byte); + if (ret < 0) + return ret; + + reg++; + n -= 8; + } while (n >= 0); + + return 0; +} + +static const struct regmap_config sx150x_regmap_config = { + .reg_bits = 8, + .val_bits = 16, + + .max_register = SX150X_MAX_REGISTER, +}; + +static const struct regmap_bus sx150x_regmap_bus = { + .reg_read = sx150x_regmap_reg_read, + .reg_write = sx150x_regmap_reg_write, +}; + +static struct gpio_ops sx150x_gpio_ops = { + .direction_input = sx150x_gpio_direction_input, + .direction_output = sx150x_gpio_direction_output, + .get_direction = sx150x_gpio_get_direction, + .get = sx150x_gpio_get, + .set = sx150x_gpio_set, +}; + +static int sx150x_probe(struct device_d *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sx150x_gpio *sx150x; + const struct sx150x_device_data *data; + + data = of_device_get_match_data(dev); + if (!data) + return -EINVAL; + + sx150x = xzalloc(sizeof(*sx150x)); + + sx150x->regmap = regmap_init(dev, &sx150x_regmap_bus, + sx150x, &sx150x_regmap_config); + sx150x->client = client; + sx150x->data = data; + sx150x->gpio.ops = &sx150x_gpio_ops; + sx150x->gpio.base = -1; + sx150x->gpio.ngpio = sx150x->data->ngpios; + sx150x->gpio.dev = &client->dev; + + return gpiochip_add(&sx150x->gpio); +} + +static __maybe_unused struct of_device_id sx150x_dt_ids[] = { + { .compatible = "semtech,sx1503q", .data = &sx1503q_device_data, }, + { } +}; + +static struct driver_d sx150x_driver = { + .name = "sx150x", + .probe = sx150x_probe, + .of_compatible = sx150x_dt_ids, +}; + +static int __init sx150x_init(void) +{ + return i2c_driver_register(&sx150x_driver); +} +device_initcall(sx150x_init); diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index baeae7b..0d5515b 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -45,6 +45,8 @@ #include #include #include +#include +#include #define PCA954X_MAX_NCHANS 8 @@ -179,6 +181,7 @@ int num, force; struct pca954x *data; int ret = -ENODEV; + int gpio; data = kzalloc(sizeof(struct pca954x), GFP_KERNEL); if (!data) { @@ -188,6 +191,10 @@ i2c_set_clientdata(client, data); + gpio = of_get_named_gpio(dev->device_node, "reset-gpios", 0); + if (gpio_is_valid(gpio)) + gpio_direction_output(gpio, 1); + /* Read the mux register at addr to verify * that the mux is in fact present. */ diff --git a/drivers/input/input.c b/drivers/input/input.c index 31a9c22..14e44d1 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -43,9 +43,9 @@ return; if (value) - set_bit(code, &idev->keys); + set_bit(code, idev->keys); else - clear_bit(code, &idev->keys); + clear_bit(code, idev->keys); event.code = code; event.value = value; diff --git a/drivers/mci/omap_hsmmc.c b/drivers/mci/omap_hsmmc.c index 180afb1..cbc69e4 100644 --- a/drivers/mci/omap_hsmmc.c +++ b/drivers/mci/omap_hsmmc.c @@ -631,6 +631,8 @@ hsmmc->mci.devname = xstrdup(alias); } + mci_of_parse(&hsmmc->mci); + dev->priv = hsmmc; dev->detect = omap_mmc_detect, diff --git a/drivers/mfd/da9053.c b/drivers/mfd/da9053.c index 250c055..9adab8c 100644 --- a/drivers/mfd/da9053.c +++ b/drivers/mfd/da9053.c @@ -240,6 +240,10 @@ priority = of_get_reset_source_priority(da9053->dev->device_node); reset_source_set_priority(type, priority); + + ret = da9053_reg_write(da9053, DA9053_FAULTLOG_REG, val); + if (ret < 0) + return; } static void __noreturn da9053_force_system_reset(struct restart_handler *rst) @@ -293,9 +297,18 @@ return 0; } +static __maybe_unused struct of_device_id da9053_dt_ids[] = { + { + .compatible = "dlg,da9052", + }, { + /* sentinel */ + } +}; + static struct driver_d da9053_driver = { .name = DRIVERNAME, .probe = da9053_probe, + .of_compatible = DRV_OF_COMPAT(da9053_dt_ids), }; static int da9053_init(void) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 656a7f5..8a67792 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -179,7 +179,7 @@ {"en25f32"}, {"en25p32"}, {"en25q32b"}, {"en25p64"}, {"en25q64"}, {"en25qh128"}, {"en25qh256"}, {"f25l32pa"}, - {"mr25h256"}, {"mr25h10"}, + {"mr25h256"}, {"mr25h10"}, {"mr25h40"}, {"gd25q32"}, {"gd25q64"}, {"160s33b"}, {"320s33b"}, {"640s33b"}, {"mx25l2005a"}, {"mx25l4005a"}, {"mx25l8005"}, {"mx25l1606e"}, diff --git a/drivers/mtd/peb.c b/drivers/mtd/peb.c index 639dc0e..66227d4 100644 --- a/drivers/mtd/peb.c +++ b/drivers/mtd/peb.c @@ -252,7 +252,6 @@ int mtd_peb_check_all_ff(struct mtd_info *mtd, int pnum, int offset, int len, int warn) { - size_t read; int err; void *buf; @@ -263,8 +262,8 @@ err = mtd_peb_read(mtd, buf, pnum, offset, len); if (err && !mtd_is_bitflip(err)) { dev_err(&mtd->class_dev, - "error %d while reading %d bytes from PEB %d:%d, read %zd bytes\n", - err, len, pnum, offset, read); + "error %d while reading %d bytes from PEB %d:%d\n", + err, len, pnum, offset); goto out; } @@ -398,7 +397,7 @@ addr = (loff_t)pnum * mtd->erasesize + offset; err = mtd_write(mtd, addr, len, &written, buf); if (err) { - dev_err(&mtd->class_dev, "error %d while writing %d bytes to PEB %d:%d, written %zd bytes\n", + dev_err(&mtd->class_dev, "error %d while writing %d bytes to PEB %d:%d, written %zu bytes\n", err, len, pnum, offset, written); } else { if (written != len) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 45be586..faeafe1 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -504,6 +504,7 @@ /* Everspin */ { "mr25h256", CAT25_INFO( 32 * 1024, 1, 256, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) }, { "mr25h10", CAT25_INFO(128 * 1024, 1, 256, 3, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) }, + { "mr25h40", CAT25_INFO(512 * 1024, 1, 256, 3, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) }, /* Fujitsu */ { "mb85rs1mt", INFO(0x047f27, 0, 128 * 1024, 1, SPI_NOR_NO_ERASE) }, diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index 43af4a5..6d08f92 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c @@ -711,7 +711,7 @@ p = (char *)vid_hdr - ubi->vid_hdr_shift; read_err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, - ubi->vid_hdr_alsize); + ubi->vid_hdr_shift + UBI_VID_HDR_SIZE); if (read_err && read_err != UBI_IO_BITFLIPS && !mtd_is_eccerr(read_err)) return read_err; diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 3f848a4..c9157cd 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -271,7 +271,7 @@ /* Allow the HW Peripheral ID to be overridden */ of_property_read_u32(np, "arm,primecell-periphid", &dev->periphid); - debug("register device 0x%08x\n", dev->dev.resource[0].start); + debug("register device %pa\n", &dev->dev.resource[0].start); ret = amba_device_add(dev); if (ret) diff --git a/include/menu.h b/include/menu.h index 3e704a8..2fef064 100644 --- a/include/menu.h +++ b/include/menu.h @@ -91,7 +91,7 @@ int menu_set_selected(struct menu *m, int num); int menu_set_auto_select(struct menu *m, int delay); struct menu* menu_get_menus(void); -void menu_add_title(struct menu *m, char *display); +void menu_add_title(struct menu *m, const char *display); /* * menu entry functions diff --git a/include/regmap.h b/include/regmap.h index bcbe6c1..9675a17 100644 --- a/include/regmap.h +++ b/include/regmap.h @@ -60,4 +60,8 @@ int regmap_get_max_register(struct regmap *map); int regmap_get_reg_stride(struct regmap *map); -#endif /* __REGMAP_H */ \ No newline at end of file +int regmap_write_bits(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val); + + +#endif /* __REGMAP_H */ diff --git a/lib/int_sqrt.c b/lib/int_sqrt.c index 30ccafb..bf8b18f 100644 --- a/lib/int_sqrt.c +++ b/lib/int_sqrt.c @@ -15,6 +15,7 @@ */ #include +#include /** * int_sqrt - rough approximation to sqrt