brintos

brintos / linux-shallow public Read only

0
0
Text · 2.8 KiB · 6c5bbff Raw
84 lines · c
1/*2 * Copyright (C) 2010 Francisco Jerez.3 * All Rights Reserved.4 *5 * Permission is hereby granted, free of charge, to any person obtaining6 * a copy of this software and associated documentation files (the7 * "Software"), to deal in the Software without restriction, including8 * without limitation the rights to use, copy, modify, merge, publish,9 * distribute, sublicense, and/or sell copies of the Software, and to10 * permit persons to whom the Software is furnished to do so, subject to11 * the following conditions:12 *13 * The above copyright notice and this permission notice (including the14 * next paragraph) shall be included in all copies or substantial15 * portions of the Software.16 *17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.20 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24 *25 */26#include <subdev/fb/regsnv04.h>27 28#define NV04_PFB_DEBUG_0					0x0010008029#	define NV04_PFB_DEBUG_0_PAGE_MODE			0x0000000130#	define NV04_PFB_DEBUG_0_REFRESH_OFF			0x0000001031#	define NV04_PFB_DEBUG_0_REFRESH_COUNTX64		0x00003f0032#	define NV04_PFB_DEBUG_0_REFRESH_SLOW_CLK		0x0000400033#	define NV04_PFB_DEBUG_0_SAFE_MODE			0x0000800034#	define NV04_PFB_DEBUG_0_ALOM_ENABLE			0x0001000035#	define NV04_PFB_DEBUG_0_CASOE				0x0010000036#	define NV04_PFB_DEBUG_0_CKE_INVERT			0x1000000037#	define NV04_PFB_DEBUG_0_REFINC				0x2000000038#	define NV04_PFB_DEBUG_0_SAVE_POWER_OFF			0x4000000039#define NV04_PFB_CFG0						0x0010020040#	define NV04_PFB_CFG0_SCRAMBLE				0x2000000041#define NV04_PFB_CFG1						0x0010020442#define NV04_PFB_SCRAMBLE(i)                         (0x00100400 + 4 * (i))43 44#define NV10_PFB_REFCTRL					0x0010021045#	define NV10_PFB_REFCTRL_VALID_1				(1 << 31)46 47static inline struct io_mapping *48fbmem_init(struct nvkm_device *dev)49{50	return io_mapping_create_wc(dev->func->resource_addr(dev, 1),51				    dev->func->resource_size(dev, 1));52}53 54static inline void55fbmem_fini(struct io_mapping *fb)56{57	io_mapping_free(fb);58}59 60static inline u3261fbmem_peek(struct io_mapping *fb, u32 off)62{63	u8 __iomem *p = io_mapping_map_atomic_wc(fb, off & PAGE_MASK);64	u32 val = ioread32(p + (off & ~PAGE_MASK));65	io_mapping_unmap_atomic(p);66	return val;67}68 69static inline void70fbmem_poke(struct io_mapping *fb, u32 off, u32 val)71{72	u8 __iomem *p = io_mapping_map_atomic_wc(fb, off & PAGE_MASK);73	iowrite32(val, p + (off & ~PAGE_MASK));74	wmb();75	io_mapping_unmap_atomic(p);76}77 78static inline bool79fbmem_readback(struct io_mapping *fb, u32 off, u32 val)80{81	fbmem_poke(fb, off, val);82	return val == fbmem_peek(fb, off);83}84