clk: at91: support configuring PCKx parent via DT
Subsystems (3)
cover clk: at91: support configuring PCKx parent via DT
This series extends AT91 with clock references to PCKx and PLLA/AUDIOPLL.
First patch simplifies clock table allocation. Next two update the table with missing clock pointers and IDs.
Michał Mirosław (3):
clk: at91: optimize pmc data allocation
clk: at91: allow setting PCKx parent via DT
clk: at91: sama5d2: allow setting all PMC clock parents via DT
drivers/clk/at91/at91sam9260.c | 7 +++-- drivers/clk/at91/at91sam9rl.c | 6 +++-- drivers/clk/at91/at91sam9x5.c | 6 +++-- drivers/clk/at91/pmc.c | 44 ++++++++++++-------------------- drivers/clk/at91/pmc.h | 8 ++++-- drivers/clk/at91/sama5d2.c | 12 ++++++--- drivers/clk/at91/sama5d4.c | 6 +++-- include/dt-bindings/clock/at91.h | 3 +++ 8 files changed, 52 insertions(+), 40 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/3 clk: at91: optimize pmc data allocation
Alloc whole data structure in one block. This makes the code shorter, more efficient and easier to extend in following patch.
--- drivers/clk/at91/at91sam9260.c | 2 +- drivers/clk/at91/at91sam9rl.c | 2 +- drivers/clk/at91/at91sam9x5.c | 2 +- drivers/clk/at91/pmc.c | 34 ++++++++-------------------------- drivers/clk/at91/pmc.h | 3 ++- drivers/clk/at91/sama5d2.c | 2 +- drivers/clk/at91/sama5d4.c | 2 +- 7 files changed, 15 insertions(+), 32 deletions(-)
drivers/clk/at91/at91sam9260.c +1 -1
@@ -462,7 +462,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,return ; err_free: -pmc_data_free (at91sam9260_pmc); +kfree (at91sam9260_pmc); }static void __init at91sam9260_pmc_setup (struct device_node *np)
drivers/clk/at91/at91sam9rl.c +1 -1
@@ -166,6 +166,6 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)return ; err_free: -pmc_data_free (at91sam9rl_pmc); +kfree (at91sam9rl_pmc); }CLK_OF_DECLARE_DRIVER (at91sam9rl_pmc,"atmel,at91sam9rl-pmc" , at91sam9rl_pmc_setup);
drivers/clk/at91/at91sam9x5.c +1 -1
@@ -278,7 +278,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,return ; err_free: -pmc_data_free (at91sam9x5_pmc); +kfree (at91sam9x5_pmc); }static void __init at91sam9g15_pmc_setup (struct device_node *np)
drivers/clk/at91/pmc.c +8 -26
@@ -76,48 +76,30 @@ struct clk_hw *of_clk_hw_pmc_get(struct of_phandle_args *clkspec, void *data)return ERR_PTR (-EINVAL ); } -void pmc_data_free (struct pmc_data *pmc_data) -{ -kfree (pmc_data->chws); -kfree (pmc_data->shws); -kfree (pmc_data->phws); -kfree (pmc_data->ghws); -} -struct pmc_data *pmc_data_allocate (unsigned int ncore,unsigned int nsystem,unsigned int nperiph,unsigned int ngck) { -struct pmc_data *pmc_data =kzalloc (sizeof (*pmc_data),GFP_KERNEL ); +unsigned int num_clks = ncore + nsystem + nperiph + ngck; +struct pmc_data *pmc_data; + pmc_data =kzalloc (sizeof (*pmc_data) + num_clks *sizeof (struct clk_hw *), +GFP_KERNEL );if (!pmc_data)return NULL ; pmc_data->ncore = ncore; - pmc_data->chws =kcalloc (ncore,sizeof (struct clk_hw *),GFP_KERNEL ); -if (!pmc_data->chws) - goto err; + pmc_data->chws = pmc_data->hwtable; pmc_data->nsystem = nsystem; - pmc_data->shws =kcalloc (nsystem,sizeof (struct clk_hw *),GFP_KERNEL ); -if (!pmc_data->shws) - goto err; + pmc_data->shws = pmc_data->chws + ncore; pmc_data->nperiph = nperiph; - pmc_data->phws =kcalloc (nperiph,sizeof (struct clk_hw *),GFP_KERNEL ); -if (!pmc_data->phws) - goto err; + pmc_data->phws = pmc_data->shws + nsystem; pmc_data->ngck = ngck; - pmc_data->ghws =kcalloc (ngck,sizeof (struct clk_hw *),GFP_KERNEL ); -if (!pmc_data->ghws) - goto err; + pmc_data->ghws = pmc_data->phws + nperiph;return pmc_data; - -err: -pmc_data_free (pmc_data); - -return NULL ; }#ifdef CONFIG_PM
drivers/clk/at91/pmc.h +2 -1
@@ -24,6 +24,8 @@ struct pmc_data {struct clk_hw **phws;unsigned int ngck;struct clk_hw **ghws; + +struct clk_hw *hwtable[0 ]; };struct clk_range {
@@ -95,7 +97,6 @@ struct clk_pcr_layout {#define nck (a) (a[ARRAY_SIZE(a) - 1].id + 1)struct pmc_data *pmc_data_allocate (unsigned int ncore,unsigned int nsystem,unsigned int nperiph,unsigned int ngck); -void pmc_data_free (struct pmc_data *pmc_data);int of_at91_get_clk_range (struct device_node *np,const char *propname,struct clk_range *range);
drivers/clk/at91/sama5d2.c +1 -1
@@ -350,6 +350,6 @@ static void __init sama5d2_pmc_setup(struct device_node *np)return ; err_free: -pmc_data_free (sama5d2_pmc); +kfree (sama5d2_pmc); }CLK_OF_DECLARE_DRIVER (sama5d2_pmc,"atmel,sama5d2-pmc" , sama5d2_pmc_setup);
drivers/clk/at91/sama5d4.c +1 -1
@@ -267,6 +267,6 @@ static void __init sama5d4_pmc_setup(struct device_node *np)return ; err_free: -pmc_data_free (sama5d4_pmc); +kfree (sama5d4_pmc); }CLK_OF_DECLARE_DRIVER (sama5d4_pmc,"atmel,sama5d4-pmc" , sama5d4_pmc_setup);
Signature · 1 line
2.20.1
kbuild test robot
build botRe: [PATCH 1/3] clk: at91: optimize pmc data allocation
I love your patch! Yet something to improve:
Hi "Michał,
I love your patch! Yet something to improve:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on robh/for-next abelloni/rtc-next v5.6-rc6 next-20200312] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Micha-Miros-aw/clk-at91-support-configuring-PCKx-parent-via-DT/20200317-041729 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next config: arm-at91_dt_defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 9.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=arm
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
drivers/clk/at91/at91sam9g45.c: In function 'at91sam9g45_pmc_setup':
>> drivers/clk/at91/at91sam9g45.c:213:2: error: implicit declaration of function 'pmc_data_free' [-Werror=implicit-function-declaration]
213 | pmc_data_free(at91sam9g45_pmc);
| ^~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
drivers/clk/at91/at91sam9n12.c: In function 'at91sam9n12_pmc_setup':
>> drivers/clk/at91/at91sam9n12.c:231:2: error: implicit declaration of function 'pmc_data_free' [-Werror=implicit-function-declaration]
231 | pmc_data_free(at91sam9n12_pmc);
| ^~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
drivers/clk/at91/sam9x60.c: In function 'sam9x60_pmc_setup':
>> drivers/clk/at91/sam9x60.c:302:2: error: implicit declaration of function 'pmc_data_free' [-Werror=implicit-function-declaration]
302 | pmc_data_free(sam9x60_pmc);
| ^~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +/pmc_data_free +213 drivers/clk/at91/at91sam9g45.c
12dc8d3be9d86c Alexandre Belloni 2020-01-17 92
12dc8d3be9d86c Alexandre Belloni 2020-01-17 93 static void __init at91sam9g45_pmc_setup(struct device_node *np)
12dc8d3be9d86c Alexandre Belloni 2020-01-17 94 {
12dc8d3be9d86c Alexandre Belloni 2020-01-17 95 const char *slck_name, *mainxtal_name;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 96 struct pmc_data *at91sam9g45_pmc;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 97 const char *parent_names[6];
12dc8d3be9d86c Alexandre Belloni 2020-01-17 98 struct regmap *regmap;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 99 struct clk_hw *hw;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 100 int i;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 101 bool bypass;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 102
12dc8d3be9d86c Alexandre Belloni 2020-01-17 103 i = of_property_match_string(np, "clock-names", "slow_clk");
12dc8d3be9d86c Alexandre Belloni 2020-01-17 104 if (i < 0)
12dc8d3be9d86c Alexandre Belloni 2020-01-17 105 return;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 106
12dc8d3be9d86c Alexandre Belloni 2020-01-17 107 slck_name = of_clk_get_parent_name(np, i);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 108
12dc8d3be9d86c Alexandre Belloni 2020-01-17 109 i = of_property_match_string(np, "clock-names", "main_xtal");
12dc8d3be9d86c Alexandre Belloni 2020-01-17 110 if (i < 0)
12dc8d3be9d86c Alexandre Belloni 2020-01-17 111 return;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 112 mainxtal_name = of_clk_get_parent_name(np, i);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 113
12dc8d3be9d86c Alexandre Belloni 2020-01-17 114 regmap = syscon_node_to_regmap(np);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 115 if (IS_ERR(regmap))
12dc8d3be9d86c Alexandre Belloni 2020-01-17 116 return;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 117
12dc8d3be9d86c Alexandre Belloni 2020-01-17 118 at91sam9g45_pmc = pmc_data_allocate(PMC_MAIN + 1,
12dc8d3be9d86c Alexandre Belloni 2020-01-17 119 nck(at91sam9g45_systemck),
12dc8d3be9d86c Alexandre Belloni 2020-01-17 120 nck(at91sam9g45_periphck), 0);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 121 if (!at91sam9g45_pmc)
12dc8d3be9d86c Alexandre Belloni 2020-01-17 122 return;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 123
12dc8d3be9d86c Alexandre Belloni 2020-01-17 124 bypass = of_property_read_bool(np, "atmel,osc-bypass");
12dc8d3be9d86c Alexandre Belloni 2020-01-17 125
12dc8d3be9d86c Alexandre Belloni 2020-01-17 126 hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
12dc8d3be9d86c Alexandre Belloni 2020-01-17 127 bypass);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 128 if (IS_ERR(hw))
12dc8d3be9d86c Alexandre Belloni 2020-01-17 129 goto err_free;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 130
12dc8d3be9d86c Alexandre Belloni 2020-01-17 131 hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc");
12dc8d3be9d86c Alexandre Belloni 2020-01-17 132 if (IS_ERR(hw))
12dc8d3be9d86c Alexandre Belloni 2020-01-17 133 goto err_free;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 134
12dc8d3be9d86c Alexandre Belloni 2020-01-17 135 at91sam9g45_pmc->chws[PMC_MAIN] = hw;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 136
12dc8d3be9d86c Alexandre Belloni 2020-01-17 137 hw = at91_clk_register_pll(regmap, "pllack", "mainck", 0,
12dc8d3be9d86c Alexandre Belloni 2020-01-17 138 &at91rm9200_pll_layout, &plla_characteristics);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 139 if (IS_ERR(hw))
12dc8d3be9d86c Alexandre Belloni 2020-01-17 140 goto err_free;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 141
12dc8d3be9d86c Alexandre Belloni 2020-01-17 142 hw = at91_clk_register_plldiv(regmap, "plladivck", "pllack");
12dc8d3be9d86c Alexandre Belloni 2020-01-17 143 if (IS_ERR(hw))
12dc8d3be9d86c Alexandre Belloni 2020-01-17 144 goto err_free;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 145
12dc8d3be9d86c Alexandre Belloni 2020-01-17 146 hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
12dc8d3be9d86c Alexandre Belloni 2020-01-17 147 if (IS_ERR(hw))
12dc8d3be9d86c Alexandre Belloni 2020-01-17 148 goto err_free;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 149
12dc8d3be9d86c Alexandre Belloni 2020-01-17 150 at91sam9g45_pmc->chws[PMC_UTMI] = hw;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 151
12dc8d3be9d86c Alexandre Belloni 2020-01-17 152 parent_names[0] = slck_name;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 153 parent_names[1] = "mainck";
12dc8d3be9d86c Alexandre Belloni 2020-01-17 154 parent_names[2] = "plladivck";
12dc8d3be9d86c Alexandre Belloni 2020-01-17 155 parent_names[3] = "utmick";
12dc8d3be9d86c Alexandre Belloni 2020-01-17 156 hw = at91_clk_register_master(regmap, "masterck", 4, parent_names,
12dc8d3be9d86c Alexandre Belloni 2020-01-17 157 &at91rm9200_master_layout,
12dc8d3be9d86c Alexandre Belloni 2020-01-17 158 &mck_characteristics);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 159 if (IS_ERR(hw))
12dc8d3be9d86c Alexandre Belloni 2020-01-17 160 goto err_free;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 161
12dc8d3be9d86c Alexandre Belloni 2020-01-17 162 at91sam9g45_pmc->chws[PMC_MCK] = hw;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 163
12dc8d3be9d86c Alexandre Belloni 2020-01-17 164 parent_names[0] = "plladivck";
12dc8d3be9d86c Alexandre Belloni 2020-01-17 165 parent_names[1] = "utmick";
12dc8d3be9d86c Alexandre Belloni 2020-01-17 166 hw = at91sam9x5_clk_register_usb(regmap, "usbck", parent_names, 2);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 167 if (IS_ERR(hw))
12dc8d3be9d86c Alexandre Belloni 2020-01-17 168 goto err_free;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 169
12dc8d3be9d86c Alexandre Belloni 2020-01-17 170 parent_names[0] = slck_name;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 171 parent_names[1] = "mainck";
12dc8d3be9d86c Alexandre Belloni 2020-01-17 172 parent_names[2] = "plladivck";
12dc8d3be9d86c Alexandre Belloni 2020-01-17 173 parent_names[3] = "utmick";
12dc8d3be9d86c Alexandre Belloni 2020-01-17 174 parent_names[4] = "masterck";
12dc8d3be9d86c Alexandre Belloni 2020-01-17 175 for (i = 0; i < 2; i++) {
12dc8d3be9d86c Alexandre Belloni 2020-01-17 176 char name[6];
12dc8d3be9d86c Alexandre Belloni 2020-01-17 177
12dc8d3be9d86c Alexandre Belloni 2020-01-17 178 snprintf(name, sizeof(name), "prog%d", i);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 179
12dc8d3be9d86c Alexandre Belloni 2020-01-17 180 hw = at91_clk_register_programmable(regmap, name,
12dc8d3be9d86c Alexandre Belloni 2020-01-17 181 parent_names, 5, i,
12dc8d3be9d86c Alexandre Belloni 2020-01-17 182 &at91sam9g45_programmable_layout);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 183 if (IS_ERR(hw))
12dc8d3be9d86c Alexandre Belloni 2020-01-17 184 goto err_free;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 185 }
12dc8d3be9d86c Alexandre Belloni 2020-01-17 186
12dc8d3be9d86c Alexandre Belloni 2020-01-17 187 for (i = 0; i < ARRAY_SIZE(at91sam9g45_systemck); i++) {
12dc8d3be9d86c Alexandre Belloni 2020-01-17 188 hw = at91_clk_register_system(regmap, at91sam9g45_systemck[i].n,
12dc8d3be9d86c Alexandre Belloni 2020-01-17 189 at91sam9g45_systemck[i].p,
12dc8d3be9d86c Alexandre Belloni 2020-01-17 190 at91sam9g45_systemck[i].id);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 191 if (IS_ERR(hw))
12dc8d3be9d86c Alexandre Belloni 2020-01-17 192 goto err_free;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 193
12dc8d3be9d86c Alexandre Belloni 2020-01-17 194 at91sam9g45_pmc->shws[at91sam9g45_systemck[i].id] = hw;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 195 }
12dc8d3be9d86c Alexandre Belloni 2020-01-17 196
12dc8d3be9d86c Alexandre Belloni 2020-01-17 197 for (i = 0; i < ARRAY_SIZE(at91sam9g45_periphck); i++) {
12dc8d3be9d86c Alexandre Belloni 2020-01-17 198 hw = at91_clk_register_peripheral(regmap,
12dc8d3be9d86c Alexandre Belloni 2020-01-17 199 at91sam9g45_periphck[i].n,
12dc8d3be9d86c Alexandre Belloni 2020-01-17 200 "masterck",
12dc8d3be9d86c Alexandre Belloni 2020-01-17 201 at91sam9g45_periphck[i].id);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 202 if (IS_ERR(hw))
12dc8d3be9d86c Alexandre Belloni 2020-01-17 203 goto err_free;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 204
12dc8d3be9d86c Alexandre Belloni 2020-01-17 205 at91sam9g45_pmc->phws[at91sam9g45_periphck[i].id] = hw;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 206 }
12dc8d3be9d86c Alexandre Belloni 2020-01-17 207
12dc8d3be9d86c Alexandre Belloni 2020-01-17 208 of_clk_add_hw_provider(np, of_clk_hw_pmc_get, at91sam9g45_pmc);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 209
12dc8d3be9d86c Alexandre Belloni 2020-01-17 210 return;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 211
12dc8d3be9d86c Alexandre Belloni 2020-01-17 212 err_free:12dc8d3be9d86c Alexandre Belloni 2020-01-17 @213 pmc_data_free(at91sam9g45_pmc);
:::::: The code at line 213 was first introduced by commit
:::::: 12dc8d3be9d86cccc35dcf32828d3a8e9d48e0d1 clk: at91: add at91sam9g45 pmc driver
:::::: TO: Alexandre Belloni <[email protected]> :::::: CC: Stephen Boyd <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 2/3 clk: at91: allow setting PCKx parent via DT
In reply to Michał MirosławThis exposes PROGx clocks for use in assigned-clocks DeviceTree property for selecting PCKx parent clock.
--- drivers/clk/at91/at91sam9260.c | 5 ++++- drivers/clk/at91/at91sam9rl.c | 4 +++- drivers/clk/at91/at91sam9x5.c | 4 +++- drivers/clk/at91/pmc.c | 12 ++++++++++-- drivers/clk/at91/pmc.h | 5 ++++- drivers/clk/at91/sama5d2.c | 4 +++- drivers/clk/at91/sama5d4.c | 4 +++- include/dt-bindings/clock/at91.h | 1 + 8 files changed, 31 insertions(+), 8 deletions(-)
drivers/clk/at91/at91sam9260.c +4 -1
@@ -354,7 +354,8 @@ static void __init at91sam926x_pmc_setup(struct device_node *np, at91sam9260_pmc =pmc_data_allocate (PMC_MAIN +1 ,ndck (data->sck, data->num_sck), -ndck (data->pck, data->num_pck),0 ); +ndck (data->pck, data->num_pck), +0 , data->num_progck);if (!at91sam9260_pmc)return ;
@@ -434,6 +435,8 @@ static void __init at91sam926x_pmc_setup(struct device_node *np, &at91rm9200_programmable_layout);if (IS_ERR (hw)) goto err_free; + + at91sam9260_pmc->pchws[i] = hw; }for (i =0 ; i < data->num_sck; i++) {
drivers/clk/at91/at91sam9rl.c +3 -1
@@ -89,7 +89,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np) at91sam9rl_pmc =pmc_data_allocate (PMC_MAIN +1 ,nck (at91sam9rl_systemck), -nck (at91sam9rl_periphck),0 ); +nck (at91sam9rl_periphck),0 ,2 );if (!at91sam9rl_pmc)return ;
@@ -138,6 +138,8 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np) &at91rm9200_programmable_layout);if (IS_ERR (hw)) goto err_free; + + at91sam9rl_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (at91sam9rl_systemck); i++) {
drivers/clk/at91/at91sam9x5.c +3 -1
@@ -151,7 +151,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,return ; at91sam9x5_pmc =pmc_data_allocate (PMC_MAIN +1 , -nck (at91sam9x5_systemck),31 ,0 ); +nck (at91sam9x5_systemck),31 ,0 ,2 );if (!at91sam9x5_pmc)return ;
@@ -227,6 +227,8 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np, &at91sam9x5_programmable_layout);if (IS_ERR (hw)) goto err_free; + + at91sam9x5_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (at91sam9x5_systemck); i++) {
drivers/clk/at91/pmc.c +10 -2
@@ -67,6 +67,10 @@ struct clk_hw *of_clk_hw_pmc_get(struct of_phandle_args *clkspec, void *data)if (idx < pmc_data->ngck)return pmc_data->ghws[idx];break ; +case PMC_TYPE_PROGRAMMABLE : +if (idx < pmc_data->npck) +return pmc_data->pchws[idx]; +break ;default :break ; }
@@ -77,9 +81,10 @@ struct clk_hw *of_clk_hw_pmc_get(struct of_phandle_args *clkspec, void *data) }struct pmc_data *pmc_data_allocate (unsigned int ncore,unsigned int nsystem, -unsigned int nperiph,unsigned int ngck) +unsigned int nperiph,unsigned int ngck, +unsigned int npck) { -unsigned int num_clks = ncore + nsystem + nperiph + ngck; +unsigned int num_clks = ncore + nsystem + nperiph + ngck + npck;struct pmc_data *pmc_data; pmc_data = kzalloc(sizeof(*pmc_data) + num_clks * sizeof(struct clk_hw *),
@@ -99,6 +104,9 @@ struct pmc_data *pmc_data_allocate(unsigned int ncore, unsigned int nsystem, pmc_data->ngck = ngck; pmc_data->ghws = pmc_data->phws + nperiph; + pmc_data->npck = npck; + pmc_data->pchws = pmc_data->ghws + ngck; +return pmc_data; }
drivers/clk/at91/pmc.h +4 -1
@@ -24,6 +24,8 @@ struct pmc_data {struct clk_hw **phws;unsigned int ngck;struct clk_hw **ghws; +unsigned int npck; +struct clk_hw **pchws;struct clk_hw *hwtable[0 ]; };
@@ -96,7 +98,8 @@ struct clk_pcr_layout {#define ndck (a, s) (a[s - 1].id + 1)#define nck (a) (a[ARRAY_SIZE(a) - 1].id + 1)struct pmc_data *pmc_data_allocate (unsigned int ncore,unsigned int nsystem, -unsigned int nperiph,unsigned int ngck); +unsigned int nperiph,unsigned int ngck, +unsigned int npck);int of_at91_get_clk_range (struct device_node *np,const char *propname,struct clk_range *range);
drivers/clk/at91/sama5d2.c +3 -1
@@ -169,7 +169,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np) sama5d2_pmc =pmc_data_allocate (PMC_I2S1_MUX +1 ,nck (sama5d2_systemck),nck (sama5d2_periph32ck), -nck (sama5d2_gck)); +nck (sama5d2_gck),3 );if (!sama5d2_pmc)return ;
@@ -267,6 +267,8 @@ static void __init sama5d2_pmc_setup(struct device_node *np) &sama5d2_programmable_layout);if (IS_ERR (hw)) goto err_free; + + sama5d2_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (sama5d2_systemck); i++) {
drivers/clk/at91/sama5d4.c +3 -1
@@ -142,7 +142,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np) sama5d4_pmc =pmc_data_allocate (PMC_MCK2 +1 ,nck (sama5d4_systemck), -nck (sama5d4_periph32ck),0 ); +nck (sama5d4_periph32ck),0 ,3 );if (!sama5d4_pmc)return ;
@@ -224,6 +224,8 @@ static void __init sama5d4_pmc_setup(struct device_node *np) &at91sam9x5_programmable_layout);if (IS_ERR (hw)) goto err_free; + + sama5d4_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (sama5d4_systemck); i++) {
include/dt-bindings/clock/at91.h +1 -0
@@ -12,6 +12,7 @@#define PMC_TYPE_SYSTEM 1#define PMC_TYPE_PERIPHERAL 2#define PMC_TYPE_GCK 3 +#define PMC_TYPE_PROGRAMMABLE 4#define PMC_SLOW 0#define PMC_MCK 1
Signature · 1 line
2.20.1
kbuild test robot
build botRe: [PATCH 2/3] clk: at91: allow setting PCKx parent via DT
I love your patch! Yet something to improve:
Hi "Michał,
I love your patch! Yet something to improve:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on robh/for-next abelloni/rtc-next v5.6-rc6 next-20200312] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Micha-Miros-aw/clk-at91-support-configuring-PCKx-parent-via-DT/20200317-041729 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next config: arm-at91_dt_defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 9.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=arm
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
drivers/clk/at91/at91sam9g45.c: In function 'at91sam9g45_pmc_setup':
>> drivers/clk/at91/at91sam9g45.c:118:20: error: too few arguments to function 'pmc_data_allocate'
118 | at91sam9g45_pmc = pmc_data_allocate(PMC_MAIN + 1,
| ^~~~~~~~~~~~~~~~~
In file included from drivers/clk/at91/at91sam9g45.c:8:
drivers/clk/at91/pmc.h:100:18: note: declared here
100 | struct pmc_data *pmc_data_allocate(unsigned int ncore, unsigned int nsystem,
| ^~~~~~~~~~~~~~~~~
drivers/clk/at91/at91sam9g45.c:213:2: error: implicit declaration of function 'pmc_data_free' [-Werror=implicit-function-declaration]
213 | pmc_data_free(at91sam9g45_pmc);
| ^~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
drivers/clk/at91/at91sam9n12.c: In function 'at91sam9n12_pmc_setup':
>> drivers/clk/at91/at91sam9n12.c:131:20: error: too few arguments to function 'pmc_data_allocate'
131 | at91sam9n12_pmc = pmc_data_allocate(PMC_MAIN + 1,
| ^~~~~~~~~~~~~~~~~
In file included from drivers/clk/at91/at91sam9n12.c:8:
drivers/clk/at91/pmc.h:100:18: note: declared here
100 | struct pmc_data *pmc_data_allocate(unsigned int ncore, unsigned int nsystem,
| ^~~~~~~~~~~~~~~~~
drivers/clk/at91/at91sam9n12.c:231:2: error: implicit declaration of function 'pmc_data_free' [-Werror=implicit-function-declaration]
231 | pmc_data_free(at91sam9n12_pmc);
| ^~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
drivers/clk/at91/sam9x60.c: In function 'sam9x60_pmc_setup':
>> drivers/clk/at91/sam9x60.c:185:16: error: too few arguments to function 'pmc_data_allocate'
185 | sam9x60_pmc = pmc_data_allocate(PMC_MAIN + 1,
| ^~~~~~~~~~~~~~~~~
In file included from drivers/clk/at91/sam9x60.c:8:
drivers/clk/at91/pmc.h:100:18: note: declared here
100 | struct pmc_data *pmc_data_allocate(unsigned int ncore, unsigned int nsystem,
| ^~~~~~~~~~~~~~~~~
drivers/clk/at91/sam9x60.c:302:2: error: implicit declaration of function 'pmc_data_free' [-Werror=implicit-function-declaration]
302 | pmc_data_free(sam9x60_pmc);
| ^~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +/pmc_data_allocate +118 drivers/clk/at91/at91sam9g45.c
12dc8d3be9d86c Alexandre Belloni 2020-01-17 92
12dc8d3be9d86c Alexandre Belloni 2020-01-17 93 static void __init at91sam9g45_pmc_setup(struct device_node *np)
12dc8d3be9d86c Alexandre Belloni 2020-01-17 94 {
12dc8d3be9d86c Alexandre Belloni 2020-01-17 95 const char *slck_name, *mainxtal_name;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 96 struct pmc_data *at91sam9g45_pmc;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 97 const char *parent_names[6];
12dc8d3be9d86c Alexandre Belloni 2020-01-17 98 struct regmap *regmap;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 99 struct clk_hw *hw;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 100 int i;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 101 bool bypass;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 102
12dc8d3be9d86c Alexandre Belloni 2020-01-17 103 i = of_property_match_string(np, "clock-names", "slow_clk");
12dc8d3be9d86c Alexandre Belloni 2020-01-17 104 if (i < 0)
12dc8d3be9d86c Alexandre Belloni 2020-01-17 105 return;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 106
12dc8d3be9d86c Alexandre Belloni 2020-01-17 107 slck_name = of_clk_get_parent_name(np, i);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 108
12dc8d3be9d86c Alexandre Belloni 2020-01-17 109 i = of_property_match_string(np, "clock-names", "main_xtal");
12dc8d3be9d86c Alexandre Belloni 2020-01-17 110 if (i < 0)
12dc8d3be9d86c Alexandre Belloni 2020-01-17 111 return;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 112 mainxtal_name = of_clk_get_parent_name(np, i);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 113
12dc8d3be9d86c Alexandre Belloni 2020-01-17 114 regmap = syscon_node_to_regmap(np);
12dc8d3be9d86c Alexandre Belloni 2020-01-17 115 if (IS_ERR(regmap))
12dc8d3be9d86c Alexandre Belloni 2020-01-17 116 return;
12dc8d3be9d86c Alexandre Belloni 2020-01-17 117 12dc8d3be9d86c Alexandre Belloni 2020-01-17 @118 at91sam9g45_pmc = pmc_data_allocate(PMC_MAIN + 1,
:::::: The code@line 118 was first introduced by commit
:::::: 12dc8d3be9d86cccc35dcf32828d3a8e9d48e0d1 clk: at91: add at91sam9g45 pmc driver
:::::: TO: Alexandre Belloni <[email protected]> :::::: CC: Stephen Boyd <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 3/3 clk: at91: sama5d2: allow setting all PMC clock parents via DT
In reply to Michał MirosławWe need to have clocks accessible via phandle to select them as peripheral clock parent using assigned-clock-parents in DT. PLLACK and AUDIOPLLCK were missing for sama5d2. Add them.
--- drivers/clk/at91/sama5d2.c | 6 +++++- include/dt-bindings/clock/at91.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/clk/at91/sama5d2.c +5 -1
@@ -166,7 +166,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)if (IS_ERR (regmap))return ; - sama5d2_pmc =pmc_data_allocate (PMC_I2S1_MUX +1 , + sama5d2_pmc =pmc_data_allocate (PMC_AUDIOPLLCK +1 ,nck (sama5d2_systemck),nck (sama5d2_periph32ck),nck (sama5d2_gck),3 );
@@ -202,6 +202,8 @@ static void __init sama5d2_pmc_setup(struct device_node *np)if (IS_ERR (hw)) goto err_free; + sama5d2_pmc->chws[PMC_PLLACK ] = hw; + hw =at91_clk_register_audio_pll_frac (regmap,"audiopll_fracck" ,"mainck" );if (IS_ERR (hw))
@@ -217,6 +219,8 @@ static void __init sama5d2_pmc_setup(struct device_node *np)if (IS_ERR (hw)) goto err_free; + sama5d2_pmc->chws[PMC_AUDIOPLLCK ] = hw; + regmap_sfr =syscon_regmap_lookup_by_compatible ("atmel,sama5d2-sfr" );if (IS_ERR (regmap_sfr)) regmap_sfr =NULL ;
include/dt-bindings/clock/at91.h +2 -0
@@ -21,6 +21,8 @@#define PMC_MCK2 4#define PMC_I2S0_MUX 5#define PMC_I2S1_MUX 6 +#define PMC_PLLACK 7 +#define PMC_AUDIOPLLCK 8#ifndef AT91_PMC_MOSCS #define AT91_PMC_MOSCS 0/* MOSCS Flag */
Signature · 1 line
2.20.1