aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTom Rini2021-04-05 11:29:57 -0400
committerTom Rini2021-04-05 11:29:57 -0400
commit90eba245a66aa20589404ba537215faf2012c1a3 (patch)
treec581cd1f00dd162aeac4262bb4e74c2a9fea98c9 /include
parentb46dd116ce03e235f2a7d4843c6278e1da44b5e1 (diff)
parentdb8b46120aed6554d1ff405260ea6d2cc2439fcc (diff)
Merge branch 'next'
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/global_data.h32
-rw-r--r--include/asm-generic/gpio.h142
-rw-r--r--include/asm-generic/sections.h3
-rw-r--r--include/cbfs.h77
-rw-r--r--include/command.h10
-rw-r--r--include/configs/chromebook_coral.h6
-rw-r--r--include/configs/hihope-rzg2.h20
-rw-r--r--include/configs/mt8183.h41
-rw-r--r--include/configs/mt8516.h (renamed from include/configs/pumpkin.h)24
-rw-r--r--include/configs/silinux-ek874.h20
-rw-r--r--include/configs/sunxi-common.h23
-rw-r--r--include/cpu_func.h4
-rw-r--r--include/dm/device-internal.h93
-rw-r--r--include/dm/device.h108
-rw-r--r--include/dm/of_extra.h8
-rw-r--r--include/dm/platdata.h15
-rw-r--r--include/dm/root.h3
-rw-r--r--include/dm/test.h25
-rw-r--r--include/dm/uclass-internal.h52
-rw-r--r--include/dm/uclass.h31
-rw-r--r--include/dm/util.h9
-rw-r--r--include/dt-bindings/display/tda998x.h8
-rw-r--r--include/dt-bindings/dma/xlnx-zynqmp-dpdma.h16
-rw-r--r--include/dt-structs.h2
-rw-r--r--include/efi_api.h21
-rw-r--r--include/efi_loader.h36
-rw-r--r--include/efi_selftest.h7
-rw-r--r--include/i2c.h15
-rw-r--r--include/image.h5
-rw-r--r--include/linker_lists.h12
-rw-r--r--include/linux/clk-provider.h5
-rw-r--r--include/log.h36
-rw-r--r--include/malloc.h3
-rw-r--r--include/os.h18
-rw-r--r--include/sandboxblockdev.h9
-rw-r--r--include/scp03.h21
-rw-r--r--include/smbios.h20
-rw-r--r--include/spi_flash.h31
-rw-r--r--include/spl.h9
-rw-r--r--include/sysinfo.h4
-rw-r--r--include/sysreset.h2
-rw-r--r--include/tee/optee_ta_scp03.h21
-rw-r--r--include/test/test.h38
-rw-r--r--include/test/ut.h45
-rw-r--r--include/tpm-common.h3
-rw-r--r--include/tpm-v1.h76
-rw-r--r--include/tpm-v2.h81
-rw-r--r--include/tpm_api.h322
48 files changed, 1419 insertions, 193 deletions
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index b6a9991fc9a..e1a5f4b1d18 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -215,10 +215,20 @@ struct global_data {
* @uclass_root_s.
*/
struct list_head *uclass_root;
-# if CONFIG_IS_ENABLED(OF_PLATDATA)
+# if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
/** @dm_driver_rt: Dynamic info about the driver */
struct driver_rt *dm_driver_rt;
# endif
+#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+ /** @dm_udevice_rt: Dynamic info about the udevice */
+ struct udevice_rt *dm_udevice_rt;
+ /**
+ * @dm_priv_base: Base address of the priv/plat region used when
+ * udevices and uclasses are in read-only memory. This is NULL if not
+ * used
+ */
+ void *dm_priv_base;
+# endif
#endif
#ifdef CONFIG_TIMER
/**
@@ -410,6 +420,12 @@ struct global_data {
* This value is used as logging level for continuation messages.
*/
int logl_prev;
+ /**
+ * @log_cont: Previous log line did not finished wtih \n
+ *
+ * This allows for chained log messages on the same line
+ */
+ bool log_cont;
#endif
#if CONFIG_IS_ENABLED(BLOBLIST)
/**
@@ -477,7 +493,7 @@ struct global_data {
#define gd_set_of_root(_root)
#endif
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
+#if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
#define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
#define gd_dm_driver_rt() gd->dm_driver_rt
#else
@@ -485,6 +501,18 @@ struct global_data {
#define gd_dm_driver_rt() NULL
#endif
+#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+#define gd_set_dm_udevice_rt(dyn) gd->dm_udevice_rt = dyn
+#define gd_dm_udevice_rt() gd->dm_udevice_rt
+#define gd_set_dm_priv_base(dyn) gd->dm_priv_base = dyn
+#define gd_dm_priv_base() gd->dm_priv_base
+#else
+#define gd_set_dm_udevice_rt(dyn)
+#define gd_dm_udevice_rt() NULL
+#define gd_set_dm_priv_base(dyn)
+#define gd_dm_priv_base() NULL
+#endif
+
#ifdef CONFIG_GENERATE_ACPI_TABLE
#define gd_acpi_ctx() gd->acpi_ctx
#else
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 82294cbdc57..2cb0500aec5 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -128,6 +128,12 @@ struct gpio_desc {
#define GPIOD_PULL_UP BIT(7) /* GPIO has pull-up enabled */
#define GPIOD_PULL_DOWN BIT(8) /* GPIO has pull-down enabled */
+/* Flags for updating the above */
+#define GPIOD_MASK_DIR (GPIOD_IS_OUT | GPIOD_IS_IN | \
+ GPIOD_IS_OUT_ACTIVE)
+#define GPIOD_MASK_DSTYPE (GPIOD_OPEN_DRAIN | GPIOD_OPEN_SOURCE)
+#define GPIOD_MASK_PULL (GPIOD_PULL_UP | GPIOD_PULL_DOWN)
+
uint offset; /* GPIO offset within the device */
/*
* We could consider adding the GPIO label in here. Possibly we could
@@ -135,12 +141,6 @@ struct gpio_desc {
*/
};
-/* helper to compute the value of the gpio output */
-#define GPIOD_FLAGS_OUTPUT_MASK (GPIOD_ACTIVE_LOW | GPIOD_IS_OUT_ACTIVE)
-#define GPIOD_FLAGS_OUTPUT(flags) \
- (((((flags) & GPIOD_FLAGS_OUTPUT_MASK) == GPIOD_IS_OUT_ACTIVE) || \
- (((flags) & GPIOD_FLAGS_OUTPUT_MASK) == GPIOD_ACTIVE_LOW)))
-
/**
* dm_gpio_is_valid() - Check if a GPIO is valid
*
@@ -260,10 +260,32 @@ int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc,
struct dm_gpio_ops {
int (*request)(struct udevice *dev, unsigned offset, const char *label);
int (*rfree)(struct udevice *dev, unsigned int offset);
+
+ /**
+ * direction_input() - deprecated
+ *
+ * Equivalent to set_flags(...GPIOD_IS_IN)
+ */
int (*direction_input)(struct udevice *dev, unsigned offset);
+
+ /**
+ * direction_output() - deprecated
+ *
+ * Equivalent to set_flags(...GPIOD_IS_OUT) with GPIOD_IS_OUT_ACTIVE
+ * also set if @value
+ */
int (*direction_output)(struct udevice *dev, unsigned offset,
int value);
+
int (*get_value)(struct udevice *dev, unsigned offset);
+
+ /**
+ * set_value() - Sets the GPIO value of an output
+ *
+ * If the driver provides an @set_flags() method then that is used
+ * in preference to this, with GPIOD_IS_OUT_ACTIVE set according to
+ * @value.
+ */
int (*set_value)(struct udevice *dev, unsigned offset, int value);
/**
* get_function() Get the GPIO function
@@ -301,35 +323,54 @@ struct dm_gpio_ops {
struct ofnode_phandle_args *args);
/**
- * set_dir_flags() - Set GPIO dir flags
+ * set_flags() - Adjust GPIO flags
*
* This function should set up the GPIO configuration according to the
- * information provide by the direction flags bitfield.
+ * information provided by @flags.
*
- * This method is optional.
+ * If any flags cannot be set (e.g. the driver or hardware does not
+ * support them or this particular GPIO does not have the requested
+ * feature), the driver should return -EINVAL.
+ *
+ * The uclass checks that flags do not obviously conflict (e.g. input
+ * and output). If the driver finds other conflicts it should return
+ * -ERECALLCONFLICT
+ *
+ * Note that GPIOD_ACTIVE_LOW should be ignored, since the uclass
+ * adjusts for it automatically. For example, for an output GPIO,
+ * GPIOD_ACTIVE_LOW causes GPIOD_IS_OUT_ACTIVE to be inverted by the
+ * uclass, so the driver always sees the value that should be set at the
+ * pin (1=high, 0=low).
+ *
+ * This method is required and should be implemented by new drivers. At
+ * some point, it will supersede direction_input() and
+ * direction_output(), which wil be removed.
*
* @dev: GPIO device
* @offset: GPIO offset within that device
- * @flags: GPIO configuration to use
- * @return 0 if OK, -ve on error
+ * @flags: New flags value (GPIOD_...)
+ *
+ * @return 0 if OK, -EINVAL if unsupported, -ERECALLCONFLICT if flags
+ * conflict in some * non-obvious way and were not applied,
+ * other -ve on error
*/
- int (*set_dir_flags)(struct udevice *dev, unsigned int offset,
- ulong flags);
+ int (*set_flags)(struct udevice *dev, unsigned int offset, ulong flags);
/**
- * get_dir_flags() - Get GPIO dir flags
+ * get_flags() - Get GPIO flags
*
- * This function return the GPIO direction flags used.
+ * This function return the GPIO flags used. It should read this from
+ * the hardware directly.
*
* This method is optional.
*
* @dev: GPIO device
* @offset: GPIO offset within that device
- * @flags: place to put the used direction flags by GPIO
+ * @flagsp: place to put the current flags value
* @return 0 if OK, -ve on error
*/
- int (*get_dir_flags)(struct udevice *dev, unsigned int offset,
- ulong *flags);
+ int (*get_flags)(struct udevice *dev, unsigned int offset,
+ ulong *flagsp);
#if CONFIG_IS_ENABLED(ACPIGEN)
/**
@@ -457,6 +498,31 @@ int gpio_get_values_as_int(const int *gpio_list);
int dm_gpio_get_values_as_int(const struct gpio_desc *desc_list, int count);
/**
+ * dm_gpio_get_values_as_int_base3() - Create a base-3 int from a list of GPIOs
+ *
+ * This uses pull-ups/pull-downs to figure out whether a GPIO line is externally
+ * pulled down, pulled up or floating. This allows three different strap values
+ * for each pin:
+ * 0 : external pull-down
+ * 1 : external pull-up
+ * 2 : floating
+ *
+ * With this it is possible to obtain more combinations from the same number of
+ * strapping pins, when compared to dm_gpio_get_values_as_int(). The external
+ * pull resistors should be made stronger that the internal SoC pull resistors,
+ * for this to work.
+ *
+ * With 2 pins, 6 combinations are possible, compared with 4
+ * With 3 pins, 27 are possible, compared with 8
+ *
+ * @desc_list: List of GPIOs to collect
+ * @count: Number of GPIOs
+ * @return resulting integer value, or -ve on error
+ */
+int dm_gpio_get_values_as_int_base3(struct gpio_desc *desc_list,
+ int count);
+
+/**
* gpio_claim_vector() - claim a number of GPIOs for input
*
* @gpio_num_array: array of gpios to claim, terminated by -1
@@ -652,6 +718,25 @@ int dm_gpio_set_value(const struct gpio_desc *desc, int value);
int dm_gpio_set_dir(struct gpio_desc *desc);
/**
+ * dm_gpio_clrset_flags() - Update flags
+ *
+ * This updates the flags as directled. Note that desc->flags is updated by this
+ * function on success. If any changes cannot be made, best efforts are made.
+ *
+ * By use of @clr and @set any of flags can be individually updated, or left
+ * alone
+ *
+ * @desc: GPIO description containing device, offset and flags,
+ * previously returned by gpio_request_by_name()
+ * @clr: Flags to clear (GPIOD_...)
+ * @set: Flags to set (GPIOD_...)
+ * @return 0 if OK, -EINVAL if the flags had obvious conflicts,
+ * -ERECALLCONFLICT if there was a non-obvious hardware conflict when attempting
+ * to set the flags
+ */
+int dm_gpio_clrset_flags(struct gpio_desc *desc, ulong clr, ulong set);
+
+/**
* dm_gpio_set_dir_flags() - Set direction using description and added flags
*
* This sets up the direction according to the provided flags and the GPIO
@@ -666,16 +751,31 @@ int dm_gpio_set_dir(struct gpio_desc *desc);
int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags);
/**
- * dm_gpio_get_dir_flags() - Get direction flags
+ * dm_gpios_clrset_flags() - Sets flags for a set of GPIOs
+ *
+ * This clears and sets flags individually for each GPIO.
+ *
+ * @desc: List of GPIOs to update
+ * @count: Number of GPIOs in the list
+ * @clr: Flags to clear (GPIOD_...), e.g. GPIOD_MASK_DIR if you are
+ * changing the direction
+ * @set: Flags to set (GPIOD_...)
+ * @return 0 if OK, -ve on error
+ */
+int dm_gpios_clrset_flags(struct gpio_desc *desc, int count, ulong clr,
+ ulong set);
+
+/**
+ * dm_gpio_get_flags() - Get flags
*
- * read the current direction flags
+ * Read the current flags
*
* @desc: GPIO description containing device, offset and flags,
* previously returned by gpio_request_by_name()
* @flags: place to put the used flags
* @return 0 if OK, -ve on error, in which case desc->flags is not updated
*/
-int dm_gpio_get_dir_flags(struct gpio_desc *desc, ulong *flags);
+int dm_gpio_get_flags(struct gpio_desc *desc, ulong *flags);
/**
* gpio_get_number() - Get the global GPIO number of a GPIO
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 0577238d60b..267f1db73f2 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -28,6 +28,9 @@ extern char __efi_helloworld_end[];
extern char __efi_var_file_begin[];
extern char __efi_var_file_end[];
+/* Private data used by of-platdata devices/uclasses */
+extern char __priv_data_start[], __priv_data_end[];
+
/* Start and end of .ctors section - used for constructor calls. */
extern char __ctors_start[], __ctors_end[];
diff --git a/include/cbfs.h b/include/cbfs.h
index 5f296d6a371..ae94f1dcdf5 100644
--- a/include/cbfs.h
+++ b/include/cbfs.h
@@ -9,6 +9,8 @@
#include <compiler.h>
#include <linux/compiler.h>
+struct cbfs_priv;
+
enum cbfs_result {
CBFS_SUCCESS = 0,
CBFS_NOT_INITIALIZED,
@@ -42,6 +44,8 @@ enum cbfs_filetype {
enum {
CBFS_HEADER_MAGIC = 0x4f524243,
+ CBFS_SIZE_UNKNOWN = 0xffffffff,
+ CBFS_ALIGN_SIZE = 0x40,
};
/**
@@ -68,6 +72,52 @@ struct cbfs_fileheader {
/* offset to struct cbfs_file_attribute or 0 */
u32 attributes_offset;
u32 offset;
+ char filename[];
+} __packed;
+
+/**
+ * These are standard values for the known compression alogrithms that coreboot
+ * knows about for stages and payloads. Of course, other CBFS users can use
+ * whatever values they want, as long as they understand them.
+ */
+#define CBFS_COMPRESS_NONE 0
+#define CBFS_COMPRESS_LZMA 1
+#define CBFS_COMPRESS_LZ4 2
+
+/*
+ * Depending on how the header was initialized, it may be backed with 0x00 or
+ * 0xff, so support both
+ */
+#define CBFS_FILE_ATTR_TAG_UNUSED 0
+#define CBFS_FILE_ATTR_TAG_UNUSED2 0xffffffff
+#define CBFS_FILE_ATTR_TAG_COMPRESSION 0x42435a4c
+#define CBFS_FILE_ATTR_TAG_HASH 0x68736148
+
+/*
+ * The common fields of extended cbfs file attributes. Attributes are expected
+ * to start with tag/len, then append their specific fields
+ */
+struct cbfs_file_attribute {
+ u32 tag;
+ /* len covers the whole structure, incl. tag and len */
+ u32 len;
+ u8 data[0];
+} __packed;
+
+struct cbfs_file_attr_compression {
+ u32 tag;
+ u32 len;
+ /* whole file compression format. 0 if no compression. */
+ u32 compression;
+ u32 decompressed_size;
+} __packed;
+
+struct cbfs_file_attr_hash {
+ u32 tag;
+ u32 len;
+ u32 hash_type;
+ /* hash_data is len - sizeof(struct) bytes */
+ u8 hash_data[];
} __packed;
struct cbfs_cachenode {
@@ -77,7 +127,9 @@ struct cbfs_cachenode {
u32 type;
u32 data_length;
u32 name_length;
- u32 attributes_offset;
+ u32 attr_offset;
+ u32 comp_algo;
+ u32 decomp_size;
};
/**
@@ -111,6 +163,21 @@ int file_cbfs_init(ulong end_of_rom);
const struct cbfs_header *file_cbfs_get_header(void);
/**
+ * cbfs_get_first() - Get the first file in a CBFS
+ *
+ * @return pointer to first file, or NULL if it is empty
+ */
+const struct cbfs_cachenode *cbfs_get_first(const struct cbfs_priv *priv);
+
+/**
+ * cbfs_get_next() - Get the next file in a CBFS
+ *
+ * @filep: Pointer to current file; updated to point to the next file, if any,
+ * else NULL
+ */
+void cbfs_get_next(const struct cbfs_cachenode **filep);
+
+/**
* file_cbfs_get_first() - Get a handle for the first file in CBFS.
*
* @return A handle for the first file in CBFS, NULL on error.
@@ -133,8 +200,6 @@ void file_cbfs_get_next(const struct cbfs_cachenode **file);
*/
const struct cbfs_cachenode *file_cbfs_find(const char *name);
-struct cbfs_priv;
-
/**
* cbfs_find_file() - Find a file in a given CBFS
*
@@ -149,11 +214,13 @@ const struct cbfs_cachenode *cbfs_find_file(struct cbfs_priv *cbfs,
* cbfs_init_mem() - Set up a new CBFS
*
* @base: Base address of CBFS
+ * @size: Size of CBFS if known, else CBFS_SIZE_UNKNOWN
+ * @require_header: true to read a header at the start, false to not require one
* @cbfsp: Returns a pointer to CBFS on success
* @return 0 if OK, -ve on error
*/
-int cbfs_init_mem(ulong base, struct cbfs_priv **privp);
-
+int cbfs_init_mem(ulong base, ulong size, bool require_hdr,
+ struct cbfs_priv **privp);
/***************************************************************************/
/* All of the functions below can be used without first initializing CBFS. */
diff --git a/include/command.h b/include/command.h
index 747f8f80958..137cfbc3231 100644
--- a/include/command.h
+++ b/include/command.h
@@ -389,6 +389,14 @@ int run_command_list(const char *cmd, int len, int flag);
return 0; \
}
+#define _CMD_REMOVE_REP(_name, _cmd) \
+ int __remove_ ## _name(void) \
+ { \
+ if (0) \
+ _cmd(NULL, 0, 0, NULL, NULL); \
+ return 0; \
+ }
+
#define U_BOOT_CMDREP_MKENT_COMPLETE(_name, _maxargs, _cmd_rep, \
_usage, _help, _comp) \
{ #_name, _maxargs, 0 ? _cmd_rep : NULL, NULL, _usage, \
@@ -405,7 +413,7 @@ int run_command_list(const char *cmd, int len, int flag);
#define U_BOOT_CMDREP_COMPLETE(_name, _maxargs, _cmd_rep, _usage, \
_help, _comp) \
- _CMD_REMOVE(sub_ ## _name, _cmd_rep)
+ _CMD_REMOVE_REP(sub_ ## _name, _cmd_rep)
#endif /* CONFIG_CMDLINE */
diff --git a/include/configs/chromebook_coral.h b/include/configs/chromebook_coral.h
index 6e8e8ec1709..00760b8a307 100644
--- a/include/configs/chromebook_coral.h
+++ b/include/configs/chromebook_coral.h
@@ -12,13 +12,13 @@
#define CONFIG_BOOTCOMMAND \
"tpm init; tpm startup TPM2_SU_CLEAR; " \
- "read mmc 2:2 100000 0 80; setexpr loader *001004f0; " \
+ "read mmc 0:2 100000 0 80; setexpr loader *001004f0; " \
"setexpr size *00100518; setexpr blocks $size / 200; " \
- "read mmc 2:2 100000 80 $blocks; setexpr setup $loader - 1000; " \
+ "read mmc 0:2 100000 80 $blocks; setexpr setup $loader - 1000; " \
"setexpr cmdline_ptr $loader - 2000; " \
"setexpr.s cmdline *$cmdline_ptr; " \
"setexpr cmdline gsub %U \\\\${uuid}; " \
- "if part uuid mmc 2:2 uuid; then " \
+ "if part uuid mmc 0:2 uuid; then " \
"zboot start 100000 0 0 0 $setup cmdline; " \
"zboot load; zboot setup; zboot dump; zboot go;" \
"fi"
diff --git a/include/configs/hihope-rzg2.h b/include/configs/hihope-rzg2.h
new file mode 100644
index 00000000000..68a51176e38
--- /dev/null
+++ b/include/configs/hihope-rzg2.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * include/configs/hihope-rzg2.h
+ * This file is HOPERUN HiHope RZ/G2 board configuration.
+ *
+ * Copyright (C) 2020 Renesas Electronics Corporation
+ */
+
+#ifndef __HIHOPE_RZG2_H
+#define __HIHOPE_RZG2_H
+
+#include "rcar-gen3-common.h"
+
+/* Ethernet RAVB */
+#define CONFIG_BITBANGMII_MULTI
+
+/* Generic Timer Definitions (use in assembler source) */
+#define COUNTER_FREQUENCY 0xFE502A /* 16.66MHz from CPclk */
+
+#endif /* __HIHOPE_RZG2_H */
diff --git a/include/configs/mt8183.h b/include/configs/mt8183.h
new file mode 100644
index 00000000000..8e7afbb48a7
--- /dev/null
+++ b/include/configs/mt8183.h
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Configuration for MT8183 based boards
+ *
+ * Copyright (C) 2021 BayLibre, SAS
+ * Author: Fabien Parent <fparent@baylibre.com
+ */
+
+#ifndef __MT8183_H
+#define __MT8183_H
+
+#include <linux/sizes.h>
+
+#define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_MALLOC_LEN SZ_4M
+
+#define CONFIG_CPU_ARMV8
+#define COUNTER_FREQUENCY 13000000
+
+#define CONFIG_SYS_NS16550_SERIAL
+#define CONFIG_SYS_NS16550_REG_SIZE -4
+#define CONFIG_SYS_NS16550_MEM32
+#define CONFIG_SYS_NS16550_COM1 0x11005200
+#define CONFIG_SYS_NS16550_CLK 26000000
+
+#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_TEXT_BASE + SZ_2M - \
+ GENERATED_GBL_DATA_SIZE)
+
+#define CONFIG_SYS_BOOTM_LEN SZ_64M
+
+/* Environment settings */
+#include <config_distro_bootcmd.h>
+
+#define BOOT_TARGET_DEVICES(func) \
+ func(MMC, mmc, 0)
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ "scriptaddr=0x40000000\0" \
+ BOOTENV
+
+#endif
diff --git a/include/configs/pumpkin.h b/include/configs/mt8516.h
index 9c52cae41d7..a1c5d8174be 100644
--- a/include/configs/pumpkin.h
+++ b/include/configs/mt8516.h
@@ -6,8 +6,8 @@
* Author: Fabien Parent <fparent@baylibre.com
*/
-#ifndef __PUMPKIN_H
-#define __PUMPKIN_H
+#ifndef __MT8516_H
+#define __MT8516_H
#include <linux/sizes.h>
@@ -31,23 +31,11 @@
/* Environment settings */
#include <config_distro_bootcmd.h>
-#define MMCBOOT \
- "mmcdev=0\0" \
- "kernel_partition=2\0" \
- "rootfs_partition=3\0" \
- "mmc_discover_partition=" \
- "part start mmc ${mmcdev} ${kernel_partition} kernel_part_addr;" \
- "part size mmc ${mmcdev} ${kernel_partition} kernel_part_size;\0" \
- "mmcboot=" \
- "mmc dev ${mmcdev};" \
- "run mmc_discover_partition;" \
- "mmc read ${kerneladdr} ${kernel_part_addr} ${kernel_part_size};" \
- "setenv bootargs ${bootargs} root=/dev/mmcblk${mmcdev}p${rootfs_partition} rootwait; " \
- "bootm ${kerneladdr}; \0"
+#define BOOT_TARGET_DEVICES(func) \
+ func(MMC, mmc, 0)
#define CONFIG_EXTRA_ENV_SETTINGS \
- "kerneladdr=0x4A000000\0" \
- MMCBOOT \
- "bootcmd=run mmcboot;\0"
+ "scriptaddr=0x40000000\0" \
+ BOOTENV
#endif
diff --git a/include/configs/silinux-ek874.h b/include/configs/silinux-ek874.h
new file mode 100644
index 00000000000..25c0cd2335c
--- /dev/null
+++ b/include/configs/silinux-ek874.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * include/configs/silinux-ek874.h
+ * This file is Silicon Linux EK874 board configuration.
+ *
+ * Copyright (C) 2021 Renesas Electronics Corporation
+ */
+
+#ifndef __SILINUX_EK874_H
+#define __SILINUX_EK874_H
+
+#include "rcar-gen3-common.h"
+
+/* Ethernet RAVB */
+#define CONFIG_BITBANGMII_MULTI
+
+/* Generic Timer Definitions (use in assembler source) */
+#define COUNTER_FREQUENCY 0xFE502A /* 16.66MHz from CPclk */
+
+#endif /* __SILINUX_EK874_H */
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 7b602dd9ea4..33a4d7b6373 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -223,23 +223,6 @@ extern int soft_i2c_gpio_scl;
#define CONFIG_VIDEO_LCD_I2C_BUS -1 /* NA, but necessary to compile */
#endif
-#ifdef CONFIG_VIDEO_SUNXI
-/*
- * The amount of RAM to keep free at the top of RAM when relocating u-boot,
- * to use as framebuffer. This must be a multiple of 4096.
- */
-#define CONFIG_SUNXI_MAX_FB_SIZE (16 << 20)
-
-#define CONFIG_VIDEO_LOGO
-#define CONFIG_VIDEO_STD_TIMINGS
-#define CONFIG_I2C_EDID
-#define VIDEO_LINE_LEN (pGD->plnSizeX)
-
-/* allow both serial and cfb console. */
-/* stop x86 thinking in cfbconsole from trying to init a pc keyboard */
-
-#endif /* CONFIG_VIDEO_SUNXI */
-
/* Ethernet support */
#ifdef CONFIG_USB_EHCI_HCD
@@ -401,11 +384,7 @@ extern int soft_i2c_gpio_scl;
"stdin=serial\0"
#endif
-#ifdef CONFIG_VIDEO
-#define CONSOLE_STDOUT_SETTINGS \
- "stdout=serial,vga\0" \
- "stderr=serial,vga\0"
-#elif CONFIG_DM_VIDEO
+#ifdef CONFIG_DM_VIDEO
#define CONSOLE_STDOUT_SETTINGS \
"stdout=serial,vidconsole\0" \
"stderr=serial,vidconsole\0"
diff --git a/include/cpu_func.h b/include/cpu_func.h
index 8aa825daa47..c3a66f04059 100644
--- a/include/cpu_func.h
+++ b/include/cpu_func.h
@@ -84,6 +84,6 @@ enum {
*/
int cleanup_before_linux_select(int flags);
-void reset_cpu(ulong addr);
-;
+void reset_cpu(void);
+
#endif
diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index 39406c3f352..e6b71cbfd2b 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -10,11 +10,86 @@
#ifndef _DM_DEVICE_INTERNAL_H
#define _DM_DEVICE_INTERNAL_H
+#include <linker_lists.h>
#include <dm/ofnode.h>
struct device_node;
struct udevice;
+/*
+ * These two macros DM_DEVICE_INST and DM_DEVICE_REF are only allowed in code
+ * generated by dtoc, because the ordering is important and if other instances
+ * creep in then they may mess up the ordering expected by dtoc.
+ *
+ * It is OK to use them with 'extern' though, since that does not actually
+ * add a new record to the linker_list.
+ */
+
+/**
+ * DM_DEVICE_INST() - Declare a bound device ready for run-time use
+ *
+ * This adds an actual struct udevice to a list which is found by driver model
+ * on start-up.
+ *
+ * For example:
+ *
+ * extern U_BOOT_DRIVER(sandbox_fixed_clock);
+ * extern DM_UCLASS_INST(clk);
+ *
+ * DM_DEVICE_INST(clk_fixed) = {
+ * .driver = DM_DRIVER_REF(sandbox_fixed_clock),
+ * .name = "sandbox_fixed_clock",
+ * .plat_ = &_sandbox_fixed_clock_plat_clk_fixed,
+ * .uclass = DM_UCLASS_REF(clk),
+ * ...
+ * .seq_ = 0,
+ * };
+ *
+ * @_name: Name of the udevice. This must be a valid C identifier, used by the
+ * linker_list.
+ */
+#define DM_DEVICE_INST(_name) \
+ ll_entry_declare(struct udevice, _name, udevice)
+
+/**
+ * DM_DEVICE_REF() - Get a reference to a device
+ *
+ * This is useful in data structures and code for referencing a udevice at
+ * build time. Before this is used, an extern DM_DEVICE_INST() must have been
+ * declared.
+ *
+ * For example:
+ *
+ * extern DM_DEVICE_INST(clk_fixed);
+ *
+ * struct udevice *devs[] = {
+ * DM_DEVICE_REF(clk_fixed),
+ * };
+ *
+ * @_name: Name of the udevice. This must be a valid C identifier, used by the
+ * linker_list
+ * @returns struct udevice * for the device
+ */
+#define DM_DEVICE_REF(_name) \
+ ll_entry_ref(struct udevice, _name, udevice)
+
+/**
+ * DM_DEVICE_GET() - Get a pointer to a given device
+ *
+ * This is similar to DM_DEVICE_REF() except that it does not need the extern
+ * declaration before it. However it cannot be used in a data structures, only
+ * in code within a function.
+ *
+ * For example:
+ *
+ * void some_function() {
+ * struct udevice *dev = DM_DEVICE_GET(clk_fixed);
+ * ...
+ * }
+ */
+#define DM_DEVICE_GET(__name) \
+ ll_entry_get(struct udevice, __name, udevice)
+
/**
* device_bind() - Create a device and bind it to a driver
*
@@ -209,6 +284,9 @@ static inline int device_chld_remove(struct udevice *dev, struct driver *drv,
* Use this function to override normal operation for special situations, such
* as needing to allocate a variable amount of data.
*
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
* @dev Device to check
* @priv New private-data pointer
*/
@@ -223,6 +301,9 @@ void dev_set_priv(struct udevice *dev, void *priv);
* Use this function to override normal operation for special situations, such
* as needing to allocate a variable amount of data.
*
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
* @dev: Device to update
* @parent_priv: New parent-private data
*/
@@ -237,6 +318,9 @@ void dev_set_parent_priv(struct udevice *dev, void *parent_priv);
* Use this function to override normal operation for special situations, such
* as needing to allocate a variable amount of data.
*
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
* @dev: Device to update
* @uclass_priv: New uclass private data
*/
@@ -251,6 +335,9 @@ void dev_set_uclass_priv(struct udevice *dev, void *uclass_priv);
* Use this function to override normal operation for special situations, such
* as needing to allocate a variable amount of data.
*
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
* @dev Device to check
* @plat New platform-data pointer
*/
@@ -265,6 +352,9 @@ void dev_set_plat(struct udevice *dev, void *priv);
* Use this function to override normal operation for special situations, such
* as needing to allocate a variable amount of data.
*
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
* @dev: Device to update
* @parent_plat: New parent platform data
*/
@@ -279,6 +369,9 @@ void dev_set_parent_plat(struct udevice *dev, void *parent_plat);
* Use this function to override normal operation for special situations, such
* as needing to allocate a variable amount of data.
*
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
* @dev: Device to update
* @uclass_plat: New uclass platform data
*/
diff --git a/include/dm/device.h b/include/dm/device.h
index bb9faa0ed93..0a9718a5b81 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -177,7 +177,9 @@ struct udevice {
struct list_head uclass_node;
struct list_head child_head;
struct list_head sibling_node;
+#if !CONFIG_IS_ENABLED(OF_PLATDATA_RT)
u32 flags_;
+#endif
int seq_;
#if !CONFIG_IS_ENABLED(OF_PLATDATA)
ofnode node_;
@@ -190,12 +192,32 @@ struct udevice {
#endif
};
+/**
+ * udevice_rt - runtime information set up by U-Boot
+ *
+ * This is only used with OF_PLATDATA_RT
+ *
+ * There is one of these for every udevice in the linker list, indexed by
+ * the udevice_info idx value.
+ *
+ * @flags_: Flags for this device DM_FLAG_... (do not access outside driver
+ * model)
+ */
+struct udevice_rt {
+ u32 flags_;
+};
+
/* Maximum sequence number supported */
#define DM_MAX_SEQ 999
/* Returns the operations for a device */
#define device_get_ops(dev) (dev->driver->ops)
+#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+u32 dev_get_flags(const struct udevice *dev);
+void dev_or_flags(const struct udevice *dev, u32 or);
+void dev_bic_flags(const struct udevice *dev, u32 bic);
+#else
static inline u32 dev_get_flags(const struct udevice *dev)
{
return dev->flags_;
@@ -210,6 +232,7 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
{
dev->flags_ &= ~bic;
}
+#endif /* OF_PLATDATA_RT */
/**
* dev_ofnode() - get the DT node reference associated with a udevice
@@ -363,6 +386,28 @@ struct driver {
ll_entry_get(struct driver, __name, driver)
/**
+ * DM_DRIVER_REF() - Get a reference to a driver
+ *
+ * This is useful in data structures and code for referencing a driver at
+ * build time. Before this is used, an extern U_BOOT_DRIVER() must have been
+ * declared.
+ *
+ * For example:
+ *
+ * extern U_BOOT_DRIVER(sandbox_fixed_clock);
+ *
+ * struct driver *drvs[] = {
+ * DM_DRIVER_REF(sandbox_fixed_clock),
+ * };
+ *
+ * @_name: Name of the driver. This must be a valid C identifier, used by the
+ * linker_list
+ * @returns struct driver * for the driver
+ */
+#define DM_DRIVER_REF(_name) \
+ ll_entry_ref(struct driver, _name, driver)
+
+/**
* Declare a macro to state a alias for a driver name. This macro will
* produce no code but its information will be parsed by tools like
* dtoc
@@ -370,6 +415,40 @@ struct driver {
#define DM_DRIVER_ALIAS(__name, __alias)
/**
+ * Declare a macro to indicate which phase of U-Boot this driver is fore.
+ *
+ *
+ * This macro produces no code but its information will be parsed by dtoc. The
+ * macro can be only be used once in a driver. Put it within the U_BOOT_DRIVER()
+ * declaration, e.g.:
+ *
+ * U_BOOT_DRIVER(cpu) = {
+ * .name = ...
+ * ...
+ * DM_PHASE(tpl)
+ * };
+ */
+#define DM_PHASE(_phase)
+
+/**
+ * Declare a macro to declare a header needed for a driver. Often the correct
+ * header can be found automatically, but only for struct declarations. For
+ * enums and #defines used in the driver declaration and declared in a different
+ * header from the structs, this macro must be used.
+ *
+ * This macro produces no code but its information will be parsed by dtoc. The
+ * macro can be used multiple times with different headers, for the same driver.
+ * Put it within the U_BOOT_DRIVER() declaration, e.g.:
+ *
+ * U_BOOT_DRIVER(cpu) = {
+ * .name = ...
+ * ...
+ * DM_HEADER(<asm/cpu.h>)
+ * };
+ */
+#define DM_HEADER(_hdr)
+
+/**
* dev_get_plat() - Get the platform data for a device
*
* This checks that dev is not NULL, but no other checks for now
@@ -611,33 +690,24 @@ int device_find_global_by_ofnode(ofnode node, struct udevice **devp);
int device_get_global_by_ofnode(ofnode node, struct udevice **devp);
/**
- * device_get_by_driver_info() - Get a device based on driver_info
- *
- * Locates a device by its struct driver_info, by using its reference which
- * is updated during the bind process.
+ * device_get_by_ofplat_idx() - Get a device based on of-platdata index
*
- * The device is probed to activate it ready for use.
- *
- * @info: Struct driver_info
- * @devp: Returns pointer to device if found, otherwise this is set to NULL
- * @return 0 if OK, -ve on error
- */
-int device_get_by_driver_info(const struct driver_info *info,
- struct udevice **devp);
-
-/**
- * device_get_by_driver_info_idx() - Get a device based on driver_info index
+ * Locates a device by either its struct driver_info index, or its
+ * struct udevice index. The latter is used with OF_PLATDATA_INST, since we have
+ * a list of build-time instantiated struct udevice records, The former is used
+ * with !OF_PLATDATA_INST since in that case we have a list of
+ * struct driver_info records.
*
- * Locates a device by its struct driver_info, by using its index number which
- * is written into the idx field of struct phandle_1_arg, etc.
+ * The index number is written into the idx field of struct phandle_1_arg, etc.
+ * It is the position of this driver_info/udevice in its linker list.
*
* The device is probed to activate it ready for use.
*
- * @idx: Index number of the driver_info structure (0=first)
+ * @idx: Index number of the driver_info/udevice structure (0=first)
* @devp: Returns pointer to device if found, otherwise this is set to NULL
* @return 0 if OK, -ve on error
*/
-int device_get_by_driver_info_idx(uint idx, struct udevice **devp);
+int device_get_by_ofplat_idx(uint idx, struct udevice **devp);
/**
* device_find_first_child() - Find the first child of a device
diff --git a/include/dm/of_extra.h b/include/dm/of_extra.h
index ca15df21b06..fc4f9743196 100644
--- a/include/dm/of_extra.h
+++ b/include/dm/of_extra.h
@@ -11,7 +11,11 @@
enum fmap_compress_t {
FMAP_COMPRESS_NONE,
+ FMAP_COMPRESS_LZMA,
FMAP_COMPRESS_LZ4,
+
+ FMAP_COMPRESS_COUNT,
+ FMAP_COMPRESS_UNKNOWN,
};
enum fmap_hash_t {
@@ -30,6 +34,10 @@ struct fmap_entry {
enum fmap_hash_t hash_algo; /* Hash algorithm */
const uint8_t *hash; /* Hash value */
int hash_size; /* Hash size */
+ /* Node pointer if CBFS, else NULL */
+ const struct cbfs_cachenode *cbfs_node;
+ /* Hash node pointer if CBFS, else NULL */
+ const struct cbfs_cachenode *cbfs_hash_node;
};
/**
diff --git a/include/dm/platdata.h b/include/dm/platdata.h
index 3821a56f2ca..4efb1dfe12d 100644
--- a/include/dm/platdata.h
+++ b/include/dm/platdata.h
@@ -71,19 +71,4 @@ struct driver_rt {
#define U_BOOT_DRVINFOS(__name) \
ll_entry_declare_list(struct driver_info, __name, driver_info)
-/**
- * Get a pointer to a given device info given its name
- *
- * With the declaration U_BOOT_DRVINFO(name), DM_DRVINFO_GET(name) will return a
- * pointer to the struct driver_info created by that declaration.
- *
- * if OF_PLATDATA is enabled, from this it is possible to use the @dev member of
- * struct driver_info to find the device pointer itself.
- *
- * @__name: Driver name (C identifier, not a string. E.g. gpio7_at_ff7e0000)
- * @return struct driver_info * to the driver that created the device
- */
-#define DM_DRVINFO_GET(__name) \
- ll_entry_get(struct driver_info, __name, driver_info)
-
#endif
diff --git a/include/dm/root.h b/include/dm/root.h
index 89afbee6196..42510b106ab 100644
--- a/include/dm/root.h
+++ b/include/dm/root.h
@@ -11,6 +11,9 @@
struct udevice;
+/* Head of the uclass list if CONFIG_OF_PLATDATA_INST is enabled */
+extern struct list_head uclass_head;
+
/**
* dm_root() - Return pointer to the top of the driver tree
*
diff --git a/include/dm/test.h b/include/dm/test.h
index c5a9610ec7d..a9562b2bfc7 100644
--- a/include/dm/test.h
+++ b/include/dm/test.h
@@ -73,6 +73,11 @@ struct dm_test_priv {
int uclass_postp;
};
+/* struct dm_test_uc_priv - private data for the testdrv uclass */
+struct dm_test_uc_priv {
+ int dummy;
+};
+
/**
* struct dm_test_perdev_class_priv - private per-device data for test uclass
*/
@@ -127,25 +132,9 @@ extern int dm_testdrv_op_count[DM_TEST_OP_COUNT];
extern struct unit_test_state global_dm_test_state;
-/*
- * struct dm_test_state - Entire state of dm test system
- *
- * This is often abreviated to dms.
- *
- * @root: Root device
- * @testdev: Test device
- * @force_fail_alloc: Force all memory allocs to fail
- * @skip_post_probe: Skip uclass post-probe processing
- */
-struct dm_test_state {
- struct udevice *root;
- struct udevice *testdev;
- int force_fail_alloc;
- int skip_post_probe;
-};
-
/* Declare a new driver model test */
-#define DM_TEST(_name, _flags) UNIT_TEST(_name, _flags, dm_test)
+#define DM_TEST(_name, _flags) \
+ UNIT_TEST(_name, UT_TESTF_DM | UT_TESTF_CONSOLE_REC | (_flags), dm_test)
/*
* struct sandbox_sdl_plat - Platform data for the SDL video driver
diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h
index c5a464be7c4..57c664c6daa 100644
--- a/include/dm/uclass-internal.h
+++ b/include/dm/uclass-internal.h
@@ -11,6 +11,55 @@
#include <dm/ofnode.h>
+/*
+ * These next two macros DM_UCLASS_INST() and DM_UCLASS_REF() are only allowed
+ * in code generated by dtoc, because the ordering is important and if other
+ * instances creep in then they may mess up the ordering expected by dtoc.
+ *
+ * It is OK to use them with 'extern' though, since that does not actually
+ * add a new record to the linker_list.
+ */
+
+/**
+ * DM_UCLASS_INST() - Declare a uclass ready for run-time use
+ *
+ * This adds an actual struct uclass to a list which is found by driver model
+ * on start-up.
+ *
+ * For example:
+ *
+ * DM_UCLASS_INST(clk) = {
+ * .uc_drv = DM_UCLASS_DRIVER_REF(clk),
+ * ...
+ * };
+ *
+ * @_name: Name of the uclass. This must be a valid C identifier, used by the
+ * linker_list.
+ */
+#define DM_UCLASS_INST(_name) \
+ ll_entry_declare(struct uclass, _name, uclass)
+
+/**
+ * DM_UCLASS_REF() - Get a reference to a uclass
+ *
+ * This is useful for referencing a uclass at build time. Before this is used,
+ * an extern DM_UCLASS_INST() must have been declared.
+ *
+ * For example:
+ *
+ * extern DM_UCLASS_INST(clk);
+ *
+ * struct uclass *ucs[] = {
+ * DM_UCLASS_REF(clk),
+ * }
+ *
+ * @_name: Name of the uclass. This must be a valid C identifier, used by the
+ * linker_list
+ * @returns struct uclass * for the device
+ */
+#define DM_UCLASS_REF(_name) \
+ ll_entry_ref(struct uclass, _name, uclass)
+
/**
* uclass_set_priv() - Set the private data for a uclass
*
@@ -20,6 +69,9 @@
* Use this function to override normal operation for special situations, such
* as needing to allocate a variable amount of data.
*
+ * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
+ * model code, since the pointer must be within the gd->dm_priv_base region.
+ *
* @uc Uclass to update
* @priv New private-data pointer
*/
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index d95683740cb..6752d8ee0be 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -114,6 +114,37 @@ struct uclass_driver {
#define UCLASS_DRIVER(__name) \
ll_entry_declare(struct uclass_driver, __name, uclass_driver)
+/*
+ * These two macros DM_UCLASS_DRIVER_REF and DM_UCLASS_DRIVER_REF are only
+ * allowed in code generated by dtoc, because the ordering is important and if
+ * other instances creep in then they may mess up the ordering expected by dtoc.
+ *
+ * It is OK to use them with 'extern' though, since that does not actually
+ * add a new record to the linker_list.
+ */
+
+/**
+ * DM_UCLASS_DRIVER_REF() - Get a reference to a uclass driver
+ *
+ * This is useful in data structures and code for referencing a uclass_driver at
+ * build time. Before this is used, an extern UCLASS_DRIVER() must have been
+ * declared.
+ *
+ * For example:
+ *
+ * extern UCLASS_DRIVER(clk);
+ *
+ * struct uclass_driver *drvs[] = {
+ * DM_UCLASS_DRIVER_REF(clk),
+ * };
+ *
+ * @_name: Name of the uclass_driver. This must be a valid C identifier, used by
+ * the linker_list.
+ * @returns struct uclass_driver * for the uclass driver
+ */
+#define DM_UCLASS_DRIVER_REF(_name) \
+ ll_entry_ref(struct uclass_driver, _name, uclass_driver)
+
/**
* uclass_get_priv() - Get the private data for a uclass
*
diff --git a/include/dm/util.h b/include/dm/util.h
index 01a044992f2..138893c9354 100644
--- a/include/dm/util.h
+++ b/include/dm/util.h
@@ -49,3 +49,12 @@ void dm_dump_driver_compat(void);
void dm_dump_static_driver_info(void);
#endif
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA_INST) && CONFIG_IS_ENABLED(READ_ONLY)
+void *dm_priv_to_rw(void *priv);
+#else
+static inline void *dm_priv_to_rw(void *priv)
+{
+ return priv;
+}
+#endif
diff --git a/include/dt-bindings/display/tda998x.h b/include/dt-bindings/display/tda998x.h
new file mode 100644
index 00000000000..746831ff396
--- /dev/null
+++ b/include/dt-bindings/display/tda998x.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _DT_BINDINGS_TDA998X_H
+#define _DT_BINDINGS_TDA998X_H
+
+#define TDA998x_SPDIF 1
+#define TDA998x_I2S 2
+
+#endif /*_DT_BINDINGS_TDA998X_H */
diff --git a/include/dt-bindings/dma/xlnx-zynqmp-dpdma.h b/include/dt-bindings/dma/xlnx-zynqmp-dpdma.h
new file mode 100644
index 00000000000..3719cda5679
--- /dev/null
+++ b/include/dt-bindings/dma/xlnx-zynqmp-dpdma.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
+/*
+ * Copyright 2019 Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ */
+
+#ifndef __DT_BINDINGS_DMA_XLNX_ZYNQMP_DPDMA_H__
+#define __DT_BINDINGS_DMA_XLNX_ZYNQMP_DPDMA_H__
+
+#define ZYNQMP_DPDMA_VIDEO0 0
+#define ZYNQMP_DPDMA_VIDEO1 1
+#define ZYNQMP_DPDMA_VIDEO2 2
+#define ZYNQMP_DPDMA_GRAPHICS 3
+#define ZYNQMP_DPDMA_AUDIO0 4
+#define ZYNQMP_DPDMA_AUDIO1 5
+
+#endif /* __DT_BINDINGS_DMA_XLNX_ZYNQMP_DPDMA_H__ */
diff --git a/include/dt-structs.h b/include/dt-structs.h
index f0e1c9cb901..f9ccaf56a46 100644
--- a/include/dt-structs.h
+++ b/include/dt-structs.h
@@ -24,7 +24,9 @@ struct phandle_2_arg {
uint idx;
int arg[2];
};
+
#include <generated/dt-structs-gen.h>
+#include <generated/dt-decl.h>
#endif
#endif
diff --git a/include/efi_api.h b/include/efi_api.h
index 4ccde1d24da..18a1adf0239 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -1732,6 +1732,23 @@ struct efi_load_file_protocol {
void *buffer);
};
+struct efi_system_resource_entry {
+ efi_guid_t fw_class;
+ u32 fw_type;
+ u32 fw_version;
+ u32 lowest_supported_fw_version;
+ u32 capsule_flags;
+ u32 last_attempt_version;
+ u32 last_attempt_status;
+} __packed;
+
+struct efi_system_resource_table {
+ u32 fw_resource_count;
+ u32 fw_resource_count_max;
+ u64 fw_resource_version;
+ struct efi_system_resource_entry entries[];
+} __packed;
+
/* Boot manager load options */
#define LOAD_OPTION_ACTIVE 0x00000001
#define LOAD_OPTION_FORCE_RECONNECT 0x00000002
@@ -1750,6 +1767,10 @@ struct efi_load_file_protocol {
#define ESRT_FW_TYPE_DEVICEFIRMWARE 0x00000002
#define ESRT_FW_TYPE_UEFIDRIVER 0x00000003
+#define EFI_SYSTEM_RESOURCE_TABLE_GUID\
+ EFI_GUID(0xb122a263, 0x3661, 0x4f68,\
+ 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80)
+
/* Last Attempt Status Values */
#define LAST_ATTEMPT_STATUS_SUCCESS 0x00000000
#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL 0x00000001
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 68daa1a4a9d..de1a496a972 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -214,6 +214,8 @@ extern const efi_guid_t efi_guid_rng_protocol;
extern const efi_guid_t efi_guid_capsule_report;
/* GUID of firmware management protocol */
extern const efi_guid_t efi_guid_firmware_management_protocol;
+/* GUID for the ESRT */
+extern const efi_guid_t efi_esrt_guid;
extern unsigned int __efi_runtime_start, __efi_runtime_stop;
extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop;
@@ -437,6 +439,7 @@ efi_status_t efi_net_register(void);
/* Called by bootefi to make the watchdog available */
efi_status_t efi_watchdog_register(void);
efi_status_t efi_initrd_register(void);
+void efi_initrd_deregister(void);
/* Called by bootefi to make SMBIOS tables available */
/**
* efi_acpi_register() - write out ACPI tables
@@ -558,6 +561,15 @@ struct efi_simple_file_system_protocol *efi_simple_file_system(
/* open file from device-path: */
struct efi_file_handle *efi_file_from_path(struct efi_device_path *fp);
+/* Registers a callback function for a notification event. */
+efi_status_t EFIAPI efi_register_protocol_notify(const efi_guid_t *protocol,
+ struct efi_event *event,
+ void **registration);
+efi_status_t efi_file_size(struct efi_file_handle *fh, efi_uintn_t *size);
+
+/* get a device path from a Boot#### option */
+struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t guid);
+
/**
* efi_size_in_pages() - convert size in bytes to size in pages
*
@@ -723,6 +735,8 @@ efi_status_t EFIAPI efi_query_variable_info(
u64 *remaining_variable_storage_size,
u64 *maximum_variable_size);
+void *efi_get_var(u16 *name, const efi_guid_t *vendor, efi_uintn_t *size);
+
/*
* See section 3.1.3 in the v2.7 UEFI spec for more details on
* the layout of EFI_LOAD_OPTION. In short it is:
@@ -744,6 +758,10 @@ struct efi_load_option {
const u8 *optional_data;
};
+struct efi_device_path *efi_dp_from_lo(struct efi_load_option *lo,
+ efi_uintn_t *size, efi_guid_t guid);
+struct efi_device_path *efi_dp_concat(const struct efi_device_path *dp1,
+ const struct efi_device_path *dp2);
efi_status_t efi_deserialize_load_option(struct efi_load_option *lo, u8 *data,
efi_uintn_t *size);
unsigned long efi_serialize_load_option(struct efi_load_option *lo, u8 **data);
@@ -890,4 +908,22 @@ static inline efi_status_t efi_launch_capsules(void)
#endif /* CONFIG_IS_ENABLED(EFI_LOADER) */
+/**
+ * Install the ESRT system table.
+ *
+ * @return status code
+ */
+efi_status_t efi_esrt_register(void);
+
+/**
+ * efi_esrt_populate() - Populates the ESRT entries from the FMP instances
+ * present in the system.
+ * If an ESRT already exists, the old ESRT is replaced in the system table.
+ * The memory of the old ESRT is deallocated.
+ *
+ * Return:
+ * - EFI_SUCCESS if the ESRT is correctly created
+ * - error code otherwise.
+ */
+efi_status_t efi_esrt_populate(void);
#endif /* _EFI_LOADER_H */
diff --git a/include/efi_selftest.h b/include/efi_selftest.h
index 1515fdaa02b..07b619901c0 100644
--- a/include/efi_selftest.h
+++ b/include/efi_selftest.h
@@ -66,11 +66,10 @@ enum efi_test_phase {
*/
EFI_SETUP_BEFORE_BOOTTIME_EXIT,
/**
- * @EFI_SETUP_AFTER_BOOTTIME_EXIT: - setup after ExitBootServices
- *
- * Setup, execute, and teardown are executed after ExitBootServices().
+ * @EFI_SETTING_VIRTUAL_ADDRESS_MAP - calls SetVirtualAddressMap()
+ * Execute calls SetVirtualAddressMap().
*/
- EFI_SETUP_AFTER_BOOTTIME_EXIT,
+ EFI_SETTING_VIRTUAL_ADDRESS_MAP,
};
extern struct efi_simple_text_output_protocol *con_out;
diff --git a/include/i2c.h b/include/i2c.h
index 7ae0c42706e..c0fe94c1f33 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -93,6 +93,8 @@ struct udevice;
* datasheet explains it's usage of this addressing
* mode.
* @emul: Emulator for this chip address (only used for emulation)
+ * @emul_idx: Emulator index, used for of-platdata and set by each i2c chip's
+ * bind() method. This allows i2c_emul_find() to work with of-platdata.
*/
struct dm_i2c_chip {
uint chip_addr;
@@ -102,6 +104,7 @@ struct dm_i2c_chip {
#ifdef CONFIG_SANDBOX
struct udevice *emul;
bool test_mode;
+ int emul_idx;
#endif
};
@@ -555,6 +558,18 @@ void i2c_dump_msgs(struct i2c_msg *msg, int nmsgs);
int i2c_emul_find(struct udevice *dev, struct udevice **emulp);
/**
+ * i2c_emul_set_idx() - Set the emulator index for an i2c sandbox device
+ *
+ * With of-platdata we cannot find the emulator using the device tree, so rely
+ * on the bind() method of each i2c driver calling this function to tell us
+ * the of-platdata idx of the emulator
+ *
+ * @dev: i2c device to set the emulator for
+ * @emul_idx: of-platdata index for that emulator
+ */
+void i2c_emul_set_idx(struct udevice *dev, int emul_idx);
+
+/**
* i2c_emul_get_device() - Find the device being emulated
*
* Given an emulator this returns the associated device
diff --git a/include/image.h b/include/image.h
index b4b284d52b7..aeb0d37ac02 100644
--- a/include/image.h
+++ b/include/image.h
@@ -886,6 +886,11 @@ static inline int image_check_type(const image_header_t *hdr, uint8_t type)
}
static inline int image_check_arch(const image_header_t *hdr, uint8_t arch)
{
+#ifndef USE_HOSTCC
+ /* Let's assume that sandbox can load any architecture */
+ if (IS_ENABLED(CONFIG_SANDBOX))
+ return true;
+#endif
return (image_get_arch(hdr) == arch) ||
(image_get_arch(hdr) == IH_ARCH_ARM && arch == IH_ARCH_ARM64);
}
diff --git a/include/linker_lists.h b/include/linker_lists.h
index fd98ecd297c..81a280a8841 100644
--- a/include/linker_lists.h
+++ b/include/linker_lists.h
@@ -212,6 +212,18 @@
})
/**
+ * ll_entry_ref() - Get a reference to a linker-generated array entry
+ *
+ * Once an extern ll_entry_declare() has been used to declare the reference,
+ * this macro allows the entry to be accessed.
+ *
+ * This is like ll_entry_get(), but without the extra code, so it is suitable
+ * for putting into data structures.
+ */
+#define ll_entry_ref(_type, _name, _list) \
+ ((_type *)&_u_boot_list_2_##_list##_2_##_name)
+
+/**
* ll_start() - Point to first entry of first linker-generated array
* @_type: Data type of the entry
*
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index cc9c430512d..6fda14f5fe6 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -192,6 +192,8 @@ struct clk_fixed_factor {
unsigned int div;
};
+extern const struct clk_ops clk_fixed_rate_ops;
+
#define to_clk_fixed_factor(_clk) container_of(_clk, struct clk_fixed_factor,\
clk)
@@ -202,6 +204,9 @@ struct clk_fixed_rate {
#define to_clk_fixed_rate(dev) ((struct clk_fixed_rate *)dev_get_plat(dev))
+void clk_fixed_rate_ofdata_to_plat_(struct udevice *dev,
+ struct clk_fixed_rate *plat);
+
struct clk_composite {
struct clk clk;
struct clk_ops ops;
diff --git a/include/log.h b/include/log.h
index 2d27f9f657e..6ef891d4d2d 100644
--- a/include/log.h
+++ b/include/log.h
@@ -316,12 +316,40 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line,
__ret); \
__ret; \
})
+
+/*
+ * Similar to the above, but any non-zero value is consider an error, not just
+ * values less than 0.
+ */
+#define log_retz(_ret) ({ \
+ int __ret = (_ret); \
+ if (__ret) \
+ log(LOG_CATEGORY, LOGL_ERR, "returning err=%d\n", __ret); \
+ __ret; \
+ })
+#define log_msg_retz(_msg, _ret) ({ \
+ int __ret = (_ret); \
+ if (__ret) \
+ log(LOG_CATEGORY, LOGL_ERR, "%s: returning err=%d\n", _msg, \
+ __ret); \
+ __ret; \
+ })
#else
/* Non-logging versions of the above which just return the error code */
#define log_ret(_ret) (_ret)
#define log_msg_ret(_msg, _ret) ((void)(_msg), _ret)
+#define log_retz(_ret) (_ret)
+#define log_msg_retz(_msg, _ret) ((void)(_msg), _ret)
#endif
+/** * enum log_rec_flags - Flags for a log record */
+enum log_rec_flags {
+ /** @LOGRECF_FORCE_DEBUG: Force output of debug record */
+ LOGRECF_FORCE_DEBUG = BIT(0),
+ /** @LOGRECF_CONT: Continuation of previous log record */
+ LOGRECF_CONT = BIT(1),
+};
+
/**
* struct log_rec - a single log record
*
@@ -337,18 +365,18 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line,
*
* @cat: Category, representing a uclass or part of U-Boot
* @level: Severity level, less severe is higher
- * @force_debug: Force output of debug
- * @file: Name of file where the log record was generated (not allocated)
* @line: Line number where the log record was generated
+ * @flags: Flags for log record (enum log_rec_flags)
+ * @file: Name of file where the log record was generated (not allocated)
* @func: Function where the log record was generated (not allocated)
* @msg: Log message (allocated)
*/
struct log_rec {
enum log_category_t cat;
enum log_level_t level;
- bool force_debug;
+ u16 line;
+ u8 flags;
const char *file;
- int line;
const char *func;
const char *msg;
};
diff --git a/include/malloc.h b/include/malloc.h
index e15e528a2e3..024b18be00e 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -880,6 +880,8 @@ extern Void_t* sbrk();
#else
+void malloc_simple_info(void);
+
#if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
#define malloc malloc_simple
#define realloc realloc_simple
@@ -887,7 +889,6 @@ extern Void_t* sbrk();
static inline void free(void *ptr) {}
void *calloc(size_t nmemb, size_t size);
void *realloc_simple(void *ptr, size_t size);
-void malloc_simple_info(void);
#else
# ifdef USE_DL_PREFIX
diff --git a/include/os.h b/include/os.h
index 65bcb232cab..77d8bd89d0f 100644
--- a/include/os.h
+++ b/include/os.h
@@ -114,7 +114,7 @@ void os_fd_restore(void);
* os_malloc() - aquires some memory from the underlying os.
*
* @length: Number of bytes to be allocated
- * Return: Pointer to length bytes or NULL on error
+ * Return: Pointer to length bytes or NULL if @length is 0 or on error
*/
void *os_malloc(size_t length);
@@ -123,11 +123,22 @@ void *os_malloc(size_t length);
*
* This returns the memory to the OS.
*
- * @ptr: Pointer to memory block to free
+ * @ptr: Pointer to memory block to free. If this is NULL then this
+ * function does nothing
*/
void os_free(void *ptr);
/**
+ * os_realloc() - reallocate memory
+ *
+ * This follows the semantics of realloc(), so can perform an os_malloc() or
+ * os_free() depending on @ptr and @length.
+ *
+ * Return: Pointer to reallocated memory or NULL if @length is 0
+ */
+void *os_realloc(void *ptr, size_t length);
+
+/**
* os_usleep() - access to the usleep function of the os
*
* @usec: time to sleep in micro seconds
@@ -313,9 +324,10 @@ int os_jump_to_image(const void *dest, int size);
*
* @fname: place to put full path to U-Boot
* @maxlen: maximum size of @fname
+ * @use_img: select the 'u-boot.img' file instead of the 'u-boot' ELF file
* Return: 0 if OK, -NOSPC if the filename is too large, -ENOENT if not found
*/
-int os_find_u_boot(char *fname, int maxlen);
+int os_find_u_boot(char *fname, int maxlen, bool use_img);
/**
* os_spl_to_uboot() - Run U-Boot proper
diff --git a/include/sandboxblockdev.h b/include/sandboxblockdev.h
index c1f0afb337d..4006e942a02 100644
--- a/include/sandboxblockdev.h
+++ b/include/sandboxblockdev.h
@@ -14,6 +14,13 @@ struct host_block_dev {
int fd;
};
-int host_dev_bind(int dev, char *filename);
+/**
+ * host_dev_bind() - Bind or unbind a device
+ *
+ * @dev: Device number (0=first slot)
+ * @filename: Host filename to use, or NULL to unbind
+ * @removable: true if the block device should mark itself as removable
+ */
+int host_dev_bind(int dev, char *filename, bool removable);
#endif
diff --git a/include/scp03.h b/include/scp03.h
new file mode 100644
index 00000000000..729667ccd1c
--- /dev/null
+++ b/include/scp03.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2021, Foundries.IO
+ *
+ */
+
+#ifndef _SCP03_H
+#define _SCP03_H
+
+/*
+ * Requests to OPTEE to enable or provision the Secure Channel Protocol on its
+ * Secure Element
+ *
+ * If key provisioning is requested, OPTEE shall generate new SCP03 keys and
+ * write them to the Secure Element.
+ *
+ * Both functions return < 0 on error else 0.
+ */
+int tee_enable_scp03(void);
+int tee_provision_scp03(void);
+#endif /* _SCP03_H */
diff --git a/include/smbios.h b/include/smbios.h
index ecc4fd1de3b..ffeefb47372 100644
--- a/include/smbios.h
+++ b/include/smbios.h
@@ -14,6 +14,10 @@
#define SMBIOS_MAJOR_VER 3
#define SMBIOS_MINOR_VER 0
+enum {
+ SMBIOS_STR_MAX = 64, /* Maximum length allowed for a string */
+};
+
/* SMBIOS structure types */
enum {
SMBIOS_BIOS_INFORMATION = 0,
@@ -269,4 +273,20 @@ const char *smbios_string(const struct smbios_header *header, int index);
*/
int smbios_update_version(const char *version);
+/**
+ * smbios_update_version_full() - Update the version string
+ *
+ * This can be called after the SMBIOS tables are written (e.g. after the U-Boot
+ * main loop has started) to update the BIOS version string (SMBIOS table 0).
+ * It scans for the correct place to put the version, so does not need U-Boot
+ * to have actually written the tables itself (e.g. if a previous bootloader
+ * did it).
+ *
+ * @smbios_tab: Start of SMBIOS tables
+ * @version: New version string to use
+ * @return 0 if OK, -ENOENT if no version string was previously written,
+ * -ENOSPC if the new string is too large to fit
+ */
+int smbios_update_version_full(void *smbios_tab, const char *version);
+
#endif /* _SMBIOS_H_ */
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 85cae32cc73..3d747c925b9 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -35,6 +35,19 @@ struct dm_spi_flash_ops {
int (*write)(struct udevice *dev, u32 offset, size_t len,
const void *buf);
int (*erase)(struct udevice *dev, u32 offset, size_t len);
+ /**
+ * get_sw_write_prot() - Check state of software write-protect feature
+ *
+ * SPI flash chips can lock a region of the flash defined by a
+ * 'protected area'. This function checks if this protected area is
+ * defined.
+ *
+ * @dev: SPI flash device
+ * @return 0 if no region is write-protected, 1 if a region is
+ * write-protected, -ENOSYS if the driver does not implement this,
+ * other -ve value on error
+ */
+ int (*get_sw_write_prot)(struct udevice *dev);
};
/* Access the serial operations for a device */
@@ -77,6 +90,20 @@ int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len);
/**
+ * spl_flash_get_sw_write_prot() - Check state of software write-protect feature
+ *
+ * SPI flash chips can lock a region of the flash defined by a
+ * 'protected area'. This function checks if this protected area is
+ * defined.
+ *
+ * @dev: SPI flash device
+ * @return 0 if no region is write-protected, 1 if a region is
+ * write-protected, -ENOSYS if the driver does not implement this,
+ * other -ve value on error
+ */
+int spl_flash_get_sw_write_prot(struct udevice *dev);
+
+/**
* spi_flash_std_probe() - Probe a SPI flash device
*
* This is the standard internal method for probing a SPI flash device to
@@ -97,7 +124,9 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
unsigned int max_hz, unsigned int spi_mode);
/* Compatibility function - this is the old U-Boot API */
-void spi_flash_free(struct spi_flash *flash);
+static inline void spi_flash_free(struct spi_flash *flash)
+{
+}
static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
size_t len, void *buf)
diff --git a/include/spl.h b/include/spl.h
index 0d134587de2..4f6e0e53f5d 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -222,6 +222,15 @@ struct spl_load_info {
void *priv;
int bl_len;
const char *filename;
+ /**
+ * read() - Read from device
+ *
+ * @load: Information about the load state
+ * @sector: Sector number to read from (each @load->bl_len bytes)
+ * @count: Number of sectors to read
+ * @buf: Buffer to read into
+ * @return number of sectors read, 0 on error
+ */
ulong (*read)(struct spl_load_info *load, ulong sector, ulong count,
void *buf);
};
diff --git a/include/sysinfo.h b/include/sysinfo.h
index 270ac1b377f..68fad25a065 100644
--- a/include/sysinfo.h
+++ b/include/sysinfo.h
@@ -37,9 +37,13 @@ struct udevice;
enum sysinfo_id {
SYSINFO_ID_NONE,
+ /* For SMBIOS tables */
SYSINFO_ID_SMBIOS_SYSTEM_VERSION,
SYSINFO_ID_SMBIOS_BASEBOARD_VERSION,
+ /* For show_board_info() */
+ SYSINFO_ID_BOARD_MODEL,
+
/* First value available for downstream/board used */
SYSINFO_ID_USER = 0x1000,
};
diff --git a/include/sysreset.h b/include/sysreset.h
index 8bb094d463b..701e4f5c86e 100644
--- a/include/sysreset.h
+++ b/include/sysreset.h
@@ -116,6 +116,6 @@ void sysreset_walk_halt(enum sysreset_t type);
/**
* reset_cpu() - calls sysreset_walk(SYSRESET_WARM)
*/
-void reset_cpu(ulong addr);
+void reset_cpu(void);
#endif
diff --git a/include/tee/optee_ta_scp03.h b/include/tee/optee_ta_scp03.h
new file mode 100644
index 00000000000..13f9956d983
--- /dev/null
+++ b/include/tee/optee_ta_scp03.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * (C) Copyright 2021, Foundries.IO
+ *
+ */
+#ifndef __TA_SCP03_H
+#define __TA_SCP03_H
+
+#define PTA_SCP03_UUID { 0xbe0e5821, 0xe718, 0x4f77, \
+ { 0xab, 0x3e, 0x8e, 0x6c, 0x73, 0xa9, 0xc7, 0x35 } }
+
+/*
+ * Enable Secure Channel Protocol functionality (SCP03) on the Secure Element.
+ * Setting the operation value to something different than NULL will trigger
+ * the SCP03 provisioning request.
+ *
+ * in params[0].a = operation
+ */
+#define PTA_CMD_ENABLE_SCP03 0
+
+#endif /*__TA_SCP03_H*/
diff --git a/include/test/test.h b/include/test/test.h
index 3fdaa2b5e51..0b124edd601 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -14,16 +14,24 @@
*
* @fail_count: Number of tests that failed
* @start: Store the starting mallinfo when doing leak test
- * @priv: A pointer to some other info some suites want to track
+ * @of_live: true to use livetree if available, false to use flattree
* @of_root: Record of the livetree root node (used for setting up tests)
+ * @root: Root device
+ * @testdev: Test device
+ * @force_fail_alloc: Force all memory allocs to fail
+ * @skip_post_probe: Skip uclass post-probe processing
* @expect_str: Temporary string used to hold expected string value
* @actual_str: Temporary string used to hold actual string value
*/
struct unit_test_state {
int fail_count;
struct mallinfo start;
- void *priv;
struct device_node *of_root;
+ bool of_live;
+ struct udevice *root;
+ struct udevice *testdev;
+ int force_fail_alloc;
+ int skip_post_probe;
char expect_str[256];
char actual_str[256];
};
@@ -36,6 +44,8 @@ enum {
UT_TESTF_FLAT_TREE = BIT(3), /* test needs flat DT */
UT_TESTF_LIVE_TREE = BIT(4), /* needs live device tree */
UT_TESTF_CONSOLE_REC = BIT(5), /* needs console recording */
+ /* do extra driver model init and uninit */
+ UT_TESTF_DM = BIT(6),
};
/**
@@ -76,13 +86,24 @@ struct unit_test {
* @_suite: name of the test suite concatenated with "_test"
*/
#define UNIT_TEST(_name, _flags, _suite) \
- ll_entry_declare(struct unit_test, _name, _suite) = { \
+ ll_entry_declare(struct unit_test, _name, ut_ ## _suite) = { \
.file = __FILE__, \
.name = #_name, \
.flags = _flags, \
.func = _name, \
}
+/* Get the start of a list of unit tests for a particular suite */
+#define UNIT_TEST_SUITE_START(_suite) \
+ ll_entry_start(struct unit_test, ut_ ## _suite)
+#define UNIT_TEST_SUITE_COUNT(_suite) \
+ ll_entry_count(struct unit_test, ut_ ## _suite)
+
+/* Use ! and ~ so that all tests will be sorted between these two values */
+#define UNIT_TEST_ALL_START() ll_entry_start(struct unit_test, ut_!)
+#define UNIT_TEST_ALL_END() ll_entry_start(struct unit_test, ut_~)
+#define UNIT_TEST_ALL_COUNT() (UNIT_TEST_ALL_END() - UNIT_TEST_ALL_START())
+
/* Sizes for devres tests */
enum {
TEST_DEVRES_SIZE = 100,
@@ -103,15 +124,4 @@ enum {
*/
struct udevice *testbus_get_clear_removed(void);
-/**
- * dm_test_main() - Run driver model tests
- *
- * Run all the available driver model tests, or a selection
- *
- * @test_name: Name of single test to run (e.g. "dm_test_fdt_pre_reloc" or just
- * "fdt_pre_reloc"), or NULL to run all
- * @return 0 if all tests passed, 1 if not
- */
-int dm_test_main(const char *test_name);
-
#endif /* __TEST_TEST_H */
diff --git a/include/test/ut.h b/include/test/ut.h
index 17400c73ea9..fbbba286ee0 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -356,4 +356,49 @@ void ut_silence_console(struct unit_test_state *uts);
*/
void ut_unsilence_console(struct unit_test_state *uts);
+/**
+ * ut_set_skip_delays() - Sets whether delays should be skipped
+ *
+ * Normally functions like mdelay() cause U-Boot to wait for a while. This
+ * allows all such delays to be skipped on sandbox, to speed up tests
+ *
+ * @uts: Test state (in case in future we want to keep state here)
+ * @skip_delays: true to skip delays, false to process them normally
+ */
+void ut_set_skip_delays(struct unit_test_state *uts, bool skip_delays);
+
+/**
+ * test_get_state() - Get the active test state
+ *
+ * @return the currently active test state, or NULL if none
+ */
+struct unit_test_state *test_get_state(void);
+
+/**
+ * test_set_state() - Set the active test state
+ *
+ * @uts: Test state to use as currently active test state, or NULL if none
+ */
+void test_set_state(struct unit_test_state *uts);
+
+/**
+ * ut_run_tests() - Run a set of tests
+ *
+ * This runs the test, handling any preparation and clean-up needed. It prints
+ * the name of each test before running it.
+ *
+ * @category: Category of these tests. This is a string printed at the start to
+ * announce the the number of tests
+ * @prefix: String prefix for the tests. Any tests that have this prefix will be
+ * printed without the prefix, so that it is easier to see the unique part
+ * of the test name. If NULL, no prefix processing is done
+ * @tests: List of tests to run
+ * @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
+ * @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);
+
#endif
diff --git a/include/tpm-common.h b/include/tpm-common.h
index c1309a2735d..998b4fbb415 100644
--- a/include/tpm-common.h
+++ b/include/tpm-common.h
@@ -55,6 +55,8 @@ enum tpm_version {
* @buf: Buffer used during the exchanges with the chip
* @pcr_count: Number of PCR per bank
* @pcr_select_min: Minimum size in bytes of the pcrSelect array
+ * @plat_hier_disabled: Platform hierarchy has been disabled (TPM is locked
+ * down until next reboot)
*/
struct tpm_chip_priv {
enum tpm_version version;
@@ -66,6 +68,7 @@ struct tpm_chip_priv {
/* TPM v2 specific data */
uint pcr_count;
uint pcr_select_min;
+ bool plat_hier_disabled;
};
/**
diff --git a/include/tpm-v1.h b/include/tpm-v1.h
index 8f6cc28a9ea..fcfe1f054f6 100644
--- a/include/tpm-v1.h
+++ b/include/tpm-v1.h
@@ -289,7 +289,7 @@ struct __packed tpm_nv_data_public {
* @param mode TPM startup mode
* @return return code of the operation
*/
-u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode);
+u32 tpm1_startup(struct udevice *dev, enum tpm_startup_type mode);
/**
* Issue a TPM_SelfTestFull command.
@@ -297,7 +297,7 @@ u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode);
* @param dev TPM device
* @return return code of the operation
*/
-u32 tpm_self_test_full(struct udevice *dev);
+u32 tpm1_self_test_full(struct udevice *dev);
/**
* Issue a TPM_ContinueSelfTest command.
@@ -305,7 +305,7 @@ u32 tpm_self_test_full(struct udevice *dev);
* @param dev TPM device
* @return return code of the operation
*/
-u32 tpm_continue_self_test(struct udevice *dev);
+u32 tpm1_continue_self_test(struct udevice *dev);
/**
* Issue a TPM_NV_DefineSpace command. The implementation is limited
@@ -318,7 +318,7 @@ u32 tpm_continue_self_test(struct udevice *dev);
* @param size size of the area
* @return return code of the operation
*/
-u32 tpm_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size);
+u32 tpm1_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size);
/**
* Issue a TPM_NV_ReadValue command. This implementation is limited
@@ -331,7 +331,7 @@ u32 tpm_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size);
* @param count size of output buffer
* @return return code of the operation
*/
-u32 tpm_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count);
+u32 tpm1_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count);
/**
* Issue a TPM_NV_WriteValue command. This implementation is limited
@@ -344,8 +344,8 @@ u32 tpm_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count);
* @param length length of data bytes of input buffer
* @return return code of the operation
*/
-u32 tpm_nv_write_value(struct udevice *dev, u32 index, const void *data,
- u32 length);
+u32 tpm1_nv_write_value(struct udevice *dev, u32 index, const void *data,
+ u32 length);
/**
* Issue a TPM_Extend command.
@@ -358,8 +358,8 @@ u32 tpm_nv_write_value(struct udevice *dev, u32 index, const void *data,
* command
* @return return code of the operation
*/
-u32 tpm_extend(struct udevice *dev, u32 index, const void *in_digest,
- void *out_digest);
+u32 tpm1_extend(struct udevice *dev, u32 index, const void *in_digest,
+ void *out_digest);
/**
* Issue a TPM_PCRRead command.
@@ -370,7 +370,7 @@ u32 tpm_extend(struct udevice *dev, u32 index, const void *in_digest,
* @param count size of output buffer
* @return return code of the operation
*/
-u32 tpm_pcr_read(struct udevice *dev, u32 index, void *data, size_t count);
+u32 tpm1_pcr_read(struct udevice *dev, u32 index, void *data, size_t count);
/**
* Issue a TSC_PhysicalPresence command. TPM physical presence flag
@@ -380,7 +380,7 @@ u32 tpm_pcr_read(struct udevice *dev, u32 index, void *data, size_t count);
* @param presence TPM physical presence flag
* @return return code of the operation
*/
-u32 tpm_tsc_physical_presence(struct udevice *dev, u16 presence);
+u32 tpm1_tsc_physical_presence(struct udevice *dev, u16 presence);
/**
* Issue a TPM_ReadPubek command.
@@ -390,7 +390,7 @@ u32 tpm_tsc_physical_presence(struct udevice *dev, u16 presence);
* @param count size of output buffer
* @return return code of the operation
*/
-u32 tpm_read_pubek(struct udevice *dev, void *data, size_t count);
+u32 tpm1_read_pubek(struct udevice *dev, void *data, size_t count);
/**
* Issue a TPM_ForceClear command.
@@ -398,7 +398,7 @@ u32 tpm_read_pubek(struct udevice *dev, void *data, size_t count);
* @param dev TPM device
* @return return code of the operation
*/
-u32 tpm_force_clear(struct udevice *dev);
+u32 tpm1_force_clear(struct udevice *dev);
/**
* Issue a TPM_PhysicalEnable command.
@@ -406,7 +406,7 @@ u32 tpm_force_clear(struct udevice *dev);
* @param dev TPM device
* @return return code of the operation
*/
-u32 tpm_physical_enable(struct udevice *dev);
+u32 tpm1_physical_enable(struct udevice *dev);
/**
* Issue a TPM_PhysicalDisable command.
@@ -414,7 +414,7 @@ u32 tpm_physical_enable(struct udevice *dev);
* @param dev TPM device
* @return return code of the operation
*/
-u32 tpm_physical_disable(struct udevice *dev);
+u32 tpm1_physical_disable(struct udevice *dev);
/**
* Issue a TPM_PhysicalSetDeactivated command.
@@ -423,7 +423,7 @@ u32 tpm_physical_disable(struct udevice *dev);
* @param state boolean state of the deactivated flag
* @return return code of the operation
*/
-u32 tpm_physical_set_deactivated(struct udevice *dev, u8 state);
+u32 tpm1_physical_set_deactivated(struct udevice *dev, u8 state);
/**
* Issue a TPM_GetCapability command. This implementation is limited
@@ -437,8 +437,8 @@ u32 tpm_physical_set_deactivated(struct udevice *dev, u8 state);
* @param count size of output buffer
* @return return code of the operation
*/
-u32 tpm_get_capability(struct udevice *dev, u32 cap_area, u32 sub_cap,
- void *cap, size_t count);
+u32 tpm1_get_capability(struct udevice *dev, u32 cap_area, u32 sub_cap,
+ void *cap, size_t count);
/**
* Issue a TPM_FlushSpecific command for a AUTH resource.
@@ -447,7 +447,7 @@ u32 tpm_get_capability(struct udevice *dev, u32 cap_area, u32 sub_cap,
* @param auth_handle handle of the auth session
* @return return code of the operation
*/
-u32 tpm_terminate_auth_session(struct udevice *dev, u32 auth_handle);
+u32 tpm1_terminate_auth_session(struct udevice *dev, u32 auth_handle);
/**
* Issue a TPM_OIAP command to setup an object independent authorization
@@ -460,7 +460,7 @@ u32 tpm_terminate_auth_session(struct udevice *dev, u32 auth_handle);
* @param auth_handle pointer to the (new) auth handle or NULL.
* @return return code of the operation
*/
-u32 tpm_oiap(struct udevice *dev, u32 *auth_handle);
+u32 tpm1_oiap(struct udevice *dev, u32 *auth_handle);
/**
* Ends an active OIAP session.
@@ -468,7 +468,7 @@ u32 tpm_oiap(struct udevice *dev, u32 *auth_handle);
* @param dev TPM device
* @return return code of the operation
*/
-u32 tpm_end_oiap(struct udevice *dev);
+u32 tpm1_end_oiap(struct udevice *dev);
/**
* Issue a TPM_LoadKey2 (Auth1) command using an OIAP session for authenticating
@@ -482,9 +482,9 @@ u32 tpm_end_oiap(struct udevice *dev);
* @param key_handle pointer to the key handle
* @return return code of the operation
*/
-u32 tpm_load_key2_oiap(struct udevice *dev, u32 parent_handle, const void *key,
- size_t key_length, const void *parent_key_usage_auth,
- u32 *key_handle);
+u32 tpm1_load_key2_oiap(struct udevice *dev, u32 parent_handle, const void *key,
+ size_t key_length, const void *parent_key_usage_auth,
+ u32 *key_handle);
/**
* Issue a TPM_GetPubKey (Auth1) command using an OIAP session for
@@ -500,9 +500,9 @@ u32 tpm_load_key2_oiap(struct udevice *dev, u32 parent_handle, const void *key,
* of the stored TPM_PUBKEY structure (iff pubkey != NULL).
* @return return code of the operation
*/
-u32 tpm_get_pub_key_oiap(struct udevice *dev, u32 key_handle,
- const void *usage_auth, void *pubkey,
- size_t *pubkey_len);
+u32 tpm1_get_pub_key_oiap(struct udevice *dev, u32 key_handle,
+ const void *usage_auth, void *pubkey,
+ size_t *pubkey_len);
/**
* Get the TPM permanent flags value
@@ -511,8 +511,8 @@ u32 tpm_get_pub_key_oiap(struct udevice *dev, u32 key_handle,
* @param pflags Place to put permanent flags
* @return return code of the operation
*/
-u32 tpm_get_permanent_flags(struct udevice *dev,
- struct tpm_permanent_flags *pflags);
+u32 tpm1_get_permanent_flags(struct udevice *dev,
+ struct tpm_permanent_flags *pflags);
/**
* Get the TPM permissions
@@ -521,7 +521,7 @@ u32 tpm_get_permanent_flags(struct udevice *dev,
* @param perm Returns permissions value
* @return return code of the operation
*/
-u32 tpm_get_permissions(struct udevice *dev, u32 index, u32 *perm);
+u32 tpm1_get_permissions(struct udevice *dev, u32 index, u32 *perm);
/**
* Flush a resource with a given handle and type from the TPM
@@ -531,7 +531,7 @@ u32 tpm_get_permissions(struct udevice *dev, u32 index, u32 *perm);
* @param resource_type type of the resource
* @return return code of the operation
*/
-u32 tpm_flush_specific(struct udevice *dev, u32 key_handle, u32 resource_type);
+u32 tpm1_flush_specific(struct udevice *dev, u32 key_handle, u32 resource_type);
#ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
/**
@@ -543,8 +543,8 @@ u32 tpm_flush_specific(struct udevice *dev, u32 key_handle, u32 resource_type);
* @param[out] handle The handle of the key (Non-null iff found)
* @return 0 if key was found in TPM; != 0 if not.
*/
-u32 tpm_find_key_sha1(struct udevice *dev, const u8 auth[20],
- const u8 pubkey_digest[20], u32 *handle);
+u32 tpm1_find_key_sha1(struct udevice *dev, const u8 auth[20],
+ const u8 pubkey_digest[20], u32 *handle);
#endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */
/**
@@ -557,7 +557,7 @@ u32 tpm_find_key_sha1(struct udevice *dev, const u8 auth[20],
* @param count size of output buffer
* @return return code of the operation
*/
-u32 tpm_get_random(struct udevice *dev, void *data, u32 count);
+u32 tpm1_get_random(struct udevice *dev, void *data, u32 count);
/**
* tpm_finalise_physical_presence() - Finalise physical presence
@@ -565,15 +565,15 @@ u32 tpm_get_random(struct udevice *dev, void *data, u32 count);
* @param dev TPM device
* @return return code of the operation (0 = success)
*/
-u32 tpm_finalise_physical_presence(struct udevice *dev);
+u32 tpm1_finalise_physical_presence(struct udevice *dev);
/**
- * tpm_nv_set_locked() - lock the non-volatile space
+ * tpm_nv_enable_locking() - lock the non-volatile space
*
* @param dev TPM device
* @return return code of the operation (0 = success)
*/
-u32 tpm_nv_set_locked(struct udevice *dev);
+u32 tpm1_nv_set_locked(struct udevice *dev);
/**
* tpm_set_global_lock() - set the global lock
@@ -589,6 +589,6 @@ u32 tpm_set_global_lock(struct udevice *dev);
* @param dev TPM device
* @return return code of the operation (0 = success)
*/
-u32 tpm_resume(struct udevice *dev);
+u32 tpm1_resume(struct udevice *dev);
#endif /* __TPM_V1_H */
diff --git a/include/tpm-v2.h b/include/tpm-v2.h
index 56eaa65815f..df67a196cf3 100644
--- a/include/tpm-v2.h
+++ b/include/tpm-v2.h
@@ -237,10 +237,14 @@ enum tpm2_handles {
enum tpm2_command_codes {
TPM2_CC_STARTUP = 0x0144,
TPM2_CC_SELF_TEST = 0x0143,
+ TPM2_CC_HIER_CONTROL = 0x0121,
TPM2_CC_CLEAR = 0x0126,
TPM2_CC_CLEARCONTROL = 0x0127,
TPM2_CC_HIERCHANGEAUTH = 0x0129,
+ TPM2_CC_NV_DEFINE_SPACE = 0x012a,
TPM2_CC_PCR_SETAUTHPOL = 0x012C,
+ TPM2_CC_NV_WRITE = 0x0137,
+ TPM2_CC_NV_WRITELOCK = 0x0138,
TPM2_CC_DAM_RESET = 0x0139,
TPM2_CC_DAM_PARAMETERS = 0x013A,
TPM2_CC_NV_READ = 0x014E,
@@ -271,6 +275,7 @@ enum tpm2_return_codes {
TPM2_RC_COMMAND_CODE = TPM2_RC_VER1 + 0x0043,
TPM2_RC_AUTHSIZE = TPM2_RC_VER1 + 0x0044,
TPM2_RC_AUTH_CONTEXT = TPM2_RC_VER1 + 0x0045,
+ TPM2_RC_NV_DEFINED = TPM2_RC_VER1 + 0x004c,
TPM2_RC_NEEDS_TEST = TPM2_RC_VER1 + 0x0053,
TPM2_RC_WARN = 0x0900,
TPM2_RC_TESTING = TPM2_RC_WARN + 0x000A,
@@ -355,6 +360,20 @@ enum {
TPM_MAX_BUF_SIZE = 1260,
};
+enum {
+ /* Secure storage for firmware settings */
+ TPM_HT_PCR = 0,
+ TPM_HT_NV_INDEX,
+ TPM_HT_HMAC_SESSION,
+ TPM_HT_POLICY_SESSION,
+
+ HR_SHIFT = 24,
+ HR_PCR = TPM_HT_PCR << HR_SHIFT,
+ HR_HMAC_SESSION = TPM_HT_HMAC_SESSION << HR_SHIFT,
+ HR_POLICY_SESSION = TPM_HT_POLICY_SESSION << HR_SHIFT,
+ HR_NV_INDEX = TPM_HT_NV_INDEX << HR_SHIFT,
+};
+
/**
* Issue a TPM2_Startup command.
*
@@ -389,6 +408,23 @@ u32 tpm2_clear(struct udevice *dev, u32 handle, const char *pw,
const ssize_t pw_sz);
/**
+ * Issue a TPM_NV_DefineSpace command
+ *
+ * This allows a space to be defined with given attributes and policy
+ *
+ * @dev TPM device
+ * @space_index index of the area
+ * @space_size size of area in bytes
+ * @nv_attributes TPM_NV_ATTRIBUTES of the area
+ * @nv_policy policy to use
+ * @nv_policy_size size of the policy
+ * @return return code of the operation
+ */
+u32 tpm2_nv_define_space(struct udevice *dev, u32 space_index,
+ size_t space_size, u32 nv_attributes,
+ const u8 *nv_policy, size_t nv_policy_size);
+
+/**
* Issue a TPM2_PCR_Extend command.
*
* @dev TPM device
@@ -403,6 +439,29 @@ u32 tpm2_pcr_extend(struct udevice *dev, u32 index, u32 algorithm,
const u8 *digest, u32 digest_len);
/**
+ * Read data from the secure storage
+ *
+ * @dev TPM device
+ * @index Index of data to read
+ * @data Place to put data
+ * @count Number of bytes of data
+ * @return code of the operation
+ */
+u32 tpm2_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count);
+
+/**
+ * Write data to the secure storage
+ *
+ * @dev TPM device
+ * @index Index of data to write
+ * @data Data to write
+ * @count Number of bytes of data
+ * @return code of the operation
+ */
+u32 tpm2_nv_write_value(struct udevice *dev, u32 index, const void *data,
+ u32 count);
+
+/**
* Issue a TPM2_PCR_Read command.
*
* @dev TPM device
@@ -516,4 +575,26 @@ u32 tpm2_pcr_setauthvalue(struct udevice *dev, const char *pw,
*/
u32 tpm2_get_random(struct udevice *dev, void *data, u32 count);
+/**
+ * Lock data in the TPM
+ *
+ * Once locked the data cannot be written until after a reboot
+ *
+ * @dev TPM device
+ * @index Index of data to lock
+ * @return code of the operation
+ */
+u32 tpm2_write_lock(struct udevice *dev, u32 index);
+
+/**
+ * Disable access to any platform data
+ *
+ * This can be called to close off access to the firmware data in the data,
+ * before calling the kernel.
+ *
+ * @dev TPM device
+ * @return code of the operation
+ */
+u32 tpm2_disable_platform_hierarchy(struct udevice *dev);
+
#endif /* __TPM_V2_H */
diff --git a/include/tpm_api.h b/include/tpm_api.h
new file mode 100644
index 00000000000..f13d98cae47
--- /dev/null
+++ b/include/tpm_api.h
@@ -0,0 +1,322 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2013 The Chromium OS Authors.
+ * Coypright (c) 2013 Guntermann & Drunck GmbH
+ */
+
+#ifndef __TPM_API_H
+#define __TPM_API_H
+
+#include <tpm-common.h>
+#include <tpm-v1.h>
+#include <tpm-v2.h>
+
+/**
+ * Issue a TPM_Startup command.
+ *
+ * @param dev TPM device
+ * @param mode TPM startup mode
+ * @return return code of the operation
+ */
+u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode);
+
+/**
+ * Issue a TPM_SelfTestFull command.
+ *
+ * @param dev TPM device
+ * @return return code of the operation
+ */
+u32 tpm_self_test_full(struct udevice *dev);
+
+/**
+ * Issue a TPM_ContinueSelfTest command.
+ *
+ * @param dev TPM device
+ * @return return code of the operation
+ */
+u32 tpm_continue_self_test(struct udevice *dev);
+
+/**
+ * Issue a TPM_NV_DefineSpace command. The implementation is limited
+ * to specify TPM_NV_ATTRIBUTES and size of the area. The area index
+ * could be one of the special value listed in enum tpm_nv_index.
+ *
+ * @param dev TPM device
+ * @param index index of the area
+ * @param perm TPM_NV_ATTRIBUTES of the area
+ * @param size size of the area
+ * @return return code of the operation
+ */
+u32 tpm_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size);
+
+/**
+ * Issue a TPM_NV_ReadValue command. This implementation is limited
+ * to read the area from offset 0. The area index could be one of
+ * the special value listed in enum tpm_nv_index.
+ *
+ * @param dev TPM device
+ * @param index index of the area
+ * @param data output buffer of the area contents
+ * @param count size of output buffer
+ * @return return code of the operation
+ */
+u32 tpm_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count);
+
+/**
+ * Issue a TPM_NV_WriteValue command. This implementation is limited
+ * to write the area from offset 0. The area index could be one of
+ * the special value listed in enum tpm_nv_index.
+ *
+ * @param dev TPM device
+ * @param index index of the area
+ * @param data input buffer to be wrote to the area
+ * @param length length of data bytes of input buffer
+ * @return return code of the operation
+ */
+u32 tpm_nv_write_value(struct udevice *dev, u32 index, const void *data,
+ u32 length);
+
+/**
+ * Issue a TPM_Extend command.
+ *
+ * @param dev TPM device
+ * @param index index of the PCR
+ * @param in_digest 160-bit value representing the event to be
+ * recorded
+ * @param out_digest 160-bit PCR value after execution of the
+ * command
+ * @return return code of the operation
+ */
+u32 tpm_pcr_extend(struct udevice *dev, u32 index, const void *in_digest,
+ void *out_digest);
+
+/**
+ * Issue a TPM_PCRRead command.
+ *
+ * @param dev TPM device
+ * @param index index of the PCR
+ * @param data output buffer for contents of the named PCR
+ * @param count size of output buffer
+ * @return return code of the operation
+ */
+u32 tpm_pcr_read(struct udevice *dev, u32 index, void *data, size_t count);
+
+/**
+ * Issue a TSC_PhysicalPresence command. TPM physical presence flag
+ * is bit-wise OR'ed of flags listed in enum tpm_physical_presence.
+ *
+ * @param dev TPM device
+ * @param presence TPM physical presence flag
+ * @return return code of the operation
+ */
+u32 tpm_tsc_physical_presence(struct udevice *dev, u16 presence);
+
+/**
+ * Issue a TPM_ReadPubek command.
+ *
+ * @param dev TPM device
+ * @param data output buffer for the public endorsement key
+ * @param count size of output buffer
+ * @return return code of the operation
+ */
+u32 tpm_read_pubek(struct udevice *dev, void *data, size_t count);
+
+/**
+ * Issue a TPM_ForceClear command.
+ *
+ * @param dev TPM device
+ * @return return code of the operation
+ */
+u32 tpm_force_clear(struct udevice *dev);
+
+/**
+ * Issue a TPM_PhysicalEnable command.
+ *
+ * @param dev TPM device
+ * @return return code of the operation
+ */
+u32 tpm_physical_enable(struct udevice *dev);
+
+/**
+ * Issue a TPM_PhysicalDisable command.
+ *
+ * @param dev TPM device
+ * @return return code of the operation
+ */
+u32 tpm_physical_disable(struct udevice *dev);
+
+/**
+ * Issue a TPM_PhysicalSetDeactivated command.
+ *
+ * @param dev TPM device
+ * @param state boolean state of the deactivated flag
+ * @return return code of the operation
+ */
+u32 tpm_physical_set_deactivated(struct udevice *dev, u8 state);
+
+/**
+ * Issue a TPM_GetCapability command. This implementation is limited
+ * to query sub_cap index that is 4-byte wide.
+ *
+ * @param dev TPM device
+ * @param cap_area partition of capabilities
+ * @param sub_cap further definition of capability, which is
+ * limited to be 4-byte wide
+ * @param cap output buffer for capability information
+ * @param count size of output buffer
+ * @return return code of the operation
+ */
+u32 tpm_get_capability(struct udevice *dev, u32 cap_area, u32 sub_cap,
+ void *cap, size_t count);
+
+/**
+ * Issue a TPM_FlushSpecific command for a AUTH resource.
+ *
+ * @param dev TPM device
+ * @param auth_handle handle of the auth session
+ * @return return code of the operation
+ */
+u32 tpm_terminate_auth_session(struct udevice *dev, u32 auth_handle);
+
+/**
+ * Issue a TPM_OIAP command to setup an object independent authorization
+ * session.
+ * Information about the session is stored internally.
+ * If there was already an OIAP session active it is terminated and a new
+ * session is set up.
+ *
+ * @param dev TPM device
+ * @param auth_handle pointer to the (new) auth handle or NULL.
+ * @return return code of the operation
+ */
+u32 tpm_oiap(struct udevice *dev, u32 *auth_handle);
+
+/**
+ * Ends an active OIAP session.
+ *
+ * @param dev TPM device
+ * @return return code of the operation
+ */
+u32 tpm_end_oiap(struct udevice *dev);
+
+/**
+ * Issue a TPM_LoadKey2 (Auth1) command using an OIAP session for authenticating
+ * the usage of the parent key.
+ *
+ * @param dev TPM device
+ * @param parent_handle handle of the parent key.
+ * @param key pointer to the key structure (TPM_KEY or TPM_KEY12).
+ * @param key_length size of the key structure
+ * @param parent_key_usage_auth usage auth for the parent key
+ * @param key_handle pointer to the key handle
+ * @return return code of the operation
+ */
+u32 tpm_load_key2_oiap(struct udevice *dev, u32 parent_handle, const void *key,
+ size_t key_length, const void *parent_key_usage_auth,
+ u32 *key_handle);
+
+/**
+ * Issue a TPM_GetPubKey (Auth1) command using an OIAP session for
+ * authenticating the usage of the key.
+ *
+ * @param dev TPM device
+ * @param key_handle handle of the key
+ * @param usage_auth usage auth for the key
+ * @param pubkey pointer to the pub key buffer; may be NULL if the pubkey
+ * should not be stored.
+ * @param pubkey_len pointer to the pub key buffer len. On entry: the size of
+ * the provided pubkey buffer. On successful exit: the size
+ * of the stored TPM_PUBKEY structure (iff pubkey != NULL).
+ * @return return code of the operation
+ */
+u32 tpm_get_pub_key_oiap(struct udevice *dev, u32 key_handle,
+ const void *usage_auth, void *pubkey,
+ size_t *pubkey_len);
+
+/**
+ * Get the TPM permissions
+ *
+ * @param dev TPM device
+ * @param perm Returns permissions value
+ * @return return code of the operation
+ */
+u32 tpm_get_permissions(struct udevice *dev, u32 index, u32 *perm);
+
+/**
+ * Flush a resource with a given handle and type from the TPM
+ *
+ * @param dev TPM device
+ * @param key_handle handle of the resource
+ * @param resource_type type of the resource
+ * @return return code of the operation
+ */
+u32 tpm_flush_specific(struct udevice *dev, u32 key_handle, u32 resource_type);
+
+#ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
+/**
+ * Search for a key by usage AuthData and the hash of the parent's pub key.
+ *
+ * @param dev TPM device
+ * @param auth Usage auth of the key to search for
+ * @param pubkey_digest SHA1 hash of the pub key structure of the key
+ * @param[out] handle The handle of the key (Non-null iff found)
+ * @return 0 if key was found in TPM; != 0 if not.
+ */
+u32 tpm_find_key_sha1(struct udevice *dev, const u8 auth[20],
+ const u8 pubkey_digest[20], u32 *handle);
+#endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */
+
+/**
+ * Read random bytes from the TPM RNG. The implementation deals with the fact
+ * that the TPM may legally return fewer bytes than requested by retrying
+ * until @p count bytes have been received.
+ *
+ * @param dev TPM device
+ * @param data output buffer for the random bytes
+ * @param count size of output buffer
+ * @return return code of the operation
+ */
+u32 tpm_get_random(struct udevice *dev, void *data, u32 count);
+
+/**
+ * tpm_finalise_physical_presence() - Finalise physical presence
+ *
+ * @param dev TPM device
+ * @return return code of the operation (0 = success)
+ */
+u32 tpm_finalise_physical_presence(struct udevice *dev);
+
+/**
+ * tpm_nv_enable_locking() - lock the non-volatile space
+ *
+ * @param dev TPM device
+ * @return return code of the operation (0 = success)
+ */
+u32 tpm_nv_enable_locking(struct udevice *dev);
+
+/**
+ * tpm_set_global_lock() - set the global lock
+ *
+ * @param dev TPM device
+ * @return return code of the operation (0 = success)
+ */
+u32 tpm_set_global_lock(struct udevice *dev);
+
+/**
+ * tpm_write_lock() - lock the non-volatile space
+ *
+ * @param dev TPM device
+ * @param index Index of space to lock
+ * @return return code of the operation (0 = success)
+ */
+u32 tpm_write_lock(struct udevice *dev, u32 index);
+
+/**
+ * tpm_resume() - start up the TPM from resume (after suspend)
+ *
+ * @param dev TPM device
+ * @return return code of the operation (0 = success)
+ */
+u32 tpm_resume(struct udevice *dev);
+
+#endif /* __TPM_API_H */