\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);
}