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

From: Lothar WaÃmann
Date: Wed Sep 17 2014 - 07:12:34 EST


Hi,

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/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;
>
I don't think EIO is an appropriate return code here. There was no I/O
in progress that had an error. IMO ENODEV would be more appropriate
here.

> +static const struct of_device_id of_imx_poweroff_match[] = {
> + { .compatible = "fsl,sec-v4.0-poweroff", },
> + {},
>
useless comma after terminating NULL element of array.
You never want any patch to add an entry after this one.
Without the comma doing so (e.g. because of a badly resolved merge
conflict) would lead to a compile error.


> +};
> +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),
>
useless use of of_match_ptr()


Lothar WaÃmann
--
___________________________________________________________

Ka-Ro electronics GmbH | PascalstraÃe 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
GeschÃftsfÃhrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@xxxxxxxxxxxxxxxxxxx
___________________________________________________________
--
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/