| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2015 Free Electrons |
|---|
| 3 | 4 | * Copyright (C) 2015 NextThing Co |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * Boris Brezillon <boris.brezillon@free-electrons.com> |
|---|
| 6 | 7 | * Maxime Ripard <maxime.ripard@free-electrons.com> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or |
|---|
| 9 | | - * modify it under the terms of the GNU General Public License as |
|---|
| 10 | | - * published by the Free Software Foundation; either version 2 of |
|---|
| 11 | | - * the License, or (at your option) any later version. |
|---|
| 12 | 8 | */ |
|---|
| 13 | 9 | |
|---|
| 14 | 10 | #ifndef __SUN4I_TCON_H__ |
|---|
| .. | .. |
|---|
| 37 | 33 | #define SUN4I_TCON_GINT1_REG 0x8 |
|---|
| 38 | 34 | |
|---|
| 39 | 35 | #define SUN4I_TCON_FRM_CTL_REG 0x10 |
|---|
| 40 | | -#define SUN4I_TCON_FRM_CTL_EN BIT(31) |
|---|
| 36 | +#define SUN4I_TCON0_FRM_CTL_EN BIT(31) |
|---|
| 37 | +#define SUN4I_TCON0_FRM_CTL_MODE_R BIT(6) |
|---|
| 38 | +#define SUN4I_TCON0_FRM_CTL_MODE_G BIT(5) |
|---|
| 39 | +#define SUN4I_TCON0_FRM_CTL_MODE_B BIT(4) |
|---|
| 41 | 40 | |
|---|
| 42 | | -#define SUN4I_TCON_FRM_SEED_PR_REG 0x14 |
|---|
| 43 | | -#define SUN4I_TCON_FRM_SEED_PG_REG 0x18 |
|---|
| 44 | | -#define SUN4I_TCON_FRM_SEED_PB_REG 0x1c |
|---|
| 45 | | -#define SUN4I_TCON_FRM_SEED_LR_REG 0x20 |
|---|
| 46 | | -#define SUN4I_TCON_FRM_SEED_LG_REG 0x24 |
|---|
| 47 | | -#define SUN4I_TCON_FRM_SEED_LB_REG 0x28 |
|---|
| 48 | | -#define SUN4I_TCON_FRM_TBL0_REG 0x2c |
|---|
| 49 | | -#define SUN4I_TCON_FRM_TBL1_REG 0x30 |
|---|
| 50 | | -#define SUN4I_TCON_FRM_TBL2_REG 0x34 |
|---|
| 51 | | -#define SUN4I_TCON_FRM_TBL3_REG 0x38 |
|---|
| 41 | +#define SUN4I_TCON0_FRM_SEED_PR_REG 0x14 |
|---|
| 42 | +#define SUN4I_TCON0_FRM_SEED_PG_REG 0x18 |
|---|
| 43 | +#define SUN4I_TCON0_FRM_SEED_PB_REG 0x1c |
|---|
| 44 | +#define SUN4I_TCON0_FRM_SEED_LR_REG 0x20 |
|---|
| 45 | +#define SUN4I_TCON0_FRM_SEED_LG_REG 0x24 |
|---|
| 46 | +#define SUN4I_TCON0_FRM_SEED_LB_REG 0x28 |
|---|
| 47 | +#define SUN4I_TCON0_FRM_TBL0_REG 0x2c |
|---|
| 48 | +#define SUN4I_TCON0_FRM_TBL1_REG 0x30 |
|---|
| 49 | +#define SUN4I_TCON0_FRM_TBL2_REG 0x34 |
|---|
| 50 | +#define SUN4I_TCON0_FRM_TBL3_REG 0x38 |
|---|
| 52 | 51 | |
|---|
| 53 | 52 | #define SUN4I_TCON0_CTL_REG 0x40 |
|---|
| 54 | 53 | #define SUN4I_TCON0_CTL_TCON_ENABLE BIT(31) |
|---|
| .. | .. |
|---|
| 113 | 112 | |
|---|
| 114 | 113 | #define SUN4I_TCON0_IO_POL_REG 0x88 |
|---|
| 115 | 114 | #define SUN4I_TCON0_IO_POL_DCLK_PHASE(phase) ((phase & 3) << 28) |
|---|
| 115 | +#define SUN4I_TCON0_IO_POL_DE_NEGATIVE BIT(27) |
|---|
| 116 | +#define SUN4I_TCON0_IO_POL_DCLK_DRIVE_NEGEDGE BIT(26) |
|---|
| 116 | 117 | #define SUN4I_TCON0_IO_POL_HSYNC_POSITIVE BIT(25) |
|---|
| 117 | 118 | #define SUN4I_TCON0_IO_POL_VSYNC_POSITIVE BIT(24) |
|---|
| 118 | 119 | |
|---|
| .. | .. |
|---|
| 153 | 154 | #define SUN4I_TCON1_BASIC5_V_SYNC(height) (((height) - 1) & 0x3ff) |
|---|
| 154 | 155 | |
|---|
| 155 | 156 | #define SUN4I_TCON1_IO_POL_REG 0xf0 |
|---|
| 157 | +/* there is no documentation about this bit */ |
|---|
| 158 | +#define SUN4I_TCON1_IO_POL_UNKNOWN BIT(26) |
|---|
| 159 | +#define SUN4I_TCON1_IO_POL_HSYNC_POSITIVE BIT(25) |
|---|
| 160 | +#define SUN4I_TCON1_IO_POL_VSYNC_POSITIVE BIT(24) |
|---|
| 161 | + |
|---|
| 156 | 162 | #define SUN4I_TCON1_IO_TRI_REG 0xf4 |
|---|
| 157 | 163 | |
|---|
| 158 | 164 | #define SUN4I_TCON_ECC_FIFO_REG 0xf8 |
|---|
| .. | .. |
|---|
| 193 | 199 | #define SUN4I_TCON_MUX_CTRL_REG 0x200 |
|---|
| 194 | 200 | |
|---|
| 195 | 201 | #define SUN4I_TCON0_LVDS_ANA0_REG 0x220 |
|---|
| 202 | +#define SUN4I_TCON0_LVDS_ANA0_DCHS BIT(16) |
|---|
| 203 | +#define SUN4I_TCON0_LVDS_ANA0_PD (BIT(20) | BIT(21)) |
|---|
| 204 | +#define SUN4I_TCON0_LVDS_ANA0_EN_MB BIT(22) |
|---|
| 205 | +#define SUN4I_TCON0_LVDS_ANA0_REG_C (BIT(24) | BIT(25)) |
|---|
| 206 | +#define SUN4I_TCON0_LVDS_ANA0_REG_V (BIT(26) | BIT(27)) |
|---|
| 207 | +#define SUN4I_TCON0_LVDS_ANA0_CK_EN (BIT(29) | BIT(28)) |
|---|
| 208 | + |
|---|
| 196 | 209 | #define SUN6I_TCON0_LVDS_ANA0_EN_MB BIT(31) |
|---|
| 197 | 210 | #define SUN6I_TCON0_LVDS_ANA0_EN_LDO BIT(30) |
|---|
| 198 | 211 | #define SUN6I_TCON0_LVDS_ANA0_EN_DRVC BIT(24) |
|---|
| .. | .. |
|---|
| 200 | 213 | #define SUN6I_TCON0_LVDS_ANA0_C(x) (((x) & 3) << 17) |
|---|
| 201 | 214 | #define SUN6I_TCON0_LVDS_ANA0_V(x) (((x) & 3) << 8) |
|---|
| 202 | 215 | #define SUN6I_TCON0_LVDS_ANA0_PD(x) (((x) & 3) << 4) |
|---|
| 216 | + |
|---|
| 217 | +#define SUN4I_TCON0_LVDS_ANA1_REG 0x224 |
|---|
| 218 | +#define SUN4I_TCON0_LVDS_ANA1_INIT (0x1f << 26 | 0x1f << 10) |
|---|
| 219 | +#define SUN4I_TCON0_LVDS_ANA1_UPDATE (0x1f << 16 | 0x1f << 00) |
|---|
| 203 | 220 | |
|---|
| 204 | 221 | #define SUN4I_TCON1_FILL_CTL_REG 0x300 |
|---|
| 205 | 222 | #define SUN4I_TCON1_FILL_BEG0_REG 0x304 |
|---|
| .. | .. |
|---|
| 224 | 241 | bool needs_de_be_mux; /* sun6i needs mux to select backend */ |
|---|
| 225 | 242 | bool needs_edp_reset; /* a80 edp reset needed for tcon0 access */ |
|---|
| 226 | 243 | bool supports_lvds; /* Does the TCON support an LVDS output? */ |
|---|
| 244 | + bool polarity_in_ch0; /* some tcon1 channels have polarity bits in tcon0 pol register */ |
|---|
| 227 | 245 | u8 dclk_min_div; /* minimum divider for TCON0 DCLK */ |
|---|
| 228 | 246 | |
|---|
| 229 | 247 | /* callback to handle tcon muxing options */ |
|---|
| 230 | 248 | int (*set_mux)(struct sun4i_tcon *, const struct drm_encoder *); |
|---|
| 249 | + /* handler for LVDS setup routine */ |
|---|
| 250 | + void (*setup_lvds_phy)(struct sun4i_tcon *tcon, |
|---|
| 251 | + const struct drm_encoder *encoder); |
|---|
| 231 | 252 | }; |
|---|
| 232 | 253 | |
|---|
| 233 | 254 | struct sun4i_tcon { |
|---|
| .. | .. |
|---|
| 253 | 274 | /* Reset control */ |
|---|
| 254 | 275 | struct reset_control *lcd_rst; |
|---|
| 255 | 276 | struct reset_control *lvds_rst; |
|---|
| 256 | | - |
|---|
| 257 | | - struct drm_panel *panel; |
|---|
| 258 | 277 | |
|---|
| 259 | 278 | /* Platform adjustments */ |
|---|
| 260 | 279 | const struct sun4i_tcon_quirks *quirks; |
|---|