blob: d0bcee72817f8e8819d1846171d999abb784f246 [file] [log] [blame]
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -04001/*
2 * keystone2: common clock header file
3 *
4 * (C) Copyright 2012-2014
5 * Texas Instruments Incorporated, <www.ti.com>
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */
9
10#ifndef __ASM_ARCH_CLOCK_H
11#define __ASM_ARCH_CLOCK_H
12
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +030013#ifndef __ASSEMBLY__
14
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -040015#ifdef CONFIG_SOC_K2HK
16#include <asm/arch/clock-k2hk.h>
17#endif
18
Hao Zhang0ecd31e2014-07-16 00:59:23 +030019#ifdef CONFIG_SOC_K2E
20#include <asm/arch/clock-k2e.h>
21#endif
22
Hao Zhang5cf77352014-10-22 16:32:29 +030023#ifdef CONFIG_SOC_K2L
24#include <asm/arch/clock-k2l.h>
25#endif
26
Lokesh Vutla0d73cc22015-07-28 14:16:45 +053027#define CORE_PLL MAIN_PLL
28#define DDR3_PLL DDR3A_PLL
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +030029
30#include <asm/types.h>
31
Khoronzhuk, Ivan90084ea2014-10-22 16:01:28 +030032#define GENERATE_ENUM(NUM, ENUM) ENUM = NUM,
33#define GENERATE_INDX_STR(NUM, STRING) #NUM"\t- "#STRING"\n"
34#define CLOCK_INDEXES_LIST CLK_LIST(GENERATE_INDX_STR)
35
Lokesh Vutla9da9afa2015-07-28 14:16:44 +053036enum {
37 SPD800,
38 SPD850,
39 SPD1000,
40 SPD1200,
41 SPD1250,
42 SPD1350,
43 SPD1400,
44 SPD1500,
45 NUM_SPDS,
46};
47
Lokesh Vutla0d73cc22015-07-28 14:16:45 +053048/* PLL identifiers */
49enum {
50 MAIN_PLL,
51 TETRIS_PLL,
52 PASS_PLL,
53 DDR3A_PLL,
54 DDR3B_PLL,
55 MAX_PLL_COUNT,
56};
57
Lokesh Vutlac40f81d2015-07-28 14:16:47 +053058enum ext_clk_e {
59 sys_clk,
60 alt_core_clk,
61 pa_clk,
62 tetris_clk,
63 ddr3a_clk,
64 ddr3b_clk,
65 ext_clk_count /* number of external clocks */
66};
67
Khoronzhuk, Ivan90084ea2014-10-22 16:01:28 +030068enum clk_e {
69 CLK_LIST(GENERATE_ENUM)
70};
71
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +030072struct keystone_pll_regs {
73 u32 reg0;
74 u32 reg1;
75};
76
77/* PLL configuration data */
78struct pll_init_data {
79 int pll;
80 int pll_m; /* PLL Multiplier */
81 int pll_d; /* PLL divider */
82 int pll_od; /* PLL output divider */
83};
84
Lokesh Vutlac40f81d2015-07-28 14:16:47 +053085extern unsigned int external_clk[ext_clk_count];
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +030086extern const struct keystone_pll_regs keystone_pll_regs[];
Lokesh Vutla70438fc2015-07-28 14:16:43 +053087extern s16 divn_val[];
Lokesh Vutla9da9afa2015-07-28 14:16:44 +053088extern int speeds[];
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +030089
Lokesh Vutla79a94a22015-07-28 14:16:46 +053090void init_plls(void);
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +030091void init_pll(const struct pll_init_data *data);
Lokesh Vutla79a94a22015-07-28 14:16:46 +053092struct pll_init_data *get_pll_init_data(int pll);
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +030093unsigned long clk_get_rate(unsigned int clk);
94unsigned long clk_round_rate(unsigned int clk, unsigned long hz);
95int clk_set_rate(unsigned int clk, unsigned long hz);
Vitaly Andrianov047e7802014-07-25 22:23:19 +030096int get_max_dev_speed(void);
97int get_max_arm_speed(void);
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +030098
99#endif
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -0400100#endif