diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2008-05-23 12:38:56 -0400 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2008-06-10 11:39:13 -0400 |
commit | 5e41486c408eb4206aee09303631427f57771691 (patch) | |
tree | 04198c2fdffdb70816ba141aaa2f2b1d6d8e72aa /arch/powerpc/sysdev/qe_lib/usb.c | |
parent | 83ff9dcf375c418ca3b98eb950711525ca1269e2 (diff) |
powerpc/QE: add support for QE USB clocks routing
This patch adds a function to the qe_lib to setup QE USB clocks routing.
To setup clocks safely, cmxgcr register needs locking, so I just reused
ucc_lock since it was used only to protect cmxgcr.
The idea behind placing clocks routing functions into the qe_lib is that
later we'll hopefully switch to the generic Linux Clock API, thus, for
example, FHCI driver may be used for QE and CPM chips without nasty #ifdefs.
This patch also fixes QE_USB_RESTART_TX command definition in the qe.h.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Acked-By: Timur Tabi <timur@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/sysdev/qe_lib/usb.c')
-rw-r--r-- | arch/powerpc/sysdev/qe_lib/usb.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/arch/powerpc/sysdev/qe_lib/usb.c b/arch/powerpc/sysdev/qe_lib/usb.c new file mode 100644 index 000000000000..8105462078eb --- /dev/null +++ b/arch/powerpc/sysdev/qe_lib/usb.c | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | * QE USB routines | ||
3 | * | ||
4 | * Copyright (c) Freescale Semicondutor, Inc. 2006. | ||
5 | * Shlomi Gridish <gridish@freescale.com> | ||
6 | * Jerry Huang <Chang-Ming.Huang@freescale.com> | ||
7 | * Copyright (c) MontaVista Software, Inc. 2008. | ||
8 | * Anton Vorontsov <avorontsov@ru.mvista.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License as published by the | ||
12 | * Free Software Foundation; either version 2 of the License, or (at your | ||
13 | * option) any later version. | ||
14 | */ | ||
15 | |||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/errno.h> | ||
18 | #include <linux/io.h> | ||
19 | #include <asm/immap_qe.h> | ||
20 | #include <asm/qe.h> | ||
21 | |||
22 | int qe_usb_clock_set(enum qe_clock clk, int rate) | ||
23 | { | ||
24 | struct qe_mux __iomem *mux = &qe_immr->qmx; | ||
25 | unsigned long flags; | ||
26 | u32 val; | ||
27 | |||
28 | switch (clk) { | ||
29 | case QE_CLK3: val = QE_CMXGCR_USBCS_CLK3; break; | ||
30 | case QE_CLK5: val = QE_CMXGCR_USBCS_CLK5; break; | ||
31 | case QE_CLK7: val = QE_CMXGCR_USBCS_CLK7; break; | ||
32 | case QE_CLK9: val = QE_CMXGCR_USBCS_CLK9; break; | ||
33 | case QE_CLK13: val = QE_CMXGCR_USBCS_CLK13; break; | ||
34 | case QE_CLK17: val = QE_CMXGCR_USBCS_CLK17; break; | ||
35 | case QE_CLK19: val = QE_CMXGCR_USBCS_CLK19; break; | ||
36 | case QE_CLK21: val = QE_CMXGCR_USBCS_CLK21; break; | ||
37 | case QE_BRG9: val = QE_CMXGCR_USBCS_BRG9; break; | ||
38 | case QE_BRG10: val = QE_CMXGCR_USBCS_BRG10; break; | ||
39 | default: | ||
40 | pr_err("%s: requested unknown clock %d\n", __func__, clk); | ||
41 | return -EINVAL; | ||
42 | } | ||
43 | |||
44 | if (qe_clock_is_brg(clk)) | ||
45 | qe_setbrg(clk, rate, 1); | ||
46 | |||
47 | spin_lock_irqsave(&cmxgcr_lock, flags); | ||
48 | |||
49 | clrsetbits_be32(&mux->cmxgcr, QE_CMXGCR_USBCS, val); | ||
50 | |||
51 | spin_unlock_irqrestore(&cmxgcr_lock, flags); | ||
52 | |||
53 | return 0; | ||
54 | } | ||
55 | EXPORT_SYMBOL(qe_usb_clock_set); | ||