PATCH
Ralf,
Here is the 2.6 36 bit I/O support patch. We beat up on it quite a bit and it seems solid on the Au1x (Db1500 board).
Pete
Index: arch/mips/au1000/common/setup.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/au1000/common/setup.c,v retrieving revision 1.17
mips/au1000/common/setup.c +0 -7
@@ -56,10 +56,6 @@extern void au1x_time_init (void );extern void (*board_timer_setup)(struct irqaction *irq);extern void au1x_timer_setup (struct irqaction *irq); -#if defined(CONFIG_64BIT_PHYS_ADDR ) && (defined(CONFIG_SOC_AU1500 ) || defined(CONFIG_SOC_AU1550 )) -extern phys_t (*fixup_bigphys_addr)(phys_t phys_addr,phys_t size); -static phys_t au1500_fixup_bigphys_addr (phys_t phys_addr,phys_t size); -#endif extern void au1xxx_time_init (void );extern void au1xxx_timer_setup (struct irqaction *irq);extern void set_cpuspec (void );
@@ -147,9 +143,6 @@ _machine_power_off = au1000_power_off; board_time_init = au1xxx_time_init; board_timer_setup = au1xxx_timer_setup; -#if defined(CONFIG_64BIT_PHYS_ADDR ) && (defined(CONFIG_SOC_AU1500 ) || defined(CONFIG_SOC_AU1550 )) - fixup_bigphys_addr = au1500_fixup_bigphys_addr; -#endif /* IO/MEM resources. */ set_io_port_base (0 );
@@ -200,7 +193,7 @@ #if defined(CONFIG_64BIT_PHYS_ADDR) && (defined(CONFIG_SOC_AU1500) ||
defined(CONFIG_SOC_AU1550))
/* This routine should be valid for all Au1500 based boards */
-static phys_t au1500_fixup_bigphys_addr(phys_t phys_addr, phys_t size) +phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size)
{
u32 pci_start = (u32)Au1500_PCI_MEM_START;
u32 pci_end = (u32)Au1500_PCI_MEM_END;
Index: arch/mips/mm/Makefile
===================================================================
RCS file: /home/cvs/linux/arch/mips/mm/Makefile,v
retrieving revision 1.68
mips/mm/Makefile +2 -1
@@ -41,10 +41,11 @@ obj-$(CONFIG_CPU_RM7000) += tlbex32-r4k.o obj-$(CONFIG_CPU_RM9000) += tlbex32-r4k.o obj-$(CONFIG_CPU_R10000) += tlbex32-r4k.o -obj-$(CONFIG_CPU_MIPS32) += tlbex32-r4k.o +obj-$(CONFIG_CPU_MIPS32) += tlbex32-mips32.o obj-$(CONFIG_CPU_MIPS64) += tlbex32-r4k.o obj-$(CONFIG_CPU_SB1) += tlbex32-r4k.o obj-$(CONFIG_CPU_TX39XX) += tlbex32-r3k.o +obj-$(CONFIG_64BIT_PHYS_ADDR) += remap.o endif ifdef CONFIG_MIPS64 obj-$(CONFIG_CPU_R4300) += tlb64-glue-r4k.o tlbex64-r4k.o
Index: arch/mips/mm/ioremap.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/mm/ioremap.c,v retrieving revision 1.19
mips/mm/ioremap.c +13 -1
@@ -97,6 +97,15 @@ }/* +* Allow physical addresses to be fixed up to help 36 bit peripherals. +*/ +phys_t __attribute__ ((weak)) +fixup_bigphys_addr (phys_t phys_addr,phys_t size) +{ +return phys_addr; +} + +/* * Generic mapping function (not visible outside): */
@@ -110,7 +119,7 @@* caller shouldn't need to know that small detail. */ -#define IS_LOW512 (addr) (!((phys_t)(addr) & ~0x1fffffffUL)) +#define IS_LOW512 (addr) (!((phys_t)(addr) & (phys_t) ~0x1fffffffULL))void *__ioremap (phys_t phys_addr,phys_t size,unsigned long flags) {
@@ -119,6 +128,8 @@phys_t last_addr;void * addr; + phys_addr =fixup_bigphys_addr (phys_addr, size); +/* Don't allow wraparound or zero size */ last_addr = phys_addr + size -1 ;if (!size || last_addr < phys_addr)
@@ -190,3 +201,4 @@EXPORT_SYMBOL (__ioremap);EXPORT_SYMBOL (__iounmap); +EXPORT_SYMBOL (fixup_bigphys_addr);
Index: arch/mips/mm/remap.c
===================================================================
RCS file: arch/mips/mm/remap.c
mips/mm/remap.c new file +115 -0
115 lines not on this page · raw message
Index: arch/mips/mm/tlb-r4k.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/mm/tlb-r4k.c,v retrieving revision 1.38
mips/mm/tlb-r4k.c +8 -2
@@ -255,8 +255,14 @@ idx =read_c0_index (); ptep =pte_offset_map (pmdp, address); -write_c0_entrylo0 (pte_val (*ptep++) >>6 ); -write_c0_entrylo1 (pte_val (*ptep) >>6 ); +#if defined(CONFIG_64BIT_PHYS_ADDR ) && defined(CONFIG_CPU_MIPS32 ) +write_c0_entrylo0 (ptep->pte_high); + ptep++; +write_c0_entrylo1 (ptep->pte_high); +#else +write_c0_entrylo0 (pte_val (*ptep++) >>6 ); +write_c0_entrylo1 (pte_val (*ptep) >>6 ); +#endif write_c0_entryhi (address | pid);mtc0_tlbw_hazard ();if (idx <0 )
Index: arch/mips/mm/tlbex32-mips32.S
===================================================================
RCS file: arch/mips/mm/tlbex32-mips32.S
mips/mm/tlbex32-mips32.S new file +325 -0
325 lines not on this page · raw message
Index: include/asm-mips/addrspace.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/addrspace.h,v retrieving revision 1.13
asm-mips/addrspace.h +4 -0
@@ -80,7 +80,11 @@#define XKSSEG 0x4000000000000000#define XKPHYS 0x8000000000000000#define XKSEG 0xc000000000000000 +#if defined(CONFIG_64BIT_PHYS_ADDR ) && defined(CONFIG_CPU_MIPS32 ) +#define CKSEG0 0x80000000 +#else #define CKSEG0 0xffffffff80000000 +#endif #define CKSEG1 0xffffffffa0000000#define CKSSEG 0xffffffffc0000000#define CKSEG3 0xffffffffe0000000
Index: include/asm-mips/io.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/io.h,v
retrieving revision 1.72
asm-mips/io.h +1 -1
@@ -171,7 +171,7 @@extern void *__ioremap (phys_t offset,phys_t size,unsigned long flags);extern void __iounmap (void *addr); -static inline void *__ioremap_mode (unsigned long offset,unsigned long size, +static inline void *__ioremap_mode (phys_t offset,unsigned long size,unsigned long flags) {if (cpu_has_64bit_addresses) {
Index: include/asm-mips/page.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/page.h,v retrieving revision 1.44
asm-mips/page.h +10 -3
@@ -32,7 +32,7 @@#ifdef CONFIG_PAGE_SIZE_64KB #define PAGE_SHIFT 16#endif -#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_SIZE (1L << PAGE_SHIFT)#define PAGE_MASK (~(PAGE_SIZE-1))#ifdef __KERNEL__
@@ -75,15 +75,22 @@* These are used to make use of C type-checking.. */ #ifdef CONFIG_64BIT_PHYS_ADDR -typedef struct {unsigned long long pte; }pte_t ; +#ifdef CONFIG_CPU_MIPS32 +typedef struct {unsigned long pte_low, pte_high; }pte_t ; +#define pte_val (x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32)) +#else +typedef struct {unsigned long long pte; }pte_t ; +#define pte_val (x) ((x).pte) +#endif #else typedef struct {unsigned long pte; }pte_t ; +#define pte_val (x) ((x).pte)#endif +typedef struct {unsigned long pmd; }pmd_t ;typedef struct {unsigned long pgd; }pgd_t ;typedef struct {unsigned long pgprot; }pgprot_t ; -#define pte_val (x) ((x).pte)#define pmd_val (x) ((x).pmd)#define pgd_val (x) ((x).pgd)#define pgprot_val (x) ((x).pgprot)
Index: include/asm-mips/pgtable-32.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/pgtable-32.h,v retrieving revision 1.11
asm-mips/pgtable-32.h +14 -0
@@ -130,8 +130,21 @@static inline int pgd_present (pgd_t pgd) {return 1 ; }static inline void pgd_clear (pgd_t *pgdp) { } +#if defined(CONFIG_64BIT_PHYS_ADDR ) && defined(CONFIG_MIPS32 )#define pte_page (x) pfn_to_page(pte_pfn(x)) +#define pte_pfn (x) ((unsigned long)((x).pte_high >> 6)) +static inline pte_t +pfn_pte (unsigned long pfn,pgprot_t prot) +{ +pte_t pte; + pte.pte_high = (pfn <<6 ) | (pgprot_val (prot) &0x3f ); + pte.pte_low =pgprot_val (prot); +return pte; +} + +#else +#define pte_page (x) pfn_to_page(pte_pfn(x))#ifdef CONFIG_CPU_VR41XX #define pte_pfn (x) ((unsigned long)((x).pte >> (PAGE_SHIFT + 2)))
@@ -140,6 +153,7 @@#define pte_pfn (x) ((unsigned long)((x).pte >> PAGE_SHIFT))#define pfn_pte (pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))#endif +#endif /* defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_MIPS32) */ #define __pgd_offset (address) pgd_index(address)#define __pmd_offset (address) (((address) >> PMD_SHIFT) &
(PTRS_PER_PMD-1))
@@ -207,11 +221,19 @@
*/
#define PTE_FILE_MAX_BITS 27
+#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_MIPS32)
+ /* fixme */
+#define pte_to_pgoff(_pte) (((_pte).pte_high >> 6) + ((_pte).pte_high & 0x3f)) +#define pgoff_to_pte(off) \
+ ((pte_t){(((off) & 0x3f) + ((off) << 6) + _PAGE_FILE)})
+
+#else
#define pte_to_pgoff(_pte) \
((((_pte).pte >> 3) & 0x1f ) + (((_pte).pte >> 9) << 6 ))
#define pgoff_to_pte(off) \
((pte_t) { (((off) & 0x1f) << 3) + (((off) >> 6) << 9) + _PAGE_FILE })
+#endif
#endif
Index: include/asm-mips/pgtable-bits.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/pgtable-bits.h,v retrieving revision 1.9
asm-mips/pgtable-bits.h +30 -0
@@ -33,6 +33,31 @@* unpredictable things. The code (when it is written) to deal with * this problem will be in the update_mmu_cache() code for the r4k. */ +#if defined(CONFIG_CPU_MIPS32 ) && defined(CONFIG_64BIT_PHYS_ADDR ) + +#define _PAGE_PRESENT (1<<6)/* implemented in software */ +#define _PAGE_READ (1<<7)/* implemented in software */ +#define _PAGE_WRITE (1<<8)/* implemented in software */ +#define _PAGE_ACCESSED (1<<9)/* implemented in software */ +#define _PAGE_MODIFIED (1<<10)/* implemented in software */ +#define _PAGE_FILE (1<<10)/* set:pagecache unset:swap */ + +#define _PAGE_R4KBUG (1<<0)/* workaround for r4k bug */ +#define _PAGE_GLOBAL (1<<0) +#define _PAGE_VALID (1<<1) +#define _PAGE_SILENT_READ (1<<1)/* synonym */ +#define _PAGE_DIRTY (1<<2)/* The MIPS dirty bit */ +#define _PAGE_SILENT_WRITE (1<<2) +#define _CACHE_MASK (7<<3) + +/* MIPS32 defines only values 2 and 3. The rest are implementation +* dependent. +*/ +#define _CACHE_UNCACHED (2<<3) +#define _CACHE_CACHABLE_NONCOHERENT (3<<3) + +#else +#define _PAGE_PRESENT (1<<0)/* implemented in software */ #define _PAGE_READ (1<<1)/* implemented in software */ #define _PAGE_WRITE (1<<2)/* implemented in software */
@@ -97,6 +122,7 @@#endif #endif +#endif /* defined(CONFIG_CPU_MIPS32) && defined(CONFIG_64BIT_PHYS_ADDR) */ #define __READABLE (_PAGE_READ | _PAGE_SILENT_READ | _PAGE_ACCESSED)#define __WRITEABLE (_PAGE_WRITE | _PAGE_SILENT_WRITE | _PAGE_MODIFIED)
@@ -113,6 +139,10 @@#define PAGE_CACHABLE_DEFAULT _CACHE_CACHABLE_COW#endif +#if defined(CONFIG_CPU_MIPS32 ) && defined(CONFIG_64BIT_PHYS_ADDR ) +#define CONF_CM_DEFAULT (PAGE_CACHABLE_DEFAULT >> 3) +#else #define CONF_CM_DEFAULT (PAGE_CACHABLE_DEFAULT >> 9) +#endif #endif /* _ASM_PGTABLE_BITS_H */
Index: include/asm-mips/pgtable.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/pgtable.h,v retrieving revision 1.97
asm-mips/pgtable.h +102 -0
118 lines not on this page · raw message
_PAGE_READ; }
static inline int pte_write(pte_t pte) { return pte_val(pte) &_PAGE_WRITE; }
static inline int pte_dirty(pte_t pte) { return pte_val(pte) &_PAGE_MODIFIED; }
@@ -191,6 +293,7 @@
pte_val(pte) |= _PAGE_SILENT_READ;
return pte;
}
+#endif
/*
* Macro to make mark a page protection value as "uncacheable". Note
@@ -215,10 +318,20 @@
*/
#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
+#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_MIPS32) +static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
+{
+ pte.pte_low &= _PAGE_CHG_MASK;
+ pte.pte_low |= pgprot_val(newprot);
+ pte.pte_high |= pgprot_val(newprot) & 0x3f;
+ return pte;
+}
+#else
static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
{
return __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot));
}
+#endif
extern void __update_tlb(struct vm_area_struct *vma, unsigned long
address,
@@ -245,7 +358,27 @@
*/
#define HAVE_ARCH_UNMAPPED_AREA
+#ifdef CONFIG_64BIT_PHYS_ADDR
+extern phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size); +
+extern int remap_page_range_high(struct vm_area_struct *vma,
+ unsigned long from,
+ phys_t phys_addr,
+ unsigned long size,
+ pgprot_t prot);
+
+static inline int io_remap_page_range(struct vm_area_struct *vma,
+ unsigned long from,
+ unsigned long phys_addr,
+ unsigned long size,
+ pgprot_t prot)
+{
+ phys_t phys_addr_high = fixup_bigphys_addr(phys_addr, size);
+ return remap_page_range_high(vma, from, phys_addr_high, size, prot);
+}
+#else
#define io_remap_page_range remap_page_range
+#endif
/*
* No page table caches to initialise