Merge branch 'next'

Bring in the assorted changes that have been staged in the 'next' branch
prior to release.

Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
Tom Rini
2020-10-05 13:05:46 -04:00
864 changed files with 47418 additions and 11313 deletions

View File

@@ -6,6 +6,8 @@
#include <common.h>
#include <dm.h>
#include <log.h>
#include <dm/devres.h>
#include <dm/device_compat.h>
#include <dm/device-internal.h>
#include <dm/lists.h>
#include <dm/uclass-internal.h>
@@ -1209,6 +1211,75 @@ int gpio_dev_request_index(struct udevice *dev, const char *nodename,
flags, 0, dev);
}
static void devm_gpiod_release(struct udevice *dev, void *res)
{
dm_gpio_free(dev, res);
}
static int devm_gpiod_match(struct udevice *dev, void *res, void *data)
{
return res == data;
}
struct gpio_desc *devm_gpiod_get_index(struct udevice *dev, const char *id,
unsigned int index, int flags)
{
int rc;
struct gpio_desc *desc;
char *propname;
static const char suffix[] = "-gpios";
propname = malloc(strlen(id) + sizeof(suffix));
if (!propname) {
rc = -ENOMEM;
goto end;
}
strcpy(propname, id);
strcat(propname, suffix);
desc = devres_alloc(devm_gpiod_release, sizeof(struct gpio_desc),
__GFP_ZERO);
if (unlikely(!desc)) {
rc = -ENOMEM;
goto end;
}
rc = gpio_request_by_name(dev, propname, index, desc, flags);
end:
if (propname)
free(propname);
if (rc)
return ERR_PTR(rc);
devres_add(dev, desc);
return desc;
}
struct gpio_desc *devm_gpiod_get_index_optional(struct udevice *dev,
const char *id,
unsigned int index,
int flags)
{
struct gpio_desc *desc = devm_gpiod_get_index(dev, id, index, flags);
if (IS_ERR(desc))
return NULL;
return desc;
}
void devm_gpiod_put(struct udevice *dev, struct gpio_desc *desc)
{
int rc;
rc = devres_release(dev, devm_gpiod_release, devm_gpiod_match, desc);
WARN_ON(rc);
}
static int gpio_post_bind(struct udevice *dev)
{
struct udevice *child;

View File

@@ -273,9 +273,12 @@ static const struct dm_gpio_ops gpio_stm32_ops = {
static int gpio_stm32_probe(struct udevice *dev)
{
struct stm32_gpio_priv *priv = dev_get_priv(dev);
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
struct ofnode_phandle_args args;
const char *name;
struct clk clk;
fdt_addr_t addr;
int ret;
int ret, i;
addr = dev_read_addr(dev);
if (addr == FDT_ADDR_T_NONE)
@@ -283,11 +286,6 @@ static int gpio_stm32_probe(struct udevice *dev)
priv->regs = (struct stm32_gpio_regs *)addr;
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
struct ofnode_phandle_args args;
const char *name;
int i;
name = dev_read_string(dev, "st,bank-name");
if (!name)
return -EINVAL;
@@ -297,6 +295,9 @@ static int gpio_stm32_probe(struct udevice *dev)
ret = dev_read_phandle_with_args(dev, "gpio-ranges",
NULL, 3, i, &args);
if (!ret && args.args_count < 3)
return -EINVAL;
if (ret == -ENOENT) {
uc_priv->gpio_count = STM32_GPIOS_PER_BANK;
priv->gpio_range = GENMASK(STM32_GPIOS_PER_BANK - 1, 0);
@@ -310,6 +311,8 @@ static int gpio_stm32_probe(struct udevice *dev)
ret = dev_read_phandle_with_args(dev, "gpio-ranges", NULL, 3,
++i, &args);
if (!ret && args.args_count < 3)
return -EINVAL;
}
dev_dbg(dev, "addr = 0x%p bank_name = %s gpio_count = %d gpio_range = 0x%x\n",