diff mbox series

mfd: mt6397: fix probe after changing mt6397-core

Message ID 20191003185323.24646-1-frank-w@public-files.de (mailing list archive)
State New, archived
Headers show
Series mfd: mt6397: fix probe after changing mt6397-core | expand

Commit Message

Frank Wunderlich Oct. 3, 2019, 6:53 p.m. UTC
Part 3 from this series [1] was not merged due to wrong splitting
and breaks mt6323 pmic on bananapi-r2

dmesg prints this line and at least switch is not initialized on bananapi-r2

mt6397 1000d000.pwrap:mt6323: unsupported chip: 0x0

this patch contains only the probe-changes and chip_data structs
from original part 3 by Hsin-Hsiung Wang

Fixes: a4872e80ce7d2a1844328176dbf279d0a2b89bdb mfd: mt6397: Extract IRQ related code from core driver

[1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=164155

Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
---
 drivers/mfd/mt6397-core.c | 64 ++++++++++++++++++++++++---------------
 1 file changed, 40 insertions(+), 24 deletions(-)

Comments

Lee Jones Oct. 4, 2019, 3:20 p.m. UTC | #1
On Thu, 03 Oct 2019, Frank Wunderlich wrote:

> Part 3 from this series [1] was not merged due to wrong splitting
> and breaks mt6323 pmic on bananapi-r2
> 
> dmesg prints this line and at least switch is not initialized on bananapi-r2
> 
> mt6397 1000d000.pwrap:mt6323: unsupported chip: 0x0
> 
> this patch contains only the probe-changes and chip_data structs
> from original part 3 by Hsin-Hsiung Wang
> 
> Fixes: a4872e80ce7d2a1844328176dbf279d0a2b89bdb mfd: mt6397: Extract IRQ related code from core driver
> 
> [1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=164155
> 
> Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
> ---
>  drivers/mfd/mt6397-core.c | 64 ++++++++++++++++++++++++---------------
>  1 file changed, 40 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
> index 310dae26ddff..b2c325ead1c8 100644
> --- a/drivers/mfd/mt6397-core.c
> +++ b/drivers/mfd/mt6397-core.c
> @@ -129,11 +129,27 @@ static int mt6397_irq_resume(struct device *dev)
>  static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_irq_suspend,
>  			mt6397_irq_resume);
>  
> +struct chip_data {
> +	u32 cid_addr;
> +	u32 cid_shift;
> +};
> +
> +static const struct chip_data mt6323_core = {
> +	.cid_addr = MT6323_CID,
> +	.cid_shift = 0,
> +};
> +
> +static const struct chip_data mt6397_core = {
> +	.cid_addr = MT6397_CID,
> +	.cid_shift = 0,
> +};

Will there be other devices which have a !0 CID shift?
Frank Wunderlich Oct. 4, 2019, 3:51 p.m. UTC | #2
This Question goes to Hsin-Hsiung Wang ;)

i only took his code (and splitted the 3rd part) to get mt6323 working again without reverting the other 2 Patches

regards Frank


> Gesendet: Freitag, 04. Oktober 2019 um 17:20 Uhr
> Von: "Lee Jones" <lee.jones@linaro.org>

> Will there be other devices which have a !0 CID shift?
Matthias Brugger Oct. 5, 2019, 8:16 a.m. UTC | #3
On 04/10/2019 17:51, Frank Wunderlich wrote:
> This Question goes to Hsin-Hsiung Wang ;)
> 
> i only took his code (and splitted the 3rd part) to get mt6323 working again without reverting the other 2 Patches
>> regards Frank
> 
> 
>> Gesendet: Freitag, 04. Oktober 2019 um 17:20 Uhr
>> Von: "Lee Jones" <lee.jones@linaro.org>
> 
>> Will there be other devices which have a !0 CID shift?
> 

Frank, a quick look at the series would have given you the answer.
@Lee: yes, this change is the preparation to support MT6358:
https://patchwork.kernel.org/patch/11110515/

