Skip to content

add MT6320 driver#19

Draft
akku1139 wants to merge 60 commits intoblade/v6.16from
dev/v6.16/mt6320
Draft

add MT6320 driver#19
akku1139 wants to merge 60 commits intoblade/v6.16from
dev/v6.16/mt6320

Conversation

@akku1139
Copy link
Member

@akku1139 akku1139 commented Jan 3, 2026

  • pwrap
  • pinctrl (untested)
  • pinfunc header
  • regulator
  • rtc
  • keys (untested)
  • battery
  • interrupts
  • audio codecs
  • adc?
  • clocks
  • led
  • power-controller

@akku1139 akku1139 marked this pull request as draft January 3, 2026 02:43
@akku1139
Copy link
Member Author

akku1139 commented Jan 18, 2026

needed to add WRAP_WR32(PMIC_WRAP_HIPRIO_ARB_EN,8); ?
https://github.com/bq/aquaris-5/blob/bc1d0d0e35c969670e2d869001be944ad0c9c5e5/mediatek/platform/mt6589/kernel/drivers/pmic_wrap/pwrap_hal.c#L896C3-L896C40
(Enable WACS2)

pwrap_writel(wrp, 0x1, PWRAP_WACS2_EN);

@akku1139
Copy link
Member Author

@akku1139
Copy link
Member Author

akku1139 commented Feb 26, 2026

MT6320's CID is duplicated!

enum chip_id {
MT6323_CHIP_ID = 0x23,
MT6328_CHIP_ID = 0x30,
MT6331_CHIP_ID = 0x20,
MT6332_CHIP_ID = 0x20,
MT6357_CHIP_ID = 0x57,
MT6358_CHIP_ID = 0x58,
MT6359_CHIP_ID = 0x59,
MT6366_CHIP_ID = 0x66,
MT6391_CHIP_ID = 0x91,
MT6397_CHIP_ID = 0x97,
};

//==============================================================================
// PMIC6320 Define
//==============================================================================
#define PMIC6320_E1_CID_CODE    0x1020
#define PMIC6320_E2_CID_CODE    0x2020

https://github.com/bq/aquaris-5/blob/bc1d0d0e35c969670e2d869001be944ad0c9c5e5/mediatek/platform/mt6589/kernel/core/include/mach/mt\_pmic.h#L6-L10

@akku1139
Copy link
Member Author

drivers/mfd/mt6397-irq.c: In function 'mt6397_irq_init':
drivers/mfd/mt6397-irq.c:201:9: error: duplicate case value
  201 |         case MT6331_CHIP_ID:
      |         ^~~~
drivers/mfd/mt6397-irq.c:181:9: note: previously used here
  181 |         case MT6320_CHIP_ID:
      |         ^~~~

akku1139 added 15 commits March 1, 2026 19:06
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>
@akku1139
Copy link
Member Author

akku1139 commented Mar 3, 2026

@akku1139
Copy link
Member Author

akku1139 commented Mar 3, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant