0001
0002
0003
0004
0005
0006
0007 #ifndef __LINUX_CLK_TI_H__
0008 #define __LINUX_CLK_TI_H__
0009
0010 #include <linux/clk-provider.h>
0011 #include <linux/clkdev.h>
0012
0013
0014
0015
0016
0017
0018 struct clk_omap_reg {
0019 void __iomem *ptr;
0020 u16 offset;
0021 u8 index;
0022 u8 flags;
0023 };
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 struct dpll_data {
0085 struct clk_omap_reg mult_div1_reg;
0086 u32 mult_mask;
0087 u32 div1_mask;
0088 struct clk_hw *clk_bypass;
0089 struct clk_hw *clk_ref;
0090 struct clk_omap_reg control_reg;
0091 u32 enable_mask;
0092 unsigned long last_rounded_rate;
0093 u16 last_rounded_m;
0094 u8 last_rounded_m4xen;
0095 u8 last_rounded_lpmode;
0096 u16 max_multiplier;
0097 u8 last_rounded_n;
0098 u8 min_divider;
0099 u16 max_divider;
0100 unsigned long max_rate;
0101 u8 modes;
0102 struct clk_omap_reg autoidle_reg;
0103 struct clk_omap_reg idlest_reg;
0104 u32 autoidle_mask;
0105 u32 freqsel_mask;
0106 u32 idlest_mask;
0107 u32 dco_mask;
0108 u32 sddiv_mask;
0109 u32 dcc_mask;
0110 unsigned long dcc_rate;
0111 u32 lpmode_mask;
0112 u32 m4xen_mask;
0113 u8 auto_recal_bit;
0114 u8 recal_en_bit;
0115 u8 recal_st_bit;
0116 struct clk_omap_reg ssc_deltam_reg;
0117 struct clk_omap_reg ssc_modfreq_reg;
0118 u32 ssc_deltam_int_mask;
0119 u32 ssc_deltam_frac_mask;
0120 u32 ssc_modfreq_mant_mask;
0121 u32 ssc_modfreq_exp_mask;
0122 u32 ssc_enable_mask;
0123 u32 ssc_downspread_mask;
0124 u32 ssc_modfreq;
0125 u32 ssc_deltam;
0126 bool ssc_downspread;
0127 u8 flags;
0128 };
0129
0130 struct clk_hw_omap;
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140 struct clk_hw_omap_ops {
0141 void (*find_idlest)(struct clk_hw_omap *oclk,
0142 struct clk_omap_reg *idlest_reg,
0143 u8 *idlest_bit, u8 *idlest_val);
0144 void (*find_companion)(struct clk_hw_omap *oclk,
0145 struct clk_omap_reg *other_reg,
0146 u8 *other_bit);
0147 void (*allow_idle)(struct clk_hw_omap *oclk);
0148 void (*deny_idle)(struct clk_hw_omap *oclk);
0149 };
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163 struct clk_hw_omap {
0164 struct clk_hw hw;
0165 struct list_head node;
0166 unsigned long fixed_rate;
0167 u8 fixed_div;
0168 struct clk_omap_reg enable_reg;
0169 u8 enable_bit;
0170 unsigned long flags;
0171 struct clk_omap_reg clksel_reg;
0172 struct dpll_data *dpll_data;
0173 const char *clkdm_name;
0174 struct clockdomain *clkdm;
0175 const struct clk_hw_omap_ops *ops;
0176 u32 context;
0177 int autoidle_count;
0178 };
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200 #define ENABLE_REG_32BIT (1 << 0)
0201 #define CLOCK_IDLE_CONTROL (1 << 1)
0202 #define CLOCK_NO_IDLE_PARENT (1 << 2)
0203 #define ENABLE_ON_INIT (1 << 3)
0204 #define INVERT_ENABLE (1 << 4)
0205 #define CLOCK_CLKOUTX2 (1 << 5)
0206
0207
0208 #define DPLL_LOW_POWER_STOP 0x1
0209 #define DPLL_LOW_POWER_BYPASS 0x5
0210 #define DPLL_LOCKED 0x7
0211
0212
0213 #define DPLL_J_TYPE 0x1
0214
0215
0216 enum {
0217 TI_CLKM_CM = 0,
0218 TI_CLKM_CM2,
0219 TI_CLKM_PRM,
0220 TI_CLKM_SCRM,
0221 TI_CLKM_CTRL,
0222 TI_CLKM_CTRL_AUX,
0223 TI_CLKM_PLLSS,
0224 CLK_MAX_MEMMAPS
0225 };
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244 struct ti_clk_ll_ops {
0245 u32 (*clk_readl)(const struct clk_omap_reg *reg);
0246 void (*clk_writel)(u32 val, const struct clk_omap_reg *reg);
0247 void (*clk_rmw)(u32 val, u32 mask, const struct clk_omap_reg *reg);
0248 int (*clkdm_clk_enable)(struct clockdomain *clkdm, struct clk *clk);
0249 int (*clkdm_clk_disable)(struct clockdomain *clkdm,
0250 struct clk *clk);
0251 struct clockdomain * (*clkdm_lookup)(const char *name);
0252 int (*cm_wait_module_ready)(u8 part, s16 prcm_mod, u16 idlest_reg,
0253 u8 idlest_shift);
0254 int (*cm_split_idlest_reg)(struct clk_omap_reg *idlest_reg,
0255 s16 *prcm_inst, u8 *idlest_reg_id);
0256 };
0257
0258 #define to_clk_hw_omap(_hw) container_of(_hw, struct clk_hw_omap, hw)
0259
0260 bool omap2_clk_is_hw_omap(struct clk_hw *hw);
0261 int omap2_clk_disable_autoidle_all(void);
0262 int omap2_clk_enable_autoidle_all(void);
0263 int omap2_clk_allow_idle(struct clk *clk);
0264 int omap2_clk_deny_idle(struct clk *clk);
0265 unsigned long omap2_dpllcore_recalc(struct clk_hw *hw,
0266 unsigned long parent_rate);
0267 int omap2_reprogram_dpllcore(struct clk_hw *clk, unsigned long rate,
0268 unsigned long parent_rate);
0269 void omap2xxx_clkt_dpllcore_init(struct clk_hw *hw);
0270 void omap2xxx_clkt_vps_init(void);
0271 unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk);
0272
0273 void ti_dt_clk_init_retry_clks(void);
0274 void ti_dt_clockdomains_setup(void);
0275 int ti_clk_setup_ll_ops(struct ti_clk_ll_ops *ops);
0276
0277 struct regmap;
0278
0279 int omap2_clk_provider_init(struct device_node *parent, int index,
0280 struct regmap *syscon, void __iomem *mem);
0281 void omap2_clk_legacy_provider_init(int index, void __iomem *mem);
0282
0283 int omap3430_dt_clk_init(void);
0284 int omap3630_dt_clk_init(void);
0285 int am35xx_dt_clk_init(void);
0286 int dm814x_dt_clk_init(void);
0287 int dm816x_dt_clk_init(void);
0288 int omap4xxx_dt_clk_init(void);
0289 int omap5xxx_dt_clk_init(void);
0290 int dra7xx_dt_clk_init(void);
0291 int am33xx_dt_clk_init(void);
0292 int am43xx_dt_clk_init(void);
0293 int omap2420_dt_clk_init(void);
0294 int omap2430_dt_clk_init(void);
0295
0296 struct ti_clk_features {
0297 u32 flags;
0298 long fint_min;
0299 long fint_max;
0300 long fint_band1_max;
0301 long fint_band2_min;
0302 u8 dpll_bypass_vals;
0303 u8 cm_idlest_val;
0304 };
0305
0306 #define TI_CLK_DPLL_HAS_FREQSEL BIT(0)
0307 #define TI_CLK_DPLL4_DENY_REPROGRAM BIT(1)
0308 #define TI_CLK_DISABLE_CLKDM_CONTROL BIT(2)
0309 #define TI_CLK_ERRATA_I810 BIT(3)
0310 #define TI_CLK_CLKCTRL_COMPAT BIT(4)
0311 #define TI_CLK_DEVICE_TYPE_GP BIT(5)
0312
0313 void ti_clk_setup_features(struct ti_clk_features *features);
0314 const struct ti_clk_features *ti_clk_get_features(void);
0315 bool ti_clk_is_in_standby(struct clk *clk);
0316 int omap3_noncore_dpll_save_context(struct clk_hw *hw);
0317 void omap3_noncore_dpll_restore_context(struct clk_hw *hw);
0318
0319 int omap3_core_dpll_save_context(struct clk_hw *hw);
0320 void omap3_core_dpll_restore_context(struct clk_hw *hw);
0321
0322 extern const struct clk_hw_omap_ops clkhwops_omap2xxx_dpll;
0323
0324 #ifdef CONFIG_ATAGS
0325 int omap3430_clk_legacy_init(void);
0326 int omap3430es1_clk_legacy_init(void);
0327 int omap36xx_clk_legacy_init(void);
0328 int am35xx_clk_legacy_init(void);
0329 #else
0330 static inline int omap3430_clk_legacy_init(void) { return -ENXIO; }
0331 static inline int omap3430es1_clk_legacy_init(void) { return -ENXIO; }
0332 static inline int omap36xx_clk_legacy_init(void) { return -ENXIO; }
0333 static inline int am35xx_clk_legacy_init(void) { return -ENXIO; }
0334 #endif
0335
0336
0337 #endif