diff --git a/drivers/tegra/hwpm/common/aperture.c b/drivers/tegra/hwpm/common/aperture.c index 1c5934a..e1c0a57 100644 --- a/drivers/tegra/hwpm/common/aperture.c +++ b/drivers/tegra/hwpm/common/aperture.c @@ -320,10 +320,24 @@ static int tegra_hwpm_func_single_element(struct tegra_soc_hwpm *hwpm, } } - /* Validate perfmux availability by reading 1st alist offset */ - ret = tegra_hwpm_regops_readl(hwpm, ip_inst, element, - tegra_hwpm_safe_add_u64(element->start_abs_pa, - element->alist[0U].reg_offset), ®_val); + if (hwpm->fake_registers_enabled) { + /* + * In this case, HWPM will allocate memory to simulate + * IP perfmux address space. Hence, the perfmux will + * always be available. + * Indicate this by setting ret = 0. + */ + ret = 0; + } else { + /* + * Validate perfmux availability by reading 1st alist offset + */ + ret = tegra_hwpm_regops_readl(hwpm, ip_inst, element, + tegra_hwpm_safe_add_u64(element->start_abs_pa, + element->alist[0U].reg_offset), + ®_val); + } + if (ret != 0) { /* * If an IP element is unavailable, perfmux register diff --git a/drivers/tegra/hwpm/common/init.c b/drivers/tegra/hwpm/common/init.c index 9e8f376..14de9d8 100644 --- a/drivers/tegra/hwpm/common/init.c +++ b/drivers/tegra/hwpm/common/init.c @@ -37,6 +37,9 @@ #ifdef CONFIG_TEGRA_NEXT2_HWPM #include #endif +#ifdef CONFIG_TEGRA_NEXT3_HWPM +#include +#endif static int tegra_hwpm_init_chip_ip_structures(struct tegra_soc_hwpm *hwpm, u32 chip_id, u32 chip_id_rev) @@ -63,10 +66,25 @@ static int tegra_hwpm_init_chip_ip_structures(struct tegra_soc_hwpm *hwpm, } break; default: -#ifdef CONFIG_TEGRA_NEXT2_HWPM +#if defined(CONFIG_TEGRA_NEXT2_HWPM) err = tegra_hwpm_next2_init_chip_ip_structures( hwpm, chip_id, chip_id_rev); -#else + if (err == 0) { + /* Execution is for NEXT2 chip */ + break; + } +#endif + +#if defined(CONFIG_TEGRA_NEXT3_HWPM) + err = tegra_hwpm_next3_init_chip_ip_structures( + hwpm, chip_id, chip_id_rev); + if (err == 0) { + /* Execution is for NEXT3 chip */ + break; + } +#endif + +#if !defined(CONFIG_TEGRA_NEXT2_HWPM) && !defined(CONFIG_TEGRA_NEXT3_HWPM) tegra_hwpm_err(hwpm, "Chip 0x%x not supported", chip_id); #endif break; diff --git a/drivers/tegra/hwpm/os/linux/driver.c b/drivers/tegra/hwpm/os/linux/driver.c index ac9c36d..aca2006 100644 --- a/drivers/tegra/hwpm/os/linux/driver.c +++ b/drivers/tegra/hwpm/os/linux/driver.c @@ -45,6 +45,9 @@ static const struct of_device_id tegra_soc_hwpm_of_match[] = { #endif #ifdef CONFIG_TEGRA_NEXT2_HWPM #include +#endif +#ifdef CONFIG_TEGRA_NEXT3_HWPM +#include #endif { }, }; diff --git a/drivers/tegra/hwpm/os/linux/io_utils.c b/drivers/tegra/hwpm/os/linux/io_utils.c index fd4dfcb..266de61 100644 --- a/drivers/tegra/hwpm/os/linux/io_utils.c +++ b/drivers/tegra/hwpm/os/linux/io_utils.c @@ -52,6 +52,11 @@ int tegra_hwpm_fake_readl_impl(struct tegra_soc_hwpm *hwpm, return -ENODEV; } + if (aperture->fake_registers == NULL) { + tegra_hwpm_err(hwpm, "Expected fake registers to be populated"); + return -ENODEV; + } + *val = aperture->fake_registers[offset]; return 0; } @@ -64,6 +69,11 @@ int tegra_hwpm_fake_writel_impl(struct tegra_soc_hwpm *hwpm, return -ENODEV; } + if (aperture->fake_registers == NULL) { + tegra_hwpm_err(hwpm, "Expected fake registers to be populated"); + return -ENODEV; + } + aperture->fake_registers[offset] = val; return 0; } diff --git a/drivers/tegra/hwpm/os/linux/soc_utils.c b/drivers/tegra/hwpm/os/linux/soc_utils.c index 171370d..69cfd89 100644 --- a/drivers/tegra/hwpm/os/linux/soc_utils.c +++ b/drivers/tegra/hwpm/os/linux/soc_utils.c @@ -34,6 +34,9 @@ #if defined(CONFIG_TEGRA_NEXT2_HWPM) #include #endif +#if defined(CONFIG_TEGRA_NEXT3_HWPM) +#include +#endif static struct hwpm_soc_chip_info chip_info = { .chip_id = CHIP_ID_UNKNOWN, @@ -89,6 +92,11 @@ int tegra_hwpm_init_chip_info(struct tegra_hwpm_os_linux *hwpm_linux) goto complete; } #endif +#if defined(CONFIG_TEGRA_NEXT3_HWPM) + if (tegra_hwpm_next3_get_chip_compatible(&chip_info) == 0) { + goto complete; + } +#endif return -ENODEV; complete: