blob: 5ef5173dec83bf32b68ea0c5931a9aa03547ad84 [file] [log] [blame]
Grant Likely8e267f32011-07-19 17:26:54 -06001/*
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +02002 * NVIDIA Tegra SoC device tree board support
Grant Likely8e267f32011-07-19 17:26:54 -06003 *
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +02004 * Copyright (C) 2011, 2013, NVIDIA Corporation
Grant Likely8e267f32011-07-19 17:26:54 -06005 * Copyright (C) 2010 Secret Lab Technologies, Ltd.
6 * Copyright (C) 2010 Google, Inc.
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */
18
Grant Likely8e267f32011-07-19 17:26:54 -060019#include <linux/clk.h>
Thierry Redinga0524ac2014-07-11 09:44:49 +020020#include <linux/clk/tegra.h>
Grant Likely8e267f32011-07-19 17:26:54 -060021#include <linux/dma-mapping.h>
Thierry Redinga0524ac2014-07-11 09:44:49 +020022#include <linux/init.h>
23#include <linux/io.h>
24#include <linux/irqchip.h>
Grant Likely8e267f32011-07-19 17:26:54 -060025#include <linux/irqdomain.h>
Thierry Redinga0524ac2014-07-11 09:44:49 +020026#include <linux/kernel.h>
Grant Likely8e267f32011-07-19 17:26:54 -060027#include <linux/of_address.h>
28#include <linux/of_fdt.h>
Thierry Redinga0524ac2014-07-11 09:44:49 +020029#include <linux/of.h>
Grant Likely8e267f32011-07-19 17:26:54 -060030#include <linux/of_platform.h>
31#include <linux/pda_power.h>
Thierry Redinga0524ac2014-07-11 09:44:49 +020032#include <linux/platform_device.h>
33#include <linux/serial_8250.h>
Danny Huangd591fdf2013-03-14 08:48:40 +080034#include <linux/slab.h>
35#include <linux/sys_soc.h>
Stephen Warrenbab53ce2012-08-27 14:22:48 -070036#include <linux/usb/tegra_usb_phy.h>
Grant Likely8e267f32011-07-19 17:26:54 -060037
Thierry Reding304664e2014-07-11 09:52:41 +020038#include <soc/tegra/fuse.h>
Thierry Reding72323982014-07-11 13:19:06 +020039#include <soc/tegra/pmc.h>
Thierry Reding304664e2014-07-11 09:52:41 +020040
Stephen Warren51100bd2013-08-20 15:47:38 -060041#include <asm/hardware/cache-l2x0.h>
Grant Likely8e267f32011-07-19 17:26:54 -060042#include <asm/mach/arch.h>
43#include <asm/mach/time.h>
Thierry Redinga0524ac2014-07-11 09:44:49 +020044#include <asm/mach-types.h>
Grant Likely8e267f32011-07-19 17:26:54 -060045#include <asm/setup.h>
Alexandre Courbot1a5de3a2013-11-24 15:30:49 +090046#include <asm/trusted_foundations.h>
Grant Likely8e267f32011-07-19 17:26:54 -060047
Grant Likely8e267f32011-07-19 17:26:54 -060048#include "board.h"
Marc Zyngiera1725732011-09-08 13:15:22 +010049#include "common.h"
Stephen Warren51100bd2013-08-20 15:47:38 -060050#include "cpuidle.h"
Stephen Warren2be39c02012-10-04 14:24:09 -060051#include "iomap.h"
Stephen Warren51100bd2013-08-20 15:47:38 -060052#include "irq.h"
Stephen Warren51100bd2013-08-20 15:47:38 -060053#include "pm.h"
54#include "reset.h"
55#include "sleep.h"
56
57/*
58 * Storage for debug-macro.S's state.
59 *
60 * This must be in .data not .bss so that it gets initialized each time the
61 * kernel is loaded. The data is declared here rather than debug-macro.S so
62 * that multiple inclusions of debug-macro.S point at the same data.
63 */
Stephen Warren2f1d70a2013-11-05 14:10:53 -070064u32 tegra_uart_config[3] = {
Stephen Warren51100bd2013-08-20 15:47:38 -060065 /* Debug UART initialization required */
66 1,
67 /* Debug UART physical address */
68 0,
69 /* Debug UART virtual address */
70 0,
Stephen Warren51100bd2013-08-20 15:47:38 -060071};
72
Stephen Warren51100bd2013-08-20 15:47:38 -060073static void __init tegra_init_early(void)
74{
Alexandre Courbot1a5de3a2013-11-24 15:30:49 +090075 of_register_trusted_foundations();
Alexandre Courbotcd198d62013-11-12 13:03:16 -070076 tegra_cpu_reset_handler_init();
Stephen Warren51100bd2013-08-20 15:47:38 -060077}
78
79static void __init tegra_dt_init_irq(void)
80{
Stephen Warren51100bd2013-08-20 15:47:38 -060081 tegra_init_irq();
82 irqchip_init();
83 tegra_legacy_irq_syscore_init();
84}
Stephen Warrenbab53ce2012-08-27 14:22:48 -070085
Grant Likely8e267f32011-07-19 17:26:54 -060086static void __init tegra_dt_init(void)
87{
Danny Huangd591fdf2013-03-14 08:48:40 +080088 struct soc_device_attribute *soc_dev_attr;
89 struct soc_device *soc_dev;
90 struct device *parent = NULL;
91
Stephen Warren441f1992013-03-25 13:22:24 -060092 tegra_clocks_apply_init_table();
93
Danny Huangd591fdf2013-03-14 08:48:40 +080094 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
95 if (!soc_dev_attr)
96 goto out;
97
98 soc_dev_attr->family = kasprintf(GFP_KERNEL, "Tegra");
Peter De Schrijver783c8f42014-06-12 18:36:37 +030099 soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d",
100 tegra_sku_info.revision);
Thierry Reding304664e2014-07-11 09:52:41 +0200101 soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%u", tegra_get_chip_id());
Danny Huangd591fdf2013-03-14 08:48:40 +0800102
103 soc_dev = soc_device_register(soc_dev_attr);
104 if (IS_ERR(soc_dev)) {
105 kfree(soc_dev_attr->family);
106 kfree(soc_dev_attr->revision);
107 kfree(soc_dev_attr->soc_id);
108 kfree(soc_dev_attr);
109 goto out;
110 }
111
112 parent = soc_device_to_device(soc_dev);
113
Stephen Warrena58116f2011-12-16 15:12:32 -0700114 /*
115 * Finished with the static registrations now; fill in the missing
116 * devices
117 */
Danny Huangd591fdf2013-03-14 08:48:40 +0800118out:
Tuomas Tynkkynen5fed6822013-07-25 21:38:04 +0300119 of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);
Grant Likely8e267f32011-07-19 17:26:54 -0600120}
121
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600122static void __init paz00_init(void)
123{
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200124 if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
125 tegra_paz00_wifikill_init();
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600126}
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600127
Stephen Warrenc554dee2012-05-02 13:43:26 -0600128static struct {
129 char *machine;
130 void (*init)(void);
131} board_init_funcs[] = {
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600132 { "compal,paz00", paz00_init },
Stephen Warrenc554dee2012-05-02 13:43:26 -0600133};
134
135static void __init tegra_dt_init_late(void)
136{
137 int i;
138
Stephen Warren51100bd2013-08-20 15:47:38 -0600139 tegra_init_suspend();
140 tegra_cpuidle_init();
Stephen Warrenc554dee2012-05-02 13:43:26 -0600141
142 for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) {
143 if (of_machine_is_compatible(board_init_funcs[i].machine)) {
144 board_init_funcs[i].init();
145 break;
146 }
147 }
148}
149
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200150static const char * const tegra_dt_board_compat[] = {
Joseph Lo73944472013-10-08 12:50:03 +0800151 "nvidia,tegra124",
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200152 "nvidia,tegra114",
153 "nvidia,tegra30",
Stephen Warrenc5444f32012-02-27 18:26:16 -0700154 "nvidia,tegra20",
Grant Likely8e267f32011-07-19 17:26:54 -0600155 NULL
156};
157
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200158DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)")
Russell King00123d9a2014-04-28 15:36:04 +0100159 .l2c_aux_val = 0x3c400001,
160 .l2c_aux_mask = 0xc20fc3fe,
Marc Zyngiera1725732011-09-08 13:15:22 +0100161 .smp = smp_ops(tegra_smp_ops),
Russell King00123d9a2014-04-28 15:36:04 +0100162 .map_io = tegra_map_common_io,
Hiroshi Doyu74696882013-02-13 19:15:48 +0200163 .init_early = tegra_init_early,
pdeschrijver@nvidia.com0d4f7472011-11-29 18:29:19 -0700164 .init_irq = tegra_dt_init_irq,
Grant Likely8e267f32011-07-19 17:26:54 -0600165 .init_machine = tegra_dt_init,
Stephen Warrenc554dee2012-05-02 13:43:26 -0600166 .init_late = tegra_dt_init_late,
Stephen Warren51100bd2013-08-20 15:47:38 -0600167 .restart = tegra_pmc_restart,
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200168 .dt_compat = tegra_dt_board_compat,
Grant Likely8e267f32011-07-19 17:26:54 -0600169MACHINE_END