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>
This commit is contained in:
committed by
Kumar Gala
parent
e517881e42
commit
dddb8d3111
@ -115,16 +115,10 @@ EXPORT_SYMBOL(cpm_command);
|
||||
* Baud rate clocks are zero-based in the driver code (as that maps
|
||||
* to port numbers). Documentation uses 1-based numbering.
|
||||
*/
|
||||
#define BRG_INT_CLK (get_brgfreq())
|
||||
#define BRG_UART_CLK (BRG_INT_CLK/16)
|
||||
|
||||
/* This function is used by UARTS, or anything else that uses a 16x
|
||||
* oversampled clock.
|
||||
*/
|
||||
void
|
||||
cpm_setbrg(uint brg, uint rate)
|
||||
void __cpm2_setbrg(uint brg, uint rate, uint clk, int div16, int src)
|
||||
{
|
||||
u32 __iomem *bp;
|
||||
u32 val;
|
||||
|
||||
/* This is good enough to get SMCs running.....
|
||||
*/
|
||||
@ -135,34 +129,14 @@ cpm_setbrg(uint brg, uint rate)
|
||||
brg -= 4;
|
||||
}
|
||||
bp += brg;
|
||||
out_be32(bp, (((BRG_UART_CLK / rate) - 1) << 1) | CPM_BRG_EN);
|
||||
|
||||
cpm2_unmap(bp);
|
||||
}
|
||||
|
||||
/* This function is used to set high speed synchronous baud rate
|
||||
* clocks.
|
||||
*/
|
||||
void
|
||||
cpm2_fastbrg(uint brg, uint rate, int div16)
|
||||
{
|
||||
u32 __iomem *bp;
|
||||
u32 val;
|
||||
|
||||
if (brg < 4) {
|
||||
bp = cpm2_map_size(im_brgc1, 16);
|
||||
} else {
|
||||
bp = cpm2_map_size(im_brgc5, 16);
|
||||
brg -= 4;
|
||||
}
|
||||
bp += brg;
|
||||
val = ((BRG_INT_CLK / rate) << 1) | CPM_BRG_EN;
|
||||
val = (((clk / rate) - 1) << 1) | CPM_BRG_EN | src;
|
||||
if (div16)
|
||||
val |= CPM_BRG_DIV16;
|
||||
|
||||
out_be32(bp, val);
|
||||
cpm2_unmap(bp);
|
||||
}
|
||||
EXPORT_SYMBOL(__cpm2_setbrg);
|
||||
|
||||
int cpm2_clk_setup(enum cpm_clk_target target, int clock, int mode)
|
||||
{
|
||||
|
Reference in New Issue
Block a user