dt/bindings: clk: Add YAML schemas for LS1028A Display Clock bindings
Subsystems (2)
PATCH v3 1/2 dt/bindings: clk: Add YAML schemas for LS1028A Display Clock bindings
LS1028A has a clock domain PXLCLK0 used for provide pixel clocks to Display output interface. Add a YAML schema for this.
--- .../devicetree/bindings/clock/fsl,plldig.yaml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/fsl,plldig.yaml
Documentation/devicetree/bindings/clock/fsl,plldig.yaml new file +43 -0
@@ -0,0 +1,43 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/bindings/clock/fsl,plldig.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP QorIQ Layerscape LS1028A Display PIXEL Clock Binding + +maintainers: + - Wen He <[email protected]> + +description: | + NXP LS1028A has a clock domain PXLCLK0 used for the Display output + interface in the display core, as implemented in TSMC CLN28HPM PLL. + which generate and offers pixel clocks to Display. + +properties: + compatible: + const: fsl,ls1028a-plldig + + reg: + maxItems: 1 + + '#clock-cells': + const: 0 + +required: + - compatible + - reg + - clocks + - '#clock-cells' + +examples: + # Display PIXEL Clock node: + - | + dpclk: clock-display@f1f0000 { + compatible = "fsl,ls1028a-plldig"; + reg = <0x0 0xf1f0000 0x0 0xffff>; + #clock-cells = <0>; + clocks = <&osc_27m>; + }; + +...
Signature · 1 line
2.17.1
PATCH v3 2/2 clk: ls1028a: Add clock driver for Display output interface
Add clock driver for QorIQ LS1028A Display output interfaces(LCD, DPHY), as implemented in TSMC CLN28HPM PLL, this PLL supports the programmable integer division and range of the display output pixel clock's 27-594MHz.
---
change in v3:
- remove the OF dependency
- use clk_parent_data instead of parent_name
drivers/clk/Kconfig | 10 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-plldig.c | 283 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 294 insertions(+) create mode 100644 drivers/clk/clk-plldig.c
drivers/clk/Kconfig +10 -0
@@ -223,6 +223,16 @@ config CLK_QORIQ This adds the clock driver support for Freescale QorIQ platforms using common clock framework. +config CLK_LS1028A_PLLDIG + bool "Clock driver for LS1028A Display output" + depends on ARCH_LAYERSCAPE || COMPILE_TEST + default ARCH_LAYERSCAPE + help + This driver support the Display output interfaces(LCD, DPHY) pixel clocks + of the QorIQ Layerscape LS1028A, as implemented TSMC CLN28HPM PLL. Not all + features of the PLL are currently supported by the driver. By default, + configured bypass mode with this PLL. + config COMMON_CLK_XGENE bool "Clock driver for APM XGene SoC" default ARCH_XGENE
drivers/clk/Makefile +1 -0
@@ -44,6 +44,7 @@ obj-$(CONFIG_COMMON_CLK_OXNAS) += clk-oxnas.o obj-$(CONFIG_COMMON_CLK_PALMAS) += clk-palmas.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_CLK_QORIQ) += clk-qoriq.o +obj-$(CONFIG_CLK_LS1028A_PLLDIG) += clk-plldig.o obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o obj-$(CONFIG_COMMON_CLK_HI655X) += clk-hi655x.o obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.o
drivers/clk/clk-plldig.c new file +283 -0
283 lines not on this page · raw message
Signature · 1 line
2.17.1
Stephen Boyd
maintainerRe: [v3 2/2] clk: ls1028a: Add clock driver for Display output interface
Quoting Wen He (2019-08-21 19:08:47)
Quoted 55 lines
Add clock driver for QorIQ LS1028A Display output
interfaces(LCD, DPHY), as implemented in TSMC CLN28HPM PLL, this PLL supports the programmable integer division and range of the display output pixel clock's 27-594MHz.Signed-off-by Wen He <[email protected]>---
change in v3:
- remove the OF dependency
- useclk_parent_datainstead ofparent_namedrivers/clk/Kconfig | 10 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-plldig.c | 283 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 294 insertions(+) create mode 100644 drivers/clk/clk-plldig.cdrivers/clk/Kconfig +10
-0@@ -223,6 +223,16 @@ config CLK_QORIQ This adds the clock driver support for Freescale QorIQ platforms using common clock framework. +config CLK_LS1028A_PLLDIG + bool "Clock driver for LS1028A Display output" + depends on ARCH_LAYERSCAPE || COMPILE_TEST + default ARCH_LAYERSCAPE + help + This driver support the Display output interfaces(LCD, DPHY) pixel clocks + of the QorIQ Layerscape LS1028A, as implemented TSMC CLN28HPM PLL. Not all + features of the PLL are currently supported by the driver. By default, + configured bypass mode with this PLL. + config COMMON_CLK_XGENE bool "Clock driver for APM XGene SoC" default ARCH_XGENEdrivers/clk/Makefile +1
-0@@ -44,6 +44,7 @@ obj-$(CONFIG_COMMON_CLK_OXNAS) += clk-oxnas.o obj-$(CONFIG_COMMON_CLK_PALMAS) += clk-palmas.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_CLK_QORIQ) += clk-qoriq.o +obj-$(CONFIG_CLK_LS1028A_PLLDIG) += clk-plldig.o obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o obj-$(CONFIG_COMMON_CLK_HI655X) += clk-hi655x.o obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.odrivers/clk/clk-plldig.c new file +0
-0
drivers/clk/clk-plldig.c line 2
Quoted 2 lines
drivers/clk/clk-plldig.c new file +2
-0@@ -0,0 +1,283 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright 2019 NXP
Please leave this as C style /* */ comment for the NXP part, but comply with the SPDX comment style of // on the first line.
Quoted 5 lines
drivers/clk/clk-plldig.c new file +5
-0+ +static long plldig_round_rate (struct clk_hw *hw,unsigned long rate, +unsigned long *parent) +{ +unsigned long parent_rate = *parent;
drivers/clk/clk-plldig.c line 167
Quoted 10 lines
drivers/clk/clk-plldig.c new file +10
-0+unsigned long round_rate; +u32 mult =0 , rfdphi1 =0 ; +bool found = false; + + found =plldig_is_valid_range (rate, parent_rate, &mult, + &rfdphi1, &round_rate); +if (!found) { +pr_warn ("%s: unable to round rate %lu, parent rate :%lu\n" , +clk_hw_get_name (hw), rate, parent_rate); +return 0 ;
This can return an error instead? In fact, you may want to use determine_rate clk op instead.
Quoted 9 lines
drivers/clk/clk-plldig.c new file +9
-0+ } + +return round_rate / rfdphi1; +} + +static int plldig_set_rate (struct clk_hw *hw,unsigned long rate, +unsigned long parent_rate) +{ +struct clk_plldig *data =to_clk_plldig (hw);
drivers/clk/clk-plldig.c line 186
Quoted 10 lines
drivers/clk/clk-plldig.c new file +10
-0+bool valid = false; +unsigned long round_rate =0 ; +u32 rfdphi1 =0 , val, mult =0 , cond =0 ; +int ret = -ETIMEDOUT ; + + valid =plldig_is_valid_range (rate, parent_rate, &mult, + &rfdphi1, &round_rate); +if (!valid) { +pr_warn ("%s: unable to support rate %lu, parent_rate: %lu\n" , +clk_hw_get_name (hw), rate, parent_rate);
Shouldn't determine_rate or round_rate make this impossible to hit in practice? I mean that those ops should prevent the rate from being rounded to such a frequency that it becomes invalid.
Quoted 29 lines
drivers/clk/clk-plldig.c new file +29
-0+return -EINVAL ; + } + + val =readl (data->regs +PLLDIG_REG_PLLDV ); + val = mult; + rfdphi1 =PLLDIG_SET_RFDPHI1 (rfdphi1); + val |= rfdphi1; + +writel (val, data->regs +PLLDIG_REG_PLLDV ); + +/* delay 200us make sure that old lock state is cleared */ +udelay (200 ); + +/* Wait until PLL is locked or timeout (maximum 1000 usecs) */ + ret =readl_poll_timeout_atomic (data->regs +PLLDIG_REG_PLLSR , cond, + cond &PLLDIG_LOCK_MASK ,0 , +USEC_PER_MSEC ); + +return ret; +} + +static const struct clk_ops plldig_clk_ops = { + .enable = plldig_enable, + .disable = plldig_disable, + .is_enabled = plldig_is_enabled, + .recalc_rate = plldig_recalc_rate, + .round_rate = plldig_round_rate, + .set_rate = plldig_set_rate, +};
[...]
Quoted 7 lines
drivers/clk/clk-plldig.c new file +7
-0+ + ret =devm_clk_hw_register (dev, &data->hw); +if (ret) { +dev_err (dev,"failed to register %s clock\n" , init.name); +return ret; + } +
drivers/clk/clk-plldig.c line 261
Quoted 10 lines
drivers/clk/clk-plldig.c new file +10
-0+ ret =devm_of_clk_add_hw_provider (dev, of_clk_hw_simple_get, &data->hw); +if (ret) +dev_err (dev,"failed adding the clock provider\n" ); + +return ret; +} + +static int plldig_clk_remove (struct platform_device *pdev) +{ +of_clk_del_provider (pdev->dev.of_node);
This isn't required. devm already does it.
drivers/clk/clk-plldig.c line 266
Quoted 5 lines
drivers/clk/clk-plldig.c new file +5
-0+return 0 ; +} + +static const struct of_device_id plldig_clk_id[] = { + { .compatible ="fsl,ls1028a-plldig" , .data =NULL },
You can leave out the data assignment.
RE: [EXT] Re: [v3 2/2] clk: ls1028a: Add clock driver for Display output interface
Quoted 180 lines
-----Original Message-----
From: Stephen Boyd <[email protected]>
Sent: 2019年8月23日 9:27
To: Mark Rutland <[email protected]>; Michael Turquette <[email protected]>; Rob Herring <[email protected]>; Wen He <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: Leo Li <[email protected]>; [email protected]; Wen He <[email protected]>
Subject: [EXT] Re: [v3 2/2] clk: ls1028a: Add clock driver for Display output interfaceCaution: EXT Email
Quoting Wen He (2019-08-21 19:08:47)
Quoted 3 lines
Add clock driver for QorIQ LS1028A Display output
interfaces(LCD, DPHY), as implemented in TSMC CLN28HPM PLL, this PLL supports the programmable integer division and range of the display output pixel clock's27-594MHz.
Quoted 19 lines
Signed-off-by Wen He <[email protected]>---
change in v3:
- remove the OF dependency
- useclk_parent_datainstead ofparent_namedrivers/clk/Kconfig | 10 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-plldig.c | 283 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 294 insertions(+) create mode 100644 drivers/clk/clk-plldig.cdrivers/clk/Kconfig index renamed from drivers/clk/Kconfig +0
-0
801fa1cd0321..ab05f342af04100644drivers/clk/Kconfig config CLK_QORIQ · line 231
Quoted 9 lines
drivers/clk/Kconfig +6
-0@@ -223,6 +223,16 @@ config CLK_QORIQ This adds the clock driver support for Freescale QorIQ platforms using common clock framework. +config CLK_LS1028A_PLLDIG + bool "Clock driver for LS1028A Display output" + depends on ARCH_LAYERSCAPE || COMPILE_TEST + default ARCH_LAYERSCAPE + help + This driver support the Display output interfaces(LCD, DPHY)pixel clocks
drivers/clk/Kconfig config CLK_QORIQ · line 232
Quoted 1 line
drivers/clk/Kconfig +1
-0+ of the QorIQ Layerscape LS1028A, as implemented TSMCCLN28HPM PLL. Not all
drivers/clk/Kconfig config CLK_QORIQ · line 233
Quoted 1 line
drivers/clk/Kconfig +1
-0+ features of the PLL are currently supported by the driver. Bydefault,
drivers/clk/Makefile obj-$(CONFIG_COMMON_CLK_OXNAS)
Quoted 10 lines
drivers/clk/Kconfig +2
-0+ configured bypass mode with this PLL. + config COMMON_CLK_XGENE bool "Clock driver for APM XGene SoC" default ARCH_XGENEdrivers/clk/Makefile index renamed from drivers/clk/Makefile +0
-0
0cad76021297..c8e22a764c4d100644drivers/clk/Makefile +0
-0@@ -44,6 +44,7 @@ obj-$(CONFIG_COMMON_CLK_OXNAS)+= clk-oxnas.o > obj-$(CONFIG_COMMON_CLK_PALMAS) += clk-palmas.o > obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o > obj-$(CONFIG_CLK_QORIQ) += clk-qoriq.o > +obj-$(CONFIG_CLK_LS1028A_PLLDIG) += clk-plldig.o > obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o > obj-$(CONFIG_COMMON_CLK_HI655X) += clk-hi655x.o > obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.odrivers/clk/clk-plldig.c line 2
Quoted 7 lines
drivers/clk/clk-plldig.c new renamed from drivers/clk/clk-plldig.c +0
-0file mode 100644 index 000000000000..c5ce80a46fd4
drivers/clk/clk-plldig.c new file +2
-0@@ -0,0 +1,283 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright 2019 NXP Please leave this as C style /* */ comment for the NXP part, but comply with the SPDX comment style of // on the first line.
drivers/clk/clk-plldig.c
Quoted 12 lines
drivers/clk/clk-plldig.c new file +12
-0+ +static long plldig_round_rate (struct clk_hw *hw,unsigned long rate, +unsigned long *parent) { +unsigned long parent_rate = *parent; +unsigned long round_rate; +u32 mult =0 , rfdphi1 =0 ; +bool found = false; + + found =plldig_is_valid_range (rate, parent_rate, &mult, + &rfdphi1, &round_rate); +if (!found) { + pr_warn("%s: unable to round rate %lu, parentrate :%lu\n",
drivers/clk/clk-plldig.c line 15
Quoted 1 line
drivers/clk/clk-plldig.c new file +1
-0+ clk_hw_get_name(hw), rate,
parent_rate);drivers/clk/clk-plldig.c line 16
Quoted 1 line
drivers/clk/clk-plldig.c new file +1
-0+return 0 ;This can return an error instead? In fact, you may want to use
determine_rateclk op instead.Quoted 7 lines
drivers/clk/clk-plldig.c new file +7
-0+ } + +return round_rate / rfdphi1; +} + +static int plldig_set_rate (struct clk_hw *hw,unsigned long rate, +unsigned long parent_rate) {drivers/clk/clk-plldig.c
Quoted 10 lines
drivers/clk/clk-plldig.c new file +10
-0+struct clk_plldig *data =to_clk_plldig (hw); +bool valid = false; +unsigned long round_rate =0 ; +u32 rfdphi1 =0 , val, mult =0 , cond =0 ; +int ret = -ETIMEDOUT ; + + valid =plldig_is_valid_range (rate, parent_rate, &mult, + &rfdphi1, &round_rate); +if (!valid) { + pr_warn("%s: unable to support rate %lu,
parent_rate: %lu\n",drivers/clk/clk-plldig.c line 35
Quoted 2 lines
drivers/clk/clk-plldig.c new file +2
-0+clk_hw_get_name (hw), rate, + parent_rate);Shouldn't
determine_rateorround_ratemake this impossible to hit in practice? I mean that those ops should prevent the rate from being rounded to such a frequency that it becomes invalid.Quoted 5 lines
drivers/clk/clk-plldig.c new file +5
-0+return -EINVAL ; + } + + val =readl (data->regs +PLLDIG_REG_PLLDV ); + val = mult;drivers/clk/clk-plldig.c
Quoted 10 lines
drivers/clk/clk-plldig.c new file +10
-0+ rfdphi1 =PLLDIG_SET_RFDPHI1 (rfdphi1); + val |= rfdphi1; + +writel (val, data->regs +PLLDIG_REG_PLLDV ); + +/* delay 200us make sure that old lock state is cleared */ +udelay (200 ); + +/* Wait until PLL is locked or timeout (maximum 1000 usecs) */ + ret = readl_poll_timeout_atomic(data->regs + PLLDIG_REG_PLLSR,cond,
drivers/clk/clk-plldig.c line 51
Quoted 1 line
drivers/clk/clk-plldig.c new file +1
-0+ cond & PLLDIG_LOCK_MASK,0,
Quoted 13 lines
drivers/clk/clk-plldig.c new file +13
-0+ USEC_PER_MSEC); + +return ret; +} + +static const struct clk_ops plldig_clk_ops = { + .enable = plldig_enable, + .disable = plldig_disable, + .is_enabled = plldig_is_enabled, + .recalc_rate = plldig_recalc_rate, + .round_rate = plldig_round_rate, + .set_rate = plldig_set_rate, +};[...]
drivers/clk/clk-plldig.c
Quoted 8 lines
drivers/clk/clk-plldig.c new file +8
-0+ + ret =devm_clk_hw_register (dev, &data->hw); +if (ret) { +dev_err (dev,"failed to register %s clock\n" , init.name); +return ret; + } + + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
&data->hw);drivers/clk/clk-plldig.c line 261
Quoted 8 lines
drivers/clk/clk-plldig.c new file +8
-0+if (ret) +dev_err (dev,"failed adding the clock provider\n" ); + +return ret; +} + +static int plldig_clk_remove (struct platform_device *pdev) { +of_clk_del_provider (pdev->dev.of_node);This isn't required. devm already does it.
Quoted 7 lines
drivers/clk/clk-plldig.c line 266
Quoted 5 lines
drivers/clk/clk-plldig.c new file +5
-0+return 0 ; +} + +static const struct of_device_id plldig_clk_id[] = { + { .compatible ="fsl,ls1028a-plldig" , .data =NULL },You can leave out the data assignment.
Thanks for the details review, will send next version.
Best Regards,
Wen