瑞芯微Rockchip开发者社区
直播中

h1654155275.5669

7年用户 1028经验值
私信 关注
[经验]

如何将RK817的TS管脚连接到外部电源的EN端

主板电路将RK817的TS管脚连接到外部电源的EN端,想实现开机时由TS管脚置高控制外部电源开启,关机时由TS管脚置低控制外部电源关闭。

查看Rockchip RK817 Datasheet文档可知,需要操作PMIC_GPIO_INT_CONFIG寄存器中的bit[4:2]来实现。

1.jpg

2.jpg

Bit[4:2]=0x7时,TS为高电平;Bit[4:2]=0x5时,TS为低电平。

开机时置高TS管脚的方法:

可通过两种方式实现,一是修改uboot代码,二是修改内核。

修改u-boot

u-boot/drivers/power/pmic/rk8xx.c文件中rk817_init_reg[]表下增加

{ RK817_GPIO_INT_CFG, 0x1C, 0x1C },

static struct reg_data rk817_init_reg[] = {

/* enable the under-voltage protection,

the under-voltage protection will shutdown the LDO3 and reset the PMIC

*/

{ RK817_BUCK4_CMIN, 0x60, 0x60},

{ RK817_PMIC_SYS_CFG1, 0x20, 0x70},

/* Set pmic_sleep as none function */

{ RK817_PMIC_SYS_CFG3, 0x00, 0x18 },

#ifdef CONFIG_DM_CHARGE_DISPLAY

/* Set pmic_int active low */

{ RK817_GPIO_INT_CFG, 0x00, 0x02 },

#endif

{ RK817_GPIO_INT_CFG, 0x1C, 0x1C },

};

reg_data类型定义如下:

struct reg_data {

u8 reg;

u8 val;

u8 mask;

};

修改内核驱动:

./kernel/drivers/mfd/rk808.c文件中rk817_pre_init_reg[]表下增加

{RK817_GPIO_INT_CFG, 0x1C, 0x1C},

static const struct rk808_reg_data rk817_pre_init_reg[] = {

{RK817_SYS_CFG(3), RK817_SLPPOL_MSK, RK817_SLPPOL_L},

{RK817_RTC_CTRL_REG, RTC_STOP, RTC_STOP},

{RK817_GPIO_INT_CFG, RK817_INT_POL_MSK, RK817_INT_POL_L},

{RK817_GPIO_INT_CFG, 0x1C, 0x1C},

{RK817_SYS_CFG(1), RK817_HOTDIE_TEMP_MSK | RK817_TSD_TEMP_MSK,

RK817_HOTDIE_105 | RK817_TSD_140},

};

关机时置低TS管脚的方法:

./kernel/drivers/mfd/rk808.c文件中rk817_shutdown_prepare()函数中增加

ret = regmap_update_bits(rk808->regmap,
             RK817_GPIO_INT_CFG,
             0x08, 0x00);

加载/* pmic sleep shutdown function */之前

static void rk817_shutdown_prepare(void)

{

int ret;

struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);

/* close rtc int when power off */
regmap_update_bits(rk808->regmap,
		   RK817_INT_STS_MSK_REG0,
		   (0x3 << 5), (0x3 << 5));
regmap_update_bits(rk808->regmap,
		   RK817_RTC_INT_REG,
		   (0x3 << 2), (0x0 << 2));

if (rk808->pins && rk808->pins->p && rk808->pins->power_off) {
	ret = regmap_update_bits(rk808->regmap,
				 RK817_SYS_CFG(3),
				 RK817_SLPPIN_FUNC_MSK,
				 SLPPIN_NULL_FUN);
	if (ret) {
		pr_err("shutdown: config SLPPIN_NULL_FUN error!\n");
	}

	ret = regmap_update_bits(rk808->regmap,
				 RK817_SYS_CFG(3),
				 RK817_SLPPOL_MSK,
				 RK817_SLPPOL_H);
	if (ret) {
		pr_err("shutdown: config RK817_SLPPOL_H error!\n");
	}
	ret = pinctrl_select_state(rk808->pins->p,
				   rk808->pins->power_off);
	if (ret)
		pr_info("%s:failed to activate pwroff state\n",
			__func__);
}

ret = regmap_update_bits(rk808->regmap,
			 RK817_GPIO_INT_CFG,
			 0x08, 0x00);
/* pmic sleep shutdown function */
ret = regmap_update_bits(rk808->regmap,
			 RK817_SYS_CFG(3),
			 RK817_SLPPIN_FUNC_MSK, SLPPIN_DN_FUN);
if (ret)
	dev_err(&rk808_i2c_client->dev, "Failed to shutdown device!\n");
/* pmic need the SCL clock to synchronize register */
mdelay(2);

}

因为开机时已将bit4,bit2置1,所以关机时只需将bit3置0。

原作者:火柴棍mcu

更多回帖

发帖
×
20
完善资料,
赚取积分