Regards,
Matthias
Hsin-Hsiung Wang Oct. 7, 2019, 3:24 a.m. UTC | #4
On Sat, 2019-10-05 at 10:16 +0200, Matthias Brugger wrote:
> 
> On 04/10/2019 17:51, Frank Wunderlich wrote:
> > This Question goes to Hsin-Hsiung Wang ;)
> > 
> > i only took his code (and splitted the 3rd part) to get mt6323 working again without reverting the other 2 Patches
> >> regards Frank
> > 
Hi Frank,
Sorry for the late reply.
I appreciate your help very much for splitting the code to fix the
issue.
This patch is ok for me.

> > 
> >> Gesendet: Freitag, 04. Oktober 2019 um 17:20 Uhr
> >> Von: "Lee Jones" <lee.jones@linaro.org>
> > 
> >> Will there be other devices which have a !0 CID shift?
> > 
> 
> Frank, a quick look at the series would have given you the answer.
> @Lee: yes, this change is the preparation to support MT6358:
> https://patchwork.kernel.org/patch/11110515/
> 

Hi, Lee
MT6358 uses 8 for the cid shift and I will submit next version patch of
mt6358 which is based on Frank's patch.

Hi, Matthias
Many thanks for the explanation.

> Regards,
> Matthias
Hsin-Hsiung Wang Oct. 7, 2019, 3:32 a.m. UTC | #5
On Sat, 2019-10-05 at 10:16 +0200, Matthias Brugger wrote:
> 
> On 04/10/2019 17:51, Frank Wunderlich wrote:
> > This Question goes to Hsin-Hsiung Wang ;)
> > 
> > i only took his code (and splitted the 3rd part) to get mt6323 working again without reverting the other 2 Patches
> >> regards Frank

Hi, Frank
Sorry for the late reply.
I appreciate your help very much for splitting the code to fix the
issue.
This patch is ok for me.

> > 
> > 
> >> Gesendet: Freitag, 04. Oktober 2019 um 17:20 Uhr
> >> Von: "Lee Jones" <lee.jones@linaro.org>
> > 
> >> Will there be other devices which have a !0 CID shift?
> > 
> 
> Frank, a quick look at the series would have given you the answer.
> @Lee: yes, this change is the preparation to support MT6358:
> https://patchwork.kernel.org/patch/11110515/
> 
Hi, Lee
MT6358 uses 8 for the cid shift and I will submit next version patch of
mt6358 which is based on Frank's patch.

Hi, Matthias
Many thanks for the explanation.

> Regards,
> Matthias
Frank Wunderlich Oct. 9, 2019, 5:19 a.m. UTC | #6
Should i send patch without the shift (because rest of series gets not merged in 5.4)?

Am 4. Oktober 2019 17:20:01 MESZ schrieb Lee Jones <lee.jones@linaro.org>:
>On Thu, 03 Oct 2019, Frank Wunderlich wrote:
>
>> Part 3 from this series [1] was not merged due to wrong splitting
>> and breaks mt6323 pmic on bananapi-r2
>> 
>> dmesg prints this line and at least switch is not initialized on
>bananapi-r2
>> 
>> mt6397 1000d000.pwrap:mt6323: unsupported chip: 0x0
>> 
>> this patch contains only the probe-changes and chip_data structs
>> from original part 3 by Hsin-Hsiung Wang
>> 
>> Fixes: a4872e80ce7d2a1844328176dbf279d0a2b89bdb mfd: mt6397: Extract
>IRQ related code from core driver
>> 
>> [1]
>https://patchwork.kernel.org/project/linux-mediatek/list/?series=164155
>> 
>> Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
>> ---
>>  drivers/mfd/mt6397-core.c | 64
>++++++++++++++++++++++++---------------
>>  1 file changed, 40 insertions(+), 24 deletions(-)
>> 
>> diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
>> index 310dae26ddff..b2c325ead1c8 100644
>> --- a/drivers/mfd/mt6397-core.c
>> +++ b/drivers/mfd/mt6397-core.c
>> @@ -129,11 +129,27 @@ static int mt6397_irq_resume(struct device
>*dev)
>>  static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_irq_suspend,
>>  			mt6397_irq_resume);
>>  
>> +struct chip_data {
>> +	u32 cid_addr;
>> +	u32 cid_shift;
>> +};
>> +
>> +static const struct chip_data mt6323_core = {
>> +	.cid_addr = MT6323_CID,
>> +	.cid_shift = 0,
>> +};
>> +
>> +static const struct chip_data mt6397_core = {
>> +	.cid_addr = MT6397_CID,
>> +	.cid_shift = 0,
>> +};
>
>Will there be other devices which have a !0 CID shift?
>
>-- 
>Lee Jones [李琼斯]
>Linaro Services Technical Lead
>Linaro.org │ Open source software for ARM SoCs
>Follow Linaro: Facebook | Twitter | Blog
>
>_______________________________________________
>Linux-mediatek mailing list
>Linux-mediatek@lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/linux-mediatek
Lee Jones Oct. 16, 2019, 9:53 a.m. UTC | #7
On Thu, 03 Oct 2019, Frank Wunderlich wrote:

