blob: a774246a2779435b47376b4f7e2cb093a59a991d [file] [log] [blame]
Jimmy Zhang6860b4a2012-04-02 13:18:53 +00001/*
2 * Copyright (c) 2011 The Chromium OS Authors.
3 * (C) Copyright 2010,2011 NVIDIA Corporation <www.nvidia.com>
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Jimmy Zhang6860b4a2012-04-02 13:18:53 +00006 */
7
8#include <common.h>
Simon Glassb0e6ef42014-12-10 08:55:57 -07009#include <i2c.h>
Jimmy Zhang6860b4a2012-04-02 13:18:53 +000010#include <tps6586x.h>
11#include <asm/io.h>
Tom Warren150c2492012-09-19 15:50:56 -070012#include <asm/arch/tegra.h>
13#include <asm/arch-tegra/ap.h>
14#include <asm/arch-tegra/tegra_i2c.h>
15#include <asm/arch-tegra/sys_proto.h>
Jimmy Zhang6860b4a2012-04-02 13:18:53 +000016
17#define VDD_CORE_NOMINAL_T25 0x17 /* 1.3v */
18#define VDD_CPU_NOMINAL_T25 0x10 /* 1.125v */
19
20#define VDD_CORE_NOMINAL_T20 0x16 /* 1.275v */
21#define VDD_CPU_NOMINAL_T20 0x0f /* 1.1v */
22
23#define VDD_RELATION 0x02 /* 50mv */
24#define VDD_TRANSITION_STEP 0x06 /* 150mv */
25#define VDD_TRANSITION_RATE 0x06 /* 3.52mv/us */
26
Simon Glassb0e6ef42014-12-10 08:55:57 -070027#define PMI_I2C_ADDRESS 0x34 /* chip requires this address */
28
Jimmy Zhang6860b4a2012-04-02 13:18:53 +000029int pmu_set_nominal(void)
30{
Simon Glassb0e6ef42014-12-10 08:55:57 -070031 struct udevice *bus, *dev;
32 int core, cpu;
33 int ret;
Jimmy Zhang6860b4a2012-04-02 13:18:53 +000034
35 /* by default, the table has been filled with T25 settings */
Tom Warren49493cb2013-04-10 10:32:32 -070036 switch (tegra_get_chip_sku()) {
Jimmy Zhang6860b4a2012-04-02 13:18:53 +000037 case TEGRA_SOC_T20:
38 core = VDD_CORE_NOMINAL_T20;
39 cpu = VDD_CPU_NOMINAL_T20;
40 break;
41 case TEGRA_SOC_T25:
42 core = VDD_CORE_NOMINAL_T25;
43 cpu = VDD_CPU_NOMINAL_T25;
44 break;
45 default:
Tom Warren49493cb2013-04-10 10:32:32 -070046 debug("%s: Unknown SKU id\n", __func__);
Jimmy Zhang6860b4a2012-04-02 13:18:53 +000047 return -1;
48 }
49
Simon Glassb0e6ef42014-12-10 08:55:57 -070050 ret = tegra_i2c_get_dvc_bus(&bus);
51 if (ret) {
Jimmy Zhang6860b4a2012-04-02 13:18:53 +000052 debug("%s: Cannot find DVC I2C bus\n", __func__);
Simon Glassb0e6ef42014-12-10 08:55:57 -070053 return ret;
Jimmy Zhang6860b4a2012-04-02 13:18:53 +000054 }
Simon Glass25ab4b02015-01-25 08:26:55 -070055 ret = i2c_get_chip(bus, PMI_I2C_ADDRESS, 1, &dev);
Simon Glassb0e6ef42014-12-10 08:55:57 -070056 if (ret) {
57 debug("%s: Cannot find DVC I2C chip\n", __func__);
58 return ret;
59 }
60
61 tps6586x_init(dev);
Jimmy Zhang6860b4a2012-04-02 13:18:53 +000062 tps6586x_set_pwm_mode(TPS6586X_PWM_SM1);
63 return tps6586x_adjust_sm0_sm1(core, cpu, VDD_TRANSITION_STEP,
64 VDD_TRANSITION_RATE, VDD_RELATION);
65}