Skip to contentSkip to conversation

arm: socfgpa: support of-platdata

PATCH New Simon Goldschmidt 8 participants 77 messages Jan 7, 2019 – Feb 1, 2019

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

cover arm: socfgpa: support of-platdata

This is an initial attempt to support OF_PLATDATA for socfpga gen5.

There are two motivations for this:
a) reduce code size to eventually support secure boot (where SPL has to authenticate the next stage by loading/checking U-Boot from a FIT image)
b) to support the cyclone 5 boot ROM's CRC check on the SPL in SRAM (on warm-restart), all bytes to check need to be in one piece. With OF_SEPARATE, this is not the case (.bss is between .rodata and the DTB). Since OF_EMBEDDED has been discouraged, OF_PLATDATA seems to be a good solution.

This series enables booting from MMC with OF_PLATDATA. Booting from SPI does not yet work (I'm working on that, but it's tougher than expected).

Tested on the socrates board. To use it:
- use socfpga_socrates_defconfig
- disable CONFIG_SPL_SPI_FLASH_SUPPORT, CONFIG_SPL_SPI_SUPPORT and CONFIG_SPL_DM_RESET (those don't work yet)
- enable CONFIG_DESIGNWARE_SERIAL (required for console)

Simon Goldschmidt (4):
arm: socfpga: imply SPL config instead of select
arm: socfpga: fix compiling with OF_PLATDATA
serial: add an of-platdata driver for "snps,dw-apb-uart"
mmc: socfpga: support of-platdata

 arch/arm/Kconfig               |  4 ++--
 arch/arm/mach-socfpga/misc.c   |  2 +-
 drivers/mmc/socfpga_dw_mmc.c   | 28 ++++++++++++++++++++---
 drivers/serial/Kconfig         | 10 ++++++++
 drivers/serial/Makefile        |  1 +
 drivers/serial/serial_dw_apb.c | 42 ++++++++++++++++++++++++++++++++++
 6 files changed, 81 insertions(+), 6 deletions(-)
 create mode 100644 drivers/serial/serial_dw_apb.c
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

---

 arch/arm/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +2 -2
index 520ea8bed9..1ca71bd323 100644
@@ -815,7 +815,6 @@ config ARCH_SOCFPGA
 	select DM_SERIAL
 	select ENABLE_ARM_SOC_BOOT0_HOOK if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
 	select OF_CONTROL
-	select SPL_DM_RESET if DM_RESET
 	select SPL_DM_SERIAL
 	select SPL_LIBCOMMON_SUPPORT
 	select SPL_LIBGENERIC_SUPPORT
@@ -823,7 +822,6 @@ config ARCH_SOCFPGA
 	select SPL_OF_CONTROL
 	select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10
 	select SPL_SERIAL_SUPPORT
-	select SPL_WATCHDOG_SUPPORT
 	select SUPPORT_SPL
 	select SYS_NS16550
 	select SYS_THUMB_BUILD if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
@@ -833,12 +831,14 @@ config ARCH_SOCFPGA
 	imply DM_SPI
 	imply DM_SPI_FLASH
 	imply FAT_WRITE
+	imply SPL_DM_RESET
 	imply SPL_LIBDISK_SUPPORT
 	imply SPL_MMC_SUPPORT
 	imply SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
 	imply SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
 	imply SPL_SPI_FLASH_SUPPORT
 	imply SPL_SPI_SUPPORT
+	imply SPL_WATCHDOG_SUPPORT
 
 config ARCH_SUNXI
 	bool "Support sunxi (Allwinner) SoCs"
Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 6 lines · Simon Goldschmidt

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Quoted 42 lines

---

 arch/arm/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +2 -2
index 520ea8bed9..1ca71bd323 100644
@@ -815,7 +815,6 @@ config ARCH_SOCFPGA
 	select DM_SERIAL
 	select ENABLE_ARM_SOC_BOOT0_HOOK if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
 	select OF_CONTROL
-	select SPL_DM_RESET if DM_RESET
 	select SPL_DM_SERIAL
 	select SPL_LIBCOMMON_SUPPORT
 	select SPL_LIBGENERIC_SUPPORT
@@ -823,7 +822,6 @@ config ARCH_SOCFPGA
 	select SPL_OF_CONTROL
 	select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10
 	select SPL_SERIAL_SUPPORT
-	select SPL_WATCHDOG_SUPPORT
 	select SUPPORT_SPL
 	select SYS_NS16550
 	select SYS_THUMB_BUILD if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
@@ -833,12 +831,14 @@ config ARCH_SOCFPGA
 	imply DM_SPI
 	imply DM_SPI_FLASH
 	imply FAT_WRITE
+	imply SPL_DM_RESET
 	imply SPL_LIBDISK_SUPPORT
 	imply SPL_MMC_SUPPORT
 	imply SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
 	imply SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
 	imply SPL_SPI_FLASH_SUPPORT
 	imply SPL_SPI_SUPPORT
+	imply SPL_WATCHDOG_SUPPORT
 
 config ARCH_SUNXI
 	bool "Support sunxi (Allwinner) SoCs"
Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 10 lines · Marek Vasut
Quoted 6 lines · Simon Goldschmidt

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Regards,
Simon

Quoted 48 lines
Quoted 33 lines

---

 arch/arm/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +1 -2
index 520ea8bed9..1ca71bd323 100644
@@ -815,7 +815,6 @@ config ARCH_SOCFPGA
      select DM_SERIAL
      select ENABLE_ARM_SOC_BOOT0_HOOK if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
      select OF_CONTROL
-     select SPL_DM_RESET if DM_RESET
      select SPL_DM_SERIAL
      select SPL_LIBCOMMON_SUPPORT
      select SPL_LIBGENERIC_SUPPORT
@@ -823,7 +822,6 @@ config ARCH_SOCFPGA
      select SPL_OF_CONTROL
      select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10
      select SPL_SERIAL_SUPPORT
-     select SPL_WATCHDOG_SUPPORT
      select SUPPORT_SPL
      select SYS_NS16550
      select SYS_THUMB_BUILD if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
@@ -833,12 +831,14 @@ config ARCH_SOCFPGA
      imply DM_SPI
      imply DM_SPI_FLASH
      imply FAT_WRITE
+     imply SPL_DM_RESET

arch/arm/Kconfig config ARCH_SOCFPGA · line 844

Quoted 10 lines
arch/arm/Kconfig +1 -0
      imply SPL_LIBDISK_SUPPORT
      imply SPL_MMC_SUPPORT
      imply SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
      imply SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
      imply SPL_SPI_FLASH_SUPPORT
      imply SPL_SPI_SUPPORT
+     imply SPL_WATCHDOG_SUPPORT
 
 config ARCH_SUNXI
      bool "Support sunxi (Allwinner) SoCs"

--
Best regards,
Marek Vasut

#4 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 20 lines · Simon Goldschmidt
Quoted 10 lines · Marek Vasut
Quoted 6 lines · Simon Goldschmidt

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

Quoted 6 lines

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Don't you need it to unreset at least the DWMMC or CQSPI ? Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10. Would that be possible ?

Signature · 2 lines
Best regards,
Marek Vasut
#5 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 22 lines · Marek Vasut
Quoted 20 lines · Simon Goldschmidt
Quoted 10 lines · Marek Vasut
Quoted 6 lines · Simon Goldschmidt

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

Quoted 8 lines
Quoted 6 lines

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Don't you need it to unreset at least the DWMMC or CQSPI ?

Reading the code, it seems like that's taken care of through another hack in spl_boot_device() ;-)

Quoted 3 lines

Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10. Would that be possible ?

I would be best, yes. I don't know when I will find the time to do that, though. I don't know how much effort that would be, either. Is there maybe a patch where A10 got converted from "as bad as gen5" to its current state? That would help me to see if I can do it...

Regards,
Simon

#6 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 30 lines · Simon Goldschmidt
Quoted 29 lines · Marek Vasut
Quoted 26 lines · Simon Goldschmidt
Quoted 10 lines · Marek Vasut
Quoted 6 lines · Simon Goldschmidt

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Quoted 4 lines
Quoted 1 line

Don't you need it to unreset at least the DWMMC or CQSPI ?

Reading the code, it seems like that's taken care of through another hack in spl_boot_device() ;-)

Sigh.

Quoted 8 lines
Quoted 3 lines

Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10. Would that be possible ?

I would be best, yes. I don't know when I will find the time to do that, though. I don't know how much effort that would be, either. Is there maybe a patch where A10 got converted from "as bad as gen5" to its current state? That would help me to see if I can do it...

A10 got switched to reset framework recently (in last 6 months or so), the reset driver is the same for Gen5 and A10 too, so it should be easy to recycle.

Signature · 2 lines
Best regards,
Marek Vasut
#7 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 43 lines · Marek Vasut
Quoted 30 lines · Simon Goldschmidt
Quoted 29 lines · Marek Vasut
Quoted 26 lines · Simon Goldschmidt
Quoted 10 lines · Marek Vasut
Quoted 6 lines · Simon Goldschmidt

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Quoted 4 lines
Quoted 1 line

Don't you need it to unreset at least the DWMMC or CQSPI ?

Reading the code, it seems like that's taken care of through another hack in spl_boot_device() ;-)

Sigh.

Quoted 4 lines
Quoted 3 lines

Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10. Would that be possible ?

Quoted 8 lines
Quoted 4 lines

I would be best, yes. I don't know when I will find the time to do that, though. I don't know how much effort that would be, either. Is there maybe a patch where A10 got converted from "as bad as gen5" to its current state? That would help me to see if I can do it...

A10 got switched to reset framework recently (in last 6 months or so), the reset driver is the same for Gen5 and A10 too, so it should be easy to recycle.

Hmm, ok, let me check that... it would indeed be nice to port this to gen5.

Since you seem kidn of opposed to OF_PLATDATA, does it make any sense to continue on this? I mean, I thought I heard people here saying "use OF_PLATDATA" if you're running out of space in SPL. After using it, I'm not too keen on using it, either, but it does seem to give me some code space back...

Regards,
Simon

#8 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 53 lines · Simon Goldschmidt
Quoted 43 lines · Marek Vasut
Quoted 30 lines · Simon Goldschmidt
Quoted 29 lines · Marek Vasut
Quoted 26 lines · Simon Goldschmidt
Quoted 10 lines · Marek Vasut
Quoted 6 lines · Simon Goldschmidt

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Quoted 4 lines
Quoted 1 line

Don't you need it to unreset at least the DWMMC or CQSPI ?

Reading the code, it seems like that's taken care of through another hack in spl_boot_device() ;-)

Sigh.

Quoted 4 lines
Quoted 3 lines

Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10. Would that be possible ?

Quoted 8 lines
Quoted 4 lines

I would be best, yes. I don't know when I will find the time to do that, though. I don't know how much effort that would be, either. Is there maybe a patch where A10 got converted from "as bad as gen5" to its current state? That would help me to see if I can do it...

A10 got switched to reset framework recently (in last 6 months or so), the reset driver is the same for Gen5 and A10 too, so it should be easy to recycle.

Quoted 6 lines

Hmm, ok, let me check that... it would indeed be nice to port this to gen5.

Since you seem kidn of opposed to OF_PLATDATA, does it make any sense to continue on this? I mean, I thought I heard people here saying "use OF_PLATDATA" if you're running out of space in SPL. After using it, I'm not too keen on using it, either, but it does seem to give me some code space back...

OF_PLATDATA is for platforms with really small SRAM, some 30k or below. This platform has a massive 60k of SRAM for SPL, so if we're running out of space, we're doing something wrong.

Signature · 2 lines
Best regards,
Marek Vasut
#9 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 56 lines · Marek Vasut
Quoted 55 lines · Simon Goldschmidt
Quoted 43 lines · Marek Vasut
Quoted 30 lines · Simon Goldschmidt
Quoted 29 lines · Marek Vasut
Quoted 26 lines · Simon Goldschmidt
Quoted 10 lines · Marek Vasut
Quoted 6 lines · Simon Goldschmidt

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Quoted 4 lines
Quoted 1 line

Don't you need it to unreset at least the DWMMC or CQSPI ?

Reading the code, it seems like that's taken care of through another hack in spl_boot_device() ;-)

Sigh.

Quoted 4 lines
Quoted 3 lines

Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10. Would that be possible ?

Quoted 8 lines
Quoted 4 lines

I would be best, yes. I don't know when I will find the time to do that, though. I don't know how much effort that would be, either. Is there maybe a patch where A10 got converted from "as bad as gen5" to its current state? That would help me to see if I can do it...

A10 got switched to reset framework recently (in last 6 months or so), the reset driver is the same for Gen5 and A10 too, so it should be easy to recycle.

Hmm, ok, let me check that... it would indeed be nice to port this to gen5.

Quoted 8 lines
Quoted 4 lines

Since you seem kidn of opposed to OF_PLATDATA, does it make any sense to continue on this? I mean, I thought I heard people here saying "use OF_PLATDATA" if you're running out of space in SPL. After using it, I'm not too keen on using it, either, but it does seem to give me some code space back...

OF_PLATDATA is for platforms with really small SRAM, some 30k or below. This platform has a massive 60k of SRAM for SPL, so if we're running out of space, we're doing something wrong.

It's not for "30k or below" but "needs more space to enable all desired features inside of SPL".

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190108/fa70070e/attachment.sig>
#10 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 62 lines · Tom Rini
Quoted 61 lines · Marek Vasut
Quoted 59 lines · Simon Goldschmidt
Quoted 43 lines · Marek Vasut
Quoted 30 lines · Simon Goldschmidt
Quoted 29 lines · Marek Vasut
Quoted 26 lines · Simon Goldschmidt
Quoted 10 lines · Marek Vasut
Quoted 6 lines · Simon Goldschmidt

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Quoted 4 lines
Quoted 1 line

Don't you need it to unreset at least the DWMMC or CQSPI ?

Reading the code, it seems like that's taken care of through another hack in spl_boot_device() ;-)

Sigh.

Quoted 4 lines
Quoted 3 lines

Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10. Would that be possible ?

Quoted 8 lines
Quoted 4 lines

I would be best, yes. I don't know when I will find the time to do that, though. I don't know how much effort that would be, either. Is there maybe a patch where A10 got converted from "as bad as gen5" to its current state? That would help me to see if I can do it...

A10 got switched to reset framework recently (in last 6 months or so), the reset driver is the same for Gen5 and A10 too, so it should be easy to recycle.

Hmm, ok, let me check that... it would indeed be nice to port this to gen5.

Since you seem kidn of opposed to OF_PLATDATA, does it make any sense to continue on this? I mean, I thought I heard people here saying "use OF_PLATDATA" if you're running out of space in SPL. After using it, I'm not too keen on using it, either, but it does seem to give me some code space back...

Quoted 6 lines
Quoted 3 lines

OF_PLATDATA is for platforms with really small SRAM, some 30k or below. This platform has a massive 60k of SRAM for SPL, so if we're running out of space, we're doing something wrong.

It's not for "30k or below" but "needs more space to enable all desired features inside of SPL".

Which the SoCFPGA should have with 60k of SRAM. If U-Boot SPL became so bloated that even platform with so much space has issues, how can we even cater for the rest of platforms with much more limited SPL ? And if that is the case, we have a much bigger problem ...

Signature · 2 lines
Best regards,
Marek Vasut
#11 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 67 lines · Marek Vasut
Quoted 66 lines · Tom Rini
Quoted 64 lines · Marek Vasut
Quoted 53 lines · Simon Goldschmidt
Quoted 43 lines · Marek Vasut
Quoted 30 lines · Simon Goldschmidt
Quoted 29 lines · Marek Vasut
Quoted 26 lines · Simon Goldschmidt
Quoted 10 lines · Marek Vasut
Quoted 6 lines · Simon Goldschmidt

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Quoted 4 lines
Quoted 1 line

Don't you need it to unreset at least the DWMMC or CQSPI ?

Reading the code, it seems like that's taken care of through another hack in spl_boot_device() ;-)

Sigh.

Quoted 4 lines
Quoted 3 lines

Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10. Would that be possible ?

Quoted 8 lines
Quoted 4 lines

I would be best, yes. I don't know when I will find the time to do that, though. I don't know how much effort that would be, either. Is there maybe a patch where A10 got converted from "as bad as gen5" to its current state? That would help me to see if I can do it...

A10 got switched to reset framework recently (in last 6 months or so), the reset driver is the same for Gen5 and A10 too, so it should be easy to recycle.

Quoted 6 lines

Hmm, ok, let me check that... it would indeed be nice to port this to gen5.

Since you seem kidn of opposed to OF_PLATDATA, does it make any sense to continue on this? I mean, I thought I heard people here saying "use OF_PLATDATA" if you're running out of space in SPL. After using it, I'm not too keen on using it, either, but it does seem to give me some code space back...

OF_PLATDATA is for platforms with really small SRAM, some 30k or below. This platform has a massive 60k of SRAM for SPL, so if we're running out of space, we're doing something wrong.

Quoted 7 lines
Quoted 2 lines

It's not for "30k or below" but "needs more space to enable all desired features inside of SPL".

Which the SoCFPGA should have with 60k of SRAM. If U-Boot SPL became so bloated that even platform with so much space has issues, how can we even cater for the rest of platforms with much more limited SPL ? And if that is the case, we have a much bigger problem ...

It depends, greatly, on what features you want within a single binary. I'm not saying SoCFPGA can't fit what it wants, including verified boot, inside of 60k. But what I am saying is we don't have a hard-and-fast limit on when you must not use OF_PLATDATA since it's always been easy to make SPL too big, once you start including all of the possible kitchen sink options (lets do falcon mode, and boot count and usb gadget and usb host and regular ethernet and mmc and nand and oh crap, where did all of my space go?).

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190108/c17b9ec2/attachment.sig>
#12 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Am 08.01.2019 um 15:58 schrieb Tom Rini:

Quoted 76 lines · Marek Vasut
Quoted 67 lines · Tom Rini
Quoted 66 lines · Marek Vasut
Quoted 64 lines · Simon Goldschmidt
Quoted 53 lines · Marek Vasut
Quoted 43 lines · Simon Goldschmidt
Quoted 30 lines · Marek Vasut
Quoted 29 lines · Simon Goldschmidt
Quoted 26 lines · Marek Vasut
Quoted 10 lines · Simon Goldschmidt
Quoted 6 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Quoted 4 lines
Quoted 1 line

Don't you need it to unreset at least the DWMMC or CQSPI ?

Reading the code, it seems like that's taken care of through another hack in spl_boot_device() ;-)

Sigh.

Quoted 4 lines
Quoted 3 lines

Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10. Would that be possible ?

Quoted 8 lines
Quoted 4 lines

I would be best, yes. I don't know when I will find the time to do that, though. I don't know how much effort that would be, either. Is there maybe a patch where A10 got converted from "as bad as gen5" to its current state? That would help me to see if I can do it...

A10 got switched to reset framework recently (in last 6 months or so), the reset driver is the same for Gen5 and A10 too, so it should be easy to recycle.

Quoted 6 lines

Hmm, ok, let me check that... it would indeed be nice to port this to gen5.

Since you seem kidn of opposed to OF_PLATDATA, does it make any sense to continue on this? I mean, I thought I heard people here saying "use OF_PLATDATA" if you're running out of space in SPL. After using it, I'm not too keen on using it, either, but it does seem to give me some code space back...

OF_PLATDATA is for platforms with really small SRAM, some 30k or below. This platform has a massive 60k of SRAM for SPL, so if we're running out of space, we're doing something wrong.

Quoted 7 lines
Quoted 2 lines

It's not for "30k or below" but "needs more space to enable all desired features inside of SPL".

Which the SoCFPGA should have with 60k of SRAM. If U-Boot SPL became so bloated that even platform with so much space has issues, how can we even cater for the rest of platforms with much more limited SPL ? And if that is the case, we have a much bigger problem ...

Quoted 8 lines

It depends, greatly, on what features you want within a single binary. I'm not saying SoCFPGA can't fit what it wants, including verified boot, inside of 60k. But what I am saying is we don't have a hard-and-fast limit on when you must not use OF_PLATDATA since it's always been easy to make SPL too big, once you start including all of the possible kitchen sink options (lets do falcon mode, and boot count and usb gadget and usb host and regular ethernet and mmc and nand and oh crap, where did all of my space go?).

I'm not saying this was directed to me (I'm sure it wasn't). Just to clarify my point: I'm really just trying to get the most basic SPL to work that loads U-Boot as FIT from spi-flash and verifies it. It might well be that it's this verified FIT offset that could be reduced...

Regards,
Simon

#13 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 86 lines · Simon Goldschmidt

Am 08.01.2019 um 15:58 schrieb Tom Rini:

Quoted 76 lines · Marek Vasut
Quoted 67 lines · Tom Rini
Quoted 66 lines · Marek Vasut
Quoted 64 lines · Simon Goldschmidt
Quoted 53 lines · Marek Vasut
Quoted 43 lines · Simon Goldschmidt
Quoted 30 lines · Marek Vasut
Quoted 29 lines · Simon Goldschmidt
Quoted 26 lines · Marek Vasut
Quoted 10 lines · Simon Goldschmidt
Quoted 6 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Quoted 4 lines
Quoted 1 line

Don't you need it to unreset at least the DWMMC or CQSPI ?

Reading the code, it seems like that's taken care of through another hack in spl_boot_device() ;-)

Sigh.

Quoted 4 lines
Quoted 3 lines

Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10. Would that be possible ?

Quoted 8 lines
Quoted 4 lines

I would be best, yes. I don't know when I will find the time to do that, though. I don't know how much effort that would be, either. Is there maybe a patch where A10 got converted from "as bad as gen5" to its current state? That would help me to see if I can do it...

A10 got switched to reset framework recently (in last 6 months or so), the reset driver is the same for Gen5 and A10 too, so it should be easy to recycle.

Quoted 6 lines

Hmm, ok, let me check that... it would indeed be nice to port this to gen5.

Since you seem kidn of opposed to OF_PLATDATA, does it make any sense to continue on this? I mean, I thought I heard people here saying "use OF_PLATDATA" if you're running out of space in SPL. After using it, I'm not too keen on using it, either, but it does seem to give me some code space back...

OF_PLATDATA is for platforms with really small SRAM, some 30k or below. This platform has a massive 60k of SRAM for SPL, so if we're running out of space, we're doing something wrong.

Quoted 7 lines
Quoted 2 lines

It's not for "30k or below" but "needs more space to enable all desired features inside of SPL".

Which the SoCFPGA should have with 60k of SRAM. If U-Boot SPL became so bloated that even platform with so much space has issues, how can we even cater for the rest of platforms with much more limited SPL ? And if that is the case, we have a much bigger problem ...

Quoted 8 lines

It depends, greatly, on what features you want within a single binary. I'm not saying SoCFPGA can't fit what it wants, including verified boot, inside of 60k. But what I am saying is we don't have a hard-and-fast limit on when you must not use OF_PLATDATA since it's always been easy to make SPL too big, once you start including all of the possible kitchen sink options (lets do falcon mode, and boot count and usb gadget and usb host and regular ethernet and mmc and nand and oh crap, where did all of my space go?).

Quoted 4 lines

I'm not saying this was directed to me (I'm sure it wasn't). Just to clarify my point: I'm really just trying to get the most basic SPL to work that loads U-Boot as FIT from spi-flash and verifies it. It might well be that it's this verified FIT offset that could be reduced...

Oh no, I'm just listing the worst case of am335x, which is my fault, and goes well over the generous 100k+ that we have available there.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190108/22b242a0/attachment.sig>
#14 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

In reply to Tom Rini
Quoted 76 lines · Tom Rini
Quoted 67 lines · Marek Vasut
Quoted 66 lines · Tom Rini
Quoted 64 lines · Marek Vasut
Quoted 53 lines · Simon Goldschmidt
Quoted 43 lines · Marek Vasut
Quoted 30 lines · Simon Goldschmidt
Quoted 29 lines · Marek Vasut
Quoted 26 lines · Simon Goldschmidt
Quoted 10 lines · Marek Vasut
Quoted 6 lines · Simon Goldschmidt

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Quoted 4 lines
Quoted 1 line

Don't you need it to unreset at least the DWMMC or CQSPI ?

Reading the code, it seems like that's taken care of through another hack in spl_boot_device() ;-)

Sigh.

Quoted 4 lines
Quoted 3 lines

Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10. Would that be possible ?

Quoted 8 lines
Quoted 4 lines

I would be best, yes. I don't know when I will find the time to do that, though. I don't know how much effort that would be, either. Is there maybe a patch where A10 got converted from "as bad as gen5" to its current state? That would help me to see if I can do it...

A10 got switched to reset framework recently (in last 6 months or so), the reset driver is the same for Gen5 and A10 too, so it should be easy to recycle.

Quoted 6 lines

Hmm, ok, let me check that... it would indeed be nice to port this to gen5.

Since you seem kidn of opposed to OF_PLATDATA, does it make any sense to continue on this? I mean, I thought I heard people here saying "use OF_PLATDATA" if you're running out of space in SPL. After using it, I'm not too keen on using it, either, but it does seem to give me some code space back...

OF_PLATDATA is for platforms with really small SRAM, some 30k or below. This platform has a massive 60k of SRAM for SPL, so if we're running out of space, we're doing something wrong.

Quoted 7 lines
Quoted 2 lines

It's not for "30k or below" but "needs more space to enable all desired features inside of SPL".

Which the SoCFPGA should have with 60k of SRAM. If U-Boot SPL became so bloated that even platform with so much space has issues, how can we even cater for the rest of platforms with much more limited SPL ? And if that is the case, we have a much bigger problem ...

Quoted 8 lines

It depends, greatly, on what features you want within a single binary. I'm not saying SoCFPGA can't fit what it wants, including verified boot, inside of 60k. But what I am saying is we don't have a hard-and-fast limit on when you must not use OF_PLATDATA since it's always been easy to make SPL too big, once you start including all of the possible kitchen sink options (lets do falcon mode, and boot count and usb gadget and usb host and regular ethernet and mmc and nand and oh crap, where did all of my space go?).

Sure, but then maybe you do need to remove some of that stuff and configure the SPL for that one single need you have.

Signature · 2 lines
Best regards,
Marek Vasut
#15 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

In reply to Marek Vasut

Am 08.01.2019 um 15:50 schrieb Marek Vasut:

Quoted 67 lines · Tom Rini
Quoted 66 lines · Marek Vasut
Quoted 64 lines · Simon Goldschmidt
Quoted 53 lines · Marek Vasut
Quoted 43 lines · Simon Goldschmidt
Quoted 30 lines · Marek Vasut
Quoted 29 lines · Simon Goldschmidt
Quoted 26 lines · Marek Vasut
Quoted 10 lines · Simon Goldschmidt
Quoted 6 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Quoted 4 lines
Quoted 1 line

Don't you need it to unreset at least the DWMMC or CQSPI ?

Reading the code, it seems like that's taken care of through another hack in spl_boot_device() ;-)

Sigh.

Quoted 4 lines
Quoted 3 lines

Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10. Would that be possible ?

Quoted 8 lines
Quoted 4 lines

I would be best, yes. I don't know when I will find the time to do that, though. I don't know how much effort that would be, either. Is there maybe a patch where A10 got converted from "as bad as gen5" to its current state? That would help me to see if I can do it...

A10 got switched to reset framework recently (in last 6 months or so), the reset driver is the same for Gen5 and A10 too, so it should be easy to recycle.

Quoted 6 lines

Hmm, ok, let me check that... it would indeed be nice to port this to gen5.

Since you seem kidn of opposed to OF_PLATDATA, does it make any sense to continue on this? I mean, I thought I heard people here saying "use OF_PLATDATA" if you're running out of space in SPL. After using it, I'm not too keen on using it, either, but it does seem to give me some code space back...

OF_PLATDATA is for platforms with really small SRAM, some 30k or below. This platform has a massive 60k of SRAM for SPL, so if we're running out of space, we're doing something wrong.

Quoted 7 lines
Quoted 2 lines

It's not for "30k or below" but "needs more space to enable all desired features inside of SPL".

Which the SoCFPGA should have with 60k of SRAM. If U-Boot SPL became so bloated that even platform with so much space has issues, how can we even cater for the rest of platforms with much more limited SPL ? And if that is the case, we have a much bigger problem ...

I have to add here: I'm not running out of space in SPL just yet. I'm at 45k But I have tried and the remaining 15k don't seem to be enough to add verified FIT loading code. I expect this to be something very rarely used, if it is used at all (I saw presentations doing this to implement verified boot, but I failed to find the code in SPL that does this)...

I don't know yet how I'll continue here. I'll check again exactly how much of the SRAM my current OF_PLATDATA patches save.

Regards,
Simon

#16 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Am 08.01.2019 um 16:01 schrieb Simon Goldschmidt:

Quoted 76 lines

Am 08.01.2019 um 15:50 schrieb Marek Vasut:

Quoted 67 lines · Tom Rini
Quoted 66 lines · Marek Vasut
Quoted 64 lines · Simon Goldschmidt
Quoted 53 lines · Marek Vasut
Quoted 43 lines · Simon Goldschmidt
Quoted 30 lines · Marek Vasut
Quoted 29 lines · Simon Goldschmidt
Quoted 26 lines · Marek Vasut
Quoted 10 lines · Simon Goldschmidt
Quoted 6 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now I know socfpga is
lacking support for clock and reset management via devicetree. And this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

That being said, drivers/reset/reset-uclass.c fails to compile with OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I don't seem
to need it for socfpga either, I don't think this would be the right series to fix that.

Quoted 4 lines
Quoted 1 line

Don't you need it to unreset at least the DWMMC or CQSPI ?

Reading the code, it seems like that's taken care of through another hack in spl_boot_device() ;-)

Sigh.

Quoted 4 lines
Quoted 3 lines

Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10. Would that be possible ?

Quoted 8 lines
Quoted 4 lines

I would be best, yes. I don't know when I will find the time to do that, though. I don't know how much effort that would be, either. Is there maybe a patch where A10 got converted from "as bad as gen5" to its current state? That would help me to see if I can do it...

A10 got switched to reset framework recently (in last 6 months or so), the reset driver is the same for Gen5 and A10 too, so it should be easy to recycle.

Quoted 6 lines

Hmm, ok, let me check that... it would indeed be nice to port this to gen5.

Since you seem kidn of opposed to OF_PLATDATA, does it make any sense to continue on this? I mean, I thought I heard people here saying "use OF_PLATDATA" if you're running out of space in SPL. After using it, I'm not too keen on using it, either, but it does seem to give me some code space back...

OF_PLATDATA is for platforms with really small SRAM, some 30k or below. This platform has a massive 60k of SRAM for SPL, so if we're running out of space, we're doing something wrong.

Quoted 7 lines
Quoted 2 lines

It's not for "30k or below" but "needs more space to enable all desired features inside of SPL".

Which the SoCFPGA should have with 60k of SRAM. If U-Boot SPL became so bloated that even platform with so much space has issues, how can we even cater for the rest of platforms with much more limited SPL ? And if that is the case, we have a much bigger problem ...

Quoted 8 lines

I have to add here: I'm not running out of space in SPL just yet. I'm at 45k But I have tried and the remaining 15k don't seem to be enough to add verified FIT loading code. I expect this to be something very rarely used, if it is used at all (I saw presentations doing this to implement verified boot, but I failed to find the code in SPL that does this)...

I don't know yet how I'll continue here. I'll check again exactly how much of the SRAM my current OF_PLATDATA patches save.

Ok, so when booting from mmc (with the tiny mmc framework), this series saves ~5.6 KiB of the SRAM for SPL (~3.7 KiB .text reduction, ~1.7 KiB for the DTB binary, other sections are slightly smaller).

It's not the world, but it's more than 10% (from ~40 KiB to 34.5 KiB). I don't insist on doing this, but I wanted to write down numbers in case someone wants to discuss this further.

Regards,
Simon

#17 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 108 lines · Simon Goldschmidt

Am 08.01.2019 um 16:01 schrieb Simon Goldschmidt:

Quoted 98 lines

Am 08.01.2019 um 15:50 schrieb Marek Vasut:

Quoted 89 lines · Tom Rini
Quoted 88 lines · Marek Vasut
Quoted 86 lines · Simon Goldschmidt
Quoted 72 lines · Marek Vasut
Quoted 62 lines · Simon Goldschmidt
Quoted 39 lines · Marek Vasut
Quoted 38 lines · Simon Goldschmidt
Quoted 35 lines
Quoted 7 lines · Marek Vasut
Quoted 5 lines · Simon Goldschmidt

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

Quoted 6 lines
Quoted 3 lines

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Here again, socfpga seems to be another bad example. Taking peripherals out of reset
is cluttered throughout the mach-socfpga code at least in SPL. By now
I know socfpga is
lacking support for clock and reset management via devicetree. And
this is bad, I know,
but can we keep this a seperate issue from OF_PLATDATA?

That being said, drivers/reset/reset-uclass.c fails to compile with
OF_PLATDATA, so I
guess this has not been used with OF_PLATDATA before. And given that I
don't seem
to need it for socfpga either, I don't think this would be the right
series to fix that.

Quoted 5 lines
Quoted 1 line

Don't you need it to unreset at least the DWMMC or CQSPI ?

Reading the code, it seems like that's taken care of through another hack in
spl_boot_device() ;-)

