brcm2708: update linux 4.4 patches to latest version
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0433-clk-bcm2835-Do-appropriate-name-lookups-for-DSI1-s-p.patch
1 From 9c7608ef6a1cdcc91462be7f48de0bdfc25dd247 Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Thu, 14 Apr 2016 15:13:53 -0700
4 Subject: [PATCH] clk: bcm2835: Do appropriate name lookups for DSI1's parents
5 as well.
6
7 Signed-off-by: Eric Anholt <eric@anholt.net>
8 ---
9 .../bindings/clock/brcm,bcm2835-cprman.txt | 12 ++++-
10 drivers/clk/bcm/clk-bcm2835.c | 54 +++++++++++++++++-----
11 2 files changed, 54 insertions(+), 12 deletions(-)
12
13 --- a/Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt
14 +++ b/Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt
15 @@ -16,7 +16,17 @@ Required properties:
16 - #clock-cells: Should be <1>. The permitted clock-specifier values can be
17 found in include/dt-bindings/clock/bcm2835.h
18 - reg: Specifies base physical address and size of the registers
19 -- clocks: The external oscillator clock phandle
20 +- clocks: phandles to the parent clocks used as input to the module, in
21 + the following order:
22 +
23 + - External oscillator
24 + - DSI1 byte clock
25 + - DSI1 DDR2 clock
26 + - DSI1 DDR clock
27 +
28 + Only external oscillator is required. The DSI clocks may
29 + not be present, in which case their children will be
30 + unusable.
31
32 Example:
33
34 --- a/drivers/clk/bcm/clk-bcm2835.c
35 +++ b/drivers/clk/bcm/clk-bcm2835.c
36 @@ -297,11 +297,29 @@
37 #define LOCK_TIMEOUT_NS 100000000
38 #define BCM2835_MAX_FB_RATE 1750000000u
39
40 +/*
41 + * Names of clocks used within the driver that need to be replaced
42 + * with an external parent's name. This array is in the order that
43 + * the clocks node in the DT references external clocks.
44 + */
45 +static const char *cprman_parent_names[] = {
46 + "xosc",
47 + "dsi1_byte",
48 + "dsi1_ddr2",
49 + "dsi1_ddr",
50 +};
51 +
52 struct bcm2835_cprman {
53 struct device *dev;
54 void __iomem *regs;
55 spinlock_t regs_lock; /* spinlock for all clocks */
56 - const char *osc_name;
57 +
58 + /*
59 + * Real names of cprman clock parents looked up through
60 + * of_clk_get_parent_name(), which will be used in the
61 + * parent_names[] arrays for clock registration.
62 + */
63 + const char *real_parent_names[ARRAY_SIZE(cprman_parent_names)];
64
65 struct clk_onecell_data onecell;
66 struct clk *clks[];
67 @@ -1170,7 +1188,7 @@ static struct clk *bcm2835_register_pll(
68 memset(&init, 0, sizeof(init));
69
70 /* All of the PLLs derive from the external oscillator. */
71 - init.parent_names = &cprman->osc_name;
72 + init.parent_names = &cprman->real_parent_names[0];
73 init.num_parents = 1;
74 init.name = data->name;
75 init.ops = &bcm2835_pll_clk_ops;
76 @@ -1253,17 +1271,21 @@ static struct clk *bcm2835_register_cloc
77 struct bcm2835_clock *clock;
78 struct clk_init_data init;
79 const char *parents[1 << CM_SRC_BITS];
80 - size_t i;
81 + size_t i, j;
82
83 /*
84 - * Replace our "xosc" references with the oscillator's
85 - * actual name.
86 + * Replace our strings referencing parent clocks with the
87 + * actual clock-output-name of the parent.
88 */
89 for (i = 0; i < data->num_mux_parents; i++) {
90 - if (strcmp(data->parents[i], "xosc") == 0)
91 - parents[i] = cprman->osc_name;
92 - else
93 - parents[i] = data->parents[i];
94 + parents[i] = data->parents[i];
95 +
96 + for (j = 0; j < ARRAY_SIZE(cprman_parent_names); j++) {
97 + if (strcmp(parents[i], cprman_parent_names[j]) == 0) {
98 + parents[i] = cprman->real_parent_names[j];
99 + break;
100 + }
101 + }
102 }
103
104 memset(&init, 0, sizeof(init));
105 @@ -1885,8 +1907,18 @@ static int bcm2835_clk_probe(struct plat
106 if (IS_ERR(cprman->regs))
107 return PTR_ERR(cprman->regs);
108
109 - cprman->osc_name = of_clk_get_parent_name(dev->of_node, 0);
110 - if (!cprman->osc_name)
111 + for (i = 0; i < ARRAY_SIZE(cprman_parent_names); i++) {
112 + cprman->real_parent_names[i] =
113 + of_clk_get_parent_name(dev->of_node, i);
114 + }
115 + /*
116 + * Make sure the external oscillator has been registered.
117 + *
118 + * The other (DSI) clocks are not present on older device
119 + * trees, which we still need to support for backwards
120 + * compatibility.
121 + */
122 + if (!cprman->real_parent_names[0])
123 return -ENODEV;
124
125 platform_set_drvdata(pdev, cprman);