blob: e8d544f0da4f5aff81cd083f6b31ad0118fc5ed6 [file] [log] [blame]
Simon Glassdb252e32014-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
Masahiro Yamada366b24f2015-08-12 07:31:55 +090015#if CONFIG_IS_ENABLED(OF_CONTROL)
Simon Glassdb252e32014-10-22 21:37:12 -060016static const struct udevice_id omap_serial_ids[] = {
17 { .compatible = "ti,omap3-uart" },
Tom Rinie33af1c2015-07-31 19:55:12 -040018 { .compatible = "ti,omap4-uart" },
Simon Glassdb252e32014-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};