mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-27 14:43:58 +08:00
7051d8e630
* update power/reset drivers to use kernel restart handler * add power off driver for i.mx6 * add DT support for gpio-charger -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABCgAGBQJUjv52AAoJENju1/PIO/qaESIP/3rRE/Gw1fmfX+F1wN+jXQao WXw2JW/IUQG0TQlpTnEqPQQu+H48dX58MbpNVSLy2O7Z4XiMRDG2HkEduyJYGm+P 37pfgiTH9Vj7MJ0EnNK3lLrQmF1l+yNHIjZUGLPEjbKmXSzJYPHwNhtC5U9/QooY igRwKC51bBw6of6pPaIYP6nxQeaNVgI3MaOnJ1+glLc0uQuy5mc4gODL6yCEkvuR WCsyJi226m/dBD+ZgejSet7kJS3JG4dR0GuqZkJ22DS5wKbwKrgXfOiVl+xrgCwR FqbvnZbscr+jt/xFJsAT5zqtvHNgxx37XVwkV3nHsKX8UugYg3rCB5T/mlgNj+m/ Cg5BePP84O1NMJHYXSj7Wo6BYYoFJO8ucT0uIKpcci3UyvtqWcMXzptNjkAtylw1 P+0EtP7HL4jBLJ5Snd0Je47w2mztmaJmqCc9LU8odznlFbaJ25X3chf3zqAoKdpY Lqe1XWxi5HtLNmuX/NsNhw0tdxuSiH5e2r7yM5Bwtm4uh4Yx9Ab9TEtloF3u+en5 ALR88cryxbP0zu0K/HFUeoM3v7mqH3x29NqAsSpY1D6p87308FUa1rkvYMlHwcFD Y2W2iZhmxnE5Bi9OTpfDgGQYNEUiELWmMDi3S3aSwb0QM9UWsi043LGMQfpG5QCn +xKTKJDNJsHAX5jYDuDY =v7l/ -----END PGP SIGNATURE----- Merge tag 'for-v3.19' of git://git.infradead.org/battery-2.6 Pull power supply updates from Sebastian Reichel:: "Power supply and reset changes for the v3.19 series - update power/reset drivers to use kernel restart handler - add power off driver for i.mx6 - add DT support for gpio-charger" * tag 'for-v3.19' of git://git.infradead.org/battery-2.6: power: reset: adjust priority of simple syscon reboot driver power: ds2782_battery: Simplify the PM hooks power/reset: brcmstb: Register with kernel restart handler power/reset: hisi: Register with kernel restart handler power/reset: keystone: Register with kernel restart handler power/reset: axxia: Register with kernel restart handler power/reset: xgene: Register with kernel restart handler power/reset: xgene: Use mdelay instead of jiffies based timeout power/reset: xgene: Use local variable dev instead of pdev->dev power/reset: xgene: Drop devm_kfree power/reset: xgene: Return -ENOMEM if out of memory power/reset: vexpress: Register with kernel restart handler power: reset: imx-snvs-poweroff: add power off driver for i.mx6 power: gpio-charger: add device tree support dt-bindings: document gpio-charger bindings
130 lines
3.0 KiB
C
130 lines
3.0 KiB
C
/*
|
|
* Copyright (C) 2013 Broadcom Corporation
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation version 2.
|
|
*
|
|
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
|
|
* kind, whether express or implied; without even the implied warranty
|
|
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include <linux/device.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/init.h>
|
|
#include <linux/io.h>
|
|
#include <linux/jiffies.h>
|
|
#include <linux/notifier.h>
|
|
#include <linux/of_address.h>
|
|
#include <linux/of_irq.h>
|
|
#include <linux/of_platform.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/printk.h>
|
|
#include <linux/reboot.h>
|
|
#include <linux/regmap.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/mfd/syscon.h>
|
|
|
|
#define RESET_SOURCE_ENABLE_REG 1
|
|
#define SW_MASTER_RESET_REG 2
|
|
|
|
static struct regmap *regmap;
|
|
static u32 rst_src_en;
|
|
static u32 sw_mstr_rst;
|
|
|
|
static int brcmstb_restart_handler(struct notifier_block *this,
|
|
unsigned long mode, void *cmd)
|
|
{
|
|
int rc;
|
|
u32 tmp;
|
|
|
|
rc = regmap_write(regmap, rst_src_en, 1);
|
|
if (rc) {
|
|
pr_err("failed to write rst_src_en (%d)\n", rc);
|
|
return NOTIFY_DONE;
|
|
}
|
|
|
|
rc = regmap_read(regmap, rst_src_en, &tmp);
|
|
if (rc) {
|
|
pr_err("failed to read rst_src_en (%d)\n", rc);
|
|
return NOTIFY_DONE;
|
|
}
|
|
|
|
rc = regmap_write(regmap, sw_mstr_rst, 1);
|
|
if (rc) {
|
|
pr_err("failed to write sw_mstr_rst (%d)\n", rc);
|
|
return NOTIFY_DONE;
|
|
}
|
|
|
|
rc = regmap_read(regmap, sw_mstr_rst, &tmp);
|
|
if (rc) {
|
|
pr_err("failed to read sw_mstr_rst (%d)\n", rc);
|
|
return NOTIFY_DONE;
|
|
}
|
|
|
|
while (1)
|
|
;
|
|
|
|
return NOTIFY_DONE;
|
|
}
|
|
|
|
static struct notifier_block brcmstb_restart_nb = {
|
|
.notifier_call = brcmstb_restart_handler,
|
|
.priority = 128,
|
|
};
|
|
|
|
static int brcmstb_reboot_probe(struct platform_device *pdev)
|
|
{
|
|
int rc;
|
|
struct device_node *np = pdev->dev.of_node;
|
|
|
|
regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
|
|
if (IS_ERR(regmap)) {
|
|
pr_err("failed to get syscon phandle\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
rc = of_property_read_u32_index(np, "syscon", RESET_SOURCE_ENABLE_REG,
|
|
&rst_src_en);
|
|
if (rc) {
|
|
pr_err("can't get rst_src_en offset (%d)\n", rc);
|
|
return -EINVAL;
|
|
}
|
|
|
|
rc = of_property_read_u32_index(np, "syscon", SW_MASTER_RESET_REG,
|
|
&sw_mstr_rst);
|
|
if (rc) {
|
|
pr_err("can't get sw_mstr_rst offset (%d)\n", rc);
|
|
return -EINVAL;
|
|
}
|
|
|
|
rc = register_restart_handler(&brcmstb_restart_nb);
|
|
if (rc)
|
|
dev_err(&pdev->dev,
|
|
"cannot register restart handler (err=%d)\n", rc);
|
|
|
|
return rc;
|
|
}
|
|
|
|
static const struct of_device_id of_match[] = {
|
|
{ .compatible = "brcm,brcmstb-reboot", },
|
|
{},
|
|
};
|
|
|
|
static struct platform_driver brcmstb_reboot_driver = {
|
|
.probe = brcmstb_reboot_probe,
|
|
.driver = {
|
|
.name = "brcmstb-reboot",
|
|
.of_match_table = of_match,
|
|
},
|
|
};
|
|
|
|
static int __init brcmstb_reboot_init(void)
|
|
{
|
|
return platform_driver_probe(&brcmstb_reboot_driver,
|
|
brcmstb_reboot_probe);
|
|
}
|
|
subsys_initcall(brcmstb_reboot_init);
|