From patchwork Tue Oct 28 09:58:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lokesh Vutla X-Patchwork-Id: 5174171 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1866CC11AD for ; Tue, 28 Oct 2014 10:03:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35C9B20340 for ; Tue, 28 Oct 2014 10:03:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 95B1A202FE for ; Tue, 28 Oct 2014 10:03:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xj3ay-0007Ae-7v; Tue, 28 Oct 2014 10:01:44 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xj3a3-0006P9-4J for linux-arm-kernel@lists.infradead.org; Tue, 28 Oct 2014 10:00:48 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s9SA0GER004238; Tue, 28 Oct 2014 05:00:16 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9SA0Gho018003; Tue, 28 Oct 2014 05:00:16 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Tue, 28 Oct 2014 05:00:16 -0500 Received: from a0131933.apr.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9S9xxJg031401; Tue, 28 Oct 2014 05:00:12 -0500 From: Lokesh Vutla To: , Subject: [PATCH V4 3/3] rtc: omap: Support regulator supply for RTC Date: Tue, 28 Oct 2014 15:28:52 +0530 Message-ID: <1414490332-14856-4-git-send-email-lokeshvutla@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1414490332-14856-1-git-send-email-lokeshvutla@ti.com> References: <1414490332-14856-1-git-send-email-lokeshvutla@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141028_030047_345091_5E1A06FF X-CRM114-Status: GOOD ( 14.69 ) X-Spam-Score: -5.6 (-----) Cc: nm@ti.com, devicetree@vger.kernel.org, tony@atomide.com, j-keerthy@ti.com, nsekhar@ti.com, johan@kernel.org, balbi@ti.com, t-kristo@ti.com, lokeshvutla@ti.com, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, 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 Certain SoCs such as DRA7, RTC is an independent voltage domain of it's own and on platforms such as DRA7-evm, this may be supplied by individual regulator on it's own. So make the OMAP RTC driver support a power regulator. Signed-off-by: Lokesh Vutla --- - Dropped the Reviewed-by tags as this patch is changed from previous version. Documentation/devicetree/bindings/rtc/rtc-omap.txt | 6 ++++ drivers/rtc/rtc-omap.c | 41 +++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt b/Documentation/devicetree/bindings/rtc/rtc-omap.txt index 750efd4..c1d84ac 100644 --- a/Documentation/devicetree/bindings/rtc/rtc-omap.txt +++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt @@ -15,6 +15,9 @@ Required properties: Optional properties: - ti,system-power-controller: whether the rtc is controlling the system power through pmic_power_en +- vrtc-supply: phandle to the regulator device tree node. +- vrtc-minuV: Minimum required voltage in uV, If default voltage needs to be changed +- vrtc-maxuV: Maximum acceptable voltage in uV, If default voltage needs to be changed Example: @@ -25,4 +28,7 @@ rtc@1c23000 { 19>; interrupt-parent = <&intc>; ti,system-power-controller; + vrtc-supply = <&ldo9_reg>; + vrtc-minuV = <1050000>; + vrtc-maxuV = <1050000>; }; diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index d9bb5e7..7f1358a 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -25,6 +25,7 @@ #include #include #include +#include /* * The OMAP RTC is a year/month/day/hours/minutes/seconds BCD clock @@ -134,6 +135,7 @@ struct omap_rtc { u8 interrupts_reg; bool is_pmic_controller; const struct omap_rtc_device_type *type; + struct regulator *supply; }; static inline u8 rtc_read(struct omap_rtc *rtc, unsigned int reg) @@ -484,7 +486,7 @@ static int omap_rtc_probe(struct platform_device *pdev) u8 reg, mask, new_ctrl; const struct platform_device_id *id_entry; const struct of_device_id *of_id; - int ret; + int ret, vrtc_minuV = 0, vrtc_maxuV = 0; rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); if (!rtc) @@ -514,6 +516,37 @@ static int omap_rtc_probe(struct platform_device *pdev) if (IS_ERR(rtc->base)) return PTR_ERR(rtc->base); + rtc->supply = devm_regulator_get_optional(&pdev->dev, "vrtc"); + if (IS_ERR(rtc->supply)) { + if (PTR_ERR(rtc->supply) == -EPROBE_DEFER) + return -EPROBE_DEFER; + + rtc->supply = NULL; + } + + if (rtc->supply) { + of_property_read_u32(pdev->dev.of_node, "vrtc-minuV", + &vrtc_minuV); + of_property_read_u32(pdev->dev.of_node, "vrtc-maxuV", + &vrtc_maxuV); + if (vrtc_minuV && vrtc_maxuV) { + ret = regulator_set_voltage(rtc->supply, + vrtc_minuV, vrtc_maxuV); + if (ret) { + dev_err(&pdev->dev, "failed to set volt %d\n", + ret); + return ret; + } + } + + ret = regulator_enable(rtc->supply); + if (ret) { + dev_err(&pdev->dev, "regulator enable failed %d\n", + ret); + return ret; + } + } + platform_set_drvdata(pdev, rtc); /* Enable the clock/module so that we can access the registers */ @@ -624,6 +657,9 @@ err: pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); + if (rtc->supply) + regulator_disable(rtc->supply); + return ret; } @@ -649,6 +685,9 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); + if (rtc->supply) + regulator_disable(rtc->supply); + return 0; }