[coreboot-gerrit] Change in ...coreboot[master]: [WIP]mb/intel/x200: Add data.vbt

Arthur Heymans (Code Review) gerrit at coreboot.org
Wed Nov 28 17:29:49 CET 2018


Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/29904


Change subject: [WIP]mb/intel/x200: Add data.vbt
......................................................................

[WIP]mb/intel/x200: Add data.vbt

There are 2 vendor BIOS's for the Lenovo X200 with the difference being the
settings in the VBT blob to accommodate different backlight frequencies.
Linux however sticks with the setting set by the firmware.

Change-Id: I4c4a7011ce03cdd511fa2e2160c2f006ba2707ba
Signed-off-by: Arthur Heymans <arthur at aheymans.xyz>
---
M src/mainboard/lenovo/x200/Kconfig
M src/mainboard/lenovo/x200/Makefile.inc
M src/mainboard/lenovo/x200/blc.c
A src/mainboard/lenovo/x200/data_ccfl.vbt
A src/mainboard/lenovo/x200/data_led.vbt
5 files changed, 51 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/04/29904/1

diff --git a/src/mainboard/lenovo/x200/Kconfig b/src/mainboard/lenovo/x200/Kconfig
index 51a08e8..6aa2f9b 100644
--- a/src/mainboard/lenovo/x200/Kconfig
+++ b/src/mainboard/lenovo/x200/Kconfig
@@ -22,6 +22,7 @@
 	select SUPERIO_NSC_PC87382
 	select DRIVERS_LENOVO_WACOM
 	select MAINBOARD_HAS_LIBGFXINIT
+#	select INTEL_GMA_HAVE_VBT
 
 config MAINBOARD_DIR
 	string
diff --git a/src/mainboard/lenovo/x200/Makefile.inc b/src/mainboard/lenovo/x200/Makefile.inc
index c10bc70..3a86aa7 100644
--- a/src/mainboard/lenovo/x200/Makefile.inc
+++ b/src/mainboard/lenovo/x200/Makefile.inc
@@ -19,3 +19,12 @@
 romstage-y += gpio.c
 
 ramstage-$(CONFIG_MAINBOARD_USE_LIBGFXINIT) += gma-mainboard.ads
+
+add_vbt_to_cbfs= \
+	$(eval cbfs-files-y += $1) \
+	$(eval $1-file := $2) \
+	$(eval $1-type := raw) \
+        $(eval $1-compression := lzma)
+
+$(call add_vbt_to_cbfs, data_ccfl.vbt, data_ccfl.vbt)
+$(call add_vbt_to_cbfs, data_led.vbt, data_led.vbt)
\ No newline at end of file
diff --git a/src/mainboard/lenovo/x200/blc.c b/src/mainboard/lenovo/x200/blc.c
index 3f8aadb..e764602 100644
--- a/src/mainboard/lenovo/x200/blc.c
+++ b/src/mainboard/lenovo/x200/blc.c
@@ -13,9 +13,14 @@
  * GNU General Public License for more details.
  */
 
+#include <device/pci_ops.h>
+#include <device/pci_def.h>
 #include <stdint.h>
 #include <commonlib/helpers.h>
+#include <console/console.h>
 #include <northbridge/intel/gm45/gm45.h>
+#include <drivers/intel/gma/i915_reg.h>
+#include <drivers/intel/gma/opregion.h>
 
 static const struct blc_pwm_t blc_entries[] = {
 	/* corrected to 320MHz CDClk, vendor set 753; works fine at both: */
@@ -43,3 +48,39 @@
 	*entries = blc_entries;
 	return ARRAY_SIZE(blc_entries);
 }
+
+static u32 get_cdclk(struct device *const dev)
+{
+	const u16 cdclk_sel =
+		pci_read_config16(dev, GCFGC_OFFSET) & GCFGC_CD_MASK;
+	switch (MCHBAR8(HPLLVCO_MCHBAR) & 0x7) {
+	case VCO_2666:
+	case VCO_4000:
+	case VCO_5333:
+		return cdclk_sel ? 333333333 : 222222222;
+	case VCO_3200:
+		return cdclk_sel ? 320000000 : 228571429;
+	default:
+		printk(BIOS_WARNING,
+		       "Unknown VCO frequency, using default cdclk.\n");
+		return 222222222;
+	}
+}
+
+static u32 blc_pwm_ctl_to_freq(void)
+{
+	struct device *dev = dev_find_slot(0, PCI_DEVFN(2, 0));
+	u8 *mmio_base = (void *)(uintptr_t)dev->resource_list[0].base;
+	u32 blc_pwm_ctl = read32(mmio_base + BLC_PWM_CTL);
+
+	return get_cdclk(dev) / (128 * (blc_pwm_ctl & 0xffff));
+}
+
+const char *mainboard_vbt_filename(void)
+{
+	if (blc_pwm_ctl_to_freq() > 200)
+		return "data_led.vbt";
+	else
+		return "data_ccfl.vbt";
+
+}
diff --git a/src/mainboard/lenovo/x200/data_ccfl.vbt b/src/mainboard/lenovo/x200/data_ccfl.vbt
new file mode 100644
index 0000000..dc044c9
--- /dev/null
+++ b/src/mainboard/lenovo/x200/data_ccfl.vbt
Binary files differ
diff --git a/src/mainboard/lenovo/x200/data_led.vbt b/src/mainboard/lenovo/x200/data_led.vbt
new file mode 100644
index 0000000..bcd6c30
--- /dev/null
+++ b/src/mainboard/lenovo/x200/data_led.vbt
Binary files differ

-- 
To view, visit https://review.coreboot.org/c/coreboot/+/29904
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I4c4a7011ce03cdd511fa2e2160c2f006ba2707ba
Gerrit-Change-Number: 29904
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur at aheymans.xyz>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20181128/38561e33/attachment.html>


More information about the coreboot-gerrit mailing list