clk: add metag specific gate/mux clocks
Subsystems (2)
cover clk: add metag specific gate/mux clocks
This adds a metag architecture specific clk-gate and clk-mux which extends the generic ones to use global lock2 to protect the register fields. It is common with metag to have an RTOS running on a different thread or core with access to different bits in the same register (which contain clock gate/switch bits for other clocks). Access to such registers must be serialised with a global lock such as the one provided by the metag architecture port in <asm/global_lock.h>
RFC because despite extending the generic clocks there's still a bit of duplicated code necessary. One alternative is to add special cases to the generic clock components for when a global or callback function based lock is desired instead of a spinlock, but I wasn't sure if that sort of hack would really be appreciated in the generic drivers.
Comments?
James Hogan (2):
clk: metag/clk-gate: add metag specific clock gate
clk: metag/clk-mux: add metag specific clk-mux
.../bindings/clock/img,meta-gate-clock.txt | 28 +++ .../bindings/clock/img,meta-mux-clock.txt | 33 ++++ drivers/clk/Makefile | 1 + drivers/clk/metag/Makefile | 3 + drivers/clk/metag/clk-gate.c | 179 +++++++++++++++++ drivers/clk/metag/clk-mux.c | 211 +++++++++++++++++++++ 6 files changed, 455 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/img,meta-gate-clock.txt create mode 100644 Documentation/devicetree/bindings/clock/img,meta-mux-clock.txt create mode 100644 drivers/clk/metag/Makefile create mode 100644 drivers/clk/metag/clk-gate.c create mode 100644 drivers/clk/metag/clk-mux.c
Signature · 1 line
1.8.1.2
RFC PATCH 1/2 clk: metag/clk-gate: add metag specific clock gate
Add a metag architecture specific clk-gate which extends the generic one to use global lock2 to protect the register fields. It is common with metag to have an RTOS running on a different thread or core with access to different bits in the same register (in this case clock gate bits for other clocks). Access to such registers must be serialised with a global lock such as the one provided by the metag architecture port in <asm/global_lock.h>
--- .../bindings/clock/img,meta-gate-clock.txt | 28 ++++ drivers/clk/Makefile | 1 + drivers/clk/metag/Makefile | 2 + drivers/clk/metag/clk-gate.c | 179 +++++++++++++++++++++ 4 files changed, 210 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/img,meta-gate-clock.txt create mode 100644 drivers/clk/metag/Makefile create mode 100644 drivers/clk/metag/clk-gate.c
Documentation/devicetree/bindings/clock/img,meta-gate-clock.txt new file +28 -0
@@ -0,0 +1,28 @@ +Binding for clock gate requiring global Meta locking. + +This binding uses the common clock binding[1]. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible : Shall be "img,meta-mux-clock". +- #clock-cells : From common clock binding; shall be set to 0. +- reg : Address of configuration register. +- bit : Bit number of gate switch in configuration register. +- clocks : From common clock binding. + +Required source clocks: +- 0 : Input clock that can be gated (doesn't have to be named). + +Optional properties: +- clock-output-names : From common clock binding. + +Example: + clock { + compatible = "img,meta-gate-clock"; + #clock-cells = <0>; + clocks = <&sys_clk>; + reg = <0x02004010 0x4>; + bit = <0>; + clock-output-names = "scb0"; + };
drivers/clk/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o obj-$(CONFIG_ARCH_TEGRA) += tegra/ +obj-$(CONFIG_METAG) += metag/ obj-$(CONFIG_X86) += x86/ # Chip specific
drivers/clk/metag/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# metag clock types +obj-$(CONFIG_COMMON_CLK) += clk-gate.o
drivers/clk/metag/clk-gate.c new file +179 -0
179 lines not on this page · raw message
Signature · 1 line
1.8.1.2
RFC PATCH 1/2 clk: metag/clk-gate: add metag specific clock gate
In reply to James HoganAdd a metag architecture specific clk-gate which extends the generic one to use global lock2 to protect the register fields. It is common with metag to have an RTOS running on a different thread or core with access to different bits in the same register (in this case clock gate bits for other clocks). Access to such registers must be serialised with a global lock such as the one provided by the metag architecture port in <asm/global_lock.h>
--- .../bindings/clock/img,meta-gate-clock.txt | 28 ++++ drivers/clk/Makefile | 1 + drivers/clk/metag/Makefile | 2 + drivers/clk/metag/clk-gate.c | 179 +++++++++++++++++++++ 4 files changed, 210 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/img,meta-gate-clock.txt create mode 100644 drivers/clk/metag/Makefile create mode 100644 drivers/clk/metag/clk-gate.c
Documentation/devicetree/bindings/clock/img,meta-gate-clock.txt new file +28 -0
@@ -0,0 +1,28 @@ +Binding for clock gate requiring global Meta locking. + +This binding uses the common clock binding[1]. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible : Shall be "img,meta-mux-clock". +- #clock-cells : From common clock binding; shall be set to 0. +- reg : Address of configuration register. +- bit : Bit number of gate switch in configuration register. +- clocks : From common clock binding. + +Required source clocks: +- 0 : Input clock that can be gated (doesn't have to be named). + +Optional properties: +- clock-output-names : From common clock binding. + +Example: + clock { + compatible = "img,meta-gate-clock"; + #clock-cells = <0>; + clocks = <&sys_clk>; + reg = <0x02004010 0x4>; + bit = <0>; + clock-output-names = "scb0"; + };
drivers/clk/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o obj-$(CONFIG_ARCH_TEGRA) += tegra/ +obj-$(CONFIG_METAG) += metag/ obj-$(CONFIG_X86) += x86/ # Chip specific
drivers/clk/metag/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# metag clock types +obj-$(CONFIG_COMMON_CLK) += clk-gate.o
drivers/clk/metag/clk-gate.c new file +179 -0
179 lines not on this page · raw message
Signature · 1 line
1.8.1.2
cover clk: add metag specific gate/mux clocks
In reply to James HoganThis adds a metag architecture specific clk-gate and clk-mux which extends the generic ones to use global lock2 to protect the register fields. It is common with metag to have an RTOS running on a different thread or core with access to different bits in the same register (which contain clock gate/switch bits for other clocks). Access to such registers must be serialised with a global lock such as the one provided by the metag architecture port in <asm/global_lock.h>
RFC because despite extending the generic clocks there's still a bit of duplicated code necessary. One alternative is to add special cases to the generic clock components for when a global or callback function based lock is desired instead of a spinlock, but I wasn't sure if that sort of hack would really be appreciated in the generic drivers.
Comments?
James Hogan (2):
clk: metag/clk-gate: add metag specific clock gate
clk: metag/clk-mux: add metag specific clk-mux
.../bindings/clock/img,meta-gate-clock.txt | 28 +++ .../bindings/clock/img,meta-mux-clock.txt | 33 ++++ drivers/clk/Makefile | 1 + drivers/clk/metag/Makefile | 3 + drivers/clk/metag/clk-gate.c | 179 +++++++++++++++++ drivers/clk/metag/clk-mux.c | 211 +++++++++++++++++++++ 6 files changed, 455 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/img,meta-gate-clock.txt create mode 100644 Documentation/devicetree/bindings/clock/img,meta-mux-clock.txt create mode 100644 drivers/clk/metag/Makefile create mode 100644 drivers/clk/metag/clk-gate.c create mode 100644 drivers/clk/metag/clk-mux.c
Signature · 1 line
1.8.1.2
Quoted 7 lines · James Hogan
This adds a metag architecture specific clk-gate and clk-mux which extends the generic ones to use global lock2 to protect the register fields. It is common with metag to have an RTOS running on a different thread or core with access to different bits in the same register (which contain clock gate/switch bits for other clocks). Access to such registers must be serialised with a global lock such as the one provided by the metag architecture port in <
asm/global_lock.h>
Hmm, sorry about the duplicated emails, I had *.patch twice in my git send-email command line :(.
RFC PATCH 2/2 clk: metag/clk-mux: add metag specific clk-mux
In reply to James HoganAdd a metag architecture specific clk-mux which extends the generic one to use global lock2 to protect the register fields. It is common with metag to have an RTOS running on a different thread or core with access to different bits in the same register (in this case clock switch bits for other clocks). Access to such registers must be serialised with a global lock such as the one provided by the metag architecture port in <asm/global_lock.h>
--- .../bindings/clock/img,meta-mux-clock.txt | 33 ++++ drivers/clk/metag/Makefile | 1 + drivers/clk/metag/clk-mux.c | 211 +++++++++++++++++++++ 3 files changed, 245 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/img,meta-mux-clock.txt create mode 100644 drivers/clk/metag/clk-mux.c
Documentation/devicetree/bindings/clock/img,meta-mux-clock.txt new file +33 -0
@@ -0,0 +1,33 @@ +Binding for clock multiplexer requiring global Meta locking. + +This binding uses the common clock binding[1]. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible : Shall be "img,meta-mux-clock". +- #clock-cells : From common clock binding; shall be set to 0. +- reg : Address of configuration register. +- shift : Shift of mux value field in configuration register. +- width : Width of mux value field in configuration register. +- clocks : From common clock binding. + +Required source clocks: +- 0..(1<<width)-1 : Input clocks to multiplex (don't have to be named). + +Optional properties: +- clock-output-names : From common clock binding. +- default-clock : Mux value to set initially. + +Example: + clock { + compatible = "img,meta-mux-clock"; + #clock-cells = <0>; + clocks = <&xtal1>, + <&xtal2>; + reg = <0x02005908 0x4>; + shift = <0>; + width = <1>; + clock-output-names = "sysclk0_sw"; + default-clock = <1>; /* default to xtal2 */ + };
drivers/clk/metag/Makefile +1 -0
@@ -1,2 +1,3 @@ # metag clock types obj-$(CONFIG_COMMON_CLK) += clk-gate.o +obj-$(CONFIG_COMMON_CLK) += clk-mux.o
drivers/clk/metag/clk-mux.c new file +211 -0
211 lines not on this page · raw message
Signature · 1 line
1.8.1.2
RFC PATCH 2/2 clk: metag/clk-mux: add metag specific clk-mux
In reply to James HoganAdd a metag architecture specific clk-mux which extends the generic one to use global lock2 to protect the register fields. It is common with metag to have an RTOS running on a different thread or core with access to different bits in the same register (in this case clock switch bits for other clocks). Access to such registers must be serialised with a global lock such as the one provided by the metag architecture port in <asm/global_lock.h>
--- .../bindings/clock/img,meta-mux-clock.txt | 33 ++++ drivers/clk/metag/Makefile | 1 + drivers/clk/metag/clk-mux.c | 211 +++++++++++++++++++++ 3 files changed, 245 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/img,meta-mux-clock.txt create mode 100644 drivers/clk/metag/clk-mux.c
Documentation/devicetree/bindings/clock/img,meta-mux-clock.txt new file +33 -0
@@ -0,0 +1,33 @@ +Binding for clock multiplexer requiring global Meta locking. + +This binding uses the common clock binding[1]. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible : Shall be "img,meta-mux-clock". +- #clock-cells : From common clock binding; shall be set to 0. +- reg : Address of configuration register. +- shift : Shift of mux value field in configuration register. +- width : Width of mux value field in configuration register. +- clocks : From common clock binding. + +Required source clocks: +- 0..(1<<width)-1 : Input clocks to multiplex (don't have to be named). + +Optional properties: +- clock-output-names : From common clock binding. +- default-clock : Mux value to set initially. + +Example: + clock { + compatible = "img,meta-mux-clock"; + #clock-cells = <0>; + clocks = <&xtal1>, + <&xtal2>; + reg = <0x02005908 0x4>; + shift = <0>; + width = <1>; + clock-output-names = "sysclk0_sw"; + default-clock = <1>; /* default to xtal2 */ + };
drivers/clk/metag/Makefile +1 -0
@@ -1,2 +1,3 @@ # metag clock types obj-$(CONFIG_COMMON_CLK) += clk-gate.o +obj-$(CONFIG_COMMON_CLK) += clk-mux.o
drivers/clk/metag/clk-mux.c new file +211 -0
211 lines not on this page · raw message
Signature · 1 line
1.8.1.2
Quoted 8 lines · James Hogan
This adds a metag architecture specific clk-gate and clk-mux which extends the generic ones to use global lock2 to protect the register fields. It is common with metag to have an RTOS running on a different thread or core with access to different bits in the same register (which contain clock gate/switch bits for other clocks). Access to such registers must be serialised with a global lock such as the one provided by the metag architecture port in <
asm/global_lock.h>
Quoted 7 lines
RFC because despite extending the generic clocks there's still a bit of duplicated code necessary. One alternative is to add special cases to the generic clock components for when a global or callback function based lock is desired instead of a spinlock, but I wasn't sure if that sort of hack would really be appreciated in the generic drivers.
Comments?
Can you please Cc the devicetree mailing list when proposing new bindings?
Your patchset brings up a question I've had which is if we should be putting the bits and register width information in devicetree at all. On the one hand it's nice to not have anything in C code, just iterate over nodes and register clocks. On the other hand, it's the first time I've seen anyone put the register interface into devicetree. From what I can tell, the regulator bindings have put at most the register base and physical properties like enable-time, max voltage, etc., but not what bits are needed to enable/disable a regulator. Also I thought I read somewhere that reg properties shouldn't overlap each other, so if you ever have two clocks living in the same register we're going to violate that.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Quoted 15 lines · Stephen Boyd
Quoted 14 lines · James Hogan
This adds a metag architecture specific clk-gate and clk-mux which extends the generic ones to use global lock2 to protect the register fields. It is common with metag to have an RTOS running on a different thread or core with access to different bits in the same register (which contain clock gate/switch bits for other clocks). Access to such registers must be serialised with a global lock such as the one provided by the metag architecture port in <
asm/global_lock.h>RFC because despite extending the generic clocks there's still a bit of duplicated code necessary. One alternative is to add special cases to the generic clock components for when a global or callback function based lock is desired instead of a spinlock, but I wasn't sure if that sort of hack would really be appreciated in the generic drivers.
Quoted 3 lines
Quoted 1 line
Comments?
Can you please Cc the devicetree mailing list when proposing new bindings?
Erm, I think it was on Cc (devicetree-discuss at lists.ozlabs.org yeh?)
Quoted 11 lines
Your patchset brings up a question I've had which is if we should be putting the bits and register width information in devicetree at all. On the one hand it's nice to not have anything in C code, just iterate over nodes and register clocks. On the other hand, it's the first time I've seen anyone put the register interface into devicetree. From what I can tell, the regulator bindings have put at most the register base and physical properties like enable-time, max voltage, etc., but not what bits are needed to enable/disable a regulator. Also I thought I read somewhere that reg properties shouldn't overlap each other, so if you ever have two clocks living in the same register we're going to violate that.
Oh, I wasn't aware of that limitation.
The SoC I'm working with has some registers full of clock enable bits (I guess one could have a gate array component with up to 32 clock inputs and outputs) and some registers full of clock mux switch bits (that would get really messy to define as a block since each bit switches between 2 parents, and some of the parents are other clock muxes in the same block). Some registers contain a bunch of low power related bits together, including clock enable bits in the same register as various pinconf settings which is used by a separate pinctrl driver.
Cheers
James
Quoted 16 lines · James Hogan
Quoted 15 lines · Stephen Boyd
Quoted 14 lines · James Hogan
This adds a metag architecture specific clk-gate and clk-mux which extends the generic ones to use global lock2 to protect the register fields. It is common with metag to have an RTOS running on a different thread or core with access to different bits in the same register (which contain clock gate/switch bits for other clocks). Access to such registers must be serialised with a global lock such as the one provided by the metag architecture port in <
asm/global_lock.h>RFC because despite extending the generic clocks there's still a bit of duplicated code necessary. One alternative is to add special cases to the generic clock components for when a global or callback function based lock is desired instead of a spinlock, but I wasn't sure if that sort of hack would really be appreciated in the generic drivers.
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
Comments?
Can you please Cc the devicetree mailing list when proposing new bindings?
Erm, I think it was on Cc (devicetree-discuss at lists.ozlabs.org yeh?)
I added them in my reply.
Quoted 14 lines
Quoted 12 lines
Your patchset brings up a question I've had which is if we should be putting the bits and register width information in devicetree at all. On the one hand it's nice to not have anything in C code, just iterate over nodes and register clocks. On the other hand, it's the first time I've seen anyone put the register interface into devicetree. From what I can tell, the regulator bindings have put at most the register base and physical properties like enable-time, max voltage, etc., but not what bits are needed to enable/disable a regulator. Also I thought I read somewhere that reg properties shouldn't overlap each other, so if you ever have two clocks living in the same register we're going to violate that.
Oh, I wasn't aware of that limitation.
Quoted 9 lines
The SoC I'm working with has some registers full of clock enable bits (I guess one could have a gate array component with up to 32 clock inputs and outputs) and some registers full of clock mux switch bits (that would get really messy to define as a block since each bit switches between 2 parents, and some of the parents are other clock muxes in the same block). Some registers contain a bunch of low power related bits together, including clock enable bits in the same register as various pinconf settings which is used by a separate pinctrl driver.
I have similar hardware and so I would like to hear what the devicetree knowledgeable people think about it. Hopefully Rob or Grant can shed some light here.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Quoted 6 lines · Stephen Boyd
Quoted 3 lines · James Hogan
Quoted 1 line · Stephen Boyd
Can you please Cc the devicetree mailing list when proposing new bindings?
Erm, I think it was on Cc (devicetree-discuss at lists.ozlabs.org yeh?)
I added them in my reply.
Ah yes, sorry, my mistake.
Cheers
James
Quoting Stephen Boyd (2013-05-15 15:31:11)
Quoted 19 lines · James Hogan
Quoted 8 lines
This adds a metag architecture specific clk-gate and clk-mux which extends the generic ones to use global lock2 to protect the register fields. It is common with metag to have an RTOS running on a different thread or core with access to different bits in the same register (which contain clock gate/switch bits for other clocks). Access to such registers must be serialised with a global lock such as the one provided by the metag architecture port in <
asm/global_lock.h>Quoted 7 lines
RFC because despite extending the generic clocks there's still a bit of duplicated code necessary. One alternative is to add special cases to the generic clock components for when a global or callback function based lock is desired instead of a spinlock, but I wasn't sure if that sort of hack would really be appreciated in the generic drivers.
Comments?
Can you please Cc the devicetree mailing list when proposing new bindings?
Quoted 12 lines
Your patchset brings up a question I've had which is if we should be putting the bits and register width information in devicetree at all. On the one hand it's nice to not have anything in C code, just iterate over nodes and register clocks. On the other hand, it's the first time I've seen anyone put the register interface into devicetree. From what I can tell, the regulator bindings have put at most the register base and physical properties like enable-time, max voltage, etc., but not what bits are needed to enable/disable a regulator. Also I thought I read somewhere that reg properties shouldn't overlap each other, so if you ever have two clocks living in the same register we're going to violate that.
I've written bindings for the generic mux-clock, divider-clock, and I'm working on a gate-clock (reusing some RFCs from a while back for gate-clock). All of these specify the base address as well as the relevant bit fields. To me this seems to intuitively describe the hardware. I'll post these bindings soon and let the bike shedding begin.
Regards,
Mike
Quoted 3 lines
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Quoting James Hogan (2013-05-10 08:02:02)
Quoted 8 lines
This adds a metag architecture specific clk-gate and clk-mux which extends the generic ones to use global lock2 to protect the register fields. It is common with metag to have an RTOS running on a different thread or core with access to different bits in the same register (which contain clock gate/switch bits for other clocks). Access to such registers must be serialised with a global lock such as the one provided by the metag architecture port in <
asm/global_lock.h>
Quoted 8 lines
RFC because despite extending the generic clocks there's still a bit of duplicated code necessary. One alternative is to add special cases to the generic clock components for when a global or callback function based lock is desired instead of a spinlock, but I wasn't sure if that sort of hack would really be appreciated in the generic drivers.
Comments?
The general approach looks OK, but you've kind of created generic mux-clock and gate-clock bindings in a metag-specific driver. I would prefer to have those functions exist in the generic drivers and your driver re-use those. I'll be posting bindings for those clocks by the end of the week (they're on my github repo now for the curious).
Wrapping the generic clock types is an OK approach and is done by several other drivers, so there is no problem there.
Regards,
Mike
Quoted 19 lines
James Hogan (2):
clk: metag/clk-gate: add metag specific clock gate
clk: metag/clk-mux: add metag specific clk-mux.../bindings/clock/img,meta-gate-clock.txt | 28 +++ .../bindings/clock/img,meta-mux-clock.txt | 33 ++++ drivers/clk/Makefile | 1 + drivers/clk/metag/Makefile | 3 + drivers/clk/metag/clk-gate.c | 179 +++++++++++++++++ drivers/clk/metag/clk-mux.c | 211 +++++++++++++++++++++ 6 files changed, 455 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/img,meta-gate-clock.txt create mode 100644 Documentation/devicetree/bindings/clock/img,meta-mux-clock.txt create mode 100644 drivers/clk/metag/Makefile create mode 100644 drivers/clk/metag/clk-gate.c create mode 100644 drivers/clk/metag/clk-mux.cSignature · 1 line
1.8.1.2