Sigh.

Quoted 5 lines
Quoted 4 lines

Anyway, I'd much prefer to start cleaning up the horrorshow that arch/arm/mach-socfpga is in terms of clock and reset, at least like A10.
Would that be possible ?

Quoted 7 lines

I would be best, yes. I don't know when I will find the time to do that, though.
I don't know how much effort that would be, either. Is there maybe a patch
where A10 got converted from "as bad as gen5" to its current state? That
would help me to see if I can do it...

Quoted 5 lines

A10 got switched to reset framework recently (in last 6 months or so),
the reset driver is the same for Gen5 and A10 too, so it should be easy
to recycle.

Hmm, ok, let me check that... it would indeed be nice to port this to gen5.

Quoted 7 lines

Since you seem kidn of opposed to OF_PLATDATA, does it make any sense to continue on this? I mean, I thought I heard people here saying "use
OF_PLATDATA" if you're running out of space in SPL. After using it, I'm not too
keen on using it, either, but it does seem to give me some code space back...

OF_PLATDATA is for platforms with really small SRAM, some 30k or below.
This platform has a massive 60k of SRAM for SPL, so if we're running out
of space, we're doing something wrong.

Quoted 7 lines
Quoted 2 lines

It's not for "30k or below" but "needs more space to enable all desired features inside of SPL".

Which the SoCFPGA should have with 60k of SRAM. If U-Boot SPL became so bloated that even platform with so much space has issues, how can we even cater for the rest of platforms with much more limited SPL ? And if that is the case, we have a much bigger problem ...

Quoted 8 lines

I have to add here: I'm not running out of space in SPL just yet. I'm at 45k But I have tried and the remaining 15k don't seem to be enough to add verified FIT loading code. I expect this to be something very rarely used, if it is used at all (I saw presentations doing this to implement verified boot, but I failed to find the code in SPL that does this)...

I don't know yet how I'll continue here. I'll check again exactly how much of the SRAM my current OF_PLATDATA patches save.

Quoted 7 lines

Ok, so when booting from mmc (with the tiny mmc framework), this series saves ~5.6 KiB of the SRAM for SPL (~3.7 KiB .text reduction, ~1.7 KiB for the DTB binary, other sections are slightly smaller).

It's not the world, but it's more than 10% (from ~40 KiB to 34.5 KiB). I don't insist on doing this, but I wanted to write down numbers in case someone wants to discuss this further.

I'm sure if you went all the way and removed even the DT support altogether, the SPL would be even smaller too.

Signature · 2 lines
Best regards,
Marek Vasut
#18 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

In reply to Marek Vasut

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 9 lines · Simon Goldschmidt
Quoted 6 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However, at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

I guess that needs some cleaning up as well ;-)

I think the proper thing to do here would be to remove this function and convert all drivers to provide appropriate 'resets' properties in the dts?

Regards,
Simon

#19 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 11 lines · Simon Goldschmidt

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 9 lines · Simon Goldschmidt
Quoted 6 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Quoted 8 lines

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However, at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

I guess that needs some cleaning up as well ;-)

Yes

Quoted 2 lines

I think the proper thing to do here would be to remove this function and convert all drivers to provide appropriate 'resets' properties in the dts?

Indeed

Signature · 2 lines
Best regards,
Marek Vasut
#20 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 19 lines · Simon Goldschmidt
Quoted 18 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 9 lines · Simon Goldschmidt
Quoted 6 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However, at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

Quoted 8 lines
Quoted 1 line

I guess that needs some cleaning up as well ;-)

Yes

Quoted 2 lines

I think the proper thing to do here would be to remove this function and convert all drivers to provide appropriate 'resets' properties in the dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some "resets" properties the the main dtsi and adding reset bulk code to the cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't enabled by U-Boot because it relies on them being enabled. How are such dependencies solved? Because even if I would add reset support in the corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Regards,
Simon

maintainer
#21 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Hi Simon,

Quoted 37 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 23 lines · Simon Goldschmidt
Quoted 13 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 11 lines · Simon Goldschmidt
Quoted 8 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Quoted 8 lines

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However, at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

I guess that needs some cleaning up as well ;-)

Quoted 7 lines

Yes

Quoted 3 lines

I think the proper thing to do here would be to remove this function and convert all drivers to provide appropriate 'resets' properties in the dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some "resets" properties the the main dtsi and adding reset bulk code to the cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset code from arch/mach_socfpga.

Quoted 6 lines

The problem would be that now Linux cannot use peripherals that aren't enabled by U-Boot because it relies on them being enabled. How are such dependencies solved? Because even if I would add reset support in the corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

I added an early reset driver for SoCFPGA that should take care of this. The patch is in v5.0-rc2[1].

Dinh

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/reset?id=b3ca9888f35fa6919569cf27c929dc0ac49e9716

#22 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Hi Dinh,

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 47 lines

Hi Simon,

Quoted 37 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 23 lines · Simon Goldschmidt
Quoted 13 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 11 lines · Simon Goldschmidt
Quoted 8 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

Quoted 8 lines

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However, at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

I guess that needs some cleaning up as well ;-)

Quoted 7 lines

Yes

Quoted 3 lines

I think the proper thing to do here would be to remove this function and convert all drivers to provide appropriate 'resets' properties in the dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some "resets" properties the the main dtsi and adding reset bulk code to the cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset code from arch/mach_socfpga.

Quoted 6 lines

The problem would be that now Linux cannot use peripherals that aren't enabled by U-Boot because it relies on them being enabled. How are such dependencies solved? Because even if I would add reset support in the corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 2 lines

I added an early reset driver for SoCFPGA that should take care of this. The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

But am I correct that my above problem remains even in v5.0 as not all peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and qspi) and would thuse not be taken out of reset by Linux?

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an older kernel...

Regards,
Simon

Quoted 6 lines

Dinh

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/reset?id=b3ca9888f35fa6919569cf27c929dc0ac49e9716

#23 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 1 line · Simon Goldschmidt

Hi Dinh,

Hi,

Quoted 50 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 49 lines

Hi Simon,

Quoted 45 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 24 lines · Simon Goldschmidt
Quoted 21 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 11 lines · Simon Goldschmidt
Quoted 8 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Quoted 8 lines

Yes

Quoted 4 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in the dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some "resets" properties the the main dtsi and adding reset bulk code to the cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't enabled by U-Boot because it relies on them being enabled. How are such dependencies solved? Because even if I would add reset support in the corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 5 lines
Quoted 2 lines

I added an early reset driver for SoCFPGA that should take care of this. The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 7 lines

But am I correct that my above problem remains even in v5.0 as not all peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and qspi) and would thuse not be taken out of reset by Linux?

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Quoted 11 lines

Regards,
Simon

Quoted 7 lines

Dinh

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/reset?id=b3ca9888f35fa6919569cf27c929dc0ac49e9716

Signature · 2 lines
Best regards,
Marek Vasut
#24 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Am 14.01.2019 um 19:31 schrieb Marek Vasut:

Quoted 67 lines · Simon Goldschmidt
Quoted 1 line

Hi Dinh,

Hi,

Quoted 50 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 49 lines

Hi Simon,

Quoted 45 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 24 lines · Simon Goldschmidt
Quoted 21 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 11 lines · Simon Goldschmidt
Quoted 8 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Quoted 8 lines

Yes

Quoted 4 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in the dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some "resets" properties the the main dtsi and adding reset bulk code to the cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't enabled by U-Boot because it relies on them being enabled. How are such dependencies solved? Because even if I would add reset support in the corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 5 lines
Quoted 2 lines

I added an early reset driver for SoCFPGA that should take care of this. The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 4 lines

But am I correct that my above problem remains even in v5.0 as not all peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and qspi) and would thuse not be taken out of reset by Linux?

Quoted 5 lines
Quoted 3 lines

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Ok, so that at leat shows me I'm going into the right direction :-)

There are some problems though:
- I do care (we're running 4.9 currently) *g*
- people running an RT kernel will care for a while (until the next stable RT after fixing this will be released)
- we would currently be breaking *all* kernels, since no kernel should yet be able to deassert reset for mmc and qspi (unless this is already done by U-Boot)...

So would it be OK to add a Kconfig option to U-Boot to keep the current behaviour (for old broken kernels like you said) until that code is spread widely enough? Or is that a no-go?

Regards,
Simon

#25 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 90 lines · Simon Goldschmidt

Am 14.01.2019 um 19:31 schrieb Marek Vasut:

Quoted 73 lines · Simon Goldschmidt
Quoted 1 line

Hi Dinh,

Hi,

Quoted 55 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 54 lines

Hi Simon,

Quoted 50 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 26 lines · Simon Goldschmidt
Quoted 21 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 11 lines · Simon Goldschmidt
Quoted 8 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Yes

Quoted 7 lines
Quoted 5 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in the
dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some
"resets" properties the the main dtsi and adding reset bulk code to the
cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset
code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't enabled by U-Boot because it relies on them being enabled. How are such
dependencies solved? Because even if I would add reset support in the corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 6 lines
Quoted 3 lines

I added an early reset driver for SoCFPGA that should take care of this.
The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 4 lines

But am I correct that my above problem remains even in v5.0 as not all peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and qspi) and would thuse not be taken out of reset by Linux?

Quoted 5 lines
Quoted 3 lines

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Ok, so that at leat shows me I'm going into the right direction :-)

There are some problems though:
- I do care (we're running 4.9 currently) *g*
- people running an RT kernel will care for a while (until the next stable RT after fixing this will be released)
- we would currently be breaking *all* kernels, since no kernel should yet be able to deassert reset for mmc and qspi (unless this is already done by U-Boot)...

Quoted 3 lines

So would it be OK to add a Kconfig option to U-Boot to keep the current behaviour (for old broken kernels like you said) until that code is spread widely enough? Or is that a no-go?

Would be nice to be able to tweak the reset driver behavior at runtime, to unreset things before booting the kernel if the user desires so.

Signature · 2 lines
Best regards,
Marek Vasut
#26 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Am 14.01.2019 um 20:33 schrieb Marek Vasut:

Quoted 91 lines · Simon Goldschmidt
Quoted 90 lines

Am 14.01.2019 um 19:31 schrieb Marek Vasut:

Quoted 73 lines · Simon Goldschmidt
Quoted 1 line

Hi Dinh,

Hi,

Quoted 55 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 54 lines

Hi Simon,

Quoted 50 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 26 lines · Simon Goldschmidt
Quoted 21 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 11 lines · Simon Goldschmidt
Quoted 8 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Yes

Quoted 7 lines
Quoted 5 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in the
dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some
"resets" properties the the main dtsi and adding reset bulk code to the
cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset
code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't enabled by U-Boot because it relies on them being enabled. How are such
dependencies solved? Because even if I would add reset support in the corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 6 lines
Quoted 3 lines

I added an early reset driver for SoCFPGA that should take care of this.
The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 4 lines

But am I correct that my above problem remains even in v5.0 as not all peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and qspi) and would thuse not be taken out of reset by Linux?

Quoted 5 lines
Quoted 3 lines

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Ok, so that at leat shows me I'm going into the right direction :-)

There are some problems though:
- I do care (we're running 4.9 currently) *g*
- people running an RT kernel will care for a while (until the next stable RT after fixing this will be released)
- we would currently be breaking *all* kernels, since no kernel should yet be able to deassert reset for mmc and qspi (unless this is already done by U-Boot)...

Quoted 6 lines
Quoted 3 lines

So would it be OK to add a Kconfig option to U-Boot to keep the current behaviour (for old broken kernels like you said) until that code is spread widely enough? Or is that a no-go?

Would be nice to be able to tweak the reset driver behavior at runtime, to unreset things before booting the kernel if the user desires so.

Instead of tweaking the reset driver, we could just add a command that does that 'rstmgr->permodrst = 0;' thing my patch would remove.

Since noone has complained so far, I think writing 0 should be OK here. I don't think it would make too much sense to use the reset handoff defines from Quartus output for such a command. I think the way Quartus does this is strange anyway...

The question is if defconfigs should be able to use this to automatically build a U-Boot config for older kernels. If so, we'd still need a Kconfig option?

Thinking further about cleanup: I guess the clock driver is not that hard to implement, either. The only thing that's driving me mad is pinmux. Is there any chance to get more info from Intel to write this properly so we can get rid of that iocsr scanchain defines?

Thanks,
Simon

#27 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 101 lines · Simon Goldschmidt

Am 14.01.2019 um 20:33 schrieb Marek Vasut:

Quoted 100 lines · Simon Goldschmidt
Quoted 98 lines

Am 14.01.2019 um 19:31 schrieb Marek Vasut:

Quoted 77 lines · Simon Goldschmidt
Quoted 1 line

Hi Dinh,

Hi,

Quoted 59 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 58 lines

Hi Simon,

Quoted 54 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 28 lines · Simon Goldschmidt
Quoted 23 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 6 lines · Simon Goldschmidt
Quoted 5 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

Quoted 6 lines
Quoted 3 lines

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing
that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Yes

Quoted 7 lines
Quoted 5 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in the
dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some
"resets" properties the the main dtsi and adding reset bulk code to the
cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset
code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't
enabled by U-Boot because it relies on them being enabled. How are such
dependencies solved? Because even if I would add reset support in the
corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 6 lines
Quoted 3 lines

I added an early reset driver for SoCFPGA that should take care of this.
The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 4 lines

But am I correct that my above problem remains even in v5.0 as not all peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and qspi) and would thuse not be taken out of reset by Linux?

Quoted 6 lines
Quoted 4 lines

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an
older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Ok, so that at leat shows me I'm going into the right direction :-)

There are some problems though:
- I do care (we're running 4.9 currently) *g*
- people running an RT kernel will care for a while (until the next stable RT after fixing this will be released)
- we would currently be breaking *all* kernels, since no kernel should yet be able to deassert reset for mmc and qspi (unless this is already done by U-Boot)...

So would it be OK to add a Kconfig option to U-Boot to keep the current behaviour (for old broken kernels like you said) until that code is spread widely enough? Or is that a no-go?

Quoted 5 lines
Quoted 2 lines

Would be nice to be able to tweak the reset driver behavior at runtime, to unreset things before booting the kernel if the user desires so.

Instead of tweaking the reset driver, we could just add a command that does that 'rstmgr->permodrst = 0;' thing my patch would remove.

I don't want a new custom command.

Quoted 8 lines

Since noone has complained so far, I think writing 0 should be OK here. I don't think it would make too much sense to use the reset handoff defines from Quartus output for such a command. I think the way Quartus does this is strange anyway...

The question is if defconfigs should be able to use this to automatically build a U-Boot config for older kernels. If so, we'd still need a Kconfig option?

I'd much rather have this runtime configurable.

Quoted 4 lines

Thinking further about cleanup: I guess the clock driver is not that hard to implement, either. The only thing that's driving me mad is pinmux. Is there any chance to get more info from Intel to write this properly so we can get rid of that iocsr scanchain defines?

Clock driver should be easy, yes. Pinmux, I don't know, maybe project chibi has some information (the cyclone I documentation project).

Signature · 2 lines
Best regards,
Marek Vasut
#28 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Am 14.01.2019 um 21:01 schrieb Marek Vasut:

Quoted 115 lines · Simon Goldschmidt
Quoted 101 lines

Am 14.01.2019 um 20:33 schrieb Marek Vasut:

Quoted 100 lines · Simon Goldschmidt
Quoted 98 lines

Am 14.01.2019 um 19:31 schrieb Marek Vasut:

Quoted 77 lines · Simon Goldschmidt
Quoted 1 line

Hi Dinh,

Hi,

Quoted 59 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 58 lines

Hi Simon,

Quoted 54 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 28 lines · Simon Goldschmidt
Quoted 23 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 6 lines · Simon Goldschmidt
Quoted 5 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

Quoted 6 lines
Quoted 3 lines

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing
that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Yes

Quoted 7 lines
Quoted 5 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in the
dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some
"resets" properties the the main dtsi and adding reset bulk code to the
cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset
code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't
enabled by U-Boot because it relies on them being enabled. How are such
dependencies solved? Because even if I would add reset support in the
corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 6 lines
Quoted 3 lines

I added an early reset driver for SoCFPGA that should take care of this.
The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 4 lines

But am I correct that my above problem remains even in v5.0 as not all peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and qspi) and would thuse not be taken out of reset by Linux?

