xref: /openbmc/u-boot/drivers/serial/serial_omap.c (revision b8098bc1)
1 /*
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 
13 DECLARE_GLOBAL_DATA_PTR;
14 
15 #ifdef CONFIG_OF_CONTROL
16 static const struct udevice_id omap_serial_ids[] = {
17 	{ .compatible = "ti,omap3-uart" },
18 	{ .compatible = "ti,omap4-uart" },
19 	{ }
20 };
21 
22 static int omap_serial_ofdata_to_platdata(struct udevice *dev)
23 {
24 	struct ns16550_platdata *plat = dev_get_platdata(dev);
25 	int ret;
26 
27 	ret = ns16550_serial_ofdata_to_platdata(dev);
28 	if (ret)
29 		return ret;
30 	plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
31 				     "clock-frequency", -1);
32 	plat->reg_shift = 2;
33 
34 	return 0;
35 }
36 #endif
37 
38 U_BOOT_DRIVER(serial_omap_ns16550) = {
39 	.name	= "serial_omap",
40 	.id	= UCLASS_SERIAL,
41 	.of_match = of_match_ptr(omap_serial_ids),
42 	.ofdata_to_platdata = of_match_ptr(omap_serial_ofdata_to_platdata),
43 	.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
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 };
49