aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen-Yu Tsai <wens@csie.org>2014-07-03 10:55:41 -0400
committerMaxime Ripard <maxime.ripard@free-electrons.com>2014-07-07 04:46:21 -0400
commit57a1fbf28424561a080b34fbdd04661282aea40e (patch)
treecef5423b166b17498992288248389167fb24418f
parent515c1a4bdcd9b55e2c21e897a9ca276bd708d145 (diff)
clk: sunxi: Add A23 APB0 divider clock support
The A23 has an almost identical PRCM clock tree. The difference in the APB0 clock is the smallest divisor is 1, instead of 2. This patch adds a separate sun8i-a23-apb0-clk driver to support it. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
-rw-r--r--Documentation/devicetree/bindings/clock/sunxi.txt1
-rw-r--r--drivers/clk/sunxi/Makefile4
-rw-r--r--drivers/clk/sunxi/clk-sun8i-apb0.c68
3 files changed, 72 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
index 18030ce96b71..68dbd3d80f31 100644
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
@@ -28,6 +28,7 @@ Required properties:
28 "allwinner,sun8i-a23-ahb1-gates-clk" - for the AHB1 gates on A23 28 "allwinner,sun8i-a23-ahb1-gates-clk" - for the AHB1 gates on A23
29 "allwinner,sun4i-a10-apb0-clk" - for the APB0 clock 29 "allwinner,sun4i-a10-apb0-clk" - for the APB0 clock
30 "allwinner,sun6i-a31-apb0-clk" - for the APB0 clock on A31 30 "allwinner,sun6i-a31-apb0-clk" - for the APB0 clock on A31
31 "allwinner,sun8i-a23-apb0-clk" - for the APB0 clock on A23
31 "allwinner,sun4i-a10-apb0-gates-clk" - for the APB0 gates on A10 32 "allwinner,sun4i-a10-apb0-gates-clk" - for the APB0 gates on A10
32 "allwinner,sun5i-a13-apb0-gates-clk" - for the APB0 gates on A13 33 "allwinner,sun5i-a13-apb0-gates-clk" - for the APB0 gates on A13
33 "allwinner,sun5i-a10s-apb0-gates-clk" - for the APB0 gates on A10s 34 "allwinner,sun5i-a10s-apb0-gates-clk" - for the APB0 gates on A10s
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index 762fd64dbd1f..6850cba35871 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -6,4 +6,6 @@ obj-y += clk-sunxi.o clk-factors.o
6obj-y += clk-a10-hosc.o 6obj-y += clk-a10-hosc.o
7obj-y += clk-a20-gmac.o 7obj-y += clk-a20-gmac.o
8 8
9obj-$(CONFIG_MFD_SUN6I_PRCM) += clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o 9obj-$(CONFIG_MFD_SUN6I_PRCM) += \
10 clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o \
11 clk-sun8i-apb0.o
diff --git a/drivers/clk/sunxi/clk-sun8i-apb0.c b/drivers/clk/sunxi/clk-sun8i-apb0.c
new file mode 100644
index 000000000000..196a4997f9d9
--- /dev/null
+++ b/drivers/clk/sunxi/clk-sun8i-apb0.c
@@ -0,0 +1,68 @@
1/*
2 * Copyright (C) 2014 Chen-Yu Tsai
3 * Author: Chen-Yu Tsai <wens@csie.org>
4 *
5 * Allwinner A23 APB0 clock driver
6 *
7 * License Terms: GNU General Public License v2
8 *
9 * Based on clk-sun6i-apb0.c
10 * Allwinner A31 APB0 clock driver
11 *
12 * Copyright (C) 2014 Free Electrons
13 * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
14 *
15 */
16
17#include <linux/clk-provider.h>
18#include <linux/module.h>
19#include <linux/of.h>
20#include <linux/platform_device.h>
21
22static int sun8i_a23_apb0_clk_probe(struct platform_device *pdev)
23{
24 struct device_node *np = pdev->dev.of_node;
25 const char *clk_name = np->name;
26 const char *clk_parent;
27 struct resource *r;
28 void __iomem *reg;
29 struct clk *clk;
30
31 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
32 reg = devm_ioremap_resource(&pdev->dev, r);
33 if (IS_ERR(reg))
34 return PTR_ERR(reg);
35
36 clk_parent = of_clk_get_parent_name(np, 0);
37 if (!clk_parent)
38 return -EINVAL;
39
40 of_property_read_string(np, "clock-output-names", &clk_name);
41
42 /* The A23 APB0 clock is a standard 2 bit wide divider clock */
43 clk = clk_register_divider(&pdev->dev, clk_name, clk_parent, 0, reg,
44 0, 2, CLK_DIVIDER_POWER_OF_TWO, NULL);
45 if (IS_ERR(clk))
46 return PTR_ERR(clk);
47
48 return of_clk_add_provider(np, of_clk_src_simple_get, clk);
49}
50
51const struct of_device_id sun8i_a23_apb0_clk_dt_ids[] = {
52 { .compatible = "allwinner,sun8i-a23-apb0-clk" },
53 { /* sentinel */ }
54};
55
56static struct platform_driver sun8i_a23_apb0_clk_driver = {
57 .driver = {
58 .name = "sun8i-a23-apb0-clk",
59 .owner = THIS_MODULE,
60 .of_match_table = sun8i_a23_apb0_clk_dt_ids,
61 },
62 .probe = sun8i_a23_apb0_clk_probe,
63};
64module_platform_driver(sun8i_a23_apb0_clk_driver);
65
66MODULE_AUTHOR("Chen-Yu Tsai <wens@csie.org>");
67MODULE_DESCRIPTION("Allwinner A23 APB0 clock Driver");
68MODULE_LICENSE("GPL v2");