Skip to contentSkip to conversation

xilinx_spips: Update CS assertion when striping

PATCH Superseded Francisco Iglesias 2 participants 6 messages Feb 22, 2018 – Feb 23, 2018 Arm/Zynq architecture

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover xilinx_spips: Update CS assertion when striping

Hi,

The first patch in this series attempts to correct the slave selection when using the striping functionality in the QSPI. The second patch in the series updates the QIOR/QIOR4 commands to use 8 dummy cycles in the QSPI for matching Micron (Numonyx) flashes (the default target flash type of the QSPI).

Best regards,
Francisco Iglesias

Francisco Iglesias (2):
xilinx_spips: Enable only two slaves when reading/writing with stripe
xilinx_spips: Use 8 dummy cycles with the QIOR/QIOR4 commands

 hw/ssi/xilinx_spips.c | 44 +++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 39 insertions(+), 5 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/2 xilinx_spips: Enable only two slaves when reading/writing with stripe

Assert only the lower cs on bus 0 and upper cs on bus 1 when both buses and chip selects are enabled (e.g reading/writing with stripe).

---
 hw/ssi/xilinx_spips.c | 42 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)
hw/ssi/xilinx_spips.c +38 -4
index 8af36ca3d4..e566d179fe 100644
@@ -223,7 +223,7 @@ static void xilinx_spips_update_cs(XilinxSPIPS *s, int field)
 {
     int i;
 
-    for (i = 0; i < s->num_cs; i++) {
+    for (i = 0; i < s->num_cs * s->num_busses; i++) {
         bool old_state = s->cs_lines_state[i];
         bool new_state = field & (1 << i);
 
@@ -234,7 +234,7 @@ static void xilinx_spips_update_cs(XilinxSPIPS *s, int field)
         }
         qemu_set_irq(s->cs_lines[i], !new_state);
     }
-    if (!(field & ((1 << s->num_cs) - 1))) {
+    if (!(field & ((1 << (s->num_cs * s->num_busses)) - 1))) {
         s->snoop_state = SNOOP_CHECKING;
         s->cmd_dummies = 0;
         s->link_state = 1;
@@ -248,7 +248,41 @@ static void xlnx_zynqmp_qspips_update_cs_lines(XlnxZynqMPQSPIPS *s)
 {
     if (s->regs[R_GQSPI_GF_SNAPSHOT]) {
         int field = ARRAY_FIELD_EX32(s->regs, GQSPI_GF_SNAPSHOT, CHIP_SELECT);
-        xilinx_spips_update_cs(XILINX_SPIPS(s), field);
+        bool both_buses_enabled;
+        uint8_t buses;
+        int cs = 0;
+
+        buses = ARRAY_FIELD_EX32(s->regs, GQSPI_GF_SNAPSHOT, DATA_BUS_SELECT);
+        both_buses_enabled = (buses & 0x3) == 0x3;
+
+        if (both_buses_enabled) {
+            /* Bus 0 lower cs */
+            if (field & 1) {
+                cs |= 1;
+            }
+            /* Bus 1 upper cs */
+            if (field & (1 << 1)) {
+                cs |= 1 << 3;
+            }
+        } else {
+            /* Bus 0 lower cs */
+            if (buses & 1 && field & 1) {
+                cs |= 1;
+            }
+            /* Bus 0 upper cs */
+            if (buses & 1 && field & (1 << 1)) {
+                cs |= 1 << 1;
+            }
+            /* Bus 1 lower cs */
+            if (buses & (1 << 1) && field & 1) {
+                cs |= 1 << 2;
+            }
+            /* Bus 1 upper cs */
+            if (buses & (1 << 1) && field & (1 << 1)) {
+                cs |= 1 << 3;
+            }
+        }
+        xilinx_spips_update_cs(XILINX_SPIPS(s), cs);
     }
 }
 
@@ -260,7 +294,7 @@ static void xilinx_spips_update_cs_lines(XilinxSPIPS *s)
     if (num_effective_busses(s) == 2) {
         /* Single bit chip-select for qspi */
         field &= 0x1;
-        field |= field << 1;
+        field |= field << 3;
     /* Dual stack U-Page */
     } else if (s->regs[R_LQSPI_CFG] & LQSPI_CFG_TWO_MEM &&
                s->regs[R_LQSPI_STS] & LQSPI_CFG_U_PAGE) {
Signature · 1 line
2.11.0
Tested-by on v1 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] xilinx_spips: Enable only two slaves when reading/writing with stripe

Quoted 58 lines · Francisco Iglesias

Assert only the lower cs on bus 0 and upper cs on bus 1 when both buses and chip selects are enabled (e.g reading/writing with stripe).

---
 hw/ssi/xilinx_spips.c | 42 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)
hw/ssi/xilinx_spips.c +25 -3
index 8af36ca3d4..e566d179fe 100644
@@ -223,7 +223,7 @@ static void xilinx_spips_update_cs(XilinxSPIPS *s, int field)
 {
     int i;
 
-    for (i = 0; i < s->num_cs; i++) {
+    for (i = 0; i < s->num_cs * s->num_busses; i++) {
         bool old_state = s->cs_lines_state[i];
         bool new_state = field & (1 << i);
 
@@ -234,7 +234,7 @@ static void xilinx_spips_update_cs(XilinxSPIPS *s, int field)
         }
         qemu_set_irq(s->cs_lines[i], !new_state);
     }
-    if (!(field & ((1 << s->num_cs) - 1))) {
+    if (!(field & ((1 << (s->num_cs * s->num_busses)) - 1))) {
         s->snoop_state = SNOOP_CHECKING;
         s->cmd_dummies = 0;
         s->link_state = 1;
@@ -248,7 +248,41 @@ static void xlnx_zynqmp_qspips_update_cs_lines(XlnxZynqMPQSPIPS *s)
 {
     if (s->regs[R_GQSPI_GF_SNAPSHOT]) {
         int field = ARRAY_FIELD_EX32(s->regs, GQSPI_GF_SNAPSHOT, CHIP_SELECT);
-        xilinx_spips_update_cs(XILINX_SPIPS(s), field);
+        bool both_buses_enabled;
+        uint8_t buses;
+        int cs = 0;
+
+        buses = ARRAY_FIELD_EX32(s->regs, GQSPI_GF_SNAPSHOT, DATA_BUS_SELECT);
+        both_buses_enabled = (buses & 0x3) == 0x3;
+
+        if (both_buses_enabled) {
+            /* Bus 0 lower cs */
+            if (field & 1) {
+                cs |= 1;
+            }
+            /* Bus 1 upper cs */
+            if (field & (1 << 1)) {
+                cs |= 1 << 3;
+            }
+        } else {
+            /* Bus 0 lower cs */
+            if (buses & 1 && field & 1) {
+                cs |= 1;
+            }
+            /* Bus 0 upper cs */
+            if (buses & 1 && field & (1 << 1)) {

hw/ssi/xilinx_spips.c static void xlnx_zynqmp_qspips_update_cs_lines(XlnxZynqMPQSPIPS *s) · line 283

Quoted 10 lines
hw/ssi/xilinx_spips.c +10 -0
+                cs |= 1 << 1;
+            }
+            /* Bus 1 lower cs */
+            if (buses & (1 << 1) && field & 1) {
+                cs |= 1 << 2;
+            }
+            /* Bus 1 upper cs */
+            if (buses & (1 << 1) && field & (1 << 1)) {
+                cs |= 1 << 3;
+            }

It might make more sense to have the buses & 1 in it's own if statement and have nested if statements here. Just to be easier to follow.

Alistair

Quoted 18 lines
hw/ssi/xilinx_spips.c +3 -2
+        }
+        xilinx_spips_update_cs(XILINX_SPIPS(s), cs);
     }
 }
 
@@ -260,7 +294,7 @@ static void xilinx_spips_update_cs_lines(XilinxSPIPS *s)
     if (num_effective_busses(s) == 2) {
         /* Single bit chip-select for qspi */
         field &= 0x1;
-        field |= field << 1;
+        field |= field << 3;
     /* Dual stack U-Page */
     } else if (s->regs[R_LQSPI_CFG] & LQSPI_CFG_TWO_MEM &&
                s->regs[R_LQSPI_STS] & LQSPI_CFG_U_PAGE) {
--

2.11.0

#3 lore raw

Re: [Qemu-devel] [PATCH 1/2] xilinx_spips: Enable only two slaves when reading/writing with stripe

Quoted 81 lines · Alistair Francis
Quoted 1 line · Francisco Iglesias

Assert only the lower cs on bus 0 and upper cs on bus 1 when both buses

and

hw/ssi/xilinx_spips.c static void xilinx_spips_update_cs(XilinxSPIPS *s,

Quoted 12 lines

chip selects are enabled (e.g reading/writing with stripe).

---
 hw/ssi/xilinx_spips.c | 42 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)
hw/ssi/xilinx_spips.c +0 -0
index 8af36ca3d4..e566d179fe 100644
@@ -223,7 +223,7 @@ static void xilinx_spips_update_cs(XilinxSPIPS *s,

int field)

hw/ssi/xilinx_spips.c static void xilinx_spips_update_cs(XilinxSPIPS *s,

Quoted 9 lines
hw/ssi/xilinx_spips.c +1 -1
 {
     int i;
 
-    for (i = 0; i < s->num_cs; i++) {
+    for (i = 0; i < s->num_cs * s->num_busses; i++) {
         bool old_state = s->cs_lines_state[i];
         bool new_state = field & (1 << i);
 
@@ -234,7 +234,7 @@ static void xilinx_spips_update_cs(XilinxSPIPS *s,

int field)

hw/ssi/xilinx_spips.c static void xlnx_zynqmp_qspips_update_cs_lines(XlnxZynqMPQSPIPS

Quoted 9 lines
hw/ssi/xilinx_spips.c +1 -1
         }
         qemu_set_irq(s->cs_lines[i], !new_state);
     }
-    if (!(field & ((1 << s->num_cs) - 1))) {
+    if (!(field & ((1 << (s->num_cs * s->num_busses)) - 1))) {
         s->snoop_state = SNOOP_CHECKING;
         s->cmd_dummies = 0;
         s->link_state = 1;
@@ -248,7 +248,41 @@ static void xlnx_zynqmp_qspips_update_cs_lines(XlnxZynqMPQSPIPS

*s)

hw/ssi/xilinx_spips.c static void xlnx_zynqmp_qspips_update_cs_lines(XlnxZynqMPQSPIPS *s)

Quoted 3 lines
hw/ssi/xilinx_spips.c +0 -0
 {
     if (s->regs[R_GQSPI_GF_SNAPSHOT]) {
         int field = ARRAY_FIELD_EX32(s->regs, GQSPI_GF_SNAPSHOT,

CHIP_SELECT);

hw/ssi/xilinx_spips.c static void xlnx_zynqmp_qspips_update_cs_lines(XlnxZynqMPQSPIPS *s)

Quoted 6 lines
hw/ssi/xilinx_spips.c +5 -1
-        xilinx_spips_update_cs(XILINX_SPIPS(s), field);
+        bool both_buses_enabled;
+        uint8_t buses;
+        int cs = 0;
+
+        buses = ARRAY_FIELD_EX32(s->regs, GQSPI_GF_SNAPSHOT,

DATA_BUS_SELECT);

Quoted 18 lines
hw/ssi/xilinx_spips.c +18 -0
+        both_buses_enabled = (buses & 0x3) == 0x3;
+
+        if (both_buses_enabled) {
+            /* Bus 0 lower cs */
+            if (field & 1) {
+                cs |= 1;
+            }
+            /* Bus 1 upper cs */
+            if (field & (1 << 1)) {
+                cs |= 1 << 3;
+            }
+        } else {
+            /* Bus 0 lower cs */
+            if (buses & 1 && field & 1) {
+                cs |= 1;
+            }
+            /* Bus 0 upper cs */
+            if (buses & 1 && field & (1 << 1)) {

hw/ssi/xilinx_spips.c static void xlnx_zynqmp_qspips_update_cs_lines(XlnxZynqMPQSPIPS *s) · line 283

Quoted 10 lines
hw/ssi/xilinx_spips.c +10 -0
+                cs |= 1 << 1;
+            }
+            /* Bus 1 lower cs */
+            if (buses & (1 << 1) && field & 1) {
+                cs |= 1 << 2;
+            }
+            /* Bus 1 upper cs */
+            if (buses & (1 << 1) && field & (1 << 1)) {
+                cs |= 1 << 3;
+            }

It might make more sense to have the buses & 1 in it's own if statement and have nested if statements here. Just to be easier to follow.

Quoted 5 lines

Alistair

Hi Alistair,

Thank you very much for reviewing and testing! Good point above, I'll do a new version of the patch doing this.

Best regards,
Francisco Iglesias

Quoted 20 lines

hw/ssi/xilinx_spips.c static void xilinx_spips_update_cs_lines(XilinxSPIPS

Quoted 6 lines
hw/ssi/xilinx_spips.c +2 -0
+        }
+        xilinx_spips_update_cs(XILINX_SPIPS(s), cs);
     }
 }
 
@@ -260,7 +294,7 @@ static void xilinx_spips_update_cs_lines(XilinxSPIPS

*s)

Quoted 12 lines
hw/ssi/xilinx_spips.c +1 -2
     if (num_effective_busses(s) == 2) {
         /* Single bit chip-select for qspi */
         field &= 0x1;
-        field |= field << 1;
+        field |= field << 3;
     /* Dual stack U-Page */
     } else if (s->regs[R_LQSPI_CFG] & LQSPI_CFG_TWO_MEM &&
                s->regs[R_LQSPI_STS] & LQSPI_CFG_U_PAGE) {
--

2.11.0

#4 lore raw

PATCH 2/2 xilinx_spips: Use 8 dummy cycles with the QIOR/QIOR4 commands

In reply to Francisco Iglesias

Use 8 dummy cycles (4 dummy bytes) with the QIOR/QIOR4 commands in legacy mode for matching what is expected by Micron (Numonyx) flashes (the default target flash type of the QSPI).

---
 hw/ssi/xilinx_spips.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ssi/xilinx_spips.c +1 -1
index e566d179fe..eb7fc0ea71 100644
@@ -578,7 +578,7 @@ static int xilinx_spips_num_dummies(XilinxQSPIPS *qs, uint8_t command)
         return 2;
     case QIOR:
     case QIOR_4:
-        return 5;
+        return 4;
     default:
         return -1;
     }
Signature · 1 line
2.11.0
Tested-by Reviewed-by on v1 2/2
#5 lore raw

Re: [Qemu-devel] [PATCH 2/2] xilinx_spips: Use 8 dummy cycles with the QIOR/QIOR4 commands

Quoted 5 lines · Francisco Iglesias

Use 8 dummy cycles (4 dummy bytes) with the QIOR/QIOR4 commands in legacy mode for matching what is expected by Micron (Numonyx) flashes (the default target flash type of the QSPI).

Tested on Xilinx's ZynqMP

Alistair

Quoted 21 lines
---
 hw/ssi/xilinx_spips.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ssi/xilinx_spips.c +1 -2
index e566d179fe..eb7fc0ea71 100644
@@ -578,7 +578,7 @@ static int xilinx_spips_num_dummies(XilinxQSPIPS *qs, uint8_t command)
         return 2;
     case QIOR:
     case QIOR_4:
-        return 5;
+        return 4;
     default:
         return -1;
     }
--

2.11.0