at91sam9g45.c (9b031c86506cef9acae45e61339fcf9deaabb793) at91sam9g45.c (153bc1c66a8814e621ca0483098ac722be860aaf)
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/clk-provider.h>
3#include <linux/mfd/syscon.h>
4#include <linux/slab.h>
5
6#include <dt-bindings/clock/at91.h>
7
8#include "pmc.h"

--- 97 unchanged lines hidden (view full) ---

106
107 slck_name = of_clk_get_parent_name(np, i);
108
109 i = of_property_match_string(np, "clock-names", "main_xtal");
110 if (i < 0)
111 return;
112 mainxtal_name = of_clk_get_parent_name(np, i);
113
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/clk-provider.h>
3#include <linux/mfd/syscon.h>
4#include <linux/slab.h>
5
6#include <dt-bindings/clock/at91.h>
7
8#include "pmc.h"

--- 97 unchanged lines hidden (view full) ---

106
107 slck_name = of_clk_get_parent_name(np, i);
108
109 i = of_property_match_string(np, "clock-names", "main_xtal");
110 if (i < 0)
111 return;
112 mainxtal_name = of_clk_get_parent_name(np, i);
113
114 regmap = syscon_node_to_regmap(np);
114 regmap = device_node_to_regmap(np);
115 if (IS_ERR(regmap))
116 return;
117
115 if (IS_ERR(regmap))
116 return;
117
118 at91sam9g45_pmc = pmc_data_allocate(PMC_MAIN + 1,
118 at91sam9g45_pmc = pmc_data_allocate(PMC_PLLACK + 1,
119 nck(at91sam9g45_systemck),
119 nck(at91sam9g45_systemck),
120 nck(at91sam9g45_periphck), 0);
120 nck(at91sam9g45_periphck), 0, 2);
121 if (!at91sam9g45_pmc)
122 return;
123
124 bypass = of_property_read_bool(np, "atmel,osc-bypass");
125
126 hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
127 bypass);
128 if (IS_ERR(hw))

--- 9 unchanged lines hidden (view full) ---

138 &at91rm9200_pll_layout, &plla_characteristics);
139 if (IS_ERR(hw))
140 goto err_free;
141
142 hw = at91_clk_register_plldiv(regmap, "plladivck", "pllack");
143 if (IS_ERR(hw))
144 goto err_free;
145
121 if (!at91sam9g45_pmc)
122 return;
123
124 bypass = of_property_read_bool(np, "atmel,osc-bypass");
125
126 hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
127 bypass);
128 if (IS_ERR(hw))

--- 9 unchanged lines hidden (view full) ---

138 &at91rm9200_pll_layout, &plla_characteristics);
139 if (IS_ERR(hw))
140 goto err_free;
141
142 hw = at91_clk_register_plldiv(regmap, "plladivck", "pllack");
143 if (IS_ERR(hw))
144 goto err_free;
145
146 at91sam9g45_pmc->chws[PMC_PLLACK] = hw;
147
146 hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
147 if (IS_ERR(hw))
148 goto err_free;
149
150 at91sam9g45_pmc->chws[PMC_UTMI] = hw;
151
152 parent_names[0] = slck_name;
153 parent_names[1] = "mainck";

--- 23 unchanged lines hidden (view full) ---

177
178 snprintf(name, sizeof(name), "prog%d", i);
179
180 hw = at91_clk_register_programmable(regmap, name,
181 parent_names, 5, i,
182 &at91sam9g45_programmable_layout);
183 if (IS_ERR(hw))
184 goto err_free;
148 hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
149 if (IS_ERR(hw))
150 goto err_free;
151
152 at91sam9g45_pmc->chws[PMC_UTMI] = hw;
153
154 parent_names[0] = slck_name;
155 parent_names[1] = "mainck";

--- 23 unchanged lines hidden (view full) ---

179
180 snprintf(name, sizeof(name), "prog%d", i);
181
182 hw = at91_clk_register_programmable(regmap, name,
183 parent_names, 5, i,
184 &at91sam9g45_programmable_layout);
185 if (IS_ERR(hw))
186 goto err_free;
187
188 at91sam9g45_pmc->pchws[i] = hw;
185 }
186
187 for (i = 0; i < ARRAY_SIZE(at91sam9g45_systemck); i++) {
188 hw = at91_clk_register_system(regmap, at91sam9g45_systemck[i].n,
189 at91sam9g45_systemck[i].p,
190 at91sam9g45_systemck[i].id);
191 if (IS_ERR(hw))
192 goto err_free;

--- 12 unchanged lines hidden (view full) ---

205 at91sam9g45_pmc->phws[at91sam9g45_periphck[i].id] = hw;
206 }
207
208 of_clk_add_hw_provider(np, of_clk_hw_pmc_get, at91sam9g45_pmc);
209
210 return;
211
212err_free:
189 }
190
191 for (i = 0; i < ARRAY_SIZE(at91sam9g45_systemck); i++) {
192 hw = at91_clk_register_system(regmap, at91sam9g45_systemck[i].n,
193 at91sam9g45_systemck[i].p,
194 at91sam9g45_systemck[i].id);
195 if (IS_ERR(hw))
196 goto err_free;

--- 12 unchanged lines hidden (view full) ---

209 at91sam9g45_pmc->phws[at91sam9g45_periphck[i].id] = hw;
210 }
211
212 of_clk_add_hw_provider(np, of_clk_hw_pmc_get, at91sam9g45_pmc);
213
214 return;
215
216err_free:
213 pmc_data_free(at91sam9g45_pmc);
217 kfree(at91sam9g45_pmc);
214}
215/*
216 * The TCB is used as the clocksource so its clock is needed early. This means
217 * this can't be a platform driver.
218 */
219CLK_OF_DECLARE_DRIVER(at91sam9g45_pmc, "atmel,at91sam9g45-pmc",
220 at91sam9g45_pmc_setup);
218}
219/*
220 * The TCB is used as the clocksource so its clock is needed early. This means
221 * this can't be a platform driver.
222 */
223CLK_OF_DECLARE_DRIVER(at91sam9g45_pmc, "atmel,at91sam9g45-pmc",
224 at91sam9g45_pmc_setup);