1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-30 15:01:27 +02:00
dm: Fix an obscure bug with empty of-platdata
Fixes for ns16550 base address and frequency-reading
Other minor fixes
This commit is contained in:
Tom Rini
2021-03-03 22:53:53 -05:00
8 changed files with 47 additions and 17 deletions

View File

@@ -449,6 +449,7 @@ config BOOTSTAGE_REPORT
config BOOTSTAGE_RECORD_COUNT config BOOTSTAGE_RECORD_COUNT
int "Number of boot stage records to store" int "Number of boot stage records to store"
depends on BOOTSTAGE
default 30 default 30
help help
This is the size of the bootstage record list and is the maximum This is the size of the bootstage record list and is the maximum
@@ -456,6 +457,7 @@ config BOOTSTAGE_RECORD_COUNT
config SPL_BOOTSTAGE_RECORD_COUNT config SPL_BOOTSTAGE_RECORD_COUNT
int "Number of boot stage records to store for SPL" int "Number of boot stage records to store for SPL"
depends on SPL_BOOTSTAGE
default 5 default 5
help help
This is the size of the bootstage record list and is the maximum This is the size of the bootstage record list and is the maximum
@@ -463,6 +465,7 @@ config SPL_BOOTSTAGE_RECORD_COUNT
config TPL_BOOTSTAGE_RECORD_COUNT config TPL_BOOTSTAGE_RECORD_COUNT
int "Number of boot stage records to store for TPL" int "Number of boot stage records to store for TPL"
depends on TPL_BOOTSTAGE
default 5 default 5
help help
This is the size of the bootstage record list and is the maximum This is the size of the bootstage record list and is the maximum

View File

@@ -349,7 +349,7 @@ void bootstage_report(void)
} }
if (data->rec_count > RECORD_COUNT) if (data->rec_count > RECORD_COUNT)
printf("Overflowed internal boot id table by %d entries\n" printf("Overflowed internal boot id table by %d entries\n"
"Please increase CONFIG_(SPL_)BOOTSTAGE_RECORD_COUNT\n", "Please increase CONFIG_(SPL_TPL_)BOOTSTAGE_RECORD_COUNT\n",
data->rec_count - RECORD_COUNT); data->rec_count - RECORD_COUNT);
puts("\nAccumulated time:\n"); puts("\nAccumulated time:\n");

View File

@@ -231,6 +231,18 @@ int host_get_dev_err(int devnum, struct blk_desc **blk_devp)
} }
#ifdef CONFIG_BLK #ifdef CONFIG_BLK
int sandbox_host_unbind(struct udevice *dev)
{
struct host_block_dev *host_dev;
/* Data validity is checked in host_dev_bind() */
host_dev = dev_get_plat(dev);
os_close(host_dev->fd);
return 0;
}
static const struct blk_ops sandbox_host_blk_ops = { static const struct blk_ops sandbox_host_blk_ops = {
.read = host_block_read, .read = host_block_read,
.write = host_block_write, .write = host_block_write,
@@ -240,6 +252,7 @@ U_BOOT_DRIVER(sandbox_host_blk) = {
.name = "sandbox_host_blk", .name = "sandbox_host_blk",
.id = UCLASS_BLK, .id = UCLASS_BLK,
.ops = &sandbox_host_blk_ops, .ops = &sandbox_host_blk_ops,
.unbind = sandbox_host_unbind,
.plat_auto = sizeof(struct host_block_dev), .plat_auto = sizeof(struct host_block_dev),
}; };
#else #else

View File

@@ -92,16 +92,20 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
if (auto_seq && !(uc->uc_drv->flags & DM_UC_FLAG_NO_AUTO_SEQ)) if (auto_seq && !(uc->uc_drv->flags & DM_UC_FLAG_NO_AUTO_SEQ))
dev->seq_ = uclass_find_next_free_seq(uc); dev->seq_ = uclass_find_next_free_seq(uc);
/* Check if we need to allocate plat */
if (drv->plat_auto) { if (drv->plat_auto) {
bool alloc = !plat; bool alloc = !plat;
/*
* For of-platdata, we try use the existing data, but if
* plat_auto is larger, we must allocate a new space
*/
if (CONFIG_IS_ENABLED(OF_PLATDATA)) { if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
if (of_plat_size) { if (of_plat_size)
dev_or_flags(dev, DM_FLAG_OF_PLATDATA); dev_or_flags(dev, DM_FLAG_OF_PLATDATA);
if (of_plat_size < drv->plat_auto) if (of_plat_size < drv->plat_auto)
alloc = true; alloc = true;
} }
}
if (alloc) { if (alloc) {
dev_or_flags(dev, DM_FLAG_ALLOC_PDATA); dev_or_flags(dev, DM_FLAG_ALLOC_PDATA);
ptr = calloc(1, drv->plat_auto); ptr = calloc(1, drv->plat_auto);
@@ -109,6 +113,11 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
ret = -ENOMEM; ret = -ENOMEM;
goto fail_alloc1; goto fail_alloc1;
} }
/*
* For of-platdata, copy the old plat into the new
* space
*/
if (CONFIG_IS_ENABLED(OF_PLATDATA) && plat) if (CONFIG_IS_ENABLED(OF_PLATDATA) && plat)
memcpy(ptr, plat, of_plat_size); memcpy(ptr, plat, of_plat_size);
dev_set_plat(dev, ptr); dev_set_plat(dev, ptr);
@@ -128,9 +137,8 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
if (parent) { if (parent) {
size = parent->driver->per_child_plat_auto; size = parent->driver->per_child_plat_auto;
if (!size) { if (!size)
size = parent->uclass->uc_drv->per_child_plat_auto; size = parent->uclass->uc_drv->per_child_plat_auto;
}
if (size) { if (size) {
dev_or_flags(dev, DM_FLAG_ALLOC_PARENT_PDATA); dev_or_flags(dev, DM_FLAG_ALLOC_PARENT_PDATA);
ptr = calloc(1, size); ptr = calloc(1, size);
@@ -200,15 +208,19 @@ fail_uclass_bind:
} }
} }
fail_alloc3: fail_alloc3:
if (CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)) {
if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) { if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) {
free(dev_get_uclass_plat(dev)); free(dev_get_uclass_plat(dev));
dev_set_uclass_plat(dev, NULL); dev_set_uclass_plat(dev, NULL);
} }
}
fail_alloc2: fail_alloc2:
if (CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)) {
if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) { if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) {
free(dev_get_plat(dev)); free(dev_get_plat(dev));
dev_set_plat(dev, NULL); dev_set_plat(dev, NULL);
} }
}
fail_alloc1: fail_alloc1:
devres_release_all(dev); devres_release_all(dev);

