blob: 97d40869a2a37d07274dc613a100a4d79fc80807 [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 Glass0fd3d912020-12-22 19:30:28 -070013#include <dm/device-internal.h>
Simon Glass2fc24d52016-07-04 11:58:24 -060014
Heiko Stübnercd769162017-02-18 19:46:29 +010015#if defined(CONFIG_ROCKCHIP_RK3188)
Simon Glass8a8d24b2020-12-03 16:55:23 -070016struct rockchip_uart_plat {
Heiko Stübnercd769162017-02-18 19:46:29 +010017 struct dtd_rockchip_rk3188_uart dtplat;
Simon Glass8a8d24b2020-12-03 16:55:23 -070018 struct ns16550_plat plat;
Heiko Stübnercd769162017-02-18 19:46:29 +010019};
20struct dtd_rockchip_rk3188_uart *dtplat, s_dtplat;
21#elif defined(CONFIG_ROCKCHIP_RK3288)
Simon Glass8a8d24b2020-12-03 16:55:23 -070022struct rockchip_uart_plat {
Simon Glass2fc24d52016-07-04 11:58:24 -060023 struct dtd_rockchip_rk3288_uart dtplat;
Simon Glass8a8d24b2020-12-03 16:55:23 -070024 struct ns16550_plat plat;
Simon Glass2fc24d52016-07-04 11:58:24 -060025};
Simon Glass2fc24d52016-07-04 11:58:24 -060026struct dtd_rockchip_rk3288_uart *dtplat, s_dtplat;
Heiko Stübnercd769162017-02-18 19:46:29 +010027#endif
Simon Glass2fc24d52016-07-04 11:58:24 -060028
29static int rockchip_serial_probe(struct udevice *dev)
30{
Simon Glass8a8d24b2020-12-03 16:55:23 -070031 struct rockchip_uart_plat *plat = dev_get_plat(dev);
Simon Glass2fc24d52016-07-04 11:58:24 -060032
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 Schocher17fa0322017-01-18 08:05:49 +010037 plat->plat.fcr = UART_FCR_DEFVAL;
Simon Glass0fd3d912020-12-22 19:30:28 -070038 dev_set_plat(dev, &plat->plat);
Simon Glass2fc24d52016-07-04 11:58:24 -060039
40 return ns16550_serial_probe(dev);
41}
42
Heiko Stübnercd769162017-02-18 19:46:29 +010043U_BOOT_DRIVER(rockchip_rk3188_uart) = {
44 .name = "rockchip_rk3188_uart",
45 .id = UCLASS_SERIAL,
Simon Glassd30c7202020-12-22 19:30:18 -070046 .priv_auto = sizeof(struct ns16550),
Simon Glass8a8d24b2020-12-03 16:55:23 -070047 .plat_auto = sizeof(struct rockchip_uart_plat),
Heiko Stübnercd769162017-02-18 19:46:29 +010048 .probe = rockchip_serial_probe,
49 .ops = &ns16550_serial_ops,
50 .flags = DM_FLAG_PRE_RELOC,
51};
52
Simon Glass2fc24d52016-07-04 11:58:24 -060053U_BOOT_DRIVER(rockchip_rk3288_uart) = {
54 .name = "rockchip_rk3288_uart",
55 .id = UCLASS_SERIAL,
Simon Glassd30c7202020-12-22 19:30:18 -070056 .priv_auto = sizeof(struct ns16550),
Simon Glass8a8d24b2020-12-03 16:55:23 -070057 .plat_auto = sizeof(struct rockchip_uart_plat),
Simon Glass2fc24d52016-07-04 11:58:24 -060058 .probe = rockchip_serial_probe,
59 .ops = &ns16550_serial_ops,
60 .flags = DM_FLAG_PRE_RELOC,
61};