Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp433070ybb; Wed, 25 Mar 2020 02:43:16 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvulv8Enx8yQyNKPes9PkMgwc7i/hnioaNxzwz2Y7YFYSPBCnVJmuJmwUEKsKgKukEOOhvo X-Received: by 2002:aca:c3c1:: with SMTP id t184mr1857218oif.113.1585129396589; Wed, 25 Mar 2020 02:43:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585129396; cv=none; d=google.com; s=arc-20160816; b=s7NfvIUzqoz9dAHoVhIJbJF8EJ/eltrDbHMNiiaTF5kw8uVTk95ETveUBCUbhsfIKz 3U1FuV0LZdWysI0H/Y4zyCVjXfuTLBEYTM2Nx7cB8hwWxah8UFjnM9hX43EqTulBBJAk Jf8AWcj9EC0croYa0ky5NND4MMgxUqasX0Gnw7P2OtHRJG2+cD1/cwSL25hhW6fzbaSp 2/61XR3xS12Kr3vEMIMHdARXlsRyJn7aa4280tuIitAHgx+2U8u3Cdb5VvaXHD51nbc7 V05F8q2W5SUeBxc5pAD7l0KksZENM4F2ZYNEdF3/G4ndjCnxCQ5ckm7UK0eaSC8exNFF H2PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vRDeYiMCG4XXoUnQTgsGkl8d/lvzN+sIbey00XaX5XM=; b=H9tz8iD5k1XtSrK8qMEKcIKYS9Dzzw3PJztI91jXK5myDt52IItIOcwKlaM3R4A3jC m6TeAoPWl0ySBhWGu28P4W5ZIkrf6SQqCKW7AbK6L54iBxJ27YWACifoI2TLZXUz872O Tf6O+N6GgkTrz5QxGtLJ91l+703rD61CwS38i5bYgN4wh0xTBT2um/6Hfyngiu1WIXXm z4yXy7t1nQjAX95bws5wkMaKqfw7pU1pn7lL164rK4IgRyrQmifMjIk7DQPqWn33KJ29 lEW865TMMWDHnFwOnJ1Vw4Q0FX60C1IpUmmm5M5WgTl3R521rO2ERImCC7ksU5+mhIcy ZY9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QDwl2z2Z; 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 p21si5530969oto.4.2020.03.25.02.43.02; Wed, 25 Mar 2020 02:43:16 -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; dkim=pass header.i=@linaro.org header.s=google header.b=QDwl2z2Z; 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 S1727462AbgCYJmm (ORCPT + 99 others); Wed, 25 Mar 2020 05:42:42 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43115 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726103AbgCYJml (ORCPT ); Wed, 25 Mar 2020 05:42:41 -0400 Received: by mail-wr1-f66.google.com with SMTP id b2so1999355wrj.10 for ; Wed, 25 Mar 2020 02:42:38 -0700 (PDT) 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=vRDeYiMCG4XXoUnQTgsGkl8d/lvzN+sIbey00XaX5XM=; b=QDwl2z2ZAKFLg9mCSI/yr6ImooOPb5Fbs+CphasVocI/0SI+R5F+v5p7dMsBsVu/sm nj+rxcBs7M7oOB3To5sLYPfUhGzDtzeVXP9I08hkoRRQAkp32UihUKBCYgPVs1vtS3Qa PbO0r02L+BfDBd7P4MzuC1Sn0jbIB5gVhiw43nLmKg98NPo4pxshHKRNPWtb3wumxT17 oFXTCCi/KZpHwm0F5Sph+oQIeujRyngu1j6ae4xUSS6A9TaRjEBRg3kxWAeWar/0cYej he5RWQlC0Ib8sddoq57miNpslYhx9gGXdmjZHuLocgjCeR7MQWMSKw9nt5HCA9DMMftx gBbg== 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=vRDeYiMCG4XXoUnQTgsGkl8d/lvzN+sIbey00XaX5XM=; b=iCq7GbShVXVDspnrPWnqKfvTHuTKGwjUeddC9A3GcMFxbkP5JbBVJrNdsGJb9rEaGk MBAn8GsVU3QkhIePJe680s5tBdUhvPIrRDDEZaxF5pdGUqcMVroOFkG+IDmU8CAok/QE /m1Z0dNe+v83CNWyKmoSdtuPDsJuBwbL2idbOzh2PBEgim9brD7yUekI/BM9Gx+xN4GL ArODTK1bOx9AmPCn8ZJN0K7oo9a7jPGsG7+6T8NHKlErfASOxgXbwNIyKom27XHrASKX 2i+hgKIp7P9FV34VFn0id1hFO4VOtLxK1sfMI0HhYmg63V8D123/E07rVKk8whpMHjP+ i9UQ== X-Gm-Message-State: ANhLgQ3rJdZhuLCFj2v71mOjQKMSjuXpXYVjx2Xh9oZG/g3OLVAsUhvf Py+oeJTnVH17BcvYtuIlDfn70Q== X-Received: by 2002:adf:9ccb:: with SMTP id h11mr2382792wre.22.1585129358113; Wed, 25 Mar 2020 02:42:38 -0700 (PDT) Received: from dell ([2.27.35.213]) by smtp.gmail.com with ESMTPSA id h26sm8323017wmb.19.2020.03.25.02.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2020 02:42:37 -0700 (PDT) Date: Wed, 25 Mar 2020 09:43:26 +0000 From: Lee Jones To: Hsin-Hsiung Wang Cc: Rob Herring , Alexandre Belloni , Matthias Brugger , Mark Rutland , Sean Wang , Sebastian Reichel , Eddie Huang , Alessandro Zummo , Frank Wunderlich , Thomas Gleixner , Richard Fontana , Josef Friedl , Ran Bi , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-rtc@vger.kernel.org, Nicolas Boichat , srv_heupstream@mediatek.com Subject: Re: [PATCH v10 3/5] mfd: Add support for the MediaTek MT6358 PMIC Message-ID: <20200325094326.GH442973@dell> References: <1583918223-22506-1-git-send-email-hsin-hsiung.wang@mediatek.com> <1583918223-22506-4-git-send-email-hsin-hsiung.wang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1583918223-22506-4-git-send-email-hsin-hsiung.wang@mediatek.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 11 Mar 2020, Hsin-Hsiung Wang wrote: > This adds support for the MediaTek MT6358 PMIC. This is a > multifunction device with the following sub modules: > > - Regulator > - RTC > - Codec > - Interrupt > > It is interfaced to the host controller using SPI interface > by a proprietary hardware called PMIC wrapper or pwrap. > MT6358 MFD is a child device of the pwrap. > > Signed-off-by: Hsin-Hsiung Wang > --- > drivers/mfd/Makefile | 2 +- > drivers/mfd/mt6358-irq.c | 236 +++++++++++++++++++++++++++++ > drivers/mfd/mt6397-core.c | 55 ++++++- > include/linux/mfd/mt6358/core.h | 158 ++++++++++++++++++++ > include/linux/mfd/mt6358/registers.h | 282 +++++++++++++++++++++++++++++++++++ > include/linux/mfd/mt6397/core.h | 3 + > 6 files changed, 731 insertions(+), 5 deletions(-) > create mode 100644 drivers/mfd/mt6358-irq.c > create mode 100644 include/linux/mfd/mt6358/core.h > create mode 100644 include/linux/mfd/mt6358/registers.h > > diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile > index b83f172..9af1414 100644 > --- a/drivers/mfd/Makefile > +++ b/drivers/mfd/Makefile > @@ -238,7 +238,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 > -mt6397-objs := mt6397-core.o mt6397-irq.o > +mt6397-objs := mt6397-core.o mt6397-irq.o mt6358-irq.o > obj-$(CONFIG_MFD_MT6397) += mt6397.o > obj-$(CONFIG_INTEL_SOC_PMIC_MRFLD) += intel_soc_pmic_mrfld.o > > diff --git a/drivers/mfd/mt6358-irq.c b/drivers/mfd/mt6358-irq.c > new file mode 100644 > index 0000000..022e5f5 > --- /dev/null > +++ b/drivers/mfd/mt6358-irq.c > @@ -0,0 +1,236 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// > +// Copyright (c) 2019 MediaTek Inc. This is out of date. > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +static struct irq_top_t mt6358_ints[] = { > + MT6358_TOP_GEN(BUCK), > + MT6358_TOP_GEN(LDO), > + MT6358_TOP_GEN(PSC), > + MT6358_TOP_GEN(SCK), > + MT6358_TOP_GEN(BM), > + MT6358_TOP_GEN(HK), > + MT6358_TOP_GEN(AUD), > + MT6358_TOP_GEN(MISC), > +}; > + > +static void pmic_irq_enable(struct irq_data *data) > +{ > + unsigned int hwirq = irqd_to_hwirq(data); > + struct mt6397_chip *chip = irq_data_get_irq_chip_data(data); 6397? This does make me wonder how different this file is to the existing support for the MT6397. What is the justification for not extending that instead of creating a brand new file? > + struct pmic_irq_data *irqd = chip->irq_data; > + > + irqd->enable_hwirq[hwirq] = true; > +} > + > +static void pmic_irq_disable(struct irq_data *data) > +{ > + unsigned int hwirq = irqd_to_hwirq(data); > + struct mt6397_chip *chip = irq_data_get_irq_chip_data(data); > + struct pmic_irq_data *irqd = chip->irq_data; > + > + irqd->enable_hwirq[hwirq] = false; > +} > + > +static void pmic_irq_lock(struct irq_data *data) > +{ > + struct mt6397_chip *chip = irq_data_get_irq_chip_data(data); > + > + mutex_lock(&chip->irqlock); > +} > + > +static void pmic_irq_sync_unlock(struct irq_data *data) > +{ > + unsigned int i, top_gp, gp_offset, en_reg, int_regs, shift; > + struct mt6397_chip *chip = irq_data_get_irq_chip_data(data); > + struct pmic_irq_data *irqd = chip->irq_data; > + > + for (i = 0; i < irqd->num_pmic_irqs; i++) { > + if (irqd->enable_hwirq[i] == irqd->cache_hwirq[i]) > + continue; > + > + /* Find out the IRQ group */ > + top_gp = 0; > + while ((top_gp + 1) < irqd->num_top && > + i >= mt6358_ints[top_gp + 1].hwirq_base) > + top_gp++; > + > + /* Find the irq registers */ Nit: "IRQ" > + gp_offset = i - mt6358_ints[top_gp].hwirq_base; > + int_regs = gp_offset / MT6358_REG_WIDTH; > + shift = gp_offset % MT6358_REG_WIDTH; > + en_reg = mt6358_ints[top_gp].en_reg + > + (mt6358_ints[top_gp].en_reg_shift * int_regs); > + > + regmap_update_bits(chip->regmap, en_reg, BIT(shift), > + irqd->enable_hwirq[i] << shift); > + > + irqd->cache_hwirq[i] = irqd->enable_hwirq[i]; > + } > + mutex_unlock(&chip->irqlock); > +} [...] > +int mt6358_irq_init(struct mt6397_chip *chip) > +{ > + int i, j, ret; > + struct pmic_irq_data *irqd; > + > + irqd = devm_kzalloc(chip->dev, sizeof(struct pmic_irq_data *), sizeof(*irqd) [...] > static const struct chip_data mt6397_core = { > .cid_addr = MT6397_CID, > .cid_shift = 0, > @@ -154,19 +184,33 @@ static int mt6397_probe(struct platform_device *pdev) > if (pmic->irq <= 0) > return pmic->irq; > > - ret = mt6397_irq_init(pmic); > - if (ret) > - return ret; > - > switch (pmic->chip_id) { > case MT6323_CHIP_ID: > + ret = mt6397_irq_init(pmic); > + if (ret) > + return ret; > + > ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, > mt6323_devs, ARRAY_SIZE(mt6323_devs), > NULL, 0, pmic->irq_domain); > break; > > + case MT6358_CHIP_ID: > + ret = mt6358_irq_init(pmic); > + if (ret) > + return ret; > + > + ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, > + mt6358_devs, ARRAY_SIZE(mt6358_devs), > + NULL, 0, pmic->irq_domain); In a subsequent patch you can choose the correct mtXXXX_devs structure to pass and call devm_mfd_add_devices() only once below the switch(). > + break; > + > case MT6391_CHIP_ID: > case MT6397_CHIP_ID: > + ret = mt6397_irq_init(pmic); > + if (ret) > + return ret; > + > ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, > mt6397_devs, ARRAY_SIZE(mt6397_devs), > NULL, 0, pmic->irq_domain); [...] -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog