Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 2fc24d5 | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015 Google, Inc |
Simon Glass | 2fc24d5 | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <debug_uart.h> |
| 8 | #include <dm.h> |
| 9 | #include <dt-structs.h> |
| 10 | #include <ns16550.h> |
| 11 | #include <serial.h> |
Kever Yang | 15f09a1 | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 12 | #include <asm/arch-rockchip/clock.h> |
Simon Glass | 0fd3d91 | 2020-12-22 19:30:28 -0700 | [diff] [blame] | 13 | #include <dm/device-internal.h> |
Simon Glass | 2fc24d5 | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 14 | |
Simon Glass | 8a8d24b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 15 | struct rockchip_uart_plat { |
Johan Jonker | 7284897 | 2022-04-09 18:55:10 +0200 | [diff] [blame] | 16 | #if CONFIG_IS_ENABLED(OF_PLATDATA) |
Johan Jonker | 6e2ee2e | 2022-04-09 18:55:12 +0200 | [diff] [blame] | 17 | struct dtd_rockchip_uart dtplat; |
Johan Jonker | 7284897 | 2022-04-09 18:55:10 +0200 | [diff] [blame] | 18 | #endif |
Simon Glass | 8a8d24b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 19 | struct ns16550_plat plat; |
Simon Glass | 2fc24d5 | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 20 | }; |
Johan Jonker | 7284897 | 2022-04-09 18:55:10 +0200 | [diff] [blame] | 21 | |
| 22 | #if CONFIG_IS_ENABLED(OF_PLATDATA) |
Johan Jonker | 6e2ee2e | 2022-04-09 18:55:12 +0200 | [diff] [blame] | 23 | struct dtd_rockchip_uart *dtplat, s_dtplat; |
Heiko Stübner | cd76916 | 2017-02-18 19:46:29 +0100 | [diff] [blame] | 24 | #endif |
Simon Glass | 2fc24d5 | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 25 | |
| 26 | static int rockchip_serial_probe(struct udevice *dev) |
| 27 | { |
Johan Jonker | 7284897 | 2022-04-09 18:55:10 +0200 | [diff] [blame] | 28 | #if CONFIG_IS_ENABLED(OF_PLATDATA) |
Simon Glass | 8a8d24b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 29 | struct rockchip_uart_plat *plat = dev_get_plat(dev); |
Simon Glass | 2fc24d5 | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 30 | |
| 31 | /* Create some new platform data for the standard driver */ |
| 32 | plat->plat.base = plat->dtplat.reg[0]; |
| 33 | plat->plat.reg_shift = plat->dtplat.reg_shift; |
| 34 | plat->plat.clock = plat->dtplat.clock_frequency; |
Heiko Schocher | 17fa032 | 2017-01-18 08:05:49 +0100 | [diff] [blame] | 35 | plat->plat.fcr = UART_FCR_DEFVAL; |
Simon Glass | 0fd3d91 | 2020-12-22 19:30:28 -0700 | [diff] [blame] | 36 | dev_set_plat(dev, &plat->plat); |
Simon Glass | 2fc24d5 | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 37 | |
| 38 | return ns16550_serial_probe(dev); |
Johan Jonker | 7284897 | 2022-04-09 18:55:10 +0200 | [diff] [blame] | 39 | #else |
| 40 | return -ENODEV; |
| 41 | #endif |
Simon Glass | 2fc24d5 | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 42 | } |
| 43 | |
Johan Jonker | 6e2ee2e | 2022-04-09 18:55:12 +0200 | [diff] [blame] | 44 | U_BOOT_DRIVER(rockchip_uart) = { |
| 45 | .name = "rockchip_uart", |
Johan Jonker | 7284897 | 2022-04-09 18:55:10 +0200 | [diff] [blame] | 46 | .id = UCLASS_SERIAL, |
Simon Glass | d30c720 | 2020-12-22 19:30:18 -0700 | [diff] [blame] | 47 | .priv_auto = sizeof(struct ns16550), |
Simon Glass | 8a8d24b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 48 | .plat_auto = sizeof(struct rockchip_uart_plat), |
Johan Jonker | 7284897 | 2022-04-09 18:55:10 +0200 | [diff] [blame] | 49 | .probe = rockchip_serial_probe, |
| 50 | .ops = &ns16550_serial_ops, |
| 51 | .flags = DM_FLAG_PRE_RELOC, |
Simon Glass | 2fc24d5 | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 52 | }; |
Johan Jonker | 6e2ee2e | 2022-04-09 18:55:12 +0200 | [diff] [blame] | 53 | DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3066_uart) |
| 54 | DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3188_uart) |
| 55 | DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3288_uart) |
| 56 | DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3328_uart) |
| 57 | DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3368_uart) |