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