Broadcom STB AVS CPUfreq driver
Subsystems (4)
v5 cover Broadcom STB AVS CPUfreq driver
From: Markus Mayer <[email protected]>
This series contains the CPUfreq driver for Broadcom SoCs that use "AVS Firmware" for voltage and frequency scaling. All voltage and frequency transitions are performed by the firmware and are therefore hidden from Linux.
The driver provides a standard CPUfreq interface to other kernel components and to userland on the one hand and communicates with the AVS co-processor on the other.
Communication between the two processors is via shared mailbox registers and interrupts (ARM -> AVS to tell the firmware that there is a command to process and AVS -> ARM to tell the driver that a command finished executing).
Changes from v4:
- Addressed comments regarding the binding document (see also
https://lkml.org/lkml/2016/10/19/642)
- Added Virsh's Acks
- Rebased on v4.9-rc1
- Patches sent from non-Broadcom account on purpose to prevent series from being marked as spam (this is currently happening for some recipients)
- No changes to any code
Changes from v3:
- moved code from brcm_avs_cpufreq_exit() into brcm_avs_cpufreq_remove()
- removed brcm_avs_cpufreq_exit() altogether
Changes from v2:
- removed file Documentation/cpu-freq/brcmstb-avs-cpufreq.txt, instead adding the text as comment in the driver itself
- wildcard match in MAINTAINERS file (drivers/cpufreq/brcmstb*)
- drivers/cpufreq/Kconfig.arm: have ARM_BRCMSTB_AVS_CPUFREQ default y for ARCH_BRCMSTB
- fixed naming and Kconfig entry for CONFIG_ARM_BRCMSTB_AVS_CPUFREQ_DEBUG
- reordered and fixed include files
- made sure driver name doesn't exceed size of cpufreq_driver.name
- got rid of device_node pointers in struct private_data; there's no need for them, as we can call of_node_put() in __map_region()
- don't set driver_data for CPUFREQ_TABLE_END
- have brcm_avs_cpufreq_get() read from the firmware rather than return policy->cur
- don't update policy->cur in brcm_avs_target_index()
- created new function brcm_avs_prepare_init() to handle compatibility checks during initialization and moved corresponding code from brcm_avs_cpufreq_init() to the new function
- brcm_avs_prepare_init() is called from brcm_avs_cpufreq_probe() and therefore will only be called once, even in the case of an error, whereas brcm_avs_cpufreq_init() is called for every core if there is an error
- renamed brcm_avs_cpu_(init|exit) to brcm_avs_cpufreq_(init|exit)
- added platform_set_drvdata(pdev, NULL) upon deregistration
- fixed various style complaints by checkpatch.pl --strict
- fixed other style issues
- updated and improved some comments
- added Viresh's Acks to patches 1/3 and 3/3
Changes from v1:
- renamed binding document
- rewrote the introduction of the binding document
- created a new driver documentation file that contains Linux specific information that was previously part of the binding document
- renamed the driver (and related config options) to include a reference to "STB", since this implementation is primarily intended for use on set-top boxes
- improved comments
- updated function __map_region()
- updated struct private_data
- added code to unmap memory regions in the error and exit paths
- added new sysfs property to report frequency directly from the co-processor register
Markus Mayer (3):
dt: cpufreq: brcm: New binding document for brcmstb-avs-cpufreq
cpufreq: brcmstb-avs-cpufreq: AVS CPUfreq driver for Broadcom STB SoCs
cpufreq: brcmstb-avs-cpufreq: add debugfs support
.../bindings/cpufreq/brcm,stb-avs-cpu-freq.txt | 78 ++ MAINTAINERS | 8 + drivers/cpufreq/Kconfig.arm | 21 + drivers/cpufreq/Makefile | 1 + drivers/cpufreq/brcmstb-avs-cpufreq.c | 1057 ++++++++++++++++++++ 5 files changed, 1165 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/brcm,stb-avs-cpu-freq.txt create mode 100644 drivers/cpufreq/brcmstb-avs-cpufreq.c
Signature · 1 line
2.7.4
PATCH v5 1/3 dt: cpufreq: brcm: New binding document for brcmstb-avs-cpufreq
From: Markus Mayer <[email protected]>
Add the binding document for the new brcmstb-avs-cpufreq driver.
--- .../bindings/cpufreq/brcm,stb-avs-cpu-freq.txt | 78 ++++++++++++++++++++++ MAINTAINERS | 7 ++ 2 files changed, 85 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/brcm,stb-avs-cpu-freq.txt
Documentation/devicetree/bindings/cpufreq/brcm,stb-avs-cpu-freq.txt new file +78 -0
@@ -0,0 +1,78 @@ +Broadcom AVS mail box and interrupt register bindings +===================================================== + +A total of three DT nodes are required. One node (brcm,avs-cpu-data-mem) +references the mailbox register used to communicate with the AVS CPU[1]. The +second node (brcm,avs-cpu-l2-intr) is required to trigger an interrupt on +the AVS CPU. The interrupt tells the AVS CPU that it needs to process a +command sent to it by a driver. Interrupting the AVS CPU is mandatory for +commands to be processed. + +The interface also requires a reference to the AVS host interrupt controller, +so a driver can react to interrupts generated by the AVS CPU whenever a command +has been processed. See [2] for more information on the brcm,l2-intc node. + +[1] The AVS CPU is an independent co-processor that runs proprietary +firmware. On some SoCs, this firmware supports DFS and DVFS in addition to +Adaptive Voltage Scaling. + +[2] Documentation/devicetree/bindings/interrupt-controller/brcm,l2-intc.txt + + +Node brcm,avs-cpu-data-mem +-------------------------- + +Required properties: +- compatible: must include: brcm,avs-cpu-data-mem and + should include: one of brcm,bcm7271-avs-cpu-data-mem or + brcm,bcm7268-avs-cpu-data-mem +- reg: Specifies base physical address and size of the registers. +- interrupts: The interrupt that the AVS CPU will use to interrupt the host + when a command completed. +- interrupt-parent: The interrupt controller the above interrupt is routed + through. +- interrupt-names: The name of the interrupt used to interrupt the host. + +Optional properties: +- None + +Node brcm,avs-cpu-l2-intr +------------------------- + +Required properties: +- compatible: must include: brcm,avs-cpu-l2-intr and + should include: one of brcm,bcm7271-avs-cpu-l2-intr or + brcm,bcm7268-avs-cpu-l2-intr +- reg: Specifies base physical address and size of the registers. + +Optional properties: +- None + + +Example +======= + + avs_host_l2_intc: interrupt-controller@f04d1200 { + #interrupt-cells = <1>; + compatible = "brcm,l2-intc"; + interrupt-parent = <&intc>; + reg = <0xf04d1200 0x48>; + interrupt-controller; + interrupts = <0x0 0x19 0x0>; + interrupt-names = "avs"; + }; + + avs-cpu-data-mem@f04c4000 { + compatible = "brcm,bcm7271-avs-cpu-data-mem", + "brcm,avs-cpu-data-mem"; + reg = <0xf04c4000 0x60>; + interrupts = <0x1a>; + interrupt-parent = <&avs_host_l2_intc>; + interrupt-names = "sw_intr"; + }; + + avs-cpu-l2-intr@f04d1100 { + compatible = "brcm,bcm7271-avs-cpu-l2-intr", + "brcm,avs-cpu-l2-intr"; + reg = <0xf04d1100 0x10>; + };
MAINTAINERS +7 -0
@@ -2738,6 +2738,13 @@ L: [email protected] S: Maintained F: drivers/mtd/nand/brcmnand/ +BROADCOM STB AVS CPUFREQ DRIVER +M: Markus Mayer <[email protected]> +M: [email protected] +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/cpufreq/brcm,stb-avs-cpu-freq.txt + BROADCOM SPECIFIC AMBA DRIVER (BCMA) M: Rafał Miłecki <[email protected]> L: [email protected]
Signature · 1 line
2.7.4
Re: [PATCH v5 1/3] dt: cpufreq: brcm: New binding document for brcmstb-avs-cpufreq
Quoted 11 lines · Markus Mayer
From: Markus Mayer <[email protected]>
Add the binding document for the new brcmstb-avs-cpufreq driver.
Signed-off-by Markus Mayer <[email protected]>Acked-by Viresh Kumar <[email protected]>--- .../bindings/cpufreq/brcm,stb-avs-cpu-freq.txt | 78 ++++++++++++++++++++++ MAINTAINERS | 7 ++ 2 files changed, 85 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/brcm,stb-avs-cpu-freq.txt
I guess if one of the nodes is used elsewhere, combining the nodes doesn't make sense. So:
Re: [PATCH v5 1/3] dt: cpufreq: brcm: New binding document for brcmstb-avs-cpufreq
Quoted 13 lines · Rob Herring
Quoted 11 lines · Markus Mayer
From: Markus Mayer <[email protected]>
Add the binding document for the new brcmstb-avs-cpufreq driver.
Signed-off-by Markus Mayer <[email protected]>Acked-by Viresh Kumar <[email protected]>--- .../bindings/cpufreq/brcm,stb-avs-cpu-freq.txt | 78 ++++++++++++++++++++++ MAINTAINERS | 7 ++ 2 files changed, 85 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/brcm,stb-avs-cpu-freq.txt
Quoted 4 lines
I guess if one of the nodes is used elsewhere, combining the nodes doesn't make sense. So:
Acked-by Rob Herring <[email protected]>
Thanks, Rob.
The series, with Acks added, is also available here:
https://github.com/mmayer/linux/tree/upstream-avs-cpufreq-4.9-v5
Regards,
-Markus
PATCH v5 2/3 cpufreq: brcmstb-avs-cpufreq: AVS CPUfreq driver for Broadcom STB SoCs
In reply to Markus MayerFrom: Markus Mayer <[email protected]>
This driver supports voltage and frequency scaling on Broadcom STB SoCs using AVS firmware with DFS and DVFS support.
Actual frequency or voltage scaling is done exclusively by the AVS firmware. The driver merely provides a standard CPUfreq interface to other kernel components and userland, and instructs the AVS firmware to perform frequency or voltage changes on its behalf.
--- MAINTAINERS | 1 + drivers/cpufreq/Kconfig.arm | 11 + drivers/cpufreq/Makefile | 1 + drivers/cpufreq/brcmstb-avs-cpufreq.c | 736 ++++++++++++++++++++++++++++++++++ 4 files changed, 749 insertions(+) create mode 100644 drivers/cpufreq/brcmstb-avs-cpufreq.c
MAINTAINERS +1 -0
@@ -2744,6 +2744,7 @@ M: [email protected] L: [email protected] S: Maintained F: Documentation/devicetree/bindings/cpufreq/brcm,stb-avs-cpu-freq.txt +F: drivers/cpufreq/brcmstb* BROADCOM SPECIFIC AMBA DRIVER (BCMA) M: Rafał Miłecki <[email protected]>
drivers/cpufreq/Kconfig.arm +11 -0
@@ -12,6 +12,17 @@ config ARM_BIG_LITTLE_CPUFREQ help This enables the Generic CPUfreq driver for ARM big.LITTLE platforms. +config ARM_BRCMSTB_AVS_CPUFREQ + tristate "Broadcom STB AVS CPUfreq driver" + depends on ARCH_BRCMSTB || COMPILE_TEST + default y + help + Some Broadcom STB SoCs use a co-processor running proprietary firmware + ("AVS") to handle voltage and frequency scaling. This driver provides + a standard CPUfreq interface to to the firmware. + + Say Y, if you have a Broadcom SoC with AVS support for DFS or DVFS. + config ARM_DT_BL_CPUFREQ tristate "Generic probing via DT for ARM big LITTLE CPUfreq driver" depends on ARM_BIG_LITTLE_CPUFREQ && OF
drivers/cpufreq/Makefile +1 -0
@@ -51,6 +51,7 @@ obj-$(CONFIG_ARM_BIG_LITTLE_CPUFREQ) += arm_big_little.o # LITTLE drivers, so that it is probed last. obj-$(CONFIG_ARM_DT_BL_CPUFREQ) += arm_big_little_dt.o +obj-$(CONFIG_ARM_BRCMSTB_AVS_CPUFREQ) += brcmstb-avs-cpufreq.o obj-$(CONFIG_ARCH_DAVINCI) += davinci-cpufreq.o obj-$(CONFIG_UX500_SOC_DB8500) += dbx500-cpufreq.o obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ) += exynos5440-cpufreq.o
drivers/cpufreq/brcmstb-avs-cpufreq.c new file +736 -0
736 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v5 3/3 cpufreq: brcmstb-avs-cpufreq: add debugfs support
In reply to Markus MayerFrom: Markus Mayer <[email protected]>
In order to aid debugging, we add a debugfs interface to the driver that allows direct interaction with the AVS co-processor.
The debugfs interface provides a means for reading all and writing some of the mailbox registers directly from the shell prompt and enables a user to execute the communications protocol between ARM CPU and AVS CPU step-by-step.
This interface should be used for debugging purposes only.
--- drivers/cpufreq/Kconfig.arm | 10 ++ drivers/cpufreq/brcmstb-avs-cpufreq.c | 323 +++++++++++++++++++++++++++++++++- 2 files changed, 332 insertions(+), 1 deletion(-)
drivers/cpufreq/Kconfig.arm +10 -0
@@ -23,6 +23,16 @@ config ARM_BRCMSTB_AVS_CPUFREQ Say Y, if you have a Broadcom SoC with AVS support for DFS or DVFS. +config ARM_BRCMSTB_AVS_CPUFREQ_DEBUG + bool "Broadcom STB AVS CPUfreq driver sysfs debug capability" + depends on ARM_BRCMSTB_AVS_CPUFREQ + help + Enabling this option turns on debug support via sysfs under + /sys/kernel/debug/brcmstb-avs-cpufreq. It is possible to read all and + write some AVS mailbox registers through sysfs entries. + + If in doubt, say N. + config ARM_DT_BL_CPUFREQ tristate "Generic probing via DT for ARM big LITTLE CPUfreq driver" depends on ARM_BIG_LITTLE_CPUFREQ && OF
drivers/cpufreq/brcmstb-avs-cpufreq.c +322 -1
359 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 7 lines · Markus Mayer
From: Markus Mayer <[email protected]>
This series contains the CPUfreq driver for Broadcom SoCs that use "AVS Firmware" for voltage and frequency scaling. All voltage and frequency transitions are performed by the firmware and are therefore hidden from Linux.
Quoted 8 lines
The driver provides a standard CPUfreq interface to other kernel components and to userland on the one hand and communicates with the AVS co-processor on the other.
Communication between the two processors is via shared mailbox registers and interrupts (ARM -> AVS to tell the firmware that there is a command to process and AVS -> ARM to tell the driver that a command finished executing).
Viresh, Rafael, are you ready to take this series? Rob gave his Ack for the DT binding.
You can pull from [1] if you prefer. The branch already has all the Acks.
Thanks,
-Markus
[1] https://github.com/mmayer/linux/commits/upstream-avs-cpufreq-4.9-v5
Quoted 75 lines
Changes from v4:
- Addressed comments regarding the binding document (see also
https://lkml.org/lkml/2016/10/19/642)
- Added Virsh's Acks
- Rebased on v4.9-rc1
- Patches sent from non-Broadcom account on purpose to prevent series from being marked as spam (this is currently happening for some recipients)
- No changes to any codeChanges from v3:
- moved code frombrcm_avs_cpufreq_exit()intobrcm_avs_cpufreq_remove()
- removedbrcm_avs_cpufreq_exit()altogetherChanges from v2:
- removed fileDocumentation/cpu-freq/brcmstb-avs-cpufreq.txt, instead adding the text as comment in the driver itself
- wildcard match inMAINTAINERSfile (drivers/cpufreq/brcmstb*)
-drivers/cpufreq/Kconfig.arm: haveARM_BRCMSTB_AVS_CPUFREQdefault y forARCH_BRCMSTB
- fixed naming andKconfigentry forCONFIG_ARM_BRCMSTB_AVS_CPUFREQ_DEBUG
- reordered and fixed include files
- made sure driver name doesn't exceed size of cpufreq_driver.name
- got rid ofdevice_nodepointers in structprivate_data; there's no need for them, as we can callof_node_put()in__map_region()
- don't setdriver_dataforCPUFREQ_TABLE_END
- havebrcm_avs_cpufreq_get()read from the firmware rather than returnpolicy->cur
- don't updatepolicy->curinbrcm_avs_target_index()
- created new functionbrcm_avs_prepare_init()to handle compatibility checks during initialization and moved corresponding code frombrcm_avs_cpufreq_init()to the new function
-brcm_avs_prepare_init()is called frombrcm_avs_cpufreq_probe()and therefore will only be called once, even in the case of an error, whereasbrcm_avs_cpufreq_init()is called for every core if there is an error
- renamedbrcm_avs_cpu_(init|exit)tobrcm_avs_cpufreq_(init|exit)
- addedplatform_set_drvdata(pdev, NULL)upon deregistration
- fixed various style complaints by checkpatch.pl --strict
- fixed other style issues
- updated and improved some comments
- added Viresh's Acks to patches 1/3 and 3/3Changes from v1:
- renamed binding document
- rewrote the introduction of the binding document
- created a new driver documentation file that contains Linux specific information that was previously part of the binding document
- renamed the driver (and related config options) to include a reference to "STB", since this implementation is primarily intended for use on set-top boxes
- improved comments
- updated function__map_region()
- updated structprivate_data
- added code to unmap memory regions in the error and exit paths
- added new sysfs property to report frequency directly from the co-processor registerMarkus Mayer (3):
dt: cpufreq: brcm: New binding document for brcmstb-avs-cpufreq
cpufreq: brcmstb-avs-cpufreq: AVS CPUfreq driver for Broadcom STB SoCs
cpufreq: brcmstb-avs-cpufreq: add debugfs support.../bindings/cpufreq/brcm,stb-avs-cpu-freq.txt | 78 ++ MAINTAINERS | 8 + drivers/cpufreq/Kconfig.arm | 21 + drivers/cpufreq/Makefile | 1 + drivers/cpufreq/brcmstb-avs-cpufreq.c | 1057 ++++++++++++++++++++ 5 files changed, 1165 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/brcm,stb-avs-cpu-freq.txt create mode 100644 drivers/cpufreq/brcmstb-avs-cpufreq.c--
2.7.4
Rafael J. Wysocki
AppliedQuoted 12 lines · Markus Mayer
Quoted 11 lines · Markus Mayer
From: Markus Mayer <[email protected]>
This series contains the CPUfreq driver for Broadcom SoCs that use "AVS Firmware" for voltage and frequency scaling. All voltage and frequency transitions are performed by the firmware and are therefore hidden from Linux.
The driver provides a standard CPUfreq interface to other kernel components and to userland on the one hand and communicates with the AVS co-processor on the other.
Quoted 7 lines
Quoted 4 lines
Communication between the two processors is via shared mailbox registers and interrupts (ARM -> AVS to tell the firmware that there is a command to process and AVS -> ARM to tell the driver that a command finished executing).
Viresh, Rafael, are you ready to take this series? Rob gave his Ack for the DT binding.
Applied.
Thanks,
Rafael