| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Remote processor framework |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * Ohad Ben-Cohen <ohad@wizery.com> |
|---|
| 8 | 9 | * Brian Swetland <swetland@google.com> |
|---|
| 9 | | - * |
|---|
| 10 | | - * This software is licensed under the terms of the GNU General Public |
|---|
| 11 | | - * License version 2, as published by the Free Software Foundation, and |
|---|
| 12 | | - * may be copied, distributed, and modified under those terms. |
|---|
| 13 | | - * |
|---|
| 14 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | | - * GNU General Public License for more details. |
|---|
| 18 | 10 | */ |
|---|
| 19 | 11 | |
|---|
| 20 | 12 | #ifndef REMOTEPROC_INTERNAL_H |
|---|
| .. | .. |
|---|
| 25 | 17 | |
|---|
| 26 | 18 | struct rproc; |
|---|
| 27 | 19 | |
|---|
| 20 | +struct rproc_debug_trace { |
|---|
| 21 | + struct rproc *rproc; |
|---|
| 22 | + struct dentry *tfile; |
|---|
| 23 | + struct list_head node; |
|---|
| 24 | + struct rproc_mem_entry trace_mem; |
|---|
| 25 | +}; |
|---|
| 26 | + |
|---|
| 28 | 27 | /* from remoteproc_core.c */ |
|---|
| 29 | 28 | void rproc_release(struct kref *kref); |
|---|
| 30 | 29 | irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); |
|---|
| 31 | 30 | void rproc_vdev_release(struct kref *ref); |
|---|
| 31 | +int rproc_of_parse_firmware(struct device *dev, int index, |
|---|
| 32 | + const char **fw_name); |
|---|
| 32 | 33 | |
|---|
| 33 | 34 | /* from remoteproc_virtio.c */ |
|---|
| 34 | 35 | int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id); |
|---|
| 35 | | -void rproc_remove_virtio_dev(struct rproc_vdev *rvdev); |
|---|
| 36 | +int rproc_remove_virtio_dev(struct device *dev, void *data); |
|---|
| 36 | 37 | |
|---|
| 37 | 38 | /* from remoteproc_debugfs.c */ |
|---|
| 38 | 39 | void rproc_remove_trace_file(struct dentry *tfile); |
|---|
| 39 | 40 | struct dentry *rproc_create_trace_file(const char *name, struct rproc *rproc, |
|---|
| 40 | | - struct rproc_mem_entry *trace); |
|---|
| 41 | + struct rproc_debug_trace *trace); |
|---|
| 41 | 42 | void rproc_delete_debug_dir(struct rproc *rproc); |
|---|
| 42 | 43 | void rproc_create_debug_dir(struct rproc *rproc); |
|---|
| 43 | 44 | void rproc_init_debugfs(void); |
|---|
| .. | .. |
|---|
| 48 | 49 | int rproc_init_sysfs(void); |
|---|
| 49 | 50 | void rproc_exit_sysfs(void); |
|---|
| 50 | 51 | |
|---|
| 52 | +#ifdef CONFIG_REMOTEPROC_CDEV |
|---|
| 53 | +void rproc_init_cdev(void); |
|---|
| 54 | +void rproc_exit_cdev(void); |
|---|
| 55 | +int rproc_char_device_add(struct rproc *rproc); |
|---|
| 56 | +void rproc_char_device_remove(struct rproc *rproc); |
|---|
| 57 | +#else |
|---|
| 58 | +static inline void rproc_init_cdev(void) |
|---|
| 59 | +{ |
|---|
| 60 | +} |
|---|
| 61 | + |
|---|
| 62 | +static inline void rproc_exit_cdev(void) |
|---|
| 63 | +{ |
|---|
| 64 | +} |
|---|
| 65 | + |
|---|
| 66 | +/* |
|---|
| 67 | + * The character device interface is an optional feature, if it is not enabled |
|---|
| 68 | + * the function should not return an error. |
|---|
| 69 | + */ |
|---|
| 70 | +static inline int rproc_char_device_add(struct rproc *rproc) |
|---|
| 71 | +{ |
|---|
| 72 | + return 0; |
|---|
| 73 | +} |
|---|
| 74 | + |
|---|
| 75 | +static inline void rproc_char_device_remove(struct rproc *rproc) |
|---|
| 76 | +{ |
|---|
| 77 | +} |
|---|
| 78 | +#endif |
|---|
| 79 | + |
|---|
| 51 | 80 | void rproc_free_vring(struct rproc_vring *rvring); |
|---|
| 52 | 81 | int rproc_alloc_vring(struct rproc_vdev *rvdev, int i); |
|---|
| 53 | 82 | |
|---|
| 54 | | -void *rproc_da_to_va(struct rproc *rproc, u64 da, int len); |
|---|
| 83 | +void *rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem); |
|---|
| 84 | +phys_addr_t rproc_va_to_pa(void *cpu_addr); |
|---|
| 55 | 85 | int rproc_trigger_recovery(struct rproc *rproc); |
|---|
| 56 | 86 | |
|---|
| 57 | 87 | int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw); |
|---|
| 58 | | -u32 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw); |
|---|
| 88 | +u64 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw); |
|---|
| 59 | 89 | int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw); |
|---|
| 60 | 90 | int rproc_elf_load_rsc_table(struct rproc *rproc, const struct firmware *fw); |
|---|
| 61 | 91 | struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, |
|---|
| 62 | 92 | const struct firmware *fw); |
|---|
| 93 | +struct rproc_mem_entry * |
|---|
| 94 | +rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); |
|---|
| 95 | + |
|---|
| 96 | +static inline int rproc_prepare_device(struct rproc *rproc) |
|---|
| 97 | +{ |
|---|
| 98 | + if (rproc->ops->prepare) |
|---|
| 99 | + return rproc->ops->prepare(rproc); |
|---|
| 100 | + |
|---|
| 101 | + return 0; |
|---|
| 102 | +} |
|---|
| 103 | + |
|---|
| 104 | +static inline int rproc_unprepare_device(struct rproc *rproc) |
|---|
| 105 | +{ |
|---|
| 106 | + if (rproc->ops->unprepare) |
|---|
| 107 | + return rproc->ops->unprepare(rproc); |
|---|
| 108 | + |
|---|
| 109 | + return 0; |
|---|
| 110 | +} |
|---|
| 111 | + |
|---|
| 112 | +static inline int rproc_attach_device(struct rproc *rproc) |
|---|
| 113 | +{ |
|---|
| 114 | + if (rproc->ops->attach) |
|---|
| 115 | + return rproc->ops->attach(rproc); |
|---|
| 116 | + |
|---|
| 117 | + return 0; |
|---|
| 118 | +} |
|---|
| 63 | 119 | |
|---|
| 64 | 120 | static inline |
|---|
| 65 | 121 | int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) |
|---|
| .. | .. |
|---|
| 71 | 127 | } |
|---|
| 72 | 128 | |
|---|
| 73 | 129 | static inline |
|---|
| 74 | | -u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) |
|---|
| 130 | +u64 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) |
|---|
| 75 | 131 | { |
|---|
| 76 | 132 | if (rproc->ops->get_boot_addr) |
|---|
| 77 | 133 | return rproc->ops->get_boot_addr(rproc, fw); |
|---|
| .. | .. |
|---|
| 97 | 153 | } |
|---|
| 98 | 154 | |
|---|
| 99 | 155 | static inline |
|---|
| 156 | +int rproc_handle_rsc(struct rproc *rproc, u32 rsc_type, void *rsc, int offset, |
|---|
| 157 | + int avail) |
|---|
| 158 | +{ |
|---|
| 159 | + if (rproc->ops->handle_rsc) |
|---|
| 160 | + return rproc->ops->handle_rsc(rproc, rsc_type, rsc, offset, |
|---|
| 161 | + avail); |
|---|
| 162 | + |
|---|
| 163 | + return RSC_IGNORED; |
|---|
| 164 | +} |
|---|
| 165 | + |
|---|
| 166 | +static inline |
|---|
| 100 | 167 | struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, |
|---|
| 101 | 168 | const struct firmware *fw) |
|---|
| 102 | 169 | { |
|---|
| .. | .. |
|---|
| 106 | 173 | return NULL; |
|---|
| 107 | 174 | } |
|---|
| 108 | 175 | |
|---|
| 176 | +static inline |
|---|
| 177 | +bool rproc_u64_fit_in_size_t(u64 val) |
|---|
| 178 | +{ |
|---|
| 179 | + if (sizeof(size_t) == sizeof(u64)) |
|---|
| 180 | + return true; |
|---|
| 181 | + |
|---|
| 182 | + return (val <= (size_t) -1); |
|---|
| 183 | +} |
|---|
| 184 | + |
|---|
| 109 | 185 | #endif /* REMOTEPROC_INTERNAL_H */ |
|---|