io.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * arch/arm/mach-tegra/io.c
  3. *
  4. * Copyright (C) 2010 Google, Inc.
  5. *
  6. * Author:
  7. * Colin Cross <ccross@google.com>
  8. * Erik Gilling <konkers@google.com>
  9. *
  10. * This software is licensed under the terms of the GNU General Public
  11. * License version 2, as published by the Free Software Foundation, and
  12. * may be copied, distributed, and modified under those terms.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/module.h>
  22. #include <linux/init.h>
  23. #include <linux/mm.h>
  24. #include <linux/io.h>
  25. #include <mach/hardware.h>
  26. #include <asm/page.h>
  27. #include <asm/mach/map.h>
  28. #include "board.h"
  29. static struct map_desc tegra_io_desc[] __initdata = {
  30. {
  31. .virtual = IO_PPSB_VIRT,
  32. .pfn = __phys_to_pfn(IO_PPSB_PHYS),
  33. .length = IO_PPSB_SIZE,
  34. .type = MT_DEVICE,
  35. },
  36. {
  37. .virtual = IO_APB_VIRT,
  38. .pfn = __phys_to_pfn(IO_APB_PHYS),
  39. .length = IO_APB_SIZE,
  40. .type = MT_DEVICE,
  41. },
  42. {
  43. .virtual = IO_CPU_VIRT,
  44. .pfn = __phys_to_pfn(IO_CPU_PHYS),
  45. .length = IO_CPU_SIZE,
  46. .type = MT_DEVICE,
  47. },
  48. };
  49. void __init tegra_map_common_io(void)
  50. {
  51. iotable_init(tegra_io_desc, ARRAY_SIZE(tegra_io_desc));
  52. }
  53. /*
  54. * Intercept ioremap() requests for addresses in our fixed mapping regions.
  55. */
  56. void __iomem *tegra_ioremap(unsigned long p, size_t size, unsigned int type)
  57. {
  58. void __iomem *v = IO_ADDRESS(p);
  59. if (v == NULL)
  60. v = __arm_ioremap(p, size, type);
  61. return v;
  62. }
  63. EXPORT_SYMBOL(tegra_ioremap);
  64. void tegra_iounmap(volatile void __iomem *addr)
  65. {
  66. unsigned long virt = (unsigned long)addr;
  67. if (virt >= VMALLOC_START && virt < VMALLOC_END)
  68. __iounmap(addr);
  69. }
  70. EXPORT_SYMBOL(tegra_iounmap);