Re: [PATCH v3 2/3] power: reset: imx-snvs-poweroff: add power off driver for i.mx6

From: Mark Rutland
Date: Thu Sep 18 2014 - 13:53:28 EST


On Thu, Sep 18, 2014 at 03:21:27AM +0100, Robin Gong wrote:
> On Wed, Sep 17, 2014 at 06:52:44PM +0100, Mark Rutland wrote:
> > On Wed, Sep 17, 2014 at 10:57:59AM +0100, Robin Gong wrote:
> > > 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@xxxxxxxxxxxxx>
> > > ---
> > > .../bindings/power_supply/imx-snvs-poweroff.txt | 23 +++++++
> > > drivers/power/reset/Kconfig | 9 +++
> > > drivers/power/reset/Makefile | 1 +
> > > drivers/power/reset/imx-snvs-poweroff.c | 66 ++++++++++++++++++++
> > > 4 files changed, 99 insertions(+)
> > > create mode 100644 Documentation/devicetree/bindings/power_supply/imx-snvs-poweroff.txt
> > > create mode 100644 drivers/power/reset/imx-snvs-poweroff.c
> > >
> > > diff --git a/Documentation/devicetree/bindings/power_supply/imx-snvs-poweroff.txt b/Documentation/devicetree/bindings/power_supply/imx-snvs-poweroff.txt
> > > new file mode 100644
> > > index 0000000..6caf64e
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/power_supply/imx-snvs-poweroff.txt
> > > @@ -0,0 +1,23 @@
> > > +i.mx6 Poweroff Driver
> > > +
> > > +SNVS_LPCR in SNVS module can power off the whole system by pull
> > > +PMIC_ON_REQ low if PMIC_ON_REQ is connected with external PMIC.
> > > +If you don't want to use PMIC_ON_REQ as power on/off control,
> > > +please set status='disabled' to disable this driver.
> > > +
> > > +Required Properties:
> > > +-compatible: "fsl,sec-v4.0-poweroff"
> > > +-reg: Specifies the physical address of the SNVS_LPCR register
> >
> > As you describe above, this is part of the SNVS module. So why does this
> > need a separate node?
> >
> > Surely there should just be a property on the SNVS node that desribers
> > whether or not this can be used?
> >
> > Mark.
> >
> Yes, put this function in rtc-snvs make things easier, honestly,this is our way
> in internal tree. But looks more and more power off driver put in drivers/power
> /reset,so we decided to add new power off driver. If it is ok to register
> pm_power_off hook in drivers/rtc/rtc-snvs.c, I can drop this patch.

My view would be that the ability to power off the system is a feature
of some SNVS modules, and that the SNVS_LPCR register is not a
sufficiently large sub-block to be described separately. I am not a fan
of partitioning HW to match Linux implementation details rather than its
logical structure.

So, asuming the layout of the SNS block is well-defined I'd just expect
a top-level SNVS node, with a driver that can decompose the block
appropriately and portion it out to different drivers as necessary.

I am not familiar with the hardware, so perhaps that is not a good idea.
How variable is the SNVS block?

Mark.

