From patchwork Thu Sep 25 09:32:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lokesh Vutla X-Patchwork-Id: 4973951 Return-Path: X-Original-To: patchwork-linux-omap@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 1FCD4BEEA7 for ; Thu, 25 Sep 2014 09:34:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C27FC202E5 for ; Thu, 25 Sep 2014 09:34:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8C0DC202C8 for ; Thu, 25 Sep 2014 09:34:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752868AbaIYJeJ (ORCPT ); Thu, 25 Sep 2014 05:34:09 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:43691 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751985AbaIYJeI (ORCPT ); Thu, 25 Sep 2014 05:34:08 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s8P9XCen020011; Thu, 25 Sep 2014 04:33:12 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s8P9XBPc027165; Thu, 25 Sep 2014 04:33:11 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Thu, 25 Sep 2014 04:33:12 -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 s8P9WrHf001216; Thu, 25 Sep 2014 04:33:08 -0500 From: Lokesh Vutla To: , CC: , , , , , , , , Subject: [PATCH v2 4/4] rtc: omap: Support regulator supply for RTC Date: Thu, 25 Sep 2014 15:02:09 +0530 Message-ID: <1411637529-18289-5-git-send-email-lokeshvutla@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411637529-18289-1-git-send-email-lokeshvutla@ti.com> References: <1411637529-18289-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=-7.6 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 --- Changes since v1: - Separated probe deferral supporting into a new patch. 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 5a0f02d..c67a775 100644 --- a/Documentation/devicetree/bindings/rtc/rtc-omap.txt +++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt @@ -10,6 +10,9 @@ Required properties: - interrupts: rtc timer, alarm interrupts in order - interrupt-parent: phandle for the interrupt controller +Optional Properties: +- rtc-supply : phandle to the regulator device tree node if needed + Example: rtc@1c23000 { diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index f28f1fd..8a8df2b 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -24,6 +24,7 @@ #include #include #include +#include /* The OMAP RTC is a year/month/day/hours/minutes/seconds BCD clock * with century-range alarm matching, driven by the 32kHz clock. @@ -124,6 +125,7 @@ * @device: Device Pointer. * pdata : Copy of saved platform data. * rtc_base : Base address of memory-mapped IO registers. + * rtc_reg : Pointer to RTC power regulator. * rtc_alarm : RTC alarm interrupt number. * rtc_timer : RTC timer interrupt number. * irq_stat : Copy of Interrupt status register. @@ -133,6 +135,7 @@ struct rtc_omap_dev { struct device *dev; unsigned long pdata; void __iomem *rtc_base; + struct regulator *rtc_reg; u32 rtc_alarm; u32 rtc_timer; u8 irqstat; @@ -402,6 +405,7 @@ static int omap_rtc_probe(struct platform_device *pdev) struct resource *res; struct rtc_omap_dev *rtc_omap; u8 reg, new_ctrl; + int ret; const struct platform_device_id *id_entry; const struct of_device_id *of_id; @@ -440,6 +444,23 @@ static int omap_rtc_probe(struct platform_device *pdev) if (IS_ERR(rtc_omap->rtc_base)) return PTR_ERR(rtc_omap->rtc_base); + rtc_omap->rtc_reg = devm_regulator_get_optional(&pdev->dev, "rtc"); + if (IS_ERR(rtc_omap->rtc_reg)) { + if (PTR_ERR(rtc_omap->rtc_reg) == -EPROBE_DEFER) { + dev_err(&pdev->dev, "regulator not ready, retry\n"); + return -EPROBE_DEFER; + } + rtc_omap->rtc_reg = NULL; + } + + if (rtc_omap->rtc_reg) { + ret = regulator_enable(rtc_omap->rtc_reg); + if (ret) { + dev_dbg(&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); @@ -549,6 +570,9 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); + if (rtc_omap->rtc_reg) + regulator_disable(rtc_omap->rtc_reg); + return 0; }