1 From b0fde8ea889e47505e4112d89da4be9469a37775 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
7 Signed-off-by: Eric Anholt <eric@anholt.net>
9 .../bindings/clock/brcm,bcm2835-cprman.txt | 12 ++++-
10 drivers/clk/bcm/clk-bcm2835.c | 54 +++++++++++++++++-----
11 2 files changed, 54 insertions(+), 12 deletions(-)
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:
23 + - External oscillator
28 + Only external oscillator is required. The DSI clocks may
29 + not be present, in which case their children will be
34 --- a/drivers/clk/bcm/clk-bcm2835.c
35 +++ b/drivers/clk/bcm/clk-bcm2835.c
37 #define LOCK_TIMEOUT_NS 100000000
38 #define BCM2835_MAX_FB_RATE 1750000000u
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.
45 +static const char *cprman_parent_names[] = {
52 struct bcm2835_cprman {
55 spinlock_t regs_lock; /* spinlock for all clocks */
56 - const char *osc_name;
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.
63 + const char *real_parent_names[ARRAY_SIZE(cprman_parent_names)];
65 struct clk_onecell_data onecell;
67 @@ -1168,7 +1186,7 @@ static struct clk *bcm2835_register_pll(
68 memset(&init, 0, sizeof(init));
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];
74 init.name = data->name;
75 init.ops = &bcm2835_pll_clk_ops;
76 @@ -1251,17 +1269,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];
84 - * Replace our "xosc" references with the oscillator's
86 + * Replace our strings referencing parent clocks with the
87 + * actual clock-output-name of the parent.
89 for (i = 0; i < data->num_mux_parents; i++) {
90 - if (strcmp(data->parents[i], "xosc") == 0)
91 - parents[i] = cprman->osc_name;
93 - parents[i] = data->parents[i];
94 + parents[i] = data->parents[i];
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];
104 memset(&init, 0, sizeof(init));
105 @@ -1883,8 +1905,18 @@ static int bcm2835_clk_probe(struct plat
106 if (IS_ERR(cprman->regs))
107 return PTR_ERR(cprman->regs);
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);
116 + * Make sure the external oscillator has been registered.
118 + * The other (DSI) clocks are not present on older device
119 + * trees, which we still need to support for backwards
122 + if (!cprman->real_parent_names[0])
125 platform_set_drvdata(pdev, cprman);