diff options
author | Timur Tabi <timur@freescale.com> | 2007-12-03 15:17:58 -0600 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2007-12-13 22:59:27 -0600 |
commit | 174b0da23199c4ae1ed06263dafd9a2e85e97d34 (patch) | |
tree | ef7e30bbc2b22269e46a08ab17823e5d43e6974f /arch/powerpc | |
parent | 255b09eb26bc285be5aad5c5606e96093094c41a (diff) |
[POWERPC] qe: add function qe_clock_source()
Add function qe_clock_source() which takes a string containing the name of a
QE clock source (as is typically found in device trees) and returns the
matching enum qe_clock value.
Update booting-without-of.txt to indicate that the UCC properties rx-clock
and tx-clock are deprecated and replaced with rx-clock-name and tx-clock-name,
which use strings instead of numbers to indicate QE clock sources.
Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/sysdev/qe_lib/qe.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c index 1df3b4a6832..21e01061aca 100644 --- a/arch/powerpc/sysdev/qe_lib/qe.c +++ b/arch/powerpc/sysdev/qe_lib/qe.c @@ -203,6 +203,38 @@ int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier) } EXPORT_SYMBOL(qe_setbrg); +/* Convert a string to a QE clock source enum + * + * This function takes a string, typically from a property in the device + * tree, and returns the corresponding "enum qe_clock" value. +*/ +enum qe_clock qe_clock_source(const char *source) +{ + unsigned int i; + + if (strcasecmp(source, "none") == 0) + return QE_CLK_NONE; + + if (strncasecmp(source, "brg", 3) == 0) { + i = simple_strtoul(source + 3, NULL, 10); + if ((i >= 1) && (i <= 16)) + return (QE_BRG1 - 1) + i; + else + return QE_CLK_DUMMY; + } + + if (strncasecmp(source, "clk", 3) == 0) { + i = simple_strtoul(source + 3, NULL, 10); + if ((i >= 1) && (i <= 24)) + return (QE_CLK1 - 1) + i; + else + return QE_CLK_DUMMY; + } + + return QE_CLK_DUMMY; +} +EXPORT_SYMBOL(qe_clock_source); + /* Initialize SNUMs (thread serial numbers) according to * QE Module Control chapter, SNUM table */ |