Home | History | Annotate | Download | only in hwdefs
      1 /*
      2  * Copyright (c) 2011 Intel Corporation. All Rights Reserved.
      3  * Copyright (c) Imagination Technologies Limited, UK
      4  *
      5  * Permission is hereby granted, free of charge, to any person obtaining a
      6  * copy of this software and associated documentation files (the
      7  * "Software"), to deal in the Software without restriction, including
      8  * without limitation the rights to use, copy, modify, merge, publish,
      9  * distribute, sub license, and/or sell copies of the Software, and to
     10  * permit persons to whom the Software is furnished to do so, subject to
     11  * the following conditions:
     12  *
     13  * The above copyright notice and this permission notice (including the
     14  * next paragraph) shall be included in all copies or substantial portions
     15  * of the Software.
     16  *
     17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
     20  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
     21  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
     22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
     23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     24  */
     25 
     26 
     27 /******************************************************************************
     28 
     29  @File         reg_io2.h
     30 
     31  @Title        MSVDX Offsets
     32 
     33  @Platform     Independent
     34 
     35  @Description  </b>\n
     36 
     37 ******************************************************************************/
     38 #if !defined (__REG_IO2_H__)
     39 #define __REG_IO2_H__
     40 
     41 #if (__cplusplus)
     42 extern "C" {
     43 #endif
     44 
     45 #include "img_types.h"
     46 
     47 #ifdef DOXYGEN_WILL_SEE_THIS
     48     /*!
     49     ******************************************************************************
     50 
     51      @Function  REGIO_READ_FIELD
     52 
     53      @Description
     54 
     55      This macro is used to extract a field from a register.
     56 
     57      @Input             ui32RegValue:           The register value.
     58 
     59      @Input             group:          The name of the group containing the register from which
     60                                                 the field is to be extracted.
     61 
     62      @Input             reg:            The name of the register from which the field is to
     63                                                 be extracted.
     64 
     65      @Input             field:          The name of the field to be extracted.
     66 
     67      @Return    IMG_UINT32:     The value of the field - right aligned.
     68 
     69     ******************************************************************************/
     70     IMG_UINT32 REGIO_READ_FIELD(IMG_UINT32      ui32RegValue, group, reg, field);
     71 
     72     /*!
     73     ******************************************************************************
     74 
     75      @Function  REGIO_READ_REPEATED_FIELD
     76 
     77      @Description
     78 
     79      This macro is used to extract the value of a repeated from a register.
     80 
     81      @Input             ui32RegValue:           The register value.
     82 
     83      @Input             group:          The name of the group containing the register from which
     84                                                 the field is to be extracted.
     85 
     86      @Input             reg:            The name of the register from which the field is to
     87                                                 be extracted.
     88 
     89      @Input             field:          The name of the field to be extracted.
     90 
     91      @Input             ui32RepIndex:           The repeat index of the field to be extracted.
     92 
     93      @Return    IMG_UINT32:     The value of the field - right aligned.
     94 
     95     ******************************************************************************/
     96     IMG_UINT32 REGIO_READ_REPEATED_FIELD(IMG_UINT32     ui32RegValue, group, reg, field, IMG_UINT32 ui32RepIndex);
     97 
     98     /*!
     99     ******************************************************************************
    100 
    101      @Function  REGIO_READ_REGISTER
    102 
    103      @Description
    104 
    105      This macro is used to read a register.
    106 
    107      @Input             ui32DevId:              The device Id within the group.
    108 
    109      @Input             group:          The name of the group containing the register to be
    110                                                 read.
    111 
    112      @Input             reg:            The name of the register to be read.
    113 
    114      @Return    IMG_UINT32:     The value of the register.
    115 
    116     ******************************************************************************/
    117     IMG_UINT32 REGIO_READ_REGISTER(IMG_UINT32   ui32DevId, group, reg);
    118 
    119     /*!
    120     ******************************************************************************
    121 
    122      @Function  REGIO_READ_TABLE_REGISTER
    123 
    124      @Description
    125 
    126      This macro is used to read a register from a table.
    127 
    128      @Input             ui32DevId:              The device Id within the group.
    129 
    130      @Input             group:          The name of the group containing the register to be
    131                                                 read.
    132 
    133      @Input             reg:            The name of the register to be read.
    134 
    135      @Input             ui32TabIndex:   The index of the table entry to be read.
    136 
    137      @Return    IMG_UINT32:     The value of the register.
    138 
    139     ******************************************************************************/
    140     IMG_UINT32 REGIO_READ_TABLE_REGISTER(IMG_UINT32     ui32DevId, group, reg, IMG_UINT32 ui32TabIndex);
    141 
    142     /*!
    143     ******************************************************************************
    144 
    145      @Function  REGIO_WRITE_FIELD
    146 
    147      @Description
    148 
    149      This macro is used to update the value of a field in a register.
    150 
    151      @Input             ui32RegValue:   The register value - which gets updated.
    152 
    153      @Input             group:          The name of the group containing the register into which
    154                                                 the field is to be written.
    155 
    156      @Input             reg:            The name of the register into which the field is to
    157                                                 be written.
    158 
    159      @Input             field:          The name of the field to be updated.
    160 
    161      @Input             ui32Value:      The value to be written to the field - right aligned.
    162 
    163      @Return    None.
    164 
    165     ******************************************************************************/
    166     IMG_VOID REGIO_WRITE_FIELD(IMG_UINT32       ui32RegValue, group, reg, field, IMG_UINT32     ui32Value);
    167 
    168     /*!
    169     ******************************************************************************
    170 
    171      @Function  REGIO_WRITE_REPEATED_FIELD
    172 
    173      @Description
    174 
    175      This macro is used to update a repeated field in a packed memory
    176      based structure.
    177 
    178      @Input             ui32RegValue:   The register value - which gets updated.
    179 
    180      @Input             group:          The name of the group containing the register into which
    181                                                 the field is to be written.
    182 
    183      @Input             reg:            The name of the register into which the field is to
    184                                                 be written.
    185 
    186      @Input             field:          The name of the field to be updated.
    187 
    188      @Input             ui32Value:      The value to be written to the field - right aligned.
    189 
    190      @Return    None.
    191 
    192     ******************************************************************************/
    193     IMG_VOID REGIO_WRITE_REPEATED_FIELD(IMG_UINT32      ui32RegValue, group, reg, field, IMG_UINT32 ui32RepIndex, IMG_UINT32    ui32Value);
    194 
    195 
    196     /*!
    197     ******************************************************************************
    198 
    199      @Function  REGIO_WRITE_REGISTER
    200 
    201      @Description
    202 
    203      This macro is used to write a register.
    204 
    205      @Input             ui32DevId:              The device Id within the group.
    206 
    207      @Input             group:          The name of the group containing the register to be
    208                                                 written.
    209 
    210      @Input             reg:            The name of the register to be written.
    211 
    212      @Input             ui32RegValue:   The value to be written to the register.
    213 
    214      @Return    None.
    215 
    216     ******************************************************************************/
    217     IMG_VOID REGIO_WRITE_REGISTER(IMG_UINT32    ui32DevId, group, reg, IMG_UINT32 ui32RegValue);
    218 
    219     /*!
    220     ******************************************************************************
    221 
    222      @Function  REGIO_WRITE_TABLE_REGISTER
    223 
    224      @Description
    225 
    226      This macro is used to wrirte a register in a table.
    227 
    228      @Input             ui32DevId:              The device Id within the group.
    229 
    230      @Input             group:          The name of the group containing the register to be
    231                                                 written.
    232 
    233      @Input             reg:            The name of the register to be written.
    234 
    235      @Input             ui32TabIndex:   The index of the table entry to be written.
    236 
    237      @Input             ui32RegValue:   The value to be written to the register.
    238 
    239      @Return    None.
    240 
    241     ******************************************************************************/
    242     IMG_VOID REGIO_WRITE_TABLE_REGISTER(IMG_UINT32      ui32DevId, group, reg, IMG_UINT32 ui32TabIndex, IMG_UINT32 ui32RegValue);
    243 
    244     /*!
    245     ******************************************************************************
    246 
    247      @Function  REGIO_WRITE_OFFSET_REGISTER
    248 
    249      @Description
    250 
    251      This macro is used to write a register at an offset from a given register.
    252 
    253      @Input             ui32DevId:              The device Id within the group.
    254 
    255      @Input             group:          The name of the group containing the register to be
    256                                                 written.
    257 
    258      @Input             reg:            The name of the base register to be written.
    259 
    260      @Input             ui32Offset:     The offset (eg. 0,1,2,...) of the register to be written.
    261 
    262      @Input             ui32RegValue:   The value to be written to the register.
    263 
    264      @Return    None.
    265 
    266     ******************************************************************************/
    267     IMG_VOID REGIO_WRITE_TABLE_REGISTER(IMG_UINT32      ui32DevId, group, reg, IMG_UINT32 ui32Offset, IMG_UINT32 ui32RegValue);
    268 
    269 #else
    270 
    271     /*!
    272     ******************************************************************************
    273 
    274      @Function  REGIO_READ_FIELD
    275 
    276     ******************************************************************************/
    277 #if 1
    278 #define REGIO_READ_FIELD(ui32RegValue, group, reg, field)                                                       \
    279         ((ui32RegValue & group##_##reg##_##field##_MASK) >> group##_##reg##_##field##_SHIFT)
    280 
    281 #else
    282 
    283 #define REGIO_READ_FIELD(ui32RegValue, group, reg, field)                                                       \
    284         ((ui32RegValue >> group##_##reg##_##field##_SHIFT) & group##_##reg##_##field##_LSBMASK)
    285 
    286 #endif
    287 
    288     /*!
    289     ******************************************************************************
    290 
    291      @Function  REGIO_READ_REPEATED_FIELD
    292 
    293     ******************************************************************************/
    294 #define REGIO_READ_REPEATED_FIELD(ui32RegValue, group, reg, field, ui32RepIndex)                                                                                                                                                                                                        \
    295         ( IMG_ASSERT(ui32RepIndex < group##_##reg##_##field##_NO_REPS),                                                                                                                                                                                                                                                                 \
    296         ((ui32RegValue & (group##_##reg##_##field##_MASK >> (ui32RepIndex * group##_##reg##_##field##_SIZE)))   \
    297         >> (group##_##reg##_##field##_SHIFT - (ui32RepIndex * group##_##reg##_##field##_SIZE))) )
    298 
    299     /*!
    300     ******************************************************************************
    301 
    302      @Function  REGIO_READ_REGISTER
    303 
    304     ******************************************************************************/
    305 #define REGIO_READ_REGISTER(ui32DevId, group, reg)                      \
    306         group##_ReadRegister(ui32DevId, group##_##reg##_OFFSET)
    307 
    308     /*!
    309     ******************************************************************************
    310 
    311      @Function  REGIO_READ_TABLE_REGISTER
    312 
    313      ******************************************************************************/
    314 #define REGIO_READ_TABLE_REGISTER(ui32DevId, group, reg, ui32TabIndex)  \
    315         ( IMG_ASSERT(ui32TabIndex < group##_##reg##_NO_ENTRIES),                                \
    316           group##_ReadRegister(ui32DevId, (group##_##reg##_OFFSET+(ui32TabIndex*group##_##reg##_STRIDE))) )
    317 
    318     /*!
    319     ******************************************************************************
    320 
    321      @Function  REGIO_WRITE_FIELD
    322 
    323     ******************************************************************************/
    324 #define REGIO_WRITE_FIELD(ui32RegValue, group, reg, field, ui32Value)                                       \
    325         (ui32RegValue) =                                                                                                                                                \
    326         ((ui32RegValue) & ~(group##_##reg##_##field##_MASK)) |                                                                  \
    327                 (((ui32Value) << (group##_##reg##_##field##_SHIFT)) & (group##_##reg##_##field##_MASK));
    328 
    329 #ifndef DEBUG
    330 #define REGIO_ASSERT( x ) ((void)0)
    331 #else
    332 #define REGIO_ASSERT( x ) IMG_ASSERT( x )
    333 #endif
    334 
    335 #define REGIO_WRITE_FIELD_MASKEDLITE(ui32RegValue, group, reg, field, ui32Value)                                                                                        \
    336         do {    \
    337                 REGIO_ASSERT( ((ui32RegValue) & (group##_##reg##_##field##_MASK) ) == 0 );                                                                                      \
    338                 (ui32RegValue) |= (((ui32Value) << (group##_##reg##_##field##_SHIFT)) & (group##_##reg##_##field##_MASK));                      \
    339         } while(0)
    340 
    341 #define REGIO_WRITE_FIELD_LITE(ui32RegValue, group, reg, field, ui32Value)                                                                                              \
    342         do { \
    343                 REGIO_ASSERT( ((ui32RegValue) & (group##_##reg##_##field##_MASK) ) == 0 );                                                                                      \
    344                 REGIO_ASSERT( ( ( (ui32Value) << (group##_##reg##_##field##_SHIFT) ) & (~(group##_##reg##_##field##_MASK))) == 0);      \
    345                 (ui32RegValue) |=  ( (ui32Value) << (group##_##reg##_##field##_SHIFT) ) ;       \
    346         } while(0)
    347 
    348     /*!
    349     ******************************************************************************
    350 
    351      @Function  REGIO_WRITE_REPEATED_FIELD
    352 
    353     ******************************************************************************/
    354 #define REGIO_WRITE_REPEATED_FIELD(ui32RegValue, group, reg, field, ui32RepIndex, ui32Value)                                                                                            \
    355         IMG_ASSERT(ui32RepIndex < group##_##reg##_##field##_NO_REPS);                                                                                                                                                           \
    356         ui32RegValue =                                                                                                                                                                                                                                                  \
    357         (ui32RegValue & ~(group##_##reg##_##field##_MASK >> (ui32RepIndex * group##_##reg##_##field##_SIZE))) |         \
    358                 (ui32Value << (group##_##reg##_##field##_SHIFT - (ui32RepIndex * group##_##reg##_##field##_SIZE)) & (group##_##reg##_##field##_MASK >> (ui32RepIndex * group##_##reg##_##field##_SIZE)));
    359 
    360     /*!
    361     ******************************************************************************
    362 
    363      @Function  REGIO_WRITE_REGISTER
    364 
    365     ******************************************************************************/
    366 #define REGIO_WRITE_REGISTER(ui32DevId, group, reg, ui32RegValue)       \
    367         group##_WriteRegister(ui32DevId, (group##_##reg##_OFFSET), (ui32RegValue))
    368 
    369     /*!
    370     ******************************************************************************
    371 
    372      @Function  REGIO_WRITE_TABLE_REGISTER
    373 
    374     ******************************************************************************/
    375 #define REGIO_WRITE_TABLE_REGISTER(ui32DevId, group, reg, ui32TabIndex, ui32RegValue)           \
    376                 group##_WriteRegister(ui32DevId, (group##_##reg##_OFFSET+(ui32TabIndex*group##_##reg##_STRIDE)), ui32RegValue)
    377 
    378 
    379     /*!
    380     ******************************************************************************
    381 
    382      @Function  REGIO_WRITE_OFFSET_REGISTER
    383 
    384     ******************************************************************************/
    385 #define REGIO_WRITE_OFFSET_REGISTER(ui32DevId, group, reg, ui32Offset, ui32RegValue)            \
    386           group##_WriteRegister(ui32DevId, (group##_##reg##_OFFSET+(ui32Offset*4)), ui32RegValue)
    387 
    388 
    389 #endif
    390 
    391 
    392 #if (__cplusplus)
    393 }
    394 #endif
    395 
    396 #endif
    397 
    398