Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Kever Yang | ca19eac | 2016-07-29 10:35:25 +0800 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2016 Rockchip Electronics Co., Ltd |
Kever Yang | ca19eac | 2016-07-29 10:35:25 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Kever Yang | ca19eac | 2016-07-29 10:35:25 +0800 | [diff] [blame] | 9 | #include <syscon.h> |
Kever Yang | 9fbe17c | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 10 | #include <asm/arch-rockchip/clock.h> |
Kever Yang | ca19eac | 2016-07-29 10:35:25 +0800 | [diff] [blame] | 11 | |
| 12 | static const struct udevice_id rk3399_syscon_ids[] = { |
| 13 | { .compatible = "rockchip,rk3399-grf", .data = ROCKCHIP_SYSCON_GRF }, |
Kever Yang | e3eba16 | 2016-08-16 17:58:10 +0800 | [diff] [blame] | 14 | { .compatible = "rockchip,rk3399-pmugrf", .data = ROCKCHIP_SYSCON_PMUGRF }, |
Kever Yang | 62d01dc | 2017-02-13 17:38:59 +0800 | [diff] [blame] | 15 | { .compatible = "rockchip,rk3399-pmusgrf", .data = ROCKCHIP_SYSCON_PMUSGRF }, |
| 16 | { .compatible = "rockchip,rk3399-cic", .data = ROCKCHIP_SYSCON_CIC }, |
Jagan Teki | ee1e44f | 2019-07-16 17:27:33 +0530 | [diff] [blame] | 17 | { .compatible = "rockchip,rk3399-pmu", .data = ROCKCHIP_SYSCON_PMU }, |
eric.gao@rock-chips.com | c4d4f54 | 2017-04-10 09:53:31 +0800 | [diff] [blame] | 18 | { } |
Kever Yang | ca19eac | 2016-07-29 10:35:25 +0800 | [diff] [blame] | 19 | }; |
| 20 | |
| 21 | U_BOOT_DRIVER(syscon_rk3399) = { |
| 22 | .name = "rk3399_syscon", |
| 23 | .id = UCLASS_SYSCON, |
Simon Glass | 9288265 | 2021-08-07 07:24:04 -0600 | [diff] [blame] | 24 | #if CONFIG_IS_ENABLED(OF_REAL) |
Frank Wang | ed59f95 | 2020-05-26 11:32:08 +0800 | [diff] [blame] | 25 | .bind = dm_scan_fdt_dev, |
| 26 | #endif |
Kever Yang | ca19eac | 2016-07-29 10:35:25 +0800 | [diff] [blame] | 27 | .of_match = rk3399_syscon_ids, |
| 28 | }; |
Kever Yang | 62d01dc | 2017-02-13 17:38:59 +0800 | [diff] [blame] | 29 | |
| 30 | #if CONFIG_IS_ENABLED(OF_PLATDATA) |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 31 | static int rk3399_syscon_bind_of_plat(struct udevice *dev) |
Kever Yang | 62d01dc | 2017-02-13 17:38:59 +0800 | [diff] [blame] | 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, |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 43 | .bind = rk3399_syscon_bind_of_plat, |
Kever Yang | 62d01dc | 2017-02-13 17:38:59 +0800 | [diff] [blame] | 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, |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 50 | .bind = rk3399_syscon_bind_of_plat, |
Kever Yang | 62d01dc | 2017-02-13 17:38:59 +0800 | [diff] [blame] | 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, |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 57 | .bind = rk3399_syscon_bind_of_plat, |
Kever Yang | 62d01dc | 2017-02-13 17:38:59 +0800 | [diff] [blame] | 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, |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 64 | .bind = rk3399_syscon_bind_of_plat, |
Kever Yang | 62d01dc | 2017-02-13 17:38:59 +0800 | [diff] [blame] | 65 | }; |
Jagan Teki | ee1e44f | 2019-07-16 17:27:33 +0530 | [diff] [blame] | 66 | |
| 67 | U_BOOT_DRIVER(rockchip_rk3399_pmu) = { |
| 68 | .name = "rockchip_rk3399_pmu", |
| 69 | .id = UCLASS_SYSCON, |
| 70 | .of_match = rk3399_syscon_ids + 4, |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 71 | .bind = rk3399_syscon_bind_of_plat, |
Jagan Teki | ee1e44f | 2019-07-16 17:27:33 +0530 | [diff] [blame] | 72 | }; |
Kever Yang | 62d01dc | 2017-02-13 17:38:59 +0800 | [diff] [blame] | 73 | #endif |