18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
48c2ecf20Sopenharmony_ci * Author:
58c2ecf20Sopenharmony_ci *      Sandy Huang <hjc@rock-chips.com>
68c2ecf20Sopenharmony_ci *      Mark Yao <mark.yao@rock-chips.com>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef _ROCKCHIP_LVDS_
108c2ecf20Sopenharmony_ci#define _ROCKCHIP_LVDS_
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG0			0x00
138c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG0_LVDS_EN		BIT(7)
148c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG0_TTL_EN		BIT(6)
158c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG0_LANECK_EN		BIT(5)
168c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG0_LANE4_EN		BIT(4)
178c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG0_LANE3_EN		BIT(3)
188c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG0_LANE2_EN		BIT(2)
198c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG0_LANE1_EN		BIT(1)
208c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG0_LANE0_EN		BIT(0)
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG1			0x04
238c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG1_LANECK_BIAS	BIT(5)
248c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG1_LANE4_BIAS		BIT(4)
258c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG1_LANE3_BIAS		BIT(3)
268c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG1_LANE2_BIAS		BIT(2)
278c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG1_LANE1_BIAS		BIT(1)
288c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG1_LANE0_BIAS		BIT(0)
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG2			0x08
318c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG2_RESERVE_ON		BIT(7)
328c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG2_LANECK_LVDS_MODE	BIT(6)
338c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG2_LANE4_LVDS_MODE	BIT(5)
348c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG2_LANE3_LVDS_MODE	BIT(4)
358c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG2_LANE2_LVDS_MODE	BIT(3)
368c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG2_LANE1_LVDS_MODE	BIT(2)
378c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG2_LANE0_LVDS_MODE	BIT(1)
388c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG2_PLL_FBDIV8		BIT(0)
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG3			0x0c
418c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG3_PLL_FBDIV_MASK	0xff
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG4			0x10
448c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG4_LANECK_TTL_MODE	BIT(5)
458c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG4_LANE4_TTL_MODE	BIT(4)
468c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG4_LANE3_TTL_MODE	BIT(3)
478c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG4_LANE2_TTL_MODE	BIT(2)
488c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG4_LANE1_TTL_MODE	BIT(1)
498c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG4_LANE0_TTL_MODE	BIT(0)
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG5			0x14
528c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG5_LANECK_TTL_DATA	BIT(5)
538c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG5_LANE4_TTL_DATA	BIT(4)
548c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG5_LANE3_TTL_DATA	BIT(3)
558c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG5_LANE2_TTL_DATA	BIT(2)
568c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG5_LANE1_TTL_DATA	BIT(1)
578c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG5_LANE0_TTL_DATA	BIT(0)
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define RK3288_LVDS_CFG_REGC			0x30
608c2ecf20Sopenharmony_ci#define RK3288_LVDS_CFG_REGC_PLL_ENABLE		0x00
618c2ecf20Sopenharmony_ci#define RK3288_LVDS_CFG_REGC_PLL_DISABLE	0xff
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REGD			0x34
648c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REGD_PLL_PREDIV_MASK	0x1f
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG20			0x80
678c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG20_MSB		0x45
688c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH0_REG20_LSB		0x44
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci#define RK3288_LVDS_CFG_REG21			0x84
718c2ecf20Sopenharmony_ci#define RK3288_LVDS_CFG_REG21_TX_ENABLE		0x92
728c2ecf20Sopenharmony_ci#define RK3288_LVDS_CFG_REG21_TX_DISABLE	0x00
738c2ecf20Sopenharmony_ci#define RK3288_LVDS_CH1_OFFSET			0x100
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#define RK3288_LVDS_GRF_SOC_CON6		0x025C
768c2ecf20Sopenharmony_ci#define RK3288_LVDS_GRF_SOC_CON7		0x0260
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci/* fbdiv value is split over 2 registers, with bit8 in reg2 */
798c2ecf20Sopenharmony_ci#define RK3288_LVDS_PLL_FBDIV_REG2(_fbd) \
808c2ecf20Sopenharmony_ci		(_fbd & BIT(8) ? RK3288_LVDS_CH0_REG2_PLL_FBDIV8 : 0)
818c2ecf20Sopenharmony_ci#define RK3288_LVDS_PLL_FBDIV_REG3(_fbd) \
828c2ecf20Sopenharmony_ci		(_fbd & RK3288_LVDS_CH0_REG3_PLL_FBDIV_MASK)
838c2ecf20Sopenharmony_ci#define RK3288_LVDS_PLL_PREDIV_REGD(_pd) \
848c2ecf20Sopenharmony_ci		(_pd & RK3288_LVDS_CH0_REGD_PLL_PREDIV_MASK)
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#define RK3288_LVDS_SOC_CON6_SEL_VOP_LIT	BIT(3)
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#define LVDS_FMT_MASK				(0x07 << 16)
898c2ecf20Sopenharmony_ci#define LVDS_MSB				BIT(3)
908c2ecf20Sopenharmony_ci#define LVDS_DUAL				BIT(4)
918c2ecf20Sopenharmony_ci#define LVDS_FMT_1				BIT(5)
928c2ecf20Sopenharmony_ci#define LVDS_TTL_EN				BIT(6)
938c2ecf20Sopenharmony_ci#define LVDS_START_PHASE_RST_1			BIT(7)
948c2ecf20Sopenharmony_ci#define LVDS_DCLK_INV				BIT(8)
958c2ecf20Sopenharmony_ci#define LVDS_CH0_EN				BIT(11)
968c2ecf20Sopenharmony_ci#define LVDS_CH1_EN				BIT(12)
978c2ecf20Sopenharmony_ci#define LVDS_PWRDN				BIT(15)
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci#define LVDS_24BIT				(0 << 1)
1008c2ecf20Sopenharmony_ci#define LVDS_18BIT				(1 << 1)
1018c2ecf20Sopenharmony_ci#define LVDS_FORMAT_VESA			(0 << 0)
1028c2ecf20Sopenharmony_ci#define LVDS_FORMAT_JEIDA			(1 << 0)
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#define LVDS_VESA_24				0
1058c2ecf20Sopenharmony_ci#define LVDS_JEIDA_24				1
1068c2ecf20Sopenharmony_ci#define LVDS_VESA_18				2
1078c2ecf20Sopenharmony_ci#define LVDS_JEIDA_18				3
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#define HIWORD_UPDATE(v, h, l)  ((GENMASK(h, l) << 16) | ((v) << (l)))
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci#define PX30_LVDS_GRF_PD_VO_CON0		0x434
1128c2ecf20Sopenharmony_ci#define   PX30_LVDS_TIE_CLKS(val)		HIWORD_UPDATE(val,  8,  8)
1138c2ecf20Sopenharmony_ci#define   PX30_LVDS_INVERT_CLKS(val)		HIWORD_UPDATE(val,  9,  9)
1148c2ecf20Sopenharmony_ci#define   PX30_LVDS_INVERT_DCLK(val)		HIWORD_UPDATE(val,  5,  5)
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#define PX30_LVDS_GRF_PD_VO_CON1		0x438
1178c2ecf20Sopenharmony_ci#define   PX30_LVDS_FORMAT(val)			HIWORD_UPDATE(val, 14, 13)
1188c2ecf20Sopenharmony_ci#define   PX30_LVDS_MODE_EN(val)		HIWORD_UPDATE(val, 12, 12)
1198c2ecf20Sopenharmony_ci#define   PX30_LVDS_MSBSEL(val)			HIWORD_UPDATE(val, 11, 11)
1208c2ecf20Sopenharmony_ci#define   PX30_LVDS_P2S_EN(val)			HIWORD_UPDATE(val,  6,  6)
1218c2ecf20Sopenharmony_ci#define   PX30_LVDS_VOP_SEL(val)		HIWORD_UPDATE(val,  1,  1)
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci#endif /* _ROCKCHIP_LVDS_ */
124