public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] mfd: mt6397: Properly fix CID of MT6328, MT6331 and MT6332
@ 2026-02-28 19:08 Akari Tsuyukusa
  2026-03-02 10:46 ` AngeloGioacchino Del Regno
  2026-03-02 14:00 ` [PATCH v2] " Akari Tsuyukusa
  0 siblings, 2 replies; 4+ messages in thread
From: Akari Tsuyukusa @ 2026-02-28 19:08 UTC (permalink / raw)
  To: lee
  Cc: matthias.bgg, angelogioacchino.delregno, akkun11.open,
	linux-kernel, linux-arm-kernel, linux-mediatek, y.oudjana

CIDs set for MT6328, MT6331 and MT6332 are not appropriate.
Many Android downstream kernels define CID as below,

MT6328:

    #define PMIC6328_E1_CID_CODE    0x2810
    #define PMIC6328_E2_CID_CODE    0x2820
    #define PMIC6328_E3_CID_CODE    0x2830

MT6331/MT6332:

    #define PMIC6331_E1_CID_CODE    0x3110
    #define PMIC6331_E2_CID_CODE    0x3120
    #define PMIC6331_E3_CID_CODE    0x3130

    #define PMIC6332_E1_CID_CODE    0x3210
    #define PMIC6332_E2_CID_CODE    0x3220
    #define PMIC6332_E3_CID_CODE    0x3230

The current configuration incorrectly uses the revision code as the CID.
Therefore, the driver cannot detect the same PMIC of different revisions.
(E1/E2 for MT6328, E1/E3 for MT6331/MT6332)
Based on these, the CID of MT6328, MT6331 and MT6332 should be corrected.

Additionally, the incorrect MT6331/MT6332 CID overlaps with the MT6320's
actual CID:

    #define PMIC6320_E1_CID_CODE    0x1020
    #define PMIC6320_E2_CID_CODE    0x2020

This causes a conflict in the switch-case statement of mt6397-irq.c,
this prevents adding support for MT6320.

Link: https://github.com/parthibx24/android_kernel_mediatek_k35/blob/4853d1fd9e40563573fa6d6b32b75d571a95e2b7/drivers/misc/mediatek/power/mt6735/pmic.h#L10-L12
Link: https://github.com/meizuosc/m75/blob/80ef1d26c5d73e131d064138ed09ff5a2be2bed8/mediatek/platform/mt6595/kernel/core/include/mach/pmic_mt6331_6332_sw.h#L9-L15
Link: https://github.com/toffyjan/android_Ticwatch_S_mooneye/blob/4f2a73b26f3821afc452cdce660cdbc73daf4e4a/arch/arm/mach-mt2601/include/mach/pmic_mt6320_sw.h#L29-L30
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
---
 drivers/mfd/mt6397-core.c       | 4 ++--
 include/linux/mfd/mt6397/core.h | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
