linux/arch/arm/mach-keystone/keystone.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0-only
   2/*
   3 * Keystone2 based boards and SOC related code.
   4 *
   5 * Copyright 2013 Texas Instruments, Inc.
   6 *      Cyril Chemparathy <cyril@ti.com>
   7 *      Santosh Shilimkar <santosh.shillimkar@ti.com>
   8 */
   9#include <linux/io.h>
  10#include <linux/of.h>
  11#include <linux/dma-map-ops.h>
  12#include <linux/init.h>
  13#include <linux/of_platform.h>
  14#include <linux/of_address.h>
  15#include <linux/memblock.h>
  16
  17#include <asm/setup.h>
  18#include <asm/mach/map.h>
  19#include <asm/mach/arch.h>
  20#include <asm/mach/time.h>
  21#include <asm/smp_plat.h>
  22#include <asm/memory.h>
  23
  24#include "memory.h"
  25
  26#include "keystone.h"
  27
  28#ifdef CONFIG_ARM_LPAE
  29static int keystone_platform_notifier(struct notifier_block *nb,
  30                                      unsigned long event, void *data)
  31{
  32        struct device *dev = data;
  33
  34        if (event != BUS_NOTIFY_ADD_DEVICE)
  35                return NOTIFY_DONE;
  36
  37        if (!dev)
  38                return NOTIFY_BAD;
  39
  40        if (!dev->of_node) {
  41                int ret = dma_direct_set_offset(dev, KEYSTONE_HIGH_PHYS_START,
  42                                                KEYSTONE_LOW_PHYS_START,
  43                                                KEYSTONE_HIGH_PHYS_SIZE);
  44                dev_err(dev, "set dma_offset%08llx%s\n",
  45                        KEYSTONE_HIGH_PHYS_START - KEYSTONE_LOW_PHYS_START,
  46                        ret ? " failed" : "");
  47        }
  48        return NOTIFY_OK;
  49}
  50
  51static struct notifier_block platform_nb = {
  52        .notifier_call = keystone_platform_notifier,
  53};
  54#endif /* CONFIG_ARM_LPAE */
  55
  56static void __init keystone_init(void)
  57{
  58#ifdef CONFIG_ARM_LPAE
  59        if (PHYS_OFFSET >= KEYSTONE_HIGH_PHYS_START)
  60                bus_register_notifier(&platform_bus_type, &platform_nb);
  61#endif
  62        keystone_pm_runtime_init();
  63}
  64
  65static long long __init keystone_pv_fixup(void)
  66{
  67        long long offset;
  68        u64 mem_start, mem_end;
  69
  70        mem_start = memblock_start_of_DRAM();
  71        mem_end = memblock_end_of_DRAM();
  72
  73        /* nothing to do if we are running out of the <32-bit space */
  74        if (mem_start >= KEYSTONE_LOW_PHYS_START &&
  75            mem_end   <= KEYSTONE_LOW_PHYS_END)
  76                return 0;
  77
  78        if (mem_start < KEYSTONE_HIGH_PHYS_START ||
  79            mem_end   > KEYSTONE_HIGH_PHYS_END) {
  80                pr_crit("Invalid address space for memory (%08llx-%08llx)\n",
  81                        mem_start, mem_end);
  82                return 0;
  83        }
  84
  85        offset = KEYSTONE_HIGH_PHYS_START - KEYSTONE_LOW_PHYS_START;
  86
  87        /* Populate the arch idmap hook */
  88        arch_phys_to_idmap_offset = -offset;
  89
  90        return offset;
  91}
  92
  93static const char *const keystone_match[] __initconst = {
  94        "ti,k2hk",
  95        "ti,k2e",
  96        "ti,k2l",
  97        "ti,k2g",
  98        "ti,keystone",
  99        NULL,
 100};
 101
 102DT_MACHINE_START(KEYSTONE, "Keystone")
 103#if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE)
 104        .dma_zone_size  = SZ_2G,
 105#endif
 106        .smp            = smp_ops(keystone_smp_ops),
 107        .init_machine   = keystone_init,
 108        .dt_compat      = keystone_match,
 109        .pv_fixup       = keystone_pv_fixup,
 110MACHINE_END
 111