aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLaurent Pinchart <laurentp@cse-semaphore.com>2008-07-22 12:00:43 -0400
committerKumar Gala <galak@kernel.crashing.org>2008-07-28 09:47:45 -0400
commitdddb8d311157d054da5441385f681b8cc0e5a94b (patch)
treee4a21e86291c011382f68fc063792c560d995f37 /arch
parente517881e427757afc3cce6d76173b1d898b30ab3 (diff)
cpm2: Rework baud rate generators configuration to support external clocks.
The CPM2 BRG setup functions cpm_setbrg and cpm2_fastbrg don't support external clocks. This patch adds a new exported __cpm2_setbrg function that takes the clock rate and clock source as extra parameters, and moves cpm_setbrg and cpm2_fastbrg to include/asm-powerpc/cpm2.h where they become inline wrappers around __cpm2_setbrg. Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/sysdev/cpm2.c34
1 files changed, 4 insertions, 30 deletions
diff --git a/arch/powerpc/sysdev/cpm2.c b/arch/powerpc/sysdev/cpm2.c
index 9311778a5082..f1c3395633b9 100644
--- a/arch/powerpc/sysdev/cpm2.c
+++ b/arch/powerpc/sysdev/cpm2.c
@@ -115,16 +115,10 @@ EXPORT_SYMBOL(cpm_command);
115 * Baud rate clocks are zero-based in the driver code (as that maps 115 * Baud rate clocks are zero-based in the driver code (as that maps
116 * to port numbers). Documentation uses 1-based numbering. 116 * to port numbers). Documentation uses 1-based numbering.
117 */ 117 */
118#define BRG_INT_CLK (get_brgfreq()) 118void __cpm2_setbrg(uint brg, uint rate, uint clk, int div16, int src)
119#define BRG_UART_CLK (BRG_INT_CLK/16)
120
121/* This function is used by UARTS, or anything else that uses a 16x
122 * oversampled clock.
123 */
124void
125cpm_setbrg(uint brg, uint rate)
126{ 119{
127 u32 __iomem *bp; 120 u32 __iomem *bp;
121 u32 val;
128 122
129 /* This is good enough to get SMCs running..... 123 /* This is good enough to get SMCs running.....
130 */ 124 */
@@ -135,34 +129,14 @@ cpm_setbrg(uint brg, uint rate)
135 brg -= 4; 129 brg -= 4;
136 } 130 }
137 bp += brg; 131 bp += brg;
138 out_be32(bp, (((BRG_UART_CLK / rate) - 1) << 1) | CPM_BRG_EN); 132 val = (((clk / rate) - 1) << 1) | CPM_BRG_EN | src;
139
140 cpm2_unmap(bp);
141}
142
143/* This function is used to set high speed synchronous baud rate
144 * clocks.
145 */
146void
147cpm2_fastbrg(uint brg, uint rate, int div16)
148{
149 u32 __iomem *bp;
150 u32 val;
151
152 if (brg < 4) {
153 bp = cpm2_map_size(im_brgc1, 16);
154 } else {
155 bp = cpm2_map_size(im_brgc5, 16);
156 brg -= 4;
157 }
158 bp += brg;
159 val = ((BRG_INT_CLK / rate) << 1) | CPM_BRG_EN;
160 if (div16) 133 if (div16)
161 val |= CPM_BRG_DIV16; 134 val |= CPM_BRG_DIV16;
162 135
163 out_be32(bp, val); 136 out_be32(bp, val);
164 cpm2_unmap(bp); 137 cpm2_unmap(bp);
165} 138}
139EXPORT_SYMBOL(__cpm2_setbrg);
166 140
167int cpm2_clk_setup(enum cpm_clk_target target, int clock, int mode) 141int cpm2_clk_setup(enum cpm_clk_target target, int clock, int mode)
168{ 142{