xref: /openbmc/linux/include/video/tgafb.h (revision e5451c8f8330e03ad3cfa16048b4daf961af434f)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  *  linux/drivers/video/tgafb.h -- DEC 21030 TGA frame buffer device
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  *  	Copyright (C) 1999,2000 Martin Lucina, Tom Zerucha
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  *  $Id: tgafb.h,v 1.4.2.3 2000/04/04 06:44:56 mato Exp $
71da177e4SLinus Torvalds  *
81da177e4SLinus Torvalds  *  This file is subject to the terms and conditions of the GNU General Public
91da177e4SLinus Torvalds  *  License. See the file COPYING in the main directory of this archive for
101da177e4SLinus Torvalds  *  more details.
111da177e4SLinus Torvalds  */
121da177e4SLinus Torvalds 
131da177e4SLinus Torvalds #ifndef TGAFB_H
141da177e4SLinus Torvalds #define TGAFB_H
151da177e4SLinus Torvalds 
161da177e4SLinus Torvalds /*
171da177e4SLinus Torvalds  * TGA hardware description (minimal)
181da177e4SLinus Torvalds  */
191da177e4SLinus Torvalds 
201da177e4SLinus Torvalds #define TGA_TYPE_8PLANE			0
211da177e4SLinus Torvalds #define TGA_TYPE_24PLANE		1
221da177e4SLinus Torvalds #define TGA_TYPE_24PLUSZ		3
231da177e4SLinus Torvalds 
241da177e4SLinus Torvalds /*
251da177e4SLinus Torvalds  * Offsets within Memory Space
261da177e4SLinus Torvalds  */
271da177e4SLinus Torvalds 
281da177e4SLinus Torvalds #define	TGA_ROM_OFFSET			0x0000000
291da177e4SLinus Torvalds #define	TGA_REGS_OFFSET			0x0100000
301da177e4SLinus Torvalds #define	TGA_8PLANE_FB_OFFSET		0x0200000
311da177e4SLinus Torvalds #define	TGA_24PLANE_FB_OFFSET		0x0804000
321da177e4SLinus Torvalds #define	TGA_24PLUSZ_FB_OFFSET		0x1004000
331da177e4SLinus Torvalds 
341da177e4SLinus Torvalds #define TGA_FOREGROUND_REG		0x0020
351da177e4SLinus Torvalds #define TGA_BACKGROUND_REG		0x0024
361da177e4SLinus Torvalds #define	TGA_PLANEMASK_REG		0x0028
371da177e4SLinus Torvalds #define TGA_PIXELMASK_ONESHOT_REG	0x002c
381da177e4SLinus Torvalds #define	TGA_MODE_REG			0x0030
391da177e4SLinus Torvalds #define	TGA_RASTEROP_REG		0x0034
401da177e4SLinus Torvalds #define	TGA_PIXELSHIFT_REG		0x0038
411da177e4SLinus Torvalds #define	TGA_DEEP_REG			0x0050
4286c6f7d0SMaciej W. Rozycki #define	TGA_START_REG			0x0054
431da177e4SLinus Torvalds #define	TGA_PIXELMASK_REG		0x005c
441da177e4SLinus Torvalds #define	TGA_CURSOR_BASE_REG		0x0060
451da177e4SLinus Torvalds #define	TGA_HORIZ_REG			0x0064
461da177e4SLinus Torvalds #define	TGA_VERT_REG			0x0068
471da177e4SLinus Torvalds #define	TGA_BASE_ADDR_REG		0x006c
481da177e4SLinus Torvalds #define	TGA_VALID_REG			0x0070
491da177e4SLinus Torvalds #define	TGA_CURSOR_XY_REG		0x0074
501da177e4SLinus Torvalds #define	TGA_INTR_STAT_REG		0x007c
511da177e4SLinus Torvalds #define TGA_DATA_REG			0x0080
521da177e4SLinus Torvalds #define	TGA_RAMDAC_SETUP_REG		0x00c0
531da177e4SLinus Torvalds #define	TGA_BLOCK_COLOR0_REG		0x0140
541da177e4SLinus Torvalds #define	TGA_BLOCK_COLOR1_REG		0x0144
551da177e4SLinus Torvalds #define	TGA_BLOCK_COLOR2_REG		0x0148
561da177e4SLinus Torvalds #define	TGA_BLOCK_COLOR3_REG		0x014c
571da177e4SLinus Torvalds #define	TGA_BLOCK_COLOR4_REG		0x0150
581da177e4SLinus Torvalds #define	TGA_BLOCK_COLOR5_REG		0x0154
591da177e4SLinus Torvalds #define	TGA_BLOCK_COLOR6_REG		0x0158
601da177e4SLinus Torvalds #define	TGA_BLOCK_COLOR7_REG		0x015c
611da177e4SLinus Torvalds #define TGA_COPY64_SRC			0x0160
621da177e4SLinus Torvalds #define TGA_COPY64_DST			0x0164
631da177e4SLinus Torvalds #define	TGA_CLOCK_REG			0x01e8
641da177e4SLinus Torvalds #define	TGA_RAMDAC_REG			0x01f0
651da177e4SLinus Torvalds #define	TGA_CMD_STAT_REG		0x01f8
661da177e4SLinus Torvalds 
671da177e4SLinus Torvalds 
681da177e4SLinus Torvalds /*
691da177e4SLinus Torvalds  * Useful defines for managing the registers
701da177e4SLinus Torvalds  */
711da177e4SLinus Torvalds 
721da177e4SLinus Torvalds #define TGA_HORIZ_ODD			0x80000000
731da177e4SLinus Torvalds #define TGA_HORIZ_POLARITY		0x40000000
741da177e4SLinus Torvalds #define TGA_HORIZ_ACT_MSB		0x30000000
751da177e4SLinus Torvalds #define TGA_HORIZ_BP			0x0fe00000
761da177e4SLinus Torvalds #define TGA_HORIZ_SYNC			0x001fc000
771da177e4SLinus Torvalds #define TGA_HORIZ_FP			0x00007c00
781da177e4SLinus Torvalds #define TGA_HORIZ_ACT_LSB		0x000001ff
791da177e4SLinus Torvalds 
801da177e4SLinus Torvalds #define TGA_VERT_SE			0x80000000
811da177e4SLinus Torvalds #define TGA_VERT_POLARITY		0x40000000
821da177e4SLinus Torvalds #define TGA_VERT_RESERVED		0x30000000
831da177e4SLinus Torvalds #define TGA_VERT_BP			0x0fc00000
841da177e4SLinus Torvalds #define TGA_VERT_SYNC			0x003f0000
851da177e4SLinus Torvalds #define TGA_VERT_FP			0x0000f800
861da177e4SLinus Torvalds #define TGA_VERT_ACTIVE			0x000007ff
871da177e4SLinus Torvalds 
881da177e4SLinus Torvalds #define TGA_VALID_VIDEO			0x01
891da177e4SLinus Torvalds #define TGA_VALID_BLANK			0x02
901da177e4SLinus Torvalds #define TGA_VALID_CURSOR		0x04
911da177e4SLinus Torvalds 
921da177e4SLinus Torvalds #define TGA_MODE_SBM_8BPP		0x000
931da177e4SLinus Torvalds #define TGA_MODE_SBM_24BPP		0x300
941da177e4SLinus Torvalds 
951da177e4SLinus Torvalds #define TGA_MODE_SIMPLE			0x00
961da177e4SLinus Torvalds #define TGA_MODE_SIMPLEZ		0x10
971da177e4SLinus Torvalds #define TGA_MODE_OPAQUE_STIPPLE		0x01
981da177e4SLinus Torvalds #define TGA_MODE_OPAQUE_FILL		0x21
991da177e4SLinus Torvalds #define TGA_MODE_TRANSPARENT_STIPPLE	0x03
1001da177e4SLinus Torvalds #define TGA_MODE_TRANSPARENT_FILL	0x23
1011da177e4SLinus Torvalds #define TGA_MODE_BLOCK_STIPPLE		0x0d
1021da177e4SLinus Torvalds #define TGA_MODE_BLOCK_FILL		0x2d
1031da177e4SLinus Torvalds #define TGA_MODE_COPY			0x07
1041da177e4SLinus Torvalds #define TGA_MODE_DMA_READ_COPY_ND	0x17
1051da177e4SLinus Torvalds #define TGA_MODE_DMA_READ_COPY_D	0x37
1061da177e4SLinus Torvalds #define TGA_MODE_DMA_WRITE_COPY		0x1f
1071da177e4SLinus Torvalds 
1081da177e4SLinus Torvalds 
1091da177e4SLinus Torvalds /*
1101da177e4SLinus Torvalds  * Useful defines for managing the ICS1562 PLL clock
1111da177e4SLinus Torvalds  */
1121da177e4SLinus Torvalds 
1131da177e4SLinus Torvalds #define TGA_PLL_BASE_FREQ 		14318		/* .18 */
1141da177e4SLinus Torvalds #define TGA_PLL_MAX_FREQ 		230000
1151da177e4SLinus Torvalds 
1161da177e4SLinus Torvalds 
1171da177e4SLinus Torvalds /*
1181da177e4SLinus Torvalds  * Useful defines for managing the BT485 on the 8-plane TGA
1191da177e4SLinus Torvalds  */
1201da177e4SLinus Torvalds 
1211da177e4SLinus Torvalds #define	BT485_READ_BIT			0x01
1221da177e4SLinus Torvalds #define	BT485_WRITE_BIT			0x00
1231da177e4SLinus Torvalds 
1241da177e4SLinus Torvalds #define	BT485_ADDR_PAL_WRITE		0x00
1251da177e4SLinus Torvalds #define	BT485_DATA_PAL			0x02
1261da177e4SLinus Torvalds #define	BT485_PIXEL_MASK		0x04
1271da177e4SLinus Torvalds #define	BT485_ADDR_PAL_READ		0x06
1281da177e4SLinus Torvalds #define	BT485_ADDR_CUR_WRITE		0x08
1291da177e4SLinus Torvalds #define	BT485_DATA_CUR			0x0a
1301da177e4SLinus Torvalds #define	BT485_CMD_0			0x0c
1311da177e4SLinus Torvalds #define	BT485_ADDR_CUR_READ		0x0e
1321da177e4SLinus Torvalds #define	BT485_CMD_1			0x10
1331da177e4SLinus Torvalds #define	BT485_CMD_2			0x12
1341da177e4SLinus Torvalds #define	BT485_STATUS			0x14
1351da177e4SLinus Torvalds #define	BT485_CMD_3			0x14
1361da177e4SLinus Torvalds #define	BT485_CUR_RAM			0x16
1371da177e4SLinus Torvalds #define	BT485_CUR_LOW_X			0x18
1381da177e4SLinus Torvalds #define	BT485_CUR_HIGH_X		0x1a
1391da177e4SLinus Torvalds #define	BT485_CUR_LOW_Y			0x1c
1401da177e4SLinus Torvalds #define	BT485_CUR_HIGH_Y		0x1e
1411da177e4SLinus Torvalds 
1421da177e4SLinus Torvalds 
1431da177e4SLinus Torvalds /*
14486c6f7d0SMaciej W. Rozycki  * Useful defines for managing the BT463 on the 24-plane TGAs/SFB+s
1451da177e4SLinus Torvalds  */
1461da177e4SLinus Torvalds 
1471da177e4SLinus Torvalds #define	BT463_ADDR_LO		0x0
1481da177e4SLinus Torvalds #define	BT463_ADDR_HI		0x1
1491da177e4SLinus Torvalds #define	BT463_REG_ACC		0x2
1501da177e4SLinus Torvalds #define	BT463_PALETTE		0x3
1511da177e4SLinus Torvalds 
1521da177e4SLinus Torvalds #define	BT463_CUR_CLR_0		0x0100
1531da177e4SLinus Torvalds #define	BT463_CUR_CLR_1		0x0101
1541da177e4SLinus Torvalds 
1551da177e4SLinus Torvalds #define	BT463_CMD_REG_0		0x0201
1561da177e4SLinus Torvalds #define	BT463_CMD_REG_1		0x0202
1571da177e4SLinus Torvalds #define	BT463_CMD_REG_2		0x0203
1581da177e4SLinus Torvalds 
1591da177e4SLinus Torvalds #define	BT463_READ_MASK_0	0x0205
1601da177e4SLinus Torvalds #define	BT463_READ_MASK_1	0x0206
1611da177e4SLinus Torvalds #define	BT463_READ_MASK_2	0x0207
1621da177e4SLinus Torvalds #define	BT463_READ_MASK_3	0x0208
1631da177e4SLinus Torvalds 
1641da177e4SLinus Torvalds #define	BT463_BLINK_MASK_0	0x0209
1651da177e4SLinus Torvalds #define	BT463_BLINK_MASK_1	0x020a
1661da177e4SLinus Torvalds #define	BT463_BLINK_MASK_2	0x020b
1671da177e4SLinus Torvalds #define	BT463_BLINK_MASK_3	0x020c
1681da177e4SLinus Torvalds 
1691da177e4SLinus Torvalds #define	BT463_WINDOW_TYPE_BASE	0x0300
1701da177e4SLinus Torvalds 
1711da177e4SLinus Torvalds /*
17286c6f7d0SMaciej W. Rozycki  * Useful defines for managing the BT459 on the 8-plane SFB+s
17386c6f7d0SMaciej W. Rozycki  */
17486c6f7d0SMaciej W. Rozycki 
17586c6f7d0SMaciej W. Rozycki #define	BT459_ADDR_LO		0x0
17686c6f7d0SMaciej W. Rozycki #define	BT459_ADDR_HI		0x1
17786c6f7d0SMaciej W. Rozycki #define	BT459_REG_ACC		0x2
17886c6f7d0SMaciej W. Rozycki #define	BT459_PALETTE		0x3
17986c6f7d0SMaciej W. Rozycki 
18086c6f7d0SMaciej W. Rozycki #define	BT459_CUR_CLR_1		0x0181
18186c6f7d0SMaciej W. Rozycki #define	BT459_CUR_CLR_2		0x0182
18286c6f7d0SMaciej W. Rozycki #define	BT459_CUR_CLR_3		0x0183
18386c6f7d0SMaciej W. Rozycki 
18486c6f7d0SMaciej W. Rozycki #define	BT459_CMD_REG_0		0x0201
18586c6f7d0SMaciej W. Rozycki #define	BT459_CMD_REG_1		0x0202
18686c6f7d0SMaciej W. Rozycki #define	BT459_CMD_REG_2		0x0203
18786c6f7d0SMaciej W. Rozycki 
18886c6f7d0SMaciej W. Rozycki #define	BT459_READ_MASK		0x0204
18986c6f7d0SMaciej W. Rozycki 
19086c6f7d0SMaciej W. Rozycki #define	BT459_BLINK_MASK	0x0206
19186c6f7d0SMaciej W. Rozycki 
19286c6f7d0SMaciej W. Rozycki #define	BT459_CUR_CMD_REG	0x0300
19386c6f7d0SMaciej W. Rozycki 
19486c6f7d0SMaciej W. Rozycki /*
1951da177e4SLinus Torvalds  * The framebuffer driver private data.
1961da177e4SLinus Torvalds  */
1971da177e4SLinus Torvalds 
1981da177e4SLinus Torvalds struct tga_par {
19986c6f7d0SMaciej W. Rozycki 	/* PCI/TC device.  */
20086c6f7d0SMaciej W. Rozycki 	struct device *dev;
2011da177e4SLinus Torvalds 
2021da177e4SLinus Torvalds 	/* Device dependent information.  */
2031da177e4SLinus Torvalds 	void __iomem *tga_mem_base;
2041da177e4SLinus Torvalds 	void __iomem *tga_fb_base;
2051da177e4SLinus Torvalds 	void __iomem *tga_regs_base;
2061da177e4SLinus Torvalds 	u8 tga_type;				/* TGA_TYPE_XXX */
2071da177e4SLinus Torvalds 	u8 tga_chip_rev;			/* dc21030 revision */
2081da177e4SLinus Torvalds 
2091da177e4SLinus Torvalds 	/* Remember blank mode.  */
2101da177e4SLinus Torvalds 	u8 vesa_blanked;
2111da177e4SLinus Torvalds 
2121da177e4SLinus Torvalds 	/* Define the video mode.  */
2131da177e4SLinus Torvalds 	u32 xres, yres;			/* resolution in pixels */
2141da177e4SLinus Torvalds 	u32 htimings;			/* horizontal timing register */
2151da177e4SLinus Torvalds 	u32 vtimings;			/* vertical timing register */
2161da177e4SLinus Torvalds 	u32 pll_freq;			/* pixclock in mhz */
2171da177e4SLinus Torvalds 	u32 bits_per_pixel;		/* bits per pixel */
2181da177e4SLinus Torvalds 	u32 sync_on_green;		/* set if sync is on green */
219*eb3daa83SAntonino A. Daplas 	u32 palette[16];
2201da177e4SLinus Torvalds };
2211da177e4SLinus Torvalds 
2221da177e4SLinus Torvalds 
2231da177e4SLinus Torvalds /*
2241da177e4SLinus Torvalds  * Macros for reading/writing TGA and RAMDAC registers
2251da177e4SLinus Torvalds  */
2261da177e4SLinus Torvalds 
2271da177e4SLinus Torvalds static inline void
TGA_WRITE_REG(struct tga_par * par,u32 v,u32 r)2281da177e4SLinus Torvalds TGA_WRITE_REG(struct tga_par *par, u32 v, u32 r)
2291da177e4SLinus Torvalds {
2301da177e4SLinus Torvalds 	writel(v, par->tga_regs_base +r);
2311da177e4SLinus Torvalds }
2321da177e4SLinus Torvalds 
2331da177e4SLinus Torvalds static inline u32
TGA_READ_REG(struct tga_par * par,u32 r)2341da177e4SLinus Torvalds TGA_READ_REG(struct tga_par *par, u32 r)
2351da177e4SLinus Torvalds {
2361da177e4SLinus Torvalds 	return readl(par->tga_regs_base +r);
2371da177e4SLinus Torvalds }
2381da177e4SLinus Torvalds 
2391da177e4SLinus Torvalds static inline void
BT485_WRITE(struct tga_par * par,u8 v,u8 r)2401da177e4SLinus Torvalds BT485_WRITE(struct tga_par *par, u8 v, u8 r)
2411da177e4SLinus Torvalds {
2421da177e4SLinus Torvalds 	TGA_WRITE_REG(par, r, TGA_RAMDAC_SETUP_REG);
2431da177e4SLinus Torvalds 	TGA_WRITE_REG(par, v | (r << 8), TGA_RAMDAC_REG);
2441da177e4SLinus Torvalds }
2451da177e4SLinus Torvalds 
2461da177e4SLinus Torvalds static inline void
BT463_LOAD_ADDR(struct tga_par * par,u16 a)2471da177e4SLinus Torvalds BT463_LOAD_ADDR(struct tga_par *par, u16 a)
2481da177e4SLinus Torvalds {
2491da177e4SLinus Torvalds 	TGA_WRITE_REG(par, BT463_ADDR_LO<<2, TGA_RAMDAC_SETUP_REG);
2501da177e4SLinus Torvalds 	TGA_WRITE_REG(par, (BT463_ADDR_LO<<10) | (a & 0xff), TGA_RAMDAC_REG);
2511da177e4SLinus Torvalds 	TGA_WRITE_REG(par, BT463_ADDR_HI<<2, TGA_RAMDAC_SETUP_REG);
2521da177e4SLinus Torvalds 	TGA_WRITE_REG(par, (BT463_ADDR_HI<<10) | (a >> 8), TGA_RAMDAC_REG);
2531da177e4SLinus Torvalds }
2541da177e4SLinus Torvalds 
2551da177e4SLinus Torvalds static inline void
BT463_WRITE(struct tga_par * par,u32 m,u16 a,u8 v)2561da177e4SLinus Torvalds BT463_WRITE(struct tga_par *par, u32 m, u16 a, u8 v)
2571da177e4SLinus Torvalds {
2581da177e4SLinus Torvalds 	BT463_LOAD_ADDR(par, a);
2591da177e4SLinus Torvalds 	TGA_WRITE_REG(par, m << 2, TGA_RAMDAC_SETUP_REG);
2601da177e4SLinus Torvalds 	TGA_WRITE_REG(par, m << 10 | v, TGA_RAMDAC_REG);
2611da177e4SLinus Torvalds }
2621da177e4SLinus Torvalds 
26386c6f7d0SMaciej W. Rozycki static inline void
BT459_LOAD_ADDR(struct tga_par * par,u16 a)26486c6f7d0SMaciej W. Rozycki BT459_LOAD_ADDR(struct tga_par *par, u16 a)
26586c6f7d0SMaciej W. Rozycki {
26686c6f7d0SMaciej W. Rozycki 	TGA_WRITE_REG(par, BT459_ADDR_LO << 2, TGA_RAMDAC_SETUP_REG);
26786c6f7d0SMaciej W. Rozycki 	TGA_WRITE_REG(par, a & 0xff, TGA_RAMDAC_REG);
26886c6f7d0SMaciej W. Rozycki 	TGA_WRITE_REG(par, BT459_ADDR_HI << 2, TGA_RAMDAC_SETUP_REG);
26986c6f7d0SMaciej W. Rozycki 	TGA_WRITE_REG(par, a >> 8, TGA_RAMDAC_REG);
27086c6f7d0SMaciej W. Rozycki }
27186c6f7d0SMaciej W. Rozycki 
27286c6f7d0SMaciej W. Rozycki static inline void
BT459_WRITE(struct tga_par * par,u32 m,u16 a,u8 v)27386c6f7d0SMaciej W. Rozycki BT459_WRITE(struct tga_par *par, u32 m, u16 a, u8 v)
27486c6f7d0SMaciej W. Rozycki {
27586c6f7d0SMaciej W. Rozycki 	BT459_LOAD_ADDR(par, a);
27686c6f7d0SMaciej W. Rozycki 	TGA_WRITE_REG(par, m << 2, TGA_RAMDAC_SETUP_REG);
27786c6f7d0SMaciej W. Rozycki 	TGA_WRITE_REG(par, v, TGA_RAMDAC_REG);
27886c6f7d0SMaciej W. Rozycki }
27986c6f7d0SMaciej W. Rozycki 
2801da177e4SLinus Torvalds #endif /* TGAFB_H */
281