diff options
author | Tom Rini <trini@konsulko.com> | 2019-07-23 21:16:21 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-07-23 21:16:21 +0300 |
commit | ff8c23e784f57a7098e91a200ed7f5a48612b653 (patch) | |
tree | 2d007e81ba9fc0d6334a9568d31422bd0e9dba88 /include | |
parent | 9565bd7c6f4241af746fd67ee5c8406a99c148b3 (diff) | |
parent | 1f99eaff08f699472860c82480344e824a737d57 (diff) | |
download | u-boot-ff8c23e784f57a7098e91a200ed7f5a48612b653.tar.xz |
Merge tag 'u-boot-stm32-20190723' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm
- add rtc driver for stm32mp1
- add remoteproc driver for stm32mp1
- use kernel qspi compatible string for stm32
Diffstat (limited to 'include')
-rw-r--r-- | include/dm/of_addr.h | 18 | ||||
-rw-r--r-- | include/dm/ofnode.h | 16 | ||||
-rw-r--r-- | include/dm/read.h | 20 | ||||
-rw-r--r-- | include/fdt_support.h | 24 | ||||
-rw-r--r-- | include/remoteproc.h | 146 |
5 files changed, 183 insertions, 41 deletions
diff --git a/include/dm/of_addr.h b/include/dm/of_addr.h index 12b1a99a80..3fa1ffce81 100644 --- a/include/dm/of_addr.h +++ b/include/dm/of_addr.h @@ -27,6 +27,24 @@ u64 of_translate_address(const struct device_node *no, const __be32 *in_addr); /** + * of_translate_dma_address() - translate a device-tree DMA address to a CPU + * address + * + * Translate a DMA address from the device-tree into a CPU physical address, + * this walks up the tree and applies the various bus mappings on the way. + * + * Note: We consider that crossing any level with #size-cells == 0 to mean + * that translation is impossible (that is we are not dealing with a value + * that can be mapped to a cpu physical address). This is not really specified + * that way, but this is traditionally the way IBM at least do things + * + * @np: node to check + * @in_addr: pointer to input DMA address + * @return translated DMA address or OF_BAD_ADDR on error + */ +u64 of_translate_dma_address(const struct device_node *no, const __be32 *in_addr); + +/** * of_get_address() - obtain an address from a node * * Extract an address from a node, returns the region size and the address diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 704f91589a..4f89db44c1 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -767,7 +767,7 @@ ofnode ofnode_by_prop_value(ofnode from, const char *propname, node = ofnode_next_subnode(node)) /** - * ofnode_translate_address() - Tranlate a device-tree address + * ofnode_translate_address() - Translate a device-tree address * * Translate an address from the device-tree into a CPU physical address. This * function walks up the tree and applies the various bus mappings along the @@ -781,6 +781,20 @@ ofnode ofnode_by_prop_value(ofnode from, const char *propname, u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr); /** + * ofnode_translate_dma_address() - Translate a device-tree DMA address + * + * Translate a DMA address from the device-tree into a CPU physical address. + * This function walks up the tree and applies the various bus mappings along + * the way. + * + * @ofnode: Device tree node giving the context in which to translate the + * DMA address + * @in_addr: pointer to the DMA address to translate + * @return the translated DMA address; OF_BAD_ADDR on error + */ +u64 ofnode_translate_dma_address(ofnode node, const fdt32_t *in_addr); + +/** * ofnode_device_is_compatible() - check if the node is compatible with compat * * This allows to check whether the node is comaptible with the compat. diff --git a/include/dm/read.h b/include/dm/read.h index 60b727cbd8..62d4be6038 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -499,7 +499,7 @@ int dev_read_resource_byname(struct udevice *dev, const char *name, struct resource *res); /** - * dev_translate_address() - Tranlate a device-tree address + * dev_translate_address() - Translate a device-tree address * * Translate an address from the device-tree into a CPU physical address. This * function walks up the tree and applies the various bus mappings along the @@ -512,6 +512,19 @@ int dev_read_resource_byname(struct udevice *dev, const char *name, u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr); /** + * dev_translate_dma_address() - Translate a device-tree DMA address + * + * Translate a DMA address from the device-tree into a CPU physical address. + * This function walks up the tree and applies the various bus mappings along + * the way. + * + * @dev: device giving the context in which to translate the DMA address + * @in_addr: pointer to the DMA address to translate + * @return the translated DMA address; OF_BAD_ADDR on error + */ +u64 dev_translate_dma_address(struct udevice *dev, const fdt32_t *in_addr); + +/** * dev_read_alias_highest_id - Get highest alias id for the given stem * @stem: Alias stem to be examined * @@ -751,6 +764,11 @@ static inline u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_a return ofnode_translate_address(dev_ofnode(dev), in_addr); } +static inline u64 dev_translate_dma_address(struct udevice *dev, const fdt32_t *in_addr) +{ + return ofnode_translate_dma_address(dev_ofnode(dev), in_addr); +} + static inline int dev_read_alias_highest_id(const char *stem) { return fdtdec_get_alias_highest_id(gd->fdt_blob, stem); diff --git a/include/fdt_support.h b/include/fdt_support.h index 27fe564f0b..cefb2b2cce 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -218,8 +218,32 @@ static inline void fdt_fixup_mtdparts(void *fdt, #endif void fdt_del_node_and_alias(void *blob, const char *alias); + +/** + * Translate an address from the DT into a CPU physical address + * + * The translation relies on the "ranges" property. + * + * @param blob Pointer to device tree blob + * @param node_offset Node DT offset + * @param in_addr Pointer to the address to translate + * @return translated address or OF_BAD_ADDR on error + */ u64 fdt_translate_address(const void *blob, int node_offset, const __be32 *in_addr); +/** + * Translate a DMA address from the DT into a CPU physical address + * + * The translation relies on the "dma-ranges" property. + * + * @param blob Pointer to device tree blob + * @param node_offset Node DT offset + * @param in_addr Pointer to the DMA address to translate + * @return translated DMA address or OF_BAD_ADDR on error + */ +u64 fdt_translate_dma_address(const void *blob, int node_offset, + const __be32 *in_addr); + int fdt_node_offset_by_compat_reg(void *blob, const char *compat, phys_addr_t compat_off); int fdt_alloc_phandle(void *blob); diff --git a/include/remoteproc.h b/include/remoteproc.h index a59dba8481..c29c0867bc 100644 --- a/include/remoteproc.h +++ b/include/remoteproc.h @@ -45,33 +45,86 @@ struct dm_rproc_uclass_pdata { }; /** - * struct dm_rproc_ops - Operations that are provided by remote proc driver - * @init: Initialize the remoteproc device invoked after probe (optional) - * Return 0 on success, -ve error on fail - * @load: Load the remoteproc device using data provided(mandatory) - * This takes the following additional arguments. - * addr- Address of the binary image to be loaded - * size- Size of the binary image to be loaded - * Return 0 on success, -ve error on fail - * @start: Start the remoteproc device (mandatory) - * Return 0 on success, -ve error on fail - * @stop: Stop the remoteproc device (optional) - * Return 0 on success, -ve error on fail - * @reset: Reset the remote proc device (optional) - * Return 0 on success, -ve error on fail - * @is_running: Check if the remote processor is running(optional) - * Return 0 on success, 1 if not running, -ve on others errors - * @ping: Ping the remote device for basic communication check(optional) - * Return 0 on success, 1 if not responding, -ve on other errors + * struct dm_rproc_ops - Driver model remote proc operations. + * + * This defines the operations provided by remote proc driver. */ struct dm_rproc_ops { + /** + * init() - Initialize the remoteproc device (optional) + * + * This is called after the probe is completed allowing the remote + * processor drivers to split up the initializations between probe and + * init if needed. + * + * @dev: Remote proc device + * @return 0 if all ok, else appropriate error value. + */ int (*init)(struct udevice *dev); + + /** + * load() - Load the remoteproc device using data provided (mandatory) + * + * Load the remoteproc device with an image, do not start the device. + * + * @dev: Remote proc device + * @addr: Address of the image to be loaded + * @size: Size of the image to be loaded + * @return 0 if all ok, else appropriate error value. + */ int (*load)(struct udevice *dev, ulong addr, ulong size); + + /** + * start() - Start the remoteproc device (mandatory) + * + * @dev: Remote proc device + * @return 0 if all ok, else appropriate error value. + */ int (*start)(struct udevice *dev); + + /** + * stop() - Stop the remoteproc device (optional) + * + * @dev: Remote proc device + * @return 0 if all ok, else appropriate error value. + */ int (*stop)(struct udevice *dev); + + /** + * reset() - Reset the remoteproc device (optional) + * + * @dev: Remote proc device + * @return 0 if all ok, else appropriate error value. + */ int (*reset)(struct udevice *dev); + + /** + * is_running() - Check if the remote processor is running (optional) + * + * @dev: Remote proc device + * @return 0 if running, 1 if not running, -ve on error. + */ int (*is_running)(struct udevice *dev); + + /** + * ping() - Ping the remote device for basic communication (optional) + * + * @dev: Remote proc device + * @return 0 on success, 1 if not responding, -ve on other errors. + */ int (*ping)(struct udevice *dev); + + /** + * device_to_virt() - Return translated virtual address (optional) + * + * Translate a device address (remote processor view) to virtual + * address (main processor view). + * + * @dev: Remote proc device + * @da: Device address + * @return virtual address. + */ + void * (*device_to_virt)(struct udevice *dev, ulong da); }; /* Accessor */ @@ -80,82 +133,93 @@ struct dm_rproc_ops { #ifdef CONFIG_REMOTEPROC /** * rproc_init() - Initialize all bound remote proc devices - * - * Return: 0 if all ok, else appropriate error value. + * @return 0 if all ok, else appropriate error value. */ int rproc_init(void); /** * rproc_dev_init() - Initialize a remote proc device based on id * @id: id of the remote processor - * - * Return: 0 if all ok, else appropriate error value. + * @return 0 if all ok, else appropriate error value. */ int rproc_dev_init(int id); /** * rproc_is_initialized() - check to see if remoteproc devices are initialized - * - * Return: 0 if all devices are initialized, else appropriate error value. + * @return true if all devices are initialized, false otherwise. */ bool rproc_is_initialized(void); /** - * rproc_load() - load binary to a remote processor + * rproc_load() - load binary or elf to a remote processor * @id: id of the remote processor - * @addr: address in memory where the binary image is located - * @size: size of the binary image - * - * Return: 0 if all ok, else appropriate error value. + * @addr: address in memory where the image is located + * @size: size of the image + * @return 0 if all ok, else appropriate error value. */ int rproc_load(int id, ulong addr, ulong size); /** * rproc_start() - Start a remote processor * @id: id of the remote processor - * - * Return: 0 if all ok, else appropriate error value. + * @return 0 if all ok, else appropriate error value. */ int rproc_start(int id); /** * rproc_stop() - Stop a remote processor * @id: id of the remote processor - * - * Return: 0 if all ok, else appropriate error value. + * @return 0 if all ok, else appropriate error value. */ int rproc_stop(int id); /** * rproc_reset() - reset a remote processor * @id: id of the remote processor - * - * Return: 0 if all ok, else appropriate error value. + * @return 0 if all ok, else appropriate error value. */ int rproc_reset(int id); /** * rproc_ping() - ping a remote processor to check if it can communicate * @id: id of the remote processor + * @return 0 if all ok, else appropriate error value. * * NOTE: this might need communication path available, which is not implemented * as part of remoteproc framework - hook on to appropriate bus architecture to * do the same - * - * Return: 0 if all ok, else appropriate error value. */ int rproc_ping(int id); /** * rproc_is_running() - check to see if remote processor is running * @id: id of the remote processor + * @return 0 if running, 1 if not running, -ve on error. * * NOTE: this may not involve actual communication capability of the remote * processor, but just ensures that it is out of reset and executing code. - * - * Return: 0 if all ok, else appropriate error value. */ int rproc_is_running(int id); + +/** + * rproc_elf32_sanity_check() - Verify if an image is a valid ELF32 one + * + * Check if a valid ELF32 image exists at the given memory location. Verify + * basic ELF32 format requirements like magic number and sections size. + * + * @addr: address of the image to verify + * @size: size of the image + * @return 0 if the image looks good, else appropriate error value. + */ +int rproc_elf32_sanity_check(ulong addr, ulong size); + +/** + * rproc_elf32_load_image() - load an ELF32 image + * @dev: device loading the ELF32 image + * @addr: valid ELF32 image address + * @return 0 if the image is successfully loaded, else appropriate error value. + */ +int rproc_elf32_load_image(struct udevice *dev, unsigned long addr); #else static inline int rproc_init(void) { return -ENOSYS; } static inline int rproc_dev_init(int id) { return -ENOSYS; } @@ -166,6 +230,10 @@ static inline int rproc_stop(int id) { return -ENOSYS; } static inline int rproc_reset(int id) { return -ENOSYS; } static inline int rproc_ping(int id) { return -ENOSYS; } static inline int rproc_is_running(int id) { return -ENOSYS; } +static inline int rproc_elf32_sanity_check(ulong addr, + ulong size) { return -ENOSYS; } +static inline int rproc_elf32_load_image(struct udevice *dev, + unsigned long addr) { return -ENOSYS; } #endif #endif /* _RPROC_H_ */ |