Various DM fixes

Addition of ofnode_get_addr_size_index()
 -----BEGIN PGP SIGNATURE-----
 
 iQFFBAABCgAvFiEEslwAIq+Gp8wWVbYnfxc6PpAIreYFAlzlSngRHHNqZ0BjaHJv
 bWl1bS5vcmcACgkQfxc6PpAIreZq5QgAiBfKSJU2x+JW9THEsb7iDe3BM10mX7np
 ewSdBCcgz0koncV7OpXyHAbCBasMB9XrsVhXZ+D3wHUkZYfSD4fMJ3Dl74qIblu/
 a76AfiT/zXIg5uwVUURsGZ2DPxOvos1u6ekgTnPi7eIbf+gDaYWJZs22Hi0jCw7x
 croFHk6iQD/icqd5WbpkyPRmcZf/dWxTT3+jOIPqByMR1ZOQ0qQMoEhrNWXk4/b7
 ElJjpqVZjeIqNZbyOZvH0KwK9RaVa5wH9GzbOmuBzqrUas0ppoUc/E4dAo85IKMK
 sALFDAMd71Z0Fzn3SVQlCcbWsBWWcL1oGrMBpSCZ2jnWF1k0/CU83w==
 =6f4t
 -----END PGP SIGNATURE-----

Merge tag 'dm-pull-22may19' of git://git.denx.de/u-boot-dm

Various DM fixes
Addition of ofnode_get_addr_size_index()
This commit is contained in:
Tom Rini 2019-05-22 12:58:58 -04:00
commit 40920bdecc
11 changed files with 151 additions and 47 deletions

View file

