Skip to contentSkip to conversation

Add Broadcom STB memory controller driver

PATCH Superseded Florian Fainelli 4 participants 10 messages Jul 22, 2022 – Jul 26, 2022

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add Broadcom STB memory controller driver

Hi Krzysztof,

This small patch series adds basic support for controlling self-refresh power down on Broadcom STB memory controllers. We might be able to contribute more features to the memory controller driver in the future like accurate reporting of the memory type, timings, and possibly some performance counters.

Changes in v2:

- merged the v1 first two patches
- added a sysfs document describing attributes exposed
- addressed feedback from Krzysztof regarding style and API usage

Florian Fainelli (3):
dt-bindings: memory-controller: Document Broadcom STB MEMC
Documentation: sysfs: Document Broadcom STB memc sysfs knobs
memory: Add Broadcom STB memory controller driver

 .../ABI/testing/sysfs-platform-brcmstb-memc   |  15 +
 .../bindings/arm/bcm/brcm,brcmstb.txt         |  11 +-
 .../brcm,brcmstb-memc-ddr.yaml                |  53 +++
 drivers/memory/Kconfig                        |   9 +
 drivers/memory/Makefile                       |   1 +
 drivers/memory/brcmstb_memc.c                 | 302 ++++++++++++++++++
 6 files changed, 382 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-brcmstb-memc
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/brcm,brcmstb-memc-ddr.yaml
 create mode 100644 drivers/memory/brcmstb_memc.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/3 dt-bindings: memory-controller: Document Broadcom STB MEMC

Document the Broadcom STB memory controller which is a trivial binding for now with a set of compatible strings and single register.

Since we introduce this binding, the section in Documentation/devicetree/bindings/arm/bcm/brcm,brcmstb.txt is removed and this binding is referenced instead.

---
 .../bindings/arm/bcm/brcm,brcmstb.txt         | 11 +---
 .../brcm,brcmstb-memc-ddr.yaml                | 53 +++++++++++++++++++
 2 files changed, 55 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/brcm,brcmstb-memc-ddr.yaml
Documentation/devicetree/bindings/arm/bcm/brcm,brcmstb.txt +2 -9
index 104cc9b41df4..e797d2f69f3b 100644
@@ -187,15 +187,8 @@ Required properties:
 Sequencer DRAM parameters and control registers. Used for Self-Refresh
 Power-Down (SRPD), among other things.
 
-Required properties:
-- compatible     : should contain one of these
-	"brcm,brcmstb-memc-ddr-rev-b.2.1"
-	"brcm,brcmstb-memc-ddr-rev-b.2.2"
-	"brcm,brcmstb-memc-ddr-rev-b.2.3"
-	"brcm,brcmstb-memc-ddr-rev-b.3.0"
-	"brcm,brcmstb-memc-ddr-rev-b.3.1"
-	"brcm,brcmstb-memc-ddr"
-- reg            : the MEMC DDR register range
+See Documentation/devicetree/bindings/memory-controllers/brcm,memc.yaml for a
+full list of supported compatible strings and properties.
 
 Example:
 
Documentation/devicetree/bindings/memory-controllers/brcm,brcmstb-memc-ddr.yaml new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH v2 1/3] dt-bindings: memory-controller: Document Broadcom STB MEMC

Quoted 7 lines · Florian Fainelli

Document the Broadcom STB memory controller which is a trivial binding for now with a set of compatible strings and single register.

Since we introduce this binding, the section in Documentation/devicetree/bindings/arm/bcm/brcm,brcmstb.txt is removed and this binding is referenced instead.

Quoted 7 lines
---
 .../bindings/arm/bcm/brcm,brcmstb.txt         | 11 +---
 .../brcm,brcmstb-memc-ddr.yaml                | 53 +++++++++++++++++++
 2 files changed, 55 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/brcm,brcmstb-memc-ddr.yaml

Running 'make dtbs_check' with the schema in this patch gives the following warnings. Consider if they are expected or the schema is incorrect. These may not be new warnings.

Note that it is not yet a requirement to have 0 warnings for dtbs_check. This will change in the future.

Full log is available here: https://patchwork.ozlabs.org/patch/

memc-ddr@2000: 'clock-frequency' is a required property

	arch/arm/boot/dts/bcm7445-bcm97445svmb.dtb
	arch/arm/boot/dts/bcm7445-bcm97445svmb.dtb
	arch/arm/boot/dts/bcm7445-bcm97445svmb.dtb

