13
13
* is not supported in current version of GPIO CAT1 driver.
14
14
*/
15
15
16
- #define DT_DRV_COMPAT infineon_cat1_gpio
16
+ #define DT_DRV_COMPAT infineon_cat1_gpio
17
17
18
18
#include <zephyr/drivers/gpio.h>
19
19
#include <zephyr/drivers/gpio/gpio_utils.h>
@@ -28,9 +28,11 @@ LOG_MODULE_REGISTER(gpio_cat1, CONFIG_GPIO_LOG_LEVEL);
28
28
struct gpio_cat1_config {
29
29
/* gpio_driver_config needs to be first */
30
30
struct gpio_driver_config common ;
31
- GPIO_PRT_Type * regs ;
31
+ GPIO_PRT_Type * regs ;
32
32
uint8_t ngpios ;
33
+ #if (!CONFIG_SOC_FAMILY_INFINEON_CAT1C )
33
34
uint8_t intr_priority ;
35
+ #endif
34
36
};
35
37
36
38
/* Data structure */
@@ -96,8 +98,7 @@ static int gpio_cat1_configure(const struct device *dev, gpio_pin_t pin, gpio_fl
96
98
return 0 ;
97
99
}
98
100
99
- static int gpio_cat1_port_get_raw (const struct device * dev ,
100
- uint32_t * value )
101
+ static int gpio_cat1_port_get_raw (const struct device * dev , uint32_t * value )
101
102
{
102
103
const struct gpio_cat1_config * const cfg = dev -> config ;
103
104
GPIO_PRT_Type * const base = cfg -> regs ;
@@ -107,8 +108,7 @@ static int gpio_cat1_port_get_raw(const struct device *dev,
107
108
return 0 ;
108
109
}
109
110
110
- static int gpio_cat1_port_set_masked_raw (const struct device * dev ,
111
- uint32_t mask , uint32_t value )
111
+ static int gpio_cat1_port_set_masked_raw (const struct device * dev , uint32_t mask , uint32_t value )
112
112
{
113
113
const struct gpio_cat1_config * const cfg = dev -> config ;
114
114
GPIO_PRT_Type * const base = cfg -> regs ;
@@ -118,8 +118,7 @@ static int gpio_cat1_port_set_masked_raw(const struct device *dev,
118
118
return 0 ;
119
119
}
120
120
121
- static int gpio_cat1_port_set_bits_raw (const struct device * dev ,
122
- uint32_t mask )
121
+ static int gpio_cat1_port_set_bits_raw (const struct device * dev , uint32_t mask )
123
122
{
124
123
const struct gpio_cat1_config * const cfg = dev -> config ;
125
124
GPIO_PRT_Type * const base = cfg -> regs ;
@@ -129,8 +128,7 @@ static int gpio_cat1_port_set_bits_raw(const struct device *dev,
129
128
return 0 ;
130
129
}
131
130
132
- static int gpio_cat1_port_clear_bits_raw (const struct device * dev ,
133
- uint32_t mask )
131
+ static int gpio_cat1_port_clear_bits_raw (const struct device * dev , uint32_t mask )
134
132
{
135
133
const struct gpio_cat1_config * const cfg = dev -> config ;
136
134
GPIO_PRT_Type * const base = cfg -> regs ;
@@ -140,8 +138,7 @@ static int gpio_cat1_port_clear_bits_raw(const struct device *dev,
140
138
return 0 ;
141
139
}
142
140
143
- static int gpio_cat1_port_toggle_bits (const struct device * dev ,
144
- uint32_t mask )
141
+ static int gpio_cat1_port_toggle_bits (const struct device * dev , uint32_t mask )
145
142
{
146
143
const struct gpio_cat1_config * const cfg = dev -> config ;
147
144
GPIO_PRT_Type * const base = cfg -> regs ;
@@ -159,6 +156,7 @@ static uint32_t gpio_cat1_get_pending_int(const struct device *dev)
159
156
return GPIO_PRT_INTR_MASKED (base );
160
157
}
161
158
159
+ #if (!(CONFIG_SOC_FAMILY_INFINEON_CAT1C && CONFIG_CPU_CORTEX_M0PLUS ))
162
160
static void gpio_isr_handler (const struct device * dev )
163
161
{
164
162
const struct gpio_cat1_config * const cfg = dev -> config ;
@@ -173,9 +171,8 @@ static void gpio_isr_handler(const struct device *dev)
173
171
gpio_fire_callbacks (& ((struct gpio_cat1_data * const )(dev )-> data )-> callbacks , dev ,
174
172
pins );
175
173
}
176
-
177
-
178
174
}
175
+ #endif
179
176
180
177
static int gpio_cat1_pin_interrupt_configure (const struct device * dev , gpio_pin_t pin ,
181
178
enum gpio_int_mode mode , enum gpio_int_trig trig )
@@ -213,8 +210,7 @@ static int gpio_cat1_pin_interrupt_configure(const struct device *dev, gpio_pin_
213
210
return 0 ;
214
211
}
215
212
216
- static int gpio_cat1_manage_callback (const struct device * port ,
217
- struct gpio_callback * callback ,
213
+ static int gpio_cat1_manage_callback (const struct device * port , struct gpio_callback * callback ,
218
214
bool set )
219
215
{
220
216
return gpio_manage_callback (& ((struct gpio_cat1_data * const )(port )-> data )-> callbacks ,
@@ -233,13 +229,29 @@ static DEVICE_API(gpio, gpio_cat1_api) = {
233
229
.get_pending_int = gpio_cat1_get_pending_int ,
234
230
};
235
231
232
+ /* Interrupts are not currently supported on the Cat1C CM0+ */
233
+ #if (CONFIG_SOC_FAMILY_INFINEON_CAT1C )
234
+ #define INTR_PRIORITY (n )
235
+
236
+ #if (CONFIG_CPU_CORTEX_M0PLUS )
237
+ #define ENABLE_INT (n )
238
+ #else
239
+ #define ENABLE_INT (n ) ENABLE_SYS_INT(n, gpio_isr_handler);
240
+ #endif
241
+
242
+ #else
243
+ #define INTR_PRIORITY (n ) .intr_priority = DT_INST_IRQ_BY_IDX(n, 0, priority),
244
+
245
+ #define ENABLE_INT (n ) \
246
+ IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), gpio_isr_handler, \
247
+ DEVICE_DT_INST_GET(n), 0); \
248
+ irq_enable(DT_INST_IRQN(n));
249
+ #endif
250
+
236
251
#define GPIO_CAT1_INIT_FUNC (n ) \
237
252
static int gpio_cat1##n##_init(const struct device *dev) \
238
253
{ \
239
- IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), gpio_isr_handler, \
240
- DEVICE_DT_INST_GET(n), 0); \
241
- irq_enable(DT_INST_IRQN(n)); \
242
- \
254
+ ENABLE_INT(n) \
243
255
return 0; \
244
256
}
245
257
@@ -250,7 +262,7 @@ static DEVICE_API(gpio, gpio_cat1_api) = {
250
262
{ \
251
263
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(n), \
252
264
}, \
253
- .intr_priority = DT_INST_IRQ_BY_IDX(n, 0, priority), \
265
+ INTR_PRIORITY(n) \
254
266
.ngpios = DT_INST_PROP(n, ngpios), \
255
267
.regs = (GPIO_PRT_Type *)DT_INST_REG_ADDR(n), \
256
268
}; \
0 commit comments