Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp254003yba; Wed, 3 Apr 2019 08:09:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrJ9kkhwJL+y+qVlEUIFCQAf2c/thfe5/Z2OMtQNkSk2BKDZmaTf5rde1ifbh1qkdrb3zy X-Received: by 2002:a17:902:12f:: with SMTP id 44mr438284plb.208.1554304196663; Wed, 03 Apr 2019 08:09:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554304196; cv=none; d=google.com; s=arc-20160816; b=y4rl++q/8PHN1apbPXb/dNRMeSgNT3275IiyOgOClRu3XFY36af5DBMU0g7o4kSN+v judopKKghKSSYXnRm33QUxXlqirSzv7b8JkyGO+kIUMmwQmDzM5CjGz4KkyeSoTfdKHE V84KHK4OWPMdlA8sA9sIG8MoQnjJDySyjfIqbyiI+gTMD5UCbeFHNAti8PHdWKABcLEt XIhXEQZTxWT9eevD7ApOwSHOPMbTvx2NG5myUCztHdtqZdPqZ67H1qadree+x9OMmjnQ 6qQbuC3U6Nbic+X5uZDvmSBMOIIZ/uC1vigQ0KcfTeAgSinHkymbWu4+Sbjt6uWbYgre okvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=DglYjm9NMPWO3euoCyBBx8wmZmNWJ82nHyrCTzEBDcA=; b=j1VUJ4IdkOq8fZk+zgM6eurLkF77TT24Ztg3Cw+kn07hTJ13y7pHTmzsLDxwjRVB8m hW1cnHVEXAL6m+EvM6ws/4czj9luR5AVmxZgSoTDkJY3BgUKbZInwkxjOnKf3KCRlNdt ABokhDcySZA8lEXt2ccxRmgtI7srCgqlZifpR2qW2GXHjsl9xROMSqs+MRi0PPASYgRR CrMV1R/RNiLNTQvzytt/VnrDN9GrsyMkqHemK82mPzunTH+Q4BXPTynZEGwzUyTa/GDe HFEgWUOcpzuqFlfV3h5nN/NHT9o4Q0A5DI7Bd+FiCt8P8x/53lL+yBuJ/yLRLJDlrNqP CUyg== 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 ci5si7048242plb.145.2019.04.03.08.09.41; Wed, 03 Apr 2019 08:09:56 -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 S1726545AbfDCPI3 (ORCPT + 99 others); Wed, 3 Apr 2019 11:08:29 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:37209 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726155AbfDCPI3 (ORCPT ); Wed, 3 Apr 2019 11:08:29 -0400 X-Originating-IP: 109.213.83.19 Received: from localhost (alyon-652-1-60-19.w109-213.abo.wanadoo.fr [109.213.83.19]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 05D041C0003; Wed, 3 Apr 2019 15:08:25 +0000 (UTC) Date: Wed, 3 Apr 2019 17:08:24 +0200 From: Alexandre Belloni To: Flavio Suligoi 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 Message-ID: <20190403150824.GO22216@piout.net> References: <1554303165-24813-1-git-send-email-f.suligoi@asem.it> <1554303165-24813-2-git-send-email-f.suligoi@asem.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1554303165-24813-2-git-send-email-f.suligoi@asem.it> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > 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