| Paul Mundt | 36ddf31 | 2006-01-16 22:14:17 -0800 | [diff] [blame] | 1 | #ifndef __ASM_SH_CLOCK_H | 
 | 2 | #define __ASM_SH_CLOCK_H | 
 | 3 |  | 
| Paul Mundt | 36ddf31 | 2006-01-16 22:14:17 -0800 | [diff] [blame] | 4 | #include <linux/list.h> | 
 | 5 | #include <linux/seq_file.h> | 
| Magnus Damm | a1153e2 | 2009-05-28 13:11:31 +0000 | [diff] [blame] | 6 | #include <linux/cpufreq.h> | 
| Paul Mundt | 1d11856 | 2006-12-01 13:15:14 +0900 | [diff] [blame] | 7 | #include <linux/clk.h> | 
| Magnus Damm | de92542 | 2008-07-17 19:09:51 +0900 | [diff] [blame] | 8 | #include <linux/err.h> | 
| Paul Mundt | 36ddf31 | 2006-01-16 22:14:17 -0800 | [diff] [blame] | 9 |  | 
 | 10 | struct clk; | 
 | 11 |  | 
 | 12 | struct clk_ops { | 
 | 13 | 	void (*init)(struct clk *clk); | 
| Paul Mundt | ae891a4 | 2009-05-12 05:30:10 +0900 | [diff] [blame] | 14 | 	int (*enable)(struct clk *clk); | 
| Paul Mundt | 36ddf31 | 2006-01-16 22:14:17 -0800 | [diff] [blame] | 15 | 	void (*disable)(struct clk *clk); | 
| Paul Mundt | b68d820 | 2009-05-12 03:45:08 +0900 | [diff] [blame] | 16 | 	unsigned long (*recalc)(struct clk *clk); | 
| dmitry pervushin | 1929cb3 | 2007-04-24 13:39:09 +0900 | [diff] [blame] | 17 | 	int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id); | 
| Francesco VIRLINZI | d680c76 | 2009-03-11 07:40:54 +0000 | [diff] [blame] | 18 | 	int (*set_parent)(struct clk *clk, struct clk *parent); | 
| Paul Mundt | f6991b0 | 2007-07-20 13:29:09 +0900 | [diff] [blame] | 19 | 	long (*round_rate)(struct clk *clk, unsigned long rate); | 
| Paul Mundt | 36ddf31 | 2006-01-16 22:14:17 -0800 | [diff] [blame] | 20 | }; | 
 | 21 |  | 
 | 22 | struct clk { | 
 | 23 | 	struct list_head	node; | 
 | 24 | 	const char		*name; | 
| Paul Mundt | 1d11856 | 2006-12-01 13:15:14 +0900 | [diff] [blame] | 25 | 	int			id; | 
| Paul Mundt | 36ddf31 | 2006-01-16 22:14:17 -0800 | [diff] [blame] | 26 | 	struct module		*owner; | 
 | 27 |  | 
 | 28 | 	struct clk		*parent; | 
 | 29 | 	struct clk_ops		*ops; | 
 | 30 |  | 
| Paul Mundt | b1f6cfe | 2009-05-12 04:27:43 +0900 | [diff] [blame] | 31 | 	struct list_head	children; | 
 | 32 | 	struct list_head	sibling;	/* node for children */ | 
 | 33 |  | 
| Magnus Damm | 4f5ecaa | 2009-05-08 08:23:29 +0000 | [diff] [blame] | 34 | 	int			usecount; | 
| Paul Mundt | 36ddf31 | 2006-01-16 22:14:17 -0800 | [diff] [blame] | 35 |  | 
 | 36 | 	unsigned long		rate; | 
 | 37 | 	unsigned long		flags; | 
| Paul Mundt | a77b5ac | 2009-05-13 17:55:00 +0900 | [diff] [blame] | 38 |  | 
| Paul Mundt | 549b5e3 | 2009-05-14 17:38:46 +0900 | [diff] [blame] | 39 | 	void __iomem		*enable_reg; | 
 | 40 | 	unsigned int		enable_bit; | 
 | 41 |  | 
| Magnus Damm | 5c8f9d9 | 2008-07-17 18:48:57 +0900 | [diff] [blame] | 42 | 	unsigned long		arch_flags; | 
| Paul Mundt | a77b5ac | 2009-05-13 17:55:00 +0900 | [diff] [blame] | 43 | 	void			*priv; | 
| Paul Mundt | cedcf33 | 2009-05-13 21:51:28 +0900 | [diff] [blame] | 44 | 	struct dentry		*dentry; | 
| Magnus Damm | a1153e2 | 2009-05-28 13:11:31 +0000 | [diff] [blame] | 45 | 	struct cpufreq_frequency_table *freq_table; | 
| Paul Mundt | 36ddf31 | 2006-01-16 22:14:17 -0800 | [diff] [blame] | 46 | }; | 
 | 47 |  | 
