xref: /freebsd/sys/arm/ti/ti_prcm.h (revision c6ec7d31830ab1c80edae95ad5e4b9dba10c47ac)
1 /*
2  * Copyright (c) 2010
3  *	Ben Gray <ben.r.gray@gmail.com>.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *	This product includes software developed by Ben Gray.
17  * 4. The name of the company nor the name of the author may be used to
18  *    endorse or promote products derived from this software without specific
19  *    prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY BEN GRAY ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL BEN GRAY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * $FreeBSD$
33  */
34 
35 
36 /*
37  * Texas Instruments - OMAP3xxx series processors
38  *
39  * Reference:
40  *  OMAP35x Applications Processor
41  *   Technical Reference Manual
42  *  (omap35xx_techref.pdf)
43  */
44 #ifndef _TI_PRCM_H_
45 #define _TI_PRCM_H_
46 
47 typedef enum {
48 
49 	/* System clocks, typically you can only call ti_prcm_clk_get_source_freq()
50 	 * on these clocks as they are enabled by default.
51 	 */
52 	SYS_CLK = 1,
53 
54 	/* The MPU (ARM) core clock */
55 	MPU_CLK = 20,
56 
57 	/* MMC modules */
58 	MMC0_CLK = 100,
59 	MMC1_CLK,
60 	MMC2_CLK,
61 	MMC3_CLK,
62 	MMC4_CLK,
63 	MMC5_CLK,
64 
65 	/* I2C modules */
66 	I2C0_CLK = 200,
67 	I2C1_CLK,
68 	I2C2_CLK,
69 	I2C3_CLK,
70 	I2C4_CLK,
71 
72 	/* USB module(s) */
73 	USBTLL_CLK = 300,
74 	USBHSHOST_CLK,
75 	USBFSHOST_CLK,
76 	USBP1_PHY_CLK,
77 	USBP2_PHY_CLK,
78 	USBP1_UTMI_CLK,
79 	USBP2_UTMI_CLK,
80 	USBP1_HSIC_CLK,
81 	USBP2_HSIC_CLK,
82 
83 	/* UART modules */
84 	UART1_CLK = 400,
85 	UART2_CLK,
86 	UART3_CLK,
87 	UART4_CLK,
88 
89 	/* General purpose timer modules */
90 	GPTIMER1_CLK = 500,
91 	GPTIMER2_CLK,
92 	GPTIMER3_CLK,
93 	GPTIMER4_CLK,
94 	GPTIMER5_CLK,
95 	GPTIMER6_CLK,
96 	GPTIMER7_CLK,
97 	GPTIMER8_CLK,
98 	GPTIMER9_CLK,
99 	GPTIMER10_CLK,
100 	GPTIMER11_CLK,
101 	GPTIMER12_CLK,
102 
103 	/* McBSP module(s) */
104 	MCBSP1_CLK = 600,
105 	MCBSP2_CLK,
106 	MCBSP3_CLK,
107 	MCBSP4_CLK,
108 	MCBSP5_CLK,
109 
110 	/* General purpose I/O modules */
111 	GPIO0_CLK = 700,
112 	GPIO1_CLK,
113 	GPIO2_CLK,
114 	GPIO3_CLK,
115 	GPIO4_CLK,
116 	GPIO5_CLK,
117 	GPIO6_CLK,
118 
119 	/* sDMA module */
120 	SDMA_CLK = 800,
121 
122 	/* DMTimer modules */
123 	DMTIMER0_CLK = 900,
124 	DMTIMER1_CLK,
125 	DMTIMER2_CLK,
126 	DMTIMER3_CLK,
127 	DMTIMER4_CLK,
128 	DMTIMER5_CLK,
129 	DMTIMER6_CLK,
130 	DMTIMER7_CLK,
131 
132 	/* CPSW modules */
133 	CPSW_CLK = 1000,
134 
135 	/* Mentor USB modules */
136 	MUSB0_CLK = 1100,
137 
138 	/* EDMA module */
139 	EDMA_TPCC_CLK = 1200,
140 	EDMA_TPTC0_CLK,
141 	EDMA_TPTC1_CLK,
142 	EDMA_TPTC2_CLK,
143 
144 	INVALID_CLK_IDENT
145 
146 } clk_ident_t;
147 
148 /*
149  *
150  */
151 typedef enum {
152 	SYSCLK_CLK,   /* System clock */
153 	EXT_CLK,
154 
155 	F32KHZ_CLK,   /* 32KHz clock */
156 	F48MHZ_CLK,   /* 48MHz clock */
157 	F64MHZ_CLK,   /* 64MHz clock */
158 	F96MHZ_CLK,   /* 96MHz clock */
159 
160 } clk_src_t;
161 
162 struct ti_clock_dev {
163 	/* The profile of the timer */
164 	clk_ident_t  id;
165 
166 	/* A bunch of callbacks associated with the clock device */
167 	int (*clk_activate)(struct ti_clock_dev *clkdev);
168 	int (*clk_deactivate)(struct ti_clock_dev *clkdev);
169 	int (*clk_set_source)(struct ti_clock_dev *clkdev,
170 	    clk_src_t clksrc);
171 	int (*clk_accessible)(struct ti_clock_dev *clkdev);
172 	int (*clk_get_source_freq)(struct ti_clock_dev *clkdev,
173 	    unsigned int *freq);
174 };
175 
176 int ti_prcm_clk_valid(clk_ident_t clk);
177 int ti_prcm_clk_enable(clk_ident_t clk);
178 int ti_prcm_clk_disable(clk_ident_t clk);
179 int ti_prcm_clk_accessible(clk_ident_t clk);
180 int ti_prcm_clk_disable_autoidle(clk_ident_t clk);
181 int ti_prcm_clk_set_source(clk_ident_t clk, clk_src_t clksrc);
182 int ti_prcm_clk_get_source_freq(clk_ident_t clk, unsigned int *freq);
183 void ti_prcm_reset(void);
184 
185 #endif   /* _TI_PRCM_H_ */
186