From patchwork Fri Apr 15 16:46:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 8852241 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D62479F1E6 for ; Fri, 15 Apr 2016 16:47:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C74CD2037C for ; Fri, 15 Apr 2016 16:47:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9F4CC20373 for ; Fri, 15 Apr 2016 16:47:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751682AbcDOQrg (ORCPT ); Fri, 15 Apr 2016 12:47:36 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:45333 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751428AbcDOQrf (ORCPT ); Fri, 15 Apr 2016 12:47:35 -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 u3FGknbl001597; Fri, 15 Apr 2016 11:46:49 -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 u3FGkncS030229; Fri, 15 Apr 2016 11:46:49 -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.224.2; Fri, 15 Apr 2016 11:46:48 -0500 Received: from [172.22.234.183] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u3FGkjAl011712; Fri, 15 Apr 2016 11:46:46 -0500 Subject: Re: [PATCH] rtc: omap: Support ext_wakeup configuration To: Marcin Niestroj , Tony Lindgren References: <1459785403-1725-1-git-send-email-m.niestroj@grinn-global.com> <20160404224046.GA17042@atomide.com> <57078A89.3080809@ti.com> <20160408151408.GS16484@atomide.com> <5707E764.7050204@ti.com> <570D2F79.9040202@grinn-global.com> CC: , , Rob Herring , Pawel Moll , Alessandro Zummo , Alexandre Belloni , Keerthy , , Dave Gerlach , "Menon, Nishanth" From: Grygorii Strashko Message-ID: <57111AF4.6070505@ti.com> Date: Fri, 15 Apr 2016 19:46:44 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <570D2F79.9040202@grinn-global.com> 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.9 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 04/12/2016 08:25 PM, Marcin Niestroj wrote: > Hi, > > On 08.04.2016 19:16, Grygorii Strashko wrote: >> On 04/08/2016 06:14 PM, Tony Lindgren wrote: >>> * Grygorii Strashko [160408 03:41]: >>>> Hi Tony, >>>> >>>> On 04/05/2016 01:40 AM, Tony Lindgren wrote: >>>>> Hi, >>>>> >>>>> * Marcin Niestroj [160404 08:57]: >>>>>> Support configuration of ext_wakeup sources. This patch makes it >>>>>> possible to enable ext_wakeup and set it's polarity, depending on >>>>>> board >>>>>> configuration. AM335x's dedicated PMIC (tps65217) uses ext_wakeup to >>>>>> notify about power-button presses. Handling power-button presses >>>>>> enables >>>>>> to recover from RTC-only power states correctly. >>>>> >>>>> I suggest you just set this pin up as a minimal gpiochip. That way >>>>> we can use the standard binding :) And if we get lucky, this pin can >>>>> also trigger during runtime. >>>>> >>>> >>>> Following my comments on v2 of this patch I propose to rollback to >>>> this version of the patch. >>>> >>>> It seems doesn't fit in gpiochip, it's more likely irqchip, but since >>>> rtc can't generate IRQ there are nor reasons for these genetic >>>> experiments and RTC's specific bindings looks more suitable, at >>>> least for me. >>> >>> Hmm well gpiochips typically are irqchip too. IMO the generic binding >>> here sounds like "gpio-wakeup" as it's an input with polarity and with >>> an optional interrupt. >>> >>> Plain irqchip would work too in this case if there are no other GPIO >>> specific features. Some other RTCs may have more GPIO like features. >>> >>> In any case, setting the ext_wakeup up as an irqchip means that the >>> RTC controller can be used as a dedicated wakeirq with Linux :) >> >> It can't :( It can't generate IRQ when state of ext_wakeup line has >> been changed. >> >>> >>> Are you guys sure there's no wake pin events during runtime? AFAIK >>> the RTCs just typically produce an interrupt when programmed to >>> do so, they don't know the state of the SoC. >>> >> >> I do not think that It can be fit in gpiochip or irqchip - >> in my opinion right way is to proceed with bindings proposed by >> Marcin in this patch v1. >> >> But, probably, it could fit in pinctrl: >> - this is pin's configuration >> - this is one-time configuration >> - or - configuration which can be applied before suspend >> and resorted after suspend. >> >> if you still wanna try some generic framework. >> > > pinctrl bindings looks ok for our use case (enable/disable input, > configure debounce), except I don't see any way to pass polarity > (active low/high) to the driver. > Below code is just a POC that pinctrl can be used here. It does one time configuration at boot, but more sates can be added - sleep, poweroff: diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi index 13ac882..9580c82 100644 --- a/arch/arm/boot/dts/dra7.dtsi +++ b/arch/arm/boot/dts/dra7.dtsi @@ -1248,11 +1248,40 @@ rtc: rtc@48838000 { compatible = "ti,am3352-rtc"; - reg = <0x48838000 0x100>; + reg = <0x48838000 0x98>; interrupts = , ; ti,hwmods = "rtcss"; clocks = <&sys_32k_ck>; + #address-cells = <1>; + #size-cells = <1>; + ranges; + + rtc_pmx: pinmux@48838098 { + compatible = "pinctrl-single"; + reg = <0x48838098 0x8>; + #address-cells = <1>; + #size-cells = <0>; + pinctrl-single,register-width = <32>; + pinctrl-single,function-mask = <0x007fffff>; + + pinctrl-names = "default"/*, "sleep"*/; + pinctrl-0 = <&rtc_default>; +/* pinctrl-1 = <&rtc_sleep>;*/ + + rtc_default: rtc_default { + pinctrl-single,pins = < + 0x0 0x000B0111 + 0x4 0x00000004 + >; + }; +/* rtc_sleep: rtc_sleep { + pinctrl-single,pins = < + 0x0 0x00000000 + 0x4 0x00000000 + >; + };*/ + }; }; /* OCP2SCP1 */ diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index ec2e9c5..28c67a4 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -428,8 +428,10 @@ static void omap_rtc_power_off(void) rtc->type->unlock(rtc); /* enable pmic_power_en control */ +/* val = rtc_readl(rtc, OMAP_RTC_PMIC_REG); rtc_writel(rtc, OMAP_RTC_PMIC_REG, val | OMAP_RTC_PMIC_POWER_EN_EN); +*/ /* set alarm two seconds from now */ omap_rtc_read_time_raw(rtc, &tm); @@ -650,6 +652,8 @@ static int omap_rtc_probe(struct platform_device *pdev) reg | OMAP_RTC_OSC_SEL_32KCLK_SRC); } + of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); + rtc->type->lock(rtc); device_init_wakeup(&pdev->dev, true);