| Paul Mundt | 0dae895 | 2009-05-12 06:18:09 +0900 | [diff] [blame] | 48 | struct clk_lookup { | 
 | 49 | 	struct list_head	node; | 
 | 50 | 	const char		*dev_id; | 
 | 51 | 	const char		*con_id; | 
 | 52 | 	struct clk		*clk; | 
 | 53 | }; | 
 | 54 |  | 
| Paul Mundt | 4ff29ff | 2009-05-12 05:14:53 +0900 | [diff] [blame] | 55 | #define CLK_ENABLE_ON_INIT	(1 << 0) | 
| Paul Mundt | 36ddf31 | 2006-01-16 22:14:17 -0800 | [diff] [blame] | 56 |  | 
 | 57 | /* Should be defined by processor-specific code */ | 
| Paul Mundt | 253b088 | 2009-05-13 17:38:11 +0900 | [diff] [blame] | 58 | void __deprecated arch_init_clk_ops(struct clk_ops **, int type); | 
| Paul Mundt | fa43972 | 2008-09-04 18:53:58 +0900 | [diff] [blame] | 59 | int __init arch_clk_init(void); | 
| Paul Mundt | 36ddf31 | 2006-01-16 22:14:17 -0800 | [diff] [blame] | 60 |  | 
 | 61 | /* arch/sh/kernel/cpu/clock.c */ | 
 | 62 | int clk_init(void); | 
| Paul Mundt | b1f6cfe | 2009-05-12 04:27:43 +0900 | [diff] [blame] | 63 | unsigned long followparent_recalc(struct clk *); | 
 | 64 | void recalculate_root_clocks(void); | 
 | 65 | void propagate_rate(struct clk *); | 
| Paul Mundt | aa87aa3 | 2009-05-12 05:51:05 +0900 | [diff] [blame] | 66 | int clk_reparent(struct clk *child, struct clk *parent); | 
| Paul Mundt | 36ddf31 | 2006-01-16 22:14:17 -0800 | [diff] [blame] | 67 | int clk_register(struct clk *); | 
 | 68 | void clk_unregister(struct clk *); | 
 | 69 |  | 
| Paul Mundt | 253b088 | 2009-05-13 17:38:11 +0900 | [diff] [blame] | 70 | /* arch/sh/kernel/cpu/clock-cpg.c */ | 
 | 71 | int __init __deprecated cpg_clk_init(void); | 
 | 72 |  | 
| dmitry pervushin | 1929cb3 | 2007-04-24 13:39:09 +0900 | [diff] [blame] | 73 | /* the exported API, in addition to clk_set_rate */ | 
 | 74 | /** | 
 | 75 |  * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter | 
 | 76 |  * @clk: clock source | 
 | 77 |  * @rate: desired clock rate in Hz | 
 | 78 |  * @algo_id: algorithm id to be passed down to ops->set_rate | 
 | 79 |  * | 
 | 80 |  * Returns success (0) or negative errno. | 
 | 81 |  */ | 
 | 82 | int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id); | 
 | 83 |  | 
 | 84 | enum clk_sh_algo_id { | 
 | 85 | 	NO_CHANGE = 0, | 
 | 86 |  | 
 | 87 | 	IUS_N1_N1, | 
 | 88 | 	IUS_322, | 
 | 89 | 	IUS_522, | 
 | 90 | 	IUS_N11, | 
 | 91 |  | 
 | 92 | 	SB_N1, | 
 | 93 |  | 
 | 94 | 	SB3_N1, | 
 | 95 | 	SB3_32, | 
 | 96 | 	SB3_43, | 
 | 97 | 	SB3_54, | 
 | 98 |  | 
 | 99 | 	BP_N1, | 
 | 100 |  | 
 | 101 | 	IP_N1, | 
 | 102 | }; | 
| Paul Mundt | b68d820 | 2009-05-12 03:45:08 +0900 | [diff] [blame] | 103 |  | 
| Magnus Damm | c94a857 | 2009-05-25 08:10:28 +0000 | [diff] [blame] | 104 | struct clk_div_mult_table { | 
 | 105 | 	unsigned int *divisors; | 
 | 106 | 	unsigned int nr_divisors; | 
 | 107 | 	unsigned int *multipliers; | 
 | 108 | 	unsigned int nr_multipliers; | 
 | 109 | }; | 
 | 110 |  | 
 | 111 | struct cpufreq_frequency_table; | 
 | 112 | void clk_rate_table_build(struct clk *clk, | 
 | 113 | 			  struct cpufreq_frequency_table *freq_table, | 
 | 114 | 			  int nr_freqs, | 
 | 115 | 			  struct clk_div_mult_table *src_table, | 
 | 116 | 			  unsigned long *bitmap); | 
 | 117 |  | 
 | 118 | long clk_rate_table_round(struct clk *clk, | 
 | 119 | 			  struct cpufreq_frequency_table *freq_table, | 
 | 120 | 			  unsigned long rate); | 
 | 121 |  | 
