Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp260500yba; Wed, 3 Apr 2019 08:16:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXIQSbp8l1NLNg8ZGeJ0fui8xVrqatQuVT6+yEBfbQ1iHLZbHRss/ir9dRWO/P7TGaV3KE X-Received: by 2002:a65:4247:: with SMTP id d7mr213977pgq.114.1554304583181; Wed, 03 Apr 2019 08:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554304583; cv=none; d=google.com; s=arc-20160816; b=cL4rhi0eM4lbsqt2I/jBAZsmxWN6Vyd5xvTPMcIAdfhDCwxfM1OXYo7DejOhyCRW8t 9pTYNA1FSAQPTa2IbXX9Qd8K8r/Gw7s1UlGuHt5tEnrYgdw4RhBgPT6qq6HqYhmwDq3y +ZvWEYDQg9YaJvQrcRy9Ofib9AdTALBNXVntKLFIOMw7jTOjX+Br6ripvozBWl7w0jZd L1FZcvipstO1/t/w6wgQrcy6aKGNhYolQ2htyTwhsi/hmRmx6yN7OkZMRJd8R6PO1EZb 1fFryi97udlbDoIFMbNfRBAgSVbIXhio//ZEZ4A5gXi7jeBfu9YowvJKjsSEq+JHIDrV 7IGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=AcJsnDrKeaSpWvASmod3Pj+8WR4UOLwRAFZdMvVLlCM=; b=hGxHJbaUS7yRtMisVVhjWR3Q6fw+YvIj5cekNaD/15j2tQrknOEeaZhXyDBdQfSH6N GlyU2IRxQnZd8+WfDk/W2ur6kdblM6J4i61piBidC3s0wtPXptzUclXC4ja2OCTDvibm eWa7QFABAu0Jh9CqMkHJ67FcQTO7fMNVcO4Zl0FRKS1kxGv9bXZkFAWoRkoPtOPzWNXA UJa3Ou5uDOn5GAQTMZxDsDlqA+hs4D86RHYvlQLPZB7a/AuXLS3nJyRNZ2cVPc2GI1FI FnfnI40I3B+qfiZf6KDeBHFndXzlgNv5Jm1KEe+NARk2a0JgPMCzCdGDX5Kagp5BPh0Z bTVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 195si13991714pga.312.2019.04.03.08.16.08; Wed, 03 Apr 2019 08:16:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726825AbfDCPOd convert rfc822-to-8bit (ORCPT + 99 others); Wed, 3 Apr 2019 11:14:33 -0400 Received: from smtp.asem.it ([151.1.184.197]:56847 "EHLO smtp.asem.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbfDCPOc (ORCPT ); Wed, 3 Apr 2019 11:14:32 -0400 Received: from webmail.asem.it by asem.it (smtp.asem.it) (SecurityGateway 5.5.0) with ESMTP id SG003789590.MSG for ; Wed, 03 Apr 2019 17:14:24 +0200S Received: from ASAS044.asem.intra (172.16.16.44) by ASAS044.asem.intra (172.16.16.44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Wed, 3 Apr 2019 17:14:24 +0200 Received: from ASAS044.asem.intra ([::1]) by ASAS044.asem.intra ([::1]) with mapi id 15.01.1261.035; Wed, 3 Apr 2019 17:14:24 +0200 From: Flavio Suligoi To: Alexandre Belloni CC: Alessandro Zummo , Rob Herring , Mark Rutland , "linux-rtc@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH 2/2] rtc: pcf2127: add battery-low INTn generation Thread-Topic: [PATCH 2/2] rtc: pcf2127: add battery-low INTn generation Thread-Index: AQHU6izzDrhx33Rd2E28nY3Qp112E6YqaEkAgAAhzmA= Date: Wed, 3 Apr 2019 15:14:24 +0000 Message-ID: <452a4cf1410a41c8b6f767ac6258482e@asem.it> References: <1554303165-24813-1-git-send-email-f.suligoi@asem.it> <1554303165-24813-2-git-send-email-f.suligoi@asem.it> <20190403150824.GO22216@piout.net> In-Reply-To: <20190403150824.GO22216@piout.net> Accept-Language: it-IT, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.17.208] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-SGHeloLookup-Result: pass smtp.helo=webmail.asem.it (ip=172.16.16.44) X-SGSPF-Result: none (smtp.asem.it) X-SGOP-RefID: str=0001.0A0B020F.5CA4CDD1.001E,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 (_st=1 _vt=0 _iwf=0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alexandre, > On 03/04/2019 16:52:45+0200, Flavio Suligoi wrote: > > The pcf2127 has an automatic battery-low detection function. > > > > In case of battery-low event, an interrupt generation through > > the pin INTn (active low) can be enabled, setting the flag BLIE > > in the register Control_3. > > > > This function is activated by the "battery-low-hw-alarm" DT property. > > > > Example of use for an NXP i.MX7D board: > > > > &i2c3 { > > clock-frequency = <100000>; > > pinctrl-names = "default"; > > pinctrl-0 = <&pinctrl_i2c3>; > > status = "okay"; > > > > pcf2127@51 { > > compatible = "nxp,pcf2127"; > > reg = <0x51>; > > battery-low-hw-alarm; > > status = "okay"; > > }; > > }; > > > > So I'm curious, how do you then use that signal? I have a (not yet sent) > series adding alarm support for the pcf2127. The issue having BLIE is > that then this will prevent the alarm to work properly. > > So my guess is that you have nINT connected to an LED or something that > the user can see? > I'm working on our custom embedded board with an NXP i.MX7D, developed here, in Asem (www.asem.it). The nINT pin is connected to a GPIO of the MX7 and then used by an applicative sw, to generate an alarm for the user. > > Signed-off-by: Flavio Suligoi > > --- > > drivers/rtc/rtc-pcf2127.c | 33 +++++++++++++++++++++++++++++++++ > > 1 file changed, 33 insertions(+) > > > > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c > > index 7cb786d..e3805c8 100644 > > --- a/drivers/rtc/rtc-pcf2127.c > > +++ b/drivers/rtc/rtc-pcf2127.c > > @@ -228,6 +228,10 @@ static int pcf2127_probe(struct device *dev, struct > regmap *regmap, > > const char *name, bool has_nvmem) > > { > > struct pcf2127 *pcf2127; > > + struct device_node *np; > > + struct i2c_client *client = to_i2c_client(dev); > > + unsigned char buf[2]; > > + int err; > > int ret = 0; > > > > dev_dbg(dev, "%s\n", __func__); > > @@ -245,6 +249,35 @@ static int pcf2127_probe(struct device *dev, struct > regmap *regmap, > > if (IS_ERR(pcf2127->rtc)) > > return PTR_ERR(pcf2127->rtc); > > > > + /* > > + * The pcf2127 has an automatic battery-low detection function. > > + * > > + * In case of battery-low event, an interrupt generation through > > + * the pin INTn (active low) can be enabled, setting the flag BLIE > > + * in the register Control_3. > > + */ > > + np = of_node_get(dev->of_node); > > + if (!np) { > > + dev_err(dev, "failed to find the RTC pcf2127 node\n"); > > + return -ENOENT; > > + } > > + if (of_get_property(np, "battery-low-hw-alarm", NULL)) { > > + dev_info(dev, "enable battery-low hw alarm on INTn pin\n"); > > + > > + /* > > + * Set BLIE bit in register Control_3 (override is possible > > + * because this register is fully zero after reset) > > + */ > > + buf[0] = PCF2127_REG_CTRL3; > > + buf[1] = 0x01; > > + /* write register's data */ > > + err = i2c_master_send(client, buf, 2); > > This has to use regmap_update_bits because this also has to work on spi. > (I don't know where you get the client pointer from anyway). > > > + if (err != 2) { > > + dev_err(dev, "%s: err=%d", __func__, err); > > + return -EIO; > > + } > > + } > > + > > if (has_nvmem) { > > struct nvmem_config nvmem_cfg = { > > .priv = pcf2127, > > -- > > 2.7.4 > > > > -- > Alexandre Belloni, Bootlin > Embedded Linux and Kernel engineering > https://bootlin.com Flavio Suligoi