18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2000, 2007-2008 MontaVista Software Inc. 38c2ecf20Sopenharmony_ci * Author: MontaVista Software, Inc. <source@mvista.com 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Updates to 2.6, Pete Popov, Embedded Alley Solutions, Inc. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify it 88c2ecf20Sopenharmony_ci * under the terms of the GNU General Public License as published by the 98c2ecf20Sopenharmony_ci * Free Software Foundation; either version 2 of the License, or (at your 108c2ecf20Sopenharmony_ci * option) any later version. 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 138c2ecf20Sopenharmony_ci * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 148c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 158c2ecf20Sopenharmony_ci * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 168c2ecf20Sopenharmony_ci * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 178c2ecf20Sopenharmony_ci * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 188c2ecf20Sopenharmony_ci * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 198c2ecf20Sopenharmony_ci * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 208c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 218c2ecf20Sopenharmony_ci * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License along 248c2ecf20Sopenharmony_ci * with this program; if not, write to the Free Software Foundation, Inc., 258c2ecf20Sopenharmony_ci * 675 Mass Ave, Cambridge, MA 02139, USA. 268c2ecf20Sopenharmony_ci */ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#include <linux/init.h> 298c2ecf20Sopenharmony_ci#include <linux/ioport.h> 308c2ecf20Sopenharmony_ci#include <linux/mm.h> 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#include <asm/dma-coherence.h> 338c2ecf20Sopenharmony_ci#include <asm/mipsregs.h> 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#include <au1000.h> 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ciextern void __init board_setup(void); 388c2ecf20Sopenharmony_ciextern void __init alchemy_set_lpj(void); 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_civoid __init plat_mem_setup(void) 418c2ecf20Sopenharmony_ci{ 428c2ecf20Sopenharmony_ci alchemy_set_lpj(); 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci if (au1xxx_cpu_needs_config_od()) 458c2ecf20Sopenharmony_ci /* Various early Au1xx0 errata corrected by this */ 468c2ecf20Sopenharmony_ci set_c0_config(1 << 19); /* Set Config[OD] */ 478c2ecf20Sopenharmony_ci else 488c2ecf20Sopenharmony_ci /* Clear to obtain best system bus performance */ 498c2ecf20Sopenharmony_ci clear_c0_config(1 << 19); /* Clear Config[OD] */ 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci hw_coherentio = 0; 528c2ecf20Sopenharmony_ci coherentio = IO_COHERENCE_ENABLED; 538c2ecf20Sopenharmony_ci switch (alchemy_get_cputype()) { 548c2ecf20Sopenharmony_ci case ALCHEMY_CPU_AU1000: 558c2ecf20Sopenharmony_ci case ALCHEMY_CPU_AU1500: 568c2ecf20Sopenharmony_ci case ALCHEMY_CPU_AU1100: 578c2ecf20Sopenharmony_ci coherentio = IO_COHERENCE_DISABLED; 588c2ecf20Sopenharmony_ci break; 598c2ecf20Sopenharmony_ci case ALCHEMY_CPU_AU1200: 608c2ecf20Sopenharmony_ci /* Au1200 AB USB does not support coherent memory */ 618c2ecf20Sopenharmony_ci if (0 == (read_c0_prid() & PRID_REV_MASK)) 628c2ecf20Sopenharmony_ci coherentio = IO_COHERENCE_DISABLED; 638c2ecf20Sopenharmony_ci break; 648c2ecf20Sopenharmony_ci } 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci board_setup(); /* board specific setup */ 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci /* IO/MEM resources. */ 698c2ecf20Sopenharmony_ci set_io_port_base(0); 708c2ecf20Sopenharmony_ci ioport_resource.start = IOPORT_RESOURCE_START; 718c2ecf20Sopenharmony_ci ioport_resource.end = IOPORT_RESOURCE_END; 728c2ecf20Sopenharmony_ci iomem_resource.start = IOMEM_RESOURCE_START; 738c2ecf20Sopenharmony_ci iomem_resource.end = IOMEM_RESOURCE_END; 748c2ecf20Sopenharmony_ci} 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci#ifdef CONFIG_MIPS_FIXUP_BIGPHYS_ADDR 778c2ecf20Sopenharmony_ci/* This routine should be valid for all Au1x based boards */ 788c2ecf20Sopenharmony_ciphys_addr_t fixup_bigphys_addr(phys_addr_t phys_addr, phys_addr_t size) 798c2ecf20Sopenharmony_ci{ 808c2ecf20Sopenharmony_ci unsigned long start = ALCHEMY_PCI_MEMWIN_START; 818c2ecf20Sopenharmony_ci unsigned long end = ALCHEMY_PCI_MEMWIN_END; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci /* Don't fixup 36-bit addresses */ 848c2ecf20Sopenharmony_ci if ((phys_addr >> 32) != 0) 858c2ecf20Sopenharmony_ci return phys_addr; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci /* Check for PCI memory window */ 888c2ecf20Sopenharmony_ci if (phys_addr >= start && (phys_addr + size - 1) <= end) 898c2ecf20Sopenharmony_ci return (phys_addr_t)(AU1500_PCI_MEM_PHYS_ADDR + phys_addr); 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci /* default nop */ 928c2ecf20Sopenharmony_ci return phys_addr; 938c2ecf20Sopenharmony_ci} 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ciint io_remap_pfn_range(struct vm_area_struct *vma, unsigned long vaddr, 968c2ecf20Sopenharmony_ci unsigned long pfn, unsigned long size, pgprot_t prot) 978c2ecf20Sopenharmony_ci{ 988c2ecf20Sopenharmony_ci phys_addr_t phys_addr = fixup_bigphys_addr(pfn << PAGE_SHIFT, size); 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci return remap_pfn_range(vma, vaddr, phys_addr >> PAGE_SHIFT, size, prot); 1018c2ecf20Sopenharmony_ci} 1028c2ecf20Sopenharmony_ciEXPORT_SYMBOL(io_remap_pfn_range); 1038c2ecf20Sopenharmony_ci#endif /* CONFIG_MIPS_FIXUP_BIGPHYS_ADDR */ 104