Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17215719ybl; Thu, 2 Jan 2020 00:48:39 -0800 (PST) X-Google-Smtp-Source: APXvYqydklOWjjIDCkgghLqi0yAXb4e3irin3g9etoMab+Myq6a9TOdogGc1eZCtG9X5i85DbGiR X-Received: by 2002:a9d:4e97:: with SMTP id v23mr86167052otk.201.1577954919526; Thu, 02 Jan 2020 00:48:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577954919; cv=none; d=google.com; s=arc-20160816; b=lsAzKJyuUY78+Gwius3BE7bD9z7drkEvLSTFRvw56zi2ZgRPBOCLwBEOmWl4Z07Eol duRrYVMxJYkJUWlpxlp2qcXW1KuivxIe7BTiPLz+MeiOChKrql2+Wz5qujw8BEmNLcom VvlUMl9gdroLAD9oalu5bJxBTg9KG1t6hS8W/CICVFGmx+DlcJ5b3DEqs5oGXUnhnNfX bWzU4OOejMI+BSw48lIBXWzf6iwMbPXrqFex4ioDtpegXljDw20RfcsJ0oYf07nbz0XB F99JFtZvjQkr0Qvz3ov+ubKPNJLqxrwAvYnqkf4IcmwrVNFPd4QNzFNmjAP2OX0AbGYm EAaA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=J4BV4xVxmbRJ/r05rBs0QYCjejbH9ewz1c2yLbanQBw=; b=Ghlb2n0x/T6cHAmWm10M/B8zLAFIC58Mg0jkN19hkRlJTybLrYp97URl4JCTkv1p6y LlNkrphW3Y0z+EikkSnCP4Ddh6H1OpXKw/y7io2Drrc7gGt3jyQRMxqTscsJwYF/2OKc oGie0EkPArSzosn8N84+5fbLN5yz8Zlh2vbHvkt1CXCnYK94lik11Ayh4numTO0JC3iM IzdJJA9jO2cRoaYjDHV30zp52VKycajhcge6KBnSJsrwM223sGtZQVo5389+xHbauqvD gLLWky+du/u9Tiu6qc9Km6cVPVbysPhJiizLwQ0yZ5ect0iLVTnswLZk1pFcg/9E8wib EKtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BCROBod9; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y9si29783550otq.315.2020.01.02.00.48.27; Thu, 02 Jan 2020 00:48:39 -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=@linaro.org header.s=google header.b=BCROBod9; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727830AbgABIql (ORCPT + 99 others); Thu, 2 Jan 2020 03:46:41 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46750 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727756AbgABIqk (ORCPT ); Thu, 2 Jan 2020 03:46:40 -0500 Received: by mail-wr1-f66.google.com with SMTP id z7so38428706wrl.13 for ; Thu, 02 Jan 2020 00:46:39 -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 :user-agent; bh=J4BV4xVxmbRJ/r05rBs0QYCjejbH9ewz1c2yLbanQBw=; b=BCROBod9j1yy6ajGa+uGcRO+X7a2oqm4ydiMzZwtcBr9thqmJoeDeB8vBmZ8hG0bas pRPAAfyxHm4lV8LwRhEx8jE7sUssEq5x7jyXSEWyaeVjbx6ftoR15mx1tVsz9zBJPr7c XKAtOPTAmr9rL8LaoS6MAbOmkxPCkurDhm33TvQuGx+C4zXTRjiHvzEgka/uTyIuQRQZ 4okHxCZsuUbIzRcY+45HcNOTYwAZ9GKO2r45tzSpjwejmSI5KqXeACQ7w61v6Pvkr5HN sAcbzQvhK41LfV8r0fmaOsCu/wE88cGOus0huQH7AwGLIQ5s63Vl1ClDEY5SRBvILAPv CzOg== 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:user-agent; bh=J4BV4xVxmbRJ/r05rBs0QYCjejbH9ewz1c2yLbanQBw=; b=b/2uJVVszw6Kq0TAeRgOmP0pidpgRsTXcwSAPbyaL5KxTthHXck9WFUJr2aqPGglNV bvEp38Jcw0ybk1E1TwaKb47YpbLmn8V0WwKh6FJjhf59ThAUVz9Y6hgmqhC4I8EGaEJ1 gqsFNKacUPJlJbhAnCtZyDVWeMu16CpSoKOJX86uq0y4P5hbB/iSXeMlI2UyLXrfAx55 NnqZShW3+guloinqzu6uViEW3f/AbRKnMep5bbPBKgWh0oZmtnhuGEfmMppET8G139+M sg4IWq2igyHR1n4JGNZEV8h/Xk/Ft+Cz5GwHbAZNjSuxuip+Ph0VhNRb/peWNALeOv+Z Pgwg== X-Gm-Message-State: APjAAAW/9FcGWn4fro1ISi02MPd+yKhaqMBB1JZs3kReTPn7nGG/ubC/ /UApEmxInwSDBEBC76YI3huLGw== X-Received: by 2002:a5d:68c5:: with SMTP id p5mr83053200wrw.193.1577954798497; Thu, 02 Jan 2020 00:46:38 -0800 (PST) Received: from dell ([2.27.35.135]) by smtp.gmail.com with ESMTPSA id g2sm54686011wrw.76.2020.01.02.00.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2020 00:46:37 -0800 (PST) Date: Thu, 2 Jan 2020 08:46:50 +0000 From: Lee Jones To: Gene Chen Cc: matthias.bgg@gmail.com, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, gene_chen@richtek.com, Wilma.Wu@mediatek.com, shufan_lee@richtek.com, cy_huang@richtek.com Subject: Re: [PATCH v6] mfd: mt6360: add pmic mt6360 driver Message-ID: <20200102084650.GA22390@dell> References: <20191225014148.19082-1-gene.chen.richtek@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191225014148.19082-1-gene.chen.richtek@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 25 Dec 2019, Gene Chen wrote: > From: Gene Chen > > Add mfd driver for mt6360 pmic chip include > Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck > > Signed-off-by: Gene Chen --- > drivers/mfd/Kconfig | 12 + > drivers/mfd/Makefile | 1 + > drivers/mfd/mt6360-core.c | 426 +++++++++++++++++++++++++++++ > include/linux/mfd/mt6360-private.h | 217 +++++++++++++++ > include/linux/mfd/mt6360.h | 32 +++ > 5 files changed, 688 insertions(+) > create mode 100644 drivers/mfd/mt6360-core.c > create mode 100644 include/linux/mfd/mt6360-private.h > create mode 100644 include/linux/mfd/mt6360.h > > changelogs between v1 & v2 > - include missing header file > > changelogs between v2 & v3 > - add changelogs > > changelogs between v3 & v4 > - fix Kconfig description > - replace mt6360_pmu_info with mt6360_pmu_data > - replace probe with probe_new > - remove unnecessary irq_chip variable > - remove annotation > - replace MT6360_MFD_CELL with OF_MFD_CELL > > changelogs between v4 & v5 > - remove unnecessary parse dt function > - use devm_i2c_new_dummy_device > - add base-commit message > > changelogs between v5 & v6 > - review return value > - remove i2c id_table > - use GPL license v2 > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > index 420900852166..e6df91d55405 100644 > --- a/drivers/mfd/Kconfig > +++ b/drivers/mfd/Kconfig > @@ -856,6 +856,18 @@ config MFD_MAX8998 > additional drivers must be enabled in order to use the functionality > of the device. > > +config MFD_MT6360 > + tristate "Mediatek MT6360 SubPMIC" > + select MFD_CORE > + select REGMAP_I2C > + select REGMAP_IRQ > + depends on I2C > + help > + Say Y here to enable MT6360 PMU/PMIC/LDO functional support. > + PMU part includes Charger, Flashlight, RGB LED > + PMIC part includes 2-channel BUCKs and 2-channel LDOs > + LDO part includes 4-channel LDOs > + > config MFD_MT6397 > tristate "MediaTek MT6397 PMIC Support" > select MFD_CORE > diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile > index aed99f08739f..f5f80d75ee53 100644 > --- a/drivers/mfd/Makefile > +++ b/drivers/mfd/Makefile > @@ -237,6 +237,7 @@ obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o > obj-$(CONFIG_INTEL_SOC_PMIC_BXTWC) += intel_soc_pmic_bxtwc.o > obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC) += intel_soc_pmic_chtwc.o > obj-$(CONFIG_INTEL_SOC_PMIC_CHTDC_TI) += intel_soc_pmic_chtdc_ti.o > +obj-$(CONFIG_MFD_MT6360) += mt6360-core.o > mt6397-objs := mt6397-core.o mt6397-irq.o > obj-$(CONFIG_MFD_MT6397) += mt6397.o > obj-$(CONFIG_INTEL_SOC_PMIC_MRFLD) += intel_soc_pmic_mrfld.o > diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c > new file mode 100644 > index 000000000000..f6d43b6dad4e > --- /dev/null > +++ b/drivers/mfd/mt6360-core.c > @@ -0,0 +1,426 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2019 MediaTek Inc. No author? > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include [...] > +#define MT6360_REGMAP_IRQ_REG(_irq_evt) \ > + REGMAP_IRQ_REG(_irq_evt, (_irq_evt) / 8, BIT((_irq_evt) % 8)) No need to roll your own macros for this. I think REGMAP_IRQ_REG_LINE() is what you're looking for. > +static const struct regmap_irq mt6360_pmu_irqs[] = { REGMAP_IRQ_REG_LINE(MT6360_CHG_TREG_EVT, 8), ... etc. > + MT6360_REGMAP_IRQ_REG(MT6360_CHG_TREG_EVT), > + MT6360_REGMAP_IRQ_REG(MT6360_CHG_AICR_EVT), [...] > + MT6360_REGMAP_IRQ_REG(MT6360_LDO7_PGB_EVT), > +}; [...] > diff --git a/include/linux/mfd/mt6360-private.h b/include/linux/mfd/mt6360-private.h > new file mode 100644 > index 000000000000..d542652f4de0 > --- /dev/null > +++ b/include/linux/mfd/mt6360-private.h As there are only appropriately namespaced macros in here, I would move them to the normal header file and dispose of this one. > @@ -0,0 +1,217 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Copyright (c) 2019 MediaTek Inc. > + */ > + > +#ifndef __MT6360_PRIVATE_H__ > +#define __MT6360_PRIVATE_H__ > + > +/* PMU register defininition */ > +#define MT6360_PMU_DEV_INFO (0x00) > +#define MT6360_PMU_CORE_CTRL1 (0x01) [...] > +#define MT6360_PMU_LDO_MASK2 (0xFF) > +#define MT6360_PMU_MAXREG (MT6360_PMU_LDO_MASK2) > + > +/* MT6360_PMU_IRQ_SET */ > +#define MT6360_PMU_IRQ_REGNUM (MT6360_PMU_LDO_IRQ2 - MT6360_PMU_CHG_IRQ1 + 1) > +#define MT6360_IRQ_RETRIG BIT(2) > + > +#define CHIP_VEN_MASK (0xF0) > +#define CHIP_VEN_MT6360 (0x50) > +#define CHIP_REV_MASK (0x0F) > + > +#endif /* __MT6360_PRIVATE_H__ */ -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog