a8fd5afcb6b3631f94159bd0287a7475a70bc586
[openwrt/staging/ynezz.git] /
1 From 317f8659bba01b307cbe4e9902d4e3d333fd7164 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Sun, 16 Jul 2017 12:39:17 +0200
4 Subject: [PATCH V2 4/8] tty/bcm63xx_uart: allow naming clock in device tree
5
6 Codify using a named clock for the refclk of the uart. This makes it
7 easier if we might need to add a gating clock (like present on the
8 BCM6345).
9
10 Acked-by: Rob Herring <robh@kernel.org>
11 Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
13 Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
14 ---
15 Documentation/devicetree/bindings/serial/brcm,bcm6345-uart.txt | 6 ++++++
16 drivers/tty/serial/bcm63xx_uart.c | 6 ++++--
17 2 files changed, 10 insertions(+), 2 deletions(-)
18
19 --- a/Documentation/devicetree/bindings/serial/brcm,bcm6345-uart.txt
20 +++ b/Documentation/devicetree/bindings/serial/brcm,bcm6345-uart.txt
21 @@ -11,6 +11,11 @@ Required properties:
22 - clocks: Clock driving the hardware; used to figure out the baud rate
23 divisor.
24
25 +
26 +Optional properties:
27 +
28 +- clock-names: Should be "refclk".
29 +
30 Example:
31
32 uart0: serial@14e00520 {
33 @@ -19,6 +24,7 @@ Example:
34 interrupt-parent = <&periph_intc>;
35 interrupts = <2>;
36 clocks = <&periph_clk>;
37 + clock-names = "refclk";
38 };
39
40 clocks {
41 --- a/drivers/tty/serial/bcm63xx_uart.c
42 +++ b/drivers/tty/serial/bcm63xx_uart.c
43 @@ -841,8 +841,10 @@ static int bcm_uart_probe(struct platfor
44 if (!res_irq)
45 return -ENODEV;
46
47 - clk = pdev->dev.of_node ? of_clk_get(pdev->dev.of_node, 0) :
48 - clk_get(&pdev->dev, "refclk");
49 + clk = clk_get(&pdev->dev, "refclk");
50 + if (IS_ERR(clk) && pdev->dev.of_node)
51 + clk = of_clk_get(pdev->dev.of_node, 0);
52 +
53 if (IS_ERR(clk))
54 return -ENODEV;
55