Quoted 6 lines
Quoted 4 lines

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an
older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Ok, so that at leat shows me I'm going into the right direction :-)

There are some problems though:
- I do care (we're running 4.9 currently) *g*
- people running an RT kernel will care for a while (until the next stable RT after fixing this will be released)
- we would currently be breaking *all* kernels, since no kernel should yet be able to deassert reset for mmc and qspi (unless this is already done by U-Boot)...

So would it be OK to add a Kconfig option to U-Boot to keep the current behaviour (for old broken kernels like you said) until that code is spread widely enough? Or is that a no-go?

Quoted 5 lines
Quoted 2 lines

Would be nice to be able to tweak the reset driver behavior at runtime, to unreset things before booting the kernel if the user desires so.

Instead of tweaking the reset driver, we could just add a command that does that 'rstmgr->permodrst = 0;' thing my patch would remove.

I don't want a new custom command.

Quoted 5 lines

Since noone has complained so far, I think writing 0 should be OK here. I don't think it would make too much sense to use the reset handoff defines from Quartus output for such a command. I think the way Quartus does this is strange anyway...

Quoted 5 lines
Quoted 3 lines

The question is if defconfigs should be able to use this to automatically build a U-Boot config for older kernels. If so, we'd still need a Kconfig option?

I'd much rather have this runtime configurable.

Then I'm afraid I don't know what you mean by "runtime configurable". What should be the configuration source that is evaluated at runtime?

Quoted 8 lines
Quoted 5 lines

Thinking further about cleanup: I guess the clock driver is not that hard to implement, either. The only thing that's driving me mad is pinmux. Is there any chance to get more info from Intel to write this properly so we can get rid of that iocsr scanchain defines?

Clock driver should be easy, yes. Pinmux, I don't know, maybe project chibi has some information (the cyclone I documentation project).

Interesing, I didn't know that project. The only thing I found is a repo on github. But it seems like that one only contains FPGA-related stuff, nothing about the HPS side...

Regards,
Simon

#29 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 125 lines · Simon Goldschmidt

Am 14.01.2019 um 21:01 schrieb Marek Vasut:

Quoted 124 lines · Simon Goldschmidt
Quoted 110 lines

Am 14.01.2019 um 20:33 schrieb Marek Vasut:

Quoted 109 lines · Simon Goldschmidt
Quoted 107 lines

Am 14.01.2019 um 19:31 schrieb Marek Vasut:

Quoted 84 lines · Simon Goldschmidt
Quoted 1 line

Hi Dinh,

Hi,

Quoted 64 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 63 lines

Hi Simon,

Quoted 59 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 30 lines · Simon Goldschmidt
Quoted 25 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 6 lines · Simon Goldschmidt
Quoted 5 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and
SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be
disabled
via defconfig.

Quoted 7 lines
Quoted 4 lines

This also seems to be required to use OF_PLATDATA, as the
reset
drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing
that, it enables *ALL* peripherals on the SoC (except for some DMA
channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Yes

Quoted 8 lines
Quoted 6 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in
the
dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some
"resets" properties the the main dtsi and adding reset bulk code to
the
cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset
code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't
enabled by U-Boot because it relies on them being enabled. How are such
dependencies solved? Because even if I would add reset support in the
corresponding Linux drivers, we probably could not bootolder Kernels
(e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 6 lines
Quoted 3 lines

I added an early reset driver for SoCFPGA that should take care of this.
The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 6 lines

But am I correct that my above problem remains even in v5.0 as not all
peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and
qspi) and would thuse not be taken out of reset by Linux?

Quoted 7 lines
Quoted 4 lines

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an
older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Ok, so that at leat shows me I'm going into the right direction :-)

There are some problems though:
- I do care (we're running 4.9 currently) *g*
- people running an RT kernel will care for a while (until the next stable RT after fixing this will be released)
- we would currently be breaking *all* kernels, since no kernel should yet be able to deassert reset for mmc and qspi (unless this is already done by U-Boot)...

So would it be OK to add a Kconfig option to U-Boot to keep the current
behaviour (for old broken kernels like you said) until that code is spread widely enough? Or is that a no-go?

Quoted 5 lines
Quoted 2 lines

Would be nice to be able to tweak the reset driver behavior at runtime, to unreset things before booting the kernel if the user desires so.

Instead of tweaking the reset driver, we could just add a command that does that 'rstmgr->permodrst = 0;' thing my patch would remove.

I don't want a new custom command.

Quoted 5 lines

Since noone has complained so far, I think writing 0 should be OK here. I don't think it would make too much sense to use the reset handoff defines from Quartus output for such a command. I think the way Quartus does this is strange anyway...

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

The question is if defconfigs should be able to use this to automatically build a U-Boot config for older kernels. If so, we'd still need a Kconfig option?

I'd much rather have this runtime configurable.

Then I'm afraid I don't know what you mean by "runtime configurable". What should be the configuration source that is evaluated at runtime?

I wonder ... maybe an environment variable with a U_BOOT_ENV_CALLBACK() hook ?

Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

Thinking further about cleanup: I guess the clock driver is not that hard to implement, either. The only thing that's driving me mad is pinmux. Is there any chance to get more info from Intel to write this properly so we can get rid of that iocsr scanchain defines?

Clock driver should be easy, yes. Pinmux, I don't know, maybe project chibi has some information (the cyclone I documentation project).

Interesing, I didn't know that project. The only thing I found is a repo on github. But it seems like that one only contains FPGA-related stuff, nothing about the HPS side...

My understanding is that the IOCSR ring is on the FPGA side and it's exactly the same as pinmux configuration for the FPGA IO, but I might be wrong.

Signature · 2 lines
Best regards,
Marek Vasut
#30 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 131 lines · Marek Vasut
Quoted 129 lines · Simon Goldschmidt

Am 14.01.2019 um 21:01 schrieb Marek Vasut:

Quoted 128 lines · Simon Goldschmidt
Quoted 110 lines

Am 14.01.2019 um 20:33 schrieb Marek Vasut:

Quoted 109 lines · Simon Goldschmidt
Quoted 107 lines

Am 14.01.2019 um 19:31 schrieb Marek Vasut:

Quoted 84 lines · Simon Goldschmidt
Quoted 1 line

Hi Dinh,

Hi,

Quoted 64 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 63 lines

Hi Simon,

Quoted 59 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 30 lines · Simon Goldschmidt
Quoted 25 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 13 lines · Simon Goldschmidt

In order to build a smaller SPL, let's imply SPL_DM_RESET and
SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be
disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the
reset
drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset
controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing
that, it enables *ALL* peripherals on the SoC (except for some DMA
channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Yes

Quoted 8 lines
Quoted 6 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in
the
dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some
"resets" properties the the main dtsi and adding reset bulk code to
the
cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset
code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't
enabled by U-Boot because it relies on them being enabled. How are such
dependencies solved? Because even if I would add reset support in the
corresponding Linux drivers, we probably could not bootolder Kernels
(e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 6 lines
Quoted 3 lines

I added an early reset driver for SoCFPGA that should take care of this.
The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 6 lines

But am I correct that my above problem remains even in v5.0 as not all
peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and
qspi) and would thuse not be taken out of reset by Linux?

Quoted 7 lines
Quoted 4 lines

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an
older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Ok, so that at leat shows me I'm going into the right direction :-)

There are some problems though:
- I do care (we're running 4.9 currently) *g*
- people running an RT kernel will care for a while (until the next stable RT after fixing this will be released)
- we would currently be breaking *all* kernels, since no kernel should yet be able to deassert reset for mmc and qspi (unless this is already done by U-Boot)...

So would it be OK to add a Kconfig option to U-Boot to keep the current
behaviour (for old broken kernels like you said) until that code is spread widely enough? Or is that a no-go?

Quoted 5 lines
Quoted 2 lines

Would be nice to be able to tweak the reset driver behavior at runtime, to unreset things before booting the kernel if the user desires so.

Instead of tweaking the reset driver, we could just add a command that does that 'rstmgr->permodrst = 0;' thing my patch would remove.

I don't want a new custom command.

Quoted 8 lines

Since noone has complained so far, I think writing 0 should be OK here. I don't think it would make too much sense to use the reset handoff defines from Quartus output for such a command. I think the way Quartus does this is strange anyway...

The question is if defconfigs should be able to use this to automatically build a U-Boot config for older kernels. If so, we'd still need a Kconfig option?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I'd much rather have this runtime configurable.

Then I'm afraid I don't know what you mean by "runtime configurable". What should be the configuration source that is evaluated at runtime?

I wonder ... maybe an environment variable with a U_BOOT_ENV_CALLBACK() hook ?

But when doing it like that, I'd still have to modify the U-Boot sources to build a version of U-Boot that could successfully boot a 4.9 kernel.
I wanted to be able to do that without changing the sources, that's why I would have added a Kconfig option...

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines

Thinking further about cleanup: I guess the clock driver is not that hard to implement, either. The only thing that's driving me mad is pinmux. Is there any chance to get more info from Intel to write this properly so we can get rid of that iocsr scanchain defines?

Clock driver should be easy, yes. Pinmux, I don't know, maybe project chibi has some information (the cyclone I documentation project).

Quoted 7 lines
Quoted 3 lines

Interesing, I didn't know that project. The only thing I found is a repo on github. But it seems like that one only contains FPGA-related stuff, nothing about the HPS side...

My understanding is that the IOCSR ring is on the FPGA side and it's exactly the same as pinmux configuration for the FPGA IO, but I might be wrong.

Hmm, I really don't know. Has anyone ever tried asking Intel for this? Is it a known fact that they won't give away such specs?

Regards,
Simon

#31 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 137 lines · Simon Goldschmidt
Quoted 136 lines · Marek Vasut
Quoted 133 lines · Simon Goldschmidt

Am 14.01.2019 um 21:01 schrieb Marek Vasut:

Quoted 124 lines · Simon Goldschmidt
Quoted 110 lines

Am 14.01.2019 um 20:33 schrieb Marek Vasut:

Quoted 109 lines · Simon Goldschmidt
Quoted 107 lines

Am 14.01.2019 um 19:31 schrieb Marek Vasut:

Quoted 84 lines · Simon Goldschmidt
Quoted 1 line

Hi Dinh,

Hi,

Quoted 64 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 63 lines

Hi Simon,

Quoted 59 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 30 lines · Simon Goldschmidt
Quoted 26 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:
On 1/7/19 10:14 PM, Simon Goldschmidt wrote:
In order to build a smaller SPL, let's imply SPL_DM_RESET and
SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be
disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the
reset
drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset
controller ?

I found that out just now: there's the function
'reset_deassert_peripherals_handoff()' in spl_gen5.c that should
"De-assert reset for peripherals and bridges based on handoff".
However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By
doing
that, it enables *ALL* peripherals on the SoC (except for
some DMA
channels that aren't really used) :-)

I guess that needs some cleaning up as well ;-)

Yes

Quoted 8 lines
Quoted 6 lines

I think the proper thing to do here would be to remove this
function and
convert all drivers to provide appropriate 'resets'
properties in
the
dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some
"resets" properties the the main dtsi and adding reset bulk code to
the
cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset
code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't
enabled by U-Boot because it relies on them being enabled. How are such
dependencies solved? Because even if I would add reset support in the
corresponding Linux drivers, we probably could not bootolder Kernels
(e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 6 lines
Quoted 3 lines

I added an early reset driver for SoCFPGA that should take care of this.
The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 6 lines

But am I correct that my above problem remains even in v5.0 as not all
peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and
qspi) and would thuse not be taken out of reset by Linux?

Quoted 7 lines
Quoted 4 lines

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an
older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Ok, so that at leat shows me I'm going into the right direction :-)

There are some problems though:
- I do care (we're running 4.9 currently) *g*
- people running an RT kernel will care for a while (until the next stable RT after fixing this will be released)
- we would currently be breaking *all* kernels, since no kernel should yet be able to deassert reset for mmc and qspi (unless this is already done by U-Boot)...

So would it be OK to add a Kconfig option to U-Boot to keep the current
behaviour (for old broken kernels like you said) until that code is spread widely enough? Or is that a no-go?

Quoted 5 lines
Quoted 2 lines

Would be nice to be able to tweak the reset driver behavior at runtime, to unreset things before booting the kernel if the user desires so.

Instead of tweaking the reset driver, we could just add a command that does that 'rstmgr->permodrst = 0;' thing my patch would remove.

I don't want a new custom command.

Quoted 5 lines

Since noone has complained so far, I think writing 0 should be OK here. I don't think it would make too much sense to use the reset handoff defines from Quartus output for such a command. I think the way Quartus does this is strange anyway...

Quoted 5 lines
Quoted 3 lines

The question is if defconfigs should be able to use this to automatically build a U-Boot config for older kernels. If so, we'd still need a Kconfig option?

I'd much rather have this runtime configurable.

Then I'm afraid I don't know what you mean by "runtime configurable". What should be the configuration source that is evaluated at runtime?

Quoted 8 lines
Quoted 2 lines

I wonder ... maybe an environment variable with a U_BOOT_ENV_CALLBACK() hook ?

But when doing it like that, I'd still have to modify the U-Boot sources to build a version of U-Boot that could successfully boot a 4.9 kernel.
I wanted to be able to do that without changing the sources, that's why I would have added a Kconfig option...

If you have an environment variable which allows you to indicate that your kernel is broken/old, you can set it and boot.

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

Thinking further about cleanup: I guess the clock driver is not that hard to implement, either. The only thing that's driving me mad is pinmux. Is there any chance to get more info from Intel to write this properly so we can get rid of that iocsr scanchain defines?

Clock driver should be easy, yes. Pinmux, I don't know, maybe project chibi has some information (the cyclone I documentation project).

Interesing, I didn't know that project. The only thing I found is a repo on github. But it seems like that one only contains FPGA-related stuff, nothing about the HPS side...

Quoted 6 lines
Quoted 3 lines

My understanding is that the IOCSR ring is on the FPGA side and it's exactly the same as pinmux configuration for the FPGA IO, but I might be wrong.

Hmm, I really don't know. Has anyone ever tried asking Intel for this? Is it a known fact that they won't give away such specs?

Dinh is on CC :)

Signature · 2 lines
Best regards,
Marek Vasut
#32 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Am 14.01.2019 um 21:49 schrieb Marek Vasut:

Quoted 141 lines · Simon Goldschmidt
Quoted 140 lines · Marek Vasut
Quoted 138 lines · Simon Goldschmidt
Quoted 125 lines

Am 14.01.2019 um 21:01 schrieb Marek Vasut:

Quoted 124 lines · Simon Goldschmidt
Quoted 110 lines

Am 14.01.2019 um 20:33 schrieb Marek Vasut:

Quoted 109 lines · Simon Goldschmidt
Quoted 107 lines

Am 14.01.2019 um 19:31 schrieb Marek Vasut:

Quoted 84 lines · Simon Goldschmidt
Quoted 1 line

Hi Dinh,

Hi,

Quoted 64 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 63 lines

Hi Simon,

Quoted 59 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 38 lines · Simon Goldschmidt

Am 07.01.2019 um 23:53 schrieb Marek Vasut:
On 1/7/19 10:14 PM, Simon Goldschmidt wrote:
In order to build a smaller SPL, let's imply SPL_DM_RESET and
SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be
disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the
reset
drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset
controller ?

I found that out just now: there's the function
'reset_deassert_peripherals_handoff()' in spl_gen5.c that should
"De-assert reset for peripherals and bridges based on handoff".
However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By
doing
that, it enables *ALL* peripherals on the SoC (except for
some DMA
channels that aren't really used) :-)

I guess that needs some cleaning up as well ;-)

Yes

I think the proper thing to do here would be to remove this
function and
convert all drivers to provide appropriate 'resets'
properties in
the
dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some
"resets" properties the the main dtsi and adding reset bulk code to
the
cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset
code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't
enabled by U-Boot because it relies on them being enabled. How are such
dependencies solved? Because even if I would add reset support in the
corresponding Linux drivers, we probably could not bootolder Kernels
(e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 6 lines
Quoted 3 lines

I added an early reset driver for SoCFPGA that should take care of this.
The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 6 lines

But am I correct that my above problem remains even in v5.0 as not all
peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and
qspi) and would thuse not be taken out of reset by Linux?

Quoted 7 lines
Quoted 4 lines

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an
older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Ok, so that at leat shows me I'm going into the right direction :-)

There are some problems though:
- I do care (we're running 4.9 currently) *g*
- people running an RT kernel will care for a while (until the next stable RT after fixing this will be released)
- we would currently be breaking *all* kernels, since no kernel should yet be able to deassert reset for mmc and qspi (unless this is already done by U-Boot)...

So would it be OK to add a Kconfig option to U-Boot to keep the current
behaviour (for old broken kernels like you said) until that code is spread widely enough? Or is that a no-go?

Quoted 5 lines
Quoted 2 lines

Would be nice to be able to tweak the reset driver behavior at runtime, to unreset things before booting the kernel if the user desires so.

Instead of tweaking the reset driver, we could just add a command that does that 'rstmgr->permodrst = 0;' thing my patch would remove.

I don't want a new custom command.

Quoted 5 lines

Since noone has complained so far, I think writing 0 should be OK here. I don't think it would make too much sense to use the reset handoff defines from Quartus output for such a command. I think the way Quartus does this is strange anyway...

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

The question is if defconfigs should be able to use this to automatically build a U-Boot config for older kernels. If so, we'd still need a Kconfig option?

I'd much rather have this runtime configurable.

Then I'm afraid I don't know what you mean by "runtime configurable". What should be the configuration source that is evaluated at runtime?

I wonder ... maybe an environment variable with a U_BOOT_ENV_CALLBACK() hook ?

Quoted 8 lines
Quoted 5 lines

But when doing it like that, I'd still have to modify the U-Boot sources to build a version of U-Boot that could successfully boot a 4.9 kernel.
I wanted to be able to do that without changing the sources, that's why I would have added a Kconfig option...

If you have an environment variable which allows you to indicate that your kernel is broken/old, you can set it and boot.

Fair enough. I'll try it like that.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 5 lines

Thinking further about cleanup: I guess the clock driver is not that hard to implement, either. The only thing that's driving me mad is pinmux. Is there any chance to get more info from Intel to write this properly so we can get rid of that iocsr scanchain defines?

Clock driver should be easy, yes. Pinmux, I don't know, maybe project chibi has some information (the cyclone I documentation project).

Interesing, I didn't know that project. The only thing I found is a repo on github. But it seems like that one only contains FPGA-related stuff, nothing about the HPS side...

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

My understanding is that the IOCSR ring is on the FPGA side and it's exactly the same as pinmux configuration for the FPGA IO, but I might be wrong.

Hmm, I really don't know. Has anyone ever tried asking Intel for this? Is it a known fact that they won't give away such specs?

Dinh is on CC :)

I know ;-)

Regards,
Simon

#33 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

In reply to Marek Vasut
Quoted 67 lines · Marek Vasut
Quoted 1 line · Simon Goldschmidt

Hi Dinh,

Hi,

Quoted 50 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 49 lines

Hi Simon,

Quoted 45 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 24 lines · Simon Goldschmidt
Quoted 21 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 11 lines · Simon Goldschmidt
Quoted 8 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Quoted 8 lines

Yes

Quoted 4 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in the dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some "resets" properties the the main dtsi and adding reset bulk code to the cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't enabled by U-Boot because it relies on them being enabled. How are such dependencies solved? Because even if I would add reset support in the corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 5 lines
Quoted 2 lines

I added an early reset driver for SoCFPGA that should take care of this. The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 4 lines

But am I correct that my above problem remains even in v5.0 as not all peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and qspi) and would thuse not be taken out of reset by Linux?

Quoted 5 lines
Quoted 3 lines

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Yes, we care. Especially since it sounds like we're talking about something that's an LTS and not super-ancient vendor kernel. Off the top of my head I can't recall if we ever fully removed support in sunxi for the vendor kernel in some cases, or just made it, eventually, opt-in as it was a fairly annoying incompatible behavior case.

But yes, in general, we do care about old kernels and need to be loud and clear about when we're removing support for them on a given SoC due to it being a PITA to support both ways of doing X and people have had Y years to migrate or correct their kernel.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190114/42d1c6ca/attachment.sig>
#34 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 80 lines · Tom Rini
Quoted 67 lines · Marek Vasut
Quoted 1 line · Simon Goldschmidt

Hi Dinh,

Hi,

Quoted 50 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 49 lines

Hi Simon,

Quoted 45 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 24 lines · Simon Goldschmidt
Quoted 21 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 11 lines · Simon Goldschmidt
Quoted 8 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Quoted 8 lines

Yes

Quoted 4 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in the dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some "resets" properties the the main dtsi and adding reset bulk code to the cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't enabled by U-Boot because it relies on them being enabled. How are such dependencies solved? Because even if I would add reset support in the corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 5 lines
Quoted 2 lines

I added an early reset driver for SoCFPGA that should take care of this. The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 4 lines

But am I correct that my above problem remains even in v5.0 as not all peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and qspi) and would thuse not be taken out of reset by Linux?

Quoted 5 lines
Quoted 3 lines

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Yes, we care. Especially since it sounds like we're talking about something that's an LTS and not super-ancient vendor kernel. Off the top of my head I can't recall if we ever fully removed support in sunxi for the vendor kernel in some cases, or just made it, eventually, opt-in as it was a fairly annoying incompatible behavior case.

Quoted 4 lines

But yes, in general, we do care about old kernels and need to be loud and clear about when we're removing support for them on a given SoC due to it being a PITA to support both ways of doing X and people have had Y years to migrate or correct their kernel.

Then we have to add some fallback mechanism, possibly the env variable to tell reset controller to unreset everything.

Signature · 2 lines
Best regards,
Marek Vasut
#35 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Am 14.01.2019 um 22:30 schrieb Marek Vasut:

Quoted 81 lines · Tom Rini
Quoted 80 lines · Marek Vasut
Quoted 67 lines · Simon Goldschmidt
Quoted 1 line

Hi Dinh,

Hi,

Quoted 50 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 49 lines

Hi Simon,

Quoted 45 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 24 lines · Simon Goldschmidt
Quoted 21 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 11 lines · Simon Goldschmidt
Quoted 8 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Quoted 8 lines

Yes

Quoted 4 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in the dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some "resets" properties the the main dtsi and adding reset bulk code to the cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't enabled by U-Boot because it relies on them being enabled. How are such dependencies solved? Because even if I would add reset support in the corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 5 lines
Quoted 2 lines

I added an early reset driver for SoCFPGA that should take care of this. The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 4 lines

But am I correct that my above problem remains even in v5.0 as not all peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and qspi) and would thuse not be taken out of reset by Linux?

Quoted 5 lines
Quoted 3 lines

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Yes, we care. Especially since it sounds like we're talking about something that's an LTS and not super-ancient vendor kernel. Off the top of my head I can't recall if we ever fully removed support in sunxi for the vendor kernel in some cases, or just made it, eventually, opt-in as it was a fairly annoying incompatible behavior case.

Quoted 7 lines
Quoted 4 lines

But yes, in general, we do care about old kernels and need to be loud and clear about when we're removing support for them on a given SoC due to it being a PITA to support both ways of doing X and people have had Y years to migrate or correct their kernel.

Then we have to add some fallback mechanism, possibly the env variable to tell reset controller to unreset everything.

So is an env variable good enough as opt-in or opt-out? How was the sunxi thing handled? My feeling is that it would be better to have a Kconfig option for such things, to make it just boot after compiling it, without relying on the manual act of changing the environment.

But I'm just some user, I'll leave it up to you two to decide ;-)

