* [PATCH v4 1/3] clk: s2mps11: Add missing of_node_put and of_clk_del_provider
2014-05-21 11:22 [PATCH v4 0/3] clk: s2mps11: Fixes and add support for S2MPS14 clocks Krzysztof Kozlowski
@ 2014-05-21 11:22 ` Krzysztof Kozlowski
2014-05-21 11:23 ` [PATCH v4 2/3] clk: s2mps11: Remove useless check for clk_table Krzysztof Kozlowski
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2014-05-21 11:22 UTC (permalink / raw)
To: Mike Turquette, linux-kernel, linux-samsung-soc
Cc: Lee Jones, Kyungmin Park, Marek Szyprowski,
Bartlomiej Zolnierkiewicz, Tomasz Figa, Krzysztof Kozlowski
Add of_clk_del_provider to remove previously registered clock provider.
Add of_node_put to decrement the ref count of clock nodes.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/clk/clk-s2mps11.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c
index f2f62a1bf61a..843ec3646501 100644
--- a/drivers/clk/clk-s2mps11.c
+++ b/drivers/clk/clk-s2mps11.c
@@ -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);
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v4 2/3] clk: s2mps11: Remove useless check for clk_table
2014-05-21 11:22 [PATCH v4 0/3] clk: s2mps11: Fixes and add support for S2MPS14 clocks Krzysztof Kozlowski
2014-05-21 11:22 ` [PATCH v4 1/3] clk: s2mps11: Add missing of_node_put and of_clk_del_provider Krzysztof Kozlowski
@ 2014-05-21 11:23 ` Krzysztof Kozlowski
2014-05-21 11:23 ` [PATCH v4 3/3] clk: s2mps11: Add support for S2MPS14 clocks Krzysztof Kozlowski
2014-05-23 22:51 ` [PATCH v4 0/3] clk: s2mps11: Fixes and add " Mike Turquette
3 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2014-05-21 11:23 UTC (permalink / raw)
To: Mike Turquette, linux-kernel, linux-samsung-soc
Cc: Lee Jones, Kyungmin Park, Marek Szyprowski,
Bartlomiej Zolnierkiewicz, Tomasz Figa, 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.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/clk/clk-s2mps11.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c
index 843ec3646501..23ffd89c4023 100644
--- a/drivers/clk/clk-s2mps11.c
+++ b/drivers/clk/clk-s2mps11.c
@@ -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);
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v4 3/3] clk: s2mps11: Add support for S2MPS14 clocks
2014-05-21 11:22 [PATCH v4 0/3] clk: s2mps11: Fixes and add support for S2MPS14 clocks Krzysztof Kozlowski
2014-05-21 11:22 ` [PATCH v4 1/3] clk: s2mps11: Add missing of_node_put and of_clk_del_provider Krzysztof Kozlowski
2014-05-21 11:23 ` [PATCH v4 2/3] clk: s2mps11: Remove useless check for clk_table Krzysztof Kozlowski
@ 2014-05-21 11:23 ` Krzysztof Kozlowski
2014-05-23 22:51 ` [PATCH v4 0/3] clk: s2mps11: Fixes and add " Mike Turquette
3 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2014-05-21 11:23 UTC (permalink / raw)
To: Mike Turquette, linux-kernel, linux-samsung-soc
Cc: Lee Jones, Kyungmin Park, Marek Szyprowski,
Bartlomiej Zolnierkiewicz, Tomasz Figa, Krzysztof Kozlowski
This patch adds support for S2MPS14 PMIC clocks (BT and AP) to the
s2mps11 clock driver.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Mike Turquette <mturquette@linaro.org>
---
drivers/clk/Kconfig | 8 +++---
drivers/clk/clk-s2mps11.c | 64 +++++++++++++++++++++++++++++++++++------------
2 files changed, 52 insertions(+), 20 deletions(-)
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 6f56d3a4f010..8f9ce8ba036d 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -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"
diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c
index 23ffd89c4023..9b7b5859a420 100644
--- a/drivers/clk/clk-s2mps11.c
+++ b/drivers/clk/clk-s2mps11.c
@@ -1,7 +1,7 @@
/*
* clk-s2mps11.c - Clock driver for S2MPS11.
*
- * Copyright (C) 2013 Samsung Electornics
+ * Copyright (C) 2013,2014 Samsung Electornics
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -13,10 +13,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
*/
#include <linux/module.h>
@@ -27,6 +23,7 @@
#include <linux/clk-provider.h>
#include <linux/platform_device.h>
#include <linux/mfd/samsung/s2mps11.h>
+#include <linux/mfd/samsung/s2mps14.h>
#include <linux/mfd/samsung/s5m8767.h>
#include <linux/mfd/samsung/core.h>
@@ -126,7 +123,21 @@ static struct clk_init_data s2mps11_clks_init[S2MPS11_CLKS_NUM] = {
},
};
-static struct device_node *s2mps11_clk_parse_dt(struct platform_device *pdev)
+static struct clk_init_data s2mps14_clks_init[S2MPS11_CLKS_NUM] = {
+ [S2MPS11_CLK_AP] = {
+ .name = "s2mps14_ap",
+ .ops = &s2mps11_clk_ops,
+ .flags = CLK_IS_ROOT,
+ },
+ [S2MPS11_CLK_BT] = {
+ .name = "s2mps14_bt",
+ .ops = &s2mps11_clk_ops,
+ .flags = CLK_IS_ROOT,
+ },
+};
+
+static struct device_node *s2mps11_clk_parse_dt(struct platform_device *pdev,
+ struct clk_init_data *clks_init)
{
struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
struct device_node *clk_np;
@@ -141,9 +152,12 @@ static struct device_node *s2mps11_clk_parse_dt(struct platform_device *pdev)
return ERR_PTR(-EINVAL);
}
- for (i = 0; i < S2MPS11_CLKS_NUM; i++)
+ for (i = 0; i < S2MPS11_CLKS_NUM; i++) {
+ if (!clks_init[i].name)
+ continue; /* Skip clocks not present in some devices */
of_property_read_string_index(clk_np, "clock-output-names", i,
- &s2mps11_clks_init[i].name);
+ &clks_init[i].name);
+ }
return clk_np;
}
@@ -153,6 +167,7 @@ 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;
unsigned int s2mps11_reg;
+ struct clk_init_data *clks_init;
int i, ret = 0;
u32 val;
@@ -168,26 +183,34 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
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))
- return PTR_ERR(s2mps11_clks->clk_np);
-
switch(platform_get_device_id(pdev)->driver_data) {
case S2MPS11X:
s2mps11_reg = S2MPS11_REG_RTC_CTRL;
+ clks_init = s2mps11_clks_init;
+ break;
+ case S2MPS14X:
+ s2mps11_reg = S2MPS14_REG_RTCCTRL;
+ clks_init = s2mps14_clks_init;
break;
case S5M8767X:
s2mps11_reg = S5M8767_REG_CTRL1;
+ clks_init = s2mps11_clks_init;
break;
default:
dev_err(&pdev->dev, "Invalid device type\n");
return -EINVAL;
};
+ /* Store clocks of_node in first element of s2mps11_clks array */
+ s2mps11_clks->clk_np = s2mps11_clk_parse_dt(pdev, clks_init);
+ if (IS_ERR(s2mps11_clks->clk_np))
+ return PTR_ERR(s2mps11_clks->clk_np);
+
for (i = 0; i < S2MPS11_CLKS_NUM; i++, s2mps11_clk++) {
+ if (!clks_init[i].name)
+ continue; /* Skip clocks not present in some devices */
s2mps11_clk->iodev = iodev;
- s2mps11_clk->hw.init = &s2mps11_clks_init[i];
+ s2mps11_clk->hw.init = &clks_init[i];
s2mps11_clk->mask = 1 << i;
s2mps11_clk->reg = s2mps11_reg;
@@ -220,8 +243,12 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
clkdev_add(s2mps11_clk->lookup);
}
- for (i = 0; i < S2MPS11_CLKS_NUM; i++)
+ for (i = 0; i < S2MPS11_CLKS_NUM; i++) {
+ /* Skip clocks not present on S2MPS14 */
+ if (!clks_init[i].name)
+ continue;
clk_table[i] = s2mps11_clks[i].clk;
+ }
clk_data.clks = clk_table;
clk_data.clk_num = S2MPS11_CLKS_NUM;
@@ -254,14 +281,19 @@ static int s2mps11_clk_remove(struct platform_device *pdev)
/* 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++)
+ for (i = 0; i < S2MPS11_CLKS_NUM; i++) {
+ /* Skip clocks not present on S2MPS14 */
+ if (!s2mps11_clks[i].lookup)
+ continue;
clkdev_drop(s2mps11_clks[i].lookup);
+ }
return 0;
}
static const struct platform_device_id s2mps11_clk_id[] = {
{ "s2mps11-clk", S2MPS11X},
+ { "s2mps14-clk", S2MPS14X},
{ "s5m8767-clk", S5M8767X},
{ },
};
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v4 0/3] clk: s2mps11: Fixes and add support for S2MPS14 clocks
2014-05-21 11:22 [PATCH v4 0/3] clk: s2mps11: Fixes and add support for S2MPS14 clocks Krzysztof Kozlowski
` (2 preceding siblings ...)
2014-05-21 11:23 ` [PATCH v4 3/3] clk: s2mps11: Add support for S2MPS14 clocks Krzysztof Kozlowski
@ 2014-05-23 22:51 ` Mike Turquette
3 siblings, 0 replies; 5+ messages in thread
From: Mike Turquette @ 2014-05-23 22:51 UTC (permalink / raw)
To: Krzysztof Kozlowski, linux-kernel, linux-samsung-soc
Cc: Lee Jones, Kyungmin Park, Marek Szyprowski,
Bartlomiej Zolnierkiewicz, Tomasz Figa, Krzysztof Kozlowski
Quoting Krzysztof Kozlowski (2014-05-21 04:22:58)
> 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?
Applied to clk-next.
Regards,
Mike
>
>
> [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(-)
>
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread