From: Hsin-hsiung Wang <hsin-hsiung.wang@mediatek.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Nicolas Boichat <drinkcat@chromium.org>,
srv_heupstream@mediatek.com,
Frank Wunderlich <frank-w@public-files.de>,
Josef Friedl <josef.friedl@speed.at>,
Ran Bi <ran.bi@mediatek.com>, Sean Wang <sean.wang@mediatek.com>,
Sebastian Reichel <sre@kernel.org>,
linux-kernel@vger.kernel.org,
Richard Fontana <rfontana@redhat.com>,
devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org,
Matthias Brugger <matthias.bgg@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Eddie Huang <eddie.huang@mediatek.com>,
linux-arm-kernel@lists.infradead.org, linux-rtc@vger.kernel.org
Subject: Re: [PATCH v10 3/5] mfd: Add support for the MediaTek MT6358 PMIC
Date: Wed, 1 Apr 2020 16:26:21 +0800 [thread overview]
Message-ID: <1585729581.2029.2.camel@mtksdaap41> (raw)
In-Reply-To: <20200325094326.GH442973@dell>
Hi,
On Wed, 2020-03-25 at 09:43 +0000, Lee Jones wrote:
> 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 <hsin-hsiung.wang@mediatek.com>
> > ---
> > 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.
>
Thanks. I will update it in the next patch.
> > +#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);
>
> 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?
>
MT6358 is similar to MT6397 for mfd driver except the hardware design of
interrupt which provides more interrupts than MT6397.
I think MT6358 can reuse the other part of MT6397 mfd driver, so I only
add the interrupt part of MT6358.
> > + 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"
>
Thanks. I will update it in the next patch.
> > + 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)
>
Thanks. I will update it in the next patch.
> [...]
>
> > 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().
>
Thanks for your comment. I will rewrite this in the next patch.
> > + 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);
>
> [...]
>
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
WARNING: multiple messages have this Message-ID (diff)
From: Hsin-hsiung Wang <hsin-hsiung.wang@mediatek.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Mark Rutland <mark.rutland@arm.com>,
Sean Wang <sean.wang@mediatek.com>,
Sebastian Reichel <sre@kernel.org>,
Eddie Huang <eddie.huang@mediatek.com>,
Alessandro Zummo <a.zummo@towertech.it>,
"Frank Wunderlich" <frank-w@public-files.de>,
Thomas Gleixner <tglx@linutronix.de>,
Richard Fontana <rfontana@redhat.com>,
Josef Friedl <josef.friedl@speed.at>,
Ran Bi <ran.bi@mediatek.com>, <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 <drinkcat@chromium.org>,
<srv_heupstream@mediatek.com>
Subject: Re: [PATCH v10 3/5] mfd: Add support for the MediaTek MT6358 PMIC
Date: Wed, 1 Apr 2020 16:26:21 +0800 [thread overview]
Message-ID: <1585729581.2029.2.camel@mtksdaap41> (raw)
In-Reply-To: <20200325094326.GH442973@dell>
Hi,
On Wed, 2020-03-25 at 09:43 +0000, Lee Jones wrote:
> 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 <hsin-hsiung.wang@mediatek.com>
> > ---
> > 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.
>
Thanks. I will update it in the next patch.
> > +#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);
>
> 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?
>
MT6358 is similar to MT6397 for mfd driver except the hardware design of
interrupt which provides more interrupts than MT6397.
I think MT6358 can reuse the other part of MT6397 mfd driver, so I only
add the interrupt part of MT6358.
> > + 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"
>
Thanks. I will update it in the next patch.
> > + 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)
>
Thanks. I will update it in the next patch.
> [...]
>
> > 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().
>
Thanks for your comment. I will rewrite this in the next patch.
> > + 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);
>
> [...]
>
WARNING: multiple messages have this Message-ID (diff)
From: Hsin-hsiung Wang <hsin-hsiung.wang@mediatek.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Nicolas Boichat <drinkcat@chromium.org>,
srv_heupstream@mediatek.com,
Frank Wunderlich <frank-w@public-files.de>,
Josef Friedl <josef.friedl@speed.at>,
Ran Bi <ran.bi@mediatek.com>, Sean Wang <sean.wang@mediatek.com>,
Sebastian Reichel <sre@kernel.org>,
linux-kernel@vger.kernel.org,
Richard Fontana <rfontana@redhat.com>,
devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org,
Matthias Brugger <matthias.bgg@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Eddie Huang <eddie.huang@mediatek.com>,
linux-arm-kernel@lists.infradead.org, linux-rtc@vger.kernel.org
Subject: Re: [PATCH v10 3/5] mfd: Add support for the MediaTek MT6358 PMIC
Date: Wed, 1 Apr 2020 16:26:21 +0800 [thread overview]
Message-ID: <1585729581.2029.2.camel@mtksdaap41> (raw)
In-Reply-To: <20200325094326.GH442973@dell>
Hi,
On Wed, 2020-03-25 at 09:43 +0000, Lee Jones wrote:
> 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 <hsin-hsiung.wang@mediatek.com>
> > ---
> > 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.
>
Thanks. I will update it in the next patch.
> > +#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);
>
> 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?
>
MT6358 is similar to MT6397 for mfd driver except the hardware design of
interrupt which provides more interrupts than MT6397.
I think MT6358 can reuse the other part of MT6397 mfd driver, so I only
add the interrupt part of MT6358.
> > + 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"
>
Thanks. I will update it in the next patch.
> > + 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)
>
Thanks. I will update it in the next patch.
> [...]
>
> > 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().
>
Thanks for your comment. I will rewrite this in the next patch.
> > + 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);
>
> [...]
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-04-01 8:26 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-11 9:16 [PATCH v10 0/5] Add Support for MediaTek PMIC MT6358 Hsin-Hsiung Wang
2020-03-11 9:16 ` Hsin-Hsiung Wang
2020-03-11 9:16 ` Hsin-Hsiung Wang
2020-03-11 9:16 ` [PATCH v10 1/5] mfd: mt6397: modify suspend/resume behavior Hsin-Hsiung Wang
2020-03-11 9:16 ` Hsin-Hsiung Wang
2020-03-11 9:16 ` Hsin-Hsiung Wang
2020-03-11 9:17 ` [PATCH v10 2/5] dt-bindings: mfd: Add compatible for the MediaTek MT6358 PMIC Hsin-Hsiung Wang
2020-03-11 9:17 ` Hsin-Hsiung Wang
2020-03-11 9:17 ` Hsin-Hsiung Wang
2020-03-11 9:17 ` [PATCH v10 3/5] mfd: Add support " Hsin-Hsiung Wang
2020-03-11 9:17 ` Hsin-Hsiung Wang
2020-03-11 9:17 ` Hsin-Hsiung Wang
2020-03-12 1:41 ` Nicolas Boichat
2020-03-12 1:41 ` Nicolas Boichat
2020-03-12 1:41 ` Nicolas Boichat
2020-03-25 9:43 ` Lee Jones
2020-03-25 9:43 ` Lee Jones
2020-03-25 9:43 ` Lee Jones
2020-04-01 8:15 ` Hsin-hsiung Wang
2020-04-01 8:15 ` Hsin-hsiung Wang
2020-04-01 8:15 ` Hsin-hsiung Wang
2020-04-01 8:26 ` Hsin-hsiung Wang [this message]
2020-04-01 8:26 ` Hsin-hsiung Wang
2020-04-01 8:26 ` Hsin-hsiung Wang
2020-03-11 9:17 ` [PATCH v10 4/5] rtc: mt6397: Add support for the MediaTek MT6358 RTC Hsin-Hsiung Wang
2020-03-11 9:17 ` Hsin-Hsiung Wang
2020-03-11 9:17 ` Hsin-Hsiung Wang
2020-03-11 22:24 ` Sebastian Reichel
2020-03-11 22:24 ` Sebastian Reichel
2020-03-11 22:24 ` Sebastian Reichel
2020-03-12 1:47 ` Nicolas Boichat
2020-03-12 1:47 ` Nicolas Boichat
2020-03-12 1:47 ` Nicolas Boichat
2020-03-12 7:44 ` Lee Jones
2020-03-12 7:44 ` Lee Jones
2020-03-12 7:44 ` Lee Jones
2020-03-12 8:57 ` Ran Bi
2020-03-12 8:57 ` Ran Bi
2020-03-12 8:57 ` Ran Bi
2020-03-13 7:22 ` Lee Jones
2020-03-13 7:22 ` Lee Jones
2020-03-13 7:22 ` Lee Jones
2020-03-13 7:47 ` Alexandre Belloni
2020-03-13 7:47 ` Alexandre Belloni
2020-03-13 7:47 ` Alexandre Belloni
2020-03-13 8:30 ` Ran Bi
2020-03-13 8:30 ` Ran Bi
2020-03-13 8:30 ` Ran Bi
2020-03-11 9:17 ` [PATCH v10 5/5] arm64: dts: mt6358: add PMIC MT6358 related nodes Hsin-Hsiung Wang
2020-03-11 9:17 ` Hsin-Hsiung Wang
2020-03-11 9:17 ` Hsin-Hsiung Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1585729581.2029.2.camel@mtksdaap41 \
--to=hsin-hsiung.wang@mediatek.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=devicetree@vger.kernel.org \
--cc=drinkcat@chromium.org \
--cc=eddie.huang@mediatek.com \
--cc=frank-w@public-files.de \
--cc=josef.friedl@speed.at \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=ran.bi@mediatek.com \
--cc=rfontana@redhat.com \
--cc=robh+dt@kernel.org \
--cc=sean.wang@mediatek.com \
--cc=sre@kernel.org \
--cc=srv_heupstream@mediatek.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.