From patchwork Sun Jun 23 08:32:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 2767031 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AD65E9F3A0 for ; Sun, 23 Jun 2013 08:34:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 839442011F for ; Sun, 23 Jun 2013 08:34:45 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D4C222011B for ; Sun, 23 Jun 2013 08:34:43 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uqfjw-0002VS-II; Sun, 23 Jun 2013 08:33:41 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UqfjS-000139-OB; Sun, 23 Jun 2013 08:33:10 +0000 Received: from smtp35.i.mail.ru ([94.100.177.95]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UqfjO-000120-GS for linux-arm-kernel@lists.infradead.org; Sun, 23 Jun 2013 08:33:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=MxdPfedy58lcLJl3TJwit06PovdWslfYlkUPt9t5vu0=; b=Q4Qlauz3l8QhAKCs4kFZFVqsu/ebS8i8BSm819DOKGXfla2ZgI42hsfrjB2JBZySWn3URwF6ac7hW0DANeQDfx3WNvg/wVrjAGZFi+Qzk15KvBFY4dbuoKsXvRfErStaoeMOfl57Lc4KTAoYvas+dC4Wfcca3AGE+0mPQVS25bY=; Received: from [188.134.40.128] (port=8727 helo=shc.zet) by smtp35.i.mail.ru with esmtpa (envelope-from ) id 1Uqfiz-0007tn-6T; Sun, 23 Jun 2013 12:32:41 +0400 From: Alexander Shiyan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/3] rtc: mxc_rtc: Add DT support Date: Sun, 23 Jun 2013 12:32:29 +0400 Message-Id: <1371976349-18679-3-git-send-email-shc_work@mail.ru> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1371976349-18679-1-git-send-email-shc_work@mail.ru> References: <1371976349-18679-1-git-send-email-shc_work@mail.ru> X-Mras: Ok X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130623_043307_005963_7AB744F9 X-CRM114-Status: GOOD ( 16.36 ) X-Spam-Score: -2.0 (--) Cc: Alessandro Zummo , Alexander Shiyan , rtc-linux@googlegroups.com, Rob Herring , Sascha Hauer , Grant Likely , Shawn Guo X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add DT bindings for the mxc_rtc driver and read the device configuration from the DT node at probe time if available. Signed-off-by: Alexander Shiyan --- Documentation/devicetree/bindings/rtc/mxc-rtc.txt | 21 ++++++++++++++++++ drivers/rtc/rtc-mxc.c | 27 +++++++++++++++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/rtc/mxc-rtc.txt diff --git a/Documentation/devicetree/bindings/rtc/mxc-rtc.txt b/Documentation/devicetree/bindings/rtc/mxc-rtc.txt new file mode 100644 index 0000000..ad8b0b3 --- /dev/null +++ b/Documentation/devicetree/bindings/rtc/mxc-rtc.txt @@ -0,0 +1,21 @@ +* i.MX Real Time Clock controller + +This binding supports the following chips: i.MX1, i.MX27, i.MX31, i.MX35 + +Required properties: +- compatible: should be: "fsl,imx1-rtc" or "fsl,imx21-rtc" +- reg: physical base address of the controller and length of memory mapped + region. +- interrupts: rtc alarm interrupt +- clocks : Should contain the rtc and ipg clocks, in the order + determined by the clock-names property. + +Example: + +rtc@10007000 { + compatible = "fsl,imx27-rtc", "fsl,imx21-rtc"; + reg = <0x10007000 0x1000>; + interrupts = <22>; + clocks = <&clks 2>, <&clks 33>; + clock-names = "rtc", "ipg"; +}; diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index b4da99c..b60ede2 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include @@ -351,7 +353,16 @@ static int mxc_rtc_probe(struct platform_device *pdev) /* Disable all interrupts */ writew(0, pdata->ioaddr + RTC_RTCIENR); - pdata->devtype = pdev->id_entry->driver_data; + if (pdev->dev.of_node) { + struct platform_driver *pdrv = container_of(pdev->dev.driver, + struct platform_driver, driver); + const struct of_device_id *of_id = + of_match_device(pdrv->driver.of_match_table, &pdev->dev); + + pdata->devtype = (enum imx_rtc_type)of_id->data; + } else + pdata->devtype = pdev->id_entry->driver_data; + platform_set_drvdata(pdev, pdata); pdata->rtc_ops.open = mxc_rtc_open; @@ -422,6 +433,13 @@ static int __maybe_unused mxc_rtc_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(mxc_rtc_pm_ops, mxc_rtc_suspend, mxc_rtc_resume); +static const struct of_device_id mxc_rtc_dt_ids[] = { + { .compatible = "fsl,imx1-rtc", .data = (void *)IMX1_RTC, }, + { .compatible = "fsl,imx21-rtc", .data = (void *)IMX21_RTC, }, + { } +}; +MODULE_DEVICE_TABLE(of, mxc_rtc_dt_ids); + static const struct platform_device_id mxc_rtc_id_table[] = { { .name = "imx1-rtc", .driver_data = IMX1_RTC, }, { .name = "imx21-rtc", .driver_data = IMX21_RTC, }, @@ -431,9 +449,10 @@ MODULE_DEVICE_TABLE(platform, mxc_rtc_id_table); static struct platform_driver mxc_rtc_driver = { .driver = { - .name = "mxc_rtc", - .owner = THIS_MODULE, - .pm = &mxc_rtc_pm_ops, + .name = "mxc_rtc", + .owner = THIS_MODULE, + .of_match_table = mxc_rtc_dt_ids, + .pm = &mxc_rtc_pm_ops, }, .probe = mxc_rtc_probe, .remove = mxc_rtc_remove,