From d4e33f5a72accc891e3600cb2d2bc579004de9e1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 4 Jul 2016 11:57:45 -0600 Subject: sandbox: Allow chaining from SPL to U-Boot proper SPL is expected to load and run U-Boot. This needs to work with sandbox also. Provide a function to locate the U-Boot image, and another to start it. This allows SPL to function on sandbox as it does on other archs. Signed-off-by: Simon Glass --- include/os.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include') diff --git a/include/os.h b/include/os.h index 954a48c9919..1782e50e775 100644 --- a/include/os.h +++ b/include/os.h @@ -286,6 +286,31 @@ int os_read_ram_buf(const char *fname); */ int os_jump_to_image(const void *dest, int size); +/** + * os_find_u_boot() - Determine the path to U-Boot proper + * + * This function is intended to be called from within sandbox SPL. It uses + * a few heuristics to find U-Boot proper. Normally it is either in the same + * directory, or the directory above (since u-boot-spl is normally in an + * spl/ subdirectory when built). + * + * @fname: Place to put full path to U-Boot + * @maxlen: Maximum size of @fname + * @return 0 if OK, -NOSPC if the filename is too large, -ENOENT if not found + */ +int os_find_u_boot(char *fname, int maxlen); + +/** + * os_spl_to_uboot() - Run U-Boot proper + * + * When called from SPL, this runs U-Boot proper. The filename is obtained by + * calling os_find_u_boot(). + * + * @fname: Full pathname to U-Boot executable + * @return 0 if OK, -ve on error + */ +int os_spl_to_uboot(const char *fname); + /** * Read the current system time * -- cgit v1.2.3 From 1c12bcee70d99fa4f4124a87ea965526ee164d3c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 4 Jul 2016 11:57:52 -0600 Subject: sandbox: Don't use IDE and iotrace in SPL These functions are not supported in SPL, so drop them. Signed-off-by: Simon Glass --- include/configs/sandbox.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 23a0c40ca52..4de89f8879d 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -16,8 +16,10 @@ #endif +#ifndef CONFIG_SPL_BUILD #define CONFIG_IO_TRACE #define CONFIG_CMD_IOTRACE +#endif #ifndef CONFIG_TIMER #define CONFIG_SYS_TIMER_RATE 1000000 @@ -192,6 +194,7 @@ #define CONFIG_CMD_LZMADEC #define CONFIG_CMD_DATE +#ifndef CONFIG_SPL_BUILD #define CONFIG_CMD_IDE #define CONFIG_SYS_IDE_MAXBUS 1 #define CONFIG_SYS_ATA_IDE0_OFFSET 0 @@ -201,6 +204,7 @@ #define CONFIG_SYS_ATA_REG_OFFSET 1 #define CONFIG_SYS_ATA_ALT_OFFSET 2 #define CONFIG_SYS_ATA_STRIDE 4 +#endif #define CONFIG_SCSI #define CONFIG_SCSI_AHCI_PLAT -- cgit v1.2.3 From 8797b2cae3ac5ddb005665e4b5cde4783a4f5555 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 4 Jul 2016 11:57:54 -0600 Subject: sandbox: Add a new sandbox_spl board It is useful to be able to build SPL for sandbox. It provides additional build coverage and allows SPL features to be tested in sandbox. However it does not need worthwhile to always create an SPL build. It nearly doubles the build time and the feature is (so far) seldom used. So for now, create a separate build target for sandbox SPL. This allows experimentation with this new feature without impacting existing workflows. Signed-off-by: Simon Glass --- include/configs/sandbox_spl.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 include/configs/sandbox_spl.h (limited to 'include') diff --git a/include/configs/sandbox_spl.h b/include/configs/sandbox_spl.h new file mode 100644 index 00000000000..7b5c3f3e033 --- /dev/null +++ b/include/configs/sandbox_spl.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2016 Google, Inc + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __SANDBOX_SPL_CONFIG_H +#define __SANDBOX_SPL_CONFIG_H + +#include + +#define CONFIG_SPL_DRIVERS_MISC_SUPPORT +#define CONFIG_SPL_ENV_SUPPORT +#define CONFIG_SPL_FRAMEWORK +#define CONFIG_SPL_LIBCOMMON_SUPPORT +#define CONFIG_SPL_LIBGENERIC_SUPPORT +#define CONFIG_SPL_SERIAL_SUPPORT + +#endif -- cgit v1.2.3 From a091a8f084f731953fa77a3da3b5bec72d37ad0f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 4 Jul 2016 11:57:55 -0600 Subject: sandbox: Add a test device that uses of-platdata Start up the test devices. These print out of-platdata contents, providing a check that the of-platdata feature is working correctly. The device-tree changes are made to sandbox.dts rather than test.dts. since the former controls the of-platdata generation. Signed-off-by: Simon Glass --- include/configs/sandbox_spl.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/configs/sandbox_spl.h b/include/configs/sandbox_spl.h index 7b5c3f3e033..ffc309867a2 100644 --- a/include/configs/sandbox_spl.h +++ b/include/configs/sandbox_spl.h @@ -8,6 +8,8 @@ #include +#define CONFIG_SPL_BOARD_INIT + #define CONFIG_SPL_DRIVERS_MISC_SUPPORT #define CONFIG_SPL_ENV_SUPPORT #define CONFIG_SPL_FRAMEWORK -- cgit v1.2.3 From 3b2a29e0971397085c616c89a3a09f2609f50ca4 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 4 Jul 2016 11:57:59 -0600 Subject: dm: regmap: Add a dummy implementation for of-platdata Add a placeholder for now so that this code will compile. It currently does nothing. Signed-off-by: Simon Glass --- include/regmap.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/regmap.h b/include/regmap.h index eccf7707f45..922b39fad06 100644 --- a/include/regmap.h +++ b/include/regmap.h @@ -56,6 +56,9 @@ int regmap_read(struct regmap *map, uint offset, uint *valp); */ int regmap_init_mem(struct udevice *dev, struct regmap **mapp); +int regmap_init_mem_platdata(struct udevice *dev, fdt32_t *reg, int size, + struct regmap **mapp); + /** * regmap_get_range() - Obtain the base memory address of a regmap range * -- cgit v1.2.3 From 04ecf36ba60f41f695095226e53310b4acaebf1e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 4 Jul 2016 11:58:00 -0600 Subject: dm: syscon: Add support for of-platdata Provide a new function which can cope with obtaining information from of-platdata instead of the device tree. Signed-off-by: Simon Glass --- include/syscon.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/syscon.h b/include/syscon.h index 4593b6e3ebf..34842aa4705 100644 --- a/include/syscon.h +++ b/include/syscon.h @@ -23,6 +23,17 @@ struct syscon_ops { #define syscon_get_ops(dev) ((struct syscon_ops *)(dev)->driver->ops) +#if CONFIG_IS_ENABLED(OF_PLATDATA) +/* + * We don't support 64-bit machines. If they are so resource-contrained that + * they need to use OF_PLATDATA, something is horribly wrong with the + * education of our hardware engineers. + */ +struct syscon_base_platdata { + u32 reg[2]; +}; +#endif + /** * syscon_get_regmap() - Get access to a register map * -- cgit v1.2.3 From f24770d8124c097b7b57ccc22b67aaf02bb6e850 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 4 Jul 2016 11:58:02 -0600 Subject: dm: Add a header that provides access to the of-platdata structs This header can be included from anywhere, but will only pull in the of-platdata struct definitions when this feature is enabled (and only in SPL). Signed-off-by: Simon Glass --- include/dt-structs.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 include/dt-structs.h (limited to 'include') diff --git a/include/dt-structs.h b/include/dt-structs.h new file mode 100644 index 00000000000..e13afa66082 --- /dev/null +++ b/include/dt-structs.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2016 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __DT_STTUCTS +#define __DT_STTUCTS + +/* These structures may only be used in SPL */ +#if CONFIG_IS_ENABLED(OF_PLATDATA) +struct phandle_2_cell { + const void *node; + int id; +}; +#include +#endif + +#endif -- cgit v1.2.3 From 7423daa60eb30b6613dfc19a51c55de23fd4d703 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 4 Jul 2016 11:58:03 -0600 Subject: dm: clk: Add support for of-platdata Add support for this feature in the core clock code. Signed-off-by: Simon Glass --- include/clk.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/clk.h b/include/clk.h index 2f31cf70e3d..161bc2825fc 100644 --- a/include/clk.h +++ b/include/clk.h @@ -60,6 +60,10 @@ struct clk { }; #if CONFIG_IS_ENABLED(OF_CONTROL) +struct phandle_2_cell; +int clk_get_by_index_platdata(struct udevice *dev, int index, + struct phandle_2_cell *cells, struct clk *clk); + /** * clock_get_by_index - Get/request a clock by integer index. * -- cgit v1.2.3 From fd1c2d9b6a3a9b41ae070ca47361bd6cc6aaaf09 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 4 Jul 2016 11:58:15 -0600 Subject: dm: core: Rename DM_NAME_ALLOCED to DM_FLAG_NAME_ALLOCED This is a flag. Adjust the name to be consistent with the other flags. Signed-off-by: Simon Glass --- include/dm/device.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 1bfcf3bcbc0..fc35f4dfd40 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -42,7 +42,7 @@ struct driver_info; #define DM_FLAG_BOUND (1 << 6) /* Device name is allocated and should be freed on unbind() */ -#define DM_NAME_ALLOCED (1 << 7) +#define DM_FLAG_NAME_ALLOCED (1 << 7) /** * struct udevice - An instance of a driver @@ -553,7 +553,7 @@ int device_set_name(struct udevice *dev, const char *name); /** * device_set_name_alloced() - note that a device name is allocated * - * This sets the DM_NAME_ALLOCED flag for the device, so that when it is + * This sets the DM_FLAG_NAME_ALLOCED flag for the device, so that when it is * unbound the name will be freed. This avoids memory leaks. * * @dev: Device to update -- cgit v1.2.3 From 9fa28190091e59b7c9b9ba32e5a81fa432c485b6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 4 Jul 2016 11:58:18 -0600 Subject: dm: core: Expand platdata for of-platdata devices Devices which use of-platdata have their own platdata. However, in many cases the driver will have its own auto-alloced platdata, for use with the device tree. The ofdata_to_platdata() method converts the device tree settings to platdata. With of-platdata we would not normally allocate the platdata since it is provided by the U_BOOT_DEVICE() declaration. However this is inconvenient since the of-platdata struct is closely tied to the device tree properties. It is unlikely to exactly match the platdata needed by the driver. In fact a useful approach is to declare platdata in the driver like this: struct r3288_mmc_platdata { struct dtd_rockchip_rk3288_dw_mshc of_platdata; /* the 'normal' fields go here */ }; In this case we have dt_platadata available, but the normal fields are not present, since ofdata_to_platdata() is never called. In fact driver model doesn't allocate any space for the 'normal' fields, since it sees that there is already platform data attached to the device. To make this easier, adjust driver model to allocate the full size of the struct (i.e. platdata_auto_alloc_size from the driver) and copy in the of-platdata. This means that when the driver's bind() method is called, the of-platdata will be present, followed by zero bytes for the empty 'normal field' portion. A new DM_FLAG_OF_PLATDATA flag is available that indicates that the platdata came from of-platdata. When the allocation/copy happens, the DM_FLAG_ALLOC_PDATA flag will be set as well. The dtoc tool is updated to output the platdata_size field, since U-Boot has no other way of knowing the size of the of-platdata struct. Signed-off-by: Simon Glass --- include/dm/device.h | 2 ++ include/dm/platdata.h | 5 +++++ 2 files changed, 7 insertions(+) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index fc35f4dfd40..c825d472366 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -44,6 +44,8 @@ struct driver_info; /* Device name is allocated and should be freed on unbind() */ #define DM_FLAG_NAME_ALLOCED (1 << 7) +#define DM_FLAG_OF_PLATDATA (1 << 8) + /** * struct udevice - An instance of a driver * diff --git a/include/dm/platdata.h b/include/dm/platdata.h index 6f4f00140e5..488b2ab0aea 100644 --- a/include/dm/platdata.h +++ b/include/dm/platdata.h @@ -22,10 +22,15 @@ * * @name: Driver name * @platdata: Driver-specific platform data + * @platdata_size: Size of platform data structure + * @flags: Platform data flags (DM_FLAG_...) */ struct driver_info { const char *name; const void *platdata; +#if CONFIG_IS_ENABLED(OF_PLATDATA) + uint platdata_size; +#endif }; /** -- cgit v1.2.3 From 1e6ca1a6ad7285569b22465b8387db242b310553 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 4 Jul 2016 11:58:22 -0600 Subject: dm: core: Add an implementation of regmap_init_mem_platdata() Add an implementation of this function which mirrors the functions of the automatic device-tree implementation. This can be used with of-platdata to create regmaps. Signed-off-by: Simon Glass --- include/regmap.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/regmap.h b/include/regmap.h index 922b39fad06..1eed94e47a3 100644 --- a/include/regmap.h +++ b/include/regmap.h @@ -56,7 +56,20 @@ int regmap_read(struct regmap *map, uint offset, uint *valp); */ int regmap_init_mem(struct udevice *dev, struct regmap **mapp); -int regmap_init_mem_platdata(struct udevice *dev, fdt32_t *reg, int size, +/** + * regmap_init_mem_platdata() - Set up a new memory register map for of-platdata + * + * This creates a new regmap with a list of regions passed in, rather than + * using the device tree. It only supports 32-bit machines. + * + * Use regmap_uninit() to free it. + * + * @dev: Device that uses this map + * @reg: List of address, size pairs + * @count: Number of pairs (e.g. 1 if the regmap has a single entry) + * @mapp: Returns allocated map + */ +int regmap_init_mem_platdata(struct udevice *dev, u32 *reg, int count, struct regmap **mapp); /** -- cgit v1.2.3