summaryrefslogtreecommitdiff
path: root/src/drivers/parade/ps8640
diff options
context:
space:
mode:
authorJitao Shi <jitao.shi@mediatek.com>2016-01-08 15:59:46 +0800
committerPatrick Georgi <pgeorgi@google.com>2016-03-12 09:12:20 +0100
commitfd99eca8001c9178b3b2b15ca7d76437305c31aa (patch)
tree05bd142e983530d82c0a23af3480bb1865fbeac4 /src/drivers/parade/ps8640
parenta622f28cb249c9d88751ce2694c83a62c25c221e (diff)
Add a driver for the parade ps8640
BRANCH=none BUG=none TEST=none Change-Id: Icf397ce2ffdaed5048367daf2086c067984fea0a Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: b5a88793ccfc46af196300791a300be67b70f5b1 Original-Change-Id: I75adf2688c9c8b9a2338f7dee5d0ac10e7181529 Original-Signed-off-by: Jitao Shi <jitao.shi@mediatek.com> Original-Reviewed-on: https://chromium-review.googlesource.com/321056 Original-Commit-Ready: Yidi Lin <yidi.lin@mediatek.com> Original-Tested-by: Yidi Lin <yidi.lin@mediatek.com> Original-Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/13981 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/drivers/parade/ps8640')
-rw-r--r--src/drivers/parade/ps8640/Kconfig20
-rw-r--r--src/drivers/parade/ps8640/Makefile.inc16
-rw-r--r--src/drivers/parade/ps8640/ps8640.c79
-rw-r--r--src/drivers/parade/ps8640/ps8640.h45
4 files changed, 160 insertions, 0 deletions
diff --git a/src/drivers/parade/ps8640/Kconfig b/src/drivers/parade/ps8640/Kconfig
new file mode 100644
index 0000000000..f0d71bbf25
--- /dev/null
+++ b/src/drivers/parade/ps8640/Kconfig
@@ -0,0 +1,20 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright 2015 MediaTek Inc.
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; version 2 of the License.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+
+config DRIVER_PARADE_PS8640
+ bool
+ default n
+ help
+ Parade PS8640 MIPI DSI to eDP Converter
diff --git a/src/drivers/parade/ps8640/Makefile.inc b/src/drivers/parade/ps8640/Makefile.inc
new file mode 100644
index 0000000000..9bfe1e7068
--- /dev/null
+++ b/src/drivers/parade/ps8640/Makefile.inc
@@ -0,0 +1,16 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright 2015 MediaTek Inc.
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; version 2 of the License.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+
+ramstage-$(CONFIG_DRIVER_PARADE_PS8640) += ps8640.c
diff --git a/src/drivers/parade/ps8640/ps8640.c b/src/drivers/parade/ps8640/ps8640.c
new file mode 100644
index 0000000000..08de2ee9a6
--- /dev/null
+++ b/src/drivers/parade/ps8640/ps8640.c
@@ -0,0 +1,79 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 MediaTek Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <delay.h>
+#include <device/i2c.h>
+#include <edid.h>
+#include <console/console.h>
+#include <timer.h>
+
+#include "ps8640.h"
+
+int ps8640_get_edid(uint8_t bus, uint8_t chip, struct edid *out)
+{
+ int ret;
+ u8 edid[EDID_LENGTH * 2];
+ u32 edid_size;
+
+ i2c_writeb(bus, chip + 2, PAGE2_I2C_BYPASS,
+ EDID_I2C_ADDR | I2C_BYPASS_EN);
+ ret = i2c_read_bytes(bus, EDID_I2C_ADDR, 0, edid, EDID_LENGTH);
+
+ if (ret != 0) {
+ printk(BIOS_INFO, "Failed to read EDID.\n");
+ return -1;
+ }
+
+ /* check if edid have extension flag, and read additional EDID data */
+ if (edid[EDID_EXTENSION_FLAG]) {
+ edid_size += EDID_LENGTH;
+ ret = i2c_read_bytes(bus, EDID_I2C_ADDR, EDID_LENGTH,
+ &edid[EDID_LENGTH], EDID_LENGTH);
+ if (ret != 0) {
+ printk(BIOS_INFO, "Failed to read EDID ext block.\n");
+ return -1;
+ }
+ }
+
+ if (decode_edid(edid, edid_size, out)) {
+ printk(BIOS_INFO, "Failed to decode EDID.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int ps8640_init(uint8_t bus, uint8_t chip)
+{
+ u8 set_vdo_done;
+ struct stopwatch sw;
+
+ stopwatch_init_msecs_expire(&sw, 350);
+
+ do {
+ i2c_readb(bus, chip + 2, PAGE2_GPIO_H, &set_vdo_done);
+ if (stopwatch_expired(&sw)) {
+ printk(BIOS_INFO, "Failed to init ps8640.\n");
+ return -1;
+ }
+ } while ((set_vdo_done & PS_GPIO9) != PS_GPIO9);
+
+ i2c_writeb(bus, chip + 3, PAGE3_SET_ADD, VDO_CTL_ADD);
+ i2c_writeb(bus, chip + 3, PAGE3_SET_VAL, VDO_DIS);
+ i2c_writeb(bus, chip + 3, PAGE3_SET_ADD, VDO_CTL_ADD);
+ i2c_writeb(bus, chip + 3, PAGE3_SET_VAL, VDO_EN);
+
+ return 0;
+}
diff --git a/src/drivers/parade/ps8640/ps8640.h b/src/drivers/parade/ps8640/ps8640.h
new file mode 100644
index 0000000000..9e483b613b
--- /dev/null
+++ b/src/drivers/parade/ps8640/ps8640.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 MediaTek Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <edid.h>
+#include <types.h>
+
+#ifndef _PS8640_H_
+#define _PS8640_H_
+
+enum {
+ PAGE2_GPIO_L = 0xa6,
+ PAGE2_GPIO_H = 0xa7,
+ PAGE2_I2C_BYPASS = 0xea,
+ PS_GPIO9 = BIT(1),
+ I2C_BYPASS_EN = BIT(7),
+
+ PAGE3_SET_ADD = 0xfe,
+ PAGE3_SET_VAL = 0xff,
+ VDO_CTL_ADD = 0x13,
+ VDO_DIS = 0x18,
+ VDO_EN = 0x1c,
+};
+
+enum {
+ EDID_LENGTH = 128,
+ EDID_I2C_ADDR = 0x50,
+ EDID_EXTENSION_FLAG = 0x7e,
+};
+
+int ps8640_init(uint8_t bus, uint8_t chip);
+int ps8640_get_edid(uint8_t bus, uint8_t chip, struct edid *out);
+#endif
+