162306a36Sopenharmony_ci/***************************************************************************\ 262306a36Sopenharmony_ci|* *| 362306a36Sopenharmony_ci|* Copyright 1993-2003 NVIDIA, Corporation. All rights reserved. *| 462306a36Sopenharmony_ci|* *| 562306a36Sopenharmony_ci|* NOTICE TO USER: The source code is copyrighted under U.S. and *| 662306a36Sopenharmony_ci|* international laws. Users and possessors of this source code are *| 762306a36Sopenharmony_ci|* hereby granted a nonexclusive, royalty-free copyright license to *| 862306a36Sopenharmony_ci|* use this code in individual and commercial software. *| 962306a36Sopenharmony_ci|* *| 1062306a36Sopenharmony_ci|* Any use of this source code must include, in the user documenta- *| 1162306a36Sopenharmony_ci|* tion and internal comments to the code, notices to the end user *| 1262306a36Sopenharmony_ci|* as follows: *| 1362306a36Sopenharmony_ci|* *| 1462306a36Sopenharmony_ci|* Copyright 1993-1999 NVIDIA, Corporation. All rights reserved. *| 1562306a36Sopenharmony_ci|* *| 1662306a36Sopenharmony_ci|* NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY *| 1762306a36Sopenharmony_ci|* OF THIS SOURCE CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" *| 1862306a36Sopenharmony_ci|* WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. NVIDIA, CORPOR- *| 1962306a36Sopenharmony_ci|* ATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOURCE CODE, *| 2062306a36Sopenharmony_ci|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE- *| 2162306a36Sopenharmony_ci|* MENT, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL *| 2262306a36Sopenharmony_ci|* NVIDIA, CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT, INCI- *| 2362306a36Sopenharmony_ci|* DENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RE- *| 2462306a36Sopenharmony_ci|* SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION *| 2562306a36Sopenharmony_ci|* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *| 2662306a36Sopenharmony_ci|* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| 2762306a36Sopenharmony_ci|* *| 2862306a36Sopenharmony_ci|* U.S. Government End Users. This source code is a "commercial *| 2962306a36Sopenharmony_ci|* item," as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| 3062306a36Sopenharmony_ci|* consisting of "commercial computer software" and "commercial *| 3162306a36Sopenharmony_ci|* computer software documentation," as such terms are used in *| 3262306a36Sopenharmony_ci|* 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Govern- *| 3362306a36Sopenharmony_ci|* ment only as a commercial end item. Consistent with 48 C.F.R. *| 3462306a36Sopenharmony_ci|* 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| 3562306a36Sopenharmony_ci|* all U.S. Government End Users acquire the source code with only *| 3662306a36Sopenharmony_ci|* those rights set forth herein. *| 3762306a36Sopenharmony_ci|* *| 3862306a36Sopenharmony_ci \***************************************************************************/ 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci/* 4162306a36Sopenharmony_ci * GPL Licensing Note - According to Mark Vojkovich, author of the Xorg/ 4262306a36Sopenharmony_ci * XFree86 'nv' driver, this source code is provided under MIT-style licensing 4362306a36Sopenharmony_ci * where the source code is provided "as is" without warranty of any kind. 4462306a36Sopenharmony_ci * The only usage restriction is for the copyright notices to be retained 4562306a36Sopenharmony_ci * whenever code is used. 4662306a36Sopenharmony_ci * 4762306a36Sopenharmony_ci * Antonino Daplas <adaplas@pol.net> 2005-03-11 4862306a36Sopenharmony_ci */ 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci#ifndef __NV_LOCAL_H__ 5162306a36Sopenharmony_ci#define __NV_LOCAL_H__ 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci/* 5462306a36Sopenharmony_ci * This file includes any environment or machine specific values to access the 5562306a36Sopenharmony_ci * HW. Put all affected includes, typdefs, etc. here so the riva_hw.* files 5662306a36Sopenharmony_ci * can stay generic in nature. 5762306a36Sopenharmony_ci */ 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci/* 6062306a36Sopenharmony_ci * HW access macros. These assume memory-mapped I/O, and not normal I/O space. 6162306a36Sopenharmony_ci */ 6262306a36Sopenharmony_ci#define NV_WR08(p,i,d) (__raw_writeb((d), (void __iomem *)(p) + (i))) 6362306a36Sopenharmony_ci#define NV_RD08(p,i) (__raw_readb((void __iomem *)(p) + (i))) 6462306a36Sopenharmony_ci#define NV_WR16(p,i,d) (__raw_writew((d), (void __iomem *)(p) + (i))) 6562306a36Sopenharmony_ci#define NV_RD16(p,i) (__raw_readw((void __iomem *)(p) + (i))) 6662306a36Sopenharmony_ci#define NV_WR32(p,i,d) (__raw_writel((d), (void __iomem *)(p) + (i))) 6762306a36Sopenharmony_ci#define NV_RD32(p,i) (__raw_readl((void __iomem *)(p) + (i))) 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci/* VGA I/O is now always done through MMIO */ 7062306a36Sopenharmony_ci#define VGA_WR08(p,i,d) (writeb((d), (void __iomem *)(p) + (i))) 7162306a36Sopenharmony_ci#define VGA_RD08(p,i) (readb((void __iomem *)(p) + (i))) 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci#define NVDmaNext(par, data) \ 7462306a36Sopenharmony_ci NV_WR32(&(par)->dmaBase[(par)->dmaCurrent++], 0, (data)) 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#define NVDmaStart(info, par, tag, size) { \ 7762306a36Sopenharmony_ci if((par)->dmaFree <= (size)) \ 7862306a36Sopenharmony_ci NVDmaWait(info, size); \ 7962306a36Sopenharmony_ci NVDmaNext(par, ((size) << 18) | (tag)); \ 8062306a36Sopenharmony_ci (par)->dmaFree -= ((size) + 1); \ 8162306a36Sopenharmony_ci} 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci#if defined(__i386__) 8462306a36Sopenharmony_ci#define _NV_FENCE() outb(0, 0x3D0); 8562306a36Sopenharmony_ci#else 8662306a36Sopenharmony_ci#define _NV_FENCE() mb(); 8762306a36Sopenharmony_ci#endif 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci#define WRITE_PUT(par, data) { \ 9062306a36Sopenharmony_ci _NV_FENCE() \ 9162306a36Sopenharmony_ci NV_RD08((par)->FbStart, 0); \ 9262306a36Sopenharmony_ci NV_WR32(&(par)->FIFO[0x0010], 0, (data) << 2); \ 9362306a36Sopenharmony_ci mb(); \ 9462306a36Sopenharmony_ci} 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci#define READ_GET(par) (NV_RD32(&(par)->FIFO[0x0011], 0) >> 2) 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci#ifdef __LITTLE_ENDIAN 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci#include <linux/bitrev.h> 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci#define reverse_order(l) \ 10362306a36Sopenharmony_cido { \ 10462306a36Sopenharmony_ci u8 *a = (u8 *)(l); \ 10562306a36Sopenharmony_ci a[0] = bitrev8(a[0]); \ 10662306a36Sopenharmony_ci a[1] = bitrev8(a[1]); \ 10762306a36Sopenharmony_ci a[2] = bitrev8(a[2]); \ 10862306a36Sopenharmony_ci a[3] = bitrev8(a[3]); \ 10962306a36Sopenharmony_ci} while(0) 11062306a36Sopenharmony_ci#else 11162306a36Sopenharmony_ci#define reverse_order(l) do { } while(0) 11262306a36Sopenharmony_ci#endif /* __LITTLE_ENDIAN */ 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci#endif /* __NV_LOCAL_H__ */ 115