|
一、节点信息:
vcamio节点位置:
/sys/class/regulator/regulator.17
cat state 可以参看当前系统电源的使能情况:
PDA:/sys/class/regulator/regulator.17 # cat state
enabled
PDA:/sys/class/regulator/regulator.17 # cat state
disabled
二、dts配置:
- 1、mt6765.dts
- kd_camera_hw1: kd_camera_hw1@1a040000 {
- compatible = "mediatek,camera_hw";
- 2、cust_mt6765_camera.dtsi
- &kd_camera_hw1 {
- ....
- cam0_vcamio-supply = <&mt_pmic_vcamio_ldo_reg>;
- ....
- };
- 3、mt6357.dtsi
- mt_pmic_vcamio_ldo_reg: ldo_vcamio {
- regulator-name = "vcamio";
- regulator-min-microvolt = <1800000>;
- regulator-max-microvolt = <1800000>;
- regulator-enable-ramp-delay = <264>;
- };
复制代码
三、定义:
- #include <linux/device.h>
- #if defined(CONFIG_LED_H196XO)
- extern struct device *gimgsensor_device;
- extern int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
- extern struct regulator *regulator_get(struct device *dev, const char *id);
- struct regulator *pregulator;
- #endif
复制代码
四、代码控制:
- #if defined(CONFIG_LED_H196XO)
- struct device *pdevice = gimgsensor_device;
- #endif
- pdevice->of_node = of_find_compatible_node(NULL, NULL, "mediatek,camera_hw");
- pregulator = regulator_get(pdevice, "cam0_vcamio"); //cam0_vcamd,cam0_vcama 看相机对应的是pmic控制,就能控制到pmic对应电源
-
- if((strcmp(cust->name, "vcamio_test") == 0)){
- if (level == 0) {
- printk("huangxuan set vcamio to 0V\n");
- if (regulator_is_enabled(pregulator)){ //如果电源打开,再关闭。这里参考camera上电部分regulator.c
- if (regulator_disable(pregulator)) {
- pr_err("[regulator]fail to regulator_disable!\n");
- }
- }
-
- }else{
- printk("huangxuan set vcamio to 1.8V\n");
- if (regulator_set_voltage(pregulator, 1800000, 1800000))
- pr_err("huangxuan [regulator]fail to regulator_set_voltage vcamio to 1.8V\n");
- regulator_enable(pregulator);
- }
- }
复制代码
五、实例(新增vcamio控制节点):
简单的加在leds灯光系统架构里,引入的一个vcamio_test节点,写0关闭vcamio,非0打开。代码架构如下:
1、dts定义:arch/arm64/boot/dts/mediatek/AGN_H196XO_M110.dts
- + led12:led@12 {
- + compatible = "mediatek,vcamio_test";
- + led_mode = <3>;
- + pwm_config = <0 0 0 0 0>;
- + };
复制代码 2、drivers/misc/mediatek/leds/mt6765/Makefile
- ccflags-y += -I$(srctree)/drivers/misc/mediatek/video/include
- +ccflags-y += -I$(srctree)/drivers/misc/mediatek/imgsensor/src/common/v1
复制代码 3、drivers/misc/mediatek/leds/mt6765/mtk_leds.c
- @@ -14,6 +14,8 @@
- #include <linux/gpio.h>
- #include <linux/of_device.h>
- #include <linux/of_gpio.h>
- +#include <linux/regulator/consumer.h>
- +#include <linux/device.h>
-
- #ifdef CONFIG_OF
- #include <linux/of.h>
- @@ -101,6 +103,14 @@ void mt_pwm_disable(u32 pwm_no, u8 pmic_pad)
-
- struct wakeup_source leds_suspend_lock;
-
- +#if defined(CONFIG_LED_H196XO)
- +extern struct device *gimgsensor_device;
- +extern int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
- +extern struct regulator *regulator_get(struct device *dev, const char *id);
- +struct regulator *pregulator;
- +#endif
- +
- +
- char *leds_name[MT65XX_LED_TYPE_TOTAL] = {
- "red",
- "green",
- @@ -112,7 +122,9 @@ void mt_pwm_disable(u32 pwm_no, u8 pmic_pad)
- #if defined(CONFIG_LED_H170XO) || defined(CONFIG_LED_H196XO)
- "red_scan",
- "green_scan",
- - "blue_scan"
- + "blue_scan",
- + "vcamio_test"
- +
- #endif
- #if defined(CONFIG_LED_H188XO)
- "red_scan",
- @@ -879,6 +891,9 @@ int mt_brightness_set_pmic_duty_store(u32 level, u32 div)
- int mt_mt65xx_led_set_cust(struct cust_mt65xx_led *cust, int level)
- {
- struct nled_setting led_tmp_setting = { 0, 0, 0 };
- +#if defined(CONFIG_LED_H196XO)
- + struct device *pdevice = gimgsensor_device;
- +#endif
- int tmp_level = level;
- static bool button_flag;
- unsigned int BacklightLevelSupport =
- @@ -977,6 +992,23 @@ int mt_mt65xx_led_set_cust(struct cust_mt65xx_led *cust, int level)
- button_flag = true;
- }
- }
- +
- +
- + pdevice->of_node = of_find_compatible_node(NULL, NULL, "mediatek,camera_hw");
- + pregulator = regulator_get(pdevice, "cam0_vcamio");
- +
- + if((strcmp(cust->name, "vcamio_test") == 0)){
- + if (level == 0) {
- + printk("huangxuan set vcamio to 0V\n");
- + regulator_disable(pregulator);
- + }else{
- + printk("huangxuan set vcamio to 1.8V\n");
- + if (regulator_set_voltage(pregulator, 1800000, 1800000))
- + pr_err("huangxuan [regulator]fail to regulator_set_voltage vcamio to 1.8V\n");
- + regulator_enable(pregulator);
- + }
- +
- + }
- #endif
-
- return mt_brightness_set_pmic(cust->data, level, bl_div_hal);
复制代码 4、drivers/misc/mediatek/leds/mt6765/mtk_leds_sw.h
- @@ -30,6 +30,8 @@ enum mt65xx_led_type {
- MT65XX_LED_TYPE_RED_SCAN,
- MT65XX_LED_TYPE_GREEN_SCAN,
- MT65XX_LED_TYPE_BLUE_SCAN,
- + MT65XX_LED_TYPE_VCAMIO_TEST,
- +
- #endif
复制代码
|
|