PERFORCE change 95860 for review
Warner Losh
imp at FreeBSD.org
Sat Apr 22 03:46:23 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=95860
Change 95860 by imp at imp_hammer on 2006/04/22 03:45:42
Tweaks to try to get Get Id working. kinda.
Affected files ...
.. //depot/projects/arm/src/sys/boot/arm/at91/libat91/spi_flash.c#4 edit
.. //depot/projects/arm/src/sys/boot/arm/at91/libat91/spi_flash.h#4 edit
Differences ...
==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/spi_flash.c#4 (text+ko) ====
@@ -42,9 +42,9 @@
static void
SendCommand(spiCommand_t *pCommand)
{
- unsigned value;
+ unsigned value, i;
- AT91C_BASE_SPI->SPI_PTCR = AT91C_PDC_TXTDIS + AT91C_PDC_RXTDIS;
+ AT91C_BASE_SPI->SPI_PTCR = AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS;
AT91C_BASE_SPI->SPI_RPR = (unsigned)pCommand->rx_cmd;
AT91C_BASE_SPI->SPI_TPR = (unsigned)pCommand->tx_cmd;
@@ -58,12 +58,21 @@
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;
+ } else {
+ AT91C_BASE_SPI->SPI_TNPR = 0;
+ AT91C_BASE_SPI->SPI_TNCR = 0;
+ AT91C_BASE_SPI->SPI_RNPR = 0;
+ AT91C_BASE_SPI->SPI_RNCR = 0;
}
AT91C_BASE_SPI->SPI_PTCR = AT91C_PDC_TXTEN + AT91C_PDC_RXTEN;
+ printf("Wait complete\r\n");
// wait for completion
- while (!((value = AT91C_BASE_SPI->SPI_SR) & AT91C_SPI_SPENDRX)) ;
+ i = 1000000;
+ while (!((value = AT91C_BASE_SPI->SPI_SR) & AT91C_SPI_SPENDRX) &&
+ i > 0) i--;
+ printf("Done %x\r\n", value);
}
@@ -88,9 +97,28 @@
spi_command.tx_cmd_size = 2;
SendCommand(&spi_command);
+ printf("FlashStatus is %x\r\n", rx_commandBuffer[1]);
return (rx_commandBuffer[1]);
}
+void
+SPI_GetId(unsigned *id)
+{
+
+ p_memset(tx_commandBuffer, 0, 8);
+ tx_commandBuffer[0] = 0x9f;
+ p_memset(rx_commandBuffer, 0, 8);
+ spi_command.tx_data_size = 0;
+ spi_command.rx_data_size = 0;
+ spi_command.tx_cmd = tx_commandBuffer;
+ spi_command.rx_cmd = rx_commandBuffer;
+ spi_command.rx_cmd_size = 5;
+ spi_command.tx_cmd_size = 2;
+ SendCommand(&spi_command);
+
+ printf("Id bytes are %x %x %x %x\r\n", rx_commandBuffer[1],
+ rx_commandBuffer[2], rx_commandBuffer[3], rx_commandBuffer[4]);
+}
/*
* .KB_C_FN_DEFINITION_START
@@ -271,6 +299,6 @@
value = pSPI->SPI_RDR;
value = pSPI->SPI_SR;
- if (((initStatus = GetFlashStatus()) & 0xFC) != 0xAC)
+ if (((initStatus = GetFlashStatus()) & 0xFC) != 0xBC)
printf(" Unexpected SPI flash status: 0x%x\r\n", initStatus);
}
==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/spi_flash.h#4 (text+ko) ====
@@ -36,6 +36,8 @@
void SPI_WriteFlash(unsigned flash_addr, char *dest_addr, unsigned size);
void SPI_InitFlash(void);
+void SPI_GetId(unsigned *id);
+
#define FLASH_PAGE_SIZE 1056
// Flash commands
@@ -43,6 +45,6 @@
#define CONTINUOUS_ARRAY_READ 0xE8
#define STATUS_REGISTER_READ 0xD7
#define PROGRAM_THROUGH_BUFFER 0x82
-
+#define MANUFACTURER_ID 0x9F
#endif
More information about the p4-projects
mailing list