12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 29026e0d1SMaxime Ripard /* 39026e0d1SMaxime Ripard * Copyright (C) 2015 Free Electrons 49026e0d1SMaxime Ripard * Copyright (C) 2015 NextThing Co 59026e0d1SMaxime Ripard * 69026e0d1SMaxime Ripard * Boris Brezillon <boris.brezillon@free-electrons.com> 79026e0d1SMaxime Ripard * Maxime Ripard <maxime.ripard@free-electrons.com> 89026e0d1SMaxime Ripard */ 99026e0d1SMaxime Ripard 109026e0d1SMaxime Ripard #ifndef __SUN4I_TCON_H__ 119026e0d1SMaxime Ripard #define __SUN4I_TCON_H__ 129026e0d1SMaxime Ripard 139026e0d1SMaxime Ripard #include <drm/drm_crtc.h> 149026e0d1SMaxime Ripard 159026e0d1SMaxime Ripard #include <linux/kernel.h> 1680a58240SChen-Yu Tsai #include <linux/list.h> 17*73289afeSVille Syrjälä #include <linux/mod_devicetable.h> 189026e0d1SMaxime Ripard #include <linux/reset.h> 199026e0d1SMaxime Ripard 209026e0d1SMaxime Ripard #define SUN4I_TCON_GCTL_REG 0x0 219026e0d1SMaxime Ripard #define SUN4I_TCON_GCTL_TCON_ENABLE BIT(31) 229026e0d1SMaxime Ripard #define SUN4I_TCON_GCTL_IOMAP_MASK BIT(0) 239026e0d1SMaxime Ripard #define SUN4I_TCON_GCTL_IOMAP_TCON1 (1 << 0) 249026e0d1SMaxime Ripard #define SUN4I_TCON_GCTL_IOMAP_TCON0 (0 << 0) 259026e0d1SMaxime Ripard 269026e0d1SMaxime Ripard #define SUN4I_TCON_GINT0_REG 0x4 279026e0d1SMaxime Ripard #define SUN4I_TCON_GINT0_VBLANK_ENABLE(pipe) BIT(31 - (pipe)) 28a493ceaeSMaxime Ripard #define SUN4I_TCON_GINT0_TCON0_TRI_FINISH_ENABLE BIT(27) 29a493ceaeSMaxime Ripard #define SUN4I_TCON_GINT0_TCON0_TRI_COUNTER_ENABLE BIT(26) 309026e0d1SMaxime Ripard #define SUN4I_TCON_GINT0_VBLANK_INT(pipe) BIT(15 - (pipe)) 31a493ceaeSMaxime Ripard #define SUN4I_TCON_GINT0_TCON0_TRI_FINISH_INT BIT(11) 32a493ceaeSMaxime Ripard #define SUN4I_TCON_GINT0_TCON0_TRI_COUNTER_INT BIT(10) 339026e0d1SMaxime Ripard 349026e0d1SMaxime Ripard #define SUN4I_TCON_GINT1_REG 0x8 35a08fc7c8SMaxime Ripard 369026e0d1SMaxime Ripard #define SUN4I_TCON_FRM_CTL_REG 0x10 375869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_CTL_EN BIT(31) 385869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_CTL_MODE_R BIT(6) 395869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_CTL_MODE_G BIT(5) 405869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_CTL_MODE_B BIT(4) 41a08fc7c8SMaxime Ripard 425869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_SEED_PR_REG 0x14 435869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_SEED_PG_REG 0x18 445869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_SEED_PB_REG 0x1c 455869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_SEED_LR_REG 0x20 465869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_SEED_LG_REG 0x24 475869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_SEED_LB_REG 0x28 485869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_TBL0_REG 0x2c 495869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_TBL1_REG 0x30 505869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_TBL2_REG 0x34 515869d90bSChen-Yu Tsai #define SUN4I_TCON0_FRM_TBL3_REG 0x38 529026e0d1SMaxime Ripard 539026e0d1SMaxime Ripard #define SUN4I_TCON0_CTL_REG 0x40 549026e0d1SMaxime Ripard #define SUN4I_TCON0_CTL_TCON_ENABLE BIT(31) 55a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CTL_IF_MASK GENMASK(25, 24) 56a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CTL_IF_8080 (1 << 24) 579026e0d1SMaxime Ripard #define SUN4I_TCON0_CTL_CLK_DELAY_MASK GENMASK(8, 4) 589026e0d1SMaxime Ripard #define SUN4I_TCON0_CTL_CLK_DELAY(delay) ((delay << 4) & SUN4I_TCON0_CTL_CLK_DELAY_MASK) 5927e18de7SChen-Yu Tsai #define SUN4I_TCON0_CTL_SRC_SEL_MASK GENMASK(2, 0) 609026e0d1SMaxime Ripard 619026e0d1SMaxime Ripard #define SUN4I_TCON0_DCLK_REG 0x44 629026e0d1SMaxime Ripard #define SUN4I_TCON0_DCLK_GATE_BIT (31) 639026e0d1SMaxime Ripard #define SUN4I_TCON0_DCLK_DIV_SHIFT (0) 649026e0d1SMaxime Ripard #define SUN4I_TCON0_DCLK_DIV_WIDTH (7) 659026e0d1SMaxime Ripard 669026e0d1SMaxime Ripard #define SUN4I_TCON0_BASIC0_REG 0x48 679026e0d1SMaxime Ripard #define SUN4I_TCON0_BASIC0_X(width) ((((width) - 1) & 0xfff) << 16) 689026e0d1SMaxime Ripard #define SUN4I_TCON0_BASIC0_Y(height) (((height) - 1) & 0xfff) 699026e0d1SMaxime Ripard 709026e0d1SMaxime Ripard #define SUN4I_TCON0_BASIC1_REG 0x4c 719026e0d1SMaxime Ripard #define SUN4I_TCON0_BASIC1_H_TOTAL(total) ((((total) - 1) & 0x1fff) << 16) 729026e0d1SMaxime Ripard #define SUN4I_TCON0_BASIC1_H_BACKPORCH(bp) (((bp) - 1) & 0xfff) 739026e0d1SMaxime Ripard 749026e0d1SMaxime Ripard #define SUN4I_TCON0_BASIC2_REG 0x50 75a88cbbd4SMaxime Ripard #define SUN4I_TCON0_BASIC2_V_TOTAL(total) (((total) & 0x1fff) << 16) 769026e0d1SMaxime Ripard #define SUN4I_TCON0_BASIC2_V_BACKPORCH(bp) (((bp) - 1) & 0xfff) 779026e0d1SMaxime Ripard 789026e0d1SMaxime Ripard #define SUN4I_TCON0_BASIC3_REG 0x54 799026e0d1SMaxime Ripard #define SUN4I_TCON0_BASIC3_H_SYNC(width) ((((width) - 1) & 0x7ff) << 16) 809026e0d1SMaxime Ripard #define SUN4I_TCON0_BASIC3_V_SYNC(height) (((height) - 1) & 0x7ff) 819026e0d1SMaxime Ripard 829026e0d1SMaxime Ripard #define SUN4I_TCON0_HV_IF_REG 0x58 83a08fc7c8SMaxime Ripard 849026e0d1SMaxime Ripard #define SUN4I_TCON0_CPU_IF_REG 0x60 85a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CPU_IF_MODE_MASK GENMASK(31, 28) 86a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CPU_IF_MODE_DSI (1 << 28) 87a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CPU_IF_TRI_FIFO_FLUSH BIT(16) 88a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CPU_IF_TRI_FIFO_EN BIT(2) 89a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CPU_IF_TRI_EN BIT(0) 90a08fc7c8SMaxime Ripard 919026e0d1SMaxime Ripard #define SUN4I_TCON0_CPU_WR_REG 0x64 929026e0d1SMaxime Ripard #define SUN4I_TCON0_CPU_RD0_REG 0x68 939026e0d1SMaxime Ripard #define SUN4I_TCON0_CPU_RDA_REG 0x6c 949026e0d1SMaxime Ripard #define SUN4I_TCON0_TTL0_REG 0x70 959026e0d1SMaxime Ripard #define SUN4I_TCON0_TTL1_REG 0x74 969026e0d1SMaxime Ripard #define SUN4I_TCON0_TTL2_REG 0x78 979026e0d1SMaxime Ripard #define SUN4I_TCON0_TTL3_REG 0x7c 989026e0d1SMaxime Ripard #define SUN4I_TCON0_TTL4_REG 0x80 99a0c1214eSMaxime Ripard 1009026e0d1SMaxime Ripard #define SUN4I_TCON0_LVDS_IF_REG 0x84 101a0c1214eSMaxime Ripard #define SUN4I_TCON0_LVDS_IF_EN BIT(31) 102a0c1214eSMaxime Ripard #define SUN4I_TCON0_LVDS_IF_BITWIDTH_MASK BIT(26) 103a0c1214eSMaxime Ripard #define SUN4I_TCON0_LVDS_IF_BITWIDTH_18BITS (1 << 26) 104a0c1214eSMaxime Ripard #define SUN4I_TCON0_LVDS_IF_BITWIDTH_24BITS (0 << 26) 105a0c1214eSMaxime Ripard #define SUN4I_TCON0_LVDS_IF_CLK_SEL_MASK BIT(20) 106a0c1214eSMaxime Ripard #define SUN4I_TCON0_LVDS_IF_CLK_SEL_TCON0 (1 << 20) 107a0c1214eSMaxime Ripard #define SUN4I_TCON0_LVDS_IF_CLK_POL_MASK BIT(4) 108a0c1214eSMaxime Ripard #define SUN4I_TCON0_LVDS_IF_CLK_POL_NORMAL (1 << 4) 109a0c1214eSMaxime Ripard #define SUN4I_TCON0_LVDS_IF_CLK_POL_INV (0 << 4) 110a0c1214eSMaxime Ripard #define SUN4I_TCON0_LVDS_IF_DATA_POL_MASK GENMASK(3, 0) 111a0c1214eSMaxime Ripard #define SUN4I_TCON0_LVDS_IF_DATA_POL_NORMAL (0xf) 112a0c1214eSMaxime Ripard #define SUN4I_TCON0_LVDS_IF_DATA_POL_INV (0) 113a0c1214eSMaxime Ripard 1149026e0d1SMaxime Ripard #define SUN4I_TCON0_IO_POL_REG 0x88 1159026e0d1SMaxime Ripard #define SUN4I_TCON0_IO_POL_DCLK_PHASE(phase) ((phase & 3) << 28) 11665bf2d54SPaul Kocialkowski #define SUN4I_TCON0_IO_POL_DE_NEGATIVE BIT(27) 11767f4aeb2SGiulio Benetti #define SUN4I_TCON0_IO_POL_DCLK_DRIVE_NEGEDGE BIT(26) 1189026e0d1SMaxime Ripard #define SUN4I_TCON0_IO_POL_HSYNC_POSITIVE BIT(25) 1199026e0d1SMaxime Ripard #define SUN4I_TCON0_IO_POL_VSYNC_POSITIVE BIT(24) 1209026e0d1SMaxime Ripard 1219026e0d1SMaxime Ripard #define SUN4I_TCON0_IO_TRI_REG 0x8c 1229026e0d1SMaxime Ripard #define SUN4I_TCON0_IO_TRI_HSYNC_DISABLE BIT(25) 1239026e0d1SMaxime Ripard #define SUN4I_TCON0_IO_TRI_VSYNC_DISABLE BIT(24) 1249026e0d1SMaxime Ripard #define SUN4I_TCON0_IO_TRI_DATA_PINS_DISABLE(pins) GENMASK(pins, 0) 1259026e0d1SMaxime Ripard 1269026e0d1SMaxime Ripard #define SUN4I_TCON1_CTL_REG 0x90 1279026e0d1SMaxime Ripard #define SUN4I_TCON1_CTL_TCON_ENABLE BIT(31) 1289026e0d1SMaxime Ripard #define SUN4I_TCON1_CTL_INTERLACE_ENABLE BIT(20) 1299026e0d1SMaxime Ripard #define SUN4I_TCON1_CTL_CLK_DELAY_MASK GENMASK(8, 4) 1309026e0d1SMaxime Ripard #define SUN4I_TCON1_CTL_CLK_DELAY(delay) ((delay << 4) & SUN4I_TCON1_CTL_CLK_DELAY_MASK) 13127e18de7SChen-Yu Tsai #define SUN4I_TCON1_CTL_SRC_SEL_MASK GENMASK(1, 0) 1329026e0d1SMaxime Ripard 1339026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC0_REG 0x94 1349026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC0_X(width) ((((width) - 1) & 0xfff) << 16) 1359026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC0_Y(height) (((height) - 1) & 0xfff) 1369026e0d1SMaxime Ripard 1379026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC1_REG 0x98 1389026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC1_X(width) ((((width) - 1) & 0xfff) << 16) 1399026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC1_Y(height) (((height) - 1) & 0xfff) 1409026e0d1SMaxime Ripard 1419026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC2_REG 0x9c 1429026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC2_X(width) ((((width) - 1) & 0xfff) << 16) 1439026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC2_Y(height) (((height) - 1) & 0xfff) 1449026e0d1SMaxime Ripard 1459026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC3_REG 0xa0 1469026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC3_H_TOTAL(total) ((((total) - 1) & 0x1fff) << 16) 1479026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC3_H_BACKPORCH(bp) (((bp) - 1) & 0xfff) 1489026e0d1SMaxime Ripard 1499026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC4_REG 0xa4 1509026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC4_V_TOTAL(total) (((total) & 0x1fff) << 16) 1519026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC4_V_BACKPORCH(bp) (((bp) - 1) & 0xfff) 1529026e0d1SMaxime Ripard 1539026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC5_REG 0xa8 1549026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC5_H_SYNC(width) ((((width) - 1) & 0x3ff) << 16) 1559026e0d1SMaxime Ripard #define SUN4I_TCON1_BASIC5_V_SYNC(height) (((height) - 1) & 0x3ff) 1569026e0d1SMaxime Ripard 1579026e0d1SMaxime Ripard #define SUN4I_TCON1_IO_POL_REG 0xf0 15850791f5dSJernej Skrabec /* there is no documentation about this bit */ 15950791f5dSJernej Skrabec #define SUN4I_TCON1_IO_POL_UNKNOWN BIT(26) 16050791f5dSJernej Skrabec #define SUN4I_TCON1_IO_POL_HSYNC_POSITIVE BIT(25) 16150791f5dSJernej Skrabec #define SUN4I_TCON1_IO_POL_VSYNC_POSITIVE BIT(24) 16250791f5dSJernej Skrabec 1639026e0d1SMaxime Ripard #define SUN4I_TCON1_IO_TRI_REG 0xf4 164a08fc7c8SMaxime Ripard 165a08fc7c8SMaxime Ripard #define SUN4I_TCON_ECC_FIFO_REG 0xf8 166a08fc7c8SMaxime Ripard #define SUN4I_TCON_ECC_FIFO_EN BIT(3) 167a08fc7c8SMaxime Ripard 1689026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_CTL_REG 0x100 1699026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_MUL_RR_REG 0x110 1709026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_MUL_RG_REG 0x114 1719026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_MUL_RB_REG 0x118 1729026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_ADD_RC_REG 0x11c 1739026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_MUL_GR_REG 0x120 1749026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_MUL_GG_REG 0x124 1759026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_MUL_GB_REG 0x128 1769026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_ADD_GC_REG 0x12c 1779026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_MUL_BR_REG 0x130 1789026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_MUL_BG_REG 0x134 1799026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_MUL_BB_REG 0x138 1809026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_ADD_BC_REG 0x13c 1819026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_RANGE_R_REG 0x140 1829026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_RANGE_G_REG 0x144 1839026e0d1SMaxime Ripard #define SUN4I_TCON_CEU_RANGE_B_REG 0x148 184a08fc7c8SMaxime Ripard 185a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CPU_TRI0_REG 0x160 186a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CPU_TRI0_BLOCK_SPACE(space) ((((space) - 1) & 0xfff) << 16) 187a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CPU_TRI0_BLOCK_SIZE(size) (((size) - 1) & 0xfff) 188a08fc7c8SMaxime Ripard 189a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CPU_TRI1_REG 0x164 190a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CPU_TRI1_BLOCK_NUM(num) (((num) - 1) & 0xffff) 191a08fc7c8SMaxime Ripard 192a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CPU_TRI2_REG 0x168 193a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CPU_TRI2_START_DELAY(delay) (((delay) & 0xffff) << 16) 194a08fc7c8SMaxime Ripard #define SUN4I_TCON0_CPU_TRI2_TRANS_START_SET(set) ((set) & 0xfff) 195a08fc7c8SMaxime Ripard 196a08fc7c8SMaxime Ripard #define SUN4I_TCON_SAFE_PERIOD_REG 0x1f0 197a08fc7c8SMaxime Ripard #define SUN4I_TCON_SAFE_PERIOD_NUM(num) (((num) & 0xfff) << 16) 198a08fc7c8SMaxime Ripard #define SUN4I_TCON_SAFE_PERIOD_MODE(mode) ((mode) & 0x3) 199a08fc7c8SMaxime Ripard 2009026e0d1SMaxime Ripard #define SUN4I_TCON_MUX_CTRL_REG 0x200 201a0c1214eSMaxime Ripard 202a0c1214eSMaxime Ripard #define SUN4I_TCON0_LVDS_ANA0_REG 0x220 203d718e53aSAndrey Lebedev #define SUN4I_TCON0_LVDS_ANA0_DCHS BIT(16) 204d718e53aSAndrey Lebedev #define SUN4I_TCON0_LVDS_ANA0_PD (BIT(20) | BIT(21)) 205d718e53aSAndrey Lebedev #define SUN4I_TCON0_LVDS_ANA0_EN_MB BIT(22) 206d718e53aSAndrey Lebedev #define SUN4I_TCON0_LVDS_ANA0_REG_C (BIT(24) | BIT(25)) 207d718e53aSAndrey Lebedev #define SUN4I_TCON0_LVDS_ANA0_REG_V (BIT(26) | BIT(27)) 208d718e53aSAndrey Lebedev #define SUN4I_TCON0_LVDS_ANA0_CK_EN (BIT(29) | BIT(28)) 209d718e53aSAndrey Lebedev 210a0c1214eSMaxime Ripard #define SUN6I_TCON0_LVDS_ANA0_EN_MB BIT(31) 211a0c1214eSMaxime Ripard #define SUN6I_TCON0_LVDS_ANA0_EN_LDO BIT(30) 212a0c1214eSMaxime Ripard #define SUN6I_TCON0_LVDS_ANA0_EN_DRVC BIT(24) 213a0c1214eSMaxime Ripard #define SUN6I_TCON0_LVDS_ANA0_EN_DRVD(x) (((x) & 0xf) << 20) 214a0c1214eSMaxime Ripard #define SUN6I_TCON0_LVDS_ANA0_C(x) (((x) & 3) << 17) 215a0c1214eSMaxime Ripard #define SUN6I_TCON0_LVDS_ANA0_V(x) (((x) & 3) << 8) 216a0c1214eSMaxime Ripard #define SUN6I_TCON0_LVDS_ANA0_PD(x) (((x) & 3) << 4) 217a0c1214eSMaxime Ripard 218d718e53aSAndrey Lebedev #define SUN4I_TCON0_LVDS_ANA1_REG 0x224 219d718e53aSAndrey Lebedev #define SUN4I_TCON0_LVDS_ANA1_INIT (0x1f << 26 | 0x1f << 10) 220d718e53aSAndrey Lebedev #define SUN4I_TCON0_LVDS_ANA1_UPDATE (0x1f << 16 | 0x1f << 00) 221d718e53aSAndrey Lebedev 2229026e0d1SMaxime Ripard #define SUN4I_TCON1_FILL_CTL_REG 0x300 2239026e0d1SMaxime Ripard #define SUN4I_TCON1_FILL_BEG0_REG 0x304 2249026e0d1SMaxime Ripard #define SUN4I_TCON1_FILL_END0_REG 0x308 2259026e0d1SMaxime Ripard #define SUN4I_TCON1_FILL_DATA0_REG 0x30c 2269026e0d1SMaxime Ripard #define SUN4I_TCON1_FILL_BEG1_REG 0x310 2279026e0d1SMaxime Ripard #define SUN4I_TCON1_FILL_END1_REG 0x314 2289026e0d1SMaxime Ripard #define SUN4I_TCON1_FILL_DATA1_REG 0x318 2299026e0d1SMaxime Ripard #define SUN4I_TCON1_FILL_BEG2_REG 0x31c 2309026e0d1SMaxime Ripard #define SUN4I_TCON1_FILL_END2_REG 0x320 2319026e0d1SMaxime Ripard #define SUN4I_TCON1_FILL_DATA2_REG 0x324 2329026e0d1SMaxime Ripard #define SUN4I_TCON1_GAMMA_TABLE_REG 0x400 2339026e0d1SMaxime Ripard 2349026e0d1SMaxime Ripard #define SUN4I_TCON_MAX_CHANNELS 2 2359026e0d1SMaxime Ripard 236ad537fb2SChen-Yu Tsai struct sun4i_tcon; 237ad537fb2SChen-Yu Tsai 23891ea2f29SChen-Yu Tsai struct sun4i_tcon_quirks { 23934d698f6SJernej Skrabec bool has_channel_0; /* a83t does not have channel 0 on second TCON */ 24091ea2f29SChen-Yu Tsai bool has_channel_1; /* a33 does not have channel 1 */ 241a0c1214eSMaxime Ripard bool has_lvds_alt; /* Does the LVDS clock have a parent other than the TCON clock? */ 24227e18de7SChen-Yu Tsai bool needs_de_be_mux; /* sun6i needs mux to select backend */ 2436664e9dcSChen-Yu Tsai bool needs_edp_reset; /* a80 edp reset needed for tcon0 access */ 244e742a17cSMaxime Ripard bool supports_lvds; /* Does the TCON support an LVDS output? */ 24550791f5dSJernej Skrabec bool polarity_in_ch0; /* some tcon1 channels have polarity bits in tcon0 pol register */ 2464396393fSChen-Yu Tsai u8 dclk_min_div; /* minimum divider for TCON0 DCLK */ 247ad537fb2SChen-Yu Tsai 248ad537fb2SChen-Yu Tsai /* callback to handle tcon muxing options */ 249abcb8766SMaxime Ripard int (*set_mux)(struct sun4i_tcon *, const struct drm_encoder *); 2505627c9d8SAndrey Lebedev /* handler for LVDS setup routine */ 2515627c9d8SAndrey Lebedev void (*setup_lvds_phy)(struct sun4i_tcon *tcon, 2525627c9d8SAndrey Lebedev const struct drm_encoder *encoder); 25391ea2f29SChen-Yu Tsai }; 25491ea2f29SChen-Yu Tsai 2559026e0d1SMaxime Ripard struct sun4i_tcon { 256ae558110SMaxime Ripard struct device *dev; 2579026e0d1SMaxime Ripard struct drm_device *drm; 2589026e0d1SMaxime Ripard struct regmap *regs; 2599026e0d1SMaxime Ripard 2609026e0d1SMaxime Ripard /* Main bus clock */ 2619026e0d1SMaxime Ripard struct clk *clk; 2629026e0d1SMaxime Ripard 2639026e0d1SMaxime Ripard /* Clocks for the TCON channels */ 2649026e0d1SMaxime Ripard struct clk *sclk0; 2659026e0d1SMaxime Ripard struct clk *sclk1; 2669026e0d1SMaxime Ripard 267a0c1214eSMaxime Ripard /* Possible mux for the LVDS clock */ 268a0c1214eSMaxime Ripard struct clk *lvds_pll; 269a0c1214eSMaxime Ripard 2709026e0d1SMaxime Ripard /* Pixel clock */ 2719026e0d1SMaxime Ripard struct clk *dclk; 272ec08d596SMaxime Ripard u8 dclk_max_div; 273ec08d596SMaxime Ripard u8 dclk_min_div; 2749026e0d1SMaxime Ripard 2759026e0d1SMaxime Ripard /* Reset control */ 2769026e0d1SMaxime Ripard struct reset_control *lcd_rst; 277a0c1214eSMaxime Ripard struct reset_control *lvds_rst; 2789026e0d1SMaxime Ripard 27991ea2f29SChen-Yu Tsai /* Platform adjustments */ 28091ea2f29SChen-Yu Tsai const struct sun4i_tcon_quirks *quirks; 28146cce6daSChen-Yu Tsai 28246cce6daSChen-Yu Tsai /* Associated crtc */ 28346cce6daSChen-Yu Tsai struct sun4i_crtc *crtc; 28480a58240SChen-Yu Tsai 285d281c862SChen-Yu Tsai int id; 286d281c862SChen-Yu Tsai 28780a58240SChen-Yu Tsai /* TCON list management */ 28880a58240SChen-Yu Tsai struct list_head list; 2899026e0d1SMaxime Ripard }; 2909026e0d1SMaxime Ripard 291894f5a9fSMaxime Ripard struct drm_bridge *sun4i_tcon_find_bridge(struct device_node *node); 292a8444c7eSMaxime Ripard struct drm_panel *sun4i_tcon_find_panel(struct device_node *node); 293a8444c7eSMaxime Ripard 2949026e0d1SMaxime Ripard void sun4i_tcon_enable_vblank(struct sun4i_tcon *tcon, bool enable); 2955b8f0910SMaxime Ripard void sun4i_tcon_mode_set(struct sun4i_tcon *tcon, 2965b8f0910SMaxime Ripard const struct drm_encoder *encoder, 2975b8f0910SMaxime Ripard const struct drm_display_mode *mode); 29845e88f99SMaxime Ripard void sun4i_tcon_set_status(struct sun4i_tcon *crtc, 29945e88f99SMaxime Ripard const struct drm_encoder *encoder, bool enable); 3009026e0d1SMaxime Ripard 301ff71c2cfSChen-Yu Tsai extern const struct of_device_id sun4i_tcon_of_table[]; 302ff71c2cfSChen-Yu Tsai 3039026e0d1SMaxime Ripard #endif /* __SUN4I_TCON_H__ */ 304