]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
reset: npcm: using syscon instead of device data
authorTomer Maimon <tmaimon77@gmail.com>
Sun, 17 Jul 2022 09:16:00 +0000 (12:16 +0300)
committerArnd Bergmann <arnd@arndb.de>
Tue, 19 Jul 2022 13:41:02 +0000 (15:41 +0200)
Using syscon device tree property instead of device data to handle the
NPCM general control registers.

In case the syscon not found the code still search for nuvoton,npcm750-gcr
to support DTS backward compatibility.

Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
drivers/reset/reset-npcm.c

index 2ea4d3136e15552f9edd6ed0aea47077fdd369bc..b08f8d8a1d63b17ce96cc9fca264b00ac0ab62e0 100644 (file)
@@ -138,8 +138,7 @@ static int npcm_reset_xlate(struct reset_controller_dev *rcdev,
 }
 
 static const struct of_device_id npcm_rc_match[] = {
-       { .compatible = "nuvoton,npcm750-reset",
-               .data = (void *)"nuvoton,npcm750-gcr" },
+       { .compatible = "nuvoton,npcm750-reset" },
        { }
 };
 
@@ -160,10 +159,15 @@ static int npcm_usb_reset(struct platform_device *pdev, struct npcm_rc_data *rc)
        gcr_dt = (const char *)
        of_match_device(dev->driver->of_match_table, dev)->data;
 
-       gcr_regmap = syscon_regmap_lookup_by_compatible(gcr_dt);
+       gcr_regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "nuvoton,sysgcr");
        if (IS_ERR(gcr_regmap)) {
-               dev_err(&pdev->dev, "Failed to find %s\n", gcr_dt);
-               return PTR_ERR(gcr_regmap);
+               dev_warn(&pdev->dev, "Failed to find nuvoton,sysgcr property, please update the device tree\n");
+               dev_info(&pdev->dev, "Using nuvoton,npcm750-gcr for Poleg backward compatibility\n");
+               gcr_regmap = syscon_regmap_lookup_by_compatible("nuvoton,npcm750-gcr");
+               if (IS_ERR(gcr_regmap)) {
+                       dev_err(&pdev->dev, "Failed to find nuvoton,npcm750-gcr");
+                       return PTR_ERR(gcr_regmap);
+               }
        }
 
        /* checking which USB device is enabled */