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>
This commit is contained in:
Anton Vorontsov 2008-05-23 20:39:06 +04:00 committed by Kumar Gala
parent b13e930906
commit 5093bb965a
5 changed files with 23 additions and 123 deletions

View File

@ -42,6 +42,7 @@ endif
ifeq ($(ARCH),powerpc) ifeq ($(ARCH),powerpc)
obj-$(CONFIG_CPM) += cpm_common.o obj-$(CONFIG_CPM) += cpm_common.o
obj-$(CONFIG_CPM2) += cpm2.o cpm2_pic.o obj-$(CONFIG_CPM2) += cpm2.o cpm2_pic.o
obj-$(CONFIG_QUICC_ENGINE) += cpm_common.o
obj-$(CONFIG_PPC_DCR) += dcr.o obj-$(CONFIG_PPC_DCR) += dcr.o
obj-$(CONFIG_8xx) += mpc8xx_pic.o cpm1.o obj-$(CONFIG_8xx) += mpc8xx_pic.o cpm1.o
obj-$(CONFIG_UCODE_PATCH) += micropatch.o obj-$(CONFIG_UCODE_PATCH) += micropatch.o

View File

@ -85,9 +85,13 @@ int __init cpm_muram_init(void)
np = of_find_compatible_node(NULL, NULL, "fsl,cpm-muram-data"); np = of_find_compatible_node(NULL, NULL, "fsl,cpm-muram-data");
if (!np) { if (!np) {
printk(KERN_ERR "Cannot find CPM muram data node"); /* try legacy bindings */
ret = -ENODEV; np = of_find_node_by_name(NULL, "data-only");
goto out; if (!np) {
printk(KERN_ERR "Cannot find CPM muram data node");
ret = -ENODEV;
goto out;
}
} }
muram_pbase = of_translate_address(np, zero); muram_pbase = of_translate_address(np, zero);
@ -189,6 +193,12 @@ void __iomem *cpm_muram_addr(unsigned long offset)
} }
EXPORT_SYMBOL(cpm_muram_addr); EXPORT_SYMBOL(cpm_muram_addr);
unsigned long cpm_muram_offset(void __iomem *addr)
{
return addr - (void __iomem *)muram_vbase;
}
EXPORT_SYMBOL(cpm_muram_offset);
/** /**
* cpm_muram_dma - turn a muram virtual address into a DMA address * cpm_muram_dma - turn a muram virtual address into a DMA address
* @offset: virtual address from cpm_muram_addr() to convert * @offset: virtual address from cpm_muram_addr() to convert

View File

@ -35,7 +35,6 @@
#include <asm/rheap.h> #include <asm/rheap.h>
static void qe_snums_init(void); static void qe_snums_init(void);
static void qe_muram_init(void);
static int qe_sdma_init(void); static int qe_sdma_init(void);
static DEFINE_SPINLOCK(qe_lock); static DEFINE_SPINLOCK(qe_lock);
@ -325,97 +324,6 @@ static int qe_sdma_init(void)
return 0; return 0;
} }
/*
* muram_alloc / muram_free bits.
*/
static DEFINE_SPINLOCK(qe_muram_lock);
/* 16 blocks should be enough to satisfy all requests
* until the memory subsystem goes up... */
static rh_block_t qe_boot_muram_rh_block[16];
static rh_info_t qe_muram_info;
static void qe_muram_init(void)
{
struct device_node *np;
const u32 *address;
u64 size;
unsigned int flags;
/* initialize the info header */
rh_init(&qe_muram_info, 1,
sizeof(qe_boot_muram_rh_block) /
sizeof(qe_boot_muram_rh_block[0]), qe_boot_muram_rh_block);
/* Attach the usable muram area */
/* XXX: This is a subset of the available muram. It
* varies with the processor and the microcode patches activated.
*/
np = of_find_compatible_node(NULL, NULL, "fsl,qe-muram-data");
if (!np) {
np = of_find_node_by_name(NULL, "data-only");
if (!np) {
WARN_ON(1);
return;
}
}
address = of_get_address(np, 0, &size, &flags);
WARN_ON(!address);
of_node_put(np);
if (address)
rh_attach_region(&qe_muram_info, *address, (int)size);
}
/* This function returns an index into the MURAM area.
*/
unsigned long qe_muram_alloc(int size, int align)
{
unsigned long start;
unsigned long flags;
spin_lock_irqsave(&qe_muram_lock, flags);
start = rh_alloc_align(&qe_muram_info, size, align, "QE");
spin_unlock_irqrestore(&qe_muram_lock, flags);
return start;
}
EXPORT_SYMBOL(qe_muram_alloc);
int qe_muram_free(unsigned long offset)
{
int ret;
unsigned long flags;
spin_lock_irqsave(&qe_muram_lock, flags);
ret = rh_free(&qe_muram_info, offset);
spin_unlock_irqrestore(&qe_muram_lock, flags);
return ret;
}
EXPORT_SYMBOL(qe_muram_free);
/* not sure if this is ever needed */
unsigned long qe_muram_alloc_fixed(unsigned long offset, int size)
{
unsigned long start;
unsigned long flags;
spin_lock_irqsave(&qe_muram_lock, flags);
start = rh_alloc_fixed(&qe_muram_info, offset, size, "commproc");
spin_unlock_irqrestore(&qe_muram_lock, flags);
return start;
}
EXPORT_SYMBOL(qe_muram_alloc_fixed);
void qe_muram_dump(void)
{
rh_dump(&qe_muram_info);
}
EXPORT_SYMBOL(qe_muram_dump);
/* The maximum number of RISCs we support */ /* The maximum number of RISCs we support */
#define MAX_QE_RISC 2 #define MAX_QE_RISC 2

