clk: at91: support configuring more clocks via DT
Subsystems (3)
v4 cover clk: at91: support configuring more clocks via DT
This series extends AT91 clock support with references to PCKx and PLLA/PLLB/AUDIOPLL. This makes the DT be able to fully specify (assign) clock parents when needed.
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: allow setting all PMC clock parents via DT
drivers/clk/at91/at91rm9200.c | 12 ++++++--- drivers/clk/at91/at91sam9260.c | 13 +++++++--- drivers/clk/at91/at91sam9g45.c | 10 +++++--- drivers/clk/at91/at91sam9n12.c | 12 ++++++--- drivers/clk/at91/at91sam9rl.c | 10 +++++--- drivers/clk/at91/at91sam9x5.c | 10 +++++--- drivers/clk/at91/pmc.c | 44 ++++++++++++-------------------- drivers/clk/at91/pmc.h | 8 ++++-- drivers/clk/at91/sam9x60.c | 10 +++++--- drivers/clk/at91/sama5d2.c | 12 ++++++--- drivers/clk/at91/sama5d3.c | 10 +++++--- drivers/clk/at91/sama5d4.c | 10 +++++--- include/dt-bindings/clock/at91.h | 4 +++ 13 files changed, 106 insertions(+), 59 deletions(-)
Signature · 1 line
2.20.1
PATCH v4 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.
---
v2: rebase and update to clk/clk-at91 branch
v3: use struct_size() and C99 trailing array
as suggested by Stephen Boyd
v4: fixed sign-off
--- 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/sam9x60.c | 2 +- drivers/clk/at91/sama5d2.c | 2 +- drivers/clk/at91/sama5d4.c | 2 +- 8 files changed, 16 insertions(+), 33 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 (struct_size (pmc_data, hwtable, num_clks), +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[]; };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/sam9x60.c +1 -1
@@ -299,7 +299,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)return ; err_free: -pmc_data_free (sam9x60_pmc); +kfree (sam9x60_pmc); }/* Some clks are used for a clocksource */ CLK_OF_DECLARE (sam9x60_pmc,"microchip,sam9x60-pmc" , sam9x60_pmc_setup);
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
PATCH v4 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.
---
v2: rebase and update to clk/clk-at91 branch
v3: rebase
v4: no changes
--- drivers/clk/at91/at91rm9200.c | 6 ++++-- drivers/clk/at91/at91sam9260.c | 5 ++++- drivers/clk/at91/at91sam9g45.c | 6 ++++-- drivers/clk/at91/at91sam9n12.c | 6 ++++-- 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/sam9x60.c | 4 +++- drivers/clk/at91/sama5d2.c | 4 +++- drivers/clk/at91/sama5d3.c | 6 ++++-- drivers/clk/at91/sama5d4.c | 4 +++- include/dt-bindings/clock/at91.h | 1 + 13 files changed, 50 insertions(+), 17 deletions(-)
drivers/clk/at91/at91rm9200.c +4 -2
@@ -100,7 +100,7 @@ static void __init at91rm9200_pmc_setup(struct device_node *np) at91rm9200_pmc =pmc_data_allocate (PMC_MAIN +1 ,nck (at91rm9200_systemck), -nck (at91rm9200_periphck),0 ); +nck (at91rm9200_periphck),0 ,4 );if (!at91rm9200_pmc)return ;
@@ -159,6 +159,8 @@ static void __init at91rm9200_pmc_setup(struct device_node *np) &at91rm9200_programmable_layout);if (IS_ERR (hw)) goto err_free; + + at91rm9200_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (at91rm9200_systemck); i++) {
@@ -187,7 +189,7 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)return ; err_free: -pmc_data_free (at91rm9200_pmc); +kfree (at91rm9200_pmc); }/* * While the TCB can be used as the clocksource, the system timer is most likely
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/at91sam9g45.c +4 -2
@@ -117,7 +117,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np) at91sam9g45_pmc =pmc_data_allocate (PMC_MAIN +1 ,nck (at91sam9g45_systemck), -nck (at91sam9g45_periphck),0 ); +nck (at91sam9g45_periphck),0 ,2 );if (!at91sam9g45_pmc)return ;
@@ -182,6 +182,8 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np) &at91sam9g45_programmable_layout);if (IS_ERR (hw)) goto err_free; + + at91sam9g45_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (at91sam9g45_systemck); i++) {
@@ -210,7 +212,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)return ; err_free: -pmc_data_free (at91sam9g45_pmc); +kfree (at91sam9g45_pmc); }/* * The TCB is used as the clocksource so its clock is needed early. This means
drivers/clk/at91/at91sam9n12.c +4 -2
@@ -129,7 +129,7 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)return ; at91sam9n12_pmc =pmc_data_allocate (PMC_MAIN +1 , -nck (at91sam9n12_systemck),31 ,0 ); +nck (at91sam9n12_systemck),31 ,0 ,2 );if (!at91sam9n12_pmc)return ;
@@ -198,6 +198,8 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np) &at91sam9x5_programmable_layout);if (IS_ERR (hw)) goto err_free; + + at91sam9n12_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (at91sam9n12_systemck); i++) {
@@ -228,7 +230,7 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)return ; err_free: -pmc_data_free (at91sam9n12_pmc); +kfree (at91sam9n12_pmc); }/* * The TCB is used as the clocksource so its clock is needed early. This means
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(struct_size(pmc_data, hwtable, num_clks),
@@ -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[]; };
@@ -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/sam9x60.c +3 -1
@@ -185,7 +185,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np) sam9x60_pmc =pmc_data_allocate (PMC_MAIN +1 ,nck (sam9x60_systemck),nck (sam9x60_periphck), -nck (sam9x60_gck)); +nck (sam9x60_gck),8 );if (!sam9x60_pmc)return ;
@@ -255,6 +255,8 @@ static void __init sam9x60_pmc_setup(struct device_node *np) &sam9x60_programmable_layout);if (IS_ERR (hw)) goto err_free; + + sam9x60_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (sam9x60_systemck); i++) {
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/sama5d3.c +4 -2
@@ -127,7 +127,7 @@ static void __init sama5d3_pmc_setup(struct device_node *np) sama5d3_pmc =pmc_data_allocate (PMC_MAIN +1 ,nck (sama5d3_systemck), -nck (sama5d3_periphck),0 ); +nck (sama5d3_periphck),0 ,3 );if (!sama5d3_pmc)return ;
@@ -201,6 +201,8 @@ static void __init sama5d3_pmc_setup(struct device_node *np) &at91sam9x5_programmable_layout);if (IS_ERR (hw)) goto err_free; + + sama5d3_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (sama5d3_systemck); i++) {
@@ -231,7 +233,7 @@ static void __init sama5d3_pmc_setup(struct device_node *np)return ; err_free: -pmc_data_free (sama5d3_pmc); +kfree (sama5d3_pmc); }/* * The TCB is used as the clocksource so its clock is needed early. This means
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
Re: [PATCH v4 2/3] clk: at91: allow setting PCKx parent via DT
Quoted 4 lines · Michał Mirosław
This exposes PROGx clocks for use in assigned-clocks DeviceTree property for selecting PCKx parent clock.
Signed-off-by Michał Mirosław <[email protected]>
Quoted 353 lines
---
v2: rebase and update to clk/clk-at91 branch
v3: rebase
v4: no changes--- drivers/clk/at91/at91rm9200.c | 6 ++++-- drivers/clk/at91/at91sam9260.c | 5 ++++- drivers/clk/at91/at91sam9g45.c | 6 ++++-- drivers/clk/at91/at91sam9n12.c | 6 ++++-- 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/sam9x60.c | 4 +++- drivers/clk/at91/sama5d2.c | 4 +++- drivers/clk/at91/sama5d3.c | 6 ++++-- drivers/clk/at91/sama5d4.c | 4 +++- include/dt-bindings/clock/at91.h | 1 + 13 files changed, 50 insertions(+), 17 deletions(-)drivers/clk/at91/at91rm9200.c +4
-2@@ -100,7 +100,7 @@ static void __init at91rm9200_pmc_setup(struct device_node *np) at91rm9200_pmc =pmc_data_allocate (PMC_MAIN +1 ,nck (at91rm9200_systemck), -nck (at91rm9200_periphck),0 ); +nck (at91rm9200_periphck),0 ,4 );if (!at91rm9200_pmc)return ;@@ -159,6 +159,8 @@ static void __init at91rm9200_pmc_setup(struct device_node *np) &at91rm9200_programmable_layout);if (IS_ERR (hw)) goto err_free; + + at91rm9200_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (at91rm9200_systemck); i++) {@@ -187,7 +189,7 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)return ; err_free: -pmc_data_free (at91rm9200_pmc); +kfree (at91rm9200_pmc); }/* * While the TCB can be used as the clocksource, the system timer is most likely 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/at91sam9g45.c +4
-2@@ -117,7 +117,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np) at91sam9g45_pmc =pmc_data_allocate (PMC_MAIN +1 ,nck (at91sam9g45_systemck), -nck (at91sam9g45_periphck),0 ); +nck (at91sam9g45_periphck),0 ,2 );if (!at91sam9g45_pmc)return ;@@ -182,6 +182,8 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np) &at91sam9g45_programmable_layout);if (IS_ERR (hw)) goto err_free; + + at91sam9g45_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (at91sam9g45_systemck); i++) {@@ -210,7 +212,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)return ; err_free: -pmc_data_free (at91sam9g45_pmc); +kfree (at91sam9g45_pmc); }/* * The TCB is used as the clocksource so its clock is needed early. This means drivers/clk/at91/at91sam9n12.c +4
-2@@ -129,7 +129,7 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)return ; at91sam9n12_pmc =pmc_data_allocate (PMC_MAIN +1 , -nck (at91sam9n12_systemck),31 ,0 ); +nck (at91sam9n12_systemck),31 ,0 ,2 );if (!at91sam9n12_pmc)return ;@@ -198,6 +198,8 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np) &at91sam9x5_programmable_layout);if (IS_ERR (hw)) goto err_free; + + at91sam9n12_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (at91sam9n12_systemck); i++) {@@ -228,7 +230,7 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)return ; err_free: -pmc_data_free (at91sam9n12_pmc); +kfree (at91sam9n12_pmc); }/* * The TCB is used as the clocksource so its clock is needed early. This means 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(struct_size(pmc_data, hwtable, num_clks),@@ -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[]; };@@ -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/sam9x60.c +3
-1@@ -185,7 +185,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np) sam9x60_pmc =pmc_data_allocate (PMC_MAIN +1 ,nck (sam9x60_systemck),nck (sam9x60_periphck), -nck (sam9x60_gck)); +nck (sam9x60_gck),8 );if (!sam9x60_pmc)return ;@@ -255,6 +255,8 @@ static void __init sam9x60_pmc_setup(struct device_node *np) &sam9x60_programmable_layout);if (IS_ERR (hw)) goto err_free; + + sam9x60_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (sam9x60_systemck); i++) {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/sama5d3.c +4
-2@@ -127,7 +127,7 @@ static void __init sama5d3_pmc_setup(struct device_node *np) sama5d3_pmc =pmc_data_allocate (PMC_MAIN +1 ,nck (sama5d3_systemck), -nck (sama5d3_periphck),0 ); +nck (sama5d3_periphck),0 ,3 );if (!sama5d3_pmc)return ;@@ -201,6 +201,8 @@ static void __init sama5d3_pmc_setup(struct device_node *np) &at91sam9x5_programmable_layout);if (IS_ERR (hw)) goto err_free; + + sama5d3_pmc->pchws[i] = hw; }for (i =0 ; i <ARRAY_SIZE (sama5d3_systemck); i++) {@@ -231,7 +233,7 @@ static void __init sama5d3_pmc_setup(struct device_node *np)return ; err_free: -pmc_data_free (sama5d3_pmc); +kfree (sama5d3_pmc); }/* * The TCB is used as the clocksource so its clock is needed early. This means 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 1Signature · 1 line
2.20.1
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 3/3 clk: at91: 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. Add support for PLLACK/PLLBCK/AUDIOPLLCK clocks where available.
---
v2: rebase to clk/clk-at91 branch
v3: no changes
v4: extend to whole family
--- drivers/clk/at91/at91rm9200.c | 6 +++++- drivers/clk/at91/at91sam9260.c | 6 +++++- drivers/clk/at91/at91sam9g45.c | 4 +++- drivers/clk/at91/at91sam9n12.c | 6 +++++- drivers/clk/at91/at91sam9rl.c | 4 +++- drivers/clk/at91/at91sam9x5.c | 4 +++- drivers/clk/at91/sam9x60.c | 4 +++- drivers/clk/at91/sama5d2.c | 6 +++++- drivers/clk/at91/sama5d3.c | 4 +++- drivers/clk/at91/sama5d4.c | 4 +++- include/dt-bindings/clock/at91.h | 3 +++ 11 files changed, 41 insertions(+), 10 deletions(-)
drivers/clk/at91/at91rm9200.c +5 -1
@@ -98,7 +98,7 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)if (IS_ERR (regmap))return ; - at91rm9200_pmc =pmc_data_allocate (PMC_MAIN +1 , + at91rm9200_pmc =pmc_data_allocate (PMC_PLLBCK +1 ,nck (at91rm9200_systemck),nck (at91rm9200_periphck),0 ,4 );if (!at91rm9200_pmc)
@@ -123,12 +123,16 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)if (IS_ERR (hw)) goto err_free; + at91rm9200_pmc->chws[PMC_PLLACK ] = hw; + hw =at91_clk_register_pll (regmap,"pllbck" ,"mainck" ,1 , &at91rm9200_pll_layout, &rm9200_pll_characteristics);if (IS_ERR (hw)) goto err_free; + at91rm9200_pmc->chws[PMC_PLLBCK ] = hw; + parent_names[0 ] = slowxtal_name; parent_names[1 ] ="mainck" ; parent_names[2 ] ="pllack" ;
drivers/clk/at91/at91sam9260.c +5 -1
@@ -352,7 +352,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,if (IS_ERR (regmap))return ; - at91sam9260_pmc =pmc_data_allocate (PMC_MAIN +1 , + at91sam9260_pmc =pmc_data_allocate (PMC_PLLBCK +1 ,ndck (data->sck, data->num_sck),ndck (data->pck, data->num_pck),0 , data->num_progck);
@@ -399,12 +399,16 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,if (IS_ERR (hw)) goto err_free; + at91sam9260_pmc->chws[PMC_PLLACK ] = hw; + hw =at91_clk_register_pll (regmap,"pllbck" ,"mainck" ,1 , data->pllb_layout, data->pllb_characteristics);if (IS_ERR (hw)) goto err_free; + at91sam9260_pmc->chws[PMC_PLLBCK ] = hw; + parent_names[0 ] = slck_name; parent_names[1 ] ="mainck" ; parent_names[2 ] ="pllack" ;
drivers/clk/at91/at91sam9g45.c +3 -1
@@ -115,7 +115,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)if (IS_ERR (regmap))return ; - at91sam9g45_pmc =pmc_data_allocate (PMC_MAIN +1 , + at91sam9g45_pmc =pmc_data_allocate (PMC_PLLACK +1 ,nck (at91sam9g45_systemck),nck (at91sam9g45_periphck),0 ,2 );if (!at91sam9g45_pmc)
@@ -143,6 +143,8 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)if (IS_ERR (hw)) goto err_free; + at91sam9g45_pmc->chws[PMC_PLLACK ] = hw; + hw =at91_clk_register_utmi (regmap,NULL ,"utmick" ,"mainck" );if (IS_ERR (hw)) goto err_free;
drivers/clk/at91/at91sam9n12.c +5 -1
@@ -128,7 +128,7 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)if (IS_ERR (regmap))return ; - at91sam9n12_pmc =pmc_data_allocate (PMC_MAIN +1 , + at91sam9n12_pmc =pmc_data_allocate (PMC_PLLBCK +1 ,nck (at91sam9n12_systemck),31 ,0 ,2 );if (!at91sam9n12_pmc)return ;
@@ -162,11 +162,15 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)if (IS_ERR (hw)) goto err_free; + at91sam9n12_pmc->chws[PMC_PLLACK ] = hw; + hw =at91_clk_register_pll (regmap,"pllbck" ,"mainck" ,1 , &at91rm9200_pll_layout, &pllb_characteristics);if (IS_ERR (hw)) goto err_free; + at91sam9n12_pmc->chws[PMC_PLLBCK ] = hw; + parent_names[0 ] = slck_name; parent_names[1 ] ="mainck" ; parent_names[2 ] ="plladivck" ;
drivers/clk/at91/at91sam9rl.c +3 -1
@@ -87,7 +87,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)if (IS_ERR (regmap))return ; - at91sam9rl_pmc =pmc_data_allocate (PMC_MAIN +1 , + at91sam9rl_pmc =pmc_data_allocate (PMC_PLLACK +1 ,nck (at91sam9rl_systemck),nck (at91sam9rl_periphck),0 ,2 );if (!at91sam9rl_pmc)
@@ -105,6 +105,8 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)if (IS_ERR (hw)) goto err_free; + at91sam9rl_pmc->chws[PMC_PLLACK ] = hw; + hw =at91_clk_register_utmi (regmap,NULL ,"utmick" ,"mainck" );if (IS_ERR (hw)) goto err_free;
drivers/clk/at91/at91sam9x5.c +3 -1
@@ -150,7 +150,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,if (IS_ERR (regmap))return ; - at91sam9x5_pmc =pmc_data_allocate (PMC_MAIN +1 , + at91sam9x5_pmc =pmc_data_allocate (PMC_PLLACK +1 ,nck (at91sam9x5_systemck),31 ,0 ,2 );if (!at91sam9x5_pmc)return ;
@@ -184,6 +184,8 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,if (IS_ERR (hw)) goto err_free; + at91sam9x5_pmc->chws[PMC_PLLACK ] = hw; + hw =at91_clk_register_utmi (regmap,NULL ,"utmick" ,"mainck" );if (IS_ERR (hw)) goto err_free;
drivers/clk/at91/sam9x60.c +3 -1
@@ -182,7 +182,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)if (IS_ERR (regmap))return ; - sam9x60_pmc =pmc_data_allocate (PMC_MAIN +1 , + sam9x60_pmc =pmc_data_allocate (PMC_PLLACK +1 ,nck (sam9x60_systemck),nck (sam9x60_periphck),nck (sam9x60_gck),8 );
@@ -214,6 +214,8 @@ static void __init sam9x60_pmc_setup(struct device_node *np)if (IS_ERR (hw)) goto err_free; + sam9x60_pmc->chws[PMC_PLLACK ] = hw; + hw =sam9x60_clk_register_pll (regmap, &pmc_pll_lock,"upllck" ,"main_osc" ,1 , &upll_characteristics);if (IS_ERR (hw))
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 ;
drivers/clk/at91/sama5d3.c +3 -1
@@ -125,7 +125,7 @@ static void __init sama5d3_pmc_setup(struct device_node *np)if (IS_ERR (regmap))return ; - sama5d3_pmc =pmc_data_allocate (PMC_MAIN +1 , + sama5d3_pmc =pmc_data_allocate (PMC_PLLACK +1 ,nck (sama5d3_systemck),nck (sama5d3_periphck),0 ,3 );if (!sama5d3_pmc)
@@ -158,6 +158,8 @@ static void __init sama5d3_pmc_setup(struct device_node *np)if (IS_ERR (hw)) goto err_free; + sama5d2_pmc->chws[PMC_PLLACK ] = hw; + hw =at91_clk_register_utmi (regmap,NULL ,"utmick" ,"mainck" );if (IS_ERR (hw)) goto err_free;
drivers/clk/at91/sama5d4.c +3 -1
@@ -140,7 +140,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)if (IS_ERR (regmap))return ; - sama5d4_pmc =pmc_data_allocate (PMC_MCK2 +1 , + sama5d4_pmc =pmc_data_allocate (PMC_PLLACK +1 ,nck (sama5d4_systemck),nck (sama5d4_periph32ck),0 ,3 );if (!sama5d4_pmc)
@@ -173,6 +173,8 @@ static void __init sama5d4_pmc_setup(struct device_node *np)if (IS_ERR (hw)) goto err_free; + sama5d2_pmc->chws[PMC_PLLACK ] = hw; + hw =at91_clk_register_utmi (regmap,NULL ,"utmick" ,"mainck" );if (IS_ERR (hw)) goto err_free;
include/dt-bindings/clock/at91.h +3 -0
@@ -21,6 +21,9 @@#define PMC_MCK2 4#define PMC_I2S0_MUX 5#define PMC_I2S1_MUX 6 +#define PMC_PLLACK 7 +#define PMC_PLLBCK 8 +#define PMC_AUDIOPLLCK 8/* SAMA5D2-only, no PLLB there */ #ifndef AT91_PMC_MOSCS #define AT91_PMC_MOSCS 0/* MOSCS Flag */
Signature · 1 line
2.20.1
Alexandre Belloni
maintainerRe: [PATCH v4 3/3] clk: at91: allow setting all PMC clock parents via DT
Hi,
include/dt-bindings/clock/at91.h line 26
Quoted 11 lines · Michał Mirosław
include/dt-bindings/clock/at91.h +3
-0@@ -21,6 +21,9 @@#define PMC_MCK2 4#define PMC_I2S0_MUX 5#define PMC_I2S1_MUX 6 +#define PMC_PLLACK 7 +#define PMC_PLLBCK 8 +#define PMC_AUDIOPLLCK 8/* SAMA5D2-only, no PLLB there */
Just use 9 here because we can't know for sure that a future SoC won't have both a PLLB and audio PLL.
Quoted 6 lines
include/dt-bindings/clock/at91.h +0
-0#ifndef AT91_PMC_MOSCS #define AT91_PMC_MOSCS 0/* MOSCS Flag */ Signature · 1 line
2.20.1
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH v4 3/3] clk: at91: allow setting all PMC clock parents via DT
Quoted 16 lines · Alexandre Belloni
Hi,
include/dt-bindings/clock/at91.h line 26
Quoted 11 lines · Michał Mirosław
include/dt-bindings/clock/at91.h +3
-0@@ -21,6 +21,9 @@#define PMC_MCK2 4#define PMC_I2S0_MUX 5#define PMC_I2S1_MUX 6 +#define PMC_PLLACK 7 +#define PMC_PLLBCK 8 +#define PMC_AUDIOPLLCK 8/* SAMA5D2-only, no PLLB there */ Just use 9 here because we can't know for sure that a future SoC won't have both a PLLB and audio PLL.
Ok. I assumed that PLLB is only in old generations. Fix coming shortly.
Best Regrads,
Michał Mirosław