summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Vasut <[email protected]>2025-10-27 17:35:36 +0100
committerMarek Vasut <[email protected]>2025-11-06 20:09:58 +0100
commit01a15d76992e8ac5d332f1db0746f5f14570dc07 (patch)
tree94cc555df49859b3c0fc37ecabe0fbbaa9ab6536
parent1fe3a731df46edaf4402535751a5c4bad3c53fe4 (diff)
gpio: renesas: Wrap quirks in struct rcar_gpio_data
Wrap the RCAR_GPIO_HAS_INEN quirk in more flexible struct rcar_gpio_data {} in preparation for addition of Renesas R-Car Gen5 GPIO controller support. The Renesas R-Car Gen5 GPIO controller requires more than a single quirk to properly describe it, therefore increase the flexibility and introduce full match data structure, and use it throughout the driver. No functional change. Signed-off-by: Marek Vasut <[email protected]>
-rw-r--r--drivers/gpio/gpio-rcar.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 8853187e64e..fada6f4c624 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -28,9 +28,13 @@
DECLARE_GLOBAL_DATA_PTR;
+struct rcar_gpio_data {
+ u32 quirks;
+};
+
struct rcar_gpio_priv {
- void __iomem *regs;
- u32 quirks;
+ void __iomem *regs;
+ const struct rcar_gpio_data *data;
};
static int rcar_gpio_get_value(struct udevice *dev, unsigned offset)
@@ -65,6 +69,7 @@ static void rcar_gpio_set_direction(struct udevice *dev, unsigned offset,
bool output)
{
struct rcar_gpio_priv *priv = dev_get_priv(dev);
+ const struct rcar_gpio_data *data = priv->data;
void __iomem *regs = priv->regs;
/*
@@ -77,7 +82,7 @@ static void rcar_gpio_set_direction(struct udevice *dev, unsigned offset,
clrbits_le32(regs + GPIO_POSNEG, BIT(offset));
/* Select "Input Enable/Disable" in INEN */
- if (priv->quirks & RCAR_GPIO_HAS_INEN) {
+ if (data->quirks & RCAR_GPIO_HAS_INEN) {
if (output)
clrbits_le32(regs + GPIO_INEN, BIT(offset));
else
@@ -141,7 +146,7 @@ static int rcar_gpio_probe(struct udevice *dev)
int ret;
priv->regs = dev_read_addr_ptr(dev);
- priv->quirks = dev_get_driver_data(dev);
+ priv->data = (const struct rcar_gpio_data *)dev_get_driver_data(dev);
uc_priv->bank_name = dev->name;
ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, node, "gpio-ranges",
@@ -163,17 +168,24 @@ static int rcar_gpio_probe(struct udevice *dev)
return 0;
}
+static const struct rcar_gpio_data rcar_gpio_gen2_data = {
+};
+
+static const struct rcar_gpio_data rcar_gpio_gen3_data = {
+ .quirks = RCAR_GPIO_HAS_INEN,
+};
+
static const struct udevice_id rcar_gpio_ids[] = {
- { .compatible = "renesas,gpio-r8a7795" },
- { .compatible = "renesas,gpio-r8a7796" },
- { .compatible = "renesas,gpio-r8a77965" },
- { .compatible = "renesas,gpio-r8a77970" },
- { .compatible = "renesas,gpio-r8a77990" },
- { .compatible = "renesas,gpio-r8a77995" },
- { .compatible = "renesas,gpio-r8a779a0", .data = RCAR_GPIO_HAS_INEN },
- { .compatible = "renesas,rcar-gen2-gpio" },
- { .compatible = "renesas,rcar-gen3-gpio" },
- { .compatible = "renesas,rcar-gen4-gpio", .data = RCAR_GPIO_HAS_INEN },
+ { .compatible = "renesas,gpio-r8a7795", .data = (ulong)&rcar_gpio_gen2_data },
+ { .compatible = "renesas,gpio-r8a7796", .data = (ulong)&rcar_gpio_gen2_data },
+ { .compatible = "renesas,gpio-r8a77965", .data = (ulong)&rcar_gpio_gen2_data },
+ { .compatible = "renesas,gpio-r8a77970", .data = (ulong)&rcar_gpio_gen2_data },
+ { .compatible = "renesas,gpio-r8a77990", .data = (ulong)&rcar_gpio_gen2_data },
+ { .compatible = "renesas,gpio-r8a77995", .data = (ulong)&rcar_gpio_gen2_data },
+ { .compatible = "renesas,gpio-r8a779a0", .data = (ulong)&rcar_gpio_gen3_data },
+ { .compatible = "renesas,rcar-gen2-gpio", .data = (ulong)&rcar_gpio_gen2_data },
+ { .compatible = "renesas,rcar-gen3-gpio", .data = (ulong)&rcar_gpio_gen2_data },
+ { .compatible = "renesas,rcar-gen4-gpio", .data = (ulong)&rcar_gpio_gen3_data },
{ /* sentinel */ }
};