]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/include/asm/arch-mx6/clock.h
upgrade to upstream version 2013.07
[karo-tx-uboot.git] / arch / arm / include / asm / arch-mx6 / clock.h
1 /*
2  * (C) Copyright 2009
3  * Stefano Babic, DENX Software Engineering, sbabic@denx.de.
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #ifndef __ASM_ARCH_CLOCK_H
9 #define __ASM_ARCH_CLOCK_H
10
11 #include <common.h>
12
13 #ifdef CONFIG_SYS_MX6_HCLK
14 #define MXC_HCLK        CONFIG_SYS_MX6_HCLK
15 #else
16 #define MXC_HCLK        24000000
17 #endif
18
19 #ifdef CONFIG_SYS_MX6_CLK32
20 #define MXC_CLK32       CONFIG_SYS_MX6_CLK32
21 #else
22 #define MXC_CLK32       32768
23 #endif
24
25 enum mxc_clock {
26         MXC_ARM_CLK = 0,
27         MXC_PER_CLK,
28         MXC_AHB_CLK,
29         MXC_IPG_CLK,
30         MXC_IPG_PERCLK,
31         MXC_UART_CLK,
32         MXC_CSPI_CLK,
33         MXC_AXI_CLK,
34         MXC_EMI_SLOW_CLK,
35         MXC_DDR_CLK,
36         MXC_ESDHC_CLK,
37         MXC_ESDHC2_CLK,
38         MXC_ESDHC3_CLK,
39         MXC_ESDHC4_CLK,
40         MXC_SATA_CLK,
41         MXC_NFC_CLK,
42         MXC_I2C_CLK,
43 };
44
45
46 struct clk {
47         const char *name;
48         int id;
49         /* Source clock this clk depends on */
50         struct clk *parent;
51         /* Secondary clock to enable/disable with this clock */
52         struct clk *secondary;
53         /* Current clock rate */
54         unsigned long rate;
55         /* Reference count of clock enable/disable */
56         __s8 usecount;
57         /* Register bit position for clock's enable/disable control. */
58         u8 enable_shift;
59         /* Register address for clock's enable/disable control. */
60         void *enable_reg;
61         u32 flags;
62         /*
63          * Function ptr to recalculate the clock's rate based on parent
64          * clock's rate
65          */
66         void (*recalc) (struct clk *);
67         /*
68          * Function ptr to set the clock to a new rate. The rate must match a
69          * supported rate returned from round_rate. Leave blank if clock is not
70         * programmable
71          */
72         int (*set_rate) (struct clk *, unsigned long);
73         /*
74          * Function ptr to round the requested clock rate to the nearest
75          * supported rate that is less than or equal to the requested rate.
76          */
77         unsigned long (*round_rate) (struct clk *, unsigned long);
78         /*
79          * Function ptr to enable the clock. Leave blank if clock can not
80          * be gated.
81          */
82         int (*enable) (struct clk *);
83         /*
84          * Function ptr to disable the clock. Leave blank if clock can not
85          * be gated.
86          */
87         void (*disable) (struct clk *);
88         /* Function ptr to set the parent clock of the clock. */
89         int (*set_parent) (struct clk *, struct clk *);
90 };
91
92 u32 imx_get_uartclk(void);
93 u32 imx_get_fecclk(void);
94 unsigned int mxc_get_clock(enum mxc_clock clk);
95 int mxc_set_clock(u32 ref, u32 freq, enum mxc_clock clk);
96 void enable_ocotp_clk(unsigned char enable);
97 void enable_usboh3_clk(unsigned char enable);
98 int enable_sata_clock(void);
99 int enable_i2c_clk(unsigned char enable, unsigned i2c_num);
100 void ipu_clk_enable(void);
101 void ipu_clk_disable(void);
102 void ocotp_clk_enable(void);
103 void ocotp_clk_disable(void);
104
105 #endif /* __ASM_ARCH_CLOCK_H */