19952f691SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2ac1bdbf2SThierry Reding /* 3ac1bdbf2SThierry Reding * Copyright (c) 2018 NVIDIA Corporation. 4ac1bdbf2SThierry Reding */ 5ac1bdbf2SThierry Reding 6ac1bdbf2SThierry Reding /* 7ac1bdbf2SThierry Reding * Function naming determines intended use: 8ac1bdbf2SThierry Reding * 9ac1bdbf2SThierry Reding * <x>_r(void) : Returns the offset for register <x>. 10ac1bdbf2SThierry Reding * 11ac1bdbf2SThierry Reding * <x>_w(void) : Returns the word offset for word (4 byte) element <x>. 12ac1bdbf2SThierry Reding * 13ac1bdbf2SThierry Reding * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits. 14ac1bdbf2SThierry Reding * 15ac1bdbf2SThierry Reding * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted 16ac1bdbf2SThierry Reding * and masked to place it at field <y> of register <x>. This value 17ac1bdbf2SThierry Reding * can be |'d with others to produce a full register value for 18ac1bdbf2SThierry Reding * register <x>. 19ac1bdbf2SThierry Reding * 20ac1bdbf2SThierry Reding * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This 21ac1bdbf2SThierry Reding * value can be ~'d and then &'d to clear the value of field <y> for 22ac1bdbf2SThierry Reding * register <x>. 23ac1bdbf2SThierry Reding * 24ac1bdbf2SThierry Reding * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted 25ac1bdbf2SThierry Reding * to place it at field <y> of register <x>. This value can be |'d 26ac1bdbf2SThierry Reding * with others to produce a full register value for <x>. 27ac1bdbf2SThierry Reding * 28ac1bdbf2SThierry Reding * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register 29ac1bdbf2SThierry Reding * <x> value 'r' after being shifted to place its LSB at bit 0. 30ac1bdbf2SThierry Reding * This value is suitable for direct comparison with other unshifted 31ac1bdbf2SThierry Reding * values appropriate for use in field <y> of register <x>. 32ac1bdbf2SThierry Reding * 33ac1bdbf2SThierry Reding * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for 34ac1bdbf2SThierry Reding * field <y> of register <x>. This value is suitable for direct 35ac1bdbf2SThierry Reding * comparison with unshifted values appropriate for use in field <y> 36ac1bdbf2SThierry Reding * of register <x>. 37ac1bdbf2SThierry Reding */ 38ac1bdbf2SThierry Reding 39ac1bdbf2SThierry Reding #ifndef HOST1X_HW_HOST1X07_UCLASS_H 40ac1bdbf2SThierry Reding #define HOST1X_HW_HOST1X07_UCLASS_H 41ac1bdbf2SThierry Reding host1x_uclass_incr_syncpt_r(void)42ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_incr_syncpt_r(void) 43ac1bdbf2SThierry Reding { 44ac1bdbf2SThierry Reding return 0x0; 45ac1bdbf2SThierry Reding } 46ac1bdbf2SThierry Reding #define HOST1X_UCLASS_INCR_SYNCPT \ 47ac1bdbf2SThierry Reding host1x_uclass_incr_syncpt_r() host1x_uclass_incr_syncpt_cond_f(u32 v)48ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_incr_syncpt_cond_f(u32 v) 49ac1bdbf2SThierry Reding { 50ac1bdbf2SThierry Reding return (v & 0xff) << 10; 51ac1bdbf2SThierry Reding } 52ac1bdbf2SThierry Reding #define HOST1X_UCLASS_INCR_SYNCPT_COND_F(v) \ 53ac1bdbf2SThierry Reding host1x_uclass_incr_syncpt_cond_f(v) host1x_uclass_incr_syncpt_indx_f(u32 v)54ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_incr_syncpt_indx_f(u32 v) 55ac1bdbf2SThierry Reding { 56*79aad29cSMikko Perttunen return (v & 0x3ff) << 0; 57ac1bdbf2SThierry Reding } 58ac1bdbf2SThierry Reding #define HOST1X_UCLASS_INCR_SYNCPT_INDX_F(v) \ 59ac1bdbf2SThierry Reding host1x_uclass_incr_syncpt_indx_f(v) host1x_uclass_wait_syncpt_r(void)60ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_wait_syncpt_r(void) 61ac1bdbf2SThierry Reding { 62ac1bdbf2SThierry Reding return 0x8; 63ac1bdbf2SThierry Reding } 64ac1bdbf2SThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT \ 65ac1bdbf2SThierry Reding host1x_uclass_wait_syncpt_r() host1x_uclass_wait_syncpt_indx_f(u32 v)66ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_wait_syncpt_indx_f(u32 v) 67ac1bdbf2SThierry Reding { 68ac1bdbf2SThierry Reding return (v & 0xff) << 24; 69ac1bdbf2SThierry Reding } 70ac1bdbf2SThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT_INDX_F(v) \ 71ac1bdbf2SThierry Reding host1x_uclass_wait_syncpt_indx_f(v) host1x_uclass_wait_syncpt_thresh_f(u32 v)72ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_wait_syncpt_thresh_f(u32 v) 73ac1bdbf2SThierry Reding { 74ac1bdbf2SThierry Reding return (v & 0xffffff) << 0; 75ac1bdbf2SThierry Reding } 76ac1bdbf2SThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT_THRESH_F(v) \ 77ac1bdbf2SThierry Reding host1x_uclass_wait_syncpt_thresh_f(v) host1x_uclass_wait_syncpt_base_r(void)78ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_wait_syncpt_base_r(void) 79ac1bdbf2SThierry Reding { 80ac1bdbf2SThierry Reding return 0x9; 81ac1bdbf2SThierry Reding } 82ac1bdbf2SThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT_BASE \ 83ac1bdbf2SThierry Reding host1x_uclass_wait_syncpt_base_r() host1x_uclass_wait_syncpt_base_indx_f(u32 v)84ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_wait_syncpt_base_indx_f(u32 v) 85ac1bdbf2SThierry Reding { 86ac1bdbf2SThierry Reding return (v & 0xff) << 24; 87ac1bdbf2SThierry Reding } 88ac1bdbf2SThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT_BASE_INDX_F(v) \ 89ac1bdbf2SThierry Reding host1x_uclass_wait_syncpt_base_indx_f(v) host1x_uclass_wait_syncpt_base_base_indx_f(u32 v)90ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_wait_syncpt_base_base_indx_f(u32 v) 91ac1bdbf2SThierry Reding { 92ac1bdbf2SThierry Reding return (v & 0xff) << 16; 93ac1bdbf2SThierry Reding } 94ac1bdbf2SThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT_BASE_BASE_INDX_F(v) \ 95ac1bdbf2SThierry Reding host1x_uclass_wait_syncpt_base_base_indx_f(v) host1x_uclass_wait_syncpt_base_offset_f(u32 v)96ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_wait_syncpt_base_offset_f(u32 v) 97ac1bdbf2SThierry Reding { 98ac1bdbf2SThierry Reding return (v & 0xffff) << 0; 99ac1bdbf2SThierry Reding } 100ac1bdbf2SThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT_BASE_OFFSET_F(v) \ 101ac1bdbf2SThierry Reding host1x_uclass_wait_syncpt_base_offset_f(v) host1x_uclass_load_syncpt_base_r(void)102ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_load_syncpt_base_r(void) 103ac1bdbf2SThierry Reding { 104ac1bdbf2SThierry Reding return 0xb; 105ac1bdbf2SThierry Reding } 106ac1bdbf2SThierry Reding #define HOST1X_UCLASS_LOAD_SYNCPT_BASE \ 107ac1bdbf2SThierry Reding host1x_uclass_load_syncpt_base_r() host1x_uclass_load_syncpt_base_base_indx_f(u32 v)108ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_load_syncpt_base_base_indx_f(u32 v) 109ac1bdbf2SThierry Reding { 110ac1bdbf2SThierry Reding return (v & 0xff) << 24; 111ac1bdbf2SThierry Reding } 112ac1bdbf2SThierry Reding #define HOST1X_UCLASS_LOAD_SYNCPT_BASE_BASE_INDX_F(v) \ 113ac1bdbf2SThierry Reding host1x_uclass_load_syncpt_base_base_indx_f(v) host1x_uclass_load_syncpt_base_value_f(u32 v)114ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_load_syncpt_base_value_f(u32 v) 115ac1bdbf2SThierry Reding { 116ac1bdbf2SThierry Reding return (v & 0xffffff) << 0; 117ac1bdbf2SThierry Reding } 118ac1bdbf2SThierry Reding #define HOST1X_UCLASS_LOAD_SYNCPT_BASE_VALUE_F(v) \ 119ac1bdbf2SThierry Reding host1x_uclass_load_syncpt_base_value_f(v) host1x_uclass_incr_syncpt_base_base_indx_f(u32 v)120ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_incr_syncpt_base_base_indx_f(u32 v) 121ac1bdbf2SThierry Reding { 122ac1bdbf2SThierry Reding return (v & 0xff) << 24; 123ac1bdbf2SThierry Reding } 124ac1bdbf2SThierry Reding #define HOST1X_UCLASS_INCR_SYNCPT_BASE_BASE_INDX_F(v) \ 125ac1bdbf2SThierry Reding host1x_uclass_incr_syncpt_base_base_indx_f(v) host1x_uclass_incr_syncpt_base_offset_f(u32 v)126ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_incr_syncpt_base_offset_f(u32 v) 127ac1bdbf2SThierry Reding { 128ac1bdbf2SThierry Reding return (v & 0xffffff) << 0; 129ac1bdbf2SThierry Reding } 130ac1bdbf2SThierry Reding #define HOST1X_UCLASS_INCR_SYNCPT_BASE_OFFSET_F(v) \ 131ac1bdbf2SThierry Reding host1x_uclass_incr_syncpt_base_offset_f(v) host1x_uclass_indoff_r(void)132ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_indoff_r(void) 133ac1bdbf2SThierry Reding { 134ac1bdbf2SThierry Reding return 0x2d; 135ac1bdbf2SThierry Reding } 136ac1bdbf2SThierry Reding #define HOST1X_UCLASS_INDOFF \ 137ac1bdbf2SThierry Reding host1x_uclass_indoff_r() host1x_uclass_indoff_indbe_f(u32 v)138ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_indoff_indbe_f(u32 v) 139ac1bdbf2SThierry Reding { 140ac1bdbf2SThierry Reding return (v & 0xf) << 28; 141ac1bdbf2SThierry Reding } 142ac1bdbf2SThierry Reding #define HOST1X_UCLASS_INDOFF_INDBE_F(v) \ 143ac1bdbf2SThierry Reding host1x_uclass_indoff_indbe_f(v) host1x_uclass_indoff_autoinc_f(u32 v)144ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_indoff_autoinc_f(u32 v) 145ac1bdbf2SThierry Reding { 146ac1bdbf2SThierry Reding return (v & 0x1) << 27; 147ac1bdbf2SThierry Reding } 148ac1bdbf2SThierry Reding #define HOST1X_UCLASS_INDOFF_AUTOINC_F(v) \ 149ac1bdbf2SThierry Reding host1x_uclass_indoff_autoinc_f(v) host1x_uclass_indoff_indmodid_f(u32 v)150ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_indoff_indmodid_f(u32 v) 151ac1bdbf2SThierry Reding { 152ac1bdbf2SThierry Reding return (v & 0xff) << 18; 153ac1bdbf2SThierry Reding } 154ac1bdbf2SThierry Reding #define HOST1X_UCLASS_INDOFF_INDMODID_F(v) \ 155ac1bdbf2SThierry Reding host1x_uclass_indoff_indmodid_f(v) host1x_uclass_indoff_indroffset_f(u32 v)156ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_indoff_indroffset_f(u32 v) 157ac1bdbf2SThierry Reding { 158ac1bdbf2SThierry Reding return (v & 0xffff) << 2; 159ac1bdbf2SThierry Reding } 160ac1bdbf2SThierry Reding #define HOST1X_UCLASS_INDOFF_INDROFFSET_F(v) \ 161ac1bdbf2SThierry Reding host1x_uclass_indoff_indroffset_f(v) host1x_uclass_indoff_rwn_read_v(void)162ac1bdbf2SThierry Redingstatic inline u32 host1x_uclass_indoff_rwn_read_v(void) 163ac1bdbf2SThierry Reding { 164ac1bdbf2SThierry Reding return 1; 165ac1bdbf2SThierry Reding } 166ac1bdbf2SThierry Reding #define HOST1X_UCLASS_INDOFF_INDROFFSET_F(v) \ 167ac1bdbf2SThierry Reding host1x_uclass_indoff_indroffset_f(v) host1x_uclass_load_syncpt_payload_32_r(void)168e902585fSMikko Perttunenstatic inline u32 host1x_uclass_load_syncpt_payload_32_r(void) 169e902585fSMikko Perttunen { 170e902585fSMikko Perttunen return 0x4e; 171e902585fSMikko Perttunen } 172e902585fSMikko Perttunen #define HOST1X_UCLASS_LOAD_SYNCPT_PAYLOAD_32 \ 173e902585fSMikko Perttunen host1x_uclass_load_syncpt_payload_32_r() host1x_uclass_wait_syncpt_32_r(void)174e902585fSMikko Perttunenstatic inline u32 host1x_uclass_wait_syncpt_32_r(void) 175e902585fSMikko Perttunen { 176e902585fSMikko Perttunen return 0x50; 177e902585fSMikko Perttunen } 178e902585fSMikko Perttunen #define HOST1X_UCLASS_WAIT_SYNCPT_32 \ 179e902585fSMikko Perttunen host1x_uclass_wait_syncpt_32_r() 180ac1bdbf2SThierry Reding 181ac1bdbf2SThierry Reding #endif 182