blob: 395bdd99c78915411aa07feb6701cb8a145168c4 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Tom Warren15fc9842014-01-24 12:46:18 -07002/*
3 * (C) Copyright 2013
4 * NVIDIA Corporation <www.nvidia.com>
Tom Warren15fc9842014-01-24 12:46:18 -07005 */
6
7#include <common.h>
Simon Glass0f2af882020-05-10 11:40:05 -06008#include <log.h>
Tom Warren15fc9842014-01-24 12:46:18 -07009#include <asm/io.h>
10#include <asm/arch-tegra/tegra_i2c.h>
Simon Glassdbd79542020-05-10 11:40:11 -060011#include <linux/delay.h>
Tom Warren15fc9842014-01-24 12:46:18 -070012
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020013/* AS3722-PMIC-specific early init regs */
Tom Warren15fc9842014-01-24 12:46:18 -070014
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020015#define AS3722_I2C_ADDR 0x80
Tom Warren15fc9842014-01-24 12:46:18 -070016
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020017#define AS3722_SD0VOLTAGE_REG 0x00 /* CPU */
18#define AS3722_SD1VOLTAGE_REG 0x01 /* CORE, already set by OTP */
19#define AS3722_SD6VOLTAGE_REG 0x06 /* GPU */
20#define AS3722_SDCONTROL_REG 0x4D
Tom Warren15fc9842014-01-24 12:46:18 -070021
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020022#define AS3722_LDO2VOLTAGE_REG 0x12 /* VPP_FUSE */
23#define AS3722_LDO6VOLTAGE_REG 0x16 /* VDD_SDMMC */
24#define AS3722_LDCONTROL_REG 0x4E
Tom Warren15fc9842014-01-24 12:46:18 -070025
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020026#if defined(CONFIG_TARGET_VENICE2)
27#define AS3722_SD0VOLTAGE_DATA (0x2800 | AS3722_SD0VOLTAGE_REG)
28#else /* TK1 or Nyan-Big */
29#define AS3722_SD0VOLTAGE_DATA (0x3C00 | AS3722_SD0VOLTAGE_REG)
30#endif
31#define AS3722_SD0CONTROL_DATA (0x0100 | AS3722_SDCONTROL_REG)
32
33#if defined(CONFIG_TARGET_JETSON_TK1) || defined(CONFIG_TARGET_CEI_TK1_SOM)
34#define AS3722_SD1VOLTAGE_DATA (0x2800 | AS3722_SD1VOLTAGE_REG)
35#define AS3722_SD1CONTROL_DATA (0x0200 | AS3722_SDCONTROL_REG)
36#endif
37
38#define AS3722_SD6CONTROL_DATA (0x4000 | AS3722_SDCONTROL_REG)
39#define AS3722_SD6VOLTAGE_DATA (0x2800 | AS3722_SD6VOLTAGE_REG)
40
41#define AS3722_LDO2CONTROL_DATA (0x0400 | AS3722_LDCONTROL_REG)
42#define AS3722_LDO2VOLTAGE_DATA (0x1000 | AS3722_LDO2VOLTAGE_REG)
43
44#define AS3722_LDO6CONTROL_DATA (0x4000 | AS3722_LDCONTROL_REG)
45#define AS3722_LDO6VOLTAGE_DATA (0x3F00 | AS3722_LDO6VOLTAGE_REG)
46
47/* AS3722-PMIC-specific early init code - get CPU rails up, etc */
Tom Warren15fc9842014-01-24 12:46:18 -070048
49void pmic_enable_cpu_vdd(void)
50{
51 debug("%s entry\n", __func__);
52
Bibek Basu9b7a41e2016-08-11 16:28:28 -060053#ifdef AS3722_SD1VOLTAGE_DATA
54 /* Set up VDD_CORE, for boards where OTP is incorrect*/
55 debug("%s: Setting VDD_CORE via AS3722 reg 1\n", __func__);
56 /* Configure VDD_CORE via the AS3722 PMIC on the PWR I2C bus */
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020057 tegra_i2c_ll_write(AS3722_I2C_ADDR,
58 AS3722_SD1VOLTAGE_DATA);
Bibek Basu9b7a41e2016-08-11 16:28:28 -060059 /*
60 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
61 * tegra_i2c_ll_write_data(AS3722_SD1CONTROL_DATA, I2C_SEND_2_BYTES);
62 */
63 udelay(10 * 1000);
64#endif
Tom Warren15fc9842014-01-24 12:46:18 -070065
66 debug("%s: Setting VDD_CPU to 1.0V via AS3722 reg 0/4D\n", __func__);
67 /*
68 * Bring up VDD_CPU via the AS3722 PMIC on the PWR I2C bus.
69 * First set VDD to 1.0V, then enable the VDD regulator.
70 */
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020071 tegra_i2c_ll_write(AS3722_I2C_ADDR,
72 AS3722_SD0VOLTAGE_DATA);
Tom Warren15fc9842014-01-24 12:46:18 -070073 /*
74 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
75 * tegra_i2c_ll_write_data(AS3722_SD0CONTROL_DATA, I2C_SEND_2_BYTES);
76 */
77 udelay(10 * 1000);
78
79 debug("%s: Setting VDD_GPU to 1.0V via AS3722 reg 6/4D\n", __func__);
80 /*
81 * Bring up VDD_GPU via the AS3722 PMIC on the PWR I2C bus.
82 * First set VDD to 1.0V, then enable the VDD regulator.
83 */
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020084 tegra_i2c_ll_write(AS3722_I2C_ADDR,
85 AS3722_SD6VOLTAGE_DATA);
Tom Warren15fc9842014-01-24 12:46:18 -070086 /*
87 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
88 * tegra_i2c_ll_write_data(AS3722_SD6CONTROL_DATA, I2C_SEND_2_BYTES);
89 */
90 udelay(10 * 1000);
91
92 debug("%s: Set VPP_FUSE to 1.2V via AS3722 reg 0x12/4E\n", __func__);
93 /*
94 * Bring up VPP_FUSE via the AS3722 PMIC on the PWR I2C bus.
95 * First set VDD to 1.2V, then enable the VDD regulator.
96 */
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020097 tegra_i2c_ll_write(AS3722_I2C_ADDR,
98 AS3722_LDO2VOLTAGE_DATA);
Tom Warren15fc9842014-01-24 12:46:18 -070099 /*
100 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
101 * tegra_i2c_ll_write_data(AS3722_LDO2CONTROL_DATA, I2C_SEND_2_BYTES);
102 */
103 udelay(10 * 1000);
104
105 debug("%s: Set VDD_SDMMC to 3.3V via AS3722 reg 0x16/4E\n", __func__);
106 /*
107 * Bring up VDD_SDMMC via the AS3722 PMIC on the PWR I2C bus.
108 * First set it to bypass 3.3V straight thru, then enable the regulator
109 *
110 * NOTE: We do this early because doing it later seems to hose the CPU
111 * power rail/partition startup. Need to debug.
112 */
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +0200113 tegra_i2c_ll_write(AS3722_I2C_ADDR,
114 AS3722_LDO6VOLTAGE_DATA);
Tom Warren15fc9842014-01-24 12:46:18 -0700115 /*
116 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
117 * tegra_i2c_ll_write_data(AS3722_LDO6CONTROL_DATA, I2C_SEND_2_BYTES);
118 */
119 udelay(10 * 1000);
120}