Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 1 | /* |
Hiroshi Doyu | 1b14f3a | 2013-02-13 19:15:50 +0200 | [diff] [blame] | 2 | * NVIDIA Tegra SoC device tree board support |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 3 | * |
Hiroshi Doyu | 1b14f3a | 2013-02-13 19:15:50 +0200 | [diff] [blame] | 4 | * Copyright (C) 2011, 2013, NVIDIA Corporation |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 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 | |
Stephen Warren | 1711b1e | 2012-10-23 11:52:53 -0600 | [diff] [blame] | 19 | #include <linux/clocksource.h> |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 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> |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 30 | #include <linux/of_platform.h> |
| 31 | #include <linux/pda_power.h> |
Stephen Warren | bab53ce | 2012-08-27 14:22:48 -0700 | [diff] [blame] | 32 | #include <linux/platform_data/tegra_usb.h> |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 33 | #include <linux/io.h> |
| 34 | #include <linux/i2c.h> |
| 35 | #include <linux/i2c-tegra.h> |
Danny Huang | d591fdf | 2013-03-14 08:48:40 +0800 | [diff] [blame^] | 36 | #include <linux/slab.h> |
| 37 | #include <linux/sys_soc.h> |
Stephen Warren | bab53ce | 2012-08-27 14:22:48 -0700 | [diff] [blame] | 38 | #include <linux/usb/tegra_usb_phy.h> |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 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 | |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 45 | #include "board.h" |
Marc Zyngier | a172573 | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 46 | #include "common.h" |
Danny Huang | d591fdf | 2013-03-14 08:48:40 +0800 | [diff] [blame^] | 47 | #include "fuse.h" |
Stephen Warren | 2be39c0 | 2012-10-04 14:24:09 -0600 | [diff] [blame] | 48 | #include "iomap.h" |
Stephen Warren | bab53ce | 2012-08-27 14:22:48 -0700 | [diff] [blame] | 49 | |
Hiroshi Doyu | deeb8d1 | 2013-01-03 08:27:05 +0200 | [diff] [blame] | 50 | static struct tegra_ehci_platform_data tegra_ehci1_pdata = { |
Stephen Warren | bab53ce | 2012-08-27 14:22:48 -0700 | [diff] [blame] | 51 | .operating_mode = TEGRA_USB_OTG, |
| 52 | .power_down_on_bus_suspend = 1, |
| 53 | .vbus_gpio = -1, |
| 54 | }; |
| 55 | |
Hiroshi Doyu | deeb8d1 | 2013-01-03 08:27:05 +0200 | [diff] [blame] | 56 | static struct tegra_ulpi_config tegra_ehci2_ulpi_phy_config = { |
Stephen Warren | bab53ce | 2012-08-27 14:22:48 -0700 | [diff] [blame] | 57 | .reset_gpio = -1, |
| 58 | .clk = "cdev2", |
| 59 | }; |
| 60 | |
Hiroshi Doyu | deeb8d1 | 2013-01-03 08:27:05 +0200 | [diff] [blame] | 61 | static struct tegra_ehci_platform_data tegra_ehci2_pdata = { |
Stephen Warren | bab53ce | 2012-08-27 14:22:48 -0700 | [diff] [blame] | 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 | |
Hiroshi Doyu | deeb8d1 | 2013-01-03 08:27:05 +0200 | [diff] [blame] | 68 | static struct tegra_ehci_platform_data tegra_ehci3_pdata = { |
Stephen Warren | bab53ce | 2012-08-27 14:22:48 -0700 | [diff] [blame] | 69 | .operating_mode = TEGRA_USB_HOST, |
| 70 | .power_down_on_bus_suspend = 1, |
| 71 | .vbus_gpio = -1, |
| 72 | }; |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 73 | |
Hiroshi Doyu | deeb8d1 | 2013-01-03 08:27:05 +0200 | [diff] [blame] | 74 | static struct of_dev_auxdata tegra20_auxdata_lookup[] __initdata = { |
Venu Byravarasu | 16a665f | 2012-12-17 18:31:01 +0000 | [diff] [blame] | 75 | OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5000000, "tegra-ehci.0", |
Stephen Warren | 8c3ec84 | 2012-03-19 13:57:13 -0600 | [diff] [blame] | 76 | &tegra_ehci1_pdata), |
Venu Byravarasu | 16a665f | 2012-12-17 18:31:01 +0000 | [diff] [blame] | 77 | OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5004000, "tegra-ehci.1", |
Stephen Warren | 8c3ec84 | 2012-03-19 13:57:13 -0600 | [diff] [blame] | 78 | &tegra_ehci2_pdata), |
Venu Byravarasu | 16a665f | 2012-12-17 18:31:01 +0000 | [diff] [blame] | 79 | OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5008000, "tegra-ehci.2", |
Stephen Warren | 8c3ec84 | 2012-03-19 13:57:13 -0600 | [diff] [blame] | 80 | &tegra_ehci3_pdata), |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 81 | {} |
| 82 | }; |
| 83 | |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 84 | static void __init tegra_dt_init(void) |
| 85 | { |
Danny Huang | d591fdf | 2013-03-14 08:48:40 +0800 | [diff] [blame^] | 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 | |
Stephen Warren | a58116f | 2011-12-16 15:12:32 -0700 | [diff] [blame] | 109 | /* |
| 110 | * Finished with the static registrations now; fill in the missing |
| 111 | * devices |
| 112 | */ |
Danny Huang | d591fdf | 2013-03-14 08:48:40 +0800 | [diff] [blame^] | 113 | out: |
Stephen Warren | 2553dcc | 2012-06-28 16:29:19 -0600 | [diff] [blame] | 114 | of_platform_populate(NULL, of_default_bus_match_table, |
Danny Huang | d591fdf | 2013-03-14 08:48:40 +0800 | [diff] [blame^] | 115 | tegra20_auxdata_lookup, parent); |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 116 | } |
| 117 | |
Stephen Warren | c554dee | 2012-05-02 13:43:26 -0600 | [diff] [blame] | 118 | static void __init trimslice_init(void) |
| 119 | { |
Stephen Warren | be6a919 | 2012-08-03 14:55:36 -0600 | [diff] [blame] | 120 | #ifdef CONFIG_TEGRA_PCI |
Stephen Warren | c554dee | 2012-05-02 13:43:26 -0600 | [diff] [blame] | 121 | int ret; |
| 122 | |
| 123 | ret = tegra_pcie_init(true, true); |
| 124 | if (ret) |
| 125 | pr_err("tegra_pci_init() failed: %d\n", ret); |
Stephen Warren | c554dee | 2012-05-02 13:43:26 -0600 | [diff] [blame] | 126 | #endif |
Stephen Warren | be6a919 | 2012-08-03 14:55:36 -0600 | [diff] [blame] | 127 | } |
Stephen Warren | c554dee | 2012-05-02 13:43:26 -0600 | [diff] [blame] | 128 | |
Stephen Warren | a12c0ef | 2012-05-02 15:47:12 -0600 | [diff] [blame] | 129 | static void __init harmony_init(void) |
| 130 | { |
Laxman Dewangan | 3cc404d | 2012-08-16 20:59:59 +0000 | [diff] [blame] | 131 | #ifdef CONFIG_TEGRA_PCI |
Stephen Warren | a12c0ef | 2012-05-02 15:47:12 -0600 | [diff] [blame] | 132 | int ret; |
| 133 | |
Stephen Warren | a12c0ef | 2012-05-02 15:47:12 -0600 | [diff] [blame] | 134 | ret = harmony_pcie_init(); |
| 135 | if (ret) |
| 136 | pr_err("harmony_pcie_init() failed: %d\n", ret); |
Stephen Warren | a12c0ef | 2012-05-02 15:47:12 -0600 | [diff] [blame] | 137 | #endif |
Stephen Warren | bb25af8 | 2012-08-03 15:24:38 -0600 | [diff] [blame] | 138 | } |
Stephen Warren | a12c0ef | 2012-05-02 15:47:12 -0600 | [diff] [blame] | 139 | |
Stephen Warren | b64a02c | 2012-05-02 16:05:44 -0600 | [diff] [blame] | 140 | static void __init paz00_init(void) |
| 141 | { |
Hiroshi Doyu | 1b14f3a | 2013-02-13 19:15:50 +0200 | [diff] [blame] | 142 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC)) |
| 143 | tegra_paz00_wifikill_init(); |
Stephen Warren | b64a02c | 2012-05-02 16:05:44 -0600 | [diff] [blame] | 144 | } |
Stephen Warren | b64a02c | 2012-05-02 16:05:44 -0600 | [diff] [blame] | 145 | |
Stephen Warren | c554dee | 2012-05-02 13:43:26 -0600 | [diff] [blame] | 146 | static struct { |
| 147 | char *machine; |
| 148 | void (*init)(void); |
| 149 | } board_init_funcs[] = { |
Stephen Warren | c554dee | 2012-05-02 13:43:26 -0600 | [diff] [blame] | 150 | { "compulab,trimslice", trimslice_init }, |
Stephen Warren | a12c0ef | 2012-05-02 15:47:12 -0600 | [diff] [blame] | 151 | { "nvidia,harmony", harmony_init }, |
Stephen Warren | b64a02c | 2012-05-02 16:05:44 -0600 | [diff] [blame] | 152 | { "compal,paz00", paz00_init }, |
Stephen Warren | c554dee | 2012-05-02 13:43:26 -0600 | [diff] [blame] | 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 | |
Hiroshi Doyu | 1b14f3a | 2013-02-13 19:15:50 +0200 | [diff] [blame] | 169 | static const char * const tegra_dt_board_compat[] = { |
| 170 | "nvidia,tegra114", |
| 171 | "nvidia,tegra30", |
Stephen Warren | c5444f3 | 2012-02-27 18:26:16 -0700 | [diff] [blame] | 172 | "nvidia,tegra20", |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 173 | NULL |
| 174 | }; |
| 175 | |
Hiroshi Doyu | 1b14f3a | 2013-02-13 19:15:50 +0200 | [diff] [blame] | 176 | DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)") |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 177 | .map_io = tegra_map_common_io, |
Marc Zyngier | a172573 | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 178 | .smp = smp_ops(tegra_smp_ops), |
Hiroshi Doyu | 7469688 | 2013-02-13 19:15:48 +0200 | [diff] [blame] | 179 | .init_early = tegra_init_early, |
pdeschrijver@nvidia.com | 0d4f747 | 2011-11-29 18:29:19 -0700 | [diff] [blame] | 180 | .init_irq = tegra_dt_init_irq, |
Stephen Warren | 1711b1e | 2012-10-23 11:52:53 -0600 | [diff] [blame] | 181 | .init_time = clocksource_of_init, |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 182 | .init_machine = tegra_dt_init, |
Stephen Warren | c554dee | 2012-05-02 13:43:26 -0600 | [diff] [blame] | 183 | .init_late = tegra_dt_init_late, |
Russell King | abea3f2 | 2011-11-05 08:48:33 +0000 | [diff] [blame] | 184 | .restart = tegra_assert_system_reset, |
Hiroshi Doyu | 1b14f3a | 2013-02-13 19:15:50 +0200 | [diff] [blame] | 185 | .dt_compat = tegra_dt_board_compat, |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 186 | MACHINE_END |