Merge tag 'u-boot-at91-2025.04-a' of https://source.denx.de/u-boot/custodians/u-boot-at91 into next
- at91 gpio driver function alternate mode for pins - assorted fixes.
This commit is contained in:
@@ -219,6 +219,44 @@ static bool at91_get_port_output(struct at91_port *at91_port, int offset)
|
||||
val = readl(&at91_port->osr);
|
||||
return val & mask;
|
||||
}
|
||||
|
||||
static bool at91_is_port_gpio(struct at91_port *at91_port, int offset)
|
||||
{
|
||||
u32 mask, val;
|
||||
|
||||
mask = 1 << offset;
|
||||
val = readl(&at91_port->psr);
|
||||
return !!(val & mask);
|
||||
}
|
||||
|
||||
static void at91_set_port_multi_drive(struct at91_port *at91_port, int offset, int is_on)
|
||||
{
|
||||
u32 mask;
|
||||
|
||||
mask = 1 << offset;
|
||||
if (is_on)
|
||||
writel(mask, &at91_port->mder);
|
||||
else
|
||||
writel(mask, &at91_port->mddr);
|
||||
}
|
||||
|
||||
static bool at91_get_port_multi_drive(struct at91_port *at91_port, int offset)
|
||||
{
|
||||
u32 mask, val;
|
||||
|
||||
mask = 1 << offset;
|
||||
val = readl(&at91_port->mdsr);
|
||||
return !!(val & mask);
|
||||
}
|
||||
|
||||
static bool at91_get_port_pullup(struct at91_port *at91_port, int offset)
|
||||
{
|
||||
u32 mask, val;
|
||||
|
||||
mask = 1 << offset;
|
||||
val = readl(&at91_port->pusr);
|
||||
return !(val & mask);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void at91_set_port_input(struct at91_port *at91_port, int offset,
|
||||
@@ -549,13 +587,68 @@ static int at91_gpio_get_function(struct udevice *dev, unsigned offset)
|
||||
{
|
||||
struct at91_port_priv *port = dev_get_priv(dev);
|
||||
|
||||
/* GPIOF_FUNC is not implemented yet */
|
||||
if (!at91_is_port_gpio(port->regs, offset))
|
||||
return GPIOF_FUNC;
|
||||
|
||||
if (at91_get_port_output(port->regs, offset))
|
||||
return GPIOF_OUTPUT;
|
||||
else
|
||||
return GPIOF_INPUT;
|
||||
}
|
||||
|
||||
static int at91_gpio_set_flags(struct udevice *dev, unsigned int offset,
|
||||
ulong flags)
|
||||
{
|
||||
struct at91_port_priv *port = dev_get_priv(dev);
|
||||
ulong supported_mask;
|
||||
|
||||
supported_mask = GPIOD_OPEN_DRAIN | GPIOD_MASK_DIR | GPIOD_PULL_UP;
|
||||
if (flags & ~supported_mask)
|
||||
return -ENOTSUPP;
|
||||
|
||||
if (flags & GPIOD_IS_OUT) {
|
||||
if (flags & GPIOD_OPEN_DRAIN)
|
||||
at91_set_port_multi_drive(port->regs, offset, true);
|
||||
else
|
||||
at91_set_port_multi_drive(port->regs, offset, false);
|
||||
|
||||
at91_set_port_output(port->regs, offset, flags & GPIOD_IS_OUT_ACTIVE);
|
||||
|
||||
} else if (flags & GPIOD_IS_IN) {
|
||||
at91_set_port_input(port->regs, offset, false);
|
||||
}
|
||||
if (flags & GPIOD_PULL_UP)
|
||||
at91_set_port_pullup(port->regs, offset, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int at91_gpio_get_flags(struct udevice *dev, unsigned int offset,
|
||||
ulong *flagsp)
|
||||
{
|
||||
struct at91_port_priv *port = dev_get_priv(dev);
|
||||
ulong dir_flags = 0;
|
||||
|
||||
if (at91_get_port_output(port->regs, offset)) {
|
||||
dir_flags |= GPIOD_IS_OUT;
|
||||
|
||||
if (at91_get_port_multi_drive(port->regs, offset))
|
||||
dir_flags |= GPIOD_OPEN_DRAIN;
|
||||
|
||||
if (at91_get_port_value(port->regs, offset))
|
||||
dir_flags |= GPIOD_IS_OUT_ACTIVE;
|
||||
} else {
|
||||
dir_flags |= GPIOD_IS_IN;
|
||||
}
|
||||
|
||||
if (at91_get_port_pullup(port->regs, offset))
|
||||
dir_flags |= GPIOD_PULL_UP;
|
||||
|
||||
*flagsp = dir_flags;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *at91_get_bank_name(uint32_t base_addr)
|
||||
{
|
||||
switch (base_addr) {
|
||||
@@ -584,6 +677,8 @@ static const struct dm_gpio_ops gpio_at91_ops = {
|
||||
.get_value = at91_gpio_get_value,
|
||||
.set_value = at91_gpio_set_value,
|
||||
.get_function = at91_gpio_get_function,
|
||||
.set_flags = at91_gpio_set_flags,
|
||||
.get_flags = at91_gpio_get_flags,
|
||||
};
|
||||
|
||||
static int at91_gpio_probe(struct udevice *dev)
|
||||
|
@@ -2205,7 +2205,6 @@ static const struct udevice_id atmel_nand_controller_of_ids[] = {
|
||||
static int atmel_nand_controller_probe(struct udevice *dev)
|
||||
{
|
||||
const struct atmel_nand_controller_caps *caps;
|
||||
struct udevice *pmecc_dev;
|
||||
|
||||
caps = (struct atmel_nand_controller_caps *)dev_get_driver_data(dev);
|
||||
if (!caps) {
|
||||
@@ -2213,12 +2212,6 @@ static int atmel_nand_controller_probe(struct udevice *dev)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Probe pmecc driver */
|
||||
if (uclass_get_device(UCLASS_MTD, 1, &pmecc_dev)) {
|
||||
printf("%s: get device fail\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return caps->ops->probe(dev, caps);
|
||||
}
|
||||
|
||||
|
@@ -913,6 +913,7 @@ struct atmel_pmecc *devm_atmel_pmecc_get(struct udevice *userdev)
|
||||
ret = ofnode_parse_phandle_with_args(userdev->node_,
|
||||
"ecc-engine",
|
||||
NULL, 0, 0, &args);
|
||||
/* Probe pmecc driver */
|
||||
ret = uclass_get_device_by_ofnode(UCLASS_MTD, args.node, &pdev);
|
||||
if (ret)
|
||||
return NULL;
|
||||
|
@@ -113,7 +113,7 @@ static int vtbl_check(struct ubi_scan_info *ubi,
|
||||
|
||||
crc = crc32(UBI_CRC32_INIT, &vtbl[i], UBI_VTBL_RECORD_SIZE_CRC);
|
||||
if (be32_to_cpu(vtbl[i].crc) != crc) {
|
||||
ubi_err("bad CRC at record %u: %#08x, not %#08x",
|
||||
ubi_err("bad CRC at record %u: #%08x, not #%08x",
|
||||
i, crc, be32_to_cpu(vtbl[i].crc));
|
||||
ubi_dump_vtbl_record(&vtbl[i], i);
|
||||
return 1;
|
||||
|
@@ -312,7 +312,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
|
||||
|
||||
*info->bf = 0;
|
||||
info->bf = p;
|
||||
while (*info->bf++ && width > 0)
|
||||
while (width > 0 && info->bf && *info->bf++)
|
||||
width--;
|
||||
while (width-- > 0)
|
||||
info->putc(info, lz ? '0' : ' ');
|
||||
|
Reference in New Issue
Block a user