1f15cbe6fSPaul Mundt #ifndef __ASM_SH_CLOCK_H 2f15cbe6fSPaul Mundt #define __ASM_SH_CLOCK_H 3f15cbe6fSPaul Mundt 4f15cbe6fSPaul Mundt #include <linux/kref.h> 5f15cbe6fSPaul Mundt #include <linux/list.h> 6f15cbe6fSPaul Mundt #include <linux/seq_file.h> 7f15cbe6fSPaul Mundt #include <linux/clk.h> 8f15cbe6fSPaul Mundt #include <linux/err.h> 9f15cbe6fSPaul Mundt 10f15cbe6fSPaul Mundt struct clk; 11f15cbe6fSPaul Mundt 12f15cbe6fSPaul Mundt struct clk_ops { 13f15cbe6fSPaul Mundt void (*init)(struct clk *clk); 14f15cbe6fSPaul Mundt void (*enable)(struct clk *clk); 15f15cbe6fSPaul Mundt void (*disable)(struct clk *clk); 16f15cbe6fSPaul Mundt void (*recalc)(struct clk *clk); 17f15cbe6fSPaul Mundt int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id); 18f15cbe6fSPaul Mundt long (*round_rate)(struct clk *clk, unsigned long rate); 19f15cbe6fSPaul Mundt }; 20f15cbe6fSPaul Mundt 21f15cbe6fSPaul Mundt struct clk { 22f15cbe6fSPaul Mundt struct list_head node; 23f15cbe6fSPaul Mundt const char *name; 24f15cbe6fSPaul Mundt int id; 25f15cbe6fSPaul Mundt struct module *owner; 26f15cbe6fSPaul Mundt 27f15cbe6fSPaul Mundt struct clk *parent; 28f15cbe6fSPaul Mundt struct clk_ops *ops; 29f15cbe6fSPaul Mundt 30f15cbe6fSPaul Mundt struct kref kref; 31f15cbe6fSPaul Mundt 32f15cbe6fSPaul Mundt unsigned long rate; 33f15cbe6fSPaul Mundt unsigned long flags; 34f15cbe6fSPaul Mundt unsigned long arch_flags; 35f15cbe6fSPaul Mundt }; 36f15cbe6fSPaul Mundt 37f15cbe6fSPaul Mundt #define CLK_ALWAYS_ENABLED (1 << 0) 38f15cbe6fSPaul Mundt #define CLK_RATE_PROPAGATES (1 << 1) 39f15cbe6fSPaul Mundt 40f15cbe6fSPaul Mundt /* Should be defined by processor-specific code */ 41f15cbe6fSPaul Mundt void arch_init_clk_ops(struct clk_ops **, int type); 42fa43972fSPaul Mundt int __init arch_clk_init(void); 43f15cbe6fSPaul Mundt 44f15cbe6fSPaul Mundt /* arch/sh/kernel/cpu/clock.c */ 45f15cbe6fSPaul Mundt int clk_init(void); 46f15cbe6fSPaul Mundt 47f15cbe6fSPaul Mundt void clk_recalc_rate(struct clk *); 48f15cbe6fSPaul Mundt 49f15cbe6fSPaul Mundt int clk_register(struct clk *); 50f15cbe6fSPaul Mundt void clk_unregister(struct clk *); 51f15cbe6fSPaul Mundt 52f15cbe6fSPaul Mundt static inline int clk_always_enable(const char *id) 53f15cbe6fSPaul Mundt { 54f15cbe6fSPaul Mundt struct clk *clk; 55f15cbe6fSPaul Mundt int ret; 56f15cbe6fSPaul Mundt 57f15cbe6fSPaul Mundt clk = clk_get(NULL, id); 58f15cbe6fSPaul Mundt if (IS_ERR(clk)) 59f15cbe6fSPaul Mundt return PTR_ERR(clk); 60f15cbe6fSPaul Mundt 61f15cbe6fSPaul Mundt ret = clk_enable(clk); 62f15cbe6fSPaul Mundt if (ret) 63f15cbe6fSPaul Mundt clk_put(clk); 64f15cbe6fSPaul Mundt 65f15cbe6fSPaul Mundt return ret; 66f15cbe6fSPaul Mundt } 67f15cbe6fSPaul Mundt 68f15cbe6fSPaul Mundt /* the exported API, in addition to clk_set_rate */ 69f15cbe6fSPaul Mundt /** 70f15cbe6fSPaul Mundt * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter 71f15cbe6fSPaul Mundt * @clk: clock source 72f15cbe6fSPaul Mundt * @rate: desired clock rate in Hz 73f15cbe6fSPaul Mundt * @algo_id: algorithm id to be passed down to ops->set_rate 74f15cbe6fSPaul Mundt * 75f15cbe6fSPaul Mundt * Returns success (0) or negative errno. 76f15cbe6fSPaul Mundt */ 77f15cbe6fSPaul Mundt int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id); 78f15cbe6fSPaul Mundt 79f15cbe6fSPaul Mundt enum clk_sh_algo_id { 80f15cbe6fSPaul Mundt NO_CHANGE = 0, 81f15cbe6fSPaul Mundt 82f15cbe6fSPaul Mundt IUS_N1_N1, 83f15cbe6fSPaul Mundt IUS_322, 84f15cbe6fSPaul Mundt IUS_522, 85f15cbe6fSPaul Mundt IUS_N11, 86f15cbe6fSPaul Mundt 87f15cbe6fSPaul Mundt SB_N1, 88f15cbe6fSPaul Mundt 89f15cbe6fSPaul Mundt SB3_N1, 90f15cbe6fSPaul Mundt SB3_32, 91f15cbe6fSPaul Mundt SB3_43, 92f15cbe6fSPaul Mundt SB3_54, 93f15cbe6fSPaul Mundt 94f15cbe6fSPaul Mundt BP_N1, 95f15cbe6fSPaul Mundt 96f15cbe6fSPaul Mundt IP_N1, 97f15cbe6fSPaul Mundt }; 98f15cbe6fSPaul Mundt #endif /* __ASM_SH_CLOCK_H */ 99