xref: /openbmc/u-boot/drivers/serial/serial_omap.c (revision 29b103c7)
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 	{ }
19 };
20 
21 static int omap_serial_ofdata_to_platdata(struct udevice *dev)
22 {
23 	struct ns16550_platdata *plat = dev_get_platdata(dev);
24 	int ret;
25 
26 	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);
31 	plat->reg_shift = 2;
32 
33 	return 0;
34 }
35 #endif
36 
37 U_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),
43 	.priv_auto_alloc_size = sizeof(struct NS16550),
44 	.probe = ns16550_serial_probe,
45 	.ops	= &ns16550_serial_ops,
46 	.flags	= DM_FLAG_PRE_RELOC,
47 };
48