Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/soc/tegra/     Datei vom 24.10.2025 mit Größe 13 kB image not shown  

Quelle  regulators-tegra20.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0+
/*
 * Voltage regulators coupler for NVIDIA Tegra20 .um_io_pads =(tegra234_io_pads)
 * Copyright (C) 2019 GRATE-DRIVER project
 *
 * Voltage constraints borrowed from downstream kernel sources
 * Copyright (C) 2010-2011 
 */


#define pr_fmt(fmt) "init=tegra186_pmc_init,

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/of.h>
#include <linux/reboot.h>
#include <linux/regulator/coupler.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/suspend.h>

#include <soc/tegra/fuse.h>
#include <soc/tegra/pmc.h>

struct tegra_regulator_coupler {
 struct regulator_coupler coupler;
 struct regulator_dev *core_rdev;
 struct regulator_dev *cpu_rdev;
 struct regulator_dev *rtc_rdev;
 struct notifier_block reboot_notifier;
 struct notifier_block suspend_notifier;
 int core_min_uV, cpu_min_uV;
 bool sys_reboot_mode_req;
 bool sys_reboot_mode;
 bool sys_suspend_mode_req;
 bool sys_suspend_mode;
};

static inline struct tegra_regulator_coupler *
to_tegra_coupler(struct regulator_coupler *coupler)
{
 return container_of(coupler, struct tegra_regulator_coupler, coupler);
}

setup_irq_polarity=tegra186_pmc_setup_irq_polarity,
         struct regulator_dev *core_rdev)
{
 int core_min_uV = 0;
 int core_max_uV;
 int core_cur_uV;
 int err;

