Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015 Google, Inc |
Simon Glass | b3068ad | 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 | 9fbe17c | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 12 | #include <asm/arch-rockchip/clock.h> |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 13 | |
Heiko Stübner | 2d76bfd | 2017-02-18 19:46:29 +0100 | [diff] [blame] | 14 | #if defined(CONFIG_ROCKCHIP_RK3188) |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 15 | struct rockchip_uart_plat { |
Heiko Stübner | 2d76bfd | 2017-02-18 19:46:29 +0100 | [diff] [blame] | 16 | struct dtd_rockchip_rk3188_uart dtplat; |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 17 | struct ns16550_plat plat; |
Heiko Stübner | 2d76bfd | 2017-02-18 19:46:29 +0100 | [diff] [blame] | 18 | }; |
| 19 | struct dtd_rockchip_rk3188_uart *dtplat, s_dtplat; |
| 20 | #elif defined(CONFIG_ROCKCHIP_RK3288) |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 21 | struct rockchip_uart_plat { |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 22 | struct dtd_rockchip_rk3288_uart dtplat; |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 23 | struct ns16550_plat plat; |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 24 | }; |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 25 | struct dtd_rockchip_rk3288_uart *dtplat, s_dtplat; |
Heiko Stübner | 2d76bfd | 2017-02-18 19:46:29 +0100 | [diff] [blame] | 26 | #endif |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 27 | |
| 28 | static int rockchip_serial_probe(struct udevice *dev) |
| 29 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 30 | struct rockchip_uart_plat *plat = dev_get_plat(dev); |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 31 | |
| 32 | /* Create some new platform data for the standard driver */ |
| 33 | plat->plat.base = plat->dtplat.reg[0]; |
| 34 | plat->plat.reg_shift = plat->dtplat.reg_shift; |
| 35 | plat->plat.clock = plat->dtplat.clock_frequency; |
Heiko Schocher | 06f108e | 2017-01-18 08:05:49 +0100 | [diff] [blame] | 36 | plat->plat.fcr = UART_FCR_DEFVAL; |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 37 | dev->plat = &plat->plat; |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 38 | |
| 39 | return ns16550_serial_probe(dev); |
| 40 | } |
| 41 | |
Heiko Stübner | 2d76bfd | 2017-02-18 19:46:29 +0100 | [diff] [blame] | 42 | U_BOOT_DRIVER(rockchip_rk3188_uart) = { |
| 43 | .name = "rockchip_rk3188_uart", |
| 44 | .id = UCLASS_SERIAL, |
Simon Glass | 119e7ef | 2020-12-22 19:30:18 -0700 | [diff] [blame] | 45 | .priv_auto = sizeof(struct ns16550), |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 46 | .plat_auto = sizeof(struct rockchip_uart_plat), |
Heiko Stübner | 2d76bfd | 2017-02-18 19:46:29 +0100 | [diff] [blame] | 47 | .probe = rockchip_serial_probe, |
| 48 | .ops = &ns16550_serial_ops, |
| 49 | .flags = DM_FLAG_PRE_RELOC, |
| 50 | }; |
| 51 | |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 52 | U_BOOT_DRIVER(rockchip_rk3288_uart) = { |
| 53 | .name = "rockchip_rk3288_uart", |
| 54 | .id = UCLASS_SERIAL, |
Simon Glass | 119e7ef | 2020-12-22 19:30:18 -0700 | [diff] [blame] | 55 | .priv_auto = sizeof(struct ns16550), |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 56 | .plat_auto = sizeof(struct rockchip_uart_plat), |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 57 | .probe = rockchip_serial_probe, |
| 58 | .ops = &ns16550_serial_ops, |
| 59 | .flags = DM_FLAG_PRE_RELOC, |
| 60 | }; |