Angel Pons | e67ab18 | 2020-04-04 18:51:11 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 2 | |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 3 | #include <device/mmio.h> |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 4 | #include <edid.h> |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 5 | #include <soc/addressmap.h> |
| 6 | #include <soc/ddp.h> |
Elyes HAOUAS | 27d02d8 | 2019-05-15 21:11:39 +0200 | [diff] [blame] | 7 | #include <types.h> |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 8 | |
Hung-Te Lin | 1c6e5a6 | 2019-08-05 14:38:30 +0800 | [diff] [blame] | 9 | static void disp_config_main_path_connection(void) |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 10 | { |
| 11 | write32(&mmsys_cfg->disp_ovl0_mout_en, OVL0_MOUT_EN_COLOR0); |
Jitao Shi | b927fe1 | 2017-02-07 08:51:01 +0800 | [diff] [blame] | 12 | write32(&mmsys_cfg->disp_color0_sel_in, COLOR0_SEL_IN_OVL0); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 13 | write32(&mmsys_cfg->disp_od_mout_en, OD_MOUT_EN_RDMA0); |
Hung-Te Lin | 1c6e5a6 | 2019-08-05 14:38:30 +0800 | [diff] [blame] | 14 | write32(&mmsys_cfg->disp_ufoe_mout_en, UFOE_MOUT_EN_DSI0); |
| 15 | write32(&mmsys_cfg->dsi0_sel_in, DSI0_SEL_IN_UFOE); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | static void disp_config_main_path_mutex(void) |
| 19 | { |
| 20 | write32(&disp_mutex->mutex[0].mod, MUTEX_MOD_MAIN_PATH); |
| 21 | |
| 22 | /* Clock source from DSI0 */ |
| 23 | write32(&disp_mutex->mutex[0].sof, BIT(0)); |
| 24 | write32(&disp_mutex->mutex[0].en, BIT(0)); |
| 25 | } |
| 26 | |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 27 | static void od_start(u32 width, u32 height) |
| 28 | { |
| 29 | write32(&disp_od->size, width << 16 | height); |
| 30 | write32(&disp_od->cfg, OD_RELAY_MODE); |
| 31 | |
| 32 | write32(&disp_od->en, 1); |
| 33 | } |
| 34 | |
Hung-Te Lin | 1c6e5a6 | 2019-08-05 14:38:30 +0800 | [diff] [blame] | 35 | static void main_disp_path_setup(u32 width, u32 height, u32 pixel_clk) |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 36 | { |
Hung-Te Lin | 7ece246 | 2019-08-05 03:08:57 +0800 | [diff] [blame] | 37 | ovl_set_roi(0, width, height, 0); |
| 38 | rdma_config(width, height, pixel_clk, 8 * KiB); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 39 | od_start(width, height); |
Hung-Te Lin | 7ece246 | 2019-08-05 03:08:57 +0800 | [diff] [blame] | 40 | write32(&disp_ufoe->start, UFO_BYPASS); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 41 | color_start(width, height); |
Hung-Te Lin | 1c6e5a6 | 2019-08-05 14:38:30 +0800 | [diff] [blame] | 42 | disp_config_main_path_connection(); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 43 | disp_config_main_path_mutex(); |
| 44 | } |
| 45 | |
Hung-Te Lin | 1c6e5a6 | 2019-08-05 14:38:30 +0800 | [diff] [blame] | 46 | static void disp_clock_on(void) |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 47 | { |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 48 | clrbits32(&mmsys_cfg->mmsys_cg_con0, CG_CON0_SMI_COMMON | |
| 49 | CG_CON0_SMI_LARB0 | |
| 50 | CG_CON0_MUTEX_32K | |
| 51 | CG_CON0_DISP_OVL0 | |
| 52 | CG_CON0_DISP_RDMA0 | |
| 53 | CG_CON0_DISP_COLOR0 | |
| 54 | CG_CON0_DISP_UFOE | |
| 55 | CG_CON0_DISP_OD); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 56 | |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 57 | clrbits32(&mmsys_cfg->mmsys_cg_con1, CG_CON1_DSI0_ENGINE | |
| 58 | CG_CON1_DSI0_DIGITAL); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 59 | } |
| 60 | |
Hung-Te Lin | 1c6e5a6 | 2019-08-05 14:38:30 +0800 | [diff] [blame] | 61 | void mtk_ddp_init(void) |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 62 | { |
Hung-Te Lin | 1c6e5a6 | 2019-08-05 14:38:30 +0800 | [diff] [blame] | 63 | disp_clock_on(); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 64 | } |
| 65 | |
Hung-Te Lin | 1c6e5a6 | 2019-08-05 14:38:30 +0800 | [diff] [blame] | 66 | void mtk_ddp_mode_set(const struct edid *edid) |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 67 | { |
| 68 | u32 fmt = OVL_INFMT_RGBA8888; |
| 69 | u32 bpp = edid->framebuffer_bits_per_pixel / 8; |
| 70 | |
| 71 | main_disp_path_setup(edid->mode.ha, edid->mode.va, |
Hung-Te Lin | 1c6e5a6 | 2019-08-05 14:38:30 +0800 | [diff] [blame] | 72 | edid->mode.pixel_clock); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 73 | |
| 74 | rdma_start(); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 75 | ovl_layer_config(fmt, bpp, edid->mode.ha, edid->mode.va); |
| 76 | } |