qe: change qe_setbrg() to take an enum qe_clock instead of an integer
qe_setbrg() currently takes an integer to indicate the BRG number. Change that to take an enum qe_clock instead, since this enum is intended to represent clock sources.
---
This patch applies to Kumar's for-2.6.25 branch. You might need to apply my other patch, "qe: fix device tree lookup code in qe_muram_init()", first.
It's safe to change the parameters to qe_setbrg() because no one is using that function yet.
arch/powerpc/sysdev/qe_lib/qe.c | 12 +++-- include/asm-powerpc/qe.h | 94 +++++++++++++++++++------------------- 2 files changed, 54 insertions(+), 52 deletions(-)
arch/powerpc/sysdev/qe_lib/qe.c +7 -5
@@ -167,19 +167,20 @@ unsigned int get_brg_clk(void)/* Program the BRG to the given sampling rate and multiplier * -* @brg: the BRG, 1-16 +* @brg: the BRG, QE_BRG1 - QE_BRG16 * @rate: the desired sampling rate * @multiplier: corresponds to the value programmed in GUMR_L[RDCR] or * GUMR_L[TDCR]. E.g., if this BRG is the RX clock, and GUMR_L[RDCR]=01, * then 'multiplier' should be 8. -* -* Also note that the value programmed into the BRGC register must be even. */ -void qe_setbrg (unsigned int brg,unsigned int rate,unsigned int multiplier) +void qe_setbrg (enum qe_clock brg,unsigned int rate,unsigned int multiplier) {u32 divisor, tempval;u32 div16 =0 ; +if ((brg <QE_BRG1 ) || (brg >QE_BRG16 )) +return ; + divisor =get_brg_clk () / (rate * multiplier);if (divisor >QE_BRGC_DIVISOR_MAX +1 ) {
@@ -196,8 +197,9 @@ void qe_setbrg(unsigned int brg, unsigned int rate, unsigned int multiplier) tempval = ((divisor -1 ) <<QE_BRGC_DIVISOR_SHIFT ) |QE_BRGC_ENABLE | div16; -out_be32 (&qe_immr->brg.brgc[brg -1 ], tempval); +out_be32 (&qe_immr->brg.brgc[brg -QE_BRG1 ], tempval); } +EXPORT_SYMBOL (qe_setbrg);/* Initialize SNUMs (thread serial numbers) according to * QE Module Control chapter, SNUM table
include/asm-powerpc/qe.h +47 -47
112 lines not on this page · raw message
Signature · 1 line
1.5.2.4
Quoted 45 lines · Timur Tabi
qe_setbrg()currently takes an integer to indicate the BRG number. Change that to take an enumqe_clockinstead, since this enum is intended to represent clock sources.Signed-off-by Timur Tabi <[email protected]>---
This patch applies to Kumar's for-2.6.25 branch. You might need to apply my other patch, "qe: fix device tree lookup code in
qe_muram_init()", first.It's safe to change the parameters to
qe_setbrg()because no one is using that function yet.arch/powerpc/sysdev/qe_lib/qe.c | 12 +++-- include/asm-powerpc/qe.h | 94 ++++++++++++++++++ +------------------- 2 files changed, 54 insertions(+), 52 deletions(-)arch/powerpc/sysdev/qe_lib/qe.c +1
-3@@ -167,19 +167,20 @@ unsigned int get_brg_clk(void)/* Program the BRG to the given sampling rate and multiplier * -* @brg: the BRG, 1-16 +* @brg: the BRG, QE_BRG1 - QE_BRG16 * @rate: the desired sampling rate * @multiplier: corresponds to the value programmed in GUMR_L[RDCR] or * GUMR_L[TDCR]. E.g., if this BRG is the RX clock, and GUMR_L[RDCR]=01, * then 'multiplier' should be 8. -* -* Also note that the value programmed into the BRGC register must be even.
*/
-voidqe_setbrg(unsigned int brg, unsigned int rate, unsigned int multiplier)
+voidqe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier){ u32 divisor, tempval; u32 div16 = 0;
arch/powerpc/sysdev/qe_lib/qe.c unsigned int get_brg_clk(void) · line 182
Quoted 2 lines
arch/powerpc/sysdev/qe_lib/qe.c +2
-0+if ((brg <QE_BRG1 ) || (brg >QE_BRG16 )) +return ;
seems like we should report some form of error like -EINVAL instead.
Quoted 16 lines
+
divisor = get_brg_clk() / (rate * multiplier); if (divisor > QE_BRGC_DIVISOR_MAX + 1) {arch/powerpc/sysdev/qe_lib/qe.c +2
-1@@ -196,8 +197,9 @@ void qe_setbrg(unsigned int brg, unsigned int rate, unsigned int multiplier) tempval = ((divisor -1 ) <<QE_BRGC_DIVISOR_SHIFT ) |QE_BRGC_ENABLE | div16; -out_be32 (&qe_immr->brg.brgc[brg -1 ], tempval); +out_be32 (&qe_immr->brg.brgc[brg -QE_BRG1 ], tempval); } +EXPORT_SYMBOL (qe_setbrg);/* Initialize SNUMs (thread serial numbers) according to
Quoted 1 line
* QE Module Control chapter, SNUM table
- k