0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef TGAFB_H
0014 #define TGAFB_H
0015
0016
0017
0018
0019
0020 #define TGA_TYPE_8PLANE 0
0021 #define TGA_TYPE_24PLANE 1
0022 #define TGA_TYPE_24PLUSZ 3
0023
0024
0025
0026
0027
0028 #define TGA_ROM_OFFSET 0x0000000
0029 #define TGA_REGS_OFFSET 0x0100000
0030 #define TGA_8PLANE_FB_OFFSET 0x0200000
0031 #define TGA_24PLANE_FB_OFFSET 0x0804000
0032 #define TGA_24PLUSZ_FB_OFFSET 0x1004000
0033
0034 #define TGA_FOREGROUND_REG 0x0020
0035 #define TGA_BACKGROUND_REG 0x0024
0036 #define TGA_PLANEMASK_REG 0x0028
0037 #define TGA_PIXELMASK_ONESHOT_REG 0x002c
0038 #define TGA_MODE_REG 0x0030
0039 #define TGA_RASTEROP_REG 0x0034
0040 #define TGA_PIXELSHIFT_REG 0x0038
0041 #define TGA_DEEP_REG 0x0050
0042 #define TGA_START_REG 0x0054
0043 #define TGA_PIXELMASK_REG 0x005c
0044 #define TGA_CURSOR_BASE_REG 0x0060
0045 #define TGA_HORIZ_REG 0x0064
0046 #define TGA_VERT_REG 0x0068
0047 #define TGA_BASE_ADDR_REG 0x006c
0048 #define TGA_VALID_REG 0x0070
0049 #define TGA_CURSOR_XY_REG 0x0074
0050 #define TGA_INTR_STAT_REG 0x007c
0051 #define TGA_DATA_REG 0x0080
0052 #define TGA_RAMDAC_SETUP_REG 0x00c0
0053 #define TGA_BLOCK_COLOR0_REG 0x0140
0054 #define TGA_BLOCK_COLOR1_REG 0x0144
0055 #define TGA_BLOCK_COLOR2_REG 0x0148
0056 #define TGA_BLOCK_COLOR3_REG 0x014c
0057 #define TGA_BLOCK_COLOR4_REG 0x0150
0058 #define TGA_BLOCK_COLOR5_REG 0x0154
0059 #define TGA_BLOCK_COLOR6_REG 0x0158
0060 #define TGA_BLOCK_COLOR7_REG 0x015c
0061 #define TGA_COPY64_SRC 0x0160
0062 #define TGA_COPY64_DST 0x0164
0063 #define TGA_CLOCK_REG 0x01e8
0064 #define TGA_RAMDAC_REG 0x01f0
0065 #define TGA_CMD_STAT_REG 0x01f8
0066
0067
0068
0069
0070
0071
0072 #define TGA_HORIZ_ODD 0x80000000
0073 #define TGA_HORIZ_POLARITY 0x40000000
0074 #define TGA_HORIZ_ACT_MSB 0x30000000
0075 #define TGA_HORIZ_BP 0x0fe00000
0076 #define TGA_HORIZ_SYNC 0x001fc000
0077 #define TGA_HORIZ_FP 0x00007c00
0078 #define TGA_HORIZ_ACT_LSB 0x000001ff
0079
0080 #define TGA_VERT_SE 0x80000000
0081 #define TGA_VERT_POLARITY 0x40000000
0082 #define TGA_VERT_RESERVED 0x30000000
0083 #define TGA_VERT_BP 0x0fc00000
0084 #define TGA_VERT_SYNC 0x003f0000
0085 #define TGA_VERT_FP 0x0000f800
0086 #define TGA_VERT_ACTIVE 0x000007ff
0087
0088 #define TGA_VALID_VIDEO 0x01
0089 #define TGA_VALID_BLANK 0x02
0090 #define TGA_VALID_CURSOR 0x04
0091
0092 #define TGA_MODE_SBM_8BPP 0x000
0093 #define TGA_MODE_SBM_24BPP 0x300
0094
0095 #define TGA_MODE_SIMPLE 0x00
0096 #define TGA_MODE_SIMPLEZ 0x10
0097 #define TGA_MODE_OPAQUE_STIPPLE 0x01
0098 #define TGA_MODE_OPAQUE_FILL 0x21
0099 #define TGA_MODE_TRANSPARENT_STIPPLE 0x03
0100 #define TGA_MODE_TRANSPARENT_FILL 0x23
0101 #define TGA_MODE_BLOCK_STIPPLE 0x0d
0102 #define TGA_MODE_BLOCK_FILL 0x2d
0103 #define TGA_MODE_COPY 0x07
0104 #define TGA_MODE_DMA_READ_COPY_ND 0x17
0105 #define TGA_MODE_DMA_READ_COPY_D 0x37
0106 #define TGA_MODE_DMA_WRITE_COPY 0x1f
0107
0108
0109
0110
0111
0112
0113 #define TGA_PLL_BASE_FREQ 14318
0114 #define TGA_PLL_MAX_FREQ 230000
0115
0116
0117
0118
0119
0120
0121 #define BT485_READ_BIT 0x01
0122 #define BT485_WRITE_BIT 0x00
0123
0124 #define BT485_ADDR_PAL_WRITE 0x00
0125 #define BT485_DATA_PAL 0x02
0126 #define BT485_PIXEL_MASK 0x04
0127 #define BT485_ADDR_PAL_READ 0x06
0128 #define BT485_ADDR_CUR_WRITE 0x08
0129 #define BT485_DATA_CUR 0x0a
0130 #define BT485_CMD_0 0x0c
0131 #define BT485_ADDR_CUR_READ 0x0e
0132 #define BT485_CMD_1 0x10
0133 #define BT485_CMD_2 0x12
0134 #define BT485_STATUS 0x14
0135 #define BT485_CMD_3 0x14
0136 #define BT485_CUR_RAM 0x16
0137 #define BT485_CUR_LOW_X 0x18
0138 #define BT485_CUR_HIGH_X 0x1a
0139 #define BT485_CUR_LOW_Y 0x1c
0140 #define BT485_CUR_HIGH_Y 0x1e
0141
0142
0143
0144
0145
0146
0147 #define BT463_ADDR_LO 0x0
0148 #define BT463_ADDR_HI 0x1
0149 #define BT463_REG_ACC 0x2
0150 #define BT463_PALETTE 0x3
0151
0152 #define BT463_CUR_CLR_0 0x0100
0153 #define BT463_CUR_CLR_1 0x0101
0154
0155 #define BT463_CMD_REG_0 0x0201
0156 #define BT463_CMD_REG_1 0x0202
0157 #define BT463_CMD_REG_2 0x0203
0158
0159 #define BT463_READ_MASK_0 0x0205
0160 #define BT463_READ_MASK_1 0x0206
0161 #define BT463_READ_MASK_2 0x0207
0162 #define BT463_READ_MASK_3 0x0208
0163
0164 #define BT463_BLINK_MASK_0 0x0209
0165 #define BT463_BLINK_MASK_1 0x020a
0166 #define BT463_BLINK_MASK_2 0x020b
0167 #define BT463_BLINK_MASK_3 0x020c
0168
0169 #define BT463_WINDOW_TYPE_BASE 0x0300
0170
0171
0172
0173
0174
0175 #define BT459_ADDR_LO 0x0
0176 #define BT459_ADDR_HI 0x1
0177 #define BT459_REG_ACC 0x2
0178 #define BT459_PALETTE 0x3
0179
0180 #define BT459_CUR_CLR_1 0x0181
0181 #define BT459_CUR_CLR_2 0x0182
0182 #define BT459_CUR_CLR_3 0x0183
0183
0184 #define BT459_CMD_REG_0 0x0201
0185 #define BT459_CMD_REG_1 0x0202
0186 #define BT459_CMD_REG_2 0x0203
0187
0188 #define BT459_READ_MASK 0x0204
0189
0190 #define BT459_BLINK_MASK 0x0206
0191
0192 #define BT459_CUR_CMD_REG 0x0300
0193
0194
0195
0196
0197
0198 struct tga_par {
0199
0200 struct device *dev;
0201
0202
0203 void __iomem *tga_mem_base;
0204 void __iomem *tga_fb_base;
0205 void __iomem *tga_regs_base;
0206 u8 tga_type;
0207 u8 tga_chip_rev;
0208
0209
0210 u8 vesa_blanked;
0211
0212
0213 u32 xres, yres;
0214 u32 htimings;
0215 u32 vtimings;
0216 u32 pll_freq;
0217 u32 bits_per_pixel;
0218 u32 sync_on_green;
0219 u32 palette[16];
0220 };
0221
0222
0223
0224
0225
0226
0227 static inline void
0228 TGA_WRITE_REG(struct tga_par *par, u32 v, u32 r)
0229 {
0230 writel(v, par->tga_regs_base +r);
0231 }
0232
0233 static inline u32
0234 TGA_READ_REG(struct tga_par *par, u32 r)
0235 {
0236 return readl(par->tga_regs_base +r);
0237 }
0238
0239 static inline void
0240 BT485_WRITE(struct tga_par *par, u8 v, u8 r)
0241 {
0242 TGA_WRITE_REG(par, r, TGA_RAMDAC_SETUP_REG);
0243 TGA_WRITE_REG(par, v | (r << 8), TGA_RAMDAC_REG);
0244 }
0245
0246 static inline void
0247 BT463_LOAD_ADDR(struct tga_par *par, u16 a)
0248 {
0249 TGA_WRITE_REG(par, BT463_ADDR_LO<<2, TGA_RAMDAC_SETUP_REG);
0250 TGA_WRITE_REG(par, (BT463_ADDR_LO<<10) | (a & 0xff), TGA_RAMDAC_REG);
0251 TGA_WRITE_REG(par, BT463_ADDR_HI<<2, TGA_RAMDAC_SETUP_REG);
0252 TGA_WRITE_REG(par, (BT463_ADDR_HI<<10) | (a >> 8), TGA_RAMDAC_REG);
0253 }
0254
0255 static inline void
0256 BT463_WRITE(struct tga_par *par, u32 m, u16 a, u8 v)
0257 {
0258 BT463_LOAD_ADDR(par, a);
0259 TGA_WRITE_REG(par, m << 2, TGA_RAMDAC_SETUP_REG);
0260 TGA_WRITE_REG(par, m << 10 | v, TGA_RAMDAC_REG);
0261 }
0262
0263 static inline void
0264 BT459_LOAD_ADDR(struct tga_par *par, u16 a)
0265 {
0266 TGA_WRITE_REG(par, BT459_ADDR_LO << 2, TGA_RAMDAC_SETUP_REG);
0267 TGA_WRITE_REG(par, a & 0xff, TGA_RAMDAC_REG);
0268 TGA_WRITE_REG(par, BT459_ADDR_HI << 2, TGA_RAMDAC_SETUP_REG);
0269 TGA_WRITE_REG(par, a >> 8, TGA_RAMDAC_REG);
0270 }
0271
0272 static inline void
0273 BT459_WRITE(struct tga_par *par, u32 m, u16 a, u8 v)
0274 {
0275 BT459_LOAD_ADDR(par, a);
0276 TGA_WRITE_REG(par, m << 2, TGA_RAMDAC_SETUP_REG);
0277 TGA_WRITE_REG(par, v, TGA_RAMDAC_REG);
0278 }
0279
0280 #endif