blob: 0d1e4128d460effbe40eecb1c299d782df3c8231 [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>
Stephen Warrenbab53ce2012-08-27 14:22:48 -070032#include <linux/platform_data/tegra_usb.h>
Grant Likely8e267f32011-07-19 17:26:54 -060033#include <linux/io.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>
Stephen Warren441f1992013-03-25 13:22:24 -060037#include <linux/clk/tegra.h>
Grant Likely8e267f32011-07-19 17:26:54 -060038
39#include <asm/mach-types.h>
40#include <asm/mach/arch.h>
41#include <asm/mach/time.h>
42#include <asm/setup.h>
43
Grant Likely8e267f32011-07-19 17:26:54 -060044#include "board.h"
Marc Zyngiera1725732011-09-08 13:15:22 +010045#include "common.h"
Danny Huangd591fdf2013-03-14 08:48:40 +080046#include "fuse.h"
Stephen Warren2be39c02012-10-04 14:24:09 -060047#include "iomap.h"
Stephen Warrenbab53ce2012-08-27 14:22:48 -070048
Hiroshi Doyudeeb8d12013-01-03 08:27:05 +020049static struct tegra_ehci_platform_data tegra_ehci1_pdata = {
Stephen Warrenbab53ce2012-08-27 14:22:48 -070050 .operating_mode = TEGRA_USB_OTG,
51 .power_down_on_bus_suspend = 1,
52 .vbus_gpio = -1,
53};
54
Hiroshi Doyudeeb8d12013-01-03 08:27:05 +020055static struct tegra_ulpi_config tegra_ehci2_ulpi_phy_config = {
Stephen Warrenbab53ce2012-08-27 14:22:48 -070056 .reset_gpio = -1,
57 .clk = "cdev2",
58};
59
Hiroshi Doyudeeb8d12013-01-03 08:27:05 +020060static struct tegra_ehci_platform_data tegra_ehci2_pdata = {
Stephen Warrenbab53ce2012-08-27 14:22:48 -070061 .phy_config = &tegra_ehci2_ulpi_phy_config,
62 .operating_mode = TEGRA_USB_HOST,
63 .power_down_on_bus_suspend = 1,
64 .vbus_gpio = -1,
65};
66
Hiroshi Doyudeeb8d12013-01-03 08:27:05 +020067static struct tegra_ehci_platform_data tegra_ehci3_pdata = {
Stephen Warrenbab53ce2012-08-27 14:22:48 -070068 .operating_mode = TEGRA_USB_HOST,
69 .power_down_on_bus_suspend = 1,
70 .vbus_gpio = -1,
71};
Grant Likely8e267f32011-07-19 17:26:54 -060072
Hiroshi Doyudeeb8d12013-01-03 08:27:05 +020073static struct of_dev_auxdata tegra20_auxdata_lookup[] __initdata = {
Venu Byravarasu16a665f2012-12-17 18:31:01 +000074 OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5000000, "tegra-ehci.0",
Stephen Warren8c3ec842012-03-19 13:57:13 -060075 &tegra_ehci1_pdata),
Venu Byravarasu16a665f2012-12-17 18:31:01 +000076 OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5004000, "tegra-ehci.1",
Stephen Warren8c3ec842012-03-19 13:57:13 -060077 &tegra_ehci2_pdata),
Venu Byravarasu16a665f2012-12-17 18:31:01 +000078 OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5008000, "tegra-ehci.2",
Stephen Warren8c3ec842012-03-19 13:57:13 -060079 &tegra_ehci3_pdata),
Grant Likely8e267f32011-07-19 17:26:54 -060080 {}
81};
82
Grant Likely8e267f32011-07-19 17:26:54 -060083static void __init tegra_dt_init(void)
84{
Danny Huangd591fdf2013-03-14 08:48:40 +080085 struct soc_device_attribute *soc_dev_attr;
86 struct soc_device *soc_dev;
87 struct device *parent = NULL;
88
Stephen Warren441f1992013-03-25 13:22:24 -060089 tegra_clocks_apply_init_table();
90
Danny Huangd591fdf2013-03-14 08:48:40 +080091 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
92 if (!soc_dev_attr)
93 goto out;
94
95 soc_dev_attr->family = kasprintf(GFP_KERNEL, "Tegra");
96 soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", tegra_revision);
97 soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%d", tegra_chip_id);
98
99 soc_dev = soc_device_register(soc_dev_attr);
100 if (IS_ERR(soc_dev)) {
101 kfree(soc_dev_attr->family);
102 kfree(soc_dev_attr->revision);
103 kfree(soc_dev_attr->soc_id);
104 kfree(soc_dev_attr);
105 goto out;
106 }
107
108 parent = soc_device_to_device(soc_dev);
109
Stephen Warrena58116f2011-12-16 15:12:32 -0700110 /*
111 * Finished with the static registrations now; fill in the missing
112 * devices
113 */
Danny Huangd591fdf2013-03-14 08:48:40 +0800114out:
Stephen Warren2553dcc2012-06-28 16:29:19 -0600115 of_platform_populate(NULL, of_default_bus_match_table,
Danny Huangd591fdf2013-03-14 08:48:40 +0800116 tegra20_auxdata_lookup, parent);
Grant Likely8e267f32011-07-19 17:26:54 -0600117}
118
Stephen Warrenc554dee2012-05-02 13:43:26 -0600119static void __init trimslice_init(void)
120{
Stephen Warrenbe6a9192012-08-03 14:55:36 -0600121#ifdef CONFIG_TEGRA_PCI
Stephen Warrenc554dee2012-05-02 13:43:26 -0600122 int ret;
123
124 ret = tegra_pcie_init(true, true);
125 if (ret)
126 pr_err("tegra_pci_init() failed: %d\n", ret);
Stephen Warrenc554dee2012-05-02 13:43:26 -0600127#endif
Stephen Warrenbe6a9192012-08-03 14:55:36 -0600128}
Stephen Warrenc554dee2012-05-02 13:43:26 -0600129
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600130static void __init harmony_init(void)
131{
Laxman Dewangan3cc404d2012-08-16 20:59:59 +0000132#ifdef CONFIG_TEGRA_PCI
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600133 int ret;
134
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600135 ret = harmony_pcie_init();
136 if (ret)
137 pr_err("harmony_pcie_init() failed: %d\n", ret);
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600138#endif
Stephen Warrenbb25af82012-08-03 15:24:38 -0600139}
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600140
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600141static void __init paz00_init(void)
142{
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200143 if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
144 tegra_paz00_wifikill_init();
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600145}
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600146
Stephen Warrenc554dee2012-05-02 13:43:26 -0600147static struct {
148 char *machine;
149 void (*init)(void);
150} board_init_funcs[] = {
Stephen Warrenc554dee2012-05-02 13:43:26 -0600151 { "compulab,trimslice", trimslice_init },
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600152 { "nvidia,harmony", harmony_init },
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600153 { "compal,paz00", paz00_init },
Stephen Warrenc554dee2012-05-02 13:43:26 -0600154};
155
156static void __init tegra_dt_init_late(void)
157{
158 int i;
159
160 tegra_init_late();
161
162 for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) {
163 if (of_machine_is_compatible(board_init_funcs[i].machine)) {
164 board_init_funcs[i].init();
165 break;
166 }
167 }
168}
169
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200170static const char * const tegra_dt_board_compat[] = {
171 "nvidia,tegra114",
172 "nvidia,tegra30",
Stephen Warrenc5444f32012-02-27 18:26:16 -0700173 "nvidia,tegra20",
Grant Likely8e267f32011-07-19 17:26:54 -0600174 NULL
175};
176
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200177DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)")
Grant Likely8e267f32011-07-19 17:26:54 -0600178 .map_io = tegra_map_common_io,
Marc Zyngiera1725732011-09-08 13:15:22 +0100179 .smp = smp_ops(tegra_smp_ops),
Hiroshi Doyu74696882013-02-13 19:15:48 +0200180 .init_early = tegra_init_early,
pdeschrijver@nvidia.com0d4f7472011-11-29 18:29:19 -0700181 .init_irq = tegra_dt_init_irq,
Stephen Warren1711b1e2012-10-23 11:52:53 -0600182 .init_time = clocksource_of_init,
Grant Likely8e267f32011-07-19 17:26:54 -0600183 .init_machine = tegra_dt_init,
Stephen Warrenc554dee2012-05-02 13:43:26 -0600184 .init_late = tegra_dt_init_late,
Russell Kingabea3f22011-11-05 08:48:33 +0000185 .restart = tegra_assert_system_reset,
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200186 .dt_compat = tegra_dt_board_compat,
Grant Likely8e267f32011-07-19 17:26:54 -0600187MACHINE_END