18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
48c2ecf20Sopenharmony_ci * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef __SHARE_H__
98c2ecf20Sopenharmony_ci#define __SHARE_H__
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include "via_modesetting.h"
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/* Define Bit Field */
148c2ecf20Sopenharmony_ci#define BIT0    0x01
158c2ecf20Sopenharmony_ci#define BIT1    0x02
168c2ecf20Sopenharmony_ci#define BIT2    0x04
178c2ecf20Sopenharmony_ci#define BIT3    0x08
188c2ecf20Sopenharmony_ci#define BIT4    0x10
198c2ecf20Sopenharmony_ci#define BIT5    0x20
208c2ecf20Sopenharmony_ci#define BIT6    0x40
218c2ecf20Sopenharmony_ci#define BIT7    0x80
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/* Video Memory Size */
248c2ecf20Sopenharmony_ci#define VIDEO_MEMORY_SIZE_16M    0x1000000
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/*
278c2ecf20Sopenharmony_ci * Lengths of the VPIT structure arrays.
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_ci#define StdCR       0x19
308c2ecf20Sopenharmony_ci#define StdSR       0x04
318c2ecf20Sopenharmony_ci#define StdGR       0x09
328c2ecf20Sopenharmony_ci#define StdAR       0x14
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define PatchCR     11
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/* Display path */
378c2ecf20Sopenharmony_ci#define IGA1        1
388c2ecf20Sopenharmony_ci#define IGA2        2
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* Define Color Depth  */
418c2ecf20Sopenharmony_ci#define MODE_8BPP       1
428c2ecf20Sopenharmony_ci#define MODE_16BPP      2
438c2ecf20Sopenharmony_ci#define MODE_32BPP      4
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define GR20    0x20
468c2ecf20Sopenharmony_ci#define GR21    0x21
478c2ecf20Sopenharmony_ci#define GR22    0x22
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/* Sequencer Registers */
508c2ecf20Sopenharmony_ci#define SR01    0x01
518c2ecf20Sopenharmony_ci#define SR10    0x10
528c2ecf20Sopenharmony_ci#define SR12    0x12
538c2ecf20Sopenharmony_ci#define SR15    0x15
548c2ecf20Sopenharmony_ci#define SR16    0x16
558c2ecf20Sopenharmony_ci#define SR17    0x17
568c2ecf20Sopenharmony_ci#define SR18    0x18
578c2ecf20Sopenharmony_ci#define SR1B    0x1B
588c2ecf20Sopenharmony_ci#define SR1A    0x1A
598c2ecf20Sopenharmony_ci#define SR1C    0x1C
608c2ecf20Sopenharmony_ci#define SR1D    0x1D
618c2ecf20Sopenharmony_ci#define SR1E    0x1E
628c2ecf20Sopenharmony_ci#define SR1F    0x1F
638c2ecf20Sopenharmony_ci#define SR20    0x20
648c2ecf20Sopenharmony_ci#define SR21    0x21
658c2ecf20Sopenharmony_ci#define SR22    0x22
668c2ecf20Sopenharmony_ci#define SR2A    0x2A
678c2ecf20Sopenharmony_ci#define SR2D    0x2D
688c2ecf20Sopenharmony_ci#define SR2E    0x2E
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci#define SR30    0x30
718c2ecf20Sopenharmony_ci#define SR39    0x39
728c2ecf20Sopenharmony_ci#define SR3D    0x3D
738c2ecf20Sopenharmony_ci#define SR3E    0x3E
748c2ecf20Sopenharmony_ci#define SR3F    0x3F
758c2ecf20Sopenharmony_ci#define SR40    0x40
768c2ecf20Sopenharmony_ci#define SR43    0x43
778c2ecf20Sopenharmony_ci#define SR44    0x44
788c2ecf20Sopenharmony_ci#define SR45    0x45
798c2ecf20Sopenharmony_ci#define SR46    0x46
808c2ecf20Sopenharmony_ci#define SR47    0x47
818c2ecf20Sopenharmony_ci#define SR48    0x48
828c2ecf20Sopenharmony_ci#define SR49    0x49
838c2ecf20Sopenharmony_ci#define SR4A    0x4A
848c2ecf20Sopenharmony_ci#define SR4B    0x4B
858c2ecf20Sopenharmony_ci#define SR4C    0x4C
868c2ecf20Sopenharmony_ci#define SR52    0x52
878c2ecf20Sopenharmony_ci#define SR57	0x57
888c2ecf20Sopenharmony_ci#define SR58	0x58
898c2ecf20Sopenharmony_ci#define SR59	0x59
908c2ecf20Sopenharmony_ci#define SR5D    0x5D
918c2ecf20Sopenharmony_ci#define SR5E    0x5E
928c2ecf20Sopenharmony_ci#define SR65    0x65
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci/* CRT Controller Registers */
958c2ecf20Sopenharmony_ci#define CR00    0x00
968c2ecf20Sopenharmony_ci#define CR01    0x01
978c2ecf20Sopenharmony_ci#define CR02    0x02
988c2ecf20Sopenharmony_ci#define CR03    0x03
998c2ecf20Sopenharmony_ci#define CR04    0x04
1008c2ecf20Sopenharmony_ci#define CR05    0x05
1018c2ecf20Sopenharmony_ci#define CR06    0x06
1028c2ecf20Sopenharmony_ci#define CR07    0x07
1038c2ecf20Sopenharmony_ci#define CR08    0x08
1048c2ecf20Sopenharmony_ci#define CR09    0x09
1058c2ecf20Sopenharmony_ci#define CR0A    0x0A
1068c2ecf20Sopenharmony_ci#define CR0B    0x0B
1078c2ecf20Sopenharmony_ci#define CR0C    0x0C
1088c2ecf20Sopenharmony_ci#define CR0D    0x0D
1098c2ecf20Sopenharmony_ci#define CR0E    0x0E
1108c2ecf20Sopenharmony_ci#define CR0F    0x0F
1118c2ecf20Sopenharmony_ci#define CR10    0x10
1128c2ecf20Sopenharmony_ci#define CR11    0x11
1138c2ecf20Sopenharmony_ci#define CR12    0x12
1148c2ecf20Sopenharmony_ci#define CR13    0x13
1158c2ecf20Sopenharmony_ci#define CR14    0x14
1168c2ecf20Sopenharmony_ci#define CR15    0x15
1178c2ecf20Sopenharmony_ci#define CR16    0x16
1188c2ecf20Sopenharmony_ci#define CR17    0x17
1198c2ecf20Sopenharmony_ci#define CR18    0x18
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/* Extend CRT Controller Registers */
1228c2ecf20Sopenharmony_ci#define CR30    0x30
1238c2ecf20Sopenharmony_ci#define CR31    0x31
1248c2ecf20Sopenharmony_ci#define CR32    0x32
1258c2ecf20Sopenharmony_ci#define CR33    0x33
1268c2ecf20Sopenharmony_ci#define CR34    0x34
1278c2ecf20Sopenharmony_ci#define CR35    0x35
1288c2ecf20Sopenharmony_ci#define CR36    0x36
1298c2ecf20Sopenharmony_ci#define CR37    0x37
1308c2ecf20Sopenharmony_ci#define CR38    0x38
1318c2ecf20Sopenharmony_ci#define CR39    0x39
1328c2ecf20Sopenharmony_ci#define CR3A    0x3A
1338c2ecf20Sopenharmony_ci#define CR3B    0x3B
1348c2ecf20Sopenharmony_ci#define CR3C    0x3C
1358c2ecf20Sopenharmony_ci#define CR3D    0x3D
1368c2ecf20Sopenharmony_ci#define CR3E    0x3E
1378c2ecf20Sopenharmony_ci#define CR3F    0x3F
1388c2ecf20Sopenharmony_ci#define CR40    0x40
1398c2ecf20Sopenharmony_ci#define CR41    0x41
1408c2ecf20Sopenharmony_ci#define CR42    0x42
1418c2ecf20Sopenharmony_ci#define CR43    0x43
1428c2ecf20Sopenharmony_ci#define CR44    0x44
1438c2ecf20Sopenharmony_ci#define CR45    0x45
1448c2ecf20Sopenharmony_ci#define CR46    0x46
1458c2ecf20Sopenharmony_ci#define CR47    0x47
1468c2ecf20Sopenharmony_ci#define CR48    0x48
1478c2ecf20Sopenharmony_ci#define CR49    0x49
1488c2ecf20Sopenharmony_ci#define CR4A    0x4A
1498c2ecf20Sopenharmony_ci#define CR4B    0x4B
1508c2ecf20Sopenharmony_ci#define CR4C    0x4C
1518c2ecf20Sopenharmony_ci#define CR4D    0x4D
1528c2ecf20Sopenharmony_ci#define CR4E    0x4E
1538c2ecf20Sopenharmony_ci#define CR4F    0x4F
1548c2ecf20Sopenharmony_ci#define CR50    0x50
1558c2ecf20Sopenharmony_ci#define CR51    0x51
1568c2ecf20Sopenharmony_ci#define CR52    0x52
1578c2ecf20Sopenharmony_ci#define CR53    0x53
1588c2ecf20Sopenharmony_ci#define CR54    0x54
1598c2ecf20Sopenharmony_ci#define CR55    0x55
1608c2ecf20Sopenharmony_ci#define CR56    0x56
1618c2ecf20Sopenharmony_ci#define CR57    0x57
1628c2ecf20Sopenharmony_ci#define CR58    0x58
1638c2ecf20Sopenharmony_ci#define CR59    0x59
1648c2ecf20Sopenharmony_ci#define CR5A    0x5A
1658c2ecf20Sopenharmony_ci#define CR5B    0x5B
1668c2ecf20Sopenharmony_ci#define CR5C    0x5C
1678c2ecf20Sopenharmony_ci#define CR5D    0x5D
1688c2ecf20Sopenharmony_ci#define CR5E    0x5E
1698c2ecf20Sopenharmony_ci#define CR5F    0x5F
1708c2ecf20Sopenharmony_ci#define CR60    0x60
1718c2ecf20Sopenharmony_ci#define CR61    0x61
1728c2ecf20Sopenharmony_ci#define CR62    0x62
1738c2ecf20Sopenharmony_ci#define CR63    0x63
1748c2ecf20Sopenharmony_ci#define CR64    0x64
1758c2ecf20Sopenharmony_ci#define CR65    0x65
1768c2ecf20Sopenharmony_ci#define CR66    0x66
1778c2ecf20Sopenharmony_ci#define CR67    0x67
1788c2ecf20Sopenharmony_ci#define CR68    0x68
1798c2ecf20Sopenharmony_ci#define CR69    0x69
1808c2ecf20Sopenharmony_ci#define CR6A    0x6A
1818c2ecf20Sopenharmony_ci#define CR6B    0x6B
1828c2ecf20Sopenharmony_ci#define CR6C    0x6C
1838c2ecf20Sopenharmony_ci#define CR6D    0x6D
1848c2ecf20Sopenharmony_ci#define CR6E    0x6E
1858c2ecf20Sopenharmony_ci#define CR6F    0x6F
1868c2ecf20Sopenharmony_ci#define CR70    0x70
1878c2ecf20Sopenharmony_ci#define CR71    0x71
1888c2ecf20Sopenharmony_ci#define CR72    0x72
1898c2ecf20Sopenharmony_ci#define CR73    0x73
1908c2ecf20Sopenharmony_ci#define CR74    0x74
1918c2ecf20Sopenharmony_ci#define CR75    0x75
1928c2ecf20Sopenharmony_ci#define CR76    0x76
1938c2ecf20Sopenharmony_ci#define CR77    0x77
1948c2ecf20Sopenharmony_ci#define CR78    0x78
1958c2ecf20Sopenharmony_ci#define CR79    0x79
1968c2ecf20Sopenharmony_ci#define CR7A    0x7A
1978c2ecf20Sopenharmony_ci#define CR7B    0x7B
1988c2ecf20Sopenharmony_ci#define CR7C    0x7C
1998c2ecf20Sopenharmony_ci#define CR7D    0x7D
2008c2ecf20Sopenharmony_ci#define CR7E    0x7E
2018c2ecf20Sopenharmony_ci#define CR7F    0x7F
2028c2ecf20Sopenharmony_ci#define CR80    0x80
2038c2ecf20Sopenharmony_ci#define CR81    0x81
2048c2ecf20Sopenharmony_ci#define CR82    0x82
2058c2ecf20Sopenharmony_ci#define CR83    0x83
2068c2ecf20Sopenharmony_ci#define CR84    0x84
2078c2ecf20Sopenharmony_ci#define CR85    0x85
2088c2ecf20Sopenharmony_ci#define CR86    0x86
2098c2ecf20Sopenharmony_ci#define CR87    0x87
2108c2ecf20Sopenharmony_ci#define CR88    0x88
2118c2ecf20Sopenharmony_ci#define CR89    0x89
2128c2ecf20Sopenharmony_ci#define CR8A    0x8A
2138c2ecf20Sopenharmony_ci#define CR8B    0x8B
2148c2ecf20Sopenharmony_ci#define CR8C    0x8C
2158c2ecf20Sopenharmony_ci#define CR8D    0x8D
2168c2ecf20Sopenharmony_ci#define CR8E    0x8E
2178c2ecf20Sopenharmony_ci#define CR8F    0x8F
2188c2ecf20Sopenharmony_ci#define CR90    0x90
2198c2ecf20Sopenharmony_ci#define CR91    0x91
2208c2ecf20Sopenharmony_ci#define CR92    0x92
2218c2ecf20Sopenharmony_ci#define CR93    0x93
2228c2ecf20Sopenharmony_ci#define CR94    0x94
2238c2ecf20Sopenharmony_ci#define CR95    0x95
2248c2ecf20Sopenharmony_ci#define CR96    0x96
2258c2ecf20Sopenharmony_ci#define CR97    0x97
2268c2ecf20Sopenharmony_ci#define CR98    0x98
2278c2ecf20Sopenharmony_ci#define CR99    0x99
2288c2ecf20Sopenharmony_ci#define CR9A    0x9A
2298c2ecf20Sopenharmony_ci#define CR9B    0x9B
2308c2ecf20Sopenharmony_ci#define CR9C    0x9C
2318c2ecf20Sopenharmony_ci#define CR9D    0x9D
2328c2ecf20Sopenharmony_ci#define CR9E    0x9E
2338c2ecf20Sopenharmony_ci#define CR9F    0x9F
2348c2ecf20Sopenharmony_ci#define CRA0    0xA0
2358c2ecf20Sopenharmony_ci#define CRA1    0xA1
2368c2ecf20Sopenharmony_ci#define CRA2    0xA2
2378c2ecf20Sopenharmony_ci#define CRA3    0xA3
2388c2ecf20Sopenharmony_ci#define CRD2    0xD2
2398c2ecf20Sopenharmony_ci#define CRD3    0xD3
2408c2ecf20Sopenharmony_ci#define CRD4    0xD4
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci/* LUT Table*/
2438c2ecf20Sopenharmony_ci#define LUT_DATA             0x3C9	/* DACDATA */
2448c2ecf20Sopenharmony_ci#define LUT_INDEX_READ       0x3C7	/* DACRX */
2458c2ecf20Sopenharmony_ci#define LUT_INDEX_WRITE      0x3C8	/* DACWX */
2468c2ecf20Sopenharmony_ci#define DACMASK              0x3C6
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci/* Definition Device */
2498c2ecf20Sopenharmony_ci#define DEVICE_CRT  0x01
2508c2ecf20Sopenharmony_ci#define DEVICE_DVI  0x03
2518c2ecf20Sopenharmony_ci#define DEVICE_LCD  0x04
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci/* Device output interface */
2548c2ecf20Sopenharmony_ci#define INTERFACE_NONE          0x00
2558c2ecf20Sopenharmony_ci#define INTERFACE_ANALOG_RGB    0x01
2568c2ecf20Sopenharmony_ci#define INTERFACE_DVP0          0x02
2578c2ecf20Sopenharmony_ci#define INTERFACE_DVP1          0x03
2588c2ecf20Sopenharmony_ci#define INTERFACE_DFP_HIGH      0x04
2598c2ecf20Sopenharmony_ci#define INTERFACE_DFP_LOW       0x05
2608c2ecf20Sopenharmony_ci#define INTERFACE_DFP           0x06
2618c2ecf20Sopenharmony_ci#define INTERFACE_LVDS0         0x07
2628c2ecf20Sopenharmony_ci#define INTERFACE_LVDS1         0x08
2638c2ecf20Sopenharmony_ci#define INTERFACE_LVDS0LVDS1    0x09
2648c2ecf20Sopenharmony_ci#define INTERFACE_TMDS          0x0A
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci#define HW_LAYOUT_LCD_ONLY      0x01
2678c2ecf20Sopenharmony_ci#define HW_LAYOUT_DVI_ONLY      0x02
2688c2ecf20Sopenharmony_ci#define HW_LAYOUT_LCD_DVI       0x03
2698c2ecf20Sopenharmony_ci#define HW_LAYOUT_LCD1_LCD2     0x04
2708c2ecf20Sopenharmony_ci#define HW_LAYOUT_LCD_EXTERNAL_LCD2 0x10
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci/* Definition CRTC Timing Index */
2738c2ecf20Sopenharmony_ci#define H_TOTAL_INDEX               0
2748c2ecf20Sopenharmony_ci#define H_ADDR_INDEX                1
2758c2ecf20Sopenharmony_ci#define H_BLANK_START_INDEX         2
2768c2ecf20Sopenharmony_ci#define H_BLANK_END_INDEX           3
2778c2ecf20Sopenharmony_ci#define H_SYNC_START_INDEX          4
2788c2ecf20Sopenharmony_ci#define H_SYNC_END_INDEX            5
2798c2ecf20Sopenharmony_ci#define V_TOTAL_INDEX               6
2808c2ecf20Sopenharmony_ci#define V_ADDR_INDEX                7
2818c2ecf20Sopenharmony_ci#define V_BLANK_START_INDEX         8
2828c2ecf20Sopenharmony_ci#define V_BLANK_END_INDEX           9
2838c2ecf20Sopenharmony_ci#define V_SYNC_START_INDEX          10
2848c2ecf20Sopenharmony_ci#define V_SYNC_END_INDEX            11
2858c2ecf20Sopenharmony_ci#define H_TOTAL_SHADOW_INDEX        12
2868c2ecf20Sopenharmony_ci#define H_BLANK_END_SHADOW_INDEX    13
2878c2ecf20Sopenharmony_ci#define V_TOTAL_SHADOW_INDEX        14
2888c2ecf20Sopenharmony_ci#define V_ADDR_SHADOW_INDEX         15
2898c2ecf20Sopenharmony_ci#define V_BLANK_SATRT_SHADOW_INDEX  16
2908c2ecf20Sopenharmony_ci#define V_BLANK_END_SHADOW_INDEX    17
2918c2ecf20Sopenharmony_ci#define V_SYNC_SATRT_SHADOW_INDEX   18
2928c2ecf20Sopenharmony_ci#define V_SYNC_END_SHADOW_INDEX     19
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci/* LCD display method
2958c2ecf20Sopenharmony_ci*/
2968c2ecf20Sopenharmony_ci#define     LCD_EXPANDSION              0x00
2978c2ecf20Sopenharmony_ci#define     LCD_CENTERING               0x01
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci/* LCD mode
3008c2ecf20Sopenharmony_ci*/
3018c2ecf20Sopenharmony_ci#define     LCD_OPENLDI               0x00
3028c2ecf20Sopenharmony_ci#define     LCD_SPWG                  0x01
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_cistruct crt_mode_table {
3058c2ecf20Sopenharmony_ci	int refresh_rate;
3068c2ecf20Sopenharmony_ci	int h_sync_polarity;
3078c2ecf20Sopenharmony_ci	int v_sync_polarity;
3088c2ecf20Sopenharmony_ci	struct via_display_timing crtc;
3098c2ecf20Sopenharmony_ci};
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_cistruct io_reg {
3128c2ecf20Sopenharmony_ci	int port;
3138c2ecf20Sopenharmony_ci	u8 index;
3148c2ecf20Sopenharmony_ci	u8 mask;
3158c2ecf20Sopenharmony_ci	u8 value;
3168c2ecf20Sopenharmony_ci};
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci#endif /* __SHARE_H__ */
319