1 // SPDX-License-Identifier: GPL-2.0+
3 * UART support for U-Boot when launched from Coreboot
5 * Copyright 2019 Google LLC
12 #include <asm/arch/sysinfo.h>
14 static int coreboot_ofdata_to_platdata(struct udevice *dev)
16 struct ns16550_platdata *plat = dev_get_plat(dev);
17 struct cb_serial *cb_info = lib_sysinfo.serial;
19 plat->base = cb_info->baseaddr;
20 plat->reg_shift = cb_info->regwidth == 4 ? 2 : 0;
21 plat->reg_width = cb_info->regwidth;
22 plat->clock = cb_info->input_hertz;
23 plat->fcr = UART_FCR_DEFVAL;
25 if (cb_info->type == CB_SERIAL_TYPE_IO_MAPPED)
26 plat->flags |= NS16550_FLAG_IO;
31 static const struct udevice_id coreboot_serial_ids[] = {
32 { .compatible = "coreboot-serial" },
36 U_BOOT_DRIVER(coreboot_uart) = {
37 .name = "coreboot_uart",
39 .of_match = coreboot_serial_ids,
40 .priv_auto = sizeof(struct NS16550),
41 .plat_auto = sizeof(struct ns16550_platdata),
42 .ofdata_to_platdata = coreboot_ofdata_to_platdata,
43 .probe = ns16550_serial_probe,
44 .ops = &ns16550_serial_ops,
45 .flags = DM_FLAG_PRE_RELOC,