1/* 2 * OMAP clock: data structure definitions, function prototypes, shared macros 3 * 4 * Copyright (C) 2004-2005, 2008-2010 Nokia Corporation 5 * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com> 6 * Based on clocks.h by Tony Lindgren, Gordon McNutt and RidgeRun, Inc 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 */ 12 13#ifndef __ARCH_ARM_OMAP_CLOCK_H 14#define __ARCH_ARM_OMAP_CLOCK_H 15 16#include <linux/list.h> 17 18struct module; 19struct clk; 20struct clockdomain; 21 22/** 23 * struct clkops - some clock function pointers 24 * @enable: fn ptr that enables the current clock in hardware 25 * @disable: fn ptr that enables the current clock in hardware 26 * @find_idlest: function returning the IDLEST register for the clock's IP blk 27 * @find_companion: function returning the "companion" clk reg for the clock 28 * 29 * A "companion" clk is an accompanying clock to the one being queried 30 * that must be enabled for the IP module connected to the clock to 31 * become accessible by the hardware. Neither @find_idlest nor 32 * @find_companion should be needed; that information is IP 33 * block-specific; the hwmod code has been created to handle this, but 34 * until hwmod data is ready and drivers have been converted to use PM 35 * runtime calls in place of clk_enable()/clk_disable(), @find_idlest and 36 * @find_companion must, unfortunately, remain. 37 */ 38struct clkops { 39 int (*enable)(struct clk *); 40 void (*disable)(struct clk *); 41 void (*find_idlest)(struct clk *, void __iomem **, 42 u8 *, u8 *); 43 void (*find_companion)(struct clk *, void __iomem **, 44 u8 *); 45}; 46 47#ifdef CONFIG_ARCH_OMAP2PLUS 48 49/* struct clksel_rate.flags possibilities */ 50#define RATE_IN_242X (1 << 0) 51#define RATE_IN_243X (1 << 1) 52#define RATE_IN_3XXX (1 << 2) /* rates common to all OMAP3 */ 53#define RATE_IN_3430ES2 (1 << 3) /* 3430ES2 rates only */ 54#define RATE_IN_36XX (1 << 4) 55#define RATE_IN_4430 (1 << 5) 56 57#define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X) 58#define RATE_IN_3430ES2PLUS (RATE_IN_3430ES2 | RATE_IN_36XX) 59 60struct clksel_rate { 61 u32 val; 62 u8 div; 63 u8 flags; 64}; 65 66/** 67 * struct clksel - available parent clocks, and a pointer to their divisors 68 * @parent: struct clk * to a possible parent clock 69 * @rates: available divisors for this parent clock 70 * 71 * A struct clksel is always associated with one or more struct clks 72 * and one or more struct clksel_rates. 73 */ 74struct clksel { 75 struct clk *parent; 76 const struct clksel_rate *rates; 77}; 78 79struct dpll_data { 80 void __iomem *mult_div1_reg; 81 u32 mult_mask; 82 u32 div1_mask; 83 struct clk *clk_bypass; 84 struct clk *clk_ref; 85 void __iomem *control_reg; 86 u32 enable_mask; 87 unsigned int rate_tolerance; 88 unsigned long last_rounded_rate; 89 u16 last_rounded_m; 90 u16 max_multiplier; 91 u8 last_rounded_n; 92 u8 min_divider; 93 u8 max_divider; 94 u8 modes; 95#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) 96 void __iomem *autoidle_reg; 97 void __iomem *idlest_reg; 98 u32 autoidle_mask; 99 u32 freqsel_mask; 100 u32 idlest_mask; 101 u8 auto_recal_bit; 102 u8 recal_en_bit; 103 u8 recal_st_bit; 104 u8 flags; 105# endif 106}; 107 108#endif 109 110/* struct clk.flags possibilities */ 111#define ENABLE_REG_32BIT (1 << 0) /* Use 32-bit access */ 112#define CLOCK_IDLE_CONTROL (1 << 1) 113#define CLOCK_NO_IDLE_PARENT (1 << 2) 114#define ENABLE_ON_INIT (1 << 3) /* Enable upon framework init */ 115#define INVERT_ENABLE (1 << 4) /* 0 enables, 1 disables */ 116 117struct clk { 118 struct list_head node; 119 const struct clkops *ops; 120 const char *name; 121 struct clk *parent; 122 struct list_head children; 123 struct list_head sibling; /* node for children */ 124 unsigned long rate; 125 void __iomem *enable_reg; 126 unsigned long (*recalc)(struct clk *); 127 int (*set_rate)(struct clk *, unsigned long); 128 long (*round_rate)(struct clk *, unsigned long); 129 void (*init)(struct clk *); 130 u8 enable_bit; 131 s8 usecount; 132 u8 fixed_div; 133 u8 flags; 134#ifdef CONFIG_ARCH_OMAP2PLUS 135 void __iomem *clksel_reg; 136 u32 clksel_mask; 137 const struct clksel *clksel; 138 struct dpll_data *dpll_data; 139 const char *clkdm_name; 140 struct clockdomain *clkdm; 141#else 142 u8 rate_offset; 143 u8 src_offset; 144#endif 145#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) 146 struct dentry *dent; /* For visible tree hierarchy */ 147#endif 148}; 149 150struct cpufreq_frequency_table; 151 152struct clk_functions { 153 int (*clk_enable)(struct clk *clk); 154 void (*clk_disable)(struct clk *clk); 155 long (*clk_round_rate)(struct clk *clk, unsigned long rate); 156 int (*clk_set_rate)(struct clk *clk, unsigned long rate); 157 int (*clk_set_parent)(struct clk *clk, struct clk *parent); 158 void (*clk_allow_idle)(struct clk *clk); 159 void (*clk_deny_idle)(struct clk *clk); 160 void (*clk_disable_unused)(struct clk *clk); 161#ifdef CONFIG_CPU_FREQ 162 void (*clk_init_cpufreq_table)(struct cpufreq_frequency_table **); 163 void (*clk_exit_cpufreq_table)(struct cpufreq_frequency_table **); 164#endif 165}; 166 167extern int mpurate; 168 169extern int clk_init(struct clk_functions *custom_clocks); 170extern void clk_preinit(struct clk *clk); 171extern int clk_register(struct clk *clk); 172extern void clk_reparent(struct clk *child, struct clk *parent); 173extern void clk_unregister(struct clk *clk); 174extern void propagate_rate(struct clk *clk); 175extern void recalculate_root_clocks(void); 176extern unsigned long followparent_recalc(struct clk *clk); 177extern void clk_enable_init_clocks(void); 178unsigned long omap_fixed_divisor_recalc(struct clk *clk); 179#ifdef CONFIG_CPU_FREQ 180extern void clk_init_cpufreq_table(struct cpufreq_frequency_table **table); 181extern void clk_exit_cpufreq_table(struct cpufreq_frequency_table **table); 182#endif 183extern struct clk *omap_clk_get_by_name(const char *name); 184 185extern const struct clkops clkops_null; 186 187extern struct clk dummy_ck; 188 189#endif 190