> Part 3 from this series [1] was not merged due to wrong splitting
> and breaks mt6323 pmic on bananapi-r2
> 
> dmesg prints this line and at least switch is not initialized on bananapi-r2
> 
> mt6397 1000d000.pwrap:mt6323: unsupported chip: 0x0
> 
> this patch contains only the probe-changes and chip_data structs
> from original part 3 by Hsin-Hsiung Wang
> 
> Fixes: a4872e80ce7d2a1844328176dbf279d0a2b89bdb mfd: mt6397: Extract IRQ related code from core driver

I've fixed this line to use the standard formatting.

> [1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=164155
> 
> Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
> ---
>  drivers/mfd/mt6397-core.c | 64 ++++++++++++++++++++++++---------------
>  1 file changed, 40 insertions(+), 24 deletions(-)

Applied, thanks.
Frank Wunderlich Oct. 22, 2019, 9:46 a.m. UTC | #8
Will it be merged on rc-cycle?

I ask because i see it only in mfd-next but not in fixes/torvalds-master

Regards Frank

Am 16. Oktober 2019 11:53:38 MESZ schrieb Lee Jones <lee.jones@linaro.org>:
>On Thu, 03 Oct 2019, Frank Wunderlich wrote:
>
>> Part 3 from this series [1] was not merged due to wrong splitting
>> and breaks mt6323 pmic on bananapi-r2
>> 
>> dmesg prints this line and at least switch is not initialized on
>bananapi-r2
>> 
>> mt6397 1000d000.pwrap:mt6323: unsupported chip: 0x0
>> 
>> this patch contains only the probe-changes and chip_data structs
>> from original part 3 by Hsin-Hsiung Wang
>> 
>> Fixes: a4872e80ce7d2a1844328176dbf279d0a2b89bdb mfd: mt6397: Extract
>IRQ related code from core driver
>
>I've fixed this line to use the standard formatting.
>
>> [1]
>https://patchwork.kernel.org/project/linux-mediatek/list/?series=164155
>> 
>> Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
>> ---
>>  drivers/mfd/mt6397-core.c | 64
>++++++++++++++++++++++++---------------
>>  1 file changed, 40 insertions(+), 24 deletions(-)
>
>Applied, thanks.
>
>-- 
>Lee Jones [李琼斯]
>Linaro Services Technical Lead
>Linaro.org │ Open source software for ARM SoCs
>Follow Linaro: Facebook | Twitter | Blog
>
>_______________________________________________
>Linux-mediatek mailing list
>Linux-mediatek@lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/linux-mediatek
Lee Jones Oct. 24, 2019, 7:57 a.m. UTC | #9
On Tue, 22 Oct 2019, Frank Wunderlich wrote:

> Will it be merged on rc-cycle?
> 
> I ask because i see it only in mfd-next but not in fixes/torvalds-master

It's been sent to Linus for the -rcs.
diff mbox series

Patch

diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
index 310dae26ddff..b2c325ead1c8 100644
--- a/drivers/mfd/mt6397-core.c
+++ b/drivers/mfd/mt6397-core.c
@@ -129,11 +129,27 @@  static int mt6397_irq_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_irq_suspend,
 			mt6397_irq_resume);
 
