2019-08-03 08:30:44 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Intel Corporation <www.intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2019-08-03 08:30:44 +00:00
|
|
|
#include <ns16550.h>
|
|
|
|
#include <serial.h>
|
|
|
|
#include <asm/arch/slimbootloader.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2019-08-03 08:30:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The serial port info hob is generated by Slim Bootloader, so eligible for
|
|
|
|
* Slim Bootloader based boards only.
|
|
|
|
*/
|
2020-12-03 23:55:21 +00:00
|
|
|
static int slimbootloader_serial_of_to_plat(struct udevice *dev)
|
2019-08-03 08:30:44 +00:00
|
|
|
{
|
|
|
|
const efi_guid_t guid = SBL_SERIAL_PORT_INFO_GUID;
|
|
|
|
struct sbl_serial_port_info *data;
|
2020-12-23 02:30:28 +00:00
|
|
|
struct ns16550_plat *plat = dev_get_plat(dev);
|
2019-08-03 08:30:44 +00:00
|
|
|
|
|
|
|
if (!gd->arch.hob_list)
|
|
|
|
panic("hob list not found!");
|
|
|
|
|
|
|
|
data = hob_get_guid_hob_data(gd->arch.hob_list, NULL, &guid);
|
|
|
|
if (!data) {
|
|
|
|
debug("failed to get serial port information\n");
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
debug("type:%d base=0x%08x baudrate=%d stride=%d clk=%d\n",
|
|
|
|
data->type,
|
|
|
|
data->base,
|
|
|
|
data->baud,
|
|
|
|
data->stride,
|
|
|
|
data->clk);
|
|
|
|
|
|
|
|
plat->base = data->base;
|
|
|
|
/* ns16550 uses reg_shift, then covert stride to shift */
|
|
|
|
plat->reg_shift = data->stride >> 1;
|
2019-12-18 05:56:23 +00:00
|
|
|
plat->reg_width = data->stride;
|
2019-08-03 08:30:44 +00:00
|
|
|
plat->clock = data->clk;
|
2019-12-18 05:56:23 +00:00
|
|
|
plat->fcr = UART_FCR_DEFVAL;
|
|
|
|
plat->flags = 0;
|
|
|
|
if (data->type == 1)
|
|
|
|
plat->flags |= NS16550_FLAG_IO;
|
2019-08-03 08:30:44 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct udevice_id slimbootloader_serial_ids[] = {
|
|
|
|
{ .compatible = "intel,slimbootloader-uart" },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(serial_slimbootloader) = {
|
|
|
|
.name = "serial_slimbootloader",
|
|
|
|
.id = UCLASS_SERIAL,
|
|
|
|
.of_match = slimbootloader_serial_ids,
|
2020-12-03 23:55:21 +00:00
|
|
|
.of_to_plat = slimbootloader_serial_of_to_plat,
|
2020-12-03 23:55:23 +00:00
|
|
|
.plat_auto = sizeof(struct ns16550_plat),
|
2020-12-23 02:30:18 +00:00
|
|
|
.priv_auto = sizeof(struct ns16550),
|
2019-08-03 08:30:44 +00:00
|
|
|
.probe = ns16550_serial_probe,
|
|
|
|
.ops = &ns16550_serial_ops,
|
|
|
|
};
|