| Magnus Damm | 098dee9 | 2009-06-04 05:31:41 +0000 | [diff] [blame] | 122 | int clk_rate_table_find(struct clk *clk, | 
 | 123 | 			struct cpufreq_frequency_table *freq_table, | 
 | 124 | 			unsigned long rate); | 
 | 125 |  | 
| Magnus Damm | 6881e8b | 2009-05-28 12:52:29 +0000 | [diff] [blame] | 126 | #define SH_CLK_MSTP32(_name, _id, _parent, _enable_reg,	\ | 
 | 127 | 	    _enable_bit, _flags)			\ | 
 | 128 | {							\ | 
 | 129 | 	.name		= _name,			\ | 
 | 130 | 	.id		= _id,				\ | 
 | 131 | 	.parent		= _parent,			\ | 
 | 132 | 	.enable_reg	= (void __iomem *)_enable_reg,	\ | 
 | 133 | 	.enable_bit	= _enable_bit,			\ | 
 | 134 | 	.flags		= _flags,			\ | 
 | 135 | } | 
 | 136 |  | 
 | 137 | int sh_clk_mstp32_register(struct clk *clks, int nr); | 
 | 138 |  | 
| Magnus Damm | a1153e2 | 2009-05-28 13:11:31 +0000 | [diff] [blame] | 139 | #define SH_CLK_DIV4(_name, _parent, _reg, _shift, _div_bitmap, _flags)	\ | 
 | 140 | {									\ | 
 | 141 | 	.name = _name,							\ | 
 | 142 | 	.parent = _parent,						\ | 
 | 143 | 	.enable_reg = (void __iomem *)_reg,				\ | 
 | 144 | 	.enable_bit = _shift,						\ | 
 | 145 | 	.arch_flags = _div_bitmap,					\ | 
 | 146 | 	.flags = _flags,						\ | 
 | 147 | } | 
 | 148 |  | 
| Magnus Damm | 0a5f337 | 2010-02-19 09:22:25 +0000 | [diff] [blame] | 149 | struct clk_div4_table { | 
 | 150 | 	struct clk_div_mult_table *div_mult_table; | 
| Magnus Damm | 7be85c6 | 2010-02-19 09:26:56 +0000 | [diff] [blame] | 151 | 	void (*kick)(struct clk *clk); | 
| Magnus Damm | 0a5f337 | 2010-02-19 09:22:25 +0000 | [diff] [blame] | 152 | }; | 
 | 153 |  | 
| Magnus Damm | a1153e2 | 2009-05-28 13:11:31 +0000 | [diff] [blame] | 154 | int sh_clk_div4_register(struct clk *clks, int nr, | 
| Magnus Damm | 0a5f337 | 2010-02-19 09:22:25 +0000 | [diff] [blame] | 155 | 			 struct clk_div4_table *table); | 
| Guennadi Liakhovetski | 31c3af5 | 2010-01-19 11:14:31 +0000 | [diff] [blame] | 156 | int sh_clk_div4_enable_register(struct clk *clks, int nr, | 
| Magnus Damm | 0a5f337 | 2010-02-19 09:22:25 +0000 | [diff] [blame] | 157 | 			 struct clk_div4_table *table); | 
| Guennadi Liakhovetski | 31c3af5 | 2010-01-19 11:14:31 +0000 | [diff] [blame] | 158 | int sh_clk_div4_reparent_register(struct clk *clks, int nr, | 
| Magnus Damm | 0a5f337 | 2010-02-19 09:22:25 +0000 | [diff] [blame] | 159 | 			 struct clk_div4_table *table); | 
| Magnus Damm | a1153e2 | 2009-05-28 13:11:31 +0000 | [diff] [blame] | 160 |  | 
| Magnus Damm | 2693e27 | 2009-06-02 08:53:54 +0000 | [diff] [blame] | 161 | #define SH_CLK_DIV6(_name, _parent, _reg, _flags)	\ | 
 | 162 | {							\ | 
 | 163 | 	.name = _name,					\ | 
 | 164 | 	.parent = _parent,				\ | 
 | 165 | 	.enable_reg = (void __iomem *)_reg,		\ | 
 | 166 | 	.flags = _flags,				\ | 
 | 167 | } | 
 | 168 |  | 
 | 169 | int sh_clk_div6_register(struct clk *clks, int nr); | 
 | 170 |  | 
| Paul Mundt | 36ddf31 | 2006-01-16 22:14:17 -0800 | [diff] [blame] | 171 | #endif /* __ASM_SH_CLOCK_H */ |