blob: 265fe007a06c4bf64ef1f249e0c71321e57376cf [file] [log] [blame]
Googlere00b8eb2019-07-08 16:37:07 -07001/*
Googler695f9d92023-09-11 15:38:29 +08002 * Copyright (c) 2014 Google, Inc
Googlere00b8eb2019-07-08 16:37:07 -07003 *
Googler695f9d92023-09-11 15:38:29 +08004 * SPDX-License-Identifier: GPL-2.0+
Googlere00b8eb2019-07-08 16:37:07 -07005 */
6
7#include <common.h>
8#include <dm.h>
Googler695f9d92023-09-11 15:38:29 +08009#include <fdtdec.h>
Googlere00b8eb2019-07-08 16:37:07 -070010#include <ns16550.h>
11#include <serial.h>
Googlere00b8eb2019-07-08 16:37:07 -070012
Googler695f9d92023-09-11 15:38:29 +080013DECLARE_GLOBAL_DATA_PTR;
Googlere00b8eb2019-07-08 16:37:07 -070014
Googler695f9d92023-09-11 15:38:29 +080015#ifdef CONFIG_OF_CONTROL
16static const struct udevice_id omap_serial_ids[] = {
17 { .compatible = "ti,omap3-uart" },
18 { }
19};
Googlere00b8eb2019-07-08 16:37:07 -070020
Googlere00b8eb2019-07-08 16:37:07 -070021static int omap_serial_ofdata_to_platdata(struct udevice *dev)
22{
Googler695f9d92023-09-11 15:38:29 +080023 struct ns16550_platdata *plat = dev_get_platdata(dev);
24 int ret;
Googlere00b8eb2019-07-08 16:37:07 -070025
Googler695f9d92023-09-11 15:38:29 +080026 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);
Googlere00b8eb2019-07-08 16:37:07 -070031 plat->reg_shift = 2;
32
Googlere00b8eb2019-07-08 16:37:07 -070033 return 0;
34}
Googler25e92cf2023-12-13 10:05:01 +000035#endif
Googler695f9d92023-09-11 15:38:29 +080036
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),
Googlere00b8eb2019-07-08 16:37:07 -070043 .priv_auto_alloc_size = sizeof(struct NS16550),
44 .probe = ns16550_serial_probe,
45 .ops = &ns16550_serial_ops,
Googlere00b8eb2019-07-08 16:37:07 -070046 .flags = DM_FLAG_PRE_RELOC,
Googlere00b8eb2019-07-08 16:37:07 -070047};