spacemit: fix P1 sub-device Kconfig defaults and dependencies
Subsystems (6)
Troy Mitchell
reviewerv4 cover spacemit: fix P1 sub-device Kconfig defaults and dependencies
This series fixes Kconfig default value and dependency handling for the SpacemiT P1 PMIC and its sub-devices.
---
Troy Mitchell (3):
regulator: spacemit: MFD_SPACEMIT_P1 as dependencies
mfd: simple-mfd-i2c: add default value
rtc: spacemit: default module when MFD_SPACEMIT_P1 is enabled
drivers/mfd/Kconfig | 1 + drivers/regulator/Kconfig | 5 ++--- drivers/rtc/Kconfig | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
---
base-commit: b87881a3c93345252ce8559ad763369febfdb75d
change-id: 20251021-p1-kconfig-fix-6d2b59d03b8f
Best regards,
Signature · 1 line
Troy Mitchell <[email protected]>
Troy Mitchell
reviewerPATCH v4 1/3 regulator: spacemit: MFD_SPACEMIT_P1 as dependencies
REGULATOR_SPACEMIT_P1 is a subdevice of P1 and should depend on MFD_SPACEMIT_P1 rather than selecting it directly. Using 'select' does not always respect the parent's dependencies, so 'depends on' is the safer and more correct choice.
Since MFD_SPACEMIT_P1 already depends on I2C_K1, the dependency in REGULATOR_SPACEMIT_P1 is now redundant.
Additionally, the default value depends on MFD_SPACEMIT_P1 rather than ARCH_SPACEMIT.
---
Change log in v4:
- default m if MFD_SPACEMIT_P1 instead of default MFD_SPACEMIT_P1
Link to v3: https://lore.kernel.org/all/[email protected]/
Changelog in v3:
- modify commit message
- change default value from ARCH_SPACEMIT to MFD_SPACEMIT_P1
- Link to v2: https://lore.kernel.org/all/[email protected]/
--- drivers/regulator/Kconfig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/regulator/Kconfig +2 -3
@@ -1496,9 +1496,8 @@ config REGULATOR_SLG51000 config REGULATOR_SPACEMIT_P1 tristate "SpacemiT P1 regulators" depends on ARCH_SPACEMIT || COMPILE_TEST - depends on I2C - select MFD_SPACEMIT_P1 - default ARCH_SPACEMIT + depends on MFD_SPACEMIT_P1 + default m if MFD_SPACEMIT_P1 help Enable support for regulators implemented by the SpacemiT P1 power controller. The P1 implements 6 high-efficiency buck
Signature · 1 line
2.52.0
Troy Mitchell
reviewerPATCH v4 2/3 mfd: simple-mfd-i2c: add default value
In reply to Troy MitchellThe default value of the P1 sub-device depends on the value of P1, so P1 should have a default value here.
---
Change log in v4:
- default m if ARCH_SPACEMIT instead of default ARCH_SPACEMIT
- Link to v3: https://lore.kernel.org/all/[email protected]/
--- drivers/mfd/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/Kconfig +1 -0
@@ -1276,6 +1276,7 @@ config MFD_SPACEMIT_P1 depends on ARCH_SPACEMIT || COMPILE_TEST depends on I2C select MFD_SIMPLE_MFD_I2C + default m if ARCH_SPACEMIT help This option supports the I2C-based SpacemiT P1 PMIC, which contains regulators, a power switch, GPIOs, an RTC, and more.
Signature · 1 line
2.52.0
Re: (subset) [PATCH v4 2/3] mfd: simple-mfd-i2c: add default value
Quoted 4 lines · Troy Mitchell
The default value of the P1 sub-device depends on the value of P1, so P1 should have a default value here.
Applied, thanks!
[2/3] mfd: simple-mfd-i2c: add default value
commit: 77df11d1f1f962636e897f3fcf0977109aa74791
--
Lee Jones [李琼斯]
Troy Mitchell
reviewerPATCH v4 3/3 rtc: spacemit: default module when MFD_SPACEMIT_P1 is enabled
In reply to Troy MitchellThe RTC driver defaulted to the same value as MFD_SPACEMIT_P1, which caused it to be built-in automatically whenever the PMIC support was set to y.
This is not always desirable, as the RTC function is not required on all platforms using the SpacemiT P1 PMIC.
--- drivers/rtc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/Kconfig +1 -1
@@ -410,7 +410,7 @@ config RTC_DRV_SPACEMIT_P1 tristate "SpacemiT P1 RTC" depends on ARCH_SPACEMIT || COMPILE_TEST depends on MFD_SPACEMIT_P1 - default MFD_SPACEMIT_P1 + default m if MFD_SPACEMIT_P1 help Enable support for the RTC function in the SpacemiT P1 PMIC. This driver can also be built as a module, which will be called
Signature · 1 line
2.52.0
Alexandre Belloni
maintainerRe: [PATCH v4 3/3] rtc: spacemit: default module when MFD_SPACEMIT_P1 is enabled
Quoted 6 lines · Troy Mitchell
The RTC driver defaulted to the same value as
MFD_SPACEMIT_P1, which caused it to be built-in automatically whenever the PMIC support was set to y.This is not always desirable, as the RTC function is not required on all platforms using the SpacemiT P1 PMIC.
But then, can't people simply change the config? I don't feel like this is an improvement.
Quoted 23 lines
Signed-off-by Troy Mitchell <[email protected]>--- drivers/rtc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/Kconfig +1
-1@@ -410,7 +410,7 @@ config RTC_DRV_SPACEMIT_P1 tristate "SpacemiT P1 RTC" depends on ARCH_SPACEMIT || COMPILE_TEST depends on MFD_SPACEMIT_P1 - default MFD_SPACEMIT_P1 + default m if MFD_SPACEMIT_P1 help Enable support for the RTC function in the SpacemiT P1 PMIC. This driver can also be built as a module, which will be calledSignature · 2 lines
-- 2.52.0
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Alex Elder
Acked-byRe: [PATCH v4 3/3] rtc: spacemit: default module when MFD_SPACEMIT_P1 is enabled
Quoted 10 lines · Alexandre Belloni
Quoted 6 lines · Troy Mitchell
The RTC driver defaulted to the same value as
MFD_SPACEMIT_P1, which caused it to be built-in automatically whenever the PMIC support was set to y.This is not always desirable, as the RTC function is not required on all platforms using the SpacemiT P1 PMIC.
But then, can't people simply change the config? I don't feel like this is an improvement.
It's not an improvement for people who want to use the SpacemiT P1 PMIC, but it's an improvement for all the other RISC-V builds using "defconfig" that would rather have that support be modular to avoid needlessly consuming resources.
I haven't done any testing on this but it looks fine to me.
I think it's a small change worth merging. I don't think doing so does any harm. Your call or course, Alexandre.
-Alex
Quoted 23 lines
Quoted 22 lines
Signed-off-by Troy Mitchell <[email protected]>--- drivers/rtc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/Kconfig +1
-1@@ -410,7 +410,7 @@ config RTC_DRV_SPACEMIT_P1 tristate "SpacemiT P1 RTC" depends on ARCH_SPACEMIT || COMPILE_TEST depends on MFD_SPACEMIT_P1 - default MFD_SPACEMIT_P1 + default m if MFD_SPACEMIT_P1 help Enable support for the RTC function in the SpacemiT P1 PMIC. This driver can also be built as a module, which will be calledSignature · 2 lines
-- 2.52.0
Alexandre Belloni
maintainerRe: [PATCH v4 3/3] rtc: spacemit: default module when MFD_SPACEMIT_P1 is enabled
Quoted 9 lines · Alex Elder
Quoted 8 lines · Alexandre Belloni
Quoted 6 lines · Troy Mitchell
The RTC driver defaulted to the same value as
MFD_SPACEMIT_P1, which caused it to be built-in automatically whenever the PMIC support was set to y.This is not always desirable, as the RTC function is not required on all platforms using the SpacemiT P1 PMIC.
Quoted 7 lines
Quoted 2 lines
But then, can't people simply change the config? I don't feel like this is an improvement.
It's not an improvement for people who want to use the SpacemiT P1 PMIC, but it's an improvement for all the other RISC-V builds using "defconfig" that would rather have that support be modular to avoid needlessly consuming resources.
But then, wouldn't MFD_SPACEMIT_P1 be simply not set or set to m ? So this doesn't have any impact on other RISC-V builds while it makes people using the SpacemiT P1 PMIC jump through hoops to be able to use the RTC as this is a very uncommon way to set default values.
My point is:
- other RISC-V platforms would simply not select MFD_SPACEMIT_P1 or have MFD_SPACEMIT_P1 set to m
- having RTC_DRV_SPACEMIT_P1 built-in by default when MFD_SPACEMIT_P1 is built-in doesn't really hurt any SpacemiT P1 users but would be the expectation of those using the RTC.
- those wanting to optimise because they won't use the RTC, they can already simply unselect RTC_DRV_SPACEMIT_P1 or set it to m.
Quoted 34 lines
I haven't done any testing on this but it looks fine to me.
Acked-by Alex Elder <[email protected]>I think it's a small change worth merging. I don't think doing so does any harm. Your call or course, Alexandre.
-Alex
Quoted 23 lines
Quoted 22 lines
Signed-off-by Troy Mitchell <[email protected]>--- drivers/rtc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/Kconfig +1
-1@@ -410,7 +410,7 @@ config RTC_DRV_SPACEMIT_P1 tristate "SpacemiT P1 RTC" depends on ARCH_SPACEMIT || COMPILE_TEST depends on MFD_SPACEMIT_P1 - default MFD_SPACEMIT_P1 + default m if MFD_SPACEMIT_P1 help Enable support for the RTC function in the SpacemiT P1 PMIC. This driver can also be built as a module, which will be calledSignature · 2 lines
-- 2.52.0
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH v4 3/3] rtc: spacemit: default module when MFD_SPACEMIT_P1 is enabled
Quoted 23 lines · Alexandre Belloni
Quoted 9 lines · Alex Elder
Quoted 8 lines · Alexandre Belloni
Quoted 6 lines · Troy Mitchell
The RTC driver defaulted to the same value as
MFD_SPACEMIT_P1, which caused it to be built-in automatically whenever the PMIC support was set to y.This is not always desirable, as the RTC function is not required on all platforms using the SpacemiT P1 PMIC.
Quoted 7 lines
Quoted 2 lines
But then, can't people simply change the config? I don't feel like this is an improvement.
It's not an improvement for people who want to use the SpacemiT P1 PMIC, but it's an improvement for all the other RISC-V builds using "defconfig" that would rather have that support be modular to avoid needlessly consuming resources.
But then, wouldn't
MFD_SPACEMIT_P1be simply not set or set to m ? So this doesn't have any impact on other RISC-V builds while it makes people using the SpacemiT P1 PMIC jump through hoops to be able to use the RTC as this is a very uncommon way to set default values.
Quoted 6 lines
My point is:
- other RISC-V platforms would simply not selectMFD_SPACEMIT_P1or haveMFD_SPACEMIT_P1set to m
- havingRTC_DRV_SPACEMIT_P1built-in by default whenMFD_SPACEMIT_P1is built-in doesn't really hurt any SpacemiT P1 users but would be the expectation of those using the RTC.
The "hurt" isn't about P1 users, it's about everyone else.
Quoted 2 lines
- those wanting to optimise because they won't use the RTC, they can already simply unselect
RTC_DRV_SPACEMIT_P1or set it to m.
The purpose is to make the driver a module (not built-in) when "defconfig" is used (without the need for any Kconfig fragments to unselect things).
In arch/riscv/configs/defconfig, we have this:
CONFIG_ARCH_SPACEMIT=y
In drivers/mfd/Kconfig b/drivers/mfd/Kconfig, we have this (added by patch 2 in this series):
config MFD_SPACEMIT_P1
default m if ARCH_SPACEMIT
So when using defconfig (alone), MFD_SPACEMIT_P1 is set to m, to benefit non-SpacemiT RISC-V platforms.
This patch is trying to do the same thing for the RTC, i.e. having RTC_DRV_SPACEMIT_P1 be defined as a module by default.
I think you understand.
-Alex
Quoted 34 lines
Quoted 33 lines
I haven't done any testing on this but it looks fine to me.
Acked-by Alex Elder <[email protected]>I think it's a small change worth merging. I don't think doing so does any harm. Your call or course, Alexandre.
-Alex
Quoted 23 lines
Quoted 22 lines
Signed-off-by Troy Mitchell <[email protected]>--- drivers/rtc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/Kconfig +1
-1@@ -410,7 +410,7 @@ config RTC_DRV_SPACEMIT_P1 tristate "SpacemiT P1 RTC" depends on ARCH_SPACEMIT || COMPILE_TEST depends on MFD_SPACEMIT_P1 - default MFD_SPACEMIT_P1 + default m if MFD_SPACEMIT_P1 help Enable support for the RTC function in the SpacemiT P1 PMIC. This driver can also be built as a module, which will be calledSignature · 2 lines
-- 2.52.0
Alexandre Belloni
maintainerRe: [PATCH v4 3/3] rtc: spacemit: default module when MFD_SPACEMIT_P1 is enabled
Quoted 50 lines · Alex Elder
Quoted 23 lines · Alexandre Belloni
Quoted 9 lines · Alex Elder
Quoted 8 lines · Alexandre Belloni
Quoted 6 lines · Troy Mitchell
The RTC driver defaulted to the same value as
MFD_SPACEMIT_P1, which caused it to be built-in automatically whenever the PMIC support was set to y.This is not always desirable, as the RTC function is not required on all platforms using the SpacemiT P1 PMIC.
Quoted 7 lines
Quoted 2 lines
But then, can't people simply change the config? I don't feel like this is an improvement.
It's not an improvement for people who want to use the SpacemiT P1 PMIC, but it's an improvement for all the other RISC-V builds using "defconfig" that would rather have that support be modular to avoid needlessly consuming resources.
But then, wouldn't
MFD_SPACEMIT_P1be simply not set or set to m ? So this doesn't have any impact on other RISC-V builds while it makes people using the SpacemiT P1 PMIC jump through hoops to be able to use the RTC as this is a very uncommon way to set default values.Quoted 6 lines
My point is:
- other RISC-V platforms would simply not selectMFD_SPACEMIT_P1or haveMFD_SPACEMIT_P1set to m
- havingRTC_DRV_SPACEMIT_P1built-in by default whenMFD_SPACEMIT_P1is built-in doesn't really hurt any SpacemiT P1 users but would be the expectation of those using the RTC.The "hurt" isn't about P1 users, it's about everyone else.
Quoted 2 lines
- those wanting to optimise because they won't use the RTC, they can already simply unselect
RTC_DRV_SPACEMIT_P1or set it to m.The purpose is to make the driver a module (not built-in) when "defconfig" is used (without the need for any
Kconfigfragments to unselect things).In
arch/riscv/configs/defconfig, we have this:
CONFIG_ARCH_SPACEMIT=yIn
drivers/mfd/Kconfigb/drivers/mfd/Kconfig, we have this (added by patch 2 in this series):
configMFD_SPACEMIT_P1
default m ifARCH_SPACEMIT
Quoted 8 lines
So when using defconfig (alone),
MFD_SPACEMIT_P1is set to m, to benefit non-SpacemiT RISC-V platforms.This patch is trying to do the same thing for the RTC, i.e. having
RTC_DRV_SPACEMIT_P1be defined as a module by default.I think you understand.
I'm sorry, I must be dumb but I don't understand. The current behaviour is that when MFD_SPACEMIT_P1 is m, then the default value for RTC_DRV_SPACEMIT_P1 will be m. Since patch 2 makes it exactly that way (MFD_SPACEMIT_P set to m), I don't get why it is necessary to mess with the default of RTC_DRV_SPACEMIT_P1.
The current default behaviour of RTC_DRV_SPACEMIT_P1 seems to be the correct one and the proper fix is then patch 2.
Re: [PATCH v4 3/3] rtc: spacemit: default module when MFD_SPACEMIT_P1 is enabled
Quoted 16 lines · Alexandre Belloni
Quoted 16 lines
The purpose is to make the driver a module (not built-in) when "defconfig" is used (without the need for any
Kconfigfragments to unselect things).In
arch/riscv/configs/defconfig, we have this:
CONFIG_ARCH_SPACEMIT=yIn
drivers/mfd/Kconfigb/drivers/mfd/Kconfig, we have this (added by patch 2 in this series):
configMFD_SPACEMIT_P1
default m ifARCH_SPACEMITSo when using defconfig (alone),
MFD_SPACEMIT_P1is set to m, to benefit non-SpacemiT RISC-V platforms.
Quoted 6 lines
Quoted 5 lines
This patch is trying to do the same thing for the RTC, i.e. having
RTC_DRV_SPACEMIT_P1be defined as a module by default.I think you understand.
I'm sorry, I must be dumb but I don't understand. The current behaviour
I think I'm the dumb one. I think I finally understand your point.
Quoted 4 lines
is that when
MFD_SPACEMIT_P1is m, then the default value forRTC_DRV_SPACEMIT_P1will be m. Since patch 2 makes it exactly that way (MFD_SPACEMIT_Pset to m), I don't get why it is necessary to mess with the default ofRTC_DRV_SPACEMIT_P1.
Your point is that patch has no real effect, at least not on the scenario I was talking about.
I.e., I was saying this mattered for using defconfig alone. But, as you point out, using defconfig alone gives us:
ARCH_SPACMIT=y (in defconfig)
MFD_SPACEMIT_P1=m (from patch 2)
And then, *without* this patch:
RTC_DRV_SPACEMIT_P1=MFD_SPACEMIT_P1
meaning
RTC_DRV_SPACEMIT_P1=m
And therefore there's no need for this patch to set the default to m rather than MFD_SPACEMIT_P1.
Quoted 2 lines
The current default behaviour of
RTC_DRV_SPACEMIT_P1seems to be the correct one and the proper fix is then patch 2.
Yes, now I understand. I'm sorry about my confusion.
-Alex
Troy Mitchell
reviewerRe: [PATCH v4 3/3] rtc: spacemit: default module when MFD_SPACEMIT_P1 is enabled
Quoted 41 lines · Alex Elder
Quoted 16 lines · Alexandre Belloni
Quoted 16 lines
The purpose is to make the driver a module (not built-in) when "defconfig" is used (without the need for any
Kconfigfragments to unselect things).In
arch/riscv/configs/defconfig, we have this:
CONFIG_ARCH_SPACEMIT=yIn
drivers/mfd/Kconfigb/drivers/mfd/Kconfig, we have this (added by patch 2 in this series):
configMFD_SPACEMIT_P1
default m ifARCH_SPACEMITSo when using defconfig (alone),
MFD_SPACEMIT_P1is set to m, to benefit non-SpacemiT RISC-V platforms.Quoted 6 lines
Quoted 5 lines
This patch is trying to do the same thing for the RTC, i.e. having
RTC_DRV_SPACEMIT_P1be defined as a module by default.I think you understand.
I'm sorry, I must be dumb but I don't understand. The current behaviour
I think I'm the dumb one. I think I finally understand your point.
Quoted 4 lines
is that when
MFD_SPACEMIT_P1is m, then the default value forRTC_DRV_SPACEMIT_P1will be m. Since patch 2 makes it exactly that way (MFD_SPACEMIT_Pset to m), I don't get why it is necessary to mess with the default ofRTC_DRV_SPACEMIT_P1.Your point is that patch has no real effect, at least not on the scenario I was talking about.
I.e., I was saying this mattered for using defconfig alone. But, as you point out, using defconfig alone gives us:
ARCH_SPACMIT=y (in defconfig)
MFD_SPACEMIT_P1=m (from patch 2)
Quoted 8 lines
And then, *without* this patch:
RTC_DRV_SPACEMIT_P1=MFD_SPACEMIT_P1
meaning
RTC_DRV_SPACEMIT_P1=mAnd therefore there's no need for this patch to set the default to m rather than
MFD_SPACEMIT_P1.
Thanks Alex and Alexandre for the clarification. You're absolutely right - the patch is indeed redundant since RTC_DRV_SPACEMIT_P1 already inherits the correct default value (m) through its dependency on MFD_SPACEMIT_P1.
I'll drop this patch in the next version and review the rest of the series for similar unnecessary default overrides.
- Troy
Quoted 8 lines
Quoted 4 lines
The current default behaviour of
RTC_DRV_SPACEMIT_P1seems to be the correct one and the proper fix is then patch 2.Yes, now I understand. I'm sorry about my confusion.
-Alex