Commit 44f89c6d authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull power supply and reset updates from Sebastian Reichel:
 "New features:
   - axp20x_usb_power: report USB type

  Cleanups:
   - convert lots of drivers to use devm_power_supply_register()
   - convert lots of reset drivers to use devm_register_sys_off_handler()
   - constify device_type and power_supply_class
   - axp20x_usb_power: use correct property to report input current limit
   - mm8013: correct handling of "not charging" status register
   - core: fix charge_behaviour formatting
   - minor fixes cleanups"

* tag 'for-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (66 commits)
  power: supply: core: fix charge_behaviour formatting
  power: supply: core: ease special formatting implementations
  power: supply: mm8013: fix "not charging" detection
  power: supply: move power_supply_attr_groups definition back to sysfs
  power: supply: core: simplify power_supply_class_init
  power: supply: core: add power_supply_for_each_device()
  power: supply: core: make power_supply_class constant
  power: supply: bq2415x_charger: report online status
  power: supply: core: move power_supply_attr_group into #ifdef block
  power: supply: core: Fix power_supply_init_attrs() stub
  power: supply: bq27xxx: Report charge full state correctly
  power: reset: rmobile-reset: Make sysc_base2 local
  power: supply: core: constify the struct device_type usage
  power: supply: axp288_fuel_gauge: Deny ROCK Pi X
  power: reset: rmobile-reset: Map correct MMIO resource
  power: reset: xgene-reboot: Fix a NULL vs IS_ERR() test
  power: supply: axp288_fuel_gauge: Add STCK1A* Intel Compute Sticks to the deny-list
  power: reset: syscon-poweroff: Use devm_register_sys_off_handler(POWER_OFF)
  power: reset: syscon-poweroff: Move device data into a struct
  power: reset: restart-poweroff: Use devm_register_sys_off_handler(POWER_OFF)
  ...
parents 80d80de4 4e61f1e9
Loading
Loading
Loading
Loading
+11 −19
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/reboot.h>
#include <linux/slab.h>

struct as3722_poweroff {
@@ -18,22 +19,18 @@ struct as3722_poweroff {
	struct as3722 *as3722;
};

static struct as3722_poweroff *as3722_pm_poweroff;

static void as3722_pm_power_off(void)
static int as3722_pm_power_off(struct sys_off_data *data)
{
	struct as3722_poweroff *as3722_pm_poweroff = data->cb_data;
	int ret;

	if (!as3722_pm_poweroff) {
		pr_err("AS3722 poweroff is not initialised\n");
		return;
	}

	ret = as3722_update_bits(as3722_pm_poweroff->as3722,
		AS3722_RESET_CONTROL_REG, AS3722_POWER_OFF, AS3722_POWER_OFF);
	if (ret < 0)
		dev_err(as3722_pm_poweroff->dev,
			"RESET_CONTROL_REG update failed, %d\n", ret);

	return NOTIFY_DONE;
}

static int as3722_poweroff_probe(struct platform_device *pdev)
@@ -54,18 +51,14 @@ static int as3722_poweroff_probe(struct platform_device *pdev)

	as3722_poweroff->as3722 = dev_get_drvdata(pdev->dev.parent);
	as3722_poweroff->dev = &pdev->dev;
	as3722_pm_poweroff = as3722_poweroff;
	if (!pm_power_off)
		pm_power_off = as3722_pm_power_off;

	return 0;
}
	return devm_register_sys_off_handler(as3722_poweroff->dev,
					     SYS_OFF_MODE_POWER_OFF,
					     SYS_OFF_PRIO_DEFAULT,
					     as3722_pm_power_off,
					     as3722_poweroff);

static void as3722_poweroff_remove(struct platform_device *pdev)
{
	if (pm_power_off == as3722_pm_power_off)
		pm_power_off = NULL;
	as3722_pm_poweroff = NULL;
	return 0;
}

static struct platform_driver as3722_poweroff_driver = {
@@ -73,7 +66,6 @@ static struct platform_driver as3722_poweroff_driver = {
		.name = "as3722-power-off",
	},
	.probe = as3722_poweroff_probe,
	.remove_new = as3722_poweroff_remove,
};

module_platform_driver(as3722_poweroff_driver);
+21 −34
Original line number Diff line number Diff line
@@ -16,13 +16,9 @@
struct atc260x_pwrc {
	struct device *dev;
	struct regmap *regmap;
	struct notifier_block restart_nb;
	int (*do_poweroff)(const struct atc260x_pwrc *pwrc, bool restart);
};

/* Global variable needed only for pm_power_off */
static struct atc260x_pwrc *atc260x_pwrc_data;

static int atc2603c_do_poweroff(const struct atc260x_pwrc *pwrc, bool restart)
{
	int ret, deep_sleep = 0;
@@ -165,18 +161,20 @@ static int atc2609a_init(const struct atc260x_pwrc *pwrc)
	return ret;
}

static void atc260x_pwrc_pm_handler(void)
static int atc260x_pwrc_pm_handler(struct sys_off_data *data)
{
	atc260x_pwrc_data->do_poweroff(atc260x_pwrc_data, false);
	struct atc260x_pwrc *pwrc = data->cb_data;

	pwrc->do_poweroff(pwrc, false);

	WARN_ONCE(1, "Unable to power off system\n");

	return NOTIFY_DONE;
}

static int atc260x_pwrc_restart_handler(struct notifier_block *nb,
					unsigned long mode, void *cmd)
static int atc260x_pwrc_restart_handler(struct sys_off_data *data)
{
	struct atc260x_pwrc *pwrc = container_of(nb, struct atc260x_pwrc,
						 restart_nb);
	struct atc260x_pwrc *pwrc = data->cb_data;
	pwrc->do_poweroff(pwrc, true);

	return NOTIFY_DONE;
@@ -194,8 +192,6 @@ static int atc260x_pwrc_probe(struct platform_device *pdev)

	priv->dev = &pdev->dev;
	priv->regmap = atc260x->regmap;
	priv->restart_nb.notifier_call = atc260x_pwrc_restart_handler;
	priv->restart_nb.priority = 192;

	switch (atc260x->ic_type) {
	case ATC2603C:
@@ -216,16 +212,20 @@ static int atc260x_pwrc_probe(struct platform_device *pdev)
	if (ret)
		return ret;

	platform_set_drvdata(pdev, priv);

	if (!pm_power_off) {
		atc260x_pwrc_data = priv;
		pm_power_off = atc260x_pwrc_pm_handler;
	} else {
		dev_warn(priv->dev, "Poweroff callback already assigned\n");
	}
	ret = devm_register_sys_off_handler(priv->dev,
					    SYS_OFF_MODE_POWER_OFF,
					    SYS_OFF_PRIO_DEFAULT,
					    atc260x_pwrc_pm_handler,
					    priv);
	if (ret)
		dev_err(priv->dev, "failed to register power-off handler: %d\n",
			ret);

	ret = register_restart_handler(&priv->restart_nb);
	ret = devm_register_sys_off_handler(priv->dev,
					    SYS_OFF_MODE_RESTART,
					    SYS_OFF_PRIO_HIGH,
					    atc260x_pwrc_restart_handler,
					    priv);
	if (ret)
		dev_err(priv->dev, "failed to register restart handler: %d\n",
			ret);
@@ -233,21 +233,8 @@ static int atc260x_pwrc_probe(struct platform_device *pdev)
	return ret;
}

static void atc260x_pwrc_remove(struct platform_device *pdev)
{
	struct atc260x_pwrc *priv = platform_get_drvdata(pdev);

	if (atc260x_pwrc_data == priv) {
		pm_power_off = NULL;
		atc260x_pwrc_data = NULL;
	}

	unregister_restart_handler(&priv->restart_nb);
}

static struct platform_driver atc260x_pwrc_driver = {
	.probe = atc260x_pwrc_probe,
	.remove_new = atc260x_pwrc_remove,
	.driver = {
		.name = "atc260x-pwrc",
	},
+6 −10
Original line number Diff line number Diff line
@@ -26,11 +26,10 @@
#define SC_EFUSE_INT_STATUS	0x180c
#define   EFUSE_READ_DONE	(1<<31)

static struct regmap *syscon;

static int axxia_restart_handler(struct notifier_block *this,
				 unsigned long mode, void *cmd)
static int axxia_restart_handler(struct sys_off_data *data)
{
	struct regmap *syscon = data->cb_data;

	/* Access Key (0xab) */
	regmap_write(syscon, SC_CRIT_WRITE_KEY, 0xab);
	/* Select internal boot from 0xffff0000 */
@@ -44,14 +43,10 @@ static int axxia_restart_handler(struct notifier_block *this,
	return NOTIFY_DONE;
}

static struct notifier_block axxia_restart_nb = {
	.notifier_call = axxia_restart_handler,
	.priority = 128,
};

static int axxia_reset_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct regmap *syscon;
	int err;

	syscon = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
@@ -60,7 +55,8 @@ static int axxia_reset_probe(struct platform_device *pdev)
		return PTR_ERR(syscon);
	}

	err = register_restart_handler(&axxia_restart_nb);
	err = devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART,
					    128, axxia_restart_handler, syscon);
	if (err)
		dev_err(dev, "cannot register restart handler (err=%d)\n", err);

+3 −8
Original line number Diff line number Diff line
@@ -15,8 +15,7 @@

static void __iomem *kona_reset_base;

static int kona_reset_handler(struct notifier_block *this,
				unsigned long mode, void *cmd)
static int kona_reset_handler(struct sys_off_data *data)
{
	/*
	 * A soft reset is triggered by writing a 0 to bit 0 of the soft reset
@@ -31,18 +30,14 @@ static int kona_reset_handler(struct notifier_block *this,
	return NOTIFY_DONE;
}

static struct notifier_block kona_reset_nb = {
	.notifier_call = kona_reset_handler,
	.priority = 128,
};

static int kona_reset_probe(struct platform_device *pdev)
{
	kona_reset_base = devm_platform_ioremap_resource(pdev, 0);
	if (IS_ERR(kona_reset_base))
		return PTR_ERR(kona_reset_base);

	return register_restart_handler(&kona_reset_nb);
	return devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART,
					     128, kona_reset_handler, NULL);
}

static const struct of_device_id of_match[] = {
+9 −7
Original line number Diff line number Diff line
@@ -70,12 +70,9 @@ static irqreturn_t gemini_powerbutton_interrupt(int irq, void *data)
	return IRQ_HANDLED;
}

/* This callback needs this static local as it has void as argument */
static struct gemini_powercon *gpw_poweroff;

static void gemini_poweroff(void)
static int gemini_poweroff(struct sys_off_data *data)
{
	struct gemini_powercon *gpw = gpw_poweroff;
	struct gemini_powercon *gpw = data->cb_data;
	u32 val;

	dev_crit(gpw->dev, "Gemini power off\n");
@@ -86,6 +83,8 @@ static void gemini_poweroff(void)
	val &= ~GEMINI_CTRL_ENABLE;
	val |= GEMINI_CTRL_SHUTDOWN;
	writel(val, gpw->base + GEMINI_PWC_CTRLREG);

	return NOTIFY_DONE;
}

static int gemini_poweroff_probe(struct platform_device *pdev)
@@ -148,8 +147,11 @@ static int gemini_poweroff_probe(struct platform_device *pdev)
	if (ret)
		return ret;

	pm_power_off = gemini_poweroff;
	gpw_poweroff = gpw;
	ret = devm_register_sys_off_handler(dev, SYS_OFF_MODE_POWER_OFF,
					    SYS_OFF_PRIO_DEFAULT,
					    gemini_poweroff, gpw);
	if (ret)
		return ret;

	dev_info(dev, "Gemini poweroff driver registered\n");

Loading