Skip to content

Commit 397c48a

Browse files
soburifabiobaltieri
authored andcommitted
dts: arm: renesas: ra4: Use renesas,ra-pinctrl-pfs driver
Switch the pinctrl driver to renesas,ra-pinctrl-pfs which can be used with FSP. Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent af2021e commit 397c48a

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed

drivers/gpio/gpio_renesas_ra.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static int gpio_ra_pin_configure(const struct device *dev, gpio_pin_t pin, gpio_
144144
const enum gpio_int_trig trig = flags & (GPIO_INT_LOW_0 | GPIO_INT_HIGH_1);
145145
const struct gpio_ra_config *config = dev->config;
146146
struct gpio_ra_data *data = dev->data;
147-
struct pinctrl_ra_pin pincfg = {0};
147+
struct ra_pinctrl_soc_pin pincfg = {0};
148148

149149
if ((flags & GPIO_OUTPUT) && (flags & GPIO_INPUT)) {
150150
/* Pin cannot be configured as input and output */
@@ -155,25 +155,25 @@ static int gpio_ra_pin_configure(const struct device *dev, gpio_pin_t pin, gpio_
155155
}
156156

157157
if (flags & GPIO_OUTPUT) {
158-
pincfg.config |= BIT(PmnPFS_PDR_POS);
158+
pincfg.cfg |= BIT(R_PFS_PORT_PIN_PmnPFS_PDR_Pos);
159159
}
160160

161161
if (flags & GPIO_PULL_UP) {
162-
pincfg.config |= BIT(PmnPFS_PCR_POS);
162+
pincfg.cfg |= BIT(R_PFS_PORT_PIN_PmnPFS_PCR_Pos);
163163
}
164164

165165
if ((flags & GPIO_SINGLE_ENDED) && (flags & GPIO_LINE_OPEN_DRAIN)) {
166-
pincfg.config |= BIT(PmnPFS_NCODR_POS);
166+
pincfg.cfg |= BIT(R_PFS_PORT_PIN_PmnPFS_NCODR_Pos);
167167
}
168168

169169
if (flags & GPIO_INT_ENABLE) {
170-
pincfg.config |= BIT(PmnPFS_ISEL_POS);
170+
pincfg.cfg |= BIT(R_PFS_PORT_PIN_PmnPFS_ISEL_Pos);
171171
}
172172

173-
pincfg.config &= ~BIT(PmnPFS_PMR_POS);
173+
pincfg.cfg &= ~BIT(R_PFS_PORT_PIN_PmnPFS_PMR_Pos);
174174

175-
pincfg.pin = pin;
176-
pincfg.port = config->port;
175+
pincfg.pin_num = pin;
176+
pincfg.port_num = config->port;
177177

178178
if (flags & GPIO_INT_ENABLE) {
179179
const struct gpio_ra_irq_info *irq_info;
@@ -230,7 +230,7 @@ static int gpio_ra_pin_get_config(const struct device *dev, gpio_pin_t pin, gpio
230230
{
231231
const struct gpio_ra_config *config = dev->config;
232232
const struct gpio_ra_irq_info *irq_info;
233-
struct pinctrl_ra_pin pincfg;
233+
struct ra_pinctrl_soc_pin pincfg;
234234
ra_isr_handler cb;
235235
const void *cbarg;
236236
uint32_t intcfg;
@@ -239,22 +239,22 @@ static int gpio_ra_pin_get_config(const struct device *dev, gpio_pin_t pin, gpio
239239

240240
memset(flags, 0, sizeof(gpio_flags_t));
241241

242-
err = pinctrl_ra_query_config(config->port, pin, &pincfg);
242+
err = ra_pinctrl_query_config(config->port, pin, &pincfg);
243243
if (err < 0) {
244244
return err;
245245
}
246246

247-
if (pincfg.config & BIT(PmnPFS_PDR_POS)) {
247+
if (pincfg.cfg & BIT(R_PFS_PORT_PIN_PmnPFS_PDR_Pos)) {
248248
*flags |= GPIO_OUTPUT;
249249
} else {
250250
*flags |= GPIO_INPUT;
251251
}
252252

253-
if (pincfg.config & BIT(PmnPFS_ISEL_POS)) {
253+
if (pincfg.cfg & BIT(R_PFS_PORT_PIN_PmnPFS_ISEL_Pos)) {
254254
*flags |= GPIO_INT_ENABLE;
255255
}
256256

257-
if (pincfg.config & BIT(PmnPFS_PCR_POS)) {
257+
if (pincfg.cfg & BIT(R_PFS_PORT_PIN_PmnPFS_PCR_Pos)) {
258258
*flags |= GPIO_PULL_UP;
259259
}
260260

drivers/pinctrl/renesas/ra/pinctrl_ra.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,16 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintp
2626

2727
return 0;
2828
}
29+
30+
int ra_pinctrl_query_config(uint32_t port, uint32_t pin, pinctrl_soc_pin_t *pincfg)
31+
{
32+
if (port >= RA_PINCTRL_PORT_NUM || pin >= RA_PINCTRL_PIN_NUM) {
33+
return -EINVAL;
34+
}
35+
36+
pincfg->port_num = port;
37+
pincfg->pin_num = pin;
38+
39+
pincfg->cfg = R_PFS->PORT[port].PIN[pin].PmnPFS;
40+
return 0;
41+
}

dts/arm/renesas/ra/ra-cm4-common.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
};
241241

242242
pinctrl: pinctrl@40040800 {
243-
compatible = "renesas,ra-pinctrl";
243+
compatible = "renesas,ra-pinctrl-pfs";
244244
reg = <0x40040800 0x500 0x40040d03 0x1>;
245245
reg-names = "pfs", "pmisc_pwpr";
246246
status = "okay";

soc/renesas/ra/common_fsp/pinctrl_soc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#include <zephyr/dt-bindings/pinctrl/renesas/pinctrl-ra.h>
1414

15+
#define RA_PINCTRL_PORT_NUM ARRAY_SIZE(((R_PFS_Type *)0)->PORT)
16+
#define RA_PINCTRL_PIN_NUM ARRAY_SIZE(((R_PFS_PORT_Type *)0)->PIN)
1517
/**
1618
* @brief Type to hold a renesas ra pin's pinctrl configuration.
1719
*/
@@ -26,6 +28,8 @@ struct ra_pinctrl_soc_pin {
2628

2729
typedef struct ra_pinctrl_soc_pin pinctrl_soc_pin_t;
2830

31+
int ra_pinctrl_query_config(uint32_t port, uint32_t pin, pinctrl_soc_pin_t *pincfg);
32+
2933
/**
3034
* @brief Utility macro to initialize each pin.
3135
*

0 commit comments

Comments
 (0)