devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Sebastian Andrzej Siewior
	<bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Cc: Alessandro Zummo
	<a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org>,
	rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	sodaville-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org
Subject: Re: [PATCH 14/15] rtc/cmos: add OF bindings
Date: Tue, 11 Jan 2011 17:04:42 -0700	[thread overview]
Message-ID: <20110112000442.GJ2131@angua.secretlab.ca> (raw)
In-Reply-To: <1292600033-12271-15-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>

On Fri, Dec 17, 2010 at 04:33:52PM +0100, Sebastian Andrzej Siewior wrote:
> This allows to load the OF driver based informations from the device
> tree. Systems without BIOS may need to perform some initialization.
> PowerPC creates a PNP device from the OF information and performs this
> kind of initialization in their private PCI quirk. This looks more
> generic.
> 
> Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> Cc: Alessandro Zummo <a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org>
> Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
> Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  Documentation/powerpc/dts-bindings/rtc-cmos.txt |   28 ++++++++++++++++
>  drivers/rtc/rtc-cmos.c                          |   40 +++++++++++++++++++++++
>  2 files changed, 68 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/powerpc/dts-bindings/rtc-cmos.txt
> 
> diff --git a/Documentation/powerpc/dts-bindings/rtc-cmos.txt b/Documentation/powerpc/dts-bindings/rtc-cmos.txt
> new file mode 100644
> index 0000000..7382989
> --- /dev/null
> +++ b/Documentation/powerpc/dts-bindings/rtc-cmos.txt
> @@ -0,0 +1,28 @@
> + Motorola mc146818 compatible RTC
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +Required properties:
> +  - compatible : "motorola,mc146818"
> +  - reg : should contain registers location and length.
> +
> +Optional properties:
> +  - interrupts : should contain interrupt.
> +  - interrupt-parent : interrupt source phandle.
> +  - ctrl-reg : Contains the initial value of the control register also
> +    called "Register B".
> +  - freq-reg : Contains the initial value of the frequency register also
> +    called "Regsiter A".
> +
> +"Register A" and "B" are usually initialized by the firmware (BIOS for
> +instance). If this is not done, it can be performed by the driver.
> +
> +ISA Example:
> +
> +	rtc@70 {
> +	         compatible = "motorola,mc146818";
> +	         interrupts = <8 3>;
> +	         interrupt-parent = <&ioapic1>;
> +	         ctrl-reg = <2>;
> +	         freq-reg = <0x26>;
> +	         reg = <1 0x70 2>;
> +	 };
> diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
> index 5856167..8cf0049 100644
> --- a/drivers/rtc/rtc-cmos.c
> +++ b/drivers/rtc/rtc-cmos.c
> @@ -36,6 +36,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/mod_devicetable.h>
>  #include <linux/log2.h>
> +#include <linux/of.h>
> +#include <linux/of_platform.h>
>  
>  /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */
>  #include <asm-generic/rtc.h>
> @@ -1121,6 +1123,15 @@ static struct pnp_driver cmos_pnp_driver = {
>  
>  #endif	/* CONFIG_PNP */
>  
> +#ifdef CONFIG_OF
> +static const struct of_device_id of_cmos_match[] = {
> +	{
> +		.compatible = "motorola,mc146818",
> +	},
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, of_cmos_match);
> +#endif
>  /*----------------------------------------------------------------*/
>  
>  /* Platform setup should have set up an RTC device, when PNP is
> @@ -1129,6 +1140,32 @@ static struct pnp_driver cmos_pnp_driver = {
>  
>  static int __init cmos_platform_probe(struct platform_device *pdev)
>  {
> +#ifdef CONFIG_OF
> +	if (pdev->dev.of_node) {
> +		struct device_node *node = pdev->dev.of_node;
> +		struct rtc_time time;
> +		int ret;
> +		const __be32 *val;
> +
> +		val = of_get_property(node, "ctrl-reg", NULL);
> +		if (val)
> +			CMOS_WRITE(be32_to_cpup(val), RTC_CONTROL);
> +
> +		val = of_get_property(node, "freq-reg", NULL);
> +		if (val)
> +			CMOS_WRITE(be32_to_cpup(val), RTC_FREQ_SELECT);
> +
> +		get_rtc_time(&time);
> +		ret = rtc_valid_tm(&time);
> +		if (ret) {
> +			struct rtc_time def_time = {
> +				.tm_year = 1,
> +				.tm_mday = 1,
> +			};
> +			set_rtc_time(&def_time);
> +		}
> +	}
> +#endif

It's usually cleaner to break the of-specific probe stuff into a
separate function that can be #ifdef'ed out as a whole instead of
having #ifdef blocks inside the probe functions.  Aside from that this
patch looks good to me.

>  	cmos_wake_setup(&pdev->dev);
>  	return cmos_do_probe(&pdev->dev,
>  			platform_get_resource(pdev, IORESOURCE_IO, 0),
> @@ -1157,6 +1194,9 @@ static struct platform_driver cmos_platform_driver = {
>  	.shutdown	= cmos_platform_shutdown,
>  	.driver = {
>  		.name		= (char *) driver_name,
> +#if defined(CONFIG_OF)
> +		.of_match_table = of_cmos_match,
> +#endif
>  		.suspend	= cmos_suspend,
>  		.resume		= cmos_resume,
>  	}
> -- 
> 1.7.3.2
> 
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss

  parent reply	other threads:[~2011-01-12  0:04 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1292600033-12271-1-git-send-email-bigeasy@linutronix.de>
     [not found] ` <1292600033-12271-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-12-17 15:33   ` [PATCH 02/15] x86: Add device tree support Sebastian Andrzej Siewior
2010-12-30  8:43     ` Grant Likely
     [not found]       ` <20101230084311.GD11721-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-12-30 21:01         ` Grant Likely
     [not found]           ` <AANLkTi=EFewaizO=1FLALE0eQPUmaFPfTmgoeF+JRpkt-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-02  0:40             ` H. Peter Anvin
2011-01-03 12:20         ` Sebastian Andrzej Siewior
2011-01-03 18:05           ` [sodaville] " H. Peter Anvin
2010-12-17 15:33   ` [PATCH 03/15] x86/dtb: Add a device tree for CE4100 Sebastian Andrzej Siewior
     [not found]     ` <1292600033-12271-4-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-12-30  8:51       ` Grant Likely
     [not found]         ` <20101230085122.GE11721-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-01-03 11:28           ` Sebastian Andrzej Siewior
2011-01-03 17:45             ` Grant Likely
     [not found]               ` <20110103174500.GC2522-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-01-05  9:48                 ` [PATCH v2 " Sebastian Andrzej Siewior
2011-01-05 10:01           ` [PATCH " Sebastian Andrzej Siewior
2011-01-05 23:20           ` David Gibson
2010-12-17 15:33   ` [PATCH 04/15] x86/dtb: add irq domain abstraction Sebastian Andrzej Siewior
2011-01-11 22:03     ` Grant Likely
     [not found]       ` <20110111220317.GA2131-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-01-23 13:06         ` Sebastian Andrzej Siewior
2010-12-17 15:33   ` [PATCH 05/15] x86/dtb: add early parsing of APIC and IO APIC Sebastian Andrzej Siewior
     [not found]     ` <1292600033-12271-6-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-12-30  8:54       ` Grant Likely
2011-01-04 13:23         ` [PATCH v2 " Sebastian Andrzej Siewior
     [not found]           ` <20110104132302.GB21359-Hfxr4Dq0UpYb1SvskN2V4Q@public.gmane.org>
2011-01-11 22:14             ` Grant Likely
     [not found]               ` <20110111221401.GB2131-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-01-18 14:56                 ` Sebastian Andrzej Siewior
2010-12-17 15:33   ` [PATCH 06/15] x86/dtb: add support hpet Sebastian Andrzej Siewior
     [not found]     ` <1292600033-12271-7-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2011-01-11 22:26       ` Grant Likely
2010-12-17 15:33   ` [PATCH 07/15] of: move of_irq_map_pci() into generic code Sebastian Andrzej Siewior
2010-12-17 21:16     ` Benjamin Herrenschmidt
2011-01-04 14:27       ` [PATCH v2 " Sebastian Andrzej Siewior
     [not found]         ` <20110104142754.GD21359-Hfxr4Dq0UpYb1SvskN2V4Q@public.gmane.org>
2011-01-11 23:27           ` Grant Likely
     [not found]             ` <20110111232726.GD2131-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-01-12 18:21               ` Sebastian Andrzej Siewior
2010-12-17 15:33   ` [PATCH 08/15] x86/dtb: add support for PCI devices backed by dtb nodes Sebastian Andrzej Siewior
     [not found]     ` <1292600033-12271-9-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2011-01-11 23:47       ` Grant Likely
2010-12-17 15:33   ` [PATCH 09/15] x86/dtb: Add generic bus probe Sebastian Andrzej Siewior
     [not found]     ` <1292600033-12271-10-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2011-01-11 23:48       ` Grant Likely
2010-12-17 15:33   ` [PATCH 10/15] x86/ioapic: Add OF bindings for IO-APIC Sebastian Andrzej Siewior
     [not found]     ` <1292600033-12271-11-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2011-01-11 23:53       ` Grant Likely
     [not found]         ` <20110111235353.GG2131-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-01-12 17:07           ` Sebastian Andrzej Siewior
     [not found]             ` <20110112170707.GA6907-Hfxr4Dq0UpYb1SvskN2V4Q@public.gmane.org>
2011-01-12 17:19               ` [sodaville] " H. Peter Anvin
     [not found]                 ` <4D2DE2B9.2000607-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2011-01-13 10:38                   ` Sebastian Andrzej Siewior
2010-12-17 15:33   ` [PATCH 12/15] of/address: use propper endianess in get_flags Sebastian Andrzej Siewior
2010-12-30  9:05     ` Grant Likely
2010-12-17 15:33   ` [PATCH 14/15] rtc/cmos: add OF bindings Sebastian Andrzej Siewior
     [not found]     ` <1292600033-12271-15-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2011-01-12  0:04       ` Grant Likely [this message]
     [not found]         ` <20110112000442.GJ2131-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-01-13 10:50           ` [PATCH v2] " Sebastian Andrzej Siewior

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=20110112000442.GJ2131@angua.secretlab.ca \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc=a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org \
    --cc=bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=sodaville-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
    --cc=x86-DgEjT+Ai2ygdnm+yROfE0A@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).