memc-ddr@2000: compatible:0: 'brcm,brcmstb-memc-ddr' is not one of ['brcm,brcmstb-memc-ddr-rev-b.1.x', 'brcm,brcmstb-memc-ddr-rev-b.2.0', 'brcm,brcmstb-memc-ddr-rev-b.2.1', 'brcm,brcmstb-memc-ddr-rev-b.2.2', 'brcm,brcmstb-memc-ddr-rev-b.2.3', 'brcm,brcmstb-memc-ddr-rev-b.2.5', 'brcm,brcmstb-memc-ddr-rev-b.2.6', 'brcm,brcmstb-memc-ddr-rev-b.2.7', 'brcm,brcmstb-memc-ddr-rev-b.2.8', 'brcm,brcmstb-memc-ddr-rev-b.3.0', 'brcm,brcmstb-memc-ddr-rev-b.3.1', 'brcm,brcmstb-memc-ddr-rev-c.1.0', 'brcm,brcmstb-memc-ddr-rev-c.1.1', 'brcm,brcmstb-memc-ddr-rev-c.1.2', 'brcm,brcmstb-memc-ddr-rev-c.1.3', 'brcm,brcmstb-memc-ddr-rev-c.1.4']

	arch/arm/boot/dts/bcm7445-bcm97445svmb.dtb
	arch/arm/boot/dts/bcm7445-bcm97445svmb.dtb
	arch/arm/boot/dts/bcm7445-bcm97445svmb.dtb

memc-ddr@2000: compatible: ['brcm,brcmstb-memc-ddr'] is too short

	arch/arm/boot/dts/bcm7445-bcm97445svmb.dtb
	arch/arm/boot/dts/bcm7445-bcm97445svmb.dtb
	arch/arm/boot/dts/bcm7445-bcm97445svmb.dtb
maintainer Reviewed-by on v2 1/3
#3 lore raw

Re: [PATCH v2 1/3] dt-bindings: memory-controller: Document Broadcom STB MEMC

In reply to Florian Fainelli
Quoted 7 lines · Florian Fainelli

Document the Broadcom STB memory controller which is a trivial binding for now with a set of compatible strings and single register.

Since we introduce this binding, the section in Documentation/devicetree/bindings/arm/bcm/brcm,brcmstb.txt is removed and this binding is referenced instead.

Quoted 7 lines
---
 .../bindings/arm/bcm/brcm,brcmstb.txt         | 11 +---
 .../brcm,brcmstb-memc-ddr.yaml                | 53 +++++++++++++++++++
 2 files changed, 55 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/brcm,brcmstb-memc-ddr.yaml
#4 lore raw

PATCH v2 2/3 Documentation: sysfs: Document Broadcom STB memc sysfs knobs

In reply to Florian Fainelli

Document the "srpd" and "frequency" sysfs attributes exposed by the brcmstb_memc driver.

---
 .../ABI/testing/sysfs-platform-brcmstb-memc       | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-brcmstb-memc
Documentation/ABI/testing/sysfs-platform-brcmstb-memc new file +15 -0
new file mode 100644
index 000000000000..2bf0f58e412c
@@ -0,0 +1,15 @@
+What:		/sys/devices/platform/*/*/*/*/srpd
+Date:		July 2022
+KernelVersion:	5.21
+Contact:	Florian Fainelli <[email protected]>
+Description:
+		Self Refresh Power Down (SRPD) inactivity timeout counted in
+		internal DDR controller clock cycles. Possible values range
+		from 0 (disable inactivity timeout) to 65535 (0xffff).
+
+What:		/sys/devices/platform/*/*/*/*/frequency
+Date:		July 2022
+KernelVersion:	5.21
+Contact:	Florian Fainelli <[email protected]>
+Description:
+		DDR PHY frequency in Hz.
Signature · 1 line
2.25.1
#5 lore raw

Re: [PATCH v2 2/3] Documentation: sysfs: Document Broadcom STB memc sysfs knobs

Quoted 15 lines · Florian Fainelli

Document the "srpd" and "frequency" sysfs attributes exposed by the brcmstb_memc driver.

---
 .../ABI/testing/sysfs-platform-brcmstb-memc       | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-brcmstb-memc
Documentation/ABI/testing/sysfs-platform-brcmstb-memc new file +0 -0
new file mode 100644
index 000000000000..2bf0f58e412c

Documentation/ABI/testing/sysfs-platform-brcmstb-memc line 1

Quoted 1 line
Documentation/ABI/testing/sysfs-platform-brcmstb-memc new file +1 -0
@@ -0,0 +1,15 @@
+What:		/sys/devices/platform/*/*/*/*/srpd

That's a lot of */. Are you sure it is correct path? Didn't you include here some driver-related path components? Can you paste in email full path as an example?

Documentation/ABI/testing/sysfs-platform-brcmstb-memc line 8

Quoted 7 lines
Documentation/ABI/testing/sysfs-platform-brcmstb-memc new file +7 -0
+Date:		July 2022
+KernelVersion:	5.21
+Contact:	Florian Fainelli <[email protected]>
+Description:
+		Self Refresh Power Down (SRPD) inactivity timeout counted in
+		internal DDR controller clock cycles. Possible values range
+		from 0 (disable inactivity timeout) to 65535 (0xffff).