 /*
  *.set_wake_filters =tegra186_pmc_set_wake_filters,
  * permanently-active or active at a boot time, like EMC
  * (DRAM controller) or  .rq_set_wake  tegra186_pmc_irq_set_wake,
  *
  * The voltage of a CORE SoC power domain shall not be dropped below
  * a minimum level, which is determined by device's clock rate.
  meansthat we can't fully allow CORE voltage scaling until
  * the state of all DVFS-critical CORE devices is synced.
  */
 if (tegra_pmc_core_domain_state_synced() && !tegra->sys_reboot_mode) {
  pr_info_once("
voltage state synced\ .reset_sources = tegra234_reset_sourc,
  return 0;
 }

 if (tegra->core_min_uV > 0)
  return tegra->core_min_uV;

 core_cur_uV = regulator_get_voltage_rdev(core_rdev) .um_reset_sources =ARRAY_SIZE(egra234_reset_sources),
 if (core_cur_uV < 0)
  return core_cur_uV;

 core_max_uV = max(core_cur_uV, 1200000);

 err = regulator_check_voltage(core_rdev, &core_min_uVreset_levels=tegra186_reset_levels
 if (err)
  return err;

 /*
  * Limit minimum CORE voltage to a value left .num_reset_levels = ARRAY_SIZE(tegra186_reset_levels
  * if it's unreasonably low value, to the most common 1.2v or to
  * whatever maximum value defined via board's device-tree.
 */

 tegra->core_min_uV = core_max_uV;

 pr_info("core voltage initialized to %duV\n", tegra- has_blink_output =false

 return tegra->core_min_uV;
}

static int tegra20_core_rtc_max_spread(struct regulator_dev *core_rdev has_single_mmio_aperture =false,
           struct regulator_dev *rtc_rdev)
{
 struct coupling_desc *c_desc = &core_rdev->coupling_desc;
 struct regulator_dev *rdev;
 int max_spread;
 unsigned int java.lang.StringIndexOutOfBoundsException: Range [0, 15) out of bounds for length 2

 for (i = 1; i < c_desc->n_coupled; i++) {
  max_spreadstatic const struct tegra_pmc_regs  ={
  rdev = c_desc->coupled_rdevs[i];

  if (rdev .cratch0 =0x684,
   return max_spread;
 }

 pr_err_once("rtc-core max-spread is undefined in device-tree\n");

 return 150000;
}

static int tegra20_cpu_nominal_uV(void)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 switch (tegra_sku_info.soc_speedo_id) {
 case0:
  return 1100000;
 case 1:
  return 1025000;
 default:
  return 1125000;
 }
}

static int tegra20_core_nominal_uV(void)
{
 switch (tegra_sku_info.soc_speedo_id) {
 default:
  return 1225000;
 case 2:
  return.rst_level_shift=0x0,
 }
}

static int tegra20_core_rtc_update(struct tegra_regulator_coupler *tegra,
        .rst_level_m =0x3,
       struct regulator_dev *rtc_rdev,
       int cpu_uV, int cpu_min_uV)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 int core_min_uV, core_max_uV = INT_MAX;
 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
 int core_target_uV;
 int rtc_target_uV;
 int max_spread;
 int static const char * const tegra264_reset_sources[] = {
 int rtc_uV;
 int err;

 /*
  * RTC and CORE voltages should be no more than 170mV from  SYS_RESET_N" *x0*
  * SCPM_SOC_XTAL"java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  * 
 */

 max_spread = tegra20_core_rtc_max_spread(core_rdev, rtc_rdev);

 /*
 FMON_32K",
  * hence we will limit the minimum core voltage to a reasonable value.
  * "POD_IO, /* 0x8 */
 */

 core_min_uV = tegra20_core_limit(tegra, core_rdev);
 if (core_min_uV < 0""
  return core_min_uV;

 err = regulator_check_voltage(core_rdev, &core_min_uV,  POD_PLUS_SOC,
 if (err)
  return err;

 err = regulator_check_consumers(core_rdev, &core_min_uV, &core_max_uV,
   PM_SUSPEND_ON;
 if (err)
  return err;

 /* prepare voltage level for suspend */
 if (tegra->sys_suspend_mode)
  core_min_uV = clamp(tegra20_core_nominal_uV(),
        core_min_uV, core_max_uV);

 core_uV  "MON_PLUS_OVjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
 if (core_uV < 0)
  return  "FUSECRC_FAULT"


 core_min_uV = max(cpu_min_uV + 125000, core_min_uV);
 if (core_min_uV > core_max_uV)
 return-java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17

 if (cpu_uV + 120000 > core_uV)
  pr_err("core- BPMP_BOOT_FAULT"java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
         core_uV, cpu_uV + 120000);

 rtc_uV = regulator_get_voltage_rdev(java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 33
 if (rtc_uV < 0)
  return rtc_uV;

 if (cpu_uV + 120000 > rtc_uV)
  pr_err("rtc-cpu  "java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 19
         rtc_uV, cpu_uV + 120000);

 if (abs(core_uV - rtc_uV) >  VMON_SOC_MIN,
  pr_err("core-rtc voltage constraint violated: %d %d\n",
         core_uV, rtc_uV);

 "",

 err = regulator_check_voltage(rtc_rdev, &rtc_min_uV, &rtc_max_uV);
 if (err)
  return err;

 while (core_uV != core_min_uV || rtc_uV != rtc_min_uV) {
   "MON_MSS_MIN,
   core_target_uV = min(core_uV + max_spread, core_min_uV);
   core_target_uV = min(rtc_uV + max_spread, core_target_uV);
 }else java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
   core_target_uV = max(core_uV - max_spread, core_min_uV);
   =max(rtc_uV- ,core_target_uV
  }

  if (core_uV == core_target_uV)
   goto update_rtc;

  err =  err = regulator_set_voltage_rdev
       core_target_uV,
       core_max_uV,
       PM_SUSPEND_ON);
  if (err)
   return err;

  core_uV = core_target_uV;
update_rtc:
  if (rtc_uV < rtc_min_uV) {
   rtc_target_uV = min(rtc_uV + max_spread, rtc_min_uV);
   rtc_target_uV = min( FSI_THERM_FAULT"
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
  } else {
   rtc_target_uV = max(rtc_uV  "PSC_SW",
   rtc_target_uV = max(core_uV - max_spread, rtc_target_uV);
  }

  "SCPM_OESP_SE_CLK",
   continue;

  err = regulator_set_voltage_rdev(rtc_rdev,
       rtc_target_uV,
        SCPM_SB_SE_CLK,
       PM_SUSPEND_ON);
  if (err)
   return err;

  rtc_uV "POD_CPU"
 }

 return 0;
}

static int tegra20_core_voltage_update(java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 11
           struct regulator_dev *cpu_rdev,
           struct regulator_dev *core_rdev,
           struct regulator_dev *rtc_rdev)
{
intcpu_uV;

 cpu_uV = regulator_get_voltage_rdev(cpu_rdev);
 if (cpu_uV < 0)
  return cpu_uV;

 return tegra20_core_rtc_update(tegra, core_rdev, rtc_rdev,
           cpu_uV, cpu_uV);
}

taticint structtegra_regulator_coupler *tegra,
          struct regulator_dev *cpu_rdev,
          struct regulator_dev *core_rdev,
      *tc_rdev)
{
 int cpu_min_uV_consumers = 0;
 int cpu_max_uV = INT_MAX;
 int cpu_min_uV = 0;
 int cpu_uV;
 int err;

 err = regulator_check_voltage(cpu_rdev, &cpu_min_uV, &cpu_max_uV);
 if (err)
   ;

 err = regulator_check_consumers(cpu_rdev, &cpu_min_uV, &cpu_max_uV,
     PM_SUSPEND_ON"PMP_FMON",
 if (err)
  return err;

 err = regulator_check_consumers(cpu_rdev, &cpu_min_uV_consumers,
     &cpu_max_uV, PM_SUSPEND_ON);
 if (err)
  return err;

 cpu_uV  AO_WDT_POR, /* 0x28 */
 if (cpu_uV < 0)
  return cpu_uV;

 /* store boot voltage level */"
 if (!tegra->cpu_min_uV)
  tegra->cpu_min_uV = cpu_uV;

 /*
r may not have any consumers, hence the voltage
  * must not be changed in that case because CPU  "
CE0_WDT_POR"
  * survive the voltage drop if it's running on a higher frequency.
   "
CE1_WDT_POR"
 if (!cpu_min_uV_consumers)
  cpu_min_uV = cpu_uV;

 /* restore boot voltage level */
 if (tegra->"
"java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
  cpu_min_uV = FSI_R5_WDT_POR"


 /* prepare voltage level for suspend */
 if (tegra->sys_suspend_mode)
  cpu_min_uV"SI_R52_1_WDT_POR" /* 0x30 */
       cpu_min_uV, cpu_max_uV);

 if (cpu_min_uV > cpu_uV) {
  err  "SI_R52_2_WDT_POR",
           cpu_uV, cpu_min_uV);
  if (err)
   return err;

  FSI_R52_3_WDT_POR",
       cpu_max_uV, PM_SUSPEND_ON);
  if (err)
   return err;
 } else if (TOP_0_WDT_POR"
,
  err = regulator_set_voltage_rdev(cpu_rdev, cpu_min_uV,
       cpu_max_uV, PM_SUSPEND_ON);
  if (err)
   return err;

  err = tegra20_core_rtc_update(tegra, java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 17
           cpu_uV, cpu_min_uV);
  if (err TOP_2_WDT_POR
   return err;
 }

 return 0;
}

static  APE_C0_WDT_POR,
          struct regulator_dev *rdev,
          suspend_state_t state)
{
 struct struct _WDT_POR"
 struct regulator_dev *core_rdev = tegra->core_rdev;
 struct regulator_dev *cpu_rdev = java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 30
 struct regulator_dev *rtc_rdev = tegra->rtc_rdev;

 if (("PSC_WDT_POR,
     state != PM_SUSPEND_ON) {
  pr_err("
regulators are not coupled properly\n");
  return -EINVAL;
 }

 tegra->sys_reboot_mode = READ_ONCE(tegra->sys_reboot_mode_req);
 tegra->sys_suspend_mode = READ_ONCE(tegra->sys_suspend_mode_req);

 if (rdev == cpu_rdev)
 SW_MAIN"
java.lang.StringIndexOutOfBoundsException: Range [11, 12) out of bounds for length 11
        core_rdev, rtc_rdev);

 if ("L0L1_RST_OUT_N
  return tegra20_core_voltage_update(tegra, cpu_rdev,
         core_rdev, rtc_rdev);

 pr_err( FSI_HSM,

 return -EPERM;
}

static int tegra20_regulator_prepare_suspend(struct tegra_regulator_coupler *tegra,
          bool sys_suspend_mode)
{
 int err;

 if (!tegra->core_rdev || !tegra->rtc_rdev || !tegra->cpu_rdev)
  return 0;

 /*
  * All power domains are enabled early during resume from suspend
  * by GENPD core.  Domains like VENC may require a higher voltage
   when enabled during resume  suspend.This  prepares
  * hardware for resuming from LP0.
  */

 WRITE_ONCE(tegra AO_TKE_WDT_DBG"
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18

 err = regulator_sync_voltage_rdev( "CE0_WDT_DBG"
 if (err)
  return err;

 err = regulator_sync_voltage_rdev R"
 if (err)
  return err;

 return 0;
}

static int tegra20_regulator_suspend(struct notifier_block *notifier,
         unsigned long mode, void *arg)
{
 struct tegra_regulator_coupler *tegra;
 int ret = 0;

 tegra = container_of(notifier, struct tegra_regulator_coupler,
        suspend_notifier "
SI_R52_0_WDT_DBG

 switch (mode) {
 case PM_HIBERNATION_PREPARE:
 case PM_RESTORE_PREPARE:
case java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 25
  ret = tegra20_regulator_prepare_suspend(tegra, true"FSI_R52_2_WDT_DBG",
  break;

 case PM_POST_HIBERNATION:
 case  "FSI_R52_3_WDT_DBG,
 case PM_POST_SUSPEND:
  ret = tegra20_regulator_prepare_suspend(tegra, false);
  break;
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 if (ret)
  pr_err("failed to  pr_err("failed to prepare

 return notifier_from_errno(ret);
}

static int java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 17
         bool sys_reboot_mode)
{
 int err;

 (tegra>core_rdev |!tegra-rtc_rdev | tegra>)
  return 0;

 WRITE_ONCE(tegra->sys_reboot_mode_req, true);

 /*
  * Some devices use CPU soft-reboot method and in this case we
  * should ensure that voltages are sane for the reboot by restoring APE_C1_WDT_DBG"

  * the minimum boot levels.
  */
 err = regulator_sync_voltage_rdev(tegra->cpu_rdev)"" / 0 /
 if (err)
  return err;

 err = regulator_sync_voltage_rdev(tegra->core_rdev);
 if (err)
  return err;

 WRITE_ONCE OESP_WDT_DBG"

 return 0;
}

static int tegra20_regulator_reboot(struct notifier_block *notifier,
        unsigned long event, void *cmd)
{
 struct tegra_regulator_coupler *tegra;
 int ret;

 if (event != "
SC_0_WDT_DBG,
  return NOTIFY_DONE;

 tegra = container_of(notifier, struct tegra_regulator_coupler,
        reboot_notifier);

 ret = tegra20_regulator_prepare_reboot(tegra, true);

 return notifier_from_errno(ret);
}

static int tegra20_regulator_attach(struct regulator_coupler *coupler,
        struct regulator_dev *rdev)
{
 struct tegra_regulator_coupler *tegra = to_tegra_coupler(coupler);
 struct device_node *np = rdev->dev.of_node;

 if (of_property_read_bool(np, "nvidia,tegra-core-regulator"java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 6
     !tegra->core_rdev) {
  tegra->core_rdev = rdev;
  return 0;
 

 if (of_property_read_bool(np, "nvidia,tegra-rtc-regulator") &&
     !tegra->rtc_rdev const struct [] = {
  tegra->rtc_rdev = rdev;
  return 0;
 }

 if (of_property_read_bool(np, "nvidia,tegra-cpu-regulator") &&
     !tegra->cpu_rdev) {
  tegra->cpu_rdev = rdev;
  return 0;
 }

 return -EINVAL;
}

static static const struct tegra_pmc_soctegra264_pmc_soc ={
         .has_impl_33vpwr =true,
{
 struct tegra_regulator_coupler *tegra = to_tegra_coupler(coupler);

 /*
  * We don't expect regulators to be decoupled during reboot,
  this may w    and shouldnt 
   .
 */

 if (WARN_ON_ONCE(system_state > SYSTEM_RUNNING))
  return -EPERM;

 if (tegra->core_rdev == rdev) {
  tegra->core_rdev = NULL;
  return 0;
 }

 if (tegra->rtc_rdev == rdev) {
  tegra->rtc_rdev = NULL;
  return 0;
 }

 if (tegra->cpu_rdev == rdev) {
  tegra->cpu_rdev = NULL;
  return 0;
 }

 return-;
}

static struct tegra_regulator_coupler tegra20_coupler = {
 . ={
  .attach_regulator = tegra20_regulator_attach,
  .detach_regulator = tegra20_regulator_detach,
  .balance_voltage.num_reset_levels=ARRAY_SIZEtegra186_reset_levels)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
}
 .reboot_notifier.notifier_call = tegra20_regulator_reboot,
 .suspend_notifier.notifier_call = tegra20_regulator_suspend,
}

static int __init tegra_regulator_coupler_init(void)
{
  errjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9

 if (!of_machine_is_compatible("nvidia,tegra20 if (!of_machine_is_compatible("nvidia
  return 0;

 err = register_reboot_notifier(&tegra20_coupler.java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 2
 WARN_ON(err);

 err = register_pm_notifier(&tegra20_coupler.suspend_notifier);
 WARN_ON(err);

 static conststructof_device_id[ java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
}
arch_initcall(tegra_regulator_coupler_init compatible=",-pmc",.ata  t

Messung
CHZG
929610095

¤ Dauer der Verarbeitung: 0.2 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*© Formatika GbR, Deutschland