Skip to contentSkip to conversation

sunxi sun6i SPI support

PATCH New Oskari Lemmela 3 participants 17 messages Jan 5, 2019 – Jan 24, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover sunxi sun6i SPI support

Minimal changes to support sun6i SPI with current sun4i SPI driver.

During testing I faced random spurious timeouts when reading 16MB flash device. When debugging spurious timeouts those values seems to be -1us.

Because timeouts are calculated as unsigned values tiny backward timer jumps causes this kind of issues.

Oskari Lemmela (2):
arm: sunxi: allwinner spi driver sun6i support
arm: timer: sunxi: fix spurious timeout issues

 arch/arm/cpu/armv8/generic_timer.c            |   2 +-
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h |   1 +
 arch/arm/include/asm/arch-sunxi/clock_sun9i.h |   1 +
 drivers/spi/Kconfig                           |   4 +-
 drivers/spi/sun4i_spi.c                       | 116 ++++++++++++++++--
 5 files changed, 108 insertions(+), 16 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

---
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h |   1 +
 arch/arm/include/asm/arch-sunxi/clock_sun9i.h |   1 +
 drivers/spi/Kconfig                           |   4 +-
 drivers/spi/sun4i_spi.c                       | 116 ++++++++++++++++--
 4 files changed, 107 insertions(+), 15 deletions(-)
