blob: 930103a42cb80b6ea92aa16e5bf490b101374ccf [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass2fc24d52016-07-04 11:58:24 -06002/*
3 * Copyright (c) 2015 Google, Inc
Simon Glass2fc24d52016-07-04 11:58:24 -06004 */
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 Yang15f09a12019-03-28 11:01:23 +080012#include <asm/arch-rockchip/clock.h>
Simon Glass2fc24d52016-07-04 11:58:24 -060013
Heiko Stübnercd769162017-02-18 19:46:29 +010014#if defined(CONFIG_ROCKCHIP_RK3188)
15struct rockchip_uart_platdata {
16 struct dtd_rockchip_rk3188_uart dtplat;
17 struct ns16550_platdata plat;
18};
19struct dtd_rockchip_rk3188_uart *dtplat, s_dtplat;
20#elif defined(CONFIG_ROCKCHIP_RK3288)
Simon Glass2fc24d52016-07-04 11:58:24 -060021struct rockchip_uart_platdata {
22 struct dtd_rockchip_rk3288_uart dtplat;
23 struct ns16550_platdata plat;
24};
Simon Glass2fc24d52016-07-04 11:58:24 -060025struct dtd_rockchip_rk3288_uart *dtplat, s_dtplat;
Heiko Stübnercd769162017-02-18 19:46:29 +010026#endif
Simon Glass2fc24d52016-07-04 11:58:24 -060027
28static int rockchip_serial_probe(struct udevice *dev)
29{
Simon Glassc69cda22020-12-03 16:55:20 -070030 struct rockchip_uart_platdata *plat = dev_get_plat(dev);
Simon Glass2fc24d52016-07-04 11:58:24 -060031
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 Schocher17fa0322017-01-18 08:05:49 +010036 plat->plat.fcr = UART_FCR_DEFVAL;
Simon Glasscaa4daa2020-12-03 16:55:18 -070037 dev->plat = &plat->plat;
Simon Glass2fc24d52016-07-04 11:58:24 -060038
39 return ns16550_serial_probe(dev);
40}
41
Heiko Stübnercd769162017-02-18 19:46:29 +010042U_BOOT_DRIVER(rockchip_rk3188_uart) = {
43 .name = "rockchip_rk3188_uart",
44 .id = UCLASS_SERIAL,
Simon Glass41575d82020-12-03 16:55:17 -070045 .priv_auto = sizeof(struct NS16550),
Simon Glasscaa4daa2020-12-03 16:55:18 -070046 .plat_auto = sizeof(struct rockchip_uart_platdata),
Heiko Stübnercd769162017-02-18 19:46:29 +010047 .probe = rockchip_serial_probe,
48 .ops = &ns16550_serial_ops,
49 .flags = DM_FLAG_PRE_RELOC,
50};
51
Simon Glass2fc24d52016-07-04 11:58:24 -060052U_BOOT_DRIVER(rockchip_rk3288_uart) = {
53 .name = "rockchip_rk3288_uart",
54 .id = UCLASS_SERIAL,
Simon Glass41575d82020-12-03 16:55:17 -070055 .priv_auto = sizeof(struct NS16550),
Simon Glasscaa4daa2020-12-03 16:55:18 -070056 .plat_auto = sizeof(struct rockchip_uart_platdata),
Simon Glass2fc24d52016-07-04 11:58:24 -060057 .probe = rockchip_serial_probe,
58 .ops = &ns16550_serial_ops,
59 .flags = DM_FLAG_PRE_RELOC,
60};