18c2ecf20Sopenharmony_ci/***************************************************************************\
28c2ecf20Sopenharmony_ci|*                                                                           *|
38c2ecf20Sopenharmony_ci|*       Copyright 1993-2003 NVIDIA, Corporation.  All rights reserved.      *|
48c2ecf20Sopenharmony_ci|*                                                                           *|
58c2ecf20Sopenharmony_ci|*     NOTICE TO USER:   The source code  is copyrighted under  U.S. and     *|
68c2ecf20Sopenharmony_ci|*     international laws.  Users and possessors of this source code are     *|
78c2ecf20Sopenharmony_ci|*     hereby granted a nonexclusive,  royalty-free copyright license to     *|
88c2ecf20Sopenharmony_ci|*     use this code in individual and commercial software.                  *|
98c2ecf20Sopenharmony_ci|*                                                                           *|
108c2ecf20Sopenharmony_ci|*     Any use of this source code must include,  in the user documenta-     *|
118c2ecf20Sopenharmony_ci|*     tion and  internal comments to the code,  notices to the end user     *|
128c2ecf20Sopenharmony_ci|*     as follows:                                                           *|
138c2ecf20Sopenharmony_ci|*                                                                           *|
148c2ecf20Sopenharmony_ci|*       Copyright 1993-1999 NVIDIA, Corporation.  All rights reserved.      *|
158c2ecf20Sopenharmony_ci|*                                                                           *|
168c2ecf20Sopenharmony_ci|*     NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY     *|
178c2ecf20Sopenharmony_ci|*     OF  THIS SOURCE  CODE  FOR ANY PURPOSE.  IT IS  PROVIDED  "AS IS"     *|
188c2ecf20Sopenharmony_ci|*     WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.  NVIDIA, CORPOR-     *|
198c2ecf20Sopenharmony_ci|*     ATION DISCLAIMS ALL WARRANTIES  WITH REGARD  TO THIS SOURCE CODE,     *|
208c2ecf20Sopenharmony_ci|*     INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE-     *|
218c2ecf20Sopenharmony_ci|*     MENT,  AND FITNESS  FOR A PARTICULAR PURPOSE.   IN NO EVENT SHALL     *|
228c2ecf20Sopenharmony_ci|*     NVIDIA, CORPORATION  BE LIABLE FOR ANY SPECIAL,  INDIRECT,  INCI-     *|
238c2ecf20Sopenharmony_ci|*     DENTAL, OR CONSEQUENTIAL DAMAGES,  OR ANY DAMAGES  WHATSOEVER RE-     *|
248c2ecf20Sopenharmony_ci|*     SULTING FROM LOSS OF USE,  DATA OR PROFITS,  WHETHER IN AN ACTION     *|
258c2ecf20Sopenharmony_ci|*     OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,  ARISING OUT OF     *|
268c2ecf20Sopenharmony_ci|*     OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE.     *|
278c2ecf20Sopenharmony_ci|*                                                                           *|
288c2ecf20Sopenharmony_ci|*     U.S. Government  End  Users.   This source code  is a "commercial     *|
298c2ecf20Sopenharmony_ci|*     item,"  as that  term is  defined at  48 C.F.R. 2.101 (OCT 1995),     *|
308c2ecf20Sopenharmony_ci|*     consisting  of "commercial  computer  software"  and  "commercial     *|
318c2ecf20Sopenharmony_ci|*     computer  software  documentation,"  as such  terms  are  used in     *|
328c2ecf20Sopenharmony_ci|*     48 C.F.R. 12.212 (SEPT 1995)  and is provided to the U.S. Govern-     *|
338c2ecf20Sopenharmony_ci|*     ment only as  a commercial end item.   Consistent with  48 C.F.R.     *|
348c2ecf20Sopenharmony_ci|*     12.212 and  48 C.F.R. 227.7202-1 through  227.7202-4 (JUNE 1995),     *|
358c2ecf20Sopenharmony_ci|*     all U.S. Government End Users  acquire the source code  with only     *|
368c2ecf20Sopenharmony_ci|*     those rights set forth herein.                                        *|
378c2ecf20Sopenharmony_ci|*                                                                           *|
388c2ecf20Sopenharmony_ci \***************************************************************************/
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/*
418c2ecf20Sopenharmony_ci * GPL Licensing Note - According to Mark Vojkovich, author of the Xorg/
428c2ecf20Sopenharmony_ci * XFree86 'nv' driver, this source code is provided under MIT-style licensing
438c2ecf20Sopenharmony_ci * where the source code is provided "as is" without warranty of any kind.
448c2ecf20Sopenharmony_ci * The only usage restriction is for the copyright notices to be retained
458c2ecf20Sopenharmony_ci * whenever code is used.
468c2ecf20Sopenharmony_ci *
478c2ecf20Sopenharmony_ci * Antonino Daplas <adaplas@pol.net> 2005-03-11
488c2ecf20Sopenharmony_ci */
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#ifndef __NV_LOCAL_H__
518c2ecf20Sopenharmony_ci#define __NV_LOCAL_H__
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci/*
548c2ecf20Sopenharmony_ci * This file includes any environment or machine specific values to access the
558c2ecf20Sopenharmony_ci * HW.  Put all affected includes, typdefs, etc. here so the riva_hw.* files
568c2ecf20Sopenharmony_ci * can stay generic in nature.
578c2ecf20Sopenharmony_ci */
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/*
608c2ecf20Sopenharmony_ci * HW access macros.  These assume memory-mapped I/O, and not normal I/O space.
618c2ecf20Sopenharmony_ci */
628c2ecf20Sopenharmony_ci#define NV_WR08(p,i,d)  (__raw_writeb((d), (void __iomem *)(p) + (i)))
638c2ecf20Sopenharmony_ci#define NV_RD08(p,i)    (__raw_readb((void __iomem *)(p) + (i)))
648c2ecf20Sopenharmony_ci#define NV_WR16(p,i,d)  (__raw_writew((d), (void __iomem *)(p) + (i)))
658c2ecf20Sopenharmony_ci#define NV_RD16(p,i)    (__raw_readw((void __iomem *)(p) + (i)))
668c2ecf20Sopenharmony_ci#define NV_WR32(p,i,d)  (__raw_writel((d), (void __iomem *)(p) + (i)))
678c2ecf20Sopenharmony_ci#define NV_RD32(p,i)    (__raw_readl((void __iomem *)(p) + (i)))
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci/* VGA I/O is now always done through MMIO */
708c2ecf20Sopenharmony_ci#define VGA_WR08(p,i,d) (writeb((d), (void __iomem *)(p) + (i)))
718c2ecf20Sopenharmony_ci#define VGA_RD08(p,i)   (readb((void __iomem *)(p) + (i)))
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define NVDmaNext(par, data) \
748c2ecf20Sopenharmony_ci     NV_WR32(&(par)->dmaBase[(par)->dmaCurrent++], 0, (data))
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#define NVDmaStart(info, par, tag, size) {    \
778c2ecf20Sopenharmony_ci     if((par)->dmaFree <= (size))             \
788c2ecf20Sopenharmony_ci        NVDmaWait(info, size);                \
798c2ecf20Sopenharmony_ci     NVDmaNext(par, ((size) << 18) | (tag));  \
808c2ecf20Sopenharmony_ci     (par)->dmaFree -= ((size) + 1);          \
818c2ecf20Sopenharmony_ci}
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci#if defined(__i386__)
848c2ecf20Sopenharmony_ci#define _NV_FENCE() outb(0, 0x3D0);
858c2ecf20Sopenharmony_ci#else
868c2ecf20Sopenharmony_ci#define _NV_FENCE() mb();
878c2ecf20Sopenharmony_ci#endif
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#define WRITE_PUT(par, data) {                   \
908c2ecf20Sopenharmony_ci  _NV_FENCE()                                    \
918c2ecf20Sopenharmony_ci  NV_RD08((par)->FbStart, 0);                    \
928c2ecf20Sopenharmony_ci  NV_WR32(&(par)->FIFO[0x0010], 0, (data) << 2); \
938c2ecf20Sopenharmony_ci  mb();                                          \
948c2ecf20Sopenharmony_ci}
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci#define READ_GET(par) (NV_RD32(&(par)->FIFO[0x0011], 0) >> 2)
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#ifdef __LITTLE_ENDIAN
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci#include <linux/bitrev.h>
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#define reverse_order(l)        \
1038c2ecf20Sopenharmony_cido {                            \
1048c2ecf20Sopenharmony_ci	u8 *a = (u8 *)(l);      \
1058c2ecf20Sopenharmony_ci	a[0] = bitrev8(a[0]);   \
1068c2ecf20Sopenharmony_ci	a[1] = bitrev8(a[1]);   \
1078c2ecf20Sopenharmony_ci	a[2] = bitrev8(a[2]);   \
1088c2ecf20Sopenharmony_ci	a[3] = bitrev8(a[3]);   \
1098c2ecf20Sopenharmony_ci} while(0)
1108c2ecf20Sopenharmony_ci#else
1118c2ecf20Sopenharmony_ci#define reverse_order(l) do { } while(0)
1128c2ecf20Sopenharmony_ci#endif                          /* __LITTLE_ENDIAN */
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#endif				/* __NV_LOCAL_H__ */
115