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