blob: b89e03703b210fa24b6a29e1a088a2817506e82e [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
Simon Glass0f2af882020-05-10 11:40:05 -06007#include <log.h>
Tom Warren15fc9842014-01-24 12:46:18 -07008#include <asm/io.h>
9#include <asm/arch-tegra/tegra_i2c.h>
Simon Glassdbd79542020-05-10 11:40:11 -060010#include <linux/delay.h>
Tom Warren15fc9842014-01-24 12:46:18 -070011
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020012/* AS3722-PMIC-specific early init regs */
Tom Warren15fc9842014-01-24 12:46:18 -070013
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020014#define AS3722_I2C_ADDR 0x80
Tom Warren15fc9842014-01-24 12:46:18 -070015
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020016#define AS3722_SD0VOLTAGE_REG 0x00 /* CPU */
17#define AS3722_SD1VOLTAGE_REG 0x01 /* CORE, already set by OTP */
18#define AS3722_SD6VOLTAGE_REG 0x06 /* GPU */
19#define AS3722_SDCONTROL_REG 0x4D
Tom Warren15fc9842014-01-24 12:46:18 -070020
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020021#define AS3722_LDO2VOLTAGE_REG 0x12 /* VPP_FUSE */
22#define AS3722_LDO6VOLTAGE_REG 0x16 /* VDD_SDMMC */
23#define AS3722_LDCONTROL_REG 0x4E
Tom Warren15fc9842014-01-24 12:46:18 -070024
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020025#if defined(CONFIG_TARGET_VENICE2)
26#define AS3722_SD0VOLTAGE_DATA (0x2800 | AS3722_SD0VOLTAGE_REG)
27#else /* TK1 or Nyan-Big */
28#define AS3722_SD0VOLTAGE_DATA (0x3C00 | AS3722_SD0VOLTAGE_REG)
29#endif
30#define AS3722_SD0CONTROL_DATA (0x0100 | AS3722_SDCONTROL_REG)
31
32#if defined(CONFIG_TARGET_JETSON_TK1) || defined(CONFIG_TARGET_CEI_TK1_SOM)
33#define AS3722_SD1VOLTAGE_DATA (0x2800 | AS3722_SD1VOLTAGE_REG)
34#define AS3722_SD1CONTROL_DATA (0x0200 | AS3722_SDCONTROL_REG)
35#endif
36
37#define AS3722_SD6CONTROL_DATA (0x4000 | AS3722_SDCONTROL_REG)
38#define AS3722_SD6VOLTAGE_DATA (0x2800 | AS3722_SD6VOLTAGE_REG)
39
40#define AS3722_LDO2CONTROL_DATA (0x0400 | AS3722_LDCONTROL_REG)
41#define AS3722_LDO2VOLTAGE_DATA (0x1000 | AS3722_LDO2VOLTAGE_REG)
42
43#define AS3722_LDO6CONTROL_DATA (0x4000 | AS3722_LDCONTROL_REG)
44#define AS3722_LDO6VOLTAGE_DATA (0x3F00 | AS3722_LDO6VOLTAGE_REG)
45
46/* AS3722-PMIC-specific early init code - get CPU rails up, etc */
Tom Warren15fc9842014-01-24 12:46:18 -070047
48void pmic_enable_cpu_vdd(void)
49{
50 debug("%s entry\n", __func__);
51
Bibek Basu9b7a41e2016-08-11 16:28:28 -060052#ifdef AS3722_SD1VOLTAGE_DATA
53 /* Set up VDD_CORE, for boards where OTP is incorrect*/
54 debug("%s: Setting VDD_CORE via AS3722 reg 1\n", __func__);
55 /* Configure VDD_CORE via the AS3722 PMIC on the PWR I2C bus */
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020056 tegra_i2c_ll_write(AS3722_I2C_ADDR,
57 AS3722_SD1VOLTAGE_DATA);
Bibek Basu9b7a41e2016-08-11 16:28:28 -060058 /*
59 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
60 * tegra_i2c_ll_write_data(AS3722_SD1CONTROL_DATA, I2C_SEND_2_BYTES);
61 */
62 udelay(10 * 1000);
63#endif
Tom Warren15fc9842014-01-24 12:46:18 -070064
65 debug("%s: Setting VDD_CPU to 1.0V via AS3722 reg 0/4D\n", __func__);
66 /*
67 * Bring up VDD_CPU via the AS3722 PMIC on the PWR I2C bus.
68 * First set VDD to 1.0V, then enable the VDD regulator.
69 */
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020070 tegra_i2c_ll_write(AS3722_I2C_ADDR,
71 AS3722_SD0VOLTAGE_DATA);
Tom Warren15fc9842014-01-24 12:46:18 -070072 /*
73 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
74 * tegra_i2c_ll_write_data(AS3722_SD0CONTROL_DATA, I2C_SEND_2_BYTES);
75 */
76 udelay(10 * 1000);
77
78 debug("%s: Setting VDD_GPU to 1.0V via AS3722 reg 6/4D\n", __func__);
79 /*
80 * Bring up VDD_GPU via the AS3722 PMIC on the PWR I2C bus.
81 * First set VDD to 1.0V, then enable the VDD regulator.
82 */
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020083 tegra_i2c_ll_write(AS3722_I2C_ADDR,
84 AS3722_SD6VOLTAGE_DATA);
Tom Warren15fc9842014-01-24 12:46:18 -070085 /*
86 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
87 * tegra_i2c_ll_write_data(AS3722_SD6CONTROL_DATA, I2C_SEND_2_BYTES);
88 */
89 udelay(10 * 1000);
90
91 debug("%s: Set VPP_FUSE to 1.2V via AS3722 reg 0x12/4E\n", __func__);
92 /*
93 * Bring up VPP_FUSE via the AS3722 PMIC on the PWR I2C bus.
94 * First set VDD to 1.2V, then enable the VDD regulator.
95 */
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +020096 tegra_i2c_ll_write(AS3722_I2C_ADDR,
97 AS3722_LDO2VOLTAGE_DATA);
Tom Warren15fc9842014-01-24 12:46:18 -070098 /*
99 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
100 * tegra_i2c_ll_write_data(AS3722_LDO2CONTROL_DATA, I2C_SEND_2_BYTES);
101 */
102 udelay(10 * 1000);
103
104 debug("%s: Set VDD_SDMMC to 3.3V via AS3722 reg 0x16/4E\n", __func__);
105 /*
106 * Bring up VDD_SDMMC via the AS3722 PMIC on the PWR I2C bus.
107 * First set it to bypass 3.3V straight thru, then enable the regulator
108 *
109 * NOTE: We do this early because doing it later seems to hose the CPU
110 * power rail/partition startup. Need to debug.
111 */
Svyatoslav Ryhel9e1ba0a2023-02-14 19:35:33 +0200112 tegra_i2c_ll_write(AS3722_I2C_ADDR,
113 AS3722_LDO6VOLTAGE_DATA);
Tom Warren15fc9842014-01-24 12:46:18 -0700114 /*
115 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
116 * tegra_i2c_ll_write_data(AS3722_LDO6CONTROL_DATA, I2C_SEND_2_BYTES);
117 */
118 udelay(10 * 1000);
119}