aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2008-05-23 12:39:06 -0400
committerKumar Gala <galak@kernel.crashing.org>2008-06-10 12:11:21 -0400
commit5093bb965a163fe288c3e5db0275165f86c895c2 (patch)
tree77af9fbf28f45e277443be5abffb85feacc0097c
parentb13e930906b313d787f4dd07fe78b74a3a8c22c4 (diff)
powerpc/QE: switch to the cpm_muram implementation
This is very trivial patch. We're transitioning to the cpm_muram_* calls. That's it. Less trivial changes: - BD_SC_* defines were defined in the cpm.h and qe.h, so to avoid redefines we remove BD_SC from the qe.h and use cpm.h along with cpm_muram_* prototypes; - qe_muram_dump was unused and thus removed; - added some code to the cpm_common.c to support legacy QE bindings (data-only node name). - For convenience, define qe_* calls to cpm_*. So drivers need not to be changed. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
-rw-r--r--arch/powerpc/sysdev/Makefile1
-rw-r--r--arch/powerpc/sysdev/cpm_common.c16
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe.c92
-rw-r--r--include/asm-powerpc/cpm.h1
-rw-r--r--include/asm-powerpc/qe.h36
5 files changed, 23 insertions, 123 deletions
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 2bfbb39380e9..16a0ed28eb00 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -42,6 +42,7 @@ endif
42ifeq ($(ARCH),powerpc) 42ifeq ($(ARCH),powerpc)
43obj-$(CONFIG_CPM) += cpm_common.o 43obj-$(CONFIG_CPM) += cpm_common.o
44obj-$(CONFIG_CPM2) += cpm2.o cpm2_pic.o 44obj-$(CONFIG_CPM2) += cpm2.o cpm2_pic.o
45obj-$(CONFIG_QUICC_ENGINE) += cpm_common.o
45obj-$(CONFIG_PPC_DCR) += dcr.o 46obj-$(CONFIG_PPC_DCR) += dcr.o
46obj-$(CONFIG_8xx) += mpc8xx_pic.o cpm1.o 47obj-$(CONFIG_8xx) += mpc8xx_pic.o cpm1.o
47obj-$(CONFIG_UCODE_PATCH) += micropatch.o 48obj-$(CONFIG_UCODE_PATCH) += micropatch.o
diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c
index cb7df2dce44f..9b75d164bdf9 100644
--- a/arch/powerpc/sysdev/cpm_common.c
+++ b/arch/powerpc/sysdev/cpm_common.c
@@ -85,9 +85,13 @@ int __init cpm_muram_init(void)
85 85
86 np = of_find_compatible_node(NULL, NULL, "fsl,cpm-muram-data"); 86 np = of_find_compatible_node(NULL, NULL, "fsl,cpm-muram-data");
87 if (!np) { 87 if (!np) {
88 printk(KERN_ERR "Cannot find CPM muram data node"); 88 /* try legacy bindings */
89 ret = -ENODEV; 89 np = of_find_node_by_name(NULL, "data-only");
90 goto out; 90 if (!np) {
91 printk(KERN_ERR "Cannot find CPM muram data node");
92 ret = -ENODEV;
93 goto out;
94 }
91 } 95 }
92 96
93 muram_pbase = of_translate_address(np, zero); 97 muram_pbase = of_translate_address(np, zero);
@@ -189,6 +193,12 @@ void __iomem *cpm_muram_addr(unsigned long offset)
189} 193}
190EXPORT_SYMBOL(cpm_muram_addr); 194EXPORT_SYMBOL(cpm_muram_addr);
191 195
196unsigned long cpm_muram_offset(void __iomem *addr)
197{
198 return addr - (void __iomem *)muram_vbase;
199}
200EXPORT_SYMBOL(cpm_muram_offset);
201
192/** 202/**
193 * cpm_muram_dma - turn a muram virtual address into a DMA address 203 * cpm_muram_dma - turn a muram virtual address into a DMA address
194 * @offset: virtual address from cpm_muram_addr() to convert 204 * @offset: virtual address from cpm_muram_addr() to convert
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index cff550eec7e8..28e05df952de 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -35,7 +35,6 @@
35#include <asm/rheap.h> 35#include <asm/rheap.h>
36 36
37static void qe_snums_init(void); 37static void qe_snums_init(void);
38static void qe_muram_init(void);
39static int qe_sdma_init(void); 38static int qe_sdma_init(void);
40 39
41static DEFINE_SPINLOCK(qe_lock); 40static DEFINE_SPINLOCK(qe_lock);
@@ -325,97 +324,6 @@ static int qe_sdma_init(void)
325 return 0; 324 return 0;
326} 325}
327 326
328/*
329 * muram_alloc / muram_free bits.
330 */
331static DEFINE_SPINLOCK(qe_muram_lock);
332
333/* 16 blocks should be enough to satisfy all requests
334 * until the memory subsystem goes up... */
335static rh_block_t qe_boot_muram_rh_block[16];
336static rh_info_t qe_muram_info;
337
338static void qe_muram_init(void)
339{
340 struct device_node *np;
341 const u32 *address;
342 u64 size;
343 unsigned int flags;
344
345 /* initialize the info header */
346 rh_init(&qe_muram_info, 1,
347 sizeof(qe_boot_muram_rh_block) /
348 sizeof(qe_boot_muram_rh_block[0]), qe_boot_muram_rh_block);
349
350 /* Attach the usable muram area */
351 /* XXX: This is a subset of the available muram. It
352 * varies with the processor and the microcode patches activated.
353 */
354 np = of_find_compatible_node(NULL, NULL, "fsl,qe-muram-data");
355 if (!np) {
356 np = of_find_node_by_name(NULL, "data-only");
357 if (!np) {
358 WARN_ON(1);
359 return;
360 }
361 }
362
363 address = of_get_address(np, 0, &size, &flags);
364 WARN_ON(!address);
365
366 of_node_put(np);
367 if (address)
368 rh_attach_region(&qe_muram_info, *address, (int)size);
369}
370
371/* This function returns an index into the MURAM area.
372 */
373unsigned long qe_muram_alloc(int size, int align)
374{
375 unsigned long start;
376 unsigned long flags;
377
378 spin_lock_irqsave(&qe_muram_lock, flags);
379 start = rh_alloc_align(&qe_muram_info, size, align, "QE");
380 spin_unlock_irqrestore(&qe_muram_lock, flags);
381
382 return start;
383}
384EXPORT_SYMBOL(qe_muram_alloc);
385
386int qe_muram_free(unsigned long offset)
387{
388 int ret;
389 unsigned long flags;
390
391 spin_lock_irqsave(&qe_muram_lock, flags);
392 ret = rh_free(&qe_muram_info, offset);
393 spin_unlock_irqrestore(&qe_muram_lock, flags);
394
395 return ret;
396}
397EXPORT_SYMBOL(qe_muram_free);
398
399/* not sure if this is ever needed */
400unsigned long qe_muram_alloc_fixed(unsigned long offset, int size)
401{
402 unsigned long start;
403 unsigned long flags;
404
405 spin_lock_irqsave(&qe_muram_lock, flags);
406 start = rh_alloc_fixed(&qe_muram_info, offset, size, "commproc");
407 spin_unlock_irqrestore(&qe_muram_lock, flags);
408
409 return start;
410}
411EXPORT_SYMBOL(qe_muram_alloc_fixed);
412
413void qe_muram_dump(void)
414{
415 rh_dump(&qe_muram_info);
416}
417EXPORT_SYMBOL(qe_muram_dump);
418
419/* The maximum number of RISCs we support */ 327/* The maximum number of RISCs we support */
420#define MAX_QE_RISC 2 328#define MAX_QE_RISC 2
421 329
diff --git a/include/asm-powerpc/cpm.h b/include/asm-powerpc/cpm.h
index ede38ffe466a..63a55337c2de 100644
--- a/include/asm-powerpc/cpm.h
+++ b/include/asm-powerpc/cpm.h
@@ -96,6 +96,7 @@ unsigned long cpm_muram_alloc(unsigned long size, unsigned long align);
96int cpm_muram_free(unsigned long offset); 96int cpm_muram_free(unsigned long offset);
97unsigned long cpm_muram_alloc_fixed(unsigned long offset, unsigned long size); 97unsigned long cpm_muram_alloc_fixed(unsigned long offset, unsigned long size);
98void __iomem *cpm_muram_addr(unsigned long offset); 98void __iomem *cpm_muram_addr(unsigned long offset);
99unsigned long cpm_muram_offset(void __iomem *addr);
99dma_addr_t cpm_muram_dma(void __iomem *addr); 100dma_addr_t cpm_muram_dma(void __iomem *addr);
100int cpm_command(u32 command, u8 opcode); 101int cpm_command(u32 command, u8 opcode);
101 102
diff --git a/include/asm-powerpc/qe.h b/include/asm-powerpc/qe.h
index 01e3c70b93ab..80807fd6a706 100644
--- a/include/asm-powerpc/qe.h
+++ b/include/asm-powerpc/qe.h
@@ -17,6 +17,7 @@
17#ifdef __KERNEL__ 17#ifdef __KERNEL__
18 18
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <asm/cpm.h>
20#include <asm/immap_qe.h> 21#include <asm/immap_qe.h>
21 22
22#define QE_NUM_OF_SNUM 28 23#define QE_NUM_OF_SNUM 28
@@ -119,20 +120,13 @@ unsigned int qe_get_brg_clk(void);
119int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier); 120int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier);
120int qe_get_snum(void); 121int qe_get_snum(void);
121void qe_put_snum(u8 snum); 122void qe_put_snum(u8 snum);
122unsigned long qe_muram_alloc(int size, int align); 123/* we actually use cpm_muram implementation, define this for convenience */
123int qe_muram_free(unsigned long offset); 124#define qe_muram_init cpm_muram_init
124unsigned long qe_muram_alloc_fixed(unsigned long offset, int size); 125#define qe_muram_alloc cpm_muram_alloc
125void qe_muram_dump(void); 126#define qe_muram_alloc_fixed cpm_muram_alloc_fixed
126 127#define qe_muram_free cpm_muram_free
127static inline void __iomem *qe_muram_addr(unsigned long offset) 128#define qe_muram_addr cpm_muram_addr
128{ 129#define qe_muram_offset cpm_muram_offset
129 return (void __iomem *)&qe_immr->muram[offset];
130}
131
132static inline unsigned long qe_muram_offset(void __iomem *addr)
133{
134 return addr - (void __iomem *)qe_immr->muram;
135}
136 130
137/* Structure that defines QE firmware binary files. 131/* Structure that defines QE firmware binary files.
138 * 132 *
@@ -199,20 +193,6 @@ struct qe_bd {
199#define BD_STATUS_MASK 0xffff0000 193#define BD_STATUS_MASK 0xffff0000
200#define BD_LENGTH_MASK 0x0000ffff 194#define BD_LENGTH_MASK 0x0000ffff
201 195
202#define BD_SC_EMPTY 0x8000 /* Receive is empty */
203#define BD_SC_READY 0x8000 /* Transmit is ready */
204#define BD_SC_WRAP 0x2000 /* Last buffer descriptor */
205#define BD_SC_INTRPT 0x1000 /* Interrupt on change */
206#define BD_SC_LAST 0x0800 /* Last buffer in frame */
207#define BD_SC_CM 0x0200 /* Continous mode */
208#define BD_SC_ID 0x0100 /* Rec'd too many idles */
209#define BD_SC_P 0x0100 /* xmt preamble */
210#define BD_SC_BR 0x0020 /* Break received */
211#define BD_SC_FR 0x0010 /* Framing error */
212#define BD_SC_PR 0x0008 /* Parity error */
213#define BD_SC_OV 0x0002 /* Overrun */
214#define BD_SC_CD 0x0001 /* ?? */
215
216/* Alignment */ 196/* Alignment */
217#define QE_INTR_TABLE_ALIGN 16 /* ??? */ 197#define QE_INTR_TABLE_ALIGN 16 /* ??? */
218#define QE_ALIGNMENT_OF_BD 8 198#define QE_ALIGNMENT_OF_BD 8