162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * linux/drivers/video/sstfb.h -- voodoo graphics frame buffer
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci *     Copyright (c) 2000,2001 Ghozlane Toumi <gtoumi@messel.emse.fr>
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci *     Created 28 Aug 2001 by Ghozlane Toumi
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#ifndef _SSTFB_H_
1262306a36Sopenharmony_ci#define _SSTFB_H_
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci/*
1562306a36Sopenharmony_ci *
1662306a36Sopenharmony_ci *  Debug Stuff
1762306a36Sopenharmony_ci *
1862306a36Sopenharmony_ci */
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#ifdef SST_DEBUG
2162306a36Sopenharmony_ci#  define dprintk(X...)		printk("sstfb: " X)
2262306a36Sopenharmony_ci#  define SST_DEBUG_REG  1
2362306a36Sopenharmony_ci#  define SST_DEBUG_FUNC 1
2462306a36Sopenharmony_ci#  define SST_DEBUG_VAR  1
2562306a36Sopenharmony_ci#else
2662306a36Sopenharmony_ci#  define dprintk(X...)		no_printk(X)
2762306a36Sopenharmony_ci#  define SST_DEBUG_REG  0
2862306a36Sopenharmony_ci#  define SST_DEBUG_FUNC 0
2962306a36Sopenharmony_ci#  define SST_DEBUG_VAR  0
3062306a36Sopenharmony_ci#endif
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci#if (SST_DEBUG_REG > 0)
3362306a36Sopenharmony_ci#  define r_dprintk(X...)	dprintk(X)
3462306a36Sopenharmony_ci#else
3562306a36Sopenharmony_ci#  define r_dprintk(X...)
3662306a36Sopenharmony_ci#endif
3762306a36Sopenharmony_ci#if (SST_DEBUG_REG > 1)
3862306a36Sopenharmony_ci#  define r_ddprintk(X...)	dprintk(" " X)
3962306a36Sopenharmony_ci#else
4062306a36Sopenharmony_ci#  define r_ddprintk(X...)
4162306a36Sopenharmony_ci#endif
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#if (SST_DEBUG_FUNC > 0)
4462306a36Sopenharmony_ci#  define f_dprintk(X...)	dprintk(X)
4562306a36Sopenharmony_ci#else
4662306a36Sopenharmony_ci#  define f_dprintk(X...)
4762306a36Sopenharmony_ci#endif
4862306a36Sopenharmony_ci#if (SST_DEBUG_FUNC > 1)
4962306a36Sopenharmony_ci#  define f_ddprintk(X...)	dprintk(" " X)
5062306a36Sopenharmony_ci#else
5162306a36Sopenharmony_ci#  define f_ddprintk(X...)	no_printk(X)
5262306a36Sopenharmony_ci#endif
5362306a36Sopenharmony_ci#if (SST_DEBUG_FUNC > 2)
5462306a36Sopenharmony_ci#  define f_dddprintk(X...)	dprintk(" " X)
5562306a36Sopenharmony_ci#else
5662306a36Sopenharmony_ci#  define f_dddprintk(X...)
5762306a36Sopenharmony_ci#endif
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#if (SST_DEBUG_VAR > 0)
6062306a36Sopenharmony_ci#  define v_dprintk(X...)	dprintk(X)
6162306a36Sopenharmony_ci#  define print_var(V, X...)	\
6262306a36Sopenharmony_ci   {				\
6362306a36Sopenharmony_ci     dprintk(X);		\
6462306a36Sopenharmony_ci     printk(" :\n");		\
6562306a36Sopenharmony_ci     sst_dbg_print_var(V);	\
6662306a36Sopenharmony_ci   }
6762306a36Sopenharmony_ci#else
6862306a36Sopenharmony_ci#  define v_dprintk(X...)
6962306a36Sopenharmony_ci#  define print_var(X,Y...)
7062306a36Sopenharmony_ci#endif
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci#define POW2(x)		(1ul<<(x))
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci/*
7562306a36Sopenharmony_ci *
7662306a36Sopenharmony_ci *  Const
7762306a36Sopenharmony_ci *
7862306a36Sopenharmony_ci */
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci/* pci stuff */
8162306a36Sopenharmony_ci#define PCI_INIT_ENABLE		0x40
8262306a36Sopenharmony_ci#  define PCI_EN_INIT_WR	  BIT(0)
8362306a36Sopenharmony_ci#  define PCI_EN_FIFO_WR	  BIT(1)
8462306a36Sopenharmony_ci#  define PCI_REMAP_DAC		  BIT(2)
8562306a36Sopenharmony_ci#define PCI_VCLK_ENABLE		0xc0	/* enable video */
8662306a36Sopenharmony_ci#define PCI_VCLK_DISABLE	0xe0
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci/* register offsets from memBaseAddr */
8962306a36Sopenharmony_ci#define STATUS			0x0000
9062306a36Sopenharmony_ci#  define STATUS_FBI_BUSY	  BIT(7)
9162306a36Sopenharmony_ci#define FBZMODE			0x0110
9262306a36Sopenharmony_ci#  define EN_CLIPPING		  BIT(0)	/* enable clipping */
9362306a36Sopenharmony_ci#  define EN_RGB_WRITE		  BIT(9)	/* enable writes to rgb area */
9462306a36Sopenharmony_ci#  define EN_ALPHA_WRITE	  BIT(10)
9562306a36Sopenharmony_ci#  define ENGINE_INVERT_Y	  BIT(17)	/* invert Y origin (pipe) */
9662306a36Sopenharmony_ci#define LFBMODE			0x0114
9762306a36Sopenharmony_ci#  define LFB_565		  0		/* bits 3:0 .16 bits RGB */
9862306a36Sopenharmony_ci#  define LFB_888		  4		/* 24 bits RGB */
9962306a36Sopenharmony_ci#  define LFB_8888		  5		/* 32 bits ARGB */
10062306a36Sopenharmony_ci#  define WR_BUFF_FRONT		  0		/* write buf select (front) */
10162306a36Sopenharmony_ci#  define WR_BUFF_BACK		  (1 << 4)	/* back */
10262306a36Sopenharmony_ci#  define RD_BUFF_FRONT		  0		/* read buff select (front) */
10362306a36Sopenharmony_ci#  define RD_BUFF_BACK		  (1 << 6)	/* back */
10462306a36Sopenharmony_ci#  define EN_PXL_PIPELINE	  BIT(8)	/* pixel pipeline (clip..)*/
10562306a36Sopenharmony_ci#  define LFB_WORD_SWIZZLE_WR	  BIT(11)	/* enable write-wordswap (big-endian) */
10662306a36Sopenharmony_ci#  define LFB_BYTE_SWIZZLE_WR	  BIT(12)	/* enable write-byteswap (big-endian) */
10762306a36Sopenharmony_ci#  define LFB_INVERT_Y		  BIT(13)	/* invert Y origin (LFB) */
10862306a36Sopenharmony_ci#  define LFB_WORD_SWIZZLE_RD	  BIT(15)	/* enable read-wordswap (big-endian) */
10962306a36Sopenharmony_ci#  define LFB_BYTE_SWIZZLE_RD	  BIT(16)	/* enable read-byteswap (big-endian) */
11062306a36Sopenharmony_ci#define CLIP_LEFT_RIGHT		0x0118
11162306a36Sopenharmony_ci#define CLIP_LOWY_HIGHY		0x011c
11262306a36Sopenharmony_ci#define NOPCMD			0x0120
11362306a36Sopenharmony_ci#define FASTFILLCMD		0x0124
11462306a36Sopenharmony_ci#define SWAPBUFFCMD		0x0128
11562306a36Sopenharmony_ci#define FBIINIT4		0x0200		/* misc controls */
11662306a36Sopenharmony_ci#  define FAST_PCI_READS	  0		/* 1 waitstate */
11762306a36Sopenharmony_ci#  define SLOW_PCI_READS	  BIT(0)	/* 2 ws */
11862306a36Sopenharmony_ci#  define LFB_READ_AHEAD	  BIT(1)
11962306a36Sopenharmony_ci#define BACKPORCH		0x0208
12062306a36Sopenharmony_ci#define VIDEODIMENSIONS		0x020c
12162306a36Sopenharmony_ci#define FBIINIT0		0x0210		/* misc+fifo  controls */
12262306a36Sopenharmony_ci#  define DIS_VGA_PASSTHROUGH	  BIT(0)
12362306a36Sopenharmony_ci#  define FBI_RESET		  BIT(1)
12462306a36Sopenharmony_ci#  define FIFO_RESET		  BIT(2)
12562306a36Sopenharmony_ci#define FBIINIT1		0x0214		/* PCI + video controls */
12662306a36Sopenharmony_ci#  define VIDEO_MASK		  0x8080010f	/* masks video related bits V1+V2*/
12762306a36Sopenharmony_ci#  define FAST_PCI_WRITES	  0		/* 0 ws */
12862306a36Sopenharmony_ci#  define SLOW_PCI_WRITES	  BIT(1)	/* 1 ws */
12962306a36Sopenharmony_ci#  define EN_LFB_READ		  BIT(3)
13062306a36Sopenharmony_ci#  define TILES_IN_X_SHIFT	  4
13162306a36Sopenharmony_ci#  define VIDEO_RESET		  BIT(8)
13262306a36Sopenharmony_ci#  define EN_BLANKING		  BIT(12)
13362306a36Sopenharmony_ci#  define EN_DATA_OE		  BIT(13)
13462306a36Sopenharmony_ci#  define EN_BLANK_OE		  BIT(14)
13562306a36Sopenharmony_ci#  define EN_HVSYNC_OE		  BIT(15)
13662306a36Sopenharmony_ci#  define EN_DCLK_OE		  BIT(16)
13762306a36Sopenharmony_ci#  define SEL_INPUT_VCLK_2X	  0		/* bit 17 */
13862306a36Sopenharmony_ci#  define SEL_INPUT_VCLK_SLAVE	  BIT(17)
13962306a36Sopenharmony_ci#  define SEL_SOURCE_VCLK_SLAVE	  0		/* bits 21:20 */
14062306a36Sopenharmony_ci#  define SEL_SOURCE_VCLK_2X_DIV2 (0x01 << 20)
14162306a36Sopenharmony_ci#  define SEL_SOURCE_VCLK_2X_SEL  (0x02 << 20)
14262306a36Sopenharmony_ci#  define EN_24BPP		  BIT(22)
14362306a36Sopenharmony_ci#  define TILES_IN_X_MSB_SHIFT	  24		/* v2 */
14462306a36Sopenharmony_ci#  define VCLK_2X_SEL_DEL_SHIFT	  27		/* vclk out delay 0,4,6,8ns */
14562306a36Sopenharmony_ci#  define VCLK_DEL_SHIFT	  29		/* vclk in delay */
14662306a36Sopenharmony_ci#define FBIINIT2		0x0218		/* Dram controls */
14762306a36Sopenharmony_ci#  define EN_FAST_RAS_READ	  BIT(5)
14862306a36Sopenharmony_ci#  define EN_DRAM_OE		  BIT(6)
14962306a36Sopenharmony_ci#  define EN_FAST_RD_AHEAD_WR	  BIT(7)
15062306a36Sopenharmony_ci#  define VIDEO_OFFSET_SHIFT	  11		/* unit: #rows tile 64x16/2 */
15162306a36Sopenharmony_ci#  define SWAP_DACVSYNC		  0
15262306a36Sopenharmony_ci#  define SWAP_DACDATA0		  (1 << 9)
15362306a36Sopenharmony_ci#  define SWAP_FIFO_STALL	  (2 << 9)
15462306a36Sopenharmony_ci#  define EN_RD_AHEAD_FIFO	  BIT(21)
15562306a36Sopenharmony_ci#  define EN_DRAM_REFRESH	  BIT(22)
15662306a36Sopenharmony_ci#  define DRAM_REFRESH_16	  (0x30 << 23)	/* dram 16 ms */
15762306a36Sopenharmony_ci#define DAC_READ		FBIINIT2	/* in remap mode */
15862306a36Sopenharmony_ci#define FBIINIT3		0x021c		/* fbi controls */
15962306a36Sopenharmony_ci#  define DISABLE_TEXTURE	  BIT(6)
16062306a36Sopenharmony_ci#  define Y_SWAP_ORIGIN_SHIFT	  22		/* Y swap subtraction value */
16162306a36Sopenharmony_ci#define HSYNC			0x0220
16262306a36Sopenharmony_ci#define VSYNC			0x0224
16362306a36Sopenharmony_ci#define DAC_DATA		0x022c
16462306a36Sopenharmony_ci#  define DAC_READ_CMD		  BIT(11)	/* set read dacreg mode */
16562306a36Sopenharmony_ci#define FBIINIT5		0x0244		/* v2 specific */
16662306a36Sopenharmony_ci#  define FBIINIT5_MASK		  0xfa40ffff    /* mask video bits*/
16762306a36Sopenharmony_ci#  define HDOUBLESCAN		  BIT(20)
16862306a36Sopenharmony_ci#  define VDOUBLESCAN		  BIT(21)
16962306a36Sopenharmony_ci#  define HSYNC_HIGH 		  BIT(23)
17062306a36Sopenharmony_ci#  define VSYNC_HIGH 		  BIT(24)
17162306a36Sopenharmony_ci#  define INTERLACE		  BIT(26)
17262306a36Sopenharmony_ci#define FBIINIT6		0x0248		/* v2 specific */
17362306a36Sopenharmony_ci#  define TILES_IN_X_LSB_SHIFT	  30		/* v2 */
17462306a36Sopenharmony_ci#define FBIINIT7		0x024c		/* v2 specific */
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ci#define BLTSRCBASEADDR		0x02c0	/* BitBLT Source base address */
17762306a36Sopenharmony_ci#define BLTDSTBASEADDR		0x02c4	/* BitBLT Destination base address */
17862306a36Sopenharmony_ci#define BLTXYSTRIDES		0x02c8	/* BitBLT Source and Destination strides */
17962306a36Sopenharmony_ci#define BLTSRCCHROMARANGE	0x02cc	/* BitBLT Source Chroma key range */
18062306a36Sopenharmony_ci#define BLTDSTCHROMARANGE	0x02d0	/* BitBLT Destination Chroma key range */
18162306a36Sopenharmony_ci#define BLTCLIPX		0x02d4	/* BitBLT Min/Max X clip values */
18262306a36Sopenharmony_ci#define BLTCLIPY		0x02d8	/* BitBLT Min/Max Y clip values */
18362306a36Sopenharmony_ci#define BLTSRCXY		0x02e0	/* BitBLT Source starting XY coordinates */
18462306a36Sopenharmony_ci#define BLTDSTXY		0x02e4	/* BitBLT Destination starting XY coordinates */
18562306a36Sopenharmony_ci#define BLTSIZE			0x02e8	/* BitBLT width and height */
18662306a36Sopenharmony_ci#define BLTROP			0x02ec	/* BitBLT Raster operations */
18762306a36Sopenharmony_ci#  define BLTROP_COPY		  0x0cccc
18862306a36Sopenharmony_ci#  define BLTROP_INVERT		  0x05555
18962306a36Sopenharmony_ci#  define BLTROP_XOR		  0x06666
19062306a36Sopenharmony_ci#define BLTCOLOR		0x02f0	/* BitBLT and foreground background colors */
19162306a36Sopenharmony_ci#define BLTCOMMAND		0x02f8	/* BitBLT command mode (v2 specific) */
19262306a36Sopenharmony_ci# define BLT_SCR2SCR_BITBLT	  0	  /* Screen-to-Screen BitBLT */
19362306a36Sopenharmony_ci# define BLT_CPU2SCR_BITBLT	  1	  /* CPU-to-screen BitBLT */
19462306a36Sopenharmony_ci# define BLT_RECFILL_BITBLT	  2	  /* BitBLT Rectangle Fill */
19562306a36Sopenharmony_ci# define BLT_16BPP_FMT		  2	  /* 16 BPP (5-6-5 RGB) */
19662306a36Sopenharmony_ci#define BLTDATA			0x02fc	/* BitBLT data for CPU-to-Screen BitBLTs */
19762306a36Sopenharmony_ci#  define LAUNCH_BITBLT		  BIT(31) /* Launch BitBLT in BltCommand, bltDstXY or bltSize */
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci/* Dac Registers */
20062306a36Sopenharmony_ci#define DACREG_WMA		0x0	/* pixel write mode address */
20162306a36Sopenharmony_ci#define DACREG_LUT		0x01	/* color value */
20262306a36Sopenharmony_ci#define DACREG_RMR		0x02	/* pixel mask */
20362306a36Sopenharmony_ci#define DACREG_RMA		0x03	/* pixel read mode address */
20462306a36Sopenharmony_ci/*Dac registers in indexed mode (TI, ATT dacs) */
20562306a36Sopenharmony_ci#define DACREG_ADDR_I		DACREG_WMA
20662306a36Sopenharmony_ci#define DACREG_DATA_I		DACREG_RMR
20762306a36Sopenharmony_ci#define DACREG_RMR_I		0x00
20862306a36Sopenharmony_ci#define DACREG_CR0_I		0x01
20962306a36Sopenharmony_ci#  define DACREG_CR0_EN_INDEXED	  BIT(0)	/* enable indexec mode */
21062306a36Sopenharmony_ci#  define DACREG_CR0_8BIT	  BIT(1)	/* set dac to 8 bits/read */
21162306a36Sopenharmony_ci#  define DACREG_CR0_PWDOWN	  BIT(3)	/* powerdown dac */
21262306a36Sopenharmony_ci#  define DACREG_CR0_16BPP	  0x30		/* mode 3 */
21362306a36Sopenharmony_ci#  define DACREG_CR0_24BPP	  0x50		/* mode 5 */
21462306a36Sopenharmony_ci#define	DACREG_CR1_I		0x05
21562306a36Sopenharmony_ci#define DACREG_CC_I		0x06
21662306a36Sopenharmony_ci#  define DACREG_CC_CLKA	  BIT(7)	/* clk A controlled by regs */
21762306a36Sopenharmony_ci#  define DACREG_CC_CLKA_C	  (2<<4)	/* clk A uses reg C */
21862306a36Sopenharmony_ci#  define DACREG_CC_CLKB	  BIT(3)	/* clk B controlled by regs */
21962306a36Sopenharmony_ci#  define DACREG_CC_CLKB_D	  3		/* clkB uses reg D */
22062306a36Sopenharmony_ci#define DACREG_AC0_I		0x48		/* clock A reg C */
22162306a36Sopenharmony_ci#define DACREG_AC1_I		0x49
22262306a36Sopenharmony_ci#define DACREG_BD0_I		0x6c		/* clock B reg D */
22362306a36Sopenharmony_ci#define DACREG_BD1_I		0x6d
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ci/* identification constants */
22662306a36Sopenharmony_ci#define DACREG_MIR_TI		0x97
22762306a36Sopenharmony_ci#define DACREG_DIR_TI		0x09
22862306a36Sopenharmony_ci#define DACREG_MIR_ATT		0x84
22962306a36Sopenharmony_ci#define DACREG_DIR_ATT		0x09
23062306a36Sopenharmony_ci/* ics dac specific registers */
23162306a36Sopenharmony_ci#define DACREG_ICS_PLLWMA	0x04	/* PLL write mode address */
23262306a36Sopenharmony_ci#define DACREG_ICS_PLLDATA	0x05	/* PLL data /parameter */
23362306a36Sopenharmony_ci#define DACREG_ICS_CMD		0x06	/* command */
23462306a36Sopenharmony_ci#  define DACREG_ICS_CMD_16BPP	  0x50	/* ics color mode 6 (16bpp bypass)*/
23562306a36Sopenharmony_ci#  define DACREG_ICS_CMD_24BPP	  0x70	/* ics color mode 7 (24bpp bypass)*/
23662306a36Sopenharmony_ci#  define DACREG_ICS_CMD_PWDOWN BIT(0)	/* powerdown dac */
23762306a36Sopenharmony_ci#define DACREG_ICS_PLLRMA	0x07	/* PLL read mode address */
23862306a36Sopenharmony_ci/*
23962306a36Sopenharmony_ci * pll parameter register:
24062306a36Sopenharmony_ci * indexed : write addr to PLLWMA, write data in PLLDATA.
24162306a36Sopenharmony_ci * for reads use PLLRMA .
24262306a36Sopenharmony_ci * 8 freq registers (0-7) for video clock (CLK0)
24362306a36Sopenharmony_ci * 2 freq registers (a-b) for graphic clock (CLK1)
24462306a36Sopenharmony_ci */
24562306a36Sopenharmony_ci#define DACREG_ICS_PLL_CLK0_1_INI 0x55	/* initial pll M value for freq f1  */
24662306a36Sopenharmony_ci#define DACREG_ICS_PLL_CLK0_7_INI 0x71	/* f7 */
24762306a36Sopenharmony_ci#define DACREG_ICS_PLL_CLK1_B_INI 0x79	/* fb */
24862306a36Sopenharmony_ci#define DACREG_ICS_PLL_CTRL	0x0e
24962306a36Sopenharmony_ci#  define DACREG_ICS_CLK0	  BIT(5)
25062306a36Sopenharmony_ci#  define DACREG_ICS_CLK0_0	  0
25162306a36Sopenharmony_ci#  define DACREG_ICS_CLK1_A	  0	/* bit4 */
25262306a36Sopenharmony_ci
25362306a36Sopenharmony_ci/* sst default init registers */
25462306a36Sopenharmony_ci#define FBIINIT0_DEFAULT DIS_VGA_PASSTHROUGH
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_ci#define FBIINIT1_DEFAULT 	\
25762306a36Sopenharmony_ci	(			\
25862306a36Sopenharmony_ci	  FAST_PCI_WRITES	\
25962306a36Sopenharmony_ci/*	  SLOW_PCI_WRITES*/	\
26062306a36Sopenharmony_ci	| VIDEO_RESET		\
26162306a36Sopenharmony_ci	| 10 << TILES_IN_X_SHIFT\
26262306a36Sopenharmony_ci	| SEL_SOURCE_VCLK_2X_SEL\
26362306a36Sopenharmony_ci	| EN_LFB_READ		\
26462306a36Sopenharmony_ci	)
26562306a36Sopenharmony_ci
26662306a36Sopenharmony_ci#define FBIINIT2_DEFAULT	\
26762306a36Sopenharmony_ci	(			\
26862306a36Sopenharmony_ci	 SWAP_DACVSYNC		\
26962306a36Sopenharmony_ci	| EN_DRAM_OE		\
27062306a36Sopenharmony_ci	| DRAM_REFRESH_16	\
27162306a36Sopenharmony_ci	| EN_DRAM_REFRESH	\
27262306a36Sopenharmony_ci	| EN_FAST_RAS_READ	\
27362306a36Sopenharmony_ci	| EN_RD_AHEAD_FIFO	\
27462306a36Sopenharmony_ci	| EN_FAST_RD_AHEAD_WR	\
27562306a36Sopenharmony_ci	)
27662306a36Sopenharmony_ci
27762306a36Sopenharmony_ci#define FBIINIT3_DEFAULT 	\
27862306a36Sopenharmony_ci	( DISABLE_TEXTURE )
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci#define FBIINIT4_DEFAULT	\
28162306a36Sopenharmony_ci	(			\
28262306a36Sopenharmony_ci	  FAST_PCI_READS	\
28362306a36Sopenharmony_ci/*	  SLOW_PCI_READS*/	\
28462306a36Sopenharmony_ci	| LFB_READ_AHEAD	\
28562306a36Sopenharmony_ci	)
28662306a36Sopenharmony_ci/* Careful with this one : writing back the data just read will trash the DAC
28762306a36Sopenharmony_ci   reading some fields give logic value on pins, but setting this field will
28862306a36Sopenharmony_ci   set the source signal driving the pin. conclusion : just use the default
28962306a36Sopenharmony_ci   as a base before writing back .
29062306a36Sopenharmony_ci*/
29162306a36Sopenharmony_ci#define FBIINIT6_DEFAULT	(0x0)
29262306a36Sopenharmony_ci
29362306a36Sopenharmony_ci/*
29462306a36Sopenharmony_ci *
29562306a36Sopenharmony_ci * Misc Const
29662306a36Sopenharmony_ci *
29762306a36Sopenharmony_ci */
29862306a36Sopenharmony_ci
29962306a36Sopenharmony_ci/* ioctl to enable/disable VGA passthrough */
30062306a36Sopenharmony_ci#define SSTFB_SET_VGAPASS	_IOW('F', 0xdd, __u32)
30162306a36Sopenharmony_ci#define SSTFB_GET_VGAPASS	_IOR('F', 0xdd, __u32)
30262306a36Sopenharmony_ci
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ci/* used to know witch clock to set */
30562306a36Sopenharmony_cienum {
30662306a36Sopenharmony_ci	VID_CLOCK=0,
30762306a36Sopenharmony_ci	GFX_CLOCK=1,
30862306a36Sopenharmony_ci};
30962306a36Sopenharmony_ci
31062306a36Sopenharmony_ci/* freq max */
31162306a36Sopenharmony_ci#define DAC_FREF	14318	/* DAC reference freq (Khz) */
31262306a36Sopenharmony_ci#define VCO_MAX		260000
31362306a36Sopenharmony_ci
31462306a36Sopenharmony_ci/*
31562306a36Sopenharmony_ci *  driver structs
31662306a36Sopenharmony_ci */
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_cistruct pll_timing {
31962306a36Sopenharmony_ci	unsigned int m;
32062306a36Sopenharmony_ci	unsigned int n;
32162306a36Sopenharmony_ci	unsigned int p;
32262306a36Sopenharmony_ci};
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_cistruct dac_switch {
32562306a36Sopenharmony_ci	const char *name;
32662306a36Sopenharmony_ci	int (*detect) (struct fb_info *info);
32762306a36Sopenharmony_ci	int (*set_pll) (struct fb_info *info, const struct pll_timing *t, const int clock);
32862306a36Sopenharmony_ci	void (*set_vidmod) (struct fb_info *info, const int bpp);
32962306a36Sopenharmony_ci};
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_cistruct sst_spec {
33262306a36Sopenharmony_ci	char * name;
33362306a36Sopenharmony_ci	int default_gfx_clock;	/* 50000 for voodoo1, 75000 for voodoo2 */
33462306a36Sopenharmony_ci	int max_gfxclk; 	/* ! in Mhz ie 60 for voodoo 1 */
33562306a36Sopenharmony_ci};
33662306a36Sopenharmony_ci
33762306a36Sopenharmony_cistruct sstfb_par {
33862306a36Sopenharmony_ci	u32 palette[16];
33962306a36Sopenharmony_ci	unsigned int yDim;
34062306a36Sopenharmony_ci	unsigned int hSyncOn;	/* hsync_len */
34162306a36Sopenharmony_ci	unsigned int hSyncOff;	/* left_margin + xres + right_margin */
34262306a36Sopenharmony_ci	unsigned int hBackPorch;/* left_margin */
34362306a36Sopenharmony_ci	unsigned int vSyncOn;
34462306a36Sopenharmony_ci	unsigned int vSyncOff;
34562306a36Sopenharmony_ci	unsigned int vBackPorch;
34662306a36Sopenharmony_ci	struct pll_timing pll;
34762306a36Sopenharmony_ci	unsigned int tiles_in_X;/* num of tiles in X res */
34862306a36Sopenharmony_ci	u8 __iomem *mmio_vbase;
34962306a36Sopenharmony_ci	struct dac_switch 	dac_sw;	/* dac specific functions */
35062306a36Sopenharmony_ci	struct pci_dev		*dev;
35162306a36Sopenharmony_ci	int	type;
35262306a36Sopenharmony_ci	u8	revision;
35362306a36Sopenharmony_ci	u8	vgapass;	/* VGA pass through: 1=enabled, 0=disabled */
35462306a36Sopenharmony_ci};
35562306a36Sopenharmony_ci
35662306a36Sopenharmony_ci#endif /* _SSTFB_H_ */
357