1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 // Software and any modification/derivatives thereof.
18 // No right, ownership, or interest to MStar Software and any
19 // modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 // supplied together with third party`s software and the use of MStar
23 // Software may require additional licenses from third parties.
24 // Therefore, you hereby agree it is your sole responsibility to separately
25 // obtain any and all third party right and license necessary for your use of
26 // such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 // MStar`s confidential information and you agree to keep MStar`s
30 // confidential information in strictest confidence and not disclose to any
31 // third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 // kind. Any warranties are hereby expressly disclaimed by MStar, including
35 // without limitation, any warranties of merchantability, non-infringement of
36 // intellectual property rights, fitness for a particular purpose, error free
37 // and in conformity with any international standard. You agree to waive any
38 // claim against MStar for any loss, damage, cost or expense that you may
39 // incur related to your use of MStar Software.
40 // In no event shall MStar be liable for any direct, indirect, incidental or
41 // consequential damages, including without limitation, lost of profit or
42 // revenues, lost or damage of data, and unauthorized system use.
43 // You agree that this Section 4 shall still apply without being affected
44 // even if MStar Software has been modified by MStar in accordance with your
45 // request or instruction for your use, except otherwise agreed by both
46 // parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 // services in relation with MStar Software to you for your use of
50 // MStar Software in conjunction with your or your customer`s product
51 // ("Services").
52 // You understand and agree that, except otherwise agreed by both parties in
53 // writing, Services are provided on an "AS IS" basis and the warranty
54 // disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 // or otherwise:
58 // (a) conferring any license or right to use MStar name, trademark, service
59 // mark, symbol or any other identification;
60 // (b) obligating MStar or any of its affiliates to furnish any person,
61 // including without limitation, you and your customers, any assistance
62 // of any kind whatsoever, or any information; or
63 // (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 // of Taiwan, R.O.C., excluding its conflict of law rules.
67 // Any and all dispute arising out hereof or related hereto shall be finally
68 // settled by arbitration referred to the Chinese Arbitration Association,
69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 // Rules of the Association by three (3) arbitrators appointed in accordance
71 // with the said Rules.
72 // The place of arbitration shall be in Taipei, Taiwan and the language shall
73 // be English.
74 // The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 // Copyright (c) 2008-2009 MStar Semiconductor, Inc.
81 // All rights reserved.
82 //
83 // Unless otherwise stipulated in writing, any and all information contained
84 // herein regardless in any format shall remain the sole proprietary of
85 // MStar Semiconductor Inc. and be kept in strict confidence
86 // ("MStar Confidential Information") by the recipient.
87 // Any unauthorized act including without limitation unauthorized disclosure,
88 // copying, use, reproduction, sale, distribution, modification, disassembling,
89 // reverse engineering and compiling of the contents of MStar Confidential
90 // Information is unlawful and strictly prohibited. MStar hereby reserves the
91 // rights to any and all damages, losses, costs and expenses resulting therefrom.
92 //
93 ////////////////////////////////////////////////////////////////////////////////
94
95
96 //-------------------------------------------------------------------------------------------------
97 // Include Files
98 //-------------------------------------------------------------------------------------------------
99 #include "MsCommon.h"
100 #include "regCHIP.h"
101 #include "halCHIP.h"
102 #include "halDMD_VD_MBX.h"
103 #include "drvMMIO.h"
104 //-------------------------------------------------------------------------------------------------
105 // Driver Compiler Options
106 //-------------------------------------------------------------------------------------------------
107
108
109 //-------------------------------------------------------------------------------------------------
110 // Local Defines
111 //-------------------------------------------------------------------------------------------------
112 #if defined(MCU_AEON)
113 #define BASEADDR_RIU 0xA0000000UL
114 #elif defined(__arm__) || defined(__aarch64__)
115 #define BASEADDR_RIU 0x1F000000UL
116 #else
117 #define BASEADDR_RIU 0xBF000000UL
118 #endif
119
120 #define RIU_MACRO_START do {
121 #define RIU_MACRO_END } while (0)
122
123 // Address bus of RIU is 16 bits.
124
125 #define RIU_READ_BYTE(addr) (READ_BYTE(_hal_DMD_VD_MBX.u32DMD_VD_MBX_BaseAddr + (addr)))
126 #define RIU_READ_2BYTE(addr) (READ_WORD(_hal_DMD_VD_MBX.u32DMD_VD_MBX_BaseAddr + (addr)))
127 #define RIU_WRITE_BYTE(addr, val) {WRITE_BYTE(_hal_DMD_VD_MBX.u32DMD_VD_MBX_BaseAddr + (addr), val)}
128 #define RIU_WRITE_2BYTE(addr, val) {WRITE_WORD(_hal_DMD_VD_MBX.u32DMD_VD_MBX_BaseAddr + (addr), val)}
129
130 // Standard Form
131
132 #define RIU_ReadByte( u32Reg ) RIU_READ_BYTE(((u32Reg) << 1) - ((u32Reg) & 1))
133
134 #define RIU_Read2Byte( u32Reg ) (RIU_READ_2BYTE((u32Reg) << 1))
135
136 #define RIU_ReadRegBit( u32Reg, u8Mask ) (RIU_READ_BYTE(((u32Reg) << 1) - ((u32Reg) & 1)) & (u8Mask))
137
138 #define RIU_WriteRegBit( u32Reg, bEnable, u8Mask ) \
139 RIU_MACRO_START \
140 RIU_WRITE_BYTE( (((u32Reg) << 1) - ((u32Reg) & 1)) , (bEnable) ? (RIU_READ_BYTE((((u32Reg) << 1) - ((u32Reg) & 1)) ) | (u8Mask)) : \
141 (RIU_READ_BYTE((((u32Reg) <<1) - ((u32Reg) & 1))) & ~(u8Mask))); \
142 RIU_MACRO_END
143
144 #define RIU_WriteByte( u32Reg, u8Val ) \
145 RIU_MACRO_START \
146 RIU_WRITE_BYTE(((u32Reg) << 1) - ((u32Reg) & 1), u8Val); \
147 RIU_MACRO_END
148
149 #define RIU_Write2Byte( u32Reg, u16Val ) \
150 RIU_MACRO_START \
151 if ( ((u32Reg) & 0x01) ) \
152 { \
153 RIU_WRITE_BYTE(((u32Reg) << 1) - 1, (MS_U8)((u16Val))); \
154 RIU_WRITE_BYTE(((u32Reg) + 1) << 1, (MS_U8)((u16Val) >> 8)); \
155 } \
156 else \
157 { \
158 RIU_WRITE_2BYTE( ((u32Reg)<<1) , u16Val); \
159 } \
160 RIU_MACRO_END
161
162 #define RIU_WriteByteMask( u32Reg, u8Val, u8Msk ) \
163 RIU_MACRO_START \
164 RIU_WRITE_BYTE( (((u32Reg) <<1) - ((u32Reg) & 1)), (RIU_READ_BYTE((((u32Reg) <<1) - ((u32Reg) & 1))) & ~(u8Msk)) | ((u8Val) & (u8Msk))); \
165 RIU_MACRO_END
166
167 #define DMD_MBX_TIMEOUT 200
168 //-------------------------------------------------------------------------------------------------
169 // Local Structures
170 //-------------------------------------------------------------------------------------------------
171 typedef struct
172 {
173 MS_PHYADDR u32DMD_VD_MBX_BaseAddr;
174 MS_BOOL bBaseAddrInitialized;
175 MS_U8 u8DMD_VD_MBX_Type;
176 } hal_DMD_VD_MBX_t;
177
178 //-------------------------------------------------------------------------------------------------
179 // Global Variables
180 //-------------------------------------------------------------------------------------------------
181
182 //-------------------------------------------------------------------------------------------------
183 // Local Variables
184 //-------------------------------------------------------------------------------------------------
185 static hal_DMD_VD_MBX_t _hal_DMD_VD_MBX =
186 {
187 .u32DMD_VD_MBX_BaseAddr = BASEADDR_RIU,
188 .bBaseAddrInitialized = 0,
189 .u8DMD_VD_MBX_Type = -1,
190 };
191 static MS_U8 MBX_SetType;
192 //-------------------------------------------------------------------------------------------------
193 // Debug Functions
194 //-------------------------------------------------------------------------------------------------
195
196
197 //-------------------------------------------------------------------------------------------------
198 // Local Functions
199 //-------------------------------------------------------------------------------------------------
200
201 //-------------------------------------------------------------------------------------------------
202 // Global Functions
203 //-------------------------------------------------------------------------------------------------
HAL_SYS_DMD_VD_MBX_Init(void)204 MS_BOOL HAL_SYS_DMD_VD_MBX_Init(void)
205 {
206 MS_VIRT u32NonPMBank;
207 MS_PHY u32NonPMBankSize;
208 if (!MDrv_MMIO_GetBASE( &u32NonPMBank, &u32NonPMBankSize, MS_MODULE_AVD))
209 {
210 printf("IOMap failure to get MAP_NONPM_BANK\n");
211 return FALSE;
212 }
213
214 _hal_DMD_VD_MBX.u32DMD_VD_MBX_BaseAddr=u32NonPMBank;
215 _hal_DMD_VD_MBX.bBaseAddrInitialized = 1;
216 _hal_DMD_VD_MBX.u8DMD_VD_MBX_Type = -1;
217 #ifdef MS_DEBUG
218 printf("HAL_SYS_DMD_VD_MBX_Init %lx\n",u32NonPMBank);
219 #endif
220 return TRUE;
221 }
222
HAL_SYS_DMD_VD_MBX_GetType(void)223 MS_U8 HAL_SYS_DMD_VD_MBX_GetType(void)
224 {
225 #ifdef MS_DEBUG
226 printf("HAL_SYS_DMD_VD_MBX_GetType %d\n",MBX_SetType);
227 #endif
228 //return RIU_ReadByte(0x1E3E);
229 return MBX_SetType;
230 }
231
HAL_SYS_DMD_VD_MBX_SetType(MS_U8 u8Value)232 void HAL_SYS_DMD_VD_MBX_SetType(MS_U8 u8Value)
233 {
234 MBX_SetType = u8Value;
235 //RIU_WriteByte(0x1E3E, u8Value);
236 }
237
238 #if (DMD_VD_MBX_CHIP_VERSION == DMD_VD_MBX_CHIP_T3)
239 // ATV
HAL_SYS_DMD_VD_MBX_ATV_WaitReady(void)240 MS_BOOL HAL_SYS_DMD_VD_MBX_ATV_WaitReady(void)
241 {
242 MS_U32 u32StartTime=MsOS_GetSystemTime();
243 while (MsOS_GetSystemTime()-u32StartTime < 10)
244 {
245 if (!RIU_ReadByte(DemodCmd)) return TRUE;
246 MsOS_DelayTaskUs(500);
247 }
248 #ifdef MS_DEBUG
249 printf("HAL_SYS_DMD_VD_MBX_ATV_WaitReady Fail\n");
250 #endif
251 return FALSE;
252 }
253
HAL_SYS_DMD_VD_MBX_ATV_ReadByte(MS_U32 u32Reg,MS_U8 * u8Value)254 MS_BOOL HAL_SYS_DMD_VD_MBX_ATV_ReadByte(MS_U32 u32Reg, MS_U8 *u8Value)
255 {
256 if (HAL_SYS_DMD_VD_MBX_ATV_WaitReady())
257 {
258 RIU_WriteByte(DemodAdrL, u32Reg&0xFF);
259 RIU_WriteByte(DemodAdrH, (u32Reg>>8)&0xFF);
260 RIU_WriteByte(DemodCmd, DemodCmdRdReg);
261
262 if (HAL_SYS_DMD_VD_MBX_ATV_WaitReady())
263 {
264 *u8Value = RIU_ReadByte(DemodData);
265 return TRUE;
266 }
267 }
268 #ifdef MS_DEBUG
269 printf("HAL_SYS_DMD_VD_MBX_ATV_ReadByte Fail\n");
270 #endif
271 *u8Value = 0;
272 return FALSE;
273 }
274
HAL_SYS_DMD_VD_MBX_ATV_WriteByte(MS_U32 u32Reg,MS_U8 u8Val)275 MS_BOOL HAL_SYS_DMD_VD_MBX_ATV_WriteByte(MS_U32 u32Reg, MS_U8 u8Val)
276 {
277 if (HAL_SYS_DMD_VD_MBX_ATV_WaitReady())
278 {
279 RIU_WriteByte(DemodAdrL, u32Reg&0xFF);
280 RIU_WriteByte(DemodAdrH, (u32Reg>>8)&0xFF);
281 RIU_WriteByte(DemodData, u8Val);
282 RIU_WriteByte(DemodCmd, DemodCmdWrReg);
283 return TRUE;
284 }
285 return FALSE;
286 }
287 #else
HAL_SYS_DMD_VD_MBX_ATV_WaitReady(void)288 MS_BOOL HAL_SYS_DMD_VD_MBX_ATV_WaitReady(void)
289 {
290 return FALSE;
291 }
292
HAL_SYS_DMD_VD_MBX_ATV_ReadByte(MS_U32 u32Reg,MS_U8 * u8Value)293 MS_BOOL HAL_SYS_DMD_VD_MBX_ATV_ReadByte(MS_U32 u32Reg, MS_U8 *u8Value)
294 {
295 return FALSE;
296 }
297
HAL_SYS_DMD_VD_MBX_ATV_WriteByte(MS_U32 u32Reg,MS_U8 u8Val)298 MS_BOOL HAL_SYS_DMD_VD_MBX_ATV_WriteByte(MS_U32 u32Reg, MS_U8 u8Val)
299 {
300 return FALSE;
301 }
302 #endif
303
304 // DVBT & DVBC
HAL_SYS_DMD_VD_MBX_DVB_WaitReady(void)305 MS_BOOL HAL_SYS_DMD_VD_MBX_DVB_WaitReady(void)
306 {
307 MS_U32 u32StartTime=MsOS_GetSystemTime();
308 while (RIU_ReadByte(MBRegBase + 0x00)) // wait VDMCU ready
309 {
310 if (MsOS_Timer_DiffTimeFromNow(u32StartTime)>DMD_MBX_TIMEOUT)
311 {
312 printf("HAL_SYS_DMD_VD_MBX_DVB_WaitReady Timeout\n");
313 return FALSE;
314 }
315 }
316 return TRUE;
317 }
318
HAL_SYS_DMD_VD_MBX_DVB_WaitHandShake(void)319 void HAL_SYS_DMD_VD_MBX_DVB_WaitHandShake(void)
320 {
321 MS_U32 u32StartTime=MsOS_GetSystemTime();
322 while(RIU_ReadByte(MBRegBase + 0x00) != 0xFF) // wait MB_CNTL set done
323 {
324 if (MsOS_Timer_DiffTimeFromNow(u32StartTime)>DMD_MBX_TIMEOUT)
325 {
326 printf("HAL_SYS_DMD_VD_MBX_DVB_WaitHandShake Timeout\n");
327 break;
328 }
329 }
330 }
331
HAL_SYS_DMD_VD_MBX_DVB_ReadByte(MS_U16 u16Addr,MS_U8 * u8Value)332 MS_BOOL HAL_SYS_DMD_VD_MBX_DVB_ReadByte(MS_U16 u16Addr, MS_U8 *u8Value)
333 {
334 if (!HAL_SYS_DMD_VD_MBX_DVB_WaitReady()) return FALSE;
335
336 RIU_WriteByte(MBRegBase + 0x02, (MS_U8)(u16Addr >> 8)); // ADDR_H
337 RIU_WriteByte(MBRegBase + 0x01, (MS_U8)u16Addr); // ADDR_L
338 RIU_WriteByte(MBRegBase + 0x00, 0x01); // MB_CNTL set read mode
339
340 RIU_WriteByte(DMDMcuBase + 0x03, 0x02); // assert interrupt to VD MCU51
341 RIU_WriteByte(DMDMcuBase + 0x03, 0x00); // de-assert interrupt to VD MCU51
342
343 HAL_SYS_DMD_VD_MBX_DVB_WaitHandShake();
344
345 *u8Value = RIU_ReadByte(MBRegBase + 0x03); // REG_DATA get
346 RIU_WriteByte(MBRegBase + 0x00, 0x00); // MB_CNTL clear
347
348 return TRUE;
349 }
350
HAL_SYS_DMD_VD_MBX_DVB_WriteByte(MS_U32 u16Addr,MS_U8 u8Data)351 MS_BOOL HAL_SYS_DMD_VD_MBX_DVB_WriteByte(MS_U32 u16Addr, MS_U8 u8Data)
352 {
353 if (!HAL_SYS_DMD_VD_MBX_DVB_WaitReady()) return FALSE;
354
355 RIU_WriteByte(MBRegBase + 0x02, (MS_U8)(u16Addr >> 8)); // ADDR_H
356 RIU_WriteByte(MBRegBase + 0x01, (MS_U8)u16Addr); // ADDR_L
357 RIU_WriteByte(MBRegBase + 0x03, u8Data); // REG_DATA
358 RIU_WriteByte(MBRegBase + 0x00, 0x02); // MB_CNTL set write mode
359
360 RIU_WriteByte(DMDMcuBase + 0x03, 0x02); // assert interrupt to VD MCU51
361 RIU_WriteByte(DMDMcuBase + 0x03, 0x00); // de-assert interrupt to VD MCU51
362
363 HAL_SYS_DMD_VD_MBX_DVB_WaitHandShake();
364
365 RIU_WriteByte(MBRegBase + 0x00, 0x00); // MB_CNTL clear
366 return TRUE;
367 }
368
HAL_SYS_DMD_VD_MBX_DVB_ReadDspReg(MS_U32 u16Addr,MS_U8 * u8Value)369 MS_BOOL HAL_SYS_DMD_VD_MBX_DVB_ReadDspReg(MS_U32 u16Addr, MS_U8 *u8Value)
370 {
371 if (!HAL_SYS_DMD_VD_MBX_DVB_WaitReady()) return FALSE;
372
373 RIU_WriteByte(MBRegBase + 0x02, (MS_U8)(u16Addr >> 8)); // ADDR_H
374 RIU_WriteByte(MBRegBase + 0x01, (MS_U8)u16Addr); // ADDR_L
375 RIU_WriteByte(MBRegBase + 0x00, 0x03); // MB_CNTL set read mode
376
377 RIU_WriteByte(DMDMcuBase + 0x03, 0x02); // assert interrupt to DMD MCU51 //mick
378 RIU_WriteByte(DMDMcuBase + 0x03, 0x00); // de-assert interrupt to DMD MCU51
379
380 HAL_SYS_DMD_VD_MBX_DVB_WaitHandShake();
381
382 *u8Value = RIU_ReadByte(MBRegBase + 0x03); // REG_DATA get
383 RIU_WriteByte(MBRegBase + 0x00, 0x00); // MB_CNTL clear
384
385 return TRUE;
386 }
387
388
HAL_SYS_DMD_VD_MBX_DVB_WriteDspReg(MS_U32 u16Addr,MS_U8 u8Value)389 MS_BOOL HAL_SYS_DMD_VD_MBX_DVB_WriteDspReg(MS_U32 u16Addr, MS_U8 u8Value)
390 {
391 if (!HAL_SYS_DMD_VD_MBX_DVB_WaitReady()) return FALSE;
392
393 RIU_WriteByte(MBRegBase + 0x02, (MS_U8)(u16Addr >> 8)); // ADDR_H
394 RIU_WriteByte(MBRegBase + 0x01, (MS_U8)u16Addr); // ADDR_L
395 RIU_WriteByte(MBRegBase + 0x03, u8Value); // REG_DATA
396 RIU_WriteByte(MBRegBase + 0x00, 0x04); // MB_CNTL set write mode
397
398 RIU_WriteByte(DMDMcuBase + 0x03, 0x02); // assert interrupt to VD MCU51 //mick
399 RIU_WriteByte(DMDMcuBase + 0x03, 0x00); // de-assert interrupt to VD MCU51
400
401 HAL_SYS_DMD_VD_MBX_DVB_WaitHandShake();
402
403 RIU_WriteByte(MBRegBase + 0x00, 0x00); // MB_CNTL clear
404
405 return TRUE;
406 }
407
HAL_SYS_DMD_VD_MBX_DVB_DBG_ReadReg(MS_U16 u16Addr,MS_U8 * u8Value)408 MS_BOOL HAL_SYS_DMD_VD_MBX_DVB_DBG_ReadReg(MS_U16 u16Addr, MS_U8 *u8Value)
409 {
410 if (!HAL_SYS_DMD_VD_MBX_DVB_WaitReady()) return FALSE;
411
412 RIU_WriteByte(MBRegBase + 0x02, (MS_U8)(u16Addr >> 8)); // ADDR_H
413 RIU_WriteByte(MBRegBase + 0x01, (MS_U8)u16Addr); // ADDR_L
414 RIU_WriteByte(MBRegBase + 0x00, 0x05); // MB_CNTL set read mode
415
416 RIU_WriteByte(DMDMcuBase + 0x03, 0x02); // assert interrupt to DMD MCU51 //mick
417 RIU_WriteByte(DMDMcuBase + 0x03, 0x00); // de-assert interrupt to DMD MCU51
418
419 HAL_SYS_DMD_VD_MBX_DVB_WaitHandShake();
420
421 *u8Value = RIU_ReadByte(MBRegBase + 0x03); // REG_DATA get
422 RIU_WriteByte(MBRegBase + 0x00, 0x00); // MB_CNTL clear
423
424 return TRUE;
425 }
426
427 //-----------------------------------------------------------------------
HAL_SYS_DMD_VD_MBX_DVB_DBG_WriteReg(MS_U32 u16Addr,MS_U8 u8Data)428 MS_BOOL HAL_SYS_DMD_VD_MBX_DVB_DBG_WriteReg(MS_U32 u16Addr, MS_U8 u8Data)
429 {
430 if (!HAL_SYS_DMD_VD_MBX_DVB_WaitReady()) return FALSE;
431
432 RIU_WriteByte(MBRegBase + 0x02, (MS_U8)(u16Addr >> 8)); // ADDR_H
433 RIU_WriteByte(MBRegBase + 0x01, (MS_U8)u16Addr); // ADDR_L
434 RIU_WriteByte(MBRegBase + 0x03, u8Data); // REG_DATA
435 RIU_WriteByte(MBRegBase + 0x00, 0x06); // MB_CNTL set write mode
436
437 RIU_WriteByte(DMDMcuBase + 0x03, 0x02); // assert interrupt to VD MCU51 //mick
438 RIU_WriteByte(DMDMcuBase + 0x03, 0x00); // de-assert interrupt to VD MCU51
439
440 HAL_SYS_DMD_VD_MBX_DVB_WaitHandShake();
441
442 RIU_WriteByte(MBRegBase + 0x00, 0x00); // MB_CNTL clear
443
444 return TRUE;
445 }
446
447 // ATSC
HAL_SYS_DMD_VD_MBX_ATSC_WriteByte(MS_U16 u16Addr,MS_U8 u8Data)448 void HAL_SYS_DMD_VD_MBX_ATSC_WriteByte(MS_U16 u16Addr, MS_U8 u8Data)
449 {
450 MS_U8 u8CheckCount;
451 MS_U8 u8CheckFlag;
452
453 RIU_WriteByte(MBRegBase + 0x00, (u16Addr&0xff));
454 RIU_WriteByte(MBRegBase + 0x01, (u16Addr>>8));
455 RIU_WriteByte(MBRegBase + 0x10, u8Data);
456 RIU_WriteByte(MBRegBase + 0x1E, 0x01);
457
458 RIU_WriteByte(DMDMcuBase + 0x03, 0x02); // assert interrupt to VD MCU51 //mick
459 RIU_WriteByte(DMDMcuBase + 0x03, 0x00); // de-assert interrupt to VD MCU51
460
461 for ( u8CheckCount=0; u8CheckCount < 10 ; u8CheckCount++ )
462 {
463 u8CheckFlag = RIU_ReadByte(MBRegBase + 0x1E);
464 if ((u8CheckFlag&0x01)==0)
465 break;
466 MsOS_DelayTask(1);
467 }
468 }
469
HAL_SYS_DMD_VD_MBX_ATSC_ReadByte(MS_U16 u16Addr)470 MS_U8 HAL_SYS_DMD_VD_MBX_ATSC_ReadByte(MS_U16 u16Addr)
471 {
472 MS_U8 u8CheckCount;
473 MS_U8 u8CheckFlag;
474 MS_U8 u8Value;
475
476 RIU_WriteByte(MBRegBase + 0x00, (u16Addr&0xff));
477 RIU_WriteByte(MBRegBase + 0x01, (u16Addr>>8));
478 RIU_WriteByte(MBRegBase + 0x1E, 0x02);
479
480 RIU_WriteByte(DMDMcuBase + 0x03, 0x02); // assert interrupt to VD MCU51 //mick
481 RIU_WriteByte(DMDMcuBase + 0x03, 0x00); // de-assert interrupt to VD MCU51
482
483 for ( u8CheckCount=0; u8CheckCount < 10 ; u8CheckCount++ )
484 {
485 u8CheckFlag = RIU_ReadByte(MBRegBase + 0x1E);
486 if ((u8CheckFlag&0x02)==0)
487 {
488 u8Value = RIU_ReadByte(MBRegBase + 0x10);
489 return u8Value;
490 }
491 MsOS_DelayTask(1);
492 }
493
494 return 0;
495 }
496