2007-06-26 13:10:30 -07:00
|
|
|
/****************************************************************************
|
2007-07-24 13:36:02 -07:00
|
|
|
* Copyright (C) 2003-2006 by XGI Technology, Taiwan.
|
|
|
|
|
*
|
|
|
|
|
* All Rights Reserved.
|
|
|
|
|
*
|
2007-06-26 13:10:30 -07:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
|
* a copy of this software and associated documentation files (the
|
2007-07-24 13:36:02 -07:00
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation on the rights to use, copy, modify, merge,
|
|
|
|
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
|
|
|
* and to permit persons to whom the Software is furnished to do so,
|
|
|
|
|
* subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
|
* portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* XGI AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
2007-06-26 13:10:30 -07:00
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef _XGI_REGS_H_
|
|
|
|
|
#define _XGI_REGS_H_
|
|
|
|
|
|
2007-07-19 10:29:18 -07:00
|
|
|
#include "drmP.h"
|
|
|
|
|
#include "drm.h"
|
2007-06-26 13:10:30 -07:00
|
|
|
|
2007-08-09 18:15:42 -07:00
|
|
|
#define BASE_3D_ENG 0x2800
|
|
|
|
|
|
|
|
|
|
#define MAKE_MASK(bits) ((1U << (bits)) - 1)
|
|
|
|
|
|
|
|
|
|
#define ONE_BIT_MASK MAKE_MASK(1)
|
|
|
|
|
#define TWENTY_BIT_MASK MAKE_MASK(20)
|
|
|
|
|
#define TWENTYONE_BIT_MASK MAKE_MASK(21)
|
|
|
|
|
#define TWENTYTWO_BIT_MASK MAKE_MASK(22)
|
|
|
|
|
|
|
|
|
|
#define M2REG_FLUSH_ENGINE_ADDRESS 0x000
|
|
|
|
|
#define M2REG_FLUSH_ENGINE_COMMAND 0x00
|
|
|
|
|
#define M2REG_FLUSH_FLIP_ENGINE_MASK (ONE_BIT_MASK<<21)
|
|
|
|
|
#define M2REG_FLUSH_2D_ENGINE_MASK (ONE_BIT_MASK<<20)
|
|
|
|
|
#define M2REG_FLUSH_3D_ENGINE_MASK TWENTY_BIT_MASK
|
|
|
|
|
|
|
|
|
|
/* Write register */
|
|
|
|
|
#define M2REG_AUTO_LINK_SETTING_ADDRESS 0x010
|
|
|
|
|
#define M2REG_AUTO_LINK_SETTING_COMMAND 0x04
|
|
|
|
|
#define M2REG_CLEAR_TIMER_INTERRUPT_MASK (ONE_BIT_MASK<<11)
|
|
|
|
|
#define M2REG_CLEAR_INTERRUPT_3_MASK (ONE_BIT_MASK<<10)
|
|
|
|
|
#define M2REG_CLEAR_INTERRUPT_2_MASK (ONE_BIT_MASK<<9)
|
|
|
|
|
#define M2REG_CLEAR_INTERRUPT_0_MASK (ONE_BIT_MASK<<8)
|
|
|
|
|
#define M2REG_CLEAR_COUNTERS_MASK (ONE_BIT_MASK<<4)
|
|
|
|
|
#define M2REG_PCI_TRIGGER_MODE_MASK (ONE_BIT_MASK<<1)
|
|
|
|
|
#define M2REG_INVALID_LIST_AUTO_INTERRUPT_MASK (ONE_BIT_MASK<<0)
|
|
|
|
|
|
|
|
|
|
/* Read register */
|
|
|
|
|
#define M2REG_AUTO_LINK_STATUS_ADDRESS 0x010
|
|
|
|
|
#define M2REG_AUTO_LINK_STATUS_COMMAND 0x04
|
|
|
|
|
#define M2REG_ACTIVE_TIMER_INTERRUPT_MASK (ONE_BIT_MASK<<11)
|
|
|
|
|
#define M2REG_ACTIVE_INTERRUPT_3_MASK (ONE_BIT_MASK<<10)
|
|
|
|
|
#define M2REG_ACTIVE_INTERRUPT_2_MASK (ONE_BIT_MASK<<9)
|
|
|
|
|
#define M2REG_ACTIVE_INTERRUPT_0_MASK (ONE_BIT_MASK<<8)
|
|
|
|
|
#define M2REG_INVALID_LIST_AUTO_INTERRUPTED_MODE_MASK (ONE_BIT_MASK<<0)
|
|
|
|
|
|
|
|
|
|
#define M2REG_PCI_TRIGGER_REGISTER_ADDRESS 0x014
|
|
|
|
|
#define M2REG_PCI_TRIGGER_REGISTER_COMMAND 0x05
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Begin instruction, double-word 0
|
|
|
|
|
*/
|
|
|
|
|
#define BEGIN_VALID_MASK (ONE_BIT_MASK<<20)
|
|
|
|
|
#define BEGIN_BEGIN_IDENTIFICATION_MASK TWENTY_BIT_MASK
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Begin instruction, double-word 1
|
|
|
|
|
*/
|
|
|
|
|
#define BEGIN_LINK_ENABLE_MASK (ONE_BIT_MASK<<31)
|
|
|
|
|
#define BEGIN_COMMAND_LIST_LENGTH_MASK TWENTYTWO_BIT_MASK
|
|
|
|
|
|
2007-06-26 13:10:30 -07:00
|
|
|
|
|
|
|
|
/* Hardware access functions */
|
2007-07-19 10:29:18 -07:00
|
|
|
static inline void OUT3C5B(struct drm_map * map, u8 index, u8 data)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_WRITE8(map, 0x3C4, index);
|
|
|
|
|
DRM_WRITE8(map, 0x3C5, data);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
2007-07-19 10:29:18 -07:00
|
|
|
static inline void OUT3X5B(struct drm_map * map, u8 index, u8 data)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_WRITE8(map, 0x3D4, index);
|
|
|
|
|
DRM_WRITE8(map, 0x3D5, data);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
2007-07-19 10:29:18 -07:00
|
|
|
static inline void OUT3CFB(struct drm_map * map, u8 index, u8 data)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_WRITE8(map, 0x3CE, index);
|
|
|
|
|
DRM_WRITE8(map, 0x3CF, data);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
2007-07-19 10:29:18 -07:00
|
|
|
static inline u8 IN3C5B(struct drm_map * map, u8 index)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_WRITE8(map, 0x3C4, index);
|
|
|
|
|
return DRM_READ8(map, 0x3C5);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
2007-07-19 10:29:18 -07:00
|
|
|
static inline u8 IN3X5B(struct drm_map * map, u8 index)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_WRITE8(map, 0x3D4, index);
|
|
|
|
|
return DRM_READ8(map, 0x3D5);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
2007-07-19 10:29:18 -07:00
|
|
|
static inline u8 IN3CFB(struct drm_map * map, u8 index)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_WRITE8(map, 0x3CE, index);
|
|
|
|
|
return DRM_READ8(map, 0x3CF);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Graphic engine register (2d/3d) acessing interface
|
|
|
|
|
*/
|
2007-07-19 10:29:18 -07:00
|
|
|
static inline void dwWriteReg(struct drm_map * map, u32 addr, u32 data)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
2007-07-23 18:50:52 -07:00
|
|
|
#ifdef XGI_MMIO_DEBUG
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_INFO("mmio_map->handle = 0x%p, addr = 0x%x, data = 0x%x\n",
|
|
|
|
|
map->handle, addr, data);
|
2007-07-23 18:50:52 -07:00
|
|
|
#endif
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_WRITE32(map, addr, data);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-06-29 15:27:38 -07:00
|
|
|
static inline void xgi_enable_mmio(struct xgi_info * info)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
|
|
|
|
u8 protect = 0;
|
2007-07-19 10:29:18 -07:00
|
|
|
u8 temp;
|
2007-06-26 13:10:30 -07:00
|
|
|
|
|
|
|
|
/* Unprotect registers */
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_WRITE8(info->mmio_map, 0x3C4, 0x11);
|
|
|
|
|
protect = DRM_READ8(info->mmio_map, 0x3C5);
|
|
|
|
|
DRM_WRITE8(info->mmio_map, 0x3C5, 0x92);
|
2007-06-26 13:10:30 -07:00
|
|
|
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_WRITE8(info->mmio_map, 0x3D4, 0x3A);
|
|
|
|
|
temp = DRM_READ8(info->mmio_map, 0x3D5);
|
|
|
|
|
DRM_WRITE8(info->mmio_map, 0x3D5, temp | 0x20);
|
2007-06-26 13:10:30 -07:00
|
|
|
|
|
|
|
|
/* Enable MMIO */
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_WRITE8(info->mmio_map, 0x3D4, 0x39);
|
|
|
|
|
temp = DRM_READ8(info->mmio_map, 0x3D5);
|
|
|
|
|
DRM_WRITE8(info->mmio_map, 0x3D5, temp | 0x01);
|
2007-06-26 13:10:30 -07:00
|
|
|
|
2007-07-19 10:29:18 -07:00
|
|
|
/* Protect registers */
|
|
|
|
|
OUT3C5B(info->mmio_map, 0x11, protect);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
2007-06-29 15:27:38 -07:00
|
|
|
static inline void xgi_disable_mmio(struct xgi_info * info)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
|
|
|
|
u8 protect = 0;
|
2007-07-19 10:29:18 -07:00
|
|
|
u8 temp;
|
2007-06-26 13:10:30 -07:00
|
|
|
|
2007-07-19 10:29:18 -07:00
|
|
|
/* Unprotect registers */
|
|
|
|
|
DRM_WRITE8(info->mmio_map, 0x3C4, 0x11);
|
|
|
|
|
protect = DRM_READ8(info->mmio_map, 0x3C5);
|
|
|
|
|
DRM_WRITE8(info->mmio_map, 0x3C5, 0x92);
|
2007-06-26 13:10:30 -07:00
|
|
|
|
|
|
|
|
/* Disable MMIO access */
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_WRITE8(info->mmio_map, 0x3D4, 0x39);
|
|
|
|
|
temp = DRM_READ8(info->mmio_map, 0x3D5);
|
|
|
|
|
DRM_WRITE8(info->mmio_map, 0x3D5, temp & 0xFE);
|
2007-06-26 13:10:30 -07:00
|
|
|
|
|
|
|
|
/* Protect registers */
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3C5B(info->mmio_map, 0x11, protect);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
2007-06-29 15:27:38 -07:00
|
|
|
static inline void xgi_enable_ge(struct xgi_info * info)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
|
|
|
|
unsigned char bOld3cf2a = 0;
|
|
|
|
|
int wait = 0;
|
|
|
|
|
|
|
|
|
|
// Enable GE
|
2007-07-30 09:59:19 -07:00
|
|
|
OUT3C5B(info->mmio_map, 0x11, 0x92);
|
2007-06-26 13:10:30 -07:00
|
|
|
|
|
|
|
|
// Save and close dynamic gating
|
2007-07-19 10:29:18 -07:00
|
|
|
bOld3cf2a = IN3CFB(info->mmio_map, 0x2a);
|
|
|
|
|
OUT3CFB(info->mmio_map, 0x2a, bOld3cf2a & 0xfe);
|
2007-06-26 13:10:30 -07:00
|
|
|
|
|
|
|
|
// Reset both 3D and 2D engine
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x84);
|
2007-06-26 13:10:30 -07:00
|
|
|
wait = 10;
|
|
|
|
|
while (wait--) {
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_READ8(info->mmio_map, 0x36);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x94);
|
2007-06-26 13:10:30 -07:00
|
|
|
wait = 10;
|
|
|
|
|
while (wait--) {
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_READ8(info->mmio_map, 0x36);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x84);
|
2007-06-26 13:10:30 -07:00
|
|
|
wait = 10;
|
|
|
|
|
while (wait--) {
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_READ8(info->mmio_map, 0x36);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
// Enable 2D engine only
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x80);
|
2007-06-26 13:10:30 -07:00
|
|
|
|
|
|
|
|
// Enable 2D+3D engine
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x84);
|
2007-06-26 13:10:30 -07:00
|
|
|
|
|
|
|
|
// Restore dynamic gating
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3CFB(info->mmio_map, 0x2a, bOld3cf2a);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
2007-06-29 15:27:38 -07:00
|
|
|
static inline void xgi_disable_ge(struct xgi_info * info)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
|
|
|
|
int wait = 0;
|
|
|
|
|
|
|
|
|
|
// Reset both 3D and 2D engine
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x84);
|
2007-06-26 13:10:30 -07:00
|
|
|
|
|
|
|
|
wait = 10;
|
|
|
|
|
while (wait--) {
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_READ8(info->mmio_map, 0x36);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x94);
|
2007-06-26 13:10:30 -07:00
|
|
|
|
|
|
|
|
wait = 10;
|
|
|
|
|
while (wait--) {
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_READ8(info->mmio_map, 0x36);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x84);
|
2007-06-26 13:10:30 -07:00
|
|
|
|
|
|
|
|
wait = 10;
|
|
|
|
|
while (wait--) {
|
2007-07-19 10:29:18 -07:00
|
|
|
DRM_READ8(info->mmio_map, 0x36);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Disable 2D engine only
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
2007-06-29 15:27:38 -07:00
|
|
|
static inline void xgi_enable_dvi_interrupt(struct xgi_info * info)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3CFB(info->mmio_map, 0x39, IN3CFB(info->mmio_map, 0x39) & ~0x01); //Set 3cf.39 bit 0 to 0
|
|
|
|
|
OUT3CFB(info->mmio_map, 0x39, IN3CFB(info->mmio_map, 0x39) | 0x01); //Set 3cf.39 bit 0 to 1
|
|
|
|
|
OUT3CFB(info->mmio_map, 0x39, IN3CFB(info->mmio_map, 0x39) | 0x02);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
2007-06-29 15:27:38 -07:00
|
|
|
static inline void xgi_disable_dvi_interrupt(struct xgi_info * info)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3CFB(info->mmio_map, 0x39, IN3CFB(info->mmio_map, 0x39) & ~0x02);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
2007-06-29 15:27:38 -07:00
|
|
|
static inline void xgi_enable_crt1_interrupt(struct xgi_info * info)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3CFB(info->mmio_map, 0x3d, IN3CFB(info->mmio_map, 0x3d) | 0x04);
|
|
|
|
|
OUT3CFB(info->mmio_map, 0x3d, IN3CFB(info->mmio_map, 0x3d) & ~0x04);
|
|
|
|
|
OUT3CFB(info->mmio_map, 0x3d, IN3CFB(info->mmio_map, 0x3d) | 0x08);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
2007-06-29 15:27:38 -07:00
|
|
|
static inline void xgi_disable_crt1_interrupt(struct xgi_info * info)
|
2007-06-26 13:10:30 -07:00
|
|
|
{
|
2007-07-19 10:29:18 -07:00
|
|
|
OUT3CFB(info->mmio_map, 0x3d, IN3CFB(info->mmio_map, 0x3d) & ~0x08);
|
2007-06-26 13:10:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|