View File

@@ -483,7 +483,7 @@ static int ns16550_serial_getinfo(struct udevice *dev,
return 0; return 0;
} }
static int ns16550_serial_assign_base(struct ns16550_plat *plat, ulong base) static int ns16550_serial_assign_base(struct ns16550_plat *plat, fdt_addr_t base)
{ {
if (base == FDT_ADDR_T_NONE) if (base == FDT_ADDR_T_NONE)
return -EINVAL; return -EINVAL;
@@ -564,6 +564,8 @@ int ns16550_serial_of_to_plat(struct udevice *dev)
if (!plat->clock) if (!plat->clock)
plat->clock = dev_read_u32_default(dev, "clock-frequency", plat->clock = dev_read_u32_default(dev, "clock-frequency",
CONFIG_SYS_NS16550_CLK); CONFIG_SYS_NS16550_CLK);
if (!plat->clock)
plat->clock = CONFIG_SYS_NS16550_CLK;
if (!plat->clock) { if (!plat->clock) {
debug("ns16550 clock not defined\n"); debug("ns16550 clock not defined\n");
return -EINVAL; return -EINVAL;

View File

@@ -60,7 +60,7 @@ config TPL_OF_CONTROL
config OF_LIVE config OF_LIVE
bool "Enable use of a live tree" bool "Enable use of a live tree"
depends on OF_CONTROL depends on DM && OF_CONTROL
help help
Normally U-Boot uses a flat device tree which saves space and Normally U-Boot uses a flat device tree which saves space and
avoids the need to unpack the tree before use. However a flat avoids the need to unpack the tree before use. However a flat

View File

@@ -22,7 +22,7 @@ config BCH
config BINMAN_FDT config BINMAN_FDT
bool "Allow access to binman information in the device tree" bool "Allow access to binman information in the device tree"
depends on BINMAN && OF_CONTROL depends on BINMAN && DM && OF_CONTROL
default y default y
help help
This enables U-Boot to access information about binman entries, This enables U-Boot to access information about binman entries,

View File

@@ -271,7 +271,7 @@ class Series(dict):
cc += get_maintainer.GetMaintainer(dir_list, commit.patch) cc += get_maintainer.GetMaintainer(dir_list, commit.patch)
for x in set(cc) & set(settings.bounces): for x in set(cc) & set(settings.bounces):
print(col.Color(col.YELLOW, 'Skipping "%s"' % x)) print(col.Color(col.YELLOW, 'Skipping "%s"' % x))
cc = set(cc) - set(settings.bounces) cc = list(set(cc) - set(settings.bounces))
if limit is not None: if limit is not None:
cc = cc[:limit] cc = cc[:limit]
all_ccs += cc all_ccs += cc