Using hex suggests one should write there hex? If so, skip decimal... You describe the user interface, not hardware registers.

Documentation/ABI/testing/sysfs-platform-brcmstb-memc line 15

Quoted 7 lines
Documentation/ABI/testing/sysfs-platform-brcmstb-memc new file +7 -0
+
+What:		/sys/devices/platform/*/*/*/*/frequency
+Date:		July 2022
+KernelVersion:	5.21
+Contact:	Florian Fainelli <[email protected]>
+Description:
+		DDR PHY frequency in Hz.

Best regards,
Krzysztof

#6 lore raw

Re: [PATCH v2 2/3] Documentation: sysfs: Document Broadcom STB memc sysfs knobs

Quoted 10 lines · Krzysztof Kozlowski
Quoted 9 lines · Florian Fainelli

Document the "srpd" and "frequency" sysfs attributes exposed by the brcmstb_memc driver.

---
 .../ABI/testing/sysfs-platform-brcmstb-memc       | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-brcmstb-memc
Quoted 11 lines

Documentation/ABI/testing/sysfs-platform-brcmstb-memc line 1

Quoted 7 lines
Documentation/ABI/testing/sysfs-platform-brcmstb-memc new file +1 -0
new file mode 100644
index 000000000000..2bf0f58e412c
@@ -0,0 +1,15 @@
+What:		/sys/devices/platform/*/*/*/*/srpd

That's a lot of */. Are you sure it is correct path? Didn't you include here some driver-related path components? Can you paste in email full path as an example?

Yes this is the correct path:

/sys/devices/platform/rdb/rdb:memory_controllers/rdb:memory_controllers:memc@0/9902000.memc-ddr/

the 'rdb' node is our top level bus node, the 'rdb:memory_controllers' is an encapsulating node that groups all of the possible memory controllers in a system (there can be between 1 and 3), the rdb:memory_controllers@0 is the first of those memory controller and finally the 9902000.memc-ddr is the sub-node that contains the register controls of interest, since the memory controller aggregates different functions (arbitration, configuration, statistics, DDR PHY SHIM layer, etc.). Maybe I should provide a more complete binding while I am it.

Quoted 11 lines

Documentation/ABI/testing/sysfs-platform-brcmstb-memc line 8

Quoted 8 lines
Documentation/ABI/testing/sysfs-platform-brcmstb-memc new file +7 -0
+Date:		July 2022
+KernelVersion:	5.21
+Contact:	Florian Fainelli <[email protected]>
+Description:
+		Self Refresh Power Down (SRPD) inactivity timeout counted in
+		internal DDR controller clock cycles. Possible values range
+		from 0 (disable inactivity timeout) to 65535 (0xffff).

Using hex suggests one should write there hex? If so, skip decimal... You describe the user interface, not hardware registers.

Fair enough.

Signature · 1 line
Florian
#7 lore raw

Re: [PATCH v2 2/3] Documentation: sysfs: Document Broadcom STB memc sysfs knobs

Quoted 23 lines · Florian Fainelli
Quoted 10 lines · Krzysztof Kozlowski
Quoted 9 lines · Florian Fainelli

Document the "srpd" and "frequency" sysfs attributes exposed by the brcmstb_memc driver.

---
 .../ABI/testing/sysfs-platform-brcmstb-memc       | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-brcmstb-memc
Quoted 11 lines

Documentation/ABI/testing/sysfs-platform-brcmstb-memc line 1

Quoted 7 lines
Documentation/ABI/testing/sysfs-platform-brcmstb-memc new file +1 -0
new file mode 100644
index 000000000000..2bf0f58e412c
@@ -0,0 +1,15 @@
+What:		/sys/devices/platform/*/*/*/*/srpd

That's a lot of */. Are you sure it is correct path? Didn't you include here some driver-related path components? Can you paste in email full path as an example?

Quoted 5 lines

Yes this is the correct path:

/sys/devices/platform/rdb/rdb:memory_controllers/rdb:memory_controllers:memc@0/9902000.memc-ddr/

the 'rdb' node is our top level bus node, the 'rdb:memory_controllers' is an encapsulating node that groups all of the possible memory controllers in a system (there can be between 1 and 3), the rdb:memory_controllers@0 is the first of those memory controller and finally the 9902000.memc-ddr is the sub-node that contains the register controls of interest, since the memory controller aggregates different functions (arbitration, configuration, statistics, DDR PHY SHIM layer, etc.). Maybe I should provide a more complete binding while I am it.

The path should be much more specific so include at least:
rdb/rdb:memory_controllers/rdb:memory_controllers:memc@*/ (or some variations of it if pieces of name change)

