76 static void __iomem *syscon_vbase;
102 #define to_syscon(_hw) container_of(_hw, struct clk_syscon, hw)
114 unsigned long iflags;
124 spin_unlock_irqrestore(&syscon_resetreg_lock, iflags);
128 static void syscon_block_reset_disable(
struct clk_syscon *sclk)
130 unsigned long iflags;
140 spin_unlock_irqrestore(&syscon_resetreg_lock, iflags);
144 static int syscon_clk_prepare(
struct clk_hw *
hw)
150 syscon_block_reset_disable(sclk);
154 static void syscon_clk_unprepare(
struct clk_hw *hw)
163 syscon_block_reset_enable(sclk);
166 static int syscon_clk_enable(
struct clk_hw *hw)
181 static void syscon_clk_disable(
struct clk_hw *hw)
197 static int syscon_clk_is_enabled(
struct clk_hw *hw)
212 static u16 syscon_get_perf(
void)
222 syscon_clk_recalc_rate(
struct clk_hw *hw,
223 unsigned long parent_rate)
226 u16 perf = syscon_get_perf();
290 syscon_clk_round_rate(
struct clk_hw *hw,
unsigned long rate,
291 unsigned long *
prate)
298 if (rate <= 13000000)
300 if (rate <= 52000000)
302 if (rate <= 104000000)
307 static int syscon_clk_set_rate(
struct clk_hw *hw,
unsigned long rate,
308 unsigned long parent_rate)
338 static const struct clk_ops syscon_clk_ops = {
339 .prepare = syscon_clk_prepare,
340 .unprepare = syscon_clk_unprepare,
341 .enable = syscon_clk_enable,
342 .disable = syscon_clk_disable,
343 .is_enabled = syscon_clk_is_enabled,
344 .recalc_rate = syscon_clk_recalc_rate,
345 .round_rate = syscon_clk_round_rate,
346 .set_rate = syscon_clk_set_rate,
351 const char *parent_name,
unsigned long flags,
359 struct clk_init_data
init;
363 pr_err(
"could not allocate syscon clock %s\n",
368 init.ops = &syscon_clk_ops;
370 init.parent_names = (parent_name ? &parent_name :
NULL);
371 init.num_parents = (parent_name ? 1 : 0);
372 sclk->hw.init = &
init;
373 sclk->hw_ctrld = hw_ctrld;
376 sclk->res_reg = res_reg;
377 sclk->res_bit = res_bit;
378 sclk->en_reg = en_reg;
379 sclk->en_bit = en_bit;
380 sclk->clk_val = clk_val;
399 #define to_mclk(_hw) container_of(_hw, struct clk_mclk, hw)
401 static int mclk_clk_prepare(
struct clk_hw *hw)
429 mclk_clk_recalc_rate(
struct clk_hw *hw,
430 unsigned long parent_rate)
432 u16 perf = syscon_get_perf();
492 mclk_clk_round_rate(
struct clk_hw *hw,
unsigned long rate,
493 unsigned long *prate)
495 if (rate <= 18900000)
497 if (rate <= 20800000)
499 if (rate <= 23100000)
501 if (rate <= 26000000)
503 if (rate <= 29700000)
505 if (rate <= 34700000)
507 if (rate <= 41600000)
513 static int mclk_clk_set_rate(
struct clk_hw *hw,
unsigned long rate,
514 unsigned long parent_rate)
557 static const struct clk_ops mclk_ops = {
558 .prepare = mclk_clk_prepare,
559 .recalc_rate = mclk_clk_recalc_rate,
560 .round_rate = mclk_clk_round_rate,
561 .set_rate = mclk_clk_set_rate,
564 static struct clk *
__init
565 mclk_clk_register(
struct device *dev,
const char *name,
566 const char *parent_name,
bool is_mspro)
570 struct clk_init_data
init;
574 pr_err(
"could not allocate MMC/SD clock %s\n",
579 init.ops = &mclk_ops;
581 init.parent_names = (parent_name ? &parent_name :
NULL);
582 init.num_parents = (parent_name ? 1 : 0);
583 mclk->hw.init = &
init;
584 mclk->is_mspro = is_mspro;
619 CLK_IS_ROOT, 13000000);
623 CLK_IS_ROOT, 208000000);
635 clk = syscon_clk_register(
NULL,
"cpu_clk",
"app_208_clk", 0,
true,
639 clk = syscon_clk_register(
NULL,
"dmac_clk",
"app_52_clk", 0,
true,
644 clk = syscon_clk_register(
NULL,
"fsmc_clk",
"app_52_clk", 0,
false,
649 clk = syscon_clk_register(
NULL,
"xgam_clk",
"app_52_clk", 0,
true,
654 clk = syscon_clk_register(
NULL,
"semi_clk",
"app_104_clk", 0,
false,
661 clk = syscon_clk_register(
NULL,
"ahb_subsys_clk",
"app_52_clk", 0,
true,
665 clk = syscon_clk_register(
NULL,
"intcon_clk",
"ahb_subsys_clk", 0,
false,
671 clk = syscon_clk_register(
NULL,
"emif_clk",
"ahb_subsys_clk", 0,
false,
678 clk = syscon_clk_register(
NULL,
"fast_clk",
"app_26_clk", 0,
true,
682 clk = syscon_clk_register(
NULL,
"i2c0_p_clk",
"fast_clk", 0,
false,
687 clk = syscon_clk_register(
NULL,
"i2c1_p_clk",
"fast_clk", 0,
false,
692 clk = syscon_clk_register(
NULL,
"mmc_p_clk",
"fast_clk", 0,
false,
697 clk = syscon_clk_register(
NULL,
"spi_p_clk",
"fast_clk", 0,
false,
706 clk = syscon_clk_register(
NULL,
"slow_clk",
"pll13", 0,
true,
710 clk = syscon_clk_register(
NULL,
"uart0_clk",
"slow_clk", 0,
false,
717 clk = syscon_clk_register(
NULL,
"gpio_clk",
"slow_clk", 0,
false,
722 clk = syscon_clk_register(
NULL,
"keypad_clk",
"slow_clk", 0,
false,
727 clk = syscon_clk_register(
NULL,
"rtc_clk",
"slow_clk", 0,
true,
732 clk = syscon_clk_register(
NULL,
"app_tmr_clk",
"slow_clk", 0,
false,
737 clk = syscon_clk_register(
NULL,
"acc_tmr_clk",
"slow_clk", 0,
false,
744 clk = mclk_clk_register(
NULL,
"mmc_clk",
"mmc_p_clk",
false);