arch/arm/include/asm/arch-sunxi/clock_sun6i.h +1 -0
index ee387127f3..4aaa0932d7 100644
@@ -321,6 +321,7 @@ struct sunxi_ccm_reg {
 #define AHB_GATE_OFFSET_MMC(n)		(AHB_GATE_OFFSET_MMC0 + (n))
 #define AHB_GATE_OFFSET_DMA		6
 #define AHB_GATE_OFFSET_SS		5
+#define AHB_GATE_OFFSET_SPI0		20
 
 /* ahb_gate1 offsets */
 #define AHB_GATE_OFFSET_DRC0		25
arch/arm/include/asm/arch-sunxi/clock_sun9i.h +1 -0
index 530e0dd73b..9bbd4d319e 100644
@@ -194,6 +194,7 @@ struct sunxi_ccm_reg {
 
 /* ahb gate1 field */
 #define AHB_GATE_OFFSET_DMA		24
+#define AHB_GATE_OFFSET_SPI0		20
 
 /* apb1_gate fields */
 #define APB1_GATE_UART_SHIFT		16
drivers/spi/Kconfig +2 -2
index a7bb5b35c2..88e772cb1a 100644
@@ -219,9 +219,9 @@ config STM32_QSPI
 	  this ST IP core.
 
 config SUN4I_SPI
-	bool "Allwinner A10 SoCs SPI controller"
+	bool "Allwinner SoCs SPI driver"
 	help
-	  SPI driver for Allwinner sun4i, sun5i and sun7i SoCs
+	  SPI driver for Allwinner SoCs
 
 config TEGRA114_SPI
 	bool "nVidia Tegra114 SPI driver"
drivers/spi/sun4i_spi.c +103 -13

232 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Quoted 4 lines · Oskari Lemmela

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

I just tried to see if this patch gives me "sf" access on a SoPine system. Unfortunately, it seems as if the sun4i_spi driver doesn't even get probed?

How did you manage to actually make use of this driver?

Alex

#3 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Hi,

Quoted 6 lines · Alexander Graf
Quoted 4 lines · Oskari Lemmela

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

Quoted 8 lines

I just tried to see if this patch gives me "sf" access on a SoPine system. Unfortunately, it seems as if the sun4i_spi driver doesn't even get probed?

How did you manage to actually make use of this driver?

Alex

You need to add spi0 alias to dts and enable needed drivers to defconfig. You can take look from Jagan's patch [1].

I didn't include those changes as Maxime already commented [2] that Kconfig depends/defaults should be modified first.

Thanks,
Oskari

[1] https://lists.denx.de/pipermail/u-boot/2018-December/353241.html
[2] https://lists.denx.de/pipermail/u-boot/2019-January/353784.html

#4 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Quoted 16 lines · Oskari Lemmelä

Hi,

Quoted 13 lines · Alexander Graf
Quoted 4 lines · Oskari Lemmela

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

I just tried to see if this patch gives me "sf" access on a SoPine system. Unfortunately, it seems as if the sun4i_spi driver doesn't even get probed?

How did you manage to actually make use of this driver?

Quoted 7 lines
Quoted 1 line

Alex

You need to add spi0 alias to dts and enable needed drivers to defconfig. You can take look from Jagan's patch [1].

I didn't include those changes as Maxime already commented [2] that Kconfig depends/defaults should be modified first.

I don't see any relation between the dts change and the Kconfig dependency issues?

But thanks for the pointer, I'll give this patch a try.

Alex

#5 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Quoted 24 lines · Alexander Graf
Quoted 21 lines · Oskari Lemmelä

Hi,

Quoted 6 lines · Alexander Graf
Quoted 4 lines · Oskari Lemmela

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

Quoted 8 lines

I just tried to see if this patch gives me "sf" access on a SoPine system. Unfortunately, it seems as if the sun4i_spi driver doesn't even get probed?

How did you manage to actually make use of this driver?

Alex

You need to add spi0 alias to dts and enable needed drivers to defconfig. You can take look from Jagan's patch [1].

Quoted 7 lines
Quoted 2 lines

I didn't include those changes as Maxime already commented [2] that Kconfig depends/defaults should be modified first.

I don't see any relation between the dts change and the Kconfig dependency issues?

But thanks for the pointer, I'll give this patch a try.

Ok, so I now get the SPI controller initialized, but it seems to only returns zeros when trying to access the SPI flash device.

In other words, it doesn't work for me :). But maybe I'm missing all the other clk patches to actually get it working?

Alex

#6 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Quoted 33 lines · Alexander Graf
Quoted 30 lines · Alexander Graf
Quoted 16 lines · Oskari Lemmelä

Hi,

Quoted 13 lines · Alexander Graf
Quoted 4 lines · Oskari Lemmela

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

I just tried to see if this patch gives me "sf" access on a SoPine system. Unfortunately, it seems as if the sun4i_spi driver doesn't even get probed?

How did you manage to actually make use of this driver?

Quoted 7 lines
Quoted 1 line

Alex

You need to add spi0 alias to dts and enable needed drivers to defconfig. You can take look from Jagan's patch [1].

I didn't include those changes as Maxime already commented [2] that Kconfig depends/defaults should be modified first.

I don't see any relation between the dts change and the Kconfig dependency issues?

Quoted 7 lines
Quoted 1 line

But thanks for the pointer, I'll give this patch a try.

Ok, so I now get the SPI controller initialized, but it seems to only returns zeros when trying to access the SPI flash device.

In other words, it doesn't work for me :). But maybe I'm missing all the other clk patches to actually get it working?

Ok, so turns out the problem is that you can't have eMMC and SPI both working. I don't quite know yet whether this is just a pinmux problem (so potentially software workaroundable) or if it's a hardware limitation (eMMC pulling a line required for SPI).

But either way, without the eMMC module, things seem to work:

Alex

#7 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Quoted 40 lines · On Thu, 24 Jan 2019 11:17:03 +0100 Alexander Graf <[email protected]> wrote:
Quoted 39 lines · Alexander Graf
Quoted 25 lines · Alexander Graf
Quoted 22 lines · Oskari Lemmelä

Hi,

Quoted 7 lines · Alexander Graf
Quoted 5 lines · Oskari Lemmela

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

Quoted 8 lines

I just tried to see if this patch gives me "sf" access on a SoPine system. Unfortunately, it seems as if the sun4i_spi driver doesn't even get probed?

How did you manage to actually make use of this driver?

Alex

You need to add spi0 alias to dts and enable needed drivers to defconfig. You can take look from Jagan's patch [1].

Quoted 7 lines
Quoted 2 lines

I didn't include those changes as Maxime already commented [2] that Kconfig depends/defaults should be modified first.

I don't see any relation between the dts change and the Kconfig dependency issues?

But thanks for the pointer, I'll give this patch a try.

Ok, so I now get the SPI controller initialized, but it seems to only returns zeros when trying to access the SPI flash device.

Quoted 7 lines
Quoted 2 lines

In other words, it doesn't work for me :). But maybe I'm missing all the other clk patches to actually get it working?

Ok, so turns out the problem is that you can't have eMMC and SPI both working. I don't quite know yet whether this is just a pinmux problem (so potentially software workaroundable) or if it's a hardware limitation (eMMC pulling a line required for SPI).

The line that is shared is "DS", which is only needed for higher (e)MMC modes (HS-400). At the moment neither Linux nor U-Boot implement this mode, and probably U-Boot will never need it: it adds software complexity for a questionable performance benefit, especially if the flash chips can't keep up with the high interface speed anyway.

We addressed this in the DTs (kernel commit fa59dd2ef755).

I am a bit puzzled here as why this happens: I can't find where U-Boot would configure PC1 to use the MMC2 function: the hard-coded mmc_pinmux_setup() doesn't touch PC1 at all. Maybe it's the BootROM configuring this line? So we would need to reset it?

As I don't have an eMMC module here at hand right now, this has to wait till tonight for further insights.

Quoted 3 lines

But either way, without the eMMC module, things seem to work:

Does anyone care to clean up the Kconfig dependency mess, since we seem to know all the options we need now? Ideally we would just need one or two symbols in the *_defconfig files, the rest being automatically selected by Kconfig magic.
It's on my list, but there are other things higher on that one.

Cheers,
Andre.

#8 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Quoted 59 lines · Andre Przywara
Quoted 40 lines · On Thu, 24 Jan 2019 11:17:03 +0100 Alexander Graf <[email protected]> wrote:
Quoted 39 lines · Alexander Graf
Quoted 25 lines · Alexander Graf
Quoted 22 lines · Oskari Lemmelä

Hi,

Quoted 7 lines · Alexander Graf
Quoted 5 lines · Oskari Lemmela

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

Quoted 8 lines

I just tried to see if this patch gives me "sf" access on a SoPine system. Unfortunately, it seems as if the sun4i_spi driver doesn't even get probed?

How did you manage to actually make use of this driver?

Alex

You need to add spi0 alias to dts and enable needed drivers to defconfig. You can take look from Jagan's patch [1].

Quoted 7 lines
Quoted 2 lines

I didn't include those changes as Maxime already commented [2] that Kconfig depends/defaults should be modified first.

I don't see any relation between the dts change and the Kconfig dependency issues?

But thanks for the pointer, I'll give this patch a try.

Ok, so I now get the SPI controller initialized, but it seems to only returns zeros when trying to access the SPI flash device.

Quoted 7 lines
Quoted 2 lines

In other words, it doesn't work for me :). But maybe I'm missing all the other clk patches to actually get it working?

Ok, so turns out the problem is that you can't have eMMC and SPI both working. I don't quite know yet whether this is just a pinmux problem (so potentially software workaroundable) or if it's a hardware limitation (eMMC pulling a line required for SPI).

The line that is shared is "DS", which is only needed for higher (e)MMC modes (HS-400). At the moment neither Linux nor U-Boot implement this mode, and probably U-Boot will never need it: it adds software complexity for a questionable performance benefit, especially if the flash chips can't keep up with the high interface speed anyway.

We addressed this in the DTs (kernel commit fa59dd2ef755).

Quoted 7 lines

I am a bit puzzled here as why this happens: I can't find where U-Boot would configure PC1 to use the MMC2 function: the hard-coded mmc_pinmux_setup() doesn't touch PC1 at all. Maybe it's the BootROM configuring this line? So we would need to reset it?

As I don't have an eMMC module here at hand right now, this has to wait till tonight for further insights.

A few more data points:

When I boot w/o eMMC module attached, SPI flash works When I then plug in the eMMC module, SPI flash still works When I that start initializing the eMMC module, SPI flash fails When I then unplug the eMMC module, SPI flash works again

So this is not pinmux related. The eMMC module really just drives the line.

Alex

#9 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Quoted 66 lines · On Thu, 24 Jan 2019 11:59:32 +0100 Alexander Graf <[email protected]> wrote:
Quoted 65 lines · Andre Przywara
Quoted 40 lines · On Thu, 24 Jan 2019 11:17:03 +0100 Alexander Graf <[email protected]> wrote:
Quoted 39 lines · Alexander Graf
Quoted 25 lines · Alexander Graf
Quoted 22 lines · Oskari Lemmelä

Hi,

Quoted 7 lines · Alexander Graf
Quoted 5 lines · Oskari Lemmela

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

Quoted 8 lines

I just tried to see if this patch gives me "sf" access on a SoPine system. Unfortunately, it seems as if the sun4i_spi driver doesn't even get probed?

How did you manage to actually make use of this driver?

Alex

You need to add spi0 alias to dts and enable needed drivers to defconfig. You can take look from Jagan's patch [1].

Quoted 7 lines
Quoted 2 lines

I didn't include those changes as Maxime already commented [2] that Kconfig depends/defaults should be modified first.

I don't see any relation between the dts change and the Kconfig dependency issues?

But thanks for the pointer, I'll give this patch a try.

Ok, so I now get the SPI controller initialized, but it seems to only returns zeros when trying to access the SPI flash device.

Quoted 7 lines
Quoted 2 lines

In other words, it doesn't work for me :). But maybe I'm missing all the other clk patches to actually get it working?

Ok, so turns out the problem is that you can't have eMMC and SPI both working. I don't quite know yet whether this is just a pinmux problem (so potentially software workaroundable) or if it's a hardware limitation (eMMC pulling a line required for SPI).

The line that is shared is "DS", which is only needed for higher (e)MMC modes (HS-400). At the moment neither Linux nor U-Boot implement this mode, and probably U-Boot will never need it: it adds software complexity for a questionable performance benefit, especially if the flash chips can't keep up with the high interface speed anyway.

We addressed this in the DTs (kernel commit fa59dd2ef755).

I am a bit puzzled here as why this happens: I can't find where U-Boot would configure PC1 to use the MMC2 function: the hard-coded mmc_pinmux_setup() doesn't touch PC1 at all. Maybe it's the BootROM configuring this line? So we would need to reset it?

Quoted 7 lines
Quoted 2 lines

As I don't have an eMMC module here at hand right now, this has to wait till tonight for further insights.

A few more data points:

When I boot w/o eMMC module attached, SPI flash works When I then plug in the eMMC module, SPI flash still works

Plug in with power off (which you should always do)? So it goes through the BootROM?

Quoted 1 line

When I that start initializing the eMMC module, SPI flash fails

What do you mean by that, exactly? Accessing eMMC from U-Boot? Because that is the interesting data point, somehow this makes the eMMC module drive the pin.

Quoted 1 line

When I then unplug the eMMC module, SPI flash works again

Again, at runtime?

Quoted 2 lines

So this is not pinmux related. The eMMC module really just drives the line.

Thanks for that.

Cheers,
Andre.

#10 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Quoted 77 lines · Andre Przywara
Quoted 66 lines · On Thu, 24 Jan 2019 11:59:32 +0100 Alexander Graf <[email protected]> wrote:
Quoted 65 lines · Andre Przywara
Quoted 40 lines · On Thu, 24 Jan 2019 11:17:03 +0100 Alexander Graf <[email protected]> wrote:
Quoted 39 lines · Alexander Graf
Quoted 25 lines · Alexander Graf
Quoted 22 lines · Oskari Lemmelä

Hi,

Quoted 7 lines · Alexander Graf
Quoted 5 lines · Oskari Lemmela

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

Quoted 8 lines

I just tried to see if this patch gives me "sf" access on a SoPine system. Unfortunately, it seems as if the sun4i_spi driver doesn't even get probed?

How did you manage to actually make use of this driver?

Alex

You need to add spi0 alias to dts and enable needed drivers to defconfig. You can take look from Jagan's patch [1].

Quoted 7 lines
Quoted 2 lines

I didn't include those changes as Maxime already commented [2] that Kconfig depends/defaults should be modified first.

I don't see any relation between the dts change and the Kconfig dependency issues?

But thanks for the pointer, I'll give this patch a try.

Ok, so I now get the SPI controller initialized, but it seems to only returns zeros when trying to access the SPI flash device.

Quoted 7 lines
Quoted 2 lines

In other words, it doesn't work for me :). But maybe I'm missing all the other clk patches to actually get it working?

Ok, so turns out the problem is that you can't have eMMC and SPI both working. I don't quite know yet whether this is just a pinmux problem (so potentially software workaroundable) or if it's a hardware limitation (eMMC pulling a line required for SPI).

The line that is shared is "DS", which is only needed for higher (e)MMC modes (HS-400). At the moment neither Linux nor U-Boot implement this mode, and probably U-Boot will never need it: it adds software complexity for a questionable performance benefit, especially if the flash chips can't keep up with the high interface speed anyway.

We addressed this in the DTs (kernel commit fa59dd2ef755).

I am a bit puzzled here as why this happens: I can't find where U-Boot would configure PC1 to use the MMC2 function: the hard-coded mmc_pinmux_setup() doesn't touch PC1 at all. Maybe it's the BootROM configuring this line? So we would need to reset it?

Quoted 7 lines
Quoted 2 lines

As I don't have an eMMC module here at hand right now, this has to wait till tonight for further insights.

A few more data points:

When I boot w/o eMMC module attached, SPI flash works When I then plug in the eMMC module, SPI flash still works

Quoted 6 lines

Plug in with power off (which you should always do)? So it goes through the BootROM?

Quoted 1 line

When I that start initializing the eMMC module, SPI flash fails

What do you mean by that, exactly? Accessing eMMC from U-Boot?

Yes, "mmc part" to be precise.

Quoted 6 lines

Because that is the interesting data point, somehow this makes the eMMC module drive the pin.

Quoted 1 line

When I then unplug the eMMC module, SPI flash works again

Again, at runtime?

Yup, all of it at runtime. I felt darey and ignored the fact that you should really only plug the eMMC module at boot time ;).

The last step definitely did not change pinmux. Hence the conclusion that this is line drive collision, not pinmux.

So I guess you're saying that forcing the eMMC into 4-DAT mode would make things work?

Alex

#11 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Quoted 96 lines · On Thu, 24 Jan 2019 12:21:17 +0100 Alexander Graf <[email protected]> wrote:
Quoted 79 lines · Andre Przywara
Quoted 68 lines · On Thu, 24 Jan 2019 11:59:32 +0100 Alexander Graf <[email protected]> wrote:
Quoted 67 lines · Andre Przywara
Quoted 40 lines · On Thu, 24 Jan 2019 11:17:03 +0100 Alexander Graf <[email protected]> wrote:
Quoted 39 lines · Alexander Graf
Quoted 25 lines · Alexander Graf
Quoted 22 lines · Oskari Lemmelä

Hi,

Quoted 7 lines · Alexander Graf
Quoted 5 lines · Oskari Lemmela

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

Quoted 8 lines

I just tried to see if this patch gives me "sf" access on a SoPine system. Unfortunately, it seems as if the sun4i_spi driver doesn't even get probed?

How did you manage to actually make use of this driver?

Alex

You need to add spi0 alias to dts and enable needed drivers to defconfig. You can take look from Jagan's patch [1].

Quoted 7 lines
Quoted 2 lines

I didn't include those changes as Maxime already commented [2] that Kconfig depends/defaults should be modified first.

I don't see any relation between the dts change and the Kconfig dependency issues?

But thanks for the pointer, I'll give this patch a try.

Ok, so I now get the SPI controller initialized, but it seems to only returns zeros when trying to access the SPI flash device.

Quoted 8 lines
Quoted 2 lines

In other words, it doesn't work for me :). But maybe I'm missing all the other clk patches to actually get it working?

Ok, so turns out the problem is that you can't have eMMC and SPI both working. I don't quite know yet whether this is just a pinmux problem (so potentially software workaroundable) or if it's a hardware limitation (eMMC pulling a line required for SPI).

The line that is shared is "DS", which is only needed for higher (e)MMC modes (HS-400). At the moment neither Linux nor U-Boot implement this mode, and probably U-Boot will never need it: it adds software complexity for a questionable performance benefit, especially if the flash chips can't keep up with the high interface speed anyway.

We addressed this in the DTs (kernel commit fa59dd2ef755).

I am a bit puzzled here as why this happens: I can't find where U-Boot would configure PC1 to use the MMC2 function: the hard-coded mmc_pinmux_setup() doesn't touch PC1 at all. Maybe it's the BootROM configuring this line? So we would need to reset it?

Quoted 7 lines
Quoted 2 lines

As I don't have an eMMC module here at hand right now, this has to wait till tonight for further insights.

A few more data points:

When I boot w/o eMMC module attached, SPI flash works When I then plug in the eMMC module, SPI flash still works

Quoted 6 lines

Plug in with power off (which you should always do)? So it goes through the BootROM?

Quoted 1 line

When I that start initializing the eMMC module, SPI flash fails

What do you mean by that, exactly? Accessing eMMC from U-Boot?

Yes, "mmc part" to be precise.

Quoted 6 lines

Because that is the interesting data point, somehow this makes the eMMC module drive the pin.

Quoted 1 line

When I then unplug the eMMC module, SPI flash works again

Again, at runtime?

Quoted 8 lines

Yup, all of it at runtime. I felt darey and ignored the fact that you should really only plug the eMMC module at boot time ;).