@ -722,11 +722,6 @@ int fdt_increase_size(void *fdt, int add_len)
#include <jffs2/load_kernel.h>
#include <mtd_node.h>
struct reg_cell {
unsigned int r0;
unsigned int r1;
};
static int fdt_del_subnodes(const void *blob, int parent_offset)
{
int off, ndepth;
@ -785,15 +780,22 @@ int fdt_node_set_part_info(void *blob, int parent_offset,
{
struct list_head *pentry;
struct part_info *part;
struct reg_cell cell;
int off, ndepth = 0;
int part_num, ret;
int sizecell;
char buf[64];
ret = fdt_del_partitions(blob, parent_offset);
if (ret < 0)
return ret;
/*
* Check if size/address is 1 or 2 cells.
* We assume #address-cells and #size-cells have same value.
*/
sizecell = fdt_getprop_u32_default_node(blob, parent_offset,
0, "#size-cells", 1);
/*
* Check if it is nand {}; subnode, adjust
* the offset in this case
@ -842,10 +844,21 @@ add_ro:
goto err_prop;
}
cell.r0 = cpu_to_fdt32(part->offset);
cell.r1 = cpu_to_fdt32(part->size);
add_reg:
ret = fdt_setprop(blob, newoff, "reg", &cell, sizeof(cell));
if (sizecell == 2) {
ret = fdt_setprop_u64(blob, newoff,
"reg", part->offset);
if (!ret)
ret = fdt_appendprop_u64(blob, newoff,
"reg", part->size);
} else {
ret = fdt_setprop_u32(blob, newoff,
"reg", part->offset);
if (!ret)
ret = fdt_appendprop_u32(blob, newoff,
"reg", part->size);
}
if (ret == -FDT_ERR_NOSPACE) {
ret = fdt_increase_size(blob, 512);
if (!ret)

View file

@ -39,7 +39,7 @@ int ofnode_read_u32(ofnode node, const char *propname, u32 *outp)
return 0;
}
int ofnode_read_u32_default(ofnode node, const char *propname, u32 def)
u32 ofnode_read_u32_default(ofnode node, const char *propname, u32 def)
{
assert(ofnode_valid(node));
ofnode_read_u32(node, propname, &def);
@ -251,7 +251,7 @@ int ofnode_read_size(ofnode node, const char *propname)
return -EINVAL;
}
fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size)
{
int na, ns;
@ -260,7 +260,7 @@ fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
uint flags;
prop_val = of_get_address(ofnode_to_np(node), index,
NULL, &flags);
(u64 *)size, &flags);
if (!prop_val)
return FDT_ADDR_T_NONE;
@ -277,12 +277,19 @@ fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
ns = ofnode_read_simple_size_cells(ofnode_get_parent(node));
return fdtdec_get_addr_size_fixed(gd->fdt_blob,
ofnode_to_offset(node), "reg",
index, na, ns, NULL, true);
index, na, ns, size, true);
}
return FDT_ADDR_T_NONE;
}
fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
{
fdt_size_t size;
return ofnode_get_addr_size_index(node, index, &size);
}
fdt_addr_t ofnode_get_addr(ofnode node)
{
return ofnode_get_addr_index(node, 0);

View file

@ -342,7 +342,7 @@ int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only)
{
int ret;
ret = dm_scan_fdt(gd->fdt_blob, pre_reloc_only);
ret = dm_scan_fdt(blob, pre_reloc_only);
if (ret) {
debug("dm_scan_fdt() failed: %d\n", ret);
return ret;

View file

@ -13,6 +13,24 @@ config MISC
set of generic read, write and ioctl methods may be used to
access the device.
config SPL_MISC
bool "Enable Driver Model for Misc drivers in SPL"
depends on SPL_DM
help
Enable driver model for miscellaneous devices. This class is
used only for those do not fit other more general classes. A
set of generic read, write and ioctl methods may be used to
access the device.
config TPL_MISC
bool "Enable Driver Model for Misc drivers in TPL"
depends on TPL_DM
help
Enable driver model for miscellaneous devices. This class is
used only for those do not fit other more general classes. A
set of generic read, write and ioctl methods may be used to
access the device.
config ALTERA_SYSID
bool "Altera Sysid support"
depends on MISC
@ -68,6 +86,24 @@ config CROS_EC
control access to the battery and main PMIC depending on the
device. You can use the 'crosec' command to access it.
config SPL_CROS_EC
bool "Enable Chrome OS EC in SPL"
help
Enable access to the Chrome OS EC in SPL. This is a separate
microcontroller typically available on a SPI bus on Chromebooks. It
provides access to the keyboard, some internal storage and may
control access to the battery and main PMIC depending on the
device. You can use the 'crosec' command to access it.
config TPL_CROS_EC
bool "Enable Chrome OS EC in TPL"
help
Enable access to the Chrome OS EC in TPL. This is a separate
microcontroller typically available on a SPI bus on Chromebooks. It
provides access to the keyboard, some internal storage and may
control access to the battery and main PMIC depending on the
device. You can use the 'crosec' command to access it.
config CROS_EC_I2C
bool "Enable Chrome OS EC I2C driver"
depends on CROS_EC
@ -86,6 +122,24 @@ config CROS_EC_LPC
through a legacy port interface, so on x86 machines the main
function of the EC is power and thermal management.
config SPL_CROS_EC_LPC
bool "Enable Chrome OS EC LPC driver in SPL"
depends on CROS_EC
help
Enable I2C access to the Chrome OS EC. This is used on x86
Chromebooks such as link and falco. The keyboard is provided
through a legacy port interface, so on x86 machines the main
function of the EC is power and thermal management.
config TPL_CROS_EC_LPC
bool "Enable Chrome OS EC LPC driver in TPL"
depends on CROS_EC
help
Enable I2C access to the Chrome OS EC. This is used on x86
Chromebooks such as link and falco. The keyboard is provided
through a legacy port interface, so on x86 machines the main
function of the EC is power and thermal management.
config CROS_EC_SANDBOX
bool "Enable Chrome OS EC sandbox driver"
depends on CROS_EC && SANDBOX
@ -95,6 +149,24 @@ config CROS_EC_SANDBOX
EC flash read/write/erase support and a few other things. It is
enough to perform a Chrome OS verified boot on sandbox.
config SPL_CROS_EC_SANDBOX
bool "Enable Chrome OS EC sandbox driver in SPL"
depends on SPL_CROS_EC && SANDBOX
help
Enable a sandbox emulation of the Chrome OS EC in SPL. This supports
keyboard (use the -l flag to enable the LCD), verified boot context,
EC flash read/write/erase support and a few other things. It is
enough to perform a Chrome OS verified boot on sandbox.
config TPL_CROS_EC_SANDBOX
bool "Enable Chrome OS EC sandbox driver in TPL"
depends on TPL_CROS_EC && SANDBOX
help
Enable a sandbox emulation of the Chrome OS EC in TPL. This supports
keyboard (use the -l flag to enable the LCD), verified boot context,
EC flash read/write/erase support and a few other things. It is
enough to perform a Chrome OS verified boot on sandbox.
config CROS_EC_SPI
bool "Enable Chrome OS EC SPI driver"
depends on CROS_EC

View file

@ -4,11 +4,13 @@
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
obj-$(CONFIG_MISC) += misc-uclass.o
obj-$(CONFIG_$(SPL_TPL_)CROS_EC) += cros_ec.o
obj-$(CONFIG_$(SPL_TPL_)CROS_EC_SANDBOX) += cros_ec_sandbox.o
obj-$(CONFIG_$(SPL_TPL_)CROS_EC_LPC) += cros_ec_lpc.o
ifndef CONFIG_SPL_BUILD
obj-$(CONFIG_CROS_EC) += cros_ec.o
obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpc.o
obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o
obj-$(CONFIG_CROS_EC_SANDBOX) += cros_ec_sandbox.o
obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
endif

View file

@ -224,7 +224,7 @@ static inline int ofnode_read_s32(ofnode node, const char *propname,
* @def: default value to return if the property has no value
* @return property value, or @def if not found
*/
int ofnode_read_u32_default(ofnode ref, const char *propname, u32 def);
u32 ofnode_read_u32_default(ofnode ref, const char *propname, u32 def);
/**
* ofnode_read_s32_default() - Read a 32-bit integer from a property
@ -354,6 +354,20 @@ ofnode ofnode_get_by_phandle(uint phandle);
*/
int ofnode_read_size(ofnode node, const char *propname);
/**
* ofnode_get_addr_size_index() - get an address/size from a node
* based on index
*
* This reads the register address/size from a node based on index
*
* @node: node to read from
* @index: Index of address to read (0 for first)
* @size: Pointer to size of the address
* @return address, or FDT_ADDR_T_NONE if not present or invalid
*/
phys_addr_t ofnode_get_addr_size_index(ofnode node, int index,
fdt_size_t *size);
/**
* ofnode_get_addr_index() - get an address from a node
*

View file

@ -24,30 +24,6 @@
typedef phys_addr_t fdt_addr_t;
typedef phys_size_t fdt_size_t;
static inline fdt32_t fdt_addr_unpack(fdt_addr_t addr, fdt32_t *upper)
{
if (upper)
#ifdef CONFIG_PHYS_64BIT
*upper = addr >> 32;
#else
*upper = 0;
#endif
return addr;
}
static inline fdt32_t fdt_size_unpack(fdt_size_t size, fdt32_t *upper)
{
if (upper)
#ifdef CONFIG_PHYS_64BIT
*upper = size >> 32;
#else
*upper = 0;
#endif
return size;
}
#ifdef CONFIG_PHYS_64BIT
#define FDT_ADDR_T_NONE (-1U)
#define fdt_addr_to_cpu(reg) be64_to_cpu(reg)

7
include/stdint.h Normal file
View file

@ -0,0 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Dummy file to allow libraries linked with U-Boot to include stdint.h without
* getting the system version.
*
* U-Boot uses linux types (linux/types.h) so does not make use of stdint.h
*/

View file

@ -1300,6 +1300,7 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
fdt32_t cells[4] = {}, *ptr = cells;
uint32_t upper, lower, phandle;
int parent, node, na, ns, err;
fdt_size_t size;
char name[64];
/* create an empty /reserved-memory node if one doesn't exist */
@ -1340,7 +1341,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
* Unpack the start address and generate the name of the new node
* base on the basename and the unit-address.
*/
lower = fdt_addr_unpack(carveout->start, &upper);
upper = upper_32_bits(carveout->start);
lower = lower_32_bits(carveout->start);
if (na > 1 && upper > 0)
snprintf(name, sizeof(name), "%s@%x,%x", basename, upper,
@ -1374,7 +1376,9 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
*ptr++ = cpu_to_fdt32(lower);
/* store one or two size cells */
lower = fdt_size_unpack(carveout->end - carveout->start + 1, &upper);
size = carveout->end - carveout->start + 1;
upper = upper_32_bits(size);
lower = lower_32_bits(size);
if (ns > 1)
*ptr++ = cpu_to_fdt32(upper);

View file

@ -155,11 +155,13 @@ static int make_fdt_carveout_device(void *fdt, uint32_t na, uint32_t ns)
};
fdt32_t cells[4], *ptr = cells;
uint32_t upper, lower;
fdt_size_t size;
char name[32];
int offset;
/* store one or two address cells */
lower = fdt_addr_unpack(carveout.start, &upper);
upper = upper_32_bits(carveout.start);
lower = lower_32_bits(carveout.start);
if (na > 1 && upper > 0)
snprintf(name, sizeof(name), "%s@%x,%x", basename, upper,
@ -173,7 +175,9 @@ static int make_fdt_carveout_device(void *fdt, uint32_t na, uint32_t ns)
*ptr++ = cpu_to_fdt32(lower);
/* store one or two size cells */
lower = fdt_size_unpack(carveout.end - carveout.start + 1, &upper);
size = carveout.end - carveout.start + 1;
upper = upper_32_bits(size);
lower = lower_32_bits(size);
if (ns > 1)
*ptr++ = cpu_to_fdt32(upper);

View file

@ -673,7 +673,12 @@ class Builder:
environment = {}
if os.path.exists(done_file):
with open(done_file, 'r') as fd:
return_code = int(fd.readline())
try:
return_code = int(fd.readline())
except ValueError:
# The file may be empty due to running out of disk space.
# Try a rebuild
return_code = 1
err_lines = []
err_file = self.GetErrFile(commit_upto, target)
if os.path.exists(err_file):