1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2017 Rockchip Electronics Co., Ltd
4  * Author: Andy Yan <andy.yan@rock-chips.com>
5  * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
6  */
7 
8 #include <common.h>
9 #include <dm.h>
10 #include <syscon.h>
11 #include <asm/arch/clock.h>
12 
13 static const struct udevice_id rk3368_syscon_ids[] = {
14 	{ .compatible = "rockchip,rk3368-grf",
15 	  .data = ROCKCHIP_SYSCON_GRF },
16 	{ .compatible = "rockchip,rk3368-pmugrf",
17 	  .data = ROCKCHIP_SYSCON_PMUGRF },
18 	{ .compatible = "rockchip,rk3368-msch",
19 	  .data = ROCKCHIP_SYSCON_MSCH },
20 	{ .compatible = "rockchip,rk3368-sgrf",
21 	  .data = ROCKCHIP_SYSCON_SGRF },
22 	{ }
23 };
24 
25 U_BOOT_DRIVER(syscon_rk3368) = {
26 	.name = "rk3368_syscon",
27 	.id = UCLASS_SYSCON,
28 	.of_match = rk3368_syscon_ids,
29 };
30 
31 #if CONFIG_IS_ENABLED(OF_PLATDATA)
32 static int rk3368_syscon_bind_of_platdata(struct udevice *dev)
33 {
34 	dev->driver_data = dev->driver->of_match->data;
35 	debug("syscon: %s %d\n", dev->name, (uint)dev->driver_data);
36 
37 	return 0;
38 }
39 
40 U_BOOT_DRIVER(rockchip_rk3368_grf) = {
41 	.name = "rockchip_rk3368_grf",
42 	.id = UCLASS_SYSCON,
43 	.of_match = rk3368_syscon_ids,
44 	.bind = rk3368_syscon_bind_of_platdata,
45 };
46 
47 U_BOOT_DRIVER(rockchip_rk3368_pmugrf) = {
48 	.name = "rockchip_rk3368_pmugrf",
49 	.id = UCLASS_SYSCON,
50 	.of_match = rk3368_syscon_ids + 1,
51 	.bind = rk3368_syscon_bind_of_platdata,
52 };
53 
54 U_BOOT_DRIVER(rockchip_rk3368_msch) = {
55 	.name = "rockchip_rk3368_msch",
56 	.id = UCLASS_SYSCON,
57 	.of_match = rk3368_syscon_ids + 2,
58 	.bind = rk3368_syscon_bind_of_platdata,
59 };
60 
61 U_BOOT_DRIVER(rockchip_rk3368_sgrf) = {
62 	.name = "rockchip_rk3368_sgrf",
63 	.id = UCLASS_SYSCON,
64 	.of_match = rk3368_syscon_ids + 3,
65 	.bind = rk3368_syscon_bind_of_platdata,
66 };
67 #endif
68