# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/linux/0200-riscv-sifive-reboot.patch # Copyright (C) 2021 - 2022 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License version 2 as used by the T2 SDE. # --- T2-COPYRIGHT-NOTE-END --- --- ./include/linux/mfd/da9063/core.h.orig 2021-07-20 11:58:26.803336163 +0200 +++ ./include/linux/mfd/da9063/core.h 2021-07-20 11:59:01.951257914 +0200 @@ -85,6 +85,9 @@ int chip_irq; unsigned int irq_base; struct regmap_irq_chip_data *regmap_irq; + + /* Restart */ + struct notifier_block restart_handler; }; int da9063_device_init(struct da9063 *da9063, unsigned int irq); --- ./drivers/mfd/da9063-core.c.orig 2021-07-20 12:00:24.843080267 +0200 +++ ./drivers/mfd/da9063-core.c 2021-07-20 14:55:59.528014000 +0200 @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -158,6 +159,20 @@ return ret; } +static int da9063_restart_notify(struct notifier_block *this, + unsigned long mode, void *cmd) +{ + struct da9063 *da9063 = container_of(this, struct da9063, restart_handler); + + regmap_write(da9063->regmap, DA9063_REG_PAGE_CON, 0x00); + regmap_write(da9063->regmap, DA9063_AD_REG_ALARM_Y, 0x20); + regmap_write(da9063->regmap, DA9063_AD_REG_SECOND_A, 0x80); + regmap_write(da9063->regmap, DA9063_REG_EVENT_A, 0x4); + regmap_write(da9063->regmap, DA9063_REG_CONTROL_F, 0x2); + + return NOTIFY_DONE; +} + int da9063_device_init(struct da9063 *da9063, unsigned int irq) { int ret; @@ -197,6 +212,12 @@ } } + da9063->restart_handler.notifier_call = da9063_restart_notify; + da9063->restart_handler.priority = 129; + ret = register_restart_handler(&da9063->restart_handler); + if (ret) dev_err(da9063->dev, "Failed to register restart handler\n"); + else devm_add_action(da9063->dev, (void(*)(void*))unregister_restart_handler, &da9063->restart_handler); + return ret; }