The last step definitely did not change pinmux. Hence the conclusion that this is line drive collision, not pinmux.

So I guess you're saying that forcing the eMMC into 4-DAT mode would make things work?

Technically DS is for HS-400, which is a step beyond 8-bit bus width. So just enabling 8 bit should not affect the DS line. There is a bit in the MMC controller to enable HS-400, but I don't see that we would set it (we actually don't even define the register).
You could try to force eMMC to 4 bit to check this theory, by hack-removing the MMC_MODE_8BIT line in sunxi_mmc_init() in drivers/mmc/sunxi-mmc.c (we don't use DM_MMC yet, so it's in the hacky part and ignores the DT property)

Cheers,
Andre.

#12 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Quoted 108 lines · Andre Przywara
Quoted 96 lines · On Thu, 24 Jan 2019 12:21:17 +0100 Alexander Graf <[email protected]> wrote:
Quoted 79 lines · Andre Przywara
Quoted 68 lines · On Thu, 24 Jan 2019 11:59:32 +0100 Alexander Graf <[email protected]> wrote:
Quoted 67 lines · Andre Przywara
Quoted 40 lines · On Thu, 24 Jan 2019 11:17:03 +0100 Alexander Graf <[email protected]> wrote:
Quoted 39 lines · Alexander Graf
Quoted 25 lines · Alexander Graf
Quoted 22 lines · Oskari Lemmelä

