siflower: add ngpios property to gpio-siflower
authorChuanhong Guo <gch981213@gmail.com>
Tue, 8 Oct 2024 06:16:15 +0000 (14:16 +0800)
committerChuanhong Guo <gch981213@gmail.com>
Wed, 5 Feb 2025 03:08:37 +0000 (11:08 +0800)
The same GPIO controller is found on all current Siflower SoCs,
with different number of GPIOs. Add ngpios property instead of
specifying it with dt match data.

Link: https://github.com/openwrt/openwrt/pull/17115
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
target/linux/siflower/dts/sf19a2890.dtsi
target/linux/siflower/files-6.6/drivers/gpio/gpio-siflower.c

index b8f1cec83ebd2f03bed3455e10d84edbfbbd2866..645cb8beb2a2c4c9dbc2592a2d36e665b56ccfe7 100644 (file)
 
                        gpio-controller;
                        #gpio-cells = <2>;
+                       ngpios = <49>;
                        gpio-ranges = <&pinctrl 0 0 49>;
 
                        interrupt-controller;
index bd3d8906b4454053d289068e7750692a0d0986bb..4253a84bf43580427e4ca8aca0d5f1a14b94ec18 100644 (file)
@@ -255,7 +255,10 @@ static int sf_gpio_probe(struct platform_device *pdev)
        u32 ngpios, ngroups;
        int ret, i;
 
-       ngpios = (unsigned int) device_get_match_data(dev);
+       ret = of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios);
+       if (ret)
+               return ret;
+
        ngroups = DIV_ROUND_UP(ngpios, GPIOS_PER_GROUP);
        priv = devm_kzalloc(dev, struct_size(priv, irq, ngroups), GFP_KERNEL);
        if (!priv)
@@ -323,7 +326,7 @@ static int sf_gpio_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id sf_gpio_ids[] = {
-       { .compatible = "siflower,sf19a2890-gpio", .data = (void *)49 },
+       { .compatible = "siflower,sf19a2890-gpio" },
        {},
 };
 MODULE_DEVICE_TABLE(of, sf_gpio_ids);