]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/ppc/8xx_io/commproc.c
Pull misc into release branch
[linux-2.6-omap-h63xx.git] / arch / ppc / 8xx_io / commproc.c
index 3b23bcb35b7abf9f8b3bd1c2efc9373f53ac60db..7088428e1fe22e32e9abd27bbb015b5639123d6c 100644 (file)
 #include <asm/tlbflush.h>
 #include <asm/rheap.h>
 
+#define immr_map(member)                                               \
+({                                                                     \
+       u32 offset = offsetof(immap_t, member);                         \
+       void *addr = ioremap (IMAP_ADDR + offset,                       \
+                             sizeof( ((immap_t*)0)->member));          \
+       addr;                                                           \
+})
+
+#define immr_map_size(member, size)                                    \
+({                                                                     \
+       u32 offset = offsetof(immap_t, member);                         \
+       void *addr = ioremap (IMAP_ADDR + offset, size);                \
+       addr;                                                           \
+})
+
 static void m8xx_cpm_dpinit(void);
 static uint    host_buffer;    /* One page of host buffer */
 static uint    host_end;       /* end + 1 */
@@ -129,7 +144,7 @@ m8xx_cpm_reset(void)
 
        /* Set SDMA Bus Request priority 5.
         * On 860T, this also enables FEC priority 6.  I am not sure
-        * this is what we realy want for some applications, but the
+        * this is what we really want for some applications, but the
         * manual recommends it.
         * Bit 25, FAM can also be set to use FEC aggressive mode (860T).
         */
@@ -364,11 +379,16 @@ static rh_block_t cpm_boot_dpmem_rh_block[16];
 static rh_info_t cpm_dpmem_info;
 
 #define CPM_DPMEM_ALIGNMENT    8
+static u8* dpram_vbase;
+static uint dpram_pbase;
 
 void m8xx_cpm_dpinit(void)
 {
        spin_lock_init(&cpm_dpmem_lock);
 
+       dpram_vbase = immr_map_size(im_cpm.cp_dpmem, CPM_DATAONLY_BASE + CPM_DATAONLY_SIZE);
+       dpram_pbase = (uint)&((immap_t *)IMAP_ADDR)->im_cpm.cp_dpmem;
+
        /* Initialize the info header */
        rh_init(&cpm_dpmem_info, CPM_DPMEM_ALIGNMENT,
                        sizeof(cpm_boot_dpmem_rh_block) /
@@ -382,7 +402,7 @@ void m8xx_cpm_dpinit(void)
         * with the processor and the microcode patches applied / activated.
         * But the following should be at least safe.
         */
-       rh_attach_region(&cpm_dpmem_info, (void *)CPM_DATAONLY_BASE, CPM_DATAONLY_SIZE);
+       rh_attach_region(&cpm_dpmem_info, CPM_DATAONLY_BASE, CPM_DATAONLY_SIZE);
 }
 
 /*
@@ -390,9 +410,9 @@ void m8xx_cpm_dpinit(void)
  * This function returns an offset into the DPRAM area.
  * Use cpm_dpram_addr() to get the virtual address of the area.
  */
-uint cpm_dpalloc(uint size, uint align)
+unsigned long cpm_dpalloc(uint size, uint align)
 {
-       void *start;
+       unsigned long start;
        unsigned long flags;
 
        spin_lock_irqsave(&cpm_dpmem_lock, flags);
@@ -400,34 +420,34 @@ uint cpm_dpalloc(uint size, uint align)
        start = rh_alloc(&cpm_dpmem_info, size, "commproc");
        spin_unlock_irqrestore(&cpm_dpmem_lock, flags);
 
-       return (uint)start;
+       return start;
 }
 EXPORT_SYMBOL(cpm_dpalloc);
 
-int cpm_dpfree(uint offset)
+int cpm_dpfree(unsigned long offset)
 {
        int ret;
        unsigned long flags;
 
        spin_lock_irqsave(&cpm_dpmem_lock, flags);
-       ret = rh_free(&cpm_dpmem_info, (void *)offset);
+       ret = rh_free(&cpm_dpmem_info, offset);
        spin_unlock_irqrestore(&cpm_dpmem_lock, flags);
 
        return ret;
 }
 EXPORT_SYMBOL(cpm_dpfree);
 
-uint cpm_dpalloc_fixed(uint offset, uint size, uint align)
+unsigned long cpm_dpalloc_fixed(unsigned long offset, uint size, uint align)
 {
-       void *start;
+       unsigned long start;
        unsigned long flags;
 
        spin_lock_irqsave(&cpm_dpmem_lock, flags);
        cpm_dpmem_info.alignment = align;
-       start = rh_alloc_fixed(&cpm_dpmem_info, (void *)offset, size, "commproc");
+       start = rh_alloc_fixed(&cpm_dpmem_info, offset, size, "commproc");
        spin_unlock_irqrestore(&cpm_dpmem_lock, flags);
 
-       return (uint)start;
+       return start;
 }
 EXPORT_SYMBOL(cpm_dpalloc_fixed);
 
@@ -437,8 +457,14 @@ void cpm_dpdump(void)
 }
 EXPORT_SYMBOL(cpm_dpdump);
 
-void *cpm_dpram_addr(uint offset)
+void *cpm_dpram_addr(unsigned long offset)
 {
        return ((immap_t *)IMAP_ADDR)->im_cpm.cp_dpmem + offset;
 }
 EXPORT_SYMBOL(cpm_dpram_addr);
+
+uint cpm_dpram_phys(u8* addr)
+{
+       return (dpram_pbase + (uint)(addr - dpram_vbase));
+}
+EXPORT_SYMBOL(cpm_dpram_phys);