Hi,

Quoted 7 lines · Alexander Graf
Quoted 5 lines · Oskari Lemmela

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

Quoted 8 lines

I just tried to see if this patch gives me "sf" access on a SoPine system. Unfortunately, it seems as if the sun4i_spi driver doesn't even get probed?

How did you manage to actually make use of this driver?

Alex

You need to add spi0 alias to dts and enable needed drivers to defconfig. You can take look from Jagan's patch [1].

Quoted 7 lines
Quoted 2 lines

I didn't include those changes as Maxime already commented [2] that Kconfig depends/defaults should be modified first.

I don't see any relation between the dts change and the Kconfig dependency issues?

But thanks for the pointer, I'll give this patch a try.

Ok, so I now get the SPI controller initialized, but it seems to only returns zeros when trying to access the SPI flash device.

Quoted 8 lines
Quoted 2 lines

In other words, it doesn't work for me :). But maybe I'm missing all the other clk patches to actually get it working?

Ok, so turns out the problem is that you can't have eMMC and SPI both working. I don't quite know yet whether this is just a pinmux problem (so potentially software workaroundable) or if it's a hardware limitation (eMMC pulling a line required for SPI).

The line that is shared is "DS", which is only needed for higher (e)MMC modes (HS-400). At the moment neither Linux nor U-Boot implement this mode, and probably U-Boot will never need it: it adds software complexity for a questionable performance benefit, especially if the flash chips can't keep up with the high interface speed anyway.

