Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (C) STMicroelectronics 2018 - All Rights Reserved |
| 4 | * Authors: Ludovic Barre <ludovic.barre@st.com> for STMicroelectronics. |
| 5 | * Fabien Dessenne <fabien.dessenne@st.com> for STMicroelectronics. |
| 6 | */ |
| 7 | |
| 8 | #include <linux/arm-smccc.h> |
| 9 | #include <linux/dma-mapping.h> |
| 10 | #include <linux/interrupt.h> |
| 11 | #include <linux/io.h> |
| 12 | #include <linux/mailbox_client.h> |
| 13 | #include <linux/mfd/syscon.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/of_address.h> |
| 16 | #include <linux/of_device.h> |
| 17 | #include <linux/of_reserved_mem.h> |
Fabien Dessenne | 410119e | 2019-08-26 17:38:43 +0200 | [diff] [blame] | 18 | #include <linux/pm_wakeirq.h> |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 19 | #include <linux/regmap.h> |
| 20 | #include <linux/remoteproc.h> |
| 21 | #include <linux/reset.h> |
Michael S. Tsirkin | bf02bd9 | 2020-04-09 17:09:35 -0400 | [diff] [blame] | 22 | #include <linux/slab.h> |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 23 | #include <linux/workqueue.h> |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 24 | |
| 25 | #include "remoteproc_internal.h" |
| 26 | |
| 27 | #define HOLD_BOOT 0 |
| 28 | #define RELEASE_BOOT 1 |
| 29 | |
| 30 | #define MBOX_NB_VQ 2 |
| 31 | #define MBOX_NB_MBX 3 |
| 32 | |
| 33 | #define STM32_SMC_RCC 0x82001000 |
| 34 | #define STM32_SMC_REG_WRITE 0x1 |
| 35 | |
| 36 | #define STM32_MBX_VQ0 "vq0" |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 37 | #define STM32_MBX_VQ0_ID 0 |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 38 | #define STM32_MBX_VQ1 "vq1" |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 39 | #define STM32_MBX_VQ1_ID 1 |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 40 | #define STM32_MBX_SHUTDOWN "shutdown" |
| 41 | |
Mathieu Poirier | 11a7aaa | 2020-07-14 14:04:43 -0600 | [diff] [blame^] | 42 | #define RSC_TBL_SIZE 1024 |
| 43 | |
Mathieu Poirier | 376ffdc | 2020-07-14 14:04:40 -0600 | [diff] [blame] | 44 | #define M4_STATE_OFF 0 |
| 45 | #define M4_STATE_INI 1 |
| 46 | #define M4_STATE_CRUN 2 |
| 47 | #define M4_STATE_CSTOP 3 |
| 48 | #define M4_STATE_STANDBY 4 |
| 49 | #define M4_STATE_CRASH 5 |
| 50 | |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 51 | struct stm32_syscon { |
| 52 | struct regmap *map; |
| 53 | u32 reg; |
| 54 | u32 mask; |
| 55 | }; |
| 56 | |
| 57 | struct stm32_rproc_mem { |
| 58 | char name[20]; |
| 59 | void __iomem *cpu_addr; |
| 60 | phys_addr_t bus_addr; |
| 61 | u32 dev_addr; |
| 62 | size_t size; |
| 63 | }; |
| 64 | |
| 65 | struct stm32_rproc_mem_ranges { |
| 66 | u32 dev_addr; |
| 67 | u32 bus_addr; |
| 68 | u32 size; |
| 69 | }; |
| 70 | |
| 71 | struct stm32_mbox { |
| 72 | const unsigned char name[10]; |
| 73 | struct mbox_chan *chan; |
| 74 | struct mbox_client client; |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 75 | struct work_struct vq_work; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 76 | int vq_id; |
| 77 | }; |
| 78 | |
| 79 | struct stm32_rproc { |
| 80 | struct reset_control *rst; |
| 81 | struct stm32_syscon hold_boot; |
| 82 | struct stm32_syscon pdds; |
Mathieu Poirier | 9276536 | 2020-07-14 14:04:39 -0600 | [diff] [blame] | 83 | struct stm32_syscon m4_state; |
| 84 | struct stm32_syscon rsctbl; |
Fabien Dessenne | 410119e | 2019-08-26 17:38:43 +0200 | [diff] [blame] | 85 | int wdg_irq; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 86 | u32 nb_rmems; |
| 87 | struct stm32_rproc_mem *rmems; |
| 88 | struct stm32_mbox mb[MBOX_NB_MBX]; |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 89 | struct workqueue_struct *workqueue; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 90 | bool secured_soc; |
Mathieu Poirier | 11a7aaa | 2020-07-14 14:04:43 -0600 | [diff] [blame^] | 91 | void __iomem *rsc_va; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | static int stm32_rproc_pa_to_da(struct rproc *rproc, phys_addr_t pa, u64 *da) |
| 95 | { |
| 96 | unsigned int i; |
| 97 | struct stm32_rproc *ddata = rproc->priv; |
| 98 | struct stm32_rproc_mem *p_mem; |
| 99 | |
| 100 | for (i = 0; i < ddata->nb_rmems; i++) { |
| 101 | p_mem = &ddata->rmems[i]; |
| 102 | |
| 103 | if (pa < p_mem->bus_addr || |
| 104 | pa >= p_mem->bus_addr + p_mem->size) |
| 105 | continue; |
| 106 | *da = pa - p_mem->bus_addr + p_mem->dev_addr; |
| 107 | dev_dbg(rproc->dev.parent, "pa %pa to da %llx\n", &pa, *da); |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | return -EINVAL; |
| 112 | } |
| 113 | |
| 114 | static int stm32_rproc_mem_alloc(struct rproc *rproc, |
| 115 | struct rproc_mem_entry *mem) |
| 116 | { |
| 117 | struct device *dev = rproc->dev.parent; |
| 118 | void *va; |
| 119 | |
| 120 | dev_dbg(dev, "map memory: %pa+%x\n", &mem->dma, mem->len); |
| 121 | va = ioremap_wc(mem->dma, mem->len); |
| 122 | if (IS_ERR_OR_NULL(va)) { |
| 123 | dev_err(dev, "Unable to map memory region: %pa+%x\n", |
| 124 | &mem->dma, mem->len); |
| 125 | return -ENOMEM; |
| 126 | } |
| 127 | |
| 128 | /* Update memory entry va */ |
| 129 | mem->va = va; |
| 130 | |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | static int stm32_rproc_mem_release(struct rproc *rproc, |
| 135 | struct rproc_mem_entry *mem) |
| 136 | { |
| 137 | dev_dbg(rproc->dev.parent, "unmap memory: %pa\n", &mem->dma); |
| 138 | iounmap(mem->va); |
| 139 | |
| 140 | return 0; |
| 141 | } |
| 142 | |
Mathieu Poirier | 7b9f18c | 2020-07-14 14:04:35 -0600 | [diff] [blame] | 143 | static int stm32_rproc_of_memory_translations(struct platform_device *pdev, |
| 144 | struct stm32_rproc *ddata) |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 145 | { |
Mathieu Poirier | 7b9f18c | 2020-07-14 14:04:35 -0600 | [diff] [blame] | 146 | struct device *parent, *dev = &pdev->dev; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 147 | struct device_node *np; |
| 148 | struct stm32_rproc_mem *p_mems; |
| 149 | struct stm32_rproc_mem_ranges *mem_range; |
| 150 | int cnt, array_size, i, ret = 0; |
| 151 | |
| 152 | parent = dev->parent; |
| 153 | np = parent->of_node; |
| 154 | |
| 155 | cnt = of_property_count_elems_of_size(np, "dma-ranges", |
| 156 | sizeof(*mem_range)); |
| 157 | if (cnt <= 0) { |
| 158 | dev_err(dev, "%s: dma-ranges property not defined\n", __func__); |
| 159 | return -EINVAL; |
| 160 | } |
| 161 | |
| 162 | p_mems = devm_kcalloc(dev, cnt, sizeof(*p_mems), GFP_KERNEL); |
| 163 | if (!p_mems) |
| 164 | return -ENOMEM; |
| 165 | mem_range = kcalloc(cnt, sizeof(*mem_range), GFP_KERNEL); |
| 166 | if (!mem_range) |
| 167 | return -ENOMEM; |
| 168 | |
| 169 | array_size = cnt * sizeof(struct stm32_rproc_mem_ranges) / sizeof(u32); |
| 170 | |
| 171 | ret = of_property_read_u32_array(np, "dma-ranges", |
| 172 | (u32 *)mem_range, array_size); |
| 173 | if (ret) { |
| 174 | dev_err(dev, "error while get dma-ranges property: %x\n", ret); |
| 175 | goto free_mem; |
| 176 | } |
| 177 | |
| 178 | for (i = 0; i < cnt; i++) { |
| 179 | p_mems[i].bus_addr = mem_range[i].bus_addr; |
| 180 | p_mems[i].dev_addr = mem_range[i].dev_addr; |
| 181 | p_mems[i].size = mem_range[i].size; |
| 182 | |
| 183 | dev_dbg(dev, "memory range[%i]: da %#x, pa %pa, size %#zx:\n", |
| 184 | i, p_mems[i].dev_addr, &p_mems[i].bus_addr, |
| 185 | p_mems[i].size); |
| 186 | } |
| 187 | |
| 188 | ddata->rmems = p_mems; |
| 189 | ddata->nb_rmems = cnt; |
| 190 | |
| 191 | free_mem: |
| 192 | kfree(mem_range); |
| 193 | return ret; |
| 194 | } |
| 195 | |
| 196 | static int stm32_rproc_mbox_idx(struct rproc *rproc, const unsigned char *name) |
| 197 | { |
| 198 | struct stm32_rproc *ddata = rproc->priv; |
| 199 | int i; |
| 200 | |
| 201 | for (i = 0; i < ARRAY_SIZE(ddata->mb); i++) { |
| 202 | if (!strncmp(ddata->mb[i].name, name, strlen(name))) |
| 203 | return i; |
| 204 | } |
| 205 | dev_err(&rproc->dev, "mailbox %s not found\n", name); |
| 206 | |
| 207 | return -EINVAL; |
| 208 | } |
| 209 | |
| 210 | static int stm32_rproc_elf_load_rsc_table(struct rproc *rproc, |
| 211 | const struct firmware *fw) |
| 212 | { |
| 213 | if (rproc_elf_load_rsc_table(rproc, fw)) |
| 214 | dev_warn(&rproc->dev, "no resource table found for this firmware\n"); |
| 215 | |
| 216 | return 0; |
| 217 | } |
| 218 | |
Mathieu Poirier | dadbdb9 | 2020-07-14 14:04:42 -0600 | [diff] [blame] | 219 | static int stm32_rproc_parse_memory_regions(struct rproc *rproc) |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 220 | { |
| 221 | struct device *dev = rproc->dev.parent; |
| 222 | struct device_node *np = dev->of_node; |
| 223 | struct of_phandle_iterator it; |
| 224 | struct rproc_mem_entry *mem; |
| 225 | struct reserved_mem *rmem; |
| 226 | u64 da; |
| 227 | int index = 0; |
| 228 | |
| 229 | /* Register associated reserved memory regions */ |
| 230 | of_phandle_iterator_init(&it, np, "memory-region", NULL, 0); |
| 231 | while (of_phandle_iterator_next(&it) == 0) { |
| 232 | rmem = of_reserved_mem_lookup(it.node); |
| 233 | if (!rmem) { |
| 234 | dev_err(dev, "unable to acquire memory-region\n"); |
| 235 | return -EINVAL; |
| 236 | } |
| 237 | |
| 238 | if (stm32_rproc_pa_to_da(rproc, rmem->base, &da) < 0) { |
| 239 | dev_err(dev, "memory region not valid %pa\n", |
| 240 | &rmem->base); |
| 241 | return -EINVAL; |
| 242 | } |
| 243 | |
| 244 | /* No need to map vdev buffer */ |
| 245 | if (strcmp(it.node->name, "vdev0buffer")) { |
| 246 | /* Register memory region */ |
| 247 | mem = rproc_mem_entry_init(dev, NULL, |
| 248 | (dma_addr_t)rmem->base, |
| 249 | rmem->size, da, |
| 250 | stm32_rproc_mem_alloc, |
| 251 | stm32_rproc_mem_release, |
| 252 | it.node->name); |
| 253 | |
| 254 | if (mem) |
| 255 | rproc_coredump_add_segment(rproc, da, |
| 256 | rmem->size); |
| 257 | } else { |
| 258 | /* Register reserved memory for vdev buffer alloc */ |
| 259 | mem = rproc_of_resm_mem_entry_init(dev, index, |
| 260 | rmem->size, |
| 261 | rmem->base, |
| 262 | it.node->name); |
| 263 | } |
| 264 | |
| 265 | if (!mem) |
| 266 | return -ENOMEM; |
| 267 | |
| 268 | rproc_add_carveout(rproc, mem); |
| 269 | index++; |
| 270 | } |
| 271 | |
Mathieu Poirier | dadbdb9 | 2020-07-14 14:04:42 -0600 | [diff] [blame] | 272 | return 0; |
| 273 | } |
| 274 | |
| 275 | static int stm32_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) |
| 276 | { |
| 277 | int ret = stm32_rproc_parse_memory_regions(rproc); |
| 278 | |
| 279 | if (ret) |
| 280 | return ret; |
| 281 | |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 282 | return stm32_rproc_elf_load_rsc_table(rproc, fw); |
| 283 | } |
| 284 | |
| 285 | static irqreturn_t stm32_rproc_wdg(int irq, void *data) |
| 286 | { |
Mathieu Poirier | b8631ab | 2020-07-14 14:04:36 -0600 | [diff] [blame] | 287 | struct platform_device *pdev = data; |
| 288 | struct rproc *rproc = platform_get_drvdata(pdev); |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 289 | |
| 290 | rproc_report_crash(rproc, RPROC_WATCHDOG); |
| 291 | |
| 292 | return IRQ_HANDLED; |
| 293 | } |
| 294 | |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 295 | static void stm32_rproc_mb_vq_work(struct work_struct *work) |
| 296 | { |
| 297 | struct stm32_mbox *mb = container_of(work, struct stm32_mbox, vq_work); |
| 298 | struct rproc *rproc = dev_get_drvdata(mb->client.dev); |
| 299 | |
| 300 | if (rproc_vq_interrupt(rproc, mb->vq_id) == IRQ_NONE) |
| 301 | dev_dbg(&rproc->dev, "no message found in vq%d\n", mb->vq_id); |
| 302 | } |
| 303 | |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 304 | static void stm32_rproc_mb_callback(struct mbox_client *cl, void *data) |
| 305 | { |
| 306 | struct rproc *rproc = dev_get_drvdata(cl->dev); |
| 307 | struct stm32_mbox *mb = container_of(cl, struct stm32_mbox, client); |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 308 | struct stm32_rproc *ddata = rproc->priv; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 309 | |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 310 | queue_work(ddata->workqueue, &mb->vq_work); |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | static void stm32_rproc_free_mbox(struct rproc *rproc) |
| 314 | { |
| 315 | struct stm32_rproc *ddata = rproc->priv; |
| 316 | unsigned int i; |
| 317 | |
| 318 | for (i = 0; i < ARRAY_SIZE(ddata->mb); i++) { |
| 319 | if (ddata->mb[i].chan) |
| 320 | mbox_free_channel(ddata->mb[i].chan); |
| 321 | ddata->mb[i].chan = NULL; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | static const struct stm32_mbox stm32_rproc_mbox[MBOX_NB_MBX] = { |
| 326 | { |
| 327 | .name = STM32_MBX_VQ0, |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 328 | .vq_id = STM32_MBX_VQ0_ID, |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 329 | .client = { |
| 330 | .rx_callback = stm32_rproc_mb_callback, |
| 331 | .tx_block = false, |
| 332 | }, |
| 333 | }, |
| 334 | { |
| 335 | .name = STM32_MBX_VQ1, |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 336 | .vq_id = STM32_MBX_VQ1_ID, |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 337 | .client = { |
| 338 | .rx_callback = stm32_rproc_mb_callback, |
| 339 | .tx_block = false, |
| 340 | }, |
| 341 | }, |
| 342 | { |
| 343 | .name = STM32_MBX_SHUTDOWN, |
| 344 | .vq_id = -1, |
| 345 | .client = { |
| 346 | .tx_block = true, |
| 347 | .tx_done = NULL, |
| 348 | .tx_tout = 500, /* 500 ms time out */ |
| 349 | }, |
| 350 | } |
| 351 | }; |
| 352 | |
Fabien Dessenne | 4a56e423 | 2019-11-15 11:03:08 +0100 | [diff] [blame] | 353 | static int stm32_rproc_request_mbox(struct rproc *rproc) |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 354 | { |
| 355 | struct stm32_rproc *ddata = rproc->priv; |
| 356 | struct device *dev = &rproc->dev; |
| 357 | unsigned int i; |
Fabien Dessenne | 4a56e423 | 2019-11-15 11:03:08 +0100 | [diff] [blame] | 358 | int j; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 359 | const unsigned char *name; |
| 360 | struct mbox_client *cl; |
| 361 | |
| 362 | /* Initialise mailbox structure table */ |
| 363 | memcpy(ddata->mb, stm32_rproc_mbox, sizeof(stm32_rproc_mbox)); |
| 364 | |
| 365 | for (i = 0; i < MBOX_NB_MBX; i++) { |
| 366 | name = ddata->mb[i].name; |
| 367 | |
| 368 | cl = &ddata->mb[i].client; |
| 369 | cl->dev = dev->parent; |
| 370 | |
| 371 | ddata->mb[i].chan = mbox_request_channel_byname(cl, name); |
| 372 | if (IS_ERR(ddata->mb[i].chan)) { |
Fabien Dessenne | 4a56e423 | 2019-11-15 11:03:08 +0100 | [diff] [blame] | 373 | if (PTR_ERR(ddata->mb[i].chan) == -EPROBE_DEFER) |
| 374 | goto err_probe; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 375 | dev_warn(dev, "cannot get %s mbox\n", name); |
| 376 | ddata->mb[i].chan = NULL; |
| 377 | } |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 378 | if (ddata->mb[i].vq_id >= 0) { |
| 379 | INIT_WORK(&ddata->mb[i].vq_work, |
| 380 | stm32_rproc_mb_vq_work); |
| 381 | } |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 382 | } |
Fabien Dessenne | 4a56e423 | 2019-11-15 11:03:08 +0100 | [diff] [blame] | 383 | |
| 384 | return 0; |
| 385 | |
| 386 | err_probe: |
| 387 | for (j = i - 1; j >= 0; j--) |
| 388 | if (ddata->mb[j].chan) |
| 389 | mbox_free_channel(ddata->mb[j].chan); |
| 390 | return -EPROBE_DEFER; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | static int stm32_rproc_set_hold_boot(struct rproc *rproc, bool hold) |
| 394 | { |
| 395 | struct stm32_rproc *ddata = rproc->priv; |
| 396 | struct stm32_syscon hold_boot = ddata->hold_boot; |
| 397 | struct arm_smccc_res smc_res; |
| 398 | int val, err; |
| 399 | |
| 400 | val = hold ? HOLD_BOOT : RELEASE_BOOT; |
| 401 | |
Arnd Bergmann | 93f1d3e | 2019-07-08 14:42:51 +0200 | [diff] [blame] | 402 | if (IS_ENABLED(CONFIG_HAVE_ARM_SMCCC) && ddata->secured_soc) { |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 403 | arm_smccc_smc(STM32_SMC_RCC, STM32_SMC_REG_WRITE, |
| 404 | hold_boot.reg, val, 0, 0, 0, 0, &smc_res); |
| 405 | err = smc_res.a0; |
| 406 | } else { |
| 407 | err = regmap_update_bits(hold_boot.map, hold_boot.reg, |
| 408 | hold_boot.mask, val); |
| 409 | } |
| 410 | |
| 411 | if (err) |
| 412 | dev_err(&rproc->dev, "failed to set hold boot\n"); |
| 413 | |
| 414 | return err; |
| 415 | } |
| 416 | |
| 417 | static void stm32_rproc_add_coredump_trace(struct rproc *rproc) |
| 418 | { |
| 419 | struct rproc_debug_trace *trace; |
| 420 | struct rproc_dump_segment *segment; |
| 421 | bool already_added; |
| 422 | |
| 423 | list_for_each_entry(trace, &rproc->traces, node) { |
| 424 | already_added = false; |
| 425 | |
| 426 | list_for_each_entry(segment, &rproc->dump_segments, node) { |
| 427 | if (segment->da == trace->trace_mem.da) { |
| 428 | already_added = true; |
| 429 | break; |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | if (!already_added) |
| 434 | rproc_coredump_add_segment(rproc, trace->trace_mem.da, |
| 435 | trace->trace_mem.len); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | static int stm32_rproc_start(struct rproc *rproc) |
| 440 | { |
Fabien Dessenne | abbe429 | 2019-08-26 17:38:06 +0200 | [diff] [blame] | 441 | struct stm32_rproc *ddata = rproc->priv; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 442 | int err; |
| 443 | |
| 444 | stm32_rproc_add_coredump_trace(rproc); |
| 445 | |
Fabien Dessenne | abbe429 | 2019-08-26 17:38:06 +0200 | [diff] [blame] | 446 | /* clear remote proc Deep Sleep */ |
| 447 | if (ddata->pdds.map) { |
| 448 | err = regmap_update_bits(ddata->pdds.map, ddata->pdds.reg, |
| 449 | ddata->pdds.mask, 0); |
| 450 | if (err) { |
| 451 | dev_err(&rproc->dev, "failed to clear pdds\n"); |
| 452 | return err; |
| 453 | } |
| 454 | } |
| 455 | |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 456 | err = stm32_rproc_set_hold_boot(rproc, false); |
| 457 | if (err) |
| 458 | return err; |
| 459 | |
| 460 | return stm32_rproc_set_hold_boot(rproc, true); |
| 461 | } |
| 462 | |
| 463 | static int stm32_rproc_stop(struct rproc *rproc) |
| 464 | { |
| 465 | struct stm32_rproc *ddata = rproc->priv; |
| 466 | int err, dummy_data, idx; |
| 467 | |
| 468 | /* request shutdown of the remote processor */ |
| 469 | if (rproc->state != RPROC_OFFLINE) { |
| 470 | idx = stm32_rproc_mbox_idx(rproc, STM32_MBX_SHUTDOWN); |
| 471 | if (idx >= 0 && ddata->mb[idx].chan) { |
| 472 | /* a dummy data is sent to allow to block on transmit */ |
| 473 | err = mbox_send_message(ddata->mb[idx].chan, |
| 474 | &dummy_data); |
| 475 | if (err < 0) |
| 476 | dev_warn(&rproc->dev, "warning: remote FW shutdown without ack\n"); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | err = stm32_rproc_set_hold_boot(rproc, true); |
| 481 | if (err) |
| 482 | return err; |
| 483 | |
| 484 | err = reset_control_assert(ddata->rst); |
| 485 | if (err) { |
| 486 | dev_err(&rproc->dev, "failed to assert the reset\n"); |
| 487 | return err; |
| 488 | } |
| 489 | |
| 490 | /* to allow platform Standby power mode, set remote proc Deep Sleep */ |
| 491 | if (ddata->pdds.map) { |
| 492 | err = regmap_update_bits(ddata->pdds.map, ddata->pdds.reg, |
| 493 | ddata->pdds.mask, 1); |
| 494 | if (err) { |
| 495 | dev_err(&rproc->dev, "failed to set pdds\n"); |
| 496 | return err; |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | return 0; |
| 501 | } |
| 502 | |
| 503 | static void stm32_rproc_kick(struct rproc *rproc, int vqid) |
| 504 | { |
| 505 | struct stm32_rproc *ddata = rproc->priv; |
| 506 | unsigned int i; |
| 507 | int err; |
| 508 | |
| 509 | if (WARN_ON(vqid >= MBOX_NB_VQ)) |
| 510 | return; |
| 511 | |
| 512 | for (i = 0; i < MBOX_NB_MBX; i++) { |
| 513 | if (vqid != ddata->mb[i].vq_id) |
| 514 | continue; |
| 515 | if (!ddata->mb[i].chan) |
| 516 | return; |
| 517 | err = mbox_send_message(ddata->mb[i].chan, (void *)(long)vqid); |
| 518 | if (err < 0) |
| 519 | dev_err(&rproc->dev, "%s: failed (%s, err:%d)\n", |
| 520 | __func__, ddata->mb[i].name, err); |
| 521 | return; |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | static struct rproc_ops st_rproc_ops = { |
| 526 | .start = stm32_rproc_start, |
| 527 | .stop = stm32_rproc_stop, |
| 528 | .kick = stm32_rproc_kick, |
| 529 | .load = rproc_elf_load_segments, |
| 530 | .parse_fw = stm32_rproc_parse_fw, |
| 531 | .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, |
Clement Leger | e29ff72b | 2020-04-22 11:30:17 +0200 | [diff] [blame] | 532 | .sanity_check = rproc_elf_sanity_check, |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 533 | .get_boot_addr = rproc_elf_get_boot_addr, |
| 534 | }; |
| 535 | |
| 536 | static const struct of_device_id stm32_rproc_match[] = { |
| 537 | { .compatible = "st,stm32mp1-m4" }, |
| 538 | {}, |
| 539 | }; |
| 540 | MODULE_DEVICE_TABLE(of, stm32_rproc_match); |
| 541 | |
| 542 | static int stm32_rproc_get_syscon(struct device_node *np, const char *prop, |
| 543 | struct stm32_syscon *syscon) |
| 544 | { |
| 545 | int err = 0; |
| 546 | |
| 547 | syscon->map = syscon_regmap_lookup_by_phandle(np, prop); |
| 548 | if (IS_ERR(syscon->map)) { |
| 549 | err = PTR_ERR(syscon->map); |
| 550 | syscon->map = NULL; |
| 551 | goto out; |
| 552 | } |
| 553 | |
| 554 | err = of_property_read_u32_index(np, prop, 1, &syscon->reg); |
| 555 | if (err) |
| 556 | goto out; |
| 557 | |
| 558 | err = of_property_read_u32_index(np, prop, 2, &syscon->mask); |
| 559 | |
| 560 | out: |
| 561 | return err; |
| 562 | } |
| 563 | |
Mathieu Poirier | 8210fc8 | 2020-07-14 14:04:37 -0600 | [diff] [blame] | 564 | static int stm32_rproc_parse_dt(struct platform_device *pdev, |
| 565 | struct stm32_rproc *ddata, bool *auto_boot) |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 566 | { |
| 567 | struct device *dev = &pdev->dev; |
| 568 | struct device_node *np = dev->of_node; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 569 | struct stm32_syscon tz; |
| 570 | unsigned int tzen; |
| 571 | int err, irq; |
| 572 | |
| 573 | irq = platform_get_irq(pdev, 0); |
Fabien Dessenne | d333de3 | 2019-08-26 17:38:29 +0200 | [diff] [blame] | 574 | if (irq == -EPROBE_DEFER) |
| 575 | return -EPROBE_DEFER; |
| 576 | |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 577 | if (irq > 0) { |
| 578 | err = devm_request_irq(dev, irq, stm32_rproc_wdg, 0, |
Mathieu Poirier | b8631ab | 2020-07-14 14:04:36 -0600 | [diff] [blame] | 579 | dev_name(dev), pdev); |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 580 | if (err) { |
| 581 | dev_err(dev, "failed to request wdg irq\n"); |
| 582 | return err; |
| 583 | } |
| 584 | |
Fabien Dessenne | 410119e | 2019-08-26 17:38:43 +0200 | [diff] [blame] | 585 | ddata->wdg_irq = irq; |
| 586 | |
| 587 | if (of_property_read_bool(np, "wakeup-source")) { |
| 588 | device_init_wakeup(dev, true); |
| 589 | dev_pm_set_wake_irq(dev, irq); |
| 590 | } |
| 591 | |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 592 | dev_info(dev, "wdg irq registered\n"); |
| 593 | } |
| 594 | |
| 595 | ddata->rst = devm_reset_control_get_by_index(dev, 0); |
| 596 | if (IS_ERR(ddata->rst)) { |
| 597 | dev_err(dev, "failed to get mcu reset\n"); |
| 598 | return PTR_ERR(ddata->rst); |
| 599 | } |
| 600 | |
| 601 | /* |
| 602 | * if platform is secured the hold boot bit must be written by |
| 603 | * smc call and read normally. |
| 604 | * if not secure the hold boot bit could be read/write normally |
| 605 | */ |
| 606 | err = stm32_rproc_get_syscon(np, "st,syscfg-tz", &tz); |
| 607 | if (err) { |
| 608 | dev_err(dev, "failed to get tz syscfg\n"); |
| 609 | return err; |
| 610 | } |
| 611 | |
| 612 | err = regmap_read(tz.map, tz.reg, &tzen); |
| 613 | if (err) { |
Mathieu Poirier | 8210fc8 | 2020-07-14 14:04:37 -0600 | [diff] [blame] | 614 | dev_err(dev, "failed to read tzen\n"); |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 615 | return err; |
| 616 | } |
| 617 | ddata->secured_soc = tzen & tz.mask; |
| 618 | |
| 619 | err = stm32_rproc_get_syscon(np, "st,syscfg-holdboot", |
| 620 | &ddata->hold_boot); |
| 621 | if (err) { |
| 622 | dev_err(dev, "failed to get hold boot\n"); |
| 623 | return err; |
| 624 | } |
| 625 | |
| 626 | err = stm32_rproc_get_syscon(np, "st,syscfg-pdds", &ddata->pdds); |
| 627 | if (err) |
Ahmad Fatoum | b1f0fa8 | 2020-02-24 18:25:19 +0100 | [diff] [blame] | 628 | dev_info(dev, "failed to get pdds\n"); |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 629 | |
Mathieu Poirier | 8210fc8 | 2020-07-14 14:04:37 -0600 | [diff] [blame] | 630 | *auto_boot = of_property_read_bool(np, "st,auto-boot"); |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 631 | |
Mathieu Poirier | 9276536 | 2020-07-14 14:04:39 -0600 | [diff] [blame] | 632 | /* |
| 633 | * See if we can check the M4 status, i.e if it was started |
| 634 | * from the boot loader or not. |
| 635 | */ |
| 636 | err = stm32_rproc_get_syscon(np, "st,syscfg-m4-state", |
| 637 | &ddata->m4_state); |
| 638 | if (err) { |
| 639 | /* remember this */ |
| 640 | ddata->m4_state.map = NULL; |
| 641 | /* no coprocessor state syscon (optional) */ |
| 642 | dev_warn(dev, "m4 state not supported\n"); |
| 643 | |
| 644 | /* no need to go further */ |
| 645 | return 0; |
| 646 | } |
| 647 | |
| 648 | /* See if we can get the resource table */ |
| 649 | err = stm32_rproc_get_syscon(np, "st,syscfg-rsc-tbl", |
| 650 | &ddata->rsctbl); |
| 651 | if (err) { |
| 652 | /* no rsc table syscon (optional) */ |
| 653 | dev_warn(dev, "rsc tbl syscon not supported\n"); |
| 654 | } |
| 655 | |
Mathieu Poirier | 95e32f8 | 2020-07-14 14:04:38 -0600 | [diff] [blame] | 656 | return 0; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 657 | } |
| 658 | |
Mathieu Poirier | 376ffdc | 2020-07-14 14:04:40 -0600 | [diff] [blame] | 659 | static int stm32_rproc_get_m4_status(struct stm32_rproc *ddata, |
| 660 | unsigned int *state) |
| 661 | { |
| 662 | /* See stm32_rproc_parse_dt() */ |
| 663 | if (!ddata->m4_state.map) { |
| 664 | /* |
| 665 | * We couldn't get the coprocessor's state, assume |
| 666 | * it is not running. |
| 667 | */ |
| 668 | state = M4_STATE_OFF; |
| 669 | return 0; |
| 670 | } |
| 671 | |
| 672 | return regmap_read(ddata->m4_state.map, ddata->m4_state.reg, state); |
| 673 | } |
| 674 | |
Mathieu Poirier | 11a7aaa | 2020-07-14 14:04:43 -0600 | [diff] [blame^] | 675 | static int stm32_rproc_da_to_pa(struct platform_device *pdev, |
| 676 | struct stm32_rproc *ddata, |
| 677 | u64 da, phys_addr_t *pa) |
| 678 | { |
| 679 | struct device *dev = &pdev->dev; |
| 680 | struct stm32_rproc_mem *p_mem; |
| 681 | unsigned int i; |
| 682 | |
| 683 | for (i = 0; i < ddata->nb_rmems; i++) { |
| 684 | p_mem = &ddata->rmems[i]; |
| 685 | |
| 686 | if (da < p_mem->dev_addr || |
| 687 | da >= p_mem->dev_addr + p_mem->size) |
| 688 | continue; |
| 689 | |
| 690 | *pa = da - p_mem->dev_addr + p_mem->bus_addr; |
| 691 | dev_dbg(dev, "da %llx to pa %#x\n", da, *pa); |
| 692 | |
| 693 | return 0; |
| 694 | } |
| 695 | |
| 696 | dev_err(dev, "can't translate da %llx\n", da); |
| 697 | |
| 698 | return -EINVAL; |
| 699 | } |
| 700 | |
| 701 | static int stm32_rproc_get_loaded_rsc_table(struct platform_device *pdev, |
| 702 | struct rproc *rproc, |
| 703 | struct stm32_rproc *ddata) |
| 704 | { |
| 705 | struct device *dev = &pdev->dev; |
| 706 | phys_addr_t rsc_pa; |
| 707 | u32 rsc_da; |
| 708 | int err; |
| 709 | |
| 710 | err = regmap_read(ddata->rsctbl.map, ddata->rsctbl.reg, &rsc_da); |
| 711 | if (err) { |
| 712 | dev_err(dev, "failed to read rsc tbl addr\n"); |
| 713 | return err; |
| 714 | } |
| 715 | |
| 716 | if (!rsc_da) |
| 717 | /* no rsc table */ |
| 718 | return 0; |
| 719 | |
| 720 | err = stm32_rproc_da_to_pa(pdev, ddata, rsc_da, &rsc_pa); |
| 721 | if (err) |
| 722 | return err; |
| 723 | |
| 724 | ddata->rsc_va = devm_ioremap_wc(dev, rsc_pa, RSC_TBL_SIZE); |
| 725 | if (IS_ERR_OR_NULL(ddata->rsc_va)) { |
| 726 | dev_err(dev, "Unable to map memory region: %pa+%zx\n", |
| 727 | &rsc_pa, RSC_TBL_SIZE); |
| 728 | ddata->rsc_va = NULL; |
| 729 | return -ENOMEM; |
| 730 | } |
| 731 | |
| 732 | /* |
| 733 | * The resource table is already loaded in device memory, no need |
| 734 | * to work with a cached table. |
| 735 | */ |
| 736 | rproc->cached_table = NULL; |
| 737 | /* Assuming the resource table fits in 1kB is fair */ |
| 738 | rproc->table_sz = RSC_TBL_SIZE; |
| 739 | rproc->table_ptr = (struct resource_table *)ddata->rsc_va; |
| 740 | |
| 741 | return 0; |
| 742 | } |
| 743 | |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 744 | static int stm32_rproc_probe(struct platform_device *pdev) |
| 745 | { |
| 746 | struct device *dev = &pdev->dev; |
| 747 | struct stm32_rproc *ddata; |
| 748 | struct device_node *np = dev->of_node; |
| 749 | struct rproc *rproc; |
Mathieu Poirier | 376ffdc | 2020-07-14 14:04:40 -0600 | [diff] [blame] | 750 | unsigned int state; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 751 | int ret; |
| 752 | |
| 753 | ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32)); |
| 754 | if (ret) |
| 755 | return ret; |
| 756 | |
| 757 | rproc = rproc_alloc(dev, np->name, &st_rproc_ops, NULL, sizeof(*ddata)); |
| 758 | if (!rproc) |
| 759 | return -ENOMEM; |
| 760 | |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 761 | ddata = rproc->priv; |
Mathieu Poirier | 8210fc8 | 2020-07-14 14:04:37 -0600 | [diff] [blame] | 762 | |
| 763 | rproc_coredump_set_elf_info(rproc, ELFCLASS32, EM_NONE); |
| 764 | |
| 765 | ret = stm32_rproc_parse_dt(pdev, ddata, &rproc->auto_boot); |
| 766 | if (ret) |
| 767 | goto free_rproc; |
| 768 | |
Mathieu Poirier | 95e32f8 | 2020-07-14 14:04:38 -0600 | [diff] [blame] | 769 | ret = stm32_rproc_of_memory_translations(pdev, ddata); |
| 770 | if (ret) |
| 771 | goto free_rproc; |
| 772 | |
Mathieu Poirier | 376ffdc | 2020-07-14 14:04:40 -0600 | [diff] [blame] | 773 | ret = stm32_rproc_get_m4_status(ddata, &state); |
| 774 | if (ret) |
| 775 | goto free_rproc; |
| 776 | |
Mathieu Poirier | dadbdb9 | 2020-07-14 14:04:42 -0600 | [diff] [blame] | 777 | if (state == M4_STATE_CRUN) { |
Mathieu Poirier | 376ffdc | 2020-07-14 14:04:40 -0600 | [diff] [blame] | 778 | rproc->state = RPROC_DETACHED; |
| 779 | |
Mathieu Poirier | dadbdb9 | 2020-07-14 14:04:42 -0600 | [diff] [blame] | 780 | ret = stm32_rproc_parse_memory_regions(rproc); |
| 781 | if (ret) |
| 782 | goto free_resources; |
Mathieu Poirier | 11a7aaa | 2020-07-14 14:04:43 -0600 | [diff] [blame^] | 783 | |
| 784 | ret = stm32_rproc_get_loaded_rsc_table(pdev, rproc, ddata); |
| 785 | if (ret) |
| 786 | goto free_resources; |
Mathieu Poirier | dadbdb9 | 2020-07-14 14:04:42 -0600 | [diff] [blame] | 787 | } |
| 788 | |
Mathieu Poirier | 8210fc8 | 2020-07-14 14:04:37 -0600 | [diff] [blame] | 789 | rproc->has_iommu = false; |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 790 | ddata->workqueue = create_workqueue(dev_name(dev)); |
| 791 | if (!ddata->workqueue) { |
| 792 | dev_err(dev, "cannot create workqueue\n"); |
| 793 | ret = -ENOMEM; |
Mathieu Poirier | dadbdb9 | 2020-07-14 14:04:42 -0600 | [diff] [blame] | 794 | goto free_resources; |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 795 | } |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 796 | |
| 797 | platform_set_drvdata(pdev, rproc); |
| 798 | |
Fabien Dessenne | 4a56e423 | 2019-11-15 11:03:08 +0100 | [diff] [blame] | 799 | ret = stm32_rproc_request_mbox(rproc); |
| 800 | if (ret) |
Mathieu Poirier | 8210fc8 | 2020-07-14 14:04:37 -0600 | [diff] [blame] | 801 | goto free_wkq; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 802 | |
| 803 | ret = rproc_add(rproc); |
| 804 | if (ret) |
| 805 | goto free_mb; |
| 806 | |
| 807 | return 0; |
| 808 | |
| 809 | free_mb: |
| 810 | stm32_rproc_free_mbox(rproc); |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 811 | free_wkq: |
| 812 | destroy_workqueue(ddata->workqueue); |
Mathieu Poirier | dadbdb9 | 2020-07-14 14:04:42 -0600 | [diff] [blame] | 813 | free_resources: |
| 814 | rproc_resource_cleanup(rproc); |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 815 | free_rproc: |
Fabien Dessenne | 410119e | 2019-08-26 17:38:43 +0200 | [diff] [blame] | 816 | if (device_may_wakeup(dev)) { |
| 817 | dev_pm_clear_wake_irq(dev); |
| 818 | device_init_wakeup(dev, false); |
| 819 | } |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 820 | rproc_free(rproc); |
| 821 | return ret; |
| 822 | } |
| 823 | |
| 824 | static int stm32_rproc_remove(struct platform_device *pdev) |
| 825 | { |
| 826 | struct rproc *rproc = platform_get_drvdata(pdev); |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 827 | struct stm32_rproc *ddata = rproc->priv; |
Fabien Dessenne | 410119e | 2019-08-26 17:38:43 +0200 | [diff] [blame] | 828 | struct device *dev = &pdev->dev; |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 829 | |
| 830 | if (atomic_read(&rproc->power) > 0) |
| 831 | rproc_shutdown(rproc); |
| 832 | |
| 833 | rproc_del(rproc); |
| 834 | stm32_rproc_free_mbox(rproc); |
Arnaud Pouliquen | 714cf5e | 2019-10-25 10:56:39 +0200 | [diff] [blame] | 835 | destroy_workqueue(ddata->workqueue); |
Fabien Dessenne | 410119e | 2019-08-26 17:38:43 +0200 | [diff] [blame] | 836 | |
| 837 | if (device_may_wakeup(dev)) { |
| 838 | dev_pm_clear_wake_irq(dev); |
| 839 | device_init_wakeup(dev, false); |
| 840 | } |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 841 | rproc_free(rproc); |
| 842 | |
| 843 | return 0; |
| 844 | } |
| 845 | |
Fabien Dessenne | 410119e | 2019-08-26 17:38:43 +0200 | [diff] [blame] | 846 | static int __maybe_unused stm32_rproc_suspend(struct device *dev) |
| 847 | { |
| 848 | struct rproc *rproc = dev_get_drvdata(dev); |
| 849 | struct stm32_rproc *ddata = rproc->priv; |
| 850 | |
| 851 | if (device_may_wakeup(dev)) |
| 852 | return enable_irq_wake(ddata->wdg_irq); |
| 853 | |
| 854 | return 0; |
| 855 | } |
| 856 | |
| 857 | static int __maybe_unused stm32_rproc_resume(struct device *dev) |
| 858 | { |
| 859 | struct rproc *rproc = dev_get_drvdata(dev); |
| 860 | struct stm32_rproc *ddata = rproc->priv; |
| 861 | |
| 862 | if (device_may_wakeup(dev)) |
| 863 | return disable_irq_wake(ddata->wdg_irq); |
| 864 | |
| 865 | return 0; |
| 866 | } |
| 867 | |
| 868 | static SIMPLE_DEV_PM_OPS(stm32_rproc_pm_ops, |
| 869 | stm32_rproc_suspend, stm32_rproc_resume); |
| 870 | |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 871 | static struct platform_driver stm32_rproc_driver = { |
| 872 | .probe = stm32_rproc_probe, |
| 873 | .remove = stm32_rproc_remove, |
| 874 | .driver = { |
| 875 | .name = "stm32-rproc", |
Fabien Dessenne | 410119e | 2019-08-26 17:38:43 +0200 | [diff] [blame] | 876 | .pm = &stm32_rproc_pm_ops, |
Fabien Dessenne | 13140de | 2019-05-14 10:26:58 +0200 | [diff] [blame] | 877 | .of_match_table = of_match_ptr(stm32_rproc_match), |
| 878 | }, |
| 879 | }; |
| 880 | module_platform_driver(stm32_rproc_driver); |
| 881 | |
| 882 | MODULE_DESCRIPTION("STM32 Remote Processor Control Driver"); |
| 883 | MODULE_AUTHOR("Ludovic Barre <ludovic.barre@st.com>"); |
| 884 | MODULE_AUTHOR("Fabien Dessenne <fabien.dessenne@st.com>"); |
| 885 | MODULE_LICENSE("GPL v2"); |
| 886 | |