18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci *  linux/drivers/video/tgafb.h -- DEC 21030 TGA frame buffer device
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci *  	Copyright (C) 1999,2000 Martin Lucina, Tom Zerucha
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci *  $Id: tgafb.h,v 1.4.2.3 2000/04/04 06:44:56 mato Exp $
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci *  This file is subject to the terms and conditions of the GNU General Public
98c2ecf20Sopenharmony_ci *  License. See the file COPYING in the main directory of this archive for
108c2ecf20Sopenharmony_ci *  more details.
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#ifndef TGAFB_H
148c2ecf20Sopenharmony_ci#define TGAFB_H
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/*
178c2ecf20Sopenharmony_ci * TGA hardware description (minimal)
188c2ecf20Sopenharmony_ci */
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define TGA_TYPE_8PLANE			0
218c2ecf20Sopenharmony_ci#define TGA_TYPE_24PLANE		1
228c2ecf20Sopenharmony_ci#define TGA_TYPE_24PLUSZ		3
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/*
258c2ecf20Sopenharmony_ci * Offsets within Memory Space
268c2ecf20Sopenharmony_ci */
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define	TGA_ROM_OFFSET			0x0000000
298c2ecf20Sopenharmony_ci#define	TGA_REGS_OFFSET			0x0100000
308c2ecf20Sopenharmony_ci#define	TGA_8PLANE_FB_OFFSET		0x0200000
318c2ecf20Sopenharmony_ci#define	TGA_24PLANE_FB_OFFSET		0x0804000
328c2ecf20Sopenharmony_ci#define	TGA_24PLUSZ_FB_OFFSET		0x1004000
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define TGA_FOREGROUND_REG		0x0020
358c2ecf20Sopenharmony_ci#define TGA_BACKGROUND_REG		0x0024
368c2ecf20Sopenharmony_ci#define	TGA_PLANEMASK_REG		0x0028
378c2ecf20Sopenharmony_ci#define TGA_PIXELMASK_ONESHOT_REG	0x002c
388c2ecf20Sopenharmony_ci#define	TGA_MODE_REG			0x0030
398c2ecf20Sopenharmony_ci#define	TGA_RASTEROP_REG		0x0034
408c2ecf20Sopenharmony_ci#define	TGA_PIXELSHIFT_REG		0x0038
418c2ecf20Sopenharmony_ci#define	TGA_DEEP_REG			0x0050
428c2ecf20Sopenharmony_ci#define	TGA_START_REG			0x0054
438c2ecf20Sopenharmony_ci#define	TGA_PIXELMASK_REG		0x005c
448c2ecf20Sopenharmony_ci#define	TGA_CURSOR_BASE_REG		0x0060
458c2ecf20Sopenharmony_ci#define	TGA_HORIZ_REG			0x0064
468c2ecf20Sopenharmony_ci#define	TGA_VERT_REG			0x0068
478c2ecf20Sopenharmony_ci#define	TGA_BASE_ADDR_REG		0x006c
488c2ecf20Sopenharmony_ci#define	TGA_VALID_REG			0x0070
498c2ecf20Sopenharmony_ci#define	TGA_CURSOR_XY_REG		0x0074
508c2ecf20Sopenharmony_ci#define	TGA_INTR_STAT_REG		0x007c
518c2ecf20Sopenharmony_ci#define TGA_DATA_REG			0x0080
528c2ecf20Sopenharmony_ci#define	TGA_RAMDAC_SETUP_REG		0x00c0
538c2ecf20Sopenharmony_ci#define	TGA_BLOCK_COLOR0_REG		0x0140
548c2ecf20Sopenharmony_ci#define	TGA_BLOCK_COLOR1_REG		0x0144
558c2ecf20Sopenharmony_ci#define	TGA_BLOCK_COLOR2_REG		0x0148
568c2ecf20Sopenharmony_ci#define	TGA_BLOCK_COLOR3_REG		0x014c
578c2ecf20Sopenharmony_ci#define	TGA_BLOCK_COLOR4_REG		0x0150
588c2ecf20Sopenharmony_ci#define	TGA_BLOCK_COLOR5_REG		0x0154
598c2ecf20Sopenharmony_ci#define	TGA_BLOCK_COLOR6_REG		0x0158
608c2ecf20Sopenharmony_ci#define	TGA_BLOCK_COLOR7_REG		0x015c
618c2ecf20Sopenharmony_ci#define TGA_COPY64_SRC			0x0160
628c2ecf20Sopenharmony_ci#define TGA_COPY64_DST			0x0164
638c2ecf20Sopenharmony_ci#define	TGA_CLOCK_REG			0x01e8
648c2ecf20Sopenharmony_ci#define	TGA_RAMDAC_REG			0x01f0
658c2ecf20Sopenharmony_ci#define	TGA_CMD_STAT_REG		0x01f8
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci/*
698c2ecf20Sopenharmony_ci * Useful defines for managing the registers
708c2ecf20Sopenharmony_ci */
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#define TGA_HORIZ_ODD			0x80000000
738c2ecf20Sopenharmony_ci#define TGA_HORIZ_POLARITY		0x40000000
748c2ecf20Sopenharmony_ci#define TGA_HORIZ_ACT_MSB		0x30000000
758c2ecf20Sopenharmony_ci#define TGA_HORIZ_BP			0x0fe00000
768c2ecf20Sopenharmony_ci#define TGA_HORIZ_SYNC			0x001fc000
778c2ecf20Sopenharmony_ci#define TGA_HORIZ_FP			0x00007c00
788c2ecf20Sopenharmony_ci#define TGA_HORIZ_ACT_LSB		0x000001ff
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#define TGA_VERT_SE			0x80000000
818c2ecf20Sopenharmony_ci#define TGA_VERT_POLARITY		0x40000000
828c2ecf20Sopenharmony_ci#define TGA_VERT_RESERVED		0x30000000
838c2ecf20Sopenharmony_ci#define TGA_VERT_BP			0x0fc00000
848c2ecf20Sopenharmony_ci#define TGA_VERT_SYNC			0x003f0000
858c2ecf20Sopenharmony_ci#define TGA_VERT_FP			0x0000f800
868c2ecf20Sopenharmony_ci#define TGA_VERT_ACTIVE			0x000007ff
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#define TGA_VALID_VIDEO			0x01
898c2ecf20Sopenharmony_ci#define TGA_VALID_BLANK			0x02
908c2ecf20Sopenharmony_ci#define TGA_VALID_CURSOR		0x04
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci#define TGA_MODE_SBM_8BPP		0x000
938c2ecf20Sopenharmony_ci#define TGA_MODE_SBM_24BPP		0x300
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define TGA_MODE_SIMPLE			0x00
968c2ecf20Sopenharmony_ci#define TGA_MODE_SIMPLEZ		0x10
978c2ecf20Sopenharmony_ci#define TGA_MODE_OPAQUE_STIPPLE		0x01
988c2ecf20Sopenharmony_ci#define TGA_MODE_OPAQUE_FILL		0x21
998c2ecf20Sopenharmony_ci#define TGA_MODE_TRANSPARENT_STIPPLE	0x03
1008c2ecf20Sopenharmony_ci#define TGA_MODE_TRANSPARENT_FILL	0x23
1018c2ecf20Sopenharmony_ci#define TGA_MODE_BLOCK_STIPPLE		0x0d
1028c2ecf20Sopenharmony_ci#define TGA_MODE_BLOCK_FILL		0x2d
1038c2ecf20Sopenharmony_ci#define TGA_MODE_COPY			0x07
1048c2ecf20Sopenharmony_ci#define TGA_MODE_DMA_READ_COPY_ND	0x17
1058c2ecf20Sopenharmony_ci#define TGA_MODE_DMA_READ_COPY_D	0x37
1068c2ecf20Sopenharmony_ci#define TGA_MODE_DMA_WRITE_COPY		0x1f
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci/*
1108c2ecf20Sopenharmony_ci * Useful defines for managing the ICS1562 PLL clock
1118c2ecf20Sopenharmony_ci */
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci#define TGA_PLL_BASE_FREQ 		14318		/* .18 */
1148c2ecf20Sopenharmony_ci#define TGA_PLL_MAX_FREQ 		230000
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci/*
1188c2ecf20Sopenharmony_ci * Useful defines for managing the BT485 on the 8-plane TGA
1198c2ecf20Sopenharmony_ci */
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci#define	BT485_READ_BIT			0x01
1228c2ecf20Sopenharmony_ci#define	BT485_WRITE_BIT			0x00
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci#define	BT485_ADDR_PAL_WRITE		0x00
1258c2ecf20Sopenharmony_ci#define	BT485_DATA_PAL			0x02
1268c2ecf20Sopenharmony_ci#define	BT485_PIXEL_MASK		0x04
1278c2ecf20Sopenharmony_ci#define	BT485_ADDR_PAL_READ		0x06
1288c2ecf20Sopenharmony_ci#define	BT485_ADDR_CUR_WRITE		0x08
1298c2ecf20Sopenharmony_ci#define	BT485_DATA_CUR			0x0a
1308c2ecf20Sopenharmony_ci#define	BT485_CMD_0			0x0c
1318c2ecf20Sopenharmony_ci#define	BT485_ADDR_CUR_READ		0x0e
1328c2ecf20Sopenharmony_ci#define	BT485_CMD_1			0x10
1338c2ecf20Sopenharmony_ci#define	BT485_CMD_2			0x12
1348c2ecf20Sopenharmony_ci#define	BT485_STATUS			0x14
1358c2ecf20Sopenharmony_ci#define	BT485_CMD_3			0x14
1368c2ecf20Sopenharmony_ci#define	BT485_CUR_RAM			0x16
1378c2ecf20Sopenharmony_ci#define	BT485_CUR_LOW_X			0x18
1388c2ecf20Sopenharmony_ci#define	BT485_CUR_HIGH_X		0x1a
1398c2ecf20Sopenharmony_ci#define	BT485_CUR_LOW_Y			0x1c
1408c2ecf20Sopenharmony_ci#define	BT485_CUR_HIGH_Y		0x1e
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci/*
1448c2ecf20Sopenharmony_ci * Useful defines for managing the BT463 on the 24-plane TGAs/SFB+s
1458c2ecf20Sopenharmony_ci */
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci#define	BT463_ADDR_LO		0x0
1488c2ecf20Sopenharmony_ci#define	BT463_ADDR_HI		0x1
1498c2ecf20Sopenharmony_ci#define	BT463_REG_ACC		0x2
1508c2ecf20Sopenharmony_ci#define	BT463_PALETTE		0x3
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci#define	BT463_CUR_CLR_0		0x0100
1538c2ecf20Sopenharmony_ci#define	BT463_CUR_CLR_1		0x0101
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci#define	BT463_CMD_REG_0		0x0201
1568c2ecf20Sopenharmony_ci#define	BT463_CMD_REG_1		0x0202
1578c2ecf20Sopenharmony_ci#define	BT463_CMD_REG_2		0x0203
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci#define	BT463_READ_MASK_0	0x0205
1608c2ecf20Sopenharmony_ci#define	BT463_READ_MASK_1	0x0206
1618c2ecf20Sopenharmony_ci#define	BT463_READ_MASK_2	0x0207
1628c2ecf20Sopenharmony_ci#define	BT463_READ_MASK_3	0x0208
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci#define	BT463_BLINK_MASK_0	0x0209
1658c2ecf20Sopenharmony_ci#define	BT463_BLINK_MASK_1	0x020a
1668c2ecf20Sopenharmony_ci#define	BT463_BLINK_MASK_2	0x020b
1678c2ecf20Sopenharmony_ci#define	BT463_BLINK_MASK_3	0x020c
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci#define	BT463_WINDOW_TYPE_BASE	0x0300
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci/*
1728c2ecf20Sopenharmony_ci * Useful defines for managing the BT459 on the 8-plane SFB+s
1738c2ecf20Sopenharmony_ci */
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci#define	BT459_ADDR_LO		0x0
1768c2ecf20Sopenharmony_ci#define	BT459_ADDR_HI		0x1
1778c2ecf20Sopenharmony_ci#define	BT459_REG_ACC		0x2
1788c2ecf20Sopenharmony_ci#define	BT459_PALETTE		0x3
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci#define	BT459_CUR_CLR_1		0x0181
1818c2ecf20Sopenharmony_ci#define	BT459_CUR_CLR_2		0x0182
1828c2ecf20Sopenharmony_ci#define	BT459_CUR_CLR_3		0x0183
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci#define	BT459_CMD_REG_0		0x0201
1858c2ecf20Sopenharmony_ci#define	BT459_CMD_REG_1		0x0202
1868c2ecf20Sopenharmony_ci#define	BT459_CMD_REG_2		0x0203
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci#define	BT459_READ_MASK		0x0204
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci#define	BT459_BLINK_MASK	0x0206
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci#define	BT459_CUR_CMD_REG	0x0300
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci/*
1958c2ecf20Sopenharmony_ci * The framebuffer driver private data.
1968c2ecf20Sopenharmony_ci */
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_cistruct tga_par {
1998c2ecf20Sopenharmony_ci	/* PCI/TC device.  */
2008c2ecf20Sopenharmony_ci	struct device *dev;
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci	/* Device dependent information.  */
2038c2ecf20Sopenharmony_ci	void __iomem *tga_mem_base;
2048c2ecf20Sopenharmony_ci	void __iomem *tga_fb_base;
2058c2ecf20Sopenharmony_ci	void __iomem *tga_regs_base;
2068c2ecf20Sopenharmony_ci	u8 tga_type;				/* TGA_TYPE_XXX */
2078c2ecf20Sopenharmony_ci	u8 tga_chip_rev;			/* dc21030 revision */
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci	/* Remember blank mode.  */
2108c2ecf20Sopenharmony_ci	u8 vesa_blanked;
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_ci	/* Define the video mode.  */
2138c2ecf20Sopenharmony_ci	u32 xres, yres;			/* resolution in pixels */
2148c2ecf20Sopenharmony_ci	u32 htimings;			/* horizontal timing register */
2158c2ecf20Sopenharmony_ci	u32 vtimings;			/* vertical timing register */
2168c2ecf20Sopenharmony_ci	u32 pll_freq;			/* pixclock in mhz */
2178c2ecf20Sopenharmony_ci	u32 bits_per_pixel;		/* bits per pixel */
2188c2ecf20Sopenharmony_ci	u32 sync_on_green;		/* set if sync is on green */
2198c2ecf20Sopenharmony_ci	u32 palette[16];
2208c2ecf20Sopenharmony_ci};
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci/*
2248c2ecf20Sopenharmony_ci * Macros for reading/writing TGA and RAMDAC registers
2258c2ecf20Sopenharmony_ci */
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_cistatic inline void
2288c2ecf20Sopenharmony_ciTGA_WRITE_REG(struct tga_par *par, u32 v, u32 r)
2298c2ecf20Sopenharmony_ci{
2308c2ecf20Sopenharmony_ci	writel(v, par->tga_regs_base +r);
2318c2ecf20Sopenharmony_ci}
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_cistatic inline u32
2348c2ecf20Sopenharmony_ciTGA_READ_REG(struct tga_par *par, u32 r)
2358c2ecf20Sopenharmony_ci{
2368c2ecf20Sopenharmony_ci	return readl(par->tga_regs_base +r);
2378c2ecf20Sopenharmony_ci}
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_cistatic inline void
2408c2ecf20Sopenharmony_ciBT485_WRITE(struct tga_par *par, u8 v, u8 r)
2418c2ecf20Sopenharmony_ci{
2428c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, r, TGA_RAMDAC_SETUP_REG);
2438c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, v | (r << 8), TGA_RAMDAC_REG);
2448c2ecf20Sopenharmony_ci}
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_cistatic inline void
2478c2ecf20Sopenharmony_ciBT463_LOAD_ADDR(struct tga_par *par, u16 a)
2488c2ecf20Sopenharmony_ci{
2498c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, BT463_ADDR_LO<<2, TGA_RAMDAC_SETUP_REG);
2508c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, (BT463_ADDR_LO<<10) | (a & 0xff), TGA_RAMDAC_REG);
2518c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, BT463_ADDR_HI<<2, TGA_RAMDAC_SETUP_REG);
2528c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, (BT463_ADDR_HI<<10) | (a >> 8), TGA_RAMDAC_REG);
2538c2ecf20Sopenharmony_ci}
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_cistatic inline void
2568c2ecf20Sopenharmony_ciBT463_WRITE(struct tga_par *par, u32 m, u16 a, u8 v)
2578c2ecf20Sopenharmony_ci{
2588c2ecf20Sopenharmony_ci	BT463_LOAD_ADDR(par, a);
2598c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, m << 2, TGA_RAMDAC_SETUP_REG);
2608c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, m << 10 | v, TGA_RAMDAC_REG);
2618c2ecf20Sopenharmony_ci}
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_cistatic inline void
2648c2ecf20Sopenharmony_ciBT459_LOAD_ADDR(struct tga_par *par, u16 a)
2658c2ecf20Sopenharmony_ci{
2668c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, BT459_ADDR_LO << 2, TGA_RAMDAC_SETUP_REG);
2678c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, a & 0xff, TGA_RAMDAC_REG);
2688c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, BT459_ADDR_HI << 2, TGA_RAMDAC_SETUP_REG);
2698c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, a >> 8, TGA_RAMDAC_REG);
2708c2ecf20Sopenharmony_ci}
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_cistatic inline void
2738c2ecf20Sopenharmony_ciBT459_WRITE(struct tga_par *par, u32 m, u16 a, u8 v)
2748c2ecf20Sopenharmony_ci{
2758c2ecf20Sopenharmony_ci	BT459_LOAD_ADDR(par, a);
2768c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, m << 2, TGA_RAMDAC_SETUP_REG);
2778c2ecf20Sopenharmony_ci	TGA_WRITE_REG(par, v, TGA_RAMDAC_REG);
2788c2ecf20Sopenharmony_ci}
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci#endif /* TGAFB_H */
281