Skip to contentSkip to conversation

add minimal bcm2835-sdram driver

PATCH Superseded [email protected] 4 participants 14 messages May 12, 2016 – May 16, 2016

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover add minimal bcm2835-sdram driver

From: Martin Sperl <[email protected]>

As the sdram clock is a critical clock to the system the minimal bcm2835-sdram driver claims (and enables) this clock and also exposes the corresponding sdram registers via debugfs.

Martin Sperl (4):
dt: bindings: add bcm2835-memory-controller documentation
memory: bcm2835: add bcm2835-memory controller
ARM: dts: bcm2835: add the bcm2835-sdram-controller to the dt
ARM: bcm2835_defconfig: add bcm2835-sdram controller

 .../memory-controllers/brcm,bcm2835-sdram.txt      |  16 +++
 arch/arm/boot/dts/bcm283x.dtsi                     |   6 +
 arch/arm/configs/bcm2835_defconfig                 |   1 +
 drivers/memory/Kconfig                             |   7 +
 drivers/memory/Makefile                            |   1 +
 drivers/memory/bcm2835-sdram.c                     | 152 +++++++++++++++++++++
 6 files changed, 183 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/brcm,bcm2835-sdram.txt
 create mode 100644 drivers/memory/bcm2835-sdram.c

--
2.1.4

#1 lore raw

PATCH 1/4 dt: bindings: add bcm2835-memory-controller documentation

From: Martin Sperl <[email protected]>

Add memory controller dt-binding documentation for the bcm2835 soc.

---
 .../bindings/memory-controllers/brcm,bcm2835-sdram.txt   | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/brcm,bcm2835-sdram.txt
Documentation/devicetree/bindings/memory-controllers/brcm,bcm2835-sdram.txt new file +16 -0
new file mode 100644
index 0000000..d1cb151
@@ -0,0 +1,16 @@
+Binding for SDRAM driver for BCM2835 SoCs.
+
+Required parameters:
+-------------------
+
+compatible : 	should be: "brcm,bcm2835-sdram"
+reg :		Address ranges of the ic1/ic2 registers.
+clocks : 	Phandle of the clock used by the sdram.
+
+Example:
+
+memory-conroller at 7e002000 {
+	compatible = "brcm,bcm2835-sdram";
+	reg = <0x7e002000 0x58>, <0x7e002800 0x58>;
+	clocks = <&clocks BCM2835_CLOCK_SDRAM>;
+};
Signature · 1 line
2.1.4
#3 lore raw

PATCH 2/4 memory: bcm2835: add bcm2835-memory controller

In reply to [email protected]

From: Martin Sperl <[email protected]>

Add a memory-controller driver for the bcm2835 SOC.

This is mostly needed to claim the SDRAM clock
so that this (and the corresponding parent pll)
never gets disabled.

It also exposes the sdram registers via debugfs.

---
 drivers/memory/Kconfig         |   7 ++
 drivers/memory/Makefile        |   1 +
 drivers/memory/bcm2835-sdram.c | 152 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 160 insertions(+)
 create mode 100644 drivers/memory/bcm2835-sdram.c
drivers/memory/Kconfig +7 -0
index 51d5cd2..a55cad3 100644
@@ -25,6 +25,13 @@ config ATMEL_SDRAMC
 	  Starting with the at91sam9g45, this controller supports SDR, DDR and
 	  LP-DDR memories.
 
+config BCM2835_SDRAM
+	bool "Broadcom BCM2835 SDRAM Controller"
+	default y
+	depends on ARCH_BCM2835 || COMPILE_TEST
+	help
+	  This driver is for Broadcom BCM2835 SDRAM Controller.
+
 config TI_AEMIF
 	tristate "Texas Instruments AEMIF driver"
 	depends on (ARCH_DAVINCI || ARCH_KEYSTONE) && OF
drivers/memory/Makefile +1 -0
index 890bdf4..1287b90 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_OF)		+= of_memory.o
 endif
 obj-$(CONFIG_ARM_PL172_MPMC)	+= pl172.o
 obj-$(CONFIG_ATMEL_SDRAMC)	+= atmel-sdramc.o
