18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2015 Free Electrons 48c2ecf20Sopenharmony_ci * Copyright (C) 2015 NextThing Co 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Boris Brezillon <boris.brezillon@free-electrons.com> 78c2ecf20Sopenharmony_ci * Maxime Ripard <maxime.ripard@free-electrons.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef __SUN4I_TCON_H__ 118c2ecf20Sopenharmony_ci#define __SUN4I_TCON_H__ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <drm/drm_crtc.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <linux/kernel.h> 168c2ecf20Sopenharmony_ci#include <linux/list.h> 178c2ecf20Sopenharmony_ci#include <linux/reset.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define SUN4I_TCON_GCTL_REG 0x0 208c2ecf20Sopenharmony_ci#define SUN4I_TCON_GCTL_TCON_ENABLE BIT(31) 218c2ecf20Sopenharmony_ci#define SUN4I_TCON_GCTL_IOMAP_MASK BIT(0) 228c2ecf20Sopenharmony_ci#define SUN4I_TCON_GCTL_IOMAP_TCON1 (1 << 0) 238c2ecf20Sopenharmony_ci#define SUN4I_TCON_GCTL_IOMAP_TCON0 (0 << 0) 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define SUN4I_TCON_GINT0_REG 0x4 268c2ecf20Sopenharmony_ci#define SUN4I_TCON_GINT0_VBLANK_ENABLE(pipe) BIT(31 - (pipe)) 278c2ecf20Sopenharmony_ci#define SUN4I_TCON_GINT0_TCON0_TRI_FINISH_ENABLE BIT(27) 288c2ecf20Sopenharmony_ci#define SUN4I_TCON_GINT0_TCON0_TRI_COUNTER_ENABLE BIT(26) 298c2ecf20Sopenharmony_ci#define SUN4I_TCON_GINT0_VBLANK_INT(pipe) BIT(15 - (pipe)) 308c2ecf20Sopenharmony_ci#define SUN4I_TCON_GINT0_TCON0_TRI_FINISH_INT BIT(11) 318c2ecf20Sopenharmony_ci#define SUN4I_TCON_GINT0_TCON0_TRI_COUNTER_INT BIT(10) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define SUN4I_TCON_GINT1_REG 0x8 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define SUN4I_TCON_FRM_CTL_REG 0x10 368c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_CTL_EN BIT(31) 378c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_CTL_MODE_R BIT(6) 388c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_CTL_MODE_G BIT(5) 398c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_CTL_MODE_B BIT(4) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_SEED_PR_REG 0x14 428c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_SEED_PG_REG 0x18 438c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_SEED_PB_REG 0x1c 448c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_SEED_LR_REG 0x20 458c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_SEED_LG_REG 0x24 468c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_SEED_LB_REG 0x28 478c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_TBL0_REG 0x2c 488c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_TBL1_REG 0x30 498c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_TBL2_REG 0x34 508c2ecf20Sopenharmony_ci#define SUN4I_TCON0_FRM_TBL3_REG 0x38 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CTL_REG 0x40 538c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CTL_TCON_ENABLE BIT(31) 548c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CTL_IF_MASK GENMASK(25, 24) 558c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CTL_IF_8080 (1 << 24) 568c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CTL_CLK_DELAY_MASK GENMASK(8, 4) 578c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CTL_CLK_DELAY(delay) ((delay << 4) & SUN4I_TCON0_CTL_CLK_DELAY_MASK) 588c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CTL_SRC_SEL_MASK GENMASK(2, 0) 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#define SUN4I_TCON0_DCLK_REG 0x44 618c2ecf20Sopenharmony_ci#define SUN4I_TCON0_DCLK_GATE_BIT (31) 628c2ecf20Sopenharmony_ci#define SUN4I_TCON0_DCLK_DIV_SHIFT (0) 638c2ecf20Sopenharmony_ci#define SUN4I_TCON0_DCLK_DIV_WIDTH (7) 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#define SUN4I_TCON0_BASIC0_REG 0x48 668c2ecf20Sopenharmony_ci#define SUN4I_TCON0_BASIC0_X(width) ((((width) - 1) & 0xfff) << 16) 678c2ecf20Sopenharmony_ci#define SUN4I_TCON0_BASIC0_Y(height) (((height) - 1) & 0xfff) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define SUN4I_TCON0_BASIC1_REG 0x4c 708c2ecf20Sopenharmony_ci#define SUN4I_TCON0_BASIC1_H_TOTAL(total) ((((total) - 1) & 0x1fff) << 16) 718c2ecf20Sopenharmony_ci#define SUN4I_TCON0_BASIC1_H_BACKPORCH(bp) (((bp) - 1) & 0xfff) 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci#define SUN4I_TCON0_BASIC2_REG 0x50 748c2ecf20Sopenharmony_ci#define SUN4I_TCON0_BASIC2_V_TOTAL(total) (((total) & 0x1fff) << 16) 758c2ecf20Sopenharmony_ci#define SUN4I_TCON0_BASIC2_V_BACKPORCH(bp) (((bp) - 1) & 0xfff) 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define SUN4I_TCON0_BASIC3_REG 0x54 788c2ecf20Sopenharmony_ci#define SUN4I_TCON0_BASIC3_H_SYNC(width) ((((width) - 1) & 0x7ff) << 16) 798c2ecf20Sopenharmony_ci#define SUN4I_TCON0_BASIC3_V_SYNC(height) (((height) - 1) & 0x7ff) 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#define SUN4I_TCON0_HV_IF_REG 0x58 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_IF_REG 0x60 848c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_IF_MODE_MASK GENMASK(31, 28) 858c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_IF_MODE_DSI (1 << 28) 868c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_IF_TRI_FIFO_FLUSH BIT(16) 878c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_IF_TRI_FIFO_EN BIT(2) 888c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_IF_TRI_EN BIT(0) 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_WR_REG 0x64 918c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_RD0_REG 0x68 928c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_RDA_REG 0x6c 938c2ecf20Sopenharmony_ci#define SUN4I_TCON0_TTL0_REG 0x70 948c2ecf20Sopenharmony_ci#define SUN4I_TCON0_TTL1_REG 0x74 958c2ecf20Sopenharmony_ci#define SUN4I_TCON0_TTL2_REG 0x78 968c2ecf20Sopenharmony_ci#define SUN4I_TCON0_TTL3_REG 0x7c 978c2ecf20Sopenharmony_ci#define SUN4I_TCON0_TTL4_REG 0x80 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_REG 0x84 1008c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_EN BIT(31) 1018c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_BITWIDTH_MASK BIT(26) 1028c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_BITWIDTH_18BITS (1 << 26) 1038c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_BITWIDTH_24BITS (0 << 26) 1048c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_CLK_SEL_MASK BIT(20) 1058c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_CLK_SEL_TCON0 (1 << 20) 1068c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_CLK_POL_MASK BIT(4) 1078c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_CLK_POL_NORMAL (1 << 4) 1088c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_CLK_POL_INV (0 << 4) 1098c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_DATA_POL_MASK GENMASK(3, 0) 1108c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_DATA_POL_NORMAL (0xf) 1118c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_DATA_POL_INV (0) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#define SUN4I_TCON0_IO_POL_REG 0x88 1148c2ecf20Sopenharmony_ci#define SUN4I_TCON0_IO_POL_DCLK_PHASE(phase) ((phase & 3) << 28) 1158c2ecf20Sopenharmony_ci#define SUN4I_TCON0_IO_POL_DE_NEGATIVE BIT(27) 1168c2ecf20Sopenharmony_ci#define SUN4I_TCON0_IO_POL_DCLK_DRIVE_NEGEDGE BIT(26) 1178c2ecf20Sopenharmony_ci#define SUN4I_TCON0_IO_POL_HSYNC_POSITIVE BIT(25) 1188c2ecf20Sopenharmony_ci#define SUN4I_TCON0_IO_POL_VSYNC_POSITIVE BIT(24) 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci#define SUN4I_TCON0_IO_TRI_REG 0x8c 1218c2ecf20Sopenharmony_ci#define SUN4I_TCON0_IO_TRI_HSYNC_DISABLE BIT(25) 1228c2ecf20Sopenharmony_ci#define SUN4I_TCON0_IO_TRI_VSYNC_DISABLE BIT(24) 1238c2ecf20Sopenharmony_ci#define SUN4I_TCON0_IO_TRI_DATA_PINS_DISABLE(pins) GENMASK(pins, 0) 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci#define SUN4I_TCON1_CTL_REG 0x90 1268c2ecf20Sopenharmony_ci#define SUN4I_TCON1_CTL_TCON_ENABLE BIT(31) 1278c2ecf20Sopenharmony_ci#define SUN4I_TCON1_CTL_INTERLACE_ENABLE BIT(20) 1288c2ecf20Sopenharmony_ci#define SUN4I_TCON1_CTL_CLK_DELAY_MASK GENMASK(8, 4) 1298c2ecf20Sopenharmony_ci#define SUN4I_TCON1_CTL_CLK_DELAY(delay) ((delay << 4) & SUN4I_TCON1_CTL_CLK_DELAY_MASK) 1308c2ecf20Sopenharmony_ci#define SUN4I_TCON1_CTL_SRC_SEL_MASK GENMASK(1, 0) 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC0_REG 0x94 1338c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC0_X(width) ((((width) - 1) & 0xfff) << 16) 1348c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC0_Y(height) (((height) - 1) & 0xfff) 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC1_REG 0x98 1378c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC1_X(width) ((((width) - 1) & 0xfff) << 16) 1388c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC1_Y(height) (((height) - 1) & 0xfff) 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC2_REG 0x9c 1418c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC2_X(width) ((((width) - 1) & 0xfff) << 16) 1428c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC2_Y(height) (((height) - 1) & 0xfff) 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC3_REG 0xa0 1458c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC3_H_TOTAL(total) ((((total) - 1) & 0x1fff) << 16) 1468c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC3_H_BACKPORCH(bp) (((bp) - 1) & 0xfff) 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC4_REG 0xa4 1498c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC4_V_TOTAL(total) (((total) & 0x1fff) << 16) 1508c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC4_V_BACKPORCH(bp) (((bp) - 1) & 0xfff) 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC5_REG 0xa8 1538c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC5_H_SYNC(width) ((((width) - 1) & 0x3ff) << 16) 1548c2ecf20Sopenharmony_ci#define SUN4I_TCON1_BASIC5_V_SYNC(height) (((height) - 1) & 0x3ff) 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci#define SUN4I_TCON1_IO_POL_REG 0xf0 1578c2ecf20Sopenharmony_ci/* there is no documentation about this bit */ 1588c2ecf20Sopenharmony_ci#define SUN4I_TCON1_IO_POL_UNKNOWN BIT(26) 1598c2ecf20Sopenharmony_ci#define SUN4I_TCON1_IO_POL_HSYNC_POSITIVE BIT(25) 1608c2ecf20Sopenharmony_ci#define SUN4I_TCON1_IO_POL_VSYNC_POSITIVE BIT(24) 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci#define SUN4I_TCON1_IO_TRI_REG 0xf4 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci#define SUN4I_TCON_ECC_FIFO_REG 0xf8 1658c2ecf20Sopenharmony_ci#define SUN4I_TCON_ECC_FIFO_EN BIT(3) 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_CTL_REG 0x100 1688c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_RR_REG 0x110 1698c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_RG_REG 0x114 1708c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_RB_REG 0x118 1718c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_ADD_RC_REG 0x11c 1728c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_GR_REG 0x120 1738c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_GG_REG 0x124 1748c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_GB_REG 0x128 1758c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_ADD_GC_REG 0x12c 1768c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_BR_REG 0x130 1778c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_BG_REG 0x134 1788c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_BB_REG 0x138 1798c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_ADD_BC_REG 0x13c 1808c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_RANGE_R_REG 0x140 1818c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_RANGE_G_REG 0x144 1828c2ecf20Sopenharmony_ci#define SUN4I_TCON_CEU_RANGE_B_REG 0x148 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI0_REG 0x160 1858c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI0_BLOCK_SPACE(space) ((((space) - 1) & 0xfff) << 16) 1868c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI0_BLOCK_SIZE(size) (((size) - 1) & 0xfff) 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI1_REG 0x164 1898c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI1_BLOCK_NUM(num) (((num) - 1) & 0xffff) 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI2_REG 0x168 1928c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI2_START_DELAY(delay) (((delay) & 0xffff) << 16) 1938c2ecf20Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI2_TRANS_START_SET(set) ((set) & 0xfff) 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci#define SUN4I_TCON_SAFE_PERIOD_REG 0x1f0 1968c2ecf20Sopenharmony_ci#define SUN4I_TCON_SAFE_PERIOD_NUM(num) (((num) & 0xfff) << 16) 1978c2ecf20Sopenharmony_ci#define SUN4I_TCON_SAFE_PERIOD_MODE(mode) ((mode) & 0x3) 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci#define SUN4I_TCON_MUX_CTRL_REG 0x200 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_REG 0x220 2028c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_DCHS BIT(16) 2038c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_PD (BIT(20) | BIT(21)) 2048c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_EN_MB BIT(22) 2058c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_REG_C (BIT(24) | BIT(25)) 2068c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_REG_V (BIT(26) | BIT(27)) 2078c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_CK_EN (BIT(29) | BIT(28)) 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_EN_MB BIT(31) 2108c2ecf20Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_EN_LDO BIT(30) 2118c2ecf20Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_EN_DRVC BIT(24) 2128c2ecf20Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_EN_DRVD(x) (((x) & 0xf) << 20) 2138c2ecf20Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_C(x) (((x) & 3) << 17) 2148c2ecf20Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_V(x) (((x) & 3) << 8) 2158c2ecf20Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_PD(x) (((x) & 3) << 4) 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA1_REG 0x224 2188c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA1_INIT (0x1f << 26 | 0x1f << 10) 2198c2ecf20Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA1_UPDATE (0x1f << 16 | 0x1f << 00) 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci#define SUN4I_TCON1_FILL_CTL_REG 0x300 2228c2ecf20Sopenharmony_ci#define SUN4I_TCON1_FILL_BEG0_REG 0x304 2238c2ecf20Sopenharmony_ci#define SUN4I_TCON1_FILL_END0_REG 0x308 2248c2ecf20Sopenharmony_ci#define SUN4I_TCON1_FILL_DATA0_REG 0x30c 2258c2ecf20Sopenharmony_ci#define SUN4I_TCON1_FILL_BEG1_REG 0x310 2268c2ecf20Sopenharmony_ci#define SUN4I_TCON1_FILL_END1_REG 0x314 2278c2ecf20Sopenharmony_ci#define SUN4I_TCON1_FILL_DATA1_REG 0x318 2288c2ecf20Sopenharmony_ci#define SUN4I_TCON1_FILL_BEG2_REG 0x31c 2298c2ecf20Sopenharmony_ci#define SUN4I_TCON1_FILL_END2_REG 0x320 2308c2ecf20Sopenharmony_ci#define SUN4I_TCON1_FILL_DATA2_REG 0x324 2318c2ecf20Sopenharmony_ci#define SUN4I_TCON1_GAMMA_TABLE_REG 0x400 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci#define SUN4I_TCON_MAX_CHANNELS 2 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_cistruct sun4i_tcon; 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_cistruct sun4i_tcon_quirks { 2388c2ecf20Sopenharmony_ci bool has_channel_0; /* a83t does not have channel 0 on second TCON */ 2398c2ecf20Sopenharmony_ci bool has_channel_1; /* a33 does not have channel 1 */ 2408c2ecf20Sopenharmony_ci bool has_lvds_alt; /* Does the LVDS clock have a parent other than the TCON clock? */ 2418c2ecf20Sopenharmony_ci bool needs_de_be_mux; /* sun6i needs mux to select backend */ 2428c2ecf20Sopenharmony_ci bool needs_edp_reset; /* a80 edp reset needed for tcon0 access */ 2438c2ecf20Sopenharmony_ci bool supports_lvds; /* Does the TCON support an LVDS output? */ 2448c2ecf20Sopenharmony_ci bool polarity_in_ch0; /* some tcon1 channels have polarity bits in tcon0 pol register */ 2458c2ecf20Sopenharmony_ci u8 dclk_min_div; /* minimum divider for TCON0 DCLK */ 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci /* callback to handle tcon muxing options */ 2488c2ecf20Sopenharmony_ci int (*set_mux)(struct sun4i_tcon *, const struct drm_encoder *); 2498c2ecf20Sopenharmony_ci /* handler for LVDS setup routine */ 2508c2ecf20Sopenharmony_ci void (*setup_lvds_phy)(struct sun4i_tcon *tcon, 2518c2ecf20Sopenharmony_ci const struct drm_encoder *encoder); 2528c2ecf20Sopenharmony_ci}; 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_cistruct sun4i_tcon { 2558c2ecf20Sopenharmony_ci struct device *dev; 2568c2ecf20Sopenharmony_ci struct drm_device *drm; 2578c2ecf20Sopenharmony_ci struct regmap *regs; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci /* Main bus clock */ 2608c2ecf20Sopenharmony_ci struct clk *clk; 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci /* Clocks for the TCON channels */ 2638c2ecf20Sopenharmony_ci struct clk *sclk0; 2648c2ecf20Sopenharmony_ci struct clk *sclk1; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci /* Possible mux for the LVDS clock */ 2678c2ecf20Sopenharmony_ci struct clk *lvds_pll; 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci /* Pixel clock */ 2708c2ecf20Sopenharmony_ci struct clk *dclk; 2718c2ecf20Sopenharmony_ci u8 dclk_max_div; 2728c2ecf20Sopenharmony_ci u8 dclk_min_div; 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci /* Reset control */ 2758c2ecf20Sopenharmony_ci struct reset_control *lcd_rst; 2768c2ecf20Sopenharmony_ci struct reset_control *lvds_rst; 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci /* Platform adjustments */ 2798c2ecf20Sopenharmony_ci const struct sun4i_tcon_quirks *quirks; 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci /* Associated crtc */ 2828c2ecf20Sopenharmony_ci struct sun4i_crtc *crtc; 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci int id; 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci /* TCON list management */ 2878c2ecf20Sopenharmony_ci struct list_head list; 2888c2ecf20Sopenharmony_ci}; 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_cistruct drm_bridge *sun4i_tcon_find_bridge(struct device_node *node); 2918c2ecf20Sopenharmony_cistruct drm_panel *sun4i_tcon_find_panel(struct device_node *node); 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_civoid sun4i_tcon_enable_vblank(struct sun4i_tcon *tcon, bool enable); 2948c2ecf20Sopenharmony_civoid sun4i_tcon_mode_set(struct sun4i_tcon *tcon, 2958c2ecf20Sopenharmony_ci const struct drm_encoder *encoder, 2968c2ecf20Sopenharmony_ci const struct drm_display_mode *mode); 2978c2ecf20Sopenharmony_civoid sun4i_tcon_set_status(struct sun4i_tcon *crtc, 2988c2ecf20Sopenharmony_ci const struct drm_encoder *encoder, bool enable); 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ciextern const struct of_device_id sun4i_tcon_of_table[]; 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci#endif /* __SUN4I_TCON_H__ */ 303