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

power: reset: imx-snvs-poweroff: add power off driver for i.mx6

This driver register pm_power_off with snvs power off function. If
your boards NOT use PMIC_ON_REQ to turn on/off external pmic, or use
other pin to do, please disable the driver in dts, otherwise, your
pm_power_off maybe overwrote by this driver.

Signed-off-by: Robin Gong <b38343@freescale.com>
Acked-By: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

authored by

Robin Gong and committed by
Shawn Guo
3db47dc0 cfd074ad

+99
+23
Documentation/devicetree/bindings/power_supply/imx-snvs-poweroff.txt
··· 1 + i.mx6 Poweroff Driver 2 + 3 + SNVS_LPCR in SNVS module can power off the whole system by pull 4 + PMIC_ON_REQ low if PMIC_ON_REQ is connected with external PMIC. 5 + If you don't want to use PMIC_ON_REQ as power on/off control, 6 + please set status='disabled' to disable this driver. 7 + 8 + Required Properties: 9 + -compatible: "fsl,sec-v4.0-poweroff" 10 + -reg: Specifies the physical address of the SNVS_LPCR register 11 + 12 + Example: 13 + snvs@020cc000 { 14 + compatible = "fsl,sec-v4.0-mon", "simple-bus"; 15 + #address-cells = <1>; 16 + #size-cells = <1>; 17 + ranges = <0 0x020cc000 0x4000>; 18 + ..... 19 + snvs_poweroff: snvs-poweroff@38 { 20 + compatible = "fsl,sec-v4.0-poweroff"; 21 + reg = <0x38 0x4>; 22 + }; 23 + }
+9
drivers/power/reset/Kconfig
··· 71 71 help 72 72 Reboot support for Hisilicon boards. 73 73 74 + config POWER_RESET_IMX 75 + bool "IMX6 power-off driver" 76 + depends on POWER_RESET && SOC_IMX6 77 + help 78 + This driver support power off external PMIC by PMIC_ON_REQ on i.mx6 79 + boards.If you want to use other pin to control external power,please 80 + say N here or disable in dts to make sure pm_power_off never be 81 + overwrote wrongly by this driver. 82 + 74 83 config POWER_RESET_MSM 75 84 bool "Qualcomm MSM power-off driver" 76 85 depends on ARCH_QCOM
+1
drivers/power/reset/Makefile
··· 6 6 obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o 7 7 obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o 8 8 obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o 9 + obj-$(CONFIG_POWER_RESET_IMX) += imx-snvs-poweroff.o 9 10 obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o 10 11 obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o 11 12 obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
+66
drivers/power/reset/imx-snvs-poweroff.c
··· 1 + /* Power off driver for i.mx6 2 + * Copyright (c) 2014, FREESCALE CORPORATION. All rights reserved. 3 + * 4 + * based on msm-poweroff.c 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 and 8 + * only version 2 as published by the Free Software Foundation. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + */ 16 + 17 + #include <linux/err.h> 18 + #include <linux/init.h> 19 + #include <linux/io.h> 20 + #include <linux/kernel.h> 21 + #include <linux/module.h> 22 + #include <linux/of.h> 23 + #include <linux/of_address.h> 24 + #include <linux/platform_device.h> 25 + 26 + static void __iomem *snvs_base; 27 + 28 + static void do_imx_poweroff(void) 29 + { 30 + u32 value = readl(snvs_base); 31 + 32 + /* set TOP and DP_EN bit */ 33 + writel(value | 0x60, snvs_base); 34 + } 35 + 36 + static int imx_poweroff_probe(struct platform_device *pdev) 37 + { 38 + snvs_base = of_iomap(pdev->dev.of_node, 0); 39 + if (!snvs_base) { 40 + dev_err(&pdev->dev, "failed to get memory\n"); 41 + return -ENODEV; 42 + } 43 + 44 + pm_power_off = do_imx_poweroff; 45 + return 0; 46 + } 47 + 48 + static const struct of_device_id of_imx_poweroff_match[] = { 49 + { .compatible = "fsl,sec-v4.0-poweroff", }, 50 + {}, 51 + }; 52 + MODULE_DEVICE_TABLE(of, of_imx_poweroff_match); 53 + 54 + static struct platform_driver imx_poweroff_driver = { 55 + .probe = imx_poweroff_probe, 56 + .driver = { 57 + .name = "imx-snvs-poweroff", 58 + .of_match_table = of_match_ptr(of_imx_poweroff_match), 59 + }, 60 + }; 61 + 62 + static int __init imx_poweroff_init(void) 63 + { 64 + return platform_driver_register(&imx_poweroff_driver); 65 + } 66 + device_initcall(imx_poweroff_init);