From patchwork Mon Jan 24 04:29:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 80089 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]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 20F671007DC for ; Mon, 24 Jan 2011 15:29:57 +1100 (EST) Received: by fxm3 with SMTP id 3sf1903986fxm.11 for ; Sun, 23 Jan 2011 20:29:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature: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; bh=oDqYY/w9zJnR98pgS+kaBSouCOCrsbdOlHhxx91Wae4=; b=C2aczLOO0dHbfWnnTS1uioVJ8+aAg1c9nQcQ6fesMrNVL6NNnFxO+86oyYx0y+zhIv sWRe665sZcj7s2m/3eRykiBmXm4fW7b7u+zWnRsiTYZrAt9EylOmgspyeuUg99PF5K2K NxB49CIoXZXgiQnj2SGvEIV/PypWsqL8fvNfk= 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=j9u1xC1MtLDVOi3IWjj64QSvA5xKojSJMkRIIlqCRHqlQYF7KzelgKN9WgVmJnpYeU c1VARtxTehzwi+2+QUwF2NnTHMvQ2grv11z0hvlbea2ejTvQ3yI96cfcHSvhtT1z5DAe 0UOrYKNO7u79XpdOKvTHNqV9LyETRv1kv6EQw= Received: by 10.223.93.144 with SMTP id v16mr280061fam.43.1295843392991; Sun, 23 Jan 2011 20:29:52 -0800 (PST) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.204.134.7 with SMTP id h7ls1371279bkt.2.p; Sun, 23 Jan 2011 20:29:52 -0800 (PST) Received: by 10.204.134.24 with SMTP id h24mr251188bkt.7.1295843391970; Sun, 23 Jan 2011 20:29:51 -0800 (PST) Received: by 10.204.134.24 with SMTP id h24mr251187bkt.7.1295843391954; Sun, 23 Jan 2011 20:29:51 -0800 (PST) Received: from www.tglx.de (www.tglx.de [62.245.132.106]) by gmr-mx.google.com with ESMTPS id f12si2199239bkf.3.2011.01.23.20.29.51 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 23 Jan 2011 20:29:51 -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 p0O4T9Qs021077; Mon, 24 Jan 2011 05:29:43 +0100 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: sodaville@linutronix.de, x86@kernel.org, devicetree-discuss@lists.ozlabs.org, Sebastian Andrzej Siewior , rtc-linux@googlegroups.com, Alessandro Zummo , Dirk Brandewie Subject: [rtc-linux] [PATCH OF 13/14] rtc/cmos: add OF bindings Date: Mon, 24 Jan 2011 09:59:01 +0530 Message-Id: <1295843342-1122-14-git-send-email-bigeasy@linutronix.de> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <1295843342-1122-1-git-send-email-bigeasy@linutronix.de> References: <1295843342-1122-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,AWL 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 | 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 @@ -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 #include #include +#include +#include /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ #include @@ -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 } };