18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _TDFX_H 38c2ecf20Sopenharmony_ci#define _TDFX_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/i2c.h> 68c2ecf20Sopenharmony_ci#include <linux/i2c-algo-bit.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci/* membase0 register offsets */ 98c2ecf20Sopenharmony_ci#define STATUS 0x00 108c2ecf20Sopenharmony_ci#define PCIINIT0 0x04 118c2ecf20Sopenharmony_ci#define SIPMONITOR 0x08 128c2ecf20Sopenharmony_ci#define LFBMEMORYCONFIG 0x0c 138c2ecf20Sopenharmony_ci#define MISCINIT0 0x10 148c2ecf20Sopenharmony_ci#define MISCINIT1 0x14 158c2ecf20Sopenharmony_ci#define DRAMINIT0 0x18 168c2ecf20Sopenharmony_ci#define DRAMINIT1 0x1c 178c2ecf20Sopenharmony_ci#define AGPINIT 0x20 188c2ecf20Sopenharmony_ci#define TMUGBEINIT 0x24 198c2ecf20Sopenharmony_ci#define VGAINIT0 0x28 208c2ecf20Sopenharmony_ci#define VGAINIT1 0x2c 218c2ecf20Sopenharmony_ci#define DRAMCOMMAND 0x30 228c2ecf20Sopenharmony_ci#define DRAMDATA 0x34 238c2ecf20Sopenharmony_ci/* reserved 0x38 */ 248c2ecf20Sopenharmony_ci/* reserved 0x3c */ 258c2ecf20Sopenharmony_ci#define PLLCTRL0 0x40 268c2ecf20Sopenharmony_ci#define PLLCTRL1 0x44 278c2ecf20Sopenharmony_ci#define PLLCTRL2 0x48 288c2ecf20Sopenharmony_ci#define DACMODE 0x4c 298c2ecf20Sopenharmony_ci#define DACADDR 0x50 308c2ecf20Sopenharmony_ci#define DACDATA 0x54 318c2ecf20Sopenharmony_ci#define RGBMAXDELTA 0x58 328c2ecf20Sopenharmony_ci#define VIDPROCCFG 0x5c 338c2ecf20Sopenharmony_ci#define HWCURPATADDR 0x60 348c2ecf20Sopenharmony_ci#define HWCURLOC 0x64 358c2ecf20Sopenharmony_ci#define HWCURC0 0x68 368c2ecf20Sopenharmony_ci#define HWCURC1 0x6c 378c2ecf20Sopenharmony_ci#define VIDINFORMAT 0x70 388c2ecf20Sopenharmony_ci#define VIDINSTATUS 0x74 398c2ecf20Sopenharmony_ci#define VIDSERPARPORT 0x78 408c2ecf20Sopenharmony_ci#define VIDINXDELTA 0x7c 418c2ecf20Sopenharmony_ci#define VIDININITERR 0x80 428c2ecf20Sopenharmony_ci#define VIDINYDELTA 0x84 438c2ecf20Sopenharmony_ci#define VIDPIXBUFTHOLD 0x88 448c2ecf20Sopenharmony_ci#define VIDCHRMIN 0x8c 458c2ecf20Sopenharmony_ci#define VIDCHRMAX 0x90 468c2ecf20Sopenharmony_ci#define VIDCURLIN 0x94 478c2ecf20Sopenharmony_ci#define VIDSCREENSIZE 0x98 488c2ecf20Sopenharmony_ci#define VIDOVRSTARTCRD 0x9c 498c2ecf20Sopenharmony_ci#define VIDOVRENDCRD 0xa0 508c2ecf20Sopenharmony_ci#define VIDOVRDUDX 0xa4 518c2ecf20Sopenharmony_ci#define VIDOVRDUDXOFF 0xa8 528c2ecf20Sopenharmony_ci#define VIDOVRDVDY 0xac 538c2ecf20Sopenharmony_ci/* ... */ 548c2ecf20Sopenharmony_ci#define VIDOVRDVDYOFF 0xe0 558c2ecf20Sopenharmony_ci#define VIDDESKSTART 0xe4 568c2ecf20Sopenharmony_ci#define VIDDESKSTRIDE 0xe8 578c2ecf20Sopenharmony_ci#define VIDINADDR0 0xec 588c2ecf20Sopenharmony_ci#define VIDINADDR1 0xf0 598c2ecf20Sopenharmony_ci#define VIDINADDR2 0xf4 608c2ecf20Sopenharmony_ci#define VIDINSTRIDE 0xf8 618c2ecf20Sopenharmony_ci#define VIDCUROVRSTART 0xfc 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define INTCTRL (0x00100000 + 0x04) 648c2ecf20Sopenharmony_ci#define CLIP0MIN (0x00100000 + 0x08) 658c2ecf20Sopenharmony_ci#define CLIP0MAX (0x00100000 + 0x0c) 668c2ecf20Sopenharmony_ci#define DSTBASE (0x00100000 + 0x10) 678c2ecf20Sopenharmony_ci#define DSTFORMAT (0x00100000 + 0x14) 688c2ecf20Sopenharmony_ci#define SRCBASE (0x00100000 + 0x34) 698c2ecf20Sopenharmony_ci#define COMMANDEXTRA_2D (0x00100000 + 0x38) 708c2ecf20Sopenharmony_ci#define CLIP1MIN (0x00100000 + 0x4c) 718c2ecf20Sopenharmony_ci#define CLIP1MAX (0x00100000 + 0x50) 728c2ecf20Sopenharmony_ci#define SRCFORMAT (0x00100000 + 0x54) 738c2ecf20Sopenharmony_ci#define SRCSIZE (0x00100000 + 0x58) 748c2ecf20Sopenharmony_ci#define SRCXY (0x00100000 + 0x5c) 758c2ecf20Sopenharmony_ci#define COLORBACK (0x00100000 + 0x60) 768c2ecf20Sopenharmony_ci#define COLORFORE (0x00100000 + 0x64) 778c2ecf20Sopenharmony_ci#define DSTSIZE (0x00100000 + 0x68) 788c2ecf20Sopenharmony_ci#define DSTXY (0x00100000 + 0x6c) 798c2ecf20Sopenharmony_ci#define COMMAND_2D (0x00100000 + 0x70) 808c2ecf20Sopenharmony_ci#define LAUNCH_2D (0x00100000 + 0x80) 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#define COMMAND_3D (0x00200000 + 0x120) 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci/* register bitfields (not all, only as needed) */ 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci/* COMMAND_2D reg. values */ 878c2ecf20Sopenharmony_ci#define TDFX_ROP_COPY 0xcc /* src */ 888c2ecf20Sopenharmony_ci#define TDFX_ROP_INVERT 0x55 /* NOT dst */ 898c2ecf20Sopenharmony_ci#define TDFX_ROP_XOR 0x66 /* src XOR dst */ 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#define AUTOINC_DSTX BIT(10) 928c2ecf20Sopenharmony_ci#define AUTOINC_DSTY BIT(11) 938c2ecf20Sopenharmony_ci#define COMMAND_2D_FILLRECT 0x05 948c2ecf20Sopenharmony_ci#define COMMAND_2D_S2S_BITBLT 0x01 /* screen to screen */ 958c2ecf20Sopenharmony_ci#define COMMAND_2D_H2S_BITBLT 0x03 /* host to screen */ 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#define COMMAND_3D_NOP 0x00 988c2ecf20Sopenharmony_ci#define STATUS_RETRACE BIT(6) 998c2ecf20Sopenharmony_ci#define STATUS_BUSY BIT(9) 1008c2ecf20Sopenharmony_ci#define MISCINIT1_CLUT_INV BIT(0) 1018c2ecf20Sopenharmony_ci#define MISCINIT1_2DBLOCK_DIS BIT(15) 1028c2ecf20Sopenharmony_ci#define DRAMINIT0_SGRAM_NUM BIT(26) 1038c2ecf20Sopenharmony_ci#define DRAMINIT0_SGRAM_TYPE BIT(27) 1048c2ecf20Sopenharmony_ci#define DRAMINIT0_SGRAM_TYPE_MASK (BIT(27) | BIT(28) | BIT(29)) 1058c2ecf20Sopenharmony_ci#define DRAMINIT0_SGRAM_TYPE_SHIFT 27 1068c2ecf20Sopenharmony_ci#define DRAMINIT1_MEM_SDRAM BIT(30) 1078c2ecf20Sopenharmony_ci#define VGAINIT0_VGA_DISABLE BIT(0) 1088c2ecf20Sopenharmony_ci#define VGAINIT0_EXT_TIMING BIT(1) 1098c2ecf20Sopenharmony_ci#define VGAINIT0_8BIT_DAC BIT(2) 1108c2ecf20Sopenharmony_ci#define VGAINIT0_EXT_ENABLE BIT(6) 1118c2ecf20Sopenharmony_ci#define VGAINIT0_WAKEUP_3C3 BIT(8) 1128c2ecf20Sopenharmony_ci#define VGAINIT0_LEGACY_DISABLE BIT(9) 1138c2ecf20Sopenharmony_ci#define VGAINIT0_ALT_READBACK BIT(10) 1148c2ecf20Sopenharmony_ci#define VGAINIT0_FAST_BLINK BIT(11) 1158c2ecf20Sopenharmony_ci#define VGAINIT0_EXTSHIFTOUT BIT(12) 1168c2ecf20Sopenharmony_ci#define VGAINIT0_DECODE_3C6 BIT(13) 1178c2ecf20Sopenharmony_ci#define VGAINIT0_SGRAM_HBLANK_DISABLE BIT(22) 1188c2ecf20Sopenharmony_ci#define VGAINIT1_MASK 0x1fffff 1198c2ecf20Sopenharmony_ci#define VIDCFG_VIDPROC_ENABLE BIT(0) 1208c2ecf20Sopenharmony_ci#define VIDCFG_CURS_X11 BIT(1) 1218c2ecf20Sopenharmony_ci#define VIDCFG_INTERLACE BIT(3) 1228c2ecf20Sopenharmony_ci#define VIDCFG_HALF_MODE BIT(4) 1238c2ecf20Sopenharmony_ci#define VIDCFG_DESK_ENABLE BIT(7) 1248c2ecf20Sopenharmony_ci#define VIDCFG_CLUT_BYPASS BIT(10) 1258c2ecf20Sopenharmony_ci#define VIDCFG_2X BIT(26) 1268c2ecf20Sopenharmony_ci#define VIDCFG_HWCURSOR_ENABLE BIT(27) 1278c2ecf20Sopenharmony_ci#define VIDCFG_PIXFMT_SHIFT 18 1288c2ecf20Sopenharmony_ci#define DACMODE_2X BIT(0) 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci/* I2C bit locations in the VIDSERPARPORT register */ 1318c2ecf20Sopenharmony_ci#define DDC_ENAB 0x00040000 1328c2ecf20Sopenharmony_ci#define DDC_SCL_OUT 0x00080000 1338c2ecf20Sopenharmony_ci#define DDC_SDA_OUT 0x00100000 1348c2ecf20Sopenharmony_ci#define DDC_SCL_IN 0x00200000 1358c2ecf20Sopenharmony_ci#define DDC_SDA_IN 0x00400000 1368c2ecf20Sopenharmony_ci#define I2C_ENAB 0x00800000 1378c2ecf20Sopenharmony_ci#define I2C_SCL_OUT 0x01000000 1388c2ecf20Sopenharmony_ci#define I2C_SDA_OUT 0x02000000 1398c2ecf20Sopenharmony_ci#define I2C_SCL_IN 0x04000000 1408c2ecf20Sopenharmony_ci#define I2C_SDA_IN 0x08000000 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci/* VGA rubbish, need to change this for multihead support */ 1438c2ecf20Sopenharmony_ci#define MISC_W 0x3c2 1448c2ecf20Sopenharmony_ci#define MISC_R 0x3cc 1458c2ecf20Sopenharmony_ci#define SEQ_I 0x3c4 1468c2ecf20Sopenharmony_ci#define SEQ_D 0x3c5 1478c2ecf20Sopenharmony_ci#define CRT_I 0x3d4 1488c2ecf20Sopenharmony_ci#define CRT_D 0x3d5 1498c2ecf20Sopenharmony_ci#define ATT_IW 0x3c0 1508c2ecf20Sopenharmony_ci#define IS1_R 0x3da 1518c2ecf20Sopenharmony_ci#define GRA_I 0x3ce 1528c2ecf20Sopenharmony_ci#define GRA_D 0x3cf 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_cistruct banshee_reg { 1578c2ecf20Sopenharmony_ci /* VGA rubbish */ 1588c2ecf20Sopenharmony_ci unsigned char att[21]; 1598c2ecf20Sopenharmony_ci unsigned char crt[25]; 1608c2ecf20Sopenharmony_ci unsigned char gra[9]; 1618c2ecf20Sopenharmony_ci unsigned char misc[1]; 1628c2ecf20Sopenharmony_ci unsigned char seq[5]; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci /* Banshee extensions */ 1658c2ecf20Sopenharmony_ci unsigned char ext[2]; 1668c2ecf20Sopenharmony_ci unsigned long vidcfg; 1678c2ecf20Sopenharmony_ci unsigned long vidpll; 1688c2ecf20Sopenharmony_ci unsigned long mempll; 1698c2ecf20Sopenharmony_ci unsigned long gfxpll; 1708c2ecf20Sopenharmony_ci unsigned long dacmode; 1718c2ecf20Sopenharmony_ci unsigned long vgainit0; 1728c2ecf20Sopenharmony_ci unsigned long vgainit1; 1738c2ecf20Sopenharmony_ci unsigned long screensize; 1748c2ecf20Sopenharmony_ci unsigned long stride; 1758c2ecf20Sopenharmony_ci unsigned long cursloc; 1768c2ecf20Sopenharmony_ci unsigned long curspataddr; 1778c2ecf20Sopenharmony_ci unsigned long cursc0; 1788c2ecf20Sopenharmony_ci unsigned long cursc1; 1798c2ecf20Sopenharmony_ci unsigned long startaddr; 1808c2ecf20Sopenharmony_ci unsigned long clip0min; 1818c2ecf20Sopenharmony_ci unsigned long clip0max; 1828c2ecf20Sopenharmony_ci unsigned long clip1min; 1838c2ecf20Sopenharmony_ci unsigned long clip1max; 1848c2ecf20Sopenharmony_ci unsigned long miscinit0; 1858c2ecf20Sopenharmony_ci}; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_cistruct tdfx_par; 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_cistruct tdfxfb_i2c_chan { 1908c2ecf20Sopenharmony_ci struct tdfx_par *par; 1918c2ecf20Sopenharmony_ci struct i2c_adapter adapter; 1928c2ecf20Sopenharmony_ci struct i2c_algo_bit_data algo; 1938c2ecf20Sopenharmony_ci}; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_cistruct tdfx_par { 1968c2ecf20Sopenharmony_ci u32 max_pixclock; 1978c2ecf20Sopenharmony_ci u32 palette[16]; 1988c2ecf20Sopenharmony_ci void __iomem *regbase_virt; 1998c2ecf20Sopenharmony_ci unsigned long iobase; 2008c2ecf20Sopenharmony_ci int wc_cookie; 2018c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_3DFX_I2C 2028c2ecf20Sopenharmony_ci struct tdfxfb_i2c_chan chan[2]; 2038c2ecf20Sopenharmony_ci#endif 2048c2ecf20Sopenharmony_ci}; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci#endif /* _TDFX_H */ 2098c2ecf20Sopenharmony_ci 210