18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * linux/drivers/video/savagefb.h -- S3 Savage Framebuffer Driver
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (c) 2001  Denis Oliver Kropp <dok@convergence.de>
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General
78c2ecf20Sopenharmony_ci * Public License.  See the file COPYING in the main directory of this
88c2ecf20Sopenharmony_ci * archive for more details.
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef __SAVAGEFB_H__
138c2ecf20Sopenharmony_ci#define __SAVAGEFB_H__
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <linux/i2c.h>
168c2ecf20Sopenharmony_ci#include <linux/i2c-algo-bit.h>
178c2ecf20Sopenharmony_ci#include <linux/mutex.h>
188c2ecf20Sopenharmony_ci#include <video/vga.h>
198c2ecf20Sopenharmony_ci#include "../edid.h"
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#ifdef SAVAGEFB_DEBUG
228c2ecf20Sopenharmony_ci# define DBG(x)		printk (KERN_DEBUG "savagefb: %s\n", (x));
238c2ecf20Sopenharmony_ci#else
248c2ecf20Sopenharmony_ci# define DBG(x)		no_printk(x)
258c2ecf20Sopenharmony_ci# define SavagePrintRegs(...)
268c2ecf20Sopenharmony_ci#endif
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#define PCI_CHIP_SAVAGE4      0x8a22
308c2ecf20Sopenharmony_ci#define PCI_CHIP_SAVAGE3D     0x8a20
318c2ecf20Sopenharmony_ci#define PCI_CHIP_SAVAGE3D_MV  0x8a21
328c2ecf20Sopenharmony_ci#define PCI_CHIP_SAVAGE2000   0x9102
338c2ecf20Sopenharmony_ci#define PCI_CHIP_SAVAGE_MX_MV 0x8c10
348c2ecf20Sopenharmony_ci#define PCI_CHIP_SAVAGE_MX    0x8c11
358c2ecf20Sopenharmony_ci#define PCI_CHIP_SAVAGE_IX_MV 0x8c12
368c2ecf20Sopenharmony_ci#define PCI_CHIP_SAVAGE_IX    0x8c13
378c2ecf20Sopenharmony_ci#define PCI_CHIP_PROSAVAGE_PM 0x8a25
388c2ecf20Sopenharmony_ci#define PCI_CHIP_PROSAVAGE_KM 0x8a26
398c2ecf20Sopenharmony_ci#define PCI_CHIP_S3TWISTER_P  0x8d01
408c2ecf20Sopenharmony_ci#define PCI_CHIP_S3TWISTER_K  0x8d02
418c2ecf20Sopenharmony_ci#define PCI_CHIP_PROSAVAGE_DDR          0x8d03
428c2ecf20Sopenharmony_ci#define PCI_CHIP_PROSAVAGE_DDRK         0x8d04
438c2ecf20Sopenharmony_ci#define PCI_CHIP_SUPSAV_MX128		0x8c22
448c2ecf20Sopenharmony_ci#define PCI_CHIP_SUPSAV_MX64		0x8c24
458c2ecf20Sopenharmony_ci#define PCI_CHIP_SUPSAV_MX64C		0x8c26
468c2ecf20Sopenharmony_ci#define PCI_CHIP_SUPSAV_IX128SDR	0x8c2a
478c2ecf20Sopenharmony_ci#define PCI_CHIP_SUPSAV_IX128DDR	0x8c2b
488c2ecf20Sopenharmony_ci#define PCI_CHIP_SUPSAV_IX64SDR		0x8c2c
498c2ecf20Sopenharmony_ci#define PCI_CHIP_SUPSAV_IX64DDR		0x8c2d
508c2ecf20Sopenharmony_ci#define PCI_CHIP_SUPSAV_IXCSDR		0x8c2e
518c2ecf20Sopenharmony_ci#define PCI_CHIP_SUPSAV_IXCDDR		0x8c2f
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#define S3_SAVAGE_SERIES(chip)    ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE2000))
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#define S3_SAVAGE3D_SERIES(chip)  ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX))
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci#define S3_SAVAGE4_SERIES(chip)   ((chip>=S3_SAVAGE4) && (chip<=S3_PROSAVAGEDDR))
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci#define S3_SAVAGE_MOBILE_SERIES(chip)  ((chip==S3_SAVAGE_MX) || (chip==S3_SUPERSAVAGE))
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#define S3_MOBILE_TWISTER_SERIES(chip) ((chip==S3_TWISTER) || (chip==S3_PROSAVAGEDDR))
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci/* Chip tags.  These are used to group the adapters into
658c2ecf20Sopenharmony_ci * related families.
668c2ecf20Sopenharmony_ci */
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_citypedef enum {
698c2ecf20Sopenharmony_ci  S3_UNKNOWN = 0,
708c2ecf20Sopenharmony_ci  S3_SAVAGE3D,
718c2ecf20Sopenharmony_ci  S3_SAVAGE_MX,
728c2ecf20Sopenharmony_ci  S3_SAVAGE4,
738c2ecf20Sopenharmony_ci  S3_PROSAVAGE,
748c2ecf20Sopenharmony_ci  S3_TWISTER,
758c2ecf20Sopenharmony_ci  S3_PROSAVAGEDDR,
768c2ecf20Sopenharmony_ci  S3_SUPERSAVAGE,
778c2ecf20Sopenharmony_ci  S3_SAVAGE2000,
788c2ecf20Sopenharmony_ci  S3_LAST
798c2ecf20Sopenharmony_ci} savage_chipset;
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#define BIOS_BSIZE		     1024
828c2ecf20Sopenharmony_ci#define BIOS_BASE		     0xc0000
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define SAVAGE_NEWMMIO_REGBASE_S3    0x1000000  /* 16MB */
858c2ecf20Sopenharmony_ci#define SAVAGE_NEWMMIO_REGBASE_S4    0x0000000
868c2ecf20Sopenharmony_ci#define SAVAGE_NEWMMIO_REGSIZE	     0x0080000  /* 512kb */
878c2ecf20Sopenharmony_ci#define SAVAGE_NEWMMIO_VGABASE	     0x8000
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#define BASE_FREQ		     14318
908c2ecf20Sopenharmony_ci#define HALF_BASE_FREQ               7159
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci#define FIFO_CONTROL_REG	     0x8200
938c2ecf20Sopenharmony_ci#define MIU_CONTROL_REG		     0x8204
948c2ecf20Sopenharmony_ci#define STREAMS_TIMEOUT_REG	     0x8208
958c2ecf20Sopenharmony_ci#define MISC_TIMEOUT_REG	     0x820c
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#define MONO_PAT_0                   0xa4e8
988c2ecf20Sopenharmony_ci#define MONO_PAT_1                   0xa4ec
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci#define MAXFIFO                      0x7f00
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#define BCI_CMD_NOP                  0x40000000
1038c2ecf20Sopenharmony_ci#define BCI_CMD_SETREG               0x96000000
1048c2ecf20Sopenharmony_ci#define BCI_CMD_RECT                 0x48000000
1058c2ecf20Sopenharmony_ci#define BCI_CMD_RECT_XP              0x01000000
1068c2ecf20Sopenharmony_ci#define BCI_CMD_RECT_YP              0x02000000
1078c2ecf20Sopenharmony_ci#define BCI_CMD_SEND_COLOR           0x00008000
1088c2ecf20Sopenharmony_ci#define BCI_CMD_DEST_GBD             0x00000000
1098c2ecf20Sopenharmony_ci#define BCI_CMD_SRC_GBD              0x00000020
1108c2ecf20Sopenharmony_ci#define BCI_CMD_SRC_SOLID            0x00000000
1118c2ecf20Sopenharmony_ci#define BCI_CMD_SRC_MONO             0x00000060
1128c2ecf20Sopenharmony_ci#define BCI_CMD_CLIP_NEW             0x00006000
1138c2ecf20Sopenharmony_ci#define BCI_CMD_CLIP_LR              0x00004000
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#define BCI_CLIP_LR(l, r)            ((((r) << 16) | (l)) & 0x0FFF0FFF)
1168c2ecf20Sopenharmony_ci#define BCI_CLIP_TL(t, l)            ((((t) << 16) | (l)) & 0x0FFF0FFF)
1178c2ecf20Sopenharmony_ci#define BCI_CLIP_BR(b, r)            ((((b) << 16) | (r)) & 0x0FFF0FFF)
1188c2ecf20Sopenharmony_ci#define BCI_W_H(w, h)                (((h) << 16) | ((w) & 0xFFF))
1198c2ecf20Sopenharmony_ci#define BCI_X_Y(x, y)                (((y) << 16) | ((x) & 0xFFF))
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci#define BCI_GBD1                     0xE0
1228c2ecf20Sopenharmony_ci#define BCI_GBD2                     0xE1
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci#define BCI_BUFFER_OFFSET            0x10000
1258c2ecf20Sopenharmony_ci#define BCI_SIZE                     0x4000
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#define BCI_SEND(dw)                 writel(dw, par->bci_base + par->bci_ptr++)
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci#define BCI_CMD_GET_ROP(cmd)         (((cmd) >> 16) & 0xFF)
1308c2ecf20Sopenharmony_ci#define BCI_CMD_SET_ROP(cmd, rop)    ((cmd) |= ((rop & 0xFF) << 16))
1318c2ecf20Sopenharmony_ci#define BCI_CMD_SEND_COLOR           0x00008000
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci#define DISP_CRT     1
1348c2ecf20Sopenharmony_ci#define DISP_LCD     2
1358c2ecf20Sopenharmony_ci#define DISP_DFP     3
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_cistruct xtimings {
1388c2ecf20Sopenharmony_ci	unsigned int Clock;
1398c2ecf20Sopenharmony_ci	unsigned int HDisplay;
1408c2ecf20Sopenharmony_ci	unsigned int HSyncStart;
1418c2ecf20Sopenharmony_ci	unsigned int HSyncEnd;
1428c2ecf20Sopenharmony_ci	unsigned int HTotal;
1438c2ecf20Sopenharmony_ci	unsigned int HAdjusted;
1448c2ecf20Sopenharmony_ci	unsigned int VDisplay;
1458c2ecf20Sopenharmony_ci	unsigned int VSyncStart;
1468c2ecf20Sopenharmony_ci	unsigned int VSyncEnd;
1478c2ecf20Sopenharmony_ci	unsigned int VTotal;
1488c2ecf20Sopenharmony_ci	unsigned int sync;
1498c2ecf20Sopenharmony_ci	int	       dblscan;
1508c2ecf20Sopenharmony_ci	int	       interlaced;
1518c2ecf20Sopenharmony_ci};
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cistruct savage_reg {
1548c2ecf20Sopenharmony_ci	unsigned char MiscOutReg;     /* Misc */
1558c2ecf20Sopenharmony_ci	unsigned char CRTC[25];       /* Crtc Controller */
1568c2ecf20Sopenharmony_ci	unsigned char Sequencer[5];   /* Video Sequencer */
1578c2ecf20Sopenharmony_ci	unsigned char Graphics[9];    /* Video Graphics */
1588c2ecf20Sopenharmony_ci	unsigned char Attribute[21];  /* Video Attribute */
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci	unsigned int mode, refresh;
1618c2ecf20Sopenharmony_ci	unsigned char SR08, SR0E, SR0F;
1628c2ecf20Sopenharmony_ci	unsigned char SR10, SR11, SR12, SR13, SR15, SR18, SR29, SR30;
1638c2ecf20Sopenharmony_ci	unsigned char SR54[8];
1648c2ecf20Sopenharmony_ci	unsigned char Clock;
1658c2ecf20Sopenharmony_ci	unsigned char CR31, CR32, CR33, CR34, CR36, CR3A, CR3B, CR3C;
1668c2ecf20Sopenharmony_ci	unsigned char CR40, CR41, CR42, CR43, CR45;
1678c2ecf20Sopenharmony_ci	unsigned char CR50, CR51, CR53, CR55, CR58, CR5B, CR5D, CR5E;
1688c2ecf20Sopenharmony_ci	unsigned char CR60, CR63, CR65, CR66, CR67, CR68, CR69, CR6D, CR6F;
1698c2ecf20Sopenharmony_ci	unsigned char CR86, CR88;
1708c2ecf20Sopenharmony_ci	unsigned char CR90, CR91, CRB0;
1718c2ecf20Sopenharmony_ci	unsigned int  STREAMS[22];	/* yuck, streams regs */
1728c2ecf20Sopenharmony_ci	unsigned int  MMPR0, MMPR1, MMPR2, MMPR3;
1738c2ecf20Sopenharmony_ci};
1748c2ecf20Sopenharmony_ci/* --------------------------------------------------------------------- */
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci#define NR_PALETTE	256
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_cistruct savagefb_par;
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_cistruct savagefb_i2c_chan {
1828c2ecf20Sopenharmony_ci	struct savagefb_par *par;
1838c2ecf20Sopenharmony_ci	struct i2c_adapter adapter;
1848c2ecf20Sopenharmony_ci	struct i2c_algo_bit_data algo;
1858c2ecf20Sopenharmony_ci	volatile u8 __iomem *ioaddr;
1868c2ecf20Sopenharmony_ci	u32   reg;
1878c2ecf20Sopenharmony_ci};
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_cistruct savagefb_par {
1908c2ecf20Sopenharmony_ci	struct pci_dev *pcidev;
1918c2ecf20Sopenharmony_ci	savage_chipset  chip;
1928c2ecf20Sopenharmony_ci	struct savagefb_i2c_chan chan;
1938c2ecf20Sopenharmony_ci	struct savage_reg state;
1948c2ecf20Sopenharmony_ci	struct savage_reg save;
1958c2ecf20Sopenharmony_ci	struct savage_reg initial;
1968c2ecf20Sopenharmony_ci	struct vgastate vgastate;
1978c2ecf20Sopenharmony_ci	struct mutex open_lock;
1988c2ecf20Sopenharmony_ci	unsigned char   *edid;
1998c2ecf20Sopenharmony_ci	u32 pseudo_palette[16];
2008c2ecf20Sopenharmony_ci	u32 open_count;
2018c2ecf20Sopenharmony_ci	int paletteEnabled;
2028c2ecf20Sopenharmony_ci	int pm_state;
2038c2ecf20Sopenharmony_ci	int display_type;
2048c2ecf20Sopenharmony_ci	int dvi;
2058c2ecf20Sopenharmony_ci	int crtonly;
2068c2ecf20Sopenharmony_ci	int dacSpeedBpp;
2078c2ecf20Sopenharmony_ci	int maxClock;
2088c2ecf20Sopenharmony_ci	int minClock;
2098c2ecf20Sopenharmony_ci	int numClocks;
2108c2ecf20Sopenharmony_ci	int clock[4];
2118c2ecf20Sopenharmony_ci	int MCLK, REFCLK, LCDclk;
2128c2ecf20Sopenharmony_ci	struct {
2138c2ecf20Sopenharmony_ci		void   __iomem *vbase;
2148c2ecf20Sopenharmony_ci		u32    pbase;
2158c2ecf20Sopenharmony_ci		u32    len;
2168c2ecf20Sopenharmony_ci		int    wc_cookie;
2178c2ecf20Sopenharmony_ci	} video;
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci	struct {
2208c2ecf20Sopenharmony_ci		void  __iomem *vbase;
2218c2ecf20Sopenharmony_ci		u32           pbase;
2228c2ecf20Sopenharmony_ci		u32           len;
2238c2ecf20Sopenharmony_ci	} mmio;
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci	volatile u32  __iomem *bci_base;
2268c2ecf20Sopenharmony_ci	unsigned int  bci_ptr;
2278c2ecf20Sopenharmony_ci	u32           cob_offset;
2288c2ecf20Sopenharmony_ci	u32           cob_size;
2298c2ecf20Sopenharmony_ci	int           cob_index;
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci	void (*SavageWaitIdle) (struct savagefb_par *par);
2328c2ecf20Sopenharmony_ci	void (*SavageWaitFifo) (struct savagefb_par *par, int space);
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci	int HorizScaleFactor;
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci	/* Panels size */
2378c2ecf20Sopenharmony_ci	int SavagePanelWidth;
2388c2ecf20Sopenharmony_ci	int SavagePanelHeight;
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci	struct {
2418c2ecf20Sopenharmony_ci		u16 red, green, blue, transp;
2428c2ecf20Sopenharmony_ci	} palette[NR_PALETTE];
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci	int depth;
2458c2ecf20Sopenharmony_ci	int vwidth;
2468c2ecf20Sopenharmony_ci};
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci#define BCI_BD_BW_DISABLE            0x10000000
2498c2ecf20Sopenharmony_ci#define BCI_BD_SET_BPP(bd, bpp)      ((bd) |= (((bpp) & 0xFF) << 16))
2508c2ecf20Sopenharmony_ci#define BCI_BD_SET_STRIDE(bd, st)    ((bd) |= ((st) & 0xFFFF))
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci/* IO functions */
2548c2ecf20Sopenharmony_cistatic inline u8 savage_in8(u32 addr, struct savagefb_par *par)
2558c2ecf20Sopenharmony_ci{
2568c2ecf20Sopenharmony_ci	return readb(par->mmio.vbase + addr);
2578c2ecf20Sopenharmony_ci}
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_cistatic inline u16 savage_in16(u32 addr, struct savagefb_par *par)
2608c2ecf20Sopenharmony_ci{
2618c2ecf20Sopenharmony_ci	return readw(par->mmio.vbase + addr);
2628c2ecf20Sopenharmony_ci}
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_cistatic inline u32 savage_in32(u32 addr, struct savagefb_par *par)
2658c2ecf20Sopenharmony_ci{
2668c2ecf20Sopenharmony_ci	return readl(par->mmio.vbase + addr);
2678c2ecf20Sopenharmony_ci}
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_cistatic inline void savage_out8(u32 addr, u8 val, struct savagefb_par *par)
2708c2ecf20Sopenharmony_ci{
2718c2ecf20Sopenharmony_ci	writeb(val, par->mmio.vbase + addr);
2728c2ecf20Sopenharmony_ci}
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_cistatic inline void savage_out16(u32 addr, u16 val, struct savagefb_par *par)
2758c2ecf20Sopenharmony_ci{
2768c2ecf20Sopenharmony_ci	writew(val, par->mmio.vbase + addr);
2778c2ecf20Sopenharmony_ci}
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_cistatic inline void savage_out32(u32 addr, u32 val, struct savagefb_par *par)
2808c2ecf20Sopenharmony_ci{
2818c2ecf20Sopenharmony_ci	writel(val, par->mmio.vbase + addr);
2828c2ecf20Sopenharmony_ci}
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_cistatic inline u8 vga_in8(int addr, struct savagefb_par *par)
2858c2ecf20Sopenharmony_ci{
2868c2ecf20Sopenharmony_ci	return savage_in8(0x8000 + addr, par);
2878c2ecf20Sopenharmony_ci}
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_cistatic inline u16 vga_in16(int addr, struct savagefb_par *par)
2908c2ecf20Sopenharmony_ci{
2918c2ecf20Sopenharmony_ci	return savage_in16(0x8000 + addr, par);
2928c2ecf20Sopenharmony_ci}
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_cistatic inline u8 vga_in32(int addr, struct savagefb_par *par)
2958c2ecf20Sopenharmony_ci{
2968c2ecf20Sopenharmony_ci	return savage_in32(0x8000 + addr, par);
2978c2ecf20Sopenharmony_ci}
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_cistatic inline void vga_out8(int addr, u8 val, struct savagefb_par *par)
3008c2ecf20Sopenharmony_ci{
3018c2ecf20Sopenharmony_ci	savage_out8(0x8000 + addr, val, par);
3028c2ecf20Sopenharmony_ci}
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_cistatic inline void vga_out16(int addr, u16 val, struct savagefb_par *par)
3058c2ecf20Sopenharmony_ci{
3068c2ecf20Sopenharmony_ci	savage_out16(0x8000 + addr, val, par);
3078c2ecf20Sopenharmony_ci}
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_cistatic inline void vga_out32(int addr, u32 val, struct savagefb_par *par)
3108c2ecf20Sopenharmony_ci{
3118c2ecf20Sopenharmony_ci	savage_out32(0x8000 + addr, val, par);
3128c2ecf20Sopenharmony_ci}
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_cistatic inline u8 VGArCR (u8 index, struct savagefb_par *par)
3158c2ecf20Sopenharmony_ci{
3168c2ecf20Sopenharmony_ci	vga_out8(0x3d4, index,  par);
3178c2ecf20Sopenharmony_ci	return vga_in8(0x3d5, par);
3188c2ecf20Sopenharmony_ci}
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_cistatic inline u8 VGArGR (u8 index, struct savagefb_par *par)
3218c2ecf20Sopenharmony_ci{
3228c2ecf20Sopenharmony_ci	vga_out8(0x3ce, index, par);
3238c2ecf20Sopenharmony_ci	return vga_in8(0x3cf, par);
3248c2ecf20Sopenharmony_ci}
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_cistatic inline u8 VGArSEQ (u8 index, struct savagefb_par *par)
3278c2ecf20Sopenharmony_ci{
3288c2ecf20Sopenharmony_ci	vga_out8(0x3c4, index, par);
3298c2ecf20Sopenharmony_ci	return vga_in8(0x3c5, par);
3308c2ecf20Sopenharmony_ci}
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_cistatic inline void VGAwCR(u8 index, u8 val, struct savagefb_par *par)
3338c2ecf20Sopenharmony_ci{
3348c2ecf20Sopenharmony_ci	vga_out8(0x3d4, index, par);
3358c2ecf20Sopenharmony_ci	vga_out8(0x3d5, val, par);
3368c2ecf20Sopenharmony_ci}
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_cistatic inline void VGAwGR(u8 index, u8 val, struct savagefb_par *par)
3398c2ecf20Sopenharmony_ci{
3408c2ecf20Sopenharmony_ci	vga_out8(0x3ce, index, par);
3418c2ecf20Sopenharmony_ci	vga_out8(0x3cf, val, par);
3428c2ecf20Sopenharmony_ci}
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_cistatic inline void VGAwSEQ(u8 index, u8 val, struct savagefb_par *par)
3458c2ecf20Sopenharmony_ci{
3468c2ecf20Sopenharmony_ci	vga_out8(0x3c4, index, par);
3478c2ecf20Sopenharmony_ci	vga_out8 (0x3c5, val, par);
3488c2ecf20Sopenharmony_ci}
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_cistatic inline void VGAenablePalette(struct savagefb_par *par)
3518c2ecf20Sopenharmony_ci{
3528c2ecf20Sopenharmony_ci	vga_in8(0x3da, par);
3538c2ecf20Sopenharmony_ci	vga_out8(0x3c0, 0x00, par);
3548c2ecf20Sopenharmony_ci	par->paletteEnabled = 1;
3558c2ecf20Sopenharmony_ci}
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_cistatic inline void VGAdisablePalette(struct savagefb_par *par)
3588c2ecf20Sopenharmony_ci{
3598c2ecf20Sopenharmony_ci	vga_in8(0x3da, par);
3608c2ecf20Sopenharmony_ci	vga_out8(0x3c0, 0x20, par);
3618c2ecf20Sopenharmony_ci	par->paletteEnabled = 0;
3628c2ecf20Sopenharmony_ci}
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_cistatic inline void VGAwATTR(u8 index, u8 value, struct savagefb_par *par)
3658c2ecf20Sopenharmony_ci{
3668c2ecf20Sopenharmony_ci	if (par->paletteEnabled)
3678c2ecf20Sopenharmony_ci		index &= ~0x20;
3688c2ecf20Sopenharmony_ci	else
3698c2ecf20Sopenharmony_ci		index |= 0x20;
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ci	vga_in8(0x3da, par);
3728c2ecf20Sopenharmony_ci	vga_out8(0x3c0, index, par);
3738c2ecf20Sopenharmony_ci	vga_out8 (0x3c0, value, par);
3748c2ecf20Sopenharmony_ci}
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_cistatic inline void VGAwMISC(u8 value, struct savagefb_par *par)
3778c2ecf20Sopenharmony_ci{
3788c2ecf20Sopenharmony_ci	vga_out8(0x3c2, value, par);
3798c2ecf20Sopenharmony_ci}
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci#ifndef CONFIG_FB_SAVAGE_ACCEL
3828c2ecf20Sopenharmony_ci#define savagefb_set_clip(x)
3838c2ecf20Sopenharmony_ci#endif
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_cistatic inline void VerticalRetraceWait(struct savagefb_par *par)
3868c2ecf20Sopenharmony_ci{
3878c2ecf20Sopenharmony_ci	vga_out8(0x3d4, 0x17, par);
3888c2ecf20Sopenharmony_ci	if (vga_in8(0x3d5, par) & 0x80) {
3898c2ecf20Sopenharmony_ci		while ((vga_in8(0x3da, par) & 0x08) == 0x08);
3908c2ecf20Sopenharmony_ci		while ((vga_in8(0x3da, par) & 0x08) == 0x00);
3918c2ecf20Sopenharmony_ci	}
3928c2ecf20Sopenharmony_ci}
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ciextern int savagefb_probe_i2c_connector(struct fb_info *info,
3958c2ecf20Sopenharmony_ci					u8 **out_edid);
3968c2ecf20Sopenharmony_ciextern void savagefb_create_i2c_busses(struct fb_info *info);
3978c2ecf20Sopenharmony_ciextern void savagefb_delete_i2c_busses(struct fb_info *info);
3988c2ecf20Sopenharmony_ciextern int  savagefb_sync(struct fb_info *info);
3998c2ecf20Sopenharmony_ciextern void savagefb_copyarea(struct fb_info *info,
4008c2ecf20Sopenharmony_ci			      const struct fb_copyarea *region);
4018c2ecf20Sopenharmony_ciextern void savagefb_fillrect(struct fb_info *info,
4028c2ecf20Sopenharmony_ci			      const struct fb_fillrect *rect);
4038c2ecf20Sopenharmony_ciextern void savagefb_imageblit(struct fb_info *info,
4048c2ecf20Sopenharmony_ci			       const struct fb_image *image);
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_ci#endif /* __SAVAGEFB_H__ */
408