Skip to contentSkip to conversation

ssi: xilinx_spips: Filter the non spi registers transactions

PATCH In review Sai Pavan Boddu 3 participants 3 messages Oct 14, 2019 – Oct 17, 2019 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ssi: xilinx_spips: Filter the non spi registers transactions

ZynqMP/Versal specific qspi registers should be handled inside zynqmp_qspi_read/write calls. When few of these transactions are handled by spi hooks we see state change in spi bus unexpectedly.

---
 hw/ssi/xilinx_spips.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
hw/ssi/xilinx_spips.c +24 -2
index a309c71..4f9f8e0 100644
@@ -109,6 +109,7 @@
 #define R_GPIO              (0x30 / 4)
 #define R_LPBK_DLY_ADJ      (0x38 / 4)
 #define R_LPBK_DLY_ADJ_RESET (0x33)
+#define R_IOU_TAPDLY_BYPASS (0x3C / 4)
 #define R_TXD1              (0x80 / 4)
 #define R_TXD2              (0x84 / 4)
 #define R_TXD3              (0x88 / 4)
@@ -139,6 +140,8 @@
 #define R_LQSPI_STS         (0xA4 / 4)
 #define LQSPI_STS_WR_RECVD      (1 << 1)
 
+#define R_DUMMY_CYCLE_EN    (0xC8 / 4)
+#define R_ECO               (0xF8 / 4)
 #define R_MOD_ID            (0xFC / 4)
 
 #define R_GQSPI_SELECT          (0x144 / 4)
