pmu.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2011 The Chromium OS Authors.
  3. * (C) Copyright 2010,2011 NVIDIA Corporation <www.nvidia.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <i2c.h>
  9. #include <tps6586x.h>
  10. #include <asm/io.h>
  11. #include <asm/arch/tegra.h>
  12. #include <asm/arch-tegra/ap.h>
  13. #include <asm/arch-tegra/tegra_i2c.h>
  14. #include <asm/arch-tegra/sys_proto.h>
  15. #define VDD_CORE_NOMINAL_T25 0x17 /* 1.3v */
  16. #define VDD_CPU_NOMINAL_T25 0x10 /* 1.125v */
  17. #define VDD_CORE_NOMINAL_T20 0x16 /* 1.275v */
  18. #define VDD_CPU_NOMINAL_T20 0x0f /* 1.1v */
  19. #define VDD_RELATION 0x02 /* 50mv */
  20. #define VDD_TRANSITION_STEP 0x06 /* 150mv */
  21. #define VDD_TRANSITION_RATE 0x06 /* 3.52mv/us */
  22. #define PMI_I2C_ADDRESS 0x34 /* chip requires this address */
  23. int pmu_set_nominal(void)
  24. {
  25. struct udevice *bus, *dev;
  26. int core, cpu;
  27. int ret;
  28. /* by default, the table has been filled with T25 settings */
  29. switch (tegra_get_chip_sku()) {
  30. case TEGRA_SOC_T20:
  31. core = VDD_CORE_NOMINAL_T20;
  32. cpu = VDD_CPU_NOMINAL_T20;
  33. break;
  34. case TEGRA_SOC_T25:
  35. core = VDD_CORE_NOMINAL_T25;
  36. cpu = VDD_CPU_NOMINAL_T25;
  37. break;
  38. default:
  39. debug("%s: Unknown SKU id\n", __func__);
  40. return -1;
  41. }
  42. ret = tegra_i2c_get_dvc_bus(&bus);
  43. if (ret) {
  44. debug("%s: Cannot find DVC I2C bus\n", __func__);
  45. return ret;
  46. }
  47. ret = i2c_get_chip(bus, PMI_I2C_ADDRESS, 1, &dev);
  48. if (ret) {
  49. debug("%s: Cannot find DVC I2C chip\n", __func__);
  50. return ret;
  51. }
  52. tps6586x_init(dev);
  53. tps6586x_set_pwm_mode(TPS6586X_PWM_SM1);
  54. return tps6586x_adjust_sm0_sm1(core, cpu, VDD_TRANSITION_STEP,
  55. VDD_TRANSITION_RATE, VDD_RELATION);
  56. }