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 | |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 19 | #include <linux/clk.h> |
Thierry Reding | a0524ac | 2014-07-11 09:44:49 +0200 | [diff] [blame] | 20 | #include <linux/clk/tegra.h> |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 21 | #include <linux/dma-mapping.h> |
Thierry Reding | a0524ac | 2014-07-11 09:44:49 +0200 | [diff] [blame] | 22 | #include <linux/init.h> |
| 23 | #include <linux/io.h> |
| 24 | #include <linux/irqchip.h> |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 25 | #include <linux/irqdomain.h> |
Thierry Reding | a0524ac | 2014-07-11 09:44:49 +0200 | [diff] [blame] | 26 | #include <linux/kernel.h> |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 27 | #include <linux/of_address.h> |
| 28 | #include <linux/of_fdt.h> |
Thierry Reding | a0524ac | 2014-07-11 09:44:49 +0200 | [diff] [blame] | 29 | #include <linux/of.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> |
Thierry Reding | a0524ac | 2014-07-11 09:44:49 +0200 | [diff] [blame] | 32 | #include <linux/platform_device.h> |
| 33 | #include <linux/serial_8250.h> |
Danny Huang | d591fdf | 2013-03-14 08:48:40 +0800 | [diff] [blame] | 34 | #include <linux/slab.h> |
| 35 | #include <linux/sys_soc.h> |
Stephen Warren | bab53ce | 2012-08-27 14:22:48 -0700 | [diff] [blame] | 36 | #include <linux/usb/tegra_usb_phy.h> |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 37 | |
Thierry Reding | 304664e | 2014-07-11 09:52:41 +0200 | [diff] [blame] | 38 | #include <soc/tegra/fuse.h> |
Thierry Reding | 7232398 | 2014-07-11 13:19:06 +0200 | [diff] [blame] | 39 | #include <soc/tegra/pmc.h> |
Thierry Reding | 304664e | 2014-07-11 09:52:41 +0200 | [diff] [blame] | 40 | |
Stephen Warren | 51100bd | 2013-08-20 15:47:38 -0600 | [diff] [blame] | 41 | #include <asm/hardware/cache-l2x0.h> |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 42 | #include <asm/mach/arch.h> |
| 43 | #include <asm/mach/time.h> |
Thierry Reding | a0524ac | 2014-07-11 09:44:49 +0200 | [diff] [blame] | 44 | #include <asm/mach-types.h> |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 45 | #include <asm/setup.h> |
Alexandre Courbot | 1a5de3a | 2013-11-24 15:30:49 +0900 | [diff] [blame] | 46 | #include <asm/trusted_foundations.h> |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 47 | |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 48 | #include "board.h" |
Marc Zyngier | a172573 | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 49 | #include "common.h" |
Stephen Warren | 51100bd | 2013-08-20 15:47:38 -0600 | [diff] [blame] | 50 | #include "cpuidle.h" |
Thierry Reding | 783944f | 2014-08-26 08:14:04 +0200 | [diff] [blame] | 51 | #include "flowctrl.h" |
Stephen Warren | 2be39c0 | 2012-10-04 14:24:09 -0600 | [diff] [blame] | 52 | #include "iomap.h" |
Stephen Warren | 51100bd | 2013-08-20 15:47:38 -0600 | [diff] [blame] | 53 | #include "irq.h" |
Stephen Warren | 51100bd | 2013-08-20 15:47:38 -0600 | [diff] [blame] | 54 | #include "pm.h" |
| 55 | #include "reset.h" |
| 56 | #include "sleep.h" |
| 57 | |
| 58 | /* |
| 59 | * Storage for debug-macro.S's state. |
| 60 | * |
| 61 | * This must be in .data not .bss so that it gets initialized each time the |
| 62 | * kernel is loaded. The data is declared here rather than debug-macro.S so |
| 63 | * that multiple inclusions of debug-macro.S point at the same data. |
| 64 | */ |
Stephen Warren | 2f1d70a | 2013-11-05 14:10:53 -0700 | [diff] [blame] | 65 | u32 tegra_uart_config[3] = { |
Stephen Warren | 51100bd | 2013-08-20 15:47:38 -0600 | [diff] [blame] | 66 | /* Debug UART initialization required */ |
| 67 | 1, |
| 68 | /* Debug UART physical address */ |
| 69 | 0, |
| 70 | /* Debug UART virtual address */ |
| 71 | 0, |
Stephen Warren | 51100bd | 2013-08-20 15:47:38 -0600 | [diff] [blame] | 72 | }; |
| 73 | |
Stephen Warren | 51100bd | 2013-08-20 15:47:38 -0600 | [diff] [blame] | 74 | static void __init tegra_init_early(void) |
| 75 | { |
Alexandre Courbot | 1a5de3a | 2013-11-24 15:30:49 +0900 | [diff] [blame] | 76 | of_register_trusted_foundations(); |
Alexandre Courbot | cd198d6 | 2013-11-12 13:03:16 -0700 | [diff] [blame] | 77 | tegra_cpu_reset_handler_init(); |
Thierry Reding | 783944f | 2014-08-26 08:14:04 +0200 | [diff] [blame] | 78 | tegra_flowctrl_init(); |
Stephen Warren | 51100bd | 2013-08-20 15:47:38 -0600 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | static void __init tegra_dt_init_irq(void) |
| 82 | { |
Stephen Warren | 51100bd | 2013-08-20 15:47:38 -0600 | [diff] [blame] | 83 | tegra_init_irq(); |
| 84 | irqchip_init(); |
Stephen Warren | 51100bd | 2013-08-20 15:47:38 -0600 | [diff] [blame] | 85 | } |
Stephen Warren | bab53ce | 2012-08-27 14:22:48 -0700 | [diff] [blame] | 86 | |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 87 | static void __init tegra_dt_init(void) |
| 88 | { |
Danny Huang | d591fdf | 2013-03-14 08:48:40 +0800 | [diff] [blame] | 89 | struct soc_device_attribute *soc_dev_attr; |
| 90 | struct soc_device *soc_dev; |
| 91 | struct device *parent = NULL; |
| 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"); |
Peter De Schrijver | 783c8f4 | 2014-06-12 18:36:37 +0300 | [diff] [blame] | 98 | soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", |
| 99 | tegra_sku_info.revision); |
Thierry Reding | 304664e | 2014-07-11 09:52:41 +0200 | [diff] [blame] | 100 | soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%u", tegra_get_chip_id()); |
Danny Huang | d591fdf | 2013-03-14 08:48:40 +0800 | [diff] [blame] | 101 | |
| 102 | soc_dev = soc_device_register(soc_dev_attr); |
| 103 | if (IS_ERR(soc_dev)) { |
| 104 | kfree(soc_dev_attr->family); |
| 105 | kfree(soc_dev_attr->revision); |
| 106 | kfree(soc_dev_attr->soc_id); |
| 107 | kfree(soc_dev_attr); |
| 108 | goto out; |
| 109 | } |
| 110 | |
| 111 | parent = soc_device_to_device(soc_dev); |
| 112 | |
Stephen Warren | a58116f | 2011-12-16 15:12:32 -0700 | [diff] [blame] | 113 | /* |
| 114 | * Finished with the static registrations now; fill in the missing |
| 115 | * devices |
| 116 | */ |
Danny Huang | d591fdf | 2013-03-14 08:48:40 +0800 | [diff] [blame] | 117 | out: |
Tuomas Tynkkynen | 5fed682 | 2013-07-25 21:38:04 +0300 | [diff] [blame] | 118 | of_platform_populate(NULL, of_default_bus_match_table, NULL, parent); |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 119 | } |
| 120 | |
Stephen Warren | b64a02c | 2012-05-02 16:05:44 -0600 | [diff] [blame] | 121 | static void __init paz00_init(void) |
| 122 | { |
Hiroshi Doyu | 1b14f3a | 2013-02-13 19:15:50 +0200 | [diff] [blame] | 123 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC)) |
| 124 | tegra_paz00_wifikill_init(); |
Stephen Warren | b64a02c | 2012-05-02 16:05:44 -0600 | [diff] [blame] | 125 | } |
Stephen Warren | b64a02c | 2012-05-02 16:05:44 -0600 | [diff] [blame] | 126 | |
Stephen Warren | c554dee | 2012-05-02 13:43:26 -0600 | [diff] [blame] | 127 | static struct { |
| 128 | char *machine; |
| 129 | void (*init)(void); |
| 130 | } board_init_funcs[] = { |
Stephen Warren | b64a02c | 2012-05-02 16:05:44 -0600 | [diff] [blame] | 131 | { "compal,paz00", paz00_init }, |
Stephen Warren | c554dee | 2012-05-02 13:43:26 -0600 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | static void __init tegra_dt_init_late(void) |
| 135 | { |
| 136 | int i; |
| 137 | |
Stephen Warren | 51100bd | 2013-08-20 15:47:38 -0600 | [diff] [blame] | 138 | tegra_init_suspend(); |
| 139 | tegra_cpuidle_init(); |
Stephen Warren | c554dee | 2012-05-02 13:43:26 -0600 | [diff] [blame] | 140 | |
| 141 | for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) { |
| 142 | if (of_machine_is_compatible(board_init_funcs[i].machine)) { |
| 143 | board_init_funcs[i].init(); |
| 144 | break; |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | |
Hiroshi Doyu | 1b14f3a | 2013-02-13 19:15:50 +0200 | [diff] [blame] | 149 | static const char * const tegra_dt_board_compat[] = { |
Joseph Lo | 7394447 | 2013-10-08 12:50:03 +0800 | [diff] [blame] | 150 | "nvidia,tegra124", |
Hiroshi Doyu | 1b14f3a | 2013-02-13 19:15:50 +0200 | [diff] [blame] | 151 | "nvidia,tegra114", |
| 152 | "nvidia,tegra30", |
Stephen Warren | c5444f3 | 2012-02-27 18:26:16 -0700 | [diff] [blame] | 153 | "nvidia,tegra20", |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 154 | NULL |
| 155 | }; |
| 156 | |
Hiroshi Doyu | 1b14f3a | 2013-02-13 19:15:50 +0200 | [diff] [blame] | 157 | DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)") |
Russell King | 00123d9a | 2014-04-28 15:36:04 +0100 | [diff] [blame] | 158 | .l2c_aux_val = 0x3c400001, |
| 159 | .l2c_aux_mask = 0xc20fc3fe, |
Marc Zyngier | a172573 | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 160 | .smp = smp_ops(tegra_smp_ops), |
Russell King | 00123d9a | 2014-04-28 15:36:04 +0100 | [diff] [blame] | 161 | .map_io = tegra_map_common_io, |
Hiroshi Doyu | 7469688 | 2013-02-13 19:15:48 +0200 | [diff] [blame] | 162 | .init_early = tegra_init_early, |
pdeschrijver@nvidia.com | 0d4f747 | 2011-11-29 18:29:19 -0700 | [diff] [blame] | 163 | .init_irq = tegra_dt_init_irq, |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 164 | .init_machine = tegra_dt_init, |
Stephen Warren | c554dee | 2012-05-02 13:43:26 -0600 | [diff] [blame] | 165 | .init_late = tegra_dt_init_late, |
Hiroshi Doyu | 1b14f3a | 2013-02-13 19:15:50 +0200 | [diff] [blame] | 166 | .dt_compat = tegra_dt_board_compat, |
Grant Likely | 8e267f3 | 2011-07-19 17:26:54 -0600 | [diff] [blame] | 167 | MACHINE_END |