Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4359282imu; Mon, 28 Jan 2019 23:37:32 -0800 (PST) X-Google-Smtp-Source: ALg8bN6gLhnVNUhJRvi20YLk1yWGFTJMKGy87pqonrZrZKMlBsFRnCqDHjwAjhM+73iNPa5c8bHV X-Received: by 2002:a17:902:bb05:: with SMTP id l5mr25403326pls.230.1548747452063; Mon, 28 Jan 2019 23:37:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548747452; cv=none; d=google.com; s=arc-20160816; b=uSRS8dT17Hb3gPmHGZKfq4xtV/6BR/lvMTSzKEBYBdAffZ80ywWKKUSc3ppAHnqJaA 25N7pRZEzEbxTo+bEbZn+Hlhv4zCu5MCExFjaPF1W6pXUWQDabUCsQtNNtb3MFxUhmZx ON8nwdeDhpmVhKBr31ZvUWw/h1n9rwt3qWokUcKA6Sd+YlVEhX4J514H+dZp3nvOQFVk w0rbvpiZZBdiun1DSUtrQDJRYVBoze8iQ/IDYRijMk2WLy3Bg3u2qZfLK+gkds4iZeNc R+4Q2etz1x3ifVHHZDlAf7J+0D3rWDeniNjp7iEnjPS8//RIEAYMVIdqM0YLHMFHQP2f t57Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=d73E7jU3nBjf12kLdQETTgLJsTcEsxIjiL8Z7y2pKf4=; b=CI2VpXUX0wVY/qsr1gudKDqOaG70pbrvhduaSEj6fzHvn4lxxigaZdm1Hd5izW1HGq qbrNWjJpJIp83qYz56X8k04dpt+/BcCLFLTzkbKUWrdMZefKxqI/GPegcuCLj4MKe09a Qe4m9IYtpPCfenOoGfsHZlVeHYA08jquLWJCsVOLRA9IcvNTQNO/k8zFq+bavkw8eJb2 5OO3AogDclPlzpb+BTKTcV38uWBIfKHOUeVowDscxriH94McQmfU6DvBJ6XoGgiYTF2L UuwN0RPFV5RbSaAmdbu8am+1Z8h6S/L571r+Gz0vUtsfpG0HUj/J/MXkbljhj2cBgIes +3Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MUv4qxDF; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n187si19212087pfn.83.2019.01.28.23.37.15; Mon, 28 Jan 2019 23:37:32 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MUv4qxDF; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726276AbfA2Hga (ORCPT + 99 others); Tue, 29 Jan 2019 02:36:30 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:37996 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725554AbfA2Hg3 (ORCPT ); Tue, 29 Jan 2019 02:36:29 -0500 Received: by mail-io1-f67.google.com with SMTP id l14so15777611ioj.5; Mon, 28 Jan 2019 23:36:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=d73E7jU3nBjf12kLdQETTgLJsTcEsxIjiL8Z7y2pKf4=; b=MUv4qxDFkQ0+pfHZnSuLbMZCvmKxFSbYNOrRxWq/gIymVD95K7Wt002H7/0ZsR3CHr ADrlPXSzbZSZ0tuPZeSsTfU3DTK2kQDxU8VOC7mssUWFc15vRaMkuANLNfBhXhzm2x5n VE4kqgaY2So5ha+CoyU3gwHrGknzS8QNUMU5xlhkVl+yidHyNdkEO8aB9PB873QsUr+9 cxx+emyyDWCw6uwoGpffnYB/hNGdX5DII04VTkQLBkcb6cTHtYQCbOABP03D81AqXP0m VUJCGFrfIJAYX/M+oCVBQneTJE2M3DUAjmnCA6p0J+TTs90/krYNBi6AQ+b1+zveaU4B eoww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=d73E7jU3nBjf12kLdQETTgLJsTcEsxIjiL8Z7y2pKf4=; b=edOU/Kr/mae//AbsMP5aNfqg0xtTkUQ5Rox9pQil9njCLvlnznuH9JQ9FKBY9dw3ky iy+SF/qqAT/A1r/i0PJEkSz4CPrDE3qdfEHzyLpB315Z9wFfV5JVC+D8XSVzV9mPmT2P xgCyFgAbEZzohtLBX1MpwfqhBIsdk/d3aGJ3HazoYzUYsN69NqbBRatqJ7zv4RkBcprT mUSg9JWreJ+7Wz9nRHFkkN5CgjCJD8tuWk7+3BXeVsKwa7sp4KG/iq3lEbkFYSs8Hn5g /HhTVtABgDXPozn0CfRr7IdLLr3QIebAtb+CbzbULERs0vdyHdvkY53E4LHC3IjMLdEw vYkw== X-Gm-Message-State: AJcUukeResl8aC72UJQ75Uw2SPN7Gir3UfDMMK3vXXee7GKIWjFplBR6 /aZVpT/xEARDBJ+GJK4cWL3KVKpCMSTHM9QqmZY= X-Received: by 2002:a6b:1490:: with SMTP id 138mr15405340iou.103.1548747388405; Mon, 28 Jan 2019 23:36:28 -0800 (PST) MIME-Version: 1.0 References: <3587c682-e1db-5140-fd8e-13c46d882dd3@gmail.com> In-Reply-To: From: Billy Laws Date: Tue, 29 Jan 2019 07:36:15 +0000 Message-ID: Subject: Re: [2/2] mfd: max77620: Add low battery monitor support To: Mark Zhang Cc: Lee Jones , linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, Laxman Dewangan , Venkat Reddy Talla Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sure, that's fine with me, will send then this gets accepted. Two other things: you should probably set the reg to 0 if the property isn't specified as regmap_add_irqchip sets it to 0xff (basically all enabled on highest limit), and you haven't updated the dt-bindings. On Tue, Jan 29, 2019 at 6:52 AM Mark Zhang wrote: > > On 1/27/2019 10:54 PM, Billy Laws wrote: > > >This patch adds PMIC configurations for low-battery > > >monitoring by handling max77620 register CNFGGLBL1. > > > > > It might be an idea to add lbhyst configuration here and support using > > custom lbdac values to specify a different cutoff point. > > Yeah this patch doesn't have support to program LBHYST & LBDAC because > according to our experiences, we don't have requirement to modify them > when low battery monitor support added. > > I think we can create a new patch to support these 2 fields in the future > when we really need them. Or you can create a patch if you have requirement > for them, is this OK to you Billy? > > Mark > > > > > See: https://datasheetspdf.com/pdf-file/924230/Maxim/MAX8698C/1 pg 46 > > >Signed-off-by: Laxman Dewangan > > >Signed-off-by: Venkat Reddy Talla > > >Signed-off-by: Mark Zhang > > >--- > > > drivers/mfd/max77620.c | 57 +++++++++++++++++++++++++++++++++++++++++- > > > 1 file changed, 56 insertions(+), 1 deletion(-) > > > > > >diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c > > >index f58143103185..9e50d145afd8 100644 > > >--- a/drivers/mfd/max77620.c > > >+++ b/drivers/mfd/max77620.c > > >@@ -474,6 +474,57 @@ static int > > max77620_init_backup_battery_charging(struct max77620_chip *chip) > > > return ret; > > > } > > > > > >+static int max77620_init_low_battery_monitor(struct max77620_chip *chip) > > >+{ > > >+ struct device *dev = chip->dev; > > >+ struct device_node *np; > > >+ bool pval; > > >+ u8 mask = 0; > > >+ u8 val = 0; > > >+ int ret; > > >+ > > >+ np = of_get_child_by_name(dev->of_node, "low-battery-monitor"); > > >+ if (!np) { > > >+ dev_info(dev, "Low battery monitoring support disabled\n"); > > >+ return 0; > > >+ } > > >+ > > >+ pval = of_property_read_bool(np, "maxim,low-battery-dac-enable"); > > >+ if (pval) { > > >+ mask |= MAX77620_CNFGGLBL1_LBDAC_EN; > > >+ val |= MAX77620_CNFGGLBL1_LBDAC_EN; > > >+ } > > >+ > > >+ pval = of_property_read_bool(np, "maxim,low-battery-dac-disable"); > > >+ if (pval) > > >+ mask |= MAX77620_CNFGGLBL1_LBDAC_EN; > > >+ > > >+ pval = of_property_read_bool(np, "maxim,low-battery-shutdown-enable"); > > >+ if (pval) { > > >+ mask |= MAX77620_CNFGGLBL1_MPPLD; > > >+ val |= MAX77620_CNFGGLBL1_MPPLD; > > >+ } > > >+ > > >+ pval = of_property_read_bool(np, "maxim,low-battery-shutdown-disable"); > > >+ if (pval) > > >+ mask |= MAX77620_CNFGGLBL1_MPPLD; > > >+ > > >+ pval = of_property_read_bool(np, "maxim,low-battery-reset-enable"); > > >+ if (pval) { > > >+ mask |= MAX77620_CNFGGLBL1_LBRSTEN; > > >+ val |= MAX77620_CNFGGLBL1_LBRSTEN; > > >+ } > > >+ > > >+ pval = of_property_read_bool(np, "maxim,low-battery-reset-disable"); > > >+ if (pval) > > >+ mask |= MAX77620_CNFGGLBL1_LBRSTEN; > > >+ > > >+ ret = regmap_update_bits(chip->rmap, MAX77620_REG_CNFGGLBL1, mask, val); > > >+ if (ret < 0) > > >+ dev_err(dev, "Reg CNFGGLBL1 update failed: %d\n", ret); > > >+ return ret; > > >+} > > >+ > > > static int max77620_read_es_version(struct max77620_chip *chip) > > > { > > > unsigned int val; > > >@@ -563,7 +614,11 @@ static int max77620_probe(struct i2c_client *client, > > > if (ret < 0) > > > return ret; > > > > > >- ret = devm_mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE, > > >+ ret = max77620_init_low_battery_monitor(chip); > > >+ if (ret < 0) > > >+ return ret; > > >+ > > >+ ret = devm_mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE, > > > mfd_cells, n_mfd_cells, NULL, 0, > > > regmap_irq_get_domain(chip->top_irq_data)); > > > if (ret < 0) { > >