blob: 265fe007a06c4bf64ef1f249e0c71321e57376cf [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" },
18 { }
19};
20
21static int omap_serial_ofdata_to_platdata(struct udevice *dev)
22{
23 struct ns16550_platdata *plat = dev_get_platdata(dev);
24 int ret;
25
26 ret = ns16550_serial_ofdata_to_platdata(dev);
27 if (ret)
28 return ret;
29 plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
30 "clock-frequency", -1);
31 plat->reg_shift = 2;
32
33 return 0;
34}
35#endif
36
37U_BOOT_DRIVER(serial_omap_ns16550) = {
38 .name = "serial_omap",
39 .id = UCLASS_SERIAL,
40 .of_match = of_match_ptr(omap_serial_ids),
41 .ofdata_to_platdata = of_match_ptr(omap_serial_ofdata_to_platdata),
42 .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
43 .priv_auto_alloc_size = sizeof(struct NS16550),
44 .probe = ns16550_serial_probe,
45 .ops = &ns16550_serial_ops,
46 .flags = DM_FLAG_PRE_RELOC,
47};