dt/bindings: Add binding for the Raspberry Pi clock provider
Subsystems (4)
PATCH v3 1/7 dt/bindings: Add binding for the Raspberry Pi clock provider
The hardware clocks are not controllable by the ARM, so we have to make requests to the firmware to do so from the VPU side. This will let us replace fixed clocks in our DT with actual clock control (and correct frequency information).
v2: Include the dt-bindings header in this commit instead of the next
one. Make the clock indices match the firmware clock IDs. Rename the binding's compat string. Move the firmware phandle to be under a vendor-specific namespace.
--- .../clock/raspberrypi,bcm2835-firmware-clocks.txt | 25 ++++++++++++++++++++++ include/dt-bindings/clk/raspberrypi.h | 23 ++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt create mode 100644 include/dt-bindings/clk/raspberrypi.h
Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt new file +25 -0
@@ -0,0 +1,25 @@ +Raspberry Pi firmware clock provider. + +The Raspberry Pi architecture doesn't provide direct access to the +CLOCKMAN peripheral from the ARM side, so Linux has to make requests +to the VPU firmware to program them. + +This binding uses the common clock binding: +Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible: Should be "raspberrypi,bcm2835-firmware-clocks" + +- #clock-cells: Shall have value <1>. The permitted clock-specifier + values can be found in + include/dt-bindings/clk/raspberrypi.h. + +- raspberrypi,firmware: Phandle to the firmware driver node. + +Example: + +firmware_clocks: firmware-clocks { + compatible = "raspberrypi,bcm2835-firmware-clocks"; + #clock-cells = <1>; + raspberrypi,firmware = <&firmware>; +};
include/dt-bindings/clk/raspberrypi.h new file +23 -0
@@ -0,0 +1,23 @@ +#/* +* Copyright ? 2015 Broadcom +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _DT_BINDINGS_CLK_RASPBERRYPI_H +#define _DT_BINDINGS_CLK_RASPBERRYPI_H + +#define RPI_CLOCK_EMMC 1 +#define RPI_CLOCK_UART0 2 +#define RPI_CLOCK_ARM 3 +#define RPI_CLOCK_CORE 4 +#define RPI_CLOCK_V3D 5 +#define RPI_CLOCK_H264 6 +#define RPI_CLOCK_ISP 7 +#define RPI_CLOCK_SDRAM 8 +#define RPI_CLOCK_PIXEL 9 +#define RPI_CLOCK_PWM 10 + +#endif
Signature · 1 line
2.1.4
PATCH v3 2/7 ARM: bcm2835: Add a Raspberry Pi-specific clock driver.
Unfortunately, the clock manager's registers are not accessible by the ARM, so we have to request that the firmware modify our clocks for us.
This driver only registers the clocks at the point they are requested by a client driver. This is partially to support returning -EPROBE_DEFER when the firmware driver isn't supported yet, but it also avoids issues with disabling "unused" clocks due to them not yet being connected to their consumers in the DT.
v2: Declare the mutex static (from review by Baruch Siach), merge
description and copyright comments.
v3: Update for new rpi firmware API. Update the compatible string.
Make the firmware handle be under a vendor-namespaced property. Make the DT indices match the firmware clock IDs. Move the driver under the firmware driver's Kconfig, since it requires it. Move a container_of() from 2 callers into the callee.
--- drivers/clk/Makefile | 1 + drivers/clk/clk-raspberrypi.c | 242 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 243 insertions(+) create mode 100644 drivers/clk/clk-raspberrypi.c
drivers/clk/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_MACH_ASM9260) += clk-asm9260.o obj-$(CONFIG_COMMON_CLK_AXI_CLKGEN) += clk-axi-clkgen.o obj-$(CONFIG_ARCH_AXXIA) += clk-axm5516.o obj-$(CONFIG_ARCH_BCM2835) += clk-bcm2835.o +obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += clk-raspberrypi.o obj-$(CONFIG_COMMON_CLK_CDCE706) += clk-cdce706.o obj-$(CONFIG_ARCH_CLPS711X) += clk-clps711x.o obj-$(CONFIG_ARCH_EFM32) += clk-efm32gg.o
drivers/clk/clk-raspberrypi.c new file +242 -0
242 lines not on this page · raw message
Signature · 1 line
2.1.4
Re: [PATCH v3 2/7] ARM: bcm2835: Add a Raspberry Pi-specific clock driver.
Quoted 10 lines · Eric Anholt
Unfortunately, the clock manager's registers are not accessible by the ARM, so we have to request that the firmware modify our clocks for us.
This driver only registers the clocks at the point they are requested by a client driver. This is partially to support returning -EPROBE_DEFER when the firmware driver isn't supported yet, but it also avoids issues with disabling "unused" clocks due to them not yet being connected to their consumers in the DT.
drivers/clk/clk-raspberrypi.c line 85
Quoted 4 lines
drivers/clk/clk-raspberrypi.c +2
-0+static int rpi_clk_set_state (struct clk_hw *hw,bool on) + if (ret || (packet[1] & (1 << 1))) {
A #define for the shift amount would be nice, so that this statement was a bit more semantic.
Aside from that, the series,
Re: [PATCH v3 2/7] ARM: bcm2835: Add a Raspberry Pi-specific clock driver.
In reply to Eric AnholtQuoted 18 lines · Eric Anholt
Unfortunately, the clock manager's registers are not accessible by the ARM, so we have to request that the firmware modify our clocks for us.
This driver only registers the clocks at the point they are requested by a client driver. This is partially to support returning -EPROBE_DEFER when the firmware driver isn't supported yet, but it also avoids issues with disabling "unused" clocks due to them not yet being connected to their consumers in the DT.
v2: Declare the mutex static (from review by Baruch Siach), merge
description and copyright comments.v3: Update for new rpi firmware API. Update the compatible string.
Make the firmware handle be under a vendor-namespaced property. Make the DT indices match the firmware clock IDs. Move the driver under the firmware driver'sKconfig, since it requires it. Move acontainer_of()from 2 callers into the callee.
Quoted 4 lines
Signed-off-by Eric Anholt <[email protected]>--- drivers/clk/Makefile | 1 + drivers/clk/clk-raspberrypi.c | 242 ++++++++++++++++++++++++++++++++++++++++++
This is not an "ARM" patch.
The subject line needs to reflect the subsystem you are submitting to.
git log --oneline -- <subsystem>
PATCH v3 3/7 ARM: bcm2835: Add DT for the firmware clocks driver.
In reply to Eric Anholtv2: Rename our compat string to mention bcm2835, and make our firmware
phandle be under a vendor-namespaced property.
--- arch/arm/boot/dts/bcm2835-rpi.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/bcm2835-rpi.dtsi +6 -0
@@ -20,6 +20,12 @@ compatible = "raspberrypi,bcm2835-firmware"; mboxes = <&mailbox>; }; + + firmware_clocks: firmware-clocks { + compatible = "raspberrypi,bcm2835-firmware-clocks"; + #clock-cells = <1>; + raspberrypi,firmware = <&firmware>; + }; }; };
Signature · 1 line
2.1.4
PATCH v3 4/7 ARM: bcm2835: Drop never-used clock-frequency property of uart0.
In reply to Eric AnholtThis appears to have been copy-and-paste from another serial driver's DT. The driver has never used this value -- instead, the pl011 driver is getting the fixed 20201000.uart clock from clk-bcm2835.c.
--- arch/arm/boot/dts/bcm2835.dtsi | 1 - 1 file changed, 1 deletion(-)
arch/arm/boot/dts/bcm2835.dtsi +0 -1
@@ -96,7 +96,6 @@ compatible = "brcm,bcm2835-pl011", "arm,pl011", "arm,primecell"; reg = <0x7e201000 0x1000>; interrupts = <2 25>; - clock-frequency = <3000000>; arm,primecell-periphid = <0x00241011>; };
Signature · 1 line
2.1.4
PATCH v3 5/7 ARM: bcm2835: Drop the fixed sys_pclk.
In reply to Eric AnholtNothing uses it, and I can't find any evidence that anything ever has.
--- drivers/clk/clk-bcm2835.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/clk/clk-bcm2835.c +0 -5
@@ -32,11 +32,6 @@ void __init bcm2835_init_clocks(void)struct clk *clk;int ret; - clk =clk_register_fixed_rate (NULL ,"sys_pclk" ,NULL ,CLK_IS_ROOT , -250000000 ); -if (IS_ERR (clk)) -pr_err ("sys_pclk not registered\n" ); - clk =clk_register_fixed_rate (NULL ,"apb_pclk" ,NULL ,CLK_IS_ROOT ,126000000 );if (IS_ERR (clk))
Signature · 1 line
2.1.4
PATCH v3 6/7 ARM: bcm2835: Use the RPi firmware clocks for uart.
In reply to Eric AnholtThis gets us a correct apb_pclk, which previously was accidentally using the "20201000.uart" clock from clk-bcm2835.c, due to the fallback clk_get_sys() path.
--- arch/arm/boot/dts/bcm2835-rpi.dtsi | 7 +++++++ arch/arm/boot/dts/bcm2835.dtsi | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-)
arch/arm/boot/dts/bcm2835-rpi.dtsi +7 -0
@@ -1,3 +1,4 @@ +#include <dt-bindings/clk/raspberrypi.h> #include "bcm2835.dtsi" / {
@@ -62,3 +63,9 @@ status = "okay"; bus-width = <4>; }; + +&uart0 { + clocks = <&firmware_clocks RPI_CLOCK_UART0>, + <&firmware_clocks RPI_CLOCK_CORE>; + clock-names = "uartclk", "apb_pclk"; +};
arch/arm/boot/dts/bcm2835.dtsi +1 -1
@@ -92,7 +92,7 @@ #interrupt-cells = <2>; }; - uart at 7e201000 { + uart0: uart at 7e201000 { compatible = "brcm,bcm2835-pl011", "arm,pl011", "arm,primecell"; reg = <0x7e201000 0x1000>; interrupts = <2 25>;
Signature · 1 line
2.1.4
PATCH v3 7/7 ARM: bcm2835: Tie SPI clock to the core clock rate.
In reply to Eric AnholtWe were previously using a fixed clock declared in the 2835 DT, but it's actually the core clock, and it might not be the same if you had adjusted it using the firmware's config.txt.
--- arch/arm/boot/dts/bcm2835-rpi.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/bcm2835-rpi.dtsi +4 -0
@@ -69,3 +69,7 @@ <&firmware_clocks RPI_CLOCK_CORE>; clock-names = "uartclk", "apb_pclk"; }; + +&spi { + clocks = <&firmware_clocks RPI_CLOCK_CORE>; +};
Signature · 1 line
2.1.4
Quoted 9 lines · Eric Anholt
The hardware clocks are not controllable by the ARM, so we have to make requests to the firmware to do so from the VPU side. This will let us replace fixed clocks in our DT with actual clock control (and correct frequency information).
v2: Include the dt-bindings header in this commit instead of the next
one. Make the clock indices match the firmware clock IDs. Rename the binding's compat string. Move the firmware phandle to be under a vendor-specific namespace.
Having failed to move the versioning bits below --- again, I'm adding
scripting to hopefully catch myself if I'm about to do it again.
-------------- 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/20150608/a70f351f/attachment.sig>
If I were the Clock Maintainer, I would have probably missed this patch. You _must_ intimate which subsystem you are submitting to.
Quoted 31 lines
The hardware clocks are not controllable by the ARM, so we have to make requests to the firmware to do so from the VPU side. This will let us replace fixed clocks in our DT with actual clock control (and correct frequency information).
v2: Include the dt-bindings header in this commit instead of the next
one. Make the clock indices match the firmware clock IDs. Rename the binding's compat string. Move the firmware phandle to be under a vendor-specific namespace.Signed-off-by Eric Anholt <[email protected]>--- .../clock/raspberrypi,bcm2835-firmware-clocks.txt | 25 ++++++++++++++++++++++ include/dt-bindings/clk/raspberrypi.h | 23 ++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt create mode 100644 include/dt-bindings/clk/raspberrypi.hDocumentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt new file +7
-0@@ -0,0 +1,25 @@ +Raspberry Pi firmware clock provider. + +The Raspberry Pi architecture doesn't provide direct access to the +CLOCKMAN peripheral from the ARM side, so Linux has to make requests +to the VPU firmware to program them. + +This binding uses the common clock binding:
Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt line 17
Quoted 10 lines
Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt new file +10
-0+Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible: Should be "raspberrypi,bcm2835-firmware-clocks" + +- #clock-cells: Shall have value <1>. The permitted clock-specifier + values can be found in + include/dt-bindings/clk/raspberrypi.h. + +- raspberrypi,firmware: Phandle to the firmware driver node.
I think 'firmware' is a candidate for a generic phandle name.
Apart from that, binding looks pretty inert:
Quoted 36 lines
Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt new file +7
-0+Example: + +firmware_clocks: firmware-clocks { + compatible = "raspberrypi,bcm2835-firmware-clocks"; + #clock-cells = <1>; + raspberrypi,firmware = <&firmware>; +};include/dt-bindings/clk/raspberrypi.h new file +23
-0@@ -0,0 +1,23 @@ +#/* +* Copyright ? 2015 Broadcom +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _DT_BINDINGS_CLK_RASPBERRYPI_H +#define _DT_BINDINGS_CLK_RASPBERRYPI_H + +#define RPI_CLOCK_EMMC 1 +#define RPI_CLOCK_UART0 2 +#define RPI_CLOCK_ARM 3 +#define RPI_CLOCK_CORE 4 +#define RPI_CLOCK_V3D 5 +#define RPI_CLOCK_H264 6 +#define RPI_CLOCK_ISP 7 +#define RPI_CLOCK_SDRAM 8 +#define RPI_CLOCK_PIXEL 9 +#define RPI_CLOCK_PWM 10 + +#endif
Quoted 38 lines · Lee Jones
If I were the Clock Maintainer, I would have probably missed this patch. You _must_ intimate which subsystem you are submitting to.
Quoted 35 lines
The hardware clocks are not controllable by the ARM, so we have to make requests to the firmware to do so from the VPU side. This will let us replace fixed clocks in our DT with actual clock control (and correct frequency information).
v2: Include the dt-bindings header in this commit instead of the next
one. Make the clock indices match the firmware clock IDs. Rename the binding's compat string. Move the firmware phandle to be under a vendor-specific namespace.Signed-off-by Eric Anholt <[email protected]>--- .../clock/raspberrypi,bcm2835-firmware-clocks.txt | 25 ++++++++++++++++++++++ include/dt-bindings/clk/raspberrypi.h | 23 ++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt create mode 100644 include/dt-bindings/clk/raspberrypi.hDocumentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt new file +11
-0@@ -0,0 +1,25 @@ +Raspberry Pi firmware clock provider. + +The Raspberry Pi architecture doesn't provide direct access to the +CLOCKMAN peripheral from the ARM side, so Linux has to make requests +to the VPU firmware to program them. + +This binding uses the common clock binding: +Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible: Should be "raspberrypi,bcm2835-firmware-clocks"
Quoted 8 lines
Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt line 17
Quoted 6 lines
Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt new file +6
-0+ +- #clock-cells: Shall have value <1>. The permitted clock-specifier + values can be found in + include/dt-bindings/clk/raspberrypi.h. + +- raspberrypi,firmware: Phandle to the firmware driver node.I think 'firmware' is a candidate for a generic phandle name.
Stephen Warren asked in the last version that I change it from
"firmware" to "raspberrypi,firmware", which made sense to me since we're
not some core infrastructure using these references. Which should it
be?
-------------- 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/20150707/7c611a25/attachment.sig>
Quoted 49 lines · Eric Anholt
Quoted 38 lines · Lee Jones
If I were the Clock Maintainer, I would have probably missed this patch. You _must_ intimate which subsystem you are submitting to.
Quoted 35 lines
The hardware clocks are not controllable by the ARM, so we have to make requests to the firmware to do so from the VPU side. This will let us replace fixed clocks in our DT with actual clock control (and correct frequency information).
v2: Include the dt-bindings header in this commit instead of the next
one. Make the clock indices match the firmware clock IDs. Rename the binding's compat string. Move the firmware phandle to be under a vendor-specific namespace.Signed-off-by Eric Anholt <[email protected]>--- .../clock/raspberrypi,bcm2835-firmware-clocks.txt | 25 ++++++++++++++++++++++ include/dt-bindings/clk/raspberrypi.h | 23 ++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt create mode 100644 include/dt-bindings/clk/raspberrypi.hDocumentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt new file +11
-0@@ -0,0 +1,25 @@ +Raspberry Pi firmware clock provider. + +The Raspberry Pi architecture doesn't provide direct access to the +CLOCKMAN peripheral from the ARM side, so Linux has to make requests +to the VPU firmware to program them. + +This binding uses the common clock binding: +Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible: Should be "raspberrypi,bcm2835-firmware-clocks"Quoted 8 lines
Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt line 17
Quoted 6 lines
Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt new file +6
-0+ +- #clock-cells: Shall have value <1>. The permitted clock-specifier + values can be found in + include/dt-bindings/clk/raspberrypi.h. + +- raspberrypi,firmware: Phandle to the firmware driver node.I think 'firmware' is a candidate for a generic phandle name.
Quoted 4 lines
Stephen Warren asked in the last version that I change it from "firmware" to "raspberrypi,firmware", which made sense to me since we're not some core infrastructure using these references. Which should it be?
We tend to use vendor specific bindings when others are unlikely to make use of them. I would have thought that different vendors would also make use of a generic 'firmware' phandle. The final decision would probably be taken by the DT guys.
Quoted 56 lines · Lee Jones
Quoted 49 lines · Eric Anholt
Quoted 38 lines · Lee Jones
If I were the Clock Maintainer, I would have probably missed this patch. You _must_ intimate which subsystem you are submitting to.
Quoted 35 lines
The hardware clocks are not controllable by the ARM, so we have to make requests to the firmware to do so from the VPU side. This will let us replace fixed clocks in our DT with actual clock control (and correct frequency information).
v2: Include the dt-bindings header in this commit instead of the next
one. Make the clock indices match the firmware clock IDs. Rename the binding's compat string. Move the firmware phandle to be under a vendor-specific namespace.Signed-off-by Eric Anholt <[email protected]>--- .../clock/raspberrypi,bcm2835-firmware-clocks.txt | 25 ++++++++++++++++++++++ include/dt-bindings/clk/raspberrypi.h | 23 ++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt create mode 100644 include/dt-bindings/clk/raspberrypi.hDocumentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt new file +11
-0@@ -0,0 +1,25 @@ +Raspberry Pi firmware clock provider. + +The Raspberry Pi architecture doesn't provide direct access to the +CLOCKMAN peripheral from the ARM side, so Linux has to make requests +to the VPU firmware to program them. + +This binding uses the common clock binding: +Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible: Should be "raspberrypi,bcm2835-firmware-clocks"Quoted 8 lines
Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt line 17
Quoted 6 lines
Documentation/devicetree/bindings/clock/raspberrypi,bcm2835-firmware-clocks.txt new file +6
-0+ +- #clock-cells: Shall have value <1>. The permitted clock-specifier + values can be found in + include/dt-bindings/clk/raspberrypi.h. + +- raspberrypi,firmware: Phandle to the firmware driver node.I think 'firmware' is a candidate for a generic phandle name.
Quoted 4 lines
Stephen Warren asked in the last version that I change it from "firmware" to "raspberrypi,firmware", which made sense to me since we're not some core infrastructure using these references. Which should it be?
Quoted 4 lines
We tend to use vendor specific bindings when others are unlikely to make use of them. I would have thought that different vendors would also make use of a generic 'firmware' phandle. The final decision would probably be taken by the DT guys.
I wouldn't expect there to be a need for a common firmware API for firmwares that don't implement some common standard (such as ACPI), since the operations supported by the firmwares will be firmware-specific, and hence not be amenable to generic clients (a client of the raspberrypi,firmware object may "translate" it to standard APIs such as clock, power domains, etc., while allowing other clients access to all the custom features). As such, I expect using a generic property name here isn't that useful.