soc/tegra: More unification and cleanup for 64-bit
Subsystems (3)
cover soc/tegra: More unification and cleanup for 64-bit
From: Thierry Reding <[email protected]>
This set of patches restricts the legacy code to 32-bit ARM for the PMC and FUSE drivers and follows up by adding Tegra210 support. Note how in particular the FUSE driver required quite a few changes to unify it for all SoC families. This makes it easier to test and extend in the future as new SoC support is added.
Mark, you requested the restriction of the legacy compatibility code in an earlier version that Paul posted. Can you take a look at this series and see if it matches your expectations? I've kept soc_is_tegra() to be consistent across all generations, but legacy code paths are guarded by an IS_ENABLED(CONFIG_ARM). I think that's a good compromise between the options that had been discussed earlier, but let me know if you want to see this done differently.
Thierry
Thierry Reding (8):
soc/tegra: pmc: Restrict legacy code to 32-bit ARM soc/tegra: pmc: Add Tegra210 support soc/tegra: Add Tegra132 support
soc/tegra: Add Tegra210 support
soc/tegra: fuse: Restrict legacy code to 32-bit ARM soc/tegra: fuse: Unify Tegra20 and Tegra30 drivers soc/tegra: fuse: Add Tegra210 support soc/tegra: fuse: Rename core_* to soc_*
arch/arm/mach-tegra/iomap.h | 3 - drivers/soc/tegra/common.c | 2 + drivers/soc/tegra/fuse/Makefile | 2 + drivers/soc/tegra/fuse/fuse-tegra.c | 255 ++++++++++++++++++++++++------- drivers/soc/tegra/fuse/fuse-tegra20.c | 172 ++++++++------------- drivers/soc/tegra/fuse/fuse-tegra30.c | 221 +++++++++------------------ drivers/soc/tegra/fuse/fuse.h | 95 ++++++++---- drivers/soc/tegra/fuse/speedo-tegra114.c | 22 +-- drivers/soc/tegra/fuse/speedo-tegra124.c | 26 ++-- drivers/soc/tegra/fuse/speedo-tegra20.c | 28 ++-- drivers/soc/tegra/fuse/speedo-tegra210.c | 184 ++++++++++++++++++++++ drivers/soc/tegra/fuse/speedo-tegra30.c | 48 +++--- drivers/soc/tegra/fuse/tegra-apbmisc.c | 76 +++++++-- drivers/soc/tegra/pmc.c | 104 +++++++++++-- include/soc/tegra/fuse.h | 6 +- include/soc/tegra/pmc.h | 5 + 16 files changed, 815 insertions(+), 434 deletions(-) create mode 100644 drivers/soc/tegra/fuse/speedo-tegra210.c
Signature · 1 line
2.3.5
PATCH 1/8 soc/tegra: pmc: Restrict legacy code to 32-bit ARM
From: Thierry Reding <[email protected]>
For backwards-compatibility with old device trees, if no PMC node exists this driver hard-codes the I/O memory region. All 64-bit ARM device tree files are recent enough that they can be required to have this node, and therefore the legacy code path is not required on 64-bit ARM.
Based on work done by Paul Walmsley <[email protected]>.
--- drivers/soc/tegra/pmc.c | 56 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 15 deletions(-)
drivers/soc/tegra/pmc.c +41 -15
@@ -17,6 +17,8 @@* */ +#define pr_fmt (fmt) "tegra-pmc: " fmt +#include <linux/kernel.h> #include <linux/clk.h> #include <linux/clk/tegra.h>
@@ -992,6 +994,7 @@ static const struct tegra_pmc_soc tegra124_pmc_soc = { };static const struct of_device_id tegra_pmc_match[] = { + { .compatible ="nvidia,tegra132-pmc" , .data = &tegra124_pmc_soc }, { .compatible ="nvidia,tegra124-pmc" , .data = &tegra124_pmc_soc }, { .compatible ="nvidia,tegra114-pmc" , .data = &tegra114_pmc_soc }, { .compatible ="nvidia,tegra30-pmc" , .data = &tegra30_pmc_soc },
@@ -1024,25 +1027,44 @@ static int __init tegra_pmc_early_init(void)bool invert;u32 value; -if (!soc_is_tegra ()) -return 0 ; - np =of_find_matching_node_and_match (NULL , tegra_pmc_match, &match);if (!np) { -pr_warn ("PMC device node not found, disabling powergating\n" ); - - regs.start =0x7000e400 ; - regs.end =0x7000e7ff ; - regs.flags =IORESOURCE_MEM ; - -pr_warn ("Using memory region %pR\n" , ®s); +/* +* Fall back to legacy initialization for 32-bit ARM only. All +* 64-bit ARM device tree files for Tegra are required to have +* a PMC node. +* +* This is for backwards-compatibility with old device trees +* that didn't contain a PMC node. Note that in this case the +* SoC data can't be matched and therefore powergating is +* disabled. +*/ +if (IS_ENABLED (CONFIG_ARM ) &&soc_is_tegra ()) { +pr_warn ("DT node not found, powergating disabled\n" ); + + regs.start =0x7000e400 ; + regs.end =0x7000e7ff ; + regs.flags =IORESOURCE_MEM ; + +pr_warn ("Using memory region %pR\n" , ®s); + }else { +/* +* At this point we're not running on Tegra, so play +* nice with multi-platform kernels. +*/ +return 0 ; + } }else { - pmc->soc = match->data; - } +/* +* Extract information from the device tree if we've found a +* matching node. +*/ +if (of_address_to_resource (np,0 , ®s) <0 ) { +pr_err ("failed to get PMC registers\n" ); +return -ENXIO ; + } -if (of_address_to_resource (np,0 , ®s) <0 ) { -pr_err ("failed to get PMC registers\n" ); -return -ENXIO ; + pmc->soc = match->data; } pmc->base =ioremap_nocache (regs.start,resource_size (®s));
@@ -1053,6 +1075,10 @@ static int __init tegra_pmc_early_init(void)mutex_init (&pmc->powergates_lock); +/* +* Invert the interrupt polarity if a PMC device tree node exists and +* contains the nvidia,invert-interrupt property. +*/ invert =of_property_read_bool (np,"nvidia,invert-interrupt" ); value =tegra_pmc_readl (PMC_CNTRL );
Signature · 1 line
2.3.5
PATCH 2/8 soc/tegra: pmc: Add Tegra210 support
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Tegra210 uses a power management controller that is compatible with earlier SoC generations but adds a couple of power partitions for new hardware blocks.
--- drivers/soc/tegra/pmc.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ include/soc/tegra/pmc.h | 5 +++++ 2 files changed, 53 insertions(+)
drivers/soc/tegra/pmc.c +48 -0
@@ -993,7 +993,55 @@ static const struct tegra_pmc_soc tegra124_pmc_soc = { .has_gpu_clamps = true, }; +static const char *const tegra210_powergates[] = { + [TEGRA_POWERGATE_CPU ] ="crail" , + [TEGRA_POWERGATE_3D ] ="3d" , + [TEGRA_POWERGATE_VENC ] ="venc" , + [TEGRA_POWERGATE_PCIE ] ="pcie" , + [TEGRA_POWERGATE_L2 ] ="l2" , + [TEGRA_POWERGATE_MPE ] ="mpe" , + [TEGRA_POWERGATE_HEG ] ="heg" , + [TEGRA_POWERGATE_SATA ] ="sata" , + [TEGRA_POWERGATE_CPU1 ] ="cpu1" , + [TEGRA_POWERGATE_CPU2 ] ="cpu2" , + [TEGRA_POWERGATE_CPU3 ] ="cpu3" , + [TEGRA_POWERGATE_CELP ] ="celp" , + [TEGRA_POWERGATE_CPU0 ] ="cpu0" , + [TEGRA_POWERGATE_C0NC ] ="c0nc" , + [TEGRA_POWERGATE_C1NC ] ="c1nc" , + [TEGRA_POWERGATE_SOR ] ="sor" , + [TEGRA_POWERGATE_DIS ] ="dis" , + [TEGRA_POWERGATE_DISB ] ="disb" , + [TEGRA_POWERGATE_XUSBA ] ="xusba" , + [TEGRA_POWERGATE_XUSBB ] ="xusbb" , + [TEGRA_POWERGATE_XUSBC ] ="xusbc" , + [TEGRA_POWERGATE_VIC ] ="vic" , + [TEGRA_POWERGATE_IRAM ] ="iram" , + [TEGRA_POWERGATE_NVDEC ] ="nvdec" , + [TEGRA_POWERGATE_NVJPG ] ="nvjpg" , + [TEGRA_POWERGATE_AUD ] ="aud" , + [TEGRA_POWERGATE_DFD ] ="dfd" , + [TEGRA_POWERGATE_VE2 ] ="ve2" , +}; + +static const u8 tegra210_cpu_powergates[] = { +TEGRA_POWERGATE_CPU0 , +TEGRA_POWERGATE_CPU1 , +TEGRA_POWERGATE_CPU2 , +TEGRA_POWERGATE_CPU3 , +}; + +static const struct tegra_pmc_soc tegra210_pmc_soc = { + .num_powergates =ARRAY_SIZE (tegra210_powergates), + .powergates = tegra210_powergates, + .num_cpu_powergates =ARRAY_SIZE (tegra210_cpu_powergates), + .cpu_powergates = tegra210_cpu_powergates, + .has_tsense_reset = true, + .has_gpu_clamps = true, +}; +static const struct of_device_id tegra_pmc_match[] = { + { .compatible ="nvidia,tegra210-pmc" , .data = &tegra210_pmc_soc }, { .compatible ="nvidia,tegra132-pmc" , .data = &tegra124_pmc_soc }, { .compatible ="nvidia,tegra124-pmc" , .data = &tegra124_pmc_soc }, { .compatible ="nvidia,tegra114-pmc" , .data = &tegra114_pmc_soc },
include/soc/tegra/pmc.h +5 -0
@@ -69,6 +69,11 @@ int tegra_pmc_cpu_remove_clamping(int cpuid);#define TEGRA_POWERGATE_XUSBC 22#define TEGRA_POWERGATE_VIC 23#define TEGRA_POWERGATE_IRAM 24 +#define TEGRA_POWERGATE_NVDEC 25 +#define TEGRA_POWERGATE_NVJPG 26 +#define TEGRA_POWERGATE_AUD 27 +#define TEGRA_POWERGATE_DFD 28 +#define TEGRA_POWERGATE_VE2 29#define TEGRA_POWERGATE_3D0 TEGRA_POWERGATE_3D
Signature · 1 line
2.3.5
PATCH 3/8 soc/tegra: Add Tegra132 support
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Add Tegra132 to the matching table for NVIDIA Tegra SoCs.
--- drivers/soc/tegra/common.c | 1 + 1 file changed, 1 insertion(+)
drivers/soc/tegra/common.c +1 -0
@@ -15,6 +15,7 @@ static const struct of_device_id tegra_machine_match[] = { { .compatible = "nvidia,tegra30", }, { .compatible = "nvidia,tegra114", }, { .compatible = "nvidia,tegra124", }, + { .compatible = "nvidia,tegra132", }, { } };
Signature · 1 line
2.3.5
PATCH 4/8 soc/tegra: Add Tegra210 support
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Add Tegra210 to the matching table for NVIDIA Tegra SoCs.
--- drivers/soc/tegra/common.c | 1 + 1 file changed, 1 insertion(+)
drivers/soc/tegra/common.c +1 -0
@@ -16,6 +16,7 @@ static const struct of_device_id tegra_machine_match[] = { { .compatible = "nvidia,tegra114", }, { .compatible = "nvidia,tegra124", }, { .compatible = "nvidia,tegra132", }, + { .compatible = "nvidia,tegra210", }, { } };
Signature · 1 line
2.3.5
PATCH 5/8 soc/tegra: fuse: Restrict legacy code to 32-bit ARM
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
For backwards-compatibility with old device trees, if no APBMISC node exists this driver hard-codes the I/O memory region. All 64-bit ARM device tree files are recent enough that they can be required to have this node, and therefore the legacy code path is not required.
Based on work done by Paul Walmsley <[email protected]>.
--- drivers/soc/tegra/fuse/tegra-apbmisc.c | 67 +++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 9 deletions(-)
drivers/soc/tegra/fuse/tegra-apbmisc.c +58 -9
@@ -21,11 +21,10 @@#include <linux/io.h> #include <soc/tegra/fuse.h> +#include <soc/tegra/common.h> #include "fuse.h" -#define APBMISC_BASE 0x70000800 -#define APBMISC_SIZE 0x64#define FUSE_SKU_INFO 0x10static void __iomem *apbmisc_base;
@@ -99,17 +98,67 @@ void __init tegra_init_revision(void)void __init tegra_init_apbmisc (void ) { +struct resource apbmisc, straps;struct device_node *np; np =of_find_matching_node (NULL , apbmisc_match); - apbmisc_base =of_iomap (np,0 ); -if (!apbmisc_base) { -pr_warn ("ioremap tegra apbmisc failed. using %08x instead\n" , -APBMISC_BASE ); - apbmisc_base =ioremap (APBMISC_BASE ,APBMISC_SIZE ); +if (!np) { +/* +* Fall back to legacy initialization for 32-bit ARM only. All +* 64-bit ARM device tree files for Tegra are required to have +* an APBMISC node. +* +* This is for backwards-compatibility with old device trees +* that didn't contain an APBMISC node. +*/ +if (IS_ENABLED (CONFIG_ARM ) &&soc_is_tegra ()) { +/* APBMISC registers (chip revision, ...) */ + apbmisc.start =0x70000800 ; + apbmisc.end =0x70000863 ; + apbmisc.flags =IORESOURCE_MEM ; + +/* strapping options */ +if (tegra_get_chip_id () ==TEGRA124 ) { + straps.start =0x7000e864 ; + straps.end =0x7000e867 ; + }else { + straps.start =0x70000008 ; + straps.end =0x7000000b ; + } + + straps.flags =IORESOURCE_MEM ; + +pr_warn ("Using APBMISC region %pR\n" , &apbmisc); +pr_warn ("Using strapping options registers %pR\n" , + &straps); + }else { +/* +* At this point we're not running on Tegra, so play +* nice with multi-platform kernels. +*/ +return ; + } + }else { +/* +* Extract information from the device tree if we've found a +* matching node. +*/ +if (of_address_to_resource (np,0 , &apbmisc) <0 ) { +pr_err ("failed to get APBMISC registers\n" ); +return ; + } + +if (of_address_to_resource (np,1 , &straps) <0 ) { +pr_err ("failed to get strapping options registers\n" ); +return ; + } } - strapping_base =of_iomap (np,1 ); + apbmisc_base =ioremap_nocache (apbmisc.start,resource_size (&apbmisc)); +if (!apbmisc_base) +pr_err ("failed to map APBMISC registers\n" ); + + strapping_base =ioremap_nocache (straps.start,resource_size (&straps));if (!strapping_base) -pr_err ("ioremap tegra strapping_base failed\n" ); +pr_err ("failed to map strapping options registers\n" ); }
Signature · 1 line
2.3.5
PATCH 6/8 soc/tegra: fuse: Unify Tegra20 and Tegra30 drivers
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Unifying the drivers makes it easier to restrict the legacy probing paths to 32-bit ARM. This in turn will come in handy as support for new 64-bit ARM SoCs is added.
--- arch/arm/mach-tegra/iomap.h | 3 - drivers/soc/tegra/fuse/Makefile | 1 + drivers/soc/tegra/fuse/fuse-tegra.c | 243 +++++++++++++++++++++++++------ drivers/soc/tegra/fuse/fuse-tegra20.c | 170 ++++++++------------- drivers/soc/tegra/fuse/fuse-tegra30.c | 205 ++++++++------------------ drivers/soc/tegra/fuse/fuse.h | 87 +++++++---- drivers/soc/tegra/fuse/speedo-tegra114.c | 8 +- drivers/soc/tegra/fuse/speedo-tegra124.c | 14 +- drivers/soc/tegra/fuse/speedo-tegra20.c | 8 +- drivers/soc/tegra/fuse/speedo-tegra30.c | 22 +-- drivers/soc/tegra/fuse/tegra-apbmisc.c | 9 +- 11 files changed, 404 insertions(+), 366 deletions(-)
arch/arm/mach-tegra/iomap.h +0 -3
@@ -82,9 +82,6 @@#define TEGRA_EMC_BASE 0x7000F400#define TEGRA_EMC_SIZE SZ_1K -#define TEGRA_FUSE_BASE 0x7000F800 -#define TEGRA_FUSE_SIZE SZ_1K -#define TEGRA_EMC0_BASE 0x7001A000#define TEGRA_EMC0_SIZE SZ_2K
drivers/soc/tegra/fuse/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += speedo-tegra20.o obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += speedo-tegra30.o obj-$(CONFIG_ARCH_TEGRA_114_SOC) += speedo-tegra114.o obj-$(CONFIG_ARCH_TEGRA_124_SOC) += speedo-tegra124.o +obj-$(CONFIG_ARCH_TEGRA_132_SOC) += speedo-tegra124.o
drivers/soc/tegra/fuse/fuse-tegra.c +195 -48
318 lines not on this page · raw message
drivers/soc/tegra/fuse/fuse-tegra20.c +61 -109
237 lines not on this page · raw message
drivers/soc/tegra/fuse/fuse-tegra30.c +60 -145
236 lines not on this page · raw message
drivers/soc/tegra/fuse/fuse.h +58 -29
111 lines not on this page · raw message
drivers/soc/tegra/fuse/speedo-tegra114.c +4 -4
@@ -74,8 +74,8 @@ static void __init rev_sku_to_speedo_ids(struct tegra_sku_info *sku_info, }if (rev ==TEGRA_REVISION_A01 ) { - tmp =tegra30_fuse_readl (0x270 ) <<1 ; - tmp |=tegra30_fuse_readl (0x26c ); + tmp =tegra_fuse_read_early (0x270 ) <<1 ; + tmp |=tegra_fuse_read_early (0x26c );if (!tmp) sku_info->cpu_speedo_id =0 ; }
@@ -95,8 +95,8 @@ void __init tegra114_init_speedo_data(struct tegra_sku_info *sku_info)rev_sku_to_speedo_ids (sku_info, &threshold); - cpu_speedo_val =tegra30_fuse_readl (0x12c ) +1024 ; - core_speedo_val =tegra30_fuse_readl (0x134 ); + cpu_speedo_val =tegra_fuse_read_early (0x12c ) +1024 ; + core_speedo_val =tegra_fuse_read_early (0x134 );for (i =0 ; i <CPU_PROCESS_CORNERS ; i++)if (cpu_speedo_val < cpu_process_speedos[threshold][i])
drivers/soc/tegra/fuse/speedo-tegra124.c +7 -7
@@ -122,16 +122,16 @@ void __init tegra124_init_speedo_data(struct tegra_sku_info *sku_info)BUILD_BUG_ON (ARRAY_SIZE (core_process_speedos) !=THRESHOLD_INDEX_COUNT ); - cpu_speedo_0_value =tegra30_fuse_readl (FUSE_CPU_SPEEDO_0 ); + cpu_speedo_0_value =tegra_fuse_read_early (FUSE_CPU_SPEEDO_0 );/* GPU Speedo is stored in CPU_SPEEDO_2 */ - sku_info->gpu_speedo_value =tegra30_fuse_readl (FUSE_CPU_SPEEDO_2 ); + sku_info->gpu_speedo_value =tegra_fuse_read_early (FUSE_CPU_SPEEDO_2 ); - soc_speedo_0_value =tegra30_fuse_readl (FUSE_SOC_SPEEDO_0 ); + soc_speedo_0_value =tegra_fuse_read_early (FUSE_SOC_SPEEDO_0 ); - cpu_iddq_value =tegra30_fuse_readl (FUSE_CPU_IDDQ ); - soc_iddq_value =tegra30_fuse_readl (FUSE_SOC_IDDQ ); - gpu_iddq_value =tegra30_fuse_readl (FUSE_GPU_IDDQ ); + cpu_iddq_value =tegra_fuse_read_early (FUSE_CPU_IDDQ ); + soc_iddq_value =tegra_fuse_read_early (FUSE_SOC_IDDQ ); + gpu_iddq_value =tegra_fuse_read_early (FUSE_GPU_IDDQ ); sku_info->cpu_speedo_value = cpu_speedo_0_value;
@@ -143,7 +143,7 @@ void __init tegra124_init_speedo_data(struct tegra_sku_info *sku_info)rev_sku_to_speedo_ids (sku_info, &threshold); - sku_info->cpu_iddq_value =tegra30_fuse_readl (FUSE_CPU_IDDQ ); + sku_info->cpu_iddq_value =tegra_fuse_read_early (FUSE_CPU_IDDQ );for (i =0 ; i <GPU_PROCESS_CORNERS ; i++) if (sku_info->gpu_speedo_value <
drivers/soc/tegra/fuse/speedo-tegra20.c +4 -4
@@ -80,8 +80,8 @@ void __init tegra20_init_speedo_data(struct tegra_sku_info *sku_info) val =0 ;for (i =CPU_SPEEDO_MSBIT ; i >=CPU_SPEEDO_LSBIT ; i--) { - reg =tegra20_spare_fuse_early (i) | -tegra20_spare_fuse_early (i +CPU_SPEEDO_REDUND_OFFS ); + reg =tegra_fuse_read_spare (i) | +tegra_fuse_read_spare (i +CPU_SPEEDO_REDUND_OFFS ); val = (val <<1 ) | (reg &0x1 ); } val = val *SPEEDO_MULT ;
@@ -95,8 +95,8 @@ void __init tegra20_init_speedo_data(struct tegra_sku_info *sku_info) val =0 ;for (i =CORE_SPEEDO_MSBIT ; i >=CORE_SPEEDO_LSBIT ; i--) { - reg =tegra20_spare_fuse_early (i) | -tegra20_spare_fuse_early (i +CORE_SPEEDO_REDUND_OFFS ); + reg =tegra_fuse_read_spare (i) | +tegra_fuse_read_spare (i +CORE_SPEEDO_REDUND_OFFS ); val = (val <<1 ) | (reg &0x1 ); } val = val *SPEEDO_MULT ;
drivers/soc/tegra/fuse/speedo-tegra30.c +11 -11
@@ -93,25 +93,25 @@ static void __init fuse_speedo_calib(u32 *speedo_g, u32 *speedo_lp)int bit_minus1;int bit_minus2; - reg =tegra30_fuse_readl (FUSE_SPEEDO_CALIB_0 ); + reg =tegra_fuse_read_early (FUSE_SPEEDO_CALIB_0 ); *speedo_lp = (reg &0xFFFF ) *4 ; *speedo_g = ((reg >>16 ) &0xFFFF ) *4 ; - ate_ver =tegra30_fuse_readl (FUSE_TEST_PROG_VER ); + ate_ver =tegra_fuse_read_early (FUSE_TEST_PROG_VER );pr_debug ("Tegra ATE prog ver %d.%d\n" , ate_ver/10 , ate_ver%10 );if (ate_ver >=26 ) { - bit_minus1 =tegra30_spare_fuse (LP_SPEEDO_BIT_MINUS1 ); - bit_minus1 |=tegra30_spare_fuse (LP_SPEEDO_BIT_MINUS1_R ); - bit_minus2 =tegra30_spare_fuse (LP_SPEEDO_BIT_MINUS2 ); - bit_minus2 |=tegra30_spare_fuse (LP_SPEEDO_BIT_MINUS2_R ); + bit_minus1 =tegra_fuse_read_spare (LP_SPEEDO_BIT_MINUS1 ); + bit_minus1 |=tegra_fuse_read_spare (LP_SPEEDO_BIT_MINUS1_R ); + bit_minus2 =tegra_fuse_read_spare (LP_SPEEDO_BIT_MINUS2 ); + bit_minus2 |=tegra_fuse_read_spare (LP_SPEEDO_BIT_MINUS2_R ); *speedo_lp |= (bit_minus1 <<1 ) | bit_minus2; - bit_minus1 =tegra30_spare_fuse (G_SPEEDO_BIT_MINUS1 ); - bit_minus1 |=tegra30_spare_fuse (G_SPEEDO_BIT_MINUS1_R ); - bit_minus2 =tegra30_spare_fuse (G_SPEEDO_BIT_MINUS2 ); - bit_minus2 |=tegra30_spare_fuse (G_SPEEDO_BIT_MINUS2_R ); + bit_minus1 =tegra_fuse_read_spare (G_SPEEDO_BIT_MINUS1 ); + bit_minus1 |=tegra_fuse_read_spare (G_SPEEDO_BIT_MINUS1_R ); + bit_minus2 =tegra_fuse_read_spare (G_SPEEDO_BIT_MINUS2 ); + bit_minus2 |=tegra_fuse_read_spare (G_SPEEDO_BIT_MINUS2_R ); *speedo_g |= (bit_minus1 <<1 ) | bit_minus2; }else { *speedo_lp |=0x3 ;
@@ -121,7 +121,7 @@ static void __init fuse_speedo_calib(u32 *speedo_g, u32 *speedo_lp)static void __init rev_sku_to_speedo_ids (struct tegra_sku_info *sku_info) { -int package_id =tegra30_fuse_readl (FUSE_PACKAGE_INFO ) &0x0F ; +int package_id =tegra_fuse_read_early (FUSE_PACKAGE_INFO ) &0x0F ;switch (sku_info->revision) {case TEGRA_REVISION_A01 :
drivers/soc/tegra/fuse/tegra-apbmisc.c +3 -6
@@ -75,8 +75,8 @@ void __init tegra_init_revision(void) rev =TEGRA_REVISION_A02 ;break ;case 3 : -if (chip_id ==TEGRA20 && (tegra20_spare_fuse_early (18 ) || -tegra20_spare_fuse_early (19 ))) +if (chip_id ==TEGRA20 && (tegra_fuse_read_spare (18 ) || +tegra_fuse_read_spare (19 ))) rev = TEGRA_REVISION_A03p;else rev =TEGRA_REVISION_A03 ;
@@ -90,10 +90,7 @@ void __init tegra_init_revision(void) tegra_sku_info.revision = rev; -if (chip_id ==TEGRA20 ) - tegra_sku_info.sku_id =tegra20_fuse_early (FUSE_SKU_INFO ); -else - tegra_sku_info.sku_id =tegra30_fuse_readl (FUSE_SKU_INFO ); + tegra_sku_info.sku_id =tegra_fuse_read_early (FUSE_SKU_INFO ); }void __init tegra_init_apbmisc (void )
Signature · 1 line
2.3.5
PATCH 7/8 soc/tegra: fuse: Add Tegra210 support
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Add Tegra210 support to the fuses driver and add Tegra210-specific speedo definitions.
--- drivers/soc/tegra/fuse/Makefile | 1 + drivers/soc/tegra/fuse/fuse-tegra.c | 4 + drivers/soc/tegra/fuse/fuse-tegra30.c | 16 ++- drivers/soc/tegra/fuse/fuse.h | 8 ++ drivers/soc/tegra/fuse/speedo-tegra210.c | 184 +++++++++++++++++++++++++++++++ include/soc/tegra/fuse.h | 4 +- 6 files changed, 215 insertions(+), 2 deletions(-) create mode 100644 drivers/soc/tegra/fuse/speedo-tegra210.c
drivers/soc/tegra/fuse/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += speedo-tegra30.o obj-$(CONFIG_ARCH_TEGRA_114_SOC) += speedo-tegra114.o obj-$(CONFIG_ARCH_TEGRA_124_SOC) += speedo-tegra124.o obj-$(CONFIG_ARCH_TEGRA_132_SOC) += speedo-tegra124.o +obj-$(CONFIG_ARCH_TEGRA_210_SOC) += speedo-tegra210.o
drivers/soc/tegra/fuse/fuse-tegra.c +4 -0
@@ -91,6 +91,7 @@ static const struct of_device_id car_match[] __initconst = { { .compatible = "nvidia,tegra114-car", }, { .compatible = "nvidia,tegra124-car", }, { .compatible = "nvidia,tegra132-car", }, + { .compatible = "nvidia,tegra210-car", }, {}, };
@@ -100,6 +101,9 @@ static struct tegra_fuse *fuse = &(struct tegra_fuse) { };static const struct of_device_id tegra_fuse_match[] = { +#ifdef CONFIG_ARCH_TEGRA_210_SOC + { .compatible ="nvidia,tegra210-efuse" , .data = &tegra210_fuse_soc }, +#endif #ifdef CONFIG_ARCH_TEGRA_132_SOC { .compatible ="nvidia,tegra132-efuse" , .data = &tegra124_fuse_soc }, #endif
drivers/soc/tegra/fuse/fuse-tegra30.c +15 -1
@@ -45,7 +45,8 @@#if defined(CONFIG_ARCH_TEGRA_3x_SOC) || \ defined(CONFIG_ARCH_TEGRA_114_SOC ) || \ defined(CONFIG_ARCH_TEGRA_124_SOC ) || \ - defined(CONFIG_ARCH_TEGRA_132_SOC ) + defined(CONFIG_ARCH_TEGRA_132_SOC ) || \ + defined(CONFIG_ARCH_TEGRA_210_SOC )static u32 tegra30_fuse_read (struct tegra_fuse *fuse,unsigned int offset) {u32 val;
@@ -137,3 +138,16 @@ const struct tegra_fuse_soc tegra124_fuse_soc = { .info = &tegra124_fuse_info, };#endif + +#if defined(CONFIG_ARCH_TEGRA_210_SOC ) +static const struct tegra_fuse_info tegra210_fuse_info = { + .read = tegra30_fuse_read, + .size =0x300 , +}; + +const struct tegra_fuse_soc tegra210_fuse_soc = { + .init = tegra30_fuse_init, + .speedo_init = tegra210_init_speedo_data, + .info = &tegra210_fuse_info, +}; +#endif
drivers/soc/tegra/fuse/fuse.h +8 -0
@@ -81,6 +81,10 @@ void tegra114_init_speedo_data(struct tegra_sku_info *sku_info);void tegra124_init_speedo_data (struct tegra_sku_info *sku_info);#endif +#ifdef CONFIG_ARCH_TEGRA_210_SOC +void tegra210_init_speedo_data (struct tegra_sku_info *sku_info); +#endif +#ifdef CONFIG_ARCH_TEGRA_2x_SOCextern const struct tegra_fuse_soc tegra20_fuse_soc;#endif
@@ -97,4 +101,8 @@ extern const struct tegra_fuse_soc tegra114_fuse_soc;extern const struct tegra_fuse_soc tegra124_fuse_soc;#endif +#ifdef CONFIG_ARCH_TEGRA_210_SOC +extern const struct tegra_fuse_soc tegra210_fuse_soc; +#endif +#endif
drivers/soc/tegra/fuse/speedo-tegra210.c new file +184 -0
184 lines not on this page · raw message
include/soc/tegra/fuse.h +3 -1
@@ -22,6 +22,7 @@#define TEGRA114 0x35#define TEGRA124 0x40#define TEGRA132 0x13 +#define TEGRA210 0x21#define TEGRA_FUSE_SKU_CALIB_0 0xf0#define TEGRA30_FUSE_SATA_CALIB 0x124
@@ -49,8 +50,9 @@ struct tegra_sku_info {int cpu_iddq_value;int core_process_id;int soc_speedo_id; -int gpu_speedo_id; +int soc_speedo_value;int gpu_process_id; +int gpu_speedo_id;int gpu_speedo_value;enum tegra_revision revision; };
Signature · 1 line
2.3.5
PATCH 8/8 soc/tegra: fuse: Rename core_* to soc_*
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
There's a mixture of core_* and soc_* prefixes for variables storing information related to the VDD_CORE rail. Choose one (soc_*) and use it more consistently.
--- drivers/soc/tegra/fuse/fuse-tegra.c | 8 ++++---- drivers/soc/tegra/fuse/fuse-tegra20.c | 2 +- drivers/soc/tegra/fuse/fuse-tegra30.c | 2 +- drivers/soc/tegra/fuse/speedo-tegra114.c | 16 ++++++++-------- drivers/soc/tegra/fuse/speedo-tegra124.c | 12 ++++++------ drivers/soc/tegra/fuse/speedo-tegra20.c | 22 +++++++++++----------- drivers/soc/tegra/fuse/speedo-tegra30.c | 26 +++++++++++++------------- include/soc/tegra/fuse.h | 2 +- 8 files changed, 45 insertions(+), 45 deletions(-)
drivers/soc/tegra/fuse/fuse-tegra.c +4 -4
@@ -304,12 +304,12 @@ static int __init tegra_init_fuse(void) fuse->soc->init (fuse); -pr_info ("Tegra Revision: %s SKU: %d CPU Process: %d Core Process: %d\n" , +pr_info ("Tegra Revision: %s SKU: %d CPU Process: %d SoC Process: %d\n" , tegra_revision_name[tegra_sku_info.revision], tegra_sku_info.sku_id, tegra_sku_info.cpu_process_id, - tegra_sku_info.core_process_id); -pr_debug ("Tegra CPU Speedo ID %d, Soc Speedo ID %d\n" , - tegra_sku_info.cpu_speedo_id, tegra_sku_info.soc_speedo_id); + tegra_sku_info.soc_process_id); +pr_debug ("Tegra CPU Speedo ID %d, SoC Speedo ID %d\n" , + tegra_sku_info.cpu_speedo_id, tegra_sku_info.soc_speedo_id);return 0 ; }
drivers/soc/tegra/fuse/fuse-tegra20.c +1 -1
@@ -140,7 +140,7 @@ static void __init tegra20_fuse_add_randomness(void) randomness[1 ] =tegra_read_straps (); randomness[2 ] =tegra_read_chipid (); randomness[3 ] = tegra_sku_info.cpu_process_id <<16 ; - randomness[3 ] |= tegra_sku_info.core_process_id; + randomness[3 ] |= tegra_sku_info.soc_process_id; randomness[4 ] = tegra_sku_info.cpu_speedo_id <<16 ; randomness[4 ] |= tegra_sku_info.soc_speedo_id; randomness[5 ] =tegra_fuse_read_early (FUSE_UID_LOW );
drivers/soc/tegra/fuse/fuse-tegra30.c +1 -1
@@ -75,7 +75,7 @@ static void __init tegra30_fuse_add_randomness(void) randomness[1 ] =tegra_read_straps (); randomness[2 ] =tegra_read_chipid (); randomness[3 ] = tegra_sku_info.cpu_process_id <<16 ; - randomness[3 ] |= tegra_sku_info.core_process_id; + randomness[3 ] |= tegra_sku_info.soc_process_id; randomness[4 ] = tegra_sku_info.cpu_speedo_id <<16 ; randomness[4 ] |= tegra_sku_info.soc_speedo_id; randomness[5 ] =tegra_fuse_read_early (FUSE_VENDOR_CODE );
drivers/soc/tegra/fuse/speedo-tegra114.c +8 -8
@@ -22,7 +22,7 @@#include "fuse.h" -#define CORE_PROCESS_CORNERS 2 +#define SOC_PROCESS_CORNERS 2#define CPU_PROCESS_CORNERS 2enum {
@@ -31,7 +31,7 @@ enum { THRESHOLD_INDEX_COUNT, }; -static const u32 __initconst core_process_speedos[][CORE_PROCESS_CORNERS ] = { +static const u32 __initconst soc_process_speedos[][SOC_PROCESS_CORNERS ] = { {1123 ,UINT_MAX }, {0 ,UINT_MAX }, };
@@ -84,27 +84,27 @@ static void __init rev_sku_to_speedo_ids(struct tegra_sku_info *sku_info,void __init tegra114_init_speedo_data (struct tegra_sku_info *sku_info) {u32 cpu_speedo_val; -u32 core_speedo_val; +u32 soc_speedo_val;int threshold;int i;BUILD_BUG_ON (ARRAY_SIZE (cpu_process_speedos) !=THRESHOLD_INDEX_COUNT ); -BUILD_BUG_ON (ARRAY_SIZE (core_process_speedos) != +BUILD_BUG_ON (ARRAY_SIZE (soc_process_speedos) !=THRESHOLD_INDEX_COUNT );rev_sku_to_speedo_ids (sku_info, &threshold); cpu_speedo_val =tegra_fuse_read_early (0x12c ) +1024 ; - core_speedo_val =tegra_fuse_read_early (0x134 ); + soc_speedo_val =tegra_fuse_read_early (0x134 );for (i =0 ; i <CPU_PROCESS_CORNERS ; i++)if (cpu_speedo_val < cpu_process_speedos[threshold][i])break ; sku_info->cpu_process_id = i; -for (i =0 ; i <CORE_PROCESS_CORNERS ; i++) -if (core_speedo_val < core_process_speedos[threshold][i]) +for (i =0 ; i <SOC_PROCESS_CORNERS ; i++) +if (soc_speedo_val < soc_process_speedos[threshold][i])break ; - sku_info->core_process_id = i; + sku_info->soc_process_id = i; }
drivers/soc/tegra/fuse/speedo-tegra124.c +6 -6
@@ -24,7 +24,7 @@#define CPU_PROCESS_CORNERS 2#define GPU_PROCESS_CORNERS 2 -#define CORE_PROCESS_CORNERS 2 +#define SOC_PROCESS_CORNERS 2#define FUSE_CPU_SPEEDO_0 0x14#define FUSE_CPU_SPEEDO_1 0x2c
@@ -53,7 +53,7 @@ static const u32 __initconst gpu_process_speedos[][GPU_PROCESS_CORNERS] = { {0, UINT_MAX}, }; -static const u32 __initconst core_process_speedos[][CORE_PROCESS_CORNERS ] = { +static const u32 __initconst soc_process_speedos[][SOC_PROCESS_CORNERS ] = { {2101 ,UINT_MAX }, {0 ,UINT_MAX }, };
@@ -119,7 +119,7 @@ void __init tegra124_init_speedo_data(struct tegra_sku_info *sku_info) THRESHOLD_INDEX_COUNT);BUILD_BUG_ON (ARRAY_SIZE (gpu_process_speedos) !=THRESHOLD_INDEX_COUNT ); -BUILD_BUG_ON (ARRAY_SIZE (core_process_speedos) != +BUILD_BUG_ON (ARRAY_SIZE (soc_process_speedos) !=THRESHOLD_INDEX_COUNT ); cpu_speedo_0_value =tegra_fuse_read_early (FUSE_CPU_SPEEDO_0 );
@@ -157,11 +157,11 @@ void __init tegra124_init_speedo_data(struct tegra_sku_info *sku_info)break ; sku_info->cpu_process_id = i; -for (i =0 ; i <CORE_PROCESS_CORNERS ; i++) +for (i =0 ; i <SOC_PROCESS_CORNERS ; i++)if (soc_speedo_0_value < - core_process_speedos[threshold][i]) + soc_process_speedos[threshold][i])break ; - sku_info->core_process_id = i; + sku_info->soc_process_id = i;pr_debug ("Tegra GPU Speedo ID=%d, Speedo Value=%d\n" , sku_info->gpu_speedo_id, sku_info->gpu_speedo_value);
drivers/soc/tegra/fuse/speedo-tegra20.c +11 -11
@@ -28,11 +28,11 @@#define CPU_SPEEDO_REDUND_MSBIT 39#define CPU_SPEEDO_REDUND_OFFS (CPU_SPEEDO_REDUND_MSBIT - CPU_SPEEDO_MSBIT) -#define CORE_SPEEDO_LSBIT 40 -#define CORE_SPEEDO_MSBIT 47 -#define CORE_SPEEDO_REDUND_LSBIT 48 -#define CORE_SPEEDO_REDUND_MSBIT 55 -#define CORE_SPEEDO_REDUND_OFFS (CORE_SPEEDO_REDUND_MSBIT - CORE_SPEEDO_MSBIT) +#define SOC_SPEEDO_LSBIT 40 +#define SOC_SPEEDO_MSBIT 47 +#define SOC_SPEEDO_REDUND_LSBIT 48 +#define SOC_SPEEDO_REDUND_MSBIT 55 +#define SOC_SPEEDO_REDUND_OFFS (SOC_SPEEDO_REDUND_MSBIT - SOC_SPEEDO_MSBIT)#define SPEEDO_MULT 4
@@ -56,7 +56,7 @@ static const u32 __initconst cpu_process_speedos[][PROCESS_CORNERS_NUM] = { {316, 331, 383, UINT_MAX}, }; -static const u32 __initconst core_process_speedos[][PROCESS_CORNERS_NUM ] = { +static const u32 __initconst soc_process_speedos[][PROCESS_CORNERS_NUM ] = { {165 ,195 ,224 ,UINT_MAX }, {165 ,195 ,224 ,UINT_MAX }, {165, 195, 224, UINT_MAX},
@@ -69,7 +69,7 @@ void __init tegra20_init_speedo_data(struct tegra_sku_info *sku_info)int i;BUILD_BUG_ON (ARRAY_SIZE (cpu_process_speedos) !=SPEEDO_ID_COUNT ); -BUILD_BUG_ON (ARRAY_SIZE (core_process_speedos) !=SPEEDO_ID_COUNT ); +BUILD_BUG_ON (ARRAY_SIZE (soc_process_speedos) !=SPEEDO_ID_COUNT );if (SPEEDO_ID_SELECT_0 (sku_info->revision)) sku_info->soc_speedo_id =SPEEDO_ID_0 ;
@@ -94,17 +94,17 @@ void __init tegra20_init_speedo_data(struct tegra_sku_info *sku_info) sku_info->cpu_process_id = i; val =0 ; -for (i =CORE_SPEEDO_MSBIT ; i >=CORE_SPEEDO_LSBIT ; i--) { +for (i =SOC_SPEEDO_MSBIT ; i >=SOC_SPEEDO_LSBIT ; i--) { reg =tegra_fuse_read_spare (i) | -tegra_fuse_read_spare (i +CORE_SPEEDO_REDUND_OFFS ); +tegra_fuse_read_spare (i +SOC_SPEEDO_REDUND_OFFS ); val = (val <<1 ) | (reg &0x1 ); } val = val *SPEEDO_MULT ;pr_debug ("Core speedo value %u\n" , val);for (i =0 ; i < (PROCESS_CORNERS_NUM -1 ); i++) { -if (val <= core_process_speedos[sku_info->soc_speedo_id][i]) +if (val <= soc_process_speedos[sku_info->soc_speedo_id][i])break ; } - sku_info->core_process_id = i; + sku_info->soc_process_id = i; }
drivers/soc/tegra/fuse/speedo-tegra30.c +13 -13
@@ -22,7 +22,7 @@#include "fuse.h" -#define CORE_PROCESS_CORNERS 1 +#define SOC_PROCESS_CORNERS 1#define CPU_PROCESS_CORNERS 6#define FUSE_SPEEDO_CALIB_0 0x14
@@ -54,7 +54,7 @@ enum { THRESHOLD_INDEX_COUNT, }; -static const u32 __initconst core_process_speedos[][CORE_PROCESS_CORNERS ] = { +static const u32 __initconst soc_process_speedos[][SOC_PROCESS_CORNERS ] = { {180 }, {170 }, {195 },
@@ -246,19 +246,19 @@ static void __init rev_sku_to_speedo_ids(struct tegra_sku_info *sku_info)void __init tegra30_init_speedo_data (struct tegra_sku_info *sku_info) {u32 cpu_speedo_val; -u32 core_speedo_val; +u32 soc_speedo_val;int i;BUILD_BUG_ON (ARRAY_SIZE (cpu_process_speedos) !=THRESHOLD_INDEX_COUNT ); -BUILD_BUG_ON (ARRAY_SIZE (core_process_speedos) != +BUILD_BUG_ON (ARRAY_SIZE (soc_process_speedos) !=THRESHOLD_INDEX_COUNT );rev_sku_to_speedo_ids (sku_info); -fuse_speedo_calib (&cpu_speedo_val, &core_speedo_val); +fuse_speedo_calib (&cpu_speedo_val, &soc_speedo_val);pr_debug ("Tegra CPU speedo value %u\n" , cpu_speedo_val); -pr_debug ("Tegra Core speedo value %u\n" , core_speedo_val); +pr_debug ("Tegra Core speedo value %u\n" , soc_speedo_val);for (i =0 ; i <CPU_PROCESS_CORNERS ; i++) {if (cpu_speedo_val < cpu_process_speedos[threshold_index][i])
@@ -273,16 +273,16 @@ void __init tegra30_init_speedo_data(struct tegra_sku_info *sku_info) sku_info->cpu_speedo_id =1 ; } -for (i =0 ; i <CORE_PROCESS_CORNERS ; i++) { -if (core_speedo_val < core_process_speedos[threshold_index][i]) +for (i =0 ; i <SOC_PROCESS_CORNERS ; i++) { +if (soc_speedo_val < soc_process_speedos[threshold_index][i])break ; } - sku_info->core_process_id = i -1 ; + sku_info->soc_process_id = i -1 ; -if (sku_info->core_process_id ==-1 ) { -pr_warn ("Tegra CORE speedo value %3d out of range" , - core_speedo_val); - sku_info->core_process_id =0 ; +if (sku_info->soc_process_id ==-1 ) { +pr_warn ("Tegra SoC speedo value %3d out of range" , + soc_speedo_val); + sku_info->soc_process_id =0 ; sku_info->soc_speedo_id =1 ; } }
include/soc/tegra/fuse.h +1 -1
@@ -48,7 +48,7 @@ struct tegra_sku_info {int cpu_speedo_id;int cpu_speedo_value;int cpu_iddq_value; -int core_process_id; +int soc_process_id;int soc_speedo_id;int soc_speedo_value;int gpu_process_id;
Signature · 1 line
2.3.5