summaryrefslogtreecommitdiffstats
path: root/sys/boot
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2006-12-20 18:25:16 +0000
committerimp <imp@FreeBSD.org>2006-12-20 18:25:16 +0000
commit4a8daf1b959be7285c549398453bf96766fd4abd (patch)
tree72513a939c8c7ec31c3796de15ff6809494feab7 /sys/boot
parent863d7fa98407e35057721cf03447382c4f2c11e9 (diff)
downloadFreeBSD-src-4a8daf1b959be7285c549398453bf96766fd4abd.zip
FreeBSD-src-4a8daf1b959be7285c549398453bf96766fd4abd.tar.gz
MFp4: Differences in flash part for bwct. need a more generic way to cope.
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/arm/at91/libat91/spi_flash.c31
-rw-r--r--sys/boot/arm/at91/libat91/spi_flash.h4
2 files changed, 35 insertions, 0 deletions
diff --git a/sys/boot/arm/at91/libat91/spi_flash.c b/sys/boot/arm/at91/libat91/spi_flash.c
index 78804b5..ab5f01e 100644
--- a/sys/boot/arm/at91/libat91/spi_flash.c
+++ b/sys/boot/arm/at91/libat91/spi_flash.c
@@ -119,6 +119,23 @@ SPI_ReadFlash(unsigned flash_addr, char *dest_addr, unsigned size)
byteAddress = flash_addr % FLASH_PAGE_SIZE;
p_memset(tx_commandBuffer, 0, 8);
+#ifdef BOOT_BWCT
+ tx_commandBuffer[0] = 0xd2;
+ tx_commandBuffer[1] = ((pageAddress >> 6) & 0xFF);
+ tx_commandBuffer[2] = ((pageAddress << 2) & 0xFC) |
+ ((byteAddress >> 8) & 0x3);
+ tx_commandBuffer[3] = byteAddress & 0xFF;
+ spi_command.tx_cmd = tx_commandBuffer;
+ spi_command.tx_cmd_size = 8;
+ spi_command.tx_data_size = size;
+ spi_command.tx_data = dest_addr;
+
+ p_memset(rx_commandBuffer, 0, 8);
+ spi_command.rx_cmd = rx_commandBuffer;
+ spi_command.rx_cmd_size = 8;
+ spi_command.rx_data_size = size;
+ spi_command.rx_data = dest_addr;
+#else
tx_commandBuffer[0] = CONTINUOUS_ARRAY_READ_HF;
tx_commandBuffer[1] = ((pageAddress >> 5) & 0xFF);
tx_commandBuffer[2] = ((pageAddress << 3) & 0xF8) |
@@ -134,6 +151,7 @@ SPI_ReadFlash(unsigned flash_addr, char *dest_addr, unsigned size)
spi_command.rx_cmd_size = 5;
spi_command.rx_data_size = size;
spi_command.rx_data = dest_addr;
+#endif
SendCommand(&spi_command);
}
@@ -159,11 +177,19 @@ SPI_WriteFlash(unsigned flash_addr, char *src_addr, unsigned size)
byteAddress = flash_addr % FLASH_PAGE_SIZE;
p_memset(tx_commandBuffer, 0, 8);
+#ifdef BOOT_BWCT
+ tx_commandBuffer[0] = 0x82;
+ tx_commandBuffer[1] = ((pageAddress >> 6) & 0xFF);
+ tx_commandBuffer[2] = ((pageAddress << 2) & 0xFC) |
+ ((byteAddress >> 8) & 0x3);
+ tx_commandBuffer[3] = (byteAddress & 0xFF);
+#else
tx_commandBuffer[0] = PROGRAM_THROUGH_BUFFER;
tx_commandBuffer[1] = ((pageAddress >> 5) & 0xFF);
tx_commandBuffer[2] = ((pageAddress << 3) & 0xF8) |
((byteAddress >> 8) & 0x7);
tx_commandBuffer[3] = (byteAddress & 0xFF);
+#endif
p_memset(rx_commandBuffer, 0, 8);
@@ -233,6 +259,11 @@ SPI_InitFlash(void)
// Increment real time counter every SLCK
AT91C_BASE_ST->ST_RTMR = 1;
+#ifdef BOOT_BWCT
+ if (((value = GetFlashStatus()) & 0xFC) != 0xB4)
+ printf(" Bad SPI status: 0x%x\n", value);
+#else
if (((value = GetFlashStatus()) & 0xFC) != 0xBC)
printf(" Bad SPI status: 0x%x\n", value);
+#endif
}
diff --git a/sys/boot/arm/at91/libat91/spi_flash.h b/sys/boot/arm/at91/libat91/spi_flash.h
index e3df2e0..90247e1 100644
--- a/sys/boot/arm/at91/libat91/spi_flash.h
+++ b/sys/boot/arm/at91/libat91/spi_flash.h
@@ -40,7 +40,11 @@ void SPI_InitFlash(void);
void SPI_GetId(unsigned *id);
+#ifdef BOOT_BWCT
+#define FLASH_PAGE_SIZE 528
+#else
#define FLASH_PAGE_SIZE 1056
+#endif
// Flash commands
OpenPOWER on IntegriCloud