aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-10-03 15:39:46 -0400
committerTom Rini <trini@konsulko.com>2022-10-03 15:39:46 -0400
commit2d4591353452638132d711551fec3495b7644731 (patch)
treee12058de7f553e84f8d13e545f130c7a48973589 /include
parent4debc57a3da6c3f4d3f89a637e99206f4cea0a96 (diff)
parent6ee6e15975cad3c99fad3a66223f3fd9287a369b (diff)
downloadu-boot-2d4591353452638132d711551fec3495b7644731.tar.gz
Merge branch 'next'WIP/03Oct2022
Diffstat (limited to 'include')
-rw-r--r--include/_exports.h3
-rw-r--r--include/asm-generic/global_data.h11
-rw-r--r--include/asm-generic/gpio.h1
-rw-r--r--include/blk.h147
-rw-r--r--include/bootm.h6
-rw-r--r--include/config_distro_bootcmd.h32
-rw-r--r--include/configs/MPC8548CDS.h3
-rw-r--r--include/configs/P1010RDB.h4
-rw-r--r--include/configs/P2041RDB.h4
-rw-r--r--include/configs/T102xRDB.h4
-rw-r--r--include/configs/T104xRDB.h5
-rw-r--r--include/configs/T208xQDS.h4
-rw-r--r--include/configs/T208xRDB.h4
-rw-r--r--include/configs/am43xx_evm.h1
-rw-r--r--include/configs/brppt1.h83
-rw-r--r--include/configs/brppt2.h1
-rw-r--r--include/configs/cm_t43.h1
-rw-r--r--include/configs/ls1012aqds.h4
-rw-r--r--include/configs/ls1021aiot.h4
-rw-r--r--include/configs/ls1021aqds.h4
-rw-r--r--include/configs/ls1021atsn.h4
-rw-r--r--include/configs/ls1021atwr.h4
-rw-r--r--include/configs/ls1028a_common.h4
-rw-r--r--include/configs/ls1043aqds.h4
-rw-r--r--include/configs/ls1043ardb.h6
-rw-r--r--include/configs/ls1046afrwy.h2
-rw-r--r--include/configs/ls1046aqds.h4
-rw-r--r--include/configs/ls1046ardb.h2
-rw-r--r--include/configs/ls1088aqds.h4
-rw-r--r--include/configs/ls1088ardb.h4
-rw-r--r--include/configs/ls2080aqds.h4
-rw-r--r--include/configs/ls2080ardb.h4
-rw-r--r--include/configs/lx2160a_common.h4
-rw-r--r--include/configs/lx2160aqds.h4
-rw-r--r--include/configs/lx2160ardb.h4
-rw-r--r--include/configs/lx2162aqds.h4
-rw-r--r--include/configs/microblaze-generic.h6
-rw-r--r--include/configs/mt7981.h25
-rw-r--r--include/configs/mt7986.h25
-rw-r--r--include/configs/mx6_common.h1
-rw-r--r--include/configs/odroid.h1
-rw-r--r--include/configs/poleg.h1
-rw-r--r--include/configs/sifive-unmatched.h2
-rw-r--r--include/configs/socfpga_common.h1
-rw-r--r--include/configs/stemmy.h1
-rw-r--r--include/configs/stm32f746-disco.h1
-rw-r--r--include/configs/stm32mp13_common.h2
-rw-r--r--include/configs/stm32mp15_common.h2
-rw-r--r--include/configs/ti_omap4_common.h1
-rw-r--r--include/configs/tqma6.h4
-rw-r--r--include/configs/trats.h1
-rw-r--r--include/configs/trats2.h1
-rw-r--r--include/configs/uniphier.h2
-rw-r--r--include/configs/xilinx_versal.h4
-rw-r--r--include/configs/xilinx_versal_net.h134
-rw-r--r--include/configs/xilinx_versal_net_mini.h21
-rw-r--r--include/configs/zynq-common.h1
-rw-r--r--include/cyclic.h150
-rw-r--r--include/dm/device.h6
-rw-r--r--include/dm/of.h15
-rw-r--r--include/dm/of_access.h61
-rw-r--r--include/dm/ofnode.h385
-rw-r--r--include/dm/ofnode_decl.h37
-rw-r--r--include/dm/read.h73
-rw-r--r--include/dt-bindings/clock/mt7981-clk.h267
-rw-r--r--include/dt-bindings/clock/mt7986-clk.h249
-rw-r--r--include/dt-bindings/gpio/sandbox-gpio.h3
-rw-r--r--include/dt-bindings/pinctrl/mt65xx.h41
-rw-r--r--include/efi_config.h98
-rw-r--r--include/efi_loader.h57
-rw-r--r--include/event.h6
-rw-r--r--include/image.h124
-rw-r--r--include/init.h15
-rw-r--r--include/linux/compat.h2
-rw-r--r--include/linux/mtd/rawnand.h13
-rw-r--r--include/linux/mtd/spi-nor.h18
-rw-r--r--include/log.h5
-rw-r--r--include/malloc.h12
-rw-r--r--include/menu.h3
-rw-r--r--include/mmc.h2
-rw-r--r--include/os.h8
-rw-r--r--include/scsi.h126
-rw-r--r--include/scsi_emul.h70
-rw-r--r--include/serial.h5
-rw-r--r--include/spi-mem.h79
-rw-r--r--include/spl.h8
-rw-r--r--include/stdio.h15
-rw-r--r--include/stdio_dev.h7
-rw-r--r--include/tee/optee.h4
-rw-r--r--include/tee/optee_service.h34
-rw-r--r--include/test/test.h32
-rw-r--r--include/test/ut.h8
-rw-r--r--include/time.h19
-rw-r--r--include/wait_bit.h2
-rw-r--r--include/watchdog.h55
95 files changed, 2214 insertions, 525 deletions
diff --git a/include/_exports.h b/include/_exports.h
index f6df8b61073..1af946fac32 100644
--- a/include/_exports.h
+++ b/include/_exports.h
@@ -12,6 +12,9 @@
EXPORT_FUNC(tstc, int, tstc, void)
EXPORT_FUNC(putc, void, putc, const char)
EXPORT_FUNC(puts, void, puts, const char *)
+#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
+ EXPORT_FUNC(flush, void, flush, void)
+#endif
EXPORT_FUNC(printf, int, printf, const char*, ...)
#if (defined(CONFIG_X86) && !defined(CONFIG_X86_64)) || defined(CONFIG_PPC)
EXPORT_FUNC(irq_install_handler, void, install_hdlr,
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index 2a747d91e16..2d55fe2ac0f 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -20,6 +20,7 @@
*/
#ifndef __ASSEMBLY__
+#include <cyclic.h>
#include <event_internal.h>
#include <fdtdec.h>
#include <membuff.h>
@@ -478,6 +479,12 @@ struct global_data {
*/
struct event_state event_state;
#endif
+#ifdef CONFIG_CYCLIC
+ /**
+ * @cyclic: cyclic driver data
+ */
+ struct cyclic_drv *cyclic;
+#endif
/**
* @dmtag_list: List of DM tags
*/
@@ -639,6 +646,10 @@ enum gd_flags {
* @GD_FLG_SMP_READY: SMP initialization is complete
*/
GD_FLG_SMP_READY = 0x80000,
+ /**
+ * @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests
+ */
+ GD_FLG_FDT_CHANGED = 0x100000,
};
#endif /* __ASSEMBLY__ */
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 81f63f06f15..0fcf70983fb 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -127,6 +127,7 @@ struct gpio_desc {
#define GPIOD_OPEN_SOURCE BIT(6) /* GPIO is open source type */
#define GPIOD_PULL_UP BIT(7) /* GPIO has pull-up enabled */
#define GPIOD_PULL_DOWN BIT(8) /* GPIO has pull-down enabled */
+#define GPIOD_IS_AF BIT(9) /* GPIO is an alternate function */
/* Flags for updating the above */
#define GPIOD_MASK_DIR (GPIOD_IS_OUT | GPIOD_IS_IN | \
diff --git a/include/blk.h b/include/blk.h
index 9503369db83..8806c382d4e 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -7,6 +7,7 @@
#ifndef BLK_H
#define BLK_H
+#include <dm/uclass-id.h>
#include <efi.h>
#ifdef CONFIG_SYS_64BIT_LBA
@@ -21,26 +22,10 @@ typedef ulong lbaint_t;
struct udevice;
-/* Interface types: */
-enum if_type {
- IF_TYPE_UNKNOWN = 0,
- IF_TYPE_IDE,
- IF_TYPE_SCSI,
- IF_TYPE_ATAPI,
- IF_TYPE_USB,
- IF_TYPE_DOC,
- IF_TYPE_MMC,
- IF_TYPE_SD,
- IF_TYPE_SATA,
- IF_TYPE_HOST,
- IF_TYPE_NVME,
- IF_TYPE_EFI_LOADER,
- IF_TYPE_PVBLOCK,
- IF_TYPE_VIRTIO,
- IF_TYPE_EFI_MEDIA,
-
- IF_TYPE_COUNT, /* Number of interface types */
-};
+static inline bool blk_enabled(void)
+{
+ return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_SPL_LEGACY_BLOCK);
+}
#define BLK_VEN_SIZE 40
#define BLK_PRD_SIZE 20
@@ -69,7 +54,7 @@ struct blk_desc {
* TODO: With driver model we should be able to use the parent
* device's uclass instead.
*/
- enum if_type if_type; /* type of the interface */
+ enum uclass_id uclass_id; /* type of the interface */
int devnum; /* device number */
unsigned char part_type; /* partition type */
unsigned char target; /* target SCSI ID */
@@ -129,7 +114,7 @@ int blkcache_init(void);
/**
* blkcache_read() - attempt to read a set of blocks from cache
*
- * @param iftype - IF_TYPE_x for type of device
+ * @param iftype - uclass_id_x for type of device
* @param dev - device index of particular type
* @param start - starting block number
* @param blkcnt - number of blocks to read
@@ -146,7 +131,7 @@ int blkcache_read(int iftype, int dev,
* blkcache_fill() - make data read from a block device available
* to the block cache
*
- * @param iftype - IF_TYPE_x for type of device
+ * @param iftype - uclass_id_x for type of device
* @param dev - device index of particular type
* @param start - starting block number
* @param blkcnt - number of blocks available
@@ -162,7 +147,7 @@ void blkcache_fill(int iftype, int dev,
* blkcache_invalidate() - discard the cache for a set of blocks
* because of a write or device (re)initialization.
*
- * @param iftype - IF_TYPE_x for type of device
+ * @param iftype - uclass_id_x for type of device
* @param dev - device index of particular type
*/
void blkcache_invalidate(int iftype, int dev);
@@ -294,22 +279,22 @@ unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
* This function does not activate the device. The device will be returned
* whether or not it is activated.
*
- * @if_type: Interface type (enum if_type_t)
+ * @uclass_id: Interface type (enum uclass_id_t)
* @devnum: Device number (specific to each interface type)
* @devp: the device, if found
* Return: 0 if found, -ENODEV if no device found, or other -ve error value
*/
-int blk_find_device(int if_type, int devnum, struct udevice **devp);
+int blk_find_device(int uclass_id, int devnum, struct udevice **devp);
/**
* blk_get_device() - Find and probe a block device ready for use
*
- * @if_type: Interface type (enum if_type_t)
+ * @uclass_id: Interface type (enum uclass_id_t)
* @devnum: Device number (specific to each interface type)
* @devp: the device, if found
* Return: 0 if found, -ENODEV if no device found, or other -ve error value
*/
-int blk_get_device(int if_type, int devnum, struct udevice **devp);
+int blk_get_device(int uclass_id, int devnum, struct udevice **devp);
/**
* blk_first_device() - Find the first device for a given interface
@@ -320,7 +305,7 @@ int blk_get_device(int if_type, int devnum, struct udevice **devp);
* @devp: the device, if found
* Return: 0 if found, -ENODEV if no device, or other -ve error value
*/
-int blk_first_device(int if_type, struct udevice **devp);
+int blk_first_device(int uclass_id, struct udevice **devp);
/**
* blk_next_device() - Find the next device for a given interface
@@ -342,7 +327,7 @@ int blk_next_device(struct udevice **devp);
* @parent: Parent of the new device
* @drv_name: Driver name to use for the block device
* @name: Name for the device
- * @if_type: Interface type (enum if_type_t)
+ * @uclass_id: Interface type (enum uclass_id_t)
* @devnum: Device number, specific to the interface type, or -1 to
* allocate the next available number
* @blksz: Block size of the device in bytes (typically 512)
@@ -350,7 +335,7 @@ int blk_next_device(struct udevice **devp);
* @devp: the new device (which has not been probed)
*/
int blk_create_device(struct udevice *parent, const char *drv_name,
- const char *name, int if_type, int devnum, int blksz,
+ const char *name, int uclass_id, int devnum, int blksz,
lbaint_t lba, struct udevice **devp);
/**
@@ -359,7 +344,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
* @parent: Parent of the new device
* @drv_name: Driver name to use for the block device
* @name: Name for the device (parent name is prepended)
- * @if_type: Interface type (enum if_type_t)
+ * @uclass_id: Interface type (enum uclass_id_t)
* @devnum: Device number, specific to the interface type, or -1 to
* allocate the next available number
* @blksz: Block size of the device in bytes (typically 512)
@@ -367,7 +352,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
* @devp: the new device (which has not been probed)
*/
int blk_create_devicef(struct udevice *parent, const char *drv_name,
- const char *name, int if_type, int devnum, int blksz,
+ const char *name, int uclass_id, int devnum, int blksz,
lbaint_t lba, struct udevice **devp);
/**
@@ -387,33 +372,33 @@ int blk_probe_or_unbind(struct udevice *dev);
*
* The devices are removed and then unbound.
*
- * @if_type: Interface type to unbind
+ * @uclass_id: Interface type to unbind
* Return: 0 if OK, -ve on error
*/
-int blk_unbind_all(int if_type);
+int blk_unbind_all(int uclass_id);
/**
* blk_find_max_devnum() - find the maximum device number for an interface type
*
- * Finds the last allocated device number for an interface type @if_type. The
+ * Finds the last allocated device number for an interface type @uclass_id. The
* next number is safe to use for a newly allocated device.
*
- * @if_type: Interface type to scan
+ * @uclass_id: Interface type to scan
* Return: maximum device number found, or -ENODEV if none, or other -ve on
* error
*/
-int blk_find_max_devnum(enum if_type if_type);
+int blk_find_max_devnum(enum uclass_id uclass_id);
/**
* blk_next_free_devnum() - get the next device number for an interface type
*
* Finds the next number that is safe to use for a newly allocated device for
- * an interface type @if_type.
+ * an interface type @uclass_id.
*
- * @if_type: Interface type to scan
+ * @uclass_id: Interface type to scan
* Return: next device number safe to use, or -ve on error
*/
-int blk_next_free_devnum(enum if_type if_type);
+int blk_next_free_devnum(enum uclass_id uclass_id);
/**
* blk_select_hwpart() - select a hardware partition
@@ -462,7 +447,7 @@ static inline ulong blk_dread(struct blk_desc *block_dev, lbaint_t start,
lbaint_t blkcnt, void *buffer)
{
ulong blks_read;
- if (blkcache_read(block_dev->if_type, block_dev->devnum,
+ if (blkcache_read(block_dev->uclass_id, block_dev->devnum,
start, blkcnt, block_dev->blksz, buffer))
return blkcnt;
@@ -473,7 +458,7 @@ static inline ulong blk_dread(struct blk_desc *block_dev, lbaint_t start,
*/
blks_read = block_dev->block_read(block_dev, start, blkcnt, buffer);
if (blks_read == blkcnt)
- blkcache_fill(block_dev->if_type, block_dev->devnum,
+ blkcache_fill(block_dev->uclass_id, block_dev->devnum,
start, blkcnt, block_dev->blksz, buffer);
return blks_read;
@@ -482,14 +467,14 @@ static inline ulong blk_dread(struct blk_desc *block_dev, lbaint_t start,
static inline ulong blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
lbaint_t blkcnt, const void *buffer)
{
- blkcache_invalidate(block_dev->if_type, block_dev->devnum);
+ blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
return block_dev->block_write(block_dev, start, blkcnt, buffer);
}
static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
lbaint_t blkcnt)
{
- blkcache_invalidate(block_dev->if_type, block_dev->devnum);
+ blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
return block_dev->block_erase(block_dev, start, blkcnt);
}
@@ -500,15 +485,15 @@ static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
* driver should be provided using U_BOOT_LEGACY_BLK() for each interface
* type that is to be supported.
*
- * @if_typename: Interface type name
- * @if_type: Interface type
+ * @uclass_idname: Interface type name
+ * @uclass_id: Interface type
* @max_devs: Maximum number of devices supported
* @desc: Pointer to list of devices for this interface type,
* or NULL to use @get_dev() instead
*/
struct blk_driver {
- const char *if_typename;
- enum if_type if_type;
+ const char *uclass_idname;
+ enum uclass_id uclass_id;
int max_devs;
struct blk_desc *desc;
/**
@@ -555,33 +540,33 @@ struct blk_driver {
#define U_BOOT_LEGACY_BLK(__name) \
ll_entry_declare(struct blk_driver, __name, blk_driver)
-struct blk_driver *blk_driver_lookup_type(int if_type);
+struct blk_driver *blk_driver_lookup_type(int uclass_id);
#endif /* !CONFIG_BLK */
/**
- * blk_get_devnum_by_typename() - Get a block device by type and number
+ * blk_get_devnum_by_uclass_idname() - Get a block device by type and number
*
* This looks through the available block devices of the given type, returning
* the one with the given @devnum.
*
- * @if_type: Block device type
+ * @uclass_id: Block device type
* @devnum: Device number
* Return: point to block device descriptor, or NULL if not found
*/
-struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum);
+struct blk_desc *blk_get_devnum_by_uclass_id(enum uclass_id uclass_id, int devnum);
/**
- * blk_get_devnum_by_type() - Get a block device by type name, and number
+ * blk_get_devnum_by_uclass_id() - Get a block device by type name, and number
*
- * This looks up the block device type based on @if_typename, then calls
- * blk_get_devnum_by_type().
+ * This looks up the block device type based on @uclass_idname, then calls
+ * blk_get_devnum_by_uclass_id().
*
- * @if_typename: Block device type name
+ * @uclass_idname: Block device type name
* @devnum: Device number
* Return: point to block device descriptor, or NULL if not found
*/
-struct blk_desc *blk_get_devnum_by_typename(const char *if_typename,
+struct blk_desc *blk_get_devnum_by_uclass_idname(const char *uclass_idname,
int devnum);
/**
@@ -600,34 +585,34 @@ int blk_dselect_hwpart(struct blk_desc *desc, int hwpart);
/**
* blk_list_part() - list the partitions for block devices of a given type
*
- * This looks up the partition type for each block device of type @if_type,
+ * This looks up the partition type for each block device of type @uclass_id,
* then displays a list of partitions.
*
- * @if_type: Block device type
+ * @uclass_id: Block device type
* Return: 0 if OK, -ENODEV if there is none of that type
*/
-int blk_list_part(enum if_type if_type);
+int blk_list_part(enum uclass_id uclass_id);
/**
* blk_list_devices() - list the block devices of a given type
*
- * This lists each block device of the type @if_type, showing the capacity
+ * This lists each block device of the type @uclass_id, showing the capacity
* as well as type-specific information.
*
- * @if_type: Block device type
+ * @uclass_id: Block device type
*/
-void blk_list_devices(enum if_type if_type);
+void blk_list_devices(enum uclass_id uclass_id);
/**
* blk_show_device() - show information about a given block device
*
* This shows the block device capacity as well as type-specific information.
*
- * @if_type: Block device type
+ * @uclass_id: Block device type
* @devnum: Device number
* Return: 0 if OK, -ENODEV for invalid device number
*/
-int blk_show_device(enum if_type if_type, int devnum);
+int blk_show_device(enum uclass_id uclass_id, int devnum);
/**
* blk_print_device_num() - show information about a given block device
@@ -635,45 +620,45 @@ int blk_show_device(enum if_type if_type, int devnum);
* This is similar to blk_show_device() but returns an error if the block
* device type is unknown.
*
- * @if_type: Block device type
+ * @uclass_id: Block device type
* @devnum: Device number
* Return: 0 if OK, -ENODEV for invalid device number, -ENOENT if the block
* device is not connected
*/
-int blk_print_device_num(enum if_type if_type, int devnum);
+int blk_print_device_num(enum uclass_id uclass_id, int devnum);
/**
* blk_print_part_devnum() - print the partition information for a device
*
- * @if_type: Block device type
+ * @uclass_id: Block device type
* @devnum: Device number
* Return: 0 if OK, -ENOENT if the block device is not connected, -ENOSYS if
* the interface type is not supported, other -ve on other error
*/
-int blk_print_part_devnum(enum if_type if_type, int devnum);
+int blk_print_part_devnum(enum uclass_id uclass_id, int devnum);
/**
* blk_read_devnum() - read blocks from a device
*
- * @if_type: Block device type
+ * @uclass_id: Block device type
* @devnum: Device number
* @blkcnt: Number of blocks to read
* @buffer: Address to write data to
* Return: number of blocks read, or -ve error number on error
*/
-ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_read_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
lbaint_t blkcnt, void *buffer);
/**
* blk_write_devnum() - write blocks to a device
*
- * @if_type: Block device type
+ * @uclass_id: Block device type
* @devnum: Device number
* @blkcnt: Number of blocks to write
* @buffer: Address to read data from
* Return: number of blocks written, or -ve error number on error
*/
-ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_write_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
lbaint_t blkcnt, const void *buffer);
/**
@@ -682,31 +667,31 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
* This is similar to blk_dselect_hwpart() but it looks up the interface and
* device number.
*
- * @if_type: Block device type
+ * @uclass_id: Block device type
* @devnum: Device number
* @hwpart: Partition number to select
* Return: 0 if OK, -ve on error
*/
-int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
+int blk_select_hwpart_devnum(enum uclass_id uclass_id, int devnum, int hwpart);
/**
- * blk_get_if_type_name() - Get the name of an interface type
+ * blk_get_uclass_name() - Get the name of an interface type
*
- * @if_type: Interface type to check
+ * @uclass_id: Interface type to check
* Return: name of interface, or NULL if none
*/
-const char *blk_get_if_type_name(enum if_type if_type);
+const char *blk_get_uclass_name(enum uclass_id uclass_id);
/**
* blk_common_cmd() - handle common commands with block devices
*
* @args: Number of arguments to the command (argv[0] is the command itself)
* @argv: Command arguments
- * @if_type: Interface type
+ * @uclass_id: Interface type
* @cur_devnump: Current device number for this interface type
* Return: 0 if OK, CMD_RET_ERROR on error
*/
-int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
+int blk_common_cmd(int argc, char *const argv[], enum uclass_id uclass_id,
int *cur_devnump);
enum blk_flag_t {
diff --git a/include/bootm.h b/include/bootm.h
index 7ed5650fcaa..044a4797ed3 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -33,7 +33,7 @@ struct cmd_tbl;
* not return.
*/
typedef int boot_os_fn(int flag, int argc, char *const argv[],
- bootm_headers_t *images);
+ struct bootm_headers *images);
extern boot_os_fn do_bootm_linux;
extern boot_os_fn do_bootm_vxworks;
@@ -47,7 +47,7 @@ int bootm_host_load_images(const void *fit, int cfg_noffset);
#endif
int boot_selected_os(int argc, char *const argv[], int state,
- bootm_headers_t *images, boot_os_fn *boot_fn);
+ struct bootm_headers *images, boot_os_fn *boot_fn);
ulong bootm_disable_interrupts(void);
@@ -56,7 +56,7 @@ int bootm_find_images(int flag, int argc, char *const argv[], ulong start,
ulong size);
int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[], int states, bootm_headers_t *images,
+ char *const argv[], int states, struct bootm_headers *images,
int boot_progress);
void arch_preboot_os(void);
diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 5506f3168f3..fcb319a20ae 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -162,11 +162,13 @@
"scan_dev_for_efi=" \
"setenv efi_fdtfile ${fdtfile}; " \
BOOTENV_EFI_SET_FDTFILE_FALLBACK \
+ BOOTENV_RUN_EXTENSION_INIT \
"for prefix in ${efi_dtb_prefixes}; do " \
"if test -e ${devtype} " \
"${devnum}:${distro_bootpart} " \
"${prefix}${efi_fdtfile}; then " \
"run load_efi_dtb; " \
+ BOOTENV_RUN_EXTENSION_APPLY \
"fi;" \
"done;" \
"run boot_efi_bootmgr;" \
@@ -418,6 +420,34 @@
BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE
#endif
+#if defined(CONFIG_CMD_EXTENSION)
+#define BOOTENV_RUN_EXTENSION_INIT "run extension_init; "
+#define BOOTENV_RUN_EXTENSION_APPLY "run extension_apply; "
+#define BOOTENV_SET_EXTENSION_NEED_INIT \
+ "extension_need_init=; " \
+ "setenv extension_overlay_addr ${fdtoverlay_addr_r}; "
+#define BOOTENV_SHARED_EXTENSION \
+ "extension_init=" \
+ "echo Extension init...; " \
+ "if ${extension_need_init}; then " \
+ "extension_need_init=false; " \
+ "extension scan; " \
+ "fi\0" \
+ \
+ "extension_overlay_cmd=" \
+ "load ${devtype} ${devnum}:${distro_bootpart} " \
+ "${extension_overlay_addr} ${prefix}${extension_overlay_name}\0" \
+ "extension_apply=" \
+ "if fdt addr -q ${fdt_addr_r}; then " \
+ "extension apply all; " \
+ "fi\0"
+#else
+#define BOOTENV_RUN_EXTENSION_INIT
+#define BOOTENV_RUN_EXTENSION_APPLY
+#define BOOTENV_SET_EXTENSION_NEED_INIT
+#define BOOTENV_SHARED_EXTENSION
+#endif
+
#define BOOTENV_DEV_NAME(devtypeu, devtypel, instance, ...) \
BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance, ## __VA_ARGS__)
#define BOOTENV_BOOT_TARGETS \
@@ -437,6 +467,7 @@
BOOTENV_SHARED_UBIFS \
BOOTENV_SHARED_EFI \
BOOTENV_SHARED_VIRTIO \
+ BOOTENV_SHARED_EXTENSION \
"boot_prefixes=/ /boot/\0" \
"boot_scripts=boot.scr.uimg boot.scr\0" \
"boot_script_dhcp=boot.scr.uimg\0" \
@@ -501,6 +532,7 @@
BOOTENV_SET_NVME_NEED_INIT \
BOOTENV_SET_IDE_NEED_INIT \
BOOTENV_SET_VIRTIO_NEED_INIT \
+ BOOTENV_SET_EXTENSION_NEED_INIT \
"for target in ${boot_targets}; do " \
"run bootcmd_${target}; " \
"done\0"
diff --git a/include/configs/MPC8548CDS.h b/include/configs/MPC8548CDS.h
index 0c710ef8865..eb7a8351794 100644
--- a/include/configs/MPC8548CDS.h
+++ b/include/configs/MPC8548CDS.h
@@ -255,9 +255,6 @@
#define CONFIG_SYS_I2C_NOPROBES { {0, 0x69} }
#endif
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_CCID
-
/*
* General PCI
* Memory space is mapped 1-1, but I/O space must start from 0.
diff --git a/include/configs/P1010RDB.h b/include/configs/P1010RDB.h
index 7f5eaf88aa4..8492a64d439 100644
--- a/include/configs/P1010RDB.h
+++ b/include/configs/P1010RDB.h
@@ -351,10 +351,6 @@ extern unsigned long get_sdram_size(void);
/* I2C EEPROM */
#if defined(CONFIG_TARGET_P1010RDB_PB)
-#ifdef CONFIG_ID_EEPROM
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#endif
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
#define MAX_NUM_PORTS 9 /* for 128Bytes EEPROM */
#endif
/* enable read and write access to EEPROM */
diff --git a/include/configs/P2041RDB.h b/include/configs/P2041RDB.h
index 11a3db59025..925720d2340 100644
--- a/include/configs/P2041RDB.h
+++ b/include/configs/P2041RDB.h
@@ -67,10 +67,6 @@
#define CONFIG_SYS_DCSRBAR_PHYS 0xf00000000ull
#endif
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/*
* DDR Setup
*/
diff --git a/include/configs/T102xRDB.h b/include/configs/T102xRDB.h
index a5461d7fc68..e0aa2b9598c 100644
--- a/include/configs/T102xRDB.h
+++ b/include/configs/T102xRDB.h
@@ -112,10 +112,6 @@
#define CONFIG_SYS_DCSRBAR_PHYS 0xf00000000ull
#endif
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/*
* DDR Setup
*/
diff --git a/include/configs/T104xRDB.h b/include/configs/T104xRDB.h
index 560083c5b31..918aabcbb5c 100644
--- a/include/configs/T104xRDB.h
+++ b/include/configs/T104xRDB.h
@@ -292,11 +292,6 @@
#if defined(CONFIG_TARGET_T1042RDB_PI) || \
defined(CONFIG_TARGET_T1040D4RDB) || \
defined(CONFIG_TARGET_T1042D4RDB)
-/* LDI/DVI Encoder for display */
-#define CONFIG_SYS_I2C_LDI_ADDR 0x38
-#define CONFIG_SYS_I2C_DVI_ADDR 0x75
-#define CONFIG_SYS_I2C_DVI_BUS_NUM 0
-
/*
* RTC configuration
*/
diff --git a/include/configs/T208xQDS.h b/include/configs/T208xQDS.h
index fc068c94a9e..e852fc4cdc8 100644
--- a/include/configs/T208xQDS.h
+++ b/include/configs/T208xQDS.h
@@ -82,10 +82,6 @@
#define CONFIG_SYS_DCSRBAR 0xf0000000
#define CONFIG_SYS_DCSRBAR_PHYS 0xf00000000ull
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/*
* DDR Setup
*/
diff --git a/include/configs/T208xRDB.h b/include/configs/T208xRDB.h
index 056e2d1925b..68cf13581ad 100644
--- a/include/configs/T208xRDB.h
+++ b/include/configs/T208xRDB.h
@@ -77,10 +77,6 @@
#define CONFIG_SYS_DCSRBAR 0xf0000000
#define CONFIG_SYS_DCSRBAR_PHYS 0xf00000000ull
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/*
* DDR Setup
*/
diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h
index 87d3a27099b..fc82a8c003e 100644
--- a/include/configs/am43xx_evm.h
+++ b/include/configs/am43xx_evm.h
@@ -29,7 +29,6 @@
/* SPL defines. */
/* Enabling L2 Cache */
-#define CONFIG_SYS_L2_PL310
#define CONFIG_SYS_PL310_BASE 0x48242000
/*
diff --git a/include/configs/brppt1.h b/include/configs/brppt1.h
index 6cb1a106002..2c5236aa58b 100644
--- a/include/configs/brppt1.h
+++ b/include/configs/brppt1.h
@@ -27,44 +27,18 @@
* the Linux kernel.
*/
-#ifdef CONFIG_SPL_OS_BOOT
-/* RAW SD card / eMMC */
-
-#endif /* CONFIG_SPL_OS_BOOT */
-
-#ifdef CONFIG_MTD_RAW_NAND
-#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
-#endif /* CONFIG_MTD_RAW_NAND */
-
-#ifdef CONFIG_MTD_RAW_NAND
-#define NANDTGTS \
-"cfgscr=mw ${dtbaddr} 0; nand read ${cfgaddr} cfgscr && source ${cfgaddr};" \
-" fdt addr ${dtbaddr} || cp ${fdtcontroladdr} ${dtbaddr} 4000\0" \
-"nandargs=setenv bootargs console=${console} ${optargs} ${optargs_rot} " \
- "root=mtd6 rootfstype=jffs2 b_mode=${b_mode}\0" \
-"b_nand=nand read ${loadaddr} kernel; nand read ${dtbaddr} dtb; " \
- "run nandargs; run cfgscr; bootz ${loadaddr} - ${dtbaddr}\0" \
-"b_tgts_std=usb0 nand net\0" \
-"b_tgts_rcy=net usb0 nand\0" \
-"b_tgts_pme=usb0 nand net\0"
-#else
-#define NANDTGTS ""
-#endif /* CONFIG_MTD_RAW_NAND */
-
-#define MMCSPI_TGTS \
+#define MMC_TGTS \
"t30args#0=setenv bootargs ${optargs_rot} ${optargs} console=${console} " \
- "b_mode=${b_mode} root=/dev/mmcblk0p2 rootfstype=ext4\0" \
+ "b_mode=${b_mode} root=${root_dev} rootfstype=ext4 rootwait\0" \
"b_t30lgcy#0=" \
- "load ${loaddev}:2 ${loadaddr} /boot/PPTImage.md5 && " \
"load ${loaddev}:2 ${loadaddr} /boot/zImage && " \
- "load ${loaddev}:2 ${dtbaddr} /boot/am335x-ppt30.dtb || " \
- "load ${loaddev}:1 ${dtbaddr} am335x-ppt30-legacy.dtb; "\
+ "run load_dtb && " \
"run t30args#0; run cfgscr; bootz ${loadaddr} - ${dtbaddr}\0" \
"t30args#1=setenv bootargs ${optargs_rot} ${optargs} console=${console} " \
"b_mode=${b_mode}\0" \
"b_t30lgcy#1=" \
"load ${loaddev}:1 ${loadaddr} zImage && " \
- "load ${loaddev}:1 ${dtbaddr} am335x-ppt30.dtb && " \
+ "load ${loaddev}:1 ${dtbaddr} am335x-brppt30.dtb && " \
"load ${loaddev}:1 ${ramaddr} rootfsPPT30.uboot && " \
"run t30args#1; run cfgscr; bootz ${loadaddr} ${ramaddr} ${dtbaddr}\0" \
"b_mmc0=load ${loaddev}:1 ${scraddr} bootscr.img && source ${scraddr}\0" \
@@ -72,28 +46,25 @@
"b_tgts_std=mmc0 mmc1 t30lgcy#0 t30lgcy#1 usb0 net\0" \
"b_tgts_rcy=t30lgcy#1 usb0 net\0" \
"b_tgts_pme=net usb0 mmc0 mmc1\0" \
-"loaddev=mmc 1\0"
+"loaddev=mmc 1\0" \
+"root_dev=/dev/mmcblk0p2\0" \
+"load_dtb=load ${loaddev}:2 ${dtbaddr} /boot/am335x-brppt30.dtb; " \
+ "if test $? -eq 0; then " \
+ "setenv root_dev /dev/mmcblk1p2; " \
+ "else; " \
+ "load ${loaddev}:1 ${dtbaddr} am335x-brppt30-legacy.dtb; " \
+ "fi;\0"
#ifdef CONFIG_ENV_IS_IN_MMC
#define MMCTGTS \
-MMCSPI_TGTS \
-"cfgscr=mw ${dtbaddr} 0;" \
+MMC_TGTS \
+"cfgscr=mw ${cfgaddr} 0;" \
" mmc dev 1; mmc read ${cfgaddr} 200 80; source ${cfgaddr};" \
" fdt addr ${dtbaddr} || cp ${fdtcontroladdr} ${dtbaddr} 4000\0"
#else
#define MMCTGTS ""
#endif /* CONFIG_MMC */
-#ifdef CONFIG_SPI
-#define SPITGTS \
-MMCSPI_TGTS \
-"cfgscr=mw ${dtbaddr} 0;" \
-" sf probe; sf read ${cfgaddr} 0xC0000 10000; source ${cfgaddr};" \
-" fdt addr ${dtbaddr} || cp ${fdtcontroladdr} ${dtbaddr} 4000\0"
-#else
-#define SPITGTS ""
-#endif /* CONFIG_SPI */
-
#define LOAD_OFFSET(x) 0x8##x
#define CONFIG_EXTRA_ENV_SETTINGS \
@@ -110,8 +81,6 @@ BUR_COMMON_ENV \
"b_usb0=usb start && load usb 0 ${scraddr} bootscr.img && source ${scraddr}\0" \
"b_net=tftp ${scraddr} netscript.img && source ${scraddr}\0" \
MMCTGTS \
-SPITGTS \
-NANDTGTS \
"b_deftgts=if test ${b_mode} = 12; then setenv b_tgts ${b_tgts_pme};" \
" elif test ${b_mode} = 0; then setenv b_tgts ${b_tgts_rcy};" \
" else setenv b_tgts ${b_tgts_std}; fi\0" \
@@ -119,28 +88,4 @@ NANDTGTS \
" do echo \"### booting ${target} ###\"; run b_${target};" \
" if test ${b_break} = 1; then; exit; fi; done\0"
-#ifdef CONFIG_MTD_RAW_NAND
-/*
- * GPMC block. We support 1 device and the physical address to
- * access CS0 at is 0x8000000.
- */
-#define CONFIG_SYS_MAX_NAND_DEVICE 1
-#define CONFIG_SYS_NAND_BASE 0x8000000
-/* don't change OMAP_ELM, ECCSCHEME. ROM code only supports this */
-#define CONFIG_SYS_NAND_ECCPOS {2, 3, 4, 5, 6, 7, 8, 9, \
- 10, 11, 12, 13, 14, 15, 16, 17, \
- 18, 19, 20, 21, 22, 23, 24, 25, \
- 26, 27, 28, 29, 30, 31, 32, 33, \
- 34, 35, 36, 37, 38, 39, 40, 41, \
- 42, 43, 44, 45, 46, 47, 48, 49, \
- 50, 51, 52, 53, 54, 55, 56, 57, }
-
-#define CONFIG_SYS_NAND_ECCSIZE 512
-#define CONFIG_SYS_NAND_ECCBYTES 14
-
-#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
-
-#define CONFIG_NAND_OMAP_GPMC_WSCFG 1
-#endif /* CONFIG_MTD_RAW_NAND */
-
#endif /* ! __CONFIG_BRPPT1_H__ */
diff --git a/include/configs/brppt2.h b/include/configs/brppt2.h
index adaba410ce9..0c7fe5f3abb 100644
--- a/include/configs/brppt2.h
+++ b/include/configs/brppt2.h
@@ -13,7 +13,6 @@
/* -- i.mx6 specifica -- */
#ifndef CONFIG_SYS_L2CACHE_OFF
-#define CONFIG_SYS_L2_PL310
#define CONFIG_SYS_PL310_BASE L2_PL310_BASE
#endif /* !CONFIG_SYS_L2CACHE_OFF */
diff --git a/include/configs/cm_t43.h b/include/configs/cm_t43.h
index 07c5cb8ded1..50cb2a47187 100644
--- a/include/configs/cm_t43.h
+++ b/include/configs/cm_t43.h
@@ -36,7 +36,6 @@
#define CONFIG_POWER_TPS65218
/* Enabling L2 Cache */
-#define CONFIG_SYS_L2_PL310
#define CONFIG_SYS_PL310_BASE 0x48242000
/*
diff --git a/include/configs/ls1012aqds.h b/include/configs/ls1012aqds.h
index 48fe8288aa1..9ad3a120118 100644
--- a/include/configs/ls1012aqds.h
+++ b/include/configs/ls1012aqds.h
@@ -49,10 +49,6 @@
#define RTC
#define CONFIG_SYS_I2C_RTC_ADDR 0x51 /* Channel 3*/
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/* Voltage monitor on channel 2*/
#define I2C_VOL_MONITOR_ADDR 0x40
diff --git a/include/configs/ls1021aiot.h b/include/configs/ls1021aiot.h
index ec688741a07..f418c8ccf71 100644
--- a/include/configs/ls1021aiot.h
+++ b/include/configs/ls1021aiot.h
@@ -59,10 +59,6 @@
* I2C
*/
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/*
* MMC
*/
diff --git a/include/configs/ls1021aqds.h b/include/configs/ls1021aqds.h
index aaf28a346d0..d383b6c655b 100644
--- a/include/configs/ls1021aqds.h
+++ b/include/configs/ls1021aqds.h
@@ -246,10 +246,6 @@
/* GPIO */
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/*
* I2C bus multiplexer
*/
diff --git a/include/configs/ls1021atsn.h b/include/configs/ls1021atsn.h
index f318eb58603..157f218a8ec 100644
--- a/include/configs/ls1021atsn.h
+++ b/include/configs/ls1021atsn.h
@@ -71,10 +71,6 @@
/* I2C */
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/* PCIe */
#define FSL_PCIE_COMPAT "fsl,ls1021a-pcie"
diff --git a/include/configs/ls1021atwr.h b/include/configs/ls1021atwr.h
index 5f3e8d5b712..83c74b66d3a 100644
--- a/include/configs/ls1021atwr.h
+++ b/include/configs/ls1021atwr.h
@@ -161,10 +161,6 @@
/* GPIO */
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 1
-
#define CONFIG_PEN_ADDR_BIG_ENDIAN
#define CONFIG_SMP_PEN_ADDR 0x01ee0200
diff --git a/include/configs/ls1028a_common.h b/include/configs/ls1028a_common.h
index 8413e68f3a7..24422665e87 100644
--- a/include/configs/ls1028a_common.h
+++ b/include/configs/ls1028a_common.h
@@ -63,10 +63,6 @@
#define I2C_MUX_PCA_ADDR_PRI 0x77 /* Primary Mux*/
#define I2C_MUX_CH_DEFAULT 0x8
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/* DisplayPort */
#define DP_PWD_EN_DEFAULT_MASK 0x8
diff --git a/include/configs/ls1043aqds.h b/include/configs/ls1043aqds.h
index 49f6cd6be11..4158d15cc0f 100644
--- a/include/configs/ls1043aqds.h
+++ b/include/configs/ls1043aqds.h
@@ -37,10 +37,6 @@
/* SATA */
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
#define CONFIG_SYS_SATA AHCI_BASE_ADDR
/*
diff --git a/include/configs/ls1043ardb.h b/include/configs/ls1043ardb.h
index ff5da5d2754..4bfe4e3ecd0 100644
--- a/include/configs/ls1043ardb.h
+++ b/include/configs/ls1043ardb.h
@@ -184,12 +184,6 @@
#define CONFIG_SYS_CS2_FTIM2 CONFIG_SYS_CPLD_FTIM2
#define CONFIG_SYS_CS2_FTIM3 CONFIG_SYS_CPLD_FTIM3
-/* EEPROM */
-#ifndef SPL_NO_EEPROM
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-#endif
-
/*
* Environment
*/
diff --git a/include/configs/ls1046afrwy.h b/include/configs/ls1046afrwy.h
index 43717cdd4e6..2df5f3f6c0b 100644
--- a/include/configs/ls1046afrwy.h
+++ b/include/configs/ls1046afrwy.h
@@ -59,8 +59,6 @@
#define CONFIG_SYS_CS0_FTIM3 CONFIG_SYS_NAND_FTIM3
/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
#define I2C_RETIMER_ADDR 0x18
/* I2C bus multiplexer */
diff --git a/include/configs/ls1046aqds.h b/include/configs/ls1046aqds.h
index 869bbd76346..1f54e516455 100644
--- a/include/configs/ls1046aqds.h
+++ b/include/configs/ls1046aqds.h
@@ -54,10 +54,6 @@
#define CFG_LPUART_EN 0x2
#endif
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/*
* IFC Definitions
*/
diff --git a/include/configs/ls1046ardb.h b/include/configs/ls1046ardb.h
index 382d5c76461..5d329577a63 100644
--- a/include/configs/ls1046ardb.h
+++ b/include/configs/ls1046ardb.h
@@ -98,8 +98,6 @@
#define CONFIG_SYS_CS2_FTIM3 CONFIG_SYS_CPLD_FTIM3
/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
#define I2C_RETIMER_ADDR 0x18
/* PMIC */
diff --git a/include/configs/ls1088aqds.h b/include/configs/ls1088aqds.h
index 747ee9d4428..2d3351e6b4f 100644
--- a/include/configs/ls1088aqds.h
+++ b/include/configs/ls1088aqds.h
@@ -287,10 +287,6 @@
#define RTC
#define CONFIG_SYS_I2C_RTC_ADDR 0x51 /* Channel 3*/
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
#ifdef CONFIG_FSL_DSPI
#if !defined(CONFIG_TFABOOT) && \
!defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI)
diff --git a/include/configs/ls1088ardb.h b/include/configs/ls1088ardb.h
index 3e829ea8659..d98ed39812a 100644
--- a/include/configs/ls1088ardb.h
+++ b/include/configs/ls1088ardb.h
@@ -198,10 +198,6 @@
#define CONFIG_SYS_I2C_RTC_ADDR 0x51 /* Channel 3*/
#endif
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
#ifndef SPL_NO_ENV
/* Initial environment variables */
#ifdef CONFIG_TFABOOT
diff --git a/include/configs/ls2080aqds.h b/include/configs/ls2080aqds.h
index 6487397f652..d02d7fc5886 100644
--- a/include/configs/ls2080aqds.h
+++ b/include/configs/ls2080aqds.h
@@ -235,10 +235,6 @@
#define CONFIG_RTC_DS3231 1
#define CONFIG_SYS_I2C_RTC_ADDR 0x68
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/* Initial environment variables */
#undef CONFIG_EXTRA_ENV_SETTINGS
#ifdef CONFIG_NXP_ESBC
diff --git a/include/configs/ls2080ardb.h b/include/configs/ls2080ardb.h
index 87d07b765c6..09484dc6094 100644
--- a/include/configs/ls2080ardb.h
+++ b/include/configs/ls2080ardb.h
@@ -222,10 +222,6 @@
#define CONFIG_SYS_I2C_RTC_ADDR 0x68
#endif
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
#define BOOT_TARGET_DEVICES(func) \
func(USB, usb, 0) \
func(MMC, mmc, 0) \
diff --git a/include/configs/lx2160a_common.h b/include/configs/lx2160a_common.h
index d39c0032c4a..ed69b857582 100644
--- a/include/configs/lx2160a_common.h
+++ b/include/configs/lx2160a_common.h
@@ -78,10 +78,6 @@
#define RTC
#define CONFIG_SYS_I2C_RTC_ADDR 0x51 /* Channel 3*/
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/* Qixis */
#define CONFIG_SYS_I2C_FPGA_ADDR 0x66
diff --git a/include/configs/lx2160aqds.h b/include/configs/lx2160aqds.h
index 585aab26bff..4e8a9048596 100644
--- a/include/configs/lx2160aqds.h
+++ b/include/configs/lx2160aqds.h
@@ -13,10 +13,6 @@
/* MAC/PHY configuration */
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/* Initial environment variables */
#define CONFIG_EXTRA_ENV_SETTINGS \
EXTRA_ENV_SETTINGS \
diff --git a/include/configs/lx2160ardb.h b/include/configs/lx2160ardb.h
index 5c4ea27787b..bb9239cc599 100644
--- a/include/configs/lx2160ardb.h
+++ b/include/configs/lx2160ardb.h
@@ -17,10 +17,6 @@
#define I2C_EMC2305_CMD 0x40
#define I2C_EMC2305_PWM 0x80
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/* Initial environment variables */
#define CONFIG_EXTRA_ENV_SETTINGS \
EXTRA_ENV_SETTINGS \
diff --git a/include/configs/lx2162aqds.h b/include/configs/lx2162aqds.h
index d1ae4034731..b70abb013f4 100644
--- a/include/configs/lx2162aqds.h
+++ b/include/configs/lx2162aqds.h
@@ -13,10 +13,6 @@
/* RTC */
#define CONFIG_SYS_RTC_BUS_NUM 0
-/* EEPROM */
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
/* Initial environment variables */
#define CONFIG_EXTRA_ENV_SETTINGS \
EXTRA_ENV_SETTINGS \
diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h
index 8eaac4f8bc2..dfae8cea7b5 100644
--- a/include/configs/microblaze-generic.h
+++ b/include/configs/microblaze-generic.h
@@ -97,10 +97,4 @@
#define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_TEXT_BASE
-/* SP location before relocation, must use scratch RAM */
-/* BRAM start */
-#define CONFIG_SYS_INIT_RAM_ADDR 0x0
-/* BRAM size - will be generated */
-#define CONFIG_SYS_INIT_RAM_SIZE 0x100000
-
#endif /* __CONFIG_H */
diff --git a/include/configs/mt7981.h b/include/configs/mt7981.h
new file mode 100644
index 00000000000..01ad3096088
--- /dev/null
+++ b/include/configs/mt7981.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Configuration for MediaTek MT7981 SoC
+ *
+ * Copyright (C) 2022 MediaTek Inc.
+ * Author: Sam Shih <sam.shih@mediatek.com>
+ */
+
+#ifndef __MT7981_H
+#define __MT7981_H
+
+#include <linux/sizes.h>
+
+#define CONFIG_SYS_NONCACHED_MEMORY SZ_1M
+
+/* Uboot definition */
+#define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_TEXT_BASE
+
+/* SPL -> Uboot */
+#define CONFIG_SYS_UBOOT_START CONFIG_SYS_TEXT_BASE
+
+/* DRAM */
+#define CONFIG_SYS_SDRAM_BASE 0x40000000
+
+#endif
diff --git a/include/configs/mt7986.h b/include/configs/mt7986.h
new file mode 100644
index 00000000000..ccdd6abdb18
--- /dev/null
+++ b/include/configs/mt7986.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Configuration for MediaTek MT7986 SoC
+ *
+ * Copyright (C) 2022 MediaTek Inc.
+ * Author: Sam Shih <sam.shih@mediatek.com>
+ */
+
+#ifndef __MT7986_H
+#define __MT7986_H
+
+#include <linux/sizes.h>
+
+#define CONFIG_SYS_NONCACHED_MEMORY SZ_1M
+
+/* Uboot definition */
+#define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_TEXT_BASE
+
+/* SPL -> Uboot */
+#define CONFIG_SYS_UBOOT_START CONFIG_SYS_TEXT_BASE
+
+/* DRAM */
+#define CONFIG_SYS_SDRAM_BASE 0x40000000
+
+#endif
diff --git a/include/configs/mx6_common.h b/include/configs/mx6_common.h
index e416f81e43a..43145567544 100644
--- a/include/configs/mx6_common.h
+++ b/include/configs/mx6_common.h
@@ -12,7 +12,6 @@
#define CONFIG_SC_TIMER_CLK 8000000 /* 8Mhz */
#else
#ifndef CONFIG_SYS_L2CACHE_OFF
-#define CONFIG_SYS_L2_PL310
#define CONFIG_SYS_PL310_BASE L2_PL310_BASE
#endif
diff --git a/include/configs/odroid.h b/include/configs/odroid.h
index 7448cc95203..babd3ca9631 100644
--- a/include/configs/odroid.h
+++ b/include/configs/odroid.h
@@ -14,7 +14,6 @@
#include <configs/exynos4-common.h>
#ifndef CONFIG_SYS_L2CACHE_OFF
-#define CONFIG_SYS_L2_PL310
#define CONFIG_SYS_PL310_BASE 0x10502000
#endif
diff --git a/include/configs/poleg.h b/include/configs/poleg.h
index f1c259f4760..05253d59efd 100644
--- a/include/configs/poleg.h
+++ b/include/configs/poleg.h
@@ -7,7 +7,6 @@
#define __CONFIG_POLEG_H
#ifndef CONFIG_SYS_L2CACHE_OFF
-#define CONFIG_SYS_L2_PL310 1
#define CONFIG_SYS_PL310_BASE 0xF03FC000 /* L2 - Cache Regs Base (4k Space)*/
#endif
diff --git a/include/configs/sifive-unmatched.h b/include/configs/sifive-unmatched.h
index 9923f3d9c34..85fab927195 100644
--- a/include/configs/sifive-unmatched.h
+++ b/include/configs/sifive-unmatched.h
@@ -51,6 +51,4 @@
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
BOOTENV
-#define CONFIG_SYS_EEPROM_BUS_NUM 0
-
#endif /* __SIFIVE_UNMATCHED_H */
diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index 4a7da76e51e..c3f30afe2b5 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -48,7 +48,6 @@
/*
* Cache
*/
-#define CONFIG_SYS_L2_PL310
#define CONFIG_SYS_PL310_BASE SOCFPGA_MPUL2_ADDRESS
/*
diff --git a/include/configs/stemmy.h b/include/configs/stemmy.h
index 71b25c23b13..3c70856fc70 100644
--- a/include/configs/stemmy.h
+++ b/include/configs/stemmy.h
@@ -15,7 +15,6 @@
*/
/* FIXME: This should be loaded from device tree... */
-#define CONFIG_SYS_L2_PL310
#define CONFIG_SYS_PL310_BASE 0xa0412000
/* Linux does not boot if FDT / initrd is loaded to end of RAM */
diff --git a/include/configs/stm32f746-disco.h b/include/configs/stm32f746-disco.h
index 64c1bc7d43f..b0ec2261141 100644
--- a/include/configs/stm32f746-disco.h
+++ b/include/configs/stm32f746-disco.h
@@ -34,7 +34,6 @@
BOOTENV
#define CONFIG_SYS_MONITOR_LEN (512 * 1024)
-#define CONFIG_SYS_UBOOT_START 0x080083FD
#define CONFIG_SYS_UBOOT_BASE (CONFIG_SYS_FLASH_BASE + \
CONFIG_SPL_PAD_TO)
diff --git a/include/configs/stm32mp13_common.h b/include/configs/stm32mp13_common.h
index 3ca65ea2a37..78089b965ae 100644
--- a/include/configs/stm32mp13_common.h
+++ b/include/configs/stm32mp13_common.h
@@ -21,8 +21,6 @@
*/
#define CONFIG_SYS_BOOTMAPSZ SZ_256M
-/* Extend size of kernel image for uncompression */
-
/*MMC SD*/
#define CONFIG_SYS_MMC_MAX_DEVICE 2
diff --git a/include/configs/stm32mp15_common.h b/include/configs/stm32mp15_common.h
index c5412ffeb31..bd8e16bc1b9 100644
--- a/include/configs/stm32mp15_common.h
+++ b/include/configs/stm32mp15_common.h
@@ -21,8 +21,6 @@
*/
#define CONFIG_SYS_BOOTMAPSZ SZ_256M
-/* Extend size of kernel image for uncompression */
-
/*MMC SD*/
#define CONFIG_SYS_MMC_MAX_DEVICE 3
diff --git a/include/configs/ti_omap4_common.h b/include/configs/ti_omap4_common.h
index 3d78972bfeb..0568946fc82 100644
--- a/include/configs/ti_omap4_common.h
+++ b/include/configs/ti_omap4_common.h
@@ -12,7 +12,6 @@
#define __CONFIG_TI_OMAP4_COMMON_H
#ifndef CONFIG_SYS_L2CACHE_OFF
-#define CONFIG_SYS_L2_PL310 1
#define CONFIG_SYS_PL310_BASE 0x48242000
#endif
diff --git a/include/configs/tqma6.h b/include/configs/tqma6.h
index a782e3d02bd..9498dbeadf4 100644
--- a/include/configs/tqma6.h
+++ b/include/configs/tqma6.h
@@ -37,10 +37,6 @@
/* I2C Configs */
#define CONFIG_I2C_MULTI_BUS
-/* I2C EEPROM (M24C64) */
-#define CONFIG_SYS_I2C_EEPROM_PAGE_WRITE_BITS 5 /* 32 Bytes */
-#define CONFIG_SYS_I2C_EEPROM_PAGE_WRITE_DELAY_MS 20
-
#if !defined(CONFIG_DM_PMIC)
#define CONFIG_POWER_PFUZE100
#define CONFIG_POWER_PFUZE100_I2C_ADDR 0x08
diff --git a/include/configs/trats.h b/include/configs/trats.h
index 53f5a6996bd..530b413d5b6 100644
--- a/include/configs/trats.h
+++ b/include/configs/trats.h
@@ -12,7 +12,6 @@
#include <configs/exynos4-common.h>
#ifndef CONFIG_SYS_L2CACHE_OFF
-#define CONFIG_SYS_L2_PL310
#define CONFIG_SYS_PL310_BASE 0x10502000
#endif
diff --git a/include/configs/trats2.h b/include/configs/trats2.h
index b7449dab8bd..06c1fcd23e0 100644
--- a/include/configs/trats2.h
+++ b/include/configs/trats2.h
@@ -13,7 +13,6 @@
#include <configs/exynos4-common.h>
#ifndef CONFIG_SYS_L2CACHE_OFF
-#define CONFIG_SYS_L2_PL310
#define CONFIG_SYS_PL310_BASE 0x10502000
#endif
diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h
index 15ae0844c1a..d9e95abcc12 100644
--- a/include/configs/uniphier.h
+++ b/include/configs/uniphier.h
@@ -169,7 +169,7 @@
/* only for SPL */
-/* subtract sizeof(struct image_header) */
+/* subtract sizeof(struct legacy_img_hdr) */
#define CONFIG_SYS_UBOOT_BASE (0x130000 - 0x40)
#endif /* __CONFIG_UNIPHIER_H__ */
diff --git a/include/configs/xilinx_versal.h b/include/configs/xilinx_versal.h
index 971bd69dec8..8caf5394ed4 100644
--- a/include/configs/xilinx_versal.h
+++ b/include/configs/xilinx_versal.h
@@ -23,10 +23,6 @@
EFI_GUID(0x20c5fba5, 0x0171, 0x457f, 0xb9, 0xcd, \
0xf5, 0x12, 0x9c, 0xd0, 0x72, 0x28)
-/* Miscellaneous configurable options */
-
-/* Console I/O Buffer Size */
-
#if defined(CONFIG_CMD_DFU)
#define DFU_DEFAULT_POLL_TIMEOUT 300
#define CONFIG_THOR_RESET_OFF
diff --git a/include/configs/xilinx_versal_net.h b/include/configs/xilinx_versal_net.h
new file mode 100644
index 00000000000..0ccd38b7e69
--- /dev/null
+++ b/include/configs/xilinx_versal_net.h
@@ -0,0 +1,134 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Configuration for Xilinx Versal NET
+ * Copyright (C) 2016 - 2022, Xilinx, Inc.
+ * Copyright (C) 2022, Advanced Micro Devices, Inc.
+ *
+ * Michal Simek <michal.simek@amd.com>
+ *
+ * Based on Configuration for Xilinx ZynqMP
+ */
+
+#ifndef __XILINX_VERSAL_NET_H
+#define __XILINX_VERSAL_NET_H
+
+/* FIXME this is causing issue at least on IPP */
+/* #define CONFIG_ARMV8_SWITCH_TO_EL1 */
+
+/* Generic Interrupt Controller Definitions */
+#define GICD_BASE 0xF9000000
+#define GICR_BASE 0xF9060000
+
+/* Serial setup */
+#define CONFIG_SYS_BAUDRATE_TABLE \
+ { 4800, 9600, 19200, 38400, 57600, 115200 }
+
+#if defined(CONFIG_CMD_DFU)
+#define DFU_DEFAULT_POLL_TIMEOUT 300
+#define CONFIG_THOR_RESET_OFF
+#define DFU_ALT_INFO_RAM \
+ "dfu_ram_info=" \
+ "setenv dfu_alt_info " \
+ "Image ram 80000 $kernel_size_r\\\\;" \
+ "system.dtb ram $fdt_addr_r $fdt_size_r\0" \
+ "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \
+ "thor_ram=run dfu_ram_info && thordown 0 ram 0\0"
+
+#define DFU_ALT_INFO \
+ DFU_ALT_INFO_RAM
+#endif
+
+#if !defined(DFU_ALT_INFO)
+# define DFU_ALT_INFO
+#endif
+
+/* Ethernet driver */
+#if defined(CONFIG_ZYNQ_GEM)
+# define PHY_ANEG_TIMEOUT 20000
+#endif
+
+#define ENV_MEM_LAYOUT_SETTINGS \
+ "fdt_addr_r=0x40000000\0" \
+ "fdt_size_r=0x400000\0" \
+ "pxefile_addr_r=0x10000000\0" \
+ "kernel_addr_r=0x18000000\0" \
+ "kernel_size_r=0x10000000\0" \
+ "kernel_comp_addr_r=0x30000000\0" \
+ "kernel_comp_size=0x3C00000\0" \
+ "scriptaddr=0x20000000\0" \
+ "ramdisk_addr_r=0x02100000\0" \
+ "script_size_f=0x80000\0"
+
+#if defined(CONFIG_MMC_SDHCI_ZYNQ)
+# define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0) func(MMC, mmc, 1)
+#else
+# define BOOT_TARGET_DEVICES_MMC(func)
+#endif
+
+#if defined(CONFIG_CMD_PXE) && defined(CONFIG_CMD_DHCP)
+# define BOOT_TARGET_DEVICES_PXE(func) func(PXE, pxe, na)
+#else
+# define BOOT_TARGET_DEVICES_PXE(func)
+#endif
+
+#if defined(CONFIG_CMD_DHCP)
+# define BOOT_TARGET_DEVICES_DHCP(func) func(DHCP, dhcp, na)
+#else
+# define BOOT_TARGET_DEVICES_DHCP(func)
+#endif
+
+#if defined(CONFIG_ZYNQMP_GQSPI) || defined(CONFIG_CADENCE_OSPI_VERSAL_NET)
+# define BOOT_TARGET_DEVICES_XSPI(func) func(XSPI, xspi, 0)
+#else
+# define BOOT_TARGET_DEVICES_XSPI(func)
+#endif
+
+#define BOOTENV_DEV_XSPI(devtypeu, devtypel, instance) \
+ "bootcmd_xspi0=sf probe 0 0 0 && " \
+ "sf read $scriptaddr $script_offset_f $script_size_f && " \
+ "echo XSPI: Trying to boot script at ${scriptaddr} && " \
+ "source ${scriptaddr}; echo XSPI: SCRIPT FAILED: continuing...;\0"
+
+#define BOOTENV_DEV_NAME_XSPI(devtypeu, devtypel, instance) \
+ "xspi0 "
+
+#define BOOT_TARGET_DEVICES_JTAG(func) func(JTAG, jtag, na)
+
+#define BOOTENV_DEV_JTAG(devtypeu, devtypel, instance) \
+ "bootcmd_jtag=echo JTAG: Trying to boot script at ${scriptaddr} && " \
+ "source ${scriptaddr}; echo JTAG: SCRIPT FAILED: continuing...;\0"
+
+#define BOOTENV_DEV_NAME_JTAG(devtypeu, devtypel, instance) \
+ "jtag "
+
+#define BOOT_TARGET_DEVICES_DFU_USB(func) func(DFU_USB, dfu_usb, 0)
+
+#define BOOTENV_DEV_DFU_USB(devtypeu, devtypel, instance) \
+ "bootcmd_dfu_usb=setenv dfu_alt_info boot.scr ram $scriptaddr " \
+ "$script_size_f; dfu 0 ram 0 && " \
+ "echo DFU: Trying to boot script at ${scriptaddr} && " \
+ "source ${scriptaddr}; " \
+ "echo DFU: SCRIPT FAILED: continuing...;\0"
+
+#define BOOTENV_DEV_NAME_DFU_USB(devtypeu, devtypel, instance) \
+ ""
+
+#define BOOT_TARGET_DEVICES(func) \
+ BOOT_TARGET_DEVICES_JTAG(func) \
+ BOOT_TARGET_DEVICES_MMC(func) \
+ BOOT_TARGET_DEVICES_XSPI(func) \
+ BOOT_TARGET_DEVICES_DFU_USB(func) \
+ BOOT_TARGET_DEVICES_PXE(func) \
+ BOOT_TARGET_DEVICES_DHCP(func)
+
+#include <config_distro_bootcmd.h>
+
+/* Initial environment variables */
+#ifndef CONFIG_EXTRA_ENV_SETTINGS
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ ENV_MEM_LAYOUT_SETTINGS \
+ BOOTENV \
+ DFU_ALT_INFO
+#endif
+
+#endif /* __XILINX_VERSAL_NET_H */
diff --git a/include/configs/xilinx_versal_net_mini.h b/include/configs/xilinx_versal_net_mini.h
new file mode 100644
index 00000000000..1939832a848
--- /dev/null
+++ b/include/configs/xilinx_versal_net_mini.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Configuration for Xilinx Versal NET MINI configuration
+ *
+ * Copyright (C) 2018 - 2022, Xilinx, Inc.
+ * Copyright (C) 2022, Advanced Micro Devices, Inc.
+ *
+ * Michal Simek <michal.simek@amd.com>
+ */
+
+#ifndef __CONFIG_VERSAL_NET_MINI_H
+#define __CONFIG_VERSAL_NET_MINI_H
+
+#define CONFIG_EXTRA_ENV_SETTINGS
+
+#include <configs/xilinx_versal_net.h>
+
+/* Undef unneeded configs */
+#undef CONFIG_EXTRA_ENV_SETTINGS
+
+#endif /* __CONFIG_VERSAL_NET_MINI_H */
diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h
index 75ae68766fa..dc0cba00103 100644
--- a/include/configs/zynq-common.h
+++ b/include/configs/zynq-common.h
@@ -11,7 +11,6 @@
/* Cache options */
#ifndef CONFIG_SYS_L2CACHE_OFF
-# define CONFIG_SYS_L2_PL310
# define CONFIG_SYS_PL310_BASE 0xf8f02000
#endif
diff --git a/include/cyclic.h b/include/cyclic.h
new file mode 100644
index 00000000000..76016364334
--- /dev/null
+++ b/include/cyclic.h
@@ -0,0 +1,150 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * A general-purpose cyclic execution infrastructure, to allow "small"
+ * (run-time wise) functions to be executed at a specified frequency.
+ * Things like LED blinking or watchdog triggering are examples for such
+ * tasks.
+ *
+ * Copyright (C) 2022 Stefan Roese <sr@denx.de>
+ */
+
+#ifndef __cyclic_h
+#define __cyclic_h
+
+#include <linux/list.h>
+#include <asm/types.h>
+
+/**
+ * struct cyclic_drv - Cyclic driver internal data
+ *
+ * @cyclic_list: Cylic list node
+ * @cyclic_ready: Flag if cyclic infrastructure is ready
+ * @cyclic_running: Flag if cyclic infrastructure is running
+ */
+struct cyclic_drv {
+ struct list_head cyclic_list;
+ bool cyclic_ready;
+ bool cyclic_running;
+};
+
+/**
+ * struct cyclic_info - Information about cyclic execution function
+ *
+ * @func: Function to call periodically
+ * @ctx: Context pointer to get passed to this function
+ * @name: Name of the cyclic function, e.g. shown in the commands
+ * @delay_ns: Delay is ns after which this function shall get executed
+ * @start_time_us: Start time in us, when this function started its execution
+ * @cpu_time_us: Total CPU time of this function
+ * @run_cnt: Counter of executions occurances
+ * @next_call: Next time in us, when the function shall be executed again
+ * @list: List node
+ */
+struct cyclic_info {
+ void (*func)(void *ctx);
+ void *ctx;
+ char *name;
+ uint64_t delay_us;
+ uint64_t start_time_us;
+ uint64_t cpu_time_us;
+ uint64_t run_cnt;
+ uint64_t next_call;
+ struct list_head list;
+};
+
+/** Function type for cyclic functions */
+typedef void (*cyclic_func_t)(void *ctx);
+
+#if defined(CONFIG_CYCLIC)
+/**
+ * cyclic_register - Register a new cyclic function
+ *
+ * @func: Function to call periodically
+ * @delay_us: Delay is us after which this function shall get executed
+ * @name: Cyclic function name/id
+ * @ctx: Context to pass to the function
+ * @return: pointer to cyclic_struct if OK, NULL on error
+ */
+struct cyclic_info *cyclic_register(cyclic_func_t func, uint64_t delay_us,
+ const char *name, void *ctx);
+
+/**
+ * cyclic_unregister - Unregister a cyclic function
+ *
+ * @cyclic: Pointer to cyclic_struct of the function that shall be removed
+ * @return: 0 if OK, -ve on error
+ */
+int cyclic_unregister(struct cyclic_info *cyclic);
+
+/**
+ * cyclic_init() - Set up cyclic functions
+ *
+ * Init a list of cyclic functions, so that these can be added as needed
+ */
+int cyclic_init(void);
+
+/**
+ * cyclic_uninit() - Clean up cyclic functions
+ *
+ * This removes all cyclic functions
+ */
+int cyclic_uninit(void);
+
+/**
+ * cyclic_get_list() - Get cyclic list pointer
+ *
+ * Return the cyclic list pointer
+ *
+ * @return: pointer to cyclic_list
+ */
+struct list_head *cyclic_get_list(void);
+
+/**
+ * cyclic_run() - Interate over all registered cyclic functions
+ *
+ * Interate over all registered cyclic functions and if the it's function
+ * needs to be executed, then call into these registered functions.
+ */
+void cyclic_run(void);
+
+/**
+ * schedule() - Schedule all potentially waiting tasks
+ *
+ * Basically a wrapper for cyclic_run(), pontentially enhanced by some
+ * other parts, that need to get handled periodically.
+ */
+void schedule(void);
+#else
+static inline struct cyclic_info *cyclic_register(cyclic_func_t func,
+ uint64_t delay_us,
+ const char *name,
+ void *ctx)
+{
+ return NULL;
+}
+
+static inline int cyclic_unregister(struct cyclic_info *cyclic)
+{
+ return 0;
+}
+
+static inline void cyclic_run(void)
+{
+}
+
+static inline void schedule(void)
+{
+}
+
+static inline int cyclic_init(void)
+{
+ return 0;
+}
+
+static inline int cyclic_uninit(void)
+{
+ return 0;
+}
+#endif
+
+#endif
diff --git a/include/dm/device.h b/include/dm/device.h
index 12c6ba37ff3..f3f953c9afc 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -253,7 +253,7 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
* @dev: device to check
* Return: reference of the device's DT node
*/
-static inline ofnode dev_ofnode(const struct udevice *dev)
+static inline __attribute_const__ ofnode dev_ofnode(const struct udevice *dev)
{
#if CONFIG_IS_ENABLED(OF_REAL)
return dev->node_;
@@ -273,7 +273,7 @@ static inline ofnode dev_ofnode(const struct udevice *dev)
#define dev_get_dma_offset(_dev) 0
#endif
-static inline int dev_of_offset(const struct udevice *dev)
+static inline __attribute_const__ int dev_of_offset(const struct udevice *dev)
{
#if CONFIG_IS_ENABLED(OF_REAL)
return ofnode_to_offset(dev_ofnode(dev));
@@ -282,7 +282,7 @@ static inline int dev_of_offset(const struct udevice *dev)
#endif
}
-static inline bool dev_has_ofnode(const struct udevice *dev)
+static inline __attribute_const__ bool dev_has_ofnode(const struct udevice *dev)
{
#if CONFIG_IS_ENABLED(OF_REAL)
return ofnode_valid(dev_ofnode(dev));
diff --git a/include/dm/of.h b/include/dm/of.h
index 9c9065b7932..fce7cef0ff6 100644
--- a/include/dm/of.h
+++ b/include/dm/of.h
@@ -31,10 +31,21 @@ struct property {
/**
* struct device_node: Device tree node
*
- * @name: Node name
+ * The top of this tree is typically gd->of_root which points to the root node.
+ *
+ * The head of the list of children for the root node (and any other node) is
+ * in @child, with @sibling providing a link to the next child.
+ *
+ * Each child has a pointer to its parent in @parent.
+ *
+ * A node may have properties in which case the head of the list of properties
+ * @properties pointers to the first one, with struct property->@next pointing
+ * to the next one.
+ *
+ * @name: Node name, "" for the root node
* @type: Node type (value of device_type property) or "<NULL>" if none
* @phandle: Phandle value of this none, or 0 if none
- * @full_name: Full path to node, e.g. "/bus@1/spi@1100"
+ * @full_name: Full path to node, e.g. "/bus@1/spi@1100" ("/" for the root node)
* @properties: Pointer to head of list of properties, or NULL if none
* @parent: Pointer to parent node, or NULL if this is the root node
* @child: Pointer to head of child node list, or NULL if no children
diff --git a/include/dm/of_access.h b/include/dm/of_access.h
index 5b7821d0a1b..c556a18f7d9 100644
--- a/include/dm/of_access.h
+++ b/include/dm/of_access.h
@@ -258,11 +258,45 @@ struct device_node *of_find_node_by_prop_value(struct device_node *from,
/**
* of_find_node_by_phandle() - Find a node given a phandle
*
+ * @root: root node to start from (NULL for default device tree)
* @handle: phandle of the node to find
*
* Return: node pointer, or NULL if not found
*/
-struct device_node *of_find_node_by_phandle(phandle handle);
+struct device_node *of_find_node_by_phandle(struct device_node *root,
+ phandle handle);
+
+/**
+ * of_read_u8() - Find and read a 8-bit integer from a property
+ *
+ * Search for a property in a device node and read a 8-bit value from
+ * it.
+ *
+ * @np: device node from which the property value is to be read.
+ * @propname: name of the property to be searched.
+ * @outp: pointer to return value, modified only if return value is 0.
+ *
+ * Return: 0 on success, -EINVAL if the property does not exist,
+ * -ENODATA if property does not have a value, and -EOVERFLOW if the
+ * property data isn't large enough.
+ */
+int of_read_u8(const struct device_node *np, const char *propname, u8 *outp);
+
+/**
+ * of_read_u16() - Find and read a 16-bit integer from a property
+ *
+ * Search for a property in a device node and read a 16-bit value from
+ * it.
+ *
+ * @np: device node from which the property value is to be read.
+ * @propname: name of the property to be searched.
+ * @outp: pointer to return value, modified only if return value is 0.
+ *
+ * Return: 0 on success, -EINVAL if the property does not exist,
+ * -ENODATA if property does not have a value, and -EOVERFLOW if the
+ * property data isn't large enough.
+ */
+int of_read_u16(const struct device_node *np, const char *propname, u16 *outp);
/**
* of_read_u32() - Find and read a 32-bit integer from a property
@@ -293,8 +327,7 @@ int of_read_u32(const struct device_node *np, const char *propname, u32 *outp);
* @outp: pointer to return value, modified only if return value is 0.
*
* Return:
- * 0 on success, -EINVAL if the property does not exist,
- * -ENODATA if property does not have a value, and -EOVERFLOW if the
+ * 0 on success, -EINVAL if the property does not exist, or -EOVERFLOW if the
* property data isn't large enough.
*/
int of_read_u32_index(const struct device_node *np, const char *propname,
@@ -311,8 +344,7 @@ int of_read_u32_index(const struct device_node *np, const char *propname,
* @outp: pointer to return value, modified only if return value is 0.
*
* Return:
- * 0 on success, -EINVAL if the property does not exist,
- * -ENODATA if property does not have a value, and -EOVERFLOW if the
+ * 0 on success, -EINVAL if the property does not exist, or -EOVERFLOW if the
* property data isn't large enough.
*/
int of_read_u64(const struct device_node *np, const char *propname, u64 *outp);
@@ -328,8 +360,8 @@ int of_read_u64(const struct device_node *np, const char *propname, u64 *outp);
* @out_values: pointer to return value, modified only if return value is 0.
* @sz: number of array elements to read
* Return:
- * 0 on success, -EINVAL if the property does not exist, -ENODATA
- * if property does not have a value, and -EOVERFLOW is longer than sz.
+ * 0 on success, -EINVAL if the property does not exist, or -EOVERFLOW if
+ * longer than sz.
*/
int of_read_u32_array(const struct device_node *np, const char *propname,
u32 *out_values, size_t sz);
@@ -531,4 +563,19 @@ struct device_node *of_get_stdout(void);
int of_write_prop(struct device_node *np, const char *propname, int len,
const void *value);
+/**
+ * of_add_subnode() - add a new subnode to a node
+ *
+ * @node: parent node to add to
+ * @name: name of subnode
+ * @len: length of name (so the caller does not need to nul-terminate a
+ * partial string), or -1 for strlen(@name)
+ * @subnodep: returns pointer to new subnode (valid if the function returns 0
+ * or -EEXIST)
+ * Returns 0 if OK, -EEXIST if already exists, -ENOMEM if out of memory, other
+ * -ve on other error
+ */
+int of_add_subnode(struct device_node *node, const char *name, int len,
+ struct device_node **subnodep);
+
#endif
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 7ce1e4c6d91..7aae2c29ef1 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -27,70 +27,147 @@ struct ofnode_phandle_args {
uint32_t args[OF_MAX_PHANDLE_ARGS];
};
+#if CONFIG_IS_ENABLED(OFNODE_MULTI_TREE)
/**
- * ofnode_to_np() - convert an ofnode to a live DT node pointer
+ * oftree_reset() - reset the state of the oftree list
*
- * This cannot be called if the reference contains an offset.
+ * Reset the oftree list so it can be started again. This should be called
+ * once the control FDT is in place, but before the ofnode interface is used.
+ */
+void oftree_reset(void);
+
+/**
+ * ofnode_to_fdt() - convert an ofnode to a flat DT pointer
*
- * @node: Reference containing struct device_node * (possibly invalid)
- * Return: pointer to device node (can be NULL)
+ * This cannot be called if the reference contains a node pointer.
+ *
+ * @node: Reference containing offset (possibly invalid)
+ * Return: DT offset (can be NULL)
+ */
+__attribute_const__ void *ofnode_to_fdt(ofnode node);
+
+/**
+ * ofnode_to_offset() - convert an ofnode to a flat DT offset
+ *
+ * This cannot be called if the reference contains a node pointer.
+ *
+ * @node: Reference containing offset (possibly invalid)
+ * Return: DT offset (can be -1)
+ */
+__attribute_const__ int ofnode_to_offset(ofnode node);
+
+/**
+ * oftree_from_fdt() - Returns an oftree from a flat device tree pointer
+ *
+ * @fdt: Device tree to use
+ *
+ * Returns: reference to the given node
+ */
+oftree oftree_from_fdt(void *fdt);
+
+/**
+ * noffset_to_ofnode() - convert a DT offset to an ofnode
+ *
+ * @other_node: Node in the same tree to use as a reference
+ * @of_offset: DT offset (either valid, or -1)
+ * Return: reference to the associated DT offset
*/
-static inline const struct device_node *ofnode_to_np(ofnode node)
+ofnode noffset_to_ofnode(ofnode other_node, int of_offset);
+
+#else /* !OFNODE_MULTI_TREE */
+static inline void oftree_reset(void) {}
+
+static inline void *ofnode_to_fdt(ofnode node)
{
#ifdef OF_CHECKS
- if (!of_live_active())
+ if (of_live_active())
return NULL;
#endif
- return node.np;
+ /* Use the control FDT by default */
+ return (void *)gd->fdt_blob;
+}
+
+static inline __attribute_const__ int ofnode_to_offset(ofnode node)
+{
+#ifdef OF_CHECKS
+ if (of_live_active())
+ return -1;
+#endif
+ return node.of_offset;
}
+static inline oftree oftree_from_fdt(void *fdt)
+{
+ oftree tree;
+
+ /* we cannot access other trees without OFNODE_MULTI_TREE */
+ if (fdt == gd->fdt_blob)
+ tree.fdt = fdt;
+ else
+ tree.fdt = NULL;
+
+ return tree;
+}
+
+static inline ofnode noffset_to_ofnode(ofnode other_node, int of_offset)
+{
+ ofnode node;
+
+ if (of_live_active())
+ node.np = NULL;
+ else
+ node.of_offset = of_offset;
+
+ return node;
+}
+
+#endif /* OFNODE_MULTI_TREE */
+
/**
- * ofnode_to_npw() - convert an ofnode to a writeable live DT node pointer
+ * ofnode_to_np() - convert an ofnode to a live DT node pointer
*
* This cannot be called if the reference contains an offset.
*
* @node: Reference containing struct device_node * (possibly invalid)
* Return: pointer to device node (can be NULL)
*/
-static inline struct device_node *ofnode_to_npw(ofnode node)
+static inline struct device_node *ofnode_to_np(ofnode node)
{
#ifdef OF_CHECKS
if (!of_live_active())
return NULL;
#endif
- /* Drop constant */
- return (struct device_node *)node.np;
+ return node.np;
}
/**
- * ofnode_to_offset() - convert an ofnode to a flat DT offset
- *
- * This cannot be called if the reference contains a node pointer.
+ * ofnode_valid() - check if an ofnode is valid
*
* @node: Reference containing offset (possibly invalid)
- * Return: DT offset (can be -1)
+ * Return: true if the reference contains a valid ofnode, false if not
*/
-static inline int ofnode_to_offset(ofnode node)
+static inline bool ofnode_valid(ofnode node)
{
-#ifdef OF_CHECKS
if (of_live_active())
- return -1;
-#endif
- return node.of_offset;
+ return node.np != NULL;
+ else
+ return node.of_offset >= 0;
}
/**
- * ofnode_valid() - check if an ofnode is valid
+ * oftree_lookup_fdt() - obtain the FDT pointer from an oftree
*
- * @node: Reference containing offset (possibly invalid)
- * Return: true if the reference contains a valid ofnode, false if it is NULL
+ * This can only be called when flat tree is enabled
+ *
+ * @tree: Tree to look at
+ * @return FDT pointer from the tree
*/
-static inline bool ofnode_valid(ofnode node)
+static inline void *oftree_lookup_fdt(oftree tree)
{
if (of_live_active())
- return node.np != NULL;
+ return NULL;
else
- return node.of_offset >= 0;
+ return tree.fdt;
}
/**
@@ -117,7 +194,7 @@ static inline ofnode offset_to_ofnode(int of_offset)
* @np: Live node pointer (can be NULL)
* Return: reference to the associated node pointer
*/
-static inline ofnode np_to_ofnode(const struct device_node *np)
+static inline ofnode np_to_ofnode(struct device_node *np)
{
ofnode node;
@@ -165,6 +242,38 @@ static inline bool ofnode_equal(ofnode ref1, ofnode ref2)
}
/**
+ * oftree_valid() - check if an oftree is valid
+ *
+ * @tree: Reference containing oftree
+ * Return: true if the reference contains a valid oftree, false if node
+ */
+static inline bool oftree_valid(oftree tree)
+{
+ if (of_live_active())
+ return tree.np;
+ else
+ return tree.fdt;
+}
+
+/**
+ * oftree_null() - Obtain a null oftree
+ *
+ * This returns an oftree which points to no tree. It works both with the flat
+ * tree and livetree.
+ */
+static inline oftree oftree_null(void)
+{
+ oftree tree;
+
+ if (of_live_active())
+ tree.np = NULL;
+ else
+ tree.fdt = NULL;
+
+ return tree;
+}
+
+/**
* ofnode_null() - Obtain a null ofnode
*
* This returns an ofnode which points to no node. It works both with the flat
@@ -195,6 +304,20 @@ static inline ofnode ofnode_root(void)
}
/**
+ * ofprop_valid() - check if an ofprop is valid
+ *
+ * @prop: Pointer to ofprop to check
+ * Return: true if the reference contains a valid ofprop, false if not
+ */
+static inline bool ofprop_valid(struct ofprop *prop)
+{
+ if (of_live_active())
+ return prop->prop;
+ else
+ return prop->offset >= 0;
+}
+
+/**
* oftree_default() - Returns the default device tree (U-Boot's control FDT)
*
* Returns: reference to the control FDT
@@ -212,6 +335,21 @@ static inline oftree oftree_default(void)
}
/**
+ * oftree_from_np() - Returns an oftree from a node pointer
+ *
+ * @root: Root node of the tree
+ * Returns: reference to the given node
+ */
+static inline oftree oftree_from_np(struct device_node *root)
+{
+ oftree tree;
+
+ tree.np = root;
+
+ return tree;
+}
+
+/**
* ofnode_name_eq() - Check if the node name is equivalent to a given name
* ignoring the unit address
*
@@ -222,6 +360,46 @@ static inline oftree oftree_default(void)
bool ofnode_name_eq(ofnode node, const char *name);
/**
+ * ofnode_read_u8() - Read a 8-bit integer from a property
+ *
+ * @node: valid node reference to read property from
+ * @propname: name of the property to read from
+ * @outp: place to put value (if found)
+ * Return: 0 if OK, -ve on error
+ */
+int ofnode_read_u8(ofnode node, const char *propname, u8 *outp);
+
+/**
+ * ofnode_read_u8_default() - Read a 8-bit integer from a property
+ *
+ * @node: valid node reference to read property from
+ * @propname: name of the property to read from
+ * @def: default value to return if the property has no value
+ * Return: property value, or @def if not found
+ */
+u8 ofnode_read_u8_default(ofnode node, const char *propname, u8 def);
+
+/**
+ * ofnode_read_u16() - Read a 16-bit integer from a property
+ *
+ * @node: valid node reference to read property from
+ * @propname: name of the property to read from
+ * @outp: place to put value (if found)
+ * Return: 0 if OK, -ve on error
+ */
+int ofnode_read_u16(ofnode node, const char *propname, u16 *outp);
+
+/**
+ * ofnode_read_u16_default() - Read a 16-bit integer from a property
+ *
+ * @node: valid node reference to read property from
+ * @propname: name of the property to read from
+ * @def: default value to return if the property has no value
+ * Return: property value, or @def if not found
+ */
+u16 ofnode_read_u16_default(ofnode node, const char *propname, u16 def);
+
+/**
* ofnode_read_u32() - Read a 32-bit integer from a property
*
* @node: valid node reference to read property from
@@ -337,12 +515,12 @@ const char *ofnode_read_string(ofnode node, const char *propname);
* @propname: name of the property to read
* @out_values: pointer to return value, modified only if return value is 0
* @sz: number of array elements to read
- * Return: 0 if OK, -ve on error
+ * Return: 0 on success, -EINVAL if the property does not exist,
+ * -ENODATA if property does not have a value, and -EOVERFLOW if the
+ * property data isn't large enough
*
* Search for a property in a device node and read 32-bit value(s) from
- * it. Returns 0 on success, -EINVAL if the property does not exist,
- * -ENODATA if property does not have a value, and -EOVERFLOW if the
- * property data isn't large enough.
+ * it.
*
* The out_values is modified only if a valid u32 value can be decoded.
*/
@@ -444,7 +622,7 @@ ofnode ofnode_get_parent(ofnode node);
* ofnode_get_name() - get the name of a node
*
* @node: valid node to look up
- * Return: name of node
+ * Return: name of node (for the root node this is "")
*/
const char *ofnode_get_name(ofnode node);
@@ -461,12 +639,23 @@ int ofnode_get_path(ofnode node, char *buf, int buflen);
/**
* ofnode_get_by_phandle() - get ofnode from phandle
*
+ * This uses the default (control) device tree
+ *
* @phandle: phandle to look up
* Return: ofnode reference to the phandle
*/
ofnode ofnode_get_by_phandle(uint phandle);
/**
+ * oftree_get_by_phandle() - get ofnode from phandle
+ *
+ * @tree: tree to use
+ * @phandle: phandle to look up
+ * Return: ofnode reference to the phandle
+ */
+ofnode oftree_get_by_phandle(oftree tree, uint phandle);
+
+/**
* ofnode_read_size() - read the size of a property
*
* @node: node to check
@@ -683,18 +872,28 @@ int ofnode_count_phandle_with_args(ofnode node, const char *list_name,
ofnode ofnode_path(const char *path);
/**
- * ofnode_path_root() - find a node by full path from a root node
+ * oftree_path() - find a node by full path from a root node
*
* @tree: Device tree to use
* @path: Full path to node, e.g. "/bus/spi@1"
* Return: reference to the node found. Use ofnode_valid() to check if it exists
*/
-ofnode ofnode_path_root(oftree tree, const char *path);
+ofnode oftree_path(oftree tree, const char *path);
+
+/**
+ * oftree_root() - get the root node of a tree
+ *
+ * @tree: Device tree to use
+ * Return: reference to the root node
+ */
+ofnode oftree_root(oftree tree);
/**
* ofnode_read_chosen_prop() - get the value of a chosen property
*
- * This looks for a property within the /chosen node and returns its value
+ * This looks for a property within the /chosen node and returns its value.
+ *
+ * This only works with the control FDT.
*
* @propname: Property name to look for
* @sizep: Returns size of property, or `FDT_ERR_...` error code if function
@@ -709,6 +908,8 @@ const void *ofnode_read_chosen_prop(const char *propname, int *sizep);
* This looks for a property within the /chosen node and returns its value,
* checking that it is a valid nul-terminated string
*
+ * This only works with the control FDT.
+ *
* @propname: Property name to look for
* Return: string value if found, else NULL
*/
@@ -720,6 +921,8 @@ const char *ofnode_read_chosen_string(const char *propname);
* This looks up a named property in the chosen node and uses that as a path to
* look up a code.
*
+ * This only works with the control FDT.
+ *
* @propname: Property name to look for
* Return: the referenced node if present, else ofnode_null()
*/
@@ -730,6 +933,8 @@ ofnode ofnode_get_chosen_node(const char *propname);
*
* This looks for a property within the /aliases node and returns its value
*
+ * This only works with the control FDT.
+ *
* @propname: Property name to look for
* @sizep: Returns size of property, or `FDT_ERR_...` error code if function
* returns NULL
@@ -743,6 +948,8 @@ const void *ofnode_read_aliases_prop(const char *propname, int *sizep);
* This looks up a named property in the aliases node and uses that as a path to
* look up a code.
*
+ * This only works with the control FDT.
+ *
* @propname: Property name to look for
* Return: the referenced node if present, else ofnode_null()
*/
@@ -775,48 +982,64 @@ int ofnode_decode_display_timing(ofnode node, int index,
const void *ofnode_get_property(ofnode node, const char *propname, int *lenp);
/**
- * ofnode_get_first_property()- get the reference of the first property
+ * ofnode_first_property()- get the reference of the first property
*
* Get reference to the first property of the node, it is used to iterate
- * and read all the property with ofnode_get_property_by_prop().
+ * and read all the property with ofprop_get_property().
*
* @node: node to read
* @prop: place to put argument reference
* Return: 0 if OK, -ve on error. -FDT_ERR_NOTFOUND if not found
*/
-int ofnode_get_first_property(ofnode node, struct ofprop *prop);
+int ofnode_first_property(ofnode node, struct ofprop *prop);
/**
- * ofnode_get_next_property() - get the reference of the next property
+ * ofnode_next_property() - get the reference of the next property
*
* Get reference to the next property of the node, it is used to iterate
- * and read all the property with ofnode_get_property_by_prop().
+ * and read all the property with ofprop_get_property().
*
* @prop: reference of current argument and place to put reference of next one
* Return: 0 if OK, -ve on error. -FDT_ERR_NOTFOUND if not found
*/
-int ofnode_get_next_property(struct ofprop *prop);
+int ofnode_next_property(struct ofprop *prop);
/**
- * ofnode_get_property_by_prop() - get a pointer to the value of a property
+ * ofnode_for_each_prop() - iterate over all properties of a node
*
- * Get value for the property identified by the provided reference.
+ * @prop: struct ofprop
+ * @node: node (lvalue, ofnode)
*
- * @prop: reference on property
- * @propname: If non-NULL, place to property name on success,
- * @lenp: If non-NULL, place to put length on success
- * Return: 0 if OK, -ve on error. -FDT_ERR_NOTFOUND if not found
+ * This is a wrapper around a for loop and is used like this::
+ *
+ * ofnode node;
+ * struct ofprop prop;
+ *
+ * ofnode_for_each_prop(prop, node) {
+ * ...use prop...
+ * }
+ *
+ * Note that this is implemented as a macro and @prop is used as
+ * iterator in the loop. The parent variable can be a constant or even a
+ * literal.
*/
-const void *ofnode_get_property_by_prop(const struct ofprop *prop,
- const char **propname, int *lenp);
+#define ofnode_for_each_prop(prop, node) \
+ for (ofnode_first_property(node, &prop); \
+ ofprop_valid(&prop); \
+ ofnode_next_property(&prop))
/**
- * ofnode_is_available() - check if a node is marked available
+ * ofprop_get_property() - get a pointer to the value of a property
*
- * @node: node to check
- * Return: true if node's 'status' property is "okay" (or is missing)
+ * Get value for the property identified by the provided reference.
+ *
+ * @prop: reference on property
+ * @propname: If non-NULL, place to property name on success,
+ * @lenp: If non-NULL, place to put length on success, or error code on failure
+ * Return: pointer to property, or NULL if not found
*/
-bool ofnode_is_available(ofnode node);
+const void *ofprop_get_property(const struct ofprop *prop,
+ const char **propname, int *lenp);
/**
* ofnode_get_addr_size() - get address and size from a property
@@ -1006,8 +1229,9 @@ ofnode ofnode_by_compatible(ofnode from, const char *compat);
* Find the next node after @from that has a @propname with a value
* @propval and a length @proplen.
*
- * @from: ofnode to start from (use ofnode_null() to start at the
- * beginning)
+ * @from: ofnode to start from. Use ofnode_null() to start at the
+ * beginning, or the return value from oftree_root() to start at the first
+ * child of the root
* @propname: property name to check
* @propval: property value to search for
* @proplen: length of the value in propval
@@ -1126,19 +1350,23 @@ int ofnode_device_is_compatible(ofnode node, const char *compat);
/**
* ofnode_write_prop() - Set a property of a ofnode
*
- * Note that the value passed to the function is *not* allocated by the
- * function itself, but must be allocated by the caller if necessary. However
- * it does allocate memory for the property struct and name.
+ * Note that if @copy is false, the value passed to the function is *not*
+ * allocated by the function itself, but must be allocated by the caller if
+ * necessary. However it does allocate memory for the property struct and name.
*
* @node: The node for whose property should be set
* @propname: The name of the property to set
* @value: The new value of the property (must be valid prior to calling
* the function)
* @len: The length of the new value of the property
+ * @copy: true to allocate memory for the value. This only has any effect with
+ * live tree, since flat tree handles this automatically. It allows a
+ * node's value to be written to the tree, without requiring that the
+ * caller allocate it
* Return: 0 if successful, -ve on error
*/
int ofnode_write_prop(ofnode node, const char *propname, const void *value,
- int len);
+ int len, bool copy);
/**
* ofnode_write_string() - Set a string property of a ofnode
@@ -1211,7 +1439,9 @@ phy_interface_t ofnode_read_phy_mode(ofnode mac_node);
*
* This reads a property from the /config node of the devicetree.
*
- * See doc/config.txt for bindings
+ * This only works with the control FDT.
+ *
+ * See doc/device-tree-bindings/config.txt for bindings
*
* @prop_name: property name to look up
* Return: true, if it exists, false if not
@@ -1223,7 +1453,7 @@ bool ofnode_conf_read_bool(const char *prop_name);
*
* This reads a property from the /config node of the devicetree.
*
- * See doc/config.txt for bindings
+ * See doc/device-tree-bindings/config.txt for bindings
*
* @prop_name: property name to look up
* @default_val: default value to return if the property is not found
@@ -1236,7 +1466,9 @@ int ofnode_conf_read_int(const char *prop_name, int default_val);
*
* This reads a property from the /config node of the devicetree.
*
- * See doc/config.txt for bindings
+ * This only works with the control FDT.
+ *
+ * See doc/device-tree-bindings/config.txt for bindings
*
* @prop_name: property name to look up
* Return: string value, if found, or NULL if not
@@ -1258,6 +1490,35 @@ static inline const char *ofnode_conf_read_str(const char *prop_name)
{
return NULL;
}
+
#endif /* CONFIG_DM */
+/**
+ * of_add_subnode() - add a new subnode to a node
+ *
+ * @parent: parent node to add to
+ * @name: name of subnode
+ * @nodep: returns pointer to new subnode (valid if the function returns 0
+ * or -EEXIST)
+ * Returns 0 if OK, -EEXIST if already exists, -ENOMEM if out of memory, other
+ * -ve on other error
+ */
+int ofnode_add_subnode(ofnode parent, const char *name, ofnode *nodep);
+
+/**
+ * ofnode_copy_props() - copy all properties from one node to another
+ *
+ * Makes a copy of all properties from the source note in the destination node.
+ * Existing properties in the destination node remain unchanged, except that
+ * any with the same name are overwritten, including changing the size of the
+ * property.
+ *
+ * For livetree, properties are copied / allocated, so the source tree does not
+ * need to be present afterwards.
+ *
+ * @src: Source node to read properties from
+ * @dst: Destination node to write properties too
+ */
+int ofnode_copy_props(ofnode src, ofnode dst);
+
#endif
diff --git a/include/dm/ofnode_decl.h b/include/dm/ofnode_decl.h
index 266253d5e33..5c2115aab0b 100644
--- a/include/dm/ofnode_decl.h
+++ b/include/dm/ofnode_decl.h
@@ -31,18 +31,47 @@
* this increases code size slightly due to the subtraction. Since it offers no
* real benefit, the approach described here seems best.
*
- * For now these points use constant types, since we don't allow writing
- * the DT.
+ * Where multiple trees are in use, this works without any trouble with live
+ * tree, except for aliases, such as ofnode_path("mmc0"), which only work on the
+ * control FDT. When the flat tree is in use, the trees are registered and a
+ * 'tree ID' is encoded into the top bits of @of_offset - see immediately below
+ * for the associated macro definitions. Note that 64-bit machines use the same
+ * encoding, even though there is more space available. This is partly because
+ * the FDT format contains 32-bit values for things like the string-table
+ * offset, therefore 64-bit offsets cannot be supported anyway.
+ *
+ * For the multiple-tree case, an invalid offset (i.e. with of_offset < 0) is
+ * still invalid. It does not contain a tree ID. So there is no way of knowing
+ * which tree produced the invalid offset.
*
* @np: Pointer to device node, used for live tree
* @of_offset: Pointer into flat device tree, used for flat tree. Note that this
* is not a really a pointer to a node: it is an offset value. See above.
*/
typedef union ofnode_union {
- const struct device_node *np;
+ struct device_node *np;
long of_offset;
} ofnode;
+/* shift for the tree ID within of_offset */
+#define OF_TREE_SHIFT 28
+
+/* mask to obtain the device tree offset from of_offset */
+#define OF_TREE_MASK ((1 << OF_TREE_SHIFT) - 1)
+
+/* encode a tree ID and node offset into an of_offset value */
+#define OFTREE_NODE(tree_id, offs) ((tree_id) << OF_TREE_SHIFT | (offs))
+
+/* decode the node offset from an of_offset value */
+#define OFTREE_OFFSET(of_offs) ((of_offs) & OF_TREE_MASK)
+
+/* decode the tree ID from an of_offset value */
+#define OFTREE_TREE_ID(of_offs) ((of_offs) >> OF_TREE_SHIFT)
+
+/* encode a node offset in the tree given by another node's of_offset value */
+#define OFTREE_MAKE_NODE(other_of_offset, offs) \
+ (((offs) & OF_TREE_MASK) | ((other_of_offset) & ~OF_TREE_MASK))
+
/**
* struct ofprop - reference to a property of a device tree node
*
@@ -57,7 +86,7 @@ typedef union ofnode_union {
*
* @node: Pointer to device node
* @offset: Pointer into flat device tree, used for flat tree.
- * @prop: Pointer to property, used for live treee.
+ * @prop: Pointer to property, used for live tree.
*/
struct ofprop {
diff --git a/include/dm/read.h b/include/dm/read.h
index 1b54b69acf0..cc4f16196fd 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -32,6 +32,47 @@ static inline const struct device_node *dev_np(const struct udevice *dev)
#if !defined(CONFIG_DM_DEV_READ_INLINE) || CONFIG_IS_ENABLED(OF_PLATDATA)
/**
+ * dev_read_u8() - read a 8-bit integer from a device's DT property
+ *
+ * @dev: device to read DT property from
+ * @propname: name of the property to read from
+ * @outp: place to put value (if found)
+ * Return: 0 if OK, -ve on error
+ */
+int dev_read_u8(const struct udevice *dev, const char *propname, u8 *outp);
+
+/**
+ * dev_read_u8_default() - read a 8-bit integer from a device's DT property
+ *
+ * @dev: device to read DT property from
+ * @propname: name of the property to read from
+ * @def: default value to return if the property has no value
+ * Return: property value, or @def if not found
+ */
+u8 dev_read_u8_default(const struct udevice *dev, const char *propname, u8 def);
+
+/**
+ * dev_read_u16() - read a 16-bit integer from a device's DT property
+ *
+ * @dev: device to read DT property from
+ * @propname: name of the property to read from
+ * @outp: place to put value (if found)
+ * Return: 0 if OK, -ve on error
+ */
+int dev_read_u16(const struct udevice *dev, const char *propname, u16 *outp);
+
+/**
+ * dev_read_u16_default() - read a 16-bit integer from a device's DT property
+ *
+ * @dev: device to read DT property from
+ * @propname: name of the property to read from
+ * @def: default value to return if the property has no value
+ * Return: property value, or @def if not found
+ */
+u16 dev_read_u16_default(const struct udevice *dev, const char *propname,
+ u16 def);
+
+/**
* dev_read_u32() - read a 32-bit integer from a device's DT property
*
* @dev: device to read DT property from
@@ -528,7 +569,7 @@ const void *dev_read_prop(const struct udevice *dev, const char *propname,
int dev_read_first_prop(const struct udevice *dev, struct ofprop *prop);
/**
- * ofnode_get_next_property() - get the reference of the next property
+ * ofnode_next_property() - get the reference of the next property
*
* Get reference to the next property of the node, it is used to iterate
* and read all the property with dev_read_prop_by_prop().
@@ -772,6 +813,30 @@ phy_interface_t dev_read_phy_mode(const struct udevice *dev);
#else /* CONFIG_DM_DEV_READ_INLINE is enabled */
#include <asm/global_data.h>
+static inline int dev_read_u8(const struct udevice *dev,
+ const char *propname, u8 *outp)
+{
+ return ofnode_read_u8(dev_ofnode(dev), propname, outp);
+}
+
+static inline int dev_read_u8_default(const struct udevice *dev,
+ const char *propname, u8 def)
+{
+ return ofnode_read_u8_default(dev_ofnode(dev), propname, def);
+}
+
+static inline int dev_read_u16(const struct udevice *dev,
+ const char *propname, u16 *outp)
+{
+ return ofnode_read_u16(dev_ofnode(dev), propname, outp);
+}
+
+static inline int dev_read_u16_default(const struct udevice *dev,
+ const char *propname, u16 def)
+{
+ return ofnode_read_u16_default(dev_ofnode(dev), propname, def);
+}
+
static inline int dev_read_u32(const struct udevice *dev,
const char *propname, u32 *outp)
{
@@ -1014,19 +1079,19 @@ static inline const void *dev_read_prop(const struct udevice *dev,
static inline int dev_read_first_prop(const struct udevice *dev, struct ofprop *prop)
{
- return ofnode_get_first_property(dev_ofnode(dev), prop);
+ return ofnode_first_property(dev_ofnode(dev), prop);
}
static inline int dev_read_next_prop(struct ofprop *prop)
{
- return ofnode_get_next_property(prop);
+ return ofnode_next_property(prop);
}
static inline const void *dev_read_prop_by_prop(struct ofprop *prop,
const char **propname,
int *lenp)
{
- return ofnode_get_property_by_prop(prop, propname, lenp);
+ return ofprop_get_property(prop, propname, lenp);
}
static inline int dev_read_alias_seq(const struct udevice *dev, int *devnump)
diff --git a/include/dt-bindings/clock/mt7981-clk.h b/include/dt-bindings/clock/mt7981-clk.h
new file mode 100644
index 00000000000..e24c759e499
--- /dev/null
+++ b/include/dt-bindings/clock/mt7981-clk.h
@@ -0,0 +1,267 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2022 MediaTek Inc. All rights reserved.
+ *
+ * Author: Sam Shih <sam.shih@mediatek.com>
+ */
+
+#ifndef _DT_BINDINGS_CLK_MT7981_H
+#define _DT_BINDINGS_CLK_MT7981_H
+
+/* INFRACFG */
+
+#define CK_INFRA_CK_F26M 0
+#define CK_INFRA_UART 1
+#define CK_INFRA_ISPI0 2
+#define CK_INFRA_I2C 3
+#define CK_INFRA_ISPI1 4
+#define CK_INFRA_PWM 5
+#define CK_INFRA_66M_MCK 6
+#define CK_INFRA_CK_F32K 7
+#define CK_INFRA_PCIE_CK 8
+#define CK_INFRA_PWM_BCK 9
+#define CK_INFRA_PWM_CK1 10
+#define CK_INFRA_PWM_CK2 11
+#define CK_INFRA_133M_HCK 12
+#define CK_INFRA_66M_PHCK 13
+#define CK_INFRA_FAUD_L_CK 14
+#define CK_INFRA_FAUD_AUD_CK 15
+#define CK_INFRA_FAUD_EG2_CK 16
+#define CK_INFRA_I2CS_CK 17
+#define CK_INFRA_MUX_UART0 18
+#define CK_INFRA_MUX_UART1 19
+#define CK_INFRA_MUX_UART2 20
+#define CK_INFRA_NFI_CK 21
+#define CK_INFRA_SPINFI_CK 22
+#define CK_INFRA_MUX_SPI0 23
+#define CK_INFRA_MUX_SPI1 24
+#define CK_INFRA_MUX_SPI2 25
+#define CK_INFRA_RTC_32K 26
+#define CK_INFRA_FMSDC_CK 27
+#define CK_INFRA_FMSDC_HCK_CK 28
+#define CK_INFRA_PERI_133M 29
+#define CK_INFRA_133M_PHCK 30
+#define CK_INFRA_USB_SYS_CK 31
+#define CK_INFRA_USB_CK 32
+#define CK_INFRA_USB_XHCI_CK 33
+#define CK_INFRA_PCIE_GFMUX_TL_O_PRE 34
+#define CK_INFRA_F26M_CK0 35
+#define CK_INFRA_133M_MCK 36
+#define CLK_INFRA_NR_CLK 37
+
+/* TOPCKGEN */
+
+#define CK_TOP_CB_CKSQ_40M 0
+#define CK_TOP_CB_M_416M 1
+#define CK_TOP_CB_M_D2 2
+#define CK_TOP_CB_M_D3 3
+#define CK_TOP_M_D3_D2 4
+#define CK_TOP_CB_M_D4 5
+#define CK_TOP_CB_M_D8 6
+#define CK_TOP_M_D8_D2 7
+#define CK_TOP_CB_MM_720M 8
+#define CK_TOP_CB_MM_D2 9
+#define CK_TOP_CB_MM_D3 10
+#define CK_TOP_CB_MM_D3_D5 11
+#define CK_TOP_CB_MM_D4 12
+#define CK_TOP_CB_MM_D6 13
+#define CK_TOP_MM_D6_D2 14
+#define CK_TOP_CB_MM_D8 15
+#define CK_TOP_CB_APLL2_196M 16
+#define CK_TOP_APLL2_D2 17
+#define CK_TOP_APLL2_D4 18
+#define CK_TOP_NET1_2500M 19
+#define CK_TOP_CB_NET1_D4 20
+#define CK_TOP_CB_NET1_D5 21
+#define CK_TOP_NET1_D5_D2 22
+#define CK_TOP_NET1_D5_D4 23
+#define CK_TOP_CB_NET1_D8 24
+#define CK_TOP_NET1_D8_D2 25
+#define CK_TOP_NET1_D8_D4 26
+#define CK_TOP_CB_NET2_800M 27
+#define CK_TOP_CB_NET2_D2 28
+#define CK_TOP_CB_NET2_D4 29
+#define CK_TOP_NET2_D4_D2 30
+#define CK_TOP_NET2_D4_D4 31
+#define CK_TOP_CB_NET2_D6 32
+#define CK_TOP_CB_WEDMCU_208M 33
+#define CK_TOP_CB_SGM_325M 34
+#define CK_TOP_CKSQ_40M_D2 35
+#define CK_TOP_CB_RTC_32K 36
+#define CK_TOP_CB_RTC_32P7K 37
+#define CK_TOP_USB_TX250M 38
+#define CK_TOP_FAUD 39
+#define CK_TOP_NFI1X 40
+#define CK_TOP_USB_EQ_RX250M 41
+#define CK_TOP_USB_CDR_CK 42
+#define CK_TOP_USB_LN0_CK 43
+#define CK_TOP_SPINFI_BCK 44
+#define CK_TOP_SPI 45
+#define CK_TOP_SPIM_MST 46
+#define CK_TOP_UART_BCK 47
+#define CK_TOP_PWM_BCK 48
+#define CK_TOP_I2C_BCK 49
+#define CK_TOP_PEXTP_TL 50
+#define CK_TOP_EMMC_208M 51
+#define CK_TOP_EMMC_400M 52
+#define CK_TOP_DRAMC_REF 53
+#define CK_TOP_DRAMC_MD32 54
+#define CK_TOP_SYSAXI 55
+#define CK_TOP_SYSAPB 56
+#define CK_TOP_ARM_DB_MAIN 57
+#define CK_TOP_AP2CNN_HOST 58
+#define CK_TOP_NETSYS 59
+#define CK_TOP_NETSYS_500M 60
+#define CK_TOP_NETSYS_WED_MCU 61
+#define CK_TOP_NETSYS_2X 62
+#define CK_TOP_SGM_325M 63
+#define CK_TOP_SGM_REG 64
+#define CK_TOP_F26M 65
+#define CK_TOP_EIP97B 66
+#define CK_TOP_USB3_PHY 67
+#define CK_TOP_AUD 68
+#define CK_TOP_A1SYS 69
+#define CK_TOP_AUD_L 70
+#define CK_TOP_A_TUNER 71
+#define CK_TOP_U2U3_REF 72
+#define CK_TOP_U2U3_SYS 73
+#define CK_TOP_U2U3_XHCI 74
+#define CK_TOP_USB_FRMCNT 75
+#define CK_TOP_NFI1X_SEL 76
+#define CK_TOP_SPINFI_SEL 77
+#define CK_TOP_SPI_SEL 78
+#define CK_TOP_SPIM_MST_SEL 79
+#define CK_TOP_UART_SEL 80
+#define CK_TOP_PWM_SEL 81
+#define CK_TOP_I2C_SEL 82
+#define CK_TOP_PEXTP_TL_SEL 83
+#define CK_TOP_EMMC_208M_SEL 84
+#define CK_TOP_EMMC_400M_SEL 85
+#define CK_TOP_F26M_SEL 86
+#define CK_TOP_DRAMC_SEL 87
+#define CK_TOP_DRAMC_MD32_SEL 88
+#define CK_TOP_SYSAXI_SEL 89
+#define CK_TOP_SYSAPB_SEL 90
+#define CK_TOP_ARM_DB_MAIN_SEL 91
+#define CK_TOP_AP2CNN_HOST_SEL 92
+#define CK_TOP_NETSYS_SEL 93
+#define CK_TOP_NETSYS_500M_SEL 94
+#define CK_TOP_NETSYS_MCU_SEL 95
+#define CK_TOP_NETSYS_2X_SEL 96
+#define CK_TOP_SGM_325M_SEL 97
+#define CK_TOP_SGM_REG_SEL 98
+#define CK_TOP_EIP97B_SEL 99
+#define CK_TOP_USB3_PHY_SEL 100
+#define CK_TOP_AUD_SEL 101
+#define CK_TOP_A1SYS_SEL 102
+#define CK_TOP_AUD_L_SEL 103
+#define CK_TOP_A_TUNER_SEL 104
+#define CK_TOP_U2U3_SEL 105
+#define CK_TOP_U2U3_SYS_SEL 106
+#define CK_TOP_U2U3_XHCI_SEL 107
+#define CK_TOP_USB_FRMCNT_SEL 108
+#define CLK_TOP_NR_CLK 109
+
+/*
+ * INFRACFG_AO
+ * clock muxes need to be append to infracfg domain, and clock gates
+ * need to be keep in infracgh_ao domain
+ */
+#define INFRACFG_AO_OFFSET 10
+
+#define CK_INFRA_UART0_SEL (0 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_UART1_SEL (1 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_UART2_SEL (2 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_SPI0_SEL (3 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_SPI1_SEL (4 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_SPI2_SEL (5 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_PWM1_SEL (6 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_PWM2_SEL (7 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_PWM_BSEL (8 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_PCIE_SEL (9 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_GPT_STA (10 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_PWM_HCK (11 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_PWM_STA (12 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_PWM1_CK (13 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_PWM2_CK (14 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_CQ_DMA_CK (15 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_AUD_BUS_CK (16 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_AUD_26M_CK (17 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_AUD_L_CK (18 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_AUD_AUD_CK (19 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_AUD_EG2_CK (20 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_DRAMC_26M_CK (21 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_DBG_CK (22 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_AP_DMA_CK (23 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_SEJ_CK (24 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_SEJ_13M_CK (25 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_THERM_CK (26 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_I2CO_CK (27 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_UART0_CK (28 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_UART1_CK (29 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_UART2_CK (30 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_SPI2_CK (31 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_SPI2_HCK_CK (32 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_NFI1_CK (33 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_SPINFI1_CK (34 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_NFI_HCK_CK (35 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_SPI0_CK (36 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_SPI1_CK (37 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_SPI0_HCK_CK (38 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_SPI1_HCK_CK (39 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_FRTC_CK (40 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_MSDC_CK (41 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_MSDC_HCK_CK (42 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_MSDC_133M_CK (43 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_MSDC_66M_CK (44 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_ADC_26M_CK (45 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_ADC_FRC_CK (46 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_FBIST2FPC_CK (47 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_I2C_MCK_CK (48 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_I2C_PCK_CK (49 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_IUSB_133_CK (50 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_IUSB_66M_CK (51 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_IUSB_SYS_CK (52 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_IUSB_CK (53 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_IPCIE_CK (54 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_IPCIER_CK (55 - INFRACFG_AO_OFFSET)
+#define CK_INFRA_IPCIEB_CK (56 - INFRACFG_AO_OFFSET)
+#define CLK_INFRA_AO_NR_CLK (57 - INFRACFG_AO_OFFSET)
+
+/* APMIXEDSYS */
+
+#define CK_APMIXED_ARMPLL 0
+#define CK_APMIXED_NET2PLL 1
+#define CK_APMIXED_MMPLL 2
+#define CK_APMIXED_SGMPLL 3
+#define CK_APMIXED_WEDMCUPLL 4
+#define CK_APMIXED_NET1PLL 5
+#define CK_APMIXED_MPLL 6
+#define CK_APMIXED_APLL2 7
+#define CLK_APMIXED_NR_CLK 8
+
+/* SGMIISYS_0 */
+
+#define CK_SGM0_TX_EN 0
+#define CK_SGM0_RX_EN 1
+#define CK_SGM0_CK0_EN 2
+#define CK_SGM0_CDR_CK0_EN 3
+#define CLK_SGMII0_NR_CLK 4
+
+/* SGMIISYS_1 */
+
+#define CK_SGM1_TX_EN 0
+#define CK_SGM1_RX_EN 1
+#define CK_SGM1_CK1_EN 2
+#define CK_SGM1_CDR_CK1_EN 3
+#define CLK_SGMII1_NR_CLK 4
+
+/* ETHSYS */
+
+#define CK_ETH_FE_EN 0
+#define CK_ETH_GP2_EN 1
+#define CK_ETH_GP1_EN 2
+#define CK_ETH_WOCPU0_EN 3
+#define CLK_ETH_NR_CLK 4
+
+#endif /* _DT_BINDINGS_CLK_MT7981_H */
diff --git a/include/dt-bindings/clock/mt7986-clk.h b/include/dt-bindings/clock/mt7986-clk.h
new file mode 100644
index 00000000000..820f8631831
--- /dev/null
+++ b/include/dt-bindings/clock/mt7986-clk.h
@@ -0,0 +1,249 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2022 MediaTek Inc. All rights reserved.
+ *
+ * Author: Sam Shih <sam.shih@mediatek.com>
+ */
+
+#ifndef _DT_BINDINGS_CLK_MT7986_H
+#define _DT_BINDINGS_CLK_MT7986_H
+
+/* INFRACFG */
+
+#define CK_INFRA_CK_F26M 0
+#define CK_INFRA_UART 1
+#define CK_INFRA_ISPI0 2
+#define CK_INFRA_I2C 3
+#define CK_INFRA_ISPI1 4
+#define CK_INFRA_PWM 5
+#define CK_INFRA_66M_MCK 6
+#define CK_INFRA_CK_F32K 7
+#define CK_INFRA_PCIE_CK 8
+#define CK_INFRA_PWM_BCK 9
+#define CK_INFRA_PWM_CK1 10
+#define CK_INFRA_PWM_CK2 11
+#define CK_INFRA_133M_HCK 12
+#define CK_INFRA_EIP_CK 13
+#define CK_INFRA_66M_PHCK 14
+#define CK_INFRA_FAUD_L_CK 15
+#define CK_INFRA_FAUD_AUD_CK 17
+#define CK_INFRA_FAUD_EG2_CK 17
+#define CK_INFRA_I2CS_CK 18
+#define CK_INFRA_MUX_UART0 19
+#define CK_INFRA_MUX_UART1 20
+#define CK_INFRA_MUX_UART2 21
+#define CK_INFRA_NFI_CK 22
+#define CK_INFRA_SPINFI_CK 23
+#define CK_INFRA_MUX_SPI0 24
+#define CK_INFRA_MUX_SPI1 25
+#define CK_INFRA_RTC_32K 26
+#define CK_INFRA_FMSDC_CK 27
+#define CK_INFRA_FMSDC_HCK_CK 28
+#define CK_INFRA_PERI_133M 29
+#define CK_INFRA_133M_PHCK 30
+#define CK_INFRA_USB_SYS_CK 31
+#define CK_INFRA_USB_CK 32
+#define CK_INFRA_USB_XHCI_CK 33
+#define CK_INFRA_PCIE_GFMUX_TL_O_PRE 34
+#define CK_INFRA_F26M_CK0 35
+#define CK_INFRA_HD_133M 36
+#define CLK_INFRA_NR_CLK 37
+
+/* TOPCKGEN */
+
+#define CK_TOP_CB_CKSQ_40M 0
+#define CK_TOP_CB_M_416M 1
+#define CK_TOP_CB_M_D2 2
+#define CK_TOP_CB_M_D4 3
+#define CK_TOP_CB_M_D8 4
+#define CK_TOP_M_D8_D2 5
+#define CK_TOP_M_D3_D2 6
+#define CK_TOP_CB_MM_D2 7
+#define CK_TOP_CB_MM_D4 8
+#define CK_TOP_CB_MM_D8 9
+#define CK_TOP_MM_D8_D2 10
+#define CK_TOP_MM_D3_D8 11
+#define CK_TOP_CB_U2_PHYD_CK 12
+#define CK_TOP_CB_APLL2_196M 13
+#define CK_TOP_APLL2_D4 14
+#define CK_TOP_CB_NET1_D4 15
+#define CK_TOP_CB_NET1_D5 16
+#define CK_TOP_NET1_D5_D2 17
+#define CK_TOP_NET1_D5_D4 18
+#define CK_TOP_NET1_D8_D2 19
+#define CK_TOP_NET1_D8_D4 20
+#define CK_TOP_CB_NET2_800M 21
+#define CK_TOP_CB_NET2_D4 22
+#define CK_TOP_NET2_D4_D2 23
+#define CK_TOP_NET2_D3_D2 24
+#define CK_TOP_CB_WEDMCU_760M 25
+#define CK_TOP_WEDMCU_D5_D2 26
+#define CK_TOP_CB_SGM_325M 27
+#define CK_TOP_CB_CKSQ_40M_D2 28
+#define CK_TOP_CB_RTC_32K 29
+#define CK_TOP_CB_RTC_32P7K 30
+#define CK_TOP_NFI1X 31
+#define CK_TOP_USB_EQ_RX250M 32
+#define CK_TOP_USB_TX250M 33
+#define CK_TOP_USB_LN0_CK 34
+#define CK_TOP_USB_CDR_CK 35
+#define CK_TOP_SPINFI_BCK 36
+#define CK_TOP_I2C_BCK 37
+#define CK_TOP_PEXTP_TL 38
+#define CK_TOP_EMMC_250M 39
+#define CK_TOP_EMMC_416M 40
+#define CK_TOP_F_26M_ADC_CK 41
+#define CK_TOP_SYSAXI 42
+#define CK_TOP_NETSYS_WED_MCU 43
+#define CK_TOP_NETSYS_2X 44
+#define CK_TOP_SGM_325M 45
+#define CK_TOP_A1SYS 46
+#define CK_TOP_EIP_B 47
+#define CK_TOP_F26M 48
+#define CK_TOP_AUD_L 49
+#define CK_TOP_A_TUNER 50
+#define CK_TOP_U2U3_REF 51
+#define CK_TOP_U2U3_SYS 52
+#define CK_TOP_U2U3_XHCI 53
+#define CK_TOP_AP2CNN_HOST 54
+#define CK_TOP_NFI1X_SEL 55
+#define CK_TOP_SPINFI_SEL 56
+#define CK_TOP_SPI_SEL 57
+#define CK_TOP_SPIM_MST_SEL 58
+#define CK_TOP_UART_SEL 59
+#define CK_TOP_PWM_SEL 60
+#define CK_TOP_I2C_SEL 61
+#define CK_TOP_PEXTP_TL_SEL 62
+#define CK_TOP_EMMC_250M_SEL 63
+#define CK_TOP_EMMC_416M_SEL 64
+#define CK_TOP_F_26M_ADC_SEL 65
+#define CK_TOP_DRAMC_SEL 66
+#define CK_TOP_DRAMC_MD32_SEL 67
+#define CK_TOP_SYSAXI_SEL 68
+#define CK_TOP_SYSAPB_SEL 69
+#define CK_TOP_ARM_DB_MAIN_SEL 70
+#define CK_TOP_ARM_DB_JTSEL 71
+#define CK_TOP_NETSYS_SEL 72
+#define CK_TOP_NETSYS_500M_SEL 73
+#define CK_TOP_NETSYS_MCU_SEL 74
+#define CK_TOP_NETSYS_2X_SEL 75
+#define CK_TOP_SGM_325M_SEL 76
+#define CK_TOP_SGM_REG_SEL 77
+#define CK_TOP_A1SYS_SEL 78
+#define CK_TOP_CONN_MCUSYS_SEL 79
+#define CK_TOP_EIP_B_SEL 80
+#define CK_TOP_PCIE_PHY_SEL 81
+#define CK_TOP_USB3_PHY_SEL 82
+#define CK_TOP_F26M_SEL 83
+#define CK_TOP_AUD_L_SEL 84
+#define CK_TOP_A_TUNER_SEL 85
+#define CK_TOP_U2U3_SEL 86
+#define CK_TOP_U2U3_SYS_SEL 87
+#define CK_TOP_U2U3_XHCI_SEL 88
+#define CK_TOP_DA_U2_REFSEL 89
+#define CK_TOP_DA_U2_CK_1P_SEL 90
+#define CK_TOP_AP2CNN_HOST_SEL 91
+#define CLK_TOP_NR_CLK 92
+
+/*
+ * INFRACFG_AO
+ * clock muxes need to be append to infracfg domain, and clock gates
+ * need to be keep in infracgh_ao domain
+ */
+
+#define CK_INFRA_UART0_SEL (0 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_UART1_SEL (1 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_UART2_SEL (2 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_SPI0_SEL (3 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_SPI1_SEL (4 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_PWM1_SEL (5 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_PWM2_SEL (6 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_PWM_BSEL (7 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_PCIE_SEL (8 + CLK_INFRA_NR_CLK)
+#define CK_INFRA_GPT_STA 0
+#define CK_INFRA_PWM_HCK 1
+#define CK_INFRA_PWM_STA 2
+#define CK_INFRA_PWM1_CK 3
+#define CK_INFRA_PWM2_CK 4
+#define CK_INFRA_CQ_DMA_CK 5
+#define CK_INFRA_EIP97_CK 6
+#define CK_INFRA_AUD_BUS_CK 7
+#define CK_INFRA_AUD_26M_CK 8
+#define CK_INFRA_AUD_L_CK 9
+#define CK_INFRA_AUD_AUD_CK 10
+#define CK_INFRA_AUD_EG2_CK 11
+#define CK_INFRA_DRAMC_26M_CK 12
+#define CK_INFRA_DBG_CK 13
+#define CK_INFRA_AP_DMA_CK 14
+#define CK_INFRA_SEJ_CK 15
+#define CK_INFRA_SEJ_13M_CK 16
+#define CK_INFRA_THERM_CK 17
+#define CK_INFRA_I2CO_CK 18
+#define CK_INFRA_TRNG_CK 19
+#define CK_INFRA_UART0_CK 20
+#define CK_INFRA_UART1_CK 21
+#define CK_INFRA_UART2_CK 22
+#define CK_INFRA_NFI1_CK 23
+#define CK_INFRA_SPINFI1_CK 24
+#define CK_INFRA_NFI_HCK_CK 25
+#define CK_INFRA_SPI0_CK 26
+#define CK_INFRA_SPI1_CK 27
+#define CK_INFRA_SPI0_HCK_CK 28
+#define CK_INFRA_SPI1_HCK_CK 29
+#define CK_INFRA_FRTC_CK 30
+#define CK_INFRA_MSDC_CK 31
+#define CK_INFRA_MSDC_HCK_CK 32
+#define CK_INFRA_MSDC_133M_CK 33
+#define CK_INFRA_MSDC_66M_CK 34
+#define CK_INFRA_ADC_26M_CK 35
+#define CK_INFRA_ADC_FRC_CK 36
+#define CK_INFRA_FBIST2FPC_CK 37
+#define CK_INFRA_IUSB_133_CK 38
+#define CK_INFRA_IUSB_66M_CK 39
+#define CK_INFRA_IUSB_SYS_CK 40
+#define CK_INFRA_IUSB_CK 41
+#define CK_INFRA_IPCIE_CK 42
+#define CK_INFRA_IPCIER_CK 43
+#define CK_INFRA_IPCIEB_CK 44
+#define CLK_INFRA_AO_NR_CLK 45
+
+/* APMIXEDSYS */
+
+#define CK_APMIXED_ARMPLL 0
+#define CK_APMIXED_NET2PLL 1
+#define CK_APMIXED_MMPLL 2
+#define CK_APMIXED_SGMPLL 3
+#define CK_APMIXED_WEDMCUPLL 4
+#define CK_APMIXED_NET1PLL 5
+#define CK_APMIXED_MPLL 6
+#define CK_APMIXED_APLL2 7
+#define CLK_APMIXED_NR_CLK 8
+
+/* SGMIISYS_0 */
+
+#define CK_SGM0_TX_EN 0
+#define CK_SGM0_RX_EN 1
+#define CK_SGM0_CK0_EN 2
+#define CK_SGM0_CDR_CK0_EN 3
+#define CLK_SGMII0_NR_CLK 4
+
+/* SGMIISYS_1 */
+
+#define CK_SGM1_TX_EN 0
+#define CK_SGM1_RX_EN 1
+#define CK_SGM1_CK1_EN 2
+#define CK_SGM1_CDR_CK1_EN 3
+#define CLK_SGMII1_NR_CLK 4
+
+/* ETHSYS */
+
+#define CK_ETH_FE_EN 0
+#define CK_ETH_GP2_EN 1
+#define CK_ETH_GP1_EN 2
+#define CK_ETH_WOCPU1_EN 3
+#define CK_ETH_WOCPU0_EN 4
+#define CLK_ETH_NR_CLK 5
+
+#endif
+
+/* _DT_BINDINGS_CLK_MT7986_H */
diff --git a/include/dt-bindings/gpio/sandbox-gpio.h b/include/dt-bindings/gpio/sandbox-gpio.h
index e4bfdb3ce1d..05f98365839 100644
--- a/include/dt-bindings/gpio/sandbox-gpio.h
+++ b/include/dt-bindings/gpio/sandbox-gpio.h
@@ -21,4 +21,7 @@
/* Bit 18 express GPIO output is active */
#define GPIO_OUT_ACTIVE 0x40000
+/* Bit 19 express GPIO set as alternate function */
+#define GPIO_AF 0x80000
+
#endif
diff --git a/include/dt-bindings/pinctrl/mt65xx.h b/include/dt-bindings/pinctrl/mt65xx.h
new file mode 100644
index 00000000000..fbea8d35bcf
--- /dev/null
+++ b/include/dt-bindings/pinctrl/mt65xx.h
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Hongzhou.Yang <hongzhou.yang@mediatek.com>
+ */
+
+#ifndef _DT_BINDINGS_PINCTRL_MT65XX_H
+#define _DT_BINDINGS_PINCTRL_MT65XX_H
+
+#define MTK_PIN_NO(x) ((x) << 8)
+#define MTK_GET_PIN_NO(x) ((x) >> 8)
+#define MTK_GET_PIN_FUNC(x) ((x) & 0xf)
+
+#define MTK_PUPD_SET_R1R0_00 100
+#define MTK_PUPD_SET_R1R0_01 101
+#define MTK_PUPD_SET_R1R0_10 102
+#define MTK_PUPD_SET_R1R0_11 103
+
+#define MTK_PULL_SET_RSEL_000 200
+#define MTK_PULL_SET_RSEL_001 201
+#define MTK_PULL_SET_RSEL_010 202
+#define MTK_PULL_SET_RSEL_011 203
+#define MTK_PULL_SET_RSEL_100 204
+#define MTK_PULL_SET_RSEL_101 205
+#define MTK_PULL_SET_RSEL_110 206
+#define MTK_PULL_SET_RSEL_111 207
+
+#define MTK_DRIVE_2mA 2
+#define MTK_DRIVE_4mA 4
+#define MTK_DRIVE_6mA 6
+#define MTK_DRIVE_8mA 8
+#define MTK_DRIVE_10mA 10
+#define MTK_DRIVE_12mA 12
+#define MTK_DRIVE_14mA 14
+#define MTK_DRIVE_16mA 16
+#define MTK_DRIVE_20mA 20
+#define MTK_DRIVE_24mA 24
+#define MTK_DRIVE_28mA 28
+#define MTK_DRIVE_32mA 32
+
+#endif /* _DT_BINDINGS_PINCTRL_MT65XX_H */
diff --git a/include/efi_config.h b/include/efi_config.h
new file mode 100644
index 00000000000..098cac21153
--- /dev/null
+++ b/include/efi_config.h
@@ -0,0 +1,98 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Menu-driven UEFI Variable maintenance
+ *
+ * Copyright (c) 2022 Masahisa Kojima, Linaro Limited
+ */
+
+#ifndef _EFI_CONFIG_H
+#define _EFI_CONFIG_H
+
+#include <efi_loader.h>
+
+#define EFICONFIG_ENTRY_NUM_MAX 99
+#define EFICONFIG_VOLUME_PATH_MAX 512
+#define EFICONFIG_FILE_PATH_MAX 512
+#define EFICONFIG_FILE_PATH_BUF_SIZE (EFICONFIG_FILE_PATH_MAX * sizeof(u16))
+
+typedef efi_status_t (*eficonfig_entry_func)(void *data);
+
+/**
+ * struct eficonfig_entry - menu entry structure
+ *
+ * @num: menu entry index
+ * @title: title of entry
+ * @key: unique key
+ * @efi_menu: pointer to the menu structure
+ * @func: callback function to be called when this entry is selected
+ * @data: data to be passed to the callback function, caller must free() this pointer
+ * @list: list structure
+ */
+struct eficonfig_entry {
+ u32 num;
+ char *title;
+ char key[3];
+ struct efimenu *efi_menu;
+ eficonfig_entry_func func;
+ void *data;
+ struct list_head list;
+};
+
+/**
+ * struct efimenu - efi menu structure
+ *
+ * @delay: delay for autoboot
+ * @active: active menu entry index
+ * @count: total count of menu entry
+ * @menu_header: menu header string
+ * @list: menu entry list structure
+ */
+struct efimenu {
+ int delay;
+ int active;
+ int count;
+ char *menu_header;
+ struct list_head list;
+};
+
+/**
+ * struct eficonfig_item - structure to construct eficonfig_entry
+ *
+ * @title: title of entry
+ * @func: callback function to be called when this entry is selected
+ * @data: data to be passed to the callback function
+ */
+struct eficonfig_item {
+ char *title;
+ eficonfig_entry_func func;
+ void *data;
+};
+
+/**
+ * struct eficonfig_select_file_info - structure to be used for file selection
+ *
+ * @current_volume: pointer to the efi_simple_file_system_protocol
+ * @dp_volume: pointer to device path of the selected device
+ * @current_path: pointer to the selected file path string
+ * @filepath_list: list_head structure for file path list
+ * @file_selectred: flag indicates file selecting status
+ */
+struct eficonfig_select_file_info {
+ struct efi_simple_file_system_protocol *current_volume;
+ struct efi_device_path *dp_volume;
+ u16 *current_path;
+ struct list_head filepath_list;
+ bool file_selected;
+};
+
+void eficonfig_print_msg(char *msg);
+void eficonfig_destroy(struct efimenu *efi_menu);
+efi_status_t eficonfig_process_quit(void *data);
+efi_status_t eficonfig_process_common(struct efimenu *efi_menu, char *menu_header);
+efi_status_t eficonfig_select_file_handler(void *data);
+efi_status_t eficonfig_get_unused_bootoption(u16 *buf,
+ efi_uintn_t buf_size, u32 *index);
+efi_status_t eficonfig_append_bootorder(u16 index);
+efi_status_t eficonfig_generate_media_device_boot_option(void);
+
+#endif
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 545ba06d946..ad01395b39c 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -142,6 +142,11 @@ static inline efi_status_t efi_launch_capsules(void)
EFI_GUID(0x63293792, 0xadf5, 0x9325, \
0xb9, 0x9f, 0x4e, 0x0e, 0x45, 0x5c, 0x1b, 0x1e)
+/* GUID for the auto generated boot menu entry */
+#define EFICONFIG_AUTO_GENERATED_ENTRY_GUID \
+ EFI_GUID(0x38c1acc1, 0x9fc0, 0x41f0, \
+ 0xb9, 0x01, 0xfa, 0x74, 0xd6, 0xd6, 0xe4, 0xde)
+
/* Use internal device tree when starting UEFI application */
#define EFI_FDT_USE_INTERNAL NULL
@@ -156,7 +161,7 @@ extern bool efi_st_keep_devices;
/* EFI system partition */
extern struct efi_system_partition {
- enum if_type if_type;
+ enum uclass_id uclass_id;
int devnum;
u8 part;
} efi_system_partition;
@@ -226,6 +231,9 @@ const char *__efi_nesting_dec(void);
#define EFI_CACHELINE_SIZE 128
#endif
+/* max bootmenu title size for volume selection */
+#define BOOTMENU_DEVICE_NAME_MAX 16
+
/* Key identifying current memory map */
extern efi_uintn_t efi_memory_map_key;
@@ -249,6 +257,9 @@ extern const struct efi_hii_string_protocol efi_hii_string;
uint16_t *efi_dp_str(struct efi_device_path *dp);
+/* GUID for the auto generated boot menu entry */
+extern const efi_guid_t efi_guid_bootmenu_auto_generated;
+
/* GUID of the U-Boot root node */
extern const efi_guid_t efi_u_boot_guid;
#ifdef CONFIG_SANDBOX
@@ -314,6 +325,8 @@ extern const efi_guid_t efi_guid_firmware_management_protocol;
extern const efi_guid_t efi_esrt_guid;
/* GUID of the SMBIOS table */
extern const efi_guid_t smbios_guid;
+/*GUID of console */
+extern const efi_guid_t efi_guid_text_input_protocol;
extern char __efi_runtime_start[], __efi_runtime_stop[];
extern char __efi_runtime_rel_start[], __efi_runtime_rel_stop[];
@@ -549,7 +562,7 @@ efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size,
struct efi_loaded_image *loaded_image_info);
/* Create handles and protocols for the partitions of a block device */
int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
- const char *if_typename, int diskid,
+ const char *uclass_idname, int diskid,
const char *pdevname);
/* Called by bootefi to make GOP (graphical) interface available */
efi_status_t efi_gop_register(void);
@@ -942,6 +955,22 @@ struct efi_signature_store {
struct x509_certificate;
struct pkcs7_message;
+/**
+ * struct eficonfig_media_boot_option - boot option for (removable) media device
+ *
+ * This structure is used to enumerate possible boot option
+ *
+ * @lo: Serialized load option data
+ * @size: Size of serialized load option data
+ * @exist: Flag to indicate the load option already exists
+ * in Non-volatile load option
+ */
+struct eficonfig_media_boot_option {
+ void *lo;
+ efi_uintn_t size;
+ bool exist;
+};
+
bool efi_hash_regions(struct image_region *regs, int count,
void **hash, const char *hash_algo, int *len);
bool efi_signature_lookup_digest(struct efi_image_regions *regs,
@@ -1073,4 +1102,28 @@ efi_status_t efi_esrt_populate(void);
efi_status_t efi_load_capsule_drivers(void);
efi_status_t platform_get_eventlog(struct udevice *dev, u64 *addr, u32 *sz);
+
+efi_status_t efi_locate_handle_buffer_int(enum efi_locate_search_type search_type,
+ const efi_guid_t *protocol, void *search_key,
+ efi_uintn_t *no_handles, efi_handle_t **buffer);
+
+efi_status_t efi_open_volume_int(struct efi_simple_file_system_protocol *this,
+ struct efi_file_handle **root);
+efi_status_t efi_file_open_int(struct efi_file_handle *this,
+ struct efi_file_handle **new_handle,
+ u16 *file_name, u64 open_mode,
+ u64 attributes);
+efi_status_t efi_file_close_int(struct efi_file_handle *file);
+efi_status_t efi_file_read_int(struct efi_file_handle *this,
+ efi_uintn_t *buffer_size, void *buffer);
+efi_status_t efi_file_setpos_int(struct efi_file_handle *file, u64 pos);
+
+typedef efi_status_t (*efi_console_filter_func)(struct efi_input_key *key);
+efi_status_t efi_console_get_u16_string
+ (struct efi_simple_text_input_protocol *cin,
+ u16 *buf, efi_uintn_t count, efi_console_filter_func filer_func,
+ int row, int col);
+
+efi_status_t efi_disk_get_device_name(const efi_handle_t handle, char *buf, int size);
+
#endif /* _EFI_LOADER_H */
diff --git a/include/event.h b/include/event.h
index e8f2f55c63d..3e6dcbc3dd6 100644
--- a/include/event.h
+++ b/include/event.h
@@ -60,9 +60,11 @@ union event_data {
* struct event_ft_fixup - FDT fixup before booting
*
* @tree: tree to update
+ * @images: images which are being booted
*/
struct event_ft_fixup {
oftree tree;
+ struct bootm_headers *images;
} ft_fixup;
};
@@ -143,8 +145,8 @@ static inline const char *event_spy_id(struct evspy_info *spy)
* vbe_simple.c - so for now, make it global.
*/
#define EVENT_SPY(_type, _func) \
- __used ll_entry_declare(struct evspy_info, _type, evspy_info) = \
- _ESPY_REC(_type, _func)
+ __used ll_entry_declare(struct evspy_info, _type ## _3_ ## _func, \
+ evspy_info) = _ESPY_REC(_type, _func)
/**
* event_register - register a new spy
diff --git a/include/image.h b/include/image.h
index d7d756c6453..eb2513c5b74 100644
--- a/include/image.h
+++ b/include/image.h
@@ -263,7 +263,7 @@ enum {
* Legacy format image header,
* all data in network byte order (aka natural aka bigendian).
*/
-typedef struct image_header {
+struct legacy_img_hdr {
uint32_t ih_magic; /* Image Header Magic Number */
uint32_t ih_hcrc; /* Image Header CRC Checksum */
uint32_t ih_time; /* Image Creation Timestamp */
@@ -276,28 +276,28 @@ typedef struct image_header {
uint8_t ih_type; /* Image Type */
uint8_t ih_comp; /* Compression Type */
uint8_t ih_name[IH_NMLEN]; /* Image Name */
-} image_header_t;
+};
-typedef struct image_info {
+struct image_info {
ulong start, end; /* start/end of blob */
ulong image_start, image_len; /* start of image within blob, len of image */
ulong load; /* load addr for the image */
uint8_t comp, type, os; /* compression, type of image, os type */
uint8_t arch; /* CPU architecture */
-} image_info_t;
+};
/*
* Legacy and FIT format headers used by do_bootm() and do_bootm_<os>()
* routines.
*/
-typedef struct bootm_headers {
+struct bootm_headers {
/*
* Legacy os image header, if it is a multi component image
* then boot_get_ramdisk() and get_fdt() will attempt to get
* data from second and third component accordingly.
*/
- image_header_t *legacy_hdr_os; /* image header pointer */
- image_header_t legacy_hdr_os_copy; /* header copy */
+ struct legacy_img_hdr *legacy_hdr_os; /* image header pointer */
+ struct legacy_img_hdr legacy_hdr_os_copy; /* header copy */
ulong legacy_hdr_valid;
/*
@@ -324,7 +324,7 @@ typedef struct bootm_headers {
int fit_noffset_setup;/* x86 setup subimage node offset */
#ifndef USE_HOSTCC
- image_info_t os; /* os image info */
+ struct image_info os; /* os image info */
ulong ep; /* entry point of OS */
ulong rd_start, rd_end;/* ramdisk start/end */
@@ -341,26 +341,32 @@ typedef struct bootm_headers {
int verify; /* env_get("verify")[0] != 'n' */
-#define BOOTM_STATE_START (0x00000001)
-#define BOOTM_STATE_FINDOS (0x00000002)
-#define BOOTM_STATE_FINDOTHER (0x00000004)
-#define BOOTM_STATE_LOADOS (0x00000008)
-#define BOOTM_STATE_RAMDISK (0x00000010)
-#define BOOTM_STATE_FDT (0x00000020)
-#define BOOTM_STATE_OS_CMDLINE (0x00000040)
-#define BOOTM_STATE_OS_BD_T (0x00000080)
-#define BOOTM_STATE_OS_PREP (0x00000100)
-#define BOOTM_STATE_OS_FAKE_GO (0x00000200) /* 'Almost' run the OS */
-#define BOOTM_STATE_OS_GO (0x00000400)
-#define BOOTM_STATE_PRE_LOAD 0x00000800
+#define BOOTM_STATE_START 0x00000001
+#define BOOTM_STATE_FINDOS 0x00000002
+#define BOOTM_STATE_FINDOTHER 0x00000004
+#define BOOTM_STATE_LOADOS 0x00000008
+#define BOOTM_STATE_RAMDISK 0x00000010
+#define BOOTM_STATE_FDT 0x00000020
+#define BOOTM_STATE_OS_CMDLINE 0x00000040
+#define BOOTM_STATE_OS_BD_T 0x00000080
+#define BOOTM_STATE_OS_PREP 0x00000100
+#define BOOTM_STATE_OS_FAKE_GO 0x00000200 /* 'Almost' run the OS */
+#define BOOTM_STATE_OS_GO 0x00000400
+#define BOOTM_STATE_PRE_LOAD 0x00000800
int state;
#if defined(CONFIG_LMB) && !defined(USE_HOSTCC)
struct lmb lmb; /* for memory mgmt */
#endif
-} bootm_headers_t;
+};
+
+#ifdef CONFIG_LMB
+#define images_lmb(_images) (&(_images)->lmb)
+#else
+#define images_lmb(_images) NULL
+#endif
-extern bootm_headers_t images;
+extern struct bootm_headers images;
/*
* Some systems (for example LWMON) have very short watchdog periods;
@@ -524,7 +530,7 @@ enum fit_load_op {
FIT_LOAD_REQUIRED, /* Must be provided */
};
-int boot_get_setup(bootm_headers_t *images, uint8_t arch, ulong *setup_start,
+int boot_get_setup(struct bootm_headers *images, uint8_t arch, ulong *setup_start,
ulong *setup_len);
/* Image format types, returned by _get_format() routine */
@@ -538,11 +544,11 @@ ulong genimg_get_kernel_addr_fit(char * const img_addr,
const char **fit_uname_kernel);
ulong genimg_get_kernel_addr(char * const img_addr);
int genimg_get_format(const void *img_addr);
-int genimg_has_config(bootm_headers_t *images);
+int genimg_has_config(struct bootm_headers *images);
-int boot_get_fpga(int argc, char *const argv[], bootm_headers_t *images,
+int boot_get_fpga(int argc, char *const argv[], struct bootm_headers *images,
uint8_t arch, const ulong *ld_start, ulong * const ld_len);
-int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images,
+int boot_get_ramdisk(int argc, char *const argv[], struct bootm_headers *images,
uint8_t arch, ulong *rd_start, ulong *rd_end);
/**
@@ -566,10 +572,10 @@ int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images,
* 0, if only valid images or no images are found
* error code, if an error occurs during fit_image_load
*/
-int boot_get_loadable(int argc, char *const argv[], bootm_headers_t *images,
+int boot_get_loadable(int argc, char *const argv[], struct bootm_headers *images,
uint8_t arch, const ulong *ld_start, ulong *const ld_len);
-int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
+int boot_get_setup_fit(struct bootm_headers *images, uint8_t arch,
ulong *setup_start, ulong *setup_len);
/**
@@ -593,9 +599,9 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
*
* Return: node offset of base image, or -ve error code on error
*/
-int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,
- const char **fit_unamep, const char **fit_uname_configp,
- int arch, ulong *datap, ulong *lenp);
+int boot_get_fdt_fit(struct bootm_headers *images, ulong addr,
+ const char **fit_unamep, const char **fit_uname_configp,
+ int arch, ulong *datap, ulong *lenp);
/**
* fit_image_load() - load an image from a FIT
@@ -627,7 +633,7 @@ int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,
* @param lenp Returns length of loaded image
* Return: node offset of image, or -ve error code on error
*/
-int fit_image_load(bootm_headers_t *images, ulong addr,
+int fit_image_load(struct bootm_headers *images, ulong addr,
const char **fit_unamep, const char **fit_uname_configp,
int arch, int image_type, int bootstage_id,
enum fit_load_op load_op, ulong *datap, ulong *lenp);
@@ -671,11 +677,11 @@ int image_source_script(ulong addr, const char *fit_uname);
* @param prop_name Property name to look up (FIT_..._PROP)
* @param addr Address of FIT in memory
*/
-int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
- ulong addr);
+int fit_get_node_from_config(struct bootm_headers *images,
+ const char *prop_name, ulong addr);
int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch,
- bootm_headers_t *images,
+ struct bootm_headers *images,
char **of_flat_tree, ulong *of_size);
void boot_fdt_add_mem_rsv_regions(struct lmb *lmb, void *fdt_blob);
int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size);
@@ -690,11 +696,11 @@ int boot_get_kbd(struct lmb *lmb, struct bd_info **kbd);
/*******************************************************************/
static inline uint32_t image_get_header_size(void)
{
- return (sizeof(image_header_t));
+ return sizeof(struct legacy_img_hdr);
}
#define image_get_hdr_l(f) \
- static inline uint32_t image_get_##f(const image_header_t *hdr) \
+ static inline uint32_t image_get_##f(const struct legacy_img_hdr *hdr) \
{ \
return uimage_to_cpu(hdr->ih_##f); \
}
@@ -707,7 +713,7 @@ image_get_hdr_l(ep) /* image_get_ep */
image_get_hdr_l(dcrc) /* image_get_dcrc */
#define image_get_hdr_b(f) \
- static inline uint8_t image_get_##f(const image_header_t *hdr) \
+ static inline uint8_t image_get_##f(const struct legacy_img_hdr *hdr) \
{ \
return hdr->ih_##f; \
}
@@ -716,12 +722,12 @@ image_get_hdr_b(arch) /* image_get_arch */
image_get_hdr_b(type) /* image_get_type */
image_get_hdr_b(comp) /* image_get_comp */
-static inline char *image_get_name(const image_header_t *hdr)
+static inline char *image_get_name(const struct legacy_img_hdr *hdr)
{
return (char *)hdr->ih_name;
}
-static inline uint32_t image_get_data_size(const image_header_t *hdr)
+static inline uint32_t image_get_data_size(const struct legacy_img_hdr *hdr)
{
return image_get_size(hdr);
}
@@ -737,22 +743,23 @@ static inline uint32_t image_get_data_size(const image_header_t *hdr)
* returns:
* image payload data start address
*/
-static inline ulong image_get_data(const image_header_t *hdr)
+static inline ulong image_get_data(const struct legacy_img_hdr *hdr)
{
return ((ulong)hdr + image_get_header_size());
}
-static inline uint32_t image_get_image_size(const image_header_t *hdr)
+static inline uint32_t image_get_image_size(const struct legacy_img_hdr *hdr)
{
return (image_get_size(hdr) + image_get_header_size());
}
-static inline ulong image_get_image_end(const image_header_t *hdr)
+
+static inline ulong image_get_image_end(const struct legacy_img_hdr *hdr)
{
return ((ulong)hdr + image_get_image_size(hdr));
}
#define image_set_hdr_l(f) \
- static inline void image_set_##f(image_header_t *hdr, uint32_t val) \
+ static inline void image_set_##f(struct legacy_img_hdr *hdr, uint32_t val) \
{ \
hdr->ih_##f = cpu_to_uimage(val); \
}
@@ -765,7 +772,7 @@ image_set_hdr_l(ep) /* image_set_ep */
image_set_hdr_l(dcrc) /* image_set_dcrc */
#define image_set_hdr_b(f) \
- static inline void image_set_##f(image_header_t *hdr, uint8_t val) \
+ static inline void image_set_##f(struct legacy_img_hdr *hdr, uint8_t val) \
{ \
hdr->ih_##f = val; \
}
@@ -774,13 +781,13 @@ image_set_hdr_b(arch) /* image_set_arch */
image_set_hdr_b(type) /* image_set_type */
image_set_hdr_b(comp) /* image_set_comp */
-static inline void image_set_name(image_header_t *hdr, const char *name)
+static inline void image_set_name(struct legacy_img_hdr *hdr, const char *name)
{
strncpy(image_get_name(hdr), name, IH_NMLEN);
}
-int image_check_hcrc(const image_header_t *hdr);
-int image_check_dcrc(const image_header_t *hdr);
+int image_check_hcrc(const struct legacy_img_hdr *hdr);
+int image_check_dcrc(const struct legacy_img_hdr *hdr);
#ifndef USE_HOSTCC
ulong env_get_bootm_low(void);
phys_size_t env_get_bootm_size(void);
@@ -788,15 +795,17 @@ phys_size_t env_get_bootm_mapsize(void);
#endif
void memmove_wd(void *to, void *from, size_t len, ulong chunksz);
-static inline int image_check_magic(const image_header_t *hdr)
+static inline int image_check_magic(const struct legacy_img_hdr *hdr)
{
return (image_get_magic(hdr) == IH_MAGIC);
}
-static inline int image_check_type(const image_header_t *hdr, uint8_t type)
+
+static inline int image_check_type(const struct legacy_img_hdr *hdr, uint8_t type)
{
return (image_get_type(hdr) == type);
}
-static inline int image_check_arch(const image_header_t *hdr, uint8_t arch)
+
+static inline int image_check_arch(const struct legacy_img_hdr *hdr, uint8_t arch)
{
/* Let's assume that sandbox can load any architecture */
if (!tools_build() && IS_ENABLED(CONFIG_SANDBOX))
@@ -804,19 +813,20 @@ static inline int image_check_arch(const image_header_t *hdr, uint8_t arch)
return (image_get_arch(hdr) == arch) ||
(image_get_arch(hdr) == IH_ARCH_ARM && arch == IH_ARCH_ARM64);
}
-static inline int image_check_os(const image_header_t *hdr, uint8_t os)
+
+static inline int image_check_os(const struct legacy_img_hdr *hdr, uint8_t os)
{
return (image_get_os(hdr) == os);
}
-ulong image_multi_count(const image_header_t *hdr);
-void image_multi_getimg(const image_header_t *hdr, ulong idx,
+ulong image_multi_count(const struct legacy_img_hdr *hdr);
+void image_multi_getimg(const struct legacy_img_hdr *hdr, ulong idx,
ulong *data, ulong *len);
void image_print_contents(const void *hdr);
#ifndef USE_HOSTCC
-static inline int image_check_target_arch(const image_header_t *hdr)
+static inline int image_check_target_arch(const struct legacy_img_hdr *hdr)
{
#ifndef IH_ARCH_DEFAULT
# error "please define IH_ARCH_DEFAULT in your arch asm/u-boot.h"
@@ -865,7 +875,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
* @lmb: Points to logical memory block structure
* Return: 0 if ok, <0 on failure
*/
-int image_setup_libfdt(bootm_headers_t *images, void *blob,
+int image_setup_libfdt(struct bootm_headers *images, void *blob,
int of_size, struct lmb *lmb);
/**
@@ -877,7 +887,7 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
* @param images Images information
* Return: 0 if ok, <0 on failure
*/
-int image_setup_linux(bootm_headers_t *images);
+int image_setup_linux(struct bootm_headers *images);
/**
* bootz_setup() - Extract stat and size of a Linux xImage
diff --git a/include/init.h b/include/init.h
index 7b8f62c1218..50a8302dc54 100644
--- a/include/init.h
+++ b/include/init.h
@@ -291,7 +291,7 @@ int show_board_info(void);
*
* @param total_size Size of U-Boot (unused?)
*/
-ulong board_get_usable_ram_top(ulong total_size);
+phys_size_t board_get_usable_ram_top(phys_size_t total_size);
int board_early_init_f(void);
@@ -343,6 +343,19 @@ void bdinfo_print_num_ll(const char *name, unsigned long long value);
/* Print a clock speed in MHz */
void bdinfo_print_mhz(const char *name, unsigned long hz);
+/**
+ * bdinfo_print_size - print size variables in bdinfo format
+ * @name: string to print before the size
+ * @size: size to print
+ *
+ * Helper function for displaying size variables as properly formatted bdinfo
+ * entries. The size is printed as "xxx Bytes", "xxx KiB", "xxx MiB",
+ * "xxx GiB", etc. as needed;
+ *
+ * For use in arch_print_bdinfo().
+ */
+void bdinfo_print_size(const char *name, uint64_t size);
+
/* Show arch-specific information for the 'bd' command */
void arch_print_bdinfo(void);
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 3d0acbd582e..921e698f407 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -2,6 +2,7 @@
#define _LINUX_COMPAT_H_
#include <console.h>
+#include <cyclic.h>
#include <log.h>
#include <malloc.h>
@@ -230,7 +231,6 @@ typedef unsigned long blkcnt_t;
#define try_to_freeze(...) 0
#define set_current_state(...) do { } while (0)
#define kthread_should_stop(...) 0
-#define schedule() do { } while (0)
#define setup_timer(timer, func, data) do {} while (0)
#define del_timer_sync(timer) do {} while (0)
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index aa45558b3d4..fb002ae6411 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -29,9 +29,8 @@ struct nand_flash_dev;
struct device_node;
/* Get the flash and manufacturer id and lookup if the type is supported. */
-struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip,
- int *maf_id, int *dev_id,
- struct nand_flash_dev *type);
+int nand_detect(struct nand_chip *chip, int *maf_id, int *dev_id,
+ struct nand_flash_dev *type);
/* Scan and identify a NAND device */
int nand_scan(struct mtd_info *mtd, int max_chips);
@@ -976,7 +975,7 @@ struct nand_chip {
void *priv;
struct {
- const struct nand_manufacturers *desc;
+ const struct nand_manufacturer *desc;
void *priv;
} manufacturer;
};
@@ -1124,19 +1123,19 @@ struct nand_flash_dev {
};
/**
- * struct nand_manufacturers - NAND Flash Manufacturer ID Structure
+ * struct nand_manufacturer - NAND Flash Manufacturer ID Structure
* @name: Manufacturer name
* @id: manufacturer ID code of device.
* @ops: manufacturer operations
*/
-struct nand_manufacturers {
+struct nand_manufacturer {
int id;
char *name;
const struct nand_manufacturer_ops *ops;
};
extern struct nand_flash_dev nand_flash_ids[];
-extern struct nand_manufacturers nand_manuf_ids[];
+extern struct nand_manufacturer nand_manuf_ids[];
extern const struct nand_manufacturer_ops toshiba_nand_manuf_ops;
extern const struct nand_manufacturer_ops samsung_nand_manuf_ops;
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 2595bad9dfe..638d807ee55 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -11,6 +11,7 @@
#include <linux/bitops.h>
#include <linux/mtd/cfi.h>
#include <linux/mtd/mtd.h>
+#include <spi-mem.h>
/*
* Manufacturer IDs
@@ -522,6 +523,7 @@ struct spi_flash {
* @quad_enable: [FLASH-SPECIFIC] enables SPI NOR quad mode
* @octal_dtr_enable: [FLASH-SPECIFIC] enables SPI NOR octal DTR mode.
* @ready: [FLASH-SPECIFIC] check if the flash is ready
+ * @dirmap: pointers to struct spi_mem_dirmap_desc for reads/writes.
* @priv: the private data
*/
struct spi_nor {
@@ -572,6 +574,11 @@ struct spi_nor {
int (*octal_dtr_enable)(struct spi_nor *nor);
int (*ready)(struct spi_nor *nor);
+ struct {
+ struct spi_mem_dirmap_desc *rdesc;
+ struct spi_mem_dirmap_desc *wdesc;
+ } dirmap;
+
void *priv;
char mtd_name[MTD_NAME_SIZE(MTD_DEV_TYPE_NOR)];
/* Compatibility for spi_flash, remove once sf layer is merged with mtd */
@@ -596,6 +603,17 @@ device_node *spi_nor_get_flash_node(struct spi_nor *nor)
#endif /* __UBOOT__ */
/**
+ * spi_nor_setup_op() - Set up common properties of a spi-mem op.
+ * @nor: pointer to a 'struct spi_nor'
+ * @op: pointer to the 'struct spi_mem_op' whose properties
+ * need to be initialized.
+ * @proto: the protocol from which the properties need to be set.
+ */
+void spi_nor_setup_op(const struct spi_nor *nor,
+ struct spi_mem_op *op,
+ const enum spi_nor_protocol proto);
+
+/**
* spi_nor_scan() - scan the SPI NOR
* @nor: the spi_nor structure
*
diff --git a/include/log.h b/include/log.h
index df497bad181..8a7b961bbfb 100644
--- a/include/log.h
+++ b/include/log.h
@@ -322,7 +322,10 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line,
*
* or:
*
- * return log_msg_ret("fred failed", fred_call());
+ * return log_msg_ret("get", fred_call());
+ *
+ * It is recommended to use <= 3 characters for the name since this will only
+ * use 4 bytes in rodata
*/
#define log_ret(_ret) ({ \
int __ret = (_ret); \
diff --git a/include/malloc.h b/include/malloc.h
index e8c8b254c0d..161ccbd1298 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -883,6 +883,18 @@ extern Void_t* sbrk();
void malloc_simple_info(void);
+/**
+ * malloc_enable_testing() - Put malloc() into test mode
+ *
+ * This only works if UNIT_TESTING is enabled
+ *
+ * @max_allocs: return -ENOMEM after max_allocs calls to malloc()
+ */
+void malloc_enable_testing(int max_allocs);
+
+/** malloc_disable_testing() - Put malloc() into normal mode */
+void malloc_disable_testing(void);
+
#if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
#define malloc malloc_simple
#define realloc realloc_simple
diff --git a/include/menu.h b/include/menu.h
index e74616cae87..702aacb170c 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -48,6 +48,9 @@ enum bootmenu_key {
KEY_DOWN,
KEY_SELECT,
KEY_QUIT,
+ KEY_PLUS,
+ KEY_MINUS,
+ KEY_SPACE,
};
void bootmenu_autoboot_loop(struct bootmenu_data *menu,
diff --git a/include/mmc.h b/include/mmc.h
index f519d869725..027e8bcc73a 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -767,7 +767,7 @@ struct mmc *mmc_create(const struct mmc_config *cfg, void *priv);
/**
* mmc_bind() - Set up a new MMC device ready for probing
*
- * A child block device is bound with the IF_TYPE_MMC interface type. This
+ * A child block device is bound with the UCLASS_MMC interface type. This
* allows the device to be used with CONFIG_BLK
*
* @dev: MMC device to set up
diff --git a/include/os.h b/include/os.h
index 148178787bc..5b353ae9d94 100644
--- a/include/os.h
+++ b/include/os.h
@@ -296,6 +296,14 @@ void os_putc(int ch);
void os_puts(const char *str);
/**
+ * os_flush() - flush controlling OS terminal
+ *
+ * This bypasses the U-Boot console support and flushes directly the OS
+ * stdout file descriptor.
+ */
+void os_flush(void);
+
+/**
* os_write_ram_buf() - write the sandbox RAM buffer to a existing file
*
* @fname: filename to write memory to (simple binary format)
diff --git a/include/scsi.h b/include/scsi.h
index b47c7463c1d..94e1d8ccb28 100644
--- a/include/scsi.h
+++ b/include/scsi.h
@@ -15,27 +15,47 @@
struct udevice;
+/**
+ * struct scsi_cmd - information about a SCSI command to be processed
+ *
+ * @cmd: command
+ * @sense_buf: for request sense
+ * @status: SCSI Status
+ * @target: Target ID
+ * @lun: Target LUN
+ * @cmdlen: command len
+ * @datalen: Total data length
+ * @pdata: pointer to data
+ * @msgout: Messge out buffer (NOT USED)
+ * @msgin: Message in buffer
+ * @sensecmdlen: Sense command len
+ * @sensedatalen: Sense data len
+ * @sensecmd: Sense command
+ * @contr_stat: Controller Status
+ * @trans_bytes: tranfered bytes
+ * @priv: Private value
+ * @dma_dir: Direction of data structure
+ */
struct scsi_cmd {
- unsigned char cmd[16]; /* command */
- /* for request sense */
- unsigned char sense_buf[64]
+ unsigned char cmd[16];
+ unsigned char sense_buf[64]
__attribute__((aligned(ARCH_DMA_MINALIGN)));
- unsigned char status; /* SCSI Status */
- unsigned char target; /* Target ID */
- unsigned char lun; /* Target LUN */
- unsigned char cmdlen; /* command len */
- unsigned long datalen; /* Total data length */
- unsigned char * pdata; /* pointer to data */
- unsigned char msgout[12]; /* Messge out buffer (NOT USED) */
- unsigned char msgin[12]; /* Message in buffer */
- unsigned char sensecmdlen; /* Sense command len */
- unsigned long sensedatalen; /* Sense data len */
- unsigned char sensecmd[6]; /* Sense command */
- unsigned long contr_stat; /* Controller Status */
- unsigned long trans_bytes; /* tranfered bytes */
-
- unsigned int priv;
- enum dma_data_direction dma_dir;
+ unsigned char status;
+ unsigned char target;
+ unsigned char lun;
+ unsigned char cmdlen;
+ unsigned long datalen;
+ unsigned char *pdata;
+ unsigned char msgout[12];
+ unsigned char msgin[12];
+ unsigned char sensecmdlen;
+ unsigned long sensedatalen;
+ unsigned char sensecmd[6];
+ unsigned long contr_stat;
+ unsigned long trans_bytes;
+
+ unsigned int priv;
+ enum dma_data_direction dma_dir;
};
/*-----------------------------------------------------------
@@ -168,6 +188,74 @@ struct scsi_cmd {
#define SCSI_WRITE_SAME 0x41 /* Write Same (O) */
/**
+ * enum scsi_cmd_phase - current phase of the SCSI protocol
+ *
+ * @SCSIPH_START: Start phase
+ * @SCSIPH_DATA: Data phase
+ * @SCSIPH_STATUS: Status phase
+ */
+enum scsi_cmd_phase {
+ SCSIPH_START,
+ SCSIPH_DATA,
+ SCSIPH_STATUS,
+};
+
+/**
+ * struct scsi_inquiry_resp - holds a SCSI inquiry command
+ *
+ * @type; command type
+ * @flags; command flags
+ * @version; command version
+ * @data_format; data format
+ * @additional_len; additional data length
+ * @spare[3]; spare bytes
+ * @vendor[8]; vendor information
+ * @product[16]; production information
+ * @revision[4]; revision information
+ */
+struct scsi_inquiry_resp {
+ u8 type;
+ u8 flags;
+ u8 version;
+ u8 data_format;
+ u8 additional_len;
+ u8 spare[3];
+ char vendor[8];
+ char product[16];
+ char revision[4];
+};
+
+/**
+ * struct scsi_read_capacity_resp - holds the response to a read-capacity cmd
+ *
+ * @last_block_addr: Logical block address of last block
+ * @block_len: Length of each block in bytes
+ */
+struct scsi_read_capacity_resp {
+ u32 last_block_addr;
+ u32 block_len;
+};
+
+/**
+ * struct scsi_read10_req - holds a SCSI READ10 request
+ *
+ * @cmd; command type
+ * @lun_flags; LUN flags
+ * @lba; Logical block address to start reading from
+ * @spare; spare bytes
+ * @xfer_len: number of blocks to read
+ * @spare2: more spare bytes
+ */
+struct __packed scsi_read10_req {
+ u8 cmd;
+ u8 lun_flags;
+ u32 lba;
+ u8 spare;
+ u16 xfer_len;
+ u8 spare2[3];
+};
+
+/**
* struct scsi_plat - stores information about SCSI controller
*
* @base: Controller base address
diff --git a/include/scsi_emul.h b/include/scsi_emul.h
new file mode 100644
index 00000000000..13c3f860b40
--- /dev/null
+++ b/include/scsi_emul.h
@@ -0,0 +1,70 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Emulation of enough SCSI commands to find and read from a unit
+ *
+ * Copyright 2022 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * implementations of SCSI functions required so that CONFIG_SCSI can be enabled
+ * for sandbox
+ */
+
+#ifndef __scsi_emul_h
+#define __scsi_emul_h
+
+/**
+ * struct scsi_emul_info - information for emulating a SCSI device
+ *
+ * @vendor: Vendor name
+ * @product: Product name
+ * @block_size: Block size of device in bytes (normally 512)
+ * @file_size: Size of the backing file for this emulator, in bytes
+ * @seek_block: Seek position for file (block number)
+ *
+ * @phase: Current SCSI phase
+ * @buff_used: Number of bytes ready to transfer back to host
+ * @read_len: Number of bytes of data left in the current read command
+ * @alloc_len: Allocation length from the last incoming command
+ * @transfer_len: Transfer length from CBW header
+ * @buff: Data buffer for outgoing data
+ */
+struct scsi_emul_info {
+ /* provided by the caller: */
+ void *buff;
+ const char *vendor;
+ const char *product;
+ int block_size;
+ loff_t file_size;
+ int seek_block;
+
+ /* state maintained by the emulator: */
+ enum scsi_cmd_phase phase;
+ int buff_used;
+ int read_len;
+ uint seek_pos;
+ int alloc_len;
+ uint transfer_len;
+};
+
+/* Indicates that a read is being started */
+#define SCSI_EMUL_DO_READ 1
+
+/**
+ * sb_scsi_emul_command() - Process a SCSI command
+ *
+ * This sets up the response in info->buff and updates various other values
+ * in info.
+ *
+ * If SCSI_EMUL_DO_READ is returned then the caller should set up so that the
+ * backing file can be read, or return an error status if there is no file.
+ *
+ * @info: Emulation information
+ * @req: Request to process
+ * @len: Length of request in bytes
+ * @return SCSI_EMUL_DO_READ if a read has started, 0 if some other operation
+ * has started, -ve if there was an error
+ */
+int sb_scsi_emul_command(struct scsi_emul_info *info,
+ const struct scsi_cmd *req, int len);
+
+#endif
diff --git a/include/serial.h b/include/serial.h
index 8c2e7adbc32..fe01bcfadb9 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -362,6 +362,11 @@ void serial_setbrg(void);
void serial_putc(const char ch);
void serial_putc_raw(const char ch);
void serial_puts(const char *str);
+#if defined(CONFIG_CONSOLE_FLUSH_SUPPORT) && CONFIG_IS_ENABLED(DM_SERIAL)
+void serial_flush(void);
+#else
+static inline void serial_flush(void) {}
+#endif
int serial_getc(void);
int serial_tstc(void);
diff --git a/include/spi-mem.h b/include/spi-mem.h
index 32ffdc2e0f9..b07cf2ed83d 100644
--- a/include/spi-mem.h
+++ b/include/spi-mem.h
@@ -134,6 +134,48 @@ struct spi_mem_op {
.dummy = __dummy, \
.data = __data, \
}
+/**
+ * struct spi_mem_dirmap_info - Direct mapping information
+ * @op_tmpl: operation template that should be used by the direct mapping when
+ * the memory device is accessed
+ * @offset: absolute offset this direct mapping is pointing to
+ * @length: length in byte of this direct mapping
+ *
+ * This information is used by the controller specific implementation to know
+ * the portion of memory that is directly mapped and the spi_mem_op that should
+ * be used to access the device.
+ * A direct mapping is only valid for one direction (read or write) and this
+ * direction is directly encoded in the ->op_tmpl.data.dir field.
+ */
+struct spi_mem_dirmap_info {
+ struct spi_mem_op op_tmpl;
+ u64 offset;
+ u64 length;
+};
+
+/**
+ * struct spi_mem_dirmap_desc - Direct mapping descriptor
+ * @mem: the SPI memory device this direct mapping is attached to
+ * @info: information passed at direct mapping creation time
+ * @nodirmap: set to 1 if the SPI controller does not implement
+ * ->mem_ops->dirmap_create() or when this function returned an
+ * error. If @nodirmap is true, all spi_mem_dirmap_{read,write}()
+ * calls will use spi_mem_exec_op() to access the memory. This is a
+ * degraded mode that allows spi_mem drivers to use the same code
+ * no matter whether the controller supports direct mapping or not
+ * @priv: field pointing to controller specific data
+ *
+ * Common part of a direct mapping descriptor. This object is created by
+ * spi_mem_dirmap_create() and controller implementation of ->create_dirmap()
+ * can create/attach direct mapping resources to the descriptor in the ->priv
+ * field.
+ */
+struct spi_mem_dirmap_desc {
+ struct spi_slave *slave;
+ struct spi_mem_dirmap_info info;
+ unsigned int nodirmap;
+ void *priv;
+};
#ifndef __UBOOT__
/**
@@ -183,10 +225,32 @@ static inline void *spi_mem_get_drvdata(struct spi_mem *mem)
* limitations)
* @supports_op: check if an operation is supported by the controller
* @exec_op: execute a SPI memory operation
+ * @dirmap_create: create a direct mapping descriptor that can later be used to
+ * access the memory device. This method is optional
+ * @dirmap_destroy: destroy a memory descriptor previous created by
+ * ->dirmap_create()
+ * @dirmap_read: read data from the memory device using the direct mapping
+ * created by ->dirmap_create(). The function can return less
+ * data than requested (for example when the request is crossing
+ * the currently mapped area), and the caller of
+ * spi_mem_dirmap_read() is responsible for calling it again in
+ * this case.
+ * @dirmap_write: write data to the memory device using the direct mapping
+ * created by ->dirmap_create(). The function can return less
+ * data than requested (for example when the request is crossing
+ * the currently mapped area), and the caller of
+ * spi_mem_dirmap_write() is responsible for calling it again in
+ * this case.
*
* This interface should be implemented by SPI controllers providing an
* high-level interface to execute SPI memory operation, which is usually the
* case for QSPI controllers.
+ *
+ * Note on ->dirmap_{read,write}(): drivers should avoid accessing the direct
+ * mapping from the CPU because doing that can stall the CPU waiting for the
+ * SPI mem transaction to finish, and this will make real-time maintainers
+ * unhappy and might make your system less reactive. Instead, drivers should
+ * use DMA to access this direct mapping.
*/
struct spi_controller_mem_ops {
int (*adjust_op_size)(struct spi_slave *slave, struct spi_mem_op *op);
@@ -194,6 +258,12 @@ struct spi_controller_mem_ops {
const struct spi_mem_op *op);
int (*exec_op)(struct spi_slave *slave,
const struct spi_mem_op *op);
+ int (*dirmap_create)(struct spi_mem_dirmap_desc *desc);
+ void (*dirmap_destroy)(struct spi_mem_dirmap_desc *desc);
+ ssize_t (*dirmap_read)(struct spi_mem_dirmap_desc *desc,
+ u64 offs, size_t len, void *buf);
+ ssize_t (*dirmap_write)(struct spi_mem_dirmap_desc *desc,
+ u64 offs, size_t len, const void *buf);
};
#ifndef __UBOOT__
@@ -260,6 +330,15 @@ int spi_mem_exec_op(struct spi_slave *slave, const struct spi_mem_op *op);
bool spi_mem_default_supports_op(struct spi_slave *mem,
const struct spi_mem_op *op);
+struct spi_mem_dirmap_desc *
+spi_mem_dirmap_create(struct spi_slave *mem,
+ const struct spi_mem_dirmap_info *info);
+void spi_mem_dirmap_destroy(struct spi_mem_dirmap_desc *desc);
+ssize_t spi_mem_dirmap_read(struct spi_mem_dirmap_desc *desc,
+ u64 offs, size_t len, void *buf);
+ssize_t spi_mem_dirmap_write(struct spi_mem_dirmap_desc *desc,
+ u64 offs, size_t len, const void *buf);
+
#ifndef __UBOOT__
int spi_mem_driver_register_with_owner(struct spi_mem_driver *drv,
struct module *owner);
diff --git a/include/spl.h b/include/spl.h
index aac6648f946..0fc3686bbca 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -17,7 +17,7 @@
#include <mmc.h>
struct blk_desc;
-struct image_header;
+struct legacy_img_hdr;
/* Value in r0 indicates we booted from U-Boot */
#define UBOOT_NOT_LOADED_FROM_SPL 0x13578642
@@ -29,7 +29,7 @@ struct image_header;
#define MMCSD_MODE_EMMCBOOT 3
struct blk_desc;
-struct image_header;
+struct legacy_img_hdr;
struct spl_boot_device;
/*
@@ -476,7 +476,7 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image);
*/
int spl_parse_image_header(struct spl_image_info *spl_image,
const struct spl_boot_device *bootdev,
- const struct image_header *header);
+ const struct legacy_img_hdr *header);
void spl_board_prepare_for_linux(void);
@@ -865,7 +865,7 @@ void spl_perform_fixups(struct spl_image_info *spl_image);
* Returns memory area which can be populated by partial image data,
* ie. uImage or fitImage header.
*/
-struct image_header *spl_get_load_buffer(ssize_t offset, size_t size);
+struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size);
void spl_save_restore_data(void);
#endif
diff --git a/include/stdio.h b/include/stdio.h
index 1939a48f0fb..3241e2d493f 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -15,6 +15,11 @@ int tstc(void);
defined(CONFIG_SPL_SERIAL))
void putc(const char c);
void puts(const char *s);
+#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
+void flush(void);
+#else
+static inline void flush(void) {}
+#endif
int __printf(1, 2) printf(const char *fmt, ...);
int vprintf(const char *fmt, va_list args);
#else
@@ -26,6 +31,10 @@ static inline void puts(const char *s)
{
}
+static inline void flush(void)
+{
+}
+
static inline int __printf(1, 2) printf(const char *fmt, ...)
{
return 0;
@@ -48,11 +57,17 @@ static inline int vprintf(const char *fmt, va_list args)
/* stderr */
#define eputc(c) fputc(stderr, c)
#define eputs(s) fputs(stderr, s)
+#define eflush() fflush(stderr)
#define eprintf(fmt, args...) fprintf(stderr, fmt, ##args)
int __printf(2, 3) fprintf(int file, const char *fmt, ...);
void fputs(int file, const char *s);
void fputc(int file, const char c);
+#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
+void fflush(int file);
+#else
+static inline void fflush(int file) {}
+#endif
int ftstc(int file);
int fgetc(int file);
diff --git a/include/stdio_dev.h b/include/stdio_dev.h
index 270fa2729fb..3105928970d 100644
--- a/include/stdio_dev.h
+++ b/include/stdio_dev.h
@@ -37,6 +37,13 @@ struct stdio_dev {
void (*putc)(struct stdio_dev *dev, const char c);
/* To put a string (accelerator) */
void (*puts)(struct stdio_dev *dev, const char *s);
+#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
+ /* To flush output queue */
+ void (*flush)(struct stdio_dev *dev);
+#define STDIO_DEV_ASSIGN_FLUSH(dev, flush_func) ((dev)->flush = (flush_func))
+#else
+#define STDIO_DEV_ASSIGN_FLUSH(dev, flush_func)
+#endif
/* INPUT functions */
diff --git a/include/tee/optee.h b/include/tee/optee.h
index 5412bc7386e..77729450bb6 100644
--- a/include/tee/optee.h
+++ b/include/tee/optee.h
@@ -30,7 +30,7 @@ struct optee_header {
};
static inline uint32_t
-optee_image_get_entry_point(const struct image_header *hdr)
+optee_image_get_entry_point(const struct legacy_img_hdr *hdr)
{
struct optee_header *optee_hdr = (struct optee_header *)(hdr + 1);
@@ -38,7 +38,7 @@ optee_image_get_entry_point(const struct image_header *hdr)
}
static inline uint32_t
-optee_image_get_load_addr(const struct image_header *hdr)
+optee_image_get_load_addr(const struct legacy_img_hdr *hdr)
{
return optee_image_get_entry_point(hdr) - sizeof(struct optee_header);
}
diff --git a/include/tee/optee_service.h b/include/tee/optee_service.h
new file mode 100644
index 00000000000..fca468af7c4
--- /dev/null
+++ b/include/tee/optee_service.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*
+ * (C) Copyright 2022 Linaro Limited
+ */
+
+#ifndef _OPTEE_SERVICE_H
+#define _OPTEE_SERVICE_H
+
+/*
+ * struct optee_service - Discoverable OP-TEE service
+ *
+ * @driver_name - Name of the related driver
+ * @uuid - UUID of the OP-TEE service related to the driver
+ *
+ * Use macro OPTEE_SERVICE_DRIVER() to register a driver related to an
+ * OP-TEE service discovered when driver asks OP-TEE services enumaration.
+ */
+struct optee_service {
+ const char *driver_name;
+ const struct tee_optee_ta_uuid uuid;
+};
+
+#ifdef CONFIG_OPTEE_SERVICE_DISCOVERY
+#define OPTEE_SERVICE_DRIVER(__name, __uuid, __drv_name) \
+ ll_entry_declare(struct optee_service, __name, optee_service) = { \
+ .uuid = __uuid, \
+ .driver_name = __drv_name, \
+ }
+#else
+#define OPTEE_SERVICE_DRIVER(__name, __uuid, __drv_name) \
+ static int __name##__COUNTER__ __always_unused
+#endif
+
+#endif /* _OPTEE_SERVICE_H */
diff --git a/include/test/test.h b/include/test/test.h
index c888d68b1ed..3bbd77c38b5 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -20,6 +20,13 @@
* @testdev: Test device
* @force_fail_alloc: Force all memory allocs to fail
* @skip_post_probe: Skip uclass post-probe processing
+ * @fdt_chksum: crc8 of the device tree contents
+ * @fdt_copy: Copy of the device tree
+ * @fdt_size: Size of the device-tree copy
+ * @other_fdt: Buffer for the other FDT (UT_TESTF_OTHER_FDT)
+ * @other_fdt_size: Size of the other FDT (UT_TESTF_OTHER_FDT)
+ * @of_other: Live tree for the other FDT
+ * @runs_per_test: Number of times to run each test (typically 1)
* @expect_str: Temporary string used to hold expected string value
* @actual_str: Temporary string used to hold actual string value
*/
@@ -32,6 +39,13 @@ struct unit_test_state {
struct udevice *testdev;
int force_fail_alloc;
int skip_post_probe;
+ uint fdt_chksum;
+ void *fdt_copy;
+ uint fdt_size;
+ void *other_fdt;
+ int other_fdt_size;
+ struct device_node *of_other;
+ int runs_per_test;
char expect_str[512];
char actual_str[512];
};
@@ -46,8 +60,7 @@ enum {
UT_TESTF_CONSOLE_REC = BIT(5), /* needs console recording */
/* do extra driver model init and uninit */
UT_TESTF_DM = BIT(6),
- /* live or flat device tree, but not both in the same executable */
- UT_TESTF_LIVE_OR_FLAT = BIT(4),
+ UT_TESTF_OTHER_FDT = BIT(7), /* read in other device tree */
};
/**
@@ -126,13 +139,24 @@ enum {
*/
struct udevice *testbus_get_clear_removed(void);
-static inline void arch_reset_for_test(void)
-{
#ifdef CONFIG_SANDBOX
#include <asm/state.h>
+#include <asm/test.h>
+#endif
+static inline void arch_reset_for_test(void)
+{
+#ifdef CONFIG_SANDBOX
state_reset_for_test(state_get_current());
#endif
}
+static inline int test_load_other_fdt(struct unit_test_state *uts)
+{
+ int ret = 0;
+#ifdef CONFIG_SANDBOX
+ ret = sandbox_load_other_fdt(&uts->other_fdt, &uts->other_fdt_size);
+#endif
+ return ret;
+}
#endif /* __TEST_TEST_H */
diff --git a/include/test/ut.h b/include/test/ut.h
index 18740f5807c..f7217aa8ac5 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -119,6 +119,11 @@ int ut_check_console_end(struct unit_test_state *uts);
*/
int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
+/* Report a failure, with printf() string */
+#define ut_reportf(fmt, args...) \
+ ut_failf(uts, __FILE__, __LINE__, __func__, "report", \
+ fmt, ##args)
+
/* Assert that a condition is non-zero */
#define ut_assert(cond) \
if (!(cond)) { \
@@ -403,9 +408,10 @@ void test_set_state(struct unit_test_state *uts);
* @count: Number of tests to run
* @select_name: Name of a single test to run (from the list provided). If NULL
* then all tests are run
+ * @runs_per_test: Number of times to run each test (typically 1)
* Return: 0 if all tests passed, -1 if any failed
*/
int ut_run_list(const char *name, const char *prefix, struct unit_test *tests,
- int count, const char *select_name);
+ int count, const char *select_name, int runs_per_test);
#endif
diff --git a/include/time.h b/include/time.h
index 9deb2cf61cc..3b2ba091247 100644
--- a/include/time.h
+++ b/include/time.h
@@ -83,6 +83,25 @@ uint64_t usec_to_tick(unsigned long usec);
(time_after_eq(a,b) && \
time_before(a,c))
+/* Same as above, but does so with platform independent 64bit types.
+ * These must be used when utilizing jiffies_64 (i.e. return value of
+ * get_jiffies_64() */
+#define time_after64(a,b) \
+ (typecheck(__u64, a) && \
+ typecheck(__u64, b) && \
+ ((__s64)((b) - (a)) < 0))
+#define time_before64(a,b) time_after64(b,a)
+
+#define time_after_eq64(a,b) \
+ (typecheck(__u64, a) && \
+ typecheck(__u64, b) && \
+ ((__s64)((a) - (b)) >= 0))
+#define time_before_eq64(a,b) time_after_eq64(b,a)
+
+#define time_in_range64(a, b, c) \
+ (time_after_eq64(a, b) && \
+ time_before_eq64(a, c))
+
/**
* usec2ticks() - Convert microseconds to internal ticks
*
diff --git a/include/wait_bit.h b/include/wait_bit.h
index dcc5c4fd396..f1d70aef873 100644
--- a/include/wait_bit.h
+++ b/include/wait_bit.h
@@ -63,7 +63,7 @@ static inline int wait_for_bit_##sfx(const void *reg, \
} \
\
udelay(1); \
- WATCHDOG_RESET(); \
+ schedule(); \
} \
\
debug("%s: Timeout (reg=%p mask=%x wait_set=%i)\n", __func__, \
diff --git a/include/watchdog.h b/include/watchdog.h
index 813cc8f2a5d..ac5f11e376f 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -10,7 +10,8 @@
#ifndef _WATCHDOG_H_
#define _WATCHDOG_H_
-#if !defined(__ASSEMBLY__)
+#include <cyclic.h>
+
/*
* Reset the watchdog timer, always returns 0
*
@@ -18,7 +19,6 @@
* and the legacy arch/<arch>/board.c code.
*/
int init_func_watchdog_reset(void);
-#endif
#if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
#define INIT_FUNC_WATCHDOG_INIT init_func_watchdog_init,
@@ -33,61 +33,14 @@ int init_func_watchdog_reset(void);
#endif
/*
- * Hardware watchdog
- */
-#ifdef CONFIG_HW_WATCHDOG
- #if defined(__ASSEMBLY__)
- #define WATCHDOG_RESET bl hw_watchdog_reset
- #else
- extern void hw_watchdog_reset(void);
-
- #define WATCHDOG_RESET hw_watchdog_reset
- #endif /* __ASSEMBLY__ */
-#else
- /*
- * Maybe a software watchdog?
- */
- #if defined(CONFIG_WATCHDOG)
- #if defined(__ASSEMBLY__)
- /* Don't require the watchdog to be enabled in SPL */
- #if defined(CONFIG_SPL_BUILD) && \
- !defined(CONFIG_SPL_WATCHDOG)
- #define WATCHDOG_RESET /*XXX DO_NOT_DEL_THIS_COMMENT*/
- #else
- #define WATCHDOG_RESET bl watchdog_reset
- #endif
- #else
- /* Don't require the watchdog to be enabled in SPL */
- #if defined(CONFIG_SPL_BUILD) && \
- !defined(CONFIG_SPL_WATCHDOG)
- #define WATCHDOG_RESET() {}
- #else
- extern void watchdog_reset(void);
-
- #define WATCHDOG_RESET watchdog_reset
- #endif
- #endif
- #else
- /*
- * No hardware or software watchdog.
- */
- #if defined(__ASSEMBLY__)
- #define WATCHDOG_RESET /*XXX DO_NOT_DEL_THIS_COMMENT*/
- #else
- #define WATCHDOG_RESET() {}
- #endif /* __ASSEMBLY__ */
- #endif /* CONFIG_WATCHDOG && !__ASSEMBLY__ */
-#endif /* CONFIG_HW_WATCHDOG */
-
-/*
* Prototypes from $(CPU)/cpu.c.
*/
-#if (defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)) && !defined(__ASSEMBLY__)
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
void hw_watchdog_init(void);
#endif
-#if defined(CONFIG_MPC85xx) && !defined(__ASSEMBLY__)
+#if defined(CONFIG_MPC85xx)
void init_85xx_watchdog(void);
#endif
#endif /* _WATCHDOG_H_ */