test VCC_TP regulator

This commit is contained in:
zeroway
2016-11-02 10:41:51 +00:00
parent 34d5dcc42d
commit 7172a72592
5 changed files with 33 additions and 1 deletions

View File

@ -1 +0,0 @@
#include "test_pf.dtsi" in you main dts file

View File

@ -0,0 +1,9 @@
# Usage
把dtsi文件包行到所使用的dts里
#include "test_pf.dtsi"
在驱动中如何使用下图中的VCC_TP,详见代码
![VCC_TP](./VCC_TP.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@ -21,17 +21,35 @@
#include <linux/earlysuspend.h> #include <linux/earlysuspend.h>
#endif #endif
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/regulator/consumer.h>
#if 0 #if 0
/ { / {
my_test_node { my_test_node {
compatible = "test_platform"; compatible = "test_platform";
VCC_TP-supply = <&ldo4_reg>;
}; };
}; };
#endif #endif
static struct regulator *supply;
static int test_pf_probe(struct platform_device *pdev) static int test_pf_probe(struct platform_device *pdev)
{ {
int ret;
printk("%s, %d\n", __FUNCTION__, __LINE__); printk("%s, %d\n", __FUNCTION__, __LINE__);
supply = devm_regulator_get(&pdev->dev, "VCC_TP");
if (IS_ERR(supply)) {
printk("regulator get of vdd_ana failed");
ret = PTR_ERR(supply);
supply = NULL;
return -1;
}
/* Enable the regulator */
ret = regulator_enable(supply);
printk("Enable regulator :) ret = %d\n", ret);
return 0; return 0;
} }
@ -42,7 +60,12 @@ static const struct of_device_id test_pf_dt_ids[] = {
static int test_pf_remove(struct platform_device *dev) static int test_pf_remove(struct platform_device *dev)
{ {
int ret;
printk("%s, %d\n", __FUNCTION__, __LINE__); printk("%s, %d\n", __FUNCTION__, __LINE__);
/* Disable the regulator */
ret = regulator_disable(supply);
printk("Disable regulator :( ret = %d\n", ret);
return 0; return 0;
} }

View File

@ -1,5 +1,6 @@
/ { / {
my_test_node { my_test_node {
compatible = "test_platform"; compatible = "test_platform";
VCC_TP-supply = <&ldo4_reg>;
}; };
}; };