diff options
author | Vitaly Bordug <vbordug@ru.mvista.com> | 2006-09-21 14:38:05 -0400 |
---|---|---|
committer | Vitaly Bordug <vbordug@ru.mvista.com> | 2006-09-21 14:38:05 -0400 |
commit | d3465c921f79cfef0a4a8ceeeef9a3721bbbb57d (patch) | |
tree | 73d602a02efd3f358990dcfa9231131e69318d3b /arch/powerpc/sysdev/cpm2_common.c | |
parent | fc8e50e349aa722d9f97ed9ba30e324ede8fa408 (diff) |
POWERPC: overhaul with cpm2_map mechanism
Incorporating the new way of cpm2 immr access, introduced in the previous
patch, into CPM2 peripheral devices (fs_enet and cpm_uart). Both ppc and
powerpc approved working( real actions taken in powerpc only, ppc just
has a wrapper to keep init stuff consistent).
Signed-off-by: Vitaly Bordug <vbordug@ru.mvista.com>
Diffstat (limited to 'arch/powerpc/sysdev/cpm2_common.c')
-rw-r--r-- | arch/powerpc/sysdev/cpm2_common.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/arch/powerpc/sysdev/cpm2_common.c b/arch/powerpc/sysdev/cpm2_common.c index 73376f9c1560..ec265995d5d8 100644 --- a/arch/powerpc/sysdev/cpm2_common.c +++ b/arch/powerpc/sysdev/cpm2_common.c | |||
@@ -130,6 +130,96 @@ cpm2_fastbrg(uint brg, uint rate, int div16) | |||
130 | cpm2_unmap(bp); | 130 | cpm2_unmap(bp); |
131 | } | 131 | } |
132 | 132 | ||
133 | int cpm2_clk_setup(enum cpm_clk_target target, int clock, int mode) | ||
134 | { | ||
135 | int ret = 0; | ||
136 | int shift; | ||
137 | int i, bits = 0; | ||
138 | cpmux_t *im_cpmux; | ||
139 | u32 *reg; | ||
140 | u32 mask = 7; | ||
141 | u8 clk_map [24][3] = { | ||
142 | {CPM_CLK_FCC1, CPM_BRG5, 0}, | ||
143 | {CPM_CLK_FCC1, CPM_BRG6, 1}, | ||
144 | {CPM_CLK_FCC1, CPM_BRG7, 2}, | ||
145 | {CPM_CLK_FCC1, CPM_BRG8, 3}, | ||
146 | {CPM_CLK_FCC1, CPM_CLK9, 4}, | ||
147 | {CPM_CLK_FCC1, CPM_CLK10, 5}, | ||
148 | {CPM_CLK_FCC1, CPM_CLK11, 6}, | ||
149 | {CPM_CLK_FCC1, CPM_CLK12, 7}, | ||
150 | {CPM_CLK_FCC2, CPM_BRG5, 0}, | ||
151 | {CPM_CLK_FCC2, CPM_BRG6, 1}, | ||
152 | {CPM_CLK_FCC2, CPM_BRG7, 2}, | ||
153 | {CPM_CLK_FCC2, CPM_BRG8, 3}, | ||
154 | {CPM_CLK_FCC2, CPM_CLK13, 4}, | ||
155 | {CPM_CLK_FCC2, CPM_CLK14, 5}, | ||
156 | {CPM_CLK_FCC2, CPM_CLK15, 6}, | ||
157 | {CPM_CLK_FCC2, CPM_CLK16, 7}, | ||
158 | {CPM_CLK_FCC3, CPM_BRG5, 0}, | ||
159 | {CPM_CLK_FCC3, CPM_BRG6, 1}, | ||
160 | {CPM_CLK_FCC3, CPM_BRG7, 2}, | ||
161 | {CPM_CLK_FCC3, CPM_BRG8, 3}, | ||
162 | {CPM_CLK_FCC3, CPM_CLK13, 4}, | ||
163 | {CPM_CLK_FCC3, CPM_CLK14, 5}, | ||
164 | {CPM_CLK_FCC3, CPM_CLK15, 6}, | ||
165 | {CPM_CLK_FCC3, CPM_CLK16, 7} | ||
166 | }; | ||
167 | |||
168 | im_cpmux = cpm2_map(im_cpmux); | ||
169 | |||
170 | switch (target) { | ||
171 | case CPM_CLK_SCC1: | ||
172 | reg = &im_cpmux->cmx_scr; | ||
173 | shift = 24; | ||
174 | case CPM_CLK_SCC2: | ||
175 | reg = &im_cpmux->cmx_scr; | ||
176 | shift = 16; | ||
177 | break; | ||
178 | case CPM_CLK_SCC3: | ||
179 | reg = &im_cpmux->cmx_scr; | ||
180 | shift = 8; | ||
181 | break; | ||
182 | case CPM_CLK_SCC4: | ||
183 | reg = &im_cpmux->cmx_scr; | ||
184 | shift = 0; | ||
185 | break; | ||
186 | case CPM_CLK_FCC1: | ||
187 | reg = &im_cpmux->cmx_fcr; | ||
188 | shift = 24; | ||
189 | break; | ||
190 | case CPM_CLK_FCC2: | ||
191 | reg = &im_cpmux->cmx_fcr; | ||
192 | shift = 16; | ||
193 | break; | ||
194 | case CPM_CLK_FCC3: | ||
195 | reg = &im_cpmux->cmx_fcr; | ||
196 | shift = 8; | ||
197 | break; | ||
198 | default: | ||
199 | printk(KERN_ERR "cpm2_clock_setup: invalid clock target\n"); | ||
200 | return -EINVAL; | ||
201 | } | ||
202 | |||
203 | if (mode == CPM_CLK_RX) | ||
204 | shift +=3; | ||
205 | |||
206 | for (i=0; i<24; i++) { | ||
207 | if (clk_map[i][0] == target && clk_map[i][1] == clock) { | ||
208 | bits = clk_map[i][2]; | ||
209 | break; | ||
210 | } | ||
211 | } | ||
212 | if (i == sizeof(clk_map)/3) | ||
213 | ret = -EINVAL; | ||
214 | |||
215 | bits <<= shift; | ||
216 | mask <<= shift; | ||
217 | out_be32(reg, (in_be32(reg) & ~mask) | bits); | ||
218 | |||
219 | cpm2_unmap(im_cpmux); | ||
220 | return ret; | ||
221 | } | ||
222 | |||
133 | /* | 223 | /* |
134 | * dpalloc / dpfree bits. | 224 | * dpalloc / dpfree bits. |
135 | */ | 225 | */ |