From e83de6429cb17817c0f85ea6e812e7e99613dcb6 Mon Sep 17 00:00:00 2001 From: Jimmy Zhang Date: Wed, 29 Oct 2014 11:12:40 -0700 Subject: [PATCH] ryu: libpayload: Set fb address in dc register Since display controller and panel configuration is done in coreboot but the frame buffer address is not available until payload stage, it is needed to have a function in libpayload to set fb address and enable window in dc registers. BRANCH=none BUG=chrome-os-partner:31936 TEST=build and test on ryu Change-Id: Ib5fe9da4d8257d616e13c5556ec25d8b900d60e3 Signed-off-by: Jimmy Zhang Reviewed-on: https://chromium-review.googlesource.com/226406 Reviewed-by: Aaron Durbin --- payloads/libpayload/configs/config.rush | 1 + payloads/libpayload/drivers/Makefile.inc | 3 ++ payloads/libpayload/drivers/video/tegra.c | 63 +++++++++++++++++++++++ payloads/libpayload/drivers/video/video.c | 15 ++++++ 4 files changed, 82 insertions(+) create mode 100644 payloads/libpayload/drivers/video/tegra.c diff --git a/payloads/libpayload/configs/config.rush b/payloads/libpayload/configs/config.rush index 709414ae85..01e3394765 100644 --- a/payloads/libpayload/configs/config.rush +++ b/payloads/libpayload/configs/config.rush @@ -45,6 +45,7 @@ CONFIG_LP_8250_MMIO32_SERIAL_CONSOLE=y # CONFIG_LP_SERIAL_ACS_FALLBACK is not set CONFIG_LP_VIDEO_CONSOLE=y CONFIG_LP_COREBOOT_VIDEO_CONSOLE=y +CONFIG_LP_TEGRA_VIDEO_CONSOLE_INIT=y # CONFIG_LP_PC_KEYBOARD is not set # diff --git a/payloads/libpayload/drivers/Makefile.inc b/payloads/libpayload/drivers/Makefile.inc index 2712f048be..e67dfdc598 100644 --- a/payloads/libpayload/drivers/Makefile.inc +++ b/payloads/libpayload/drivers/Makefile.inc @@ -65,6 +65,9 @@ libc-$(CONFIG_LP_GEODELX_VIDEO_CONSOLE) += video/font8x16.c libc-$(CONFIG_LP_COREBOOT_VIDEO_CONSOLE) += video/corebootfb.c libc-$(CONFIG_LP_COREBOOT_VIDEO_CONSOLE) += video/font8x16.c +# Tegra132 framebuffer init driver +libc-$(CONFIG_LP_TEGRA_VIDEO_CONSOLE_INIT) += video/tegra.c + libc-$(CONFIG_LP_STORAGE) += storage/storage.c libc-$(CONFIG_LP_STORAGE_ATA) += storage/ata.c libc-$(CONFIG_LP_STORAGE_ATAPI) += storage/atapi.c diff --git a/payloads/libpayload/drivers/video/tegra.c b/payloads/libpayload/drivers/video/tegra.c new file mode 100644 index 0000000000..b9244ca5c6 --- /dev/null +++ b/payloads/libpayload/drivers/video/tegra.c @@ -0,0 +1,63 @@ +/* + * Copyright 2014 Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include +#include +#include + +#define write32(val, addr) *(volatile uint32_t *)addr = val +#define read32(addr) *(volatile uint32_t *)addr + +#define WIN_ENABLE (1 << 30) +#define TEGRA_DC_WIN_OPTIONS 0x54201c00 +#define TEGRA_DC_FB_START 0x54202000 + +struct video_console tegra_video_console; + +static int tegra_fb_init(void) +{ + uint32_t value; + + if ((lib_sysinfo.framebuffer == NULL) || + !(lib_sysinfo.framebuffer->physical_address)) + return -1; + + write32(((uint32_t)lib_sysinfo.framebuffer->physical_address), + TEGRA_DC_FB_START); + value = read32(TEGRA_DC_WIN_OPTIONS); + write32((value | WIN_ENABLE), TEGRA_DC_WIN_OPTIONS); + + /* + * This is not a full functional video driver. The return value here + * must be non-zero so that upper layer can continue scaning to find + * the real video driver. + */ + return -1; +} + +struct video_console tegra_video_console = { + .init = tegra_fb_init, +}; diff --git a/payloads/libpayload/drivers/video/video.c b/payloads/libpayload/drivers/video/video.c index 5f76a3075a..d88069efd3 100644 --- a/payloads/libpayload/drivers/video/video.c +++ b/payloads/libpayload/drivers/video/video.c @@ -43,8 +43,23 @@ extern struct video_console coreboot_video_console; extern struct video_console vga_video_console; #endif +#ifdef CONFIG_LP_TEGRA_VIDEO_CONSOLE_INIT +extern struct video_console tegra_video_console; +#endif + static struct video_console *console_list[] = { +/* + * tegra_video_console only provides the init function to do a few + * dc configuration settings. Since it is not a full-fledged video + * driver, its init function will not return success so that + * function video_init() can find the real video driver. Also + * tegra_video_console must be placed at first position in this + * console_list[] to ensure the tegra init function is being called. + */ +#ifdef CONFIG_LP_TEGRA_VIDEO_CONSOLE_INIT + &tegra_video_console, +#endif #ifdef CONFIG_LP_GEODELX_VIDEO_CONSOLE &geodelx_video_console, #endif