source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/xvd/7552/bxvd_reg.c

Last change on this file was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 8.8 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2004-2011, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bxvd_reg.c $
11 * $brcm_Revision: Hydra_Software_Devel/12 $
12 * $brcm_Date: 7/20/11 3:04p $
13 *
14 * Module Description:
15 *   See Module Overview below.
16 *
17 * Revision History:
18 *
19 * $brcm_Log: /magnum/portinginterface/xvd/7401/bxvd_reg.c $
20 *
21 * Hydra_Software_Devel/12   7/20/11 3:04p davidp
22 * SW7420-2001: Reorder header file includes.
23 *
24 * Hydra_Software_Devel/11   6/27/11 1:30p davidp
25 * SW7425-628: Fix GISB workaround non SVD capable write_isr case.
26 *
27 * Hydra_Software_Devel/10   6/25/11 9:51a davidp
28 * SW7425-628: Change BKNI_Printfs to BDBG_MSGs.
29 *
30 * Hydra_Software_Devel/9   6/24/11 6:55p davidp
31 * SW7425-628: Add delay and retry to BXVD_Reg_Write32_isr GISB timeout
32 * workaround.
33 *
34 * Hydra_Software_Devel/8   6/24/11 8:07a davidp
35 * SW7425-628: Only perform GISB timeout workaround on SVD.
36 *
37 * Hydra_Software_Devel/7   6/23/11 6:03p davidp
38 * SW7425-615: Increase write error delay to 50 usec.
39 *
40 * Hydra_Software_Devel/6   6/21/11 3:43p btosi
41 * SW7425-615: added GISB error check to the register write routines
42 *
43 * Hydra_Software_Devel/5   6/17/11 11:40a btosi
44 * SW7425-615: fixed converity issue
45 *
46 * Hydra_Software_Devel/4   6/16/11 4:30p davidp
47 * SW7425-615: Add and use BXVD_P_GISB_ERR_WORKAROUND symbolic constant.
48 *
49 * Hydra_Software_Devel/3   6/16/11 11:21a btosi
50 * SW7425-615: added retry mechanism for register reads that fail
51 *
52 * Hydra_Software_Devel/2   7/15/05 1:08p pblanco
53 * PR16052: Clean build with new code and data.
54 *
55 * Hydra_Software_Devel/1   7/13/05 12:30p pblanco
56 * PR16052: Initial checkin.
57 *
58 ***************************************************************************/
59#include "bstd.h"
60#include "bxvd_platform.h"
61#include "bxvd_priv.h"
62#include "bxvd.h"
63#include "bxvd_reg.h"
64
65BDBG_MODULE(BXVD_REG);
66
67#define BXVD_REG_READ_MAX_RETRIES            10
68#define BXVD_REG_WRITE_POST_FAILURE_DELAY    5 /* wait this many usecs for the write to complete */
69
70uint32_t BXVD_Reg_Read32_isr(BXVD_Handle hXvd, uint32_t offset)
71{
72   uint32_t uiValue;
73
74#if BXVD_P_SVD_GISB_ERR_WORKAROUND
75
76   if (hXvd->bSVCCapable)
77   {
78      uint32_t uiLoop;
79      bool bSuccess=true;
80
81      for ( uiLoop=0; uiLoop < BXVD_REG_READ_MAX_RETRIES; uiLoop++ )
82      {
83
84         /* SW7425-628: work around for the bus error caused by register reads. */
85         uint32_t uiStatus;
86
87         uiValue = BREG_Read32_isr(hXvd->hReg, offset);
88
89         /* Check if the AVD_RGR_BRIDGE_INTR bit is set in the CPU status register. */
90         uiStatus = BREG_Read32_isr(hXvd->hReg, BCHP_SVD_INTR2_0_CPU_STATUS);
91
92         if ( uiStatus & BCHP_SVD_INTR2_0_CPU_STATUS_AVD_RGR_BRIDGE_INTR_MASK )
93         {
94            /* If the bit is set, the read failed.  Clear the AVD_RGR_BRIDGE_INTR
95             * bit and read the register again.
96             */
97            bSuccess = false;
98
99            /* Clear the RBUS-GISB-RBUS Bridge interrupt.  */
100            BREG_Write32_isr(
101               hXvd->hReg, 
102               BCHP_SVD_INTR2_0_CPU_CLEAR, 
103               BCHP_SVD_INTR2_0_CPU_CLEAR_AVD_RGR_BRIDGE_INTR_MASK
104               );
105
106            BXVD_DBG_MSG(hXvd, ("BXVD_Reg_Read32_isr read failed: offset: %08x uiStatus: %08x", offset, uiStatus ));
107         }
108         else
109         {
110            bSuccess = true;
111         }
112
113         if ( true == bSuccess )
114         {
115            break;
116         }
117
118      }    /* end of for ( uiLoop < BXVD_REG_READ_MAX_RETRIES ) */
119 
120      if ( uiLoop == BXVD_REG_READ_MAX_RETRIES )
121      {
122         BXVD_DBG_MSG(hXvd, ("BXVD_Reg_Read32_isr: didn't get a clean read of %08x", offset ));
123      }
124   }
125   else
126   {
127      uiValue = BREG_Read32_isr(hXvd->hReg, offset);
128   }
129#else
130
131   uiValue = BREG_Read32_isr(hXvd->hReg, offset);
132
133#endif
134
135   return uiValue;
136}
137
138#define MAX_LOOP_CNT 10
139
140void BXVD_Reg_Write32_isr(BXVD_Handle hXvd, uint32_t offset, uint32_t data)
141{
142
143#if BXVD_P_SVD_GISB_ERR_WORKAROUND
144
145   bool bDone= false;
146   uint32_t loopCnt=0;
147#if 0
148   volatile uint32_t uiVal = data;
149   uint32_t delayLoopCnt = 20000;
150#endif
151
152   while (!bDone)
153   {
154      BREG_Write32_isr(hXvd->hReg, offset, data);
155
156      if (hXvd->bSVCCapable)
157      {
158         uint32_t uiStatus;
159     
160#if 1
161         BKNI_Delay( 1 );  /* not a long one */
162#else
163         while(delayLoopCnt--)
164         {
165            uiVal = data;
166         }
167#endif
168
169         /* Check if the AVD_RGR_BRIDGE_INTR bit is set in the CPU status register. */
170         uiStatus = BREG_Read32_isr(hXvd->hReg, BCHP_SVD_INTR2_0_CPU_STATUS);
171
172         if ( uiStatus & BCHP_SVD_INTR2_0_CPU_STATUS_AVD_RGR_BRIDGE_INTR_MASK )
173         {
174            /* If the write "fails", clear the interrupt bit and then wait
175             * for the write to complete.
176             */
177            BREG_Write32_isr(
178               hXvd->hReg, 
179               BCHP_SVD_INTR2_0_CPU_CLEAR, 
180               BCHP_SVD_INTR2_0_CPU_CLEAR_AVD_RGR_BRIDGE_INTR_MASK
181               );
182
183            BXVD_DBG_MSG(hXvd, ("BXVD_Reg_Write32_isr write failed: LoopCnt:%d  offset: %08x data: %08x uiStatus: %08x",
184                                loopCnt, offset, data, uiStatus ));
185
186            BKNI_Delay( BXVD_REG_WRITE_POST_FAILURE_DELAY );
187#if 0
188            uiVal = BREG_Read32_isr(hXvd->hReg, offset);
189
190            BKNI_Printf("\t**** BXVD_Write_ISR bus error:cnt: %d addr:%08x  data:%08x val:%08x ****\n",
191                        loopCnt, offset, data, uiVal);
192
193            if ((data == uiVal) || (loopCnt==MAX_LOOP_CNT))
194            {
195               bDone=true;
196            }
197#else
198            if (loopCnt==MAX_LOOP_CNT)
199            {
200               bDone=true;
201            }
202#endif
203         }
204         else
205         {
206            bDone=true;
207         }
208      }
209      else /* Not SVD Capable */
210      {
211         bDone=true;
212      }
213     
214      loopCnt++;
215   }
216#else
217
218   BREG_Write32_isr(hXvd->hReg, offset, data);
219
220#endif
221}
222
223uint32_t BXVD_Reg_Read32(BXVD_Handle hXvd, uint32_t offset)
224{
225   uint32_t uiValue;
226
227#if BXVD_P_SVD_GISB_ERR_WORKAROUND
228
229   if (hXvd->bSVCCapable)
230   {
231      uint32_t uiLoop;
232      bool bSuccess=true;
233
234      for ( uiLoop=0; uiLoop < BXVD_REG_READ_MAX_RETRIES; uiLoop++ )
235      {
236
237         /* SW7425-628: work around for the bus error caused by register reads. */
238         uint32_t uiStatus;
239
240         uiValue = BREG_Read32(hXvd->hReg, offset);
241
242         /* Check if the AVD_RGR_BRIDGE_INTR bit is set in the CPU status register. */
243         uiStatus = BREG_Read32(hXvd->hReg, BCHP_SVD_INTR2_0_CPU_STATUS);
244
245         if ( uiStatus & BCHP_SVD_INTR2_0_CPU_STATUS_AVD_RGR_BRIDGE_INTR_MASK )
246         {
247            /* If the bit is set, the read failed.  Clear the AVD_RGR_BRIDGE_INTR
248             * bit and read the register again.
249             */
250            bSuccess = false;
251
252            /* Clear the RBUS-GISB-RBUS Bridge interrupt.  */
253            BREG_Write32(
254               hXvd->hReg, 
255               BCHP_SVD_INTR2_0_CPU_CLEAR, 
256               BCHP_SVD_INTR2_0_CPU_CLEAR_AVD_RGR_BRIDGE_INTR_MASK
257               );
258
259            BXVD_DBG_MSG(hXvd, ("BXVD_Reg_Read32 read failed: offset: %08x uiStatus: %08x", offset, uiStatus ));
260         }
261         else
262         {
263            bSuccess = true;
264         }
265
266         if ( true == bSuccess )
267         {
268            break;
269         }
270
271      }     /* end of for ( uiLoop < BXVD_REG_READ_MAX_RETRIES ) */
272
273      if ( uiLoop == BXVD_REG_READ_MAX_RETRIES )
274      {
275         BXVD_DBG_MSG(hXvd, ("BXVD_Reg_Read32: didn't get a clean read of %08x", offset ));
276      }
277   }
278   else
279   {
280      uiValue = BREG_Read32(hXvd->hReg, offset);
281   }
282#else
283
284   uiValue = BREG_Read32(hXvd->hReg, offset);
285
286#endif
287
288   return uiValue;
289}
290
291void BXVD_Reg_Write32(BXVD_Handle hXvd, uint32_t offset, uint32_t data)
292{
293   BREG_Write32(hXvd->hReg, offset, data);
294
295#if BXVD_P_SVD_GISB_ERR_WORKAROUND
296
297   if (hXvd->bSVCCapable)
298   {
299      uint32_t uiStatus;
300
301      /* Check if the AVD_RGR_BRIDGE_INTR bit is set in the CPU status register. */
302      uiStatus = BREG_Read32(hXvd->hReg, BCHP_SVD_INTR2_0_CPU_STATUS);
303
304      if ( uiStatus & BCHP_SVD_INTR2_0_CPU_STATUS_AVD_RGR_BRIDGE_INTR_MASK )
305      {
306         /* If the write "fails", clear the interrupt bit and then wait
307          * for the write to complete.
308          */
309         BREG_Write32(
310            hXvd->hReg, 
311            BCHP_SVD_INTR2_0_CPU_CLEAR, 
312            BCHP_SVD_INTR2_0_CPU_CLEAR_AVD_RGR_BRIDGE_INTR_MASK
313            );
314
315         BXVD_DBG_MSG(hXvd, ("BXVD_Reg_Write32 write failed: offset: %08x uiStatus: %08x", offset, uiStatus ));
316
317         BKNI_Delay( BXVD_REG_WRITE_POST_FAILURE_DELAY );
318      }
319   }
320
321#endif   
322}
323
Note: See TracBrowser for help on using the repository browser.