MTK6580电源使用(regulator)

2019-07-13 23:07发布

关于MTK6580电源使用
相关的API
    struct regulator *__must_check regulator_get(struct device *dev,const char *id);
    int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
    int __must_check regulator_enable(struct regulator *regulator);
    int regulator_disable(struct regulator *regulator); 在platform_device使用
    struct platform_device {
        ...
        struct device   dev;
        ..
    }; //需要包含的头文件
    #include
    #include
    #include   
    struct regulator *reg_V33_433;
    reg_V33_433 = regulator_get(&pdev->dev,"VGP1");             //get pointer to regulator structure VGP1
    if (IS_ERR(reg_V33_433)) {
        printk("regulator_get() failed! ");
    }    
    ret=regulator_set_voltage(reg_V33_433, 3300000, 3300000);  // set 3.3v
    if (ret)
        printk("regulator_set_voltage() failed! ");
    ret=regulator_enable(reg_V33_433);                             //open power
    if (ret)
        printk("regulator_enable() failed! ");
             一般使用
struct device *dev
struct regulator *reg_V33_BT;
    if(!(IS_ERR(dev))){
        reg_V33_BT = regulator_get(dev,"VCN_1V8");
    }
    if(reg_V33_BT)
    {
    regulator_set_voltage(reg_V33_BT, 3300000, 3300000);
    regulator_enable(reg_V33_BT);
    }