aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2008-05-23 12:38:56 -0400
committerKumar Gala <galak@kernel.crashing.org>2008-06-10 11:39:13 -0400
commit5e41486c408eb4206aee09303631427f57771691 (patch)
tree04198c2fdffdb70816ba141aaa2f2b1d6d8e72aa
parent83ff9dcf375c418ca3b98eb950711525ca1269e2 (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>
-rw-r--r--arch/powerpc/sysdev/qe_lib/Kconfig4
-rw-r--r--arch/powerpc/sysdev/qe_lib/Makefile1
-rw-r--r--arch/powerpc/sysdev/qe_lib/ucc.c7
-rw-r--r--arch/powerpc/sysdev/qe_lib/usb.c55
-rw-r--r--include/asm-powerpc/qe.h23
5 files changed, 86 insertions, 4 deletions
diff --git a/arch/powerpc/sysdev/qe_lib/Kconfig b/arch/powerpc/sysdev/qe_lib/Kconfig
index adc66212a419..76ffbc48d4b9 100644
--- a/arch/powerpc/sysdev/qe_lib/Kconfig
+++ b/arch/powerpc/sysdev/qe_lib/Kconfig
@@ -20,3 +20,7 @@ config UCC
20 bool 20 bool
21 default y if UCC_FAST || UCC_SLOW 21 default y if UCC_FAST || UCC_SLOW
22 22
23config QE_USB
24 bool
25 help
26 QE USB Host Controller support
diff --git a/arch/powerpc/sysdev/qe_lib/Makefile b/arch/powerpc/sysdev/qe_lib/Makefile
index 874fe1a5b1cf..e9ff8884f74a 100644
--- a/arch/powerpc/sysdev/qe_lib/Makefile
+++ b/arch/powerpc/sysdev/qe_lib/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_QUICC_ENGINE)+= qe.o qe_ic.o qe_io.o
6obj-$(CONFIG_UCC) += ucc.o 6obj-$(CONFIG_UCC) += ucc.o
7obj-$(CONFIG_UCC_SLOW) += ucc_slow.o 7obj-$(CONFIG_UCC_SLOW) += ucc_slow.o
8obj-$(CONFIG_UCC_FAST) += ucc_fast.o 8obj-$(CONFIG_UCC_FAST) += ucc_fast.o
9obj-$(CONFIG_QE_USB) += usb.o
diff --git a/arch/powerpc/sysdev/qe_lib/ucc.c b/arch/powerpc/sysdev/qe_lib/ucc.c
index 0e348d9af8a6..d3c7f5af9bc8 100644
--- a/arch/powerpc/sysdev/qe_lib/ucc.c
+++ b/arch/powerpc/sysdev/qe_lib/ucc.c
@@ -26,7 +26,8 @@
26#include <asm/qe.h> 26#include <asm/qe.h>
27#include <asm/ucc.h> 27#include <asm/ucc.h>
28 28
29static DEFINE_SPINLOCK(ucc_lock); 29DEFINE_SPINLOCK(cmxgcr_lock);
30EXPORT_SYMBOL(cmxgcr_lock);
30 31
31int ucc_set_qe_mux_mii_mng(unsigned int ucc_num) 32int ucc_set_qe_mux_mii_mng(unsigned int ucc_num)
32{ 33{
@@ -35,10 +36,10 @@ int ucc_set_qe_mux_mii_mng(unsigned int ucc_num)
35 if (ucc_num > UCC_MAX_NUM - 1) 36 if (ucc_num > UCC_MAX_NUM - 1)
36 return -EINVAL; 37 return -EINVAL;
37 38
38 spin_lock_irqsave(&ucc_lock, flags); 39 spin_lock_irqsave(&cmxgcr_lock, flags);
39 clrsetbits_be32(&qe_immr->qmx.cmxgcr, QE_CMXGCR_MII_ENET_MNG, 40 clrsetbits_be32(&qe_immr->qmx.cmxgcr, QE_CMXGCR_MII_ENET_MNG,
40 ucc_num << QE_CMXGCR_MII_ENET_MNG_SHIFT); 41 ucc_num << QE_CMXGCR_MII_ENET_MNG_SHIFT);
41 spin_unlock_irqrestore(&ucc_lock, flags); 42 spin_unlock_irqrestore(&cmxgcr_lock, flags);
42 43
43 return 0; 44 return 0;
44} 45}
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
22int 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}
55EXPORT_SYMBOL(qe_usb_clock_set);
diff --git a/include/asm-powerpc/qe.h b/include/asm-powerpc/qe.h
index c3be6e2e1490..d217288ec6bf 100644
--- a/include/asm-powerpc/qe.h
+++ b/include/asm-powerpc/qe.h
@@ -16,6 +16,7 @@
16#define _ASM_POWERPC_QE_H 16#define _ASM_POWERPC_QE_H
17#ifdef __KERNEL__ 17#ifdef __KERNEL__
18 18
19#include <linux/spinlock.h>
19#include <asm/immap_qe.h> 20#include <asm/immap_qe.h>
20 21
21#define QE_NUM_OF_SNUM 28 22#define QE_NUM_OF_SNUM 28
@@ -74,6 +75,13 @@ enum qe_clock {
74 QE_CLK_DUMMY 75 QE_CLK_DUMMY
75}; 76};
76 77
78static inline bool qe_clock_is_brg(enum qe_clock clk)
79{
80 return clk >= QE_BRG1 && clk <= QE_BRG16;
81}
82
83extern spinlock_t cmxgcr_lock;
84
77/* Export QE common operations */ 85/* Export QE common operations */
78extern void qe_reset(void); 86extern void qe_reset(void);
79extern int par_io_init(struct device_node *np); 87extern int par_io_init(struct device_node *np);
@@ -156,6 +164,9 @@ int qe_upload_firmware(const struct qe_firmware *firmware);
156/* Obtain information on the uploaded firmware */ 164/* Obtain information on the uploaded firmware */
157struct qe_firmware_info *qe_get_firmware_info(void); 165struct qe_firmware_info *qe_get_firmware_info(void);
158 166
167/* QE USB */
168int qe_usb_clock_set(enum qe_clock clk, int rate);
169
159/* Buffer descriptors */ 170/* Buffer descriptors */
160struct qe_bd { 171struct qe_bd {
161 __be16 status; 172 __be16 status;
@@ -254,6 +265,16 @@ enum comm_dir {
254#define QE_CMXGCR_MII_ENET_MNG 0x00007000 265#define QE_CMXGCR_MII_ENET_MNG 0x00007000
255#define QE_CMXGCR_MII_ENET_MNG_SHIFT 12 266#define QE_CMXGCR_MII_ENET_MNG_SHIFT 12
256#define QE_CMXGCR_USBCS 0x0000000f 267#define QE_CMXGCR_USBCS 0x0000000f
268#define QE_CMXGCR_USBCS_CLK3 0x1
269#define QE_CMXGCR_USBCS_CLK5 0x2
270#define QE_CMXGCR_USBCS_CLK7 0x3
271#define QE_CMXGCR_USBCS_CLK9 0x4
272#define QE_CMXGCR_USBCS_CLK13 0x5
273#define QE_CMXGCR_USBCS_CLK17 0x6
274#define QE_CMXGCR_USBCS_CLK19 0x7
275#define QE_CMXGCR_USBCS_CLK21 0x8
276#define QE_CMXGCR_USBCS_BRG9 0x9
277#define QE_CMXGCR_USBCS_BRG10 0xa
257 278
258/* QE CECR Commands. 279/* QE CECR Commands.
259*/ 280*/
@@ -283,7 +304,7 @@ enum comm_dir {
283#define QE_HPAC_START_TX 0x0000060b 304#define QE_HPAC_START_TX 0x0000060b
284#define QE_HPAC_START_RX 0x0000070b 305#define QE_HPAC_START_RX 0x0000070b
285#define QE_USB_STOP_TX 0x0000000a 306#define QE_USB_STOP_TX 0x0000000a
286#define QE_USB_RESTART_TX 0x0000000b 307#define QE_USB_RESTART_TX 0x0000000c
287#define QE_QMC_STOP_TX 0x0000000c 308#define QE_QMC_STOP_TX 0x0000000c
288#define QE_QMC_STOP_RX 0x0000000d 309#define QE_QMC_STOP_RX 0x0000000d
289#define QE_SS7_SU_FIL_RESET 0x0000000e 310#define QE_SS7_SU_FIL_RESET 0x0000000e