Skip to contentSkip to conversation

arm socfpga: Revert "spi: cadence_qspi_apb: Support 32 bit AHB address"

U-Boot Frank Mori Hess 2 participants 6 messages Dec 3, 2017 – Dec 4, 2017 SPI

lore
Share & tools
lore
#0 lore raw

This reverts commit dac3bf20fb2c9b03476be0d73db620f62ab3cee1.

My u-boot spl crashes in a loop when I boot off a
cadence qspi flash. I narrowed it down to the changes from commit dac3bf20fb2c9b03476be0d73db620f62ab3cee1 which removes CQSPI_INDIRECTTRIGGER_ADDR_MASK. Restoring the mask allows the spl to successfully load the main u-boot. My board is an Altera HPS cyclone V socfpga. It has an ahb base address of 0xffa00000 and for some reason, without the CQSPI_INDIRECTTRIGGER_ADDR_MASK the board reboots when cadence_qspi_apb_indirect_read_execute tries to read from the ahb base address. I'm was using version 2016.11 of u-boot.

---
 drivers/spi/cadence_qspi_apb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/cadence_qspi_apb.c +3 -2
index e02f2217f4..b300f36607 100644
@@ -47,6 +47,7 @@
 #define CQSPI_INST_TYPE_QUAD			2
 
 #define CQSPI_STIG_DATA_LEN_MAX			8
+#define CQSPI_INDIRECTTRIGGER_ADDR_MASK		0xFFFFF
 
 #define CQSPI_DUMMY_CLKS_PER_BYTE		8
 #define CQSPI_DUMMY_BYTES_MAX			4
