sunxi: add support for 4.1
[openwrt.git] / target / linux / sunxi / patches-4.1 / 162-clk-sunxi-codec-clock.patch
1 From 9b95732096c11d84bd0082aed0d575d8c09e3ab6 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= <emilio@elopez.com.ar>
3 Date: Fri, 18 Jul 2014 15:49:37 -0300
4 Subject: [PATCH] clk: sunxi: codec clock support
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 The codec clock on sun4i, sun5i and sun7i is a simple gate with PLL2 as
10 parent.
11
12 Signed-off-by: Emilio López <emilio@elopez.com.ar>
13 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
14 ---
15  drivers/clk/sunxi/Makefile        |  1 +
16  drivers/clk/sunxi/clk-a10-codec.c | 41 +++++++++++++++++++++++++++++++++++++++
17  2 files changed, 42 insertions(+)
18  create mode 100644 drivers/clk/sunxi/clk-a10-codec.c
19
20 diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
21 index eb36c38..6fa845e 100644
22 --- a/drivers/clk/sunxi/Makefile
23 +++ b/drivers/clk/sunxi/Makefile
24 @@ -3,6 +3,7 @@
25  #
26  
27  obj-y += clk-sunxi.o clk-factors.o
28 +obj-y += clk-a10-codec.o
29  obj-y += clk-a10-hosc.o
30  obj-y += clk-a10-pll2.o
31  obj-y += clk-a20-gmac.o
32 diff --git a/drivers/clk/sunxi/clk-a10-codec.c b/drivers/clk/sunxi/clk-a10-codec.c
33 new file mode 100644
34 index 0000000..c70acbf
35 --- /dev/null
36 +++ b/drivers/clk/sunxi/clk-a10-codec.c
37 @@ -0,0 +1,41 @@
38 +/*
39 + * Copyright 2013 Emilio López
40 + *
41 + * Emilio López <emilio@elopez.com.ar>
42 + *
43 + * This program is free software; you can redistribute it and/or modify
44 + * it under the terms of the GNU General Public License as published by
45 + * the Free Software Foundation; either version 2 of the License, or
46 + * (at your option) any later version.
47 + *
48 + * This program is distributed in the hope that it will be useful,
49 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
50 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
51 + * GNU General Public License for more details.
52 + */
53 +
54 +#include <linux/clk-provider.h>
55 +#include <linux/clkdev.h>
56 +#include <linux/of.h>
57 +#include <linux/of_address.h>
58 +
59 +#define SUN4I_CODEC_GATE       31
60 +
61 +static void __init sun4i_codec_clk_setup(struct device_node *node)
62 +{
63 +       struct clk *clk;
64 +       const char *clk_name = node->name, *parent_name;
65 +       void __iomem *reg;
66 +
67 +       of_property_read_string(node, "clock-output-names", &clk_name);
68 +       parent_name = of_clk_get_parent_name(node, 0);
69 +       reg = of_iomap(node, 0);
70 +
71 +       clk = clk_register_gate(NULL, clk_name, parent_name,
72 +                               CLK_SET_RATE_PARENT, reg,
73 +                               SUN4I_CODEC_GATE, 0, NULL);
74 +
75 +       if (!IS_ERR(clk))
76 +               of_clk_add_provider(node, of_clk_src_simple_get, clk);
77 +}
78 +CLK_OF_DECLARE(sun4i_codec, "allwinner,sun4i-a10-codec-clk", sun4i_codec_clk_setup);