其他分享
首页 > 其他分享> > 玩转移远SC60 Android开发板------(2)LCD背光控制

玩转移远SC60 Android开发板------(2)LCD背光控制

作者:互联网

SC60 Android开发板
在这里插入图片描述
SC60的背光使用PM_MPP4输出PWM信号来控制背光芯片:
在这里插入图片描述
但是PMU的MPP4脚默认并不是PWM功能,需要修改配置。PWM的设备树节点为:

		pm8953_pwm: qcom,pwms@bc00 {
			status = "Okay";
			compatible = "qcom,qpnp-pwm";
			reg = <0xbc00 0x100>;
			reg-names = "qpnp-lpg-channel-base";
			qcom,channel-id = <0>;
			qcom,supported-sizes = <6>, <9>;
			#pwm-cells = <2>;
			qcom,dtest-line = <2>; // notice: pwm need config DTETS2
			qcom,dtest-output = <2>;
		};

如下修改把MPP4配置为数字输出功能:

&pm8953_mpps {
	/delete-node/ case_therm;
//begin: stone mofify mpp4 for lcd-backlight
	mpp@a300 {
		reg = <0xa300 0x100>;
		com,pin-num = <4>;          /*管脚号*/
		qcom,mode = <1>; 		/* Digital output */
		qcom,invert = <0>; 		/* Disable invert */
		qcom,src-sel = <5>; 		/* DTEST2 ?? */
		qcom,pull = <1>;
		qcom,vin-sel = <3>;		/* VPH_PWR */
		qcom,master-en = <1>; 		/* Enable MPP */
		status = "okay";
	};
//end: stone mofify mpp4 for lcd-backlight
};

这样,在对应的LCD驱动中指定PWM的管脚即可:

&dsi_lead_ili9885a_1080p_video{
	qcom,mdss-dsi-panel-timings-phy-v2 = [23 1e 08 09 05 03 04 a0
		23 1e 08 09 05 03 04 a0
		23 1e 08 09 05 03 04 a0
		23 1e 08 09 05 03 04 a0
		23 1e 08 09 05 03 04 a0];
	//qcom,esd-check-enabled;
	qcom,mdss-dsi-panel-status-check-mode = "reg_read";
	qcom,mdss-dsi-panel-status-command = [06 01 00 01 00 00 02 0a];
	qcom,mdss-dsi-panel-status-command-state = "dsi_hs_mode";
	qcom,mdss-dsi-panel-status-value = <0x08>;
	qcom,mdss-dsi-panel-on-check-value = <0x08>;
	qcom,mdss-dsi-panel-status-read-length = <2>;
	qcom,mdss-dsi-panel-max-error-count = <3>;

	qcom,display-id = "secondary";
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_pwm";
	qcom,mdss-dsi-bl-pmic-pwm-frequency = <25>;
	qcom,mdss-dsi-bl-pmic-bank-select = <0>;
	qcom,mdss-dsi-pwm-gpio = <&pm8953_mpps 4 0>;  //这里指定PWM管脚MPP4
	qcom,5v-boost-gpio = <&tlmm 0 0>;
};

要注意,8953上默认是把MPP4脚作为温度采样功能配置了,需要修改掉:

			case_therm {
				cas_therm_default: cas_therm_default {
					pins = "mpp4";
					function = "analog";
					input-enable;
					qcom,amux-route = <3>;
				};
			};
			
chan@13 {
				label = "case_therm";
				reg = <0x13>;
				qcom,decimation = <0>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "ratiometric";
				qcom,scale-function = <2>;
				qcom,hw-settle-time = <2>;
				qcom,fast-avg-setup = <0>;
				qcom,vadc-thermal-node;
			};

如果要在LK阶段打开PWM,参考如下代码修改LK中的背光函数即可:

 static int pwm_backlight_ctrl(uint8_t enable)
 {
+//begin: stone added for pm8953-mpp4 as lcd-backlight
+#ifdef FEATURE_SC60
+	struct pm8x41_mpp mpp;
+	int rc;
+
+	mpp.base = PM8x41_MMP4_BASE;
+	mpp.vin = MPP_VIN3;
+
+	if(enable) {
+		pm_pwm_enable(false);
+		rc = pm_pwm_config(PWM_DUTY_US, PWM_PERIOD_US);
+		if (rc < 0)
+			mpp.mode = MPP_HIGH;
+		else {
+			mpp.mode = MPP_DTEST2;
+			pm_pwm_enable(true);
+		}
+		pm8x41_config_output_mpp(&mpp);
+		pm8x41_enable_mpp(&mpp, MPP_ENABLE);
+		//pm8x41_reg_write(0x1BCD0, 0xA5);
+		//pm8x41_reg_write(0x1BCE3, 0x02);//notic: config pwm choose dtest2
+	} else {
+		pm_pwm_enable(false);
+		pm8x41_enable_mpp(&mpp, MPP_DISABLE);
+	}
+	mdelay(20);
+#else
……
#endif
}

标签:开发板,LCD,qcom,mpp,dsi,------,mdss,pwm,panel
来源: https://blog.csdn.net/cornerstone1/article/details/112863060