blob: 325fe427fd854211bbb6288a2d7075e892f708d4 [file] [log] [blame]
Simon Glass0bf24952014-10-22 21:37:12 -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>
9#include <fdtdec.h>
10#include <ns16550.h>
11#include <serial.h>
12
13DECLARE_GLOBAL_DATA_PTR;
14
15#ifdef CONFIG_OF_CONTROL
16static const struct udevice_id omap_serial_ids[] = {
17 { .compatible = "ti,omap3-uart" },
Tom Rini57cd6812015-07-31 19:55:12 -040018 { .compatible = "ti,omap4-uart" },
Simon Glass0bf24952014-10-22 21:37:12 -060019 { }
20};
21
22static int omap_serial_ofdata_to_platdata(struct udevice *dev)
23{
24 struct ns16550_platdata *plat = dev_get_platdata(dev);
25 int ret;
26
27 ret = ns16550_serial_ofdata_to_platdata(dev);
28 if (ret)
29 return ret;
30 plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
31 "clock-frequency", -1);
32 plat->reg_shift = 2;
33
34 return 0;
35}
36#endif
37
38U_BOOT_DRIVER(serial_omap_ns16550) = {
39 .name = "serial_omap",
40 .id = UCLASS_SERIAL,
41 .of_match = of_match_ptr(omap_serial_ids),
42 .ofdata_to_platdata = of_match_ptr(omap_serial_ofdata_to_platdata),
43 .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
44 .priv_auto_alloc_size = sizeof(struct NS16550),
45 .probe = ns16550_serial_probe,
46 .ops = &ns16550_serial_ops,
47 .flags = DM_FLAG_PRE_RELOC,
48};