devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@ti.com>
To: Johan Hovold <johan@kernel.org>
Cc: Lokesh Vutla <lokeshvutla@ti.com>,
	rtc-linux@googlegroups.com, linux-omap@vger.kernel.org,
	a.zummo@towertech.it, tony@atomide.com, bcousson@baylibre.com,
	balbi@ti.com, akpm@linux-foundation.org, linux@roeck-us.net,
	nsekhar@ti.com, t-kristo@ti.com, j-keerthy@ti.com,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org
Subject: Re: [PATCH V3 3/3] rtc: omap: Support regulator supply for RTC
Date: Fri, 24 Oct 2014 10:40:17 -0500	[thread overview]
Message-ID: <20141024154017.GJ26941@saruman> (raw)
In-Reply-To: <20141024075312.GD28808@localhost>

[-- Attachment #1: Type: text/plain, Size: 3693 bytes --]

Hi,

On Fri, Oct 24, 2014 at 09:53:12AM +0200, Johan Hovold wrote:
> On Fri, Oct 24, 2014 at 10:23:45AM +0530, Lokesh Vutla wrote:
> > On some Soc's RTC is powered by an external power regulator.
> > e.g. RTC on DRA7 SoC. Make the OMAP RTC driver support a
> > power regulator.
> > 
> > Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
> > ---
> >  Documentation/devicetree/bindings/rtc/rtc-omap.txt |  3 +++
> >  drivers/rtc/rtc-omap.c                             | 24 ++++++++++++++++++++++
> >  2 files changed, 27 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
> > index 750efd4..e7ad12b 100644
> > --- a/Documentation/devicetree/bindings/rtc/rtc-omap.txt
> > +++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
> > @@ -15,6 +15,8 @@ Required properties:
> >  Optional properties:
> >  - ti,system-power-controller: whether the rtc is controlling the system power
> >    through pmic_power_en
> > +Optional Properties:
> 
> No need to repeat the "Optional Properties" header.
> 
> > +- vrtc-supply: phandle to the regulator device tree node if needed
> >  
> >  Example:
> >  
> > @@ -25,4 +27,5 @@ rtc@1c23000 {
> >  		      19>;
> >  	interrupt-parent = <&intc>;
> >  	ti,system-power-controller;
> > +	vrtc-supply = <&ldo9_reg>;
> >  };
> > diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
> > index d9bb5e7..61fe630 100644
> > --- a/drivers/rtc/rtc-omap.c
> > +++ b/drivers/rtc/rtc-omap.c
> > @@ -25,6 +25,7 @@
> >  #include <linux/of_device.h>
> >  #include <linux/pm_runtime.h>
> >  #include <linux/io.h>
> > +#include <linux/regulator/consumer.h>
> >  
> >  /*
> >   * The OMAP RTC is a year/month/day/hours/minutes/seconds BCD clock
> > @@ -134,6 +135,7 @@ struct omap_rtc {
> >  	u8 interrupts_reg;
> >  	bool is_pmic_controller;
> >  	const struct omap_rtc_device_type *type;
> > +	struct regulator *supply;
> >  };
> >  
> >  static inline u8 rtc_read(struct omap_rtc *rtc, unsigned int reg)
> > @@ -516,6 +518,22 @@ static int omap_rtc_probe(struct platform_device *pdev)
> >  
> >  	platform_set_drvdata(pdev, rtc);
> 
> Also could you move the regulator allocation before this
> platform_set_drvdata when resending? It's not required, but that call
> sort of separates the allocations from the device initialisation
> currently.
> 
> > +	rtc->supply = devm_regulator_get_optional(&pdev->dev, "vrtc");
> > +	if (IS_ERR(rtc->supply)) {
> > +		if (PTR_ERR(rtc->supply) == -EPROBE_DEFER)
> > +			return -EPROBE_DEFER;
> > +
> > +		rtc->supply = NULL;
> > +	}
> > +
> > +	if (rtc->supply) {
> > +		ret = regulator_enable(rtc->supply);
> > +		if (ret) {
> > +			dev_err(&pdev->dev, "regulator enable failed\n");
> > +			return ret;
> > +		}
> > +	}
> > +
> >  	/* Enable the clock/module so that we can access the registers */
> >  	pm_runtime_enable(&pdev->dev);
> >  	pm_runtime_get_sync(&pdev->dev);
> > @@ -624,6 +642,9 @@ err:
> >  	pm_runtime_put_sync(&pdev->dev);
> >  	pm_runtime_disable(&pdev->dev);
> >  
> > +	if (rtc->supply)
> > +		regulator_disable(rtc->supply);
> > +
> >  	return ret;
> >  }
> >  
> > @@ -649,6 +670,9 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
> >  	pm_runtime_put_sync(&pdev->dev);
> >  	pm_runtime_disable(&pdev->dev);
> >  
> > +	if (rtc->supply)
> > +		regulator_disable(rtc->supply);
> > +
> >  	return 0;
> >  }
> 
> Looks good otherwise. Feel free to add
> 
> Reviewed-by: Johan Hovold <johan@kernel.org>

Conditional on Johan's comments:

Reviewed-by: Felipe Balbi <balbi@ti.com>

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2014-10-24 15:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-24  4:53 [PATCH V3 0/3] rtc: omap: Add support for regulator supply Lokesh Vutla
2014-10-24  4:53 ` [PATCH V3 1/3] rtc: omap: use module_platform_driver Lokesh Vutla
2014-10-24  7:33   ` Johan Hovold
2014-10-24 15:38   ` Felipe Balbi
2014-10-24  4:53 ` [PATCH V3 2/3] rtc: omap: Update Kconfig for OMAP RTC Lokesh Vutla
2014-10-24  4:53 ` [PATCH V3 3/3] rtc: omap: Support regulator supply for RTC Lokesh Vutla
2014-10-24  7:53   ` Johan Hovold
2014-10-24  7:57     ` Lokesh Vutla
2014-10-24 15:40     ` Felipe Balbi [this message]
2014-10-24  8:07   ` [PATCH V4 " Lokesh Vutla
2014-10-24 15:40     ` Felipe Balbi
2014-10-24 13:26   ` [PATCH V3 " Nishanth Menon
2014-10-24 15:43     ` Felipe Balbi
2014-10-24 15:47       ` Nishanth Menon
2014-10-28  9:49     ` Lokesh Vutla

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=20141024154017.GJ26941@saruman \
    --to=balbi@ti.com \
    --cc=a.zummo@towertech.it \
    --cc=akpm@linux-foundation.org \
    --cc=bcousson@baylibre.com \
    --cc=devicetree@vger.kernel.org \
    --cc=j-keerthy@ti.com \
    --cc=johan@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lokeshvutla@ti.com \
    --cc=nsekhar@ti.com \
    --cc=rtc-linux@googlegroups.com \
    --cc=t-kristo@ti.com \
    --cc=tony@atomide.com \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).