gpio: nomadik: Finish conversion to use firmware node APIs
authorAndy Shevchenko <andy.shevchenko@gmail.com>
Sat, 2 Mar 2024 17:33:29 +0000 (19:33 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Sun, 3 Mar 2024 08:43:10 +0000 (09:43 +0100)
Previously driver got a few updates in order to replace OF APIs by
respective firmware node, however it was not finished to the logical
end, e.g., some APIs that has been used are still require OF node
to be passed. Finish that job by converting leftovers to use firmware
node APIs.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20240302173401.217830-1-andy.shevchenko@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/Kconfig
drivers/gpio/gpio-nomadik.c
drivers/pinctrl/nomadik/pinctrl-nomadik.c
include/linux/gpio/gpio-nomadik.h

index f633be517654a14aad2558865f89f44556ba110c..ef20ab921010d9c9909ac04d09f7a47b1bf219e7 100644 (file)
@@ -481,7 +481,6 @@ config GPIO_MXS
 config GPIO_NOMADIK
        bool "Nomadik GPIO driver"
        depends on ARCH_U8500 || ARCH_NOMADIK || MACH_EYEQ5 || COMPILE_TEST
-       depends on OF_GPIO
        select GPIOLIB_IRQCHIP
        help
          Say yes here to support the Nomadik SoC GPIO block. This block is also
index c9fd6631e0aa7665eaaf6f50169ac6ac5b5c1ec6..483086deb3974ff45096d948cf074a64e50084b2 100644 (file)
 #include <linux/gpio/driver.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
-#include <linux/of_device.h>
-#include <linux/of_platform.h>
+#include <linux/mod_devicetable.h>
 #include <linux/pinctrl/pinctrl.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/reset.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
@@ -504,7 +504,7 @@ static inline void nmk_gpio_dbg_show_one(struct seq_file *s,
  * it is the pin controller or GPIO driver. However we need to use the right
  * platform device when looking up resources so pay attention to pdev.
  */
-struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
+struct nmk_gpio_chip *nmk_gpio_populate_chip(struct fwnode_handle *fwnode,
                                             struct platform_device *pdev)
 {
        struct nmk_gpio_chip *nmk_chip;
@@ -517,9 +517,9 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
        u32 id, ngpio;
        int ret;
 
-       gpio_dev = bus_find_device_by_of_node(&platform_bus_type, np);
+       gpio_dev = bus_find_device_by_fwnode(&platform_bus_type, fwnode);
        if (!gpio_dev) {
-               pr_err("populate \"%pOFn\": device not found\n", np);
+               dev_err(&pdev->dev, "populate \"%pfwP\": device not found\n", fwnode);
                return ERR_PTR(-ENODEV);
        }
        gpio_pdev = to_platform_device(gpio_dev);
@@ -624,7 +624,6 @@ static const struct irq_chip nmk_irq_chip = {
 static int nmk_gpio_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct device_node *np = dev->of_node;
        struct nmk_gpio_chip *nmk_chip;
        struct gpio_irq_chip *girq;
        bool supports_sleepmode;
@@ -632,7 +631,7 @@ static int nmk_gpio_probe(struct platform_device *pdev)
        int irq;
        int ret;
 
-       nmk_chip = nmk_gpio_populate_chip(np, pdev);
+       nmk_chip = nmk_gpio_populate_chip(dev_fwnode(dev), pdev);
        if (IS_ERR(nmk_chip)) {
                dev_err(dev, "could not populate nmk chip struct\n");
                return PTR_ERR(nmk_chip);
index 7849144b3b8028246b4838d81da8200794e4af49..47d5484f6bdf331044d04d365417e64215ef9d14 100644 (file)
@@ -1190,8 +1190,8 @@ static int nmk_pinctrl_resume(struct device *dev)
 
 static int nmk_pinctrl_probe(struct platform_device *pdev)
 {
-       struct device_node *np = pdev->dev.of_node;
-       struct device_node *prcm_np;
+       struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev);
+       struct fwnode_handle *prcm_fwnode;
        struct nmk_pinctrl *npct;
        uintptr_t version = 0;
        int i;
@@ -1216,28 +1216,27 @@ static int nmk_pinctrl_probe(struct platform_device *pdev)
         * or after this point: it shouldn't matter as the APIs are orthogonal.
         */
        for (i = 0; i < NMK_MAX_BANKS; i++) {
-               struct device_node *gpio_np;
+               struct fwnode_handle *gpio_fwnode;
                struct nmk_gpio_chip *nmk_chip;
 
-               gpio_np = of_parse_phandle(np, "nomadik-gpio-chips", i);
-               if (!gpio_np)
+               gpio_fwnode = fwnode_find_reference(fwnode, "nomadik-gpio-chips", i);
+               if (IS_ERR(gpio_fwnode))
                        continue;
 
-               dev_info(&pdev->dev, "populate NMK GPIO %d \"%pOFn\"\n",
-                        i, gpio_np);
-               nmk_chip = nmk_gpio_populate_chip(gpio_np, pdev);
+               dev_info(&pdev->dev, "populate NMK GPIO %d \"%pfwP\"\n", i, gpio_fwnode);
+               nmk_chip = nmk_gpio_populate_chip(gpio_fwnode, pdev);
                if (IS_ERR(nmk_chip))
                        dev_err(&pdev->dev,
                                "could not populate nmk chip struct - continue anyway\n");
-               of_node_put(gpio_np);
+               fwnode_handle_put(gpio_fwnode);
                /* We are NOT compatible with mobileye,eyeq5-gpio. */
                BUG_ON(nmk_chip->is_mobileye_soc);
        }
 
-       prcm_np = of_parse_phandle(np, "prcm", 0);
-       if (prcm_np) {
-               npct->prcm_base = of_iomap(prcm_np, 0);
-               of_node_put(prcm_np);
+       prcm_fwnode = fwnode_find_reference(fwnode, "prcm", 0);
+       if (!IS_ERR(prcm_fwnode)) {
+               npct->prcm_base = fwnode_iomap(prcm_fwnode, 0);
+               fwnode_handle_put(prcm_fwnode);
        }
        if (!npct->prcm_base) {
                if (version == PINCTRL_NMK_STN8815) {
index 9bdb09fda4c909708c910c4c7ca814c107b6decb..4a95ea7935fb390c21b0951be5926342ca0ef01a 100644 (file)
@@ -2,6 +2,8 @@
 #ifndef __LINUX_GPIO_NOMADIK_H
 #define __LINUX_GPIO_NOMADIK_H
 
+struct fwnode_handle;
+
 /* Package definitions */
 #define PINCTRL_NMK_STN8815    0
 #define PINCTRL_NMK_DB8500     1
@@ -263,7 +265,7 @@ void __nmk_gpio_make_output(struct nmk_gpio_chip *nmk_chip,
                            unsigned int offset, int val);
 void __nmk_gpio_set_slpm(struct nmk_gpio_chip *nmk_chip, unsigned int offset,
                         enum nmk_gpio_slpm mode);
-struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
+struct nmk_gpio_chip *nmk_gpio_populate_chip(struct fwnode_handle *fwnode,
                                             struct platform_device *pdev);
 
 /* Symbols declared in pinctrl-nomadik used by gpio-nomadik. */