diff options
| author | Bjorn Andersson <bjorn.andersson@linaro.org> | 2018-01-05 18:58:01 -0500 |
|---|---|---|
| committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2018-01-15 12:29:40 -0500 |
| commit | 0f21f9cc9d868784c7564edc0cfeddd25ca9621a (patch) | |
| tree | 4529534ba2c028abd340bf7f47ba9646eb838091 | |
| parent | fb98e2bdbd5f5949459dcfe9976bdafdb0ed1948 (diff) | |
remoteproc: Merge rproc_ops and rproc_fw_ops
There are currently a few different schemes used for overriding fw_ops
or parts of fw_ops. Merge fw_ops into rproc_ops and expose the default
ELF-loader symbols so that they can be assigned by the drivers.
To keep backwards compatibility with the "default" case, a driver not
specifying the "load" operation is assumed to want the full ELF-loader
suit of functions.
Reviewed-By: Loic Pallardy <loic.pallardy@st.com>
Tested-By: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
| -rw-r--r-- | drivers/remoteproc/qcom_adsp_pil.c | 9 | ||||
| -rw-r--r-- | drivers/remoteproc/qcom_q6v5_pil.c | 9 | ||||
| -rw-r--r-- | drivers/remoteproc/qcom_wcnss.c | 9 | ||||
| -rw-r--r-- | drivers/remoteproc/remoteproc_core.c | 10 | ||||
| -rw-r--r-- | drivers/remoteproc/remoteproc_elf_loader.c | 30 | ||||
| -rw-r--r-- | drivers/remoteproc/remoteproc_internal.h | 51 | ||||
| -rw-r--r-- | drivers/remoteproc/st_slim_rproc.c | 22 | ||||
| -rw-r--r-- | include/linux/remoteproc.h | 17 |
8 files changed, 67 insertions, 90 deletions
diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c index 3f6af54dbc96..56156c12bd73 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c | |||
| @@ -85,11 +85,6 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw) | |||
| 85 | adsp->mem_region, adsp->mem_phys, adsp->mem_size); | 85 | adsp->mem_region, adsp->mem_phys, adsp->mem_size); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | static const struct rproc_fw_ops adsp_fw_ops = { | ||
| 89 | .find_rsc_table = qcom_mdt_find_rsc_table, | ||
| 90 | .load = adsp_load, | ||
| 91 | }; | ||
| 92 | |||
| 93 | static int adsp_start(struct rproc *rproc) | 88 | static int adsp_start(struct rproc *rproc) |
| 94 | { | 89 | { |
| 95 | struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; | 90 | struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; |
| @@ -182,6 +177,8 @@ static const struct rproc_ops adsp_ops = { | |||
| 182 | .start = adsp_start, | 177 | .start = adsp_start, |
| 183 | .stop = adsp_stop, | 178 | .stop = adsp_stop, |
| 184 | .da_to_va = adsp_da_to_va, | 179 | .da_to_va = adsp_da_to_va, |
| 180 | .find_rsc_table = qcom_mdt_find_rsc_table, | ||
| 181 | .load = adsp_load, | ||
| 185 | }; | 182 | }; |
| 186 | 183 | ||
| 187 | static irqreturn_t adsp_wdog_interrupt(int irq, void *dev) | 184 | static irqreturn_t adsp_wdog_interrupt(int irq, void *dev) |
| @@ -344,8 +341,6 @@ static int adsp_probe(struct platform_device *pdev) | |||
| 344 | return -ENOMEM; | 341 | return -ENOMEM; |
| 345 | } | 342 | } |
| 346 | 343 | ||
| 347 | rproc->fw_ops = &adsp_fw_ops; | ||
| 348 | |||
| 349 | adsp = (struct qcom_adsp *)rproc->priv; | 344 | adsp = (struct qcom_adsp *)rproc->priv; |
| 350 | adsp->dev = &pdev->dev; | 345 | adsp->dev = &pdev->dev; |
| 351 | adsp->rproc = rproc; | 346 | adsp->rproc = rproc; |
diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c index 8a3fa2bcc9f6..3ea668d9fd4c 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c | |||
| @@ -342,11 +342,6 @@ static int q6v5_load(struct rproc *rproc, const struct firmware *fw) | |||
| 342 | return 0; | 342 | return 0; |
| 343 | } | 343 | } |
| 344 | 344 | ||
| 345 | static const struct rproc_fw_ops q6v5_fw_ops = { | ||
| 346 | .find_rsc_table = q6v5_find_rsc_table, | ||
| 347 | .load = q6v5_load, | ||
| 348 | }; | ||
| 349 | |||
| 350 | static int q6v5_rmb_pbl_wait(struct q6v5 *qproc, int ms) | 345 | static int q6v5_rmb_pbl_wait(struct q6v5 *qproc, int ms) |
| 351 | { | 346 | { |
| 352 | unsigned long timeout; | 347 | unsigned long timeout; |
| @@ -931,6 +926,8 @@ static const struct rproc_ops q6v5_ops = { | |||
| 931 | .start = q6v5_start, | 926 | .start = q6v5_start, |
| 932 | .stop = q6v5_stop, | 927 | .stop = q6v5_stop, |
| 933 | .da_to_va = q6v5_da_to_va, | 928 | .da_to_va = q6v5_da_to_va, |
| 929 | .find_rsc_table = q6v5_find_rsc_table, | ||
| 930 | .load = q6v5_load, | ||
| 934 | }; | 931 | }; |
| 935 | 932 | ||
| 936 | static irqreturn_t q6v5_wdog_interrupt(int irq, void *dev) | 933 | static irqreturn_t q6v5_wdog_interrupt(int irq, void *dev) |
| @@ -1150,8 +1147,6 @@ static int q6v5_probe(struct platform_device *pdev) | |||
| 1150 | return -ENOMEM; | 1147 | return -ENOMEM; |
| 1151 | } | 1148 | } |
| 1152 | 1149 | ||
| 1153 | rproc->fw_ops = &q6v5_fw_ops; | ||
| 1154 | |||
| 1155 | qproc = (struct q6v5 *)rproc->priv; | 1150 | qproc = (struct q6v5 *)rproc->priv; |
| 1156 | qproc->dev = &pdev->dev; | 1151 | qproc->dev = &pdev->dev; |
| 1157 | qproc->rproc = rproc; | 1152 | qproc->rproc = rproc; |
diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c index c7686393d505..e53fc6f268fc 100644 --- a/drivers/remoteproc/qcom_wcnss.c +++ b/drivers/remoteproc/qcom_wcnss.c | |||
| @@ -156,11 +156,6 @@ static int wcnss_load(struct rproc *rproc, const struct firmware *fw) | |||
| 156 | wcnss->mem_region, wcnss->mem_phys, wcnss->mem_size); | 156 | wcnss->mem_region, wcnss->mem_phys, wcnss->mem_size); |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | static const struct rproc_fw_ops wcnss_fw_ops = { | ||
| 160 | .find_rsc_table = qcom_mdt_find_rsc_table, | ||
| 161 | .load = wcnss_load, | ||
| 162 | }; | ||
| 163 | |||
| 164 | static void wcnss_indicate_nv_download(struct qcom_wcnss *wcnss) | 159 | static void wcnss_indicate_nv_download(struct qcom_wcnss *wcnss) |
| 165 | { | 160 | { |
| 166 | u32 val; | 161 | u32 val; |
| @@ -313,6 +308,8 @@ static const struct rproc_ops wcnss_ops = { | |||
| 313 | .start = wcnss_start, | 308 | .start = wcnss_start, |
| 314 | .stop = wcnss_stop, | 309 | .stop = wcnss_stop, |
| 315 | .da_to_va = wcnss_da_to_va, | 310 | .da_to_va = wcnss_da_to_va, |
| 311 | .find_rsc_table = qcom_mdt_find_rsc_table, | ||
| 312 | .load = wcnss_load, | ||
| 316 | }; | 313 | }; |
| 317 | 314 | ||
| 318 | static irqreturn_t wcnss_wdog_interrupt(int irq, void *dev) | 315 | static irqreturn_t wcnss_wdog_interrupt(int irq, void *dev) |
| @@ -492,8 +489,6 @@ static int wcnss_probe(struct platform_device *pdev) | |||
| 492 | return -ENOMEM; | 489 | return -ENOMEM; |
| 493 | } | 490 | } |
| 494 | 491 | ||
| 495 | rproc->fw_ops = &wcnss_fw_ops; | ||
| 496 | |||
| 497 | wcnss = (struct qcom_wcnss *)rproc->priv; | 492 | wcnss = (struct qcom_wcnss *)rproc->priv; |
| 498 | wcnss->dev = &pdev->dev; | 493 | wcnss->dev = &pdev->dev; |
| 499 | wcnss->rproc = rproc; | 494 | wcnss->rproc = rproc; |
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index dbf685dbafcf..2c669a73e77d 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c | |||
| @@ -1437,8 +1437,14 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, | |||
| 1437 | 1437 | ||
| 1438 | atomic_set(&rproc->power, 0); | 1438 | atomic_set(&rproc->power, 0); |
| 1439 | 1439 | ||
| 1440 | /* Set ELF as the default fw_ops handler */ | 1440 | /* Default to ELF loader if no load function is specified */ |
| 1441 | rproc->fw_ops = &rproc_elf_fw_ops; | 1441 | if (!rproc->ops->load) { |
| 1442 | rproc->ops->load = rproc_elf_load_segments; | ||
| 1443 | rproc->ops->find_rsc_table = rproc_elf_find_rsc_table; | ||
| 1444 | rproc->ops->find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table; | ||
| 1445 | rproc->ops->sanity_check = rproc_elf_sanity_check; | ||
| 1446 | rproc->ops->get_boot_addr = rproc_elf_get_boot_addr; | ||
| 1447 | } | ||
| 1442 | 1448 | ||
| 1443 | mutex_init(&rproc->lock); | 1449 | mutex_init(&rproc->lock); |
| 1444 | 1450 | ||
diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c index c523983a4aec..822fa1bf893f 100644 --- a/drivers/remoteproc/remoteproc_elf_loader.c +++ b/drivers/remoteproc/remoteproc_elf_loader.c | |||
| @@ -39,8 +39,7 @@ | |||
| 39 | * | 39 | * |
| 40 | * Make sure this fw image is sane. | 40 | * Make sure this fw image is sane. |
| 41 | */ | 41 | */ |
| 42 | static int | 42 | int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) |
| 43 | rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) | ||
| 44 | { | 43 | { |
| 45 | const char *name = rproc->firmware; | 44 | const char *name = rproc->firmware; |
| 46 | struct device *dev = &rproc->dev; | 45 | struct device *dev = &rproc->dev; |
| @@ -98,6 +97,7 @@ rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) | |||
| 98 | 97 | ||
| 99 | return 0; | 98 | return 0; |
| 100 | } | 99 | } |
| 100 | EXPORT_SYMBOL(rproc_elf_sanity_check); | ||
| 101 | 101 | ||
| 102 | /** | 102 | /** |
| 103 | * rproc_elf_get_boot_addr() - Get rproc's boot address. | 103 | * rproc_elf_get_boot_addr() - Get rproc's boot address. |
| @@ -110,13 +110,13 @@ rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) | |||
| 110 | * Note that the boot address is not a configurable property of all remote | 110 | * Note that the boot address is not a configurable property of all remote |
| 111 | * processors. Some will always boot at a specific hard-coded address. | 111 | * processors. Some will always boot at a specific hard-coded address. |
| 112 | */ | 112 | */ |
| 113 | static | ||
| 114 | u32 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw) | 113 | u32 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw) |
| 115 | { | 114 | { |
| 116 | struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data; | 115 | struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data; |
| 117 | 116 | ||
| 118 | return ehdr->e_entry; | 117 | return ehdr->e_entry; |
| 119 | } | 118 | } |
| 119 | EXPORT_SYMBOL(rproc_elf_get_boot_addr); | ||
| 120 | 120 | ||
| 121 | /** | 121 | /** |
| 122 | * rproc_elf_load_segments() - load firmware segments to memory | 122 | * rproc_elf_load_segments() - load firmware segments to memory |
| @@ -142,8 +142,7 @@ u32 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw) | |||
| 142 | * directly allocate memory for every segment/resource. This is not yet | 142 | * directly allocate memory for every segment/resource. This is not yet |
| 143 | * supported, though. | 143 | * supported, though. |
| 144 | */ | 144 | */ |
| 145 | static int | 145 | int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) |
| 146 | rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) | ||
| 147 | { | 146 | { |
| 148 | struct device *dev = &rproc->dev; | 147 | struct device *dev = &rproc->dev; |
| 149 | struct elf32_hdr *ehdr; | 148 | struct elf32_hdr *ehdr; |
| @@ -207,6 +206,7 @@ rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) | |||
| 207 | 206 | ||
| 208 | return ret; | 207 | return ret; |
| 209 | } | 208 | } |
| 209 | EXPORT_SYMBOL(rproc_elf_load_segments); | ||
| 210 | 210 | ||
| 211 | static struct elf32_shdr * | 211 | static struct elf32_shdr * |
| 212 | find_table(struct device *dev, struct elf32_hdr *ehdr, size_t fw_size) | 212 | find_table(struct device *dev, struct elf32_hdr *ehdr, size_t fw_size) |
| @@ -282,9 +282,9 @@ find_table(struct device *dev, struct elf32_hdr *ehdr, size_t fw_size) | |||
| 282 | * size into @tablesz. If a valid table isn't found, NULL is returned | 282 | * size into @tablesz. If a valid table isn't found, NULL is returned |
| 283 | * (and @tablesz isn't set). | 283 | * (and @tablesz isn't set). |
| 284 | */ | 284 | */ |
| 285 | static struct resource_table * | 285 | struct resource_table *rproc_elf_find_rsc_table(struct rproc *rproc, |
| 286 | rproc_elf_find_rsc_table(struct rproc *rproc, const struct firmware *fw, | 286 | const struct firmware *fw, |
| 287 | int *tablesz) | 287 | int *tablesz) |
| 288 | { | 288 | { |
| 289 | struct elf32_hdr *ehdr; | 289 | struct elf32_hdr *ehdr; |
| 290 | struct elf32_shdr *shdr; | 290 | struct elf32_shdr *shdr; |
| @@ -303,6 +303,7 @@ rproc_elf_find_rsc_table(struct rproc *rproc, const struct firmware *fw, | |||
| 303 | 303 | ||
| 304 | return table; | 304 | return table; |
| 305 | } | 305 | } |
| 306 | EXPORT_SYMBOL(rproc_elf_find_rsc_table); | ||
| 306 | 307 | ||
| 307 | /** | 308 | /** |
| 308 | * rproc_elf_find_loaded_rsc_table() - find the loaded resource table | 309 | * rproc_elf_find_loaded_rsc_table() - find the loaded resource table |
| @@ -315,8 +316,8 @@ rproc_elf_find_rsc_table(struct rproc *rproc, const struct firmware *fw, | |||
| 315 | * Returns the pointer to the resource table if it is found or NULL otherwise. | 316 | * Returns the pointer to the resource table if it is found or NULL otherwise. |
| 316 | * If the table wasn't loaded yet the result is unspecified. | 317 | * If the table wasn't loaded yet the result is unspecified. |
| 317 | */ | 318 | */ |
| 318 | static struct resource_table * | 319 | struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, |
| 319 | rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw) | 320 | const struct firmware *fw) |
| 320 | { | 321 | { |
| 321 | struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data; | 322 | struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data; |
| 322 | struct elf32_shdr *shdr; | 323 | struct elf32_shdr *shdr; |
| @@ -327,11 +328,4 @@ rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw) | |||
| 327 | 328 | ||
| 328 | return rproc_da_to_va(rproc, shdr->sh_addr, shdr->sh_size); | 329 | return rproc_da_to_va(rproc, shdr->sh_addr, shdr->sh_size); |
| 329 | } | 330 | } |
| 330 | 331 | EXPORT_SYMBOL(rproc_elf_find_loaded_rsc_table); | |
| 331 | const struct rproc_fw_ops rproc_elf_fw_ops = { | ||
| 332 | .load = rproc_elf_load_segments, | ||
| 333 | .find_rsc_table = rproc_elf_find_rsc_table, | ||
| 334 | .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, | ||
| 335 | .sanity_check = rproc_elf_sanity_check, | ||
| 336 | .get_boot_addr = rproc_elf_get_boot_addr | ||
| 337 | }; | ||
diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index c1077bec5d0b..a42690c514e2 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h | |||
| @@ -25,26 +25,6 @@ | |||
| 25 | 25 | ||
| 26 | struct rproc; | 26 | struct rproc; |
| 27 | 27 | ||
| 28 | /** | ||
| 29 | * struct rproc_fw_ops - firmware format specific operations. | ||
| 30 | * @find_rsc_table: find the resource table inside the firmware image | ||
| 31 | * @find_loaded_rsc_table: find the loaded resouce table | ||
| 32 | * @load: load firmeware to memory, where the remote processor | ||
| 33 | * expects to find it | ||
| 34 | * @sanity_check: sanity check the fw image | ||
| 35 | * @get_boot_addr: get boot address to entry point specified in firmware | ||
| 36 | */ | ||
| 37 | struct rproc_fw_ops { | ||
| 38 | struct resource_table *(*find_rsc_table)(struct rproc *rproc, | ||
| 39 | const struct firmware *fw, | ||
| 40 | int *tablesz); | ||
| 41 | struct resource_table *(*find_loaded_rsc_table)( | ||
| 42 | struct rproc *rproc, const struct firmware *fw); | ||
| 43 | int (*load)(struct rproc *rproc, const struct firmware *fw); | ||
| 44 | int (*sanity_check)(struct rproc *rproc, const struct firmware *fw); | ||
| 45 | u32 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw); | ||
| 46 | }; | ||
| 47 | |||
| 48 | /* from remoteproc_core.c */ | 28 | /* from remoteproc_core.c */ |
| 49 | void rproc_release(struct kref *kref); | 29 | void rproc_release(struct kref *kref); |
| 50 | irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); | 30 | irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); |
| @@ -74,11 +54,20 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i); | |||
| 74 | void *rproc_da_to_va(struct rproc *rproc, u64 da, int len); | 54 | void *rproc_da_to_va(struct rproc *rproc, u64 da, int len); |
| 75 | int rproc_trigger_recovery(struct rproc *rproc); | 55 | int rproc_trigger_recovery(struct rproc *rproc); |
| 76 | 56 | ||
| 57 | 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); | ||
| 59 | int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw); | ||
| 60 | struct resource_table *rproc_elf_find_rsc_table(struct rproc *rproc, | ||
| 61 | const struct firmware *fw, | ||
| 62 | int *tablesz); | ||
| 63 | struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, | ||
| 64 | const struct firmware *fw); | ||
| 65 | |||
| 77 | static inline | 66 | static inline |
| 78 | int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) | 67 | int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) |
| 79 | { | 68 | { |
| 80 | if (rproc->fw_ops->sanity_check) | 69 | if (rproc->ops->sanity_check) |
| 81 | return rproc->fw_ops->sanity_check(rproc, fw); | 70 | return rproc->ops->sanity_check(rproc, fw); |
| 82 | 71 | ||
| 83 | return 0; | 72 | return 0; |
| 84 | } | 73 | } |
| @@ -86,8 +75,8 @@ int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) | |||
| 86 | static inline | 75 | static inline |
| 87 | u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) | 76 | u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) |
| 88 | { | 77 | { |
| 89 | if (rproc->fw_ops->get_boot_addr) | 78 | if (rproc->ops->get_boot_addr) |
| 90 | return rproc->fw_ops->get_boot_addr(rproc, fw); | 79 | return rproc->ops->get_boot_addr(rproc, fw); |
| 91 | 80 | ||
| 92 | return 0; | 81 | return 0; |
| 93 | } | 82 | } |
| @@ -95,8 +84,8 @@ u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) | |||
| 95 | static inline | 84 | static inline |
| 96 | int rproc_load_segments(struct rproc *rproc, const struct firmware *fw) | 85 | int rproc_load_segments(struct rproc *rproc, const struct firmware *fw) |
| 97 | { | 86 | { |
| 98 | if (rproc->fw_ops->load) | 87 | if (rproc->ops->load) |
| 99 | return rproc->fw_ops->load(rproc, fw); | 88 | return rproc->ops->load(rproc, fw); |
| 100 | 89 | ||
| 101 | return -EINVAL; | 90 | return -EINVAL; |
| 102 | } | 91 | } |
| @@ -106,8 +95,8 @@ struct resource_table *rproc_find_rsc_table(struct rproc *rproc, | |||
| 106 | const struct firmware *fw, | 95 | const struct firmware *fw, |
| 107 | int *tablesz) | 96 | int *tablesz) |
| 108 | { | 97 | { |
| 109 | if (rproc->fw_ops->find_rsc_table) | 98 | if (rproc->ops->find_rsc_table) |
| 110 | return rproc->fw_ops->find_rsc_table(rproc, fw, tablesz); | 99 | return rproc->ops->find_rsc_table(rproc, fw, tablesz); |
| 111 | 100 | ||
| 112 | return NULL; | 101 | return NULL; |
| 113 | } | 102 | } |
| @@ -116,12 +105,10 @@ static inline | |||
| 116 | struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, | 105 | struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, |
| 117 | const struct firmware *fw) | 106 | const struct firmware *fw) |
| 118 | { | 107 | { |
| 119 | if (rproc->fw_ops->find_loaded_rsc_table) | 108 | if (rproc->ops->find_loaded_rsc_table) |
| 120 | return rproc->fw_ops->find_loaded_rsc_table(rproc, fw); | 109 | return rproc->ops->find_loaded_rsc_table(rproc, fw); |
| 121 | 110 | ||
| 122 | return NULL; | 111 | return NULL; |
| 123 | } | 112 | } |
| 124 | 113 | ||
| 125 | extern const struct rproc_fw_ops rproc_elf_fw_ops; | ||
| 126 | |||
| 127 | #endif /* REMOTEPROC_INTERNAL_H */ | 114 | #endif /* REMOTEPROC_INTERNAL_H */ |
diff --git a/drivers/remoteproc/st_slim_rproc.c b/drivers/remoteproc/st_slim_rproc.c index 6cfd862f945b..1bce63a06424 100644 --- a/drivers/remoteproc/st_slim_rproc.c +++ b/drivers/remoteproc/st_slim_rproc.c | |||
| @@ -200,12 +200,6 @@ static void *slim_rproc_da_to_va(struct rproc *rproc, u64 da, int len) | |||
| 200 | return va; | 200 | return va; |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | static const struct rproc_ops slim_rproc_ops = { | ||
| 204 | .start = slim_rproc_start, | ||
| 205 | .stop = slim_rproc_stop, | ||
| 206 | .da_to_va = slim_rproc_da_to_va, | ||
| 207 | }; | ||
| 208 | |||
| 209 | /* | 203 | /* |
| 210 | * Firmware handler operations: sanity, boot address, load ... | 204 | * Firmware handler operations: sanity, boot address, load ... |
| 211 | */ | 205 | */ |
| @@ -223,8 +217,14 @@ static struct resource_table *slim_rproc_find_rsc_table(struct rproc *rproc, | |||
| 223 | return &empty_rsc_tbl; | 217 | return &empty_rsc_tbl; |
| 224 | } | 218 | } |
| 225 | 219 | ||
| 226 | static struct rproc_fw_ops slim_rproc_fw_ops = { | 220 | static const struct rproc_ops slim_rproc_ops = { |
| 221 | .start = slim_rproc_start, | ||
| 222 | .stop = slim_rproc_stop, | ||
| 223 | .da_to_va = slim_rproc_da_to_va, | ||
| 227 | .find_rsc_table = slim_rproc_find_rsc_table, | 224 | .find_rsc_table = slim_rproc_find_rsc_table, |
| 225 | .get_boot_addr = rproc_elf_get_boot_addr, | ||
| 226 | .load = rproc_elf_load_segments, | ||
| 227 | .sanity_check = rproc_elf_sanity_check, | ||
| 228 | }; | 228 | }; |
| 229 | 229 | ||
| 230 | /** | 230 | /** |
| @@ -249,7 +249,6 @@ struct st_slim_rproc *st_slim_rproc_alloc(struct platform_device *pdev, | |||
| 249 | struct rproc *rproc; | 249 | struct rproc *rproc; |
| 250 | struct resource *res; | 250 | struct resource *res; |
| 251 | int err, i; | 251 | int err, i; |
| 252 | const struct rproc_fw_ops *elf_ops; | ||
| 253 | 252 | ||
| 254 | if (!fw_name) | 253 | if (!fw_name) |
| 255 | return ERR_PTR(-EINVAL); | 254 | return ERR_PTR(-EINVAL); |
| @@ -267,13 +266,6 @@ struct st_slim_rproc *st_slim_rproc_alloc(struct platform_device *pdev, | |||
| 267 | slim_rproc = rproc->priv; | 266 | slim_rproc = rproc->priv; |
| 268 | slim_rproc->rproc = rproc; | 267 | slim_rproc->rproc = rproc; |
| 269 | 268 | ||
| 270 | elf_ops = rproc->fw_ops; | ||
| 271 | /* Use some generic elf ops */ | ||
| 272 | slim_rproc_fw_ops.load = elf_ops->load; | ||
| 273 | slim_rproc_fw_ops.sanity_check = elf_ops->sanity_check; | ||
| 274 | |||
| 275 | rproc->fw_ops = &slim_rproc_fw_ops; | ||
| 276 | |||
| 277 | /* get imem and dmem */ | 269 | /* get imem and dmem */ |
| 278 | for (i = 0; i < ARRAY_SIZE(mem_names); i++) { | 270 | for (i = 0; i < ARRAY_SIZE(mem_names); i++) { |
| 279 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, | 271 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, |
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index cc4d30a790b3..ca2021cf7b39 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h | |||
| @@ -324,6 +324,7 @@ struct rproc_mem_entry { | |||
| 324 | }; | 324 | }; |
| 325 | 325 | ||
| 326 | struct rproc; | 326 | struct rproc; |
| 327 | struct firmware; | ||
| 327 | 328 | ||
| 328 | /** | 329 | /** |
| 329 | * struct rproc_ops - platform-specific device handlers | 330 | * struct rproc_ops - platform-specific device handlers |
| @@ -331,12 +332,26 @@ struct rproc; | |||
| 331 | * @stop: power off the device | 332 | * @stop: power off the device |
| 332 | * @kick: kick a virtqueue (virtqueue id given as a parameter) | 333 | * @kick: kick a virtqueue (virtqueue id given as a parameter) |
| 333 | * @da_to_va: optional platform hook to perform address translations | 334 | * @da_to_va: optional platform hook to perform address translations |
| 335 | * @find_rsc_table: find the resource table inside the firmware image | ||
| 336 | * @find_loaded_rsc_table: find the loaded resouce table | ||
| 337 | * @load: load firmeware to memory, where the remote processor | ||
| 338 | * expects to find it | ||
| 339 | * @sanity_check: sanity check the fw image | ||
| 340 | * @get_boot_addr: get boot address to entry point specified in firmware | ||
| 334 | */ | 341 | */ |
| 335 | struct rproc_ops { | 342 | struct rproc_ops { |
| 336 | int (*start)(struct rproc *rproc); | 343 | int (*start)(struct rproc *rproc); |
| 337 | int (*stop)(struct rproc *rproc); | 344 | int (*stop)(struct rproc *rproc); |
| 338 | void (*kick)(struct rproc *rproc, int vqid); | 345 | void (*kick)(struct rproc *rproc, int vqid); |
| 339 | void * (*da_to_va)(struct rproc *rproc, u64 da, int len); | 346 | void * (*da_to_va)(struct rproc *rproc, u64 da, int len); |
| 347 | struct resource_table *(*find_rsc_table)(struct rproc *rproc, | ||
| 348 | const struct firmware *fw, | ||
| 349 | int *tablesz); | ||
| 350 | struct resource_table *(*find_loaded_rsc_table)( | ||
| 351 | struct rproc *rproc, const struct firmware *fw); | ||
| 352 | int (*load)(struct rproc *rproc, const struct firmware *fw); | ||
| 353 | int (*sanity_check)(struct rproc *rproc, const struct firmware *fw); | ||
| 354 | u32 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw); | ||
| 340 | }; | 355 | }; |
| 341 | 356 | ||
| 342 | /** | 357 | /** |
| @@ -390,7 +405,6 @@ enum rproc_crash_type { | |||
| 390 | * @priv: private data which belongs to the platform-specific rproc module | 405 | * @priv: private data which belongs to the platform-specific rproc module |
| 391 | * @ops: platform-specific start/stop rproc handlers | 406 | * @ops: platform-specific start/stop rproc handlers |
| 392 | * @dev: virtual device for refcounting and common remoteproc behavior | 407 | * @dev: virtual device for refcounting and common remoteproc behavior |
| 393 | * @fw_ops: firmware-specific handlers | ||
| 394 | * @power: refcount of users who need this rproc powered up | 408 | * @power: refcount of users who need this rproc powered up |
| 395 | * @state: state of the device | 409 | * @state: state of the device |
| 396 | * @lock: lock which protects concurrent manipulations of the rproc | 410 | * @lock: lock which protects concurrent manipulations of the rproc |
| @@ -421,7 +435,6 @@ struct rproc { | |||
| 421 | void *priv; | 435 | void *priv; |
| 422 | struct rproc_ops *ops; | 436 | struct rproc_ops *ops; |
| 423 | struct device dev; | 437 | struct device dev; |
| 424 | const struct rproc_fw_ops *fw_ops; | ||
| 425 | atomic_t power; | 438 | atomic_t power; |
| 426 | unsigned int state; | 439 | unsigned int state; |
| 427 | struct mutex lock; | 440 | struct mutex lock; |
