blob: cdf54da027b6a0d17935aa4c0d8e6fbf390eece2 [file] [log] [blame]
Jagan Teki78eb2a42018-08-05 11:16:33 +05301// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (C) 2018 Amarula Solutions.
4 * Author: Jagan Teki <jagan@amarulasolutions.com>
5 */
6
7#include <common.h>
8#include <clk-uclass.h>
9#include <dm.h>
10#include <errno.h>
11#include <asm/arch/ccu.h>
12#include <dt-bindings/clock/sun8i-r40-ccu.h>
13#include <dt-bindings/reset/sun8i-r40-ccu.h>
14
15static struct ccu_clk_gate r40_gates[] = {
16 [CLK_BUS_OTG] = GATE(0x060, BIT(25)),
17 [CLK_BUS_EHCI0] = GATE(0x060, BIT(26)),
18 [CLK_BUS_EHCI1] = GATE(0x060, BIT(27)),
19 [CLK_BUS_EHCI2] = GATE(0x060, BIT(28)),
20 [CLK_BUS_OHCI0] = GATE(0x060, BIT(29)),
21 [CLK_BUS_OHCI1] = GATE(0x060, BIT(30)),
22 [CLK_BUS_OHCI2] = GATE(0x060, BIT(31)),
23
24 [CLK_USB_PHY0] = GATE(0x0cc, BIT(8)),
25 [CLK_USB_PHY1] = GATE(0x0cc, BIT(9)),
26 [CLK_USB_PHY2] = GATE(0x0cc, BIT(10)),
27 [CLK_USB_OHCI0] = GATE(0x0cc, BIT(16)),
28 [CLK_USB_OHCI1] = GATE(0x0cc, BIT(17)),
29 [CLK_USB_OHCI2] = GATE(0x0cc, BIT(18)),
30};
31
32static struct ccu_reset r40_resets[] = {
33 [RST_USB_PHY0] = RESET(0x0cc, BIT(0)),
34 [RST_USB_PHY1] = RESET(0x0cc, BIT(1)),
35 [RST_USB_PHY2] = RESET(0x0cc, BIT(2)),
36
37 [RST_BUS_OTG] = RESET(0x2c0, BIT(25)),
38 [RST_BUS_EHCI0] = RESET(0x2c0, BIT(26)),
39 [RST_BUS_EHCI1] = RESET(0x2c0, BIT(27)),
40 [RST_BUS_EHCI2] = RESET(0x2c0, BIT(28)),
41 [RST_BUS_OHCI0] = RESET(0x2c0, BIT(29)),
42 [RST_BUS_OHCI1] = RESET(0x2c0, BIT(30)),
43 [RST_BUS_OHCI2] = RESET(0x2c0, BIT(31)),
44};
45
46static const struct ccu_desc r40_ccu_desc = {
47 .gates = r40_gates,
48 .resets = r40_resets,
49};
50
51static int r40_clk_bind(struct udevice *dev)
52{
53 return sunxi_reset_bind(dev, ARRAY_SIZE(r40_resets));
54}
55
56static const struct udevice_id r40_clk_ids[] = {
57 { .compatible = "allwinner,sun8i-r40-ccu",
58 .data = (ulong)&r40_ccu_desc },
59 { }
60};
61
62U_BOOT_DRIVER(clk_sun8i_r40) = {
63 .name = "sun8i_r40_ccu",
64 .id = UCLASS_CLK,
65 .of_match = r40_clk_ids,
66 .priv_auto_alloc_size = sizeof(struct ccu_priv),
67 .ops = &sunxi_clk_ops,
68 .probe = sunxi_clk_probe,
69 .bind = r40_clk_bind,
70};