@@ -560,7 +561,7 @@ int cadence_qspi_apb_indirect_read_setup(struct cadence_spi_platdata *plat,
 		addr_bytes = cmdlen - 1;
 
 	/* Setup the indirect trigger address */
-	writel((u32)plat->ahbbase,
+	writel(((u32)plat->ahbbase & CQSPI_INDIRECTTRIGGER_ADDR_MASK),
 	       plat->regbase + CQSPI_REG_INDIRECTTRIGGER);
 
 	/* Configure the opcode */
@@ -710,7 +711,7 @@ int cadence_qspi_apb_indirect_write_setup(struct cadence_spi_platdata *plat,
 		return -EINVAL;
 	}
 	/* Setup the indirect trigger address */
-	writel((u32)plat->ahbbase,
+	writel(((u32)plat->ahbbase & CQSPI_INDIRECTTRIGGER_ADDR_MASK),
 	       plat->regbase + CQSPI_REG_INDIRECTTRIGGER);
 
 	/* Configure the opcode */
Signature · 1 line
2.11.0
#1 lore raw
Quoted 11 lines · Frank Mori Hess

This reverts commit dac3bf20fb2c9b03476be0d73db620f62ab3cee1.

My u-boot spl crashes in a loop when I boot off a
cadence qspi flash. I narrowed it down to the changes from commit dac3bf20fb2c9b03476be0d73db620f62ab3cee1 which removes CQSPI_INDIRECTTRIGGER_ADDR_MASK. Restoring the mask allows the spl to successfully load the main u-boot. My board is an Altera HPS cyclone V socfpga. It has an ahb base address of 0xffa00000 and for some reason, without the CQSPI_INDIRECTTRIGGER_ADDR_MASK the board reboots when cadence_qspi_apb_indirect_read_execute tries to read from the ahb base address. I'm was using version 2016.11 of u-boot.

This breaks TI platforms where INDIRECTTRIGGER_ADDR is 32bit wide. Instead please try this patch series which adds cdns,trigger-address DT
property: http://patchwork.ozlabs.org/patch/838589/

Regards
Vignesh

Quoted 37 lines
---
 drivers/spi/cadence_qspi_apb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/cadence_qspi_apb.c +3 -2
index e02f2217f4..b300f36607 100644
@@ -47,6 +47,7 @@
 #define CQSPI_INST_TYPE_QUAD			2
 
 #define CQSPI_STIG_DATA_LEN_MAX			8
+#define CQSPI_INDIRECTTRIGGER_ADDR_MASK		0xFFFFF
 
 #define CQSPI_DUMMY_CLKS_PER_BYTE		8
 #define CQSPI_DUMMY_BYTES_MAX			4
@@ -560,7 +561,7 @@ int cadence_qspi_apb_indirect_read_setup(struct cadence_spi_platdata *plat,
 		addr_bytes = cmdlen - 1;
 
 	/* Setup the indirect trigger address */
-	writel((u32)plat->ahbbase,
+	writel(((u32)plat->ahbbase & CQSPI_INDIRECTTRIGGER_ADDR_MASK),
 	       plat->regbase + CQSPI_REG_INDIRECTTRIGGER);
 
 	/* Configure the opcode */
@@ -710,7 +711,7 @@ int cadence_qspi_apb_indirect_write_setup(struct cadence_spi_platdata *plat,
 		return -EINVAL;
 	}
 	/* Setup the indirect trigger address */
-	writel((u32)plat->ahbbase,
+	writel(((u32)plat->ahbbase & CQSPI_INDIRECTTRIGGER_ADDR_MASK),
 	       plat->regbase + CQSPI_REG_INDIRECTTRIGGER);
 
 	/* Configure the opcode */
#2 lore raw

Since your commit broke my platform to fix yours, shouldn't it be reverted and TI platforms use your pending patch queue?

On Dec 3, 2017 23:14, "Vignesh R" <[email protected]> wrote:

Quoted 11 lines · Frank Mori Hess

This reverts commit dac3bf20fb2c9b03476be0d73db620f62ab3cee1.

My u-boot spl crashes in a loop when I boot off a
cadence qspi flash. I narrowed it down to the changes from commit dac3bf20fb2c9b03476be0d73db620f62ab3cee1 which removes CQSPI_INDIRECTTRIGGER_ADDR_MASK. Restoring the mask allows the spl to successfully load the main u-boot. My board is an Altera HPS cyclone V socfpga. It has an ahb base address of 0xffa00000 and for some reason, without the CQSPI_INDIRECTTRIGGER_ADDR_MASK the board reboots when cadence_qspi_apb_indirect_read_execute tries to read from the ahb base address. I'm was using version 2016.11 of u-boot.

This breaks TI platforms where INDIRECTTRIGGER_ADDR is 32bit wide. Instead please try this patch series which adds cdns,trigger-address DT
property: http://patchwork.ozlabs.org/patch/838589/

Regards
Vignesh

drivers/spi/cadence_qspi_apb

Quoted 7 lines
---
 drivers/spi/cadence_qspi_apb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/cadence_qspi_apb renamed from drivers/spi/cadence_qspi_apb.c +0 -0

.c

drivers/spi/cadence_qspi_apb.c int cadence_qspi_apb_indirect_read_setup(struct

Quoted 12 lines

index e02f2217f4..b300f36607 100644

drivers/spi/cadence_qspi_apb.c +1 -0
@@ -47,6 +47,7 @@
 #define CQSPI_INST_TYPE_QUAD                 2
 
 #define CQSPI_STIG_DATA_LEN_MAX                      8
+#define CQSPI_INDIRECTTRIGGER_ADDR_MASK              0xFFFFF
 
 #define CQSPI_DUMMY_CLKS_PER_BYTE            8
 #define CQSPI_DUMMY_BYTES_MAX                        4
@@ -560,7 +561,7 @@ int cadence_qspi_apb_indirect_read_setup(struct

cadence_spi_platdata *plat,

drivers/spi/cadence_qspi_apb.c int cadence_qspi_apb_indirect_write_setup(struct

Quoted 9 lines
drivers/spi/cadence_qspi_apb.c +1 -1
              addr_bytes = cmdlen - 1;
 
      /* Setup the indirect trigger address */
-     writel((u32)plat->ahbbase,
+     writel(((u32)plat->ahbbase & CQSPI_INDIRECTTRIGGER_ADDR_MASK),
             plat->regbase + CQSPI_REG_INDIRECTTRIGGER);
 
      /* Configure the opcode */
@@ -710,7 +711,7 @@ int cadence_qspi_apb_indirect_write_setup(struct

cadence_spi_platdata *plat,

Quoted 9 lines
drivers/spi/cadence_qspi_apb.c +1 -1
              return -EINVAL;
      }
      /* Setup the indirect trigger address */
-     writel((u32)plat->ahbbase,
+     writel(((u32)plat->ahbbase & CQSPI_INDIRECTTRIGGER_ADDR_MASK),
             plat->regbase + CQSPI_REG_INDIRECTTRIGGER);
 
      /* Configure the opcode */
#3 lore raw

Hi,

Quoted 3 lines · Frank Mori Hess

Since your commit broke my platform to fix yours, shouldn't it be reverted and TI platforms use your pending patch queue?

Socfpga DT defined ahb base as 0xffa00000 while masked upper bits in the code, which was confusing. And seems that my patch did work on some socfgpa board looking at the original commit message.
If the patch is reverted then, applying pending patches alone will not help because my patch would be needed anyway to make sure we don't mask 31-20 bits on TI platforms.
Therefore instead of reverting and the re-applying, I would recommend to ping SPI maintainer to get http://patchwork.ozlabs.org/patch/838589/
merged as early as possible.

Quoted 69 lines

On Dec 3, 2017 23:14, "Vignesh R" <[email protected] <mailto:[email protected]>> wrote:

    On Sunday 03 December 2017 09:29 PM, Frank Mori Hess wrote:
    > This reverts commit dac3bf20fb2c9b03476be0d73db620f62ab3cee1.
    >
    > My u-boot spl crashes in a loop when I boot off a
    > cadence qspi flash.  I narrowed it down to the changes from commit
    > dac3bf20fb2c9b03476be0d73db620f62ab3cee1 which removes
    > CQSPI_INDIRECTTRIGGER_ADDR_MASK.  Restoring the mask allows the spl to
    > successfully load the main u-boot.  My board is an Altera HPS cyclone
    > V socfpga.  It has an ahb base address of 0xffa00000 and for some
    > reason, without the CQSPI_INDIRECTTRIGGER_ADDR_MASK the board reboots
    > when cadence_qspi_apb_indirect_read_execute tries to read from the ahb
    > base address.  I'm was using version 2016.11 of u-boot.

    This breaks TI platforms where INDIRECTTRIGGER_ADDR is 32bit wide.
    Instead please try this patch series which adds cdns,trigger-address DT
    property: http://patchwork.ozlabs.org/patch/838589/
    <http://patchwork.ozlabs.org/patch/838589/>

    Regards
    Vignesh

    >
    > Signed-off-by: Frank Mori Hess <[email protected]
    <mailto:[email protected]>>
    > ---
    >  drivers/spi/cadence_qspi_apb.c | 5 +++--
    >  1 file changed, 3 insertions(+), 2 deletions(-)
    >
    > diff --git a/drivers/spi/cadence_qspi_apb.c
    b/drivers/spi/cadence_qspi_apb.c
    > index e02f2217f4..b300f36607 100644
    > --- a/drivers/spi/cadence_qspi_apb.c
    > +++ b/drivers/spi/cadence_qspi_apb.c
    > @@ -47,6 +47,7 @@
    >  #define CQSPI_INST_TYPE_QUAD                 2
    >
    >  #define CQSPI_STIG_DATA_LEN_MAX                      8
    > +#define CQSPI_INDIRECTTRIGGER_ADDR_MASK              0xFFFFF
    >
    >  #define CQSPI_DUMMY_CLKS_PER_BYTE            8
    >  #define CQSPI_DUMMY_BYTES_MAX                        4
    > @@ -560,7 +561,7 @@ int
    cadence_qspi_apb_indirect_read_setup(struct cadence_spi_platdata *plat,
    >               addr_bytes = cmdlen - 1;
    >
    >       /* Setup the indirect trigger address */
    > -     writel((u32)plat->ahbbase,
    > +     writel(((u32)plat->ahbbase & CQSPI_INDIRECTTRIGGER_ADDR_MASK),
    >              plat->regbase + CQSPI_REG_INDIRECTTRIGGER);
    >
    >       /* Configure the opcode */
    > @@ -710,7 +711,7 @@ int
    cadence_qspi_apb_indirect_write_setup(struct cadence_spi_platdata *plat,
    >               return -EINVAL;
    >       }
    >       /* Setup the indirect trigger address */
    > -     writel((u32)plat->ahbbase,
    > +     writel(((u32)plat->ahbbase & CQSPI_INDIRECTTRIGGER_ADDR_MASK),
    >              plat->regbase + CQSPI_REG_INDIRECTTRIGGER);
    >
    >       /* Configure the opcode */
    >
#4 lore raw
Quoted 10 lines · Vignesh R

Hi,

Quoted 3 lines · Frank Mori Hess

Since your commit broke my platform to fix yours, shouldn't it be reverted and TI platforms use your pending patch queue?

Socfpga DT defined ahb base as 0xffa00000 while masked upper bits in the code, which was confusing. And seems that my patch did work on some socfgpa board looking at the original commit message.

There is nothing in the original commit message that suggests it worked on any socfpga board, unless you mean

"Since AHB address is passed from DT
and read as u32 value, it anyway does not make sense to mask upper bits."

which is simply wrong.

Quoted 3 lines

If the patch is reverted then, applying pending patches alone will not help because my patch would be needed anyway to make sure we don't mask 31-20 bits on TI platforms.

No it won't needed, see http://patchwork.ozlabs.org/patch/838592/ that patch series writes plat->trigger_address instead of ahbbase (masked or not).

#5 lore raw
Quoted 12 lines · Frank Mori Hess
Quoted 10 lines · Vignesh R

Hi,

Quoted 3 lines · Frank Mori Hess

Since your commit broke my platform to fix yours, shouldn't it be reverted and TI platforms use your pending patch queue?

Socfpga DT defined ahb base as 0xffa00000 while masked upper bits in the code, which was confusing. And seems that my patch did work on some socfgpa board looking at the original commit message.

Quoted 8 lines

There is nothing in the original commit message that suggests it worked on any socfpga board, unless you mean

"Since AHB address is passed from DT
and read as u32 value, it anyway does not make sense to mask upper bits."

which is simply wrong.

There is a "Tested-by:" tag in the commit as well as:
https://patchwork.ozlabs.org/patch/609955/

Quoted 8 lines
Quoted 3 lines

If the patch is reverted then, applying pending patches alone will not help because my patch would be needed anyway to make sure we don't mask 31-20 bits on TI platforms.

No it won't needed, see http://patchwork.ozlabs.org/patch/838592/ that patch series writes plat->trigger_address instead of ahbbase (masked or not).

Okay, but reverting this patch would mean Jason has to rebase above patch. Instead applying that patch would anyway fix the issue.