]> git.baikalelectronics.ru Git - kernel.git/commitdiff
clk: at91: allow setting PCKx parent via DT
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>
Mon, 4 May 2020 22:37:56 +0000 (00:37 +0200)
committerStephen Boyd <sboyd@kernel.org>
Wed, 27 May 2020 03:22:43 +0000 (20:22 -0700)
This exposes PROGx clocks for use in assigned-clocks DeviceTree property
for selecting PCKx parent clock.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Link: https://lkml.kernel.org/r/0054532c00163ddf405dad658b32f0d7d97fcc8e.1588630999.git.mirq-linux@rere.qmqm.pl
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
13 files changed:
drivers/clk/at91/at91rm9200.c
drivers/clk/at91/at91sam9260.c
drivers/clk/at91/at91sam9g45.c
drivers/clk/at91/at91sam9n12.c
drivers/clk/at91/at91sam9rl.c
drivers/clk/at91/at91sam9x5.c
drivers/clk/at91/pmc.c
drivers/clk/at91/pmc.h
drivers/clk/at91/sam9x60.c
drivers/clk/at91/sama5d2.c
drivers/clk/at91/sama5d3.c
drivers/clk/at91/sama5d4.c
include/dt-bindings/clock/at91.h

index 6f4e1151553d25fe797d1278582e67c484bfdccb..8da88e9a95d82524c2ea9cd55d56789c2bd7f60f 100644 (file)
@@ -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++) {
index 946f03a09858c2b5f9fd3dd0784d62d0dbc69114..7e5ff252fffce49c516886c41a55dbb6f5b9e997 100644 (file)
@@ -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++) {
index 53e8252b8a63be33b7bccfaee6da5725d2f7f8c3..5d18eb04c2184d509dae11f84c29cd9035cb632f 100644 (file)
@@ -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++) {
index f3ae1cd3cb8d7c27c6d8c55d20f1853224c87d71..3a2564c2f724d00cfa2171b6af8b8844dd3e8b96 100644 (file)
@@ -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++) {
index cc739d214ae34864b140a33552431ebfaf9129eb..bcf07f6a0e0ee47bddaf39162024abf77fa96c77 100644 (file)
@@ -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++) {
index aac99d6995689a1da4cb2a41e08169126626bbaa..f13756b407e2c303b1ddf762e19cfded68325bc7 100644 (file)
@@ -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++) {
index ac8a76ca0266b0a680a2b1a51c5a91d8a882d0e9..20ee9dccee78792678a6839b51d5aec95525d7f8 100644 (file)
@@ -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;
 }
 
index fc3ef772b9d9f8845b382cb790ef6b374dcd94f0..df616f2937e70586ab5cc3ee28fe86566ebe07a9 100644 (file)
@@ -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);
index a7d4f648db264668ff9eb4c5228930fbc7469407..db14e0427c7fa527eaf3fc8881f69d7e1ee31b41 100644 (file)
@@ -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++) {
index a86b42e40aef8a3b7fef28213828ed5ddc32213f..fa9f6126c158745489ae5b118c9fe1cb05ad6d70 100644 (file)
@@ -170,7 +170,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;
 
@@ -268,6 +268,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++) {
index 914e6f225510b040542888882446b7884a2fd2b3..507eef6797f1b7ce2a3f637090a2fdc518b4dc14 100644 (file)
@@ -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++) {
index 4ca9a46195006f6b3e05a3de5971cb3bc296c002..80692902b4e41ac8dc20e0fc9205a7891cbb153b 100644 (file)
@@ -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++) {
index 38b5554153c800374aa23b289f05dc89e5d45c38..c3f4aa6a2d296b695142513b1022d57cefc88725 100644 (file)
@@ -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