Hikey960 Spi 调试进阶之番外篇(LDO 设置)  

分享到:

DragonCat
Level 2Admin
注册时间:8年 前
帖子数: 42
2017年6月28日 下午5:54  

我们要在hikey960 上面调试设备,设备怎样供电是我们必须去考虑的首要问题,除了接口选择之外(一般来说设备接口,当你拿到设备以后,其接口都是确定的)。

 

如下是hikey960 power tree,如图:

上图中我们主要关注由pmu 提供的ldo,其余均是固定的,不可控制的。我们现以hikey960 40 pin低速接口中的VOUT11 1V8/2V95 为例进行说明,如下图标注管脚(35)。

经梳理这一管脚连接可知,VOUT11 1V8/2V95 出自PMU(Hi6421v530),如下图红色标注。

现在我的设备需要VOUT11 1V8/2V95 输出3V3, 经查,此管脚对应PMU LDO11

    可知ldo11 可以设置 1V75, 1V8,1V825,2V8,2V85,2V95,3V,3V3, ldo11 可以满足设备供电需求。

 

       目前check pmu代码,发现代码没有释放ldo11,需要修改代码来来支持,修改如下:

 

 

hi6421v530-regulator.c中,可以看到ldo11 可以设置的电压值,如下:

/* HI6421v530 regulators */

 

enum hi6421v530_regulator_id {

 

......

 

/*HI6421V530_LDO11,

 

HI6421V530_LDO12,*/

 

......

 

HI6421V530_NUM_REGULATORS,

 

};

 

 

 

需要修改为:

 

/* HI6421v530 regulators */

 

enum hi6421v530_regulator_id {

 

......

 

HI6421V530_LDO11,

 

/*HI6421V530_LDO12,*/

 

......

 

HI6421V530_NUM_REGULATORS,

 

};

 

 

 

static struct of_regulator_match hi6421v530_regulator_match[] = {

 

......

 

/*HI6421V530_REGULATOR_OF_MATCH(hi6421v530_ldo11, LDO11),

 

HI6421V530_REGULATOR_OF_MATCH(hi6421v530_ldo12, LDO12),*/

 

......

 

};

 

需要修改为:

 

static struct of_regulator_match hi6421v530_regulator_match[] = {

 

......

 

HI6421V530_REGULATOR_OF_MATCH(hi6421v530_ldo11, LDO11),

 

/*HI6421V530_REGULATOR_OF_MATCH(hi6421v530_ldo12, LDO12),*/

 

......

 

};

 

 

 

static struct hi6421v530_regulator_info

 

hi6421v530_regulator_info[HI6421V530_NUM_REGULATORS] = {

 

.....

 

/*HI6421V530_LDO(LDO11, ldo_9_11_12_13_14_voltages, 0x06f, 0x7, 0x06e, 0x2,

 

40000, 0x1, 8000),

 

HI6421V530_LDO(LDO12, ldo_9_11_12_13_14_voltages, 0x071, 0x7, 0x070, 0x2,

 

40000, 0x1, 8000),*/

 

.....

 

};

 

需要修改为

 

static struct hi6421v530_regulator_info

 

hi6421v530_regulator_info[HI6421V530_NUM_REGULATORS] = {

 

.....

 

HI6421V530_LDO(LDO11, ldo_9_11_12_13_14_voltages, 0x06f, 0x7, 0x06e, 0x2,

 

40000, 0x1, 8000),

 

/*HI6421V530_LDO(LDO12, ldo_9_11_12_13_14_voltages, 0x071, 0x7, 0x070, 0x2,

 

40000, 0x1, 8000),*/

 

.....

 

};

 

 

 

还需要修改dts hi3660-hikey960.dts ,支持ldo11,需改如下:

pmic: pmic@fff34000 {

 

compatible = "hisilicon,hi6421-pmic";

 

reg = <0x0 0xfff34000 0x0 0x1000>;

 

interrupt-controller;

 

#interrupt-cells = <2>;

 

 

 

regulators {

 

......

 

+ldo11: LDO11 {

 

+regulator-compatible = "hi6421v530_ldo11";

 

+regulator-name = "LDO11";

 

+regulator-min-microvolt = <1750000>;

 

+regulator-max-microvolt = <3300000>;

 

+regulator-enable-ramp-delay = <120>;

 

+};

 

.....

 

};

 

};

 

};

 

这样系统就支持LDO11了,我们就可以通过接口设置LDO11输出电压啦。

 

 

 

我们下来介绍下regulator的操作接口,如下:

 

1.struct regulator* devm_regulator_get(struct device *dev,const char *id);

 

作用:通过设备树上在设备信息中的设置的供电信息ID来获取使用的ldo

 

例如:我在HI3660.dtsi spi4中配置:

 

spi4: spi@fdf06000 {

 

compatible = "arm,pl022", "arm,primecell";

 

reg = <0x0 0xfdf06000 0x0 0x1000>;

 

#address-cells = <1>;

 

#size-cells = <0>;

 

interrupts = <0 313 4>;

 

clocks = <&crg_ctrl HI3660_CLK_GATE_SPI4>;

 

clock-names = "apb_pclk";

 

pinctrl-names = "default";

 

pinctrl-0 = <&spi4_pmx_func &spi4_cfg_func>;

 

num-cs = <1>;

 

cs-gpios = <&gpio27 2 0>; /*cs : 218*/

 

//status = "disabled";

 

status = "ok";

 

+spidev@0 {

 

+ compatible = "dcb,spidev";

 

+ reg = <0 0>;

+ spi-max-frequency = <9600000>;

 

+ spidev_vdd-supply = <&ldo11>;

 

+};

 

};

 

devm_regulator_get就可以通过spidev_vdd 获取ldo11

 

2.regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);

 

作用:通过设置devm_regulator_get获取的regulator 的电压值,若想设置ldo3V3,则设置 min_uV = max_uV = 3300000

 

 

 

  1. regulator_enable(struct regulator *regulator);

 

作用:使能 devm_regulator_get获取的regulator,这样你的设置就生效啦。

 

 

 

这样pmu ldo11 就可以输出3.3v啦,可以给spi 设备进行供电。

 

 

 

 

 

 

 

 

 

 

 

 


DragonCat liked
回复引用
  
Working

登陆 或者 注册