RE: [PATCH v2 4/4] power: reset: Add new driver for RZ/V2M PWC poweroff

Fabrizio Castro
2023-01-05T17:34:40Z

Hi Geert,

Thanks for your feedback!

>
> Hi Fabrizio,
>
> On Wed, Dec 21, 2022 at 10:09 PM Fabrizio Castro
> <fabrizio.castro.jz@renesas.com> wrote:
> > The RZ/V2M PWC IP controls external power supplies and therefore
> > can turn the power supplies off when powering down the system.
> >
> > Add driver to poweroff the system.
> >
> > Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
> > ---
> >
> > v1->v2: Dropped OF match table and syscon as a result of the change in
> > DT model
>
> Thanks for your patch!
>
> > --- /dev/null
> > +++ b/drivers/power/reset/rzv2m-pwc-poweroff.c
> > @@ -0,0 +1,67 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Copyright (C) 2022 Renesas Electronics Corporation
> > + *
> > + * Reset driver for Renesas RZ/V2M External Power Sequence Controller
> (PWC)
> > + */
> > +
> > +#include <linux/delay.h>
> > +#include <linux/io.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/reboot.h>
> > +#include "../../mfd/rzv2m-pwc.h"
> > +
> > +#define PWC_PWCRST_RSTSOFTAX 0x1
> > +#define PWC_PWCCKEN_ENGCKMAIN 0x1
> > +#define PWC_PWCCTL_PWOFF 0x1
> > +
> > +struct rzv2m_pwc_poweroff_priv {
> > + void __iomem *base;
> > + struct device *dev;
> > +};
> > +
> > +static int rzv2m_pwc_poweroff(struct sys_off_data *data)
> > +{
> > + struct rzv2m_pwc_poweroff_priv *priv =
> > + (struct rzv2m_pwc_poweroff_priv *)data->cb_data;
>
> No need for this cast.

Thanks for pointing this out. I'll fix that in v3.

Thanks,
Fab

>
> > +
> > + writel(PWC_PWCRST_RSTSOFTAX, priv->base + PWC_PWCRST);
> > + writel(PWC_PWCCKEN_ENGCKMAIN, priv->base + PWC_PWCCKEN);
> > + writel(PWC_PWCCTL_PWOFF, priv->base + PWC_PWCCTL);
> > +
> > + mdelay(150);
> > +
> > + dev_err(priv->dev, "Failed to power off the system");
> > +
> > + return NOTIFY_DONE;
> > +}
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-
> m68k.org
>
> In personal conversations with technical people, I call myself a hacker.
> But
> when I'm talking to journalists I just say "programmer" or something like
> that.
> -- Linus Torvalds