> > > +
> > > +Example:
> > > + snvs@020cc000 {
> > > + compatible = "fsl,sec-v4.0-mon", "simple-bus";
> > > + #address-cells = <1>;
> > > + #size-cells = <1>;
> > > + ranges = <0 0x020cc000 0x4000>;
> > > + .....
> > > + snvs-poweroff@38 {
> > > + compatible = "fsl,sec-v4.0-poweroff";
> > > + reg = <0x38 0x4>;
> > > + };
> > > + }
> > > diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
> > > index ca41523..b26c547 100644
> > > --- a/drivers/power/reset/Kconfig
> > > +++ b/drivers/power/reset/Kconfig
> > > @@ -45,6 +45,15 @@ config POWER_RESET_HISI
> > > help
> > > Reboot support for Hisilicon boards.
> > >
> > > +config POWER_RESET_IMX
> > > + bool "IMX6 power-off driver"
> > > + depends on POWER_RESET && SOC_IMX6
> > > + help
> > > + This driver support power off external PMIC by PMIC_ON_REQ on i.mx6
> > > + boards.If you want to use other pin to control external power,please
> > > + say N here or disable in dts to make sure pm_power_off never be
> > > + overwrote wrongly by this driver.
> > > +
> > > config POWER_RESET_MSM
> > > bool "Qualcomm MSM power-off driver"
> > > depends on POWER_RESET && ARCH_QCOM
> > > diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
> > > index a42e70e..2524daf 100644
> > > --- a/drivers/power/reset/Makefile
> > > +++ b/drivers/power/reset/Makefile
> > > @@ -3,6 +3,7 @@ obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o
> > > obj-$(CONFIG_POWER_RESET_BRCMSTB) += brcmstb-reboot.o
> > > obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
> > > obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o
> > > +obj-$(CONFIG_POWER_RESET_IMX) += imx-snvs-poweroff.o
> > > obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o
> > > obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
> > > obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
> > > diff --git a/drivers/power/reset/imx-snvs-poweroff.c b/drivers/power/reset/imx-snvs-poweroff.c
> > > new file mode 100644
> > > index 0000000..d726ac4
> > > --- /dev/null
> > > +++ b/drivers/power/reset/imx-snvs-poweroff.c
> > > @@ -0,0 +1,66 @@
> > > +/* Power off driver for i.mx6
> > > + * Copyright (c) 2014, FREESCALE CORPORATION. All rights reserved.
> > > + *
> > > + * based on msm-poweroff.c
> > > + *
> > > + * This program is free software; you can redistribute it and/or modify
> > > + * it under the terms of the GNU General Public License version 2 and
> > > + * only version 2 as published by the Free Software Foundation.
> > > + *
> > > + * This program is distributed in the hope that it will be useful,
> > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > > + * GNU General Public License for more details.
> > > + *
> > > + */
> > > +
> > > +#include <linux/err.h>
> > > +#include <linux/init.h>
> > > +#include <linux/io.h>
> > > +#include <linux/kernel.h>
> > > +#include <linux/module.h>
> > > +#include <linux/of.h>
> > > +#include <linux/of_address.h>
> > > +#include <linux/platform_device.h>
> > > +
> > > +static void __iomem *snvs_base;
> > > +
> > > +static void do_imx_poweroff(void)
> > > +{
> > > + u32 value = readl(snvs_base);
> > > +
> > > + /* set TOP and DP_EN bit */
> > > + writel(value | 0x60, snvs_base);
> > > +}
> > > +
> > > +static int imx_poweroff_probe(struct platform_device *pdev)
> > > +{
> > > + snvs_base = of_iomap(pdev->dev.of_node, 0);
> > > + if (!snvs_base) {
> > > + dev_err(&pdev->dev, "failed to get memory\n");
> > > + return -EIO;
> > > + }
> > > +
> > > + pm_power_off = do_imx_poweroff;
> > > + return 0;
> > > +}
> > > +
> > > +static const struct of_device_id of_imx_poweroff_match[] = {
> > > + { .compatible = "fsl,sec-v4.0-poweroff", },
> > > + {},
> > > +};
> > > +MODULE_DEVICE_TABLE(of, of_imx_poweroff_match);
> > > +
> > > +static struct platform_driver imx_poweroff_driver = {
> > > + .probe = imx_poweroff_probe,
> > > + .driver = {
> > > + .name = "imx-snvs-poweroff",
> > > + .of_match_table = of_match_ptr(of_imx_poweroff_match),
> > > + },
> > > +};
> > > +
> > > +static int __init imx_poweroff_init(void)
> > > +{
> > > + return platform_driver_register(&imx_poweroff_driver);
> > > +}
> > > +device_initcall(imx_poweroff_init);
> > > --
> > > 1.7.9.5
> > >
> > >
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/