We addressed this in the DTs (kernel commit fa59dd2ef755).

I am a bit puzzled here as why this happens: I can't find where U-Boot would configure PC1 to use the MMC2 function: the hard-coded mmc_pinmux_setup() doesn't touch PC1 at all. Maybe it's the BootROM configuring this line? So we would need to reset it?

Quoted 7 lines
Quoted 2 lines

As I don't have an eMMC module here at hand right now, this has to wait till tonight for further insights.

A few more data points:

When I boot w/o eMMC module attached, SPI flash works When I then plug in the eMMC module, SPI flash still works

Quoted 6 lines

Plug in with power off (which you should always do)? So it goes through the BootROM?

Quoted 1 line

When I that start initializing the eMMC module, SPI flash fails

What do you mean by that, exactly? Accessing eMMC from U-Boot?

Yes, "mmc part" to be precise.

Quoted 6 lines

Because that is the interesting data point, somehow this makes the eMMC module drive the pin.

Quoted 1 line

When I then unplug the eMMC module, SPI flash works again

Again, at runtime?

Quoted 8 lines

Yup, all of it at runtime. I felt darey and ignored the fact that you should really only plug the eMMC module at boot time ;).

The last step definitely did not change pinmux. Hence the conclusion that this is line drive collision, not pinmux.

