devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
To: Alexandre Belloni
	<alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: Nicolas Ferre
	<nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>,
	Jean-Christophe Plagniol-Villard
	<plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>,
	Andrew Victor <linux-PelNFVqkFnVyf+4FbqDuWQ@public.gmane.org>,
	Alessandro Zummo
	<a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org>,
	rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
	Johan Hovold <jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Ian Campbell
	<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
	Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v5 5/9] rtc: at91sam9: make use of syscon/regmap to access GPBR registers
Date: Fri, 12 Sep 2014 07:33:06 +0200	[thread overview]
Message-ID: <20140912073306.5ac2c295@bbrezillon> (raw)
In-Reply-To: <20140911174209.GE3131-m++hUPXGwpdeoWH0uzbU5w@public.gmane.org>

On Thu, 11 Sep 2014 19:42:09 +0200
Alexandre Belloni <alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> wrote:

> On 11/09/2014 at 15:53:08 +0200, Boris Brezillon wrote :
> > The GPBR registers are not part of the RTT block and thus should not be
> > defined in the reg property of the rtt node.
> > 
> > Use syscon to provide a proper DT representation and reference the GPBR
> > syscon device in a new "atmel,time-reg" property which store both the
> > syscon device phandle and the register offset within the GPBR block.
> > 
> > When using non DT boards, we won't be able to retrieve the syscon regmap,
> > hence we need to create our own regmap using the memory region defined
> > in the 2nd memory resource assigned to the RTT platform device.
> > 
> > Signed-off-by: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> > ---
> >  drivers/rtc/Kconfig        |  1 +
> >  drivers/rtc/rtc-at91sam9.c | 59 +++++++++++++++++++++++++++++++++++++++-------
> >  2 files changed, 51 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> > index a168e96..7d76da8 100644
> > --- a/drivers/rtc/Kconfig
> > +++ b/drivers/rtc/Kconfig
> > @@ -1081,6 +1081,7 @@ config RTC_DRV_AT91RM9200
> >  config RTC_DRV_AT91SAM9
> >  	tristate "AT91SAM9x/AT91CAP9 RTT as RTC"
> >  	depends on ARCH_AT91 && !(ARCH_AT91RM9200 || ARCH_AT91X40)
> > +	select MFD_SYSCON
> >  	help
> >  	  RTC driver for the Atmel AT91SAM9x and AT91CAP9 internal RTT
> >  	  (Real Time Timer). These timers are powered by the backup power
> > diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
> > index d72c34d..944e317 100644
> > --- a/drivers/rtc/rtc-at91sam9.c
> > +++ b/drivers/rtc/rtc-at91sam9.c
> > @@ -21,6 +21,8 @@
> >  #include <linux/slab.h>
> >  #include <linux/platform_data/atmel.h>
> >  #include <linux/io.h>
> > +#include <linux/mfd/syscon.h>
> > +#include <linux/regmap.h>
> >  
> >  /*
> >   * This driver uses two configurable hardware resources that live in the
> > @@ -72,7 +74,8 @@ struct sam9_rtc {
> >  	void __iomem		*rtt;
> >  	struct rtc_device	*rtcdev;
> >  	u32			imr;
> > -	void __iomem		*gpbr;
> > +	struct regmap		*gpbr;
> > +	unsigned int		gpbr_offset;
> >  	int 			irq;
> >  };
> >  
> > @@ -81,10 +84,19 @@ struct sam9_rtc {
> >  #define rtt_writel(rtc, field, val) \
> >  	writel((val), (rtc)->rtt + AT91_RTT_ ## field)
> >  
> > -#define gpbr_readl(rtc) \
> > -	readl((rtc)->gpbr)
> > -#define gpbr_writel(rtc, val) \
> > -	writel((val), (rtc)->gpbr)
> > +static inline unsigned int gpbr_readl(struct sam9_rtc *rtc)
> > +{
> > +	unsigned int val;
> > +
> > +	regmap_read(rtc->gpbr, rtc->gpbr_offset, &val);
> > +
> > +	return val;
> > +}
> > +
> > +static inline void gpbr_writel(struct sam9_rtc *rtc, unsigned int val)
> > +{
> > +	regmap_write(rtc->gpbr, rtc->gpbr_offset, val);
> > +}
> >  
> >  /*
> >   * Read current time and date in RTC
> > @@ -301,6 +313,12 @@ static const struct rtc_class_ops at91_rtc_ops = {
> >  	.alarm_irq_enable = at91_rtc_alarm_irq_enable,
> >  };
> >  
> > +static struct regmap_config gpbr_regmap_config = {
> > +	.reg_bits = 32,
> > +	.val_bits = 32,
> > +	.reg_stride = 4,
> > +};
> > +
> >  /*
> >   * Initialize and install RTC driver
> >   */
> > @@ -334,10 +352,33 @@ static int at91_rtc_probe(struct platform_device *pdev)
> >  	if (IS_ERR(rtc->rtt))
> >  		return PTR_ERR(rtc->rtt);
> >  
> > -	r = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> > -	rtc->gpbr = devm_ioremap_resource(&pdev->dev, r);
> > -	if (IS_ERR(rtc->gpbr))
> > -		return PTR_ERR(rtc->rtt);
> > +	if (!pdev->dev.of_node) {
> > +		void __iomem *gpbr;
> > +
> > +		r = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> > +		gpbr = devm_ioremap_resource(&pdev->dev, r);
> > +		if (IS_ERR(gpbr))
> > +			return PTR_ERR(gpbr);
> > +
> 
> Maybe you could add a comment here as this is soon to be dead code.

Sure. I'll add a TODO comment.

Thanks.

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-09-12  5:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-11 13:18 [PATCH v4 0/9] rtc: at91sam9: add DT support Boris BREZILLON
     [not found] ` <1410441525-25258-1-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-09-11 13:18   ` [PATCH v4 1/9] rtc: at91sam9: remove references to mach specific headers Boris BREZILLON
2014-09-11 13:18 ` [PATCH v4 2/9] rtc: at91sam9: use standard readl/writel functions instead of raw versions Boris BREZILLON
2014-09-11 13:18 ` [PATCH v4 3/9] rtc: at91sam9: replace devm_ioremap by devm_ioremap_resource Boris BREZILLON
2014-09-11 13:18 ` [PATCH v4 4/9] rtc: at91sam9: add DT support Boris BREZILLON
2014-09-11 13:18 ` [PATCH v4 5/9] rtc: at91sam9: make use of syscon/regmap to access GPBR registers Boris BREZILLON
2014-09-11 13:44   ` Boris BREZILLON
     [not found]   ` <1410441525-25258-6-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-09-11 13:53     ` [PATCH v5 " Boris BREZILLON
     [not found]       ` <1410443588-9092-1-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-09-11 17:42         ` Alexandre Belloni
     [not found]           ` <20140911174209.GE3131-m++hUPXGwpdeoWH0uzbU5w@public.gmane.org>
2014-09-12  5:33             ` Boris BREZILLON [this message]
2014-09-11 13:18 ` [PATCH v4 6/9] ARM: at91: add clk_lookup entry for RTT devices Boris BREZILLON
2014-09-11 13:18 ` [PATCH v4 7/9] rtc: at91sam9: use clk API instead of relying on AT91_SLOW_CLOCK Boris BREZILLON
2014-09-11 13:18 ` [PATCH v4 8/9] rtc: at91sam9: add DT bindings documentation Boris BREZILLON
2014-09-11 13:18 ` [PATCH v4 9/9] mfd: syscon: add Atmel GPBR DT bindings documention Boris BREZILLON
     [not found]   ` <1410441525-25258-10-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-09-17 16:34     ` Lee Jones
2014-09-17 17:57       ` Boris BREZILLON
2014-09-17 21:32         ` Lee Jones
  -- strict thread matches above, loose matches on Subject: below --
2014-09-22  9:10 [PATCH v5 0/9] rtc: at91sam9: add DT support Boris BREZILLON
2014-09-22  9:10 ` [PATCH v5 5/9] rtc: at91sam9: make use of syscon/regmap to access GPBR registers Boris BREZILLON
     [not found]   ` <1411377058-26155-6-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-09-22 15:06     ` Alexandre Belloni
2014-09-22 15:18     ` Johan Hovold

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=20140912073306.5ac2c295@bbrezillon \
    --to=boris.brezillon-wi1+55scjutkeb57/3fjtnbpr1lh4cv8@public.gmane.org \
    --cc=a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org \
    --cc=alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
    --cc=jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-PelNFVqkFnVyf+4FbqDuWQ@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org \
    --cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
    --cc=plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.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: 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).