@@ -36,6 +36,7 @@ struct stm32_exti_bank {
36
36
u32 rpr_ofst ;
37
37
u32 fpr_ofst ;
38
38
u32 trg_ofst ;
39
+ u32 seccfgr_ofst ;
39
40
};
40
41
41
42
#define UNDEF_REG ~0
@@ -54,10 +55,12 @@ struct stm32_exti_chip_data {
54
55
u32 mask_cache ;
55
56
u32 rtsr_cache ;
56
57
u32 ftsr_cache ;
58
+ u32 event_reserved ;
57
59
};
58
60
59
61
struct stm32_exti_host_data {
60
62
void __iomem * base ;
63
+ struct device * dev ;
61
64
struct stm32_exti_chip_data * chips_data ;
62
65
const struct stm32_exti_drv_data * drv_data ;
63
66
struct hwspinlock * hwlock ;
@@ -73,6 +76,7 @@ static const struct stm32_exti_bank stm32f4xx_exti_b1 = {
73
76
.rpr_ofst = 0x14 ,
74
77
.fpr_ofst = UNDEF_REG ,
75
78
.trg_ofst = UNDEF_REG ,
79
+ .seccfgr_ofst = UNDEF_REG ,
76
80
};
77
81
78
82
static const struct stm32_exti_bank * stm32f4xx_exti_banks [] = {
@@ -93,6 +97,7 @@ static const struct stm32_exti_bank stm32h7xx_exti_b1 = {
93
97
.rpr_ofst = 0x88 ,
94
98
.fpr_ofst = UNDEF_REG ,
95
99
.trg_ofst = UNDEF_REG ,
100
+ .seccfgr_ofst = UNDEF_REG ,
96
101
};
97
102
98
103
static const struct stm32_exti_bank stm32h7xx_exti_b2 = {
@@ -104,6 +109,7 @@ static const struct stm32_exti_bank stm32h7xx_exti_b2 = {
104
109
.rpr_ofst = 0x98 ,
105
110
.fpr_ofst = UNDEF_REG ,
106
111
.trg_ofst = UNDEF_REG ,
112
+ .seccfgr_ofst = UNDEF_REG ,
107
113
};
108
114
109
115
static const struct stm32_exti_bank stm32h7xx_exti_b3 = {
@@ -115,6 +121,7 @@ static const struct stm32_exti_bank stm32h7xx_exti_b3 = {
115
121
.rpr_ofst = 0xA8 ,
116
122
.fpr_ofst = UNDEF_REG ,
117
123
.trg_ofst = UNDEF_REG ,
124
+ .seccfgr_ofst = UNDEF_REG ,
118
125
};
119
126
120
127
static const struct stm32_exti_bank * stm32h7xx_exti_banks [] = {
@@ -137,6 +144,7 @@ static const struct stm32_exti_bank stm32mp1_exti_b1 = {
137
144
.rpr_ofst = 0x0C ,
138
145
.fpr_ofst = 0x10 ,
139
146
.trg_ofst = 0x3EC ,
147
+ .seccfgr_ofst = 0x14 ,
140
148
};
141
149
142
150
static const struct stm32_exti_bank stm32mp1_exti_b2 = {
@@ -148,6 +156,7 @@ static const struct stm32_exti_bank stm32mp1_exti_b2 = {
148
156
.rpr_ofst = 0x2C ,
149
157
.fpr_ofst = 0x30 ,
150
158
.trg_ofst = 0x3E8 ,
159
+ .seccfgr_ofst = 0x34 ,
151
160
};
152
161
153
162
static const struct stm32_exti_bank stm32mp1_exti_b3 = {
@@ -159,6 +168,7 @@ static const struct stm32_exti_bank stm32mp1_exti_b3 = {
159
168
.rpr_ofst = 0x4C ,
160
169
.fpr_ofst = 0x50 ,
161
170
.trg_ofst = 0x3E4 ,
171
+ .seccfgr_ofst = 0x54 ,
162
172
};
163
173
164
174
static const struct stm32_exti_bank * stm32mp1_exti_banks [] = {
@@ -706,6 +716,12 @@ static int stm32_exti_h_domain_alloc(struct irq_domain *dm,
706
716
bank = hwirq / IRQS_PER_BANK ;
707
717
chip_data = & host_data -> chips_data [bank ];
708
718
719
+ /* Check if event is reserved (Secure) */
720
+ if (chip_data -> event_reserved & BIT (hwirq % IRQS_PER_BANK )) {
721
+ dev_err (host_data -> dev , "event %lu is reserved, secure\n" , hwirq );
722
+ return - EPERM ;
723
+ }
724
+
709
725
event_trg = readl_relaxed (host_data -> base + chip_data -> reg_bank -> trg_ofst );
710
726
chip = (event_trg & BIT (hwirq % IRQS_PER_BANK )) ?
711
727
& stm32_exti_h_chip : & stm32_exti_h_chip_direct ;
@@ -803,6 +819,10 @@ stm32_exti_chip_data *stm32_exti_chip_init(struct stm32_exti_host_data *h_data,
803
819
if (stm32_bank -> emr_ofst != UNDEF_REG )
804
820
writel_relaxed (0 , base + stm32_bank -> emr_ofst );
805
821
822
+ /* reserve Secure events */
823
+ if (stm32_bank -> seccfgr_ofst != UNDEF_REG )
824
+ chip_data -> event_reserved = readl_relaxed (base + stm32_bank -> seccfgr_ofst );
825
+
806
826
pr_info ("%pOF: bank%d\n" , node , bank_idx );
807
827
808
828
return chip_data ;
@@ -908,6 +928,7 @@ static int stm32_exti_probe(struct platform_device *pdev)
908
928
return - ENOMEM ;
909
929
910
930
dev_set_drvdata (dev , host_data );
931
+ host_data -> dev = dev ;
911
932
912
933
/* check for optional hwspinlock which may be not available yet */
913
934
ret = of_hwspin_lock_get_id (np , 0 );
0 commit comments