From aaba703fd0f08f3c63ad241cbb29273f0ebbf2a6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Nov 2018 08:14:27 -0700 Subject: [PATCH 1/8] spl: misc: Allow misc drivers in SPL and TPL In some cases it is necessary to read the keyboard in early phases of U-Boot. The cros_ec keyboard is kept in the misc directory. Update the config to allow this. Signed-off-by: Simon Glass --- drivers/misc/Kconfig | 72 +++++++++++++++++++++++++++++++++++++++++++ drivers/misc/Makefile | 8 +++-- 2 files changed, 77 insertions(+), 3 deletions(-) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 0e645f58be..cb8b5c04db 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -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 diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 6bdf5054f4..509c588582 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -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 From 089ff8eb669f8c8e98bff2a6ea4bb5fd9bf34d3b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 17 Dec 2018 09:15:44 -0700 Subject: [PATCH 2/8] Add an empty stdint.h file Some libraries build by U-Boot may include stdint.h. This is not used by U-Boot itself and causes conflicts with the types defined in linux/types.h. To work around this, add an empty file with this name so that it will be used in preference to the compiler version. Signed-off-by: Simon Glass --- include/stdint.h | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 include/stdint.h diff --git a/include/stdint.h b/include/stdint.h new file mode 100644 index 0000000000..2e126d14bd --- /dev/null +++ b/include/stdint.h @@ -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 + */ From 3bf2f15351e9533c9c99ebbdd93cafca30558b0d Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Mon, 15 Apr 2019 10:08:21 +0200 Subject: [PATCH 3/8] fdtdec: Remove fdt_{addr,size}_unpack() U-Boot already defines the {upper,lower}_32_bits() macros that have the same purpose. Use the existing macros instead of defining new APIs. Signed-off-by: Thierry Reding --- include/fdtdec.h | 24 ------------------------ lib/fdtdec.c | 8 ++++++-- lib/fdtdec_test.c | 8 ++++++-- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/include/fdtdec.h b/include/fdtdec.h index 110aa6ab6d..fa8e34f6f9 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -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) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index fea44a9a8c..d0ba888973 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -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); diff --git a/lib/fdtdec_test.c b/lib/fdtdec_test.c index f6defe16c5..1f4f270540 100644 --- a/lib/fdtdec_test.c +++ b/lib/fdtdec_test.c @@ -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); From 3a9a62a18e57b1ed3adbe3a3d00b9793ec55c08f Mon Sep 17 00:00:00 2001 From: Stefan Mavrodiev Date: Wed, 24 Apr 2019 08:31:54 +0300 Subject: [PATCH 4/8] common: fdt_support: Check mtdparts cell size When using fdt_fixup_mtdparts() offset and length cell sizes are limited to 4 bytes (1 cell). However if the mtd device is bigger then 4GiB, then #address-cells and #size-cells are 8 bytes (2 cells) [1]. This patch read #size-cells and uses either fdt32_t or fdt64_t cell size. The default is fdt32_t. [1] Documentation/devicetree/bindings/mtd/partition.txt Signed-off-by: Stefan Mavrodiev Reviewed-by: Simon Glass --- common/fdt_support.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index 4e7cf6ebe9..f31e9b0cc5 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -722,11 +722,6 @@ int fdt_increase_size(void *fdt, int add_len) #include #include -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) From e679d03b08fbde6145fdef150f4b240e6d14448e Mon Sep 17 00:00:00 2001 From: Keerthy Date: Wed, 24 Apr 2019 17:19:53 +0530 Subject: [PATCH 5/8] core: ofnode: Add ofnode_get_addr_size_index Add ofnode_get_addr_size_index function to fetch the address and size of the reg space based on index. Signed-off-by: Keerthy Reviewed-by: Simon Glass --- drivers/core/ofnode.c | 13 ++++++++++--- include/dm/ofnode.h | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index cc0c031e0d..12977a7790 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -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); diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index d206ee2caa..1be5ba4b45 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -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 * From 347ea0b63eb5143bf0e48aba65a41f50999367f0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 26 Apr 2019 19:02:23 -0600 Subject: [PATCH 6/8] buildman: Deal more nicely with invalid build-status file The 'done' files created by buildman may end up being empty if buildman runs out of disk space while writing them. At present buildman dies with an exception when using -s to check the build status. Fix this. Seriesl-cc: trini Signed-off-by: Simon Glass --- tools/buildman/builder.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 6a6c83bf33..fbb236676c 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -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): From b061ef39c350c288542536b09dc01d9e984a12ac Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Fri, 10 May 2019 17:48:20 +0000 Subject: [PATCH 7/8] core: ofnode: Have ofnode_read_u32_default return a u32 It was returning an int, which doesn't work if the u32 it is reading, or the default value, will overflow a signed int. While it could be made to work, when using a C standard/compiler where casting negative signed values to unsigned has a defined behavior, combined with careful casting, it seems obvious one is meant to use ofnode_read_s32_default() with signed values. Cc: Simon Glass Signed-off-by: Trent Piepho --- drivers/core/ofnode.c | 2 +- include/dm/ofnode.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 12977a7790..c72c6e2673 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -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); diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 1be5ba4b45..4ab2ae1ba5 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -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 From ee730a7cd2afe445e53e92b5c37396a5b118f7af Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Wed, 15 May 2019 10:07:01 +0200 Subject: [PATCH 8/8] dm: core: Fix dm_extended_scan_fdt() This function takes an argument, blob, but never uses it, instead uses gd->fdt_blob directly. Fixes: e81c98649b7a ("dm: core: add clocks node scan") Reported-by: AKASHI Takahiro Signed-off-by: Patrice Chotard Reviewed-by: Bin Meng --- drivers/core/root.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/core/root.c b/drivers/core/root.c index 8fa096648e..aa5ca4087a 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -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;