Regards,
Simon

#36 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

In reply to Marek Vasut
Quoted 81 lines · Marek Vasut
Quoted 80 lines · Tom Rini
Quoted 67 lines · Marek Vasut
Quoted 1 line · Simon Goldschmidt

Hi Dinh,

Hi,

Quoted 50 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 49 lines

Hi Simon,

Quoted 45 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 24 lines · Simon Goldschmidt
Quoted 21 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 11 lines · Simon Goldschmidt
Quoted 8 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Quoted 8 lines

Yes

Quoted 4 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in the dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some "resets" properties the the main dtsi and adding reset bulk code to the cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that aren't enabled by U-Boot because it relies on them being enabled. How are such dependencies solved? Because even if I would add reset support in the corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 5 lines
Quoted 2 lines

I added an early reset driver for SoCFPGA that should take care of this. The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 4 lines

But am I correct that my above problem remains even in v5.0 as not all peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and qspi) and would thuse not be taken out of reset by Linux?

Quoted 5 lines
Quoted 3 lines

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running with an older kernel...

Yes, it'd break old broken kernels . The real question is, do we care ?

Yes, we care. Especially since it sounds like we're talking about something that's an LTS and not super-ancient vendor kernel. Off the top of my head I can't recall if we ever fully removed support in sunxi for the vendor kernel in some cases, or just made it, eventually, opt-in as it was a fairly annoying incompatible behavior case.

Quoted 7 lines
Quoted 4 lines

But yes, in general, we do care about old kernels and need to be loud and clear about when we're removing support for them on a given SoC due to it being a PITA to support both ways of doing X and people have had Y years to migrate or correct their kernel.

Then we have to add some fallback mechanism, possibly the env variable to tell reset controller to unreset everything.

Alright, so the prior art in question is:
commit accc9e446be6c3bd129315a0c5830bddccfa16da

Author: Hans de Goede <[email protected]>
Date:   Wed Oct 22 14:56:36 2014 +0200

sunxi: Add CONFIG_OLD_SUNXI_KERNEL_COMPAT Kconfig option

And is about supporting the sunxi 3.4 vendor kernel tree, and something we have still (and a single enabler of). So, what's the range of broken / not broken kernels here?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190114/7a318a2f/attachment.sig>
#37 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Am Mo., 14. Jan. 2019, 22:50 hat Tom Rini <[email protected]> geschrieben:

Quoted 110 lines · Marek Vasut
Quoted 20 lines · Tom Rini
Quoted 19 lines · Marek Vasut
Quoted 18 lines · Simon Goldschmidt
Quoted 1 line

Hi Dinh,

Hi,

Quoted 13 lines

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 12 lines

Hi Simon,

Quoted 9 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 8 lines · Simon Goldschmidt
Quoted 7 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 6 lines · Simon Goldschmidt
Quoted 5 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset

controller ?

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By

doing

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

that, it enables *ALL* peripherals on the SoC (except for some

DMA

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

channels that aren't really used) :-)

I guess that needs some cleaning up as well ;-)

Yes

Quoted 3 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties

in the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding

some

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"resets" properties the the main dtsi and adding reset bulk code

to the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

cadence_qspi, denali_dt nand and drivers, I can nearly remove the

reset

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

code from arch/mach_socfpga.

The problem would be that now Linux cannot use peripherals that

aren't

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

enabled by U-Boot because it relies on them being enabled. How are

such

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

dependencies solved? Because even if I would add reset support in

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

corresponding Linux drivers, we probably could not bootolder

Kernels

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

(e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

I added an early reset driver for SoCFPGA that should take care of

this.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

We had the same problem with A10, indeed.

Quoted 1 line

But am I correct that my above problem remains even in v5.0 as not

all

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc

and

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

qspi) and would thuse not be taken out of reset by Linux?

Plus: should U-Boot work with older Linux kernels? Because if so, we need fallback code in U-Boot to unreset peripherals when running

with an

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

older kernel...

Yes, it'd break old broken kernels . The real question is, do we care

?

Quoted 5 lines
Quoted 5 lines

Yes, we care. Especially since it sounds like we're talking about something that's an LTS and not super-ancient vendor kernel. Off the top of my head I can't recall if we ever fully removed support in sunxi for the vendor kernel in some cases, or just made it, eventually,

opt-in

Quoted 5 lines
Quoted 5 lines

as it was a fairly annoying incompatible behavior case.

But yes, in general, we do care about old kernels and need to be loud and clear about when we're removing support for them on a given SoC due to it being a PITA to support both ways of doing X and people have had

Y

Quoted 4 lines
Quoted 1 line

years to migrate or correct their kernel.

Then we have to add some fallback mechanism, possibly the env variable to tell reset controller to unreset everything.

Alright, so the prior art in question is:
commit accc9e446be6c3bd129315a0c5830bddccfa16da

Quoted 9 lines
Author: Hans de Goede <[email protected]>
Date:   Wed Oct 22 14:56:36 2014 +0200

sunxi: Add CONFIG_OLD_SUNXI_KERNEL_COMPAT Kconfig option

And is about supporting the sunxi 3.4 vendor kernel tree, and something we have still (and a single enabler of). So, what's the range of broken / not broken kernels here?

I haven't yet tested but my idea is that it is still broken (some of the devices won't come out of reset in some scenarios).

So I guess such a Kconfig option would even need to be enabled by default for some time...

Regards,
Simon

Quoted 1 line
#38 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 135 lines · Simon Goldschmidt

Am Mo., 14. Jan. 2019, 22:50 hat Tom Rini <[email protected] <mailto:[email protected]>> geschrieben:

On Mon, Jan 14, 2019 at 10:30:36PM +0100, Marek Vasut wrote:
> On 1/14/19 10:28 PM, Tom Rini wrote:
> > On Mon, Jan 14, 2019 at 07:31:26PM +0100, Marek Vasut wrote:
> >> On 1/14/19 5:05 PM, Simon Goldschmidt wrote:
> >>> Hi Dinh,
> >>
> >> Hi,
> >>
> >>> Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:
> >>>> Hi Simon,
> >>>>
> >>>> On 1/14/19 9:50 AM, Simon Goldschmidt wrote:
> >>>>> Am 11.01.2019 um 23:02 schrieb Marek Vasut:
> >>>>>> On 1/11/19 9:39 PM, Simon Goldschmidt wrote:
> >>>>>>> Am 07.01.2019 um 23:53 schrieb Marek Vasut:
> >>>>>>>> On 1/7/19 10:14 PM, Simon Goldschmidt wrote:
> >>>>>>>>> In order to build a smaller SPL, let's imply SPL_DM_RESET and
> >>>>>>>>> SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be
> >>>>>>>>> disabled
> >>>>>>>>> via defconfig.
> >>>>>>>>>
> >>>>>>>>> This also seems to be required to use OF_PLATDATA, as the reset
> >>>>>>>>> drivers
> >>>>>>>>> don't seem to work with it.
> >>>>>>>>
> >>>>>>>> How do you un-reset IP blocks if you disable the reset controller ?
> >>>>>>>
> >>>>>>> I found that out just now: there's the function
> >>>>>>> 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should
> >>>>>>> "De-assert reset for peripherals and bridges based on handoff".
> >>>>>>> However,
> >>>>>>> at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing
> >>>>>>> that, it enables *ALL* peripherals on the SoC (except for some DMA
> >>>>>>> channels that aren't really used) :-)
> >>>>>>>
> >>>>>>> I guess that needs some cleaning up as well ;-)
> >>>>>>
> >>>>>> Yes
> >>>>>>
> >>>>>>> I think the proper thing to do here would be to remove this > >>>>>>> function and
> >>>>>>> convert all drivers to provide appropriate 'resets' properties in the
> >>>>>>> dts?
> >>>>>>
> >>>>>> Indeed
> >>>>>
> >>>>> So I just did that and it works nice for SPL and U-Boot: By adding some
> >>>>> "resets" properties the the main dtsi and adding reset bulk code to the
> >>>>> cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset
> >>>>> code from arch/mach_socfpga.
> >>>>>
> >>>>> The problem would be that now Linux cannot use peripherals that aren't
> >>>>> enabled by U-Boot because it relies on them being enabled. How are such
> >>>>> dependencies solved? Because even if I would add reset support in the
> >>>>> corresponding Linux drivers, we probably could not bootolder Kernels
> >>>>> (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot... > >>>>>
> >>>>
> >>>> I added an early reset driver for SoCFPGA that should take care of this.
> >>>> The patch is in v5.0-rc2[1].
> >>>
> >>> OK, it's good to know that this work is already done, I haven't > >>> monitored this close enough.
> >>
> >> We had the same problem with A10, indeed.
> >>
> >>> But am I correct that my above problem remains even in v5.0 as not all
> >>> peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and
> >>> qspi) and would thuse not be taken out of reset by Linux? > >>>
> >>> Plus: should U-Boot work with older Linux kernels? Because if so, we
> >>> need fallback code in U-Boot to unreset peripherals when running with an
> >>> older kernel...
> >>
> >> Yes, it'd break old broken kernels . The real question is, do we care ?
> >
> > Yes, we care.  Especially since it sounds like we're talking about > > something that's an LTS and not super-ancient vendor kernel. Off the
> > top of my head I can't recall if we ever fully removed support in sunxi
> > for the vendor kernel in some cases, or just made it, eventually, opt-in
> > as it was a fairly annoying incompatible behavior case. > >
> > But yes, in general, we do care about old kernels and need to be loud
> > and clear about when we're removing support for them on a given SoC due
> > to it being a PITA to support both ways of doing X and people have had Y
> > years to migrate or correct their kernel.
>
> Then we have to add some fallback mechanism, possibly the env variable > to tell reset controller to unreset everything.

Alright, so the prior art in question is:
commit accc9e446be6c3bd129315a0c5830bddccfa16da
Author: Hans de Goede <hdegoede at redhat.com <mailto:[email protected]>> Date:   Wed Oct 22 14:56:36 2014 +0200

    sunxi: Add CONFIG_OLD_SUNXI_KERNEL_COMPAT Kconfig option

And is about supporting the sunxi 3.4 vendor kernel tree, and something we have still (and a single enabler of).  So, what's the range of broken / not broken kernels here?

Quoted 5 lines

I haven't yet tested but my idea is that it is still broken (some of the devices won't come out of reset in some scenarios).

So I guess such a Kconfig option would even need to be enabled by default for some time...

Well, if you had a variable to configure that at runtime, you won't need another ad-hoc Kconfig option .

Signature · 2 lines
Best regards,
Marek Vasut
maintainer
#39 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

In reply to Simon Goldschmidt
Quoted 55 lines · Simon Goldschmidt

Hi Dinh,

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 49 lines

Hi Simon,

Quoted 39 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 24 lines · Simon Goldschmidt
Quoted 21 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 11 lines · Simon Goldschmidt
Quoted 8 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Quoted 8 lines

Yes

Quoted 4 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in the dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some "resets" properties the the main dtsi and adding reset bulk code to the cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset code from arch/mach_socfpga.

Quoted 6 lines

The problem would be that now Linux cannot use peripherals that aren't enabled by U-Boot because it relies on them being enabled. How are such dependencies solved? Because even if I would add reset support in the corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 2 lines

I added an early reset driver for SoCFPGA that should take care of this. The patch is in v5.0-rc2[1].

Quoted 7 lines

OK, it's good to know that this work is already done, I haven't monitored this close enough.

But am I correct that my above problem remains even in v5.0 as not all peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and qspi) and would thuse not be taken out of reset by Linux?

Yes, I see that. I will send a patch for those.

Dinh

#40 lore raw

PATCH 1/4 arm: socfpga: imply SPL config instead of select

Quoted 62 lines · Dinh Nguyen
Quoted 58 lines · Simon Goldschmidt

Hi Dinh,

Am 14.01.2019 um 16:58 schrieb Dinh Nguyen:

Quoted 49 lines

Hi Simon,

Quoted 39 lines · Simon Goldschmidt

Am 11.01.2019 um 23:02 schrieb Marek Vasut:

Quoted 24 lines · Simon Goldschmidt
Quoted 21 lines

Am 07.01.2019 um 23:53 schrieb Marek Vasut:

Quoted 11 lines · Simon Goldschmidt
Quoted 8 lines

In order to build a smaller SPL, let's imply SPL_DM_RESET and SPL_WATCHDOG_SUPPORT instead of selecting them, so they can be disabled
via defconfig.

This also seems to be required to use OF_PLATDATA, as the reset drivers
don't seem to work with it.

How do you un-reset IP blocks if you disable the reset controller ?

I found that out just now: there's the function 'reset_deassert_peripherals_handoff()' in spl_gen5.c that should "De-assert reset for peripherals and bridges based on handoff". However,
at least for Gen5, it just writes a 0 to rstmgr->permodrst. By doing that, it enables *ALL* peripherals on the SoC (except for some DMA channels that aren't really used) :-)

Quoted 1 line

I guess that needs some cleaning up as well ;-)

Quoted 8 lines

Yes

Quoted 4 lines

I think the proper thing to do here would be to remove this function and
convert all drivers to provide appropriate 'resets' properties in the dts?

Indeed

So I just did that and it works nice for SPL and U-Boot: By adding some "resets" properties the the main dtsi and adding reset bulk code to the cadence_qspi, denali_dt nand and drivers, I can nearly remove the reset code from arch/mach_socfpga.

Quoted 6 lines

The problem would be that now Linux cannot use peripherals that aren't enabled by U-Boot because it relies on them being enabled. How are such dependencies solved? Because even if I would add reset support in the corresponding Linux drivers, we probably could not bootolder Kernels (e.g. the Debian 9 kernel - v4.9.x) with a new U-Boot...

Quoted 2 lines

I added an early reset driver for SoCFPGA that should take care of this. The patch is in v5.0-rc2[1].

OK, it's good to know that this work is already done, I haven't monitored this close enough.

Quoted 6 lines
Quoted 4 lines

But am I correct that my above problem remains even in v5.0 as not all peripherals in socfpga.dtsi have a "resets" property set (e.g. mmc and qspi) and would thuse not be taken out of reset by Linux?

Yes, I see that. I will send a patch for those.

OK, great! I don't know the driver structure in Linux as well, will that be a dts change only or does it require changing the mmc/qspi drivers to deassert those resets?

The reset handles are also missing for yet more peripherals, I have prepared this as a patch for U-Boot, but I guess the devicetree is still in sync, so I could send this patch for Linux as well?

Regards,
Simon

#41 lore raw

PATCH 2/4 arm: socfpga: fix compiling with OF_PLATDATA

In reply to Simon Goldschmidt

'socfpga_eth_reset_common' must not be compiled when OF_PLATDATA is enabled since it uses functions accessing the devicetree.

Since this function is not used in SPL anyway, change the compile guard to reflect this and fix compiling SPL with OF_PLATDATA.

---

 arch/arm/mach-socfpga/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/misc.c +1 -1
index 78fbe28724..30f74d9940 100644
@@ -120,7 +120,7 @@ int arch_cpu_init(void)
 	return 0;
 }
 
-#ifdef CONFIG_ETH_DESIGNWARE
+#if defined CONFIG_ETH_DESIGNWARE && !defined CONFIG_SPL_BUILD
 static int dwmac_phymode_to_modereg(const char *phymode, u32 *modereg)
 {
 	if (!phymode)
Signature · 1 line
2.17.1
#42 lore raw

PATCH 2/4 arm: socfpga: fix compiling with OF_PLATDATA

Quoted 5 lines · Simon Goldschmidt

'socfpga_eth_reset_common' must not be compiled when OF_PLATDATA is enabled since it uses functions accessing the devicetree.

Since this function is not used in SPL anyway, change the compile guard to reflect this and fix compiling SPL with OF_PLATDATA.

Doesn't this break ethernet in SPL ? I think it does. The real fix is to move this PHY mode configuration into the driver.

Quoted 20 lines

---

 arch/arm/mach-socfpga/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/misc.c +1 -1
index 78fbe28724..30f74d9940 100644
@@ -120,7 +120,7 @@ int arch_cpu_init(void)
 	return 0;
 }
 
-#ifdef CONFIG_ETH_DESIGNWARE
+#if defined CONFIG_ETH_DESIGNWARE && !defined CONFIG_SPL_BUILD
 static int dwmac_phymode_to_modereg(const char *phymode, u32 *modereg)
 {
 	if (!phymode)
Signature · 2 lines
Best regards,
Marek Vasut
#43 lore raw

PATCH 2/4 arm: socfpga: fix compiling with OF_PLATDATA

Quoted 10 lines · Marek Vasut
Quoted 5 lines · Simon Goldschmidt

'socfpga_eth_reset_common' must not be compiled when OF_PLATDATA is enabled since it uses functions accessing the devicetree.

Since this function is not used in SPL anyway, change the compile guard to reflect this and fix compiling SPL with OF_PLATDATA.

Doesn't this break ethernet in SPL ? I think it does. The real fix is to move this PHY mode configuration into the driver.

Hmm, ethernet in SPL. Haven't thought of that :-)

While it could be easy to move the DTS part of PHY mode configuration into the driver, moving the reset portion of that code into the driver would be ugly unless using proper reset management?

Quoted 15 lines
Quoted 15 lines

---

 arch/arm/mach-socfpga/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/misc.c +0 -0
index 78fbe28724..30f74d9940 100644
@@ -120,7 +120,7 @@ int arch_cpu_init(void)
      return 0;
 }
 
Quoted 2 lines

arch/arm/mach-socfpga/misc.c int arch_cpu_init(void) · line 123

Quoted 2 lines
arch/arm/mach-socfpga/misc.c +1 -1
-#ifdef CONFIG_ETH_DESIGNWARE
+#if defined CONFIG_ETH_DESIGNWARE && !defined CONFIG_SPL_BUILD

Would it work for you to change this into:

#if defined CONFIG_ETH_DESIGNWARE && !CONFIG_IS_ENABLED(OF_PLATDATA)

We could still fix the reset code when actually using OF_PLATDATA with ethernet...

Regards,
Simon

Quoted 9 lines

arch/arm/mach-socfpga/misc.c int arch_cpu_init(void) · line 126

Quoted 4 lines
arch/arm/mach-socfpga/misc.c +0 -0
 static int dwmac_phymode_to_modereg(const char *phymode, u32 *modereg)
 {
      if (!phymode)

--
Best regards,
Marek Vasut

#44 lore raw

PATCH 2/4 arm: socfpga: fix compiling with OF_PLATDATA

Quoted 9 lines · Simon Goldschmidt
Quoted 8 lines · Marek Vasut
Quoted 5 lines · Simon Goldschmidt

'socfpga_eth_reset_common' must not be compiled when OF_PLATDATA is enabled since it uses functions accessing the devicetree.

Since this function is not used in SPL anyway, change the compile guard to reflect this and fix compiling SPL with OF_PLATDATA.

Quoted 8 lines
Quoted 2 lines

Doesn't this break ethernet in SPL ? I think it does. The real fix is to move this PHY mode configuration into the driver.

Hmm, ethernet in SPL. Haven't thought of that :-)

While it could be easy to move the DTS part of PHY mode configuration into the driver, moving the reset portion of that code into the driver would be ugly unless using proper reset management?

Well, it's still better than having it live in arch/arm/ , which was at that point the best option, but right now it's no longer. And I think Joyce ran into similar topic with some other Altera IP.

Quoted 19 lines
Quoted 14 lines
Quoted 14 lines

---

 arch/arm/mach-socfpga/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/misc.c +0 -0
index 78fbe28724..30f74d9940 100644
@@ -120,7 +120,7 @@ int arch_cpu_init(void)
      return 0;
 }
 
Quoted 2 lines

arch/arm/mach-socfpga/misc.c int arch_cpu_init(void) · line 123

Quoted 2 lines
arch/arm/mach-socfpga/misc.c +1 -1
-#ifdef CONFIG_ETH_DESIGNWARE
+#if defined CONFIG_ETH_DESIGNWARE && !defined CONFIG_SPL_BUILD

Would it work for you to change this into:

Quoted 4 lines

#if defined CONFIG_ETH_DESIGNWARE && !CONFIG_IS_ENABLED(OF_PLATDATA)

We could still fix the reset code when actually using OF_PLATDATA with ethernet...

Is it too much work to fix it properly ?

Signature · 2 lines
Best regards,
Marek Vasut
#45 lore raw

PATCH 2/4 arm: socfpga: fix compiling with OF_PLATDATA

Quoted 16 lines · Marek Vasut
Quoted 14 lines · Simon Goldschmidt
Quoted 10 lines · Marek Vasut
Quoted 5 lines · Simon Goldschmidt

'socfpga_eth_reset_common' must not be compiled when OF_PLATDATA is enabled since it uses functions accessing the devicetree.

Since this function is not used in SPL anyway, change the compile guard to reflect this and fix compiling SPL with OF_PLATDATA.

Doesn't this break ethernet in SPL ? I think it does. The real fix is to move this PHY mode configuration into the driver.

Hmm, ethernet in SPL. Haven't thought of that :-)

Quoted 7 lines
Quoted 3 lines

While it could be easy to move the DTS part of PHY mode configuration into the driver, moving the reset portion of that code into the driver would be ugly unless using proper reset management?

Well, it's still better than having it live in arch/arm/ , which was at that point the best option, but right now it's no longer. And I think Joyce ran into similar topic with some other Altera IP.

Hmm, ok, I could search for that.

Quoted 19 lines
Quoted 19 lines
Quoted 14 lines
Quoted 14 lines

---

 arch/arm/mach-socfpga/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/misc.c +0 -0
index 78fbe28724..30f74d9940 100644
@@ -120,7 +120,7 @@ int arch_cpu_init(void)
      return 0;
 }
 
Quoted 2 lines

arch/arm/mach-socfpga/misc.c int arch_cpu_init(void) · line 123

Quoted 2 lines
arch/arm/mach-socfpga/misc.c +1 -1
-#ifdef CONFIG_ETH_DESIGNWARE
+#if defined CONFIG_ETH_DESIGNWARE && !defined CONFIG_SPL_BUILD

Would it work for you to change this into:

Quoted 6 lines
Quoted 4 lines

#if defined CONFIG_ETH_DESIGNWARE && !CONFIG_IS_ENABLED(OF_PLATDATA)

We could still fix the reset code when actually using OF_PLATDATA with ethernet...

Is it too much work to fix it properly ?

Well, just moving the functions I commented out into the eth driver would mean it would at some point call back into arch/arm/mach-socfpga code.

If that is acceptable, it wouldn't be too much work and I could certainly do it. But the question remains whether such a change would "fix it properly". In my opinion, it wouldn't. But it would probably still be better than the current state
where some code in arch/arm parses ETH DTS nodes...

Regards,
Simon

#46 lore raw

PATCH 2/4 arm: socfpga: fix compiling with OF_PLATDATA

Quoted 53 lines · Simon Goldschmidt
Quoted 16 lines · Marek Vasut
Quoted 14 lines · Simon Goldschmidt
Quoted 10 lines · Marek Vasut
Quoted 5 lines · Simon Goldschmidt

'socfpga_eth_reset_common' must not be compiled when OF_PLATDATA is enabled since it uses functions accessing the devicetree.

Since this function is not used in SPL anyway, change the compile guard to reflect this and fix compiling SPL with OF_PLATDATA.

