blob: 7b5ab6c5cada9e52193ba338ae0bf52b7f00b40b [file] [log] [blame]
Lokesh Vutla6c2441c2015-09-19 14:47:36 +05301/*
2 * Copyright (c) 2015 Texas Instruments, <www.ti.com>
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#include <asm/arch/clock.h>
13
14DECLARE_GLOBAL_DATA_PTR;
15
16#if CONFIG_IS_ENABLED(OF_CONTROL)
17static const struct udevice_id keystone_serial_ids[] = {
18 { .compatible = "ti,keystone-uart" },
19 { .compatible = "ns16550a" },
20 { }
21};
22
23static int keystone_serial_ofdata_to_platdata(struct udevice *dev)
24{
25 struct ns16550_platdata *plat = dev_get_platdata(dev);
26 int ret;
27
28 ret = ns16550_serial_ofdata_to_platdata(dev);
29 if (ret)
30 return ret;
31 plat->clock = CONFIG_SYS_NS16550_CLK;
32 return 0;
33}
34#endif
35
36U_BOOT_DRIVER(serial_keystone_ns16550) = {
37 .name = "serial_keystone",
38 .id = UCLASS_SERIAL,
39#if CONFIG_IS_ENABLED(OF_CONTROL)
40 .of_match = of_match_ptr(keystone_serial_ids),
41 .ofdata_to_platdata = of_match_ptr(keystone_serial_ofdata_to_platdata),
42 .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
43#endif
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};