Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / drivers / sysreset / sysreset_syscon.c
index f19e80e6e4f65a02ac4739557ba2a52fdbc9f8ec..f64701aab3c834ad967a30f04b1ef3ca0a217e81 100644 (file)
@@ -13,6 +13,7 @@
 #include <regmap.h>
 #include <sysreset.h>
 #include <syscon.h>
+#include <linux/err.h>
 
 struct syscon_reboot_priv {
        struct regmap *regmap;
@@ -23,6 +24,10 @@ struct syscon_reboot_priv {
 static int syscon_reboot_request(struct udevice *dev, enum sysreset_t type)
 {
        struct syscon_reboot_priv *priv = dev_get_priv(dev);
+       ulong driver_data = dev_get_driver_data(dev);
+
+       if (type != driver_data)
+               return -EPROTONOSUPPORT;
 
        regmap_write(priv->regmap, priv->offset, priv->mask);
 
@@ -35,19 +40,10 @@ static struct sysreset_ops syscon_reboot_ops = {
 
 int syscon_reboot_probe(struct udevice *dev)
 {
-       struct udevice *syscon;
        struct syscon_reboot_priv *priv = dev_get_priv(dev);
-       int err;
-
-       err = uclass_get_device_by_phandle(UCLASS_SYSCON, dev,
-                                          "regmap", &syscon);
-       if (err) {
-               pr_err("unable to find syscon device\n");
-               return err;
-       }
 
-       priv->regmap = syscon_get_regmap(syscon);
-       if (!priv->regmap) {
+       priv->regmap = syscon_regmap_lookup_by_phandle(dev, "regmap");
+       if (IS_ERR(priv->regmap)) {
                pr_err("unable to find regmap\n");
                return -ENODEV;
        }
@@ -59,7 +55,8 @@ int syscon_reboot_probe(struct udevice *dev)
 }
 
 static const struct udevice_id syscon_reboot_ids[] = {
-       { .compatible = "syscon-reboot" },
+       { .compatible = "syscon-reboot", .data = SYSRESET_COLD },
+       { .compatible = "syscon-poweroff", .data = SYSRESET_POWER_OFF },
        { /* sentinel */ }
 };