aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-applications/spi-test/files/0001-Modified-the-spi-driver-test-application-to-support-.patch
blob: ebc648e098e6e732b997203db4775a586e959727 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From a059c0737d9f75ce4e62acf3644708e32dc34fc2 Mon Sep 17 00:00:00 2001
From: smavila <smavila@wallaby.amd.com>
Date: Mon, 3 Dec 2018 06:21:04 +0000
Subject: [PATCH] Modified the spi driver  test application to support SPI ROM
 Flash in Wallaby platform

Signed-off-by: smavila <smavila@wallaby.amd.com>
Signed-off-by: Arsalan H. Awan <Arsalan_Awan@mentor.com>
---
 spirom-test.c      | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 spirom-test.c

diff --git a/spirom-test.c b/spirom-test.c
old mode 100644
new mode 100755
index 22c9003..2f10309
--- a/spirom-test.c
+++ b/spirom-test.c
@@ -243,8 +243,23 @@ void parse_cmd(const char *cmdline)
 			return;
 		}
 
+		/* read device ID Command with response */
+		tr.buf[0] = ROM_RDID;
+		tr.direction = RECEIVE;
+		tr.addr_present = 0;
+		tr.len = 3;
+
+		ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
+		if (ret < 1) {
+			printf("\nError executing RDID command\n\n");
+			return;
+		}
+		
+		if( (tr.buf[1] == 0x20) && (tr.buf[2] == 0xbb) && (tr.buf[3] == 0x18))
+			tr.buf[0] = 0xC7; /* N25Q128A SPI ROM needs 0xC7 as erase command */
+		else
+			tr.buf[0] = ROM_CHIP_ERASE;	
 		/* Command without data */
-		tr.buf[0] = ROM_CHIP_ERASE;
 		tr.direction = 0;
 		tr.len = 0;
 		tr.addr_present = 0;
-- 
2.17.1