So I guess you're saying that forcing the eMMC into 4-DAT mode would make things work?

Quoted 8 lines

Technically DS is for HS-400, which is a step beyond 8-bit bus width. So just enabling 8 bit should not affect the DS line. There is a bit in the MMC controller to enable HS-400, but I don't see that we would set it (we actually don't even define the register).
You could try to force eMMC to 4 bit to check this theory, by hack-removing the MMC_MODE_8BIT line in sunxi_mmc_init() in drivers/mmc/sunxi-mmc.c (we don't use DM_MMC yet, so it's in the hacky part and ignores the DT property)

Ok, that did not help. I guess the next best useful thing to do now would be to measure what the MISO line shows in each situation. Unfortunately I don't have my oscilloscope handy :).

Alex

#13 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Quoted 123 lines · On Thu, 24 Jan 2019 13:07:54 +0100 Alexander Graf <[email protected]> wrote:
Quoted 113 lines · Andre Przywara
Quoted 101 lines · On Thu, 24 Jan 2019 12:21:17 +0100 Alexander Graf <[email protected]> wrote:
Quoted 83 lines · Andre Przywara
Quoted 72 lines · On Thu, 24 Jan 2019 11:59:32 +0100 Alexander Graf <[email protected]> wrote:
Quoted 71 lines · Andre Przywara
Quoted 47 lines · On Thu, 24 Jan 2019 11:17:03 +0100 Alexander Graf <[email protected]> wrote:
Quoted 38 lines · Alexander Graf
Quoted 29 lines · Alexander Graf
Quoted 17 lines · Oskari Lemmelä

Hi,

Quoted 14 lines · Alexander Graf
Quoted 5 lines · Oskari Lemmela

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

I just tried to see if this patch gives me "sf" access on a SoPine system. Unfortunately, it seems as if the sun4i_spi driver doesn't even get probed?

How did you manage to actually make use of this driver?

Quoted 8 lines
Quoted 1 line

Alex

You need to add spi0 alias to dts and enable needed drivers to defconfig. You can take look from Jagan's patch [1].

I didn't include those changes as Maxime already commented
[2] that Kconfig depends/defaults should be modified first.

Quoted 5 lines

