| Colin Cross | d861196 | 2010-01-28 16:40:29 -0800 | [diff] [blame] | 1 | /* | 
 | 2 |  * arch/arm/mach-tegra/include/mach/clock.h | 
 | 3 |  * | 
 | 4 |  * Copyright (C) 2010 Google, Inc. | 
| Prashant Gaikwad | 96a1bd1 | 2012-08-06 11:57:42 +0530 | [diff] [blame] | 5 |  * Copyright (c) 2012 NVIDIA CORPORATION.  All rights reserved. | 
| Colin Cross | d861196 | 2010-01-28 16:40:29 -0800 | [diff] [blame] | 6 |  * | 
 | 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 Gaikwad | 96a1bd1 | 2012-08-06 11:57:42 +0530 | [diff] [blame] | 24 | #include <linux/clk-provider.h> | 
| Jean-Christop PLAGNIOL-VILLARD | 6d803ba | 2010-11-17 10:04:33 +0100 | [diff] [blame] | 25 | #include <linux/clkdev.h> | 
| Colin Cross | 4729fd7 | 2011-02-12 16:43:05 -0800 | [diff] [blame] | 26 | #include <linux/list.h> | 
| Colin Cross | d861196 | 2010-01-28 16:40:29 -0800 | [diff] [blame] | 27 |  | 
| Peter De Schrijver | 4fccf75 | 2012-01-09 05:35:11 +0000 | [diff] [blame] | 28 | #include <mach/clk.h> | 
 | 29 |  | 
| Colin Cross | d861196 | 2010-01-28 16:40:29 -0800 | [diff] [blame] | 30 | #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 Cross | 71fc84c | 2010-06-07 20:49:46 -0700 | [diff] [blame] | 34 | #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 Schrijver | 4fccf75 | 2012-01-09 05:35:11 +0000 | [diff] [blame] | 45 | #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 Cross | d861196 | 2010-01-28 16:40:29 -0800 | [diff] [blame] | 53 | #define ENABLE_ON_INIT		(1 << 28) | 
| Peter De Schrijver | 4fccf75 | 2012-01-09 05:35:11 +0000 | [diff] [blame] | 54 | #define PERIPH_ON_APB           (1 << 29) | 
| Colin Cross | d861196 | 2010-01-28 16:40:29 -0800 | [diff] [blame] | 55 |  | 
| Prashant Gaikwad | 96a1bd1 | 2012-08-06 11:57:42 +0530 | [diff] [blame] | 56 | struct clk_tegra; | 
 | 57 | #define to_clk_tegra(_hw) container_of(_hw, struct clk_tegra, hw) | 
| Prashant Gaikwad | 96a1bd1 | 2012-08-06 11:57:42 +0530 | [diff] [blame] | 58 |  | 
| Colin Cross | d861196 | 2010-01-28 16:40:29 -0800 | [diff] [blame] | 59 | struct clk_mux_sel { | 
 | 60 | 	struct clk	*input; | 
 | 61 | 	u32		value; | 
 | 62 | }; | 
 | 63 |  | 
| Colin Cross | f151961 | 2011-02-12 16:05:31 -0800 | [diff] [blame] | 64 | struct clk_pll_freq_table { | 
| Colin Cross | d861196 | 2010-01-28 16:40:29 -0800 | [diff] [blame] | 65 | 	unsigned long	input_rate; | 
 | 66 | 	unsigned long	output_rate; | 
 | 67 | 	u16		n; | 
 | 68 | 	u16		m; | 
 | 69 | 	u8		p; | 
 | 70 | 	u8		cpcon; | 
 | 71 | }; | 
 | 72 |  | 
| Prashant Gaikwad | 96a1bd1 | 2012-08-06 11:57:42 +0530 | [diff] [blame] | 73 | enum clk_state { | 
 | 74 | 	UNINITIALIZED = 0, | 
 | 75 | 	ON, | 
 | 76 | 	OFF, | 
 | 77 | }; | 
 | 78 |  | 
| Prashant Gaikwad | 96a1bd1 | 2012-08-06 11:57:42 +0530 | [diff] [blame] | 79 | struct 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 Gaikwad | 96a1bd1 | 2012-08-06 11:57:42 +0530 | [diff] [blame] | 134 |  | 
| Colin Cross | d861196 | 2010-01-28 16:40:29 -0800 | [diff] [blame] | 135 | struct clk_duplicate { | 
 | 136 | 	const char *name; | 
 | 137 | 	struct clk_lookup lookup; | 
 | 138 | }; | 
 | 139 |  | 
 | 140 | struct tegra_clk_init_table { | 
 | 141 | 	const char *name; | 
 | 142 | 	const char *parent; | 
 | 143 | 	unsigned long rate; | 
 | 144 | 	bool enabled; | 
 | 145 | }; | 
 | 146 |  | 
| Prashant Gaikwad | 92fe58f | 2012-08-06 11:57:43 +0530 | [diff] [blame] | 147 | void tegra_clk_add(struct clk *c); | 
| Prashant Gaikwad | 96a1bd1 | 2012-08-06 11:57:42 +0530 | [diff] [blame] | 148 | void tegra2_init_clocks(void); | 
 | 149 | void tegra30_init_clocks(void); | 
 | 150 | struct clk *tegra_get_clock_by_name(const char *name); | 
 | 151 | void tegra_clk_init_from_table(struct tegra_clk_init_table *table); | 
| Colin Cross | d861196 | 2010-01-28 16:40:29 -0800 | [diff] [blame] | 152 |  | 
 | 153 | #endif |