/*1* Copyright 2000, 2007-2008 MontaVista Software Inc.2* Author: MontaVista Software, Inc. <[email protected]3*4* Updates to 2.6, Pete Popov, Embedded Alley Solutions, Inc.5*6* This program is free software; you can redistribute it and/or modify it7* under the terms of the GNU General Public License as published by the8* Free Software Foundation; either version 2 of the License, or (at your9* option) any later version.10*11* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED12* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF13* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN14* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,15* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT16* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF17* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON18* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT19* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF20* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.21*22* You should have received a copy of the GNU General Public License along23* with this program; if not, write to the Free Software Foundation, Inc.,24* 675 Mass Ave, Cambridge, MA 02139, USA.25*/2627#include <linux/init.h>28#include <linux/ioport.h>29#include <linux/mm.h>30#include <linux/dma-map-ops.h> /* for dma_default_coherent */3132#include <asm/bootinfo.h>33#include <asm/mipsregs.h>3435#include <au1000.h>3637static bool alchemy_dma_coherent(void)38{39switch (alchemy_get_cputype()) {40case ALCHEMY_CPU_AU1000:41case ALCHEMY_CPU_AU1500:42case ALCHEMY_CPU_AU1100:43return false;44case ALCHEMY_CPU_AU1200:45/* Au1200 AB USB does not support coherent memory */46if ((read_c0_prid() & PRID_REV_MASK) == 0)47return false;48return true;49default:50return true;51}52}5354void __init plat_mem_setup(void)55{56alchemy_set_lpj();5758if (au1xxx_cpu_needs_config_od())59/* Various early Au1xx0 errata corrected by this */60set_c0_config(1 << 19); /* Set Config[OD] */61else62/* Clear to obtain best system bus performance */63clear_c0_config(1 << 19); /* Clear Config[OD] */6465dma_default_coherent = alchemy_dma_coherent();6667board_setup(); /* board specific setup */6869/* IO/MEM resources. */70set_io_port_base(0);71ioport_resource.start = IOPORT_RESOURCE_START;72ioport_resource.end = IOPORT_RESOURCE_END;73iomem_resource.start = IOMEM_RESOURCE_START;74iomem_resource.end = IOMEM_RESOURCE_END;75}7677#ifdef CONFIG_MIPS_FIXUP_BIGPHYS_ADDR78/* This routine should be valid for all Au1x based boards */79phys_addr_t fixup_bigphys_addr(phys_addr_t phys_addr, phys_addr_t size)80{81unsigned long start = ALCHEMY_PCI_MEMWIN_START;82unsigned long end = ALCHEMY_PCI_MEMWIN_END;8384/* Don't fixup 36-bit addresses */85if ((phys_addr >> 32) != 0)86return phys_addr;8788/* Check for PCI memory window */89if (phys_addr >= start && (phys_addr + size - 1) <= end)90return (phys_addr_t)(AU1500_PCI_MEM_PHYS_ADDR + phys_addr);9192/* default nop */93return phys_addr;94}9596int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long vaddr,97unsigned long pfn, unsigned long size, pgprot_t prot)98{99phys_addr_t phys_addr = fixup_bigphys_addr(pfn << PAGE_SHIFT, size);100101return remap_pfn_range(vma, vaddr, phys_addr >> PAGE_SHIFT, size, prot);102}103EXPORT_SYMBOL(io_remap_pfn_range);104#endif /* CONFIG_MIPS_FIXUP_BIGPHYS_ADDR */105106107