blob: 4bf6062c645e99dbe10b6afe423fae44ee9e5d94 [file] [log] [blame]
Simon Glasse98a03c2014-10-10 07:49:20 -06001/*
2 * Copyright (c) 2014 Google, Inc
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <dm.h>
Bin Meng1eb47ef2014-12-31 16:05:13 +08009#include <fdtdec.h>
Simon Glasse98a03c2014-10-10 07:49:20 -060010#include <ns16550.h>
11#include <serial.h>
12
Bin Meng1eb47ef2014-12-31 16:05:13 +080013DECLARE_GLOBAL_DATA_PTR;
14
Bin Meng41702ba2014-12-17 15:50:47 +080015static const struct udevice_id x86_serial_ids[] = {
16 { .compatible = "x86-uart" },
Simon Glasse98a03c2014-10-10 07:49:20 -060017 { }
18};
19
Bin Meng41702ba2014-12-17 15:50:47 +080020static int x86_serial_ofdata_to_platdata(struct udevice *dev)
Simon Glasse98a03c2014-10-10 07:49:20 -060021{
22 struct ns16550_platdata *plat = dev_get_platdata(dev);
23 int ret;
24
25 ret = ns16550_serial_ofdata_to_platdata(dev);
26 if (ret)
27 return ret;
Bin Meng1eb47ef2014-12-31 16:05:13 +080028
29 plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
30 "clock-frequency", 1843200);
Simon Glasse98a03c2014-10-10 07:49:20 -060031
32 return 0;
33}
Bin Meng1eb47ef2014-12-31 16:05:13 +080034
Simon Glasse98a03c2014-10-10 07:49:20 -060035U_BOOT_DRIVER(serial_ns16550) = {
Bin Meng41702ba2014-12-17 15:50:47 +080036 .name = "serial_x86",
Simon Glasse98a03c2014-10-10 07:49:20 -060037 .id = UCLASS_SERIAL,
Bin Meng41702ba2014-12-17 15:50:47 +080038 .of_match = x86_serial_ids,
39 .ofdata_to_platdata = x86_serial_ofdata_to_platdata,
Simon Glasse98a03c2014-10-10 07:49:20 -060040 .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
41 .priv_auto_alloc_size = sizeof(struct NS16550),
42 .probe = ns16550_serial_probe,
43 .ops = &ns16550_serial_ops,
44};