Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4665341imu; Tue, 29 Jan 2019 05:35:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN5uuY73dgjeI+7RfNW+KYyKDAy0U6QBtqiaG4B0pCPPyHkVDVBDRyr2I7Cm5tcg8mAvlyKr X-Received: by 2002:a63:5d20:: with SMTP id r32mr23958002pgb.329.1548768936611; Tue, 29 Jan 2019 05:35:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548768936; cv=none; d=google.com; s=arc-20160816; b=BgAYIZIY92IohNKqQnb6L6CYZQbzucB6/cUzy1HJMGm1SKDt3du9F/qAmJcMxaGas2 hwWZHG0bhqtfYzi7lQ2fA9B2O/JIWT8dlMkG3d1zgva+PcRapjjG9qA/xCHEXViJjXya /KL1fvnSo/kG+Qz19LkmxAS9HzFmjYSDK3ilGemMsIUu4Wx9levIFglE+txMJ3upYdo3 fNTl1Flte+03pk7I8aOAbowNbUM43JyDJuIXtgO0mGvFUOiHL4yDZV/pmpk12ucGGtaP xpzH3FRahj66GedfMLvTSnD4ZNt9vTeA07ab0A3lNcCQPVnhxwI823f9+Df0BPbBvSDP SyRw== 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=n2pqcBcqDNXAnnXz1IaPEeQZksuwsUmzPuVbz+IoagQ=; b=cO2D/43WqBvwSXG89u+n09bU6gGimSemZ3vB/gdM1vhdvpao6gqhbxM8dSVMMiPajm NgSI6rXHKMUUNsmKexCr03m8ywoZQryfbMRNetkMXUeHnOYmPkktP/SHnM0YDGt9odu3 HBpD4dWdVTJh2pW6Gc8c0ndWVE5n9S5NFcAUcxbloJ7b/YP1WvcDRhqwHuEyFJK6caXn hvfA15mkIAlVQRED/DHFI51HMsxvw+oilDGxUGnk3WzhieWPZl+q/scUK7hLhPMI5gBN XsqZxSS374UjnTjslgghJzn2xrMjoPNyCpkTdCjweK9xrxF+teGQvGCglCgXBO6cgxBC g0PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p8DOYMNs; 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 i1si34983013pgi.480.2019.01.29.05.35.20; Tue, 29 Jan 2019 05:35:36 -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=p8DOYMNs; 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 S1727425AbfA2Nd7 (ORCPT + 99 others); Tue, 29 Jan 2019 08:33:59 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:42486 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbfA2Nd7 (ORCPT ); Tue, 29 Jan 2019 08:33:59 -0500 Received: by mail-io1-f67.google.com with SMTP id x6so16283936ioa.9; Tue, 29 Jan 2019 05:33:58 -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=n2pqcBcqDNXAnnXz1IaPEeQZksuwsUmzPuVbz+IoagQ=; b=p8DOYMNsDgVJVNuNO+TtZV5A93c2/nSv565C5EV+HkruOrTe0/aUXiVtggsifT01NA H0bNgR/UZhkO1gRfNjX1cvmFA2OdCVJLTg/PGS0ZIO9DFJP1Rg72gdLoJvSaLincfXIx feLHquMEbZFC7ir2BM0ywmQAs7w/cHm2Xy6y/XAbxlIYSE4ARA4RU7Hf+umLii4bwooz WXeeYqyCCGWElx1tD5lU93QpoLU2KHdSZnW/v0hdidqSr7v6JiQtF0Da1DgCbctslwAp b5t4RbvB/J3OoT9VprnE63dtA0Uyxzm6QSrlfqDjI56mkhB81szGuwzRGWwgGcPif4SK hVDw== 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=n2pqcBcqDNXAnnXz1IaPEeQZksuwsUmzPuVbz+IoagQ=; b=lJBdgTtvsNsixAI04FCOahYqnf/SqO8fJs1qiarMj2LnQNV9rKCGGzMu4G+zE8l54q jh4k1ZXkb7RiGuSX8PAM6F0C9kz2M/HMEkgXRVroM32UsvlMSAKFFZmg6VGZDAK3lqqz aWi6ly4mMRBS5M0BXVgg4vMhWYar4ONFuLCzt6EeMOOS0vbPaEwPfvbicz/+GdxFQdXP 8v+txczTbIedX6o2rvvMeC7uDlg/BFln7xXp5fc/VPNXlvOXbfh4p857vnr8mvFNnY4Y sAWdDDs2QIKzxcB6Av4FHMMS/DVjxSXsJSBgdhvoMi+I9Gg2Y5/ltmpZyuBATUZsJliB G9FA== X-Gm-Message-State: AHQUAuauPYeB1vCR06BAdC7pxpMtg33Xu4koBSPF3EFVCjIaNekNdUHJ PrteG6rJO2Wt56Kb+GQXaXd9ALizGdvCl2SDofE= X-Received: by 2002:a5d:870b:: with SMTP id u11mr14957629iom.168.1548768837943; Tue, 29 Jan 2019 05:33:57 -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 13:33:46 +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 It does, see this article https://blog.quendi.moe/2018/07/03/en-debugging-nintendo-switch-linux-power-management-battery-desync-edition/ On Tue, Jan 29, 2019 at 9:03 AM Mark Zhang wrote: > > On 1/29/2019 3:36 PM, Billy Laws wrote: > > 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. > > Billy, v2 is out, dt-bindings patches are added. > But after a second thought, I don't think regmap_add_irqchip might set > registers to 0xff. I mean, for 2 registers which this patch set touches, > they're not IRQ registers(mask/status/...), so regmap_add_irqchip should > not touch them so I didn't make changes to driver codes in v2. > > Mark > > > > > 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) { > >>>