RK 平台下TPS65910 PMU 模拟IO口方法

本文介绍了如何使用 TPS65910 芯片配置 LDO5 的电压参数,并展示了通过 Linux 驱动进行电压设置和开关操作的具体实现。文中详细解释了结构体 regulator_init_data 的配置方法,包括设置电压范围、操作掩码等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

\kernel\arch\arm\mach-rk2928\board-rk2928-sdk-tps65910.c

static struct regulator_init_data tps65910_ldo5 = {
.constraints = {
.name           = "VAUX33",
.min_uV = 1800000,
.max_uV = 3300000,
.apply_uV = 1,
.always_on      = 0, //由于在头文件中已经赋值,那么在此处需要重新赋值为0
.valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE,
.valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL,

},
.num_consumer_supplies = ARRAY_SIZE(tps65910_ldo5_supply),
.consumer_supplies =  tps65910_ldo5_supply,
};


如下结构体在 #include <linux/regulator/machine.h>文件中,always_on:1; /* regulator never off when system is on */文件中已经赋值,赋的值为1,说明将这个电源不可控制
struct regulation_constraints {

char *name;

/* voltage output range (inclusive) - for voltage control */
int min_uV;
int max_uV;

int uV_offset;

/* current output range (inclusive) - for current control */
int min_uA;
int max_uA;

/* valid regulator operating modes for this machine */
unsigned int valid_modes_mask;

/* valid operations for regulator on this machine */
unsigned int valid_ops_mask;

/* regulator input voltage - only if supply is another regulator */
int input_uV;

/* regulator suspend states for global PMIC STANDBY/HIBERNATE */
struct regulator_state state_disk;
struct regulator_state state_mem;
struct regulator_state state_standby;
suspend_state_t initial_state; /* suspend state to set at init */

/* mode to set on startup */
unsigned int initial_mode;

/* constraint flags */
unsigned always_on:1; /* regulator never off when system is on */这个是系统电压永远打开,在头文件中已经赋值
unsigned boot_on:1; /* bootloader/firmware enabled regulator */
unsigned apply_uV:1; /* apply uV constraint if min == max */
};





#include <linux/mfd/tps65910.h>
#include <linux/regulator/machine.h>
struct regulator *ldo;

注意:每次关或打电LDO时,必须先用regulator_get获取LDO,然后再对LDO进行关闭或打开操作
do
{
ldo = regulator_get(NULL, "vaux33"); //vcc_tp
if (ldo== NULL || IS_ERR(ldo)){
printk("get ~~~~~~~~~~~~~~~~~~~~~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!ldo failed!\n");
   }
       regulator_set_voltage(ldo, 3300000, 3300000); 
regulator_enable(ldo);
printk("%s  _tp=%dmV end\n", __func__, regulator_get_voltage(ldo));
regulator_put(ldo);
msleep(200);
ldo = regulator_get(NULL, "vaux33"); //vcc_tp
if (ldo== NULL || IS_ERR(ldo)){
printk("get ~~~~~~~~~~~~~~~~~~~~~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!ldo failed!\n");
   }
while(regulator_is_enabled(ldo)>0)
{
regulator_disable(ldo);
   printk("get ~~~~~~~~~~~~~~~~~~~~~!!!!!!!!!!!!!!!!!!!! !!!!!!!!!fdsfasdassassssafsfsled!\n");
           }
regulator_put(ldo);     
msleep(200); 
}while(1);





printk("mitech_wangrencai active_low = %d\n", data->active_low);
if (data->active_low)
{
enable_vibra_VAUX33(1);
}
else
{
enable_vibra_VAUX33(0);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值