blob: fc97cfd52769f687120639481d683f675193478e [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
Stephen Warren1711b1e2012-10-23 11:52:53 -060019#include <linux/clocksource.h>
Grant Likely8e267f32011-07-19 17:26:54 -060020#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/platform_device.h>
23#include <linux/serial_8250.h>
24#include <linux/clk.h>
25#include <linux/dma-mapping.h>
26#include <linux/irqdomain.h>
27#include <linux/of.h>
28#include <linux/of_address.h>
29#include <linux/of_fdt.h>
Grant Likely8e267f32011-07-19 17:26:54 -060030#include <linux/of_platform.h>
31#include <linux/pda_power.h>
32#include <linux/io.h>
Danny Huangd591fdf2013-03-14 08:48:40 +080033#include <linux/slab.h>
34#include <linux/sys_soc.h>
Stephen Warrenbab53ce2012-08-27 14:22:48 -070035#include <linux/usb/tegra_usb_phy.h>
Stephen Warren441f1992013-03-25 13:22:24 -060036#include <linux/clk/tegra.h>
Grant Likely8e267f32011-07-19 17:26:54 -060037
38#include <asm/mach-types.h>
39#include <asm/mach/arch.h>
40#include <asm/mach/time.h>
41#include <asm/setup.h>
42
Grant Likely8e267f32011-07-19 17:26:54 -060043#include "board.h"
Marc Zyngiera1725732011-09-08 13:15:22 +010044#include "common.h"
Danny Huangd591fdf2013-03-14 08:48:40 +080045#include "fuse.h"
Stephen Warren2be39c02012-10-04 14:24:09 -060046#include "iomap.h"
Stephen Warrenbab53ce2012-08-27 14:22:48 -070047
Grant Likely8e267f32011-07-19 17:26:54 -060048static void __init tegra_dt_init(void)
49{
Danny Huangd591fdf2013-03-14 08:48:40 +080050 struct soc_device_attribute *soc_dev_attr;
51 struct soc_device *soc_dev;
52 struct device *parent = NULL;
53
Stephen Warren441f1992013-03-25 13:22:24 -060054 tegra_clocks_apply_init_table();
55
Danny Huangd591fdf2013-03-14 08:48:40 +080056 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
57 if (!soc_dev_attr)
58 goto out;
59
60 soc_dev_attr->family = kasprintf(GFP_KERNEL, "Tegra");
61 soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", tegra_revision);
62 soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%d", tegra_chip_id);
63
64 soc_dev = soc_device_register(soc_dev_attr);
65 if (IS_ERR(soc_dev)) {
66 kfree(soc_dev_attr->family);
67 kfree(soc_dev_attr->revision);
68 kfree(soc_dev_attr->soc_id);
69 kfree(soc_dev_attr);
70 goto out;
71 }
72
73 parent = soc_device_to_device(soc_dev);
74
Stephen Warrena58116f2011-12-16 15:12:32 -070075 /*
76 * Finished with the static registrations now; fill in the missing
77 * devices
78 */
Danny Huangd591fdf2013-03-14 08:48:40 +080079out:
Tuomas Tynkkynen5fed6822013-07-25 21:38:04 +030080 of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);
Grant Likely8e267f32011-07-19 17:26:54 -060081}
82
Stephen Warrenc554dee2012-05-02 13:43:26 -060083static void __init trimslice_init(void)
84{
Stephen Warrenbe6a9192012-08-03 14:55:36 -060085#ifdef CONFIG_TEGRA_PCI
Stephen Warrenc554dee2012-05-02 13:43:26 -060086 int ret;
87
88 ret = tegra_pcie_init(true, true);
89 if (ret)
90 pr_err("tegra_pci_init() failed: %d\n", ret);
Stephen Warrenc554dee2012-05-02 13:43:26 -060091#endif
Stephen Warrenbe6a9192012-08-03 14:55:36 -060092}
Stephen Warrenc554dee2012-05-02 13:43:26 -060093
Stephen Warrena12c0ef2012-05-02 15:47:12 -060094static void __init harmony_init(void)
95{
Laxman Dewangan3cc404d2012-08-16 20:59:59 +000096#ifdef CONFIG_TEGRA_PCI
Stephen Warrena12c0ef2012-05-02 15:47:12 -060097 int ret;
98
Stephen Warrena12c0ef2012-05-02 15:47:12 -060099 ret = harmony_pcie_init();
100 if (ret)
101 pr_err("harmony_pcie_init() failed: %d\n", ret);
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600102#endif
Stephen Warrenbb25af82012-08-03 15:24:38 -0600103}
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600104
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600105static void __init paz00_init(void)
106{
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200107 if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
108 tegra_paz00_wifikill_init();
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600109}
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600110
Stephen Warrenc554dee2012-05-02 13:43:26 -0600111static struct {
112 char *machine;
113 void (*init)(void);
114} board_init_funcs[] = {
Stephen Warrenc554dee2012-05-02 13:43:26 -0600115 { "compulab,trimslice", trimslice_init },
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600116 { "nvidia,harmony", harmony_init },
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600117 { "compal,paz00", paz00_init },
Stephen Warrenc554dee2012-05-02 13:43:26 -0600118};
119
120static void __init tegra_dt_init_late(void)
121{
122 int i;
123
124 tegra_init_late();
125
126 for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) {
127 if (of_machine_is_compatible(board_init_funcs[i].machine)) {
128 board_init_funcs[i].init();
129 break;
130 }
131 }
132}
133
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200134static const char * const tegra_dt_board_compat[] = {
135 "nvidia,tegra114",
136 "nvidia,tegra30",
Stephen Warrenc5444f32012-02-27 18:26:16 -0700137 "nvidia,tegra20",
Grant Likely8e267f32011-07-19 17:26:54 -0600138 NULL
139};
140
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200141DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)")
Grant Likely8e267f32011-07-19 17:26:54 -0600142 .map_io = tegra_map_common_io,
Marc Zyngiera1725732011-09-08 13:15:22 +0100143 .smp = smp_ops(tegra_smp_ops),
Hiroshi Doyu74696882013-02-13 19:15:48 +0200144 .init_early = tegra_init_early,
pdeschrijver@nvidia.com0d4f7472011-11-29 18:29:19 -0700145 .init_irq = tegra_dt_init_irq,
Stephen Warren1711b1e2012-10-23 11:52:53 -0600146 .init_time = clocksource_of_init,
Grant Likely8e267f32011-07-19 17:26:54 -0600147 .init_machine = tegra_dt_init,
Stephen Warrenc554dee2012-05-02 13:43:26 -0600148 .init_late = tegra_dt_init_late,
Russell Kingabea3f22011-11-05 08:48:33 +0000149 .restart = tegra_assert_system_reset,
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200150 .dt_compat = tegra_dt_board_compat,
Grant Likely8e267f32011-07-19 17:26:54 -0600151MACHINE_END