Skip to content
Newer
Older
100644 255 lines (216 sloc) 8.3 KB
4bc042b initial public release v1.50
Patrick Titiano authored
1 /*
2 *
3 * @Component OMAPCONF
4 * @Filename alwon44xx.c
5 * @Description OMAP4 PRCM ALWON Definitions & Functions
6 * @Author Patrick Titiano (p-titiano@ti.com)
7 * @Date 2010
8 * @Copyright Texas Instruments Incorporated
9 *
10 *
11 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
12 *
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 *
42 */
43
44
45 #include <alwon44xx.h>
46 #include <cm44xx.h>
47 #include <prm44xx.h>
48 #include <lib44xx.h>
49 #include <help.h>
50 #include <lib.h>
51 #include <mem.h>
52 #include <cpuinfo.h>
53 #include <string.h>
54
55
56 /* #define ALWON44XX_DEBUG */
57 #ifdef ALWON44XX_DEBUG
58 #define dprintf(format, ...) printf(format, ## __VA_ARGS__)
59 #else
60 #define dprintf(format, ...)
61 #endif
62
63
64 #define PRCM_ALWON_REG_TABLE_SIZE 11
65
66
67 static reg_table prcm_alwon_reg_table[PRCM_ALWON_REG_TABLE_SIZE];
68 static unsigned int init_done = 0;
69
70 static int alwon44xx_regtable_init(void);
71
72
73 /* ------------------------------------------------------------------------*//**
74 * @FUNCTION alwon44xx_name2addr
75 * @BRIEF retrieve physical address of a register, given its name.
76 * @RETURNS 0 in case of success
77 * OMAPCONF_ERR_CPU
78 * OMAPCONF_ERR_REG_ACCESS
79 * @param[in] name: register name
80 * @param[in, out] addr: register address
81 * @DESCRIPTION retrieve physical address of a register, given its name.
82 *//*------------------------------------------------------------------------ */
83 int alwon44xx_name2addr(char *name, unsigned int *addr)
84 {
85 CHECK_CPU(44xx, OMAPCONF_ERR_CPU);
86
87 if (!init_done)
88 alwon44xx_regtable_init();
89
90 return name2addr(name, addr, prcm_alwon_reg_table);
91 }
92
93
94 /* ------------------------------------------------------------------------*//**
95 * @FUNCTION alwon44xx_dump
96 * @BRIEF dump PRCM ALWON registers
97 * @RETURNS 0 in case of success
98 * OMAPCONF_ERR_CPU
99 * OMAPCONF_ERR_REG_ACCESS
100 * @DESCRIPTION dump PRCM ALWON registers
101 *//*------------------------------------------------------------------------ */
102 int alwon44xx_dump(void)
103 {
104 CHECK_CPU(44xx, OMAPCONF_ERR_CPU);
105
106 if (!init_done)
107 alwon44xx_regtable_init();
108
109 return dumpregs(prcm_alwon_reg_table);
110 }
111
112
113 /* ------------------------------------------------------------------------*//**
114 * @FUNCTION alwon44xx_config_show
115 * @BRIEF analyze ALWON power configuration
116 * @RETURNS 0 in case of success
117 * OMAPCONF_ERR_CPU
118 * OMAPCONF_ERR_REG_ACCESS
119 * @param[in] stream: output file stream
120 * @DESCRIPTION analyze ALWON power configuration
121 *//*------------------------------------------------------------------------ */
122 int alwon44xx_config_show(FILE *stream)
123 {
124 unsigned int cm_clkstctrl;
125 unsigned int rm_context;
126 unsigned int cm_clkctrl;
127 int ret;
128
129 CHECK_CPU(44xx, OMAPCONF_ERR_CPU);
130
131 if (!init_done)
132 alwon44xx_regtable_init();
133
134 if (mem_read(OMAP4430_CM_ALWON_CLKSTCTRL, &cm_clkstctrl) != 0)
135 return OMAPCONF_ERR_REG_ACCESS;
136
137 ret = clkdm44xx_config_show(stream, "ALWON",
138 OMAP4430_CM_ALWON_CLKSTCTRL, cm_clkstctrl);
139 if (ret != 0)
140 return ret;
141
142 if (mem_read(OMAP4430_CM_ALWON_SR_MPU_CLKCTRL, &cm_clkctrl) != 0)
143 return OMAPCONF_ERR_REG_ACCESS;
144 if (mem_read(OMAP4430_RM_ALWON_SR_MPU_CONTEXT, &rm_context) != 0)
145 return OMAPCONF_ERR_REG_ACCESS;
146 ret = mod44xx_config_show(stream, "SR_MPU",
147 OMAP4430_CM_ALWON_SR_MPU_CLKCTRL, cm_clkctrl,
148 OMAP4430_RM_ALWON_SR_MPU_CONTEXT, rm_context);
149 if (ret != 0)
150 return ret;
151
152 if (mem_read(OMAP4430_CM_ALWON_SR_IVA_CLKCTRL, &cm_clkctrl) != 0)
153 return OMAPCONF_ERR_REG_ACCESS;
154 if (mem_read(OMAP4430_RM_ALWON_SR_IVA_CONTEXT, &rm_context) != 0)
155 return OMAPCONF_ERR_REG_ACCESS;
156 ret = mod44xx_config_show(stream, "SR_IVA",
157 OMAP4430_CM_ALWON_SR_IVA_CLKCTRL, cm_clkctrl,
158 OMAP4430_RM_ALWON_SR_IVA_CONTEXT, rm_context);
159 if (ret != 0)
160 return ret;
161
162 if (mem_read(OMAP4430_CM_ALWON_SR_CORE_CLKCTRL, &cm_clkctrl) != 0)
163 return OMAPCONF_ERR_REG_ACCESS;
164 if (mem_read(OMAP4430_RM_ALWON_SR_CORE_CONTEXT, &rm_context) != 0)
165 return OMAPCONF_ERR_REG_ACCESS;
166 ret = mod44xx_config_show(stream, "SR_CORE",
167 OMAP4430_CM_ALWON_SR_CORE_CLKCTRL, cm_clkctrl,
168 OMAP4430_RM_ALWON_SR_CORE_CONTEXT, rm_context);
169 if (ret != 0)
170 return ret;
171
172 return 0;
173 }
174
175
176 /* ------------------------------------------------------------------------*//**
177 * @FUNCTION alwon44xx_main
178 * @BRIEF alwon functions main entry point
179 * @RETURNS 0 in case of success
180 * OMAPCONF_ERR_ARG
181 * OMAPCONF_ERR_CPU
182 * OMAPCONF_ERR_INTERNAL
183 * @param[in] argc: shell input argument number
184 * @param[in] argv: shell input argument(s)
185 * @DESCRIPTION alwon functions main entry point
186 *//*------------------------------------------------------------------------ */
187 int alwon44xx_main(int argc, char *argv[])
188 {
189 int ret;
190
191 CHECK_CPU(44xx, OMAPCONF_ERR_CPU);
192
193 if (argc == 2) {
194 if (!init_done)
195 alwon44xx_regtable_init();
196 if (strcmp(argv[1], "dump") == 0) {
197 ret = alwon44xx_dump();
198 } else if (strcmp(argv[1], "cfg") == 0) {
199 ret = alwon44xx_config_show(stdout);
200 } else {
201 help(HELP_PRCM);
202 ret = OMAPCONF_ERR_ARG;
203 }
204 } else {
205 help(HELP_PRCM);
206 ret = OMAPCONF_ERR_ARG;
207 }
208
209 return ret;
210 }
211
212
213 /* ------------------------------------------------------------------------*//**
214 * @FUNCTION alwon44xx_regtable_init
215 * @BRIEF initialize regtable
216 * @RETURNS 0 in case of success
217 * OMAPCONF_ERR_CPU
218 * @DESCRIPTION initialize regtable
219 *//*------------------------------------------------------------------------ */
220 static int alwon44xx_regtable_init(void)
221 {
222 int i = 0;
223
224 CHECK_CPU(44xx, OMAPCONF_ERR_CPU);
225
226 /* Init PRCM registers table */
227 strcpy(prcm_alwon_reg_table[i].name, "PM_ALWON_SR_MPU_WKDEP");
228 prcm_alwon_reg_table[i++].addr = OMAP4430_PM_ALWON_SR_MPU_WKDEP;
229 strcpy(prcm_alwon_reg_table[i].name, "RM_ALWON_SR_MPU_CONTEXT");
230 prcm_alwon_reg_table[i++].addr = OMAP4430_RM_ALWON_SR_MPU_CONTEXT;
231 strcpy(prcm_alwon_reg_table[i].name, "PM_ALWON_SR_IVA_WKDEP");
232 prcm_alwon_reg_table[i++].addr = OMAP4430_PM_ALWON_SR_IVA_WKDEP;
233 strcpy(prcm_alwon_reg_table[i].name, "RM_ALWON_SR_IVA_CONTEXT");
234 prcm_alwon_reg_table[i++].addr = OMAP4430_RM_ALWON_SR_IVA_CONTEXT;
235 strcpy(prcm_alwon_reg_table[i].name, "PM_ALWON_SR_CORE_WKDEP");
236 prcm_alwon_reg_table[i++].addr = OMAP4430_PM_ALWON_SR_CORE_WKDEP;
237 strcpy(prcm_alwon_reg_table[i].name, "RM_ALWON_SR_CORE_CONTEXT");
238 prcm_alwon_reg_table[i++].addr = OMAP4430_RM_ALWON_SR_CORE_CONTEXT;
239 strcpy(prcm_alwon_reg_table[i].name, "CM_ALWON_CLKSTCTRL");
240 prcm_alwon_reg_table[i++].addr = OMAP4430_CM_ALWON_CLKSTCTRL;
241 strcpy(prcm_alwon_reg_table[i].name, "CM_ALWON_SR_MPU_CLKCTRL");
242 prcm_alwon_reg_table[i++].addr = OMAP4430_CM_ALWON_SR_MPU_CLKCTRL;
243 strcpy(prcm_alwon_reg_table[i].name, "CM_ALWON_SR_IVA_CLKCTRL");
244 prcm_alwon_reg_table[i++].addr = OMAP4430_CM_ALWON_SR_IVA_CLKCTRL;
245 strcpy(prcm_alwon_reg_table[i].name, "CM_ALWON_SR_CORE_CLKCTRL");
246 prcm_alwon_reg_table[i++].addr = OMAP4430_CM_ALWON_SR_CORE_CLKCTRL;
247 strcpy(prcm_alwon_reg_table[i].name, "END");
248 prcm_alwon_reg_table[i].addr = 0;
249
250 dprintf("prcm_alwon_reg_table last index=%d, size=%d\n", i, i + 1);
251
252 init_done = 1;
253 return 0;
254 }
Something went wrong with that request. Please try again.