From patchwork Fri Oct 24 04:53:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lokesh Vutla X-Patchwork-Id: 5144071 Return-Path: X-Original-To: patchwork-linux-omap@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 3B8819FAB2 for ; Fri, 24 Oct 2014 04:56:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6BECA2021B for ; Fri, 24 Oct 2014 04:56:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 314CC2026C for ; Fri, 24 Oct 2014 04:56:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755390AbaJXE4E (ORCPT ); Fri, 24 Oct 2014 00:56:04 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:35950 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755270AbaJXE4B (ORCPT ); Fri, 24 Oct 2014 00:56:01 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s9O4t5SN013557; Thu, 23 Oct 2014 23:55:05 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9O4t54N021345; Thu, 23 Oct 2014 23:55:05 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Thu, 23 Oct 2014 23:55:05 -0500 Received: from a0131933.apr.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9O4slCb028330; Thu, 23 Oct 2014 23:55:01 -0500 From: Lokesh Vutla To: , , , CC: , , , , , , , , , , Subject: [PATCH V3 3/3] rtc: omap: Support regulator supply for RTC Date: Fri, 24 Oct 2014 10:23:45 +0530 Message-ID: <1414126425-13198-4-git-send-email-lokeshvutla@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1414126425-13198-1-git-send-email-lokeshvutla@ti.com> References: <1414126425-13198-1-git-send-email-lokeshvutla@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 On some Soc's RTC is powered by an external power regulator. e.g. RTC on DRA7 SoC. Make the OMAP RTC driver support a power regulator. Signed-off-by: Lokesh Vutla Reviewed-by: Johan Hovold Reviewed-by: Felipe Balbi --- Documentation/devicetree/bindings/rtc/rtc-omap.txt | 3 +++ drivers/rtc/rtc-omap.c | 24 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt b/Documentation/devicetree/bindings/rtc/rtc-omap.txt index 750efd4..e7ad12b 100644 --- a/Documentation/devicetree/bindings/rtc/rtc-omap.txt +++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt @@ -15,6 +15,8 @@ Required properties: Optional properties: - ti,system-power-controller: whether the rtc is controlling the system power through pmic_power_en +Optional Properties: +- vrtc-supply: phandle to the regulator device tree node if needed Example: @@ -25,4 +27,5 @@ rtc@1c23000 { 19>; interrupt-parent = <&intc>; ti,system-power-controller; + vrtc-supply = <&ldo9_reg>; }; diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index d9bb5e7..61fe630 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) @@ -516,6 +518,22 @@ static int omap_rtc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, rtc); + 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) { + ret = regulator_enable(rtc->supply); + if (ret) { + dev_err(&pdev->dev, "regulator enable failed\n"); + return ret; + } + } + /* Enable the clock/module so that we can access the registers */ pm_runtime_enable(&pdev->dev); pm_runtime_get_sync(&pdev->dev); @@ -624,6 +642,9 @@ err: pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); + if (rtc->supply) + regulator_disable(rtc->supply); + return ret; } @@ -649,6 +670,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; }