blob: cdcff3baee36f1220108f5942a10ef157101fe51 [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
Vitaly Andrianov29646842015-09-19 16:26:40 +053027#ifdef CONFIG_SOC_K2G
28#include <asm/arch/clock-k2g.h>
29#endif
30
Lokesh Vutla0d73cc22015-07-28 14:16:45 +053031#define CORE_PLL MAIN_PLL
32#define DDR3_PLL DDR3A_PLL
Vitaly Andrianov29646842015-09-19 16:26:40 +053033#define NSS_PLL PASS_PLL
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +030034
Lokesh Vutla41f7ea82015-07-28 14:16:48 +053035#define CLK_LIST(CLK)\
36 CLK(0, core_pll_clk)\
37 CLK(1, pass_pll_clk)\
38 CLK(2, tetris_pll_clk)\
39 CLK(3, ddr3a_pll_clk)\
40 CLK(4, ddr3b_pll_clk)\
41 CLK(5, sys_clk0_clk)\
42 CLK(6, sys_clk0_1_clk)\
43 CLK(7, sys_clk0_2_clk)\
44 CLK(8, sys_clk0_3_clk)\
45 CLK(9, sys_clk0_4_clk)\
46 CLK(10, sys_clk0_6_clk)\
47 CLK(11, sys_clk0_8_clk)\
48 CLK(12, sys_clk0_12_clk)\
49 CLK(13, sys_clk0_24_clk)\
50 CLK(14, sys_clk1_clk)\
51 CLK(15, sys_clk1_3_clk)\
52 CLK(16, sys_clk1_4_clk)\
53 CLK(17, sys_clk1_6_clk)\
54 CLK(18, sys_clk1_12_clk)\
55 CLK(19, sys_clk2_clk)\
Vitaly Andrianov7fd5b642015-09-19 16:26:41 +053056 CLK(20, sys_clk3_clk)\
57 CLK(21, uart_pll_clk)
Lokesh Vutla41f7ea82015-07-28 14:16:48 +053058
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +030059#include <asm/types.h>
60
Khoronzhuk, Ivan90084ea2014-10-22 16:01:28 +030061#define GENERATE_ENUM(NUM, ENUM) ENUM = NUM,
62#define GENERATE_INDX_STR(NUM, STRING) #NUM"\t- "#STRING"\n"
63#define CLOCK_INDEXES_LIST CLK_LIST(GENERATE_INDX_STR)
64
Lokesh Vutla9da9afa2015-07-28 14:16:44 +053065enum {
66 SPD800,
67 SPD850,
68 SPD1000,
69 SPD1200,
70 SPD1250,
71 SPD1350,
72 SPD1400,
73 SPD1500,
74 NUM_SPDS,
75};
76
Lokesh Vutla0d73cc22015-07-28 14:16:45 +053077/* PLL identifiers */
78enum {
79 MAIN_PLL,
80 TETRIS_PLL,
81 PASS_PLL,
82 DDR3A_PLL,
83 DDR3B_PLL,
Vitaly Andrianov29646842015-09-19 16:26:40 +053084 UART_PLL,
Lokesh Vutla0d73cc22015-07-28 14:16:45 +053085 MAX_PLL_COUNT,
86};
87
Lokesh Vutlac40f81d2015-07-28 14:16:47 +053088enum ext_clk_e {
89 sys_clk,
90 alt_core_clk,
91 pa_clk,
92 tetris_clk,
93 ddr3a_clk,
94 ddr3b_clk,
Vitaly Andrianov7fd5b642015-09-19 16:26:41 +053095 uart_clk,
Lokesh Vutlac40f81d2015-07-28 14:16:47 +053096 ext_clk_count /* number of external clocks */
97};
98
Khoronzhuk, Ivan90084ea2014-10-22 16:01:28 +030099enum clk_e {
100 CLK_LIST(GENERATE_ENUM)
101};
102
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +0300103struct keystone_pll_regs {
104 u32 reg0;
105 u32 reg1;
106};
107
108/* PLL configuration data */
109struct pll_init_data {
110 int pll;
111 int pll_m; /* PLL Multiplier */
112 int pll_d; /* PLL divider */
113 int pll_od; /* PLL output divider */
114};
115
Lokesh Vutlac40f81d2015-07-28 14:16:47 +0530116extern unsigned int external_clk[ext_clk_count];
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +0300117extern const struct keystone_pll_regs keystone_pll_regs[];
Lokesh Vutla70438fc2015-07-28 14:16:43 +0530118extern s16 divn_val[];
Lokesh Vutla9da9afa2015-07-28 14:16:44 +0530119extern int speeds[];
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +0300120
Lokesh Vutla79a94a22015-07-28 14:16:46 +0530121void init_plls(void);
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +0300122void init_pll(const struct pll_init_data *data);
Lokesh Vutla79a94a22015-07-28 14:16:46 +0530123struct pll_init_data *get_pll_init_data(int pll);
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +0300124unsigned long clk_get_rate(unsigned int clk);
125unsigned long clk_round_rate(unsigned int clk, unsigned long hz);
126int clk_set_rate(unsigned int clk, unsigned long hz);
Vitaly Andrianov047e7802014-07-25 22:23:19 +0300127int get_max_dev_speed(void);
128int get_max_arm_speed(void);
Lokesh Vutlada18b182015-10-08 11:31:47 +0530129void pll_pa_clk_sel(void);
Khoronzhuk, Ivan43b126f2014-07-09 23:44:47 +0300130
131#endif
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -0400132#endif