+struct chip_data {
+	u32 cid_addr;
+	u32 cid_shift;
+};
+
+static const struct chip_data mt6323_core = {
+	.cid_addr = MT6323_CID,
+	.cid_shift = 0,
+};
+
+static const struct chip_data mt6397_core = {
+	.cid_addr = MT6397_CID,
+	.cid_shift = 0,
+};
+
 static int mt6397_probe(struct platform_device *pdev)
 {
 	int ret;
 	unsigned int id;
 	struct mt6397_chip *pmic;
+	const struct chip_data *pmic_core;
 
 	pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
 	if (!pmic)
@@ -149,28 +165,30 @@  static int mt6397_probe(struct platform_device *pdev)
 	if (!pmic->regmap)
 		return -ENODEV;
 
-	platform_set_drvdata(pdev, pmic);
+	pmic_core = of_device_get_match_data(&pdev->dev);
+	if (!pmic_core)
+		return -ENODEV;
 
-	ret = regmap_read(pmic->regmap, MT6397_CID, &id);
+	ret = regmap_read(pmic->regmap, pmic_core->cid_addr, &id);
 	if (ret) {
-		dev_err(pmic->dev, "Failed to read chip id: %d\n", ret);
+		dev_err(&pdev->dev, "Failed to read chip id: %d\n", ret);
 		return ret;
 	}
 
+	pmic->chip_id = (id >> pmic_core->cid_shift) & 0xff;
+
+	platform_set_drvdata(pdev, pmic);
+
 	pmic->irq = platform_get_irq(pdev, 0);
 	if (pmic->irq <= 0)
 		return pmic->irq;
 
-	switch (id & 0xff) {
-	case MT6323_CHIP_ID:
-		pmic->int_con[0] = MT6323_INT_CON0;
-		pmic->int_con[1] = MT6323_INT_CON1;
-		pmic->int_status[0] = MT6323_INT_STATUS0;
-		pmic->int_status[1] = MT6323_INT_STATUS1;
-		ret = mt6397_irq_init(pmic);
-		if (ret)
-			return ret;
+	ret = mt6397_irq_init(pmic);
+	if (ret)
+		return ret;
 
+	switch (pmic->chip_id) {
+	case MT6323_CHIP_ID:
 		ret = devm_mfd_add_devices(&pdev->dev, -1, mt6323_devs,
 					   ARRAY_SIZE(mt6323_devs), NULL,
 					   0, pmic->irq_domain);
@@ -178,21 +196,13 @@  static int mt6397_probe(struct platform_device *pdev)
 
 	case MT6391_CHIP_ID:
 	case MT6397_CHIP_ID:
-		pmic->int_con[0] = MT6397_INT_CON0;
-		pmic->int_con[1] = MT6397_INT_CON1;
-		pmic->int_status[0] = MT6397_INT_STATUS0;
-		pmic->int_status[1] = MT6397_INT_STATUS1;
-		ret = mt6397_irq_init(pmic);
-		if (ret)
-			return ret;
-
 		ret = devm_mfd_add_devices(&pdev->dev, -1, mt6397_devs,
 					   ARRAY_SIZE(mt6397_devs), NULL,
 					   0, pmic->irq_domain);
 		break;
 
 	default:
-		dev_err(&pdev->dev, "unsupported chip: %d\n", id);
+		dev_err(&pdev->dev, "unsupported chip: %d\n", pmic->chip_id);
 		return -ENODEV;
 	}
 
@@ -205,9 +215,15 @@  static int mt6397_probe(struct platform_device *pdev)
 }
 
 static const struct of_device_id mt6397_of_match[] = {
-	{ .compatible = "mediatek,mt6397" },
-	{ .compatible = "mediatek,mt6323" },
-	{ }
+	{
+		.compatible = "mediatek,mt6323",
+		.data = &mt6323_core,
+	}, {
+		.compatible = "mediatek,mt6397",
+		.data = &mt6397_core,
+	}, {
+		/* sentinel */
+	}
 };
 MODULE_DEVICE_TABLE(of, mt6397_of_match);