clk: add userspace clock consumer
Subsystems (2)
PATCH v2 1/1 clk: add userspace clock consumer
This adds userspace consumer for common clock.
This driver is inspired from Userspace regulator consumer (REGULATOR_USERSPACE_CONSUMER) and it is useful for test purposes and some classes of devices that are controlled entirely from user space.
Example binding and usages:
clksqw_userspace_consumer {
compatible = "linux,clock-userspace-consumer";
clocks = <&clksqw>;
};# cd /sys/devices/platform/clksqw_userspace_consumer # echo 8192 > rate # echo 1 > enable
This also create new COMMON_CLK_DEBUG option and this userspace clock consumer depends on it.
---
* v2
- change compatible property to "linux,clock-userspace-consumer"
- rename sysfs file from 'state' to 'enable'
- create new COMMON_CLK_DEBUG option
.../bindings/clock/clk-userspace-consumer.txt | 17 +++ drivers/clk/Kconfig | 9 ++ drivers/clk/Kconfig.debug | 9 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-userspace-consumer.c | 169 +++++++++++++++++++++ 5 files changed, 205 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/clk-userspace-consumer.txt create mode 100644 drivers/clk/Kconfig.debug create mode 100644 drivers/clk/clk-userspace-consumer.c
Documentation/devicetree/bindings/clock/clk-userspace-consumer.txt new file +17 -0
@@ -0,0 +1,17 @@ +* Userspace consumer for common clock + +Required properties: +- compatible: Should be "linux,clock-userspace-consumer" +- clocks: clock phandle to control from userspace + +Examples: + +clk32k_userspace_consumer { + compatible = "linux,clock-userspace-consumer"; + clocks = <&clk32k>; +}; + +sqw_userspace_consumer { + compatible = "linux,clock-userspace-consumer"; + clocks = <&sqw>; +};
drivers/clk/Kconfig +9 -0
@@ -25,6 +25,15 @@ config COMMON_CLK menu "Common Clock Framework" depends on COMMON_CLK +config COMMON_CLK_DEBUG + bool "Clock driver debugging support" + depends on DEBUG_KERNEL + ---help--- + Say Y here if you are developing clock drivers or trying to + debug and identify the problems. + +source "drivers/clk/Kconfig.debug" + config COMMON_CLK_WM831X tristate "Clock driver for WM831x/2x PMICs" depends on MFD_WM831X
drivers/clk/Kconfig.debug new file +9 -0
@@ -0,0 +1,9 @@ +config COMMON_CLK_USERSPACE_CONSUMER + tristate "Userspace clock consumer support" + depends on COMMON_CLK_DEBUG + help + There are some classes of devices that are controlled entirely + from user space. Userspace consumer driver provides ability to + control clock for such devices. + + If unsure, say no.
drivers/clk/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_COMMON_CLK) += clk-gpio.o ifeq ($(CONFIG_OF), y) obj-$(CONFIG_COMMON_CLK) += clk-conf.o endif +obj-$(CONFIG_COMMON_CLK_USERSPACE_CONSUMER) += clk-userspace-consumer.o # hardware specific clock types # please keep this section sorted lexicographically by file/directory path name
drivers/clk/clk-userspace-consumer.c new file +169 -0
169 lines not on this page · raw message
Signature · 1 line
2.5.0
Rob Herring
maintainerQuoted 5 lines · Akinobu Mita
This adds userspace consumer for common clock.
This driver is inspired from Userspace regulator consumer (
REGULATOR_USERSPACE_CONSUMER) and it is useful for test purposes and some classes of devices that are controlled entirely from user space.
Whether the kernel handles a clock or userspace does should have nothing to do with DT. Plus DT does not expose many of the clocks, so any debug feature needs to expose all clocks and be independent of DT.
Beyond debug, I don't think we should be exposing clock control to userspace.
Quoted 15 lines
Example binding and usages:
clksqw_userspace_consumer { compatible = "linux,clock-userspace-consumer"; clocks = <&clksqw>; };# cd /sys/devices/platform/clksqw_userspace_consumer # echo 8192 > rate # echo 1 > enableThis also create new
COMMON_CLK_DEBUGoption and this userspace clock consumer depends on it.
Quoted 7 lines
Signed-off-by Akinobu Mita <[email protected]>Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>---
* v2
- change compatible property to "linux,clock-userspace-consumer"
- rename sysfs file from 'state' to 'enable'
While it is good this is under a debug option, it also needs to be under debugfs, not sysfs.
Quoted 11 lines
- create new
COMMON_CLK_DEBUGoption.../bindings/clock/clk-userspace-consumer.txt | 17 +++ drivers/clk/Kconfig | 9 ++ drivers/clk/Kconfig.debug | 9 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-userspace-consumer.c | 169 +++++++++++++++++++++ 5 files changed, 205 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/clk-userspace-consumer.txt create mode 100644 drivers/clk/Kconfig.debug create mode 100644 drivers/clk/clk-userspace-consumer.c
Quoted 7 lines · Rob Herring
Quoted 5 lines · Akinobu Mita
This adds userspace consumer for common clock.
This driver is inspired from Userspace regulator consumer (
REGULATOR_USERSPACE_CONSUMER) and it is useful for test purposes and some classes of devices that are controlled entirely from user space.
Quoted 6 lines
Whether the kernel handles a clock or userspace does should have nothing to do with DT. Plus DT does not expose many of the clocks, so any debug feature needs to expose all clocks and be independent of DT.
Beyond debug, I don't think we should be exposing clock control to userspace.
Agreed. Plus, the userspace regulator consumer doesn't have any DT binding for it, so I don't see why we would have a DT binding for the clk one.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
2016-02-25 7:08 GMT+09:00 Stephen Boyd <[email protected]>:
Quoted 12 lines · Rob Herring
Quoted 11 lines · Akinobu Mita
Quoted 5 lines
This adds userspace consumer for common clock.
This driver is inspired from Userspace regulator consumer (
REGULATOR_USERSPACE_CONSUMER) and it is useful for test purposes and some classes of devices that are controlled entirely from user space.Whether the kernel handles a clock or userspace does should have nothing to do with DT. Plus DT does not expose many of the clocks, so any debug feature needs to expose all clocks and be independent of DT.
Quoted 6 lines
Quoted 2 lines
Beyond debug, I don't think we should be exposing clock control to userspace.
Agreed. Plus, the userspace regulator consumer doesn't have any DT binding for it, so I don't see why we would have a DT binding for the clk one.
OK. I'll drop a DT binding part of this driver.
I'll still try to expose this feature by platform device instead of exposing under clk debugfs. Because we don't want to allow controlling all clock devices (which may result abuse of the feature). Instead, this userspace consumer only allows explicitly specified devices to control.
Quoted 5 lines · Akinobu Mita
2016-02-25 7:08 GMT+09:00 Stephen Boyd <[email protected]>:
Quoted 3 lines
Agreed. Plus, the userspace regulator consumer doesn't have any DT binding for it, so I don't see why we would have a DT binding for the clk one.
Quoted 7 lines
OK. I'll drop a DT binding part of this driver.
I'll still try to expose this feature by platform device instead of exposing under clk debugfs. Because we don't want to allow controlling all clock devices (which may result abuse of the feature). Instead, this userspace consumer only allows explicitly specified devices to control.
I'm pretty lost on this whole patch. Is it for debug? Or is it to put clk control into userspace? If it's for debug, why not just keep this patch around locally and use it for debugging? If it's for userspace clk control we need to have a larger discussion around the concept of that (since Rob doesn't think it should be done at all) and ABI (sysfs or ioctl?) before moving forward.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project