From owner-p4-projects@FreeBSD.ORG Tue Apr 25 17:09:56 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B21C616A404; Tue, 25 Apr 2006 17:09:56 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8C6C516A401 for ; Tue, 25 Apr 2006 17:09:56 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3EAD043D49 for ; Tue, 25 Apr 2006 17:09:56 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k3PH9uDn038039 for ; Tue, 25 Apr 2006 17:09:56 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3PH9tds038033 for perforce@freebsd.org; Tue, 25 Apr 2006 17:09:55 GMT (envelope-from imp@freebsd.org) Date: Tue, 25 Apr 2006 17:09:55 GMT Message-Id: <200604251709.k3PH9tds038033@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 96070 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Apr 2006 17:09:56 -0000 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; }