2014-09-19 08:51:52 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
* Copyright 2014 Rockchip 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 <arch/io.h>
|
|
|
|
#include <console/console.h>
|
|
|
|
#include <delay.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <soc/addressmap.h>
|
|
|
|
#include <soc/clock.h>
|
|
|
|
#include <soc/edp.h>
|
|
|
|
#include <soc/vop.h>
|
|
|
|
|
|
|
|
#include "chip.h"
|
|
|
|
|
|
|
|
static struct rk3288_vop_regs * const vop_regs[] = {
|
|
|
|
(struct rk3288_vop_regs *)VOP_BIG_BASE,
|
|
|
|
(struct rk3288_vop_regs *)VOP_LIT_BASE
|
|
|
|
};
|
|
|
|
|
|
|
|
void rkvop_enable(u32 vop_id, u32 fbbase, const struct edid *edid)
|
|
|
|
{
|
|
|
|
u32 lb_mode;
|
|
|
|
u32 rgb_mode;
|
2015-07-31 03:49:48 +02:00
|
|
|
u32 hactive = edid->mode.ha;
|
|
|
|
u32 vactive = edid->mode.va;
|
|
|
|
u32 hsync_len = edid->mode.hspw;
|
|
|
|
u32 hback_porch = edid->mode.hbl - edid->mode.hso - edid->mode.hspw;
|
|
|
|
u32 vsync_len = edid->mode.vspw;
|
|
|
|
u32 vback_porch = edid->mode.vbl - edid->mode.vso - edid->mode.vspw;
|
2014-09-19 08:51:52 +02:00
|
|
|
u32 xpos = 0, ypos = 0;
|
|
|
|
struct rk3288_vop_regs *preg = vop_regs[vop_id];
|
|
|
|
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(&preg->win0_act_info,
|
|
|
|
V_ACT_WIDTH(hactive - 1) | V_ACT_HEIGHT(vactive - 1));
|
2014-09-19 08:51:52 +02:00
|
|
|
|
2015-02-20 05:19:23 +01:00
|
|
|
write32(&preg->win0_dsp_st, V_DSP_XST(xpos + hsync_len + hback_porch) |
|
|
|
|
V_DSP_YST(ypos + vsync_len + vback_porch));
|
2014-09-19 08:51:52 +02:00
|
|
|
|
2015-02-20 05:19:23 +01:00
|
|
|
write32(&preg->win0_dsp_info, V_DSP_WIDTH(hactive - 1) |
|
|
|
|
V_DSP_HEIGHT(vactive - 1));
|
2014-09-19 08:51:52 +02:00
|
|
|
|
|
|
|
clrsetbits_le32(&preg->win0_color_key, M_WIN0_KEY_EN | M_WIN0_KEY_COLOR,
|
|
|
|
V_WIN0_KEY_EN(0) |
|
|
|
|
V_WIN0_KEY_COLOR(0));
|
|
|
|
|
|
|
|
switch (edid->framebuffer_bits_per_pixel) {
|
|
|
|
case 16:
|
|
|
|
rgb_mode = RGB565;
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(&preg->win0_vir, V_RGB565_VIRWIDTH(hactive));
|
2014-09-19 08:51:52 +02:00
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
rgb_mode = RGB888;
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(&preg->win0_vir, V_RGB888_VIRWIDTH(hactive));
|
2014-09-19 08:51:52 +02:00
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
default:
|
|
|
|
rgb_mode = ARGB8888;
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(&preg->win0_vir, V_ARGB888_VIRWIDTH(hactive));
|
2014-09-19 08:51:52 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hactive > 2560)
|
|
|
|
lb_mode = LB_RGB_3840X2;
|
|
|
|
else if (hactive > 1920)
|
|
|
|
lb_mode = LB_RGB_2560X4;
|
|
|
|
else if (hactive > 1280)
|
|
|
|
lb_mode = LB_RGB_1920X5;
|
|
|
|
else
|
|
|
|
lb_mode = LB_RGB_1280X8;
|
|
|
|
|
|
|
|
clrsetbits_le32(&preg->win0_ctrl0,
|
|
|
|
M_WIN0_LB_MODE | M_WIN0_DATA_FMT | M_WIN0_EN,
|
|
|
|
V_WIN0_LB_MODE(lb_mode) |
|
|
|
|
V_WIN0_DATA_FMT(rgb_mode) | V_WIN0_EN(1));
|
|
|
|
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(&preg->win0_yrgb_mst, fbbase);
|
2014-09-19 08:51:52 +02:00
|
|
|
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(&preg->reg_cfg_done, 0x01); /* enable reg config */
|
2014-09-19 08:51:52 +02:00
|
|
|
}
|
|
|
|
|
2015-04-29 17:08:12 +02:00
|
|
|
void rkvop_mode_set(u32 vop_id, const struct edid *edid, u32 mode)
|
2014-09-19 08:51:52 +02:00
|
|
|
{
|
2015-07-31 03:49:48 +02:00
|
|
|
u32 hactive = edid->mode.ha;
|
|
|
|
u32 vactive = edid->mode.va;
|
|
|
|
u32 hfront_porch = edid->mode.hso;
|
|
|
|
u32 hsync_len = edid->mode.hspw;
|
|
|
|
u32 hback_porch = edid->mode.hbl - edid->mode.hso - edid->mode.hspw;
|
|
|
|
u32 vfront_porch = edid->mode.vso;
|
|
|
|
u32 vsync_len = edid->mode.vspw;
|
|
|
|
u32 vback_porch = edid->mode.vbl - edid->mode.vso - edid->mode.vspw;
|
2014-09-19 08:51:52 +02:00
|
|
|
struct rk3288_vop_regs *preg = vop_regs[vop_id];
|
|
|
|
|
2015-04-29 17:08:12 +02:00
|
|
|
switch (mode) {
|
|
|
|
|
2015-06-17 22:47:28 +02:00
|
|
|
case VOP_MODE_HDMI:
|
2015-04-29 17:08:12 +02:00
|
|
|
clrsetbits_le32(&preg->sys_ctrl,
|
|
|
|
M_ALL_OUT_EN, V_HDMI_OUT_EN(1));
|
|
|
|
break;
|
|
|
|
|
2015-06-17 22:47:28 +02:00
|
|
|
case VOP_MODE_EDP:
|
2015-04-29 17:08:12 +02:00
|
|
|
default:
|
|
|
|
clrsetbits_le32(&preg->sys_ctrl,
|
|
|
|
M_ALL_OUT_EN, V_EDP_OUT_EN(1));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
clrsetbits_le32(&preg->dsp_ctrl0,
|
|
|
|
M_DSP_OUT_MODE | M_DSP_VSYNC_POL | M_DSP_HSYNC_POL,
|
|
|
|
V_DSP_OUT_MODE(15) |
|
2015-07-31 03:49:48 +02:00
|
|
|
V_DSP_HSYNC_POL(edid->mode.phsync == '+') |
|
|
|
|
V_DSP_VSYNC_POL(edid->mode.pvsync == '+'));
|
2015-04-29 17:08:12 +02:00
|
|
|
|
2015-02-20 05:19:23 +01:00
|
|
|
write32(&preg->dsp_htotal_hs_end, V_HSYNC(hsync_len) |
|
|
|
|
V_HORPRD(hsync_len + hback_porch + hactive + hfront_porch));
|
2014-09-19 08:51:52 +02:00
|
|
|
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(&preg->dsp_hact_st_end,
|
2015-02-20 05:19:23 +01:00
|
|
|
V_HEAP(hsync_len + hback_porch + hactive) |
|
|
|
|
V_HASP(hsync_len + hback_porch));
|
2014-09-19 08:51:52 +02:00
|
|
|
|
2015-02-20 05:19:23 +01:00
|
|
|
write32(&preg->dsp_vtotal_vs_end, V_VSYNC(vsync_len) |
|
|
|
|
V_VERPRD(vsync_len + vback_porch + vactive + vfront_porch));
|
2014-09-19 08:51:52 +02:00
|
|
|
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(&preg->dsp_vact_st_end,
|
2015-02-20 05:19:23 +01:00
|
|
|
V_VAEP(vsync_len + vback_porch + vactive) |
|
|
|
|
V_VASP(vsync_len + vback_porch));
|
2014-09-19 08:51:52 +02:00
|
|
|
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(&preg->post_dsp_hact_info,
|
2015-02-20 05:19:23 +01:00
|
|
|
V_HEAP(hsync_len + hback_porch + hactive) |
|
|
|
|
V_HASP(hsync_len + hback_porch));
|
2014-09-19 08:51:52 +02:00
|
|
|
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(&preg->post_dsp_vact_info,
|
2015-02-20 05:19:23 +01:00
|
|
|
V_VAEP(vsync_len + vback_porch + vactive) |
|
|
|
|
V_VASP(vsync_len + vback_porch));
|
2014-09-19 08:51:52 +02:00
|
|
|
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(&preg->reg_cfg_done, 0x01); /* enable reg config */
|
2014-09-19 08:51:52 +02:00
|
|
|
}
|