]> Pileus Git - ~andy/linux/blob - arch/arm/mach-tegra/tegra.c
Merge branch 'gic/cleanup' into next/soc
[~andy/linux] / arch / arm / mach-tegra / tegra.c
1 /*
2  * NVIDIA Tegra SoC device tree board support
3  *
4  * Copyright (C) 2011, 2013, NVIDIA Corporation
5  * 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
19 #include <linux/clocksource.h>
20 #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>
30 #include <linux/of_platform.h>
31 #include <linux/pda_power.h>
32 #include <linux/platform_data/tegra_usb.h>
33 #include <linux/io.h>
34 #include <linux/i2c.h>
35 #include <linux/i2c-tegra.h>
36 #include <linux/slab.h>
37 #include <linux/sys_soc.h>
38 #include <linux/usb/tegra_usb_phy.h>
39
40 #include <asm/mach-types.h>
41 #include <asm/mach/arch.h>
42 #include <asm/mach/time.h>
43 #include <asm/setup.h>
44
45 #include "board.h"
46 #include "common.h"
47 #include "fuse.h"
48 #include "iomap.h"
49
50 static struct tegra_ehci_platform_data tegra_ehci1_pdata = {
51         .operating_mode = TEGRA_USB_OTG,
52         .power_down_on_bus_suspend = 1,
53         .vbus_gpio = -1,
54 };
55
56 static struct tegra_ulpi_config tegra_ehci2_ulpi_phy_config = {
57         .reset_gpio = -1,
58         .clk = "cdev2",
59 };
60
61 static struct tegra_ehci_platform_data tegra_ehci2_pdata = {
62         .phy_config = &tegra_ehci2_ulpi_phy_config,
63         .operating_mode = TEGRA_USB_HOST,
64         .power_down_on_bus_suspend = 1,
65         .vbus_gpio = -1,
66 };
67
68 static struct tegra_ehci_platform_data tegra_ehci3_pdata = {
69         .operating_mode = TEGRA_USB_HOST,
70         .power_down_on_bus_suspend = 1,
71         .vbus_gpio = -1,
72 };
73
74 static struct of_dev_auxdata tegra20_auxdata_lookup[] __initdata = {
75         OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5000000, "tegra-ehci.0",
76                        &tegra_ehci1_pdata),
77         OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5004000, "tegra-ehci.1",
78                        &tegra_ehci2_pdata),
79         OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5008000, "tegra-ehci.2",
80                        &tegra_ehci3_pdata),
81         {}
82 };
83
84 static void __init tegra_dt_init(void)
85 {
86         struct soc_device_attribute *soc_dev_attr;
87         struct soc_device *soc_dev;
88         struct device *parent = NULL;
89
90         soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
91         if (!soc_dev_attr)
92                 goto out;
93
94         soc_dev_attr->family = kasprintf(GFP_KERNEL, "Tegra");
95         soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", tegra_revision);
96         soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%d", tegra_chip_id);
97
98         soc_dev = soc_device_register(soc_dev_attr);
99         if (IS_ERR(soc_dev)) {
100                 kfree(soc_dev_attr->family);
101                 kfree(soc_dev_attr->revision);
102                 kfree(soc_dev_attr->soc_id);
103                 kfree(soc_dev_attr);
104                 goto out;
105         }
106
107         parent = soc_device_to_device(soc_dev);
108
109         /*
110          * Finished with the static registrations now; fill in the missing
111          * devices
112          */
113 out:
114         of_platform_populate(NULL, of_default_bus_match_table,
115                                 tegra20_auxdata_lookup, parent);
116 }
117
118 static void __init trimslice_init(void)
119 {
120 #ifdef CONFIG_TEGRA_PCI
121         int ret;
122
123         ret = tegra_pcie_init(true, true);
124         if (ret)
125                 pr_err("tegra_pci_init() failed: %d\n", ret);
126 #endif
127 }
128
129 static void __init harmony_init(void)
130 {
131 #ifdef CONFIG_TEGRA_PCI
132         int ret;
133
134         ret = harmony_pcie_init();
135         if (ret)
136                 pr_err("harmony_pcie_init() failed: %d\n", ret);
137 #endif
138 }
139
140 static void __init paz00_init(void)
141 {
142         if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
143                 tegra_paz00_wifikill_init();
144 }
145
146 static struct {
147         char *machine;
148         void (*init)(void);
149 } board_init_funcs[] = {
150         { "compulab,trimslice", trimslice_init },
151         { "nvidia,harmony", harmony_init },
152         { "compal,paz00", paz00_init },
153 };
154
155 static void __init tegra_dt_init_late(void)
156 {
157         int i;
158
159         tegra_init_late();
160
161         for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) {
162                 if (of_machine_is_compatible(board_init_funcs[i].machine)) {
163                         board_init_funcs[i].init();
164                         break;
165                 }
166         }
167 }
168
169 static const char * const tegra_dt_board_compat[] = {
170         "nvidia,tegra114",
171         "nvidia,tegra30",
172         "nvidia,tegra20",
173         NULL
174 };
175
176 DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)")
177         .map_io         = tegra_map_common_io,
178         .smp            = smp_ops(tegra_smp_ops),
179         .init_early     = tegra_init_early,
180         .init_irq       = tegra_dt_init_irq,
181         .init_time      = clocksource_of_init,
182         .init_machine   = tegra_dt_init,
183         .init_late      = tegra_dt_init_late,
184         .restart        = tegra_assert_system_reset,
185         .dt_compat      = tegra_dt_board_compat,
186 MACHINE_END