[edk2] [platforms: PATCH 5/6] Marvell/Drivers: MvSpiFlash: Fix bank selection for Spansion

Marcin Wojtas posted 6 patches 7 years, 1 month ago
There is a newer version of this series
[edk2] [platforms: PATCH 5/6] Marvell/Drivers: MvSpiFlash: Fix bank selection for Spansion
Posted by Marcin Wojtas 7 years, 1 month ago
Spansion SPI flash devices use different command for bank
selection. Update it, basing on the first byte of flash ID.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
 Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c | 5 +++++
 Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
index 703994c..a00fc305 100755
--- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
+++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
@@ -150,6 +150,11 @@ SpiFlashCmdBankaddrWrite (
 {
   UINT8 Cmd = CMD_BANK_WRITE;
 
+  /* Update bank selection command for Spansion */
+  if (Slave->Info->Id[0] == SPI_FLASH_MFR_SPANSION) {
+    Cmd = CMD_BANKADDR_BRWR;
+  }
+
   MvSpiFlashWriteCommon (Slave, &Cmd, 1, &BankSel, 1);
 }
 
diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h
index 2583484..00af188 100755
--- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h
+++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h
@@ -57,6 +57,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define CMD_READ_ARRAY_FAST             0x0b
 #define CMD_PAGE_PROGRAM                0x02
 #define CMD_BANK_WRITE                  0xc5
+#define CMD_BANKADDR_BRWR               0x17
 #define CMD_ERASE_4K                    0x20
 #define CMD_ERASE_32K                   0x52
 #define CMD_ERASE_64K                   0xd8
@@ -72,6 +73,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #define SPI_FLASH_16MB_BOUN             0x1000000
 
+/* Manufacturer ID's */
+#define SPI_FLASH_MFR_SPANSION          0x01
+
 typedef enum {
   SPI_FLASH_READ_ID,
   SPI_FLASH_READ, // Read from SPI flash with address
-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [platforms: PATCH 5/6] Marvell/Drivers: MvSpiFlash: Fix bank selection for Spansion
Posted by Leif Lindholm 7 years, 1 month ago
On Tue, Oct 31, 2017 at 04:59:34AM +0100, Marcin Wojtas wrote:
> Spansion SPI flash devices use different command for bank
> selection. Update it, basing on the first byte of flash ID.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas <mw@semihalf.com>
> ---
>  Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c | 5 +++++
>  Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h | 4 ++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
> index 703994c..a00fc305 100755
> --- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
> +++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
> @@ -150,6 +150,11 @@ SpiFlashCmdBankaddrWrite (
>  {
>    UINT8 Cmd = CMD_BANK_WRITE;
>  
> +  /* Update bank selection command for Spansion */
> +  if (Slave->Info->Id[0] == SPI_FLASH_MFR_SPANSION) {
> +    Cmd = CMD_BANKADDR_BRWR;
> +  }
> +
>    MvSpiFlashWriteCommon (Slave, &Cmd, 1, &BankSel, 1);
>  }
>  
> diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h
> index 2583484..00af188 100755
> --- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h
> +++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h
> @@ -57,6 +57,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>  #define CMD_READ_ARRAY_FAST             0x0b
>  #define CMD_PAGE_PROGRAM                0x02
>  #define CMD_BANK_WRITE                  0xc5
> +#define CMD_BANKADDR_BRWR               0x17
>  #define CMD_ERASE_4K                    0x20
>  #define CMD_ERASE_32K                   0x52
>  #define CMD_ERASE_64K                   0xd8
> @@ -72,6 +73,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>  
>  #define SPI_FLASH_16MB_BOUN             0x1000000
>  
> +/* Manufacturer ID's */
> +#define SPI_FLASH_MFR_SPANSION          0x01
> +

Please move this definition to NorFlashInfoLib.
Otherwise this patch looks OK.

/
    Leif

>  typedef enum {
>    SPI_FLASH_READ_ID,
>    SPI_FLASH_READ, // Read from SPI flash with address
> -- 
> 2.7.4
> 
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [platforms: PATCH 5/6] Marvell/Drivers: MvSpiFlash: Fix bank selection for Spansion
Posted by Marcin Wojtas 7 years, 1 month ago
2017-11-01 4:50 GMT+01:00 Leif Lindholm <leif.lindholm@linaro.org>:
> On Tue, Oct 31, 2017 at 04:59:34AM +0100, Marcin Wojtas wrote:
>> Spansion SPI flash devices use different command for bank
>> selection. Update it, basing on the first byte of flash ID.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Marcin Wojtas <mw@semihalf.com>
>> ---
>>  Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c | 5 +++++
>>  Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h | 4 ++++
>>  2 files changed, 9 insertions(+)
>>
>> diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
>> index 703994c..a00fc305 100755
>> --- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
>> +++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
>> @@ -150,6 +150,11 @@ SpiFlashCmdBankaddrWrite (
>>  {
>>    UINT8 Cmd = CMD_BANK_WRITE;
>>
>> +  /* Update bank selection command for Spansion */
>> +  if (Slave->Info->Id[0] == SPI_FLASH_MFR_SPANSION) {
>> +    Cmd = CMD_BANKADDR_BRWR;
>> +  }
>> +
>>    MvSpiFlashWriteCommon (Slave, &Cmd, 1, &BankSel, 1);
>>  }
>>
>> diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h
>> index 2583484..00af188 100755
>> --- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h
>> +++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h
>> @@ -57,6 +57,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>>  #define CMD_READ_ARRAY_FAST             0x0b
>>  #define CMD_PAGE_PROGRAM                0x02
>>  #define CMD_BANK_WRITE                  0xc5
>> +#define CMD_BANKADDR_BRWR               0x17
>>  #define CMD_ERASE_4K                    0x20
>>  #define CMD_ERASE_32K                   0x52
>>  #define CMD_ERASE_64K                   0xd8
>> @@ -72,6 +73,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>>
>>  #define SPI_FLASH_16MB_BOUN             0x1000000
>>
>> +/* Manufacturer ID's */
>> +#define SPI_FLASH_MFR_SPANSION          0x01
>> +
>
> Please move this definition to NorFlashInfoLib.
> Otherwise this patch looks OK.
>

Ok.

Thanks,
Marcin
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel