Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: tps6594: Add board power-off support

Add a system level power-off handler if the "system-power-controller"
flag is set for this device in the device tree.

A power-off request is triggered by writing the TRIGGER_I2C_0 bit (which
is actually just a convention and really depends on the freely
programmable FSM).

Co-developed-by: Job Sava <jsava@criticallink.com>
Signed-off-by: Job Sava <jsava@criticallink.com>
Signed-off-by: Michael Walle <mwalle@kernel.org>
Link: https://lore.kernel.org/r/20250826134631.1499936-4-mwalle@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Michael Walle and committed by
Lee Jones
2215a87b d766ca01

+20
+20
drivers/mfd/tps6594-core.c
··· 15 15 #include <linux/interrupt.h> 16 16 #include <linux/module.h> 17 17 #include <linux/of.h> 18 + #include <linux/reboot.h> 18 19 19 20 #include <linux/mfd/core.h> 20 21 #include <linux/mfd/tps6594.h> ··· 689 688 return ret; 690 689 } 691 690 691 + static int tps6594_power_off_handler(struct sys_off_data *data) 692 + { 693 + struct tps6594 *tps = data->cb_data; 694 + int ret; 695 + 696 + ret = regmap_update_bits(tps->regmap, TPS6594_REG_FSM_I2C_TRIGGERS, 697 + TPS6594_BIT_TRIGGER_I2C(0), TPS6594_BIT_TRIGGER_I2C(0)); 698 + if (ret) 699 + return notifier_from_errno(ret); 700 + 701 + return NOTIFY_DONE; 702 + } 703 + 692 704 int tps6594_device_init(struct tps6594 *tps, bool enable_crc) 693 705 { 694 706 struct device *dev = tps->dev; ··· 782 768 regmap_irq_get_domain(tps->irq_data)); 783 769 if (ret) 784 770 return dev_err_probe(dev, ret, "Failed to add RTC child device\n"); 771 + } 772 + 773 + if (of_device_is_system_power_controller(dev->of_node)) { 774 + ret = devm_register_power_off_handler(tps->dev, tps6594_power_off_handler, tps); 775 + if (ret) 776 + return dev_err_probe(dev, ret, "Failed to register power-off handler\n"); 785 777 } 786 778 787 779 return 0;