Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2010 Francisco Jerez.
0003  * All Rights Reserved.
0004  *
0005  * Permission is hereby granted, free of charge, to any person obtaining
0006  * a copy of this software and associated documentation files (the
0007  * "Software"), to deal in the Software without restriction, including
0008  * without limitation the rights to use, copy, modify, merge, publish,
0009  * distribute, sublicense, and/or sell copies of the Software, and to
0010  * permit persons to whom the Software is furnished to do so, subject to
0011  * the following conditions:
0012  *
0013  * The above copyright notice and this permission notice (including the
0014  * next paragraph) shall be included in all copies or substantial
0015  * portions of the Software.
0016  *
0017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0018  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
0020  * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
0021  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
0022  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
0023  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0024  *
0025  */
0026 #include <subdev/fb/regsnv04.h>
0027 
0028 #define NV04_PFB_DEBUG_0                    0x00100080
0029 #   define NV04_PFB_DEBUG_0_PAGE_MODE           0x00000001
0030 #   define NV04_PFB_DEBUG_0_REFRESH_OFF         0x00000010
0031 #   define NV04_PFB_DEBUG_0_REFRESH_COUNTX64        0x00003f00
0032 #   define NV04_PFB_DEBUG_0_REFRESH_SLOW_CLK        0x00004000
0033 #   define NV04_PFB_DEBUG_0_SAFE_MODE           0x00008000
0034 #   define NV04_PFB_DEBUG_0_ALOM_ENABLE         0x00010000
0035 #   define NV04_PFB_DEBUG_0_CASOE               0x00100000
0036 #   define NV04_PFB_DEBUG_0_CKE_INVERT          0x10000000
0037 #   define NV04_PFB_DEBUG_0_REFINC              0x20000000
0038 #   define NV04_PFB_DEBUG_0_SAVE_POWER_OFF          0x40000000
0039 #define NV04_PFB_CFG0                       0x00100200
0040 #   define NV04_PFB_CFG0_SCRAMBLE               0x20000000
0041 #define NV04_PFB_CFG1                       0x00100204
0042 #define NV04_PFB_SCRAMBLE(i)                         (0x00100400 + 4 * (i))
0043 
0044 #define NV10_PFB_REFCTRL                    0x00100210
0045 #   define NV10_PFB_REFCTRL_VALID_1             (1 << 31)
0046 
0047 static inline struct io_mapping *
0048 fbmem_init(struct nvkm_device *dev)
0049 {
0050     return io_mapping_create_wc(dev->func->resource_addr(dev, 1),
0051                     dev->func->resource_size(dev, 1));
0052 }
0053 
0054 static inline void
0055 fbmem_fini(struct io_mapping *fb)
0056 {
0057     io_mapping_free(fb);
0058 }
0059 
0060 static inline u32
0061 fbmem_peek(struct io_mapping *fb, u32 off)
0062 {
0063     u8 __iomem *p = io_mapping_map_atomic_wc(fb, off & PAGE_MASK);
0064     u32 val = ioread32(p + (off & ~PAGE_MASK));
0065     io_mapping_unmap_atomic(p);
0066     return val;
0067 }
0068 
0069 static inline void
0070 fbmem_poke(struct io_mapping *fb, u32 off, u32 val)
0071 {
0072     u8 __iomem *p = io_mapping_map_atomic_wc(fb, off & PAGE_MASK);
0073     iowrite32(val, p + (off & ~PAGE_MASK));
0074     wmb();
0075     io_mapping_unmap_atomic(p);
0076 }
0077 
0078 static inline bool
0079 fbmem_readback(struct io_mapping *fb, u32 off, u32 val)
0080 {
0081     fbmem_poke(fb, off, val);
0082     return val == fbmem_peek(fb, off);
0083 }