]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
[POWERPC] qe: add function qe_clock_source()
authorTimur Tabi <timur@freescale.com>
Mon, 3 Dec 2007 21:17:58 +0000 (15:17 -0600)
committerKumar Gala <galak@kernel.crashing.org>
Fri, 14 Dec 2007 04:59:27 +0000 (22:59 -0600)
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>
Documentation/powerpc/booting-without-of.txt
arch/powerpc/sysdev/qe_lib/qe.c
include/asm-powerpc/qe.h

index c3fc9d955030ea167e107d2bd132e4739f6dc56a..ee0209a7de3ee62d810c060e72ec69ad17f2d4c1 100644 (file)
@@ -1629,6 +1629,19 @@ platforms are moved over to use the flattened-device-tree model.
    - interrupt-parent : the phandle for the interrupt controller that
      services interrupts for this device.
    - pio-handle : The phandle for the Parallel I/O port configuration.
+   - rx-clock-name: the UCC receive clock source
+     "none": clock source is disabled
+     "brg1" through "brg16": clock source is BRG1-BRG16, respectively
+     "clk1" through "clk24": clock source is CLK1-CLK24, respectively
+   - tx-clock-name: the UCC transmit clock source
+     "none": clock source is disabled
+     "brg1" through "brg16": clock source is BRG1-BRG16, respectively
+     "clk1" through "clk24": clock source is CLK1-CLK24, respectively
+   The following two properties are deprecated.  rx-clock has been replaced
+   with rx-clock-name, and tx-clock has been replaced with tx-clock-name.
+   Drivers that currently use the deprecated properties should continue to
+   do so, in order to support older device trees, but they should be updated
+   to check for the new properties first.
    - rx-clock : represents the UCC receive clock source.
      0x00 : clock source is disabled;
      0x1~0x10 : clock source is BRG1~BRG16 respectively;
index 1df3b4a6832f7ef5d2dd0fff50ee5739824ff8b2..21e01061aca92735f8dd276824cf6a146dded2cd 100644 (file)
@@ -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
  */
index bcf60bef65247d58d476d1da81a49c58e15596e9..a24b7b14958fc5361e1680653f8d37c15babbd60 100644 (file)
@@ -84,6 +84,7 @@ extern int par_io_data_set(u8 port, u8 pin, u8 val);
 
 /* QE internal API */
 int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input);
+enum qe_clock qe_clock_source(const char *source);
 int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier);
 int qe_get_snum(void);
 void qe_put_snum(u8 snum);