brcm2708: update linux 4.4 patches to latest version
[openwrt/svn-archive/archive.git] / target / linux / brcm2708 / patches-4.4 / 0162-clk-bcm2835-Add-a-driver-for-the-auxiliary-periphera.patch
1 From 924276b92ff47f0e778a9405d00637be4ca88736 Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Tue, 15 Dec 2015 15:35:58 -0800
4 Subject: [PATCH 162/170] clk: bcm2835: Add a driver for the auxiliary
5 peripheral clock gates.
6
7 There are a pair of SPI masters and a mini UART that were last minute
8 additions. As a result, they didn't get integrated in the same way as
9 the other gates off of the VPU clock in CPRMAN.
10
11 Signed-off-by: Eric Anholt <eric@anholt.net>
12 Signed-off-by: Michael Turquette <mturquette@baylibre.com>
13
14 updated Makefile to preserve the rasoberry pi architectures
15 ---
16 drivers/clk/bcm/Makefile | 1 +
17 drivers/clk/bcm/clk-bcm2835-aux.c | 85 +++++++++++++++++++++++++++++++++++++++
18 2 files changed, 86 insertions(+)
19 create mode 100644 drivers/clk/bcm/clk-bcm2835-aux.c
20
21 --- a/drivers/clk/bcm/Makefile
22 +++ b/drivers/clk/bcm/Makefile
23 @@ -4,6 +4,7 @@ obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm281
24 obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm21664.o
25 obj-$(CONFIG_COMMON_CLK_IPROC) += clk-iproc-armpll.o clk-iproc-pll.o clk-iproc-asiu.o
26 obj-$(CONFIG_ARCH_BCM2835)$(CONFIG_ARCH_BCM2708)$(CONFIG_ARCH_BCM2709) += clk-bcm2835.o
27 +obj-$(CONFIG_ARCH_BCM2835) += clk-bcm2835-aux.o
28 obj-$(CONFIG_COMMON_CLK_IPROC) += clk-ns2.o
29 obj-$(CONFIG_ARCH_BCM_CYGNUS) += clk-cygnus.o
30 obj-$(CONFIG_ARCH_BCM_NSP) += clk-nsp.o
31 --- /dev/null
32 +++ b/drivers/clk/bcm/clk-bcm2835-aux.c
33 @@ -0,0 +1,85 @@
34 +/*
35 + * Copyright (C) 2015 Broadcom
36 + *
37 + * This program is free software; you can redistribute it and/or modify
38 + * it under the terms of the GNU General Public License as published by
39 + * the Free Software Foundation; either version 2 of the License, or
40 + * (at your option) any later version.
41 + *
42 + * This program is distributed in the hope that it will be useful,
43 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
44 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 + * GNU General Public License for more details.
46 + */
47 +
48 +#include <linux/clk.h>
49 +#include <linux/clk-provider.h>
50 +#include <linux/clk/bcm2835.h>
51 +#include <linux/module.h>
52 +#include <linux/platform_device.h>
53 +#include <dt-bindings/clock/bcm2835-aux.h>
54 +
55 +#define BCM2835_AUXIRQ 0x00
56 +#define BCM2835_AUXENB 0x04
57 +
58 +static int bcm2835_aux_clk_probe(struct platform_device *pdev)
59 +{
60 + struct device *dev = &pdev->dev;
61 + struct clk_onecell_data *onecell;
62 + const char *parent;
63 + struct clk *parent_clk;
64 + struct resource *res;
65 + void __iomem *reg, *gate;
66 +
67 + parent_clk = devm_clk_get(dev, NULL);
68 + if (IS_ERR(parent_clk))
69 + return PTR_ERR(parent_clk);
70 + parent = __clk_get_name(parent_clk);
71 +
72 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
73 + reg = devm_ioremap_resource(dev, res);
74 + if (!reg)
75 + return -ENODEV;
76 +
77 + onecell = devm_kmalloc(dev, sizeof(*onecell), GFP_KERNEL);
78 + if (!onecell)
79 + return -ENOMEM;
80 + onecell->clk_num = BCM2835_AUX_CLOCK_COUNT;
81 + onecell->clks = devm_kcalloc(dev, BCM2835_AUX_CLOCK_COUNT,
82 + sizeof(*onecell->clks), GFP_KERNEL);
83 + if (!onecell->clks)
84 + return -ENOMEM;
85 +
86 + gate = reg + BCM2835_AUXENB;
87 + onecell->clks[BCM2835_AUX_CLOCK_UART] =
88 + clk_register_gate(dev, "aux_uart", parent, 0, gate, 0, 0, NULL);
89 +
90 + onecell->clks[BCM2835_AUX_CLOCK_SPI1] =
91 + clk_register_gate(dev, "aux_spi1", parent, 0, gate, 1, 0, NULL);
92 +
93 + onecell->clks[BCM2835_AUX_CLOCK_SPI2] =
94 + clk_register_gate(dev, "aux_spi2", parent, 0, gate, 2, 0, NULL);
95 +
96 + of_clk_add_provider(pdev->dev.of_node, of_clk_src_onecell_get, onecell);
97 +
98 + return 0;
99 +}
100 +
101 +static const struct of_device_id bcm2835_aux_clk_of_match[] = {
102 + { .compatible = "brcm,bcm2835-aux", },
103 + {},
104 +};
105 +MODULE_DEVICE_TABLE(of, bcm2835_aux_clk_of_match);
106 +
107 +static struct platform_driver bcm2835_aux_clk_driver = {
108 + .driver = {
109 + .name = "bcm2835-aux-clk",
110 + .of_match_table = bcm2835_aux_clk_of_match,
111 + },
112 + .probe = bcm2835_aux_clk_probe,
113 +};
114 +builtin_platform_driver(bcm2835_aux_clk_driver);
115 +
116 +MODULE_AUTHOR("Eric Anholt <eric@anholt.net>");
117 +MODULE_DESCRIPTION("BCM2835 auxiliary peripheral clock driver");
118 +MODULE_LICENSE("GPL v2");