Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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