blob: 27232c901a22d011e8452d09cc88d31735fa16e4 [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>
34#include <linux/i2c.h>
35#include <linux/i2c-tegra.h>
Stephen Warrenbab53ce2012-08-27 14:22:48 -070036#include <linux/usb/tegra_usb_phy.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"
Stephen Warren2be39c02012-10-04 14:24:09 -060045#include "iomap.h"
Stephen Warrenbab53ce2012-08-27 14:22:48 -070046
Hiroshi Doyudeeb8d12013-01-03 08:27:05 +020047static struct tegra_ehci_platform_data tegra_ehci1_pdata = {
Stephen Warrenbab53ce2012-08-27 14:22:48 -070048 .operating_mode = TEGRA_USB_OTG,
49 .power_down_on_bus_suspend = 1,
50 .vbus_gpio = -1,
51};
52
Hiroshi Doyudeeb8d12013-01-03 08:27:05 +020053static struct tegra_ulpi_config tegra_ehci2_ulpi_phy_config = {
Stephen Warrenbab53ce2012-08-27 14:22:48 -070054 .reset_gpio = -1,
55 .clk = "cdev2",
56};
57
Hiroshi Doyudeeb8d12013-01-03 08:27:05 +020058static struct tegra_ehci_platform_data tegra_ehci2_pdata = {
Stephen Warrenbab53ce2012-08-27 14:22:48 -070059 .phy_config = &tegra_ehci2_ulpi_phy_config,
60 .operating_mode = TEGRA_USB_HOST,
61 .power_down_on_bus_suspend = 1,
62 .vbus_gpio = -1,
63};
64
Hiroshi Doyudeeb8d12013-01-03 08:27:05 +020065static struct tegra_ehci_platform_data tegra_ehci3_pdata = {
Stephen Warrenbab53ce2012-08-27 14:22:48 -070066 .operating_mode = TEGRA_USB_HOST,
67 .power_down_on_bus_suspend = 1,
68 .vbus_gpio = -1,
69};
Grant Likely8e267f32011-07-19 17:26:54 -060070
Hiroshi Doyudeeb8d12013-01-03 08:27:05 +020071static struct of_dev_auxdata tegra20_auxdata_lookup[] __initdata = {
Venu Byravarasu16a665f2012-12-17 18:31:01 +000072 OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5000000, "tegra-ehci.0",
Stephen Warren8c3ec842012-03-19 13:57:13 -060073 &tegra_ehci1_pdata),
Venu Byravarasu16a665f2012-12-17 18:31:01 +000074 OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5004000, "tegra-ehci.1",
Stephen Warren8c3ec842012-03-19 13:57:13 -060075 &tegra_ehci2_pdata),
Venu Byravarasu16a665f2012-12-17 18:31:01 +000076 OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5008000, "tegra-ehci.2",
Stephen Warren8c3ec842012-03-19 13:57:13 -060077 &tegra_ehci3_pdata),
Grant Likely8e267f32011-07-19 17:26:54 -060078 {}
79};
80
Grant Likely8e267f32011-07-19 17:26:54 -060081static void __init tegra_dt_init(void)
82{
Stephen Warrena58116f2011-12-16 15:12:32 -070083 /*
84 * Finished with the static registrations now; fill in the missing
85 * devices
86 */
Stephen Warren2553dcc2012-06-28 16:29:19 -060087 of_platform_populate(NULL, of_default_bus_match_table,
Stephen Warrena58116f2011-12-16 15:12:32 -070088 tegra20_auxdata_lookup, NULL);
Grant Likely8e267f32011-07-19 17:26:54 -060089}
90
Stephen Warrenc554dee2012-05-02 13:43:26 -060091static void __init trimslice_init(void)
92{
Stephen Warrenbe6a9192012-08-03 14:55:36 -060093#ifdef CONFIG_TEGRA_PCI
Stephen Warrenc554dee2012-05-02 13:43:26 -060094 int ret;
95
96 ret = tegra_pcie_init(true, true);
97 if (ret)
98 pr_err("tegra_pci_init() failed: %d\n", ret);
Stephen Warrenc554dee2012-05-02 13:43:26 -060099#endif
Stephen Warrenbe6a9192012-08-03 14:55:36 -0600100}
Stephen Warrenc554dee2012-05-02 13:43:26 -0600101
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600102static void __init harmony_init(void)
103{
Laxman Dewangan3cc404d2012-08-16 20:59:59 +0000104#ifdef CONFIG_TEGRA_PCI
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600105 int ret;
106
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600107 ret = harmony_pcie_init();
108 if (ret)
109 pr_err("harmony_pcie_init() failed: %d\n", ret);
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600110#endif
Stephen Warrenbb25af82012-08-03 15:24:38 -0600111}
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600112
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600113static void __init paz00_init(void)
114{
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200115 if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
116 tegra_paz00_wifikill_init();
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600117}
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600118
Stephen Warrenc554dee2012-05-02 13:43:26 -0600119static struct {
120 char *machine;
121 void (*init)(void);
122} board_init_funcs[] = {
Stephen Warrenc554dee2012-05-02 13:43:26 -0600123 { "compulab,trimslice", trimslice_init },
Stephen Warrena12c0ef2012-05-02 15:47:12 -0600124 { "nvidia,harmony", harmony_init },
Stephen Warrenb64a02c2012-05-02 16:05:44 -0600125 { "compal,paz00", paz00_init },
Stephen Warrenc554dee2012-05-02 13:43:26 -0600126};
127
128static void __init tegra_dt_init_late(void)
129{
130 int i;
131
132 tegra_init_late();
133
134 for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) {
135 if (of_machine_is_compatible(board_init_funcs[i].machine)) {
136 board_init_funcs[i].init();
137 break;
138 }
139 }
140}
141
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200142static const char * const tegra_dt_board_compat[] = {
143 "nvidia,tegra114",
144 "nvidia,tegra30",
Stephen Warrenc5444f32012-02-27 18:26:16 -0700145 "nvidia,tegra20",
Grant Likely8e267f32011-07-19 17:26:54 -0600146 NULL
147};
148
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200149DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)")
Grant Likely8e267f32011-07-19 17:26:54 -0600150 .map_io = tegra_map_common_io,
Marc Zyngiera1725732011-09-08 13:15:22 +0100151 .smp = smp_ops(tegra_smp_ops),
Hiroshi Doyu74696882013-02-13 19:15:48 +0200152 .init_early = tegra_init_early,
pdeschrijver@nvidia.com0d4f7472011-11-29 18:29:19 -0700153 .init_irq = tegra_dt_init_irq,
Stephen Warren1711b1e2012-10-23 11:52:53 -0600154 .init_time = clocksource_of_init,
Grant Likely8e267f32011-07-19 17:26:54 -0600155 .init_machine = tegra_dt_init,
Stephen Warrenc554dee2012-05-02 13:43:26 -0600156 .init_late = tegra_dt_init_late,
Russell Kingabea3f22011-11-05 08:48:33 +0000157 .restart = tegra_assert_system_reset,
Hiroshi Doyu1b14f3a2013-02-13 19:15:50 +0200158 .dt_compat = tegra_dt_board_compat,
Grant Likely8e267f32011-07-19 17:26:54 -0600159MACHINE_END