LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org,
	Alessandro Zummo <a.zummo@towertech.it>,
	rtc-linux@googlegroups.com, devicetree-discuss@lists.ozlabs.org,
	x86@kernel.org, sodaville@linutronix.de
Subject: Re: [PATCH OF 13/14] rtc/cmos: add OF bindings
Date: Wed, 16 Feb 2011 15:11:08 -0700	[thread overview]
Message-ID: <20110216221108.GJ22837@angua.secretlab.ca> (raw)
In-Reply-To: <1295843342-1122-14-git-send-email-bigeasy@linutronix.de>

On Mon, Jan 24, 2011 at 09:59:01AM +0530, 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@googlegroups.com
> Cc: Alessandro Zummo <a.zummo@towertech.it>
> Cc: devicetree-discuss@lists.ozlabs.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
> ---
>  Documentation/powerpc/dts-bindings/rtc-cmos.txt |   28 ++++++++++++++
>  drivers/rtc/rtc-cmos.c                          |   46 +++++++++++++++++++++++
>  2 files changed, 74 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

Move to Documentation/devicetree/bindings/rtc/

> @@ -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 c7ff8df..2709e00 100644
> --- a/drivers/rtc/rtc-cmos.c
> +++ b/drivers/rtc/rtc-cmos.c
> @@ -37,6 +37,8 @@
>  #include <linux/mod_devicetable.h>
>  #include <linux/log2.h>
>  #include <linux/pm.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>
> @@ -1123,6 +1125,46 @@ 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);
> +
> +static __init void cmos_of_init(struct platform_device *pdev)
> +{
> +	struct device_node *node = pdev->dev.of_node;
> +	struct rtc_time time;
> +	int ret;
> +	const __be32 *val;
> +
> +	if (!node)
> +		return;
> +
> +	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);
> +	}
> +}
> +#else
> +static inline void cmos_of_init(struct platform_device *pdev) {}
> +#endif
>  /*----------------------------------------------------------------*/
>  
>  /* Platform setup should have set up an RTC device, when PNP is
> @@ -1131,6 +1173,7 @@ static struct pnp_driver cmos_pnp_driver = {
>  
>  static int __init cmos_platform_probe(struct platform_device *pdev)
>  {
> +	cmos_of_init(pdev);
>  	cmos_wake_setup(&pdev->dev);
>  	return cmos_do_probe(&pdev->dev,
>  			platform_get_resource(pdev, IORESOURCE_IO, 0),
> @@ -1162,6 +1205,9 @@ static struct platform_driver cmos_platform_driver = {
>  #ifdef CONFIG_PM
>  		.pm		= &cmos_pm_ops,
>  #endif
> +#if defined(CONFIG_OF)
> +		.of_match_table = of_cmos_match,
> +#endif

The #if defined(CONFIG_OF) is no longer necessary around
.of_match_table, particularly if you have a #else above that #defines
of_cmos_match to NULL.

>  	}
>  };
>  
> -- 
> 1.7.3.2
> 
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss

  parent reply	other threads:[~2011-02-16 22:11 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-24  4:28 Device tree on x86, part v3 Sebastian Andrzej Siewior
2011-01-24  4:28 ` [PATCH TIP 01/14] x86/e820: remove conditional early mapping in parse_e820_ext Sebastian Andrzej Siewior
2011-02-03 20:57   ` Grant Likely
2011-01-24  4:28 ` [PATCH TIP 02/14] x86: Add device tree support Sebastian Andrzej Siewior
2011-01-24  4:34   ` Sebastian Andrzej Siewior
2011-02-16 21:27     ` Grant Likely
2011-02-17 11:05       ` [sodaville] " Sebastian Andrzej Siewior
2011-02-16 21:26   ` Grant Likely
2011-02-17 11:03     ` Sebastian Andrzej Siewior
2011-02-16 21:31   ` Grant Likely
2011-02-17 11:31     ` [sodaville] " Sebastian Andrzej Siewior
2011-02-17 17:02       ` Grant Likely
2011-01-24  4:28 ` [PATCH TIP 03/14] x86/dtb: Add a device tree for CE4100 Sebastian Andrzej Siewior
2011-01-27  5:00   ` David Gibson
2011-01-27  9:11     ` Sebastian Andrzej Siewior
2011-02-03 20:59       ` Grant Likely
2011-02-03 21:32         ` Mitch Bradley
2011-02-04  9:40           ` Sebastian Andrzej Siewior
2011-02-02 18:58     ` [PATCH TIP v2 " Sebastian Andrzej Siewior
2011-02-03 21:07       ` Grant Likely
2011-02-04 10:06         ` Sebastian Andrzej Siewior
2011-02-16 21:44       ` Grant Likely
2011-02-22 11:21         ` [sodaville] " Sebastian Andrzej Siewior
2011-01-24  4:28 ` [PATCH TIP 04/14] x86/dtb: add irq domain abstraction Sebastian Andrzej Siewior
2011-01-24  4:28 ` [PATCH TIP 05/14] x86/dtb: add early parsing of APIC and IO APIC Sebastian Andrzej Siewior
2011-02-16 21:47   ` Grant Likely
2011-01-24  4:28 ` [PATCH TIP 06/14] x86/dtb: add support hpet Sebastian Andrzej Siewior
2011-01-24  4:28 ` [PATCH OF 07/14] of: move of_irq_map_pci() into generic code Sebastian Andrzej Siewior
2011-02-10 13:57   ` Michal Simek
2011-02-16 21:53   ` Grant Likely
2011-02-17  7:49     ` Michal Simek
2011-01-24  4:28 ` [PATCH TIP 08/14] x86/dtb: add support for PCI devices backed by dtb nodes Sebastian Andrzej Siewior
2011-02-16 21:59   ` Grant Likely
2011-02-22 11:21     ` [sodaville] " Sebastian Andrzej Siewior
2011-01-24  4:28 ` [PATCH TIP 09/14] x86/dtb: Add generic bus probe Sebastian Andrzej Siewior
2011-02-04 10:21   ` [PATCH v2 " Sebastian Andrzej Siewior
2011-02-16 22:04     ` Grant Likely
2011-01-24  4:28 ` [PATCH TIP 10/14] x86/ioapic: Add OF bindings for IO-APIC Sebastian Andrzej Siewior
2011-02-16 22:04   ` Grant Likely
2011-01-24  4:28 ` [PATCH TIP 11/14] x86/ce4100: use OF for ioapic Sebastian Andrzej Siewior
2011-01-24  4:29 ` [PATCH OF 12/14] x86/rtc: don't register rtc if we the DT blob Sebastian Andrzej Siewior
2011-02-16 22:08   ` Grant Likely
2011-02-16 22:09   ` Grant Likely
2011-02-17 13:13     ` [sodaville] " Sebastian Andrzej Siewior
2011-01-24  4:29 ` [PATCH OF 13/14] rtc/cmos: add OF bindings Sebastian Andrzej Siewior
2011-01-24  4:38   ` Sebastian Andrzej Siewior
2011-02-16 22:11   ` Grant Likely [this message]
2011-02-17 13:26     ` [sodaville] " Sebastian Andrzej Siewior
2011-02-17 16:46       ` Grant Likely
2011-01-24  4:29 ` [PATCH TIP 14/14] x86/pci: remove warning 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=20110216221108.GJ22837@angua.secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --cc=a.zummo@towertech.it \
    --cc=bigeasy@linutronix.de \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rtc-linux@googlegroups.com \
    --cc=sodaville@linutronix.de \
    --cc=x86@kernel.org \
    --subject='Re: [PATCH OF 13/14] rtc/cmos: add OF bindings' \
    /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

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).