View File

@ -96,6 +96,7 @@ unsigned long cpm_muram_alloc(unsigned long size, unsigned long align);
int cpm_muram_free(unsigned long offset); int cpm_muram_free(unsigned long offset);
unsigned long cpm_muram_alloc_fixed(unsigned long offset, unsigned long size); unsigned long cpm_muram_alloc_fixed(unsigned long offset, unsigned long size);
void __iomem *cpm_muram_addr(unsigned long offset); void __iomem *cpm_muram_addr(unsigned long offset);
unsigned long cpm_muram_offset(void __iomem *addr);
dma_addr_t cpm_muram_dma(void __iomem *addr); dma_addr_t cpm_muram_dma(void __iomem *addr);
int cpm_command(u32 command, u8 opcode); int cpm_command(u32 command, u8 opcode);

View File

@ -17,6 +17,7 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <asm/cpm.h>
#include <asm/immap_qe.h> #include <asm/immap_qe.h>
#define QE_NUM_OF_SNUM 28 #define QE_NUM_OF_SNUM 28
@ -119,20 +120,13 @@ unsigned int qe_get_brg_clk(void);
int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier); int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier);
int qe_get_snum(void); int qe_get_snum(void);
void qe_put_snum(u8 snum); void qe_put_snum(u8 snum);
unsigned long qe_muram_alloc(int size, int align); /* we actually use cpm_muram implementation, define this for convenience */
int qe_muram_free(unsigned long offset); #define qe_muram_init cpm_muram_init
unsigned long qe_muram_alloc_fixed(unsigned long offset, int size); #define qe_muram_alloc cpm_muram_alloc
void qe_muram_dump(void); #define qe_muram_alloc_fixed cpm_muram_alloc_fixed
#define qe_muram_free cpm_muram_free
static inline void __iomem *qe_muram_addr(unsigned long offset) #define qe_muram_addr cpm_muram_addr
{ #define qe_muram_offset cpm_muram_offset
return (void __iomem *)&qe_immr->muram[offset];
}
static inline unsigned long qe_muram_offset(void __iomem *addr)
{
return addr - (void __iomem *)qe_immr->muram;
}
/* Structure that defines QE firmware binary files. /* Structure that defines QE firmware binary files.
* *
@ -199,20 +193,6 @@ struct qe_bd {
#define BD_STATUS_MASK 0xffff0000 #define BD_STATUS_MASK 0xffff0000
#define BD_LENGTH_MASK 0x0000ffff #define BD_LENGTH_MASK 0x0000ffff
#define BD_SC_EMPTY 0x8000 /* Receive is empty */
#define BD_SC_READY 0x8000 /* Transmit is ready */
#define BD_SC_WRAP 0x2000 /* Last buffer descriptor */
#define BD_SC_INTRPT 0x1000 /* Interrupt on change */
#define BD_SC_LAST 0x0800 /* Last buffer in frame */
#define BD_SC_CM 0x0200 /* Continous mode */
#define BD_SC_ID 0x0100 /* Rec'd too many idles */
#define BD_SC_P 0x0100 /* xmt preamble */
#define BD_SC_BR 0x0020 /* Break received */
#define BD_SC_FR 0x0010 /* Framing error */
#define BD_SC_PR 0x0008 /* Parity error */
#define BD_SC_OV 0x0002 /* Overrun */
#define BD_SC_CD 0x0001 /* ?? */
/* Alignment */ /* Alignment */
#define QE_INTR_TABLE_ALIGN 16 /* ??? */ #define QE_INTR_TABLE_ALIGN 16 /* ??? */
#define QE_ALIGNMENT_OF_BD 8 #define QE_ALIGNMENT_OF_BD 8