blob: 891cd7b7ed6803d2a79096c8bdfca1d6f2d21f43 [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
Mugunthan V N595e6f22015-09-28 16:17:47 +053015#define DEFAULT_CLK_SPEED 48000000 /* 48Mhz */
16
Masahiro Yamada366b24f2015-08-12 07:31:55 +090017#if CONFIG_IS_ENABLED(OF_CONTROL)
Simon Glassdb252e32014-10-22 21:37:12 -060018static const struct udevice_id omap_serial_ids[] = {
Mugunthan V N39ed4db2015-09-28 16:17:48 +053019 { .compatible = "ti,omap2-uart" },
Simon Glassdb252e32014-10-22 21:37:12 -060020 { .compatible = "ti,omap3-uart" },
Tom Rinie33af1c2015-07-31 19:55:12 -040021 { .compatible = "ti,omap4-uart" },
Mugunthan V N39ed4db2015-09-28 16:17:48 +053022 { .compatible = "ti,am3352-uart" },
23 { .compatible = "ti,am4372-uart" },
24 { .compatible = "ti,dra742-uart" },
Simon Glassdb252e32014-10-22 21:37:12 -060025 { }
26};
27
28static int omap_serial_ofdata_to_platdata(struct udevice *dev)
29{
30 struct ns16550_platdata *plat = dev_get_platdata(dev);
31 int ret;
32
33 ret = ns16550_serial_ofdata_to_platdata(dev);
34 if (ret)
35 return ret;
36 plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
Mugunthan V N595e6f22015-09-28 16:17:47 +053037 "clock-frequency", DEFAULT_CLK_SPEED);
Simon Glassdb252e32014-10-22 21:37:12 -060038 plat->reg_shift = 2;
39
40 return 0;
41}
42#endif
43
44U_BOOT_DRIVER(serial_omap_ns16550) = {
45 .name = "serial_omap",
46 .id = UCLASS_SERIAL,
47 .of_match = of_match_ptr(omap_serial_ids),
48 .ofdata_to_platdata = of_match_ptr(omap_serial_ofdata_to_platdata),
49 .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
50 .priv_auto_alloc_size = sizeof(struct NS16550),
51 .probe = ns16550_serial_probe,
52 .ops = &ns16550_serial_ops,
53 .flags = DM_FLAG_PRE_RELOC,
54};