Doesn't this break ethernet in SPL ? I think it does. The real fix is to move this PHY mode configuration into the driver.

Hmm, ethernet in SPL. Haven't thought of that :-)

Quoted 7 lines
Quoted 3 lines

While it could be easy to move the DTS part of PHY mode configuration into the driver, moving the reset portion of that code into the driver would be ugly unless using proper reset management?

Well, it's still better than having it live in arch/arm/ , which was at that point the best option, but right now it's no longer. And I think Joyce ran into similar topic with some other Altera IP.

Hmm, ok, I could search for that.

Quoted 19 lines
Quoted 19 lines
Quoted 14 lines
Quoted 14 lines

---

 arch/arm/mach-socfpga/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/misc.c +0 -0
index 78fbe28724..30f74d9940 100644
@@ -120,7 +120,7 @@ int arch_cpu_init(void)
      return 0;
 }
 
Quoted 2 lines

arch/arm/mach-socfpga/misc.c int arch_cpu_init(void) · line 123

Quoted 2 lines
arch/arm/mach-socfpga/misc.c +1 -1
-#ifdef CONFIG_ETH_DESIGNWARE
+#if defined CONFIG_ETH_DESIGNWARE && !defined CONFIG_SPL_BUILD

Would it work for you to change this into:

Quoted 6 lines
Quoted 4 lines

#if defined CONFIG_ETH_DESIGNWARE && !CONFIG_IS_ENABLED(OF_PLATDATA)

We could still fix the reset code when actually using OF_PLATDATA with ethernet...

Is it too much work to fix it properly ?

Quoted 8 lines

Well, just moving the functions I commented out into the eth driver would mean it would at some point call back into arch/arm/mach-socfpga code.

If that is acceptable, it wouldn't be too much work and I could certainly do it. But the question remains whether such a change would "fix it properly". In my opinion, it wouldn't. But it would probably still be better than the current state
where some code in arch/arm parses ETH DTS nodes...

Right. I think you can just pull that info from the DT node associated with the DWMAC driver.

Signature · 2 lines
Best regards,
Marek Vasut
#47 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

In reply to Simon Goldschmidt

Add a driver for the "snps,dw-apb-uart" used in socfpga and others.

This driver is required to get OF_PLATDATA to work for socfpga. It uses the ns16550 driver, converting the platdata from of-platdata go the ns16550 format.

---

 drivers/serial/Kconfig         | 10 ++++++++
 drivers/serial/Makefile        |  1 +
 drivers/serial/serial_dw_apb.c | 42 ++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 drivers/serial/serial_dw_apb.c
drivers/serial/Kconfig +10 -0
index b7ff2960ab..10addd3309 100644
@@ -511,6 +511,16 @@ config BCM283X_PL011_SERIAL
 	  that supports automatic disable, so that it only gets used when
 	  the UART is actually muxed.
 
+config DESIGNWARE_SERIAL
+	bool "DesignWare UART support"
+	depends on DM_SERIAL && SPL_OF_PLATDATA
+	help
+	  Select this to enable a UART driver for "snps,dw-apb-uart" devices
+	  when using CONFIG_SPL_OF_PLATDATA (i.e. a compiled-in device tree
+	  replacement).
+	  This uses the ns16550 driver, converting the platdata from of-platdata
+	  to the ns16550 format.
+
 config BCM6345_SERIAL
 	bool "Support for BCM6345 UART"
 	depends on DM_SERIAL
drivers/serial/Makefile +1 -0
index 06ee30697d..f1ebb90d92 100644
@@ -46,6 +46,7 @@ obj-$(CONFIG_MESON_SERIAL) += serial_meson.o
 obj-$(CONFIG_INTEL_MID_SERIAL) += serial_intel_mid.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_ROCKCHIP_SERIAL) += serial_rockchip.o
+obj-$(CONFIG_DESIGNWARE_SERIAL) += serial_dw_apb.o
 endif
 obj-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o
 obj-$(CONFIG_SANDBOX_SERIAL) += sandbox.o
drivers/serial/serial_dw_apb.c new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.17.1
#48 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

Hi Simon,

Quoted 95 lines

Add a driver for the "snps,dw-apb-uart" used in socfpga and others.

This driver is required to get OF_PLATDATA to work for socfpga. It uses the ns16550 driver, converting the platdata from of-platdata go the ns16550 format.

---

 drivers/serial/Kconfig         | 10 ++++++++
 drivers/serial/Makefile        |  1 +
 drivers/serial/serial_dw_apb.c | 42
++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+)
 create mode 100644 drivers/serial/serial_dw_apb.c
drivers/serial/Kconfig +0 -0
index b7ff2960ab..10addd3309 100644
@@ -511,6 +511,16 @@ config BCM283X_PL011_SERIAL
 	  that supports automatic disable, so that it only gets used

when the UART is actually muxed.

drivers/serial/Kconfig +5 -0
+config DESIGNWARE_SERIAL
+	bool "DesignWare UART support"
+	depends on DM_SERIAL && SPL_OF_PLATDATA
+	help
+	  Select this to enable a UART driver for "snps,dw-apb-uart"

devices

drivers/serial/Kconfig +1 -0
+	  when using CONFIG_SPL_OF_PLATDATA (i.e. a compiled-in

device tree

drivers/serial/Kconfig +2 -0
+	  replacement).
+	  This uses the ns16550 driver, converting the platdata from

of-platdata

drivers/serial/Kconfig +2 -0
+	  to the ns16550 format.
+
 config BCM6345_SERIAL
 	bool "Support for BCM6345 UART"
 	depends on DM_SERIAL
drivers/serial/Makefile +1 -0
index 06ee30697d..f1ebb90d92 100644
@@ -46,6 +46,7 @@ obj-$(CONFIG_MESON_SERIAL) += serial_meson.o
 obj-$(CONFIG_INTEL_MID_SERIAL) += serial_intel_mid.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_ROCKCHIP_SERIAL) += serial_rockchip.o
+obj-$(CONFIG_DESIGNWARE_SERIAL) += serial_dw_apb.o
 endif
 obj-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o
 obj-$(CONFIG_SANDBOX_SERIAL) += sandbox.o
(quoted diff) +0 -0

b/drivers/serial/serial_dw_apb.c new file mode 100644 index 0000000000..26580e5ba5

drivers/serial/serial_dw_apb.c new file +37 -0
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2018 Simon Goldschmidt
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dt-structs.h>
+#include <ns16550.h>
+#include <serial.h>
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+struct dw_apb_uart_platdata {
+	struct dtd_snps_dw_apb_uart dtplat;
+	struct ns16550_platdata plat;
+};
+
+static int dw_apb_serial_probe(struct udevice *dev)
+{
+	struct dw_apb_uart_platdata *plat = dev_get_platdata(dev);
+
+	/* Set up correct platform data for the standard driver */
+	plat->plat.base = plat->dtplat.reg[0];
+	plat->plat.reg_shift = plat->dtplat.reg_shift;
+	plat->plat.reg_width = plat->dtplat.reg_io_width;
+	plat->plat.clock = plat->dtplat.clock_frequency;
+	plat->plat.fcr = UART_FCR_DEFVAL;
+	dev->platdata = &plat->plat;
+
+	return ns16550_serial_probe(dev);
+}
+
+U_BOOT_DRIVER(snps_dw_apb_uart) = {
+	.name	= "snps_dw_apb_uart",
+	.id	= UCLASS_SERIAL,
+	.priv_auto_alloc_size = sizeof(struct NS16550),
+	.platdata_auto_alloc_size = sizeof(struct

dw_apb_uart_platdata),

drivers/serial/serial_dw_apb.c line 40

Quoted 3 lines
drivers/serial/serial_dw_apb.c new file +3 -0
+	.probe	= dw_apb_serial_probe,
+	.ops	= &ns16550_serial_ops,
+	.flags	= DM_FLAG_PRE_RELOC,

Is it possible/or is your application requiring the pinmux/clock setting for this serial?

With OF_PLATDATA we don't need to parse (and provide) the DTS (and we use the DM/DTS driver's code in a way similar to "native" one).

I'm wondering, if it would be possible to "mimic" the dependencies between DM drivers without DTS parsing / providing overhead.

At least in my case I would need in SPL:

-> driver XXX (working with u-boot proper's DM/DTS)

	---> CLK (uclass-clk) to enable clocks
	---> pinctrl (to config pins)

As an example: uart or eMMC.

I'm aware that it would be possible to use the old "approach" to configure pinmux and clk separately (as it is done now) and only re-use the DM portion of driver with OF_PLATDATA having all the necessary info.

However, I'm wondering if there is a better way to achieve it (or if I misunderstood something).

drivers/serial/serial_dw_apb.c

Quoted 2 lines
drivers/serial/serial_dw_apb.c new file +2 -0
+};
+#endif

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190107/120a02ab/attachment.sig>

#49 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

Quoted 96 lines · Lukasz Majewski

Hi Simon,

Quoted 93 lines

Add a driver for the "snps,dw-apb-uart" used in socfpga and others.

This driver is required to get OF_PLATDATA to work for socfpga. It uses the ns16550 driver, converting the platdata from of-platdata go the ns16550 format.

---

 drivers/serial/Kconfig         | 10 ++++++++
 drivers/serial/Makefile        |  1 +
 drivers/serial/serial_dw_apb.c | 42
++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+)
 create mode 100644 drivers/serial/serial_dw_apb.c
drivers/serial/Kconfig +0 -0
index b7ff2960ab..10addd3309 100644
@@ -511,6 +511,16 @@ config BCM283X_PL011_SERIAL
        that supports automatic disable, so that it only gets used

when the UART is actually muxed.

drivers/serial/Kconfig +5 -0
+config DESIGNWARE_SERIAL
+     bool "DesignWare UART support"
+     depends on DM_SERIAL && SPL_OF_PLATDATA
+     help
+       Select this to enable a UART driver for "snps,dw-apb-uart"

devices
+ when using CONFIG_SPL_OF_PLATDATA (i.e. a compiled-in
device tree

drivers/serial/Kconfig +2 -0
+       replacement).
+       This uses the ns16550 driver, converting the platdata from

of-platdata

drivers/serial/Kconfig +2 -0
+       to the ns16550 format.
+
 config BCM6345_SERIAL
      bool "Support for BCM6345 UART"
      depends on DM_SERIAL
drivers/serial/Makefile +1 -0
index 06ee30697d..f1ebb90d92 100644
@@ -46,6 +46,7 @@ obj-$(CONFIG_MESON_SERIAL) += serial_meson.o
 obj-$(CONFIG_INTEL_MID_SERIAL) += serial_intel_mid.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_ROCKCHIP_SERIAL) += serial_rockchip.o
+obj-$(CONFIG_DESIGNWARE_SERIAL) += serial_dw_apb.o
 endif
 obj-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o
 obj-$(CONFIG_SANDBOX_SERIAL) += sandbox.o
(quoted diff) +0 -0

b/drivers/serial/serial_dw_apb.c new file mode 100644 index 0000000000..26580e5ba5

drivers/serial/serial_dw_apb.c new file +36 -0
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2018 Simon Goldschmidt
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dt-structs.h>
+#include <ns16550.h>
+#include <serial.h>
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+struct dw_apb_uart_platdata {
+     struct dtd_snps_dw_apb_uart dtplat;
+     struct ns16550_platdata plat;
+};
+
+static int dw_apb_serial_probe(struct udevice *dev)
+{
+     struct dw_apb_uart_platdata *plat = dev_get_platdata(dev);
+
+     /* Set up correct platform data for the standard driver */
+     plat->plat.base = plat->dtplat.reg[0];
+     plat->plat.reg_shift = plat->dtplat.reg_shift;
+     plat->plat.reg_width = plat->dtplat.reg_io_width;
+     plat->plat.clock = plat->dtplat.clock_frequency;
+     plat->plat.fcr = UART_FCR_DEFVAL;
+     dev->platdata = &plat->plat;
+
+     return ns16550_serial_probe(dev);
+}
+
+U_BOOT_DRIVER(snps_dw_apb_uart) = {
+     .name   = "snps_dw_apb_uart",
+     .id     = UCLASS_SERIAL,
+     .priv_auto_alloc_size = sizeof(struct NS16550),
Quoted 8 lines

drivers/serial/serial_dw_apb.c line 40

Quoted 5 lines
drivers/serial/serial_dw_apb.c new file +1 -0
+     .platdata_auto_alloc_size = sizeof(struct

dw_apb_uart_platdata),

drivers/serial/serial_dw_apb.c new file +3 -0
+     .probe  = dw_apb_serial_probe,
+     .ops    = &ns16550_serial_ops,
+     .flags  = DM_FLAG_PRE_RELOC,

Is it possible/or is your application requiring the pinmux/clock setting for this serial?

No, the socfpga gen5 platform is somewhat of a real bad example regarding pinmux and clocks. These are implemented completely separate, based on files generated by the FPGA toolchain...

And as you can see above, the clock must be encoded into the DTS (and platdata) instead of calculating it via clock references.

This might be valid for socfpga only, and this driver migth be used on other boards as well. But I think it wouldn't hurt to start it like this and continue improving it once it is used on other platforms - it has to be actively enabled and is only used for SPL with OF_PLATDATA.

Quoted 5 lines

With OF_PLATDATA we don't need to parse (and provide) the DTS (and we use the DM/DTS driver's code in a way similar to "native" one).

I'm wondering, if it would be possible to "mimic" the dependencies between DM drivers without DTS parsing / providing overhead.

I'm actually working on something like that as I want to use QSPI with of- platdata and there I need the parent/child connection between the SPI master and the spi-flash...

Quoted 4 lines

At least in my case I would need in SPL:

-> driver XXX (working with u-boot proper's DM/DTS)

        ---> CLK (uclass-clk) to enable clocks

Clock binding might already work with dtoc, but I haven't tried.

Quoted 1 line
        ---> pinctrl (to config pins)

As I've written above, sadly socfpga does not use pinctrl.

Quoted 10 lines

As an example: uart or eMMC.

I'm aware that it would be possible to use the old "approach" to configure pinmux and clk separately (as it is done now) and only re-use the DM portion of driver with OF_PLATDATA having all the necessary info.

However, I'm wondering if there is a better way to achieve it (or if I misunderstood something).

There might be a better way, but porting socfpga to pinctrl seems nearly unpossible without further documentation from Intel. Using CLK might work but needs to be done...

In fact this UART is inspired by Simon's Rockchip UART for of-platdata, which behaves about the same but uses different compatible strings.

Regards,
Simon

Quoted 10 lines

drivers/serial/serial_dw_apb.c

Quoted 3 lines
drivers/serial/serial_dw_apb.c new file +2 -0
+};
+#endif

Best regards,

Lukasz Majewski

#50 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

Hi Simon,

Quoted 107 lines · Lukasz Majewski
Quoted 97 lines

Hi Simon,

Quoted 94 lines

Add a driver for the "snps,dw-apb-uart" used in socfpga and others.

This driver is required to get OF_PLATDATA to work for socfpga. It uses the ns16550 driver, converting the platdata from of-platdata go the ns16550 format.

---

 drivers/serial/Kconfig         | 10 ++++++++
 drivers/serial/Makefile        |  1 +
 drivers/serial/serial_dw_apb.c | 42

++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 drivers/serial/serial_dw_apb.c

drivers/serial/Kconfig +0 -0
index b7ff2960ab..10addd3309 100644
@@ -511,6 +511,16 @@ config BCM283X_PL011_SERIAL
        that supports automatic disable, so that it only gets used

when the UART is actually muxed.

drivers/serial/Kconfig +5 -0
+config DESIGNWARE_SERIAL
+     bool "DesignWare UART support"
+     depends on DM_SERIAL && SPL_OF_PLATDATA
+     help
+       Select this to enable a UART driver for "snps,dw-apb-uart"

devices
+ when using CONFIG_SPL_OF_PLATDATA (i.e. a compiled-in
device tree

drivers/serial/Kconfig +2 -0
+       replacement).
+       This uses the ns16550 driver, converting the platdata from

of-platdata

drivers/serial/Kconfig +2 -0
+       to the ns16550 format.
+
 config BCM6345_SERIAL
      bool "Support for BCM6345 UART"
      depends on DM_SERIAL
drivers/serial/Makefile +1 -0
index 06ee30697d..f1ebb90d92 100644
@@ -46,6 +46,7 @@ obj-$(CONFIG_MESON_SERIAL) += serial_meson.o
 obj-$(CONFIG_INTEL_MID_SERIAL) += serial_intel_mid.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_ROCKCHIP_SERIAL) += serial_rockchip.o
+obj-$(CONFIG_DESIGNWARE_SERIAL) += serial_dw_apb.o
 endif
 obj-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o
 obj-$(CONFIG_SANDBOX_SERIAL) += sandbox.o
(quoted diff) +0 -0

b/drivers/serial/serial_dw_apb.c new file mode 100644 index 0000000000..26580e5ba5

drivers/serial/serial_dw_apb.c new file +36 -0
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2018 Simon Goldschmidt
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dt-structs.h>
+#include <ns16550.h>
+#include <serial.h>
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+struct dw_apb_uart_platdata {
+     struct dtd_snps_dw_apb_uart dtplat;
+     struct ns16550_platdata plat;
+};
+
+static int dw_apb_serial_probe(struct udevice *dev)
+{
+     struct dw_apb_uart_platdata *plat = dev_get_platdata(dev);
+
+     /* Set up correct platform data for the standard driver */
+     plat->plat.base = plat->dtplat.reg[0];
+     plat->plat.reg_shift = plat->dtplat.reg_shift;
+     plat->plat.reg_width = plat->dtplat.reg_io_width;
+     plat->plat.clock = plat->dtplat.clock_frequency;
+     plat->plat.fcr = UART_FCR_DEFVAL;
+     dev->platdata = &plat->plat;
+
+     return ns16550_serial_probe(dev);
+}
+
+U_BOOT_DRIVER(snps_dw_apb_uart) = {
+     .name   = "snps_dw_apb_uart",
+     .id     = UCLASS_SERIAL,
+     .priv_auto_alloc_size = sizeof(struct NS16550),
Quoted 8 lines

drivers/serial/serial_dw_apb.c line 40

Quoted 5 lines
drivers/serial/serial_dw_apb.c new file +1 -0
+     .platdata_auto_alloc_size = sizeof(struct

dw_apb_uart_platdata),

drivers/serial/serial_dw_apb.c new file +3 -0
+     .probe  = dw_apb_serial_probe,
+     .ops    = &ns16550_serial_ops,
+     .flags  = DM_FLAG_PRE_RELOC,  

Is it possible/or is your application requiring the pinmux/clock setting for this serial?

Quoted 6 lines

No, the socfpga gen5 platform is somewhat of a real bad example regarding pinmux and clocks. These are implemented completely separate, based on files generated by the FPGA toolchain...

And as you can see above, the clock must be encoded into the DTS (and platdata) instead of calculating it via clock references.

Just to be clear here - the FPGA SDK (Quartus ?) generates clock info in different way than "normal" SoCs and it cannot use "clocks" and "clocks-names" properties to define needed clocks?

Quoted 3 lines

This might be valid for socfpga only, and this driver migth be used on other boards as well.

I think yes. IMHO the goal here is to reuse DM versions of drivers in the SPL (as non DM ones will be removed finally).

Quoted 8 lines

But I think it wouldn't hurt to start it
like this and continue improving it once it is used on other platforms - it has to be actively enabled and is only used for SPL with OF_PLATDATA.

Quoted 3 lines

With OF_PLATDATA we don't need to parse (and provide) the DTS (and we use the DM/DTS driver's code in a way similar to "native" one).

Quoted 6 lines
Quoted 2 lines

I'm wondering, if it would be possible to "mimic" the dependencies between DM drivers without DTS parsing / providing overhead.

I'm actually working on something like that as I want to use QSPI with of- platdata and there I need the parent/child connection between the SPI master and the spi-flash...

This is my point - the OF_PLATDATA allows using the DM ready driver as the standalone (no DTS parsing nor appending) entity in SPL.

The problem (at least for iMX6) is the dependency on pinmux (which properties by default are stripped from SPL's version of DTB).

I could hack it with having relevant pins defined as "hog" group, which would be configured when pinctrl driver is probed in SPL. However, this would prevent me from re-using kernel DTS out of the box.

Quoted 23 lines
Quoted 5 lines

At least in my case I would need in SPL:

-> driver XXX (working with u-boot proper's DM/DTS)

        ---> CLK (uclass-clk) to enable clocks  

Clock binding might already work with dtoc, but I haven't tried.

Quoted 1 line
        ---> pinctrl (to config pins)  

As I've written above, sadly socfpga does not use pinctrl.

Quoted 10 lines

As an example: uart or eMMC.

I'm aware that it would be possible to use the old "approach" to configure pinmux and clk separately (as it is done now) and only re-use the DM portion of driver with OF_PLATDATA having all the necessary info.

However, I'm wondering if there is a better way to achieve it (or if I misunderstood something).

Quoted 7 lines

There might be a better way, but porting socfpga to pinctrl seems nearly unpossible without further documentation from Intel. Using CLK might work but needs to be done...

In fact this UART is inspired by Simon's Rockchip UART for of-platdata, which behaves about the same but uses different compatible strings.

Thanks for the info. I will look into that.

Quoted 14 lines

Regards,
Simon

Quoted 10 lines

drivers/serial/serial_dw_apb.c

Quoted 3 lines
drivers/serial/serial_dw_apb.c new file +2 -0
+};
+#endif  

Best regards,

Lukasz Majewski

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190108/54451572/attachment.sig>

#51 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

Quoted 114 lines · Lukasz Majewski

Hi Simon,

Quoted 111 lines · Lukasz Majewski
Quoted 97 lines

Hi Simon,

Quoted 94 lines

Add a driver for the "snps,dw-apb-uart" used in socfpga and others.

This driver is required to get OF_PLATDATA to work for socfpga. It uses the ns16550 driver, converting the platdata from of-platdata go the ns16550 format.

---

 drivers/serial/Kconfig         | 10 ++++++++
 drivers/serial/Makefile        |  1 +
 drivers/serial/serial_dw_apb.c | 42

++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 drivers/serial/serial_dw_apb.c

drivers/serial/Kconfig +0 -0
index b7ff2960ab..10addd3309 100644
@@ -511,6 +511,16 @@ config BCM283X_PL011_SERIAL
        that supports automatic disable, so that it only gets used

when the UART is actually muxed.

drivers/serial/Kconfig +5 -0
+config DESIGNWARE_SERIAL
+     bool "DesignWare UART support"
+     depends on DM_SERIAL && SPL_OF_PLATDATA
+     help
+       Select this to enable a UART driver for "snps,dw-apb-uart"

devices
+ when using CONFIG_SPL_OF_PLATDATA (i.e. a compiled-in
device tree

drivers/serial/Kconfig +2 -0
+       replacement).
+       This uses the ns16550 driver, converting the platdata from

of-platdata

drivers/serial/Kconfig +2 -0
+       to the ns16550 format.
+
 config BCM6345_SERIAL
      bool "Support for BCM6345 UART"
      depends on DM_SERIAL
drivers/serial/Makefile +1 -0
index 06ee30697d..f1ebb90d92 100644
@@ -46,6 +46,7 @@ obj-$(CONFIG_MESON_SERIAL) += serial_meson.o
 obj-$(CONFIG_INTEL_MID_SERIAL) += serial_intel_mid.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_ROCKCHIP_SERIAL) += serial_rockchip.o
+obj-$(CONFIG_DESIGNWARE_SERIAL) += serial_dw_apb.o
 endif
 obj-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o
 obj-$(CONFIG_SANDBOX_SERIAL) += sandbox.o
(quoted diff) +0 -0

b/drivers/serial/serial_dw_apb.c new file mode 100644 index 0000000000..26580e5ba5

