1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2016 Rockchip Electronics Co., Ltd
4  */
5 
6 #include <common.h>
7 #include <dm.h>
8 #include <log.h>
9 #include <syscon.h>
10 #include <asm/arch-rockchip/clock.h>
11 
12 static const struct udevice_id rk3399_syscon_ids[] = {
13 	{ .compatible = "rockchip,rk3399-grf", .data = ROCKCHIP_SYSCON_GRF },
14 	{ .compatible = "rockchip,rk3399-pmugrf", .data = ROCKCHIP_SYSCON_PMUGRF },
15 	{ .compatible = "rockchip,rk3399-pmusgrf", .data = ROCKCHIP_SYSCON_PMUSGRF },
16 	{ .compatible = "rockchip,rk3399-cic", .data = ROCKCHIP_SYSCON_CIC },
17 	{ .compatible = "rockchip,rk3399-pmu", .data = ROCKCHIP_SYSCON_PMU },
18 	{ }
19 };
20 
21 U_BOOT_DRIVER(syscon_rk3399) = {
22 	.name = "rk3399_syscon",
23 	.id = UCLASS_SYSCON,
24 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
25 	.bind = dm_scan_fdt_dev,
26 #endif
27 	.of_match = rk3399_syscon_ids,
28 };
29 
30 #if CONFIG_IS_ENABLED(OF_PLATDATA)
rk3399_syscon_bind_of_plat(struct udevice * dev)31 static int rk3399_syscon_bind_of_plat(struct udevice *dev)
32 {
33 	dev->driver_data = dev->driver->of_match->data;
34 	debug("syscon: %s %d\n", dev->name, (uint)dev->driver_data);
35 
36 	return 0;
37 }
38 
39 U_BOOT_DRIVER(rockchip_rk3399_grf) = {
40 	.name = "rockchip_rk3399_grf",
41 	.id = UCLASS_SYSCON,
42 	.of_match = rk3399_syscon_ids,
43 	.bind = rk3399_syscon_bind_of_plat,
44 };
45 
46 U_BOOT_DRIVER(rockchip_rk3399_pmugrf) = {
47 	.name = "rockchip_rk3399_pmugrf",
48 	.id = UCLASS_SYSCON,
49 	.of_match = rk3399_syscon_ids + 1,
50 	.bind = rk3399_syscon_bind_of_plat,
51 };
52 
53 U_BOOT_DRIVER(rockchip_rk3399_pmusgrf) = {
54 	.name = "rockchip_rk3399_pmusgrf",
55 	.id = UCLASS_SYSCON,
56 	.of_match = rk3399_syscon_ids + 2,
57 	.bind = rk3399_syscon_bind_of_plat,
58 };
59 
60 U_BOOT_DRIVER(rockchip_rk3399_cic) = {
61 	.name = "rockchip_rk3399_cic",
62 	.id = UCLASS_SYSCON,
63 	.of_match = rk3399_syscon_ids + 3,
64 	.bind = rk3399_syscon_bind_of_plat,
65 };
66 
67 U_BOOT_DRIVER(rockchip_rk3399_pmu) = {
68 	.name = "rockchip_rk3399_pmu",
69 	.id = UCLASS_SYSCON,
70 	.of_match = rk3399_syscon_ids + 4,
71 	.bind = rk3399_syscon_bind_of_plat,
72 };
73 #endif
74