Skip to contentSkip to conversation

clk: s2mps11: Fixes and add support for S2MPS14 clocks

PATCH Applied Krzysztof Kozlowski 2 participants 5 messages May 21, 2014 – May 23, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v4 cover clk: s2mps11: Fixes and add support for S2MPS14 clocks

Hi,

This is actually a resend of previous patches, rebased on latest 3.15-rc5. There are no changes, beside rebasing.

The first two fixes were posted previously as separate patches and they didn't get review [1]. I am attaching them here.
The last patch adds support for S2MPS14 device and already was reviewed/acked [2].

Mike, could you pick them up or should they go through MFD tree?

[1] https://lkml.org/lkml/2014/4/7/42
[2] http://thread.gmane.org/gmane.linux.kernel.samsung-soc/28039/focus=310279

Changes since v3:
=================
1. Add Mike's acked-by (see [2]).
2. Rebase patch 3/3 on the fixes (patches 1 and 2).
3. Rebase on v3.15-rc5-157-g60b5f90d0fac

Changes since v2:
=================
1. Patch 2/3: Remove MFD cells of_compatible which aren't used by child drivers and are not documented.
2. Added Tomasz's Review-by.

Changes since v1:
=================
1. Patch 1/3: Update driver description in Kconfig.
2. Patch 2/3: Add of_compatible to all MFD cells.
3. Add Yadwinder's Review-by.

Best regards,
Krzysztof

Krzysztof Kozlowski (3):
clk: s2mps11: Add missing of_node_put and of_clk_del_provider
clk: s2mps11: Remove useless check for clk_table
clk: s2mps11: Add support for S2MPS14 clocks

 drivers/clk/Kconfig       |  8 ++---
 drivers/clk/clk-s2mps11.c | 88 +++++++++++++++++++++++++++++++++--------------
 2 files changed, 66 insertions(+), 30 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v4 1/3 clk: s2mps11: Add missing of_node_put and of_clk_del_provider

Add of_clk_del_provider to remove previously registered clock provider. Add of_node_put to decrement the ref count of clock nodes.

---
 drivers/clk/clk-s2mps11.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/clk/clk-s2mps11.c +11 -5
