[processor-sdk/performance-audio-sr.git] / psdk_cust / pdk_k2g_1_0_1_1_eng / packages / ti / board / src / flash / platform_flash / evmc66x_elm.c
1 /*
2 * Copyright (c) 2015, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
34 /**
35 * \file evmc66x_elm.c
36 *
37 * \brief This file contains APIs for ELM module.
38 *
39 */
41 /************************
42 * Include Files
43 ************************/
44 #include "platform_internal.h"
46 /*******************************************************************************
47 * API DEFINITIONS
48 *******************************************************************************/
50 /**
51 * \brief This function reads the IP revision code of ELM.\n
52 *
53 * \param hElm ELM handle for accessing HW registers.\n
54 *
55 * \return ipRev IP revision code of ELM.\n
56 */
57 Uint32 elmRevisionGet(elmHandle hElm)
58 {
59 Uint32 ipRev;
61 ipRev = CSL_FEXT(hElm->HEADER.REVISION, ELM_REVISION_REV_NUMBER);
63 return (ipRev);
64 }
66 /**
67 * \brief This function configs the Internal OCP clock gating strategy.\n
68 *
69 * \param hElm ELM handle for accessing HW registers.\n
70 *
71 * \param configVal Config value for OCP clk gating.\n
72 * This can take one of the following values :\n
73 * ELM_AUTOGATING_OCP_FREE -- OCP clock is free-running\n
74 * ELM_AUTOGATING_OCP_GATING -- Automatic internal OCP
75 * clock gating strategy is
76 * applied based on the OCP
77 * interface activity.\n
78 *
79 * \return none.\n
80 */
81 void elmAutoGatingConfig(elmHandle hElm, Uint32 configVal)
82 {
83 CSL_FINS(hElm->HEADER.SYSCONFIG, ELM_SYSCONFIG_AUTOGATING, configVal);
84 }
86 /**
87 * \brief This function sets the idle mode for ELM.\n
88 *
89 * \param hElm ELM handle for accessing HW registers.\n
90 *
91 * \param mode Idle mode.\n
92 * This can take one of the following values :\n
93 * ELM_IDLEMODE_FORCEIDLE -- for force-idle. \n
94 * ELM_IDLEMODE_NOIDLE -- for no-idle. \n
95 * ELM_IDLEMODE_SMARTIDLE -- for smart-idle.\n
96 *
97 * \return none.\n
98 */
99 void elmIdleModeSelect(elmHandle hElm, Uint32 mode)
100 {
101 CSL_FINS(hElm->HEADER.SYSCONFIG, ELM_SYSCONFIG_SIDLEMODE, mode);
102 }
104 /**
105 * \brief This function Resets the ELM.\n
106 *
107 * \param hElm ELM handle for accessing HW registers.\n
108 *
109 * \return None.\n
110 */
111 void elmModuleReset(elmHandle hElm)
112 {
113 CSL_FINS(hElm->HEADER.SYSCONFIG, ELM_SYSCONFIG_SOFTRESET,
114 ELM_BIT_SET_HIGH);
115 }
117 /**
118 * \brief This function sets the OCP Clock activity when module is in IDLE
119 * mode.\n
120 *
121 * \param hElm ELM handle for accessing HW registers.\n
122 *
123 * \param configVal Config value.\n
124 * This can take one of the following values :\n
125 * ELM_CLOCKACTIVITYOCP_OCP_OFF -- OCP clock is swith off\n
126 * ELM_CLOCKACTIVITYOCP_OCP_ON -- OCP Clock is
127 * maintained during
128 * wake up period.\n
129 *
130 * \return none.\n
131 */
132 void elmOCPClkActivityConfig(elmHandle hElm, Uint32 configVal)
133 {
134 CSL_FINS(hElm->HEADER.SYSCONFIG, ELM_SYSCONFIG_CLOCKACTIVITYOCP,
135 configVal);
136 }
138 /**
139 * \brief This function gets the software resets status of ELM.\n
140 *
141 * \param hElm ELM handle for accessing HW registers.\n
142 *
143 * \return status Reset status : \n
144 * 0 : Module reset is on-going.\n
145 * 1 : Module reset is completed.\n
146 */
147 Uint32 elmModuleResetStatusGet(elmHandle hElm)
148 {
149 Uint32 resetStat;
151 resetStat = CSL_FEXT(hElm->HEADER.SYSSTS, ELM_SYSSTS_RESETDONE);
153 return (resetStat);
154 }
156 /**
157 * \brief This function gets Interrupt status.\n
158 *
159 * \param hElm ELM handle for accessing HW registers.\n
160 *
161 * \param flag Flag for which interrupt status has to get.\n
162 * This can take one of the following values :\n
163 * ELM_LOC_VALID_0_STATUS : Error-location
164 * status for syndrome
165 * polynomial 0.\n
166 * ELM_LOC_VALID_1_STATUS : Error-location
167 * status for syndrome
168 * polynomial 1.\n
169 * ELM_LOC_VALID_2_STATUS : Error-location
170 * status for syndrome
171 * polynomial 2.\n
172 * ELM_LOC_VALID_3_STATUS : Error-location
173 * status for syndrome
174 * polynomial 3.\n
175 * ELM_LOC_VALID_4_STATUS : Error-location
176 * status for syndrome
177 * polynomial 4.\n
178 * ELM_LOC_VALID_5_STATUS : Error-location
179 * status for syndrome
180 * polynomial 5.\n
181 * ELM_LOC_VALID_6_STATUS : Error-location
182 * status for syndrome
183 * polynomial 6.\n
184 * ELM_LOC_VALID_7_STATUS : Error-location
185 * status for syndrome
186 * polynomial 7.\n
187 * ELM_PAGE_VALID_STATUS : Error-location
188 * status for a full
189 * page. \n
190 *
191 * \return intSts Interrupt Status. Return value meaning depends on the
192 * param flag. \n
193 * If flag is ELM_LOC_VALID_i_STATUS where i = 0 to 7,
194 * then\n
195 * 0 : No syndrome processed or process in progress.\n
196 * 1 : Error-location process completed.\n
197 *
198 * If flag is ELM_PAGE_VALID_STATUS, then\n
199 * 0 : Error locations invalid for all polynomials
200 * enabled.\n
201 * 1 : All error locations valid.\n
202 *
203 */
204 Uint32 elmIntStatusGet(elmHandle hElm, Uint32 flag)
205 {
206 Uint32 retVal;
208 retVal = 0;
210 switch(flag)
211 {
212 case ELM_LOC_VALID_0_STATUS:
213 retVal = CSL_FEXT(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_0);
214 break;
215 case ELM_LOC_VALID_1_STATUS:
216 retVal = CSL_FEXT(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_1);
217 break;
218 case ELM_LOC_VALID_2_STATUS:
219 retVal = CSL_FEXT(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_2);
220 break;
221 case ELM_LOC_VALID_3_STATUS:
222 retVal = CSL_FEXT(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_3);
223 break;
224 case ELM_LOC_VALID_4_STATUS:
225 retVal = CSL_FEXT(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_4);
226 break;
227 case ELM_LOC_VALID_5_STATUS:
228 retVal = CSL_FEXT(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_5);
229 break;
230 case ELM_LOC_VALID_6_STATUS:
231 retVal = CSL_FEXT(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_6);
232 break;
233 case ELM_LOC_VALID_7_STATUS:
234 retVal = CSL_FEXT(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_7);
235 break;
236 case ELM_PAGE_VALID_STATUS:
237 retVal = CSL_FEXT(hElm->HEADER.IRQSTS, ELM_IRQSTS_PAGE_VALID);
238 break;
239 default:
240 /* Nothing to do here */
241 break;
242 }
244 return (retVal);
245 }
247 /**
248 * \brief This function clears the interrupt.\n
249 *
250 * \param hElm ELM handle for accessing HW registers.\n
251 *
252 * \param flag Flag for which interrupt status has to clear.\n
253 * This can take one of the following values :\n
254 * ELM_LOC_VALID_0_STATUS : Error-location
255 * interrupt for syndrome
256 * polynomial 0.\n
257 * ELM_LOC_VALID_1_STATUS : Error-location
258 * interrupt for syndrome
259 * polynomial 1.\n
260 * ELM_LOC_VALID_2_STATUS : Error-location
261 * interrupt for syndrome
262 * polynomial 2.\n
263 * ELM_LOC_VALID_3_STATUS : Error-location
264 * interrupt for syndrome
265 * polynomial 3.\n
266 * ELM_LOC_VALID_4_STATUS : Error-location
267 * interrupt for syndrome
268 * polynomial 4.\n
269 * ELM_LOC_VALID_5_STATUS : Error-location
270 * interrupt for syndrome
271 * polynomial 5.\n
272 * ELM_LOC_VALID_6_STATUS : Error-location
273 * interrupt for syndrome
274 * polynomial 6.\n
275 * ELM_LOC_VALID_7_STATUS : Error-location
276 * interrupt for syndrome
277 * polynomial 7.\n
278 * ELM_PAGE_VALID_STATUS : Error-location
279 * interrupt for a full
280 * page.\n
281 *
282 * \return None. \n
283 *
284 */
285 void elmIntStatusClear(elmHandle hElm, Uint32 flag)
286 {
287 switch(flag)
288 {
289 case ELM_LOC_VALID_0_STATUS:
290 CSL_FINS(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_0,
291 ELM_BIT_SET_HIGH);
292 break;
293 case ELM_LOC_VALID_1_STATUS:
294 CSL_FINS(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_1,
295 ELM_BIT_SET_HIGH);
296 break;
297 case ELM_LOC_VALID_2_STATUS:
298 CSL_FINS(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_2,
299 ELM_BIT_SET_HIGH);
300 break;
301 case ELM_LOC_VALID_3_STATUS:
302 CSL_FINS(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_3,
303 ELM_BIT_SET_HIGH);
304 break;
305 case ELM_LOC_VALID_4_STATUS:
306 CSL_FINS(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_4,
307 ELM_BIT_SET_HIGH);
308 break;
309 case ELM_LOC_VALID_5_STATUS:
310 CSL_FINS(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_5,
311 ELM_BIT_SET_HIGH);
312 break;
313 case ELM_LOC_VALID_6_STATUS:
314 CSL_FINS(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_6,
315 ELM_BIT_SET_HIGH);
316 break;
317 case ELM_LOC_VALID_7_STATUS:
318 CSL_FINS(hElm->HEADER.IRQSTS, ELM_IRQSTS_LOC_VALID_7,
319 ELM_BIT_SET_HIGH);
320 break;
321 case ELM_PAGE_VALID_STATUS:
322 CSL_FINS(hElm->HEADER.IRQSTS, ELM_IRQSTS_PAGE_VALID,
323 ELM_BIT_SET_HIGH);
324 break;
325 default:
326 /* Nothing to do here */
327 break;
328 }
329 }
331 /**
332 * \brief This function configs i.e enables or disables the interrupts.\n
333 *
334 * \param hElm ELM handle for accessing HW registers.\n
335 *
336 * \param intflag intFlag for which interrupt has to config.\n
337 * This can take one of the following values :\n
338 * ELM_LOC_VALID_0_STATUS : Error-location
339 * interrupt for syndrome
340 * polynomial 0.\n
341 * ELM_LOC_VALID_1_STATUS : Error-location
342 * interrupt for syndrome
343 * polynomial 1.\n
344 * ELM_LOC_VALID_2_STATUS : Error-location
345 * interrupt for syndrome
346 * polynomial 2.\n
347 * ELM_LOC_VALID_3_STATUS : Error-location
348 * interrupt for syndrome
349 * polynomial 3.\n
350 * ELM_LOC_VALID_4_STATUS : Error-location
351 * interrupt for syndrome
352 * polynomial 4.\n
353 * ELM_LOC_VALID_5_STATUS : Error-location
354 * interrupt for syndrome
355 * polynomial 5.\n
356 * ELM_LOC_VALID_6_STATUS : Error-location
357 * interrupt for syndrome
358 * polynomial 6.\n
359 * ELM_LOC_VALID_7_STATUS : Error-location
360 * interrupt for syndrome
361 * polynomial 7.\n
362 * ELM_PAGE_VALID_STATUS : Error-location
363 * interrupt for a full
364 * page. \n
365 *
366 * \param configVal Config Value.\n
367 * This can take one of the following values :\n
368 * ELM_INT_ENALBLE : To enble the interrupt\n
369 * ELM_INT_DISALBLE : To disable the
370 * interrupt.\n
371 * \return None. \n
372 *
373 */
374 void elmIntConfig(elmHandle hElm, Uint32 intFlag, Uint32 configVal)
375 {
376 switch(intFlag)
377 {
378 case ELM_LOC_VALID_0_STATUS:
379 if(configVal == ELM_INT_ENALBLE)
380 {
381 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_0,
382 ELM_BIT_ENABLE);
383 }
384 else
385 {
386 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_0,
387 ELM_BIT_DISABLE);
388 }
389 break;
390 case ELM_LOC_VALID_1_STATUS:
391 if(configVal == ELM_INT_ENALBLE)
392 {
393 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_1,
394 ELM_BIT_ENABLE);
395 }
396 else
397 {
398 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_1,
399 ELM_BIT_DISABLE);
400 }
401 break;
402 case ELM_LOC_VALID_2_STATUS:
403 if(configVal == ELM_INT_ENALBLE)
404 {
405 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_2,
406 ELM_BIT_ENABLE);
407 }
408 else
409 {
410 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_2,
411 ELM_BIT_DISABLE);
412 }
413 break;
414 case ELM_LOC_VALID_3_STATUS:
415 if(configVal == ELM_INT_ENALBLE)
416 {
417 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_3,
418 ELM_BIT_ENABLE);
419 }
420 else
421 {
422 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_3,
423 ELM_BIT_DISABLE);
424 }
425 break;
426 case ELM_LOC_VALID_4_STATUS:
427 if(configVal == ELM_INT_ENALBLE)
428 {
429 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_4,
430 ELM_BIT_ENABLE);
431 }
432 else
433 {
434 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_4,
435 ELM_BIT_DISABLE);
436 }
437 break;
438 case ELM_LOC_VALID_5_STATUS:
439 if(configVal == ELM_INT_ENALBLE)
440 {
441 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_5,
442 ELM_BIT_ENABLE);
443 }
444 else
445 {
446 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_5,
447 ELM_BIT_DISABLE);
448 }
449 break;
450 case ELM_LOC_VALID_6_STATUS:
451 if(configVal == ELM_INT_ENALBLE)
452 {
453 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_6,
454 ELM_BIT_ENABLE);
455 }
456 else
457 {
458 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_6,
459 ELM_BIT_DISABLE);
460 }
461 break;
462 case ELM_LOC_VALID_7_STATUS:
463 if(configVal == ELM_INT_ENALBLE)
464 {
465 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_7,
466 ELM_BIT_ENABLE);
467 }
468 else
469 {
470 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_LOCATION_MASK_7,
471 ELM_BIT_DISABLE);
472 }
473 break;
474 case ELM_PAGE_VALID_STATUS:
475 if(configVal == ELM_INT_ENALBLE)
476 {
477 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_PAGE_MASK,
478 ELM_BIT_ENABLE);
479 }
480 else
481 {
482 CSL_FINS(hElm->HEADER.IRQEN, ELM_IRQEN_PAGE_MASK,
483 ELM_BIT_DISABLE);
484 }
485 break;
486 default:
487 /* Nothing to do here */
488 break;
489 }
490 }
492 /**
493 * \brief This function sets the Error correction level for BCH alogorithm.\n
494 *
495 * \param hElm ELM handle for accessing HW registers.\n
496 *
497 * \param bchECCLevel BCH error correction level.\n
498 * This can take one of the following values :\n
499 * ELM_ECC_BCH_LEVEL_16BITS : For Upto 16 bits error
500 * correction.\n
501 * ELM_ECC_BCH_LEVEL_8BITS : For Upto 8 bits error
502 * correction.\n
503 * ELM_ECC_BCH_LEVEL_4BITS : For Upto 4 bits error
504 * correction.\n
505 *
506 * \return None. \n
507 *
508 */
509 void elmErrCorrectionLevelSet(elmHandle hElm, Uint32 bchECCLevel)
510 {
511 CSL_FINS(hElm->HEADER.LOCATION_CONFIG, ELM_LOCATION_CONFIG_ECC_BCH_LEVEL,
512 bchECCLevel);
513 }
515 /**
516 * \brief This function sets the size of the buffers for which
517 * the error-location engine is used.\n
518 *
519 * \param hElm ELM handle for accessing HW registers.\n
520 *
521 * \param eccSize eccSize in number of nibbles (i.e 4-bits entities).\n
522 *
523 * \return None. \n
524 *
525 */
526 void elmECCSizeSet(elmHandle hElm, Uint32 eccSize)
527 {
528 CSL_FINS(hElm->HEADER.LOCATION_CONFIG, ELM_LOCATION_CONFIG_ECC_SIZE,
529 eccSize);
530 }
532 /**
533 * \brief This function sets mode of the ELM module.\n
534 *
535 * \param hElm ELM handle for accessing HW registers.\n
536 * \param mode mode of the ELM.\n
537 * This can take one of the following values :\n
538 * ELM_MODE_PAGE -- For page mode.\n
539 * ELM_MODE_CONTINUOUS -- For continuous mode.\n
540 *
541 * \param sectorNum Sector number or syndrome polynomial number which has
542 * to select as part of the page in page mode.\n
543 * This can take one of the following values :\n
544 * ELM_PAGEMODE_SECTOR_0 -- For selecting syndrome
545 * polynomial 0 as part of the
546 * page in page mode.\n
547 * ELM_PAGEMODE_SECTOR_1 -- For selecting syndrome
548 * polynomial 1 as part of the
549 * page in page mode.\n
550 * ELM_PAGEMODE_SECTOR_2 -- For selecting syndrome
551 * polynomial 2 as part of the
552 * page in page mode.\n
553 * ELM_PAGEMODE_SECTOR_3 -- For selecting syndrome
554 * polynomial 3 as part of the
555 * page in page mode.\n
556 * ELM_PAGEMODE_SECTOR_4 -- For selecting syndrome
557 * polynomial 4 as part of the
558 * page in page mode.\n
559 * ELM_PAGEMODE_SECTOR_5 -- For selecting syndrome
560 * polynomial 5 as part of the
561 * page in page mode.\n
562 * ELM_PAGEMODE_SECTOR_6 -- For selecting syndrome
563 * polynomial 6 as part of the
564 * page in page mode.\n
565 * ELM_PAGEMODE_SECTOR_7 -- For selecting syndrome
566 * polynomial 7 as part of the
567 * page in page mode.\n
569 * \return None. \n
570 *
571 */
572 void elmModeSet(elmHandle hElm, Uint32 mode, Uint32 sectorNum)
573 {
574 if(mode == ELM_MODE_CONTINUOUS)
575 {
576 hElm->HEADER.PAGE_CTRL &= ~( 1 << sectorNum );
577 }
578 else
579 {
580 hElm->HEADER.PAGE_CTRL |= ( mode << sectorNum );
581 }
582 }
584 /**
585 * \brief This function sets the fragments of syndrome polynomial for
586 * error-location processing.\n
587 *
588 * \param hElm ELM handle for accessing HW registers.\n
589 *
590 * \param synFrgmtId Syndrome fragment ID.\n
591 * This can take one of the following values :\n
592 * ELM_SYNDROME_FRGMT_0 - For syndrome fragment 0.\n
593 * ELM_SYNDROME_FRGMT_1 - For syndrome fragment 1.\n
594 * ELM_SYNDROME_FRGMT_2 - For syndrome fragment 2.\n
595 * ELM_SYNDROME_FRGMT_3 - For syndrome fragment 3.\n
596 * ELM_SYNDROME_FRGMT_4 - For syndrome fragment 4.\n
597 * ELM_SYNDROME_FRGMT_5 - For syndrome fragment 5.\n
598 * ELM_SYNDROME_FRGMT_6 - For syndrome fragment 6.\n
599 * \param synFrgmtVal Syndrome fragment value.\n
600 *
601 * \param csNum Chip Select Number, 0 - 7.\n
602 *
603 * \return None. \n
604 *
605 */
606 void elmSyndromeFrgmtSet(elmHandle hElm, Uint32 synFrgmtId,
607 Uint32 synFrgmtVal, Uint32 csNum)
608 {
609 volatile Uint32 *elmSynFrgmt;
611 elmSynFrgmt = (Uint32 *)(&(hElm->SYNDROMES[csNum].SYNDROME_FRAGMENT_0) + 4*synFrgmtId);
613 if(synFrgmtId != ELM_SYNDROME_FRGMT_6)
614 {
615 *elmSynFrgmt = synFrgmtVal;
616 }
617 else
618 {
619 *elmSynFrgmt = (synFrgmtVal & CSL_ELM_SYNDROME_FRAGMENT_6_SYNDROME_6_MASK);
620 }
621 }
623 /**
624 * \brief This function starts the error-location processing for the polynomial
625 * set in the syndrome fragment registers.\n
626 *
627 * \param hElm ELM handle for accessing HW registers.\n
628 *
629 * \param csNum Chip Select Number, 0 - 7.\n
630 *
631 * \return None. \n
632 *
633 */
634 void elmErrLocProcessingStart(elmHandle hElm, Uint32 csNum)
635 {
636 hElm->SYNDROMES[csNum].SYNDROME_FRAGMENT_6 |=
637 CSL_ELM_SYNDROME_FRAGMENT_6_SYNDROME_VALID_MASK;
638 }
640 /**
641 * \brief This function gets the error-location processing status.\n
642 *
643 * \param hElm ELM handle for accessing HW registers.\n
644 *
645 * \param csNum Chip Select Number, 0 - 7.\n
646 *
647 * \return status. \n
648 * 0 : ECC error-location process failed.\n
649 * 1 : ECC error-location process passed.\n
650 *
651 */
652 Uint32 elmErrLocProcessingStatusGet(elmHandle hElm, Uint32 csNum)
653 {
654 Uint32 status;
656 status = CSL_FEXT(hElm->ERROR_LOCATIONS[csNum].LOCATION_STS,
657 ELM_LOCATION_STS_ECC_CORRECTBL);
658 return (status);
659 }
661 /**
662 * \brief This function gets the number of errors detected and located
663 * during error-location processing.\n
664 *
665 * \param hElm ELM handle for accessing HW registers.\n
666 *
667 * \param csNum Chip Select Number, 0 - 7.\n
668 *
669 * \return Number of errors detected and located.\n
670 *
671 */
672 Uint32 elmNumOfErrsGet(elmHandle hElm, Uint32 csNum)
673 {
674 Uint32 numOfErrs;
676 numOfErrs = CSL_FEXT(hElm->ERROR_LOCATIONS[csNum].LOCATION_STS,
677 ELM_LOCATION_STS_ECC_NB_ERRORS);
679 return (numOfErrs);
680 }
682 /**
683 * \brief This function gets the Error-location bit address for the error
684 * number passed.\n
685 *
686 * \param hElm ELM handle for accessing HW registers.\n
687 *
688 * \param errNum Error number.\n
689 * This can take one of the following values :\n
690 * ELM_ERROR_NUM_0 - For 0th error.\n
691 * ELM_ERROR_NUM_1 - For 1th error.\n
692 * ELM_ERROR_NUM_2 - For 2th error.\n
693 * ELM_ERROR_NUM_3 - For 3th error.\n
694 * ELM_ERROR_NUM_4 - For 4th error.\n
695 * ELM_ERROR_NUM_5 - For 5th error.\n
696 * ELM_ERROR_NUM_6 - For 6th error.\n
697 * ELM_ERROR_NUM_7 - For 7th error.\n
698 * ELM_ERROR_NUM_8 - For 8th error.\n
699 * ELM_ERROR_NUM_9 - For 9th error.\n
700 * ELM_ERROR_NUM_10 - For 10th error.\n
701 * ELM_ERROR_NUM_11 - For 11th error.\n
702 * ELM_ERROR_NUM_12 - For 12th error.\n
703 * ELM_ERROR_NUM_13 - For 13th error.\n
704 * ELM_ERROR_NUM_14 - For 14th error.\n
705 * ELM_ERROR_NUM_15 - For 15th error.\n
706 *
707 * \param csNum Chip Select Number, 0 - 7.\n
708 *
709 * \return Bit address for the error number.\n
710 *
711 */
712 Uint32 elmErrLocBitAddrGet(elmHandle hElm, Uint32 errNum, Uint32 csNum)
713 {
714 volatile Uint32 *elmErrLoc;
715 Uint32 bitAddr;
717 elmErrLoc = (Uint32 *)(&(hElm->ERROR_LOCATIONS[csNum].ERROR_LOCATION_0) +
718 4*errNum);
720 bitAddr = (*elmErrLoc & CSL_ELM_ERROR_LOCATION_0_ECC_ERROR_LOCATION_MASK);
722 return (bitAddr);
723 }
724 /***************************** End Of File ***********************************/