lkml.org 
[lkml]   [2020]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v11 3/5] mfd: Add support for the MediaTek MT6358 PMIC
From
Date
Hi, Sirs

On Tue, 2020-03-31 at 15:36 +0800, Nicolas Boichat wrote:
> On Tue, Mar 31, 2020 at 12:07 PM Hsin-Hsiung Wang
> <hsin-hsiung.wang@mediatek.com> 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 <hsin-hsiung.wang@mediatek.com>
> > Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
>
> This is missing a few comments from Lee Jones on v10, actually, repeated below:
> https://patchwork.kernel.org/patch/11431239/#23244041
>

So sorry for missing this comment.I will reply it later.
Thanks a lot.

> > ---
> > 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.
>
> 2020
>
> > +
> > +#include <linux/interrupt.h>
> > +#include <linux/mfd/mt6358/core.h>
> > +#include <linux/mfd/mt6358/registers.h>
> > +#include <linux/mfd/mt6397/core.h>
> > +#include <linux/module.h>
> > +#include <linux/of.h>
> > +#include <linux/of_device.h>
> > +#include <linux/of_irq.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/regmap.h>
> > +
> > +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);
> > + 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 */
>
> From Lee Jones: '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);
> > +
> [...]
> > +static const struct irq_domain_ops mt6358_irq_domain_ops = {
> > + .map = pmic_irq_domain_map,
> > + .xlate = irq_domain_xlate_twocell,
> > +};
> > +
> > +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 *),
>
> From Lee Jones: 'sizeof(*irqd)'
>
> > + GFP_KERNEL);
> > + if (!irqd)
> > + return -ENOMEM;
> > +
> > + chip->irq_data = irqd;
> > +
> [...]
> > @@ -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);
> > + break;
>
> From Lee Jones: "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()."
>
> Can you look into that as a follow-up patch?
>
>
> > +
> > 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);
>
> [snip]

\
 
 \ /
  Last update: 2020-03-31 10:29    [W:0.040 / U:1.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site