summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2014-04-02 21:57:40 +0800
committerMarc Jones <marc.jones@se-eng.com>2014-12-16 22:56:08 +0100
commit3af0d310c1c074398a64dec0b4f4d500005767cc (patch)
treef9a9bf8061b5910736b1b56459b5cd2ac340ae80 /src
parentbe71ee5dec8f038cdd0e98efe93dadf0128d0f24 (diff)
downloadcoreboot-3af0d310c1c074398a64dec0b4f4d500005767cc.tar.xz
tegra124: Initialize display panel by EDID.
Tegra124 family products may want to use many different display panels with various timing settings. To support them, we should initialize display panel by EDID instead of hard-coded values. BUG=none TEST=emerge-nyan coreboot chromeos-bootimage BRANCH=none Original-Change-Id: Ib125a7f9cb1e6c8cf2d79e0baab525acfd1b7a6e Original-Signed-off-by: Hung-Te Lin <hungte@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/192730 Original-Reviewed-by: Tom Warren <twarren@nvidia.com> Original-Reviewed-by: Jimmy Zhang <jimmzhang@nvidia.com> Original-Reviewed-by: Gabe Black <gabeblack@chromium.org> (cherry picked from commit 43ecd473419aa0fbdd22487416b0b6cfea6a20d1) Signed-off-by: Marc Jones <marc.jones@se-eng.com> Change-Id: I6af47db113035e9440e663a769318776c7b6b70b Reviewed-on: http://review.coreboot.org/7764 Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Tested-by: build bot (Jenkins)
Diffstat (limited to 'src')
-rw-r--r--src/soc/nvidia/tegra124/display.c9
-rw-r--r--src/soc/nvidia/tegra124/dp.c57
-rw-r--r--src/soc/nvidia/tegra124/include/soc/addressmap.h1
3 files changed, 58 insertions, 9 deletions
diff --git a/src/soc/nvidia/tegra124/display.c b/src/soc/nvidia/tegra124/display.c
index c3117fdb01..33769bac6d 100644
--- a/src/soc/nvidia/tegra124/display.c
+++ b/src/soc/nvidia/tegra124/display.c
@@ -222,17 +222,18 @@ void display_startup(device_t dev)
struct pwm_controller *pwm = (void *)TEGRA_PWM_BASE;
struct tegra_dc *dc = &dc_data;
- /* should probably just make it all MiB ... in future */
- u32 framebuffer_size_mb = config->framebuffer_size / MiB;
- u32 framebuffer_base_mb= config->framebuffer_base / MiB;
-
/* init dc */
dc->base = (void *)TEGRA_ARM_DISPLAYA;
dc->config = config;
config->dc_data = dc;
+ /* Note dp_init may read EDID and change some config values. */
dp_init(config);
+ /* should probably just make it all MiB ... in future */
+ u32 framebuffer_size_mb = config->framebuffer_size / MiB;
+ u32 framebuffer_base_mb= config->framebuffer_base / MiB;
+
/* light it all up */
/* This one may have been done in romstage but that's ok for now. */
if (config->panel_vdd_gpio){
diff --git a/src/soc/nvidia/tegra124/dp.c b/src/soc/nvidia/tegra124/dp.c
index f539ec3534..cc341b898f 100644
--- a/src/soc/nvidia/tegra124/dp.c
+++ b/src/soc/nvidia/tegra124/dp.c
@@ -19,6 +19,7 @@
#include <console/console.h>
#include <device/device.h>
#include <device/i2c.h>
+#include <edid.h>
#include <stdlib.h>
#include <string.h>
#include <delay.h>
@@ -323,11 +324,8 @@ static int tegra_dc_dp_dpcd_write(struct tegra_dc_dp_data *dp, u32 cmd,
return ret;
}
-/* TODO(hungte) Change this to static when EDID parsing functions are ready. */
-int tegra_dc_i2c_aux_read(struct tegra_dc_dp_data *dp, u32 i2c_addr,
- u8 addr, u8 *data, u32 *size, u32 *aux_stat);
-int tegra_dc_i2c_aux_read(struct tegra_dc_dp_data *dp, u32 i2c_addr,
- u8 addr, u8 *data, u32 *size, u32 *aux_stat)
+static int tegra_dc_i2c_aux_read(struct tegra_dc_dp_data *dp, u32 i2c_addr,
+ u8 addr, u8 *data, u32 *size, u32 *aux_stat)
{
u32 finished = 0;
int ret = 0;
@@ -620,6 +618,53 @@ static int tegra_dc_dp_init_link_cfg(
return 0;
}
+static void tegra_dp_update_config(struct tegra_dc_dp_data *dp,
+ struct soc_nvidia_tegra124_config *config)
+{
+ struct edid edid;
+ u8 buf[128] = {0};
+ u32 size = sizeof(buf), aux_stat = 0;
+
+ tegra_dc_dpaux_enable(dp);
+ if (tegra_dc_i2c_aux_read(dp, TEGRA_EDID_I2C_ADDRESS, 0, buf, &size,
+ &aux_stat)) {
+ printk(BIOS_ERR, "%s: Failed to read EDID. Use defaults.\n",
+ __func__);
+ return;
+ }
+
+ if (decode_edid(buf, sizeof(buf), &edid)) {
+ printk(BIOS_ERR, "%s: Failed to decode EDID. Use defaults.\n",
+ __func__);
+ return;
+ }
+
+ config->xres = edid.ha;
+ config->yres = edid.va;
+ config->pixel_clock = edid.pixel_clock * 1000;
+
+ config->hfront_porch = edid.hso;
+ config->hsync_width = edid.hspw;
+ config->hback_porch = edid.hbl - edid.hso - edid.hspw;
+
+ config->vfront_porch = edid.vso;
+ config->vsync_width = edid.vspw;
+ config->vback_porch = edid.vbl - edid.vso - edid.vspw;
+
+ /**
+ * Note edid->framebuffer_bits_per_pixel is currently hard-coded as 32,
+ * so we should keep the default value in device config.
+ *
+ * EDID v1.3 panels may not have color depth info, so we need to check
+ * if these values are zero before updating config.
+ */
+ if (edid.panel_bits_per_pixel)
+ config->panel_bits_per_pixel = edid.panel_bits_per_pixel;
+ if (edid.panel_bits_per_color)
+ config->color_depth = edid.panel_bits_per_color;
+ printk(BIOS_SPEW, "%s: configuration updated by EDID.\n", __func__);
+}
+
void dp_init(void * _config)
{
struct soc_nvidia_tegra124_config *config = (void *)_config;
@@ -639,6 +684,8 @@ void dp_init(void * _config)
dp->aux_base = (void *)TEGRA_ARM_DPAUX;
dp->link_cfg.is_valid = 0;
dp->enabled = 0;
+
+ tegra_dp_update_config(dp, config);
}
static void tegra_dp_hpd_config(struct tegra_dc_dp_data *dp,
diff --git a/src/soc/nvidia/tegra124/include/soc/addressmap.h b/src/soc/nvidia/tegra124/include/soc/addressmap.h
index a27da64071..1afaba84cd 100644
--- a/src/soc/nvidia/tegra124/include/soc/addressmap.h
+++ b/src/soc/nvidia/tegra124/include/soc/addressmap.h
@@ -79,6 +79,7 @@ enum {
enum {
TEGRA_I2C_BASE_COUNT = 6,
+ TEGRA_EDID_I2C_ADDRESS = 0x50,
};
#endif /* __SOC_NVIDIA_TEGRA124_INCLUDE_SOC_ADDRESS_MAP_H__ */