index 3e58d0764c7e..1bdacda9a933 100644
--- a/drivers/mfd/mt6397-core.c
+++ b/drivers/mfd/mt6397-core.c
@@ -297,7 +297,7 @@ static const struct chip_data mt6323_core = {
 
 static const struct chip_data mt6328_core = {
 	.cid_addr = MT6328_HWCID,
-	.cid_shift = 0,
+	.cid_shift = 8,
 	.cells = mt6328_devs,
 	.cell_size = ARRAY_SIZE(mt6328_devs),
 	.irq_init = mt6397_irq_init,
@@ -313,7 +313,7 @@ static const struct chip_data mt6357_core = {
 
 static const struct chip_data mt6331_mt6332_core = {
 	.cid_addr = MT6331_HWCID,
-	.cid_shift = 0,
+	.cid_shift = 8,
 	.cells = mt6331_mt6332_devs,
 	.cell_size = ARRAY_SIZE(mt6331_mt6332_devs),
 	.irq_init = mt6397_irq_init,
diff --git a/include/linux/mfd/mt6397/core.h b/include/linux/mfd/mt6397/core.h
index b774c3a4bb62..340fc72e22aa 100644
--- a/include/linux/mfd/mt6397/core.h
+++ b/include/linux/mfd/mt6397/core.h
@@ -12,9 +12,9 @@
 
 enum chip_id {
 	MT6323_CHIP_ID = 0x23,
-	MT6328_CHIP_ID = 0x30,
-	MT6331_CHIP_ID = 0x20,
-	MT6332_CHIP_ID = 0x20,
+	MT6328_CHIP_ID = 0x28,
+	MT6331_CHIP_ID = 0x31,
+	MT6332_CHIP_ID = 0x32,
 	MT6357_CHIP_ID = 0x57,
 	MT6358_CHIP_ID = 0x58,
 	MT6359_CHIP_ID = 0x59,
-- 
2.52.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mfd: mt6397: Properly fix CID of MT6328, MT6331 and MT6332
  2026-02-28 19:08 [PATCH] mfd: mt6397: Properly fix CID of MT6328, MT6331 and MT6332 Akari Tsuyukusa
@ 2026-03-02 10:46 ` AngeloGioacchino Del Regno
  2026-03-02 14:00 ` [PATCH v2] " Akari Tsuyukusa
  1 sibling, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-03-02 10:46 UTC (permalink / raw)
  To: Akari Tsuyukusa, lee
  Cc: matthias.bgg, linux-kernel, linux-arm-kernel, linux-mediatek,
	y.oudjana

Il 28/02/26 20:08, Akari Tsuyukusa ha scritto:
> CIDs set for MT6328, MT6331 and MT6332 are not appropriate.
> Many Android downstream kernels define CID as below,
> 
> MT6328:
> 
>      #define PMIC6328_E1_CID_CODE    0x2810
>      #define PMIC6328_E2_CID_CODE    0x2820
>      #define PMIC6328_E3_CID_CODE    0x2830
> 
> MT6331/MT6332:
> 
>      #define PMIC6331_E1_CID_CODE    0x3110
>      #define PMIC6331_E2_CID_CODE    0x3120
>      #define PMIC6331_E3_CID_CODE    0x3130
> 
>      #define PMIC6332_E1_CID_CODE    0x3210
>      #define PMIC6332_E2_CID_CODE    0x3220
>      #define PMIC6332_E3_CID_CODE    0x3230
> 
> The current configuration incorrectly uses the revision code as the CID.
> Therefore, the driver cannot detect the same PMIC of different revisions.
> (E1/E2 for MT6328, E1/E3 for MT6331/MT6332)
> Based on these, the CID of MT6328, MT6331 and MT6332 should be corrected.
> 
> Additionally, the incorrect MT6331/MT6332 CID overlaps with the MT6320's
> actual CID:
> 
>      #define PMIC6320_E1_CID_CODE    0x1020
>      #define PMIC6320_E2_CID_CODE    0x2020
> 
> This causes a conflict in the switch-case statement of mt6397-irq.c,
> this prevents adding support for MT6320.
> 
> Link: https://github.com/parthibx24/android_kernel_mediatek_k35/blob/4853d1fd9e40563573fa6d6b32b75d571a95e2b7/drivers/misc/mediatek/power/mt6735/pmic.h#L10-L12
> Link: https://github.com/meizuosc/m75/blob/80ef1d26c5d73e131d064138ed09ff5a2be2bed8/mediatek/platform/mt6595/kernel/core/include/mach/pmic_mt6331_6332_sw.h#L9-L15
> Link: https://github.com/toffyjan/android_Ticwatch_S_mooneye/blob/4f2a73b26f3821afc452cdce660cdbc73daf4e4a/arch/arm/mach-mt2601/include/mach/pmic_mt6320_sw.h#L29-L30

Please remove these links, these will be invalid in a few months, so they are
irrelevant.

> Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>

Anyway:

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

Cheers,
Angelo


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] mfd: mt6397: Properly fix CID of MT6328, MT6331 and MT6332
  2026-02-28 19:08 [PATCH] mfd: mt6397: Properly fix CID of MT6328, MT6331 and MT6332 Akari Tsuyukusa
  2026-03-02 10:46 ` AngeloGioacchino Del Regno
@ 2026-03-02 14:00 ` Akari Tsuyukusa
  2026-03-06 13:54   ` (subset) " Lee Jones
  1 sibling, 1 reply; 4+ messages in thread
From: Akari Tsuyukusa @ 2026-03-02 14:00 UTC (permalink / raw)
  To: lee
  Cc: matthias.bgg, linux-kernel, linux-arm-kernel, linux-mediatek,
	y.oudjana, angelogioacchino.delregno, Akari Tsuyukusa

CIDs set for MT6328, MT6331 and MT6332 are not appropriate.
Many Android downstream kernels define CID as below,

MT6328:

    #define PMIC6328_E1_CID_CODE    0x2810
    #define PMIC6328_E2_CID_CODE    0x2820
    #define PMIC6328_E3_CID_CODE    0x2830

MT6331/MT6332:

    #define PMIC6331_E1_CID_CODE    0x3110
    #define PMIC6331_E2_CID_CODE    0x3120
    #define PMIC6331_E3_CID_CODE    0x3130

    #define PMIC6332_E1_CID_CODE    0x3210
    #define PMIC6332_E2_CID_CODE    0x3220
    #define PMIC6332_E3_CID_CODE    0x3230

The current configuration incorrectly uses the revision code as the CID.
Therefore, the driver cannot detect the same PMIC of different revisions.
(E1/E2 for MT6328, E1/E3 for MT6331/MT6332)
Based on these, the CID of MT6328, MT6331 and MT6332 should be corrected.

Additionally, the incorrect MT6331/MT6332 CID overlaps with the MT6320's
actual CID:

    #define PMIC6320_E1_CID_CODE    0x1020
    #define PMIC6320_E2_CID_CODE    0x2020

This causes a conflict in the switch-case statement of mt6397-irq.c,
this prevents adding support for MT6320.

Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
Changes in v2:
- Remove GitHub links from the commit message as they may become invalid. (Requested by Angelo)
- Add Reviewed-by tag.
- No code changes.

 drivers/mfd/mt6397-core.c       | 4 ++--
 include/linux/mfd/mt6397/core.h | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
index 3e58d0764c7e..1bdacda9a933 100644
--- a/drivers/mfd/mt6397-core.c
+++ b/drivers/mfd/mt6397-core.c
@@ -297,7 +297,7 @@ static const struct chip_data mt6323_core = {
 
 static const struct chip_data mt6328_core = {
 	.cid_addr = MT6328_HWCID,
-	.cid_shift = 0,
+	.cid_shift = 8,
 	.cells = mt6328_devs,
 	.cell_size = ARRAY_SIZE(mt6328_devs),
 	.irq_init = mt6397_irq_init,
@@ -313,7 +313,7 @@ static const struct chip_data mt6357_core = {
 
 static const struct chip_data mt6331_mt6332_core = {
 	.cid_addr = MT6331_HWCID,
-	.cid_shift = 0,
+	.cid_shift = 8,
 	.cells = mt6331_mt6332_devs,
 	.cell_size = ARRAY_SIZE(mt6331_mt6332_devs),
 	.irq_init = mt6397_irq_init,
diff --git a/include/linux/mfd/mt6397/core.h b/include/linux/mfd/mt6397/core.h
index b774c3a4bb62..340fc72e22aa 100644
--- a/include/linux/mfd/mt6397/core.h
+++ b/include/linux/mfd/mt6397/core.h
@@ -12,9 +12,9 @@
 
 enum chip_id {
 	MT6323_CHIP_ID = 0x23,
-	MT6328_CHIP_ID = 0x30,
-	MT6331_CHIP_ID = 0x20,
-	MT6332_CHIP_ID = 0x20,
+	MT6328_CHIP_ID = 0x28,
+	MT6331_CHIP_ID = 0x31,
+	MT6332_CHIP_ID = 0x32,
 	MT6357_CHIP_ID = 0x57,
 	MT6358_CHIP_ID = 0x58,
 	MT6359_CHIP_ID = 0x59,
-- 
2.52.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: (subset) [PATCH v2] mfd: mt6397: Properly fix CID of MT6328, MT6331 and MT6332
  2026-03-02 14:00 ` [PATCH v2] " Akari Tsuyukusa
@ 2026-03-06 13:54   ` Lee Jones
  0 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-03-06 13:54 UTC (permalink / raw)
  To: lee, Akari Tsuyukusa
  Cc: matthias.bgg, linux-kernel, linux-arm-kernel, linux-mediatek,
	y.oudjana, angelogioacchino.delregno

On Mon, 02 Mar 2026 23:00:45 +0900, Akari Tsuyukusa wrote:
> CIDs set for MT6328, MT6331 and MT6332 are not appropriate.
> Many Android downstream kernels define CID as below,
> 
> MT6328:
> 
>     #define PMIC6328_E1_CID_CODE    0x2810
>     #define PMIC6328_E2_CID_CODE    0x2820
>     #define PMIC6328_E3_CID_CODE    0x2830
> 
> [...]

Applied, thanks!

[1/1] mfd: mt6397: Properly fix CID of MT6328, MT6331 and MT6332
      commit: f59b2bc3e6dbcd75c53f1881c1f08a6d3c2a72e5

--
Lee Jones [李琼斯]



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-06 13:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-28 19:08 [PATCH] mfd: mt6397: Properly fix CID of MT6328, MT6331 and MT6332 Akari Tsuyukusa
2026-03-02 10:46 ` AngeloGioacchino Del Regno
2026-03-02 14:00 ` [PATCH v2] " Akari Tsuyukusa
2026-03-06 13:54   ` (subset) " Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox