Release 4.17 drivers/power/reset/sc27xx-poweroff.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/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)
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_PM_SLEEP_SMP
int cpu = smp_processor_id();
freeze_secondary_cpus(cpu);
#endif
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Baolin Wang | 23 | 95.83% | 1 | 50.00% |
Colin Ian King | 1 | 4.17% | 1 | 50.00% |
Total | 24 | 100.00% | 2 | 100.00% |
static struct syscore_ops poweroff_syscore_ops = {
.shutdown = sc27xx_poweroff_shutdown,
};
static void sc27xx_poweroff_do_poweroff(void)
{
regmap_write(regmap, SC27XX_PWR_PD_HW, SC27XX_PWR_OFF_EN);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Baolin Wang | 17 | 100.00% | 1 | 100.00% |
Total | 17 | 100.00% | 1 | 100.00% |
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;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Baolin Wang | 54 | 100.00% | 1 | 100.00% |
Total | 54 | 100.00% | 1 | 100.00% |
static struct platform_driver sc27xx_poweroff_driver = {
.probe = sc27xx_poweroff_probe,
.driver = {
.name = "sc27xx-poweroff",
},
};
builtin_platform_driver(sc27xx_poweroff_driver);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Baolin Wang | 168 | 99.41% | 1 | 50.00% |
Colin Ian King | 1 | 0.59% | 1 | 50.00% |
Total | 169 | 100.00% | 2 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.