2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-07-04 17:58:24 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Google, Inc
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <debug_uart.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <dt-structs.h>
|
|
|
|
#include <ns16550.h>
|
|
|
|
#include <serial.h>
|
2019-03-28 03:01:23 +00:00
|
|
|
#include <asm/arch-rockchip/clock.h>
|
2020-12-23 02:30:28 +00:00
|
|
|
#include <dm/device-internal.h>
|
2016-07-04 17:58:24 +00:00
|
|
|
|
2020-12-03 23:55:23 +00:00
|
|
|
struct rockchip_uart_plat {
|
2022-04-09 16:55:10 +00:00
|
|
|
#if CONFIG_IS_ENABLED(OF_PLATDATA)
|
2022-04-09 16:55:12 +00:00
|
|
|
struct dtd_rockchip_uart dtplat;
|
2022-04-09 16:55:10 +00:00
|
|
|
#endif
|
2020-12-03 23:55:23 +00:00
|
|
|
struct ns16550_plat plat;
|
2016-07-04 17:58:24 +00:00
|
|
|
};
|
2022-04-09 16:55:10 +00:00
|
|
|
|
|
|
|
#if CONFIG_IS_ENABLED(OF_PLATDATA)
|
2022-04-09 16:55:12 +00:00
|
|
|
struct dtd_rockchip_uart *dtplat, s_dtplat;
|
2017-02-18 18:46:29 +00:00
|
|
|
#endif
|
2016-07-04 17:58:24 +00:00
|
|
|
|
|
|
|
static int rockchip_serial_probe(struct udevice *dev)
|
|
|
|
{
|
2022-04-09 16:55:10 +00:00
|
|
|
#if CONFIG_IS_ENABLED(OF_PLATDATA)
|
2020-12-03 23:55:23 +00:00
|
|
|
struct rockchip_uart_plat *plat = dev_get_plat(dev);
|
2016-07-04 17:58:24 +00:00
|
|
|
|
|
|
|
/* Create some new platform data for the standard driver */
|
|
|
|
plat->plat.base = plat->dtplat.reg[0];
|
|
|
|
plat->plat.reg_shift = plat->dtplat.reg_shift;
|
|
|
|
plat->plat.clock = plat->dtplat.clock_frequency;
|
2017-01-18 07:05:49 +00:00
|
|
|
plat->plat.fcr = UART_FCR_DEFVAL;
|
2020-12-23 02:30:28 +00:00
|
|
|
dev_set_plat(dev, &plat->plat);
|
2016-07-04 17:58:24 +00:00
|
|
|
|
|
|
|
return ns16550_serial_probe(dev);
|
2022-04-09 16:55:10 +00:00
|
|
|
#else
|
|
|
|
return -ENODEV;
|
|
|
|
#endif
|
2016-07-04 17:58:24 +00:00
|
|
|
}
|
|
|
|
|
2022-04-09 16:55:12 +00:00
|
|
|
U_BOOT_DRIVER(rockchip_uart) = {
|
|
|
|
.name = "rockchip_uart",
|
2022-04-09 16:55:10 +00:00
|
|
|
.id = UCLASS_SERIAL,
|
2020-12-23 02:30:18 +00:00
|
|
|
.priv_auto = sizeof(struct ns16550),
|
2020-12-03 23:55:23 +00:00
|
|
|
.plat_auto = sizeof(struct rockchip_uart_plat),
|
2022-04-09 16:55:10 +00:00
|
|
|
.probe = rockchip_serial_probe,
|
|
|
|
.ops = &ns16550_serial_ops,
|
|
|
|
.flags = DM_FLAG_PRE_RELOC,
|
2016-07-04 17:58:24 +00:00
|
|
|
};
|
2022-04-09 16:55:12 +00:00
|
|
|
DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3066_uart)
|
|
|
|
DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3188_uart)
|
|
|
|
DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3288_uart)
|
|
|
|
DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3328_uart)
|
|
|
|
DM_DRIVER_ALIAS(rockchip_uart, rockchip_rk3368_uart)
|