aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/blk.h56
-rw-r--r--include/bloblist.h23
-rw-r--r--include/cros_ec.h17
-rw-r--r--include/os.h5
-rw-r--r--include/spl.h31
5 files changed, 119 insertions, 13 deletions
diff --git a/include/blk.h b/include/blk.h
index c4401b0025..19bab081c2 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -19,6 +19,8 @@ typedef ulong lbaint_t;
#define LBAF "%" LBAFlength "x"
#define LBAFU "%" LBAFlength "u"
+struct udevice;
+
/* Interface types: */
enum if_type {
IF_TYPE_UNKNOWN = 0,
@@ -683,4 +685,58 @@ const char *blk_get_if_type_name(enum if_type if_type);
int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
int *cur_devnump);
+enum blk_flag_t {
+ BLKF_FIXED = 1 << 0,
+ BLKF_REMOVABLE = 1 << 1,
+ BLKF_BOTH = BLKF_FIXED | BLKF_REMOVABLE,
+};
+
+/**
+ * blk_first_device_err() - Get the first block device
+ *
+ * The device returned is probed if necessary, and ready for use
+ *
+ * @flags: Indicates type of device to return
+ * @devp: Returns pointer to the first device in that uclass, or NULL if none
+ * @return 0 if found, -ENODEV if not found, other -ve on error
+ */
+int blk_first_device_err(enum blk_flag_t flags, struct udevice **devp);
+
+/**
+ * blk_next_device_err() - Get the next block device
+ *
+ * The device returned is probed if necessary, and ready for use
+ *
+ * @flags: Indicates type of device to return
+ * @devp: On entry, pointer to device to lookup. On exit, returns pointer
+ * to the next device in the uclass if no error occurred, or -ENODEV if
+ * there is no next device.
+ * @return 0 if found, -ENODEV if not found, other -ve on error
+ */
+int blk_next_device_err(enum blk_flag_t flags, struct udevice **devp);
+
+/**
+ * blk_foreach_probe() - Helper function to iteration through block devices
+ *
+ * This creates a for() loop which works through the available devices in
+ * a uclass in order from start to end. Devices are probed if necessary,
+ * and ready for use.
+ *
+ * @flags: Indicates type of device to return
+ * @dev: struct udevice * to hold the current device. Set to NULL when there
+ * are no more devices.
+ */
+#define blk_foreach_probe(flags, pos) \
+ for (int _ret = blk_first_device_err(flags, &(pos)); \
+ !_ret && pos; \
+ _ret = blk_next_device_err(flags, &(pos)))
+
+/**
+ * blk_count_devices() - count the number of devices of a particular type
+ *
+ * @flags: Indicates type of device to find
+ * @return number of devices matching those flags
+ */
+int blk_count_devices(enum blk_flag_t flag);
+
#endif
diff --git a/include/bloblist.h b/include/bloblist.h
index 964b974fda..9f007c7a94 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -64,10 +64,10 @@ enum bloblist_tag_t {
* first bloblist_rec starts at this offset from the start of the header
* @flags: Space for BLOBLISTF_... flags (none yet)
* @magic: BLOBLIST_MAGIC
- * @size: Total size of all records (non-zero if valid) including this header.
+ * @size: Total size of the bloblist (non-zero if valid) including this header.
* The bloblist extends for this many bytes from the start of this header.
- * @alloced: Total size allocated for this bloblist. When adding new records,
- * the bloblist can grow up to this size. This starts out as
+ * When adding new records, the bloblist can grow up to this size.
+ * @alloced: Total size allocated so far for this bloblist. This starts out as
* sizeof(bloblist_hdr) since we need at least that much space to store a
* valid bloblist
* @spare: Spare space (for future use)
@@ -180,6 +180,19 @@ void *bloblist_ensure(uint tag, int size);
int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp);
/**
+ * bloblist_resize() - resize a blob
+ *
+ * Any blobs above this one are relocated up or down. The resized blob remains
+ * in the same place.
+ *
+ * @tag: Tag to add (enum bloblist_tag_t)
+ * @new_size: New size of the blob (>0 to expand, <0 to contract)
+ * @return 0 if OK, -ENOSPC if the bloblist does not have enough space, -ENOENT
+ * if the tag is not found
+ */
+int bloblist_resize(uint tag, int new_size);
+
+/**
* bloblist_new() - Create a new, empty bloblist of a given size
*
* @addr: Address of bloblist
@@ -217,6 +230,10 @@ int bloblist_finish(void);
* bloblist_get_stats() - Get information about the bloblist
*
* This returns useful information about the bloblist
+ *
+ * @basep: Returns base address of bloblist
+ * @sizep: Returns the number of bytes used in the bloblist
+ * @allocedp: Returns the total space allocated to the bloblist
*/
void bloblist_get_stats(ulong *basep, ulong *sizep, ulong *allocedp);
diff --git a/include/cros_ec.h b/include/cros_ec.h
index 9396b4d246..ef89deff76 100644
--- a/include/cros_ec.h
+++ b/include/cros_ec.h
@@ -199,15 +199,6 @@ int cros_ec_flash_protect(struct udevice *dev, uint32_t set_mask,
struct ec_response_flash_protect *resp);
/**
- * Notify EC of current boot mode
- *
- * @param dev CROS-EC device
- * @param vboot_mode Verified boot mode
- * @return 0 if ok, <0 on error
- */
-int cros_ec_entering_mode(struct udevice *dev, int mode);
-
-/**
* Run internal tests on the cros_ec interface.
*
* @param dev CROS-EC device
@@ -652,4 +643,12 @@ int cros_ec_vstore_read(struct udevice *dev, int slot, uint8_t *data);
int cros_ec_vstore_write(struct udevice *dev, int slot, const uint8_t *data,
size_t size);
+/**
+ * cros_ec_read_batt_charge() - Read the battery-charge state
+ *
+ * @dev: CROS-EC device
+ * @chargep: Return battery-charge state as a percentage
+ */
+int cros_ec_read_batt_charge(struct udevice *dev, uint *chargep);
+
#endif
diff --git a/include/os.h b/include/os.h
index bd1096eb8b..7b20d606dd 100644
--- a/include/os.h
+++ b/include/os.h
@@ -327,9 +327,12 @@ 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
+ * @cur_prefix: prefix of current executable, e.g. "spl" or "tpl"
+ * @next_prefix: prefix of executable to find, e.g. "spl" or ""
* Return: 0 if OK, -NOSPC if the filename is too large, -ENOENT if not found
*/
-int os_find_u_boot(char *fname, int maxlen, bool use_img);
+int os_find_u_boot(char *fname, int maxlen, bool use_img,
+ const char *cur_prefix, const char *next_prefix);
/**
* os_spl_to_uboot() - Run U-Boot proper
diff --git a/include/spl.h b/include/spl.h
index c643943482..74a1939452 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -176,6 +176,27 @@ static inline const char *spl_phase_name(enum u_boot_phase phase)
}
}
+/**
+ * spl_phase_prefix() - Get the prefix of the current phase
+ *
+ * @phase: Phase to look up
+ * @return phase prefix ("spl", "tpl", etc.)
+ */
+static inline const char *spl_phase_prefix(enum u_boot_phase phase)
+{
+ switch (phase) {
+ case PHASE_TPL:
+ return "tpl";
+ case PHASE_SPL:
+ return "spl";
+ case PHASE_BOARD_F:
+ case PHASE_BOARD_R:
+ return "";
+ default:
+ return "phase?";
+ }
+}
+
/* A string name for SPL or TPL */
#ifdef CONFIG_SPL_BUILD
# ifdef CONFIG_TPL_BUILD
@@ -484,6 +505,16 @@ struct spl_image_loader {
struct spl_boot_device *bootdev);
};
+/* Helper function for accessing the name */
+static inline const char *spl_loader_name(const struct spl_image_loader *loader)
+{
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+ return loader->name;
+#else
+ return NULL;
+#endif
+}
+
/* Declare an SPL image loader */
#define SPL_LOAD_IMAGE(__name) \
ll_entry_declare(struct spl_image_loader, __name, spl_image_loader)