keystone.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Keystone2 based boards and SOC related code.
  3. *
  4. * Copyright 2013 Texas Instruments, Inc.
  5. * Cyril Chemparathy <cyril@ti.com>
  6. * Santosh Shilimkar <santosh.shillimkar@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms and conditions of the GNU General Public License,
  10. * version 2, as published by the Free Software Foundation.
  11. */
  12. #include <linux/io.h>
  13. #include <linux/of.h>
  14. #include <linux/init.h>
  15. #include <linux/of_platform.h>
  16. #include <linux/of_address.h>
  17. #include <linux/memblock.h>
  18. #include <asm/setup.h>
  19. #include <asm/mach/map.h>
  20. #include <asm/mach/arch.h>
  21. #include <asm/mach/time.h>
  22. #include <asm/smp_plat.h>
  23. #include <asm/memory.h>
  24. #include "memory.h"
  25. #include "keystone.h"
  26. static unsigned long keystone_dma_pfn_offset __read_mostly;
  27. static int keystone_platform_notifier(struct notifier_block *nb,
  28. unsigned long event, void *data)
  29. {
  30. struct device *dev = data;
  31. if (event != BUS_NOTIFY_ADD_DEVICE)
  32. return NOTIFY_DONE;
  33. if (!dev)
  34. return NOTIFY_BAD;
  35. if (!dev->of_node) {
  36. dev->dma_pfn_offset = keystone_dma_pfn_offset;
  37. dev_err(dev, "set dma_pfn_offset%08lx\n",
  38. dev->dma_pfn_offset);
  39. }
  40. return NOTIFY_OK;
  41. }
  42. static struct notifier_block platform_nb = {
  43. .notifier_call = keystone_platform_notifier,
  44. };
  45. static void __init keystone_init(void)
  46. {
  47. if (PHYS_OFFSET >= KEYSTONE_HIGH_PHYS_START) {
  48. keystone_dma_pfn_offset = PFN_DOWN(KEYSTONE_HIGH_PHYS_START -
  49. KEYSTONE_LOW_PHYS_START);
  50. bus_register_notifier(&platform_bus_type, &platform_nb);
  51. }
  52. keystone_pm_runtime_init();
  53. }
  54. static long long __init keystone_pv_fixup(void)
  55. {
  56. long long offset;
  57. phys_addr_t mem_start, mem_end;
  58. mem_start = memblock_start_of_DRAM();
  59. mem_end = memblock_end_of_DRAM();
  60. /* nothing to do if we are running out of the <32-bit space */
  61. if (mem_start >= KEYSTONE_LOW_PHYS_START &&
  62. mem_end <= KEYSTONE_LOW_PHYS_END)
  63. return 0;
  64. if (mem_start < KEYSTONE_HIGH_PHYS_START ||
  65. mem_end > KEYSTONE_HIGH_PHYS_END) {
  66. pr_crit("Invalid address space for memory (%08llx-%08llx)\n",
  67. (u64)mem_start, (u64)mem_end);
  68. return 0;
  69. }
  70. offset = KEYSTONE_HIGH_PHYS_START - KEYSTONE_LOW_PHYS_START;
  71. /* Populate the arch idmap hook */
  72. arch_phys_to_idmap_offset = -offset;
  73. return offset;
  74. }
  75. static const char *const keystone_match[] __initconst = {
  76. "ti,k2hk",
  77. "ti,k2e",
  78. "ti,k2l",
  79. "ti,k2g",
  80. "ti,keystone",
  81. NULL,
  82. };
  83. DT_MACHINE_START(KEYSTONE, "Keystone")
  84. #if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE)
  85. .dma_zone_size = SZ_2G,
  86. #endif
  87. .smp = smp_ops(keystone_smp_ops),
  88. .init_machine = keystone_init,
  89. .dt_compat = keystone_match,
  90. .pv_fixup = keystone_pv_fixup,
  91. MACHINE_END