ARM: mxs: allow boards to select DC-DC switching clock source
Subsystems (2)
PATCH v2 1/1 ARM: mxs: allow boards to select DC-DC switching clock source
For some board designs, it might be useful to switch the DC-DC clock source to something else rather the default 24 MHz, e.g. for EMI reasons.
For this, override the mxs_power_setup_dcdc_clocksource function in your board support files.
Example:
void mxs_power_setup_dcdc_clocksource(void)
{
mxs_power_select_dcdc_clocksource(POWER_MISC_FREQSEL_20MHZ);
}---
Changes in v2:
- use a weak function approach instead of ifdef'ery as suggested by Marek Vasut
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c | 31 +++++++++++++++++++++++++++++ arch/arm/include/asm/arch-mxs/sys_proto.h | 2 ++ 2 files changed, 33 insertions(+)
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +31 -0
@@ -248,6 +248,36 @@ static void mxs_power_setup_5v_detect(void) }/** +* mxs_power_switch_dcdc_clocksource() - Switch PLL clock for DC-DC converters +* +* This function configures and then enables an alternative PLL clock source +* for the DC-DC converters. +*/ +void mxs_power_select_dcdc_clocksource (uint32_t freqsel) +{ +struct mxs_power_regs *power_regs = + (struct mxs_power_regs *)MXS_POWER_BASE ; + +/* Select clocksource for DC-DC converters */ +clrsetbits_le32 (&power_regs->hw_power_misc, +POWER_MISC_FREQSEL_MASK , + freqsel); +setbits_le32 (&power_regs->hw_power_misc, +POWER_MISC_SEL_PLLCLK ); +} + +/** +* mxs_power_setup_dcdc_clocksource() +* +* Normally, there is no need to switch DC-DC clocksource. However, boards +* can implement this function when required. +*/ +__weak void mxs_power_setup_dcdc_clocksource (void ) +{ +debug ("SPL: Using default DC-DC clocksource\n" ); +} + +/** * mxs_src_power_init() - Preconfigure the power block * * This function configures reasonable values for the DC-DC control loop
@@ -872,6 +902,7 @@ static void mxs_power_configure_power_source(void)debug ("SPL: Configuring power source\n" ); +mxs_power_setup_dcdc_clocksource ();mxs_src_power_init ();if (readl (&power_regs->hw_power_sts) &POWER_STS_VDD5V_GT_VDDIO ) {
arch/arm/include/asm/arch-mxs/sys_proto.h +2 -0
@@ -25,6 +25,8 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int));void mxs_common_spl_init (const uint32_t arg,const uint32_t *resptr,const iomux_cfg_t *iomux_setup,const unsigned int iomux_size); + +void mxs_power_select_dcdc_clocksource (uint32_t freqsel);#endif struct mxs_pair {
Signature · 1 line
2.5.0
PATCH v2 1/1 ARM: mxs: allow boards to select DC-DC switching clock source
Quoted 3 lines · Michael Heimpold
For some board designs, it might be useful to switch the DC-DC clock source to something else rather the default 24 MHz, e.g. for EMI reasons.
Can you elaborate on this ? Also, is there gonna be a user for this?
Quoted 43 lines
For this, override the
mxs_power_setup_dcdc_clocksourcefunction in your board support files.Example:
voidmxs_power_setup_dcdc_clocksource(void){ mxs_power_select_dcdc_clocksource(POWER_MISC_FREQSEL_20MHZ); }Signed-off-by Michael Heimpold <[email protected]>Cc Marek Vasut <[email protected]>Cc Otavio Salvador <[email protected]>Cc Fabio Estevam <[email protected]>---
Changes in v2:
- use a weak function approach instead of ifdef'ery as suggested by Marek Vasutarch/arm/cpu/arm926ejs/mxs/spl_power_init.c | 31 +++++++++++++++++++++++++++++ arch/arm/include/asm/arch-mxs/sys_proto.h | 2 ++ 2 files changed, 33 insertions(+)(quoted diff) +0
-0
b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.cindex 1972de8..64e215c 100644arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +1
-0@@ -248,6 +248,36 @@ static void mxs_power_setup_5v_detect(void) }/** +* mxs_power_switch_dcdc_clocksource() - Switch PLL clock for DC-DC converters + *
+ * This function configures and then enables an alternative PLL clock source + * for the DC-DC converters.
+ */arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +5
-0+void mxs_power_select_dcdc_clocksource (uint32_t freqsel) +{ +struct mxs_power_regs *power_regs = + (struct mxs_power_regs *)MXS_POWER_BASE ; +
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c static void mxs_power_setup_5v_detect(void) · line 270
Quoted 10 lines
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +10
-0+/* Select clocksource for DC-DC converters */ +clrsetbits_le32 (&power_regs->hw_power_misc, +POWER_MISC_FREQSEL_MASK , + freqsel); +setbits_le32 (&power_regs->hw_power_misc, +POWER_MISC_SEL_PLLCLK ); +} + +/** +* mxs_power_setup_dcdc_clocksource()
Please make sure this is compatible with kerneldoc.
Quoted 27 lines
+ * Normally, there is no need to switch DC-DC clocksource. However, boards
+ * can implement this function when required.
+ */arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +7
-0+__weak void mxs_power_setup_dcdc_clocksource (void ) +{ +debug ("SPL: Using default DC-DC clocksource\n" ); +} + +/** * mxs_src_power_init() - Preconfigure the power block * * This function configures reasonable values for the DC-DC control loop @@ -872,6 +902,7 @@ static void mxs_power_configure_power_source(void)debug ("SPL: Configuring power source\n" ); +mxs_power_setup_dcdc_clocksource ();mxs_src_power_init ();if (readl (&power_regs->hw_power_sts) &POWER_STS_VDD5V_GT_VDDIO ) {(quoted diff) +0
-0
b/arch/arm/include/asm/arch-mxs/sys_proto.hindex 20ff101..4160e43 100644arch/arm/include/asm/arch-mxs/sys_proto.h +0
-0@@ -25,6 +25,8 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int),int (*cd)(int)); void mxs_common_spl_init(const
uint32_targ, constuint32_t*resptr, constiomux_cfg_t*iomux_setup,
arch/arm/include/asm/arch-mxs/sys_proto.h int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int)); · line 29
Quoted 3 lines
arch/arm/include/asm/arch-mxs/sys_proto.h +2
-0const unsigned int iomux_size); + +void mxs_power_select_dcdc_clocksource (uint32_t freqsel);
This function does not need to be exported if it's __weak I believe.
PATCH v2 1/1 ARM: mxs: allow boards to select DC-DC switching clock source
Hi Marek,
Am Saturday 12 December 2015, 02:42:47 schrieb Marek Vasut:
Quoted 6 lines · Michael Heimpold
Quoted 3 lines
For some board designs, it might be useful to switch the DC-DC clock source to something else rather the default 24 MHz, e.g. for EMI reasons.
Can you elaborate on this ? Also, is there gonna be a user for this?
Sure. Every DC-DC switching frequency also generates some harmonics. On usual board design, this is not a huge problem, but on our I2SE Duckbill EnOcean devices, the EnOcean transceiver sits very close to the i.MX because of stacked PCBs. Our hardware guys measured, that the harmonics overlaps a little bit with the EnOcean spectrum. Changing the DC-DC frequency results in others harmonics, which do not interfere anymore.
I already sent a patch for adding Duckbill support and I'm preparing a v2 which would include this topic, so this would be the first user of this feature.
Quoted 56 lines
Quoted 56 lines
For this, override the
mxs_power_setup_dcdc_clocksourcefunction in your board support files.Example:
voidmxs_power_setup_dcdc_clocksource(void)
{mxs_power_select_dcdc_clocksource(POWER_MISC_FREQSEL_20MHZ);}
Signed-off-by Michael Heimpold <[email protected]>Cc Marek Vasut <[email protected]>Cc Otavio Salvador <[email protected]>Cc Fabio Estevam <[email protected]>---
Changes in v2:
- use a weak function approach instead of ifdef'ery as suggestedby Marek Vasut
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c | 31+++++++++++++++++++++++++++++
arch/arm/include/asm/arch-mxs/sys_proto.h| 2 ++
2 files changed, 33 insertions(+)(quoted diff) +0
-0
b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.cindex 1972de8..64e215c 100644arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +1
-0@@ -248,6 +248,36 @@ static void mxs_power_setup_5v_detect(void) }/** +* mxs_power_switch_dcdc_clocksource() - Switch PLL clock for DC-DC converters + *
+ * This function configures and then enables an alternative PLL clock source + * for the DC-DC converters.
+ */arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +9
-0+void mxs_power_select_dcdc_clocksource (uint32_t freqsel) +{ +struct mxs_power_regs *power_regs = + (struct mxs_power_regs *)MXS_POWER_BASE ; + +/* Select clocksource for DC-DC converters */ +clrsetbits_le32 (&power_regs->hw_power_misc, +POWER_MISC_FREQSEL_MASK , + freqsel);
Quoted 8 lines
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c static void mxs_power_setup_5v_detect(void) · line 270
Quoted 6 lines
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +6
-0+setbits_le32 (&power_regs->hw_power_misc, +POWER_MISC_SEL_PLLCLK ); +} + +/** +* mxs_power_setup_dcdc_clocksource() Please make sure this is compatible with kerneldoc.
Ah, yes. Will do in v3.
Quoted 34 lines
Quoted 34 lines
+ * Normally, there is no need to switch DC-DC clocksource. However, boards
+ * can implement this function when required.
+ */arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +7
-0+__weak void mxs_power_setup_dcdc_clocksource (void ) +{ +debug ("SPL: Using default DC-DC clocksource\n" ); +} + +/** * mxs_src_power_init() - Preconfigure the power block * * This function configures reasonable values for the DC-DC control loop @@ -872,6 +902,7 @@ static void mxs_power_configure_power_source(void)debug ("SPL: Configuring power source\n" ); +mxs_power_setup_dcdc_clocksource ();mxs_src_power_init ();arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +0
-0if (readl (&power_regs->hw_power_sts) &POWER_STS_VDD5V_GT_VDDIO ) {(quoted diff) +0
-0
b/arch/arm/include/asm/arch-mxs/sys_proto.hindex 20ff101..4160e43 100644arch/arm/include/asm/arch-mxs/sys_proto.h +0
-0@@ -25,6 +25,8 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int),int (*cd)(int)); void mxs_common_spl_init(const
uint32_targ, constuint32_t*resptr, constiomux_cfg_t*iomux_setup,
Quoted 6 lines
arch/arm/include/asm/arch-mxs/sys_proto.h int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int)); · line 29
Quoted 4 lines
arch/arm/include/asm/arch-mxs/sys_proto.h +2
-0const unsigned int iomux_size); + +void mxs_power_select_dcdc_clocksource (uint32_t freqsel);This function does not need to be exported if it's
__weakI believe.
mxs_power_setup_dcdc_clocksource is the weak function, not mxs_power_select_dcdc_clocksource so I think this is needed.
Regards,
Michael
PATCH v2 1/1 ARM: mxs: allow boards to select DC-DC switching clock source
Quoted 1 line · Michael Heimpold
Hi Marek,
Hi!
Quoted 8 lines
Am Saturday 12 December 2015, 02:42:47 schrieb Marek Vasut:
Quoted 6 lines · Michael Heimpold
Quoted 3 lines
For some board designs, it might be useful to switch the DC-DC clock source to something else rather the default 24 MHz, e.g. for EMI reasons.
Can you elaborate on this ? Also, is there gonna be a user for this?
Quoted 10 lines
Sure. Every DC-DC switching frequency also generates some harmonics. On usual board design, this is not a huge problem, but on our I2SE Duckbill EnOcean devices, the EnOcean transceiver sits very close to the i.MX because of stacked PCBs. Our hardware guys measured, that the harmonics overlaps a little bit with the EnOcean spectrum. Changing the DC-DC frequency results in others harmonics, which do not interfere anymore.
I already sent a patch for adding Duckbill support and I'm preparing a v2 which would include this topic, so this would be the first user of this feature.
Ah, thanks for the detailed explanation, got it.
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
For this, override the
mxs_power_setup_dcdc_clocksourcefunction in your board support files.Example:
voidmxs_power_setup_dcdc_clocksource(void)
{mxs_power_select_dcdc_clocksource(POWER_MISC_FREQSEL_20MHZ);}
Signed-off-by Michael Heimpold <[email protected]>Cc Marek Vasut <[email protected]>Cc Otavio Salvador <[email protected]>Cc Fabio Estevam <[email protected]>---
Changes in v2:
- use a weak function approach instead of ifdef'ery as suggestedby Marek Vasut
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c | 31+++++++++++++++++++++++++++++
arch/arm/include/asm/arch-mxs/sys_proto.h| 2 ++
2 files changed, 33 insertions(+)(quoted diff) +0
-0
b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.cindex 1972de8..64e215c 100644arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +0
-0@@ -248,6 +248,36 @@ static void mxs_power_setup_5v_detect(void) }/**
Quoted 7 lines
Quoted 7 lines
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c
Quoted 7 lines
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +1
-0+* mxs_power_switch_dcdc_clocksource() - Switch PLL clock for DC-DC converters + *
+ * This function configures and then enables an alternative PLL clock source + * for the DC-DC converters.
+ */arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +2
-0+void mxs_power_select_dcdc_clocksource (uint32_t freqsel) +{
Looks like the comment and name of the function do not match here ("select" vs "switch").
Quoted 18 lines
Quoted 7 lines
Quoted 7 lines
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +7
-0+struct mxs_power_regs *power_regs = + (struct mxs_power_regs *)MXS_POWER_BASE ; + +/* Select clocksource for DC-DC converters */ +clrsetbits_le32 (&power_regs->hw_power_misc, +POWER_MISC_FREQSEL_MASK , + freqsel);Quoted 8 lines
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c static void mxs_power_setup_5v_detect(void) · line 270
Quoted 6 lines
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +6
-0+setbits_le32 (&power_regs->hw_power_misc, +POWER_MISC_SEL_PLLCLK ); +} + +/** +* mxs_power_setup_dcdc_clocksource() Please make sure this is compatible with kerneldoc.
Ah, yes. Will do in v3.
Quoted 7 lines
Quoted 7 lines
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c static void mxs_power_setup_5v_detect(void) · line 277
Quoted 7 lines
+ * Normally, there is no need to switch DC-DC clocksource. However, boards
+ * can implement this function when required.
+ */arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +3
-0+__weak void mxs_power_setup_dcdc_clocksource (void ) +{ +debug ("SPL: Using default DC-DC clocksource\n" );
Shouldn't this call the mxs_power_select_dcdc_clocksource() then somehow ?
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +4
-0+} + +/** * mxs_src_power_init() - Preconfigure the power block * * This function configures reasonable values for the DC-DC control loop @@ -872,6 +902,7 @@ static void mxs_power_configure_power_source(void)debug ("SPL: Configuring power source\n" ); +mxs_power_setup_dcdc_clocksource ();mxs_src_power_init ();arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +0
-0if (readl (&power_regs->hw_power_sts) &POWER_STS_VDD5V_GT_VDDIO ) {(quoted diff) +0
-0
b/arch/arm/include/asm/arch-mxs/sys_proto.hindex 20ff101..4160e43 100644 ---a/arch/arm/include/asm/arch-mxs/sys_proto.h+++b/arch/arm/include/asm/arch-mxs/sys_proto.h(quoted diff) +0
-0@@ -25,6 +25,8 @@ int mxsmmc_initialize(bd_t *bis, int id, int(*wp)(int), int (*cd)(int)); void mxs_common_spl_init(const
uint32_targ, constuint32_t*resptr, constiomux_cfg_t*iomux_setup,const unsigned int
iomux_size);
Quoted 7 lines
Quoted 4 lines
arch/arm/include/asm/arch-mxs/sys_proto.h int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int)); · line 29
Quoted 2 lines
arch/arm/include/asm/arch-mxs/sys_proto.h +2
-0+ +void mxs_power_select_dcdc_clocksource (uint32_t freqsel);This function does not need to be exported if it's
__weakI believe.
mxs_power_setup_dcdc_clocksourceis the weak function, notmxs_power_select_dcdc_clocksourceso I think this is needed.
So the user is supposed to call this function from the board code, right?
Best regards,
Marek Vasut