From: Sebastian Reichel <sebastian.reichel@collabora.com> To: Claudiu.Beznea@microchip.com Cc: Nicolas.Ferre@microchip.com, alexandre.belloni@bootlin.com, Ludovic.Desroches@microchip.com, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] power: reset: at91-poweroff: move shdwc related data to one structure Date: Thu, 6 Dec 2018 21:59:36 +0100 [thread overview] Message-ID: <20181206205936.jqcirosf2s34gcje@earth.universe> (raw) In-Reply-To: <1544117357-24177-1-git-send-email-claudiu.beznea@microchip.com> [-- Attachment #1: Type: text/plain, Size: 4731 bytes --] Hi, On Thu, Dec 06, 2018 at 05:29:46PM +0000, Claudiu.Beznea@microchip.com wrote: > From: Claudiu Beznea <claudiu.beznea@microchip.com> > > Move SHDWC realted data to only one structure to have them grouped. > Inspired from commit 9be74f0d39c1 ("power: reset: at91-poweroff: make > mpddrc_base part of struct shdwc"). > > Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> > --- Thanks, queued. -- Sebastian > > Changes in v2: > - avoid allocate at91_shdwc and keep it static instead > - avoid registering at91_shdwc as platform data and use static variable > instead > > drivers/power/reset/at91-poweroff.c | 48 +++++++++++++++++++------------------ > 1 file changed, 25 insertions(+), 23 deletions(-) > > diff --git a/drivers/power/reset/at91-poweroff.c b/drivers/power/reset/at91-poweroff.c > index d3d87af24e55..9e74e131c675 100644 > --- a/drivers/power/reset/at91-poweroff.c > +++ b/drivers/power/reset/at91-poweroff.c > @@ -51,14 +51,16 @@ static const char *shdwc_wakeup_modes[] = { > [AT91_SHDW_WKMODE0_ANYLEVEL] = "any", > }; > > -static void __iomem *at91_shdwc_base; > -static struct clk *sclk; > -static void __iomem *mpddrc_base; > +static struct shdwc { > + struct clk *sclk; > + void __iomem *shdwc_base; > + void __iomem *mpddrc_base; > +} at91_shdwc; > > static void __init at91_wakeup_status(struct platform_device *pdev) > { > const char *reason; > - u32 reg = readl(at91_shdwc_base + AT91_SHDW_SR); > + u32 reg = readl(at91_shdwc.shdwc_base + AT91_SHDW_SR); > > /* Simple power-on, just bail out */ > if (!reg) > @@ -92,9 +94,9 @@ static void at91_poweroff(void) > > " b .\n\t" > : > - : "r" (mpddrc_base), > + : "r" (at91_shdwc.mpddrc_base), > "r" cpu_to_le32(AT91_DDRSDRC_LPDDR2_PWOFF), > - "r" (at91_shdwc_base), > + "r" (at91_shdwc.shdwc_base), > "r" cpu_to_le32(AT91_SHDW_KEY | AT91_SHDW_SHDW) > : "r6"); > } > @@ -144,7 +146,7 @@ static void at91_poweroff_dt_set_wakeup_mode(struct platform_device *pdev) > if (of_property_read_bool(np, "atmel,wakeup-rtt-timer")) > mode |= AT91_SHDW_RTTWKEN; > > - writel(wakeup_mode | mode, at91_shdwc_base + AT91_SHDW_MR); > + writel(wakeup_mode | mode, at91_shdwc.shdwc_base + AT91_SHDW_MR); > } > > static int __init at91_poweroff_probe(struct platform_device *pdev) > @@ -155,15 +157,15 @@ static int __init at91_poweroff_probe(struct platform_device *pdev) > int ret; > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > - at91_shdwc_base = devm_ioremap_resource(&pdev->dev, res); > - if (IS_ERR(at91_shdwc_base)) > - return PTR_ERR(at91_shdwc_base); > + at91_shdwc.shdwc_base = devm_ioremap_resource(&pdev->dev, res); > + if (IS_ERR(at91_shdwc.shdwc_base)) > + return PTR_ERR(at91_shdwc.shdwc_base); > > - sclk = devm_clk_get(&pdev->dev, NULL); > - if (IS_ERR(sclk)) > - return PTR_ERR(sclk); > + at91_shdwc.sclk = devm_clk_get(&pdev->dev, NULL); > + if (IS_ERR(at91_shdwc.sclk)) > + return PTR_ERR(at91_shdwc.sclk); > > - ret = clk_prepare_enable(sclk); > + ret = clk_prepare_enable(at91_shdwc.sclk); > if (ret) { > dev_err(&pdev->dev, "Could not enable slow clock\n"); > return ret; > @@ -176,20 +178,20 @@ static int __init at91_poweroff_probe(struct platform_device *pdev) > > np = of_find_compatible_node(NULL, NULL, "atmel,sama5d3-ddramc"); > if (np) { > - mpddrc_base = of_iomap(np, 0); > + at91_shdwc.mpddrc_base = of_iomap(np, 0); > of_node_put(np); > > - if (!mpddrc_base) { > + if (!at91_shdwc.mpddrc_base) { > ret = -ENOMEM; > goto clk_disable; > } > > - ddr_type = readl(mpddrc_base + AT91_DDRSDRC_MDR) & > + ddr_type = readl(at91_shdwc.mpddrc_base + AT91_DDRSDRC_MDR) & > AT91_DDRSDRC_MD; > if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 && > ddr_type != AT91_DDRSDRC_MD_LPDDR3) { > - iounmap(mpddrc_base); > - mpddrc_base = NULL; > + iounmap(at91_shdwc.mpddrc_base); > + at91_shdwc.mpddrc_base = NULL; > } > } > > @@ -198,7 +200,7 @@ static int __init at91_poweroff_probe(struct platform_device *pdev) > return 0; > > clk_disable: > - clk_disable_unprepare(sclk); > + clk_disable_unprepare(at91_shdwc.sclk); > return ret; > } > > @@ -207,10 +209,10 @@ static int __exit at91_poweroff_remove(struct platform_device *pdev) > if (pm_power_off == at91_poweroff) > pm_power_off = NULL; > > - if (mpddrc_base) > - iounmap(mpddrc_base); > + if (at91_shdwc.mpddrc_base) > + iounmap(at91_shdwc.mpddrc_base); > > - clk_disable_unprepare(sclk); > + clk_disable_unprepare(at91_shdwc.sclk); > > return 0; > } > -- > 2.7.4 > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Sebastian Reichel <sebastian.reichel@collabora.com> To: Claudiu.Beznea@microchip.com Cc: alexandre.belloni@bootlin.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Ludovic.Desroches@microchip.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2] power: reset: at91-poweroff: move shdwc related data to one structure Date: Thu, 6 Dec 2018 21:59:36 +0100 [thread overview] Message-ID: <20181206205936.jqcirosf2s34gcje@earth.universe> (raw) In-Reply-To: <1544117357-24177-1-git-send-email-claudiu.beznea@microchip.com> [-- Attachment #1.1: Type: text/plain, Size: 4731 bytes --] Hi, On Thu, Dec 06, 2018 at 05:29:46PM +0000, Claudiu.Beznea@microchip.com wrote: > From: Claudiu Beznea <claudiu.beznea@microchip.com> > > Move SHDWC realted data to only one structure to have them grouped. > Inspired from commit 9be74f0d39c1 ("power: reset: at91-poweroff: make > mpddrc_base part of struct shdwc"). > > Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> > --- Thanks, queued. -- Sebastian > > Changes in v2: > - avoid allocate at91_shdwc and keep it static instead > - avoid registering at91_shdwc as platform data and use static variable > instead > > drivers/power/reset/at91-poweroff.c | 48 +++++++++++++++++++------------------ > 1 file changed, 25 insertions(+), 23 deletions(-) > > diff --git a/drivers/power/reset/at91-poweroff.c b/drivers/power/reset/at91-poweroff.c > index d3d87af24e55..9e74e131c675 100644 > --- a/drivers/power/reset/at91-poweroff.c > +++ b/drivers/power/reset/at91-poweroff.c > @@ -51,14 +51,16 @@ static const char *shdwc_wakeup_modes[] = { > [AT91_SHDW_WKMODE0_ANYLEVEL] = "any", > }; > > -static void __iomem *at91_shdwc_base; > -static struct clk *sclk; > -static void __iomem *mpddrc_base; > +static struct shdwc { > + struct clk *sclk; > + void __iomem *shdwc_base; > + void __iomem *mpddrc_base; > +} at91_shdwc; > > static void __init at91_wakeup_status(struct platform_device *pdev) > { > const char *reason; > - u32 reg = readl(at91_shdwc_base + AT91_SHDW_SR); > + u32 reg = readl(at91_shdwc.shdwc_base + AT91_SHDW_SR); > > /* Simple power-on, just bail out */ > if (!reg) > @@ -92,9 +94,9 @@ static void at91_poweroff(void) > > " b .\n\t" > : > - : "r" (mpddrc_base), > + : "r" (at91_shdwc.mpddrc_base), > "r" cpu_to_le32(AT91_DDRSDRC_LPDDR2_PWOFF), > - "r" (at91_shdwc_base), > + "r" (at91_shdwc.shdwc_base), > "r" cpu_to_le32(AT91_SHDW_KEY | AT91_SHDW_SHDW) > : "r6"); > } > @@ -144,7 +146,7 @@ static void at91_poweroff_dt_set_wakeup_mode(struct platform_device *pdev) > if (of_property_read_bool(np, "atmel,wakeup-rtt-timer")) > mode |= AT91_SHDW_RTTWKEN; > > - writel(wakeup_mode | mode, at91_shdwc_base + AT91_SHDW_MR); > + writel(wakeup_mode | mode, at91_shdwc.shdwc_base + AT91_SHDW_MR); > } > > static int __init at91_poweroff_probe(struct platform_device *pdev) > @@ -155,15 +157,15 @@ static int __init at91_poweroff_probe(struct platform_device *pdev) > int ret; > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > - at91_shdwc_base = devm_ioremap_resource(&pdev->dev, res); > - if (IS_ERR(at91_shdwc_base)) > - return PTR_ERR(at91_shdwc_base); > + at91_shdwc.shdwc_base = devm_ioremap_resource(&pdev->dev, res); > + if (IS_ERR(at91_shdwc.shdwc_base)) > + return PTR_ERR(at91_shdwc.shdwc_base); > > - sclk = devm_clk_get(&pdev->dev, NULL); > - if (IS_ERR(sclk)) > - return PTR_ERR(sclk); > + at91_shdwc.sclk = devm_clk_get(&pdev->dev, NULL); > + if (IS_ERR(at91_shdwc.sclk)) > + return PTR_ERR(at91_shdwc.sclk); > > - ret = clk_prepare_enable(sclk); > + ret = clk_prepare_enable(at91_shdwc.sclk); > if (ret) { > dev_err(&pdev->dev, "Could not enable slow clock\n"); > return ret; > @@ -176,20 +178,20 @@ static int __init at91_poweroff_probe(struct platform_device *pdev) > > np = of_find_compatible_node(NULL, NULL, "atmel,sama5d3-ddramc"); > if (np) { > - mpddrc_base = of_iomap(np, 0); > + at91_shdwc.mpddrc_base = of_iomap(np, 0); > of_node_put(np); > > - if (!mpddrc_base) { > + if (!at91_shdwc.mpddrc_base) { > ret = -ENOMEM; > goto clk_disable; > } > > - ddr_type = readl(mpddrc_base + AT91_DDRSDRC_MDR) & > + ddr_type = readl(at91_shdwc.mpddrc_base + AT91_DDRSDRC_MDR) & > AT91_DDRSDRC_MD; > if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 && > ddr_type != AT91_DDRSDRC_MD_LPDDR3) { > - iounmap(mpddrc_base); > - mpddrc_base = NULL; > + iounmap(at91_shdwc.mpddrc_base); > + at91_shdwc.mpddrc_base = NULL; > } > } > > @@ -198,7 +200,7 @@ static int __init at91_poweroff_probe(struct platform_device *pdev) > return 0; > > clk_disable: > - clk_disable_unprepare(sclk); > + clk_disable_unprepare(at91_shdwc.sclk); > return ret; > } > > @@ -207,10 +209,10 @@ static int __exit at91_poweroff_remove(struct platform_device *pdev) > if (pm_power_off == at91_poweroff) > pm_power_off = NULL; > > - if (mpddrc_base) > - iounmap(mpddrc_base); > + if (at91_shdwc.mpddrc_base) > + iounmap(at91_shdwc.mpddrc_base); > > - clk_disable_unprepare(sclk); > + clk_disable_unprepare(at91_shdwc.sclk); > > return 0; > } > -- > 2.7.4 > [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] [-- Attachment #2: Type: text/plain, Size: 176 bytes --] _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2018-12-06 20:59 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-12-06 17:29 [PATCH v2] power: reset: at91-poweroff: move shdwc related data to one structure Claudiu.Beznea 2018-12-06 17:29 ` Claudiu.Beznea 2018-12-06 17:29 ` Claudiu.Beznea 2018-12-06 20:59 ` Sebastian Reichel [this message] 2018-12-06 20:59 ` Sebastian Reichel
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20181206205936.jqcirosf2s34gcje@earth.universe \ --to=sebastian.reichel@collabora.com \ --cc=Claudiu.Beznea@microchip.com \ --cc=Ludovic.Desroches@microchip.com \ --cc=Nicolas.Ferre@microchip.com \ --cc=alexandre.belloni@bootlin.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-pm@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.