drivers/serial/serial_dw_apb.c new file +36 -0
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2018 Simon Goldschmidt
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dt-structs.h>
+#include <ns16550.h>
+#include <serial.h>
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+struct dw_apb_uart_platdata {
+     struct dtd_snps_dw_apb_uart dtplat;
+     struct ns16550_platdata plat;
+};
+
+static int dw_apb_serial_probe(struct udevice *dev)
+{
+     struct dw_apb_uart_platdata *plat = dev_get_platdata(dev);
+
+     /* Set up correct platform data for the standard driver */
+     plat->plat.base = plat->dtplat.reg[0];
+     plat->plat.reg_shift = plat->dtplat.reg_shift;
+     plat->plat.reg_width = plat->dtplat.reg_io_width;
+     plat->plat.clock = plat->dtplat.clock_frequency;
+     plat->plat.fcr = UART_FCR_DEFVAL;
+     dev->platdata = &plat->plat;
+
+     return ns16550_serial_probe(dev);
+}
+
+U_BOOT_DRIVER(snps_dw_apb_uart) = {
+     .name   = "snps_dw_apb_uart",
+     .id     = UCLASS_SERIAL,
+     .priv_auto_alloc_size = sizeof(struct NS16550),
Quoted 8 lines

drivers/serial/serial_dw_apb.c line 40

Quoted 5 lines
drivers/serial/serial_dw_apb.c new file +1 -0
+     .platdata_auto_alloc_size = sizeof(struct

dw_apb_uart_platdata),

drivers/serial/serial_dw_apb.c new file +3 -0
+     .probe  = dw_apb_serial_probe,
+     .ops    = &ns16550_serial_ops,
+     .flags  = DM_FLAG_PRE_RELOC,

Is it possible/or is your application requiring the pinmux/clock setting for this serial?

No, the socfpga gen5 platform is somewhat of a real bad example regarding pinmux and clocks. These are implemented completely separate, based on files generated by the FPGA toolchain...

Quoted 6 lines
Quoted 2 lines

And as you can see above, the clock must be encoded into the DTS (and platdata) instead of calculating it via clock references.

Just to be clear here - the FPGA SDK (Quartus ?) generates clock info in different way than "normal" SoCs and it cannot use "clocks" and "clocks-names" properties to define needed clocks?

I'm afraid I don't know what the "normal" SoC way is in Linux. Coming from smaller embedded systems like STM32, what Quartus generates here is not uncommon :-)

The DTS for socfpga has clock references but at least for the gen5 devices, these are not used.

Anyway, how do "normal" SoCs select the target speed of IP cores? The DTS only describes what can be done. I.e. how do I tell U-Boot that I want the CPU at say, 400 MHz, not 800 MHz? (This question of course applies to peripherals as well).

Quoted 6 lines
Quoted 3 lines

This might be valid for socfpga only, and this driver migth be used on other boards as well.

I think yes. IMHO the goal here is to reuse DM versions of drivers in the SPL (as non DM ones will be removed finally).

Well, this *is* a DM serial driver. It is just lacking clock and pinctrl references
for some platforms...

Quoted 16 lines
Quoted 9 lines

But I think it wouldn't hurt to start it
like this and continue improving it once it is used on other platforms - it has to be actively enabled and is only used for SPL with OF_PLATDATA.

Quoted 3 lines

With OF_PLATDATA we don't need to parse (and provide) the DTS (and we use the DM/DTS driver's code in a way similar to "native" one).

Quoted 6 lines
Quoted 2 lines

I'm wondering, if it would be possible to "mimic" the dependencies between DM drivers without DTS parsing / providing overhead.

I'm actually working on something like that as I want to use QSPI with of- platdata and there I need the parent/child connection between the SPI master and the spi-flash...

Quoted 5 lines

This is my point - the OF_PLATDATA allows using the DM ready driver as the standalone (no DTS parsing nor appending) entity in SPL.

The problem (at least for iMX6) is the dependency on pinmux (which properties by default are stripped from SPL's version of DTB).

You need to stop it stripping that, of course ;-)

I'd like that for socfpga as well. Unfortunately, there is no documentation of the pinmux configuration for these Intel FPGAs and Quartus only generates 4 big u32 arrays :-(

Quoted 32 lines

I could hack it with having relevant pins defined as "hog" group, which would be configured when pinctrl driver is probed in SPL. However, this would prevent me from re-using kernel DTS out of the box.

Quoted 27 lines
Quoted 5 lines

At least in my case I would need in SPL:

-> driver XXX (working with u-boot proper's DM/DTS)

        ---> CLK (uclass-clk) to enable clocks

Clock binding might already work with dtoc, but I haven't tried.

Quoted 1 line
        ---> pinctrl (to config pins)

As I've written above, sadly socfpga does not use pinctrl.

Quoted 10 lines

As an example: uart or eMMC.

I'm aware that it would be possible to use the old "approach" to configure pinmux and clk separately (as it is done now) and only re-use the DM portion of driver with OF_PLATDATA having all the necessary info.

However, I'm wondering if there is a better way to achieve it (or if I misunderstood something).

There might be a better way, but porting socfpga to pinctrl seems nearly unpossible without further documentation from Intel. Using CLK might work but needs to be done...

Quoted 5 lines
Quoted 3 lines

In fact this UART is inspired by Simon's Rockchip UART for of-platdata, which behaves about the same but uses different compatible strings.

Thanks for the info. I will look into that.

It's actually pretty much the same like this, only the names change. That might be worth combining, but the device/driver binding code would need to allow checking for multiple compatible strings.

Regards,
Simon

#52 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

Hi Simon,

Quoted 121 lines · Lukasz Majewski
Quoted 120 lines

Hi Simon,

Quoted 116 lines
Quoted 99 lines · Lukasz Majewski

Hi Simon,

Quoted 96 lines

Add a driver for the "snps,dw-apb-uart" used in socfpga and others.

This driver is required to get OF_PLATDATA to work for socfpga. It uses the ns16550 driver, converting the platdata from of-platdata go the ns16550 format.

Signed-off-by: Simon Goldschmidt
<[email protected]> ---

 drivers/serial/Kconfig         | 10 ++++++++
 drivers/serial/Makefile        |  1 +
 drivers/serial/serial_dw_apb.c | 42

++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 drivers/serial/serial_dw_apb.c

drivers/serial/Kconfig +0 -0
index b7ff2960ab..10addd3309 100644
@@ -511,6 +511,16 @@ config BCM283X_PL011_SERIAL
        that supports automatic disable, so that it only gets

used when the UART is actually muxed.

drivers/serial/Kconfig +5 -0
+config DESIGNWARE_SERIAL
+     bool "DesignWare UART support"
+     depends on DM_SERIAL && SPL_OF_PLATDATA
+     help
+       Select this to enable a UART driver for

"snps,dw-apb-uart" devices
+ when using CONFIG_SPL_OF_PLATDATA (i.e. a compiled-in
device tree

drivers/serial/Kconfig +2 -0
+       replacement).
+       This uses the ns16550 driver, converting the platdata

from of-platdata

drivers/serial/Kconfig +2 -0
+       to the ns16550 format.
+
 config BCM6345_SERIAL
      bool "Support for BCM6345 UART"
      depends on DM_SERIAL
drivers/serial/Makefile +1 -0
index 06ee30697d..f1ebb90d92 100644
@@ -46,6 +46,7 @@ obj-$(CONFIG_MESON_SERIAL) += serial_meson.o
 obj-$(CONFIG_INTEL_MID_SERIAL) += serial_intel_mid.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_ROCKCHIP_SERIAL) += serial_rockchip.o
+obj-$(CONFIG_DESIGNWARE_SERIAL) += serial_dw_apb.o
 endif
 obj-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o
 obj-$(CONFIG_SANDBOX_SERIAL) += sandbox.o
(quoted diff) +0 -0

b/drivers/serial/serial_dw_apb.c new file mode 100644 index 0000000000..26580e5ba5

drivers/serial/serial_dw_apb.c new file +20 -0
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2018 Simon Goldschmidt
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dt-structs.h>
+#include <ns16550.h>
+#include <serial.h>
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+struct dw_apb_uart_platdata {
+     struct dtd_snps_dw_apb_uart dtplat;
+     struct ns16550_platdata plat;
+};
+
+static int dw_apb_serial_probe(struct udevice *dev)
+{
+     struct dw_apb_uart_platdata *plat =

dev_get_platdata(dev); +
+ /* Set up correct platform data for the standard driver
*/

drivers/serial/serial_dw_apb.c new file +14 -0
+     plat->plat.base = plat->dtplat.reg[0];
+     plat->plat.reg_shift = plat->dtplat.reg_shift;
+     plat->plat.reg_width = plat->dtplat.reg_io_width;
+     plat->plat.clock = plat->dtplat.clock_frequency;
+     plat->plat.fcr = UART_FCR_DEFVAL;
+     dev->platdata = &plat->plat;
+
+     return ns16550_serial_probe(dev);
+}
+
+U_BOOT_DRIVER(snps_dw_apb_uart) = {
+     .name   = "snps_dw_apb_uart",
+     .id     = UCLASS_SERIAL,
+     .priv_auto_alloc_size = sizeof(struct NS16550),
Quoted 8 lines

drivers/serial/serial_dw_apb.c line 40

Quoted 5 lines

+ .platdata_auto_alloc_size = sizeof(struct
dw_apb_uart_platdata),

drivers/serial/serial_dw_apb.c new file +3 -0
+     .probe  = dw_apb_serial_probe,
+     .ops    = &ns16550_serial_ops,
+     .flags  = DM_FLAG_PRE_RELOC,  

Is it possible/or is your application requiring the pinmux/clock setting for this serial?

No, the socfpga gen5 platform is somewhat of a real bad example regarding pinmux and clocks. These are implemented completely separate, based on files generated by the FPGA toolchain...

And as you can see above, the clock must be encoded into the DTS (and platdata) instead of calculating it via clock references.

Quoted 7 lines
Quoted 3 lines

Just to be clear here - the FPGA SDK (Quartus ?) generates clock info in different way than "normal" SoCs and it cannot use "clocks" and "clocks-names" properties to define needed clocks?

I'm afraid I don't know what the "normal" SoC way is in Linux. Coming from smaller embedded systems like STM32, what Quartus generates here is not uncommon :-)

Only Intel (ALtera) knows what Quartus generates (to some extend :-) ).

Quoted 3 lines

The DTS for socfpga has clock references but at least for the gen5 devices, these are not used.

Ok. I see.

Quoted 5 lines

Anyway, how do "normal" SoCs select the target speed of IP cores? The DTS only describes what can be done. I.e. how do I tell U-Boot that I want the CPU at say, 400 MHz, not 800 MHz? (This question of course applies to peripherals as well).

In case of IMX6 there is a set of "clock" functions in mach-imx/mx6/clock.c

Those functions are called by board code/drivers.

In Linux the CLK hierarchy is modelled in a more verbose way and describes all the needed MUXes, PLLs, Gates, etc. However, IMHO we don't need such verbose description in U-boot as at most we need to increase the ROM default clock and enable it (to improve boot time).

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines

This might be valid for socfpga only, and this driver migth be used on other boards as well.

I think yes. IMHO the goal here is to reuse DM versions of drivers in the SPL (as non DM ones will be removed finally).

Well, this *is* a DM serial driver.

Yes. That was my point to reuse this DM code in SPL.

Quoted 3 lines

It is just lacking clock and
pinctrl references
for some platforms...

And this is problematic to have full DM reuse in SPL with reasonable size.

In one of IMX6Q boards the SPL grown from 35 KiB to 51 KiB when the DM/DTS conversion has been done (without OF_PLATDATA, tiny printf/malloc).

Quoted 19 lines
Quoted 19 lines
Quoted 18 lines

But I think it wouldn't hurt to start it
like this and continue improving it once it is used on other platforms - it has to be actively enabled and is only used for SPL with OF_PLATDATA.

Quoted 7 lines

With OF_PLATDATA we don't need to parse (and provide) the DTS (and we use the DM/DTS driver's code in a way similar to "native" one).

I'm wondering, if it would be possible to "mimic" the dependencies between DM drivers without DTS parsing / providing overhead.

I'm actually working on something like that as I want to use QSPI with of- platdata and there I need the parent/child connection between the SPI master and the spi-flash...

Quoted 7 lines
Quoted 5 lines

This is my point - the OF_PLATDATA allows using the DM ready driver as the standalone (no DTS parsing nor appending) entity in SPL.

The problem (at least for iMX6) is the dependency on pinmux (which properties by default are stripped from SPL's version of DTB).

You need to stop it stripping that, of course ;-)

Yes :-).

Quoted 4 lines

I'd like that for socfpga as well. Unfortunately, there is no documentation of the pinmux configuration for these Intel FPGAs and Quartus only generates 4 big u32 arrays :-(

Binary blob is the best way to configure things :-) -> Then just use single "for" and everything just works :-).

Quoted 37 lines
Quoted 37 lines

I could hack it with having relevant pins defined as "hog" group, which would be configured when pinctrl driver is probed in SPL. However, this would prevent me from re-using kernel DTS out of the box.

Quoted 30 lines
Quoted 5 lines

At least in my case I would need in SPL:

-> driver XXX (working with u-boot proper's DM/DTS)

        ---> CLK (uclass-clk) to enable clocks  

Clock binding might already work with dtoc, but I haven't tried.

Quoted 1 line
        ---> pinctrl (to config pins)  

As I've written above, sadly socfpga does not use pinctrl.

Quoted 10 lines

As an example: uart or eMMC.

I'm aware that it would be possible to use the old "approach" to configure pinmux and clk separately (as it is done now) and only re-use the DM portion of driver with OF_PLATDATA having all the necessary info.

However, I'm wondering if there is a better way to achieve it (or if I misunderstood something).

There might be a better way, but porting socfpga to pinctrl seems nearly unpossible without further documentation from Intel. Using CLK might work but needs to be done...

In fact this UART is inspired by Simon's Rockchip UART for of-platdata, which behaves about the same but uses different compatible strings.

Quoted 5 lines
Quoted 1 line

Thanks for the info. I will look into that.

It's actually pretty much the same like this, only the names change. That might be worth combining, but the device/driver binding code would need to allow checking for multiple compatible strings.

Ok. I see.

Quoted 3 lines

Regards,
Simon

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190108/4a29706f/attachment.sig>

#53 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

In reply to Simon Goldschmidt

Hi Simon,

Quoted 32 lines

-----Original Message-----
From: Simon Goldschmidt [mailto:simon.k.r.goldschmidt at gmail.com]
Sent: Tuesday, January 8, 2019 12:14 AM
To: Marek Vasut <[email protected]>
Cc: Simon Goldschmidt <[email protected]>; Patrice Chotard <[email protected]>; Simon Glass <[email protected]>; Anup Patel <[email protected]>; Lokesh Vutla <[email protected]>; Alexey Brodkin <[email protected]>; Patrick Delaunay <[email protected]>; Marek Vasut <[email protected]>; u-boot at lists.denx.de; Álvaro Fernández Rojas <[email protected]>; Ryder Lee <[email protected]>; Vikas Manocha <[email protected]>; Alexander Graf <[email protected]>; Weijie Gao <[email protected]>
Subject: [PATCH v1 3/4] serial: add an of-platdata driver for "snps,dw-apb-uart"

Add a driver for the "snps,dw-apb-uart" used in socfpga and others.

This driver is required to get OF_PLATDATA to work for socfpga. It uses the ns16550 driver, converting the platdata from of-platdata go the ns16550 format.

---

 drivers/serial/Kconfig         | 10 ++++++++
 drivers/serial/Makefile        |  1 +
 drivers/serial/serial_dw_apb.c | 42 ++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 drivers/serial/serial_dw_apb.c
drivers/serial/Kconfig +0 -0
index b7ff2960ab..10addd3309 100644

drivers/serial/Kconfig config BCM283X_PL011_SERIAL · line 516

Quoted 6 lines
drivers/serial/Kconfig +3 -0
@@ -511,6 +511,16 @@ config BCM283X_PL011_SERIAL
 	  that supports automatic disable, so that it only gets used when
 	  the UART is actually muxed.
 
+config DESIGNWARE_SERIAL
+	bool "DesignWare UART support"
+	depends on DM_SERIAL && SPL_OF_PLATDATA

Might be a bit naïve question but why depend on SPL_OF_PLATDATA only? What about CONFIG_OF_EMBED?

I'd happily switch my ARC boards on this driver and get rid of all CONFIG_SYS_NS16550_xxx nonsense in include/configs/myboardname.h

-Alexey

#54 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

Hi Alexey,

Quoted 38 lines · Alexey Brodkin

Hi Simon,

Quoted 35 lines

-----Original Message-----
From: Simon Goldschmidt [mailto:simon.k.r.goldschmidt at gmail.com]
Sent: Tuesday, January 8, 2019 12:14 AM
To: Marek Vasut <[email protected]>
Cc: Simon Goldschmidt <[email protected]>; Patrice Chotard <[email protected]>; Simon Glass <[email protected]>; Anup Patel <[email protected]>; Lokesh Vutla <[email protected]>; Alexey Brodkin <[email protected]>; Patrick Delaunay <[email protected]>; Marek Vasut <[email protected]>; u-boot at lists.denx.de; Álvaro Fernández Rojas <[email protected]>; Ryder Lee <[email protected]>; Vikas Manocha <[email protected]>; Alexander Graf <[email protected]>; Weijie Gao <[email protected]>
Subject: [PATCH v1 3/4] serial: add an of-platdata driver for "snps,dw-apb-uart"

Add a driver for the "snps,dw-apb-uart" used in socfpga and others.

This driver is required to get OF_PLATDATA to work for socfpga. It uses the ns16550 driver, converting the platdata from of-platdata go the ns16550 format.

---

 drivers/serial/Kconfig         | 10 ++++++++
 drivers/serial/Makefile        |  1 +
 drivers/serial/serial_dw_apb.c | 42 ++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 drivers/serial/serial_dw_apb.c
drivers/serial/Kconfig +0 -0
index b7ff2960ab..10addd3309 100644
@@ -511,6 +511,16 @@ config BCM283X_PL011_SERIAL
        that supports automatic disable, so that it only gets used when
        the UART is actually muxed.
 
Quoted 5 lines

drivers/serial/Kconfig config BCM283X_PL011_SERIAL · line 516

Quoted 3 lines
drivers/serial/Kconfig +3 -0
+config DESIGNWARE_SERIAL
+     bool "DesignWare UART support"
+     depends on DM_SERIAL && SPL_OF_PLATDATA

Might be a bit naïve question but why depend on SPL_OF_PLATDATA only?

Because my focus has been to get OF_PLATDATA running on my socfpga board. But since Marek seems to be opposed, I guess I'll drop this series and try to find
a different way to squeeze out the bytes I need.

Quoted 4 lines

What about CONFIG_OF_EMBED?

I'd happily switch my ARC boards on this driver and get rid of all CONFIG_SYS_NS16550_xxx nonsense in include/configs/myboardname.h

You're right there, this would be a good idea for socfpga as well. Maybe I'll continue that line some day, but I don't have immediate plans for this.

Regards,
Simon

#55 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

In reply to Alexey Brodkin

Hi Alexey,

Am 09.01.2019 um 09:35 schrieb Alexey Brodkin:

Quoted 44 lines

Hi Simon,

Quoted 32 lines

-----Original Message-----
From: Simon Goldschmidt [mailto:simon.k.r.goldschmidt at gmail.com]
Sent: Tuesday, January 8, 2019 12:14 AM
To: Marek Vasut <[email protected]>
Cc: Simon Goldschmidt <[email protected]>; Patrice Chotard <[email protected]>; Simon Glass <[email protected]>; Anup Patel <[email protected]>; Lokesh Vutla <[email protected]>; Alexey Brodkin <[email protected]>; Patrick Delaunay <[email protected]>; Marek Vasut <[email protected]>; u-boot at lists.denx.de; Álvaro Fernández Rojas <[email protected]>; Ryder Lee <[email protected]>; Vikas Manocha <[email protected]>; Alexander Graf <[email protected]>; Weijie Gao <[email protected]>
Subject: [PATCH v1 3/4] serial: add an of-platdata driver for "snps,dw-apb-uart"

Add a driver for the "snps,dw-apb-uart" used in socfpga and others.

This driver is required to get OF_PLATDATA to work for socfpga. It uses the ns16550 driver, converting the platdata from of-platdata go the ns16550 format.

---

  drivers/serial/Kconfig         | 10 ++++++++
  drivers/serial/Makefile        |  1 +
  drivers/serial/serial_dw_apb.c | 42 ++++++++++++++++++++++++++++++++++
  3 files changed, 53 insertions(+)

create mode 100644 drivers/serial/serial_dw_apb.c

drivers/serial/Kconfig +0 -0
index b7ff2960ab..10addd3309 100644

drivers/serial/Kconfig config BCM283X_PL011_SERIAL · line 516

Quoted 6 lines
drivers/serial/Kconfig +3 -0
@@ -511,6 +511,16 @@ config BCM283X_PL011_SERIAL
  	  that supports automatic disable, so that it only gets used when
  	  the UART is actually muxed.
 
+config DESIGNWARE_SERIAL
+	bool "DesignWare UART support"
+	depends on DM_SERIAL && SPL_OF_PLATDATA

Might be a bit naïve question but why depend on SPL_OF_PLATDATA only? What about CONFIG_OF_EMBED?

Quoted 2 lines

I'd happily switch my ARC boards on this driver and get rid of all CONFIG_SYS_NS16550_xxx nonsense in include/configs/myboardname.h

I checked include/configs/socfpga_common.h again and by its using Kconfig and DM_SERIAL, there are no CONFIG_SYS_NS16550_xxx defines left (other than CONFIG_SYS_NS16550_SERIAL, which I will remove).

So it seems it's not a matter of a new driver but a matter of cleaning up the boards to use DM_SERIAL, I guess?

Regards,
Simon

#56 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

Hi Simon,

[snip]

Quoted 6 lines
Quoted 6 lines

drivers/serial/Kconfig config BCM283X_PL011_SERIAL · line 516

Quoted 3 lines
drivers/serial/Kconfig +3 -0
+config DESIGNWARE_SERIAL
+	bool "DesignWare UART support"
+	depends on DM_SERIAL && SPL_OF_PLATDATA

Might be a bit naïve question but why depend on SPL_OF_PLATDATA only? What about CONFIG_OF_EMBED?

Ok I completely forgot that standard ns16550 driver already covers DW APB UART, see https://elixir.bootlin.com/u-boot/latest/source/drivers/serial/ns16550.c#L456

Quoted 6 lines
Quoted 2 lines

I'd happily switch my ARC boards on this driver and get rid of all CONFIG_SYS_NS16550_xxx nonsense in include/configs/myboardname.h

I checked include/configs/socfpga_common.h again and by its using Kconfig and DM_SERIAL, there are no CONFIG_SYS_NS16550_xxx defines left (other than CONFIG_SYS_NS16550_SERIAL, which I will remove).

So it's not that easy apparently :)
At least CONFIG_SYS_NS16550_MEM32 is still used really required for getting correct accessor used, see implementation of serial_{in|out}_shift() in drivers/serial/ns16550.c.

If CONFIG_SYS_NS16550_MEM32 is not set then simple readb() is used so that 8-bit data offset in 32-bit word is lost and we're dead in the water.

That said accessors in ns16550 are begging for significant rework to make the driver completely OF-driven.

-Alexey

#57 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

Quoted 22 lines · Alexey Brodkin

Hi Simon,

[snip]

Quoted 6 lines
Quoted 6 lines

drivers/serial/Kconfig config BCM283X_PL011_SERIAL · line 516

Quoted 3 lines
drivers/serial/Kconfig +3 -0
+config DESIGNWARE_SERIAL
+  bool "DesignWare UART support"
+  depends on DM_SERIAL && SPL_OF_PLATDATA

Might be a bit naïve question but why depend on SPL_OF_PLATDATA only? What about CONFIG_OF_EMBED?

Ok I completely forgot that standard ns16550 driver already covers DW APB UART, see https://elixir.bootlin.com/u-boot/latest/source/drivers/serial/ns16550.c#L456

Quoted 6 lines
Quoted 2 lines

I'd happily switch my ARC boards on this driver and get rid of all CONFIG_SYS_NS16550_xxx nonsense in include/configs/myboardname.h

I checked include/configs/socfpga_common.h again and by its using Kconfig and DM_SERIAL, there are no CONFIG_SYS_NS16550_xxx defines left (other than CONFIG_SYS_NS16550_SERIAL, which I will remove).

Quoted 7 lines

So it's not that easy apparently :)
At least CONFIG_SYS_NS16550_MEM32 is still used really required for getting correct accessor used, see implementation of serial_{in|out}_shift() in drivers/serial/ns16550.c.

If CONFIG_SYS_NS16550_MEM32 is not set then simple readb() is used so that 8-bit data offset in 32-bit word is lost and we're dead in the water.

Isn't that covered by 'plat->reg_shift' which is read from dts property "reg-shift = <2>"?

Remember that CONFIG_SYS_NS16550_REG_SIZE is not used/required for 32-bit socfpga as well!

Quoted 2 lines

That said accessors in ns16550 are begging for significant rework to make the driver completely OF-driven.

I think much of the code in ns16550.c could be removed if non-DM support was dropped. That might clean things up as well.

Regards,
Simon

#58 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

Hi Simon,

Quoted 43 lines

-----Original Message-----
From: Simon Goldschmidt [mailto:simon.k.r.goldschmidt at gmail.com]
Sent: Friday, January 11, 2019 11:41 AM
To: Alexey Brodkin <[email protected]>
Cc: Patrice Chotard <[email protected]>; Simon Glass <[email protected]>; Anup Patel <[email protected]>; Lokesh Vutla <[email protected]>; Patrick Delaunay <[email protected]>; Marek Vasut <[email protected]>; u-boot at lists.denx.de; Álvaro Fernández Rojas <[email protected]>; Ryder Lee <[email protected]>; Vikas Manocha <[email protected]>; Alexander Graf <[email protected]>; Weijie Gao <[email protected]>; Marek Vasut <[email protected]>
Subject: Re: [PATCH v1 3/4] serial: add an of-platdata driver for "snps,dw-apb-uart"

Quoted 9 lines · Alexey Brodkin

Hi Simon,

[snip]

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
drivers/serial/Kconfig +3 -0
+config DESIGNWARE_SERIAL
+  bool "DesignWare UART support"
+  depends on DM_SERIAL && SPL_OF_PLATDATA
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Might be a bit naïve question but why depend on SPL_OF_PLATDATA only? What about CONFIG_OF_EMBED?

Ok I completely forgot that standard ns16550 driver already covers DW APB UART, see https://urldefense.proofpoint.com/v2/url?u=https-3A__elixir.bootlin.com_u-

2Dboot_latest_source_drivers_serial_ns16550.c- 23L456&d=DwIFaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=lqdeeSSEes0GFDDl656eViXO7breS55ytWkhpk5R81I&m=wyhoU5_3rGv5y 373_cpetmUHK9_ALMCC29QnKS2As5k&s=uMDuaOZ__YoyqakveKqByAtb1lfRQBYktcVgGH3oawE&e=

Quoted 13 lines
Quoted 7 lines
Quoted 3 lines

I'd happily switch my ARC boards on this driver and get rid of all CONFIG_SYS_NS16550_xxx nonsense in include/configs/myboardname.h

I checked include/configs/socfpga_common.h again and by its using Kconfig and DM_SERIAL, there are no CONFIG_SYS_NS16550_xxx defines left (other than CONFIG_SYS_NS16550_SERIAL, which I will remove).

So it's not that easy apparently :)
At least CONFIG_SYS_NS16550_MEM32 is still used really required for getting correct accessor used, see implementation of serial_{in|out}_shift() in drivers/serial/ns16550.c.

Quoted 5 lines
Quoted 2 lines

If CONFIG_SYS_NS16550_MEM32 is not set then simple readb() is used so that 8-bit data offset in 32-bit word is lost and we're dead in the water.

Isn't that covered by 'plat->reg_shift' which is read from dts property "reg-shift = <2>"?

Well actually CONFIG_SYS_NS16550_MEM32 is an alias to "reg-io-width = <4>"
which selects exactly accessor (right as CONFIG_SYS_NS16550_MEM32 in serial_{in|out}_shift()). But even though we do read "reg-io-width"
from .dtb it is not used in the driver. It was added by Andy Shevchenko
recently, see http://git.denx.de/?p=u-boot.git;a=commit;h=4e7207791c05b3ecff916c1b1b1b21401ec29b0b

BTW as I may see some SoCFPGA configs do mention this define:
---------------------------------->8----------------------------- # git grep CONFIG_SYS_NS16550_MEM32 | grep socfpga include/configs/socfpga_arria10_socdk.h:33:#define CONFIG_SYS_NS16550_MEM32 include/configs/socfpga_stratix10_socdk.h:146:#define CONFIG_SYS_NS16550_MEM32 ---------------------------------->8-----------------------------

as well as this DT property:
---------------------------------->8-----------------------------

# git grep reg-io-width | grep socfpga
arch/arm/dts/socfpga.dtsi:877:                  reg-io-width = <4>;
arch/arm/dts/socfpga.dtsi:889:                  reg-io-width = <4>;
arch/arm/dts/socfpga_arria10.dtsi:829:                  reg-io-width = <4>;
arch/arm/dts/socfpga_arria10.dtsi:840:                  reg-io-width = <4>;
arch/arm/dts/socfpga_stratix10.dtsi:252:                        reg-io-width = <4>;
arch/arm/dts/socfpga_stratix10.dtsi:265:                        reg-io-width = <4>;
arch/arm/dts/socfpga_stratix10.dtsi:314:                        reg-io-width = <4>;
arch/arm/dts/socfpga_stratix10.dtsi:326:                        reg-io-width = <4>;
---------------------------------->8-----------------------------

So I guess you may experiment with it a bit.

-Alexey

#59 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

Quoted 58 lines · Alexey Brodkin

Hi Simon,

Quoted 43 lines

-----Original Message-----
From: Simon Goldschmidt [mailto:simon.k.r.goldschmidt at gmail.com]
Sent: Friday, January 11, 2019 11:41 AM
To: Alexey Brodkin <[email protected]>
Cc: Patrice Chotard <[email protected]>; Simon Glass <[email protected]>; Anup Patel <[email protected]>; Lokesh Vutla <[email protected]>; Patrick Delaunay <[email protected]>; Marek Vasut <[email protected]>; u-boot at lists.denx.de; Álvaro Fernández Rojas <[email protected]>; Ryder Lee <[email protected]>; Vikas Manocha <[email protected]>; Alexander Graf <[email protected]>; Weijie Gao <[email protected]>; Marek Vasut <[email protected]>
Subject: Re: [PATCH v1 3/4] serial: add an of-platdata driver for "snps,dw-apb-uart"

Quoted 9 lines · Alexey Brodkin

Hi Simon,

[snip]

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
drivers/serial/Kconfig +3 -0
+config DESIGNWARE_SERIAL
+  bool "DesignWare UART support"
+  depends on DM_SERIAL && SPL_OF_PLATDATA
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Might be a bit naïve question but why depend on SPL_OF_PLATDATA only? What about CONFIG_OF_EMBED?

Ok I completely forgot that standard ns16550 driver already covers DW APB UART, see https://urldefense.proofpoint.com/v2/url?u=https-3A__elixir.bootlin.com_u-

2Dboot_latest_source_drivers_serial_ns16550.c- 23L456&d=DwIFaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=lqdeeSSEes0GFDDl656eViXO7breS55ytWkhpk5R81I&m=wyhoU5_3rGv5y 373_cpetmUHK9_ALMCC29QnKS2As5k&s=uMDuaOZ__YoyqakveKqByAtb1lfRQBYktcVgGH3oawE&e=

Quoted 13 lines
Quoted 7 lines
Quoted 3 lines

I'd happily switch my ARC boards on this driver and get rid of all CONFIG_SYS_NS16550_xxx nonsense in include/configs/myboardname.h

I checked include/configs/socfpga_common.h again and by its using Kconfig and DM_SERIAL, there are no CONFIG_SYS_NS16550_xxx defines left (other than CONFIG_SYS_NS16550_SERIAL, which I will remove).

So it's not that easy apparently :)
At least CONFIG_SYS_NS16550_MEM32 is still used really required for getting correct accessor used, see implementation of serial_{in|out}_shift() in drivers/serial/ns16550.c.

Quoted 5 lines
Quoted 2 lines

If CONFIG_SYS_NS16550_MEM32 is not set then simple readb() is used so that 8-bit data offset in 32-bit word is lost and we're dead in the water.

Isn't that covered by 'plat->reg_shift' which is read from dts property "reg-shift = <2>"?

Well actually CONFIG_SYS_NS16550_MEM32 is an alias to "reg-io-width = <4>"
which selects exactly accessor (right as CONFIG_SYS_NS16550_MEM32 in serial_{in|out}_shift()). But even though we do read "reg-io-width"
from .dtb it is not used in the driver. It was added by Andy Shevchenko
recently, see http://git.denx.de/?p=u-boot.git;a=commit;h=4e7207791c05b3ecff916c1b1b1b21401ec29b0b

Quoted 6 lines

BTW as I may see some SoCFPGA configs do mention this define:
---------------------------------->8-----------------------------

# git grep CONFIG_SYS_NS16550_MEM32 | grep socfpga
include/configs/socfpga_arria10_socdk.h:33:#define CONFIG_SYS_NS16550_MEM32
include/configs/socfpga_stratix10_socdk.h:146:#define CONFIG_SYS_NS16550_MEM32
---------------------------------->8-----------------------------

Right. Sorry for being unclear. I'm working on the "sub-mach" "Gen5" only. Those two are different types that I can't really test. Seems like Arria10 and Stratix10 might
not be converted to DM yet?

Quoted 6 lines

as well as this DT property:
---------------------------------->8-----------------------------

# git grep reg-io-width | grep socfpga
arch/arm/dts/socfpga.dtsi:877:                  reg-io-width = <4>;
arch/arm/dts/socfpga.dtsi:889:                  reg-io-width = <4>;

Those two are of interest to my boards.

Quoted 9 lines

arch/arm/dts/socfpga_arria10.dtsi:829: reg-io-width = <4>;
arch/arm/dts/socfpga_arria10.dtsi:840: reg-io-width = <4>;

arch/arm/dts/socfpga_stratix10.dtsi:252:                        reg-io-width = <4>;
arch/arm/dts/socfpga_stratix10.dtsi:265:                        reg-io-width = <4>;
arch/arm/dts/socfpga_stratix10.dtsi:314:                        reg-io-width = <4>;
arch/arm/dts/socfpga_stratix10.dtsi:326:                        reg-io-width = <4>;

---------------------------------->8-----------------------------

So I guess you may experiment with it a bit.

Ok, you're right there. I guess it just works for me when using 8-bit access, but you're right that the driver should use 32-bit access when configured like that via 'reg-io-width'. I'll have a look at that.

Thanks for insisting ;-)

