]> git.dujemihanovic.xyz Git - linux.git/commitdiff
Add poweroff support to 88pm88x driver v6.6-pxa1908
authorblacksilver <blacksilver@debdan.net>
Mon, 30 Oct 2023 13:48:05 +0000 (14:48 +0100)
committerDuje Mihanović <duje.mihanovic@skole.hr>
Sun, 5 Nov 2023 14:07:13 +0000 (15:07 +0100)
drivers/mfd/88pm88x-core.c
drivers/mfd/88pm88x-i2c.c
include/linux/mfd/88pm88x.h

index 04409a2b0356346dcfaedf8904ba39aeab3d5998..3ad8f5ff4de804e23bdd51a79e9215b78fb1985c 100644 (file)
@@ -554,31 +554,14 @@ void pm88x_dev_exit(struct pm88x_chip *chip)
        pm88x_irq_exit(chip);
 }
 
-void pm88x_power_off(void)
+static int pm88x_power_off(struct pm88x_chip *chip)
 {
-       pr_info("powers off the system.");
-       /* TODO: implement later */
-
-       for (;;)
-               cpu_relax();
+       return regmap_update_bits(chip->base_regmap,
+               PM88X_MISC_CONFIG1, PM88X_SW_PDOWN, PM88X_SW_PDOWN);
 }
 
-int pm88x_reboot_notifier_callback(struct notifier_block *this,
-                                  unsigned long code, void *unused)
+int pm88x_power_off_handler(struct sys_off_data *data)
 {
-       struct pm88x_chip *chip =
-               container_of(this, struct pm88x_chip, reboot_notifier);
-
-       switch (code) {
-       case SYS_HALT:
-       case SYS_POWER_OFF:
-               dev_info(chip->dev, "system is down.\n");
-               break;
-       case SYS_RESTART:
-       default:
-               dev_info(chip->dev, "system will reboot.\n");
-               break;
-       }
-
-       return 0;
-}
+       pm88x_power_off(data->cb_data);
+       return NOTIFY_DONE;
+}
\ No newline at end of file
index 7650014d9c9068e7a191f1d89f35d9895dc55cbe..ae4a09f3b34be2b885a9f7e405b9caf1dfab03c2 100644 (file)
@@ -86,10 +86,12 @@ static int pm88x_i2c_probe(struct i2c_client *client)
                goto err_apply_patch;
        }
 
-       pm_power_off = pm88x_power_off;
-
-       chip->reboot_notifier.notifier_call = pm88x_reboot_notifier_callback;
-       register_reboot_notifier(&(chip->reboot_notifier));
+       ret = devm_register_power_off_handler(chip->dev,
+                                       pm88x_power_off_handler, chip);
+       if (ret) {
+               dev_err(chip->dev, "failed to register power-off handler: %d\n", ret);
+               return ret;
+       }
 
        return 0;
 
index ceffd976d3b73c57128447956344f70c2a1d8241..188f7f31c660aab45c5c9faaa86b5420d31f7870 100644 (file)
@@ -200,10 +200,6 @@ int pm88x_apply_patch(struct pm88x_chip *chip);
 int pm88x_stepping_fixup(struct pm88x_chip *chip);
 int pm88x_apply_board_fixup(struct pm88x_chip *chip, struct device_node *np);
 
-struct pm88x_chip *pm88x_get_chip(void);
-void pm88x_set_chip(struct pm88x_chip *chip);
-void pm88x_power_off(void);
-int pm88x_reboot_notifier_callback(struct notifier_block *nb,
-                                  unsigned long code, void *unused);
+int pm88x_power_off_handler(struct sys_off_data *data);
 
 #endif /* __LINUX_MFD_88PM88X_H */