Commit e8b60a45 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Mike Turquette

clk: s2mps11: Add support for S2MPS14 clocks

This patch adds support for S2MPS14 PMIC clocks (BT and AP) to the
s2mps11 clock driver.
Signed-off-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: default avatarYadwinder Singh Brar <yadi.brar@samsung.com>
Reviewed-by: default avatarTomasz Figa <t.figa@samsung.com>
Acked-by: default avatarMike Turquette <mturquette@linaro.org>
Signed-off-by: default avatarMike Turquette <mturquette@linaro.org>
parent 7002483c
...@@ -65,12 +65,12 @@ config COMMON_CLK_SI570 ...@@ -65,12 +65,12 @@ config COMMON_CLK_SI570
clock generators. clock generators.
config COMMON_CLK_S2MPS11 config COMMON_CLK_S2MPS11
tristate "Clock driver for S2MPS11/S5M8767 MFD" tristate "Clock driver for S2MPS1X/S5M8767 MFD"
depends on MFD_SEC_CORE depends on MFD_SEC_CORE
---help--- ---help---
This driver supports S2MPS11/S5M8767 crystal oscillator clock. These This driver supports S2MPS11/S2MPS14/S5M8767 crystal oscillator
multi-function devices have 3 fixed-rate oscillators, clocked at clock. These multi-function devices have two (S2MPS14) or three
32KHz each. (S2MPS11, S5M8767) fixed-rate oscillators, clocked at 32KHz each.
config CLK_TWL6040 config CLK_TWL6040
tristate "External McPDM functional clock from twl6040" tristate "External McPDM functional clock from twl6040"
......
/* /*
* clk-s2mps11.c - Clock driver for S2MPS11. * 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 * 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 * under the terms of the GNU General Public License as published by the
...@@ -13,10 +13,6 @@ ...@@ -13,10 +13,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * 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> #include <linux/module.h>
...@@ -27,6 +23,7 @@ ...@@ -27,6 +23,7 @@
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mfd/samsung/s2mps11.h> #include <linux/mfd/samsung/s2mps11.h>
#include <linux/mfd/samsung/s2mps14.h>
#include <linux/mfd/samsung/s5m8767.h> #include <linux/mfd/samsung/s5m8767.h>
#include <linux/mfd/samsung/core.h> #include <linux/mfd/samsung/core.h>
...@@ -126,7 +123,21 @@ static struct clk_init_data s2mps11_clks_init[S2MPS11_CLKS_NUM] = { ...@@ -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 sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
struct device_node *clk_np; struct device_node *clk_np;
...@@ -141,9 +152,12 @@ static struct device_node *s2mps11_clk_parse_dt(struct platform_device *pdev) ...@@ -141,9 +152,12 @@ static struct device_node *s2mps11_clk_parse_dt(struct platform_device *pdev)
return ERR_PTR(-EINVAL); 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, of_property_read_string_index(clk_np, "clock-output-names", i,
&s2mps11_clks_init[i].name); &clks_init[i].name);
}
return clk_np; return clk_np;
} }
...@@ -153,6 +167,7 @@ static int s2mps11_clk_probe(struct platform_device *pdev) ...@@ -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 sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
struct s2mps11_clk *s2mps11_clks, *s2mps11_clk; struct s2mps11_clk *s2mps11_clks, *s2mps11_clk;
unsigned int s2mps11_reg; unsigned int s2mps11_reg;
struct clk_init_data *clks_init;
int i, ret = 0; int i, ret = 0;
u32 val; u32 val;
...@@ -168,26 +183,34 @@ static int s2mps11_clk_probe(struct platform_device *pdev) ...@@ -168,26 +183,34 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
if (!clk_table) if (!clk_table)
return -ENOMEM; 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) { switch(platform_get_device_id(pdev)->driver_data) {
case S2MPS11X: case S2MPS11X:
s2mps11_reg = S2MPS11_REG_RTC_CTRL; 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; break;
case S5M8767X: case S5M8767X:
s2mps11_reg = S5M8767_REG_CTRL1; s2mps11_reg = S5M8767_REG_CTRL1;
clks_init = s2mps11_clks_init;
break; break;
default: default:
dev_err(&pdev->dev, "Invalid device type\n"); dev_err(&pdev->dev, "Invalid device type\n");
return -EINVAL; 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++) { 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->iodev = iodev;
s2mps11_clk->hw.init = &s2mps11_clks_init[i]; s2mps11_clk->hw.init = &clks_init[i];
s2mps11_clk->mask = 1 << i; s2mps11_clk->mask = 1 << i;
s2mps11_clk->reg = s2mps11_reg; s2mps11_clk->reg = s2mps11_reg;
...@@ -220,8 +243,12 @@ static int s2mps11_clk_probe(struct platform_device *pdev) ...@@ -220,8 +243,12 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
clkdev_add(s2mps11_clk->lookup); 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_table[i] = s2mps11_clks[i].clk;
}
clk_data.clks = clk_table; clk_data.clks = clk_table;
clk_data.clk_num = S2MPS11_CLKS_NUM; clk_data.clk_num = S2MPS11_CLKS_NUM;
...@@ -254,14 +281,19 @@ static int s2mps11_clk_remove(struct platform_device *pdev) ...@@ -254,14 +281,19 @@ static int s2mps11_clk_remove(struct platform_device *pdev)
/* Drop the reference obtained in s2mps11_clk_parse_dt */ /* Drop the reference obtained in s2mps11_clk_parse_dt */
of_node_put(s2mps11_clks[0].clk_np); 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); clkdev_drop(s2mps11_clks[i].lookup);
}
return 0; return 0;
} }
static const struct platform_device_id s2mps11_clk_id[] = { static const struct platform_device_id s2mps11_clk_id[] = {
{ "s2mps11-clk", S2MPS11X}, { "s2mps11-clk", S2MPS11X},
{ "s2mps14-clk", S2MPS14X},
{ "s5m8767-clk", S5M8767X}, { "s5m8767-clk", S5M8767X},
{ }, { },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment