mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-08 14:14:32 +00:00
41575d8e4c
This construct is quite long-winded. In earlier days it made some sense since auto-allocation was a strange concept. But with driver model now used pretty universally, we can shorten this to 'auto'. This reduces verbosity and makes it easier to read. Coincidentally it also ensures that every declaration is on one line, thus making dtoc's job easier. Signed-off-by: Simon Glass <sjg@chromium.org>
65 lines
1.7 KiB
C
65 lines
1.7 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2019 Intel Corporation <www.intel.com>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <log.h>
|
|
#include <ns16550.h>
|
|
#include <serial.h>
|
|
#include <asm/arch/slimbootloader.h>
|
|
|
|
/**
|
|
* The serial port info hob is generated by Slim Bootloader, so eligible for
|
|
* Slim Bootloader based boards only.
|
|
*/
|
|
static int slimbootloader_serial_ofdata_to_platdata(struct udevice *dev)
|
|
{
|
|
const efi_guid_t guid = SBL_SERIAL_PORT_INFO_GUID;
|
|
struct sbl_serial_port_info *data;
|
|
struct ns16550_platdata *plat = dev->platdata;
|
|
|
|
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;
|
|
plat->reg_width = data->stride;
|
|
plat->clock = data->clk;
|
|
plat->fcr = UART_FCR_DEFVAL;
|
|
plat->flags = 0;
|
|
if (data->type == 1)
|
|
plat->flags |= NS16550_FLAG_IO;
|
|
|
|
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,
|
|
.ofdata_to_platdata = slimbootloader_serial_ofdata_to_platdata,
|
|
.platdata_auto = sizeof(struct ns16550_platdata),
|
|
.priv_auto = sizeof(struct NS16550),
|
|
.probe = ns16550_serial_probe,
|
|
.ops = &ns16550_serial_ops,
|
|
};
|