index f2f62a1bf61a..843ec3646501 100644
@@ -44,6 +44,7 @@ enum {
 
 struct s2mps11_clk {
 	struct sec_pmic_dev *iodev;
+	struct device_node *clk_np;
 	struct clk_hw hw;
 	struct clk *clk;
 	struct clk_lookup *lookup;
@@ -156,7 +157,6 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
 {
 	struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
 	struct s2mps11_clk *s2mps11_clks, *s2mps11_clk;
-	struct device_node *clk_np = NULL;
 	unsigned int s2mps11_reg;
 	int i, ret = 0;
 	u32 val;
@@ -168,9 +168,10 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
 
 	s2mps11_clk = s2mps11_clks;
 
-	clk_np = s2mps11_clk_parse_dt(pdev);
-	if (IS_ERR(clk_np))
-		return PTR_ERR(clk_np);
+	/* Store clocks of_node in first element of s2mps11_clks array */
+	s2mps11_clks->clk_np = s2mps11_clk_parse_dt(pdev);
+	if (IS_ERR(s2mps11_clks->clk_np))
+		return PTR_ERR(s2mps11_clks->clk_np);
 
 	switch(platform_get_device_id(pdev)->driver_data) {
 	case S2MPS11X:
@@ -225,7 +226,8 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
 
 		clk_data.clks = clk_table;
 		clk_data.clk_num = S2MPS11_CLKS_NUM;
-		of_clk_add_provider(clk_np, of_clk_src_onecell_get, &clk_data);
+		of_clk_add_provider(s2mps11_clks->clk_np,
+				of_clk_src_onecell_get, &clk_data);
 	}
 
 	platform_set_drvdata(pdev, s2mps11_clks);
@@ -250,6 +252,10 @@ static int s2mps11_clk_remove(struct platform_device *pdev)
 	struct s2mps11_clk *s2mps11_clks = platform_get_drvdata(pdev);
 	int i;
 
+	of_clk_del_provider(s2mps11_clks[0].clk_np);
+	/* Drop the reference obtained in s2mps11_clk_parse_dt */
+	of_node_put(s2mps11_clks[0].clk_np);
+
 	for (i = 0; i < S2MPS11_CLKS_NUM; i++)
 		clkdev_drop(s2mps11_clks[i].lookup);
 
Signature · 1 line
1.9.1
#2 lore raw

PATCH v4 2/3 clk: s2mps11: Remove useless check for clk_table

In reply to Krzysztof Kozlowski

There is no need for checking if 'clk_table' is not NULL twice (first after allocation and second at the end of probe()). Also move allocation of this 'clk_table' to probe from s2mps11_clk_parse_dt as this is logical place for it.

---
 drivers/clk/clk-s2mps11.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/clk/clk-s2mps11.c +11 -13
index 843ec3646501..23ffd89c4023 100644
@@ -141,11 +141,6 @@ static struct device_node *s2mps11_clk_parse_dt(struct platform_device *pdev)
 		return ERR_PTR(-EINVAL);
 	}
 
-	clk_table = devm_kzalloc(&pdev->dev, sizeof(struct clk *) *
-				 S2MPS11_CLKS_NUM, GFP_KERNEL);
-	if (!clk_table)
-		return ERR_PTR(-ENOMEM);
-
 	for (i = 0; i < S2MPS11_CLKS_NUM; i++)
 		of_property_read_string_index(clk_np, "clock-output-names", i,
 				&s2mps11_clks_init[i].name);
@@ -168,6 +163,11 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
 
 	s2mps11_clk = s2mps11_clks;
 
+	clk_table = devm_kzalloc(&pdev->dev, sizeof(struct clk *) *
+				 S2MPS11_CLKS_NUM, GFP_KERNEL);
+	if (!clk_table)
+		return -ENOMEM;
+
 	/* Store clocks of_node in first element of s2mps11_clks array */
 	s2mps11_clks->clk_np = s2mps11_clk_parse_dt(pdev);
 	if (IS_ERR(s2mps11_clks->clk_np))
@@ -220,15 +220,13 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
 		clkdev_add(s2mps11_clk->lookup);
 	}
 
-	if (clk_table) {
-		for (i = 0; i < S2MPS11_CLKS_NUM; i++)
-			clk_table[i] = s2mps11_clks[i].clk;
+	for (i = 0; i < S2MPS11_CLKS_NUM; i++)
+		clk_table[i] = s2mps11_clks[i].clk;
 
-		clk_data.clks = clk_table;
-		clk_data.clk_num = S2MPS11_CLKS_NUM;
-		of_clk_add_provider(s2mps11_clks->clk_np,
-				of_clk_src_onecell_get, &clk_data);
-	}
+	clk_data.clks = clk_table;
+	clk_data.clk_num = S2MPS11_CLKS_NUM;
+	of_clk_add_provider(s2mps11_clks->clk_np, of_clk_src_onecell_get,
+			&clk_data);
 
 	platform_set_drvdata(pdev, s2mps11_clks);
 
Signature · 1 line
1.9.1
#3 lore raw

PATCH v4 3/3 clk: s2mps11: Add support for S2MPS14 clocks

In reply to Krzysztof Kozlowski

This patch adds support for S2MPS14 PMIC clocks (BT and AP) to the s2mps11 clock driver.

---
 drivers/clk/Kconfig       |  8 +++---
 drivers/clk/clk-s2mps11.c | 64 +++++++++++++++++++++++++++++++++++------------
 2 files changed, 52 insertions(+), 20 deletions(-)
drivers/clk/Kconfig +4 -4
index 6f56d3a4f010..8f9ce8ba036d 100644
@@ -65,12 +65,12 @@ config COMMON_CLK_SI570
 	  clock generators.
 
 config COMMON_CLK_S2MPS11
-	tristate "Clock driver for S2MPS11/S5M8767 MFD"
+	tristate "Clock driver for S2MPS1X/S5M8767 MFD"
 	depends on MFD_SEC_CORE
 	---help---
-	  This driver supports S2MPS11/S5M8767 crystal oscillator clock. These
-	  multi-function devices have 3 fixed-rate oscillators, clocked at
-	  32KHz each.
+	  This driver supports S2MPS11/S2MPS14/S5M8767 crystal oscillator
+	  clock. These multi-function devices have two (S2MPS14) or three
+	  (S2MPS11, S5M8767) fixed-rate oscillators, clocked at 32KHz each.
 
 config CLK_TWL6040
 	tristate "External McPDM functional clock from twl6040"
drivers/clk/clk-s2mps11.c +48 -16

141 lines not on this page · raw message

Signature · 1 line
1.9.1
#4 lore raw
In reply to Krzysztof Kozlowski

Quoting Krzysztof Kozlowski (2014-05-21 04:22:58)

Quoted 6 lines

Hi,

This is actually a resend of previous patches, rebased on latest 3.15-rc5. There are no changes, beside rebasing.

Quoted 6 lines

The first two fixes were posted previously as separate patches and they didn't get review [1]. I am attaching them here.
The last patch adds support for S2MPS14 device and already was reviewed/acked [2].

Mike, could you pick them up or should they go through MFD tree?

Applied to clk-next.

Regards,
Mike

Quoted 41 lines

[1] https://lkml.org/lkml/2014/4/7/42
[2] http://thread.gmane.org/gmane.linux.kernel.samsung-soc/28039/focus=310279

Changes since v3:
=================
1. Add Mike's acked-by (see [2]).
2. Rebase patch 3/3 on the fixes (patches 1 and 2).
3. Rebase on v3.15-rc5-157-g60b5f90d0fac

Changes since v2:
=================
1. Patch 2/3: Remove MFD cells of_compatible which aren't used by child drivers and are not documented.
2. Added Tomasz's Review-by.

Changes since v1:
=================
1. Patch 1/3: Update driver description in Kconfig.
2. Patch 2/3: Add of_compatible to all MFD cells.
3. Add Yadwinder's Review-by.

Best regards,
Krzysztof

Krzysztof Kozlowski (3):
clk: s2mps11: Add missing of_node_put and of_clk_del_provider
clk: s2mps11: Remove useless check for clk_table
clk: s2mps11: Add support for S2MPS14 clocks

 drivers/clk/Kconfig       |  8 ++---
 drivers/clk/clk-s2mps11.c | 88 +++++++++++++++++++++++++++++++++--------------
 2 files changed, 66 insertions(+), 30 deletions(-)
Signature · 1 line
1.9.1