2007-06-26 14:10:30 -06:00
|
|
|
/****************************************************************************
|
2007-07-24 14:36:02 -06:00
|
|
|
* Copyright (C) 2003-2006 by XGI Technology, Taiwan.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
2007-06-26 14:10:30 -06: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 14:36:02 -06: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 14:10:30 -06:00
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _XGI_REGS_H_
|
|
|
|
#define _XGI_REGS_H_
|
|
|
|
|
2007-07-19 11:29:18 -06:00
|
|
|
#include "drmP.h"
|
|
|
|
#include "drm.h"
|
2007-06-26 14:10:30 -06:00
|
|
|
|
|
|
|
|
|
|
|
/* Hardware access functions */
|
2007-07-19 11:29:18 -06:00
|
|
|
static inline void OUT3C5B(struct drm_map * map, u8 index, u8 data)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_WRITE8(map, 0x3C4, index);
|
|
|
|
DRM_WRITE8(map, 0x3C5, data);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
2007-07-19 11:29:18 -06:00
|
|
|
static inline void OUT3X5B(struct drm_map * map, u8 index, u8 data)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_WRITE8(map, 0x3D4, index);
|
|
|
|
DRM_WRITE8(map, 0x3D5, data);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
2007-07-19 11:29:18 -06:00
|
|
|
static inline void OUT3CFB(struct drm_map * map, u8 index, u8 data)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_WRITE8(map, 0x3CE, index);
|
|
|
|
DRM_WRITE8(map, 0x3CF, data);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
2007-07-19 11:29:18 -06:00
|
|
|
static inline u8 IN3C5B(struct drm_map * map, u8 index)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_WRITE8(map, 0x3C4, index);
|
|
|
|
return DRM_READ8(map, 0x3C5);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
2007-07-19 11:29:18 -06:00
|
|
|
static inline u8 IN3X5B(struct drm_map * map, u8 index)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_WRITE8(map, 0x3D4, index);
|
|
|
|
return DRM_READ8(map, 0x3D5);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
2007-07-19 11:29:18 -06:00
|
|
|
static inline u8 IN3CFB(struct drm_map * map, u8 index)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_WRITE8(map, 0x3CE, index);
|
|
|
|
return DRM_READ8(map, 0x3CF);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Graphic engine register (2d/3d) acessing interface
|
|
|
|
*/
|
2007-07-19 11:29:18 -06:00
|
|
|
static inline void dwWriteReg(struct drm_map * map, u32 addr, u32 data)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
2007-07-23 19:50:52 -06:00
|
|
|
#ifdef XGI_MMIO_DEBUG
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_INFO("mmio_map->handle = 0x%p, addr = 0x%x, data = 0x%x\n",
|
|
|
|
map->handle, addr, data);
|
2007-07-23 19:50:52 -06:00
|
|
|
#endif
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_WRITE32(map, addr, data);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-29 16:27:38 -06:00
|
|
|
static inline void xgi_enable_mmio(struct xgi_info * info)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
|
|
|
u8 protect = 0;
|
2007-07-19 11:29:18 -06:00
|
|
|
u8 temp;
|
2007-06-26 14:10:30 -06:00
|
|
|
|
|
|
|
/* Unprotect registers */
|
2007-07-19 11:29:18 -06: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 14:10:30 -06:00
|
|
|
|
2007-07-19 11:29:18 -06: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 14:10:30 -06:00
|
|
|
|
|
|
|
/* Enable MMIO */
|
2007-07-19 11:29:18 -06: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 14:10:30 -06:00
|
|
|
|
2007-07-19 11:29:18 -06:00
|
|
|
/* Protect registers */
|
|
|
|
OUT3C5B(info->mmio_map, 0x11, protect);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
2007-06-29 16:27:38 -06:00
|
|
|
static inline void xgi_disable_mmio(struct xgi_info * info)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
|
|
|
u8 protect = 0;
|
2007-07-19 11:29:18 -06:00
|
|
|
u8 temp;
|
2007-06-26 14:10:30 -06:00
|
|
|
|
2007-07-19 11:29:18 -06: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 14:10:30 -06:00
|
|
|
|
|
|
|
/* Disable MMIO access */
|
2007-07-19 11:29:18 -06: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 14:10:30 -06:00
|
|
|
|
|
|
|
/* Protect registers */
|
2007-07-19 11:29:18 -06:00
|
|
|
OUT3C5B(info->mmio_map, 0x11, protect);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
2007-06-29 16:27:38 -06:00
|
|
|
static inline void xgi_enable_ge(struct xgi_info * info)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
|
|
|
unsigned char bOld3cf2a = 0;
|
|
|
|
int wait = 0;
|
|
|
|
|
|
|
|
// Enable GE
|
2007-07-30 10:59:19 -06:00
|
|
|
OUT3C5B(info->mmio_map, 0x11, 0x92);
|
2007-06-26 14:10:30 -06:00
|
|
|
|
|
|
|
// Save and close dynamic gating
|
2007-07-19 11:29:18 -06:00
|
|
|
bOld3cf2a = IN3CFB(info->mmio_map, 0x2a);
|
|
|
|
OUT3CFB(info->mmio_map, 0x2a, bOld3cf2a & 0xfe);
|
2007-06-26 14:10:30 -06:00
|
|
|
|
|
|
|
// Reset both 3D and 2D engine
|
2007-07-19 11:29:18 -06:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x84);
|
2007-06-26 14:10:30 -06:00
|
|
|
wait = 10;
|
|
|
|
while (wait--) {
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_READ8(info->mmio_map, 0x36);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
2007-07-19 11:29:18 -06:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x94);
|
2007-06-26 14:10:30 -06:00
|
|
|
wait = 10;
|
|
|
|
while (wait--) {
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_READ8(info->mmio_map, 0x36);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
2007-07-19 11:29:18 -06:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x84);
|
2007-06-26 14:10:30 -06:00
|
|
|
wait = 10;
|
|
|
|
while (wait--) {
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_READ8(info->mmio_map, 0x36);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
// Enable 2D engine only
|
2007-07-19 11:29:18 -06:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x80);
|
2007-06-26 14:10:30 -06:00
|
|
|
|
|
|
|
// Enable 2D+3D engine
|
2007-07-19 11:29:18 -06:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x84);
|
2007-06-26 14:10:30 -06:00
|
|
|
|
|
|
|
// Restore dynamic gating
|
2007-07-19 11:29:18 -06:00
|
|
|
OUT3CFB(info->mmio_map, 0x2a, bOld3cf2a);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
2007-06-29 16:27:38 -06:00
|
|
|
static inline void xgi_disable_ge(struct xgi_info * info)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
|
|
|
int wait = 0;
|
|
|
|
|
|
|
|
// Reset both 3D and 2D engine
|
2007-07-19 11:29:18 -06:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x84);
|
2007-06-26 14:10:30 -06:00
|
|
|
|
|
|
|
wait = 10;
|
|
|
|
while (wait--) {
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_READ8(info->mmio_map, 0x36);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
2007-07-19 11:29:18 -06:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x94);
|
2007-06-26 14:10:30 -06:00
|
|
|
|
|
|
|
wait = 10;
|
|
|
|
while (wait--) {
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_READ8(info->mmio_map, 0x36);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
2007-07-19 11:29:18 -06:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0x84);
|
2007-06-26 14:10:30 -06:00
|
|
|
|
|
|
|
wait = 10;
|
|
|
|
while (wait--) {
|
2007-07-19 11:29:18 -06:00
|
|
|
DRM_READ8(info->mmio_map, 0x36);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Disable 2D engine only
|
2007-07-19 11:29:18 -06:00
|
|
|
OUT3X5B(info->mmio_map, 0x36, 0);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
2007-06-29 16:27:38 -06:00
|
|
|
static inline void xgi_enable_dvi_interrupt(struct xgi_info * info)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
2007-07-19 11:29:18 -06: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 14:10:30 -06:00
|
|
|
}
|
2007-06-29 16:27:38 -06:00
|
|
|
static inline void xgi_disable_dvi_interrupt(struct xgi_info * info)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
2007-07-19 11:29:18 -06:00
|
|
|
OUT3CFB(info->mmio_map, 0x39, IN3CFB(info->mmio_map, 0x39) & ~0x02);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
2007-06-29 16:27:38 -06:00
|
|
|
static inline void xgi_enable_crt1_interrupt(struct xgi_info * info)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
2007-07-19 11:29:18 -06: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 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
2007-06-29 16:27:38 -06:00
|
|
|
static inline void xgi_disable_crt1_interrupt(struct xgi_info * info)
|
2007-06-26 14:10:30 -06:00
|
|
|
{
|
2007-07-19 11:29:18 -06:00
|
|
|
OUT3CFB(info->mmio_map, 0x3d, IN3CFB(info->mmio_map, 0x3d) & ~0x08);
|
2007-06-26 14:10:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|