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: 251669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-wg0-x239.google.com (mail-wg0-x239.google.com [IPv6:2a00:1450:400c:c00::239]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 36F1C2C009E for ; Sun, 16 Jun 2013 21:20:50 +1000 (EST) Received: by mail-wg0-f57.google.com with SMTP id b12sf402759wgh.22 for ; Sun, 16 Jun 2013 04:20:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:x-beenthere:from:to:cc:subject:date:message-id :x-mailer:in-reply-to:references:x-spam:x-mras:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=JYh1VJlbxv5U8Io6WXQGfmVOEKUUt6N12ZwGK4gZwss=; b=uqUK0z2dbf39k36pTZzkUkmnjNigmlu0SjgoiTMPxjS+jmNOqGl6k9+CBVVBuo93Q+ t1D1syO7laups8rcI+2+757GYjUBm4u/uB8Amm835sXX95s/tXxbEl9t0mF0K88u6PBE 2FJn1cWbI/BpMoRh07FEEK9O1veH+UqIsR88q7TuKO6WVx92EHkf1e8UL6zSbOYABrNQ EOkYknUo5ereU0tLmJ6GDL2DZBmXkRC9fkhQLn4Im/+UupeS+dfJERHWSZClyzllfyDc ZgBlWhMHpbH0sI3bIezQvDNfSilzcCHpJqFYabB9FMH4fhoSBzfjqaEGz7I3ID0hCl/0 lPRA== X-Received: by 10.180.198.100 with SMTP id jb4mr130818wic.14.1371381646997; Sun, 16 Jun 2013 04:20:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.180.93.7 with SMTP id cq7ls167362wib.34.canary; Sun, 16 Jun 2013 04:20:46 -0700 (PDT) X-Received: by 10.204.224.8 with SMTP id im8mr734736bkb.5.1371381646531; Sun, 16 Jun 2013 04:20:46 -0700 (PDT) Received: from smtp45.i.mail.ru (smtp45.i.mail.ru. [94.100.177.105]) by gmr-mx.google.com with ESMTPS id cm16si547420bkb.0.2013.06.16.04.20.46 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 16 Jun 2013 04:20:46 -0700 (PDT) Received-SPF: pass (google.com: domain of shc_work@mail.ru designates 94.100.177.105 as permitted sender) client-ip=94.100.177.105; 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 Cc: rtc-linux@googlegroups.com, Russell King , Sascha Hauer , Grant Likely , Rob Herring , Alessandro Zummo , Shawn Guo , Alexander Shiyan Subject: [rtc-linux] [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-Spam: Not detected X-Mras: Ok X-Original-Sender: shc_work@mail.ru X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of shc_work@mail.ru designates 94.100.177.105 as permitted sender) smtp.mail=shc_work@mail.ru; dkim=pass header.i=@mail.ru Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , 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,