From patchwork Fri Dec 17 15:33:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 75911 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-fx0-f56.google.com (mail-fx0-f56.google.com [209.85.161.56]) by ozlabs.org (Postfix) with ESMTP id A3B231007D6 for ; Sat, 18 Dec 2010 02:34:54 +1100 (EST) Received: by fxm3 with SMTP id 3sf188330fxm.11 for ; Fri, 17 Dec 2010 07:34:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:mime-version:x-beenthere:received :received:received:received:received-spf:received:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references:x-virus-scanned :x-virus-status:x-spam-status:x-spam-checker-version :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :sender:list-subscribe:list-unsubscribe:content-type; bh=hrOnh9nOo4ArYVEZcn7NKXQDWzEvCXXdMysZxHnZe0k=; b=Jd8znzGfiSHh3X0as3SwSgZScKaLlrlA/vZE165XP8EtOWpLv2uPMVFeuMhfpglcd8 UvcGVGzmChjkftkZzBFebRtKpzQGe9nVgWzMlZ2JLdUO/BzuqkDwC74wBusmarkeAlme 6635TrJWGt60ep+6z4QSf1yjFyKXSqHl7ESAM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:x-virus-scanned :x-virus-status:x-spam-status:x-spam-checker-version :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :sender:list-subscribe:list-unsubscribe:content-type; b=uuUJNpL9VJaoZ4em0Th5B7YqX/IwhP7LIQOQeY1d3LPLRxwX4ArP6tbcsUXEbZUuEj WSL0oh3X36fxkE1ffZjqeYAg2HoaoUHX2mUpZDREJKliz1mmFpmRHy6K0Z/iDKdRf+l3 u/4FGSJy6583Erux5FYNxbP+DA6ugpDBQ8IK0= Received: by 10.223.73.195 with SMTP id r3mr50862faj.3.1292600090087; Fri, 17 Dec 2010 07:34:50 -0800 (PST) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.223.99.152 with SMTP id u24ls977711fan.0.p; Fri, 17 Dec 2010 07:34:49 -0800 (PST) Received: by 10.223.70.137 with SMTP id d9mr92017faj.12.1292600089505; Fri, 17 Dec 2010 07:34:49 -0800 (PST) Received: by 10.223.70.137 with SMTP id d9mr92016faj.12.1292600089479; Fri, 17 Dec 2010 07:34:49 -0800 (PST) Received: from www.tglx.de (www.tglx.de [62.245.132.106]) by gmr-mx.google.com with ESMTPS id a26si32149faa.8.2010.12.17.07.34.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 17 Dec 2010 07:34:49 -0800 (PST) Received-SPF: neutral (google.com: 62.245.132.106 is neither permitted nor denied by best guess record for domain of bigeasy@linutronix.de) client-ip=62.245.132.106; Received: from Shiva.tec.linutronix.de (www.tglx.de [127.0.0.1]) by www.tglx.de (8.13.8/8.13.8/TGLX-2007100201) with ESMTP id oBHFY6wD016621; Fri, 17 Dec 2010 16:34:43 +0100 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: sodaville@linutronix.de, x86@kernel.org, dirk.brandewie@gmail.com, Sebastian Andrzej Siewior , rtc-linux@googlegroups.com, Alessandro Zummo , devicetree-discuss@lists.ozlabs.org Subject: [rtc-linux] [PATCH 14/15] rtc/cmos: add OF bindings Date: Fri, 17 Dec 2010 16:33:52 +0100 Message-Id: <1292600033-12271-15-git-send-email-bigeasy@linutronix.de> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <1292600033-12271-1-git-send-email-bigeasy@linutronix.de> References: <1292600033-12271-1-git-send-email-bigeasy@linutronix.de> X-Virus-Scanned: clamav-milter 0.95.3 at www.tglx.de X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED autolearn=failed version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on www.tglx.de X-Original-Sender: bigeasy@linutronix.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 62.245.132.106 is neither permitted nor denied by best guess record for domain of bigeasy@linutronix.de) smtp.mail=bigeasy@linutronix.de Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , 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 Cc: devicetree-discuss@lists.ozlabs.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Dirk Brandewie --- 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 #include #include +#include +#include /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ #include @@ -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 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, }