xref: /openbmc/u-boot/drivers/clk/sunxi/clk_a80.c (revision 3fd39937)
1 // 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/sun9i-a80-ccu.h>
13 #include <dt-bindings/reset/sun9i-a80-ccu.h>
14 
15 static const struct ccu_clk_gate a80_gates[] = {
16 	[CLK_BUS_UART0]		= GATE(0x594, BIT(16)),
17 	[CLK_BUS_UART1]		= GATE(0x594, BIT(17)),
18 	[CLK_BUS_UART2]		= GATE(0x594, BIT(18)),
19 	[CLK_BUS_UART3]		= GATE(0x594, BIT(19)),
20 	[CLK_BUS_UART4]		= GATE(0x594, BIT(20)),
21 	[CLK_BUS_UART5]		= GATE(0x594, BIT(21)),
22 };
23 
24 static const struct ccu_reset a80_resets[] = {
25 	[RST_BUS_UART0]		= RESET(0x5b4, BIT(16)),
26 	[RST_BUS_UART1]		= RESET(0x5b4, BIT(17)),
27 	[RST_BUS_UART2]		= RESET(0x5b4, BIT(18)),
28 	[RST_BUS_UART3]		= RESET(0x5b4, BIT(19)),
29 	[RST_BUS_UART4]		= RESET(0x5b4, BIT(20)),
30 	[RST_BUS_UART5]		= RESET(0x5b4, BIT(21)),
31 };
32 
33 static const struct ccu_desc a80_ccu_desc = {
34 	.gates = a80_gates,
35 	.resets = a80_resets,
36 };
37 
38 static int a80_clk_bind(struct udevice *dev)
39 {
40 	return sunxi_reset_bind(dev, ARRAY_SIZE(a80_resets));
41 }
42 
43 static const struct udevice_id a80_ccu_ids[] = {
44 	{ .compatible = "allwinner,sun9i-a80-ccu",
45 	  .data = (ulong)&a80_ccu_desc },
46 	{ }
47 };
48 
49 U_BOOT_DRIVER(clk_sun9i_a80) = {
50 	.name		= "sun9i_a80_ccu",
51 	.id		= UCLASS_CLK,
52 	.of_match	= a80_ccu_ids,
53 	.priv_auto_alloc_size	= sizeof(struct ccu_priv),
54 	.ops		= &sunxi_clk_ops,
55 	.probe		= sunxi_clk_probe,
56 	.bind		= a80_clk_bind,
57 };
58