blob: 2aa37f5c44c07d45c48f8166954c975a12d2b302 [file] [log] [blame]
Colin Crossd8611962010-01-28 16:40:29 -08001/*
2 * arch/arm/mach-tegra/include/mach/clock.h
3 *
4 * Copyright (C) 2010 Google, Inc.
Prashant Gaikwad96a1bd12012-08-06 11:57:42 +05305 * Copyright (c) 2012 NVIDIA CORPORATION. All rights reserved.
Colin Crossd8611962010-01-28 16:40:29 -08006 *
7 * Author:
8 * Colin Cross <ccross@google.com>
9 *
10 * This software is licensed under the terms of the GNU General Public
11 * License version 2, as published by the Free Software Foundation, and
12 * may be copied, distributed, and modified under those terms.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 */
20
21#ifndef __MACH_TEGRA_CLOCK_H
22#define __MACH_TEGRA_CLOCK_H
23
Prashant Gaikwad96a1bd12012-08-06 11:57:42 +053024#include <linux/clk-provider.h>
Jean-Christop PLAGNIOL-VILLARD6d803ba2010-11-17 10:04:33 +010025#include <linux/clkdev.h>
Colin Cross4729fd72011-02-12 16:43:05 -080026#include <linux/list.h>
Colin Crossd8611962010-01-28 16:40:29 -080027
Peter De Schrijver4fccf752012-01-09 05:35:11 +000028#include <mach/clk.h>
29
Colin Crossd8611962010-01-28 16:40:29 -080030#define DIV_BUS (1 << 0)
31#define DIV_U71 (1 << 1)
32#define DIV_U71_FIXED (1 << 2)
33#define DIV_2 (1 << 3)
Colin Cross71fc84c2010-06-07 20:49:46 -070034#define DIV_U16 (1 << 4)
35#define PLL_FIXED (1 << 5)
36#define PLL_HAS_CPCON (1 << 6)
37#define MUX (1 << 7)
38#define PLLD (1 << 8)
39#define PERIPH_NO_RESET (1 << 9)
40#define PERIPH_NO_ENB (1 << 10)
41#define PERIPH_EMC_ENB (1 << 11)
42#define PERIPH_MANUAL_RESET (1 << 12)
43#define PLL_ALT_MISC_REG (1 << 13)
44#define PLLU (1 << 14)
Peter De Schrijver4fccf752012-01-09 05:35:11 +000045#define PLLX (1 << 15)
46#define MUX_PWM (1 << 16)
47#define MUX8 (1 << 17)
48#define DIV_U71_UART (1 << 18)
49#define MUX_CLK_OUT (1 << 19)
50#define PLLM (1 << 20)
51#define DIV_U71_INT (1 << 21)
52#define DIV_U71_IDLE (1 << 22)
Colin Crossd8611962010-01-28 16:40:29 -080053#define ENABLE_ON_INIT (1 << 28)
Peter De Schrijver4fccf752012-01-09 05:35:11 +000054#define PERIPH_ON_APB (1 << 29)
Colin Crossd8611962010-01-28 16:40:29 -080055
Prashant Gaikwad96a1bd12012-08-06 11:57:42 +053056struct clk_tegra;
57#define to_clk_tegra(_hw) container_of(_hw, struct clk_tegra, hw)
Prashant Gaikwad96a1bd12012-08-06 11:57:42 +053058
Colin Crossd8611962010-01-28 16:40:29 -080059struct clk_mux_sel {
60 struct clk *input;
61 u32 value;
62};
63
Colin Crossf1519612011-02-12 16:05:31 -080064struct clk_pll_freq_table {
Colin Crossd8611962010-01-28 16:40:29 -080065 unsigned long input_rate;
66 unsigned long output_rate;
67 u16 n;
68 u16 m;
69 u8 p;
70 u8 cpcon;
71};
72
Prashant Gaikwad96a1bd12012-08-06 11:57:42 +053073enum clk_state {
74 UNINITIALIZED = 0,
75 ON,
76 OFF,
77};
78
Prashant Gaikwad96a1bd12012-08-06 11:57:42 +053079struct clk_tegra {
80 /* node for master clocks list */
81 struct list_head node; /* node for list of all clocks */
82 struct clk_lookup lookup;
83 struct clk_hw hw;
84
85 bool set;
86 unsigned long fixed_rate;
87 unsigned long max_rate;
88 unsigned long min_rate;
89 u32 flags;
90 const char *name;
91
92 enum clk_state state;
93 u32 div;
94 u32 mul;
95
96 u32 reg;
97 u32 reg_shift;
98
99 struct list_head shared_bus_list;
100
101 union {
102 struct {
103 unsigned int clk_num;
104 } periph;
105 struct {
106 unsigned long input_min;
107 unsigned long input_max;
108 unsigned long cf_min;
109 unsigned long cf_max;
110 unsigned long vco_min;
111 unsigned long vco_max;
112 const struct clk_pll_freq_table *freq_table;
113 int lock_delay;
114 unsigned long fixed_rate;
115 } pll;
116 struct {
117 u32 sel;
118 u32 reg_mask;
119 } mux;
120 struct {
121 struct clk *main;
122 struct clk *backup;
123 } cpu;
124 struct {
125 struct list_head node;
126 bool enabled;
127 unsigned long rate;
128 } shared_bus_user;
129 } u;
130
131 void (*reset)(struct clk_hw *, bool);
132 int (*clk_cfg_ex)(struct clk_hw *, enum tegra_clk_ex_param, u32);
133};
Prashant Gaikwad96a1bd12012-08-06 11:57:42 +0530134
Colin Crossd8611962010-01-28 16:40:29 -0800135struct clk_duplicate {
136 const char *name;
137 struct clk_lookup lookup;
138};
139
140struct tegra_clk_init_table {
141 const char *name;
142 const char *parent;
143 unsigned long rate;
144 bool enabled;
145};
146
Prashant Gaikwad92fe58f2012-08-06 11:57:43 +0530147void tegra_clk_add(struct clk *c);
Prashant Gaikwad96a1bd12012-08-06 11:57:42 +0530148void tegra2_init_clocks(void);
149void tegra30_init_clocks(void);
150struct clk *tegra_get_clock_by_name(const char *name);
151void tegra_clk_init_from_table(struct tegra_clk_init_table *table);
Colin Crossd8611962010-01-28 16:40:29 -0800152
153#endif