1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2019 Intel Corporation <www.intel.com>
10 #include <asm/arch/slimbootloader.h>
13 * The serial port info hob is generated by Slim Bootloader, so eligible for
14 * Slim Bootloader based boards only.
16 static int slimbootloader_serial_ofdata_to_platdata(struct udevice *dev)
18 const efi_guid_t guid = SBL_SERIAL_PORT_INFO_GUID;
19 struct sbl_serial_port_info *data;
20 struct ns16550_platdata *plat = dev->platdata;
22 if (!gd->arch.hob_list)
23 panic("hob list not found!");
25 data = hob_get_guid_hob_data(gd->arch.hob_list, NULL, &guid);
27 debug("failed to get serial port information\n");
30 debug("type:%d base=0x%08x baudrate=%d stride=%d clk=%d\n",
38 * The data->type provides port io or mmio access type info,
39 * but the access type will be controlled by
40 * CONFIG_SYS_NS16550_PORT_MAPPED or CONFIG_SYS_NS16550_MEM32.
42 * TBD: ns16550 access type configuration in runtime.
43 * ex) plat->access_type = data->type
45 plat->base = data->base;
46 /* ns16550 uses reg_shift, then covert stride to shift */
47 plat->reg_shift = data->stride >> 1;
48 plat->clock = data->clk;
53 static const struct udevice_id slimbootloader_serial_ids[] = {
54 { .compatible = "intel,slimbootloader-uart" },
58 U_BOOT_DRIVER(serial_slimbootloader) = {
59 .name = "serial_slimbootloader",
61 .of_match = slimbootloader_serial_ids,
62 .ofdata_to_platdata = slimbootloader_serial_ofdata_to_platdata,
63 .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
64 .priv_auto_alloc_size = sizeof(struct NS16550),
65 .probe = ns16550_serial_probe,
66 .ops = &ns16550_serial_ops,