Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 Google, Inc |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <debug_uart.h> |
| 9 | #include <dm.h> |
| 10 | #include <dt-structs.h> |
| 11 | #include <ns16550.h> |
| 12 | #include <serial.h> |
| 13 | #include <asm/arch/clock.h> |
| 14 | |
Heiko Stübner | 2d76bfd | 2017-02-18 19:46:29 +0100 | [diff] [blame] | 15 | #if defined(CONFIG_ROCKCHIP_RK3188) |
| 16 | struct rockchip_uart_platdata { |
| 17 | struct dtd_rockchip_rk3188_uart dtplat; |
| 18 | struct ns16550_platdata plat; |
| 19 | }; |
| 20 | struct dtd_rockchip_rk3188_uart *dtplat, s_dtplat; |
| 21 | #elif defined(CONFIG_ROCKCHIP_RK3288) |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 22 | struct rockchip_uart_platdata { |
| 23 | struct dtd_rockchip_rk3288_uart dtplat; |
| 24 | struct ns16550_platdata plat; |
| 25 | }; |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 26 | struct dtd_rockchip_rk3288_uart *dtplat, s_dtplat; |
Heiko Stübner | 2d76bfd | 2017-02-18 19:46:29 +0100 | [diff] [blame] | 27 | #endif |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 28 | |
| 29 | static int rockchip_serial_probe(struct udevice *dev) |
| 30 | { |
| 31 | struct rockchip_uart_platdata *plat = dev_get_platdata(dev); |
| 32 | |
| 33 | /* Create some new platform data for the standard driver */ |
| 34 | plat->plat.base = plat->dtplat.reg[0]; |
| 35 | plat->plat.reg_shift = plat->dtplat.reg_shift; |
| 36 | plat->plat.clock = plat->dtplat.clock_frequency; |
Heiko Schocher | 06f108e | 2017-01-18 08:05:49 +0100 | [diff] [blame] | 37 | plat->plat.fcr = UART_FCR_DEFVAL; |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 38 | dev->platdata = &plat->plat; |
| 39 | |
| 40 | return ns16550_serial_probe(dev); |
| 41 | } |
| 42 | |
Heiko Stübner | 2d76bfd | 2017-02-18 19:46:29 +0100 | [diff] [blame] | 43 | U_BOOT_DRIVER(rockchip_rk3188_uart) = { |
| 44 | .name = "rockchip_rk3188_uart", |
| 45 | .id = UCLASS_SERIAL, |
| 46 | .priv_auto_alloc_size = sizeof(struct NS16550), |
| 47 | .platdata_auto_alloc_size = sizeof(struct rockchip_uart_platdata), |
| 48 | .probe = rockchip_serial_probe, |
| 49 | .ops = &ns16550_serial_ops, |
| 50 | .flags = DM_FLAG_PRE_RELOC, |
| 51 | }; |
| 52 | |
Simon Glass | b3068ad | 2016-07-04 11:58:24 -0600 | [diff] [blame] | 53 | U_BOOT_DRIVER(rockchip_rk3288_uart) = { |
| 54 | .name = "rockchip_rk3288_uart", |
| 55 | .id = UCLASS_SERIAL, |
| 56 | .priv_auto_alloc_size = sizeof(struct NS16550), |
| 57 | .platdata_auto_alloc_size = sizeof(struct rockchip_uart_platdata), |
| 58 | .probe = rockchip_serial_probe, |
| 59 | .ops = &ns16550_serial_ops, |
| 60 | .flags = DM_FLAG_PRE_RELOC, |
| 61 | }; |