18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/* Geode LX framebuffer driver
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 2006-2007, Advanced Micro Devices,Inc.
58c2ecf20Sopenharmony_ci * Copyright (c) 2008  Andres Salomon <dilinger@debian.org>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci#ifndef _LXFB_H_
88c2ecf20Sopenharmony_ci#define _LXFB_H_
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/fb.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define GP_REG_COUNT	(0x7c / 4)
138c2ecf20Sopenharmony_ci#define DC_REG_COUNT	(0xf0 / 4)
148c2ecf20Sopenharmony_ci#define VP_REG_COUNT	(0x158 / 8)
158c2ecf20Sopenharmony_ci#define FP_REG_COUNT	(0x60 / 8)
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define DC_PAL_COUNT	0x104
188c2ecf20Sopenharmony_ci#define DC_HFILT_COUNT	0x100
198c2ecf20Sopenharmony_ci#define DC_VFILT_COUNT	0x100
208c2ecf20Sopenharmony_ci#define VP_COEFF_SIZE	0x1000
218c2ecf20Sopenharmony_ci#define VP_PAL_COUNT	0x100
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define OUTPUT_CRT   0x01
248c2ecf20Sopenharmony_ci#define OUTPUT_PANEL 0x02
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistruct lxfb_par {
278c2ecf20Sopenharmony_ci	int output;
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci	void __iomem *gp_regs;
308c2ecf20Sopenharmony_ci	void __iomem *dc_regs;
318c2ecf20Sopenharmony_ci	void __iomem *vp_regs;
328c2ecf20Sopenharmony_ci	int powered_down;
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	/* register state, for power mgmt functionality */
358c2ecf20Sopenharmony_ci	struct {
368c2ecf20Sopenharmony_ci		uint64_t padsel;
378c2ecf20Sopenharmony_ci		uint64_t dotpll;
388c2ecf20Sopenharmony_ci		uint64_t dfglcfg;
398c2ecf20Sopenharmony_ci		uint64_t dcspare;
408c2ecf20Sopenharmony_ci	} msr;
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci	uint32_t gp[GP_REG_COUNT];
438c2ecf20Sopenharmony_ci	uint32_t dc[DC_REG_COUNT];
448c2ecf20Sopenharmony_ci	uint64_t vp[VP_REG_COUNT];
458c2ecf20Sopenharmony_ci	uint64_t fp[FP_REG_COUNT];
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	uint32_t dc_pal[DC_PAL_COUNT];
488c2ecf20Sopenharmony_ci	uint32_t vp_pal[VP_PAL_COUNT];
498c2ecf20Sopenharmony_ci	uint32_t hcoeff[DC_HFILT_COUNT * 2];
508c2ecf20Sopenharmony_ci	uint32_t vcoeff[DC_VFILT_COUNT];
518c2ecf20Sopenharmony_ci	uint32_t vp_coeff[VP_COEFF_SIZE / 4];
528c2ecf20Sopenharmony_ci};
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_cistatic inline unsigned int lx_get_pitch(unsigned int xres, int bpp)
558c2ecf20Sopenharmony_ci{
568c2ecf20Sopenharmony_ci	return (((xres * (bpp >> 3)) + 7) & ~7);
578c2ecf20Sopenharmony_ci}
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_civoid lx_set_mode(struct fb_info *);
608c2ecf20Sopenharmony_ciunsigned int lx_framebuffer_size(void);
618c2ecf20Sopenharmony_ciint lx_blank_display(struct fb_info *, int);
628c2ecf20Sopenharmony_civoid lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int,
638c2ecf20Sopenharmony_ci			unsigned int, unsigned int);
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ciint lx_powerdown(struct fb_info *info);
668c2ecf20Sopenharmony_ciint lx_powerup(struct fb_info *info);
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci/* Graphics Processor registers (table 6-29 from the data book) */
698c2ecf20Sopenharmony_cienum gp_registers {
708c2ecf20Sopenharmony_ci	GP_DST_OFFSET = 0,
718c2ecf20Sopenharmony_ci	GP_SRC_OFFSET,
728c2ecf20Sopenharmony_ci	GP_STRIDE,
738c2ecf20Sopenharmony_ci	GP_WID_HEIGHT,
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci	GP_SRC_COLOR_FG,
768c2ecf20Sopenharmony_ci	GP_SRC_COLOR_BG,
778c2ecf20Sopenharmony_ci	GP_PAT_COLOR_0,
788c2ecf20Sopenharmony_ci	GP_PAT_COLOR_1,
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	GP_PAT_COLOR_2,
818c2ecf20Sopenharmony_ci	GP_PAT_COLOR_3,
828c2ecf20Sopenharmony_ci	GP_PAT_COLOR_4,
838c2ecf20Sopenharmony_ci	GP_PAT_COLOR_5,
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci	GP_PAT_DATA_0,
868c2ecf20Sopenharmony_ci	GP_PAT_DATA_1,
878c2ecf20Sopenharmony_ci	GP_RASTER_MODE,
888c2ecf20Sopenharmony_ci	GP_VECTOR_MODE,
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci	GP_BLT_MODE,
918c2ecf20Sopenharmony_ci	GP_BLT_STATUS,
928c2ecf20Sopenharmony_ci	GP_HST_SRC,
938c2ecf20Sopenharmony_ci	GP_BASE_OFFSET,
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	GP_CMD_TOP,
968c2ecf20Sopenharmony_ci	GP_CMD_BOT,
978c2ecf20Sopenharmony_ci	GP_CMD_READ,
988c2ecf20Sopenharmony_ci	GP_CMD_WRITE,
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci	GP_CH3_OFFSET,
1018c2ecf20Sopenharmony_ci	GP_CH3_MODE_STR,
1028c2ecf20Sopenharmony_ci	GP_CH3_WIDHI,
1038c2ecf20Sopenharmony_ci	GP_CH3_HSRC,
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci	GP_LUT_INDEX,
1068c2ecf20Sopenharmony_ci	GP_LUT_DATA,
1078c2ecf20Sopenharmony_ci	GP_INT_CNTRL, /* 0x78 */
1088c2ecf20Sopenharmony_ci};
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#define GP_BLT_STATUS_CE		(1 << 4)	/* cmd buf empty */
1118c2ecf20Sopenharmony_ci#define GP_BLT_STATUS_PB		(1 << 0)	/* primitive busy */
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci/* Display Controller registers (table 6-47 from the data book) */
1158c2ecf20Sopenharmony_cienum dc_registers {
1168c2ecf20Sopenharmony_ci	DC_UNLOCK = 0,
1178c2ecf20Sopenharmony_ci	DC_GENERAL_CFG,
1188c2ecf20Sopenharmony_ci	DC_DISPLAY_CFG,
1198c2ecf20Sopenharmony_ci	DC_ARB_CFG,
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci	DC_FB_ST_OFFSET,
1228c2ecf20Sopenharmony_ci	DC_CB_ST_OFFSET,
1238c2ecf20Sopenharmony_ci	DC_CURS_ST_OFFSET,
1248c2ecf20Sopenharmony_ci	DC_RSVD_0,
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci	DC_VID_Y_ST_OFFSET,
1278c2ecf20Sopenharmony_ci	DC_VID_U_ST_OFFSET,
1288c2ecf20Sopenharmony_ci	DC_VID_V_ST_OFFSET,
1298c2ecf20Sopenharmony_ci	DC_DV_TOP,
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci	DC_LINE_SIZE,
1328c2ecf20Sopenharmony_ci	DC_GFX_PITCH,
1338c2ecf20Sopenharmony_ci	DC_VID_YUV_PITCH,
1348c2ecf20Sopenharmony_ci	DC_RSVD_1,
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	DC_H_ACTIVE_TIMING,
1378c2ecf20Sopenharmony_ci	DC_H_BLANK_TIMING,
1388c2ecf20Sopenharmony_ci	DC_H_SYNC_TIMING,
1398c2ecf20Sopenharmony_ci	DC_RSVD_2,
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci	DC_V_ACTIVE_TIMING,
1428c2ecf20Sopenharmony_ci	DC_V_BLANK_TIMING,
1438c2ecf20Sopenharmony_ci	DC_V_SYNC_TIMING,
1448c2ecf20Sopenharmony_ci	DC_FB_ACTIVE,
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci	DC_CURSOR_X,
1478c2ecf20Sopenharmony_ci	DC_CURSOR_Y,
1488c2ecf20Sopenharmony_ci	DC_RSVD_3,
1498c2ecf20Sopenharmony_ci	DC_LINE_CNT,
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci	DC_PAL_ADDRESS,
1528c2ecf20Sopenharmony_ci	DC_PAL_DATA,
1538c2ecf20Sopenharmony_ci	DC_DFIFO_DIAG,
1548c2ecf20Sopenharmony_ci	DC_CFIFO_DIAG,
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci	DC_VID_DS_DELTA,
1578c2ecf20Sopenharmony_ci	DC_GLIU0_MEM_OFFSET,
1588c2ecf20Sopenharmony_ci	DC_DV_CTL,
1598c2ecf20Sopenharmony_ci	DC_DV_ACCESS,
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci	DC_GFX_SCALE,
1628c2ecf20Sopenharmony_ci	DC_IRQ_FILT_CTL,
1638c2ecf20Sopenharmony_ci	DC_FILT_COEFF1,
1648c2ecf20Sopenharmony_ci	DC_FILT_COEFF2,
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci	DC_VBI_EVEN_CTL,
1678c2ecf20Sopenharmony_ci	DC_VBI_ODD_CTL,
1688c2ecf20Sopenharmony_ci	DC_VBI_HOR,
1698c2ecf20Sopenharmony_ci	DC_VBI_LN_ODD,
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci	DC_VBI_LN_EVEN,
1728c2ecf20Sopenharmony_ci	DC_VBI_PITCH,
1738c2ecf20Sopenharmony_ci	DC_CLR_KEY,
1748c2ecf20Sopenharmony_ci	DC_CLR_KEY_MASK,
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci	DC_CLR_KEY_X,
1778c2ecf20Sopenharmony_ci	DC_CLR_KEY_Y,
1788c2ecf20Sopenharmony_ci	DC_IRQ,
1798c2ecf20Sopenharmony_ci	DC_RSVD_4,
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci	DC_RSVD_5,
1828c2ecf20Sopenharmony_ci	DC_GENLK_CTL,
1838c2ecf20Sopenharmony_ci	DC_VID_EVEN_Y_ST_OFFSET,
1848c2ecf20Sopenharmony_ci	DC_VID_EVEN_U_ST_OFFSET,
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci	DC_VID_EVEN_V_ST_OFFSET,
1878c2ecf20Sopenharmony_ci	DC_V_ACTIVE_EVEN_TIMING,
1888c2ecf20Sopenharmony_ci	DC_V_BLANK_EVEN_TIMING,
1898c2ecf20Sopenharmony_ci	DC_V_SYNC_EVEN_TIMING,	/* 0xec */
1908c2ecf20Sopenharmony_ci};
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci#define DC_UNLOCK_LOCK			0x00000000
1938c2ecf20Sopenharmony_ci#define DC_UNLOCK_UNLOCK		0x00004758	/* magic value */
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci#define DC_GENERAL_CFG_FDTY		(1 << 17)
1968c2ecf20Sopenharmony_ci#define DC_GENERAL_CFG_DFHPEL_SHIFT	(12)
1978c2ecf20Sopenharmony_ci#define DC_GENERAL_CFG_DFHPSL_SHIFT	(8)
1988c2ecf20Sopenharmony_ci#define DC_GENERAL_CFG_VGAE		(1 << 7)
1998c2ecf20Sopenharmony_ci#define DC_GENERAL_CFG_DECE		(1 << 6)
2008c2ecf20Sopenharmony_ci#define DC_GENERAL_CFG_CMPE		(1 << 5)
2018c2ecf20Sopenharmony_ci#define DC_GENERAL_CFG_VIDE		(1 << 3)
2028c2ecf20Sopenharmony_ci#define DC_GENERAL_CFG_DFLE		(1 << 0)
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci#define DC_DISPLAY_CFG_VISL		(1 << 27)
2058c2ecf20Sopenharmony_ci#define DC_DISPLAY_CFG_PALB		(1 << 25)
2068c2ecf20Sopenharmony_ci#define DC_DISPLAY_CFG_DCEN		(1 << 24)
2078c2ecf20Sopenharmony_ci#define DC_DISPLAY_CFG_DISP_MODE_24BPP	(1 << 9)
2088c2ecf20Sopenharmony_ci#define DC_DISPLAY_CFG_DISP_MODE_16BPP	(1 << 8)
2098c2ecf20Sopenharmony_ci#define DC_DISPLAY_CFG_DISP_MODE_8BPP	(0)
2108c2ecf20Sopenharmony_ci#define DC_DISPLAY_CFG_TRUP		(1 << 6)
2118c2ecf20Sopenharmony_ci#define DC_DISPLAY_CFG_VDEN		(1 << 4)
2128c2ecf20Sopenharmony_ci#define DC_DISPLAY_CFG_GDEN		(1 << 3)
2138c2ecf20Sopenharmony_ci#define DC_DISPLAY_CFG_TGEN		(1 << 0)
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci#define DC_DV_TOP_DV_TOP_EN		(1 << 0)
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci#define DC_DV_CTL_DV_LINE_SIZE		((1 << 10) | (1 << 11))
2188c2ecf20Sopenharmony_ci#define DC_DV_CTL_DV_LINE_SIZE_1K	(0)
2198c2ecf20Sopenharmony_ci#define DC_DV_CTL_DV_LINE_SIZE_2K	(1 << 10)
2208c2ecf20Sopenharmony_ci#define DC_DV_CTL_DV_LINE_SIZE_4K	(1 << 11)
2218c2ecf20Sopenharmony_ci#define DC_DV_CTL_DV_LINE_SIZE_8K	((1 << 10) | (1 << 11))
2228c2ecf20Sopenharmony_ci#define DC_DV_CTL_CLEAR_DV_RAM		(1 << 0)
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci#define DC_IRQ_FILT_CTL_H_FILT_SEL	(1 << 10)
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci#define DC_CLR_KEY_CLR_KEY_EN		(1 << 24)
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci#define DC_IRQ_VIP_VSYNC_IRQ_STATUS	(1 << 21)	/* undocumented? */
2298c2ecf20Sopenharmony_ci#define DC_IRQ_STATUS			(1 << 20)	/* undocumented? */
2308c2ecf20Sopenharmony_ci#define DC_IRQ_VIP_VSYNC_LOSS_IRQ_MASK	(1 << 1)
2318c2ecf20Sopenharmony_ci#define DC_IRQ_MASK			(1 << 0)
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci#define DC_GENLK_CTL_FLICK_SEL_MASK	(0x0F << 28)
2348c2ecf20Sopenharmony_ci#define DC_GENLK_CTL_ALPHA_FLICK_EN	(1 << 25)
2358c2ecf20Sopenharmony_ci#define DC_GENLK_CTL_FLICK_EN		(1 << 24)
2368c2ecf20Sopenharmony_ci#define DC_GENLK_CTL_GENLK_EN		(1 << 18)
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci/*
2408c2ecf20Sopenharmony_ci * Video Processor registers (table 6-71).
2418c2ecf20Sopenharmony_ci * There is space for 64 bit values, but we never use more than the
2428c2ecf20Sopenharmony_ci * lower 32 bits.  The actual register save/restore code only bothers
2438c2ecf20Sopenharmony_ci * to restore those 32 bits.
2448c2ecf20Sopenharmony_ci */
2458c2ecf20Sopenharmony_cienum vp_registers {
2468c2ecf20Sopenharmony_ci	VP_VCFG = 0,
2478c2ecf20Sopenharmony_ci	VP_DCFG,
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci	VP_VX,
2508c2ecf20Sopenharmony_ci	VP_VY,
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci	VP_SCL,
2538c2ecf20Sopenharmony_ci	VP_VCK,
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci	VP_VCM,
2568c2ecf20Sopenharmony_ci	VP_PAR,
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci	VP_PDR,
2598c2ecf20Sopenharmony_ci	VP_SLR,
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci	VP_MISC,
2628c2ecf20Sopenharmony_ci	VP_CCS,
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci	VP_VYS,
2658c2ecf20Sopenharmony_ci	VP_VXS,
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci	VP_RSVD_0,
2688c2ecf20Sopenharmony_ci	VP_VDC,
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci	VP_RSVD_1,
2718c2ecf20Sopenharmony_ci	VP_CRC,
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci	VP_CRC32,
2748c2ecf20Sopenharmony_ci	VP_VDE,
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	VP_CCK,
2778c2ecf20Sopenharmony_ci	VP_CCM,
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci	VP_CC1,
2808c2ecf20Sopenharmony_ci	VP_CC2,
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci	VP_A1X,
2838c2ecf20Sopenharmony_ci	VP_A1Y,
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci	VP_A1C,
2868c2ecf20Sopenharmony_ci	VP_A1T,
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci	VP_A2X,
2898c2ecf20Sopenharmony_ci	VP_A2Y,
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci	VP_A2C,
2928c2ecf20Sopenharmony_ci	VP_A2T,
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci	VP_A3X,
2958c2ecf20Sopenharmony_ci	VP_A3Y,
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci	VP_A3C,
2988c2ecf20Sopenharmony_ci	VP_A3T,
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci	VP_VRR,
3018c2ecf20Sopenharmony_ci	VP_AWT,
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci	VP_VTM,
3048c2ecf20Sopenharmony_ci	VP_VYE,
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci	VP_A1YE,
3078c2ecf20Sopenharmony_ci	VP_A2YE,
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	VP_A3YE,	/* 0x150 */
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci	VP_VCR = 0x1000, /* 0x1000 - 0x1fff */
3128c2ecf20Sopenharmony_ci};
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_ci#define VP_VCFG_VID_EN			(1 << 0)
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci#define VP_DCFG_GV_GAM			(1 << 21)
3178c2ecf20Sopenharmony_ci#define VP_DCFG_PWR_SEQ_DELAY		((1 << 17) | (1 << 18) | (1 << 19))
3188c2ecf20Sopenharmony_ci#define VP_DCFG_PWR_SEQ_DELAY_DEFAULT	(1 << 19)	/* undocumented */
3198c2ecf20Sopenharmony_ci#define VP_DCFG_CRT_SYNC_SKW		((1 << 14) | (1 << 15) | (1 << 16))
3208c2ecf20Sopenharmony_ci#define VP_DCFG_CRT_SYNC_SKW_DEFAULT	(1 << 16)
3218c2ecf20Sopenharmony_ci#define VP_DCFG_CRT_VSYNC_POL		(1 << 9)
3228c2ecf20Sopenharmony_ci#define VP_DCFG_CRT_HSYNC_POL		(1 << 8)
3238c2ecf20Sopenharmony_ci#define VP_DCFG_DAC_BL_EN		(1 << 3)
3248c2ecf20Sopenharmony_ci#define VP_DCFG_VSYNC_EN		(1 << 2)
3258c2ecf20Sopenharmony_ci#define VP_DCFG_HSYNC_EN		(1 << 1)
3268c2ecf20Sopenharmony_ci#define VP_DCFG_CRT_EN			(1 << 0)
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci#define VP_MISC_APWRDN			(1 << 11)
3298c2ecf20Sopenharmony_ci#define VP_MISC_DACPWRDN		(1 << 10)
3308c2ecf20Sopenharmony_ci#define VP_MISC_BYP_BOTH		(1 << 0)
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci/*
3348c2ecf20Sopenharmony_ci * Flat Panel registers (table 6-71).
3358c2ecf20Sopenharmony_ci * Also 64 bit registers; see above note about 32-bit handling.
3368c2ecf20Sopenharmony_ci */
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_ci/* we're actually in the VP register space, starting at address 0x400 */
3398c2ecf20Sopenharmony_ci#define VP_FP_START	0x400
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_cienum fp_registers {
3428c2ecf20Sopenharmony_ci	FP_PT1 = 0,
3438c2ecf20Sopenharmony_ci	FP_PT2,
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci	FP_PM,
3468c2ecf20Sopenharmony_ci	FP_DFC,
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci	FP_RSVD_0,
3498c2ecf20Sopenharmony_ci	FP_RSVD_1,
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci	FP_RSVD_2,
3528c2ecf20Sopenharmony_ci	FP_RSVD_3,
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci	FP_RSVD_4,
3558c2ecf20Sopenharmony_ci	FP_DCA,
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ci	FP_DMD,
3588c2ecf20Sopenharmony_ci	FP_CRC, /* 0x458 */
3598c2ecf20Sopenharmony_ci};
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci#define FP_PT2_HSP			(1 << 22)
3628c2ecf20Sopenharmony_ci#define FP_PT2_VSP			(1 << 23)
3638c2ecf20Sopenharmony_ci#define FP_PT2_SCRC			(1 << 27)	/* shfclk free */
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_ci#define FP_PM_P				(1 << 24)	/* panel power ctl */
3668c2ecf20Sopenharmony_ci#define FP_PM_PANEL_PWR_UP		(1 << 3)	/* r/o */
3678c2ecf20Sopenharmony_ci#define FP_PM_PANEL_PWR_DOWN		(1 << 2)	/* r/o */
3688c2ecf20Sopenharmony_ci#define FP_PM_PANEL_OFF			(1 << 1)	/* r/o */
3698c2ecf20Sopenharmony_ci#define FP_PM_PANEL_ON			(1 << 0)	/* r/o */
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ci#define FP_DFC_BC			((1 << 4) | (1 << 5) | (1 << 6))
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci/* register access functions */
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_cistatic inline uint32_t read_gp(struct lxfb_par *par, int reg)
3778c2ecf20Sopenharmony_ci{
3788c2ecf20Sopenharmony_ci	return readl(par->gp_regs + 4*reg);
3798c2ecf20Sopenharmony_ci}
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_cistatic inline void write_gp(struct lxfb_par *par, int reg, uint32_t val)
3828c2ecf20Sopenharmony_ci{
3838c2ecf20Sopenharmony_ci	writel(val, par->gp_regs + 4*reg);
3848c2ecf20Sopenharmony_ci}
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_cistatic inline uint32_t read_dc(struct lxfb_par *par, int reg)
3878c2ecf20Sopenharmony_ci{
3888c2ecf20Sopenharmony_ci	return readl(par->dc_regs + 4*reg);
3898c2ecf20Sopenharmony_ci}
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_cistatic inline void write_dc(struct lxfb_par *par, int reg, uint32_t val)
3928c2ecf20Sopenharmony_ci{
3938c2ecf20Sopenharmony_ci	writel(val, par->dc_regs + 4*reg);
3948c2ecf20Sopenharmony_ci}
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_cistatic inline uint32_t read_vp(struct lxfb_par *par, int reg)
3978c2ecf20Sopenharmony_ci{
3988c2ecf20Sopenharmony_ci	return readl(par->vp_regs + 8*reg);
3998c2ecf20Sopenharmony_ci}
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_cistatic inline void write_vp(struct lxfb_par *par, int reg, uint32_t val)
4028c2ecf20Sopenharmony_ci{
4038c2ecf20Sopenharmony_ci	writel(val, par->vp_regs + 8*reg);
4048c2ecf20Sopenharmony_ci}
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_cistatic inline uint32_t read_fp(struct lxfb_par *par, int reg)
4078c2ecf20Sopenharmony_ci{
4088c2ecf20Sopenharmony_ci	return readl(par->vp_regs + 8*reg + VP_FP_START);
4098c2ecf20Sopenharmony_ci}
4108c2ecf20Sopenharmony_ci
4118c2ecf20Sopenharmony_cistatic inline void write_fp(struct lxfb_par *par, int reg, uint32_t val)
4128c2ecf20Sopenharmony_ci{
4138c2ecf20Sopenharmony_ci	writel(val, par->vp_regs + 8*reg + VP_FP_START);
4148c2ecf20Sopenharmony_ci}
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ci/* MSRs are defined in linux/cs5535.h; their bitfields are here */
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_ci#define MSR_GLCP_DOTPLL_LOCK		(1 << 25)	/* r/o */
4208c2ecf20Sopenharmony_ci#define MSR_GLCP_DOTPLL_HALFPIX		(1 << 24)
4218c2ecf20Sopenharmony_ci#define MSR_GLCP_DOTPLL_BYPASS		(1 << 15)
4228c2ecf20Sopenharmony_ci#define MSR_GLCP_DOTPLL_DOTRESET	(1 << 0)
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci/* note: this is actually the VP's GLD_MSR_CONFIG */
4258c2ecf20Sopenharmony_ci#define MSR_LX_GLD_MSR_CONFIG_FMT	((1 << 3) | (1 << 4) | (1 << 5))
4268c2ecf20Sopenharmony_ci#define MSR_LX_GLD_MSR_CONFIG_FMT_FP	(1 << 3)
4278c2ecf20Sopenharmony_ci#define MSR_LX_GLD_MSR_CONFIG_FMT_CRT	(0)
4288c2ecf20Sopenharmony_ci#define MSR_LX_GLD_MSR_CONFIG_FPC	(1 << 15)	/* FP *and* CRT */
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_ci#define MSR_LX_MSR_PADSEL_TFT_SEL_LOW	0xDFFFFFFF	/* ??? */
4318c2ecf20Sopenharmony_ci#define MSR_LX_MSR_PADSEL_TFT_SEL_HIGH	0x0000003F	/* ??? */
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_ci#define MSR_LX_SPARE_MSR_DIS_CFIFO_HGO	(1 << 11)	/* undocumented */
4348c2ecf20Sopenharmony_ci#define MSR_LX_SPARE_MSR_VFIFO_ARB_SEL	(1 << 10)	/* undocumented */
4358c2ecf20Sopenharmony_ci#define MSR_LX_SPARE_MSR_WM_LPEN_OVRD	(1 << 9)	/* undocumented */
4368c2ecf20Sopenharmony_ci#define MSR_LX_SPARE_MSR_LOAD_WM_LPEN_M	(1 << 8)	/* undocumented */
4378c2ecf20Sopenharmony_ci#define MSR_LX_SPARE_MSR_DIS_INIT_V_PRI	(1 << 7)	/* undocumented */
4388c2ecf20Sopenharmony_ci#define MSR_LX_SPARE_MSR_DIS_VIFO_WM	(1 << 6)
4398c2ecf20Sopenharmony_ci#define MSR_LX_SPARE_MSR_DIS_CWD_CHECK	(1 << 5)	/* undocumented */
4408c2ecf20Sopenharmony_ci#define MSR_LX_SPARE_MSR_PIX8_PAN_FIX	(1 << 4)	/* undocumented */
4418c2ecf20Sopenharmony_ci#define MSR_LX_SPARE_MSR_FIRST_REQ_MASK	(1 << 1)	/* undocumented */
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci#endif
444