Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3590663pxb; Mon, 25 Jan 2021 22:36:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJymQj6FsOFikKeQfPm7LZuj73v8WGuZ7a0P8m59mifwL6CyVHovmGA8voGsdWWJTudN+XqC X-Received: by 2002:a17:906:d8c3:: with SMTP id re3mr2618775ejb.80.1611642999378; Mon, 25 Jan 2021 22:36:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611642999; cv=none; d=google.com; s=arc-20160816; b=cPYQhdr3/QyiaE/qv9ny0D4BlHgV/XK/oxi+ztepNGD9QPkBi0QLK6lFXmLpV4bMgx OkKwA+DySwZ7WXcJgDQ7/RJYgp+W1LVWUMqUStmHDGEPOGIOzKdBFDtL+YVCk9rZ5tSq WrGNqdysoMciFzCV7wH3tGjPhj914nCJIeGwZ7OTk7MgBSlVTybtK6PDNkcR3vBNg+SO 4lG6jFi5Imz8sHMjDHqE0sKg9fErSNC2vUKcniwVV7rQi+Ch6856hd38x0VustIg5p4d ainmpvDWChiId4+ngku/DgSJ3fv6Z+LZOVaaAlNVhwqUZp5YRLptbUpfQMaKfvtxlnww CRdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zH0NEkG3AkFr4jGffOltirP3sm6e4qzdbWMUDm6pzLE=; b=E6zyZVSKDq5JQU0cze6z0RKcRwKt7r/O/oKpeLtt2n8zn7FLP4qs/h1u9I0LeoKoUc PLp/hHxgjWULEXNjvxH4T+404TvESV6Md8ls3R7MugY65gITObGy0cNNcmf3dOjBeqwk ePpkNTippDZNBgm6ZOADpoEj6jndp3znSUII/MVuHFsnfWNfGcDLOscOFv+Za26EZM7o Nnv379YrtTWA3TBQ2WVdXNjdME9iYjlPP9BkNZ+JaEcotVIugwzjDPDl23uQ97rypRnq YFH5Lg7zhPqotw034j1gZEXWsZlbSYhQxljjHQl2893XE5ubvBgW8FBDm07/3DVwQTEM 7YRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SRebwxQ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t16si8084480edr.4.2021.01.25.22.36.13; Mon, 25 Jan 2021 22:36:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SRebwxQ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727260AbhAZGcX (ORCPT + 99 others); Tue, 26 Jan 2021 01:32:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729290AbhAYOLq (ORCPT ); Mon, 25 Jan 2021 09:11:46 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A3D7C061574 for ; Mon, 25 Jan 2021 06:10:49 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id f16so2053270wmq.5 for ; Mon, 25 Jan 2021 06:10:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=zH0NEkG3AkFr4jGffOltirP3sm6e4qzdbWMUDm6pzLE=; b=SRebwxQ7TFksC5IwMikzJ5HEz185i6km8QLqy2tzc21KOY3W+dnsTINsjvyumQSmG0 1QoGHJp+x3n3QwXEWYFCqsvWd0DqduPME/tlSPj20Z4++oqUQczekiSN7TKBZI5cuYjY IX1ziQ4Ock3gmA2IOv8sS2v/0V/nz8w+f0qVH9mZlTROxDpWGCwfnRgQPslEKVD3Rbiw f8jZFun5gdlTwzzuoW4ewllgKY6skqeU71ZUekohbSCxEa3f+LqLWCjjwSgB/IdR1gS3 MR2dVPZrRXaUVPLWXp/fesDG41ubLtiMBHtvEzTapz9FVU5L4KohQ1/xPocjQwQkPeEz 3k6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=zH0NEkG3AkFr4jGffOltirP3sm6e4qzdbWMUDm6pzLE=; b=nkPxsOwavBTp0vPpYViRsntrz/ir+6Jqg/Np2GESzAPtJlUyknYcGC9+GjcIde7RgV +qY8qYLrbizGqzrfFK333wnHal8+RHk0VUaT2ktoAS2Vqkh9zMOgIFzlM3etI5fiLPjn OuD1xV20cDwqJ50KhAxeP2hIXT1L5gAd74tiZPeB5ekHpd2rqHhEvPZPh+PAVkwuU3Rd cC4/ZLVeKoP8ovmB7mZv4D5jbFS+cY6jnEUjMBqm/hhIemdngciF2yxQduJUeNm7GYXQ uYU7GpyEWuwF7Rcom3vsF8gLvd72bzKhALelCrkrisdmpogXoX4NeFwrbkxfX/NFTB+x 4C6w== X-Gm-Message-State: AOAM530Qba6o5T1vW3/lCjz96lfJQ/dDVu4GnVAyEgyDo1gN1t3+OWs7 NHB0dh5KwEXfq6hBL8Nn5duuEw== X-Received: by 2002:a1c:e255:: with SMTP id z82mr340638wmg.60.1611583847665; Mon, 25 Jan 2021 06:10:47 -0800 (PST) Received: from dell ([91.110.221.194]) by smtp.gmail.com with ESMTPSA id c18sm41394036wmk.0.2021.01.25.06.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 06:10:46 -0800 (PST) Date: Mon, 25 Jan 2021 14:10:44 +0000 From: Lee Jones To: Matti Vaittinen Cc: mazziesaccount@gmail.com, Rob Herring , Liam Girdwood , Mark Brown , Michael Turquette , Stephen Boyd , Linus Walleij , Bartosz Golaszewski , Alessandro Zummo , Alexandre Belloni , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-power@fi.rohmeurope.com, linux-clk@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org Subject: Re: [PATCH v2 09/17] mfd: Support for ROHM BD71815 PMIC core Message-ID: <20210125141044.GZ4903@dell> References: <14480ca837005aecd7053202c2347e36ad29faee.1611037866.git.matti.vaittinen@fi.rohmeurope.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <14480ca837005aecd7053202c2347e36ad29faee.1611037866.git.matti.vaittinen@fi.rohmeurope.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 19 Jan 2021, Matti Vaittinen wrote: > Add core support for ROHM BD71815 Power Management IC. > > The IC integrates regulators, a battery charger with a coulomb counter, > a real-time clock (RTC), clock gate and general-purpose outputs (GPO). > > Signed-off-by: Matti Vaittinen > --- > Changes since v1: > - Used BIT() for better readability > - removed some unused definitions > > drivers/mfd/Kconfig | 15 +- > drivers/mfd/rohm-bd71828.c | 416 +++++++++++++++++++++-- > include/linux/mfd/rohm-bd71815.h | 561 +++++++++++++++++++++++++++++++ > include/linux/mfd/rohm-bd71828.h | 3 + > 4 files changed, 952 insertions(+), 43 deletions(-) > create mode 100644 include/linux/mfd/rohm-bd71815.h > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > index bdfce7b15621..59bfacb91898 100644 > --- a/drivers/mfd/Kconfig > +++ b/drivers/mfd/Kconfig > @@ -1984,19 +1984,20 @@ config MFD_ROHM_BD70528 > charger. > > config MFD_ROHM_BD71828 > - tristate "ROHM BD71828 Power Management IC" > + tristate "ROHM BD71828 and BD71815 Power Management IC" > depends on I2C=y > depends on OF > select REGMAP_I2C > select REGMAP_IRQ > select MFD_CORE > help > - Select this option to get support for the ROHM BD71828 Power > - Management IC. BD71828GW is a single-chip power management IC for > - battery-powered portable devices. The IC integrates 7 buck > - converters, 7 LDOs, and a 1500 mA single-cell linear charger. > - Also included is a Coulomb counter, a real-time clock (RTC), and > - a 32.768 kHz clock gate. > + Select this option to get support for the ROHM BD71828 and BD71815 > + Power Management ICs. BD71828GW and BD71815AGW are single-chip power > + management ICs mainly for battery-powered portable devices. > + The BD71828 integrates 7 buck converters and 7 LDOs. The BD71815 > + has 5 bucks, 7 LDOs, and a boost for driving LEDs. Both ICs provide > + also a single-cell linear charger, a Coulomb counter, a real-time > + clock (RTC), GPIOs and a 32.768 kHz clock gate. > > config MFD_STM32_LPTIMER > tristate "Support for STM32 Low-Power Timer" > diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-bd71828.c > index 210261d026f2..28b82477ce4c 100644 > --- a/drivers/mfd/rohm-bd71828.c > +++ b/drivers/mfd/rohm-bd71828.c > @@ -2,7 +2,7 @@ > // > // Copyright (C) 2019 ROHM Semiconductors > // > -// ROHM BD71828 PMIC driver > +// ROHM BD71828/BD71815 PMIC driver > > #include > #include > @@ -11,7 +11,9 @@ > #include > #include > #include > +#include > #include > +#include > #include > #include > #include > @@ -29,12 +31,102 @@ static struct gpio_keys_platform_data bd71828_powerkey_data = { > .name = "bd71828-pwrkey", > }; > > -static const struct resource rtc_irqs[] = { > +static const struct resource bd71815_rtc_irqs[] = { > + DEFINE_RES_IRQ_NAMED(BD71815_INT_RTC0, "bd71815-rtc-alm-0"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_RTC1, "bd71815-rtc-alm-1"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_RTC2, "bd71815-rtc-alm-2"), > +}; > + > +static const struct resource bd71828_rtc_irqs[] = { > DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC0, "bd71828-rtc-alm-0"), > DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC1, "bd71828-rtc-alm-1"), > DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC2, "bd71828-rtc-alm-2"), > }; > > +static struct resource bd71815_power_irqs[] = { > + DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_RMV, "bd71815-dcin-rmv"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_CLPS_OUT, "bd71815-clps-out"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_CLPS_IN, "bd71815-clps-in"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_OVP_RES, "bd71815-dcin-ovp-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_OVP_DET, "bd71815-dcin-ovp-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_MON_RES, "bd71815-dcin-mon-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_MON_DET, "bd71815-dcin-mon-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_UV_RES, "bd71815-vsys-uv-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_UV_DET, "bd71815-vsys-uv-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_LOW_RES, "bd71815-vsys-low-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_LOW_DET, "bd71815-vsys-low-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_MON_RES, "bd71815-vsys-mon-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_MON_RES, "bd71815-vsys-mon-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_WDG_TEMP, "bd71815-chg-wdg-temp"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_WDG_TIME, "bd71815-chg-wdg"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_RECHARGE_RES, "bd71815-rechg-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_RECHARGE_DET, "bd71815-rechg-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_RANGED_TEMP_TRANSITION, > + "bd71815-ranged-temp-transit"), The new line limit is 100. Feel free to run these out. > + DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_STATE_TRANSITION, > + "bd71815-chg-state-change"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_TEMP_NORMAL, > + "bd71815-bat-temp-normal"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_TEMP_ERANGE, > + "bd71815-bat-temp-erange"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_REMOVED, "bd71815-bat-rmv"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_DETECTED, "bd71815-bat-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_THERM_REMOVED, "bd71815-therm-rmv"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_THERM_DETECTED, "bd71815-therm-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_DEAD, "bd71815-bat-dead"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_SHORTC_RES, > + "bd71815-bat-short-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_SHORTC_DET, > + "bd71815-bat-short-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_LOW_VOLT_RES, > + "bd71815-bat-low-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_LOW_VOLT_DET, > + "bd71815-bat-low-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_VOLT_RES, > + "bd71815-bat-over-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_VOLT_DET, > + "bd71815-bat-over-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_MON_RES, "bd71815-bat-mon-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_MON_DET, "bd71815-bat-mon-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_CC_MON1, "bd71815-bat-cc-mon1"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_CC_MON2, "bd71815-bat-cc-mon2"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_CC_MON3, "bd71815-bat-cc-mon3"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_1_RES, > + "bd71815-bat-oc1-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_1_DET, > + "bd71815-bat-oc1-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_2_RES, > + "bd71815-bat-oc2-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_2_DET, > + "bd71815-bat-oc2-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_3_RES, > + "bd71815-bat-oc3-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_BAT_OVER_CURR_3_DET, > + "bd71815-bat-oc3-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_TEMP_BAT_LOW_RES, > + "bd71815-bat-low-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_TEMP_BAT_LOW_DET, > + "bd71815-bat-low-det"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_TEMP_BAT_HI_RES, "bd71815-bat-hi-res"), > + DEFINE_RES_IRQ_NAMED(BD71815_INT_TEMP_BAT_HI_DET, "bd71815-bat-hi-det"), > +}; [...] > +static const struct regmap_irq bd71815_irqs[] = { [...] > + REGMAP_IRQ_REG(BD71815_INT_TEMP_CHIP_OVER_VF_DET, 10, > + BD71815_INT_TEMP_CHIP_OVER_VF_DET_MASK), As above. > + /* RTC Alarm */ > + REGMAP_IRQ_REG(BD71815_INT_RTC0, 11, BD71815_INT_RTC0_MASK), > + REGMAP_IRQ_REG(BD71815_INT_RTC1, 11, BD71815_INT_RTC1_MASK), > + REGMAP_IRQ_REG(BD71815_INT_RTC2, 11, BD71815_INT_RTC2_MASK), > +}; [...] > +static int set_clk_mode(struct device *dev, struct regmap *regmap, > + int clkmode_reg) > +{ > + int ret; > + const char *mode; > + > + ret = of_property_read_string_index(dev->of_node, "rohm,clkout-mode", 0, > + &mode); > + if (ret) { > + if (ret == -EINVAL) > + return 0; > + return ret; > + } > + if (!strncmp(mode, "open-drain", 10)) { > + dev_dbg(dev, "configuring clk32kout as open-drain"); Do you *really* need these? > + ret = regmap_update_bits(regmap, clkmode_reg, OUT32K_MODE, > + OUT32K_MODE_OPEN_DRAIN); > + } else if (!strncmp(mode, "cmos", 4)) { > + dev_dbg(dev, "configuring clk32kout as cmos"); > + ret = regmap_update_bits(regmap, clkmode_reg, OUT32K_MODE, > + OUT32K_MODE_CMOS); > + } else { > + dev_err(dev, "bad clk32kout mode configuration"); > + return -EINVAL; > + } > + return ret; > +} > + > static int bd71828_i2c_probe(struct i2c_client *i2c) > { > - struct rohm_regmap_dev *chip; > struct regmap_irq_chip_data *irq_data; > int ret; > + struct regmap *regmap; > + const struct regmap_config *regmap_config; > + struct regmap_irq_chip *irqchip; > + unsigned int chip_type; > + struct mfd_cell *mfd; > + int cells; > + int button_irq; > + int clkmode_reg; > > if (!i2c->irq) { > dev_err(&i2c->dev, "No IRQ configured\n"); > return -EINVAL; > } > > - chip = devm_kzalloc(&i2c->dev, sizeof(*chip), GFP_KERNEL); > - if (!chip) > - return -ENOMEM; > - > - dev_set_drvdata(&i2c->dev, chip); > + chip_type = (unsigned int)(uintptr_t) > + of_device_get_match_data(&i2c->dev); > + switch (chip_type) { > + case ROHM_CHIP_TYPE_BD71828: > + mfd = bd71828_mfd_cells; > + cells = ARRAY_SIZE(bd71828_mfd_cells); > + regmap_config = &bd71828_regmap; > + irqchip = &bd71828_irq_chip; > + clkmode_reg = BD71815_REG_OUT32K; > + button_irq = BD71828_INT_SHORTPUSH; > + dev_info(&i2c->dev, "BD71828 found\n"); > + break; > + case ROHM_CHIP_TYPE_BD71815: > + mfd = bd71815_mfd_cells; > + cells = ARRAY_SIZE(bd71815_mfd_cells); > + regmap_config = &bd71815_regmap; > + irqchip = &bd71815_irq_chip; > + clkmode_reg = BD71828_REG_OUT32K; > + /* > + * If BD71817 support is needed we should be able to handle it > + * with proper DT configs + BD71815 drivers + power-button. > + * BD71815 data-sheet does not list the power-button IRQ so we > + * don't use it. > + */ > + button_irq = 0; > + dev_info(&i2c->dev, "BD71815 found\n"); Again, are these *really* useful to you and/or your users? Besides, this device not *found* i.e. scanned/read and instantiated, it has simply been matched from the local DTB. It can still be wrong. You can probably omit them. [...] > diff --git a/include/linux/mfd/rohm-bd71815.h b/include/linux/mfd/rohm-bd71815.h > new file mode 100644 > index 000000000000..8ee5874a5b73 > --- /dev/null > +++ b/include/linux/mfd/rohm-bd71815.h > @@ -0,0 +1,561 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > +/* > + * Copyright 2014 Embest Technology Co. Ltd. Inc. Jeeze! Is this for the Amiga? > + * Author: yanglsh@embest-tech.com > + * > + * 2020, 2021 Heavily modified by: You should probably add a proper copyright. > + * Matti Vaittinen > + */ > + > +#ifndef _MFD_BD71815_H > +#define _MFD_BD71815_H > + > +#include [...] -- Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog