[coreboot-gerrit] Change in coreboot[master]: nb/intel/gm45: Allow setting backlight pwm frequency from CBFS

Arthur Heymans (Code Review) gerrit at coreboot.org
Mon Apr 3 22:50:03 CEST 2017


Arthur Heymans has uploaded a new change for review. ( https://review.coreboot.org/19090 )

Change subject: nb/intel/gm45: Allow setting backlight pwm frequency from CBFS
......................................................................

nb/intel/gm45: Allow setting backlight pwm frequency from CBFS

This patch allows the user to override the default pwm backlight
frequency using a cbfsfile called "backlight_pwm".
This file can be added using:
"cbfstool coreboot.rom add-int -i $freq_value -n backlight_pwm"

TESTED on Thinkpad X200

Change-Id: I82e90e47ffc42b8d7062af87f6b174cd03445bb7
Signed-off-by: Arthur Heymans <arthur at aheymans.xyz>
---
M src/northbridge/intel/gm45/gma.c
1 file changed, 37 insertions(+), 2 deletions(-)


  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/19090/1

diff --git a/src/northbridge/intel/gm45/gma.c b/src/northbridge/intel/gm45/gma.c
index cbb8451..fa10bb2 100644
--- a/src/northbridge/intel/gm45/gma.c
+++ b/src/northbridge/intel/gm45/gma.c
@@ -15,6 +15,7 @@
  */
 
 #include <arch/io.h>
+#include <cbfs.h>
 #include <console/console.h>
 #include <delay.h>
 #include <device/device.h>
@@ -641,12 +642,37 @@
 		return (blc_mod << 16) | blc_mod;
 }
 
+static int get_pwm_from_cbfs(void)
+{
+	struct cbfsf fh;
+	uint64_t blc_pwm;
+	uint32_t matchraw = CBFS_TYPE_RAW;
+
+	if (!cbfs_boot_locate(&fh, "backlight_pwm", &matchraw)) {
+		if (rdev_readat(&fh.data, &blc_pwm, 0, sizeof(blc_pwm))
+			== sizeof(blc_pwm)) {
+			return (int)blc_pwm;
+		} else {
+			printk(BIOS_ERR, "gma: Error reading blc pwm from CBFS\n");
+		}
+	} else {
+		printk(BIOS_ERR, "gma: 'backlight_pwm' not found in CBFS,"
+			"using default value\n");
+	}
+
+	return -1;
+}
+
+#define MINIMUM_BLC_PWM 50
+
 static void gma_pm_init_post_vbios(struct device *const dev)
 {
 	const struct northbridge_intel_gm45_config *const conf = dev->chip_info;
 
 	u32 reg32;
 	u8 reg8;
+	u16 blc_pwm;
+	int blc_pwm_cbfs;
 
 	/* Setup Panel Power On Delays */
 	reg32 = gtt_read(PP_ON_DELAYS);
@@ -675,13 +701,22 @@
 	/* Enable Backlight  */
 	gtt_write(BLC_PWM_CTL2, (1 << 31));
 	reg8 = 100;
+	blc_pwm_cbfs = get_pwm_from_cbfs();
+	if ((blc_pwm_cbfs < MINIMUM_BLC_PWM) || (blc_pwm_cbfs > 0xffff)) {
+		blc_pwm = conf->pwm_freq;
+		printk(BIOS_DEBUG, "Using default pwm value\n");
+	} else {
+		blc_pwm = blc_pwm_cbfs;
+		printk(BIOS_DEBUG, "Using pwm value from CBFS of %dHz\n", blc_pwm);
+	}
+
 	if (conf->duty_cycle != 0)
 		reg8 = conf->duty_cycle;
-	if (conf->pwm_freq == 0)
+	if (!blc_pwm)
 		gtt_write(BLC_PWM_CTL, 0x06100610);
 	else
 		gtt_write(BLC_PWM_CTL, freq_to_blc_pwm_ctl(dev,
-						conf->pwm_freq,	reg8));
+						blc_pwm, reg8));
 }
 
 static void gma_func0_init(struct device *dev)

-- 
To view, visit https://review.coreboot.org/19090
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I82e90e47ffc42b8d7062af87f6b174cd03445bb7
Gerrit-PatchSet: 1
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Arthur Heymans <arthur at aheymans.xyz>



More information about the coreboot-gerrit mailing list