Commit 35874f3617b38e0c1f72163407c41d554a8f5939
Committed by
Thierry Reding
1 parent
3f394f8064
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
ARM: tegra: move fuse exports to soc/tegra/fuse.h
All fuse related functionality will move to a driver in the following patches. To prepare for this, export all the required functionality in a global header file and move all users of fuse.h to soc/tegra/fuse.h. While we're at it, remove tegra_bct_strapping, as its only user was removed in Commit a7cbe92cef27 ("ARM: tegra: remove tegra EMC scaling driver"). Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com> Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
Showing 6 changed files with 22 additions and 14 deletions Inline Diff
arch/arm/mach-tegra/fuse.h
1 | /* | 1 | /* |
2 | * Copyright (C) 2010 Google, Inc. | 2 | * Copyright (C) 2010 Google, Inc. |
3 | * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. | 3 | * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. |
4 | * | 4 | * |
5 | * Author: | 5 | * Author: |
6 | * Colin Cross <ccross@android.com> | 6 | * Colin Cross <ccross@android.com> |
7 | * | 7 | * |
8 | * This software is licensed under the terms of the GNU General Public | 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 | 9 | * License version 2, as published by the Free Software Foundation, and |
10 | * may be copied, distributed, and modified under those terms. | 10 | * may be copied, distributed, and modified under those terms. |
11 | * | 11 | * |
12 | * This program is distributed in the hope that it will be useful, | 12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. |
16 | * | 16 | * |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #ifndef __MACH_TEGRA_FUSE_H | 19 | #ifndef __MACH_TEGRA_FUSE_H |
20 | #define __MACH_TEGRA_FUSE_H | 20 | #define __MACH_TEGRA_FUSE_H |
21 | 21 | ||
22 | #define SKU_ID_T20 8 | 22 | #define SKU_ID_T20 8 |
23 | #define SKU_ID_T25SE 20 | 23 | #define SKU_ID_T25SE 20 |
24 | #define SKU_ID_AP25 23 | 24 | #define SKU_ID_AP25 23 |
25 | #define SKU_ID_T25 24 | 25 | #define SKU_ID_T25 24 |
26 | #define SKU_ID_AP25E 27 | 26 | #define SKU_ID_AP25E 27 |
27 | #define SKU_ID_T25E 28 | 27 | #define SKU_ID_T25E 28 |
28 | 28 | ||
29 | #ifndef __ASSEMBLY__ | 29 | #ifndef __ASSEMBLY__ |
30 | enum tegra_revision { | ||
31 | TEGRA_REVISION_UNKNOWN = 0, | ||
32 | TEGRA_REVISION_A01, | ||
33 | TEGRA_REVISION_A02, | ||
34 | TEGRA_REVISION_A03, | ||
35 | TEGRA_REVISION_A03p, | ||
36 | TEGRA_REVISION_A04, | ||
37 | TEGRA_REVISION_MAX, | ||
38 | }; | ||
39 | 30 | ||
40 | extern int tegra_sku_id; | 31 | extern int tegra_sku_id; |
41 | extern int tegra_cpu_process_id; | 32 | extern int tegra_cpu_process_id; |
42 | extern int tegra_core_process_id; | 33 | extern int tegra_core_process_id; |
43 | extern int tegra_cpu_speedo_id; /* only exist in Tegra30 and later */ | 34 | extern int tegra_cpu_speedo_id; /* only exist in Tegra30 and later */ |
44 | extern int tegra_soc_speedo_id; | 35 | extern int tegra_soc_speedo_id; |
45 | extern enum tegra_revision tegra_revision; | ||
46 | 36 | ||
47 | extern int tegra_bct_strapping; | ||
48 | |||
49 | unsigned long long tegra_chip_uid(void); | 37 | unsigned long long tegra_chip_uid(void); |
50 | void tegra_init_fuse(void); | ||
51 | bool tegra_spare_fuse(int bit); | 38 | bool tegra_spare_fuse(int bit); |
52 | u32 tegra_fuse_readl(unsigned long offset); | 39 | u32 tegra_fuse_readl(unsigned long offset); |
53 | 40 | ||
54 | #ifdef CONFIG_ARCH_TEGRA_2x_SOC | 41 | #ifdef CONFIG_ARCH_TEGRA_2x_SOC |
55 | void tegra20_init_speedo_data(void); | 42 | void tegra20_init_speedo_data(void); |
56 | #else | 43 | #else |
57 | static inline void tegra20_init_speedo_data(void) {} | 44 | static inline void tegra20_init_speedo_data(void) {} |
58 | #endif | 45 | #endif |
59 | 46 | ||
60 | #ifdef CONFIG_ARCH_TEGRA_3x_SOC | 47 | #ifdef CONFIG_ARCH_TEGRA_3x_SOC |
61 | void tegra30_init_speedo_data(void); | 48 | void tegra30_init_speedo_data(void); |
62 | #else | 49 | #else |
63 | static inline void tegra30_init_speedo_data(void) {} | 50 | static inline void tegra30_init_speedo_data(void) {} |
64 | #endif | 51 | #endif |
65 | 52 | ||
66 | #ifdef CONFIG_ARCH_TEGRA_114_SOC | 53 | #ifdef CONFIG_ARCH_TEGRA_114_SOC |
67 | void tegra114_init_speedo_data(void); | 54 | void tegra114_init_speedo_data(void); |
68 | #else | 55 | #else |
69 | static inline void tegra114_init_speedo_data(void) {} | 56 | static inline void tegra114_init_speedo_data(void) {} |
70 | #endif | 57 | #endif |
71 | #endif /* __ASSEMBLY__ */ | 58 | #endif /* __ASSEMBLY__ */ |
72 | 59 | ||
73 | #endif | 60 | #endif |
74 | 61 |
arch/arm/mach-tegra/tegra.c
1 | /* | 1 | /* |
2 | * NVIDIA Tegra SoC device tree board support | 2 | * NVIDIA Tegra SoC device tree board support |
3 | * | 3 | * |
4 | * Copyright (C) 2011, 2013, NVIDIA Corporation | 4 | * Copyright (C) 2011, 2013, NVIDIA Corporation |
5 | * Copyright (C) 2010 Secret Lab Technologies, Ltd. | 5 | * Copyright (C) 2010 Secret Lab Technologies, Ltd. |
6 | * Copyright (C) 2010 Google, Inc. | 6 | * Copyright (C) 2010 Google, Inc. |
7 | * | 7 | * |
8 | * This software is licensed under the terms of the GNU General Public | 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 | 9 | * License version 2, as published by the Free Software Foundation, and |
10 | * may be copied, distributed, and modified under those terms. | 10 | * may be copied, distributed, and modified under those terms. |
11 | * | 11 | * |
12 | * This program is distributed in the hope that it will be useful, | 12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. |
16 | * | 16 | * |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/clk.h> | 19 | #include <linux/clk.h> |
20 | #include <linux/clk/tegra.h> | 20 | #include <linux/clk/tegra.h> |
21 | #include <linux/dma-mapping.h> | 21 | #include <linux/dma-mapping.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/irqchip.h> | 24 | #include <linux/irqchip.h> |
25 | #include <linux/irqdomain.h> | 25 | #include <linux/irqdomain.h> |
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/of_address.h> | 27 | #include <linux/of_address.h> |
28 | #include <linux/of_fdt.h> | 28 | #include <linux/of_fdt.h> |
29 | #include <linux/of.h> | 29 | #include <linux/of.h> |
30 | #include <linux/of_platform.h> | 30 | #include <linux/of_platform.h> |
31 | #include <linux/pda_power.h> | 31 | #include <linux/pda_power.h> |
32 | #include <linux/platform_device.h> | 32 | #include <linux/platform_device.h> |
33 | #include <linux/serial_8250.h> | 33 | #include <linux/serial_8250.h> |
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/sys_soc.h> | 35 | #include <linux/sys_soc.h> |
36 | #include <linux/usb/tegra_usb_phy.h> | 36 | #include <linux/usb/tegra_usb_phy.h> |
37 | 37 | ||
38 | #include <soc/tegra/fuse.h> | 38 | #include <soc/tegra/fuse.h> |
39 | 39 | ||
40 | #include <asm/hardware/cache-l2x0.h> | 40 | #include <asm/hardware/cache-l2x0.h> |
41 | #include <asm/mach/arch.h> | 41 | #include <asm/mach/arch.h> |
42 | #include <asm/mach/time.h> | 42 | #include <asm/mach/time.h> |
43 | #include <asm/mach-types.h> | 43 | #include <asm/mach-types.h> |
44 | #include <asm/setup.h> | 44 | #include <asm/setup.h> |
45 | #include <asm/trusted_foundations.h> | 45 | #include <asm/trusted_foundations.h> |
46 | 46 | ||
47 | #include "apbio.h" | 47 | #include "apbio.h" |
48 | #include "board.h" | 48 | #include "board.h" |
49 | #include "common.h" | 49 | #include "common.h" |
50 | #include "cpuidle.h" | 50 | #include "cpuidle.h" |
51 | #include "fuse.h" | ||
52 | #include "iomap.h" | 51 | #include "iomap.h" |
53 | #include "irq.h" | 52 | #include "irq.h" |
54 | #include "pmc.h" | 53 | #include "pmc.h" |
55 | #include "pm.h" | 54 | #include "pm.h" |
56 | #include "reset.h" | 55 | #include "reset.h" |
57 | #include "sleep.h" | 56 | #include "sleep.h" |
58 | 57 | ||
59 | /* | 58 | /* |
60 | * Storage for debug-macro.S's state. | 59 | * Storage for debug-macro.S's state. |
61 | * | 60 | * |
62 | * This must be in .data not .bss so that it gets initialized each time the | 61 | * This must be in .data not .bss so that it gets initialized each time the |
63 | * kernel is loaded. The data is declared here rather than debug-macro.S so | 62 | * kernel is loaded. The data is declared here rather than debug-macro.S so |
64 | * that multiple inclusions of debug-macro.S point at the same data. | 63 | * that multiple inclusions of debug-macro.S point at the same data. |
65 | */ | 64 | */ |
66 | u32 tegra_uart_config[3] = { | 65 | u32 tegra_uart_config[3] = { |
67 | /* Debug UART initialization required */ | 66 | /* Debug UART initialization required */ |
68 | 1, | 67 | 1, |
69 | /* Debug UART physical address */ | 68 | /* Debug UART physical address */ |
70 | 0, | 69 | 0, |
71 | /* Debug UART virtual address */ | 70 | /* Debug UART virtual address */ |
72 | 0, | 71 | 0, |
73 | }; | 72 | }; |
74 | 73 | ||
75 | static void __init tegra_init_early(void) | 74 | static void __init tegra_init_early(void) |
76 | { | 75 | { |
77 | of_register_trusted_foundations(); | 76 | of_register_trusted_foundations(); |
78 | tegra_apb_io_init(); | 77 | tegra_apb_io_init(); |
79 | tegra_init_fuse(); | 78 | tegra_init_fuse(); |
80 | tegra_cpu_reset_handler_init(); | 79 | tegra_cpu_reset_handler_init(); |
81 | tegra_powergate_init(); | 80 | tegra_powergate_init(); |
82 | tegra_hotplug_init(); | 81 | tegra_hotplug_init(); |
83 | } | 82 | } |
84 | 83 | ||
85 | static void __init tegra_dt_init_irq(void) | 84 | static void __init tegra_dt_init_irq(void) |
86 | { | 85 | { |
87 | tegra_pmc_init_irq(); | 86 | tegra_pmc_init_irq(); |
88 | tegra_init_irq(); | 87 | tegra_init_irq(); |
89 | irqchip_init(); | 88 | irqchip_init(); |
90 | tegra_legacy_irq_syscore_init(); | 89 | tegra_legacy_irq_syscore_init(); |
91 | } | 90 | } |
92 | 91 | ||
93 | static void __init tegra_dt_init(void) | 92 | static void __init tegra_dt_init(void) |
94 | { | 93 | { |
95 | struct soc_device_attribute *soc_dev_attr; | 94 | struct soc_device_attribute *soc_dev_attr; |
96 | struct soc_device *soc_dev; | 95 | struct soc_device *soc_dev; |
97 | struct device *parent = NULL; | 96 | struct device *parent = NULL; |
98 | 97 | ||
99 | tegra_pmc_init(); | 98 | tegra_pmc_init(); |
100 | 99 | ||
101 | tegra_clocks_apply_init_table(); | 100 | tegra_clocks_apply_init_table(); |
102 | 101 | ||
103 | soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); | 102 | soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); |
104 | if (!soc_dev_attr) | 103 | if (!soc_dev_attr) |
105 | goto out; | 104 | goto out; |
106 | 105 | ||
107 | soc_dev_attr->family = kasprintf(GFP_KERNEL, "Tegra"); | 106 | soc_dev_attr->family = kasprintf(GFP_KERNEL, "Tegra"); |
108 | soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", tegra_revision); | 107 | soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", tegra_revision); |
109 | soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%u", tegra_get_chip_id()); | 108 | soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%u", tegra_get_chip_id()); |
110 | 109 | ||
111 | soc_dev = soc_device_register(soc_dev_attr); | 110 | soc_dev = soc_device_register(soc_dev_attr); |
112 | if (IS_ERR(soc_dev)) { | 111 | if (IS_ERR(soc_dev)) { |
113 | kfree(soc_dev_attr->family); | 112 | kfree(soc_dev_attr->family); |
114 | kfree(soc_dev_attr->revision); | 113 | kfree(soc_dev_attr->revision); |
115 | kfree(soc_dev_attr->soc_id); | 114 | kfree(soc_dev_attr->soc_id); |
116 | kfree(soc_dev_attr); | 115 | kfree(soc_dev_attr); |
117 | goto out; | 116 | goto out; |
118 | } | 117 | } |
119 | 118 | ||
120 | parent = soc_device_to_device(soc_dev); | 119 | parent = soc_device_to_device(soc_dev); |
121 | 120 | ||
122 | /* | 121 | /* |
123 | * Finished with the static registrations now; fill in the missing | 122 | * Finished with the static registrations now; fill in the missing |
124 | * devices | 123 | * devices |
125 | */ | 124 | */ |
126 | out: | 125 | out: |
127 | of_platform_populate(NULL, of_default_bus_match_table, NULL, parent); | 126 | of_platform_populate(NULL, of_default_bus_match_table, NULL, parent); |
128 | } | 127 | } |
129 | 128 | ||
130 | static void __init paz00_init(void) | 129 | static void __init paz00_init(void) |
131 | { | 130 | { |
132 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC)) | 131 | if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC)) |
133 | tegra_paz00_wifikill_init(); | 132 | tegra_paz00_wifikill_init(); |
134 | } | 133 | } |
135 | 134 | ||
136 | static struct { | 135 | static struct { |
137 | char *machine; | 136 | char *machine; |
138 | void (*init)(void); | 137 | void (*init)(void); |
139 | } board_init_funcs[] = { | 138 | } board_init_funcs[] = { |
140 | { "compal,paz00", paz00_init }, | 139 | { "compal,paz00", paz00_init }, |
141 | }; | 140 | }; |
142 | 141 | ||
143 | static void __init tegra_dt_init_late(void) | 142 | static void __init tegra_dt_init_late(void) |
144 | { | 143 | { |
145 | int i; | 144 | int i; |
146 | 145 | ||
147 | tegra_init_suspend(); | 146 | tegra_init_suspend(); |
148 | tegra_cpuidle_init(); | 147 | tegra_cpuidle_init(); |
149 | tegra_powergate_debugfs_init(); | 148 | tegra_powergate_debugfs_init(); |
150 | 149 | ||
151 | for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) { | 150 | for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) { |
152 | if (of_machine_is_compatible(board_init_funcs[i].machine)) { | 151 | if (of_machine_is_compatible(board_init_funcs[i].machine)) { |
153 | board_init_funcs[i].init(); | 152 | board_init_funcs[i].init(); |
154 | break; | 153 | break; |
155 | } | 154 | } |
156 | } | 155 | } |
157 | } | 156 | } |
158 | 157 | ||
159 | static const char * const tegra_dt_board_compat[] = { | 158 | static const char * const tegra_dt_board_compat[] = { |
160 | "nvidia,tegra124", | 159 | "nvidia,tegra124", |
161 | "nvidia,tegra114", | 160 | "nvidia,tegra114", |
162 | "nvidia,tegra30", | 161 | "nvidia,tegra30", |
163 | "nvidia,tegra20", | 162 | "nvidia,tegra20", |
164 | NULL | 163 | NULL |
165 | }; | 164 | }; |
166 | 165 | ||
167 | DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)") | 166 | DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)") |
168 | .l2c_aux_val = 0x3c400001, | 167 | .l2c_aux_val = 0x3c400001, |
169 | .l2c_aux_mask = 0xc20fc3fe, | 168 | .l2c_aux_mask = 0xc20fc3fe, |
170 | .smp = smp_ops(tegra_smp_ops), | 169 | .smp = smp_ops(tegra_smp_ops), |
171 | .map_io = tegra_map_common_io, | 170 | .map_io = tegra_map_common_io, |
172 | .init_early = tegra_init_early, | 171 | .init_early = tegra_init_early, |
173 | .init_irq = tegra_dt_init_irq, | 172 | .init_irq = tegra_dt_init_irq, |
174 | .init_machine = tegra_dt_init, | 173 | .init_machine = tegra_dt_init, |
175 | .init_late = tegra_dt_init_late, | 174 | .init_late = tegra_dt_init_late, |
176 | .restart = tegra_pmc_restart, | 175 | .restart = tegra_pmc_restart, |
177 | .dt_compat = tegra_dt_board_compat, | 176 | .dt_compat = tegra_dt_board_compat, |
178 | MACHINE_END | 177 | MACHINE_END |
179 | 178 |
arch/arm/mach-tegra/tegra114_speedo.c
1 | /* | 1 | /* |
2 | * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms and conditions of the GNU General Public License, | 5 | * under the terms and conditions of the GNU General Public License, |
6 | * version 2, as published by the Free Software Foundation. | 6 | * version 2, as published by the Free Software Foundation. |
7 | * | 7 | * |
8 | * This program is distributed in the hope it will be useful, but WITHOUT | 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
11 | * more details. | 11 | * more details. |
12 | * | 12 | * |
13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/bug.h> | 17 | #include <linux/bug.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | 19 | ||
20 | #include <soc/tegra/fuse.h> | ||
21 | |||
20 | #include "fuse.h" | 22 | #include "fuse.h" |
21 | 23 | ||
22 | #define CORE_PROCESS_CORNERS_NUM 2 | 24 | #define CORE_PROCESS_CORNERS_NUM 2 |
23 | #define CPU_PROCESS_CORNERS_NUM 2 | 25 | #define CPU_PROCESS_CORNERS_NUM 2 |
24 | 26 | ||
25 | enum { | 27 | enum { |
26 | THRESHOLD_INDEX_0, | 28 | THRESHOLD_INDEX_0, |
27 | THRESHOLD_INDEX_1, | 29 | THRESHOLD_INDEX_1, |
28 | THRESHOLD_INDEX_COUNT, | 30 | THRESHOLD_INDEX_COUNT, |
29 | }; | 31 | }; |
30 | 32 | ||
31 | static const u32 core_process_speedos[][CORE_PROCESS_CORNERS_NUM] = { | 33 | static const u32 core_process_speedos[][CORE_PROCESS_CORNERS_NUM] = { |
32 | {1123, UINT_MAX}, | 34 | {1123, UINT_MAX}, |
33 | {0, UINT_MAX}, | 35 | {0, UINT_MAX}, |
34 | }; | 36 | }; |
35 | 37 | ||
36 | static const u32 cpu_process_speedos[][CPU_PROCESS_CORNERS_NUM] = { | 38 | static const u32 cpu_process_speedos[][CPU_PROCESS_CORNERS_NUM] = { |
37 | {1695, UINT_MAX}, | 39 | {1695, UINT_MAX}, |
38 | {0, UINT_MAX}, | 40 | {0, UINT_MAX}, |
39 | }; | 41 | }; |
40 | 42 | ||
41 | static void rev_sku_to_speedo_ids(int rev, int sku, int *threshold) | 43 | static void rev_sku_to_speedo_ids(int rev, int sku, int *threshold) |
42 | { | 44 | { |
43 | u32 tmp; | 45 | u32 tmp; |
44 | 46 | ||
45 | switch (sku) { | 47 | switch (sku) { |
46 | case 0x00: | 48 | case 0x00: |
47 | case 0x10: | 49 | case 0x10: |
48 | case 0x05: | 50 | case 0x05: |
49 | case 0x06: | 51 | case 0x06: |
50 | tegra_cpu_speedo_id = 1; | 52 | tegra_cpu_speedo_id = 1; |
51 | tegra_soc_speedo_id = 0; | 53 | tegra_soc_speedo_id = 0; |
52 | *threshold = THRESHOLD_INDEX_0; | 54 | *threshold = THRESHOLD_INDEX_0; |
53 | break; | 55 | break; |
54 | 56 | ||
55 | case 0x03: | 57 | case 0x03: |
56 | case 0x04: | 58 | case 0x04: |
57 | tegra_cpu_speedo_id = 2; | 59 | tegra_cpu_speedo_id = 2; |
58 | tegra_soc_speedo_id = 1; | 60 | tegra_soc_speedo_id = 1; |
59 | *threshold = THRESHOLD_INDEX_1; | 61 | *threshold = THRESHOLD_INDEX_1; |
60 | break; | 62 | break; |
61 | 63 | ||
62 | default: | 64 | default: |
63 | pr_err("Tegra114 Unknown SKU %d\n", sku); | 65 | pr_err("Tegra114 Unknown SKU %d\n", sku); |
64 | tegra_cpu_speedo_id = 0; | 66 | tegra_cpu_speedo_id = 0; |
65 | tegra_soc_speedo_id = 0; | 67 | tegra_soc_speedo_id = 0; |
66 | *threshold = THRESHOLD_INDEX_0; | 68 | *threshold = THRESHOLD_INDEX_0; |
67 | break; | 69 | break; |
68 | } | 70 | } |
69 | 71 | ||
70 | if (rev == TEGRA_REVISION_A01) { | 72 | if (rev == TEGRA_REVISION_A01) { |
71 | tmp = tegra_fuse_readl(0x270) << 1; | 73 | tmp = tegra_fuse_readl(0x270) << 1; |
72 | tmp |= tegra_fuse_readl(0x26c); | 74 | tmp |= tegra_fuse_readl(0x26c); |
73 | if (!tmp) | 75 | if (!tmp) |
74 | tegra_cpu_speedo_id = 0; | 76 | tegra_cpu_speedo_id = 0; |
75 | } | 77 | } |
76 | } | 78 | } |
77 | 79 | ||
78 | void tegra114_init_speedo_data(void) | 80 | void tegra114_init_speedo_data(void) |
79 | { | 81 | { |
80 | u32 cpu_speedo_val; | 82 | u32 cpu_speedo_val; |
81 | u32 core_speedo_val; | 83 | u32 core_speedo_val; |
82 | int threshold; | 84 | int threshold; |
83 | int i; | 85 | int i; |
84 | 86 | ||
85 | BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) != | 87 | BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) != |
86 | THRESHOLD_INDEX_COUNT); | 88 | THRESHOLD_INDEX_COUNT); |
87 | BUILD_BUG_ON(ARRAY_SIZE(core_process_speedos) != | 89 | BUILD_BUG_ON(ARRAY_SIZE(core_process_speedos) != |
88 | THRESHOLD_INDEX_COUNT); | 90 | THRESHOLD_INDEX_COUNT); |
89 | 91 | ||
90 | rev_sku_to_speedo_ids(tegra_revision, tegra_sku_id, &threshold); | 92 | rev_sku_to_speedo_ids(tegra_revision, tegra_sku_id, &threshold); |
91 | 93 | ||
92 | cpu_speedo_val = tegra_fuse_readl(0x12c) + 1024; | 94 | cpu_speedo_val = tegra_fuse_readl(0x12c) + 1024; |
93 | core_speedo_val = tegra_fuse_readl(0x134); | 95 | core_speedo_val = tegra_fuse_readl(0x134); |
94 | 96 | ||
95 | for (i = 0; i < CPU_PROCESS_CORNERS_NUM; i++) | 97 | for (i = 0; i < CPU_PROCESS_CORNERS_NUM; i++) |
96 | if (cpu_speedo_val < cpu_process_speedos[threshold][i]) | 98 | if (cpu_speedo_val < cpu_process_speedos[threshold][i]) |
97 | break; | 99 | break; |
98 | tegra_cpu_process_id = i; | 100 | tegra_cpu_process_id = i; |
99 | 101 | ||
100 | for (i = 0; i < CORE_PROCESS_CORNERS_NUM; i++) | 102 | for (i = 0; i < CORE_PROCESS_CORNERS_NUM; i++) |
101 | if (core_speedo_val < core_process_speedos[threshold][i]) | 103 | if (core_speedo_val < core_process_speedos[threshold][i]) |
102 | break; | 104 | break; |
103 | tegra_core_process_id = i; | 105 | tegra_core_process_id = i; |
104 | } | 106 | } |
105 | 107 |
arch/arm/mach-tegra/tegra20_speedo.c
1 | /* | 1 | /* |
2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms and conditions of the GNU General Public License, | 5 | * under the terms and conditions of the GNU General Public License, |
6 | * version 2, as published by the Free Software Foundation. | 6 | * version 2, as published by the Free Software Foundation. |
7 | * | 7 | * |
8 | * This program is distributed in the hope it will be useful, but WITHOUT | 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
11 | * more details. | 11 | * more details. |
12 | * | 12 | * |
13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/bug.h> | 17 | #include <linux/bug.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | 19 | ||
20 | #include <soc/tegra/fuse.h> | ||
21 | |||
20 | #include "fuse.h" | 22 | #include "fuse.h" |
21 | 23 | ||
22 | #define CPU_SPEEDO_LSBIT 20 | 24 | #define CPU_SPEEDO_LSBIT 20 |
23 | #define CPU_SPEEDO_MSBIT 29 | 25 | #define CPU_SPEEDO_MSBIT 29 |
24 | #define CPU_SPEEDO_REDUND_LSBIT 30 | 26 | #define CPU_SPEEDO_REDUND_LSBIT 30 |
25 | #define CPU_SPEEDO_REDUND_MSBIT 39 | 27 | #define CPU_SPEEDO_REDUND_MSBIT 39 |
26 | #define CPU_SPEEDO_REDUND_OFFS (CPU_SPEEDO_REDUND_MSBIT - CPU_SPEEDO_MSBIT) | 28 | #define CPU_SPEEDO_REDUND_OFFS (CPU_SPEEDO_REDUND_MSBIT - CPU_SPEEDO_MSBIT) |
27 | 29 | ||
28 | #define CORE_SPEEDO_LSBIT 40 | 30 | #define CORE_SPEEDO_LSBIT 40 |
29 | #define CORE_SPEEDO_MSBIT 47 | 31 | #define CORE_SPEEDO_MSBIT 47 |
30 | #define CORE_SPEEDO_REDUND_LSBIT 48 | 32 | #define CORE_SPEEDO_REDUND_LSBIT 48 |
31 | #define CORE_SPEEDO_REDUND_MSBIT 55 | 33 | #define CORE_SPEEDO_REDUND_MSBIT 55 |
32 | #define CORE_SPEEDO_REDUND_OFFS (CORE_SPEEDO_REDUND_MSBIT - CORE_SPEEDO_MSBIT) | 34 | #define CORE_SPEEDO_REDUND_OFFS (CORE_SPEEDO_REDUND_MSBIT - CORE_SPEEDO_MSBIT) |
33 | 35 | ||
34 | #define SPEEDO_MULT 4 | 36 | #define SPEEDO_MULT 4 |
35 | 37 | ||
36 | #define PROCESS_CORNERS_NUM 4 | 38 | #define PROCESS_CORNERS_NUM 4 |
37 | 39 | ||
38 | #define SPEEDO_ID_SELECT_0(rev) ((rev) <= 2) | 40 | #define SPEEDO_ID_SELECT_0(rev) ((rev) <= 2) |
39 | #define SPEEDO_ID_SELECT_1(sku) \ | 41 | #define SPEEDO_ID_SELECT_1(sku) \ |
40 | (((sku) != 20) && ((sku) != 23) && ((sku) != 24) && \ | 42 | (((sku) != 20) && ((sku) != 23) && ((sku) != 24) && \ |
41 | ((sku) != 27) && ((sku) != 28)) | 43 | ((sku) != 27) && ((sku) != 28)) |
42 | 44 | ||
43 | enum { | 45 | enum { |
44 | SPEEDO_ID_0, | 46 | SPEEDO_ID_0, |
45 | SPEEDO_ID_1, | 47 | SPEEDO_ID_1, |
46 | SPEEDO_ID_2, | 48 | SPEEDO_ID_2, |
47 | SPEEDO_ID_COUNT, | 49 | SPEEDO_ID_COUNT, |
48 | }; | 50 | }; |
49 | 51 | ||
50 | static const u32 cpu_process_speedos[][PROCESS_CORNERS_NUM] = { | 52 | static const u32 cpu_process_speedos[][PROCESS_CORNERS_NUM] = { |
51 | {315, 366, 420, UINT_MAX}, | 53 | {315, 366, 420, UINT_MAX}, |
52 | {303, 368, 419, UINT_MAX}, | 54 | {303, 368, 419, UINT_MAX}, |
53 | {316, 331, 383, UINT_MAX}, | 55 | {316, 331, 383, UINT_MAX}, |
54 | }; | 56 | }; |
55 | 57 | ||
56 | static const u32 core_process_speedos[][PROCESS_CORNERS_NUM] = { | 58 | static const u32 core_process_speedos[][PROCESS_CORNERS_NUM] = { |
57 | {165, 195, 224, UINT_MAX}, | 59 | {165, 195, 224, UINT_MAX}, |
58 | {165, 195, 224, UINT_MAX}, | 60 | {165, 195, 224, UINT_MAX}, |
59 | {165, 195, 224, UINT_MAX}, | 61 | {165, 195, 224, UINT_MAX}, |
60 | }; | 62 | }; |
61 | 63 | ||
62 | void tegra20_init_speedo_data(void) | 64 | void tegra20_init_speedo_data(void) |
63 | { | 65 | { |
64 | u32 reg; | 66 | u32 reg; |
65 | u32 val; | 67 | u32 val; |
66 | int i; | 68 | int i; |
67 | 69 | ||
68 | BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) != SPEEDO_ID_COUNT); | 70 | BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) != SPEEDO_ID_COUNT); |
69 | BUILD_BUG_ON(ARRAY_SIZE(core_process_speedos) != SPEEDO_ID_COUNT); | 71 | BUILD_BUG_ON(ARRAY_SIZE(core_process_speedos) != SPEEDO_ID_COUNT); |
70 | 72 | ||
71 | if (SPEEDO_ID_SELECT_0(tegra_revision)) | 73 | if (SPEEDO_ID_SELECT_0(tegra_revision)) |
72 | tegra_soc_speedo_id = SPEEDO_ID_0; | 74 | tegra_soc_speedo_id = SPEEDO_ID_0; |
73 | else if (SPEEDO_ID_SELECT_1(tegra_sku_id)) | 75 | else if (SPEEDO_ID_SELECT_1(tegra_sku_id)) |
74 | tegra_soc_speedo_id = SPEEDO_ID_1; | 76 | tegra_soc_speedo_id = SPEEDO_ID_1; |
75 | else | 77 | else |
76 | tegra_soc_speedo_id = SPEEDO_ID_2; | 78 | tegra_soc_speedo_id = SPEEDO_ID_2; |
77 | 79 | ||
78 | val = 0; | 80 | val = 0; |
79 | for (i = CPU_SPEEDO_MSBIT; i >= CPU_SPEEDO_LSBIT; i--) { | 81 | for (i = CPU_SPEEDO_MSBIT; i >= CPU_SPEEDO_LSBIT; i--) { |
80 | reg = tegra_spare_fuse(i) | | 82 | reg = tegra_spare_fuse(i) | |
81 | tegra_spare_fuse(i + CPU_SPEEDO_REDUND_OFFS); | 83 | tegra_spare_fuse(i + CPU_SPEEDO_REDUND_OFFS); |
82 | val = (val << 1) | (reg & 0x1); | 84 | val = (val << 1) | (reg & 0x1); |
83 | } | 85 | } |
84 | val = val * SPEEDO_MULT; | 86 | val = val * SPEEDO_MULT; |
85 | pr_debug("%s CPU speedo value %u\n", __func__, val); | 87 | pr_debug("%s CPU speedo value %u\n", __func__, val); |
86 | 88 | ||
87 | for (i = 0; i < (PROCESS_CORNERS_NUM - 1); i++) { | 89 | for (i = 0; i < (PROCESS_CORNERS_NUM - 1); i++) { |
88 | if (val <= cpu_process_speedos[tegra_soc_speedo_id][i]) | 90 | if (val <= cpu_process_speedos[tegra_soc_speedo_id][i]) |
89 | break; | 91 | break; |
90 | } | 92 | } |
91 | tegra_cpu_process_id = i; | 93 | tegra_cpu_process_id = i; |
92 | 94 | ||
93 | val = 0; | 95 | val = 0; |
94 | for (i = CORE_SPEEDO_MSBIT; i >= CORE_SPEEDO_LSBIT; i--) { | 96 | for (i = CORE_SPEEDO_MSBIT; i >= CORE_SPEEDO_LSBIT; i--) { |
95 | reg = tegra_spare_fuse(i) | | 97 | reg = tegra_spare_fuse(i) | |
96 | tegra_spare_fuse(i + CORE_SPEEDO_REDUND_OFFS); | 98 | tegra_spare_fuse(i + CORE_SPEEDO_REDUND_OFFS); |
97 | val = (val << 1) | (reg & 0x1); | 99 | val = (val << 1) | (reg & 0x1); |
98 | } | 100 | } |
99 | val = val * SPEEDO_MULT; | 101 | val = val * SPEEDO_MULT; |
100 | pr_debug("%s Core speedo value %u\n", __func__, val); | 102 | pr_debug("%s Core speedo value %u\n", __func__, val); |
101 | 103 | ||
102 | for (i = 0; i < (PROCESS_CORNERS_NUM - 1); i++) { | 104 | for (i = 0; i < (PROCESS_CORNERS_NUM - 1); i++) { |
103 | if (val <= core_process_speedos[tegra_soc_speedo_id][i]) | 105 | if (val <= core_process_speedos[tegra_soc_speedo_id][i]) |
104 | break; | 106 | break; |
105 | } | 107 | } |
106 | tegra_core_process_id = i; | 108 | tegra_core_process_id = i; |
107 | 109 | ||
108 | pr_info("Tegra20 Soc Speedo ID %d", tegra_soc_speedo_id); | 110 | pr_info("Tegra20 Soc Speedo ID %d", tegra_soc_speedo_id); |
109 | } | 111 | } |
110 | 112 |
arch/arm/mach-tegra/tegra30_speedo.c
1 | /* | 1 | /* |
2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms and conditions of the GNU General Public License, | 5 | * under the terms and conditions of the GNU General Public License, |
6 | * version 2, as published by the Free Software Foundation. | 6 | * version 2, as published by the Free Software Foundation. |
7 | * | 7 | * |
8 | * This program is distributed in the hope it will be useful, but WITHOUT | 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
11 | * more details. | 11 | * more details. |
12 | * | 12 | * |
13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/bug.h> | 17 | #include <linux/bug.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | 19 | ||
20 | #include <soc/tegra/fuse.h> | ||
21 | |||
20 | #include "fuse.h" | 22 | #include "fuse.h" |
21 | 23 | ||
22 | #define CORE_PROCESS_CORNERS_NUM 1 | 24 | #define CORE_PROCESS_CORNERS_NUM 1 |
23 | #define CPU_PROCESS_CORNERS_NUM 6 | 25 | #define CPU_PROCESS_CORNERS_NUM 6 |
24 | 26 | ||
25 | #define FUSE_SPEEDO_CALIB_0 0x114 | 27 | #define FUSE_SPEEDO_CALIB_0 0x114 |
26 | #define FUSE_PACKAGE_INFO 0X1FC | 28 | #define FUSE_PACKAGE_INFO 0X1FC |
27 | #define FUSE_TEST_PROG_VER 0X128 | 29 | #define FUSE_TEST_PROG_VER 0X128 |
28 | 30 | ||
29 | #define G_SPEEDO_BIT_MINUS1 58 | 31 | #define G_SPEEDO_BIT_MINUS1 58 |
30 | #define G_SPEEDO_BIT_MINUS1_R 59 | 32 | #define G_SPEEDO_BIT_MINUS1_R 59 |
31 | #define G_SPEEDO_BIT_MINUS2 60 | 33 | #define G_SPEEDO_BIT_MINUS2 60 |
32 | #define G_SPEEDO_BIT_MINUS2_R 61 | 34 | #define G_SPEEDO_BIT_MINUS2_R 61 |
33 | #define LP_SPEEDO_BIT_MINUS1 62 | 35 | #define LP_SPEEDO_BIT_MINUS1 62 |
34 | #define LP_SPEEDO_BIT_MINUS1_R 63 | 36 | #define LP_SPEEDO_BIT_MINUS1_R 63 |
35 | #define LP_SPEEDO_BIT_MINUS2 64 | 37 | #define LP_SPEEDO_BIT_MINUS2 64 |
36 | #define LP_SPEEDO_BIT_MINUS2_R 65 | 38 | #define LP_SPEEDO_BIT_MINUS2_R 65 |
37 | 39 | ||
38 | enum { | 40 | enum { |
39 | THRESHOLD_INDEX_0, | 41 | THRESHOLD_INDEX_0, |
40 | THRESHOLD_INDEX_1, | 42 | THRESHOLD_INDEX_1, |
41 | THRESHOLD_INDEX_2, | 43 | THRESHOLD_INDEX_2, |
42 | THRESHOLD_INDEX_3, | 44 | THRESHOLD_INDEX_3, |
43 | THRESHOLD_INDEX_4, | 45 | THRESHOLD_INDEX_4, |
44 | THRESHOLD_INDEX_5, | 46 | THRESHOLD_INDEX_5, |
45 | THRESHOLD_INDEX_6, | 47 | THRESHOLD_INDEX_6, |
46 | THRESHOLD_INDEX_7, | 48 | THRESHOLD_INDEX_7, |
47 | THRESHOLD_INDEX_8, | 49 | THRESHOLD_INDEX_8, |
48 | THRESHOLD_INDEX_9, | 50 | THRESHOLD_INDEX_9, |
49 | THRESHOLD_INDEX_10, | 51 | THRESHOLD_INDEX_10, |
50 | THRESHOLD_INDEX_11, | 52 | THRESHOLD_INDEX_11, |
51 | THRESHOLD_INDEX_COUNT, | 53 | THRESHOLD_INDEX_COUNT, |
52 | }; | 54 | }; |
53 | 55 | ||
54 | static const u32 core_process_speedos[][CORE_PROCESS_CORNERS_NUM] = { | 56 | static const u32 core_process_speedos[][CORE_PROCESS_CORNERS_NUM] = { |
55 | {180}, | 57 | {180}, |
56 | {170}, | 58 | {170}, |
57 | {195}, | 59 | {195}, |
58 | {180}, | 60 | {180}, |
59 | {168}, | 61 | {168}, |
60 | {192}, | 62 | {192}, |
61 | {180}, | 63 | {180}, |
62 | {170}, | 64 | {170}, |
63 | {195}, | 65 | {195}, |
64 | {180}, | 66 | {180}, |
65 | {180}, | 67 | {180}, |
66 | {180}, | 68 | {180}, |
67 | }; | 69 | }; |
68 | 70 | ||
69 | static const u32 cpu_process_speedos[][CPU_PROCESS_CORNERS_NUM] = { | 71 | static const u32 cpu_process_speedos[][CPU_PROCESS_CORNERS_NUM] = { |
70 | {306, 338, 360, 376, UINT_MAX}, | 72 | {306, 338, 360, 376, UINT_MAX}, |
71 | {295, 336, 358, 375, UINT_MAX}, | 73 | {295, 336, 358, 375, UINT_MAX}, |
72 | {325, 325, 358, 375, UINT_MAX}, | 74 | {325, 325, 358, 375, UINT_MAX}, |
73 | {325, 325, 358, 375, UINT_MAX}, | 75 | {325, 325, 358, 375, UINT_MAX}, |
74 | {292, 324, 348, 364, UINT_MAX}, | 76 | {292, 324, 348, 364, UINT_MAX}, |
75 | {324, 324, 348, 364, UINT_MAX}, | 77 | {324, 324, 348, 364, UINT_MAX}, |
76 | {324, 324, 348, 364, UINT_MAX}, | 78 | {324, 324, 348, 364, UINT_MAX}, |
77 | {295, 336, 358, 375, UINT_MAX}, | 79 | {295, 336, 358, 375, UINT_MAX}, |
78 | {358, 358, 358, 358, 397, UINT_MAX}, | 80 | {358, 358, 358, 358, 397, UINT_MAX}, |
79 | {364, 364, 364, 364, 397, UINT_MAX}, | 81 | {364, 364, 364, 364, 397, UINT_MAX}, |
80 | {295, 336, 358, 375, 391, UINT_MAX}, | 82 | {295, 336, 358, 375, 391, UINT_MAX}, |
81 | {295, 336, 358, 375, 391, UINT_MAX}, | 83 | {295, 336, 358, 375, 391, UINT_MAX}, |
82 | }; | 84 | }; |
83 | 85 | ||
84 | static int threshold_index; | 86 | static int threshold_index; |
85 | static int package_id; | 87 | static int package_id; |
86 | 88 | ||
87 | static void fuse_speedo_calib(u32 *speedo_g, u32 *speedo_lp) | 89 | static void fuse_speedo_calib(u32 *speedo_g, u32 *speedo_lp) |
88 | { | 90 | { |
89 | u32 reg; | 91 | u32 reg; |
90 | int ate_ver; | 92 | int ate_ver; |
91 | int bit_minus1; | 93 | int bit_minus1; |
92 | int bit_minus2; | 94 | int bit_minus2; |
93 | 95 | ||
94 | reg = tegra_fuse_readl(FUSE_SPEEDO_CALIB_0); | 96 | reg = tegra_fuse_readl(FUSE_SPEEDO_CALIB_0); |
95 | 97 | ||
96 | *speedo_lp = (reg & 0xFFFF) * 4; | 98 | *speedo_lp = (reg & 0xFFFF) * 4; |
97 | *speedo_g = ((reg >> 16) & 0xFFFF) * 4; | 99 | *speedo_g = ((reg >> 16) & 0xFFFF) * 4; |
98 | 100 | ||
99 | ate_ver = tegra_fuse_readl(FUSE_TEST_PROG_VER); | 101 | ate_ver = tegra_fuse_readl(FUSE_TEST_PROG_VER); |
100 | pr_info("%s: ATE prog ver %d.%d\n", __func__, ate_ver/10, ate_ver%10); | 102 | pr_info("%s: ATE prog ver %d.%d\n", __func__, ate_ver/10, ate_ver%10); |
101 | 103 | ||
102 | if (ate_ver >= 26) { | 104 | if (ate_ver >= 26) { |
103 | bit_minus1 = tegra_spare_fuse(LP_SPEEDO_BIT_MINUS1); | 105 | bit_minus1 = tegra_spare_fuse(LP_SPEEDO_BIT_MINUS1); |
104 | bit_minus1 |= tegra_spare_fuse(LP_SPEEDO_BIT_MINUS1_R); | 106 | bit_minus1 |= tegra_spare_fuse(LP_SPEEDO_BIT_MINUS1_R); |
105 | bit_minus2 = tegra_spare_fuse(LP_SPEEDO_BIT_MINUS2); | 107 | bit_minus2 = tegra_spare_fuse(LP_SPEEDO_BIT_MINUS2); |
106 | bit_minus2 |= tegra_spare_fuse(LP_SPEEDO_BIT_MINUS2_R); | 108 | bit_minus2 |= tegra_spare_fuse(LP_SPEEDO_BIT_MINUS2_R); |
107 | *speedo_lp |= (bit_minus1 << 1) | bit_minus2; | 109 | *speedo_lp |= (bit_minus1 << 1) | bit_minus2; |
108 | 110 | ||
109 | bit_minus1 = tegra_spare_fuse(G_SPEEDO_BIT_MINUS1); | 111 | bit_minus1 = tegra_spare_fuse(G_SPEEDO_BIT_MINUS1); |
110 | bit_minus1 |= tegra_spare_fuse(G_SPEEDO_BIT_MINUS1_R); | 112 | bit_minus1 |= tegra_spare_fuse(G_SPEEDO_BIT_MINUS1_R); |
111 | bit_minus2 = tegra_spare_fuse(G_SPEEDO_BIT_MINUS2); | 113 | bit_minus2 = tegra_spare_fuse(G_SPEEDO_BIT_MINUS2); |
112 | bit_minus2 |= tegra_spare_fuse(G_SPEEDO_BIT_MINUS2_R); | 114 | bit_minus2 |= tegra_spare_fuse(G_SPEEDO_BIT_MINUS2_R); |
113 | *speedo_g |= (bit_minus1 << 1) | bit_minus2; | 115 | *speedo_g |= (bit_minus1 << 1) | bit_minus2; |
114 | } else { | 116 | } else { |
115 | *speedo_lp |= 0x3; | 117 | *speedo_lp |= 0x3; |
116 | *speedo_g |= 0x3; | 118 | *speedo_g |= 0x3; |
117 | } | 119 | } |
118 | } | 120 | } |
119 | 121 | ||
120 | static void rev_sku_to_speedo_ids(int rev, int sku) | 122 | static void rev_sku_to_speedo_ids(int rev, int sku) |
121 | { | 123 | { |
122 | switch (rev) { | 124 | switch (rev) { |
123 | case TEGRA_REVISION_A01: | 125 | case TEGRA_REVISION_A01: |
124 | tegra_cpu_speedo_id = 0; | 126 | tegra_cpu_speedo_id = 0; |
125 | tegra_soc_speedo_id = 0; | 127 | tegra_soc_speedo_id = 0; |
126 | threshold_index = THRESHOLD_INDEX_0; | 128 | threshold_index = THRESHOLD_INDEX_0; |
127 | break; | 129 | break; |
128 | case TEGRA_REVISION_A02: | 130 | case TEGRA_REVISION_A02: |
129 | case TEGRA_REVISION_A03: | 131 | case TEGRA_REVISION_A03: |
130 | switch (sku) { | 132 | switch (sku) { |
131 | case 0x87: | 133 | case 0x87: |
132 | case 0x82: | 134 | case 0x82: |
133 | tegra_cpu_speedo_id = 1; | 135 | tegra_cpu_speedo_id = 1; |
134 | tegra_soc_speedo_id = 1; | 136 | tegra_soc_speedo_id = 1; |
135 | threshold_index = THRESHOLD_INDEX_1; | 137 | threshold_index = THRESHOLD_INDEX_1; |
136 | break; | 138 | break; |
137 | case 0x81: | 139 | case 0x81: |
138 | switch (package_id) { | 140 | switch (package_id) { |
139 | case 1: | 141 | case 1: |
140 | tegra_cpu_speedo_id = 2; | 142 | tegra_cpu_speedo_id = 2; |
141 | tegra_soc_speedo_id = 2; | 143 | tegra_soc_speedo_id = 2; |
142 | threshold_index = THRESHOLD_INDEX_2; | 144 | threshold_index = THRESHOLD_INDEX_2; |
143 | break; | 145 | break; |
144 | case 2: | 146 | case 2: |
145 | tegra_cpu_speedo_id = 4; | 147 | tegra_cpu_speedo_id = 4; |
146 | tegra_soc_speedo_id = 1; | 148 | tegra_soc_speedo_id = 1; |
147 | threshold_index = THRESHOLD_INDEX_7; | 149 | threshold_index = THRESHOLD_INDEX_7; |
148 | break; | 150 | break; |
149 | default: | 151 | default: |
150 | pr_err("Tegra30: Unknown pkg %d\n", package_id); | 152 | pr_err("Tegra30: Unknown pkg %d\n", package_id); |
151 | BUG(); | 153 | BUG(); |
152 | break; | 154 | break; |
153 | } | 155 | } |
154 | break; | 156 | break; |
155 | case 0x80: | 157 | case 0x80: |
156 | switch (package_id) { | 158 | switch (package_id) { |
157 | case 1: | 159 | case 1: |
158 | tegra_cpu_speedo_id = 5; | 160 | tegra_cpu_speedo_id = 5; |
159 | tegra_soc_speedo_id = 2; | 161 | tegra_soc_speedo_id = 2; |
160 | threshold_index = THRESHOLD_INDEX_8; | 162 | threshold_index = THRESHOLD_INDEX_8; |
161 | break; | 163 | break; |
162 | case 2: | 164 | case 2: |
163 | tegra_cpu_speedo_id = 6; | 165 | tegra_cpu_speedo_id = 6; |
164 | tegra_soc_speedo_id = 2; | 166 | tegra_soc_speedo_id = 2; |
165 | threshold_index = THRESHOLD_INDEX_9; | 167 | threshold_index = THRESHOLD_INDEX_9; |
166 | break; | 168 | break; |
167 | default: | 169 | default: |
168 | pr_err("Tegra30: Unknown pkg %d\n", package_id); | 170 | pr_err("Tegra30: Unknown pkg %d\n", package_id); |
169 | BUG(); | 171 | BUG(); |
170 | break; | 172 | break; |
171 | } | 173 | } |
172 | break; | 174 | break; |
173 | case 0x83: | 175 | case 0x83: |
174 | switch (package_id) { | 176 | switch (package_id) { |
175 | case 1: | 177 | case 1: |
176 | tegra_cpu_speedo_id = 7; | 178 | tegra_cpu_speedo_id = 7; |
177 | tegra_soc_speedo_id = 1; | 179 | tegra_soc_speedo_id = 1; |
178 | threshold_index = THRESHOLD_INDEX_10; | 180 | threshold_index = THRESHOLD_INDEX_10; |
179 | break; | 181 | break; |
180 | case 2: | 182 | case 2: |
181 | tegra_cpu_speedo_id = 3; | 183 | tegra_cpu_speedo_id = 3; |
182 | tegra_soc_speedo_id = 2; | 184 | tegra_soc_speedo_id = 2; |
183 | threshold_index = THRESHOLD_INDEX_3; | 185 | threshold_index = THRESHOLD_INDEX_3; |
184 | break; | 186 | break; |
185 | default: | 187 | default: |
186 | pr_err("Tegra30: Unknown pkg %d\n", package_id); | 188 | pr_err("Tegra30: Unknown pkg %d\n", package_id); |
187 | BUG(); | 189 | BUG(); |
188 | break; | 190 | break; |
189 | } | 191 | } |
190 | break; | 192 | break; |
191 | case 0x8F: | 193 | case 0x8F: |
192 | tegra_cpu_speedo_id = 8; | 194 | tegra_cpu_speedo_id = 8; |
193 | tegra_soc_speedo_id = 1; | 195 | tegra_soc_speedo_id = 1; |
194 | threshold_index = THRESHOLD_INDEX_11; | 196 | threshold_index = THRESHOLD_INDEX_11; |
195 | break; | 197 | break; |
196 | case 0x08: | 198 | case 0x08: |
197 | tegra_cpu_speedo_id = 1; | 199 | tegra_cpu_speedo_id = 1; |
198 | tegra_soc_speedo_id = 1; | 200 | tegra_soc_speedo_id = 1; |
199 | threshold_index = THRESHOLD_INDEX_4; | 201 | threshold_index = THRESHOLD_INDEX_4; |
200 | break; | 202 | break; |
201 | case 0x02: | 203 | case 0x02: |
202 | tegra_cpu_speedo_id = 2; | 204 | tegra_cpu_speedo_id = 2; |
203 | tegra_soc_speedo_id = 2; | 205 | tegra_soc_speedo_id = 2; |
204 | threshold_index = THRESHOLD_INDEX_5; | 206 | threshold_index = THRESHOLD_INDEX_5; |
205 | break; | 207 | break; |
206 | case 0x04: | 208 | case 0x04: |
207 | tegra_cpu_speedo_id = 3; | 209 | tegra_cpu_speedo_id = 3; |
208 | tegra_soc_speedo_id = 2; | 210 | tegra_soc_speedo_id = 2; |
209 | threshold_index = THRESHOLD_INDEX_6; | 211 | threshold_index = THRESHOLD_INDEX_6; |
210 | break; | 212 | break; |
211 | case 0: | 213 | case 0: |
212 | switch (package_id) { | 214 | switch (package_id) { |
213 | case 1: | 215 | case 1: |
214 | tegra_cpu_speedo_id = 2; | 216 | tegra_cpu_speedo_id = 2; |
215 | tegra_soc_speedo_id = 2; | 217 | tegra_soc_speedo_id = 2; |
216 | threshold_index = THRESHOLD_INDEX_2; | 218 | threshold_index = THRESHOLD_INDEX_2; |
217 | break; | 219 | break; |
218 | case 2: | 220 | case 2: |
219 | tegra_cpu_speedo_id = 3; | 221 | tegra_cpu_speedo_id = 3; |
220 | tegra_soc_speedo_id = 2; | 222 | tegra_soc_speedo_id = 2; |
221 | threshold_index = THRESHOLD_INDEX_3; | 223 | threshold_index = THRESHOLD_INDEX_3; |
222 | break; | 224 | break; |
223 | default: | 225 | default: |
224 | pr_err("Tegra30: Unknown pkg %d\n", package_id); | 226 | pr_err("Tegra30: Unknown pkg %d\n", package_id); |
225 | BUG(); | 227 | BUG(); |
226 | break; | 228 | break; |
227 | } | 229 | } |
228 | break; | 230 | break; |
229 | default: | 231 | default: |
230 | pr_warn("Tegra30: Unknown SKU %d\n", sku); | 232 | pr_warn("Tegra30: Unknown SKU %d\n", sku); |
231 | tegra_cpu_speedo_id = 0; | 233 | tegra_cpu_speedo_id = 0; |
232 | tegra_soc_speedo_id = 0; | 234 | tegra_soc_speedo_id = 0; |
233 | threshold_index = THRESHOLD_INDEX_0; | 235 | threshold_index = THRESHOLD_INDEX_0; |
234 | break; | 236 | break; |
235 | } | 237 | } |
236 | break; | 238 | break; |
237 | default: | 239 | default: |
238 | pr_warn("Tegra30: Unknown chip rev %d\n", rev); | 240 | pr_warn("Tegra30: Unknown chip rev %d\n", rev); |
239 | tegra_cpu_speedo_id = 0; | 241 | tegra_cpu_speedo_id = 0; |
240 | tegra_soc_speedo_id = 0; | 242 | tegra_soc_speedo_id = 0; |
241 | threshold_index = THRESHOLD_INDEX_0; | 243 | threshold_index = THRESHOLD_INDEX_0; |
242 | break; | 244 | break; |
243 | } | 245 | } |
244 | } | 246 | } |
245 | 247 | ||
246 | void tegra30_init_speedo_data(void) | 248 | void tegra30_init_speedo_data(void) |
247 | { | 249 | { |
248 | u32 cpu_speedo_val; | 250 | u32 cpu_speedo_val; |
249 | u32 core_speedo_val; | 251 | u32 core_speedo_val; |
250 | int i; | 252 | int i; |
251 | 253 | ||
252 | BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) != | 254 | BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos) != |
253 | THRESHOLD_INDEX_COUNT); | 255 | THRESHOLD_INDEX_COUNT); |
254 | BUILD_BUG_ON(ARRAY_SIZE(core_process_speedos) != | 256 | BUILD_BUG_ON(ARRAY_SIZE(core_process_speedos) != |
255 | THRESHOLD_INDEX_COUNT); | 257 | THRESHOLD_INDEX_COUNT); |
256 | 258 | ||
257 | package_id = tegra_fuse_readl(FUSE_PACKAGE_INFO) & 0x0F; | 259 | package_id = tegra_fuse_readl(FUSE_PACKAGE_INFO) & 0x0F; |
258 | 260 | ||
259 | rev_sku_to_speedo_ids(tegra_revision, tegra_sku_id); | 261 | rev_sku_to_speedo_ids(tegra_revision, tegra_sku_id); |
260 | fuse_speedo_calib(&cpu_speedo_val, &core_speedo_val); | 262 | fuse_speedo_calib(&cpu_speedo_val, &core_speedo_val); |
261 | pr_debug("%s CPU speedo value %u\n", __func__, cpu_speedo_val); | 263 | pr_debug("%s CPU speedo value %u\n", __func__, cpu_speedo_val); |
262 | pr_debug("%s Core speedo value %u\n", __func__, core_speedo_val); | 264 | pr_debug("%s Core speedo value %u\n", __func__, core_speedo_val); |
263 | 265 | ||
264 | for (i = 0; i < CPU_PROCESS_CORNERS_NUM; i++) { | 266 | for (i = 0; i < CPU_PROCESS_CORNERS_NUM; i++) { |
265 | if (cpu_speedo_val < cpu_process_speedos[threshold_index][i]) | 267 | if (cpu_speedo_val < cpu_process_speedos[threshold_index][i]) |
266 | break; | 268 | break; |
267 | } | 269 | } |
268 | tegra_cpu_process_id = i - 1; | 270 | tegra_cpu_process_id = i - 1; |
269 | 271 | ||
270 | if (tegra_cpu_process_id == -1) { | 272 | if (tegra_cpu_process_id == -1) { |
271 | pr_warn("Tegra30: CPU speedo value %3d out of range", | 273 | pr_warn("Tegra30: CPU speedo value %3d out of range", |
272 | cpu_speedo_val); | 274 | cpu_speedo_val); |
273 | tegra_cpu_process_id = 0; | 275 | tegra_cpu_process_id = 0; |
274 | tegra_cpu_speedo_id = 1; | 276 | tegra_cpu_speedo_id = 1; |
275 | } | 277 | } |
276 | 278 | ||
277 | for (i = 0; i < CORE_PROCESS_CORNERS_NUM; i++) { | 279 | for (i = 0; i < CORE_PROCESS_CORNERS_NUM; i++) { |
278 | if (core_speedo_val < core_process_speedos[threshold_index][i]) | 280 | if (core_speedo_val < core_process_speedos[threshold_index][i]) |
279 | break; | 281 | break; |
280 | } | 282 | } |
281 | tegra_core_process_id = i - 1; | 283 | tegra_core_process_id = i - 1; |
282 | 284 | ||
283 | if (tegra_core_process_id == -1) { | 285 | if (tegra_core_process_id == -1) { |
284 | pr_warn("Tegra30: CORE speedo value %3d out of range", | 286 | pr_warn("Tegra30: CORE speedo value %3d out of range", |
285 | core_speedo_val); | 287 | core_speedo_val); |
286 | tegra_core_process_id = 0; | 288 | tegra_core_process_id = 0; |
287 | tegra_soc_speedo_id = 1; | 289 | tegra_soc_speedo_id = 1; |
288 | } | 290 | } |
289 | 291 | ||
290 | pr_info("Tegra30: CPU Speedo ID %d, Soc Speedo ID %d", | 292 | pr_info("Tegra30: CPU Speedo ID %d, Soc Speedo ID %d", |
291 | tegra_cpu_speedo_id, tegra_soc_speedo_id); | 293 | tegra_cpu_speedo_id, tegra_soc_speedo_id); |
292 | } | 294 | } |
293 | 295 |
include/soc/tegra/fuse.h
1 | /* | 1 | /* |
2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms and conditions of the GNU General Public License, | 5 | * under the terms and conditions of the GNU General Public License, |
6 | * version 2, as published by the Free Software Foundation. | 6 | * version 2, as published by the Free Software Foundation. |
7 | * | 7 | * |
8 | * This program is distributed in the hope it will be useful, but WITHOUT | 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
11 | * more details. | 11 | * more details. |
12 | * | 12 | * |
13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #ifndef __SOC_TEGRA_FUSE_H__ | 17 | #ifndef __SOC_TEGRA_FUSE_H__ |
18 | #define __SOC_TEGRA_FUSE_H__ | 18 | #define __SOC_TEGRA_FUSE_H__ |
19 | 19 | ||
20 | #define TEGRA20 0x20 | 20 | #define TEGRA20 0x20 |
21 | #define TEGRA30 0x30 | 21 | #define TEGRA30 0x30 |
22 | #define TEGRA114 0x35 | 22 | #define TEGRA114 0x35 |
23 | #define TEGRA124 0x40 | 23 | #define TEGRA124 0x40 |
24 | 24 | ||
25 | #ifndef __ASSEMBLY__ | 25 | #ifndef __ASSEMBLY__ |
26 | 26 | ||
27 | u32 tegra_read_chipid(void); | 27 | u32 tegra_read_chipid(void); |
28 | u8 tegra_get_chip_id(void); | 28 | u8 tegra_get_chip_id(void); |
29 | 29 | ||
30 | enum tegra_revision { | ||
31 | TEGRA_REVISION_UNKNOWN = 0, | ||
32 | TEGRA_REVISION_A01, | ||
33 | TEGRA_REVISION_A02, | ||
34 | TEGRA_REVISION_A03, | ||
35 | TEGRA_REVISION_A03p, | ||
36 | TEGRA_REVISION_A04, | ||
37 | TEGRA_REVISION_MAX, | ||
38 | }; | ||
39 | |||
40 | u32 tegra_read_straps(void); | ||
41 | u32 tegra_read_chipid(void); | ||
42 | void tegra_init_fuse(void); | ||
43 | |||
44 | extern enum tegra_revision tegra_revision; | ||
45 | |||
30 | #if defined(CONFIG_TEGRA20_APB_DMA) | 46 | #if defined(CONFIG_TEGRA20_APB_DMA) |
31 | int tegra_apb_readl_using_dma(unsigned long offset, u32 *value); | 47 | int tegra_apb_readl_using_dma(unsigned long offset, u32 *value); |
32 | int tegra_apb_writel_using_dma(u32 value, unsigned long offset); | 48 | int tegra_apb_writel_using_dma(u32 value, unsigned long offset); |
33 | #else | 49 | #else |
34 | static inline int tegra_apb_readl_using_dma(unsigned long offset, u32 *value) | 50 | static inline int tegra_apb_readl_using_dma(unsigned long offset, u32 *value) |
35 | { | 51 | { |
36 | return -EINVAL; | 52 | return -EINVAL; |
37 | } | 53 | } |
38 | static inline int tegra_apb_writel_using_dma(u32 value, unsigned long offset) | 54 | static inline int tegra_apb_writel_using_dma(u32 value, unsigned long offset) |
39 | { | 55 | { |
40 | return -EINVAL; | 56 | return -EINVAL; |
41 | } | 57 | } |
42 | #endif /* CONFIG_TEGRA20_APB_DMA */ | 58 | #endif /* CONFIG_TEGRA20_APB_DMA */ |
43 | 59 | ||
44 | #endif /* __ASSEMBLY__ */ | 60 | #endif /* __ASSEMBLY__ */ |
45 | 61 | ||
46 | #endif /* __SOC_TEGRA_FUSE_H__ */ | 62 | #endif /* __SOC_TEGRA_FUSE_H__ */ |
47 | 63 |