本文主要是介绍SDM660平台PWM配置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
概述:高通sdm660平台代码默认配置为WLED,支持OLED,而我们的硬件设置为PWM,刚开始配置,我直接让跑了wled,但并没有输出,当手动拉高pwm输出,屏可以正常显示,所以就需要配置pwm,分为xbl和kernel两个阶段的配置。
1、xbl配置
根据硬件,两个控制引脚背光使能gpio76和PWM(pm660a_gpio6),首先我们需要将gpio6复用为pwm,另外,xbl采用了lpg模式控制背光(lpg=pwm),添加如下:
diff --git a/boot_images/QcomPkg/Sdm660Pkg/Library/MDPPlatformLib/MDPPlatformLib.c b/boot_images/QcomPkg/Sdm660Pkg/Library/MDPPlatformLib/MDPPlatformLib.c
index 874e14d90..221127074 100755
--- a/boot_images/QcomPkg/Sdm660Pkg/Library/MDPPlatformLib/MDPPlatformLib.c
+++ b/boot_images/QcomPkg/Sdm660Pkg/Library/MDPPlatformLib/MDPPlatformLib.c
@@ -65,6 +65,7 @@ extern "C" {*/#define CDP_DISP_RESET_GPIO 53 //GPIO number for LCD0_RESET_N#define CDP_DISP_TE_GPIO 59 //GPIO number for TE
+#define CDP_DISP_BL_EN_GPIO 76/* Helper macro for supported panels table entry PanelInfoType */#define PANEL_CREATE_ENTRY(_name_,_id_,_dtlable_,_interface_,_xml_,_cfg_,_pll_, _top0_, _top1_, _top2_) \
@@ -535,7 +536,7 @@ const static int8 CM546B1_1080p_video_xmldata[] ="</DSITermSequence>\n""<Group id='Backlight Configuration'>"" <BacklightType units='MDP_Panel_BacklightType'>1</BacklightType>\n"
-" <BacklightPmicControlType units='MDP_PmicBacklightControlType'>2</BacklightPmicControlType>\n"
+" <BacklightPmicControlType units='MDP_PmicBacklightControlType'>1</BacklightPmicControlType>\n"" <DisplayResetInfo>0 10 10000 10000 0</DisplayResetInfo>\n""</Group>\n";/*added by cyl for lcd bring up JIRA:MC0310-2 --end*/
@@ -2140,6 +2141,11 @@ static MDP_Status Panel_CDP_PowerUp(MDP_Display_IDType eDisplayId, Panel_PowerCt{DEBUG((EFI_D_WARN, "DisplayDxe: Configure GPIO %d for TE line failed %d\n", CDP_DISP_TE_GPIO));}
+
+ TLMMProtocol->ConfigGpio((UINT32)EFI_GPIO_CFG(CDP_DISP_BL_EN_GPIO, 0, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_2MA), TLMM_GPIO_ENABLE);
+ TLMMProtocol->GpioOut((UINT32)EFI_GPIO_CFG(CDP_DISP_BL_EN_GPIO, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA), GPIO_HIGH_VALUE);}return Status;
@@ -2497,6 +2503,45 @@ static MDP_Status Panel_CDP_BacklightLevel(MDP_Display_IDType eDisplayId, Panel_}}break;
+ case MDP_PMIC_BACKLIGHT_CONTROLTYPE_LPG:
+ {
+ EFI_QCOM_PMIC_LPG_PROTOCOL *PmicLpgProtocol = NULL;
+ EFI_QCOM_PMIC_GPIO_PROTOCOL *PmicGpioProtocol = NULL;
+
+ if (EFI_SUCCESS != gBS->LocateProtocol(&gQcomPmicGpioProtocolGuid, NULL, (VOID **)&PmicGpioProtocol))
+ {
+ Status = MDP_STATUS_NO_RESOURCES;
+ }
+ else
+ {
+ Status = PmicGpioProtocol->ConfigDigitalOutput(PMIC_PMI_DEV_INDEX,
+ EFI_PM_GPIO_6,
+ EFI_PM_GPIO_OUT_BUFFER_CONFIG_CMOS,
+ EFI_PM_GPIO_VIN0,
+ EFI_PM_GPIO_SOURCE_SPECIAL_FUNCTION1,
+ EFI_PM_GPIO_OUT_BUFFER_LOW,
+ 1);
+ if (EFI_SUCCESS != Status)
+ {
+ Status = MDP_STATUS_FAILED;
+ }
+ }
+
+ if (EFI_SUCCESS != gBS->LocateProtocol(&gQcomPmicLpgProtocolGuid, NULL, (VOID **)&PmicLpgProtocol))
+ {
+ Status = MDP_STATUS_NO_RESOURCES;
+ }
+ else
+ {
+ if (EFI_SUCCESS != PmicLpgProtocol->LpgConfig(PMIC_PMI_DEV_INDEX, EFI_PM_LPG_CHAN_4, 102, EFI_PM_LPG_PWM_PRE_DIV_6, EFI_PM_LPG_PWM_FREQ_EXPO_7, EFI_PM_LPG_PWM_CLOCK_19_2_MHZ
, EFI_PM_LPG_PWM_9BIT))
+ {
+ DEBUG((EFI_D_ERROR, "LPG Protocol LpgConfig failed\n"));
+ }
+ }
+ }
+ break;default:break;}
diff --git a/boot_images/QcomPkg/Sdm660Pkg/Library/MDPPlatformLib/MDPPlatformLib.inf b/boot_images/QcomPkg/Sdm660Pkg/Library/MDPPlatformLib/MDPPlatformLib.inf
index 48a53320e..67f9a82bf 100755
--- a/boot_images/QcomPkg/Sdm660Pkg/Library/MDPPlatformLib/MDPPlatformLib.inf
+++ b/boot_images/QcomPkg/Sdm660Pkg/Library/MDPPlatformLib/MDPPlatformLib.inf
@@ -38,12 +38,14 @@[Protocols]gEfiPlatformInfoProtocolGuidgEfiChipInfoProtocolGuid
+ gQcomPmicLpgProtocolGuidgQcomPmicWledProtocolGuidgQcomPmicIbbProtocolGuidgQcomPmicLabProtocolGuidgQcomPmicVersionProtocolGuidgQcomPmicLcdbProtocolGuidgQcomPmicOledbProtocolGuid
+ gQcomPmicGpioProtocolGuidgEfiTLMMProtocolGuid
lpg模式配置中参数说明:
PmicLpgProtocol->LpgConfig(PMIC_PMI_DEV_INDEX, EFI_PM_LPG_CHAN_4, 102, EFI_PM_LPG_PWM_PRE_DIV_6, EFI_PM_LPG_PWM_FREQ_EXPO_7, EFI_PM_LPG_PWM_CLOCK_19_2_MHZ, EFI_PM_LPG_PWM_9BIT)
PMIC_PMI_DEV_INDEX:PMIC接口设备(LCD / OLED)这里配置为1
EFI_PM_LPG_CHAN_4 :lpg通道,由所接gpio决定(芯片手册中可查看),选择channel4
EFI_PM_LPG_PWM_PRE_DIV_6 :脉宽调制前置分频器值
EFI_PM_LPG_PWM_FREQ_EXPO_7:LPG脉宽调制频率指数值
EFI_PM_LPG_PWM_CLOCK_19_2_MHZ:脉宽调制时钟
EFI_PM_LPG_PWM_9BIT:脉宽调制比特大小
这里如果想配置PWM,如下:
+ uint32 uWLEDValue = (0x1FF * pBacklightConfig->uLevel) / 100; // Calculate duty cycle based on 12 bit mode
+
+ eLocalStatus = PMICPWMProtocol->PwmConfig(0,
+ EFI_PM_PWM_RSRC_PWM_1,
+ uWLEDValue,
+ 1,
+ 2,
+ EFI_PM_PWM_CLK_19_2_MHZ,
+ EFI_PM_PWM_SIZE_9BIT);
2、kernel配置
kernel配置如xbl,首先配置了gpio6的func,设备树添加pwms,驱动中通过of_pwm_get(np, NULL)获取设备树信息,然后通过pwm_config()函数即可调用。
diff --git a/fibo/common/kernel/msm-4.19/arch/arm64/boot/dts/qcom/sc218-evk/pm660l.dtsi b/fibo/common/kernel/msm-4.19/arch/arm64/boot/dts/qcom/sc218-evk/pm660l.dtsi
index e5fa849ac..255b5d002 100755
--- a/fibo/common/kernel/msm-4.19/arch/arm64/boot/dts/qcom/sc218-evk/pm660l.dtsi
+++ b/fibo/common/kernel/msm-4.19/arch/arm64/boot/dts/qcom/sc218-evk/pm660l.dtsi
@@ -58,6 +58,18 @@"pm660l_gpio11", "pm660l_gpio12";gpio-controller;#gpio-cells = <2>;
+
+ pwm_bl {
+ pwm_bl_default: pwm_bl_default {
+ pins = "gpio6";
+ function = "func1";
+ bias-disable;
+ power-source = <0>;
+ output-low;
+ qcom,drive-strength = <3>;
+ drive-push-pull;
+ };
+ };};};diff --git a/fibo/common/kernel/msm-4.19/arch/arm64/boot/dts/qcom/sc218-evk/sdm660-mtp.dtsi b/fibo/common/kernel/msm-4.19/arch/arm64/boot/dts/qcom/sc218-evk/sdm660-mtp.dtsi
index e24afcc00..eee65bee1 100755
--- a/fibo/common/kernel/msm-4.19/arch/arm64/boot/dts/qcom/sc218-evk/sdm660-mtp.dtsi
+++ b/fibo/common/kernel/msm-4.19/arch/arm64/boot/dts/qcom/sc218-evk/sdm660-mtp.dtsi
@@ -119,10 +119,11 @@&mdss_dsi0 {qcom,dsi-pref-prim-pan = <&dsi_CM546B1_1080p_video>;pinctrl-names = "mdss_default", "mdss_sleep";
- pinctrl-0 = <&mdss_dsi_active &mdss_te_active>;
+ pinctrl-0 = <&mdss_dsi_active &mdss_te_active &pwm_bl_default>;pinctrl-1 = <&mdss_dsi_suspend &mdss_te_suspend>;qcom,platform-reset-gpio = <&tlmm 53 0>;qcom,platform-te-gpio = <&tlmm 59 0>;
+ qcom,platform-bklight-en-gpio = <&tlmm 76 0>;};@@ -188,9 +189,13 @@&dsi_CM546B1_1080p_video {
- qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
- qcom,mdss-dsi-bl-min-level = <1>;
- qcom,mdss-dsi-bl-max-level = <4095>;
+ qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_pwm";
+ qcom,mdss-dsi-bl-pwm-pmi;
+ pwms = <&pm660l_pwm 0 1000000>;
+ qcom,bl-pmic-pwm-period-usecs = <100>;
+ qcom,mdss-dsi-bl-pmic-pwm-frequency = <1000000>;
+ qcom,mdss-dsi-bl-min-level = <1>;
+ qcom,mdss-dsi-bl-max-level = <4095>;qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;};
参数说明:
pwms = <&pm660l_pwm 0 1000000>;
第一个参数 表示此背光接在 pm660l_pwm 上;
第二个参数 表示 index 为 0,pm660l_pwm下只有 1个 pwm,所以填 0
第三个参数 表示周期为 1000000ns(1ms)
3、pwm背光简单debug
cd pwmchip3
echo 0 > export
echo 1000000 > period
echo 500000 > duty_cycle
echo 1 > enable //背光可亮
这篇关于SDM660平台PWM配置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!