+obj-$(CONFIG_BCM2835_SDRAM)	+= bcm2835-sdram.o
 obj-$(CONFIG_TI_AEMIF)		+= ti-aemif.o
 obj-$(CONFIG_TI_EMIF)		+= emif.o
 obj-$(CONFIG_OMAP_GPMC)		+= omap-gpmc.o
drivers/memory/bcm2835-sdram.c new file +152 -0

152 lines not on this page · raw message

Signature · 1 line
2.1.4
#4 lore raw

PATCH 3/4 ARM: dts: bcm2835: add the bcm2835-sdram-controller to the dt

In reply to [email protected]

From: Martin Sperl <[email protected]>

Add the bcm2835 sdram controller to the device tree.

---
 arch/arm/boot/dts/bcm283x.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/bcm283x.dtsi +6 -0
index 8aaf193..9db9d97 100644
@@ -22,6 +22,12 @@
 		#address-cells = <1>;
 		#size-cells = <1>;
 
+		memory-controller at 7e002000 {
+			compatible = "brcm,bcm2835-sdram";
+			reg = <0x7e002000 0x58>, <0x7e002800 0x58>;
+			clocks = <&clocks BCM2835_CLOCK_SDRAM>;
+		};
+
 		timer at 7e003000 {
 			compatible = "brcm,bcm2835-system-timer";
 			reg = <0x7e003000 0x1000>;
Signature · 1 line
2.1.4
#7 lore raw

PATCH 4/4 ARM: bcm2835_defconfig: add bcm2835-sdram controller

In reply to [email protected]

From: Martin Sperl <[email protected]>

Add the bcm2835-sdram controller driver to the default config. (as the driver is enabled by default vi KConfig, we only need to enable CONFIG_MEMORY)

---
 arch/arm/configs/bcm2835_defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm/configs/bcm2835_defconfig +1 -0
index 1ef69fc..29a44bd 100644
@@ -107,6 +107,7 @@ CONFIG_MAILBOX=y
 CONFIG_BCM2835_MBOX=y
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_RASPBERRYPI_POWER=y
+CONFIG_MEMORY=y
 CONFIG_PWM=y
 CONFIG_PWM_BCM2835=y
 CONFIG_RASPBERRYPI_FIRMWARE=y

--
2.1.4

#8 lore raw
In reply to [email protected]

Hi Martin,

Quoted 9 lines

kernel at martin.sperl.org hat am 12. Mai 2016 um 14:38 geschrieben:

From: Martin Sperl <[email protected]>

As the sdram clock is a critical clock to the system the minimal bcm2835-sdram driver claims (and enables) this clock and also exposes the corresponding sdram registers via debugfs.

sounds like this driver should fix an clock handling issue. Unfortunately this isn't a solution in case the driver is disabled.

Does the GPU firmware handle the SDRAM controller or is it initialized by bootcode?

Stefan

#5 lore raw

Re: [PATCH 3/4] ARM: dts: bcm2835: add the bcm2835-sdram-controller to the dt

In reply to [email protected]

Hi,

Quoted 17 lines

kernel at martin.sperl.org hat am 12. Mai 2016 um 14:38 geschrieben:

From: Martin Sperl <[email protected]>

Add the bcm2835 sdram controller to the device tree.

---
 arch/arm/boot/dts/bcm283x.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/bcm283x.dtsi +0 -0
index 8aaf193..9db9d97 100644

arch/arm/boot/dts/bcm283x.dtsi line 27

Quoted 6 lines
arch/arm/boot/dts/bcm283x.dtsi +3 -0
@@ -22,6 +22,12 @@
 		#address-cells = <1>;
 		#size-cells = <1>;
 
+		memory-controller at 7e002000 {
+			compatible = "brcm,bcm2835-sdram";
+			reg = <0x7e002000 0x58>, <0x7e002800 0x58>;

where do you get these addresses?

According to register documentation [1] the adresses belong to the interrupt controller.

Maybe 0x7ee00000 is the right address.

[1] - https://github.com/hermanhermitage/videocoreiv/wiki/Register-Documentation

Quoted 14 lines
arch/arm/boot/dts/bcm283x.dtsi +3 -0
+			clocks = <&clocks BCM2835_CLOCK_SDRAM>;
+		};
+
 		timer at 7e003000 {
 			compatible = "brcm,bcm2835-system-timer";
 			reg = <0x7e003000 0x1000>;
Signature · 7 lines
2.1.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#9 lore raw
In reply to Stefan Wahren
Quoted 10 lines · Stefan Wahren

Hi Martin,

Quoted 5 lines

kernel at martin.sperl.org hat am 12. Mai 2016 um 14:38 geschrieben:

From: Martin Sperl <[email protected]>

Quoted 7 lines
Quoted 4 lines

As the sdram clock is a critical clock to the system the minimal bcm2835-sdram driver claims (and enables) this clock and also exposes the corresponding sdram registers via debugfs.

sounds like this driver should fix an clock handling issue. Unfortunately this isn't a solution in case the driver is disabled.

Unfortunately there is no way around this - the driver has to be enabled so that the sdram clock or the parent pll, which typically is plld_core, never gets disabled.

The only other option would be marking the clock as critical for those legacy drivers.

See also the discussions around the clock register for the sdram clock, where we have the ?normal? clock and some pll as well - even if the ?normal? clock is disabled, then clearing the sdram register (or the parent) freezes the system.

Quoted 4 lines

Does the GPU firmware handle the SDRAM controller or is it initialized by bootcode?

AFAIK it is enabled in bootcode.bin and - as of now - the firmware updates refresh cycles when SOC temperatures change.
FW checks every 30 seconds unless there is a key set in config.txt, which - supposedly - produces a slight impact every 30 seconds to the system.

Martin

#10 lore raw

Hi,

Quoted 22 lines

Martin Sperl <[email protected]> hat am 12. Mai 2016 um 17:28 geschrieben:

Quoted 9 lines · Stefan Wahren

Hi Martin,

Quoted 5 lines

kernel at martin.sperl.org hat am 12. Mai 2016 um 14:38 geschrieben:

From: Martin Sperl <[email protected]>

Quoted 8 lines
Quoted 4 lines

As the sdram clock is a critical clock to the system the minimal bcm2835-sdram driver claims (and enables) this clock and also exposes the corresponding sdram registers via debugfs.

sounds like this driver should fix an clock handling issue. Unfortunately this
isn't a solution in case the driver is disabled.

Quoted 6 lines

Unfortunately there is no way around this - the driver has to be enabled so that the sdram clock or the parent pll, which typically is plld_core, never gets disabled.

The only other option would be marking the clock as critical for those legacy drivers.

i would prefer this option. Since this would be more a fix we could get this faster in, it's more clear why we are doing that and less to review.

Did i miss a drawback?

Stefan

Quoted 19 lines

See also the discussions around the clock register for the sdram clock, where we have the ?normal? clock and some pll as well - even if the ?normal? clock is disabled, then clearing the sdram register (or the parent) freezes the system.

Quoted 4 lines

Does the GPU firmware handle the SDRAM controller or is it initialized by bootcode?

AFAIK it is enabled in bootcode.bin and - as of now - the firmware updates refresh cycles when SOC temperatures change.
FW checks every 30 seconds unless there is a key set in config.txt, which - supposedly - produces a slight impact every 30 seconds to the system.

Martin

#6 lore raw

Re: [PATCH 3/4] ARM: dts: bcm2835: add the bcm2835-sdram-controller to the dt

In reply to Stefan Wahren
Quoted 25 lines · Stefan Wahren

Hi,

Quoted 20 lines

kernel at martin.sperl.org hat am 12. Mai 2016 um 14:38 geschrieben:

From: Martin Sperl <[email protected]>

Add the bcm2835 sdram controller to the device tree.

---
arch/arm/boot/dts/bcm283x.dtsi | 6 ++++++

1 file changed, 6 insertions(+)
arch/arm/boot/dts/bcm283x.dtsi +0 -0
index 8aaf193..9db9d97 100644
@@ -22,6 +22,12 @@
 		#address-cells = <1>;
 		#size-cells = <1>;
 
Quoted 5 lines

arch/arm/boot/dts/bcm283x.dtsi line 27

Quoted 3 lines
arch/arm/boot/dts/bcm283x.dtsi +3 -0
+		memory-controller at 7e002000 {
+			compatible = "brcm,bcm2835-sdram";
+			reg = <0x7e002000 0x58>, <0x7e002800 0x58>;

where do you get these addresses?

I took this info based on the shared headers by broadcom:
https://github.com/msperl/rpi-registers/blob/master/md/README.md

And the bootrom code showed something similar that would point to these registers.

Ic0 and ic1 register values also show the valid memory regions:
Especially IC[01]_SRC0 contains reference to the SRAM size on the CM - 0x20000000
here the fump of devmem2:
Value at address 0x3F00200C (0x76f3300c): 0x20000000.

But as you point out that may also be the interrupt controller for the VC4 cores?

It is probably the location where the VC4 interrupt table is situated.

Quoted 4 lines

According to register documentation [1] the adresses belong to the interrupt controller.

Maybe 0x7ee00000 is the right address.

This would also fall in range with the cache register ranges:
0x7ee00000 SD
0x7ee01000 L2
0x7ee02000 L1

L1 contains also IC0 and IC1 register names (L1_IC0_CONTROL et.al.) so I guess this is what has set me in the wrong direction...

Thanks for pointing it out...

I guess I will need to amend the patchset for that?

Martin

#11 lore raw
In reply to Stefan Wahren
Quoted 31 lines · Stefan Wahren

Hi,

Quoted 26 lines

Martin Sperl <[email protected]> hat am 12. Mai 2016 um 17:28 geschrieben:

Quoted 9 lines · Stefan Wahren

Hi Martin,

Quoted 5 lines

kernel at martin.sperl.org hat am 12. Mai 2016 um 14:38 geschrieben:

From: Martin Sperl <[email protected]>

Quoted 8 lines
Quoted 4 lines

As the sdram clock is a critical clock to the system the minimal bcm2835-sdram driver claims (and enables) this clock and also exposes the corresponding sdram registers via debugfs.

sounds like this driver should fix an clock handling issue. Unfortunately this
isn't a solution in case the driver is disabled.

Unfortunately there is no way around this - the driver has to be enabled so that the sdram clock or the parent pll, which typically is plld_core, never gets disabled.

Quoted 7 lines
Quoted 2 lines

The only other option would be marking the clock as critical for those legacy drivers.

i would prefer this option. Since this would be more a fix we could get this faster in, it's more clear why we are doing that and less to review.

Did i miss a drawback?

We had long discussions already on that - and HAND_OFF did not make it into the kernel either.

I had hoped that this was simple enough.

Martin

#12 lore raw
In reply to [email protected]
Quoted 6 lines · kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

As the sdram clock is a critical clock to the system the minimal bcm2835-sdram driver claims (and enables) this clock and also exposes the corresponding sdram registers via debugfs.

I don't think this is a good solution to the problem you are trying to work around. You're relying on the fact that this driver gets successfully probed before a driver that would -EPROBE_DEFER on a sibling clock, which is not a guarantee.

Let's please continue the debugging of clock management on linux-clk.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160512/1f9f9b34/attachment.sig>

#13 lore raw
Quoted 13 lines · Eric Anholt
Quoted 6 lines · kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

As the sdram clock is a critical clock to the system the minimal bcm2835-sdram driver claims (and enables) this clock and also exposes the corresponding sdram registers via debugfs.

Quoted 4 lines

I don't think this is a good solution to the problem you are trying to work around. You're relying on the fact that this driver gets successfully probed before a driver that would -EPROBE_DEFER on a sibling clock, which is not a guarantee.

Ah - that is probably the reason why hand_off has not gone in...

Quoted 2 lines

Let's please continue the debugging of clock management on linux-clk.

I am just trying to find a solution that works...

Still I think that having a driver that claims the clock and register range is good to have - at least this way we can have a peek at what the firmware does set up.

maintainer Acked-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] dt: bindings: add bcm2835-memory-controller documentation

In reply to [email protected]
Quoted 10 lines · kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Add memory controller dt-binding documentation for the bcm2835 soc.

---
 .../bindings/memory-controllers/brcm,bcm2835-sdram.txt   | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/brcm,bcm2835-sdram.txt

I'd suspect a DDR controller has more than one clock, but otherwise looks fine. And this binding is pretty much independent of the discussion for this series.