mfd/power: ab8500: Push algorithm to power supply code
authorLinus Walleij <linus.walleij@linaro.org>
Fri, 12 Mar 2021 08:36:03 +0000 (09:36 +0100)
committerLee Jones <lee.jones@linaro.org>
Mon, 22 Mar 2021 14:55:51 +0000 (14:55 +0000)
The charging algorithm header is only used locally in the
power supply subsystem so push this down into
drivers/power/supply and rename from the confusing
"ux500_chargalg.h" to "ab8500-chargalg.h" for clarity:
it is only used with the AB8500.

This is another remnant of non-DT code needing to pass
data from boardfiles, which we don't do anymore.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/power/supply/ab8500-chargalg.h [new file with mode: 0644]
drivers/power/supply/ab8500_charger.c
drivers/power/supply/abx500_chargalg.c
drivers/power/supply/pm2301_charger.c
include/linux/mfd/abx500/ux500_chargalg.h [deleted file]

diff --git a/drivers/power/supply/ab8500-chargalg.h b/drivers/power/supply/ab8500-chargalg.h
new file mode 100644 (file)
index 0000000..94a6f90
--- /dev/null
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) ST-Ericsson SA 2012
+ * Author: Johan Gardsmark <johan.gardsmark@stericsson.com> for ST-Ericsson.
+ */
+
+#ifndef _AB8500_CHARGALG_H_
+#define _AB8500_CHARGALG_H_
+
+#include <linux/power_supply.h>
+
+/*
+ * Valid only for supplies of type:
+ * - POWER_SUPPLY_TYPE_MAINS,
+ * - POWER_SUPPLY_TYPE_USB,
+ * because only them store as drv_data pointer to struct ux500_charger.
+ */
+#define psy_to_ux500_charger(x) power_supply_get_drvdata(psy)
+
+/* Forward declaration */
+struct ux500_charger;
+
+struct ux500_charger_ops {
+       int (*enable) (struct ux500_charger *, int, int, int);
+       int (*check_enable) (struct ux500_charger *, int, int);
+       int (*kick_wd) (struct ux500_charger *);
+       int (*update_curr) (struct ux500_charger *, int);
+};
+
+/**
+ * struct ux500_charger - power supply ux500 charger sub class
+ * @psy                        power supply base class
+ * @ops                        ux500 charger operations
+ * @max_out_volt       maximum output charger voltage in mV
+ * @max_out_curr       maximum output charger current in mA
+ * @enabled            indicates if this charger is used or not
+ * @external           external charger unit (pm2xxx)
+ */
+struct ux500_charger {
+       struct power_supply *psy;
+       struct ux500_charger_ops ops;
+       int max_out_volt;
+       int max_out_curr;
+       int wdt_refresh;
+       bool enabled;
+       bool external;
+};
+
+extern struct blocking_notifier_head charger_notifier_list;
+
+#endif /* _AB8500_CHARGALG_H_ */
index 50989a5ec95c2d170154d67d5d83279653b25927..a9be10eb2c22e0904b004d7cf4e773e3a0bb34fe 100644 (file)
 #include <linux/mfd/core.h>
 #include <linux/mfd/abx500/ab8500.h>
 #include <linux/mfd/abx500.h>
-#include <linux/mfd/abx500/ux500_chargalg.h>
 #include <linux/usb/otg.h>
 #include <linux/mutex.h>
 #include <linux/iio/consumer.h>
 
 #include "ab8500-bm.h"
+#include "ab8500-chargalg.h"
 
 /* Charger constants */
 #define NO_PW_CONN                     0
index 5b28d58041b4b867a1ac77aec636a7dd5ff455d7..f5b792243727dfce09cd1552558e8853e74ede59 100644 (file)
 #include <linux/mfd/core.h>
 #include <linux/mfd/abx500.h>
 #include <linux/mfd/abx500/ab8500.h>
-#include <linux/mfd/abx500/ux500_chargalg.h>
 #include <linux/notifier.h>
 
 #include "ab8500-bm.h"
+#include "ab8500-chargalg.h"
 
 /* Watchdog kick interval */
 #define CHG_WD_INTERVAL                        (6 * HZ)
index 5aeff75db33b415618e6773b4d31755027c9d222..d53e0c37c0590c8551ea17b971af47d02630c27b 100644 (file)
 #include <linux/i2c.h>
 #include <linux/workqueue.h>
 #include <linux/mfd/abx500/ab8500.h>
-#include <linux/mfd/abx500/ux500_chargalg.h>
 #include <linux/pm2301_charger.h>
 #include <linux/gpio.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm.h>
 
 #include "ab8500-bm.h"
+#include "ab8500-chargalg.h"
 #include "pm2301_charger.h"
 
 #define to_pm2xxx_charger_ac_device_info(x) container_of((x), \
diff --git a/include/linux/mfd/abx500/ux500_chargalg.h b/include/linux/mfd/abx500/ux500_chargalg.h
deleted file mode 100644 (file)
index 9b97d28..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright (C) ST-Ericsson SA 2012
- * Author: Johan Gardsmark <johan.gardsmark@stericsson.com> for ST-Ericsson.
- */
-
-#ifndef _UX500_CHARGALG_H
-#define _UX500_CHARGALG_H
-
-#include <linux/power_supply.h>
-
-/*
- * Valid only for supplies of type:
- * - POWER_SUPPLY_TYPE_MAINS,
- * - POWER_SUPPLY_TYPE_USB,
- * because only them store as drv_data pointer to struct ux500_charger.
- */
-#define psy_to_ux500_charger(x) power_supply_get_drvdata(psy)
-
-/* Forward declaration */
-struct ux500_charger;
-
-struct ux500_charger_ops {
-       int (*enable) (struct ux500_charger *, int, int, int);
-       int (*check_enable) (struct ux500_charger *, int, int);
-       int (*kick_wd) (struct ux500_charger *);
-       int (*update_curr) (struct ux500_charger *, int);
-};
-
-/**
- * struct ux500_charger - power supply ux500 charger sub class
- * @psy                        power supply base class
- * @ops                        ux500 charger operations
- * @max_out_volt       maximum output charger voltage in mV
- * @max_out_curr       maximum output charger current in mA
- * @enabled            indicates if this charger is used or not
- * @external           external charger unit (pm2xxx)
- */
-struct ux500_charger {
-       struct power_supply *psy;
-       struct ux500_charger_ops ops;
-       int max_out_volt;
-       int max_out_curr;
-       int wdt_refresh;
-       bool enabled;
-       bool external;
-};
-
-extern struct blocking_notifier_head charger_notifier_list;
-
-#endif