However looking at the driver, this is regular platform driver, thus it will appear as:
/sys/bus/platform/9902000.memc-ddr

Best regards,
Krzysztof

maintainer
#8 lore raw

Re: [PATCH v2 2/3] Documentation: sysfs: Document Broadcom STB memc sysfs knobs

Quoted 30 lines · Krzysztof Kozlowski
Quoted 23 lines · Florian Fainelli
Quoted 10 lines · Krzysztof Kozlowski
Quoted 9 lines · Florian Fainelli

Document the "srpd" and "frequency" sysfs attributes exposed by the brcmstb_memc driver.

---
 .../ABI/testing/sysfs-platform-brcmstb-memc       | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-brcmstb-memc
Quoted 11 lines

Documentation/ABI/testing/sysfs-platform-brcmstb-memc line 1

Quoted 7 lines
Documentation/ABI/testing/sysfs-platform-brcmstb-memc new file +1 -0
new file mode 100644
index 000000000000..2bf0f58e412c
@@ -0,0 +1,15 @@
+What:		/sys/devices/platform/*/*/*/*/srpd

That's a lot of */. Are you sure it is correct path? Didn't you include here some driver-related path components? Can you paste in email full path as an example?

Quoted 5 lines

Yes this is the correct path:

/sys/devices/platform/rdb/rdb:memory_controllers/rdb:memory_controllers:memc@0/9902000.memc-ddr/

the 'rdb' node is our top level bus node, the 'rdb:memory_controllers' is an encapsulating node that groups all of the possible memory controllers in a system (there can be between 1 and 3), the rdb:memory_controllers@0 is the first of those memory controller and finally the 9902000.memc-ddr is the sub-node that contains the register controls of interest, since the memory controller aggregates different functions (arbitration, configuration, statistics, DDR PHY SHIM layer, etc.). Maybe I should provide a more complete binding while I am it.

Quoted 7 lines

The path should be much more specific so include at least:
rdb/rdb:memory_controllers/rdb:memory_controllers:memc@*/ (or some variations of it if pieces of name change)

However looking at the driver, this is regular platform driver, thus it will appear as:
/sys/bus/platform/9902000.memc-ddr

There is a missing /devices in the path, but yet that will work too:

/sys/bus/platform/devices/9902000.memc-ddr

Thanks!

Signature · 1 line
Florian
#9 lore raw

PATCH v2 3/3 memory: Add Broadcom STB memory controller driver

In reply to Florian Fainelli

Add support for configuring the Self Refresh Power Down (SRPD) inactivity timeout on Broadcom STB chips. This is used to conserve power when the DRAM activity is reduced.

---
 drivers/memory/Kconfig        |   9 +
 drivers/memory/Makefile       |   1 +
 drivers/memory/brcmstb_memc.c | 302 ++++++++++++++++++++++++++++++++++
 3 files changed, 312 insertions(+)
 create mode 100644 drivers/memory/brcmstb_memc.c
drivers/memory/Kconfig +9 -0
index ac1a411648d8..fac290e48e0b 100644
@@ -66,6 +66,15 @@ config BRCMSTB_DPFE
 	  for the DRAM's temperature. Slower refresh rate means cooler RAM,
 	  higher refresh rate means hotter RAM.
 
+config BRCMSTB_MEMC
+	tristate "Broadcom STB MEMC driver"
+	default ARCH_BRCMSTB
+	depends on ARCH_BRCMSTB || COMPILE_TEST
+	help
+	  This driver provides a way to configure the Broadcom STB memory
+	  controller and specifically control the Self Refresh Power Down
+	  (SRPD) inactivity timeout.
+
 config BT1_L2_CTL
 	bool "Baikal-T1 CM2 L2-RAM Cache Control Block"
 	depends on MIPS_BAIKAL_T1 || COMPILE_TEST
drivers/memory/Makefile +1 -0
index bc7663ed1c25..e148f636c082 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_ARM_PL172_MPMC)	+= pl172.o
 obj-$(CONFIG_ATMEL_SDRAMC)	+= atmel-sdramc.o
 obj-$(CONFIG_ATMEL_EBI)		+= atmel-ebi.o
 obj-$(CONFIG_BRCMSTB_DPFE)	+= brcmstb_dpfe.o
+obj-$(CONFIG_BRCMSTB_MEMC)	+= brcmstb_memc.o
 obj-$(CONFIG_BT1_L2_CTL)	+= bt1-l2-ctl.o
 obj-$(CONFIG_TI_AEMIF)		+= ti-aemif.o
 obj-$(CONFIG_TI_EMIF)		+= emif.o
drivers/memory/brcmstb_memc.c new file +302 -0

302 lines not on this page · raw message

Signature · 1 line
2.25.1