mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 08:42:12 +02:00
Merge git://git.denx.de/u-boot-dm
This commit is contained in:
@@ -319,6 +319,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
|
|||||||
DIR *dir;
|
DIR *dir;
|
||||||
int ret;
|
int ret;
|
||||||
char *fname;
|
char *fname;
|
||||||
|
char *old_fname;
|
||||||
int len;
|
int len;
|
||||||
int dirlen;
|
int dirlen;
|
||||||
|
|
||||||
@@ -344,16 +345,23 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
next = malloc(sizeof(*node) + strlen(entry->d_name) + 1);
|
next = malloc(sizeof(*node) + strlen(entry->d_name) + 1);
|
||||||
|
if (!next) {
|
||||||
|
os_dirent_free(head);
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
if (dirlen + strlen(entry->d_name) > len) {
|
if (dirlen + strlen(entry->d_name) > len) {
|
||||||
len = dirlen + strlen(entry->d_name);
|
len = dirlen + strlen(entry->d_name);
|
||||||
|
old_fname = fname;
|
||||||
fname = realloc(fname, len);
|
fname = realloc(fname, len);
|
||||||
}
|
if (!fname) {
|
||||||
if (!next || !fname) {
|
free(old_fname);
|
||||||
free(next);
|
free(next);
|
||||||
os_dirent_free(head);
|
os_dirent_free(head);
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
next->next = NULL;
|
next->next = NULL;
|
||||||
strcpy(next->name, entry->d_name);
|
strcpy(next->name, entry->d_name);
|
||||||
switch (entry->d_type) {
|
switch (entry->d_type) {
|
||||||
|
@@ -254,6 +254,7 @@ static void *alloc_priv(int size, uint flags)
|
|||||||
void *priv;
|
void *priv;
|
||||||
|
|
||||||
if (flags & DM_FLAG_ALLOC_PRIV_DMA) {
|
if (flags & DM_FLAG_ALLOC_PRIV_DMA) {
|
||||||
|
size = ROUND(size, ARCH_DMA_MINALIGN);
|
||||||
priv = memalign(ARCH_DMA_MINALIGN, size);
|
priv = memalign(ARCH_DMA_MINALIGN, size);
|
||||||
if (priv) {
|
if (priv) {
|
||||||
memset(priv, '\0', size);
|
memset(priv, '\0', size);
|
||||||
|
@@ -468,8 +468,10 @@ fdt_addr_t ofnode_get_addr_size(ofnode node, const char *property,
|
|||||||
int na, ns;
|
int na, ns;
|
||||||
int psize;
|
int psize;
|
||||||
const struct device_node *np = ofnode_to_np(node);
|
const struct device_node *np = ofnode_to_np(node);
|
||||||
const __be32 *prop = of_get_property(np, "reg", &psize);
|
const __be32 *prop = of_get_property(np, property, &psize);
|
||||||
|
|
||||||
|
if (!prop)
|
||||||
|
return FDT_ADDR_T_NONE;
|
||||||
na = of_n_addr_cells(np);
|
na = of_n_addr_cells(np);
|
||||||
ns = of_n_addr_cells(np);
|
ns = of_n_addr_cells(np);
|
||||||
*sizep = of_read_number(prop + na, ns);
|
*sizep = of_read_number(prop + na, ns);
|
||||||
|
@@ -138,7 +138,7 @@ int peripheral_request(unsigned short per, const char *label)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(per & P_DEFINED))
|
if (!(per & P_DEFINED))
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
BUG_ON(ident >= MAX_RESOURCES);
|
BUG_ON(ident >= MAX_RESOURCES);
|
||||||
|
|
||||||
|
@@ -50,11 +50,11 @@ static int atmel_pio4_config_io_func(u32 port, u32 pin,
|
|||||||
u32 reg, mask;
|
u32 reg, mask;
|
||||||
|
|
||||||
if (pin >= ATMEL_PIO_NPINS_PER_BANK)
|
if (pin >= ATMEL_PIO_NPINS_PER_BANK)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
port_base = atmel_pio4_port_base(port);
|
port_base = atmel_pio4_port_base(port);
|
||||||
if (!port_base)
|
if (!port_base)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
mask = 1 << pin;
|
mask = 1 << pin;
|
||||||
reg = func;
|
reg = func;
|
||||||
@@ -128,11 +128,11 @@ int atmel_pio4_set_pio_output(u32 port, u32 pin, u32 value)
|
|||||||
u32 reg, mask;
|
u32 reg, mask;
|
||||||
|
|
||||||
if (pin >= ATMEL_PIO_NPINS_PER_BANK)
|
if (pin >= ATMEL_PIO_NPINS_PER_BANK)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
port_base = atmel_pio4_port_base(port);
|
port_base = atmel_pio4_port_base(port);
|
||||||
if (!port_base)
|
if (!port_base)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
mask = 0x01 << pin;
|
mask = 0x01 << pin;
|
||||||
reg = ATMEL_PIO_CFGR_FUNC_GPIO | ATMEL_PIO_DIR_MASK;
|
reg = ATMEL_PIO_CFGR_FUNC_GPIO | ATMEL_PIO_DIR_MASK;
|
||||||
@@ -154,11 +154,11 @@ int atmel_pio4_get_pio_input(u32 port, u32 pin)
|
|||||||
u32 reg, mask;
|
u32 reg, mask;
|
||||||
|
|
||||||
if (pin >= ATMEL_PIO_NPINS_PER_BANK)
|
if (pin >= ATMEL_PIO_NPINS_PER_BANK)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
port_base = atmel_pio4_port_base(port);
|
port_base = atmel_pio4_port_base(port);
|
||||||
if (!port_base)
|
if (!port_base)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
mask = 0x01 << pin;
|
mask = 0x01 << pin;
|
||||||
reg = ATMEL_PIO_CFGR_FUNC_GPIO;
|
reg = ATMEL_PIO_CFGR_FUNC_GPIO;
|
||||||
|
@@ -168,13 +168,18 @@ static int imx_rgpio2p_bind(struct udevice *dev)
|
|||||||
|
|
||||||
addr = devfdt_get_addr_index(dev, 1);
|
addr = devfdt_get_addr_index(dev, 1);
|
||||||
if (addr == FDT_ADDR_T_NONE)
|
if (addr == FDT_ADDR_T_NONE)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO:
|
* TODO:
|
||||||
* When every board is converted to driver model and DT is supported,
|
* When every board is converted to driver model and DT is supported,
|
||||||
* this can be done by auto-alloc feature, but not using calloc
|
* this can be done by auto-alloc feature, but not using calloc
|
||||||
* to alloc memory for platdata.
|
* to alloc memory for platdata.
|
||||||
|
*
|
||||||
|
* For example imx_rgpio2p_plat uses platform data rather than device
|
||||||
|
* tree.
|
||||||
|
*
|
||||||
|
* NOTE: DO NOT COPY this code if you are using device tree.
|
||||||
*/
|
*/
|
||||||
plat = calloc(1, sizeof(*plat));
|
plat = calloc(1, sizeof(*plat));
|
||||||
if (!plat)
|
if (!plat)
|
||||||
|
@@ -304,13 +304,18 @@ static int mxc_gpio_bind(struct udevice *dev)
|
|||||||
|
|
||||||
addr = devfdt_get_addr(dev);
|
addr = devfdt_get_addr(dev);
|
||||||
if (addr == FDT_ADDR_T_NONE)
|
if (addr == FDT_ADDR_T_NONE)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO:
|
* TODO:
|
||||||
* When every board is converted to driver model and DT is supported,
|
* When every board is converted to driver model and DT is supported,
|
||||||
* this can be done by auto-alloc feature, but not using calloc
|
* this can be done by auto-alloc feature, but not using calloc
|
||||||
* to alloc memory for platdata.
|
* to alloc memory for platdata.
|
||||||
|
*
|
||||||
|
* For example mxc_plat below uses platform data rather than device
|
||||||
|
* tree.
|
||||||
|
*
|
||||||
|
* NOTE: DO NOT COPY this code if you are using device tree.
|
||||||
*/
|
*/
|
||||||
plat = calloc(1, sizeof(*plat));
|
plat = calloc(1, sizeof(*plat));
|
||||||
if (!plat)
|
if (!plat)
|
||||||
|
@@ -299,7 +299,7 @@ static int omap_gpio_probe(struct udevice *dev)
|
|||||||
|
|
||||||
static int omap_gpio_bind(struct udevice *dev)
|
static int omap_gpio_bind(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct omap_gpio_platdata *plat = dev->platdata;
|
struct omap_gpio_platdata *plat = dev_get_platdata(dev);
|
||||||
fdt_addr_t base_addr;
|
fdt_addr_t base_addr;
|
||||||
|
|
||||||
if (plat)
|
if (plat)
|
||||||
@@ -307,13 +307,17 @@ static int omap_gpio_bind(struct udevice *dev)
|
|||||||
|
|
||||||
base_addr = devfdt_get_addr(dev);
|
base_addr = devfdt_get_addr(dev);
|
||||||
if (base_addr == FDT_ADDR_T_NONE)
|
if (base_addr == FDT_ADDR_T_NONE)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO:
|
* TODO:
|
||||||
* When every board is converted to driver model and DT is
|
* When every board is converted to driver model and DT is
|
||||||
* supported, this can be done by auto-alloc feature, but
|
* supported, this can be done by auto-alloc feature, but
|
||||||
* not using calloc to alloc memory for platdata.
|
* not using calloc to alloc memory for platdata.
|
||||||
|
*
|
||||||
|
* For example am33xx_gpio uses platform data rather than device tree.
|
||||||
|
*
|
||||||
|
* NOTE: DO NOT COPY this code if you are using device tree.
|
||||||
*/
|
*/
|
||||||
plat = calloc(1, sizeof(*plat));
|
plat = calloc(1, sizeof(*plat));
|
||||||
if (!plat)
|
if (!plat)
|
||||||
|
@@ -249,22 +249,11 @@ static int pca953x_probe(struct udevice *dev)
|
|||||||
{
|
{
|
||||||
struct pca953x_info *info = dev_get_platdata(dev);
|
struct pca953x_info *info = dev_get_platdata(dev);
|
||||||
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
|
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
|
||||||
struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
|
|
||||||
char name[32], *str;
|
char name[32], *str;
|
||||||
int addr;
|
int addr;
|
||||||
ulong driver_data;
|
ulong driver_data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!info) {
|
|
||||||
dev_err(dev, "platdata not ready\n");
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!chip) {
|
|
||||||
dev_err(dev, "i2c not ready\n");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
addr = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", 0);
|
addr = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", 0);
|
||||||
if (addr == 0)
|
if (addr == 0)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
@@ -181,7 +181,7 @@ static int tegra186_gpio_bind(struct udevice *parent)
|
|||||||
|
|
||||||
regs = (uint32_t *)devfdt_get_addr_name(parent, "gpio");
|
regs = (uint32_t *)devfdt_get_addr_name(parent, "gpio");
|
||||||
if (regs == (uint32_t *)FDT_ADDR_T_NONE)
|
if (regs == (uint32_t *)FDT_ADDR_T_NONE)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
for (port = 0; port < ctlr_data->port_count; port++) {
|
for (port = 0; port < ctlr_data->port_count; port++) {
|
||||||
struct tegra186_gpio_platdata *plat;
|
struct tegra186_gpio_platdata *plat;
|
||||||
|
@@ -105,32 +105,18 @@ static int vybrid_gpio_probe(struct udevice *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vybrid_gpio_bind(struct udevice *dev)
|
static int vybrid_gpio_odata_to_platdata(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct vybrid_gpio_platdata *plat = dev->platdata;
|
struct vybrid_gpio_platdata *plat = dev_get_platdata(dev);
|
||||||
fdt_addr_t base_addr;
|
fdt_addr_t base_addr;
|
||||||
|
|
||||||
if (plat)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
base_addr = devfdt_get_addr(dev);
|
base_addr = devfdt_get_addr(dev);
|
||||||
if (base_addr == FDT_ADDR_T_NONE)
|
if (base_addr == FDT_ADDR_T_NONE)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO:
|
|
||||||
* When every board is converted to driver model and DT is
|
|
||||||
* supported, this can be done by auto-alloc feature, but
|
|
||||||
* not using calloc to alloc memory for platdata.
|
|
||||||
*/
|
|
||||||
plat = calloc(1, sizeof(*plat));
|
|
||||||
if (!plat)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
plat->base = base_addr;
|
plat->base = base_addr;
|
||||||
plat->chip = dev->req_seq;
|
plat->chip = dev->req_seq;
|
||||||
plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL);
|
plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL);
|
||||||
dev->platdata = plat;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -144,8 +130,9 @@ U_BOOT_DRIVER(gpio_vybrid) = {
|
|||||||
.name = "gpio_vybrid",
|
.name = "gpio_vybrid",
|
||||||
.id = UCLASS_GPIO,
|
.id = UCLASS_GPIO,
|
||||||
.ops = &gpio_vybrid_ops,
|
.ops = &gpio_vybrid_ops,
|
||||||
|
.of_match = vybrid_gpio_ids,
|
||||||
|
.ofdata_to_platdata = vybrid_gpio_odata_to_platdata,
|
||||||
.probe = vybrid_gpio_probe,
|
.probe = vybrid_gpio_probe,
|
||||||
.priv_auto_alloc_size = sizeof(struct vybrid_gpios),
|
.priv_auto_alloc_size = sizeof(struct vybrid_gpios),
|
||||||
.of_match = vybrid_gpio_ids,
|
.platdata_auto_alloc_size = sizeof(struct vybrid_gpio_platdata),
|
||||||
.bind = vybrid_gpio_bind,
|
|
||||||
};
|
};
|
||||||
|
@@ -412,7 +412,7 @@ static int imx_lpi2c_probe(struct udevice *bus)
|
|||||||
|
|
||||||
addr = devfdt_get_addr(bus);
|
addr = devfdt_get_addr(bus);
|
||||||
if (addr == FDT_ADDR_T_NONE)
|
if (addr == FDT_ADDR_T_NONE)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
i2c_bus->base = addr;
|
i2c_bus->base = addr;
|
||||||
i2c_bus->index = bus->seq;
|
i2c_bus->index = bus->seq;
|
||||||
|
@@ -176,7 +176,7 @@ static int bus_i2c_set_bus_speed(struct mxc_i2c_bus *i2c_bus, int speed)
|
|||||||
int reg_shift = quirk ? VF610_I2C_REGSHIFT : IMX_I2C_REGSHIFT;
|
int reg_shift = quirk ? VF610_I2C_REGSHIFT : IMX_I2C_REGSHIFT;
|
||||||
|
|
||||||
if (!base)
|
if (!base)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Store divider value */
|
/* Store divider value */
|
||||||
writeb(idx, base + (IFDR << reg_shift));
|
writeb(idx, base + (IFDR << reg_shift));
|
||||||
@@ -239,7 +239,7 @@ static int tx_byte(struct mxc_i2c_bus *i2c_bus, u8 byte)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if (ret & I2SR_RX_NO_AK)
|
if (ret & I2SR_RX_NO_AK)
|
||||||
return -ENODEV;
|
return -EREMOTEIO;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,14 +418,14 @@ static int i2c_init_transfer(struct mxc_i2c_bus *i2c_bus, u8 chip,
|
|||||||
VF610_I2C_REGSHIFT : IMX_I2C_REGSHIFT;
|
VF610_I2C_REGSHIFT : IMX_I2C_REGSHIFT;
|
||||||
|
|
||||||
if (!i2c_bus->base)
|
if (!i2c_bus->base)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
for (retry = 0; retry < 3; retry++) {
|
for (retry = 0; retry < 3; retry++) {
|
||||||
ret = i2c_init_transfer_(i2c_bus, chip, addr, alen);
|
ret = i2c_init_transfer_(i2c_bus, chip, addr, alen);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
return 0;
|
return 0;
|
||||||
i2c_imx_stop(i2c_bus);
|
i2c_imx_stop(i2c_bus);
|
||||||
if (ret == -ENODEV)
|
if (ret == -EREMOTEIO)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
printf("%s: failed for chip 0x%x retry=%d\n", __func__, chip,
|
printf("%s: failed for chip 0x%x retry=%d\n", __func__, chip,
|
||||||
@@ -754,7 +754,7 @@ static int mxc_i2c_probe(struct udevice *bus)
|
|||||||
|
|
||||||
addr = devfdt_get_addr(bus);
|
addr = devfdt_get_addr(bus);
|
||||||
if (addr == FDT_ADDR_T_NONE)
|
if (addr == FDT_ADDR_T_NONE)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
i2c_bus->base = addr;
|
i2c_bus->base = addr;
|
||||||
i2c_bus->index = bus->seq;
|
i2c_bus->index = bus->seq;
|
||||||
@@ -783,7 +783,7 @@ static int mxc_i2c_probe(struct udevice *bus)
|
|||||||
!dm_gpio_is_valid(&i2c_bus->scl_gpio) |
|
!dm_gpio_is_valid(&i2c_bus->scl_gpio) |
|
||||||
ret | ret2) {
|
ret | ret2) {
|
||||||
dev_err(dev, "i2c bus %d at %lu, fail to request scl/sda gpio\n", bus->seq, i2c_bus->base);
|
dev_err(dev, "i2c bus %d at %lu, fail to request scl/sda gpio\n", bus->seq, i2c_bus->base);
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -94,7 +94,7 @@ static int tegra186_bpmp_i2c_probe(struct udevice *dev)
|
|||||||
"nvidia,bpmp-bus-id", U32_MAX);
|
"nvidia,bpmp-bus-id", U32_MAX);
|
||||||
if (priv->bpmp_bus_id == U32_MAX) {
|
if (priv->bpmp_bus_id == U32_MAX) {
|
||||||
debug("%s: could not parse nvidia,bpmp-bus-id\n", __func__);
|
debug("%s: could not parse nvidia,bpmp-bus-id\n", __func__);
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -36,6 +36,9 @@ static int do_ut_print(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
snprintf(str, 0, "testing none");
|
snprintf(str, 0, "testing none");
|
||||||
assert(*str == 'x');
|
assert(*str == 'x');
|
||||||
|
|
||||||
|
sprintf(big_str, "_%ls_", L"foo");
|
||||||
|
assert(!strcmp("_foo_", big_str));
|
||||||
|
|
||||||
/* Test the banner function */
|
/* Test the banner function */
|
||||||
s = display_options_get_banner(true, str, sizeof(str));
|
s = display_options_get_banner(true, str, sizeof(str));
|
||||||
assert(s == str);
|
assert(s == str);
|
||||||
|
Reference in New Issue
Block a user