2 * TI Clock driver internal definitions
4 * Copyright (C) 2014 Texas Instruments, Inc
5 * Tero Kristo (t-kristo@ti.com)
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation version 2.
11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12 * kind, whether express or implied; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 #ifndef __DRIVERS_CLK_TI_CLOCK__
17 #define __DRIVERS_CLK_TI_CLOCK__
19 struct clk_omap_divider
{
21 struct clk_omap_reg reg
;
26 const struct clk_div_table
*table
;
29 #define to_clk_omap_divider(_hw) container_of(_hw, struct clk_omap_divider, hw)
33 struct clk_omap_reg reg
;
41 #define to_clk_omap_mux(_hw) container_of(_hw, struct clk_omap_mux, hw)
54 #define CLKF_INDEX_POWER_OF_TWO (1 << 0)
55 #define CLKF_INDEX_STARTS_AT_ONE (1 << 1)
56 #define CLKF_SET_RATE_PARENT (1 << 2)
57 #define CLKF_OMAP3 (1 << 3)
58 #define CLKF_AM35XX (1 << 4)
61 #define CLKF_SET_BIT_TO_DISABLE (1 << 5)
62 #define CLKF_INTERFACE (1 << 6)
63 #define CLKF_SSI (1 << 7)
64 #define CLKF_DSS (1 << 8)
65 #define CLKF_HSOTGUSB (1 << 9)
66 #define CLKF_WAIT (1 << 10)
67 #define CLKF_NO_WAIT (1 << 11)
68 #define CLKF_HSDIV (1 << 12)
69 #define CLKF_CLKDM (1 << 13)
72 #define CLKF_LOW_POWER_STOP (1 << 5)
73 #define CLKF_LOCK (1 << 6)
74 #define CLKF_LOW_POWER_BYPASS (1 << 7)
75 #define CLKF_PER (1 << 8)
76 #define CLKF_CORE (1 << 9)
77 #define CLKF_J_TYPE (1 << 10)
80 #define CLKF_SW_SUP BIT(5)
81 #define CLKF_HW_SUP BIT(6)
82 #define CLKF_NO_IDLEST BIT(7)
84 #define CLK(dev, con, ck) \
95 const char *clkdm_name
;
107 const char * const *parents
;
111 struct ti_clk_divider
{
130 /* Composite clock component types */
132 CLK_COMPONENT_TYPE_GATE
= 0,
133 CLK_COMPONENT_TYPE_DIVIDER
,
134 CLK_COMPONENT_TYPE_MUX
,
135 CLK_COMPONENT_TYPE_MAX
,
139 * struct ti_dt_clk - OMAP DT clock alias declarations
140 * @lk: clock lookup definition
141 * @node_name: clock DT node to map to
144 struct clk_lookup lk
;
148 #define DT_CLK(dev, con, name) \
157 /* CLKCTRL type definitions */
158 struct omap_clkctrl_div_data
{
164 struct omap_clkctrl_bit_data
{
167 const char * const *parents
;
171 struct omap_clkctrl_reg_data
{
173 const struct omap_clkctrl_bit_data
*bit_data
;
176 const char *clkdm_name
;
179 struct omap_clkctrl_data
{
181 const struct omap_clkctrl_reg_data
*regs
;
184 extern const struct omap_clkctrl_data omap4_clkctrl_data
[];
185 extern const struct omap_clkctrl_data omap5_clkctrl_data
[];
186 extern const struct omap_clkctrl_data dra7_clkctrl_data
[];
187 extern const struct omap_clkctrl_data am3_clkctrl_data
[];
188 extern const struct omap_clkctrl_data am4_clkctrl_data
[];
189 extern const struct omap_clkctrl_data am438x_clkctrl_data
[];
190 extern const struct omap_clkctrl_data dm814_clkctrl_data
[];
191 extern const struct omap_clkctrl_data dm816_clkctrl_data
[];
193 typedef void (*ti_of_clk_init_cb_t
)(void *, struct device_node
*);
195 struct clk
*ti_clk_register(struct device
*dev
, struct clk_hw
*hw
,
197 int ti_clk_add_alias(struct device
*dev
, struct clk
*clk
, const char *con
);
198 void ti_clk_add_aliases(void);
200 void ti_clk_latch(struct clk_omap_reg
*reg
, s8 shift
);
202 struct clk_hw
*ti_clk_build_component_mux(struct ti_clk_mux
*setup
);
204 int ti_clk_parse_divider_data(int *div_table
, int num_dividers
, int max_div
,
206 const struct clk_div_table
**table
);
208 int ti_clk_get_reg_addr(struct device_node
*node
, int index
,
209 struct clk_omap_reg
*reg
);
210 void ti_dt_clocks_register(struct ti_dt_clk
*oclks
);
211 int ti_clk_retry_init(struct device_node
*node
, void *user
,
212 ti_of_clk_init_cb_t func
);
213 int ti_clk_add_component(struct device_node
*node
, struct clk_hw
*hw
, int type
);
215 void omap2_init_clk_hw_omap_clocks(struct clk_hw
*hw
);
216 int of_ti_clk_autoidle_setup(struct device_node
*node
);
217 void omap2_clk_enable_init_clocks(const char **clk_names
, u8 num_clocks
);
219 extern const struct clk_hw_omap_ops clkhwops_omap3_dpll
;
220 extern const struct clk_hw_omap_ops clkhwops_omap4_dpllmx
;
221 extern const struct clk_hw_omap_ops clkhwops_wait
;
222 extern const struct clk_hw_omap_ops clkhwops_iclk
;
223 extern const struct clk_hw_omap_ops clkhwops_iclk_wait
;
224 extern const struct clk_hw_omap_ops clkhwops_omap2430_i2chs_wait
;
225 extern const struct clk_hw_omap_ops clkhwops_omap3430es2_dss_usbhost_wait
;
226 extern const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_hsotgusb_wait
;
227 extern const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_dss_usbhost_wait
;
228 extern const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_ssi_wait
;
229 extern const struct clk_hw_omap_ops clkhwops_am35xx_ipss_module_wait
;
230 extern const struct clk_hw_omap_ops clkhwops_am35xx_ipss_wait
;
232 extern const struct clk_ops ti_clk_divider_ops
;
233 extern const struct clk_ops ti_clk_mux_ops
;
234 extern const struct clk_ops omap_gate_clk_ops
;
236 void omap2_init_clk_clkdm(struct clk_hw
*hw
);
237 int omap2_clkops_enable_clkdm(struct clk_hw
*hw
);
238 void omap2_clkops_disable_clkdm(struct clk_hw
*hw
);
240 int omap2_dflt_clk_enable(struct clk_hw
*hw
);
241 void omap2_dflt_clk_disable(struct clk_hw
*hw
);
242 int omap2_dflt_clk_is_enabled(struct clk_hw
*hw
);
243 void omap2_clk_dflt_find_companion(struct clk_hw_omap
*clk
,
244 struct clk_omap_reg
*other_reg
,
246 void omap2_clk_dflt_find_idlest(struct clk_hw_omap
*clk
,
247 struct clk_omap_reg
*idlest_reg
,
248 u8
*idlest_bit
, u8
*idlest_val
);
250 void omap2_clkt_iclk_allow_idle(struct clk_hw_omap
*clk
);
251 void omap2_clkt_iclk_deny_idle(struct clk_hw_omap
*clk
);
253 u8
omap2_init_dpll_parent(struct clk_hw
*hw
);
254 int omap3_noncore_dpll_enable(struct clk_hw
*hw
);
255 void omap3_noncore_dpll_disable(struct clk_hw
*hw
);
256 int omap3_noncore_dpll_set_parent(struct clk_hw
*hw
, u8 index
);
257 int omap3_noncore_dpll_set_rate(struct clk_hw
*hw
, unsigned long rate
,
258 unsigned long parent_rate
);
259 int omap3_noncore_dpll_set_rate_and_parent(struct clk_hw
*hw
,
261 unsigned long parent_rate
,
263 int omap3_noncore_dpll_determine_rate(struct clk_hw
*hw
,
264 struct clk_rate_request
*req
);
265 long omap2_dpll_round_rate(struct clk_hw
*hw
, unsigned long target_rate
,
266 unsigned long *parent_rate
);
267 unsigned long omap3_clkoutx2_recalc(struct clk_hw
*hw
,
268 unsigned long parent_rate
);
271 * OMAP3_DPLL5_FREQ_FOR_USBHOST: USBHOST and USBTLL are the only clocks
272 * that are sourced by DPLL5, and both of these require this clock
273 * to be at 120 MHz for proper operation.
275 #define OMAP3_DPLL5_FREQ_FOR_USBHOST 120000000
277 unsigned long omap3_dpll_recalc(struct clk_hw
*hw
, unsigned long parent_rate
);
278 int omap3_dpll4_set_rate(struct clk_hw
*clk
, unsigned long rate
,
279 unsigned long parent_rate
);
280 int omap3_dpll4_set_rate_and_parent(struct clk_hw
*hw
, unsigned long rate
,
281 unsigned long parent_rate
, u8 index
);
282 int omap3_dpll5_set_rate(struct clk_hw
*hw
, unsigned long rate
,
283 unsigned long parent_rate
);
284 void omap3_clk_lock_dpll5(void);
286 unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw
*hw
,
287 unsigned long parent_rate
);
288 long omap4_dpll_regm4xen_round_rate(struct clk_hw
*hw
,
289 unsigned long target_rate
,
290 unsigned long *parent_rate
);
291 int omap4_dpll_regm4xen_determine_rate(struct clk_hw
*hw
,
292 struct clk_rate_request
*req
);
294 extern struct ti_clk_ll_ops
*ti_clk_ll_ops
;