Nico Huber submitted this change.

View Change

Approvals: Nico Huber: Verified Angel Pons: Looks good to me, approved
gma bxt panel: Correct panel backlight handling

Change-Id: Icfad261fb4d5ff478974948c0148880c5b8cb40c
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/c/libgfxinit/+/38265
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
---
M common/hw-gfx-gma-config.ads.template
M common/hw-gfx-gma-panel.adb
M common/hw-gfx-gma-panel.ads
3 files changed, 40 insertions(+), 19 deletions(-)

diff --git a/common/hw-gfx-gma-config.ads.template b/common/hw-gfx-gma-config.ads.template
index 01a67c1..39fa825 100644
--- a/common/hw-gfx-gma-config.ads.template
+++ b/common/hw-gfx-gma-config.ads.template
@@ -182,6 +182,7 @@
Use_PP_VDD_Override : <genbool> := Up_To_Ironlake;
Has_PCH_Panel_Power : <genbool> := Ironlake_On;
Has_PP_Divisor_Reg : <genbool> := not Gen_Broxton;
+ Has_New_Backlight_Control : <genbool> := Gen_Broxton;

----------- PCH/FDI: ---------
Has_PCH : <genbool> := not Gen_Broxton and not Gen_G45;
diff --git a/common/hw-gfx-gma-panel.adb b/common/hw-gfx-gma-panel.adb
index 1cd0d55..3d6b342 100644
--- a/common/hw-gfx-gma-panel.adb
+++ b/common/hw-gfx-gma-panel.adb
@@ -155,8 +155,11 @@
PCH_BLC_PWM_CTL1_PHASE_IN_INCREMENT : constant := 16#00_00ff# * 2 ** 0;

PCH_BLC_PWM_CTL2_BL_MOD_FREQ_MASK : constant := 16#00_ffff# * 2 ** 16;
+ PCH_BLC_PWM_CTL2_BL_MOD_FREQ_SHIFT : constant := 16;
PCH_BLC_PWM_CTL2_BL_DUTY_CYC_MASK : constant := 16#00_ffff# * 2 ** 0;

+ BXT_BLC_PWM_CTL_ENABLE : constant := 16#00_0001# * 2 ** 31;
+
----------------------------------------------------------------------------

procedure Static_Init
@@ -380,9 +383,15 @@

pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

- Registers.Set_Mask
- (Register => Panel_PP_Regs.CONTROL,
- Mask => PCH_PP_CONTROL_BACKLIGHT_ENABLE);
+ if Config.Has_New_Backlight_Control then
+ Registers.Set_Mask
+ (Register => Registers.BXT_BLC_PWM_CTL_1,
+ Mask => BXT_BLC_PWM_CTL_ENABLE);
+ else
+ Registers.Set_Mask
+ (Register => Panel_PP_Regs.CONTROL,
+ Mask => PCH_PP_CONTROL_BACKLIGHT_ENABLE);
+ end if;
end Backlight_On;

procedure Backlight_Off (Panel : Panel_Control) is
@@ -393,12 +402,18 @@

pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

- Registers.Unset_Mask
- (Register => Panel_PP_Regs.CONTROL,
- Mask => PCH_PP_CONTROL_BACKLIGHT_ENABLE);
+ if Config.Has_New_Backlight_Control then
+ Registers.Unset_Mask
+ (Register => Registers.BXT_BLC_PWM_CTL_1,
+ Mask => BXT_BLC_PWM_CTL_ENABLE);
+ else
+ Registers.Unset_Mask
+ (Register => Panel_PP_Regs.CONTROL,
+ Mask => PCH_PP_CONTROL_BACKLIGHT_ENABLE);
+ end if;
end Backlight_Off;

- procedure Set_Backlight (Panel : Panel_Control; Level : Word16) is
+ procedure Set_Backlight (Panel : Panel_Control; Level : Word32) is
begin
if Panel not in Valid_Panels then
return;
@@ -406,15 +421,17 @@

pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

- Registers.Unset_And_Set_Mask
- (Register => Registers.BLC_PWM_CPU_CTL,
- Mask_Unset => CPU_BLC_PWM_DATA_BL_DUTY_CYC_MASK,
- Mask_Set => Word32 (Level));
+ if Config.Has_New_Backlight_Control then
+ Registers.Write (Registers.BXT_BLC_PWM_DUTY_1, Level);
+ else
+ Registers.Unset_And_Set_Mask
+ (Register => Registers.BLC_PWM_CPU_CTL,
+ Mask_Unset => CPU_BLC_PWM_DATA_BL_DUTY_CYC_MASK,
+ Mask_Set => Level);
+ end if;
end Set_Backlight;

- procedure Get_Max_Backlight (Panel : Panel_Control; Level : out Word16)
- is
- Reg : Word32;
+ procedure Get_Max_Backlight (Panel : Panel_Control; Level : out Word32) is
begin
if Panel not in Valid_Panels then
Level := 0;
@@ -423,9 +440,12 @@

pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));

- Registers.Read (Registers.BLC_PWM_PCH_CTL2, Reg);
- Level := Word16
- (Shift_Right (Reg and PCH_BLC_PWM_CTL2_BL_MOD_FREQ_MASK, 16));
+ if Config.Has_New_Backlight_Control then
+ Registers.Read (Registers.BXT_BLC_PWM_FREQ_1, Level);
+ else
+ Registers.Read (Registers.BLC_PWM_PCH_CTL2, Level);
+ Level := Shift_Right (Level, PCH_BLC_PWM_CTL2_BL_MOD_FREQ_SHIFT);
+ end if;
end Get_Max_Backlight;

end HW.GFX.GMA.Panel;
diff --git a/common/hw-gfx-gma-panel.ads b/common/hw-gfx-gma-panel.ads
index baf47f7..2a97f0e 100644
--- a/common/hw-gfx-gma-panel.ads
+++ b/common/hw-gfx-gma-panel.ads
@@ -54,8 +54,8 @@

procedure Backlight_Off (Panel : Panel_Control);

- procedure Set_Backlight (Panel : Panel_Control; Level : Word16);
+ procedure Set_Backlight (Panel : Panel_Control; Level : Word32);

- procedure Get_Max_Backlight (Panel : Panel_Control; Level : out Word16);
+ procedure Get_Max_Backlight (Panel : Panel_Control; Level : out Word32);

end HW.GFX.GMA.Panel;

To view, visit change 38265. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-Change-Id: Icfad261fb4d5ff478974948c0148880c5b8cb40c
Gerrit-Change-Number: 38265
Gerrit-PatchSet: 3
Gerrit-Owner: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-CC: Paul Menzel <paulepanter@users.sourceforge.net>
Gerrit-MessageType: merged