1 // SPDX-License-Identifier: GPL-2.0
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.
8 #include <linux/arm-smccc.h>
9 #include <linux/dma-mapping.h>
10 #include <linux/interrupt.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>
18 #include <linux/pm_wakeirq.h>
19 #include <linux/regmap.h>
20 #include <linux/remoteproc.h>
21 #include <linux/reset.h>
22 #include <linux/slab.h>
23 #include <linux/workqueue.h>
25 #include "remoteproc_internal.h"
28 #define RELEASE_BOOT 1
33 #define STM32_SMC_RCC 0x82001000
34 #define STM32_SMC_REG_WRITE 0x1
36 #define STM32_MBX_VQ0 "vq0"
37 #define STM32_MBX_VQ0_ID 0
38 #define STM32_MBX_VQ1 "vq1"
39 #define STM32_MBX_VQ1_ID 1
40 #define STM32_MBX_SHUTDOWN "shutdown"
42 #define RSC_TBL_SIZE 1024
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
57 struct stm32_rproc_mem
{
59 void __iomem
*cpu_addr
;
65 struct stm32_rproc_mem_ranges
{
72 const unsigned char name
[10];
73 struct mbox_chan
*chan
;
74 struct mbox_client client
;
75 struct work_struct vq_work
;
80 struct reset_control
*rst
;
81 struct stm32_syscon hold_boot
;
82 struct stm32_syscon pdds
;
83 struct stm32_syscon m4_state
;
84 struct stm32_syscon rsctbl
;
87 struct stm32_rproc_mem
*rmems
;
88 struct stm32_mbox mb
[MBOX_NB_MBX
];
89 struct workqueue_struct
*workqueue
;
94 static int stm32_rproc_pa_to_da(struct rproc
*rproc
, phys_addr_t pa
, u64
*da
)
97 struct stm32_rproc
*ddata
= rproc
->priv
;
98 struct stm32_rproc_mem
*p_mem
;
100 for (i
= 0; i
< ddata
->nb_rmems
; i
++) {
101 p_mem
= &ddata
->rmems
[i
];
103 if (pa
< p_mem
->bus_addr
||
104 pa
>= p_mem
->bus_addr
+ p_mem
->size
)
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
);
114 static int stm32_rproc_mem_alloc(struct rproc
*rproc
,
115 struct rproc_mem_entry
*mem
)
117 struct device
*dev
= rproc
->dev
.parent
;
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
);
128 /* Update memory entry va */
134 static int stm32_rproc_mem_release(struct rproc
*rproc
,
135 struct rproc_mem_entry
*mem
)
137 dev_dbg(rproc
->dev
.parent
, "unmap memory: %pa\n", &mem
->dma
);
143 static int stm32_rproc_of_memory_translations(struct platform_device
*pdev
,
144 struct stm32_rproc
*ddata
)
146 struct device
*parent
, *dev
= &pdev
->dev
;
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;
152 parent
= dev
->parent
;
153 np
= parent
->of_node
;
155 cnt
= of_property_count_elems_of_size(np
, "dma-ranges",
158 dev_err(dev
, "%s: dma-ranges property not defined\n", __func__
);
162 p_mems
= devm_kcalloc(dev
, cnt
, sizeof(*p_mems
), GFP_KERNEL
);
165 mem_range
= kcalloc(cnt
, sizeof(*mem_range
), GFP_KERNEL
);
169 array_size
= cnt
* sizeof(struct stm32_rproc_mem_ranges
) / sizeof(u32
);
171 ret
= of_property_read_u32_array(np
, "dma-ranges",
172 (u32
*)mem_range
, array_size
);
174 dev_err(dev
, "error while get dma-ranges property: %x\n", ret
);
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
;
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
,
188 ddata
->rmems
= p_mems
;
189 ddata
->nb_rmems
= cnt
;
196 static int stm32_rproc_mbox_idx(struct rproc
*rproc
, const unsigned char *name
)
198 struct stm32_rproc
*ddata
= rproc
->priv
;
201 for (i
= 0; i
< ARRAY_SIZE(ddata
->mb
); i
++) {
202 if (!strncmp(ddata
->mb
[i
].name
, name
, strlen(name
)))
205 dev_err(&rproc
->dev
, "mailbox %s not found\n", name
);
210 static int stm32_rproc_elf_load_rsc_table(struct rproc
*rproc
,
211 const struct firmware
*fw
)
213 if (rproc_elf_load_rsc_table(rproc
, fw
))
214 dev_warn(&rproc
->dev
, "no resource table found for this firmware\n");
219 static int stm32_rproc_parse_memory_regions(struct rproc
*rproc
)
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
;
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
);
234 dev_err(dev
, "unable to acquire memory-region\n");
238 if (stm32_rproc_pa_to_da(rproc
, rmem
->base
, &da
) < 0) {
239 dev_err(dev
, "memory region not valid %pa\n",
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
,
250 stm32_rproc_mem_alloc
,
251 stm32_rproc_mem_release
,
255 rproc_coredump_add_segment(rproc
, da
,
258 /* Register reserved memory for vdev buffer alloc */
259 mem
= rproc_of_resm_mem_entry_init(dev
, index
,
268 rproc_add_carveout(rproc
, mem
);
275 static int stm32_rproc_parse_fw(struct rproc
*rproc
, const struct firmware
*fw
)
277 int ret
= stm32_rproc_parse_memory_regions(rproc
);
282 return stm32_rproc_elf_load_rsc_table(rproc
, fw
);
285 static irqreturn_t
stm32_rproc_wdg(int irq
, void *data
)
287 struct platform_device
*pdev
= data
;
288 struct rproc
*rproc
= platform_get_drvdata(pdev
);
290 rproc_report_crash(rproc
, RPROC_WATCHDOG
);
295 static void stm32_rproc_mb_vq_work(struct work_struct
*work
)
297 struct stm32_mbox
*mb
= container_of(work
, struct stm32_mbox
, vq_work
);
298 struct rproc
*rproc
= dev_get_drvdata(mb
->client
.dev
);
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
);
304 static void stm32_rproc_mb_callback(struct mbox_client
*cl
, void *data
)
306 struct rproc
*rproc
= dev_get_drvdata(cl
->dev
);
307 struct stm32_mbox
*mb
= container_of(cl
, struct stm32_mbox
, client
);
308 struct stm32_rproc
*ddata
= rproc
->priv
;
310 queue_work(ddata
->workqueue
, &mb
->vq_work
);
313 static void stm32_rproc_free_mbox(struct rproc
*rproc
)
315 struct stm32_rproc
*ddata
= rproc
->priv
;
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
;
325 static const struct stm32_mbox stm32_rproc_mbox
[MBOX_NB_MBX
] = {
327 .name
= STM32_MBX_VQ0
,
328 .vq_id
= STM32_MBX_VQ0_ID
,
330 .rx_callback
= stm32_rproc_mb_callback
,
335 .name
= STM32_MBX_VQ1
,
336 .vq_id
= STM32_MBX_VQ1_ID
,
338 .rx_callback
= stm32_rproc_mb_callback
,
343 .name
= STM32_MBX_SHUTDOWN
,
348 .tx_tout
= 500, /* 500 ms time out */
353 static int stm32_rproc_request_mbox(struct rproc
*rproc
)
355 struct stm32_rproc
*ddata
= rproc
->priv
;
356 struct device
*dev
= &rproc
->dev
;
359 const unsigned char *name
;
360 struct mbox_client
*cl
;
362 /* Initialise mailbox structure table */
363 memcpy(ddata
->mb
, stm32_rproc_mbox
, sizeof(stm32_rproc_mbox
));
365 for (i
= 0; i
< MBOX_NB_MBX
; i
++) {
366 name
= ddata
->mb
[i
].name
;
368 cl
= &ddata
->mb
[i
].client
;
369 cl
->dev
= dev
->parent
;
371 ddata
->mb
[i
].chan
= mbox_request_channel_byname(cl
, name
);
372 if (IS_ERR(ddata
->mb
[i
].chan
)) {
373 if (PTR_ERR(ddata
->mb
[i
].chan
) == -EPROBE_DEFER
)
375 dev_warn(dev
, "cannot get %s mbox\n", name
);
376 ddata
->mb
[i
].chan
= NULL
;
378 if (ddata
->mb
[i
].vq_id
>= 0) {
379 INIT_WORK(&ddata
->mb
[i
].vq_work
,
380 stm32_rproc_mb_vq_work
);
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
;
393 static int stm32_rproc_set_hold_boot(struct rproc
*rproc
, bool hold
)
395 struct stm32_rproc
*ddata
= rproc
->priv
;
396 struct stm32_syscon hold_boot
= ddata
->hold_boot
;
397 struct arm_smccc_res smc_res
;
400 val
= hold
? HOLD_BOOT
: RELEASE_BOOT
;
402 if (IS_ENABLED(CONFIG_HAVE_ARM_SMCCC
) && ddata
->secured_soc
) {
403 arm_smccc_smc(STM32_SMC_RCC
, STM32_SMC_REG_WRITE
,
404 hold_boot
.reg
, val
, 0, 0, 0, 0, &smc_res
);
407 err
= regmap_update_bits(hold_boot
.map
, hold_boot
.reg
,
408 hold_boot
.mask
, val
);
412 dev_err(&rproc
->dev
, "failed to set hold boot\n");
417 static void stm32_rproc_add_coredump_trace(struct rproc
*rproc
)
419 struct rproc_debug_trace
*trace
;
420 struct rproc_dump_segment
*segment
;
423 list_for_each_entry(trace
, &rproc
->traces
, node
) {
424 already_added
= false;
426 list_for_each_entry(segment
, &rproc
->dump_segments
, node
) {
427 if (segment
->da
== trace
->trace_mem
.da
) {
428 already_added
= true;
434 rproc_coredump_add_segment(rproc
, trace
->trace_mem
.da
,
435 trace
->trace_mem
.len
);
439 static int stm32_rproc_start(struct rproc
*rproc
)
441 struct stm32_rproc
*ddata
= rproc
->priv
;
444 stm32_rproc_add_coredump_trace(rproc
);
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);
451 dev_err(&rproc
->dev
, "failed to clear pdds\n");
456 err
= stm32_rproc_set_hold_boot(rproc
, false);
460 return stm32_rproc_set_hold_boot(rproc
, true);
463 static int stm32_rproc_attach(struct rproc
*rproc
)
465 stm32_rproc_add_coredump_trace(rproc
);
467 return stm32_rproc_set_hold_boot(rproc
, true);
470 static int stm32_rproc_stop(struct rproc
*rproc
)
472 struct stm32_rproc
*ddata
= rproc
->priv
;
473 int err
, dummy_data
, idx
;
475 /* request shutdown of the remote processor */
476 if (rproc
->state
!= RPROC_OFFLINE
) {
477 idx
= stm32_rproc_mbox_idx(rproc
, STM32_MBX_SHUTDOWN
);
478 if (idx
>= 0 && ddata
->mb
[idx
].chan
) {
479 /* a dummy data is sent to allow to block on transmit */
480 err
= mbox_send_message(ddata
->mb
[idx
].chan
,
483 dev_warn(&rproc
->dev
, "warning: remote FW shutdown without ack\n");
487 err
= stm32_rproc_set_hold_boot(rproc
, true);
491 err
= reset_control_assert(ddata
->rst
);
493 dev_err(&rproc
->dev
, "failed to assert the reset\n");
497 /* to allow platform Standby power mode, set remote proc Deep Sleep */
498 if (ddata
->pdds
.map
) {
499 err
= regmap_update_bits(ddata
->pdds
.map
, ddata
->pdds
.reg
,
500 ddata
->pdds
.mask
, 1);
502 dev_err(&rproc
->dev
, "failed to set pdds\n");
507 /* update coprocessor state to OFF if available */
508 if (ddata
->m4_state
.map
) {
509 err
= regmap_update_bits(ddata
->m4_state
.map
,
511 ddata
->m4_state
.mask
,
514 dev_err(&rproc
->dev
, "failed to set copro state\n");
522 static void stm32_rproc_kick(struct rproc
*rproc
, int vqid
)
524 struct stm32_rproc
*ddata
= rproc
->priv
;
528 if (WARN_ON(vqid
>= MBOX_NB_VQ
))
531 for (i
= 0; i
< MBOX_NB_MBX
; i
++) {
532 if (vqid
!= ddata
->mb
[i
].vq_id
)
534 if (!ddata
->mb
[i
].chan
)
536 err
= mbox_send_message(ddata
->mb
[i
].chan
, (void *)(long)vqid
);
538 dev_err(&rproc
->dev
, "%s: failed (%s, err:%d)\n",
539 __func__
, ddata
->mb
[i
].name
, err
);
544 static const struct rproc_ops st_rproc_ops
= {
545 .start
= stm32_rproc_start
,
546 .stop
= stm32_rproc_stop
,
547 .attach
= stm32_rproc_attach
,
548 .kick
= stm32_rproc_kick
,
549 .load
= rproc_elf_load_segments
,
550 .parse_fw
= stm32_rproc_parse_fw
,
551 .find_loaded_rsc_table
= rproc_elf_find_loaded_rsc_table
,
552 .sanity_check
= rproc_elf_sanity_check
,
553 .get_boot_addr
= rproc_elf_get_boot_addr
,
556 static const struct of_device_id stm32_rproc_match
[] = {
557 { .compatible
= "st,stm32mp1-m4" },
560 MODULE_DEVICE_TABLE(of
, stm32_rproc_match
);
562 static int stm32_rproc_get_syscon(struct device_node
*np
, const char *prop
,
563 struct stm32_syscon
*syscon
)
567 syscon
->map
= syscon_regmap_lookup_by_phandle(np
, prop
);
568 if (IS_ERR(syscon
->map
)) {
569 err
= PTR_ERR(syscon
->map
);
574 err
= of_property_read_u32_index(np
, prop
, 1, &syscon
->reg
);
578 err
= of_property_read_u32_index(np
, prop
, 2, &syscon
->mask
);
584 static int stm32_rproc_parse_dt(struct platform_device
*pdev
,
585 struct stm32_rproc
*ddata
, bool *auto_boot
)
587 struct device
*dev
= &pdev
->dev
;
588 struct device_node
*np
= dev
->of_node
;
589 struct stm32_syscon tz
;
593 irq
= platform_get_irq(pdev
, 0);
594 if (irq
== -EPROBE_DEFER
)
595 return -EPROBE_DEFER
;
598 err
= devm_request_irq(dev
, irq
, stm32_rproc_wdg
, 0,
599 dev_name(dev
), pdev
);
601 dev_err(dev
, "failed to request wdg irq\n");
605 ddata
->wdg_irq
= irq
;
607 if (of_property_read_bool(np
, "wakeup-source")) {
608 device_init_wakeup(dev
, true);
609 dev_pm_set_wake_irq(dev
, irq
);
612 dev_info(dev
, "wdg irq registered\n");
615 ddata
->rst
= devm_reset_control_get_by_index(dev
, 0);
616 if (IS_ERR(ddata
->rst
)) {
617 dev_err(dev
, "failed to get mcu reset\n");
618 return PTR_ERR(ddata
->rst
);
622 * if platform is secured the hold boot bit must be written by
623 * smc call and read normally.
624 * if not secure the hold boot bit could be read/write normally
626 err
= stm32_rproc_get_syscon(np
, "st,syscfg-tz", &tz
);
628 dev_err(dev
, "failed to get tz syscfg\n");
632 err
= regmap_read(tz
.map
, tz
.reg
, &tzen
);
634 dev_err(dev
, "failed to read tzen\n");
637 ddata
->secured_soc
= tzen
& tz
.mask
;
639 err
= stm32_rproc_get_syscon(np
, "st,syscfg-holdboot",
642 dev_err(dev
, "failed to get hold boot\n");
646 err
= stm32_rproc_get_syscon(np
, "st,syscfg-pdds", &ddata
->pdds
);
648 dev_info(dev
, "failed to get pdds\n");
650 *auto_boot
= of_property_read_bool(np
, "st,auto-boot");
653 * See if we can check the M4 status, i.e if it was started
654 * from the boot loader or not.
656 err
= stm32_rproc_get_syscon(np
, "st,syscfg-m4-state",
660 ddata
->m4_state
.map
= NULL
;
661 /* no coprocessor state syscon (optional) */
662 dev_warn(dev
, "m4 state not supported\n");
664 /* no need to go further */
668 /* See if we can get the resource table */
669 err
= stm32_rproc_get_syscon(np
, "st,syscfg-rsc-tbl",
672 /* no rsc table syscon (optional) */
673 dev_warn(dev
, "rsc tbl syscon not supported\n");
679 static int stm32_rproc_get_m4_status(struct stm32_rproc
*ddata
,
682 /* See stm32_rproc_parse_dt() */
683 if (!ddata
->m4_state
.map
) {
685 * We couldn't get the coprocessor's state, assume
688 *state
= M4_STATE_OFF
;
692 return regmap_read(ddata
->m4_state
.map
, ddata
->m4_state
.reg
, state
);
695 static int stm32_rproc_da_to_pa(struct platform_device
*pdev
,
696 struct stm32_rproc
*ddata
,
697 u64 da
, phys_addr_t
*pa
)
699 struct device
*dev
= &pdev
->dev
;
700 struct stm32_rproc_mem
*p_mem
;
703 for (i
= 0; i
< ddata
->nb_rmems
; i
++) {
704 p_mem
= &ddata
->rmems
[i
];
706 if (da
< p_mem
->dev_addr
||
707 da
>= p_mem
->dev_addr
+ p_mem
->size
)
710 *pa
= da
- p_mem
->dev_addr
+ p_mem
->bus_addr
;
711 dev_dbg(dev
, "da %llx to pa %#x\n", da
, *pa
);
716 dev_err(dev
, "can't translate da %llx\n", da
);
721 static int stm32_rproc_get_loaded_rsc_table(struct platform_device
*pdev
,
723 struct stm32_rproc
*ddata
)
725 struct device
*dev
= &pdev
->dev
;
730 err
= regmap_read(ddata
->rsctbl
.map
, ddata
->rsctbl
.reg
, &rsc_da
);
732 dev_err(dev
, "failed to read rsc tbl addr\n");
740 err
= stm32_rproc_da_to_pa(pdev
, ddata
, rsc_da
, &rsc_pa
);
744 ddata
->rsc_va
= devm_ioremap_wc(dev
, rsc_pa
, RSC_TBL_SIZE
);
745 if (IS_ERR_OR_NULL(ddata
->rsc_va
)) {
746 dev_err(dev
, "Unable to map memory region: %pa+%zx\n",
747 &rsc_pa
, RSC_TBL_SIZE
);
748 ddata
->rsc_va
= NULL
;
753 * The resource table is already loaded in device memory, no need
754 * to work with a cached table.
756 rproc
->cached_table
= NULL
;
757 /* Assuming the resource table fits in 1kB is fair */
758 rproc
->table_sz
= RSC_TBL_SIZE
;
759 rproc
->table_ptr
= (struct resource_table
*)ddata
->rsc_va
;
764 static int stm32_rproc_probe(struct platform_device
*pdev
)
766 struct device
*dev
= &pdev
->dev
;
767 struct stm32_rproc
*ddata
;
768 struct device_node
*np
= dev
->of_node
;
773 ret
= dma_coerce_mask_and_coherent(dev
, DMA_BIT_MASK(32));
777 rproc
= rproc_alloc(dev
, np
->name
, &st_rproc_ops
, NULL
, sizeof(*ddata
));
783 rproc_coredump_set_elf_info(rproc
, ELFCLASS32
, EM_NONE
);
785 ret
= stm32_rproc_parse_dt(pdev
, ddata
, &rproc
->auto_boot
);
789 ret
= stm32_rproc_of_memory_translations(pdev
, ddata
);
793 ret
= stm32_rproc_get_m4_status(ddata
, &state
);
797 if (state
== M4_STATE_CRUN
) {
798 rproc
->state
= RPROC_DETACHED
;
800 ret
= stm32_rproc_parse_memory_regions(rproc
);
804 ret
= stm32_rproc_get_loaded_rsc_table(pdev
, rproc
, ddata
);
809 rproc
->has_iommu
= false;
810 ddata
->workqueue
= create_workqueue(dev_name(dev
));
811 if (!ddata
->workqueue
) {
812 dev_err(dev
, "cannot create workqueue\n");
817 platform_set_drvdata(pdev
, rproc
);
819 ret
= stm32_rproc_request_mbox(rproc
);
823 ret
= rproc_add(rproc
);
830 stm32_rproc_free_mbox(rproc
);
832 destroy_workqueue(ddata
->workqueue
);
834 rproc_resource_cleanup(rproc
);
836 if (device_may_wakeup(dev
)) {
837 dev_pm_clear_wake_irq(dev
);
838 device_init_wakeup(dev
, false);
844 static int stm32_rproc_remove(struct platform_device
*pdev
)
846 struct rproc
*rproc
= platform_get_drvdata(pdev
);
847 struct stm32_rproc
*ddata
= rproc
->priv
;
848 struct device
*dev
= &pdev
->dev
;
850 if (atomic_read(&rproc
->power
) > 0)
851 rproc_shutdown(rproc
);
854 stm32_rproc_free_mbox(rproc
);
855 destroy_workqueue(ddata
->workqueue
);
857 if (device_may_wakeup(dev
)) {
858 dev_pm_clear_wake_irq(dev
);
859 device_init_wakeup(dev
, false);
866 static int __maybe_unused
stm32_rproc_suspend(struct device
*dev
)
868 struct rproc
*rproc
= dev_get_drvdata(dev
);
869 struct stm32_rproc
*ddata
= rproc
->priv
;
871 if (device_may_wakeup(dev
))
872 return enable_irq_wake(ddata
->wdg_irq
);
877 static int __maybe_unused
stm32_rproc_resume(struct device
*dev
)
879 struct rproc
*rproc
= dev_get_drvdata(dev
);
880 struct stm32_rproc
*ddata
= rproc
->priv
;
882 if (device_may_wakeup(dev
))
883 return disable_irq_wake(ddata
->wdg_irq
);
888 static SIMPLE_DEV_PM_OPS(stm32_rproc_pm_ops
,
889 stm32_rproc_suspend
, stm32_rproc_resume
);
891 static struct platform_driver stm32_rproc_driver
= {
892 .probe
= stm32_rproc_probe
,
893 .remove
= stm32_rproc_remove
,
895 .name
= "stm32-rproc",
896 .pm
= &stm32_rproc_pm_ops
,
897 .of_match_table
= of_match_ptr(stm32_rproc_match
),
900 module_platform_driver(stm32_rproc_driver
);
902 MODULE_DESCRIPTION("STM32 Remote Processor Control Driver");
903 MODULE_AUTHOR("Ludovic Barre <ludovic.barre@st.com>");
904 MODULE_AUTHOR("Fabien Dessenne <fabien.dessenne@st.com>");
905 MODULE_LICENSE("GPL v2");