mirror of
https://github.com/54shady/kernel_drivers_examples.git
synced 2025-08-15 02:39:36 +00:00
test VCC_TP regulator
This commit is contained in:
@ -1 +0,0 @@
|
|||||||
#include "test_pf.dtsi" in you main dts file
|
|
9
debug/platform_driver_test/README.md
Normal file
9
debug/platform_driver_test/README.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Usage
|
||||||
|
|
||||||
|
把dtsi文件包行到所使用的dts里
|
||||||
|
|
||||||
|
#include "test_pf.dtsi"
|
||||||
|
|
||||||
|
在驱动中如何使用下图中的VCC_TP,详见代码
|
||||||
|
|
||||||
|

|
BIN
debug/platform_driver_test/VCC_TP.png
Normal file
BIN
debug/platform_driver_test/VCC_TP.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/ {
|
/ {
|
||||||
my_test_node {
|
my_test_node {
|
||||||
compatible = "test_platform";
|
compatible = "test_platform";
|
||||||
|
VCC_TP-supply = <&ldo4_reg>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user