0001
0002
0003
0004
0005
0006 #ifndef __I915_REG_DEFS__
0007 #define __I915_REG_DEFS__
0008
0009 #include <linux/bitfield.h>
0010 #include <linux/bits.h>
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #define REG_BIT(__n) \
0021 ((u32)(BIT(__n) + \
0022 BUILD_BUG_ON_ZERO(__is_constexpr(__n) && \
0023 ((__n) < 0 || (__n) > 31))))
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #define REG_GENMASK(__high, __low) \
0035 ((u32)(GENMASK(__high, __low) + \
0036 BUILD_BUG_ON_ZERO(__is_constexpr(__high) && \
0037 __is_constexpr(__low) && \
0038 ((__low) < 0 || (__high) > 31 || (__low) > (__high)))))
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 #define REG_GENMASK64(__high, __low) \
0050 ((u64)(GENMASK_ULL(__high, __low) + \
0051 BUILD_BUG_ON_ZERO(__is_constexpr(__high) && \
0052 __is_constexpr(__low) && \
0053 ((__low) < 0 || (__high) > 63 || (__low) > (__high)))))
0054
0055
0056
0057
0058 #define IS_POWER_OF_2(__x) ((__x) && (((__x) & ((__x) - 1)) == 0))
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 #define REG_FIELD_PREP(__mask, __val) \
0071 ((u32)((((typeof(__mask))(__val) << __bf_shf(__mask)) & (__mask)) + \
0072 BUILD_BUG_ON_ZERO(!__is_constexpr(__mask)) + \
0073 BUILD_BUG_ON_ZERO((__mask) == 0 || (__mask) > U32_MAX) + \
0074 BUILD_BUG_ON_ZERO(!IS_POWER_OF_2((__mask) + (1ULL << __bf_shf(__mask)))) + \
0075 BUILD_BUG_ON_ZERO(__builtin_choose_expr(__is_constexpr(__val), (~((__mask) >> __bf_shf(__mask)) & (__val)), 0))))
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087 #define REG_FIELD_GET(__mask, __val) ((u32)FIELD_GET(__mask, __val))
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 #define REG_FIELD_GET64(__mask, __val) ((u64)FIELD_GET(__mask, __val))
0100
0101 typedef struct {
0102 u32 reg;
0103 } i915_reg_t;
0104
0105 #define _MMIO(r) ((const i915_reg_t){ .reg = (r) })
0106
0107 #define INVALID_MMIO_REG _MMIO(0)
0108
0109 static __always_inline u32 i915_mmio_reg_offset(i915_reg_t reg)
0110 {
0111 return reg.reg;
0112 }
0113
0114 static inline bool i915_mmio_reg_equal(i915_reg_t a, i915_reg_t b)
0115 {
0116 return i915_mmio_reg_offset(a) == i915_mmio_reg_offset(b);
0117 }
0118
0119 static inline bool i915_mmio_reg_valid(i915_reg_t reg)
0120 {
0121 return !i915_mmio_reg_equal(reg, INVALID_MMIO_REG);
0122 }
0123
0124 #define VLV_DISPLAY_BASE 0x180000
0125
0126 #endif