1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2011-2013
4 * Texas Instruments, <www.ti.com>
9 #include <power/tps65910.h>
11 struct udevice *tps65910_dev __section(".data") = NULL;
13 static inline int tps65910_read_reg(int addr, uchar *buf)
15 #if !CONFIG_IS_ENABLED(DM_I2C)
16 return i2c_read(TPS65910_CTRL_I2C_ADDR, addr, 1, buf, 1);
20 rc = dm_i2c_reg_read(tps65910_dev, addr);
28 static inline int tps65910_write_reg(int addr, uchar *buf)
30 #if !CONFIG_IS_ENABLED(DM_I2C)
31 return i2c_write(TPS65910_CTRL_I2C_ADDR, addr, 1, buf, 1);
33 return dm_i2c_reg_write(tps65910_dev, addr, *buf);
37 int power_tps65910_init(unsigned char bus)
39 #if CONFIG_IS_ENABLED(DM_I2C)
40 struct udevice *dev = NULL;
43 rc = i2c_get_chip_for_busnum(bus, TPS65910_CTRL_I2C_ADDR, 1, &dev);
53 * tps65910_set_i2c_control() - Set the TPS65910 to be controlled via the I2C
55 * @return: 0 on success, not 0 on failure
57 int tps65910_set_i2c_control(void)
62 /* VDD1/2 voltage selection register access by control i/f */
63 ret = tps65910_read_reg(TPS65910_DEVCTRL_REG, &buf);
68 buf |= TPS65910_DEVCTRL_REG_SR_CTL_I2C_SEL_CTL_I2C;
70 return tps65910_write_reg(TPS65910_DEVCTRL_REG, &buf);
74 * tps65910_voltage_update() - Voltage switching for MPU frequency switching.
75 * @module: mpu - 0, core - 1
76 * @vddx_op_vol_sel: vdd voltage to set
77 * @return: 0 on success, not 0 on failure
79 int tps65910_voltage_update(unsigned int module, unsigned char vddx_op_vol_sel)
82 unsigned int reg_offset;
86 reg_offset = TPS65910_VDD1_OP_REG;
88 reg_offset = TPS65910_VDD2_OP_REG;
91 ret = tps65910_read_reg(reg_offset, &buf);
95 buf &= ~TPS65910_OP_REG_CMD_MASK;
97 ret = tps65910_write_reg(reg_offset, &buf);
101 /* Configure VDDx OP Voltage */
102 ret = tps65910_read_reg(reg_offset, &buf);
106 buf &= ~TPS65910_OP_REG_SEL_MASK;
107 buf |= vddx_op_vol_sel;
109 ret = tps65910_write_reg(reg_offset, &buf);
113 ret = tps65910_read_reg(reg_offset, &buf);
117 if ((buf & TPS65910_OP_REG_SEL_MASK) != vddx_op_vol_sel)