Regards,
Simon

#60 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

In reply to Alexey Brodkin
Quoted 2 lines · Alexey Brodkin

Might be a bit naïve question but why depend on SPL_OF_PLATDATA only? What about CONFIG_OF_EMBED?

No driver should depend on OF_EMBED IIUC. New U-Boot spils a warning when production boards are using it.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#61 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

Quoted 10 lines · Andy Shevchenko
Quoted 2 lines · Alexey Brodkin

Might be a bit naïve question but why depend on SPL_OF_PLATDATA only? What about CONFIG_OF_EMBED?

No driver should depend on OF_EMBED IIUC. New U-Boot spils a warning when production boards are using it.

By now, actually I even dislike the idea of depending on OF_PLATDATA myself. Maybe we should fix the OF_PLATDATA to driver matching code to better handle drivers with multiple compatible strings instead of adding dedicated drivers.

Regards,
Simon

#62 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

Hi Simon,

Quoted 11 lines · Simon Goldschmidt
Quoted 8 lines · Andy Shevchenko
Quoted 2 lines · Alexey Brodkin

Might be a bit naïve question but why depend on SPL_OF_PLATDATA only? What about CONFIG_OF_EMBED?

Quoted 6 lines
Quoted 2 lines

No driver should depend on OF_EMBED IIUC. New U-Boot spils a warning when production boards are using it.

By now, actually I even dislike the idea of depending on OF_PLATDATA myself. Maybe we should fix the OF_PLATDATA to driver matching code to better handle drivers with multiple compatible strings instead of adding dedicated drivers.

Sounds good.

One option I rejected with the initial impl was to add tags to the DT to tell dtoc what to do. I still hope to avoid that, but it is an option, if helpful.

Regards,
Simon

#63 lore raw

PATCH 3/4 serial: add an of-platdata driver for "snps, dw-apb-uart"

In reply to Simon Goldschmidt
Quoted 7 lines · Simon Goldschmidt

Add a driver for the "snps,dw-apb-uart" used in socfpga and others.

This driver is required to get OF_PLATDATA to work for socfpga. It uses the ns16550 driver, converting the platdata from of-platdata go the ns16550 format.

Quoted 9 lines

---

 drivers/serial/Kconfig         | 10 ++++++++
 drivers/serial/Makefile        |  1 +
 drivers/serial/serial_dw_apb.c | 42 ++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 drivers/serial/serial_dw_apb.c
#64 lore raw

PATCH 4/4 mmc: socfpga: support of-platdata

In reply to Simon Goldschmidt

This adds support for OF_PLATDATA to the socfpga_dw_mmc driver.

To do that, also the name of the driver has to be changed to match the compatible string in the platdata generated from dts.

---

 drivers/mmc/socfpga_dw_mmc.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)
drivers/mmc/socfpga_dw_mmc.c +25 -3
index 739c1629a2..8503dff932 100644
@@ -8,6 +8,7 @@
 #include <asm/arch/system_manager.h>
 #include <clk.h>
 #include <dm.h>
+#include <dt-structs.h>
 #include <dwmmc.h>
 #include <errno.h>
 #include <fdtdec.h>
@@ -24,6 +25,9 @@ static const struct socfpga_system_manager *system_manager_base =
 		(void *)SOCFPGA_SYSMGR_ADDRESS;
 
 struct socfpga_dwmci_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_altr_socfpga_dw_mshc dtplat;
+#endif
 	struct mmc_config cfg;
 	struct mmc mmc;
 };
@@ -100,6 +104,7 @@ static int socfpga_dwmmc_get_clk_rate(struct udevice *dev)
 
 static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct dwmci_socfpga_priv_data *priv = dev_get_priv(dev);
 	struct dwmci_host *host = &priv->host;
 	int fifo_depth;
@@ -129,13 +134,13 @@ static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev)
 	priv->smplsel = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
 					"smplsel", 0);
 	host->priv = priv;
-
+#endif
 	return 0;
 }
 
 static int socfpga_dwmmc_probe(struct udevice *dev)
 {
-#ifdef CONFIG_BLK
+#if defined(CONFIG_BLK) || CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct socfpga_dwmci_plat *plat = dev_get_platdata(dev);
 #endif
 	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
@@ -143,6 +148,23 @@ static int socfpga_dwmmc_probe(struct udevice *dev)
 	struct dwmci_host *host = &priv->host;
 	int ret;
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct dtd_altr_socfpga_dw_mshc *dtplat = &plat->dtplat;
+
+	host->name = dev->name;
+	host->ioaddr = (void *)dtplat->reg[0];
+	host->buswidth = dtplat->bus_width;
+	host->clksel = socfpga_dwmci_clksel;
+	host->dev_index = 0;
+	host->fifoth_val = MSIZE(0x2) |
+		RX_WMARK(dtplat->fifo_depth / 2 - 1) |
+		TX_WMARK(dtplat->fifo_depth / 2);
+	host->priv = priv;
+	/* TODO: these are optional, of-platdata does not support this. */
+	priv->drvsel = 3;
+	priv->smplsel = 0;
+#endif
+
 	ret = socfpga_dwmmc_get_clk_rate(dev);
 	if (ret)
 		return ret;
@@ -185,7 +207,7 @@ static const struct udevice_id socfpga_dwmmc_ids[] = {
 };
 
 U_BOOT_DRIVER(socfpga_dwmmc_drv) = {
-	.name		= "socfpga_dwmmc",
+	.name		= "altr_socfpga_dw_mshc",
 	.id		= UCLASS_MMC,
 	.of_match	= socfpga_dwmmc_ids,
 	.ofdata_to_platdata = socfpga_dwmmc_ofdata_to_platdata,
Signature · 1 line
2.17.1
#65 lore raw

cover arm: socfgpa: support of-platdata

In reply to Simon Goldschmidt

Hi Simon,

Quoted 11 lines

This is an initial attempt to support OF_PLATDATA for socfpga gen5.

There are two motivations for this:
a) reduce code size to eventually support secure boot (where SPL has to authenticate the next stage by loading/checking U-Boot from a FIT image)
b) to support the cyclone 5 boot ROM's CRC check on the SPL in SRAM (on warm-restart), all bytes to check need to be in one piece. With OF_SEPARATE, this is not the case (.bss is between .rodata and the DTB). Since OF_EMBEDDED has been discouraged, OF_PLATDATA seems to be a good solution.

I'm not an expert with SOCFPGA nor your application, but maybe
selecting: "SPL_SEPARATE_BSS" would fix your issue?

This option allows putting on IMX6 SPL the DTB blob into OCRAM (internal RAM), before the DDR is setup (so it would be possible to calculate CRC).

I've stumbled upon such issue when I wanted to switch from OF_EMBEDDED to OF_SEPARATE.

Quoted 18 lines

This series enables booting from MMC with OF_PLATDATA. Booting from SPI does not yet work (I'm working on that, but it's tougher than expected).

Tested on the socrates board. To use it:
- use socfpga_socrates_defconfig
- disable CONFIG_SPL_SPI_FLASH_SUPPORT, CONFIG_SPL_SPI_SUPPORT and CONFIG_SPL_DM_RESET (those don't work yet)
- enable CONFIG_DESIGNWARE_SERIAL (required for console)

Simon Goldschmidt (4):
arm: socfpga: imply SPL config instead of select
arm: socfpga: fix compiling with OF_PLATDATA
serial: add an of-platdata driver for "snps,dw-apb-uart"
mmc: socfpga: support of-platdata

Quoted 9 lines
 arch/arm/Kconfig               |  4 ++--
 arch/arm/mach-socfpga/misc.c   |  2 +-
 drivers/mmc/socfpga_dw_mmc.c   | 28 ++++++++++++++++++++---
 drivers/serial/Kconfig         | 10 ++++++++
 drivers/serial/Makefile        |  1 +
 drivers/serial/serial_dw_apb.c | 42

++++++++++++++++++++++++++++++++++ 6 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 drivers/serial/serial_dw_apb.c

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190107/5504b18d/attachment.sig>

#66 lore raw

cover arm: socfgpa: support of-platdata

Quoted 15 lines · Lukasz Majewski

Hi Simon,

Quoted 11 lines

This is an initial attempt to support OF_PLATDATA for socfpga gen5.

There are two motivations for this:
a) reduce code size to eventually support secure boot (where SPL has to authenticate the next stage by loading/checking U-Boot from a FIT image)
b) to support the cyclone 5 boot ROM's CRC check on the SPL in SRAM (on warm-restart), all bytes to check need to be in one piece. With OF_SEPARATE, this is not the case (.bss is between .rodata and the DTB). Since OF_EMBEDDED has been discouraged, OF_PLATDATA seems to be a good solution.

Quoted 6 lines

I'm not an expert with SOCFPGA nor your application, but maybe
selecting: "SPL_SEPARATE_BSS" would fix your issue?

This option allows putting on IMX6 SPL the DTB blob into OCRAM (internal RAM), before the DDR is setup (so it would be possible to calculate CRC).

In socfpga, the whole SPL is copied into OCRAM by the boot ROM and executed from there. How can OF_SEPARATE help here? I tried enabling it but the SPL map file does not change. The only difference is there is no padding between the binary
and the DTB ('u-boot-spl-nodtb.bin' vs 'u-boot-spl-dtb.bin')

Regards,
Simon

Quoted 44 lines

I've stumbled upon such issue when I wanted to switch from OF_EMBEDDED to OF_SEPARATE.

Quoted 18 lines

This series enables booting from MMC with OF_PLATDATA. Booting from SPI does not yet work (I'm working on that, but it's tougher than expected).

Tested on the socrates board. To use it:
- use socfpga_socrates_defconfig
- disable CONFIG_SPL_SPI_FLASH_SUPPORT, CONFIG_SPL_SPI_SUPPORT and CONFIG_SPL_DM_RESET (those don't work yet)
- enable CONFIG_DESIGNWARE_SERIAL (required for console)

Simon Goldschmidt (4):
arm: socfpga: imply SPL config instead of select
arm: socfpga: fix compiling with OF_PLATDATA
serial: add an of-platdata driver for "snps,dw-apb-uart"
mmc: socfpga: support of-platdata

Quoted 9 lines
 arch/arm/Kconfig               |  4 ++--
 arch/arm/mach-socfpga/misc.c   |  2 +-
 drivers/mmc/socfpga_dw_mmc.c   | 28 ++++++++++++++++++++---
 drivers/serial/Kconfig         | 10 ++++++++
 drivers/serial/Makefile        |  1 +
 drivers/serial/serial_dw_apb.c | 42

++++++++++++++++++++++++++++++++++ 6 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 drivers/serial/serial_dw_apb.c

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de

#67 lore raw

cover arm: socfgpa: support of-platdata

In reply to Simon Goldschmidt
Quoted 11 lines · Simon Goldschmidt

This is an initial attempt to support OF_PLATDATA for socfpga gen5.

There are two motivations for this:
a) reduce code size to eventually support secure boot (where SPL has to authenticate the next stage by loading/checking U-Boot from a FIT image)
b) to support the cyclone 5 boot ROM's CRC check on the SPL in SRAM (on warm-restart), all bytes to check need to be in one piece. With OF_SEPARATE, this is not the case (.bss is between .rodata and the DTB). Since OF_EMBEDDED has been discouraged, OF_PLATDATA seems to be a good solution.

I'd much prefer parsing the DT (and thus, decoupling the SW from HW) than having some ad-hoc plat data again if we can avoid that.

Signature · 2 lines
Best regards,
Marek Vasut
#68 lore raw

cover arm: socfgpa: support of-platdata

Quoted 14 lines · Marek Vasut
Quoted 11 lines · Simon Goldschmidt

This is an initial attempt to support OF_PLATDATA for socfpga gen5.

There are two motivations for this:
a) reduce code size to eventually support secure boot (where SPL has to authenticate the next stage by loading/checking U-Boot from a FIT image)
b) to support the cyclone 5 boot ROM's CRC check on the SPL in SRAM (on warm-restart), all bytes to check need to be in one piece. With OF_SEPARATE, this is not the case (.bss is between .rodata and the DTB). Since OF_EMBEDDED has been discouraged, OF_PLATDATA seems to be a good solution.

Quoted 2 lines

I'd much prefer parsing the DT (and thus, decoupling the SW from HW) than having some ad-hoc plat data again if we can avoid that.

So you're against the whole OF_PLATDATA thing or how should I understand that?

It's not really ad-hoc, it's the DT converted to C structs. It's just in another format, but it's still (sort of) decoupled SW from HW.

As written above, I have two goals I want to achieve with this. Right now, I cannot enable verified boot in SPL because the available OCRAM cannot hold all the code. And it seemed to me OF_PLATDATA could help me there.

Regards,
Simon

#69 lore raw

cover arm: socfgpa: support of-platdata

Quoted 15 lines · Simon Goldschmidt
Quoted 14 lines · Marek Vasut
Quoted 11 lines · Simon Goldschmidt

This is an initial attempt to support OF_PLATDATA for socfpga gen5.

There are two motivations for this:
a) reduce code size to eventually support secure boot (where SPL has to authenticate the next stage by loading/checking U-Boot from a FIT image)
b) to support the cyclone 5 boot ROM's CRC check on the SPL in SRAM (on warm-restart), all bytes to check need to be in one piece. With OF_SEPARATE, this is not the case (.bss is between .rodata and the DTB). Since OF_EMBEDDED has been discouraged, OF_PLATDATA seems to be a good solution.

Quoted 5 lines
Quoted 2 lines

I'd much prefer parsing the DT (and thus, decoupling the SW from HW) than having some ad-hoc plat data again if we can avoid that.

So you're against the whole OF_PLATDATA thing or how should I understand that?

