blob: 891cd7b7ed6803d2a79096c8bdfca1d6f2d21f43 [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
Mugunthan V N3a648452015-09-28 16:17:47 +053015#define DEFAULT_CLK_SPEED 48000000 /* 48Mhz */
16
Masahiro Yamada0f925822015-08-12 07:31:55 +090017#if CONFIG_IS_ENABLED(OF_CONTROL)
Simon Glass0bf24952014-10-22 21:37:12 -060018static const struct udevice_id omap_serial_ids[] = {
Mugunthan V Ne5a098b2015-09-28 16:17:48 +053019 { .compatible = "ti,omap2-uart" },
Simon Glass0bf24952014-10-22 21:37:12 -060020 { .compatible = "ti,omap3-uart" },
Tom Rini57cd6812015-07-31 19:55:12 -040021 { .compatible = "ti,omap4-uart" },
Mugunthan V Ne5a098b2015-09-28 16:17:48 +053022 { .compatible = "ti,am3352-uart" },
23 { .compatible = "ti,am4372-uart" },
24 { .compatible = "ti,dra742-uart" },
Simon Glass0bf24952014-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 N3a648452015-09-28 16:17:47 +053037 "clock-frequency", DEFAULT_CLK_SPEED);
Simon Glass0bf24952014-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};