xref: /openbmc/linux/arch/arm/mach-tegra/tegra.c (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
19c92ab61SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
22dfc91e8SHiroshi Doyu /*
31b14f3a5SHiroshi Doyu  * NVIDIA Tegra SoC device tree board support
42dfc91e8SHiroshi Doyu  *
51b14f3a5SHiroshi Doyu  * Copyright (C) 2011, 2013, NVIDIA Corporation
62dfc91e8SHiroshi Doyu  * Copyright (C) 2010 Secret Lab Technologies, Ltd.
72dfc91e8SHiroshi Doyu  * Copyright (C) 2010 Google, Inc.
82dfc91e8SHiroshi Doyu  */
92dfc91e8SHiroshi Doyu 
102dfc91e8SHiroshi Doyu #include <linux/clk.h>
11a0524accSThierry Reding #include <linux/clk/tegra.h>
122dfc91e8SHiroshi Doyu #include <linux/dma-mapping.h>
13a0524accSThierry Reding #include <linux/init.h>
14a0524accSThierry Reding #include <linux/io.h>
15a0524accSThierry Reding #include <linux/irqchip.h>
162dfc91e8SHiroshi Doyu #include <linux/irqdomain.h>
17a0524accSThierry Reding #include <linux/kernel.h>
182dfc91e8SHiroshi Doyu #include <linux/of_address.h>
192dfc91e8SHiroshi Doyu #include <linux/of_fdt.h>
20a0524accSThierry Reding #include <linux/of.h>
212dfc91e8SHiroshi Doyu #include <linux/of_platform.h>
22a0524accSThierry Reding #include <linux/platform_device.h>
23a0524accSThierry Reding #include <linux/serial_8250.h>
24d591fdf8SDanny Huang #include <linux/slab.h>
25d591fdf8SDanny Huang #include <linux/sys_soc.h>
262dfc91e8SHiroshi Doyu #include <linux/usb/tegra_usb_phy.h>
272dfc91e8SHiroshi Doyu 
284cb5d9ecSThierry Reding #include <linux/firmware/trusted_foundations.h>
294cb5d9ecSThierry Reding 
30304664eaSThierry Reding #include <soc/tegra/fuse.h>
317232398aSThierry Reding #include <soc/tegra/pmc.h>
32304664eaSThierry Reding 
336ad27b83SDmitry Osipenko #include <asm/firmware.h>
3451100bdcSStephen Warren #include <asm/hardware/cache-l2x0.h>
352dfc91e8SHiroshi Doyu #include <asm/mach/arch.h>
362dfc91e8SHiroshi Doyu #include <asm/mach/time.h>
37a0524accSThierry Reding #include <asm/mach-types.h>
3814e086baSDmitry Osipenko #include <asm/psci.h>
392dfc91e8SHiroshi Doyu #include <asm/setup.h>
402dfc91e8SHiroshi Doyu 
412dfc91e8SHiroshi Doyu #include "board.h"
422dfc91e8SHiroshi Doyu #include "common.h"
432dfc91e8SHiroshi Doyu #include "iomap.h"
4451100bdcSStephen Warren #include "pm.h"
4551100bdcSStephen Warren #include "reset.h"
4651100bdcSStephen Warren #include "sleep.h"
4751100bdcSStephen Warren 
4851100bdcSStephen Warren /*
4951100bdcSStephen Warren  * Storage for debug-macro.S's state.
5051100bdcSStephen Warren  *
5151100bdcSStephen Warren  * This must be in .data not .bss so that it gets initialized each time the
5251100bdcSStephen Warren  * kernel is loaded. The data is declared here rather than debug-macro.S so
5351100bdcSStephen Warren  * that multiple inclusions of debug-macro.S point at the same data.
5451100bdcSStephen Warren  */
552f1d70afSStephen Warren u32 tegra_uart_config[3] = {
5651100bdcSStephen Warren 	/* Debug UART initialization required */
5751100bdcSStephen Warren 	1,
5851100bdcSStephen Warren 	/* Debug UART physical address */
5951100bdcSStephen Warren 	0,
6051100bdcSStephen Warren 	/* Debug UART virtual address */
6151100bdcSStephen Warren 	0,
6251100bdcSStephen Warren };
6351100bdcSStephen Warren 
tegra_init_early(void)6451100bdcSStephen Warren static void __init tegra_init_early(void)
6551100bdcSStephen Warren {
661a5de3aeSAlexandre Courbot 	of_register_trusted_foundations();
67cd198d6dSAlexandre Courbot 	tegra_cpu_reset_handler_init();
686ad27b83SDmitry Osipenko 	call_firmware_op(l2x0_init);
6951100bdcSStephen Warren }
7051100bdcSStephen Warren 
tegra_dt_init_irq(void)7151100bdcSStephen Warren static void __init tegra_dt_init_irq(void)
7251100bdcSStephen Warren {
7351100bdcSStephen Warren 	tegra_init_irq();
7451100bdcSStephen Warren 	irqchip_init();
7551100bdcSStephen Warren }
762dfc91e8SHiroshi Doyu 
tegra_dt_init(void)772dfc91e8SHiroshi Doyu static void __init tegra_dt_init(void)
782dfc91e8SHiroshi Doyu {
7927a0342aSThierry Reding 	struct device *parent = tegra_soc_device_register();
80d591fdf8SDanny Huang 
81435ebcbcSKefeng Wang 	of_platform_default_populate(NULL, NULL, parent);
822dfc91e8SHiroshi Doyu }
832dfc91e8SHiroshi Doyu 
tegra_dt_init_late(void)842dfc91e8SHiroshi Doyu static void __init tegra_dt_init_late(void)
852dfc91e8SHiroshi Doyu {
86da35cbcaSArnd Bergmann 	if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) &&
87da35cbcaSArnd Bergmann 	    of_machine_is_compatible("compal,paz00"))
88da35cbcaSArnd Bergmann 		tegra_paz00_wifikill_init();
8915164e00SDmitry Osipenko 
9015164e00SDmitry Osipenko 	if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) &&
9115164e00SDmitry Osipenko 	    of_machine_is_compatible("nvidia,tegra20"))
9215164e00SDmitry Osipenko 		platform_device_register_simple("tegra20-cpufreq", -1, NULL, 0);
9314e086baSDmitry Osipenko 
9414e086baSDmitry Osipenko 	if (IS_ENABLED(CONFIG_ARM_TEGRA_CPUIDLE) && !psci_smp_available())
9514e086baSDmitry Osipenko 		platform_device_register_simple("tegra-cpuidle", -1, NULL, 0);
96*b9bf73aeSDmitry Osipenko 
97*b9bf73aeSDmitry Osipenko 	if (IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) &&
98*b9bf73aeSDmitry Osipenko 	    of_machine_is_compatible("nvidia,tegra30"))
99*b9bf73aeSDmitry Osipenko 		platform_device_register_simple("tegra20-cpufreq", -1, NULL, 0);
1002dfc91e8SHiroshi Doyu }
1012dfc91e8SHiroshi Doyu 
1021b14f3a5SHiroshi Doyu static const char * const tegra_dt_board_compat[] = {
10373944475SJoseph Lo 	"nvidia,tegra124",
1041b14f3a5SHiroshi Doyu 	"nvidia,tegra114",
1051b14f3a5SHiroshi Doyu 	"nvidia,tegra30",
1062dfc91e8SHiroshi Doyu 	"nvidia,tegra20",
1072dfc91e8SHiroshi Doyu 	NULL
1082dfc91e8SHiroshi Doyu };
1092dfc91e8SHiroshi Doyu 
1101b14f3a5SHiroshi Doyu DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)")
11135509737SDmitry Osipenko 	.l2c_aux_val	= 0x3c400000,
11235509737SDmitry Osipenko 	.l2c_aux_mask	= 0xc20fc3ff,
1132dfc91e8SHiroshi Doyu 	.smp		= smp_ops(tegra_smp_ops),
11400123d9aSRussell King 	.map_io		= tegra_map_common_io,
1152dfc91e8SHiroshi Doyu 	.init_early	= tegra_init_early,
1162dfc91e8SHiroshi Doyu 	.init_irq	= tegra_dt_init_irq,
1172dfc91e8SHiroshi Doyu 	.init_machine	= tegra_dt_init,
1182dfc91e8SHiroshi Doyu 	.init_late	= tegra_dt_init_late,
1191b14f3a5SHiroshi Doyu 	.dt_compat	= tegra_dt_board_compat,
1202dfc91e8SHiroshi Doyu MACHINE_END
121