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