Skip to content

Commit 9832973

Browse files
sebhubdanieldegrasse
authored andcommitted
drivers: gpio: mchp_mss: Add reset support
Add support to reset the device through a reset controller. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
1 parent 9132ac4 commit 9832973

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

drivers/gpio/gpio_mchp_mss.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515

1616
#include <zephyr/drivers/gpio/gpio_utils.h>
1717

18+
/* Is MSS GPIO module 'resets' line property defined */
19+
#define MSS_GPIO_RESET_ENABLED DT_ANY_INST_HAS_PROP_STATUS_OKAY(resets)
20+
21+
#if MSS_GPIO_RESET_ENABLED
22+
#include <zephyr/drivers/reset.h>
23+
#endif
1824

1925
#define MSS_GPIO_INPUT_MODE 0x02
2026
#define MSS_GPIO_OUTPUT_MODE 0x05
@@ -48,6 +54,9 @@ struct mss_gpio_config {
4854
uintptr_t gpio_base_addr;
4955
uint32_t gpio_irq_base;
5056
mss_gpio_cfg_func_t gpio_cfg_func;
57+
#if MSS_GPIO_RESET_ENABLED
58+
struct reset_dt_spec reset_spec;
59+
#endif
5160
};
5261

5362
struct mss_gpio_data {
@@ -209,10 +218,15 @@ static DEVICE_API(gpio, mss_gpio_driver) = {
209218
static int mss_gpio_init(const struct device *dev)
210219
{
211220
volatile struct mss_gpio_t *gpio = DEV_GPIO(dev);
221+
const struct mss_gpio_config *cfg = DEV_GPIO_CFG(dev);
212222

213-
gpio->gpio_irq = 0xFFFFFFFFU;
223+
#if MSS_GPIO_RESET_ENABLED
224+
if (cfg->reset_spec.dev != NULL) {
225+
(void)reset_line_deassert_dt(&cfg->reset_spec);
226+
}
227+
#endif
214228

215-
const struct mss_gpio_config *cfg = DEV_GPIO_CFG(dev);
229+
gpio->gpio_irq = 0xFFFFFFFFU;
216230
/* Configure GPIO device */
217231
cfg->gpio_cfg_func();
218232
return 0;
@@ -239,7 +253,9 @@ static void mss_gpio_irq_handler(const struct device *dev)
239253
}, \
240254
.gpio_base_addr = DT_INST_REG_ADDR(n), \
241255
.gpio_irq_base = DT_INST_IRQN(n), \
242-
.gpio_cfg_func = gpio_mss_gpio_cfg_func_##n \
256+
.gpio_cfg_func = gpio_mss_gpio_cfg_func_##n, \
257+
IF_ENABLED(DT_INST_NODE_HAS_PROP(n, resets), \
258+
(.reset_spec = RESET_DT_SPEC_INST_GET(n),)) \
243259
}; \
244260
\
245261
DEVICE_DT_INST_DEFINE(n, \

dts/bindings/gpio/microchip,mpfs-gpio.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Microchip PolarFire SoC GPIO
55

66
compatible: "microchip,mpfs-gpio"
77

8-
include: [gpio-controller.yaml, base.yaml]
8+
include: [gpio-controller.yaml, base.yaml, reset-device.yaml]
99

1010
properties:
1111
reg:

0 commit comments

Comments
 (0)