clk: nuvoton: Use clk_parent_data instead and add a header file
Subsystems (2)
v3 cover clk: nuvoton: Use clk_parent_data instead and add a header file
From: Jacky Huang <[email protected]>
This set of patches addresses some of the issues that were identified in the ma35d1 clock driver.
1. The external functions referenced between the .c files in this driver should not be declared within the .c files themselves. Instead, a shared .h file should be created to reference them.
2. Update all constant hex values written in uppercase to be lowercase.
3. For the declaration of parent clocks, use struct clk_parent_data instead of a string. Due to the change in the passed arguments, replace the usage of devm_clk_hw_register_mux() with clk_hw_register_mux_parent_data() for all cases.
v3:
- Extract the unrelated parts from patch 1/3 and create another patch,
patch 2/3.
- In patch 3/3, remove the modifications about line reformatting, as they irrelevant and have no practical effect.
v2:
- In v1, all these modifications were included in a single patch, which is not ideal. In v2, there were no changes made to the patch content itself, but the different modification topics were separated into two individual patches
Jacky Huang (3):
clk: nuvoton: Add clk-ma35d1.h for driver extern functions
clk: nuvoton: Update all constant hex values to lowercase
clk: nuvoton: Use clk_parent_data instead of string for parent clock
drivers/clk/nuvoton/clk-ma35d1-divider.c | 7 +- drivers/clk/nuvoton/clk-ma35d1-pll.c | 5 +- drivers/clk/nuvoton/clk-ma35d1.c | 348 +++++++++++++++-------- drivers/clk/nuvoton/clk-ma35d1.h | 18 ++ 4 files changed, 259 insertions(+), 119 deletions(-) create mode 100644 drivers/clk/nuvoton/clk-ma35d1.h
Signature · 1 line
2.34.1
PATCH v3 1/3 clk: nuvoton: Add clk-ma35d1.h for driver extern functions
From: Jacky Huang <[email protected]>
Moved the declaration of extern functions ma35d1_reg_clk_pll() and ma35d1_reg_adc_clkdiv() from the .c files to the newly created header file clk-ma35d1.h.
--- drivers/clk/nuvoton/clk-ma35d1-divider.c | 7 ++----- drivers/clk/nuvoton/clk-ma35d1-pll.c | 5 ++--- drivers/clk/nuvoton/clk-ma35d1.c | 10 ++-------- drivers/clk/nuvoton/clk-ma35d1.h | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 drivers/clk/nuvoton/clk-ma35d1.h
drivers/clk/nuvoton/clk-ma35d1-divider.c +2 -5
@@ -9,6 +9,8 @@#include <linux/regmap.h> #include <linux/spinlock.h> +#include "clk-ma35d1.h" +struct ma35d1_adc_clk_div {struct clk_hw hw;void __iomem *reg;
@@ -20,11 +22,6 @@ struct ma35d1_adc_clk_div {spinlock_t *lock; }; -struct clk_hw *ma35d1_reg_adc_clkdiv (struct device *dev,const char *name, -struct clk_hw *parent_hw,spinlock_t *lock, -unsigned long flags,void __iomem *reg, -u8 shift,u8 width,u32 mask_bit); -static inline struct ma35d1_adc_clk_div *to_ma35d1_adc_clk_div (struct clk_hw *_hw) { return container_of(_hw, struct ma35d1_adc_clk_div, hw);
drivers/clk/nuvoton/clk-ma35d1-pll.c +2 -3
@@ -15,6 +15,8 @@#include <linux/units.h> #include <dt-bindings/clock/nuvoton,ma35d1-clk.h> +#include "clk-ma35d1.h" +/* PLL frequency limits */ #define PLL_FREF_MAX_FREQ (200 * HZ_PER_MHZ)#define PLL_FREF_MIN_FREQ (1 * HZ_PER_MHZ)
@@ -71,9 +73,6 @@ struct ma35d1_clk_pll {void __iomem *ctl2_base; }; -struct clk_hw *ma35d1_reg_clk_pll (struct device *dev,u32 id,u8 u8mode,const char *name, -struct clk_hw *parent_hw,void __iomem *base); -static inline struct ma35d1_clk_pll *to_ma35d1_clk_pll (struct clk_hw *_hw) { return container_of(_hw, struct ma35d1_clk_pll, hw);
drivers/clk/nuvoton/clk-ma35d1.c +2 -8
@@ -12,6 +12,8 @@#include <linux/spinlock.h> #include <dt-bindings/clock/nuvoton,ma35d1-clk.h> +#include "clk-ma35d1.h" +static DEFINE_SPINLOCK (ma35d1_lock);#define PLL_MAX_NUM 5
@@ -60,14 +62,6 @@ static DEFINE_SPINLOCK(ma35d1_lock);#define PLL_MODE_FRAC 1#define PLL_MODE_SS 2 -struct clk_hw *ma35d1_reg_clk_pll (struct device *dev,u32 id,u8 u8mode, -const char *name,struct clk_hw *parent_hw, -void __iomem *base); -struct clk_hw *ma35d1_reg_adc_clkdiv (struct device *dev,const char *name, -struct clk_hw *hw,spinlock_t *lock, -unsigned long flags,void __iomem *reg, -u8 shift,u8 width,u32 mask_bit); -static const struct clk_parent_data ca35clk_sel_clks[] = { { .index =0 },/* HXT */ { .index =1 },/* CAPLL */
drivers/clk/nuvoton/clk-ma35d1.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2023 Nuvoton Technology Corp. +* Author: Chi-Fang Li <[email protected]> +*/ + +#ifndef __DRV_CLK_NUVOTON_MA35D1_H +#define __DRV_CLK_NUVOTON_MA35D1_H + +struct clk_hw *ma35d1_reg_clk_pll (struct device *dev,u32 id,u8 u8mode,const char *name, +struct clk_hw *parent_hw,void __iomem *base); + +struct clk_hw *ma35d1_reg_adc_clkdiv (struct device *dev,const char *name, +struct clk_hw *parent_hw,spinlock_t *lock, +unsigned long flags,void __iomem *reg, +u8 shift,u8 width,u32 mask_bit); + +#endif /* __DRV_CLK_NUVOTON_MA35D1_H */
Signature · 1 line
2.34.1
PATCH v3 2/3 clk: nuvoton: Update all constant hex values to lowercase
In reply to Jacky HuangFrom: Jacky Huang <[email protected]>
The constant hex values used to define register offsets were written in uppercase. This patch update all these constant hex values to be lowercase.
--- drivers/clk/nuvoton/clk-ma35d1.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/clk/nuvoton/clk-ma35d1.c +16 -16
@@ -22,19 +22,19 @@ static DEFINE_SPINLOCK(ma35d1_lock);#define REG_CLK_PWRCTL 0x00#define REG_CLK_SYSCLK0 0x04#define REG_CLK_SYSCLK1 0x08 -#define REG_CLK_APBCLK0 0x0C +#define REG_CLK_APBCLK0 0x0c#define REG_CLK_APBCLK1 0x10#define REG_CLK_APBCLK2 0x14#define REG_CLK_CLKSEL0 0x18 -#define REG_CLK_CLKSEL1 0x1C +#define REG_CLK_CLKSEL1 0x1c#define REG_CLK_CLKSEL2 0x20#define REG_CLK_CLKSEL3 0x24#define REG_CLK_CLKSEL4 0x28 -#define REG_CLK_CLKDIV0 0x2C +#define REG_CLK_CLKDIV0 0x2c#define REG_CLK_CLKDIV1 0x30#define REG_CLK_CLKDIV2 0x34#define REG_CLK_CLKDIV3 0x38 -#define REG_CLK_CLKDIV4 0x3C +#define REG_CLK_CLKDIV4 0x3c#define REG_CLK_CLKOCTL 0x40#define REG_CLK_STATUS 0x50#define REG_CLK_PLL0CTL0 0x60
@@ -44,18 +44,18 @@ static DEFINE_SPINLOCK(ma35d1_lock);#define REG_CLK_PLL3CTL0 0x90#define REG_CLK_PLL3CTL1 0x94#define REG_CLK_PLL3CTL2 0x98 -#define REG_CLK_PLL4CTL0 0xA0 -#define REG_CLK_PLL4CTL1 0xA4 -#define REG_CLK_PLL4CTL2 0xA8 -#define REG_CLK_PLL5CTL0 0xB0 -#define REG_CLK_PLL5CTL1 0xB4 -#define REG_CLK_PLL5CTL2 0xB8 -#define REG_CLK_CLKDCTL 0xC0 -#define REG_CLK_CLKDSTS 0xC4 -#define REG_CLK_CDUPB 0xC8 -#define REG_CLK_CDLOWB 0xCC -#define REG_CLK_CKFLTRCTL 0xD0 -#define REG_CLK_TESTCLK 0xF0 +#define REG_CLK_PLL4CTL0 0xa0 +#define REG_CLK_PLL4CTL1 0xa4 +#define REG_CLK_PLL4CTL2 0xa8 +#define REG_CLK_PLL5CTL0 0xb0 +#define REG_CLK_PLL5CTL1 0xb4 +#define REG_CLK_PLL5CTL2 0xb8 +#define REG_CLK_CLKDCTL 0xc0 +#define REG_CLK_CLKDSTS 0xc4 +#define REG_CLK_CDUPB 0xc8 +#define REG_CLK_CDLOWB 0xcc +#define REG_CLK_CKFLTRCTL 0xd0 +#define REG_CLK_TESTCLK 0xf0#define REG_CLK_PLLCTL 0x40#define PLL_MODE_INT 0
Signature · 1 line
2.34.1
PATCH v3 3/3 clk: nuvoton: Use clk_parent_data instead of string for parent clock
In reply to Jacky HuangFrom: Jacky Huang <[email protected]>
For the declaration of parent clocks, use struct clk_parent_data instead of a string. Due to the change in the passed arguments, replace the usage of devm_clk_hw_register_mux() with clk_hw_register_mux_parent_data() for all cases.
--- drivers/clk/nuvoton/clk-ma35d1.c | 306 ++++++++++++++++++++++--------- 1 file changed, 219 insertions(+), 87 deletions(-)
drivers/clk/nuvoton/clk-ma35d1.c +219 -87
@@ -63,167 +63,298 @@ static DEFINE_SPINLOCK(ma35d1_lock);#define PLL_MODE_SS 2static const struct clk_parent_data ca35clk_sel_clks[] = { - { .index =0 },/* HXT */ - { .index =1 },/* CAPLL */ - { .index =2 }/* DDRPLL */ + { .fw_name ="hxt" , }, + { .fw_name ="capll" , }, + { .fw_name ="ddrpll" , }, }; -static const char *const sysclk0_sel_clks[] = { -"epll_div2" ,"syspll" +static const struct clk_parent_data sysclk0_sel_clks[] = { + { .fw_name ="epll_div2" , }, + { .fw_name ="syspll" , }, }; -static const char *const sysclk1_sel_clks[] = { -"hxt" ,"syspll" +static const struct clk_parent_data sysclk1_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="syspll" , }, }; -static const char *const axiclk_sel_clks[] = { -"capll_div2" ,"capll_div4" +static const struct clk_parent_data axiclk_sel_clks[] = { + { .fw_name ="capll_div2" , }, + { .fw_name ="capll_div4" , }, }; -static const char *const ccap_sel_clks[] = { -"hxt" ,"vpll" ,"apll" ,"syspll" +static const struct clk_parent_data ccap_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="vpll" , }, + { .fw_name ="apll" , }, + { .fw_name ="syspll" , }, }; -static const char *const sdh_sel_clks[] = { -"syspll" ,"apll" ,"dummy" ,"dummy" +static const struct clk_parent_data sdh_sel_clks[] = { + { .fw_name ="syspll" , }, + { .fw_name ="apll" , }, }; -static const char *const dcu_sel_clks[] = { -"epll_div2" ,"syspll" +static const struct clk_parent_data dcu_sel_clks[] = { + { .fw_name ="epll_div2" , }, + { .fw_name ="syspll" , }, }; -static const char *const gfx_sel_clks[] = { -"epll" ,"syspll" +static const struct clk_parent_data gfx_sel_clks[] = { + { .fw_name ="epll" , }, + { .fw_name ="syspll" , }, }; -static const char *const dbg_sel_clks[] = { -"hirc" ,"syspll" +static const struct clk_parent_data dbg_sel_clks[] = { + { .fw_name ="hirc" , }, + { .fw_name ="syspll" , }, }; -static const char *const timer0_sel_clks[] = { -"hxt" ,"lxt" ,"pclk0" ,"dummy" ,"dummy" ,"lirc" ,"dummy" ,"hirc" +static const struct clk_parent_data timer0_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk0" , }, + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="lirc" , }, + { .index =-1 , }, + { .fw_name ="hirc" , }, }; -static const char *const timer1_sel_clks[] = { -"hxt" ,"lxt" ,"pclk0" ,"dummy" ,"dummy" ,"lirc" ,"dummy" ,"hirc" +static const struct clk_parent_data timer1_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk0" , }, + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="lirc" , }, + { .index =-1 , }, + { .fw_name ="hirc" , }, }; -static const char *const timer2_sel_clks[] = { -"hxt" ,"lxt" ,"pclk1" ,"dummy" ,"dummy" ,"lirc" ,"dummy" ,"hirc" +static const struct clk_parent_data timer2_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk1" , }, + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="lirc" , }, + { .index =-1 , }, + { .fw_name ="hirc" , }, }; -static const char *const timer3_sel_clks[] = { -"hxt" ,"lxt" ,"pclk1" ,"dummy" ,"dummy" ,"lirc" ,"dummy" ,"hirc" +static const struct clk_parent_data timer3_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk1" , }, + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="lirc" , }, + { .index =-1 , }, + { .fw_name ="hirc" , }, }; -static const char *const timer4_sel_clks[] = { -"hxt" ,"lxt" ,"pclk2" ,"dummy" ,"dummy" ,"lirc" ,"dummy" ,"hirc" +static const struct clk_parent_data timer4_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk2" , }, + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="lirc" , }, + { .index =-1 , }, + { .fw_name ="hirc" , }, }; -static const char *const timer5_sel_clks[] = { -"hxt" ,"lxt" ,"pclk2" ,"dummy" ,"dummy" ,"lirc" ,"dummy" ,"hirc" +static const struct clk_parent_data timer5_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk2" , }, + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="lirc" , }, + { .index =-1 , }, + { .fw_name ="hirc" , }, }; -static const char *const timer6_sel_clks[] = { -"hxt" ,"lxt" ,"pclk0" ,"dummy" ,"dummy" ,"lirc" ,"dummy" ,"hirc" +static const struct clk_parent_data timer6_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk0" , }, + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="lirc" , }, + { .index =-1 , }, + { .fw_name ="hirc" , }, }; -static const char *const timer7_sel_clks[] = { -"hxt" ,"lxt" ,"pclk0" ,"dummy" ,"dummy" ,"lirc" ,"dummy" ,"hirc" +static const struct clk_parent_data timer7_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk0" , }, + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="lirc" , }, + { .index =-1 , }, + { .fw_name ="hirc" , }, }; -static const char *const timer8_sel_clks[] = { -"hxt" ,"lxt" ,"pclk1" ,"dummy" ,"dummy" ,"lirc" ,"dummy" ,"hirc" +static const struct clk_parent_data timer8_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk1" , }, + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="lirc" , }, + { .index =-1 , }, + { .fw_name ="hirc" , }, }; -static const char *const timer9_sel_clks[] = { -"hxt" ,"lxt" ,"pclk1" ,"dummy" ,"dummy" ,"lirc" ,"dummy" ,"hirc" +static const struct clk_parent_data timer9_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk1" , }, + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="lirc" , }, + { .index =-1 , }, + { .fw_name ="hirc" , }, }; -static const char *const timer10_sel_clks[] = { -"hxt" ,"lxt" ,"pclk2" ,"dummy" ,"dummy" ,"lirc" ,"dummy" ,"hirc" +static const struct clk_parent_data timer10_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk2" , }, + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="lirc" , }, + { .index =-1 , }, + { .fw_name ="hirc" , }, }; -static const char *const timer11_sel_clks[] = { -"hxt" ,"lxt" ,"pclk2" ,"dummy" ,"dummy" ,"lirc" ,"dummy" ,"hirc" +static const struct clk_parent_data timer11_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk2" , }, + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="lirc" , }, + { .index =-1 , }, + { .fw_name ="hirc" , }, }; -static const char *const uart_sel_clks[] = { -"hxt" ,"sysclk1_div2" ,"dummy" ,"dummy" +static const struct clk_parent_data uart_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="sysclk1_div2" , }, }; -static const char *const wdt0_sel_clks[] = { -"dummy" ,"lxt" ,"pclk3_div4096" ,"lirc" +static const struct clk_parent_data wdt0_sel_clks[] = { + { .index =-1 , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk3_div4096" , }, + { .fw_name ="lirc" , }, }; -static const char *const wdt1_sel_clks[] = { -"dummy" ,"lxt" ,"pclk3_div4096" ,"lirc" +static const struct clk_parent_data wdt1_sel_clks[] = { + { .index =-1 , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk3_div4096" , }, + { .fw_name ="lirc" , }, }; -static const char *const wdt2_sel_clks[] = { -"dummy" ,"lxt" ,"pclk4_div4096" ,"lirc" +static const struct clk_parent_data wdt2_sel_clks[] = { + { .index =-1 , }, + { .fw_name ="lxt" , }, + { .fw_name ="pclk4_div4096" , }, + { .fw_name ="lirc" , }, }; -static const char *const wwdt0_sel_clks[] = { -"dummy" ,"dummy" ,"pclk3_div4096" ,"lirc" +static const struct clk_parent_data wwdt0_sel_clks[] = { + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="pclk3_div4096" , }, + { .fw_name ="lirc" , }, }; -static const char *const wwdt1_sel_clks[] = { -"dummy" ,"dummy" ,"pclk3_div4096" ,"lirc" +static const struct clk_parent_data wwdt1_sel_clks[] = { + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="pclk3_div4096" , }, + { .fw_name ="lirc" , }, }; -static const char *const wwdt2_sel_clks[] = { -"dummy" ,"dummy" ,"pclk4_div4096" ,"lirc" +static const struct clk_parent_data wwdt2_sel_clks[] = { + { .index =-1 , }, + { .index =-1 , }, + { .fw_name ="pclk4_div4096" , }, + { .fw_name ="lirc" , }, }; -static const char *const spi0_sel_clks[] = { -"pclk1" ,"apll" ,"dummy" ,"dummy" +static const struct clk_parent_data spi0_sel_clks[] = { + { .fw_name ="pclk1" , }, + { .fw_name ="apll" , }, }; -static const char *const spi1_sel_clks[] = { -"pclk2" ,"apll" ,"dummy" ,"dummy" +static const struct clk_parent_data spi1_sel_clks[] = { + { .fw_name ="pclk2" , }, + { .fw_name ="apll" , }, }; -static const char *const spi2_sel_clks[] = { -"pclk1" ,"apll" ,"dummy" ,"dummy" +static const struct clk_parent_data spi2_sel_clks[] = { + { .fw_name ="pclk1" , }, + { .fw_name ="apll" , }, }; -static const char *const spi3_sel_clks[] = { -"pclk2" ,"apll" ,"dummy" ,"dummy" +static const struct clk_parent_data spi3_sel_clks[] = { + { .fw_name ="pclk2" , }, + { .fw_name ="apll" , }, }; -static const char *const qspi0_sel_clks[] = { -"pclk0" ,"apll" ,"dummy" ,"dummy" +static const struct clk_parent_data qspi0_sel_clks[] = { + { .fw_name ="pclk0" , }, + { .fw_name ="apll" , }, }; -static const char *const qspi1_sel_clks[] = { -"pclk0" ,"apll" ,"dummy" ,"dummy" +static const struct clk_parent_data qspi1_sel_clks[] = { + { .fw_name ="pclk0" , }, + { .fw_name ="apll" , }, }; -static const char *const i2s0_sel_clks[] = { -"apll" ,"sysclk1_div2" ,"dummy" ,"dummy" +static const struct clk_parent_data i2s0_sel_clks[] = { + { .fw_name ="apll" , }, + { .fw_name ="sysclk1_div2" , }, }; -static const char *const i2s1_sel_clks[] = { -"apll" ,"sysclk1_div2" ,"dummy" ,"dummy" +static const struct clk_parent_data i2s1_sel_clks[] = { + { .fw_name ="apll" , }, + { .fw_name ="sysclk1_div2" , }, }; -static const char *const can_sel_clks[] = { -"apll" ,"vpll" +static const struct clk_parent_data can_sel_clks[] = { + { .fw_name ="apll" , }, + { .fw_name ="vpll" , }, }; -static const char *const cko_sel_clks[] = { -"hxt" ,"lxt" ,"hirc" ,"lirc" ,"capll_div4" ,"syspll" , -"ddrpll" ,"epll_div2" ,"apll" ,"vpll" ,"dummy" ,"dummy" , -"dummy" ,"dummy" ,"dummy" ,"dummy" +static const struct clk_parent_data cko_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, + { .fw_name ="hirc" , }, + { .fw_name ="lirc" , }, + { .fw_name ="capll_div4" , }, + { .fw_name ="syspll" , }, + { .fw_name ="ddrpll" , }, + { .fw_name ="epll_div2" , }, + { .fw_name ="apll" , }, + { .fw_name ="vpll" , }, }; -static const char *const smc_sel_clks[] = { -"hxt" ,"pclk4" +static const struct clk_parent_data smc_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="pclk4" , }, }; -static const char *const kpi_sel_clks[] = { -"hxt" ,"lxt" +static const struct clk_parent_data kpi_sel_clks[] = { + { .fw_name ="hxt" , }, + { .fw_name ="lxt" , }, };static const struct clk_div_table ip_div_table[] = {
@@ -255,11 +386,12 @@ static struct clk_hw *ma35d1_clk_mux_parent(struct device *dev, const char *namestatic struct clk_hw *ma35d1_clk_mux (struct device *dev,const char *name,void __iomem *reg,u8 shift,u8 width, -const char *const *parents,int num_parents) +const struct clk_parent_data *pdata, +int num_pdata) { -return devm_clk_hw_register_mux (dev, name, parents, num_parents, -CLK_SET_RATE_NO_REPARENT , reg, shift, - width,0 , &ma35d1_lock); +return clk_hw_register_mux_parent_data (dev, name, pdata, num_pdata, +CLK_SET_RATE_NO_REPARENT , reg, shift, + width,0 , &ma35d1_lock); } static struct clk_hw *ma35d1_clk_divider(struct device *dev, const char *name,
Signature · 1 line
2.34.1
Stephen Boyd
maintainerRe: [PATCH v3 3/3] clk: nuvoton: Use clk_parent_data instead of string for parent clock
Quoting Jacky Huang (2023-06-22 07:13:43)
Quoted 17 lines
From: Jacky Huang <[email protected]>
For the declaration of parent clocks, use struct
clk_parent_datainstead of a string. Due to the change in the passed arguments, replace the usage ofdevm_clk_hw_register_mux()withclk_hw_register_mux_parent_data()for all cases.Signed-off-by Jacky Huang <[email protected]>--- drivers/clk/nuvoton/clk-ma35d1.c | 306 ++++++++++++++++++++++--------- 1 file changed, 219 insertions(+), 87 deletions(-)drivers/clk/nuvoton/clk-ma35d1.c +0
-0
drivers/clk/nuvoton/clk-ma35d1.c static DEFINE_SPINLOCK(ma35d1_lock); · line 68
Quoted 9 lines
drivers/clk/nuvoton/clk-ma35d1.c +3
-3@@ -63,167 +63,298 @@ static DEFINE_SPINLOCK(ma35d1_lock);#define PLL_MODE_SS 2static const struct clk_parent_data ca35clk_sel_clks[] = { - { .index =0 },/* HXT */ - { .index =1 },/* CAPLL */ - { .index =2 }/* DDRPLL */ + { .fw_name ="hxt" , }, + { .fw_name ="capll" , }, + { .fw_name ="ddrpll" , },
Is there any reason why this changed from numbers to strings? It is faster to directly index vs. access the clock-names property. The preference is to use the index field and only use fw_name if we're migrating legacy clk drivers to use DT based lookups.
Re: [PATCH v3 3/3] clk: nuvoton: Use clk_parent_data instead of string for parent clock
Quoted 20 lines · Stephen Boyd
Quoting Jacky Huang (2023-06-22 07:13:43)
Quoted 19 lines
From: Jacky Huang <[email protected]>
For the declaration of parent clocks, use struct
clk_parent_datainstead of a string. Due to the change in the passed arguments, replace the usage ofdevm_clk_hw_register_mux()withclk_hw_register_mux_parent_data()for all cases.Signed-off-by Jacky Huang <[email protected]>--- drivers/clk/nuvoton/clk-ma35d1.c | 306 ++++++++++++++++++++++--------- 1 file changed, 219 insertions(+), 87 deletions(-)drivers/clk/nuvoton/clk-ma35d1.c +0
-0@@ -63,167 +63,298 @@ static DEFINE_SPINLOCK(ma35d1_lock);#define PLL_MODE_SS 2
Quoted 11 lines
drivers/clk/nuvoton/clk-ma35d1.c static DEFINE_SPINLOCK(ma35d1_lock); · line 68
Quoted 7 lines
drivers/clk/nuvoton/clk-ma35d1.c +3
-3static const struct clk_parent_data ca35clk_sel_clks[] = { - { .index =0 },/* HXT */ - { .index =1 },/* CAPLL */ - { .index =2 }/* DDRPLL */ + { .fw_name ="hxt" , }, + { .fw_name ="capll" , }, + { .fw_name ="ddrpll" , },Is there any reason why this changed from numbers to strings? It is faster to directly index vs. access the clock-names property. The preference is to use the index field and only use
fw_nameif we're migrating legacy clk drivers to use DT based lookups.
This is simply because I think strings are more readable than numbers. Since using an index is the preferred method, I will change all occurrences of ".fw_name" to ".index" and add comments to describe it.
As this patch was applied, I will create another patch relative to this one.
Best Regards,
Jacky Huang
Quoted 5 lines · Jacky Huang
From: Jacky Huang <[email protected]>
This set of patches addresses some of the issues that were identified in the ma35d1 clock driver.
I've gone ahead and applied all three now, on top of the soc/newsoc branch. If any other issues come up, please send patches relative to that.
Thanks,
Arnd
This series was applied to soc/soc.git (for-next) by Arnd Bergmann <[email protected]>:
Hello:
This series was applied to soc/soc.git (for-next)
by Arnd Bergmann <[email protected]>:
Quoted 10 lines · On Thu, 22 Jun 2023 14:13:40 +0000 you wrote:
From: Jacky Huang <[email protected]>
This set of patches addresses some of the issues that were identified in the ma35d1 clock driver.
1. The external functions referenced between the .c files in this driver should not be declared within the .c files themselves. Instead, a shared .h file should be created to reference them.
[...]
Here is the summary with links:
- [v3,1/3] clk: nuvoton: Add clk-ma35d1.h for driver extern functions
https://git.kernel.org/soc/soc/c/a5e3f37217b7 - [v3,2/3] clk: nuvoton: Update all constant hex values to lowercase https://git.kernel.org/soc/soc/c/ebd617b67543 - [v3,3/3] clk: nuvoton: Use clk_parent_data instead of string for parent clock https://git.kernel.org/soc/soc/c/f50a000b4219
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html