@@ -938,7 +941,16 @@ static uint64_t xlnx_zynqmp_qspips_read(void *opaque,
     int shortfall;
 
     if (reg <= R_MOD_ID) {
-        return xilinx_spips_read(opaque, addr, size);
+        switch (addr) {
+        case R_GPIO:
+        case R_LPBK_DLY_ADJ:
+        case R_IOU_TAPDLY_BYPASS:
+        case R_DUMMY_CYCLE_EN:
+        case R_ECO:
+            return s->regs[addr / 4];
+        default:
+            return xilinx_spips_read(opaque, addr, size);
+        }
     } else {
         switch (reg) {
         case R_GQSPI_RXD:
@@ -1063,7 +1075,17 @@ static void xlnx_zynqmp_qspips_write(void *opaque, hwaddr addr,
     uint32_t reg = addr / 4;
 
     if (reg <= R_MOD_ID) {
-        xilinx_qspips_write(opaque, addr, value, size);
+        switch (reg) {
+        case R_GPIO:
+        case R_LPBK_DLY_ADJ:
+        case R_IOU_TAPDLY_BYPASS:
+        case R_DUMMY_CYCLE_EN:
+        case R_ECO:
+            s->regs[addr] = value;
+            break;
+        default:
+            xilinx_qspips_write(opaque, addr, value, size);
+        }
     } else {
         switch (reg) {
         case R_GQSPI_CNFG:
Signature · 1 line
2.7.4
#1 lore raw
Quoted 35 lines · Sai Pavan Boddu

ZynqMP/Versal specific qspi registers should be handled inside zynqmp_qspi_read/write calls. When few of these transactions are handled by spi hooks we see state change in spi bus unexpectedly.

---
 hw/ssi/xilinx_spips.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
hw/ssi/xilinx_spips.c +3 -0
index a309c71..4f9f8e0 100644
@@ -109,6 +109,7 @@
 #define R_GPIO              (0x30 / 4)
 #define R_LPBK_DLY_ADJ      (0x38 / 4)
 #define R_LPBK_DLY_ADJ_RESET (0x33)
+#define R_IOU_TAPDLY_BYPASS (0x3C / 4)
 #define R_TXD1              (0x80 / 4)
 #define R_TXD2              (0x84 / 4)
 #define R_TXD3              (0x88 / 4)
@@ -139,6 +140,8 @@
 #define R_LQSPI_STS         (0xA4 / 4)
 #define LQSPI_STS_WR_RECVD      (1 << 1)
 
+#define R_DUMMY_CYCLE_EN    (0xC8 / 4)
+#define R_ECO               (0xF8 / 4)
 #define R_MOD_ID            (0xFC / 4)
 
 #define R_GQSPI_SELECT          (0x144 / 4)
@@ -938,7 +941,16 @@ static uint64_t xlnx_zynqmp_qspips_read(void *opaque,
     int shortfall;
 
     if (reg <= R_MOD_ID) {

hw/ssi/xilinx_spips.c static uint64_t xlnx_zynqmp_qspips_read(void *opaque, · line 952

Quoted 10 lines
hw/ssi/xilinx_spips.c +9 -1
-        return xilinx_spips_read(opaque, addr, size);
+        switch (addr) {
+        case R_GPIO:
+        case R_LPBK_DLY_ADJ:
+        case R_IOU_TAPDLY_BYPASS:
+        case R_DUMMY_CYCLE_EN:
+        case R_ECO:
+            return s->regs[addr / 4];
+        default:
+            return xilinx_spips_read(opaque, addr, size);

This doesn't seem right. This should have no functional change for the read function and has the consequence of not printing the memory accesses. If you try to debug this code now you won't see all of these operations in the log.

Quoted 10 lines
hw/ssi/xilinx_spips.c +2 -1
+        }
     } else {
         switch (reg) {
         case R_GQSPI_RXD:
@@ -1063,7 +1075,17 @@ static void xlnx_zynqmp_qspips_write(void *opaque, hwaddr addr,
     uint32_t reg = addr / 4;
 
     if (reg <= R_MOD_ID) {
-        xilinx_qspips_write(opaque, addr, value, size);
+        switch (reg) {

hw/ssi/xilinx_spips.c static void xlnx_zynqmp_qspips_write(void *opaque, hwaddr addr, · line 1088

Quoted 10 lines
hw/ssi/xilinx_spips.c +10 -0
+        case R_GPIO:
+        case R_LPBK_DLY_ADJ:
+        case R_IOU_TAPDLY_BYPASS:
+        case R_DUMMY_CYCLE_EN:
+        case R_ECO:
+            s->regs[addr] = value;
+            break;
+        default:
+            xilinx_qspips_write(opaque, addr, value, size);
+        }

For the write code it looks like this skips the "no_reg_update" goto. Maybe that is the issue that you are seeing?

Alistair

Quoted 7 lines
hw/ssi/xilinx_spips.c +0 -1
     } else {
         switch (reg) {
         case R_GQSPI_CNFG:
--

2.7.4

#2 lore raw

Hi Alistair,

Quoted 58 lines

-----Original Message-----
From: Alistair Francis <[email protected]>
Sent: Thursday, October 17, 2019 4:39 AM
To: Sai Pavan Boddu <[email protected]>
Cc: Alistair Francis <[email protected]>; Peter Maydell <[email protected]>; [email protected] Developers <qemu- [email protected]>
Subject: Re: [PATCH] ssi: xilinx_spips: Filter the non spi registers transactions

hw/ssi/xilinx_spips.c static uint64_t xlnx_zynqmp_qspips_read(void

Quoted 32 lines · Sai Pavan Boddu

ZynqMP/Versal specific qspi registers should be handled inside zynqmp_qspi_read/write calls. When few of these transactions are handled by spi hooks we see state change in spi bus unexpectedly.

---
 hw/ssi/xilinx_spips.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
hw/ssi/xilinx_spips.c index renamed from hw/ssi/xilinx_spips.c +0 -0

a309c71..4f9f8e0 100644

hw/ssi/xilinx_spips.c +3 -0
@@ -109,6 +109,7 @@
 #define R_GPIO              (0x30 / 4)
 #define R_LPBK_DLY_ADJ      (0x38 / 4)
 #define R_LPBK_DLY_ADJ_RESET (0x33)
+#define R_IOU_TAPDLY_BYPASS (0x3C / 4)
 #define R_TXD1              (0x80 / 4)
 #define R_TXD2              (0x84 / 4)
 #define R_TXD3              (0x88 / 4)
@@ -139,6 +140,8 @@
 #define R_LQSPI_STS         (0xA4 / 4)
 #define LQSPI_STS_WR_RECVD      (1 << 1)
 
+#define R_DUMMY_CYCLE_EN    (0xC8 / 4)
+#define R_ECO               (0xF8 / 4)
 #define R_MOD_ID            (0xFC / 4)
 
 #define R_GQSPI_SELECT          (0x144 / 4)
@@ -938,7 +941,16 @@ static uint64_t xlnx_zynqmp_qspips_read(void

*opaque,

hw/ssi/xilinx_spips.c static uint64_t xlnx_zynqmp_qspips_read(void *opaque, · line 952

Quoted 13 lines
hw/ssi/xilinx_spips.c +9 -1
     int shortfall;
 
     if (reg <= R_MOD_ID) {
-        return xilinx_spips_read(opaque, addr, size);
+        switch (addr) {
+        case R_GPIO:
+        case R_LPBK_DLY_ADJ:
+        case R_IOU_TAPDLY_BYPASS:
+        case R_DUMMY_CYCLE_EN:
+        case R_ECO:
+            return s->regs[addr / 4];
+        default:
+            return xilinx_spips_read(opaque, addr, size);
Quoted 4 lines

This doesn't seem right. This should have no functional change for the read function and has the consequence of not printing the memory accesses. If you try to debug this code now you won't see all of these operations in the log.

[Sai Pavan Boddu] Yeah reads do not have any issue. But I see your point of debug prints.

Quoted 23 lines

hw/ssi/xilinx_spips.c static void xlnx_zynqmp_qspips_write(void

Quoted 6 lines
hw/ssi/xilinx_spips.c +1 -0
+        }
     } else {
         switch (reg) {
         case R_GQSPI_RXD:
@@ -1063,7 +1075,17 @@ static void xlnx_zynqmp_qspips_write(void

*opaque, hwaddr addr,

Quoted 5 lines
hw/ssi/xilinx_spips.c +1 -1
     uint32_t reg = addr / 4;
 
     if (reg <= R_MOD_ID) {
-        xilinx_qspips_write(opaque, addr, value, size);
+        switch (reg) {

hw/ssi/xilinx_spips.c static void xlnx_zynqmp_qspips_write(void *opaque, hwaddr addr, · line 1088

Quoted 10 lines
hw/ssi/xilinx_spips.c +10 -0
+        case R_GPIO:
+        case R_LPBK_DLY_ADJ:
+        case R_IOU_TAPDLY_BYPASS:
+        case R_DUMMY_CYCLE_EN:
+        case R_ECO:
+            s->regs[addr] = value;
+            break;
+        default:
+            xilinx_qspips_write(opaque, addr, value, size);
+        }
Quoted 2 lines

For the write code it looks like this skips the "no_reg_update" goto. Maybe that is the issue that you are seeing?

[Sai Pavan Boddu] yes, no_reg_update triggers update of cs lines. We can also put a check there to skip no_reg_update when it’s a zynqmp qspi. I will try that and send a V2.

Thanks
Sai Pavan

Quoted 10 lines

Alistair

Quoted 7 lines
hw/ssi/xilinx_spips.c +0 -1
     } else {
         switch (reg) {
         case R_GQSPI_CNFG:
--

2.7.4