19
19
#include <linux/of_address.h>
20
20
#include <linux/of_irq.h>
21
21
#include <linux/platform_device.h>
22
- #include <linux/syscore_ops .h>
22
+ #include <linux/pm .h>
23
23
24
24
#include <dt-bindings/interrupt-controller/arm-gic.h>
25
25
@@ -64,8 +64,6 @@ struct stm32_exti_host_data {
64
64
bool dt_has_irqs_desc ; /* skip internal desc_irqs array and get it from DT */
65
65
};
66
66
67
- static struct stm32_exti_host_data * stm32_host_data ;
68
-
69
67
static const struct stm32_exti_bank stm32f4xx_exti_b1 = {
70
68
.imr_ofst = 0x00 ,
71
69
.emr_ofst = 0x04 ,
@@ -622,50 +620,32 @@ static int stm32_exti_h_set_affinity(struct irq_data *d,
622
620
return IRQ_SET_MASK_OK_DONE ;
623
621
}
624
622
625
- static int __maybe_unused stm32_exti_h_suspend (void )
623
+ static int stm32_exti_h_suspend (struct device * dev )
626
624
{
625
+ struct stm32_exti_host_data * host_data = dev_get_drvdata (dev );
627
626
struct stm32_exti_chip_data * chip_data ;
628
627
int i ;
629
628
630
- for (i = 0 ; i < stm32_host_data -> drv_data -> bank_nr ; i ++ ) {
631
- chip_data = & stm32_host_data -> chips_data [i ];
632
- raw_spin_lock (& chip_data -> rlock );
629
+ for (i = 0 ; i < host_data -> drv_data -> bank_nr ; i ++ ) {
630
+ chip_data = & host_data -> chips_data [i ];
633
631
stm32_chip_suspend (chip_data , chip_data -> wake_active );
634
- raw_spin_unlock (& chip_data -> rlock );
635
632
}
636
633
637
634
return 0 ;
638
635
}
639
636
640
- static void __maybe_unused stm32_exti_h_resume (void )
637
+ static int stm32_exti_h_resume (struct device * dev )
641
638
{
639
+ struct stm32_exti_host_data * host_data = dev_get_drvdata (dev );
642
640
struct stm32_exti_chip_data * chip_data ;
643
641
int i ;
644
642
645
- for (i = 0 ; i < stm32_host_data -> drv_data -> bank_nr ; i ++ ) {
646
- chip_data = & stm32_host_data -> chips_data [i ];
647
- raw_spin_lock (& chip_data -> rlock );
643
+ for (i = 0 ; i < host_data -> drv_data -> bank_nr ; i ++ ) {
644
+ chip_data = & host_data -> chips_data [i ];
648
645
stm32_chip_resume (chip_data , chip_data -> mask_cache );
649
- raw_spin_unlock (& chip_data -> rlock );
650
646
}
651
- }
652
647
653
- static struct syscore_ops stm32_exti_h_syscore_ops = {
654
- #ifdef CONFIG_PM_SLEEP
655
- .suspend = stm32_exti_h_suspend ,
656
- .resume = stm32_exti_h_resume ,
657
- #endif
658
- };
659
-
660
- static void stm32_exti_h_syscore_init (struct stm32_exti_host_data * host_data )
661
- {
662
- stm32_host_data = host_data ;
663
- register_syscore_ops (& stm32_exti_h_syscore_ops );
664
- }
665
-
666
- static void stm32_exti_h_syscore_deinit (void )
667
- {
668
- unregister_syscore_ops (& stm32_exti_h_syscore_ops );
648
+ return 0 ;
669
649
}
670
650
671
651
static int stm32_exti_h_retrigger (struct irq_data * d )
@@ -789,8 +769,6 @@ stm32_exti_host_data *stm32_exti_host_init(const struct stm32_exti_drv_data *dd,
789
769
goto free_chips_data ;
790
770
}
791
771
792
- stm32_host_data = host_data ;
793
-
794
772
return host_data ;
795
773
796
774
free_chips_data :
@@ -916,11 +894,6 @@ static void stm32_exti_remove_irq(void *data)
916
894
irq_domain_remove (domain );
917
895
}
918
896
919
- static void stm32_exti_remove (struct platform_device * pdev )
920
- {
921
- stm32_exti_h_syscore_deinit ();
922
- }
923
-
924
897
static int stm32_exti_probe (struct platform_device * pdev )
925
898
{
926
899
int ret , i ;
@@ -934,6 +907,8 @@ static int stm32_exti_probe(struct platform_device *pdev)
934
907
if (!host_data )
935
908
return - ENOMEM ;
936
909
910
+ dev_set_drvdata (dev , host_data );
911
+
937
912
/* check for optional hwspinlock which may be not available yet */
938
913
ret = of_hwspin_lock_get_id (np , 0 );
939
914
if (ret == - EPROBE_DEFER )
@@ -996,8 +971,6 @@ static int stm32_exti_probe(struct platform_device *pdev)
996
971
if (of_property_read_bool (np , "interrupts-extended" ))
997
972
host_data -> dt_has_irqs_desc = true;
998
973
999
- stm32_exti_h_syscore_init (host_data );
1000
-
1001
974
return 0 ;
1002
975
}
1003
976
@@ -1009,12 +982,16 @@ static const struct of_device_id stm32_exti_ids[] = {
1009
982
};
1010
983
MODULE_DEVICE_TABLE (of , stm32_exti_ids );
1011
984
985
+ static const struct dev_pm_ops stm32_exti_dev_pm_ops = {
986
+ NOIRQ_SYSTEM_SLEEP_PM_OPS (stm32_exti_h_suspend , stm32_exti_h_resume )
987
+ };
988
+
1012
989
static struct platform_driver stm32_exti_driver = {
1013
990
.probe = stm32_exti_probe ,
1014
- .remove_new = stm32_exti_remove ,
1015
991
.driver = {
1016
992
.name = "stm32_exti" ,
1017
993
.of_match_table = stm32_exti_ids ,
994
+ .pm = & stm32_exti_dev_pm_ops ,
1018
995
},
1019
996
};
1020
997
0 commit comments