If we can avoid it, I'd prefer to do so.

Quoted 6 lines

It's not really ad-hoc, it's the DT converted to C structs. It's just in another format, but it's still (sort of) decoupled SW from HW.

As written above, I have two goals I want to achieve with this. Right now, I cannot enable verified boot in SPL because the available OCRAM cannot hold all the code. And it seemed to me OF_PLATDATA could help me there.

Well this might be a long shot, but I discussed this lack of OCRAM during 35C3 and there was a suggestion to lock L2 cache lines above ROM (so there's some backing store) and use that as extra SRAM. Would that help you ?

Signature · 2 lines
Best regards,
Marek Vasut
#70 lore raw

cover arm: socfgpa: support of-platdata

Quoted 28 lines · Marek Vasut
Quoted 15 lines · Simon Goldschmidt
Quoted 14 lines · Marek Vasut
Quoted 11 lines · Simon Goldschmidt

This is an initial attempt to support OF_PLATDATA for socfpga gen5.

There are two motivations for this:
a) reduce code size to eventually support secure boot (where SPL has to authenticate the next stage by loading/checking U-Boot from a FIT image)
b) to support the cyclone 5 boot ROM's CRC check on the SPL in SRAM (on warm-restart), all bytes to check need to be in one piece. With OF_SEPARATE, this is not the case (.bss is between .rodata and the DTB). Since OF_EMBEDDED has been discouraged, OF_PLATDATA seems to be a good solution.

Quoted 5 lines
Quoted 2 lines

I'd much prefer parsing the DT (and thus, decoupling the SW from HW) than having some ad-hoc plat data again if we can avoid that.

So you're against the whole OF_PLATDATA thing or how should I understand that?

If we can avoid it, I'd prefer to do so.

Quoted 3 lines

It's not really ad-hoc, it's the DT converted to C structs. It's just in another format, but it's still (sort of) decoupled SW from HW.

Quoted 8 lines
Quoted 3 lines

As written above, I have two goals I want to achieve with this. Right now, I cannot enable verified boot in SPL because the available OCRAM cannot hold all the code. And it seemed to me OF_PLATDATA could help me there.

Well this might be a long shot, but I discussed this lack of OCRAM during 35C3 and there was a suggestion to lock L2 cache lines above ROM (so there's some backing store) and use that as extra SRAM. Would that help you ?

I would have joined that discussion if my Family would have let me go during the holidays :-))

This is an interesing idea, but actually it's a lack of code/rodata size. The Intel
docs clearly state that the binary SPL loaded from SPI/MMC must be 60 KiB at max. I have not checked the code size increase I would get when enabling trusted boot (SPL loading U-Boot from FIT and verifying it with a public key), but I'm currently
at ~45 KiB for .text, .rodata and DTB and only 40 bytes for BSS. I'm booting from SPI.
When booting from MMC, the code is about ~4 KiB smaller but BSS grows to ~600 Bytes.

Of course the stack and initial malloc area do need some bytes too, but I think summed up, bss, stack and malloc should probably fit into 4 KiB, so I currently have
about 15 KiB to add FIT loading and public key verification/hashing. I don't think that's
enough just from the code size.

And on socfpga, I think all added code would use the heap, which is changed to SDRAM
very early, so it's not the RAM that is tight.

Regards,
Simon

#71 lore raw

cover arm: socfgpa: support of-platdata

Quoted 41 lines · Simon Goldschmidt
Quoted 28 lines · Marek Vasut
Quoted 15 lines · Simon Goldschmidt
Quoted 14 lines · Marek Vasut
Quoted 11 lines · Simon Goldschmidt

This is an initial attempt to support OF_PLATDATA for socfpga gen5.

There are two motivations for this:
a) reduce code size to eventually support secure boot (where SPL has to authenticate the next stage by loading/checking U-Boot from a FIT image)
b) to support the cyclone 5 boot ROM's CRC check on the SPL in SRAM (on warm-restart), all bytes to check need to be in one piece. With OF_SEPARATE, this is not the case (.bss is between .rodata and the DTB). Since OF_EMBEDDED has been discouraged, OF_PLATDATA seems to be a good solution.

Quoted 5 lines
Quoted 2 lines

I'd much prefer parsing the DT (and thus, decoupling the SW from HW) than having some ad-hoc plat data again if we can avoid that.

So you're against the whole OF_PLATDATA thing or how should I understand that?

If we can avoid it, I'd prefer to do so.

Quoted 3 lines

It's not really ad-hoc, it's the DT converted to C structs. It's just in another format, but it's still (sort of) decoupled SW from HW.

Quoted 8 lines
Quoted 3 lines

As written above, I have two goals I want to achieve with this. Right now, I cannot enable verified boot in SPL because the available OCRAM cannot hold all the code. And it seemed to me OF_PLATDATA could help me there.

Well this might be a long shot, but I discussed this lack of OCRAM during 35C3 and there was a suggestion to lock L2 cache lines above ROM (so there's some backing store) and use that as extra SRAM. Would that help you ?

I would have joined that discussion if my Family would have let me go during the holidays :-))

Quoted 10 lines

This is an interesing idea, but actually it's a lack of code/rodata size. The Intel
docs clearly state that the binary SPL loaded from SPI/MMC must be 60 KiB at max. I have not checked the code size increase I would get when enabling trusted boot (SPL loading U-Boot from FIT and verifying it with a public key), but I'm currently
at ~45 KiB for .text, .rodata and DTB and only 40 bytes for BSS. I'm booting from SPI.
When booting from MMC, the code is about ~4 KiB smaller but BSS grows to ~600 Bytes.

I wonder if there are some huge chunks of code which could be optimized?

Quoted 10 lines

Of course the stack and initial malloc area do need some bytes too, but I think summed up, bss, stack and malloc should probably fit into 4 KiB, so I currently have
about 15 KiB to add FIT loading and public key verification/hashing. I don't think that's
enough just from the code size.

And on socfpga, I think all added code would use the heap, which is changed to SDRAM
very early, so it's not the RAM that is tight.

Can you check readelf and see how the function size looks ? Maybe there's something which is just too big ?

Signature · 2 lines
Best regards,
Marek Vasut
#72 lore raw

cover arm: socfgpa: support of-platdata

Quoted 63 lines · Marek Vasut
Quoted 41 lines · Simon Goldschmidt
Quoted 28 lines · Marek Vasut
Quoted 15 lines · Simon Goldschmidt
Quoted 14 lines · Marek Vasut
Quoted 11 lines · Simon Goldschmidt

This is an initial attempt to support OF_PLATDATA for socfpga gen5.

There are two motivations for this:
a) reduce code size to eventually support secure boot (where SPL has to authenticate the next stage by loading/checking U-Boot from a FIT image)
b) to support the cyclone 5 boot ROM's CRC check on the SPL in SRAM (on warm-restart), all bytes to check need to be in one piece. With OF_SEPARATE, this is not the case (.bss is between .rodata and the DTB). Since OF_EMBEDDED has been discouraged, OF_PLATDATA seems to be a good solution.

Quoted 5 lines
Quoted 2 lines

I'd much prefer parsing the DT (and thus, decoupling the SW from HW) than having some ad-hoc plat data again if we can avoid that.

So you're against the whole OF_PLATDATA thing or how should I understand that?

If we can avoid it, I'd prefer to do so.

Quoted 3 lines

It's not really ad-hoc, it's the DT converted to C structs. It's just in another format, but it's still (sort of) decoupled SW from HW.

Quoted 8 lines
Quoted 3 lines

As written above, I have two goals I want to achieve with this. Right now, I cannot enable verified boot in SPL because the available OCRAM cannot hold all the code. And it seemed to me OF_PLATDATA could help me there.

Well this might be a long shot, but I discussed this lack of OCRAM during 35C3 and there was a suggestion to lock L2 cache lines above ROM (so there's some backing store) and use that as extra SRAM. Would that help you ?

I would have joined that discussion if my Family would have let me go during the holidays :-))

Quoted 10 lines

This is an interesing idea, but actually it's a lack of code/rodata size. The Intel
docs clearly state that the binary SPL loaded from SPI/MMC must be 60 KiB at max. I have not checked the code size increase I would get when enabling trusted boot (SPL loading U-Boot from FIT and verifying it with a public key), but I'm currently
at ~45 KiB for .text, .rodata and DTB and only 40 bytes for BSS. I'm booting from SPI.
When booting from MMC, the code is about ~4 KiB smaller but BSS grows to ~600 Bytes.

I wonder if there are some huge chunks of code which could be optimized?

Quoted 7 lines

Of course the stack and initial malloc area do need some bytes too, but I think summed up, bss, stack and malloc should probably fit into 4 KiB, so I currently have
about 15 KiB to add FIT loading and public key verification/hashing. I don't think that's
enough just from the code size.

Quoted 6 lines
Quoted 3 lines

And on socfpga, I think all added code would use the heap, which is changed to SDRAM
very early, so it's not the RAM that is tight.

Can you check readelf and see how the function size looks ? Maybe there's something which is just too big ?

I'm looking at the map file all the time ;-) The only thing that looks too big is
SDRAM initialization, which is about 16 KiB overall, I think. The rest just seems
to be smaller parts. But the binary blob u32 arrays created by Quartus don't help, either: rodata is about 9 KiB.

Regards,
Simon

#73 lore raw

cover arm: socfgpa: support of-platdata

Quoted 71 lines · Simon Goldschmidt
Quoted 63 lines · Marek Vasut
Quoted 41 lines · Simon Goldschmidt
Quoted 28 lines · Marek Vasut
Quoted 15 lines · Simon Goldschmidt
Quoted 14 lines · Marek Vasut
Quoted 11 lines · Simon Goldschmidt

This is an initial attempt to support OF_PLATDATA for socfpga gen5.

There are two motivations for this:
a) reduce code size to eventually support secure boot (where SPL has to authenticate the next stage by loading/checking U-Boot from a FIT image)
b) to support the cyclone 5 boot ROM's CRC check on the SPL in SRAM (on warm-restart), all bytes to check need to be in one piece. With OF_SEPARATE, this is not the case (.bss is between .rodata and the DTB). Since OF_EMBEDDED has been discouraged, OF_PLATDATA seems to be a good solution.

Quoted 5 lines
Quoted 2 lines

I'd much prefer parsing the DT (and thus, decoupling the SW from HW) than having some ad-hoc plat data again if we can avoid that.

So you're against the whole OF_PLATDATA thing or how should I understand that?

If we can avoid it, I'd prefer to do so.

Quoted 3 lines

It's not really ad-hoc, it's the DT converted to C structs. It's just in another format, but it's still (sort of) decoupled SW from HW.

Quoted 8 lines
Quoted 3 lines

As written above, I have two goals I want to achieve with this. Right now, I cannot enable verified boot in SPL because the available OCRAM cannot hold all the code. And it seemed to me OF_PLATDATA could help me there.

Well this might be a long shot, but I discussed this lack of OCRAM during 35C3 and there was a suggestion to lock L2 cache lines above ROM (so there's some backing store) and use that as extra SRAM. Would that help you ?

I would have joined that discussion if my Family would have let me go during the holidays :-))

Quoted 10 lines

This is an interesing idea, but actually it's a lack of code/rodata size. The Intel
docs clearly state that the binary SPL loaded from SPI/MMC must be 60 KiB at max. I have not checked the code size increase I would get when enabling trusted boot (SPL loading U-Boot from FIT and verifying it with a public key), but I'm currently
at ~45 KiB for .text, .rodata and DTB and only 40 bytes for BSS. I'm booting from SPI.
When booting from MMC, the code is about ~4 KiB smaller but BSS grows to ~600 Bytes.

I wonder if there are some huge chunks of code which could be optimized?

Quoted 7 lines

Of course the stack and initial malloc area do need some bytes too, but I think summed up, bss, stack and malloc should probably fit into 4 KiB, so I currently have
about 15 KiB to add FIT loading and public key verification/hashing. I don't think that's
enough just from the code size.

Quoted 6 lines
Quoted 3 lines

And on socfpga, I think all added code would use the heap, which is changed to SDRAM
very early, so it's not the RAM that is tight.

Can you check readelf and see how the function size looks ? Maybe there's something which is just too big ?

Quoted 6 lines

I'm looking at the map file all the time ;-) The only thing that looks too big is
SDRAM initialization, which is about 16 KiB overall, I think. The rest just seems
to be smaller parts. But the binary blob u32 arrays created by Quartus don't help, either: rodata is about 9 KiB.

Can that be somehow optimized ? The ideal approach would be to move it somehow to DT.

Signature · 2 lines
Best regards,
Marek Vasut
#74 lore raw

cover arm: socfgpa: support of-platdata

Quoted 80 lines · Marek Vasut
Quoted 71 lines · Simon Goldschmidt
Quoted 63 lines · Marek Vasut
Quoted 41 lines · Simon Goldschmidt
Quoted 28 lines · Marek Vasut
Quoted 15 lines · Simon Goldschmidt
Quoted 14 lines · Marek Vasut
Quoted 11 lines · Simon Goldschmidt

This is an initial attempt to support OF_PLATDATA for socfpga gen5.

There are two motivations for this:
a) reduce code size to eventually support secure boot (where SPL has to authenticate the next stage by loading/checking U-Boot from a FIT image)
b) to support the cyclone 5 boot ROM's CRC check on the SPL in SRAM (on warm-restart), all bytes to check need to be in one piece. With OF_SEPARATE, this is not the case (.bss is between .rodata and the DTB). Since OF_EMBEDDED has been discouraged, OF_PLATDATA seems to be a good solution.

Quoted 5 lines
Quoted 2 lines

I'd much prefer parsing the DT (and thus, decoupling the SW from HW) than having some ad-hoc plat data again if we can avoid that.

So you're against the whole OF_PLATDATA thing or how should I understand that?

If we can avoid it, I'd prefer to do so.

Quoted 3 lines

It's not really ad-hoc, it's the DT converted to C structs. It's just in another format, but it's still (sort of) decoupled SW from HW.

Quoted 8 lines
Quoted 3 lines

As written above, I have two goals I want to achieve with this. Right now, I cannot enable verified boot in SPL because the available OCRAM cannot hold all the code. And it seemed to me OF_PLATDATA could help me there.

Well this might be a long shot, but I discussed this lack of OCRAM during 35C3 and there was a suggestion to lock L2 cache lines above ROM (so there's some backing store) and use that as extra SRAM. Would that help you ?

I would have joined that discussion if my Family would have let me go during the holidays :-))

Quoted 10 lines

This is an interesing idea, but actually it's a lack of code/rodata size. The Intel
docs clearly state that the binary SPL loaded from SPI/MMC must be 60 KiB at max. I have not checked the code size increase I would get when enabling trusted boot (SPL loading U-Boot from FIT and verifying it with a public key), but I'm currently
at ~45 KiB for .text, .rodata and DTB and only 40 bytes for BSS. I'm booting from SPI.
When booting from MMC, the code is about ~4 KiB smaller but BSS grows to ~600 Bytes.

I wonder if there are some huge chunks of code which could be optimized?

Quoted 7 lines

Of course the stack and initial malloc area do need some bytes too, but I think summed up, bss, stack and malloc should probably fit into 4 KiB, so I currently have
about 15 KiB to add FIT loading and public key verification/hashing. I don't think that's
enough just from the code size.

Quoted 6 lines
Quoted 3 lines

And on socfpga, I think all added code would use the heap, which is changed to SDRAM
very early, so it's not the RAM that is tight.

Can you check readelf and see how the function size looks ? Maybe there's something which is just too big ?

Quoted 6 lines

I'm looking at the map file all the time ;-) The only thing that looks too big is
SDRAM initialization, which is about 16 KiB overall, I think. The rest just seems
to be smaller parts. But the binary blob u32 arrays created by Quartus don't help, either: rodata is about 9 KiB.

Quoted 2 lines

Can that be somehow optimized ? The ideal approach would be to move it somehow to DT.

I don't know if those binary blobs (pin config, clock config etc.) can be converted
without internal information from Intel.

The SDRAM initialization might just be bad code, I don't know.

So like you wrote in the other thread: obviously, we're doing something wrong as those 60 KiB will not be enough for what I want SPL to do. But, I haven't yet found something that is just obviously code bloat.

Regards,
Simon

#75 lore raw

cover arm: socfgpa: support of-platdata

Quoted 88 lines · Simon Goldschmidt
Quoted 80 lines · Marek Vasut
Quoted 71 lines · Simon Goldschmidt
Quoted 63 lines · Marek Vasut
Quoted 41 lines · Simon Goldschmidt
Quoted 28 lines · Marek Vasut
Quoted 15 lines · Simon Goldschmidt
Quoted 14 lines · Marek Vasut
Quoted 11 lines · Simon Goldschmidt

This is an initial attempt to support OF_PLATDATA for socfpga gen5.

There are two motivations for this:
a) reduce code size to eventually support secure boot (where SPL has to authenticate the next stage by loading/checking U-Boot from a FIT image)
b) to support the cyclone 5 boot ROM's CRC check on the SPL in SRAM (on warm-restart), all bytes to check need to be in one piece. With OF_SEPARATE, this is not the case (.bss is between .rodata and the DTB). Since OF_EMBEDDED has been discouraged, OF_PLATDATA seems to be a good solution.

Quoted 5 lines
Quoted 2 lines

I'd much prefer parsing the DT (and thus, decoupling the SW from HW) than having some ad-hoc plat data again if we can avoid that.

So you're against the whole OF_PLATDATA thing or how should I understand that?

If we can avoid it, I'd prefer to do so.

Quoted 3 lines

It's not really ad-hoc, it's the DT converted to C structs. It's just in another format, but it's still (sort of) decoupled SW from HW.

Quoted 8 lines
Quoted 3 lines

As written above, I have two goals I want to achieve with this. Right now, I cannot enable verified boot in SPL because the available OCRAM cannot hold all the code. And it seemed to me OF_PLATDATA could help me there.

Well this might be a long shot, but I discussed this lack of OCRAM during 35C3 and there was a suggestion to lock L2 cache lines above ROM (so there's some backing store) and use that as extra SRAM. Would that help you ?

I would have joined that discussion if my Family would have let me go during the holidays :-))

Quoted 10 lines

This is an interesing idea, but actually it's a lack of code/rodata size. The Intel
docs clearly state that the binary SPL loaded from SPI/MMC must be 60 KiB at max. I have not checked the code size increase I would get when enabling trusted boot (SPL loading U-Boot from FIT and verifying it with a public key), but I'm currently
at ~45 KiB for .text, .rodata and DTB and only 40 bytes for BSS. I'm booting from SPI.
When booting from MMC, the code is about ~4 KiB smaller but BSS grows to ~600 Bytes.

I wonder if there are some huge chunks of code which could be optimized?

Quoted 7 lines

Of course the stack and initial malloc area do need some bytes too, but I think summed up, bss, stack and malloc should probably fit into 4 KiB, so I currently have
about 15 KiB to add FIT loading and public key verification/hashing. I don't think that's
enough just from the code size.

Quoted 6 lines
Quoted 3 lines

And on socfpga, I think all added code would use the heap, which is changed to SDRAM
very early, so it's not the RAM that is tight.

Can you check readelf and see how the function size looks ? Maybe there's something which is just too big ?

Quoted 6 lines

I'm looking at the map file all the time ;-) The only thing that looks too big is
SDRAM initialization, which is about 16 KiB overall, I think. The rest just seems
to be smaller parts. But the binary blob u32 arrays created by Quartus don't help, either: rodata is about 9 KiB.

Quoted 2 lines

Can that be somehow optimized ? The ideal approach would be to move it somehow to DT.

I don't know if those binary blobs (pin config, clock config etc.) can be converted
without internal information from Intel.

Quoted 5 lines

The SDRAM initialization might just be bad code, I don't know.

So like you wrote in the other thread: obviously, we're doing something wrong as those 60 KiB will not be enough for what I want SPL to do. But, I haven't yet found something that is just obviously code bloat.

I wonder if the SDRAM init tables aren't a bit sparse for example. Maybe something can be done there ?

Signature · 2 lines
Best regards,
Marek Vasut
#76 lore raw

cover arm: socfgpa: support of-platdata

Am 08.01.2019 um 15:43 schrieb Marek Vasut:

Quoted 89 lines · Simon Goldschmidt
Quoted 88 lines · Marek Vasut
Quoted 80 lines · Simon Goldschmidt
Quoted 71 lines · Marek Vasut
Quoted 63 lines · Simon Goldschmidt
Quoted 41 lines · Marek Vasut
Quoted 28 lines · Simon Goldschmidt
Quoted 15 lines · Marek Vasut
Quoted 14 lines · Simon Goldschmidt
Quoted 11 lines

This is an initial attempt to support OF_PLATDATA for socfpga gen5.

There are two motivations for this:
a) reduce code size to eventually support secure boot (where SPL has to authenticate the next stage by loading/checking U-Boot from a FIT image)
b) to support the cyclone 5 boot ROM's CRC check on the SPL in SRAM (on warm-restart), all bytes to check need to be in one piece. With OF_SEPARATE, this is not the case (.bss is between .rodata and the DTB). Since OF_EMBEDDED has been discouraged, OF_PLATDATA seems to be a good solution.

Quoted 5 lines
Quoted 2 lines

I'd much prefer parsing the DT (and thus, decoupling the SW from HW) than having some ad-hoc plat data again if we can avoid that.

So you're against the whole OF_PLATDATA thing or how should I understand that?

If we can avoid it, I'd prefer to do so.

Quoted 3 lines

It's not really ad-hoc, it's the DT converted to C structs. It's just in another format, but it's still (sort of) decoupled SW from HW.

Quoted 8 lines
Quoted 3 lines

As written above, I have two goals I want to achieve with this. Right now, I cannot enable verified boot in SPL because the available OCRAM cannot hold all the code. And it seemed to me OF_PLATDATA could help me there.

Well this might be a long shot, but I discussed this lack of OCRAM during 35C3 and there was a suggestion to lock L2 cache lines above ROM (so there's some backing store) and use that as extra SRAM. Would that help you ?

I would have joined that discussion if my Family would have let me go during the holidays :-))

Quoted 10 lines

This is an interesing idea, but actually it's a lack of code/rodata size. The Intel
docs clearly state that the binary SPL loaded from SPI/MMC must be 60 KiB at max. I have not checked the code size increase I would get when enabling trusted boot (SPL loading U-Boot from FIT and verifying it with a public key), but I'm currently
at ~45 KiB for .text, .rodata and DTB and only 40 bytes for BSS. I'm booting from SPI.
When booting from MMC, the code is about ~4 KiB smaller but BSS grows to ~600 Bytes.

I wonder if there are some huge chunks of code which could be optimized?

Quoted 7 lines

Of course the stack and initial malloc area do need some bytes too, but I think summed up, bss, stack and malloc should probably fit into 4 KiB, so I currently have
about 15 KiB to add FIT loading and public key verification/hashing. I don't think that's
enough just from the code size.

Quoted 6 lines
Quoted 3 lines

And on socfpga, I think all added code would use the heap, which is changed to SDRAM
very early, so it's not the RAM that is tight.

Can you check readelf and see how the function size looks ? Maybe there's something which is just too big ?

Quoted 6 lines

I'm looking at the map file all the time ;-) The only thing that looks too big is
SDRAM initialization, which is about 16 KiB overall, I think. The rest just seems
to be smaller parts. But the binary blob u32 arrays created by Quartus don't help, either: rodata is about 9 KiB.

Quoted 2 lines

Can that be somehow optimized ? The ideal approach would be to move it somehow to DT.

I don't know if those binary blobs (pin config, clock config etc.) can be converted
without internal information from Intel.

Quoted 8 lines
Quoted 5 lines

The SDRAM initialization might just be bad code, I don't know.

So like you wrote in the other thread: obviously, we're doing something wrong as those 60 KiB will not be enough for what I want SPL to do. But, I haven't yet found something that is just obviously code bloat.

I wonder if the SDRAM init tables aren't a bit sparse for example. Maybe something can be done there ?

I'll drop this series. There are some more cleanups in SPL to do before I'll be working on platdata again and this one won't apply any more after those changes are done.

Regards,
Simon