mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-03 00:54:09 +08:00
a10c9c710f
Core: * Nothing Drivers: * at91-reset: cleanups, proper handling for sam9x60 * sc27xx, charger-manager: allow building as module * sc27xx: add support to read current charge capacity * axp288: more quirks for weird hardware * misc. fixes -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAl6I5QEACgkQ2O7X88g7 +pqAuw//a7kiTyhmRVd06OrYZRJNXjHB2bGqsZhW6skjgfZnIGqd8RAGEEFvfFkf ga9ChtIbWAscZwcud77t9NeNksQEBDjHaekL9LtQ1zuwYHWbpS2fZb89SHrGhk0q tJ/JegZpEWFH+6ZqmXrIxMV32/XSs2prWZRb+8RyuTq6mJE3DOaeL9e9rfkXUW1N s+wWW2a6JXAriFHgPk/BZMM/AUOlYpRaRmF77QvYK3Tfq2x2CeEvzHNr4e6fI9af LycVLkK5kjTXTnGyPn11LhGia8I+YGDB6NXyOEYD9wfnDRA/IlLAOYbuNzmxA+U7 oTm/swY8yHYpiOWM9A+I57c44wUIAp/rxIs6xafz6f1gPScClXKX9SQ0WjQfknCp vS7VZ4WjIjZSFrghND/CUjE0bEtbYNZC25T3NomU2MXuJAUvO83QjSaPG0Q9DzCw jVkrbS3gcq9ePAmZEvVhMh37By5IWzalM2DxRE9zuNxRZ2Px4T+zP6sJ4Wp4LWpK Ufss2WtjzpixYIEc3M3WjptXEaGWynpOnj69iDkPekSTOhuHH69ykiwyM4fA0jGN bttCV19e0HVSGxeXXyOEznwMqeBwv+EMgxEasm71TewEJzu/5caagihLCZuJv/Ji /O+T5uHiONhIHXKZMkYIa3SCcHSCKVBxbADuyCNUEWT7pehm2Uk= =BCS7 -----END PGP SIGNATURE----- Merge tag 'for-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply Pull power supply and reset changes from Sebastian Reichel: "Core: - Nothing Drivers: - at91-reset: cleanups, proper handling for sam9x60 - sc27xx, charger-manager: allow building as module - sc27xx: add support to read current charge capacity - axp288: more quirks for weird hardware - misc fixes" * tag 'for-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (26 commits) power: reset: sc27xx: Allow the SC27XX poweroff driver building into a module power: reset: sc27xx: Change to use cpu_down() power: reset: sc27xx: Power off the external subsystems' connection power: twl4030: Use scnprintf() for avoiding potential buffer overflow power: supply: bq27xxx_battery: Silence deferred-probe error power: reset: at91-reset: handle nrst async for sam9x60 power: reset: at91-reset: get rid of at91_reset_data power: reset: at91-reset: keep only one reset function power: reset: at91-reset: make at91sam9g45_restart() generic power: reset: at91-reset: introduce ramc_lpr to struct at91_reset power: reset: at91-reset: use r4 as tmp argument power: reset: at91-reset: introduce args member in at91_reset_data power: reset: at91-reset: introduce struct at91_reset_data power: reset: at91-reset: devm_kzalloc() for at91_reset data structure power: reset: at91-reset: pass rstc base address to at91_reset_status() power: reset: at91-reset: convert reset in pointer to struct at91_reset power: reset: at91-reset: add notifier block to struct at91_reset power: reset: at91-reset: add sclk to struct at91_reset power: reset: at91-reset: add ramc_base[] to struct at91_reset power: reset: at91-reset: introduce struct at91_reset ...
80 lines
1.9 KiB
C
80 lines
1.9 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (C) 2018 Spreadtrum Communications Inc.
|
|
* Copyright (C) 2018 Linaro Ltd.
|
|
*/
|
|
|
|
#include <linux/cpu.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/pm.h>
|
|
#include <linux/regmap.h>
|
|
#include <linux/syscore_ops.h>
|
|
|
|
#define SC27XX_PWR_PD_HW 0xc2c
|
|
#define SC27XX_PWR_OFF_EN BIT(0)
|
|
#define SC27XX_SLP_CTRL 0xdf0
|
|
#define SC27XX_LDO_XTL_EN BIT(3)
|
|
|
|
static struct regmap *regmap;
|
|
|
|
/*
|
|
* On Spreadtrum platform, we need power off system through external SC27xx
|
|
* series PMICs, and it is one similar SPI bus mapped by regmap to access PMIC,
|
|
* which is not fast io access.
|
|
*
|
|
* So before stopping other cores, we need release other cores' resource by
|
|
* taking cpus down to avoid racing regmap or spi mutex lock when poweroff
|
|
* system through PMIC.
|
|
*/
|
|
static void sc27xx_poweroff_shutdown(void)
|
|
{
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
int cpu;
|
|
|
|
for_each_online_cpu(cpu) {
|
|
if (cpu != smp_processor_id())
|
|
remove_cpu(cpu);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
static struct syscore_ops poweroff_syscore_ops = {
|
|
.shutdown = sc27xx_poweroff_shutdown,
|
|
};
|
|
|
|
static void sc27xx_poweroff_do_poweroff(void)
|
|
{
|
|
/* Disable the external subsys connection's power firstly */
|
|
regmap_write(regmap, SC27XX_SLP_CTRL, SC27XX_LDO_XTL_EN);
|
|
|
|
regmap_write(regmap, SC27XX_PWR_PD_HW, SC27XX_PWR_OFF_EN);
|
|
}
|
|
|
|
static int sc27xx_poweroff_probe(struct platform_device *pdev)
|
|
{
|
|
if (regmap)
|
|
return -EINVAL;
|
|
|
|
regmap = dev_get_regmap(pdev->dev.parent, NULL);
|
|
if (!regmap)
|
|
return -ENODEV;
|
|
|
|
pm_power_off = sc27xx_poweroff_do_poweroff;
|
|
register_syscore_ops(&poweroff_syscore_ops);
|
|
return 0;
|
|
}
|
|
|
|
static struct platform_driver sc27xx_poweroff_driver = {
|
|
.probe = sc27xx_poweroff_probe,
|
|
.driver = {
|
|
.name = "sc27xx-poweroff",
|
|
},
|
|
};
|
|
module_platform_driver(sc27xx_poweroff_driver);
|
|
|
|
MODULE_DESCRIPTION("Power off driver for SC27XX PMIC Device");
|
|
MODULE_AUTHOR("Baolin Wang <baolin.wang@unisoc.com>");
|
|
MODULE_LICENSE("GPL v2");
|