I don't see any relation between the dts change and the Kconfig dependency issues?

But thanks for the pointer, I'll give this patch a try.

Quoted 7 lines

Ok, so I now get the SPI controller initialized, but it seems to only returns zeros when trying to access the SPI flash device.

In other words, it doesn't work for me :). But maybe I'm missing all the other clk patches to actually get it working?

Quoted 5 lines

Ok, so turns out the problem is that you can't have eMMC and SPI both working. I don't quite know yet whether this is just a pinmux problem (so potentially software workaroundable) or if it's a hardware limitation (eMMC pulling a line required for SPI).

The line that is shared is "DS", which is only needed for higher (e)MMC modes (HS-400). At the moment neither Linux nor U-Boot implement this mode, and probably U-Boot will never need it: it adds software complexity for a questionable performance benefit, especially if the flash chips can't keep up with the high interface speed anyway.

We addressed this in the DTs (kernel commit fa59dd2ef755).

I am a bit puzzled here as why this happens: I can't find where U-Boot would configure PC1 to use the MMC2 function: the hard-coded mmc_pinmux_setup() doesn't touch PC1 at all. Maybe it's the BootROM configuring this line? So we would need to reset it?

Quoted 7 lines
Quoted 2 lines

As I don't have an eMMC module here at hand right now, this has to wait till tonight for further insights.

A few more data points:

When I boot w/o eMMC module attached, SPI flash works When I then plug in the eMMC module, SPI flash still works

Quoted 7 lines

Plug in with power off (which you should always do)? So it goes through the BootROM?

Quoted 2 lines

When I that start initializing the eMMC module, SPI flash fails

What do you mean by that, exactly? Accessing eMMC from U-Boot?

Yes, "mmc part" to be precise.

Quoted 6 lines

Because that is the interesting data point, somehow this makes the eMMC module drive the pin.

Quoted 1 line

When I then unplug the eMMC module, SPI flash works again

Again, at runtime?

Quoted 8 lines

Yup, all of it at runtime. I felt darey and ignored the fact that you should really only plug the eMMC module at boot time ;).

The last step definitely did not change pinmux. Hence the conclusion that this is line drive collision, not pinmux.

So I guess you're saying that forcing the eMMC into 4-DAT mode would make things work?

Quoted 8 lines

Technically DS is for HS-400, which is a step beyond 8-bit bus width. So just enabling 8 bit should not affect the DS line. There is a bit in the MMC controller to enable HS-400, but I don't see that we would set it (we actually don't even define the register). You could try to force eMMC to 4 bit to check this theory, by hack-removing the MMC_MODE_8BIT line in sunxi_mmc_init() in drivers/mmc/sunxi-mmc.c (we don't use DM_MMC yet, so it's in the hacky part and ignores the DT property)

Quoted 3 lines

Ok, that did not help. I guess the next best useful thing to do now would be to measure what the MISO line shows in each situation. Unfortunately I don't have my oscilloscope handy :).

Can't you configure PC1 as a gpio, and read that? Not sure the "gpio" command works with PC1 being a "function pin", but you could always hack it to GPIO-in by clearing bits[7:4] in 0x01C20848, with md.l/mw.l.

Cheers,
Andre.

#14 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

Quoted 5 lines · Andre Przywara
Quoted 2 lines · On Thu, 24 Jan 2019 13:07:54 +0100 Alexander Graf <[email protected]> wrote:

On 24.01.19 12:31, Andre Przywara wrote:

Quoted 7 lines
Quoted 3 lines

Ok, that did not help. I guess the next best useful thing to do now would be to measure what the MISO line shows in each situation. Unfortunately I don't have my oscilloscope handy :).

Can't you configure PC1 as a gpio, and read that? Not sure the "gpio" command works with PC1 being a "function pin", but you could always hack it to GPIO-in by clearing bits[7:4] in 0x01C20848, with md.l/mw.l.

That showed a 0. But it doesn't really tell any story over time :).

However, I quickly added a bit of debug output to the SD command emission code. And the spi flash already stops working while the eMMC is booting up. So this is nothing we configure - the eMMC simply pulls that line down automatically as soon as it's booted up.

If I configure it to not ever emit CMD1, the SF keeps working, but the eMMC does not come up unfortunately. I guess it's not compatible to the pure SD command set.

Alex

---

