mbox series

[v2,0/3] Add Broadcom STB memory controller driver

Message ID 20220722201043.2731570-1-f.fainelli@gmail.com
Headers show
Series Add Broadcom STB memory controller driver | expand

Message

Florian Fainelli July 22, 2022, 8:10 p.m. UTC
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

Comments

Krzysztof Kozlowski July 23, 2022, 5:59 p.m. UTC | #1
On 22/07/2022 22:10, Florian Fainelli wrote:
> Document the "srpd" and "frequency" sysfs attributes exposed by
> the brcmstb_memc driver.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  .../ABI/testing/sysfs-platform-brcmstb-memc       | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>  create mode 100644 Documentation/ABI/testing/sysfs-platform-brcmstb-memc
> 
> diff --git a/Documentation/ABI/testing/sysfs-platform-brcmstb-memc b/Documentation/ABI/testing/sysfs-platform-brcmstb-memc
> new file mode 100644
> index 000000000000..2bf0f58e412c
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-platform-brcmstb-memc
> @@ -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?

> +Date:		July 2022
> +KernelVersion:	5.21
> +Contact:	Florian Fainelli <f.fainelli@gmail.com>
> +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.

> +
> +What:		/sys/devices/platform/*/*/*/*/frequency
> +Date:		July 2022
> +KernelVersion:	5.21
> +Contact:	Florian Fainelli <f.fainelli@gmail.com>
> +Description:
> +		DDR PHY frequency in Hz.


Best regards,
Krzysztof
Florian Fainelli July 25, 2022, 4:07 p.m. UTC | #2
On 7/23/22 10:59, Krzysztof Kozlowski wrote:
> On 22/07/2022 22:10, Florian Fainelli wrote:
>> Document the "srpd" and "frequency" sysfs attributes exposed by
>> the brcmstb_memc driver.
>>
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>> ---
>>  .../ABI/testing/sysfs-platform-brcmstb-memc       | 15 +++++++++++++++
>>  1 file changed, 15 insertions(+)
>>  create mode 100644 Documentation/ABI/testing/sysfs-platform-brcmstb-memc
>>
>> diff --git a/Documentation/ABI/testing/sysfs-platform-brcmstb-memc b/Documentation/ABI/testing/sysfs-platform-brcmstb-memc
>> new file mode 100644
>> index 000000000000..2bf0f58e412c
>> --- /dev/null
>> +++ b/Documentation/ABI/testing/sysfs-platform-brcmstb-memc
>> @@ -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.

> 
>> +Date:		July 2022
>> +KernelVersion:	5.21
>> +Contact:	Florian Fainelli <f.fainelli@gmail.com>
>> +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.
Krzysztof Kozlowski July 26, 2022, 9:34 a.m. UTC | #3
On 25/07/2022 18:07, Florian Fainelli wrote:
> On 7/23/22 10:59, Krzysztof Kozlowski wrote:
>> On 22/07/2022 22:10, Florian Fainelli wrote:
>>> Document the "srpd" and "frequency" sysfs attributes exposed by
>>> the brcmstb_memc driver.
>>>
>>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>>> ---
>>>  .../ABI/testing/sysfs-platform-brcmstb-memc       | 15 +++++++++++++++
>>>  1 file changed, 15 insertions(+)
>>>  create mode 100644 Documentation/ABI/testing/sysfs-platform-brcmstb-memc
>>>
>>> diff --git a/Documentation/ABI/testing/sysfs-platform-brcmstb-memc b/Documentation/ABI/testing/sysfs-platform-brcmstb-memc
>>> new file mode 100644
>>> index 000000000000..2bf0f58e412c
>>> --- /dev/null
>>> +++ b/Documentation/ABI/testing/sysfs-platform-brcmstb-memc
>>> @@ -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.

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
Florian Fainelli July 26, 2022, 5:27 p.m. UTC | #4
On 7/26/22 02:34, Krzysztof Kozlowski wrote:
> On 25/07/2022 18:07, Florian Fainelli wrote:
>> On 7/23/22 10:59, Krzysztof Kozlowski wrote:
>>> On 22/07/2022 22:10, Florian Fainelli wrote:
>>>> Document the "srpd" and "frequency" sysfs attributes exposed by
>>>> the brcmstb_memc driver.
>>>>
>>>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>>>> ---
>>>>  .../ABI/testing/sysfs-platform-brcmstb-memc       | 15 +++++++++++++++
>>>>  1 file changed, 15 insertions(+)
>>>>  create mode 100644 Documentation/ABI/testing/sysfs-platform-brcmstb-memc
>>>>
>>>> diff --git a/Documentation/ABI/testing/sysfs-platform-brcmstb-memc b/Documentation/ABI/testing/sysfs-platform-brcmstb-memc
>>>> new file mode 100644
>>>> index 000000000000..2bf0f58e412c
>>>> --- /dev/null
>>>> +++ b/Documentation/ABI/testing/sysfs-platform-brcmstb-memc
>>>> @@ -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.
> 
> 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!