io.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/io.h>
  21. #include <mach/hardware.h>
  22. #include <asm/page.h>
  23. #include <mach/msm_iomap.h>
  24. #include <asm/mach/map.h>
  25. #include <mach/board.h>
  26. #define MSM_DEVICE(name) { \
  27. .virtual = (unsigned long) MSM_##name##_BASE, \
  28. .pfn = __phys_to_pfn(MSM_##name##_PHYS), \
  29. .length = MSM_##name##_SIZE, \
  30. .type = MT_DEVICE_NONSHARED, \
  31. }
  32. static struct map_desc msm_io_desc[] __initdata = {
  33. MSM_DEVICE(VIC),
  34. MSM_DEVICE(CSR),
  35. MSM_DEVICE(GPT),
  36. MSM_DEVICE(DMOV),
  37. MSM_DEVICE(GPIO1),
  38. MSM_DEVICE(GPIO2),
  39. MSM_DEVICE(CLK_CTL),
  40. #ifdef CONFIG_MSM_DEBUG_UART
  41. MSM_DEVICE(DEBUG_UART),
  42. #endif
  43. {
  44. .virtual = (unsigned long) MSM_SHARED_RAM_BASE,
  45. .pfn = __phys_to_pfn(MSM_SHARED_RAM_PHYS),
  46. .length = MSM_SHARED_RAM_SIZE,
  47. .type = MT_DEVICE,
  48. },
  49. };
  50. void __init msm_map_common_io(void)
  51. {
  52. /* Make sure the peripheral register window is closed, since
  53. * we will use PTE flags (TEX[1]=1,B=0,C=1) to determine which
  54. * pages are peripheral interface or not.
  55. */
  56. asm("mcr p15, 0, %0, c15, c2, 4" : : "r" (0));
  57. iotable_init(msm_io_desc, ARRAY_SIZE(msm_io_desc));
  58. }
  59. void __iomem *
  60. __msm_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype)
  61. {
  62. if (mtype == MT_DEVICE) {
  63. /* The peripherals in the 88000000 - D0000000 range
  64. * are only accessable by type MT_DEVICE_NONSHARED.
  65. * Adjust mtype as necessary to make this "just work."
  66. */
  67. if ((phys_addr >= 0x88000000) && (phys_addr < 0xD0000000))
  68. mtype = MT_DEVICE_NONSHARED;
  69. }
  70. return __arm_ioremap(phys_addr, size, mtype);
  71. }