clk: keystone: add sci-clk support
Subsystems (4)
v4 cover clk: keystone: add sci-clk support
Hi,
This revision is a rebase on top of 4.12-rc1, with following changes:
1) Dropped the usage of dt-bindings include genpd/k2g.h as this is apparently going to be removed
2) Dropped the dt-bindings include file for the clock identifiers based on item [1]. The identifiers are only used once for anything within the driver, and it is more readable this way also. The DT users should use magic numbers for accessing the clocks, relative to what is done for example for IP addresses etc.
3) Fixed the node name for the clocks in patch #1
4) Init time failure fixes in patch #2
5) Some other minor fixes for comments provided for v3 of the patch #2
Boot tested with some additional patches on top on keystone-k2g.
(Bootable reference branch, NOT FOR MERGE:
https://github.com/t-kristo/linux-pm/tree/4.12-rc1-ti-sci-v4c-integ)
-Tero
PATCH v4 1/2 Documentation: dt: Add TI SCI clock driver
Add a clock implementation, TI SCI clock, that will hook to the common clock framework, and allow each clock to be controlled via TI SCI protocol.
--- .../devicetree/bindings/clock/ti,sci-clk.txt | 37 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/ti,sci-clk.txt
Documentation/devicetree/bindings/clock/ti,sci-clk.txt new file +37 -0
@@ -0,0 +1,37 @@ +Texas Instruments TI-SCI Clocks +=============================== + +All clocks on Texas Instruments' SoCs that contain a System Controller, +are only controlled by this entity. Communication between a host processor +running an OS and the System Controller happens through a protocol known +as TI-SCI[1]. This clock implementation plugs into the common clock +framework and makes use of the TI-SCI protocol on clock API requests. + +[1] Documentation/devicetree/bindings/arm/keystone/ti,sci.txt + +Required properties: +------------------- +- compatible: Must be "ti,k2g-sci-clk" +- #clock-cells: Shall be 2. + In clock consumers, this cell represents the device ID and clock ID + exposed by the PM firmware. The assignments can be found in the header + files <dt-bindings/genpd/<soc>.h> (which covers the device IDs) and + <dt-bindings/clock/<soc>.h> (which covers the clock IDs), where <soc> + is the SoC involved, for example 'k2g'. + +Examples: +-------- + +pmmc: pmmc { + compatible = "ti,k2g-sci"; + + k2g_clks: clocks { + compatible = "ti,k2g-sci-clk"; + #clock-cells = <2>; + }; +}; + +uart0: serial at 2530c00 { + compatible = "ns16550a"; + clocks = <&k2g_clks 0x2c 0>; +};
MAINTAINERS +1 -0
@@ -12630,6 +12630,7 @@ F: include/linux/soc/ti/ti_sci_protocol.h F: Documentation/devicetree/bindings/soc/ti/sci-pm-domain.txt F: include/dt-bindings/genpd/k2g.h F: drivers/soc/ti/ti_sci_pm_domains.c +F: Documentation/devicetree/bindings/clock/ti,sci-clk.txt THANKO'S RAREMONO AM/FM/SW RADIO RECEIVER USB DRIVER M: Hans Verkuil <[email protected]>
Signature · 1 line
1.9.1
Rob Herring
maintainerPATCH v4 1/2 Documentation: dt: Add TI SCI clock driver
Quoted 10 lines · Tero Kristo
Add a clock implementation, TI SCI clock, that will hook to the common clock framework, and allow each clock to be controlled via TI SCI protocol.
Signed-off-by Tero Kristo <[email protected]>--- .../devicetree/bindings/clock/ti,sci-clk.txt | 37 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/ti,sci-clk.txt
PATCH v4 2/2 clk: keystone: Add sci-clk driver support
In reply to Tero KristoIn K2G, the clock handling is done through firmware executing on a separate core. Linux kernel needs to communicate to the firmware through TI system control interface to access any power management related resources, including clocks.
The keystone sci-clk driver does this, by communicating to the firmware through the TI SCI driver. The driver adds support for registering clocks through DT, and basic required clock operations like prepare/get_rate, etc.
--- MAINTAINERS | 1 + drivers/clk/Kconfig | 8 +- drivers/clk/Makefile | 2 +- drivers/clk/keystone/Kconfig | 15 + drivers/clk/keystone/Makefile | 3 +- drivers/clk/keystone/sci-clk.c | 720 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 740 insertions(+), 9 deletions(-) create mode 100644 drivers/clk/keystone/Kconfig create mode 100644 drivers/clk/keystone/sci-clk.c
MAINTAINERS +1 -0
@@ -12631,6 +12631,7 @@ F: Documentation/devicetree/bindings/soc/ti/sci-pm-domain.txt F: include/dt-bindings/genpd/k2g.h F: drivers/soc/ti/ti_sci_pm_domains.c F: Documentation/devicetree/bindings/clock/ti,sci-clk.txt +F: drivers/clk/keystone/sci-clk.c THANKO'S RAREMONO AM/FM/SW RADIO RECEIVER USB DRIVER M: Hans Verkuil <[email protected]>
drivers/clk/Kconfig +1 -7
@@ -164,13 +164,6 @@ config COMMON_CLK_XGENE ---help--- Sypport for the APM X-Gene SoC reference, PLL, and device clocks. -config COMMON_CLK_KEYSTONE - tristate "Clock drivers for Keystone based SOCs" - depends on (ARCH_KEYSTONE || COMPILE_TEST) && OF - ---help--- - Supports clock drivers for Keystone based SOCs. These SOCs have local - a power sleep control module that gate the clock to the IPs and PLLs. - config COMMON_CLK_NXP def_bool COMMON_CLK && (ARCH_LPC18XX || ARCH_LPC32XX) select REGMAP_MMIO if ARCH_LPC32XX
@@ -219,6 +212,7 @@ config COMMON_CLK_VC5 source "drivers/clk/bcm/Kconfig" source "drivers/clk/hisilicon/Kconfig" +source "drivers/clk/keystone/Kconfig" source "drivers/clk/mediatek/Kconfig" source "drivers/clk/meson/Kconfig" source "drivers/clk/mvebu/Kconfig"
drivers/clk/Makefile +1 -1
@@ -61,7 +61,7 @@ obj-$(CONFIG_H8300) += h8300/ obj-$(CONFIG_ARCH_HISI) += hisilicon/ obj-$(CONFIG_ARCH_MXC) += imx/ obj-$(CONFIG_MACH_INGENIC) += ingenic/ -obj-$(CONFIG_COMMON_CLK_KEYSTONE) += keystone/ +obj-$(CONFIG_ARCH_KEYSTONE) += keystone/ obj-$(CONFIG_MACH_LOONGSON32) += loongson1/ obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/ obj-$(CONFIG_COMMON_CLK_AMLOGIC) += meson/
drivers/clk/keystone/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +config COMMON_CLK_KEYSTONE + tristate "Clock drivers for Keystone based SOCs" + depends on (ARCH_KEYSTONE || COMPILE_TEST) && OF + ---help--- + Supports clock drivers for Keystone based SOCs. These SOCs have local + a power sleep control module that gate the clock to the IPs and PLLs. + +config TI_SCI_CLK + tristate "TI System Control Interface clock drivers" + depends on (ARCH_KEYSTONE || COMPILE_TEST) && OF + default TI_SCI_PROTOCOL + ---help--- + This adds the clock driver support over TI System Control Interface. + If you wish to use clock resources from the PMMC firmware, say Y. + Otherwise, say N.
drivers/clk/keystone/Makefile +2 -1
@@ -1 +1,2 @@ -obj-y += pll.o gate.o +obj-$(CONFIG_COMMON_CLK_KEYSTONE) += pll.o gate.o +obj-$(CONFIG_TI_SCI_CLK) += sci-clk.o
drivers/clk/keystone/sci-clk.c new file +721 -0
721 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v4 2/2 clk: keystone: Add sci-clk driver support
Quoted 11 lines · Tero Kristo
drivers/clk/keystone/sci-clk.c new file +11
-0+ +/** +* ti_sci_clk_probe - Probe function for the TI SCI clock driver +* @pdev: platform device pointer to be probed +* +* Probes the TI SCI clock device. Allocates a new clock provider +* and registers this to the common clock framework. Also applies +* any required flags to the identified clocks via clock lists +* supplied from DT. Returns 0 for success, negative error value +* for failure. +*/
drivers/clk/keystone/sci-clk.c line 668
Quoted 10 lines
drivers/clk/keystone/sci-clk.c new file +10
-0+static int ti_sci_clk_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct device_node *np = dev->of_node; +struct sci_clk_provider *provider; +const struct ti_sci_handle *handle; +struct sci_clk_data *data; +int ret; + + data = (struct sci_clk_data *)of_device_get_match_data (dev);
It would be nice to avoid this cast, and also check for NULL here. I tried to do it in a few minutes but then that caused a problem with throwing away const on sci_clk_data. Can this be resolved? We probably shouldn't be assigning the sci_clk_data::clocks member anyway if the structure is const assuming it goes into the read-only section. It may cause some restructuring of the code though.
Quoted 4 lines
drivers/clk/keystone/sci-clk.c new file +4
-0+ + handle =devm_ti_sci_get_handle (dev); +if (IS_ERR (handle)) +return PTR_ERR (handle);
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v4 2/2 clk: keystone: Add sci-clk driver support
Quoted 23 lines · Stephen Boyd
Quoted 11 lines · Tero Kristo
drivers/clk/keystone/sci-clk.c new file +11
-0+ +/** +* ti_sci_clk_probe - Probe function for the TI SCI clock driver +* @pdev: platform device pointer to be probed +* +* Probes the TI SCI clock device. Allocates a new clock provider +* and registers this to the common clock framework. Also applies +* any required flags to the identified clocks via clock lists +* supplied from DT. Returns 0 for success, negative error value +* for failure. +*/ drivers/clk/keystone/sci-clk.c line 668
Quoted 10 lines
drivers/clk/keystone/sci-clk.c new file +10
-0+static int ti_sci_clk_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct device_node *np = dev->of_node; +struct sci_clk_provider *provider; +const struct ti_sci_handle *handle; +struct sci_clk_data *data; +int ret; + + data = (struct sci_clk_data *)of_device_get_match_data (dev);
Quoted 7 lines
It would be nice to avoid this cast, and also check for NULL here. I tried to do it in a few minutes but then that caused a problem with throwing away const on
sci_clk_data. Can this be resolved? We probably shouldn't be assigning thesci_clk_data::clocksmember anyway if the structure is const assuming it goes into the read-only section. It may cause some restructuring of the code though.
Yeah, thats a good catch. I just cooked up a fix for that, will post v5 of this patch alone in a bit.
Basically I moved the sci_clk_data->clocks to the provider itself so the sci_clk_data can remain const.
-Tero
Quoted 5 lines
Quoted 5 lines
drivers/clk/keystone/sci-clk.c new file +4
-0+ + handle =devm_ti_sci_get_handle (dev); +if (IS_ERR (handle)) +return PTR_ERR (handle);
v4 cover clk: keystone: add sci-clk support
In reply to Tero KristoHi Stephen,
Do you have any comments on this series or shall I just send a pull-req out?
-Tero