rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------* |
| 2 | * Copyright Statement: * |
| 3 | * * |
| 4 | * This software/firmware and related documentation ("MediaTek Software") * |
| 5 | * are protected under international and related jurisdictions'copyright laws * |
| 6 | * as unpublished works. The information contained herein is confidential and * |
| 7 | * proprietary to MediaTek Inc. Without the prior written permission of * |
| 8 | * MediaTek Inc., any reproduction, modification, use or disclosure of * |
| 9 | * MediaTek Software, and information contained herein, in whole or in part, * |
| 10 | * shall be strictly prohibited. * |
| 11 | * MediaTek Inc. Copyright (C) 2010. All rights reserved. * |
| 12 | * * |
| 13 | * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND * |
| 14 | * AGREES TO THE FOLLOWING: * |
| 15 | * * |
| 16 | * 1)Any and all intellectual property rights (including without * |
| 17 | * limitation, patent, copyright, and trade secrets) in and to this * |
| 18 | * Software/firmware and related documentation ("MediaTek Software") shall * |
| 19 | * remain the exclusive property of MediaTek Inc. Any and all intellectual * |
| 20 | * property rights (including without limitation, patent, copyright, and * |
| 21 | * trade secrets) in and to any modifications and derivatives to MediaTek * |
| 22 | * Software, whoever made, shall also remain the exclusive property of * |
| 23 | * MediaTek Inc. Nothing herein shall be construed as any transfer of any * |
| 24 | * title to any intellectual property right in MediaTek Software to Receiver. * |
| 25 | * * |
| 26 | * 2)This MediaTek Software Receiver received from MediaTek Inc. and/or its * |
| 27 | * representatives is provided to Receiver on an "AS IS" basis only. * |
| 28 | * MediaTek Inc. expressly disclaims all warranties, expressed or implied, * |
| 29 | * including but not limited to any implied warranties of merchantability, * |
| 30 | * non-infringement and fitness for a particular purpose and any warranties * |
| 31 | * arising out of course of performance, course of dealing or usage of trade. * |
| 32 | * MediaTek Inc. does not provide any warranty whatsoever with respect to the * |
| 33 | * software of any third party which may be used by, incorporated in, or * |
| 34 | * supplied with the MediaTek Software, and Receiver agrees to look only to * |
| 35 | * such third parties for any warranty claim relating thereto. Receiver * |
| 36 | * expressly acknowledges that it is Receiver's sole responsibility to obtain * |
| 37 | * from any third party all proper licenses contained in or delivered with * |
| 38 | * MediaTek Software. MediaTek is not responsible for any MediaTek Software * |
| 39 | * releases made to Receiver's specifications or to conform to a particular * |
| 40 | * standard or open forum. * |
| 41 | * * |
| 42 | * 3)Receiver further acknowledge that Receiver may, either presently * |
| 43 | * and/or in the future, instruct MediaTek Inc. to assist it in the * |
| 44 | * development and the implementation, in accordance with Receiver's designs, * |
| 45 | * of certain softwares relating to Receiver's product(s) (the "Services"). * |
| 46 | * Except as may be otherwise agreed to in writing, no warranties of any * |
| 47 | * kind, whether express or implied, are given by MediaTek Inc. with respect * |
| 48 | * to the Services provided, and the Services are provided on an "AS IS" * |
| 49 | * basis. Receiver further acknowledges that the Services may contain errors * |
| 50 | * that testing is important and it is solely responsible for fully testing * |
| 51 | * the Services and/or derivatives thereof before they are used, sublicensed * |
| 52 | * or distributed. Should there be any third party action brought against * |
| 53 | * MediaTek Inc. arising out of or relating to the Services, Receiver agree * |
| 54 | * to fully indemnify and hold MediaTek Inc. harmless. If the parties * |
| 55 | * mutually agree to enter into or continue a business relationship or other * |
| 56 | * arrangement, the terms and conditions set forth herein shall remain * |
| 57 | * effective and, unless explicitly stated otherwise, shall prevail in the * |
| 58 | * event of a conflict in the terms in any agreements entered into between * |
| 59 | * the parties. * |
| 60 | * * |
| 61 | * 4)Receiver's sole and exclusive remedy and MediaTek Inc.'s entire and * |
| 62 | * cumulative liability with respect to MediaTek Software released hereunder * |
| 63 | * will be, at MediaTek Inc.'s sole discretion, to replace or revise the * |
| 64 | * MediaTek Software at issue. * |
| 65 | * * |
| 66 | * 5)The transaction contemplated hereunder shall be construed in * |
| 67 | * accordance with the laws of Singapore, excluding its conflict of laws * |
| 68 | * principles. Any disputes, controversies or claims arising thereof and * |
| 69 | * related thereto shall be settled via arbitration in Singapore, under the * |
| 70 | * then current rules of the International Chamber of Commerce (ICC). The * |
| 71 | * arbitration shall be conducted in English. The awards of the arbitration * |
| 72 | * shall be final and binding upon both parties and shall be entered and * |
| 73 | * enforceable in any court of competent jurisdiction. * |
| 74 | *---------------------------------------------------------------------------*/ |
| 75 | /*----------------------------------------------------------------------------- |
| 76 | * |
| 77 | * Description: |
| 78 | * |
| 79 | *---------------------------------------------------------------------------*/ |
| 80 | |
| 81 | #ifndef X_HAL_IO_H |
| 82 | #define X_HAL_IO_H |
| 83 | |
| 84 | |
| 85 | //#include "..\Common\pd_def.h" |
| 86 | #include "dramc_pi_api.h" |
| 87 | //=========================================================================== |
| 88 | |
| 89 | // field access macro----------------------------------------------------------- |
| 90 | |
| 91 | /* field macros */ |
| 92 | #define Fld(wid, shft) (((U32)wid << 16) | (shft << 8)) |
| 93 | #define Fld_wid(fld) ((UINT8)((fld)>>16)) |
| 94 | #define Fld_shft(fld) ((UINT8)((fld)>>8)) |
| 95 | #define Fld_ac(fld) ((UINT8)(fld)) |
| 96 | |
| 97 | /* access method*/ |
| 98 | #define AC_FULLB0 1 |
| 99 | #define AC_FULLB1 2 |
| 100 | #define AC_FULLB2 3 |
| 101 | #define AC_FULLB3 4 |
| 102 | #define AC_FULLW10 5 |
| 103 | #define AC_FULLW21 6 |
| 104 | #define AC_FULLW32 7 |
| 105 | #define AC_FULLDW 8 |
| 106 | #define AC_MSKB0 11 |
| 107 | #define AC_MSKB1 12 |
| 108 | #define AC_MSKB2 13 |
| 109 | #define AC_MSKB3 14 |
| 110 | #define AC_MSKW10 15 |
| 111 | #define AC_MSKW21 16 |
| 112 | #define AC_MSKW32 17 |
| 113 | #define AC_MSKDW 18 |
| 114 | |
| 115 | #define Fld2Msk32(fld) /*lint -save -e504 */ (((U32)0xffffffff>>(32-Fld_wid(fld)))<<Fld_shft(fld)) /*lint -restore */ |
| 116 | #define P_Fld(val,fld) ((sizeof(upk)>1)?Fld2Msk32(fld):(((UINT32)(val)&((1<<Fld_wid(fld))-1))<<Fld_shft(fld))) |
| 117 | |
| 118 | extern void mt_reg_sync_writel(unsigned int v, volatile unsigned int *a); |
| 119 | #if !__ETT__ |
| 120 | #define dsb(option) __asm__ __volatile__ ("dsb sy" #option : : : "memory") |
| 121 | #else |
| 122 | #include <barriers.h> |
| 123 | #endif |
| 124 | #define mt_reg_sync_write(x,y) mt_reg_sync_writel((y), (volatile unsigned int *)(x)) |
| 125 | |
| 126 | extern U32 u4Dram_Register_Read(DRAMC_CTX_T *p, unsigned long u4reg_addr); |
| 127 | extern U8 ucDram_Register_Write(DRAMC_CTX_T *p, unsigned long u4reg_addr, U32 u4reg_value); |
| 128 | |
| 129 | extern void vIO32Write4BMsk2(DRAMC_CTX_T *p, unsigned long reg32, U32 val32, U32 msk32); |
| 130 | extern void vIO32Write4BMsk_All2(DRAMC_CTX_T *p, unsigned long reg32, U32 val32, U32 msk32); |
| 131 | extern void vIO32Write4B_All2(DRAMC_CTX_T *p, unsigned long reg32, U32 val32); |
| 132 | |
| 133 | // ========================= |
| 134 | // public Macro for general use. |
| 135 | //========================== |
| 136 | #define u4IO32Read4B(reg32) u4Dram_Register_Read(p,reg32) |
| 137 | #define vIO32Write4B(reg32,val32) ucDram_Register_Write(p,reg32,val32) |
| 138 | #define vIO32Write4B_All(reg32, val32) vIO32Write4B_All2(p, reg32, val32) |
| 139 | #define vIO32Write4BMsk(reg32, val32, msk32) vIO32Write4BMsk2(p, reg32, val32, msk32) |
| 140 | #define vIO32Write4BMsk_All(reg32, val32, msk32) vIO32Write4BMsk_All2(p, reg32, val32, msk32) |
| 141 | |
| 142 | #if SW_CHANGE_FOR_SIMULATION |
| 143 | extern U32 u4IO32ReadFldAlign2(DRAMC_CTX_T *p, U32 reg32, U32 fld); |
| 144 | extern void vIO32WriteFldAlign2(DRAMC_CTX_T *p, U32 reg32, U32 val, U32 fld); |
| 145 | extern void vIO32WriteFldAlign_All2(DRAMC_CTX_T *p, U32 reg32, U32 val, U32 fld); |
| 146 | #define u4IO32ReadFldAlign(reg32, fld) u4IO32ReadFldAlign2(p, reg32, fld) |
| 147 | #define vIO32WriteFldAlign(reg32, val, fld) vIO32WriteFldAlign2(p, reg32, val, fld) |
| 148 | #define vIO32WriteFldAlign_All(reg32, val, fld) vIO32WriteFldAlign_All2(p, reg32, val, fld) |
| 149 | |
| 150 | #define vIO32WriteFldMulti(reg32,list) /*lint -save -e506 -e504 -e514 -e62 -e737 -e572 -e961 -e648 -e701 -e732 -e571 */ \ |
| 151 | { \ |
| 152 | UINT16 upk; \ |
| 153 | INT32 msk=(INT32)(list); \ |
| 154 | {UINT8 upk; \ |
| 155 | if ((U32)msk==0xffffffff) \ |
| 156 | (vIO32Write4B(reg32,(list))); \ |
| 157 | else if((U32)msk) \ |
| 158 | vIO32Write4BMsk(reg32,(list),((U32)msk)); \ |
| 159 | } \ |
| 160 | }/*lint -restore */ |
| 161 | |
| 162 | #define vIO32WriteFldMulti_All(reg32,list) /*lint -save -e506 -e504 -e514 -e62 -e737 -e572 -e961 -e648 -e701 -e732 -e571 */ \ |
| 163 | { \ |
| 164 | UINT16 upk; \ |
| 165 | INT32 msk=(INT32)(list); \ |
| 166 | {UINT8 upk; \ |
| 167 | if ((U32)msk==0xffffffff) \ |
| 168 | (vIO32Write4B_All(reg32,(list))); \ |
| 169 | else if((U32)msk) \ |
| 170 | vIO32Write4BMsk_All(reg32,(list),((U32)msk)); \ |
| 171 | } \ |
| 172 | }/*lint -restore */ |
| 173 | |
| 174 | #else |
| 175 | |
| 176 | #define u4IO32ReadFldAlign(reg32,fld) /*lint -save -e506 -e504 -e514 -e62 -e737 -e572 -e961 -e648 -e701 -e732 -e571 */ \ |
| 177 | ((Fld_ac(fld)==AC_FULLDW)? u4IO32Read4B(reg32):((u4IO32Read4B(reg32)&Fld2Msk32(fld))>>Fld_shft(fld)) ) |
| 178 | |
| 179 | #define vIO32WriteFldAlign(reg32,val,fld) /*lint -save -e506 -e504 -e514 -e62 -e737 -e572 -e961 -e648 -e701 -e732 -e571 */ \ |
| 180 | ((Fld_ac(fld)==AC_FULLDW)?(vIO32Write4B((reg32),(val))) : (vIO32Write4BMsk((reg32),((U32)(val)<<Fld_shft(fld)),Fld2Msk32(fld))) ) |
| 181 | |
| 182 | #define vIO32WriteFldMulti(reg32,list) /*lint -save -e506 -e504 -e514 -e62 -e737 -e572 -e961 -e648 -e701 -e732 -e571 */ \ |
| 183 | { \ |
| 184 | UINT16 upk; \ |
| 185 | INT32 msk=(INT32)(list); \ |
| 186 | {UINT8 upk; \ |
| 187 | ((U32)msk==0xffffffff)?(vIO32Write4B(reg32,(list))):(((U32)msk)?vIO32Write4BMsk(reg32,(list),((U32)msk)):0); \ |
| 188 | } \ |
| 189 | }/*lint -restore */ |
| 190 | |
| 191 | //========================= |
| 192 | // Public Macro for write all-dramC or all-PHY registers |
| 193 | //========================= |
| 194 | #define vIO32WriteFldAlign_All(reg32,val,fld) /*lint -save -e506 -e504 -e514 -e62 -e737 -e572 -e961 -e648 -e701 -e732 -e571 */ \ |
| 195 | ((Fld_ac(fld)==AC_FULLDW)?(vIO32Write4B_All((reg32),(val))) : (vIO32Write4BMsk_All((reg32),((U32)(val)<<Fld_shft(fld)),Fld2Msk32(fld))) ) |
| 196 | |
| 197 | #define vIO32WriteFldMulti_All(reg32,list) /*lint -save -e506 -e504 -e514 -e62 -e737 -e572 -e961 -e648 -e701 -e732 -e571 */ \ |
| 198 | { \ |
| 199 | UINT16 upk; \ |
| 200 | INT32 msk=(INT32)(list); \ |
| 201 | {UINT8 upk; \ |
| 202 | ((U32)msk==0xffffffff)?(vIO32Write4B_All(reg32,(list))):(((U32)msk)?vIO32Write4BMsk_All(reg32,(list),((U32)msk)):0); \ |
| 203 | } \ |
| 204 | }/*lint -restore */ |
| 205 | #endif |
| 206 | |
| 207 | #define REG_ACCESS_NAO_DGB 0 |
| 208 | #define REG_ACCESS_PORTING_DGB 0 |
| 209 | #define REG_SHUFFLE_REG_CHECK 0 |
| 210 | |
| 211 | |
| 212 | #endif // X_HAL_IO_H |