* [PATCH V3 0/3] support different number of clocks for svc i3c controller
@ 2025-04-22 7:08 carlos.song
2025-04-22 7:08 ` [PATCH V3 1/3] dt-bindings: i3c: silvaco,i3c-master: add i.MX94 and i.MX95 I3C carlos.song
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: carlos.song @ 2025-04-22 7:08 UTC (permalink / raw)
To: miquel.raynal, Frank.Li, alexandre.belloni, robh, krzk+dt,
conor+dt, shawnguo, s.hauer, kernel, festevam, conor.culhane
Cc: linux-i3c, imx, devicetree, linux-kernel, linux-arm-kernel
From: Carlos Song <carlos.song@nxp.com>
I.MX94 and I.MX95 I3C only need two clocks and legacy I3C needs three
clocks. So add restrictions for clock and clock-names properties for
different Socs. In driver, use the clk_bulk API to handle clocks to
support different numbers of clocks more easily. Make the code cleaner
and more flexible.
---
Change for V3:
- Remove unrelated fix in imx95.dtsi.
Change for V2:
- Fix bot found errors running 'make dt_binding_check'
- Fix warning from bot test. Use -EINVA instead of uninitialized ret in
dev_err_probe
- Use master->fclk = master->clks[i].clk instead of devm_clk_get
(dev, "fast_clk");
Carlos Song (3):
dt-bindings: i3c: silvaco,i3c-master: add i.MX94 and i.MX95 I3C
i3c: master: svc: switch to bulk clk API for flexible clock support
arm64: dts: imx95: correct i3c node in imx95
.../bindings/i3c/silvaco,i3c-master.yaml | 45 +++++++++--
arch/arm64/boot/dts/freescale/imx95.dtsi | 10 +--
drivers/i3c/master/svc-i3c-master.c | 76 +++++++------------
3 files changed, 69 insertions(+), 62 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH V3 1/3] dt-bindings: i3c: silvaco,i3c-master: add i.MX94 and i.MX95 I3C
2025-04-22 7:08 [PATCH V3 0/3] support different number of clocks for svc i3c controller carlos.song
@ 2025-04-22 7:08 ` carlos.song
2025-04-24 7:46 ` Krzysztof Kozlowski
2025-04-22 7:08 ` [PATCH V3 2/3] i3c: master: svc: switch to bulk clk API for flexible clock support carlos.song
2025-04-22 7:08 ` [PATCH V3 3/3] arm64: dts: imx95: correct i3c node in imx95 carlos.song
2 siblings, 1 reply; 5+ messages in thread
From: carlos.song @ 2025-04-22 7:08 UTC (permalink / raw)
To: miquel.raynal, Frank.Li, alexandre.belloni, robh, krzk+dt,
conor+dt, shawnguo, s.hauer, kernel, festevam, conor.culhane
Cc: linux-i3c, imx, devicetree, linux-kernel, linux-arm-kernel
From: Carlos Song <carlos.song@nxp.com>
Add compatible string "nxp,imx94-i3c" and "nxp,imx95-i3c" for the i.MX94
chip and i.MX95 chip. Backward is compatible with "silvaco,i3c-master-v1".
Also i.MX94 and i.MX95 I3C only need two clocks and Legacy I3C needs
three clocks. So add restrictions for clock and clock-names properties
for different Socs.
Signed-off-by: Carlos Song <carlos.song@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
---
Change for V3:
- No change
Change for V2:
- Fix bot found errors running 'make dt_binding_check'
---
.../bindings/i3c/silvaco,i3c-master.yaml | 45 ++++++++++++++++---
1 file changed, 39 insertions(+), 6 deletions(-)
diff --git a/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml b/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml
index 4fbdcdac0aee..fd64741abc0c 100644
--- a/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml
+++ b/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml
@@ -9,14 +9,17 @@ title: Silvaco I3C master
maintainers:
- Conor Culhane <conor.culhane@silvaco.com>
-allOf:
- - $ref: i3c.yaml#
-
properties:
compatible:
- enum:
- - nuvoton,npcm845-i3c
- - silvaco,i3c-master-v1
+ oneOf:
+ - enum:
+ - nuvoton,npcm845-i3c
+ - silvaco,i3c-master-v1
+ - items:
+ - enum:
+ - nxp,imx94-i3c
+ - nxp,imx95-i3c
+ - const: silvaco,i3c-master-v1
reg:
maxItems: 1
@@ -25,12 +28,14 @@ properties:
maxItems: 1
clocks:
+ minItems: 2
items:
- description: system clock
- description: bus clock
- description: other (slower) events clock
clock-names:
+ minItems: 2
items:
- const: pclk
- const: fast_clk
@@ -46,6 +51,34 @@ required:
- clock-names
- clocks
+allOf:
+ - $ref: i3c.yaml#
+ # Legacy Socs need three clocks
+ - if:
+ properties:
+ compatible:
+ const: silvaco,i3c-master-v1
+ then:
+ properties:
+ clocks:
+ minItems: 3
+ clock-names:
+ minItems: 3
+ # imx94 and imx95 Soc need two clocks
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - nxp,imx94-i3c
+ - nxp,imx95-i3c
+ then:
+ properties:
+ clocks:
+ maxItems: 2
+ clock-names:
+ maxItems: 2
+
unevaluatedProperties: false
examples:
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH V3 2/3] i3c: master: svc: switch to bulk clk API for flexible clock support
2025-04-22 7:08 [PATCH V3 0/3] support different number of clocks for svc i3c controller carlos.song
2025-04-22 7:08 ` [PATCH V3 1/3] dt-bindings: i3c: silvaco,i3c-master: add i.MX94 and i.MX95 I3C carlos.song
@ 2025-04-22 7:08 ` carlos.song
2025-04-22 7:08 ` [PATCH V3 3/3] arm64: dts: imx95: correct i3c node in imx95 carlos.song
2 siblings, 0 replies; 5+ messages in thread
From: carlos.song @ 2025-04-22 7:08 UTC (permalink / raw)
To: miquel.raynal, Frank.Li, alexandre.belloni, robh, krzk+dt,
conor+dt, shawnguo, s.hauer, kernel, festevam, conor.culhane
Cc: linux-i3c, imx, devicetree, linux-kernel, linux-arm-kernel
From: Carlos Song <carlos.song@nxp.com>
Use the clk_bulk API to handle clocks, so the code can support different
numbers of clocks more easily. Make the code cleaner and more flexible.
No change in functionality.
Signed-off-by: Carlos Song <carlos.song@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
---
Change for V3:
- No change
Change for V2:
- fix warning from bot test. Use -EINVA instead of uninitialized ret in
dev_err_probe
- use master->fclk = master->clks[i].clk instead of devm_clk_get
(dev, "fast_clk");
---
drivers/i3c/master/svc-i3c-master.c | 76 ++++++++++-------------------
1 file changed, 26 insertions(+), 50 deletions(-)
diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index 85e16de208d3..d8cb0b9a2597 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -203,9 +203,9 @@ struct svc_i3c_drvdata {
* @hj_work: Hot-join work
* @ibi_work: IBI work
* @irq: Main interrupt
- * @pclk: System clock
+ * @num_clks: I3C clock number
* @fclk: Fast clock (bus)
- * @sclk: Slow clock (other events)
+ * @clks: I3C clock array
* @xferqueue: Transfer queue structure
* @xferqueue.list: List member
* @xferqueue.cur: Current ongoing transfer
@@ -231,9 +231,9 @@ struct svc_i3c_master {
struct work_struct hj_work;
struct work_struct ibi_work;
int irq;
- struct clk *pclk;
+ int num_clks;
struct clk *fclk;
- struct clk *sclk;
+ struct clk_bulk_data *clks;
struct {
struct list_head list;
struct svc_i3c_xfer *cur;
@@ -1875,42 +1875,11 @@ static const struct i3c_master_controller_ops svc_i3c_master_ops = {
.set_speed = svc_i3c_master_set_speed,
};
-static int svc_i3c_master_prepare_clks(struct svc_i3c_master *master)
-{
- int ret = 0;
-
- ret = clk_prepare_enable(master->pclk);
- if (ret)
- return ret;
-
- ret = clk_prepare_enable(master->fclk);
- if (ret) {
- clk_disable_unprepare(master->pclk);
- return ret;
- }
-
- ret = clk_prepare_enable(master->sclk);
- if (ret) {
- clk_disable_unprepare(master->pclk);
- clk_disable_unprepare(master->fclk);
- return ret;
- }
-
- return 0;
-}
-
-static void svc_i3c_master_unprepare_clks(struct svc_i3c_master *master)
-{
- clk_disable_unprepare(master->pclk);
- clk_disable_unprepare(master->fclk);
- clk_disable_unprepare(master->sclk);
-}
-
static int svc_i3c_master_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct svc_i3c_master *master;
- int ret;
+ int ret, i;
master = devm_kzalloc(dev, sizeof(*master), GFP_KERNEL);
if (!master)
@@ -1924,27 +1893,31 @@ static int svc_i3c_master_probe(struct platform_device *pdev)
if (IS_ERR(master->regs))
return PTR_ERR(master->regs);
- master->pclk = devm_clk_get(dev, "pclk");
- if (IS_ERR(master->pclk))
- return PTR_ERR(master->pclk);
+ master->num_clks = devm_clk_bulk_get_all(dev, &master->clks);
+ if (master->num_clks < 0)
+ return dev_err_probe(dev, -EINVAL, "can't get I3C clocks\n");
+
+ for (i = 0; i < master->num_clks; i++) {
+ if (!strcmp(master->clks[i].id, "fast_clk"))
+ break;
+ }
+
+ if (i == master->num_clks)
+ return dev_err_probe(dev, -EINVAL,
+ "can't get I3C peripheral clock\n");
- master->fclk = devm_clk_get(dev, "fast_clk");
+ master->fclk = master->clks[i].clk;
if (IS_ERR(master->fclk))
return PTR_ERR(master->fclk);
- master->sclk = devm_clk_get(dev, "slow_clk");
- if (IS_ERR(master->sclk))
- return PTR_ERR(master->sclk);
-
master->irq = platform_get_irq(pdev, 0);
if (master->irq < 0)
return master->irq;
master->dev = dev;
-
- ret = svc_i3c_master_prepare_clks(master);
+ ret = clk_bulk_prepare_enable(master->num_clks, master->clks);
if (ret)
- return ret;
+ return dev_err_probe(dev, ret, "can't enable I3C clocks\n");
INIT_WORK(&master->hj_work, svc_i3c_master_hj_work);
INIT_WORK(&master->ibi_work, svc_i3c_master_ibi_work);
@@ -1998,7 +1971,7 @@ static int svc_i3c_master_probe(struct platform_device *pdev)
pm_runtime_set_suspended(&pdev->dev);
err_disable_clks:
- svc_i3c_master_unprepare_clks(master);
+ clk_bulk_disable_unprepare(master->num_clks, master->clks);
return ret;
}
@@ -2036,7 +2009,7 @@ static int __maybe_unused svc_i3c_runtime_suspend(struct device *dev)
struct svc_i3c_master *master = dev_get_drvdata(dev);
svc_i3c_save_regs(master);
- svc_i3c_master_unprepare_clks(master);
+ clk_bulk_disable_unprepare(master->num_clks, master->clks);
pinctrl_pm_select_sleep_state(dev);
return 0;
@@ -2045,9 +2018,12 @@ static int __maybe_unused svc_i3c_runtime_suspend(struct device *dev)
static int __maybe_unused svc_i3c_runtime_resume(struct device *dev)
{
struct svc_i3c_master *master = dev_get_drvdata(dev);
+ int ret;
pinctrl_pm_select_default_state(dev);
- svc_i3c_master_prepare_clks(master);
+ ret = clk_bulk_prepare_enable(master->num_clks, master->clks);
+ if (ret)
+ return ret;
svc_i3c_restore_regs(master);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH V3 3/3] arm64: dts: imx95: correct i3c node in imx95
2025-04-22 7:08 [PATCH V3 0/3] support different number of clocks for svc i3c controller carlos.song
2025-04-22 7:08 ` [PATCH V3 1/3] dt-bindings: i3c: silvaco,i3c-master: add i.MX94 and i.MX95 I3C carlos.song
2025-04-22 7:08 ` [PATCH V3 2/3] i3c: master: svc: switch to bulk clk API for flexible clock support carlos.song
@ 2025-04-22 7:08 ` carlos.song
2 siblings, 0 replies; 5+ messages in thread
From: carlos.song @ 2025-04-22 7:08 UTC (permalink / raw)
To: miquel.raynal, Frank.Li, alexandre.belloni, robh, krzk+dt,
conor+dt, shawnguo, s.hauer, kernel, festevam, conor.culhane
Cc: linux-i3c, imx, devicetree, linux-kernel, linux-arm-kernel
From: Carlos Song <carlos.song@nxp.com>
I.MX95 I3C only need two clocks so add clock fix. Add "nxp,imx95-i3c"
compatible string for all imx95 i3c nodes.
Signed-off-by: Carlos Song <carlos.song@nxp.com>
---
Change for V3:
- Remove unrelated fix in imx95.dtsi
Change for V2:
- No change
---
arch/arm64/boot/dts/freescale/imx95.dtsi | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/arch/arm64/boot/dts/freescale/imx95.dtsi b/arch/arm64/boot/dts/freescale/imx95.dtsi
index 9bb26b466a06..7eb2b1a0e3ea 100644
--- a/arch/arm64/boot/dts/freescale/imx95.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx95.dtsi
@@ -681,15 +681,14 @@ tpm6: pwm@42510000 {
};
i3c2: i3c@42520000 {
- compatible = "silvaco,i3c-master-v1";
+ compatible = "nxp,imx95-i3c", "silvaco,i3c-master-v1";
reg = <0x42520000 0x10000>;
interrupts = <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>;
#address-cells = <3>;
#size-cells = <0>;
clocks = <&scmi_clk IMX95_CLK_BUSAON>,
- <&scmi_clk IMX95_CLK_I3C2>,
<&scmi_clk IMX95_CLK_I3C2SLOW>;
- clock-names = "pclk", "fast_clk", "slow_clk";
+ clock-names = "pclk", "fast_clk";
status = "disabled";
};
@@ -1266,15 +1265,14 @@ tpm2: pwm@44320000 {
};
i3c1: i3c@44330000 {
- compatible = "silvaco,i3c-master-v1";
+ compatible = "nxp,imx95-i3c", "silvaco,i3c-master-v1";
reg = <0x44330000 0x10000>;
interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
#address-cells = <3>;
#size-cells = <0>;
clocks = <&scmi_clk IMX95_CLK_BUSAON>,
- <&scmi_clk IMX95_CLK_I3C1>,
<&scmi_clk IMX95_CLK_I3C1SLOW>;
- clock-names = "pclk", "fast_clk", "slow_clk";
+ clock-names = "pclk", "fast_clk";
status = "disabled";
};
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH V3 1/3] dt-bindings: i3c: silvaco,i3c-master: add i.MX94 and i.MX95 I3C
2025-04-22 7:08 ` [PATCH V3 1/3] dt-bindings: i3c: silvaco,i3c-master: add i.MX94 and i.MX95 I3C carlos.song
@ 2025-04-24 7:46 ` Krzysztof Kozlowski
0 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-04-24 7:46 UTC (permalink / raw)
To: carlos.song
Cc: miquel.raynal, Frank.Li, alexandre.belloni, robh, krzk+dt,
conor+dt, shawnguo, s.hauer, kernel, festevam, conor.culhane,
linux-i3c, imx, devicetree, linux-kernel, linux-arm-kernel
On Tue, Apr 22, 2025 at 03:08:51PM GMT, carlos.song@nxp.com wrote:
> From: Carlos Song <carlos.song@nxp.com>
>
> Add compatible string "nxp,imx94-i3c" and "nxp,imx95-i3c" for the i.MX94
> chip and i.MX95 chip. Backward is compatible with "silvaco,i3c-master-v1".
>
> Also i.MX94 and i.MX95 I3C only need two clocks and Legacy I3C needs
> three clocks. So add restrictions for clock and clock-names properties
> for different Socs.
>
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> Change for V3:
> - No change
> Change for V2:
> - Fix bot found errors running 'make dt_binding_check'
> ---
> .../bindings/i3c/silvaco,i3c-master.yaml | 45 ++++++++++++++++---
> 1 file changed, 39 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml b/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml
> index 4fbdcdac0aee..fd64741abc0c 100644
> --- a/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml
> +++ b/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml
> @@ -9,14 +9,17 @@ title: Silvaco I3C master
> maintainers:
> - Conor Culhane <conor.culhane@silvaco.com>
>
> -allOf:
> - - $ref: i3c.yaml#
> -
> properties:
> compatible:
> - enum:
> - - nuvoton,npcm845-i3c
> - - silvaco,i3c-master-v1
> + oneOf:
> + - enum:
> + - nuvoton,npcm845-i3c
> + - silvaco,i3c-master-v1
> + - items:
> + - enum:
> + - nxp,imx94-i3c
> + - nxp,imx95-i3c
> + - const: silvaco,i3c-master-v1
>
> reg:
> maxItems: 1
> @@ -25,12 +28,14 @@ properties:
> maxItems: 1
>
> clocks:
> + minItems: 2
> items:
> - description: system clock
> - description: bus clock
> - description: other (slower) events clock
>
> clock-names:
> + minItems: 2
> items:
> - const: pclk
> - const: fast_clk
> @@ -46,6 +51,34 @@ required:
> - clock-names
> - clocks
>
> +allOf:
> + - $ref: i3c.yaml#
> + # Legacy Socs need three clocks
Drop comment. I do not get what is here a legacy SoC. Which ones are
legacy and *why*?
> + - if:
> + properties:
> + compatible:
> + const: silvaco,i3c-master-v1
Missing nuvoton compatible. This is supposed to be enum.
> + then:
> + properties:
> + clocks:
> + minItems: 3
> + clock-names:
> + minItems: 3
> + # imx94 and imx95 Soc need two clocks
Drop comment. Don't repeat constraints in free form text.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-04-24 7:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-22 7:08 [PATCH V3 0/3] support different number of clocks for svc i3c controller carlos.song
2025-04-22 7:08 ` [PATCH V3 1/3] dt-bindings: i3c: silvaco,i3c-master: add i.MX94 and i.MX95 I3C carlos.song
2025-04-24 7:46 ` Krzysztof Kozlowski
2025-04-22 7:08 ` [PATCH V3 2/3] i3c: master: svc: switch to bulk clk API for flexible clock support carlos.song
2025-04-22 7:08 ` [PATCH V3 3/3] arm64: dts: imx95: correct i3c node in imx95 carlos.song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).