[edk2] [platforms: PATCH 11/11] Drivers/Spi/Devices/MvSpiFlash: Fix bank selection for Spansion

Marcin Wojtas posted 11 patches 7 years, 3 months ago
[edk2] [platforms: PATCH 11/11] Drivers/Spi/Devices/MvSpiFlash: Fix bank selection for Spansion
Posted by Marcin Wojtas 7 years, 3 months 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 | 1 +
 2 files changed, 6 insertions(+)

diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
index bfb8fa3..4c15513 100755
--- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
+++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
@@ -280,6 +280,11 @@ SpiFlashCmdBankaddrWrite (
 {
   UINT8 Cmd = CMD_BANK_WRITE;
 
+  /* Update bank selection command for Spansion */
+  if (Slave->Info->Id[0] == 0x01) {
+    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 b876966..d44c56f 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
-- 
1.8.3.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [platforms: PATCH 11/11] Drivers/Spi/Devices/MvSpiFlash: Fix bank selection for Spansion
Posted by Leif Lindholm 7 years, 3 months ago
On Fri, Sep 01, 2017 at 03:08:23PM +0200, 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 | 1 +
>  2 files changed, 6 insertions(+)
> 
> diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
> index bfb8fa3..4c15513 100755
> --- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
> +++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c
> @@ -280,6 +280,11 @@ SpiFlashCmdBankaddrWrite (
>  {
>    UINT8 Cmd = CMD_BANK_WRITE;
>  
> +  /* Update bank selection command for Spansion */
> +  if (Slave->Info->Id[0] == 0x01) {

Need a #define for that 0x01.

/
    Leif

> +    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 b876966..d44c56f 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
> -- 
> 1.8.3.1
> 
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel