Merge branch '2021-10-19-assorted-changes'
- Assorted minor fixes and a new GPIO driver
This commit is contained in:
commit
fb1018106a
@ -756,6 +756,7 @@ F: include/fdt*
|
||||
F: include/linux/libfdt*
|
||||
F: cmd/fdt.c
|
||||
F: common/fdt_support.c
|
||||
F: scripts/dtc-version.sh
|
||||
|
||||
FREEBSD
|
||||
M: Rafal Jaworowski <raj@semihalf.com>
|
||||
|
32
Makefile
32
Makefile
@ -299,9 +299,7 @@ KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
|
||||
# have older compilers as their default, so we make it explicit for
|
||||
# these that our host tools are GNU11 (i.e. C11 w/ GNU extensions).
|
||||
CSTD_FLAG := -std=gnu11
|
||||
ifeq ($(HOSTOS),linux)
|
||||
KBUILD_HOSTCFLAGS += $(CSTD_FLAG)
|
||||
endif
|
||||
|
||||
ifeq ($(HOSTOS),cygwin)
|
||||
KBUILD_HOSTCFLAGS += -ansi
|
||||
@ -415,7 +413,13 @@ PERL = perl
|
||||
PYTHON ?= python
|
||||
PYTHON2 = python2
|
||||
PYTHON3 ?= python3
|
||||
DTC ?= $(objtree)/scripts/dtc/dtc
|
||||
|
||||
# The devicetree compiler and pylibfdt are automatically built unless DTC is
|
||||
# provided. If DTC is provided, it is assumed the pylibfdt is available too.
|
||||
DTC_INTREE := $(objtree)/scripts/dtc/dtc
|
||||
DTC ?= $(DTC_INTREE)
|
||||
DTC_MIN_VERSION := 010406
|
||||
|
||||
CHECK = sparse
|
||||
|
||||
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
|
||||
@ -1954,9 +1958,29 @@ endif
|
||||
|
||||
endif
|
||||
|
||||
# Check dtc and pylibfdt, if DTC is provided, else build them
|
||||
PHONY += scripts_dtc
|
||||
scripts_dtc: scripts_basic
|
||||
$(Q)$(MAKE) $(build)=scripts/dtc
|
||||
$(Q)if test "$(DTC)" = "$(DTC_INTREE)"; then \
|
||||
$(MAKE) $(build)=scripts/dtc; \
|
||||
else \
|
||||
if ! $(DTC) -v >/dev/null; then \
|
||||
echo '*** Failed to check dtc version: $(DTC)'; \
|
||||
false; \
|
||||
else \
|
||||
if test "$(call dtc-version)" -lt $(DTC_MIN_VERSION); then \
|
||||
echo '*** Your dtc is too old, please upgrade to dtc $(DTC_MIN_VERSION) or newer'; \
|
||||
false; \
|
||||
else \
|
||||
if [ -n "$(CONFIG_PYLIBFDT)" ]; then \
|
||||
if ! echo "import libfdt" | $(PYTHON3) 2>/dev/null; then \
|
||||
echo '*** pylibfdt does not seem to be available with $(PYTHON3)'; \
|
||||
false; \
|
||||
fi; \
|
||||
fi; \
|
||||
fi; \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
quiet_cmd_cpp_lds = LDS $@
|
||||
|
@ -59,6 +59,9 @@ int dram_init_banksize(void)
|
||||
gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
|
||||
gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
|
||||
|
||||
gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
|
||||
gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@ CONFIG_BOOTP_SEND_HOSTNAME=y
|
||||
CONFIG_BOOTCOUNT_LIMIT=y
|
||||
CONFIG_CLK=y
|
||||
CONFIG_CLK_CDCE9XX=y
|
||||
CONFIG_CLK_TI_CTRL=y
|
||||
CONFIG_DFU_TFTP=y
|
||||
CONFIG_DFU_MMC=y
|
||||
CONFIG_DFU_NAND=y
|
||||
|
21
doc/build/gcc.rst
vendored
21
doc/build/gcc.rst
vendored
@ -120,6 +120,27 @@ Further important build parameters are
|
||||
* O=<dir> - generate all output files in directory <dir>, including .config
|
||||
* V=1 - verbose build
|
||||
|
||||
Devicetree compiler
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Boards that use `CONFIG_OF_CONTROL` (i.e. almost all of them) need the
|
||||
devicetree compiler (dtc). Those with `CONFIG_PYLIBFDT` need pylibfdt, a Python
|
||||
library for accessing devicetree data. Suitable versions of these are included
|
||||
in the U-Boot tree in `scripts/dtc` and built automatically as needed.
|
||||
|
||||
To use the system versions of these, use the DTC parameter, for example
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
DTC=/usr/bin/dtc make
|
||||
|
||||
In this case, dtc and pylibfdt are not built. The build checks that the version
|
||||
of dtc is new enough. It also makes sure that pylibfdt is present, if needed
|
||||
(see `scripts_dtc` in the Makefile).
|
||||
|
||||
Note that the :doc:`tools` are always built with the included version of libfdt
|
||||
so it is not possible to build U-Boot tools with a system libfdt, at present.
|
||||
|
||||
Other build targets
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
36
doc/device-tree-bindings/gpio/gpio-max7320.txt
Normal file
36
doc/device-tree-bindings/gpio/gpio-max7320.txt
Normal file
@ -0,0 +1,36 @@
|
||||
* MAX7320 I/O expanders
|
||||
|
||||
The original maxim 7320 i/o expander offers 8 bit push/pull outputs.
|
||||
There exists some clones which offers 16 bit.
|
||||
|
||||
Required Properties:
|
||||
|
||||
- compatible: should be one of the following.
|
||||
- "maxim,max7320"
|
||||
|
||||
- reg: I2C slave address.
|
||||
|
||||
- gpio-controller: Marks the device node as a gpio controller.
|
||||
- #gpio-cells: Should be 2. The first cell is the GPIO number and the second
|
||||
cell specifies GPIO flags, as defined in <dt-bindings/gpio/gpio.h>. Only the
|
||||
GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW flags are supported.
|
||||
|
||||
Optional Properties:
|
||||
|
||||
- ngpios: tell the driver how many gpios the device offers.
|
||||
if the property is omitted, 8bit (original maxim) is assumed.
|
||||
|
||||
Please refer to gpio.txt in this directory for details of the common GPIO
|
||||
bindings used by client devices.
|
||||
|
||||
Example: MAX7320 I/O expander node
|
||||
|
||||
ledgpio: max7320@5d {
|
||||
status = "okay";
|
||||
compatible = "maxim,max7320";
|
||||
reg = <0x5d>;
|
||||
#gpio-cells = <2>;
|
||||
gpio-controller;
|
||||
ngpios = <16>;
|
||||
};
|
||||
|
@ -26,6 +26,7 @@ static int dummy_enable(struct clk *clk)
|
||||
const struct clk_ops clk_fixed_rate_ops = {
|
||||
.get_rate = clk_fixed_rate_get_rate,
|
||||
.enable = dummy_enable,
|
||||
.disable = dummy_enable,
|
||||
};
|
||||
|
||||
void clk_fixed_rate_ofdata_to_plat_(struct udevice *dev,
|
||||
|
@ -183,6 +183,14 @@ config LPC32XX_GPIO
|
||||
help
|
||||
Support for the LPC32XX GPIO driver.
|
||||
|
||||
config MAX7320_GPIO
|
||||
bool "MAX7320 I2C GPIO Expander driver"
|
||||
depends on DM_GPIO && DM_I2C
|
||||
help
|
||||
Support for MAX7320 I2C 8/16-bit GPIO expander.
|
||||
original maxim device has 8 push/pull outputs,
|
||||
some clones offers 16bit.
|
||||
|
||||
config MCP230XX_GPIO
|
||||
bool "MCP230XX GPIO driver"
|
||||
depends on DM
|
||||
|
@ -68,3 +68,4 @@ obj-$(CONFIG_MSCC_SGPIO) += mscc_sgpio.o
|
||||
obj-$(CONFIG_NX_GPIO) += nx_gpio.o
|
||||
obj-$(CONFIG_SIFIVE_GPIO) += sifive-gpio.o
|
||||
obj-$(CONFIG_NOMADIK_GPIO) += nmk_gpio.o
|
||||
obj-$(CONFIG_MAX7320_GPIO) += max7320_gpio.o
|
||||
|
113
drivers/gpio/max7320_gpio.c
Normal file
113
drivers/gpio/max7320_gpio.c
Normal file
@ -0,0 +1,113 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* max7320 I2C GPIO EXPANDER DRIVER
|
||||
*
|
||||
* Copyright (C) 2021 Hannes Schmelzer <oe5hpm@oevsv.at>
|
||||
* B&R Industrial Automation GmbH - http://www.br-automation.com
|
||||
*
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <i2c.h>
|
||||
#include <asm-generic/gpio.h>
|
||||
#include <linux/bitops.h>
|
||||
|
||||
struct max7320_chip {
|
||||
u32 outreg;
|
||||
};
|
||||
|
||||
static int max7320_direction_output(struct udevice *dev,
|
||||
unsigned int offset, int value)
|
||||
{
|
||||
struct max7320_chip *plat = dev_get_plat(dev);
|
||||
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
|
||||
struct dm_i2c_chip *chip = dev_get_parent_plat(dev);
|
||||
|
||||
int ret;
|
||||
|
||||
if (value)
|
||||
plat->outreg |= BIT(offset);
|
||||
else
|
||||
plat->outreg &= ~BIT(offset);
|
||||
|
||||
ret = dm_i2c_write(dev,
|
||||
plat->outreg & 0xff,
|
||||
(uint8_t *)&plat->outreg + 1,
|
||||
uc_priv->gpio_count > 8 ? 1 : 0);
|
||||
if (ret)
|
||||
printf("%s i2c write failed to addr %x\n", __func__,
|
||||
chip->chip_addr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int max7320_get_value(struct udevice *dev, unsigned int offset)
|
||||
{
|
||||
struct max7320_chip *plat = dev_get_plat(dev);
|
||||
|
||||
return (plat->outreg >> offset) & 0x1;
|
||||
}
|
||||
|
||||
static int max7320_set_value(struct udevice *dev, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
return max7320_direction_output(dev, offset, value);
|
||||
}
|
||||
|
||||
static int max7320_get_function(struct udevice *dev, unsigned int offset)
|
||||
{
|
||||
return GPIOF_OUTPUT;
|
||||
}
|
||||
|
||||
static int max7320_ofdata_plat(struct udevice *dev)
|
||||
{
|
||||
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
|
||||
|
||||
uc_priv->gpio_count = dev_read_u32_default(dev, "ngpios", 8);
|
||||
if (uc_priv->gpio_count > 16) {
|
||||
printf("%s: max7320 doesn't support more than 16 gpios!",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
|
||||
"gpio-bank-name", NULL);
|
||||
if (!uc_priv->bank_name)
|
||||
uc_priv->bank_name = fdt_get_name(gd->fdt_blob,
|
||||
dev_of_offset(dev), NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int max7320_gpio_probe(struct udevice *dev)
|
||||
{
|
||||
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
|
||||
|
||||
debug("%s GPIO controller with %d gpios probed\n",
|
||||
uc_priv->bank_name, uc_priv->gpio_count);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct dm_gpio_ops max7320_gpio_ops = {
|
||||
.direction_output = max7320_direction_output,
|
||||
.set_value = max7320_set_value,
|
||||
.get_value = max7320_get_value,
|
||||
.get_function = max7320_get_function,
|
||||
};
|
||||
|
||||
static const struct udevice_id max7320_gpio_ids[] = {
|
||||
{ .compatible = "maxim,max7320" },
|
||||
{ }
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(gpio_max7320) = {
|
||||
.name = "gpio_max7320",
|
||||
.id = UCLASS_GPIO,
|
||||
.ops = &max7320_gpio_ops,
|
||||
.of_match = max7320_gpio_ids,
|
||||
.of_to_plat = max7320_ofdata_plat,
|
||||
.probe = max7320_gpio_probe,
|
||||
.plat_auto = sizeof(struct max7320_chip),
|
||||
};
|
@ -5,9 +5,6 @@
|
||||
config SUPPORT_OF_CONTROL
|
||||
bool
|
||||
|
||||
config DTC
|
||||
bool
|
||||
|
||||
config PYLIBFDT
|
||||
bool
|
||||
|
||||
@ -42,7 +39,6 @@ menu "Device Tree Control"
|
||||
|
||||
config OF_CONTROL
|
||||
bool "Run-time configuration via Device Tree"
|
||||
select DTC
|
||||
select OF_LIBFDT if !OF_PLATDATA
|
||||
select OF_REAL if !OF_PLATDATA
|
||||
help
|
||||
|
@ -30,6 +30,9 @@
|
||||
#define PHYS_SDRAM_1_SIZE 0x80000000 - DRAM_SEC_SIZE
|
||||
#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
|
||||
|
||||
#define PHYS_SDRAM_2 0x8080000000
|
||||
#define PHYS_SDRAM_2_SIZE 0x180000000
|
||||
|
||||
#define CONFIG_SYS_MMC_MAX_BLK_COUNT 127
|
||||
|
||||
#define CONFIG_EXTRA_ENV_SETTINGS \
|
||||
|
@ -148,6 +148,7 @@ cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4))
|
||||
|
||||
# added for U-Boot
|
||||
binutils-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/binutils-version.sh $(AS))
|
||||
dtc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/dtc-version.sh $(DTC))
|
||||
|
||||
# cc-ldoption
|
||||
# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
|
||||
|
@ -10,4 +10,3 @@ always := $(hostprogs-y)
|
||||
|
||||
# Let clean descend into subdirs
|
||||
subdir- += basic kconfig
|
||||
subdir-$(CONFIG_DTC) += dtc
|
||||
|
27
scripts/dtc-version.sh
Executable file
27
scripts/dtc-version.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
# dtc-version dtc-command
|
||||
#
|
||||
# Prints the dtc version of `dtc-command' in a canonical 6-digit form
|
||||
# such as `010404' for dtc 1.4.4
|
||||
#
|
||||
|
||||
dtc="$*"
|
||||
|
||||
if [ ${#dtc} -eq 0 ]; then
|
||||
echo "Error: No dtc command specified"
|
||||
printf "Usage:\n\t$0 <dtc-command>\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! which $dtc >/dev/null ; then
|
||||
echo "Error: Cannot find dtc: $dtc"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MAJOR=$($dtc -v | head -1 | awk '{print $NF}' | cut -d . -f 1)
|
||||
MINOR=$($dtc -v | head -1 | awk '{print $NF}' | cut -d . -f 2)
|
||||
PATCH=$($dtc -v | head -1 | awk '{print $NF}' | cut -d . -f 3 | cut -d - -f 1)
|
||||
|
||||
printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCH
|
@ -295,8 +295,7 @@ HOST_EXTRACFLAGS += -include $(srctree)/include/compiler.h \
|
||||
-I$(srctree)/tools \
|
||||
-DUSE_HOSTCC \
|
||||
-D__KERNEL_STRICT_NAMES \
|
||||
-D_GNU_SOURCE \
|
||||
-std=gnu99
|
||||
-D_GNU_SOURCE
|
||||
|
||||
__build: $(LOGO-y)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user