Date: Tue, 25 Apr 2006 17:09:55 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 96070 for review Message-ID: <200604251709.k3PH9tds038033@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=96070 Change 96070 by imp@imp_hammer on 2006/04/25 17:09:22 Hmmm, seems to be the printf that made it work :-( Affected files ... .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/spi_flash.c#6 edit Differences ... ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/spi_flash.c#6 (text+ko) ==== @@ -32,6 +32,20 @@ static char tx_commandBuffer[8], rx_commandBuffer[8]; +static void +Delay(void) +{ +#if 0 + unsigned later; + + later = (AT91C_BASE_ST->ST_CRTR + 10) & AT91C_ST_CRTV; + while (later != AT91C_BASE_ST->ST_CRTR) + continue; +#else + printf("V--------"); +#endif +} + /* * .KB_C_FN_DEFINITION_START * void SendCommand(spiCommand_t *pCommand) @@ -42,31 +56,26 @@ static void SendCommand(spiCommand_t *pCommand) { - unsigned i, v; + unsigned v; + AT91PS_SPI pSPI = AT91C_BASE_SPI; - AT91C_BASE_SPI->SPI_PTCR = AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS; + pSPI->SPI_PTCR = AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS; - AT91C_BASE_SPI->SPI_RPR = (unsigned)pCommand->rx_cmd; - AT91C_BASE_SPI->SPI_RCR = pCommand->rx_cmd_size; - AT91C_BASE_SPI->SPI_TPR = (unsigned)pCommand->tx_cmd; - AT91C_BASE_SPI->SPI_TCR = pCommand->tx_cmd_size; + pSPI->SPI_RPR = (unsigned)pCommand->rx_cmd; + pSPI->SPI_RCR = pCommand->rx_cmd_size; + pSPI->SPI_TPR = (unsigned)pCommand->tx_cmd; + pSPI->SPI_TCR = pCommand->tx_cmd_size; - AT91C_BASE_SPI->SPI_TNPR = (unsigned)pCommand->tx_data; - AT91C_BASE_SPI->SPI_TNCR = pCommand->tx_data_size; - AT91C_BASE_SPI->SPI_RNPR = (unsigned)pCommand->rx_data; - AT91C_BASE_SPI->SPI_RNCR = pCommand->rx_data_size; + pSPI->SPI_TNPR = (unsigned)pCommand->tx_data; + pSPI->SPI_TNCR = pCommand->tx_data_size; + pSPI->SPI_RNPR = (unsigned)pCommand->rx_data; + pSPI->SPI_RNCR = pCommand->rx_data_size; - AT91C_BASE_SPI->SPI_PTCR = AT91C_PDC_TXTEN | AT91C_PDC_RXTEN; + pSPI->SPI_PTCR = AT91C_PDC_TXTEN | AT91C_PDC_RXTEN; // wait for completion - i = 100000; - while (!((v = AT91C_BASE_SPI->SPI_SR) & AT91C_SPI_SPENDRX) && --i > 0) { - if ((v & 0xffff) != 0) - printf("V is 0x%x\r\n", v); - continue; - } - if (i == 0) - printf("STALLED! %x\r\n", AT91C_BASE_SPI->SPI_SR); + while (!((v = pSPI->SPI_SR) & AT91C_SPI_SPENDRX)) + Delay(); } @@ -299,4 +308,6 @@ if (((initStatus = GetFlashStatus()) & 0xFC) != 0xBC) printf(" Unexpected SPI flash status: 0x%x\r\n", initStatus); + // Increment real time counter every SLCK + AT91C_BASE_ST->ST_RTMR = 1; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604251709.k3PH9tds038033>