1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2013-2014, NVIDIA CORPORATION. All rights reserved.
7 #include <linux/device.h>
8 #include <linux/kernel.h>
10 #include <soc/tegra/fuse.h>
14 #define SOC_PROCESS_CORNERS 2
15 #define CPU_PROCESS_CORNERS 2
20 THRESHOLD_INDEX_COUNT
,
23 static const u32 __initconst soc_process_speedos
[][SOC_PROCESS_CORNERS
] = {
28 static const u32 __initconst cpu_process_speedos
[][CPU_PROCESS_CORNERS
] = {
33 static void __init
rev_sku_to_speedo_ids(struct tegra_sku_info
*sku_info
,
37 u32 sku
= sku_info
->sku_id
;
38 enum tegra_revision rev
= sku_info
->revision
;
45 sku_info
->cpu_speedo_id
= 1;
46 sku_info
->soc_speedo_id
= 0;
47 *threshold
= THRESHOLD_INDEX_0
;
52 sku_info
->cpu_speedo_id
= 2;
53 sku_info
->soc_speedo_id
= 1;
54 *threshold
= THRESHOLD_INDEX_1
;
58 pr_err("Tegra Unknown SKU %d\n", sku
);
59 sku_info
->cpu_speedo_id
= 0;
60 sku_info
->soc_speedo_id
= 0;
61 *threshold
= THRESHOLD_INDEX_0
;
65 if (rev
== TEGRA_REVISION_A01
) {
66 tmp
= tegra_fuse_read_early(0x270) << 1;
67 tmp
|= tegra_fuse_read_early(0x26c);
69 sku_info
->cpu_speedo_id
= 0;
73 void __init
tegra114_init_speedo_data(struct tegra_sku_info
*sku_info
)
80 BUILD_BUG_ON(ARRAY_SIZE(cpu_process_speedos
) !=
81 THRESHOLD_INDEX_COUNT
);
82 BUILD_BUG_ON(ARRAY_SIZE(soc_process_speedos
) !=
83 THRESHOLD_INDEX_COUNT
);
85 rev_sku_to_speedo_ids(sku_info
, &threshold
);
87 cpu_speedo_val
= tegra_fuse_read_early(0x12c) + 1024;
88 soc_speedo_val
= tegra_fuse_read_early(0x134);
90 for (i
= 0; i
< CPU_PROCESS_CORNERS
; i
++)
91 if (cpu_speedo_val
< cpu_process_speedos
[threshold
][i
])
93 sku_info
->cpu_process_id
= i
;
95 for (i
= 0; i
< SOC_PROCESS_CORNERS
; i
++)
96 if (soc_speedo_val
< soc_process_speedos
[threshold
][i
])
98 sku_info
->soc_process_id
= i
;