···11+/*22+ * I/O remap functions for Hexagon33+ *44+ * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.55+ *66+ * This program is free software; you can redistribute it and/or modify77+ * it under the terms of the GNU General Public License version 2 and88+ * only version 2 as published by the Free Software Foundation.99+ *1010+ * This program is distributed in the hope that it will be useful,1111+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1313+ * GNU General Public License for more details.1414+ *1515+ * You should have received a copy of the GNU General Public License1616+ * along with this program; if not, write to the Free Software1717+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA1818+ * 02110-1301, USA.1919+ */2020+2121+#include <linux/io.h>2222+#include <linux/vmalloc.h>2323+2424+void __iomem *ioremap_nocache(unsigned long phys_addr, unsigned long size)2525+{2626+ unsigned long last_addr, addr;2727+ unsigned long offset = phys_addr & ~PAGE_MASK;2828+ struct vm_struct *area;2929+3030+ pgprot_t prot = __pgprot(_PAGE_PRESENT|_PAGE_READ|_PAGE_WRITE3131+ |(__HEXAGON_C_DEV << 6));3232+3333+ last_addr = phys_addr + size - 1;3434+3535+ /* Wrapping not allowed */3636+ if (!size || (last_addr < phys_addr))3737+ return NULL;3838+3939+ /* Rounds up to next page size, including whole-page offset */4040+ size = PAGE_ALIGN(offset + size);4141+4242+ area = get_vm_area(size, VM_IOREMAP);4343+ addr = (unsigned long)area->addr;4444+4545+ if (ioremap_page_range(addr, addr+size, phys_addr, prot)) {4646+ vunmap((void *)addr);4747+ return NULL;4848+ }4949+5050+ return (void __iomem *) (offset + addr);5151+}5252+5353+void __iounmap(const volatile void __iomem *addr)5454+{5555+ vunmap((void *) ((unsigned long) addr & PAGE_MASK));5656+}