86 lines
2.0 KiB
C
86 lines
2.0 KiB
C
#include "sys/sbd.h"
|
|
#include "sys/hal2.h"
|
|
|
|
void
|
|
hal2_codecactrl1()
|
|
{
|
|
volatile unsigned long *idr0 = (unsigned long *)PHYS_TO_K1(HAL2_IDR0);
|
|
volatile unsigned long *iar = (unsigned long *)PHYS_TO_K1(HAL2_IAR);
|
|
volatile unsigned long *isr = (unsigned long *)PHYS_TO_K1(HAL2_ISR);
|
|
int i, nbad =0;
|
|
unsigned short j;
|
|
unsigned short val;
|
|
unsigned short rb0, rb1;
|
|
int nspin = 0;
|
|
int badval[1024];
|
|
|
|
printf("begin test of HAL2 CODECA CTRL1 register\n");
|
|
*isr = 0x8;
|
|
/*
|
|
* clear the badval array
|
|
*/
|
|
for (i = 0; i < 1024; i++) {
|
|
badval[i] = 0;
|
|
}
|
|
for (i = 0; i < 32000; i++) {
|
|
for (j = 0; j < 32; j++) {
|
|
/*
|
|
* loop through all values for bits 0-4; let
|
|
* bits 8 and 9 be the same as bits 0-1.
|
|
*/
|
|
val = j | ((j & 0x3) << 8);
|
|
*idr0 = val;
|
|
*iar = HAL2_CODECA_CTRL1_W; /* write the values */
|
|
/*
|
|
* spin on the ISR to make sure the value we
|
|
* just wrote is latched in before we read it
|
|
*/
|
|
while (*isr & HAL2_ISR_TSTATUS) nspin++;
|
|
*idr0= 0xffff;
|
|
/*
|
|
* read back twice, just to make sure
|
|
* back-to-back reads will agree.
|
|
*/
|
|
*iar = HAL2_CODECA_CTRL1_R;
|
|
while (*isr & HAL2_ISR_TSTATUS) nspin++;
|
|
rb0 = *idr0;
|
|
rb0 &= 0x31f;
|
|
*iar = HAL2_CODECA_CTRL1_R;
|
|
while (*isr & HAL2_ISR_TSTATUS) nspin++;
|
|
rb1 = *idr0;
|
|
rb1 &= 0x31f;
|
|
if (rb0 != val) {
|
|
nbad++;
|
|
printf("error [read 1]: wrote 0x%x, got 0x%x\n",val,rb0);
|
|
badval[val]++;
|
|
}
|
|
if (rb1 != val) {
|
|
nbad++;
|
|
printf("error [read 2]: wrote 0x%x, got 0x%x\n",val,rb1);
|
|
badval[val]++;
|
|
}
|
|
}
|
|
}
|
|
/*
|
|
* now, if there were any bad readbacks, print for which
|
|
* values they occurred.
|
|
*/
|
|
if (nbad) {
|
|
printf("bad readbacks: ");
|
|
for (i = 0; i < 1024; i++) {
|
|
if (badval[i]) {
|
|
printf("value 0x%x (#bad %d), ", i, badval[i]);
|
|
}
|
|
}
|
|
printf("\n");
|
|
}
|
|
printf("spins: %d\n",nspin);
|
|
printf("end test of HAL2 CODECA CTRL1 register\n");
|
|
}
|
|
|
|
main()
|
|
{
|
|
hal2_configure_pbus_pio();
|
|
hal2_codecactrl1();
|
|
}
|