SF: Detected w25q128bv with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC CMD 0 ... allowed
SF: Detected w25q128bv with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC CMD 8 ... allowed
SF: Detected w25q128bv with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC CMD 55 ... allowed
SF: Detected w25q128bv with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC CMD 0 ... allowed
SF: Detected w25q128bv with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC CMD 1 ... allowed
SF: Detected w25q128bv with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC CMD 1 ... allowed
SF: Detected w25q128bv with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC CMD 0 ... allowed
SF: Detected w25q128bv with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC CMD 1 ... allowed
SF: Detected w25q128bv with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC CMD 1 ... allowed
SF: Detected w25q128bv with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC CMD 1 ... allowed
SF: Detected w25q128bv with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC CMD 1 ... allowed
SF: unrecognized JEDEC id bytes: 00, 00, 00
Failed to initialize SPI flash at 0:0 (error -2)
MMC CMD 1 ... allowed
SF: unrecognized JEDEC id bytes: 00, 00, 00
Failed to initialize SPI flash at 0:0 (error -2)
MMC CMD 2 ... allowed
SF: unrecognized JEDEC id bytes: 00, 00, 00
Failed to initialize SPI flash at 0:0 (error -2)
MMC CMD 3 ... allowed
[...]

Alex

#15 lore raw

PATCH 1/2 arm: sunxi: allwinner spi driver sun6i support

In reply to Andre Przywara

Hi,

Quoted 59 lines · Andre Przywara
Quoted 34 lines · On Thu, 24 Jan 2019 11:17:03 +0100 Alexander Graf <[email protected]> wrote:
Quoted 33 lines · Alexander Graf
Quoted 22 lines · Alexander Graf
Quoted 20 lines · Oskari Lemmelä

Hi,

Quoted 6 lines · Alexander Graf
Quoted 5 lines · Oskari Lemmela

Minimal changes to support sun6i based Allwinner SOCs Changes are based to SPL driver arch/arm/mach-sunxi/spl_spi_sunxi.c

Quoted 8 lines

I just tried to see if this patch gives me "sf" access on a SoPine system. Unfortunately, it seems as if the sun4i_spi driver doesn't even get probed?

How did you manage to actually make use of this driver?

Alex

You need to add spi0 alias to dts and enable needed drivers to defconfig. You can take look from Jagan's patch [1].

Quoted 6 lines
Quoted 2 lines

I didn't include those changes as Maxime already commented [2] that Kconfig depends/defaults should be modified first.

I don't see any relation between the dts change and the Kconfig dependency issues?

But thanks for the pointer, I'll give this patch a try.

Ok, so I now get the SPI controller initialized, but it seems to only returns zeros when trying to access the SPI flash device.

Quoted 6 lines
Quoted 2 lines

In other words, it doesn't work for me :). But maybe I'm missing all the other clk patches to actually get it working?

Ok, so turns out the problem is that you can't have eMMC and SPI both working. I don't quite know yet whether this is just a pinmux problem (so potentially software workaroundable) or if it's a hardware limitation (eMMC pulling a line required for SPI).

The line that is shared is "DS", which is only needed for higher (e)MMC modes (HS-400). At the moment neither Linux nor U-Boot implement this mode, and probably U-Boot will never need it: it adds software complexity for a questionable performance benefit, especially if the flash chips can't keep up with the high interface speed anyway.

We addressed this in the DTs (kernel commit fa59dd2ef755).

I am a bit puzzled here as why this happens: I can't find where U-Boot would configure PC1 to use the MMC2 function: the hard-coded mmc_pinmux_setup() doesn't touch PC1 at all. Maybe it's the BootROM configuring this line? So we would need to reset it?

As I don't have an eMMC module here at hand right now, this has to wait till tonight for further insights.

Quoted 8 lines
Quoted 3 lines

But either way, without the eMMC module, things seem to work:

Does anyone care to clean up the Kconfig dependency mess, since we seem to know all the options we need now? Ideally we would just need one or two symbols in the *_defconfig files, the rest being automatically selected by Kconfig magic.
It's on my list, but there are other things higher on that one.

I can try contribute and take a look this one.

Quoted 2 lines

Cheers,
Andre.

Thanks,
Oskari

#16 lore raw

PATCH 2/2 arm: timer: sunxi: fix spurious timeout issues

In reply to Oskari Lemmela

Fixes spurious timeouts which have seen during testing SPI driver. Timeouts disappear when number of bits are reduced to 10.

Timer tiny backward jumps causes spurious timeouts.

---
 arch/arm/cpu/armv8/generic_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/armv8/generic_timer.c +1 -1
index c1706dcec1..2e06ee4ed2 100644
@@ -66,7 +66,7 @@ unsigned long timer_read_counter(void)
 	isb();
 	do {
 		asm volatile("mrs %0, cntpct_el0" : "=r" (cntpct));
-	} while (((cntpct + 1) & GENMASK(10, 0)) <= 1);
+	} while (((cntpct + 1) & GENMASK(9, 0)) <= 1);
 
 	return cntpct;
 }
Signature · 1 line
2.17.1