From patchwork Sun Jun 16 11:20:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 2728061 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 2A97F9F96B for ; Sun, 16 Jun 2013 11:21:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3422C20172 for ; Sun, 16 Jun 2013 11:21:25 +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 883102016A for ; Sun, 16 Jun 2013 11:21:23 +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 1UoB1G-0005fV-DX; Sun, 16 Jun 2013 11:21:14 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UoB1D-0001ws-Gz; Sun, 16 Jun 2013 11:21:11 +0000 Received: from smtp45.i.mail.ru ([94.100.177.105]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UoB18-0001vx-Ty for linux-arm-kernel@lists.infradead.org; Sun, 16 Jun 2013 11:21: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=2t6qM+GYs5kjF2lSTN1N/GLvMmQco/lcE+vNSrD4w3g=; b=ul4TcC+/SSXH1r+roNUyBpNXhLC/8XoGVJidkoNepKDdRcWwDMysFnvYoyDQbsvBe76vbC/j29TiqM4gf0rnqRG678Us7GqUVDeQJark0VDYry1wRg+UhlgWmB0gpYzzSb/ZWAutyoe7O6JkQclbsKMFDWucNuFRa3uPReaUvIA=; Received: from [188.134.40.128] (port=21129 helo=shc.zet) by smtp45.i.mail.ru with esmtpa (envelope-from ) id 1UoB0n-0004jB-Of; Sun, 16 Jun 2013 15:20:45 +0400 From: Alexander Shiyan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] rtc: mxc_rtc: Add DT support Date: Sun, 16 Jun 2013 15:20:24 +0400 Message-Id: <1371381624-18823-3-git-send-email-shc_work@mail.ru> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1371381624-18823-1-git-send-email-shc_work@mail.ru> References: <1371381624-18823-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-20130616_072107_428934_C57F3B06 X-CRM114-Status: GOOD ( 16.46 ) X-Spam-Score: -2.0 (--) Cc: Alessandro Zummo , Russell King , 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 3d692881..b49842a 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, priv->ioaddr + RTC_RTCIENR); - priv->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); + + priv->devtype = (enum imx_rtc_type)of_id->data; + } else + priv->devtype = pdev->id_entry->driver_data; + platform_set_drvdata(pdev, priv); priv->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,