NV50: basic fbcon + misc fixes
[platform/upstream/libdrm.git] / linux-core / xgi_regs.h
1 /****************************************************************************
2  * Copyright (C) 2003-2006 by XGI Technology, Taiwan.
3  *
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation on the rights to use, copy, modify, merge,
10  * publish, distribute, sublicense, and/or sell copies of the Software,
11  * and to permit persons to whom the Software is furnished to do so,
12  * subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial
16  * portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
21  * XGI AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  ***************************************************************************/
26
27 #ifndef _XGI_REGS_H_
28 #define _XGI_REGS_H_
29
30 #include "drmP.h"
31 #include "drm.h"
32
33 #define MAKE_MASK(bits)  ((1U << (bits)) - 1)
34
35 #define ONE_BIT_MASK        MAKE_MASK(1)
36 #define TWENTY_BIT_MASK     MAKE_MASK(20)
37 #define TWENTYONE_BIT_MASK  MAKE_MASK(21)
38 #define TWENTYTWO_BIT_MASK  MAKE_MASK(22)
39
40
41 /* Port 0x3d4/0x3d5, index 0x2a */
42 #define XGI_INTERFACE_SEL 0x2a
43 #define DUAL_64BIT        (1U<<7)
44 #define INTERNAL_32BIT    (1U<<6)
45 #define EN_SEP_WR         (1U<<5)
46 #define POWER_DOWN_SEL    (1U<<4)
47 /*#define RESERVED_3      (1U<<3) */
48 #define SUBS_MCLK_PCICLK  (1U<<2)
49 #define MEM_SIZE_MASK     (3<<0)
50 #define MEM_SIZE_32MB     (0<<0)
51 #define MEM_SIZE_64MB     (1<<0)
52 #define MEM_SIZE_128MB    (2<<0)
53 #define MEM_SIZE_256MB    (3<<0)
54
55 /* Port 0x3d4/0x3d5, index 0x36 */
56 #define XGI_GE_CNTL 0x36
57 #define GE_ENABLE        (1U<<7)
58 /*#define RESERVED_6     (1U<<6) */
59 /*#define RESERVED_5     (1U<<5) */
60 #define GE_RESET         (1U<<4)
61 /*#define RESERVED_3     (1U<<3) */
62 #define GE_ENABLE_3D     (1U<<2)
63 /*#define RESERVED_1     (1U<<1) */
64 /*#define RESERVED_0     (1U<<0) */
65
66 /* Port 0x3ce/0x3cf, index 0x2a */
67 #define XGI_MISC_CTRL 0x2a
68 #define MOTION_VID_SUSPEND   (1U<<7)
69 #define DVI_CRTC_TIMING_SEL  (1U<<6)
70 #define LCD_SEL_CTL_NEW      (1U<<5)
71 #define LCD_SEL_EXT_DELYCTRL (1U<<4)
72 #define REG_LCDDPARST        (1U<<3)
73 #define LCD2DPAOFF           (1U<<2)
74 /*#define RESERVED_1         (1U<<1) */
75 #define EN_GEPWM             (1U<<0)  /* Enable GE power management */
76
77
78 #define BASE_3D_ENG 0x2800
79
80 #define M2REG_FLUSH_ENGINE_ADDRESS 0x000
81 #define M2REG_FLUSH_ENGINE_COMMAND 0x00
82 #define M2REG_FLUSH_FLIP_ENGINE_MASK              (ONE_BIT_MASK<<21)
83 #define M2REG_FLUSH_2D_ENGINE_MASK                (ONE_BIT_MASK<<20)
84 #define M2REG_FLUSH_3D_ENGINE_MASK                TWENTY_BIT_MASK
85
86 #define M2REG_RESET_ADDRESS 0x004
87 #define M2REG_RESET_COMMAND 0x01
88 #define M2REG_RESET_STATUS2_MASK                  (ONE_BIT_MASK<<10)
89 #define M2REG_RESET_STATUS1_MASK                  (ONE_BIT_MASK<<9)
90 #define M2REG_RESET_STATUS0_MASK                  (ONE_BIT_MASK<<8)
91 #define M2REG_RESET_3DENG_MASK                    (ONE_BIT_MASK<<4)
92 #define M2REG_RESET_2DENG_MASK                    (ONE_BIT_MASK<<2)
93
94 /* Write register */
95 #define M2REG_AUTO_LINK_SETTING_ADDRESS 0x010
96 #define M2REG_AUTO_LINK_SETTING_COMMAND 0x04
97 #define M2REG_CLEAR_TIMER_INTERRUPT_MASK          (ONE_BIT_MASK<<11)
98 #define M2REG_CLEAR_INTERRUPT_3_MASK              (ONE_BIT_MASK<<10)
99 #define M2REG_CLEAR_INTERRUPT_2_MASK              (ONE_BIT_MASK<<9)
100 #define M2REG_CLEAR_INTERRUPT_0_MASK              (ONE_BIT_MASK<<8)
101 #define M2REG_CLEAR_COUNTERS_MASK                 (ONE_BIT_MASK<<4)
102 #define M2REG_PCI_TRIGGER_MODE_MASK               (ONE_BIT_MASK<<1)
103 #define M2REG_INVALID_LIST_AUTO_INTERRUPT_MASK    (ONE_BIT_MASK<<0)
104
105 /* Read register */
106 #define M2REG_AUTO_LINK_STATUS_ADDRESS 0x010
107 #define M2REG_AUTO_LINK_STATUS_COMMAND 0x04
108 #define M2REG_ACTIVE_TIMER_INTERRUPT_MASK          (ONE_BIT_MASK<<11)
109 #define M2REG_ACTIVE_INTERRUPT_3_MASK              (ONE_BIT_MASK<<10)
110 #define M2REG_ACTIVE_INTERRUPT_2_MASK              (ONE_BIT_MASK<<9)
111 #define M2REG_ACTIVE_INTERRUPT_0_MASK              (ONE_BIT_MASK<<8)
112 #define M2REG_INVALID_LIST_AUTO_INTERRUPTED_MODE_MASK    (ONE_BIT_MASK<<0)
113
114 #define     M2REG_PCI_TRIGGER_REGISTER_ADDRESS 0x014
115 #define     M2REG_PCI_TRIGGER_REGISTER_COMMAND 0x05
116
117
118 /**
119  * Begin instruction, double-word 0
120  */
121 #define BEGIN_STOP_STORE_CURRENT_POINTER_MASK   (ONE_BIT_MASK<<22)
122 #define BEGIN_VALID_MASK                        (ONE_BIT_MASK<<20)
123 #define BEGIN_BEGIN_IDENTIFICATION_MASK         TWENTY_BIT_MASK
124
125 /**
126  * Begin instruction, double-word 1
127  */
128 #define BEGIN_LINK_ENABLE_MASK                  (ONE_BIT_MASK<<31)
129 #define BEGIN_COMMAND_LIST_LENGTH_MASK          TWENTYTWO_BIT_MASK
130
131
132 /* Hardware access functions */
133 static inline void OUT3C5B(struct drm_map * map, u8 index, u8 data)
134 {
135         DRM_WRITE8(map, 0x3C4, index);
136         DRM_WRITE8(map, 0x3C5, data);
137 }
138
139 static inline void OUT3X5B(struct drm_map * map, u8 index, u8 data)
140 {
141         DRM_WRITE8(map, 0x3D4, index);
142         DRM_WRITE8(map, 0x3D5, data);
143 }
144
145 static inline void OUT3CFB(struct drm_map * map, u8 index, u8 data)
146 {
147         DRM_WRITE8(map, 0x3CE, index);
148         DRM_WRITE8(map, 0x3CF, data);
149 }
150
151 static inline u8 IN3C5B(struct drm_map * map, u8 index)
152 {
153         DRM_WRITE8(map, 0x3C4, index);
154         return DRM_READ8(map, 0x3C5);
155 }
156
157 static inline u8 IN3X5B(struct drm_map * map, u8 index)
158 {
159         DRM_WRITE8(map, 0x3D4, index);
160         return DRM_READ8(map, 0x3D5);
161 }
162
163 static inline u8 IN3CFB(struct drm_map * map, u8 index)
164 {
165         DRM_WRITE8(map, 0x3CE, index);
166         return DRM_READ8(map, 0x3CF);
167 }
168
169 #endif