Guest
Public paste!

Untitled

By: a guest | Sep 3rd, 2010 | Syntax: None | Size: 2.61 KB | Hits: 37 | Expires: Never
Copy text to clipboard
  1. /* arch/arm/mach-msm/io.c
  2.  *
  3.  * MSM7K io support
  4.  *
  5.  * Copyright (C) 2007 Google, Inc.
  6.  * Author: Brian Swetland <swetland@google.com>
  7.  *
  8.  * This software is licensed under the terms of the GNU General Public
  9.  * License version 2, as published by the Free Software Foundation, and
  10.  * may be copied, distributed, and modified under those terms.
  11.  *
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  *
  17.  */
  18.  
  19. #include <linux/kernel.h>
  20. #include <linux/init.h>
  21. #include <linux/io.h>
  22. #include <linux/module.h>
  23.  
  24. #include <mach/hardware.h>
  25. #include <asm/page.h>
  26. #include <mach/msm_iomap.h>
  27. #include <asm/mach/map.h>
  28.  
  29. #include <mach/board.h>
  30.  
  31. #define MSM_DEVICE(name) { \
  32.                 .virtual = (unsigned long) MSM_##name##_BASE, \
  33.                 .pfn = __phys_to_pfn(MSM_##name##_PHYS), \
  34.                 .length = MSM_##name##_SIZE, \
  35.                 .type = MT_DEVICE_NONSHARED, \
  36.          }
  37.  
  38. static struct map_desc msm_io_desc[] __initdata = {
  39.         MSM_DEVICE(VIC),
  40.         MSM_DEVICE(CSR),
  41.         MSM_DEVICE(GPT),
  42.         MSM_DEVICE(DMOV),
  43.         MSM_DEVICE(GPIO1),
  44.         MSM_DEVICE(GPIO2),
  45.         MSM_DEVICE(CLK_CTL),
  46.         MSM_DEVICE(MDP),
  47.         MSM_DEVICE(AD5),
  48.         MSM_DEVICE(MDC),
  49. #ifdef CONFIG_MSM_DEBUG_UART
  50.         MSM_DEVICE(DEBUG_UART),
  51. #endif
  52.         {
  53.                 .virtual =  (unsigned long) MSM_SHARED_RAM_BASE,
  54.                 .pfn =      __phys_to_pfn(MSM_SHARED_RAM_PHYS),
  55.                 .length =   MSM_SHARED_RAM_SIZE,
  56.                 .type =     MT_DEVICE,
  57.         },
  58.         {
  59.                 .virtual =  (unsigned long) MSM_SPL_BASE,
  60.                 .pfn =      __phys_to_pfn(MSM_SPL_PHYS),
  61.                 .length =   MSM_SPL_SIZE,
  62.                 .type =     MT_DEVICE,
  63.         },
  64.         MSM_DEVICE(GPIOCFG1),
  65.         MSM_DEVICE(GPIOCFG2),
  66.         MSM_DEVICE(TS),
  67.         MSM_DEVICE(AXIGS),
  68.         MSM_DEVICE(SSBI),
  69.         MSM_DEVICE(TSSC),
  70.         MSM_DEVICE(IMEM),
  71. };
  72.  
  73. void __init msm_map_common_io(void)
  74. {
  75.         /* Make sure the peripheral register window is closed, since
  76.          * we will use PTE flags (TEX[1]=1,B=0,C=1) to determine which
  77.          * pages are peripheral interface or not.
  78.          */
  79.         asm("mcr p15, 0, %0, c15, c2, 4" : : "r" (0));
  80.  
  81.         iotable_init(msm_io_desc, ARRAY_SIZE(msm_io_desc));
  82. }
  83.  
  84. void __iomem *
  85. __msm_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype)
  86. {
  87.         if (mtype == MT_DEVICE) {
  88.                 /* The peripherals in the 88000000 - D0000000 range
  89.                  * are only accessable by type MT_DEVICE_NONSHARED.
  90.                  * Adjust mtype as necessary to make this "just work."
  91.                  */
  92.                 if ((phys_addr >= 0x88000000) && (phys_addr < 0xD0000000))
  93.                         mtype = MT_DEVICE_NONSHARED;
  94.         }
  95.  
  96.         return __arm_ioremap(phys_addr, size, mtype);
  97. }
  98.  
  99. EXPORT_SYMBOL(__msm_ioremap);