blob: eb0a45d97ff145a713732c1fc5bc677f43a06356 [file] [log] [blame]
Jagan Teki1d150b42018-12-22 21:32:49 +05301// SPDX-License-Identifier: GPL-2.0+
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/sun50i-a64-ccu.h>
Jagan Teki7f6c2a82019-01-18 22:18:13 +053013#include <dt-bindings/reset/sun50i-a64-ccu.h>
Jagan Teki1d150b42018-12-22 21:32:49 +053014
15static const struct ccu_clk_gate a64_gates[] = {
16 [CLK_BUS_OTG] = GATE(0x060, BIT(23)),
17 [CLK_BUS_EHCI0] = GATE(0x060, BIT(24)),
18 [CLK_BUS_EHCI1] = GATE(0x060, BIT(25)),
19 [CLK_BUS_OHCI0] = GATE(0x060, BIT(28)),
20 [CLK_BUS_OHCI1] = GATE(0x060, BIT(29)),
21
22 [CLK_USB_PHY0] = GATE(0x0cc, BIT(8)),
23 [CLK_USB_PHY1] = GATE(0x0cc, BIT(9)),
24 [CLK_USB_HSIC] = GATE(0x0cc, BIT(10)),
25 [CLK_USB_HSIC_12M] = GATE(0x0cc, BIT(11)),
26 [CLK_USB_OHCI0] = GATE(0x0cc, BIT(16)),
27 [CLK_USB_OHCI1] = GATE(0x0cc, BIT(17)),
28};
29
Jagan Teki7f6c2a82019-01-18 22:18:13 +053030static const struct ccu_reset a64_resets[] = {
31 [RST_USB_PHY0] = RESET(0x0cc, BIT(0)),
32 [RST_USB_PHY1] = RESET(0x0cc, BIT(1)),
33 [RST_USB_HSIC] = RESET(0x0cc, BIT(2)),
34
35 [RST_BUS_OTG] = RESET(0x2c0, BIT(23)),
36 [RST_BUS_EHCI0] = RESET(0x2c0, BIT(24)),
37 [RST_BUS_EHCI1] = RESET(0x2c0, BIT(25)),
38 [RST_BUS_OHCI0] = RESET(0x2c0, BIT(28)),
39 [RST_BUS_OHCI1] = RESET(0x2c0, BIT(29)),
40};
41
Jagan Teki1d150b42018-12-22 21:32:49 +053042static const struct ccu_desc a64_ccu_desc = {
43 .gates = a64_gates,
Jagan Teki7f6c2a82019-01-18 22:18:13 +053044 .resets = a64_resets,
Jagan Teki1d150b42018-12-22 21:32:49 +053045};
46
Jagan Teki7f6c2a82019-01-18 22:18:13 +053047static int a64_clk_bind(struct udevice *dev)
48{
49 return sunxi_reset_bind(dev, ARRAY_SIZE(a64_resets));
50}
51
Jagan Teki1d150b42018-12-22 21:32:49 +053052static const struct udevice_id a64_ccu_ids[] = {
53 { .compatible = "allwinner,sun50i-a64-ccu",
54 .data = (ulong)&a64_ccu_desc },
55 { }
56};
57
58U_BOOT_DRIVER(clk_sun50i_a64) = {
59 .name = "sun50i_a64_ccu",
60 .id = UCLASS_CLK,
61 .of_match = a64_ccu_ids,
62 .priv_auto_alloc_size = sizeof(struct ccu_priv),
63 .ops = &sunxi_clk_ops,
64 .probe = sunxi_clk_probe,
Jagan Teki7f6c2a82019-01-18 22:18:13 +053065 .bind = a64_clk_bind,
Jagan Teki1d150b42018-12-22 21:32:49 +053066};