2014-10-23 03:37:12 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Google, Inc
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <fdtdec.h>
|
|
|
|
#include <ns16550.h>
|
|
|
|
#include <serial.h>
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2015-09-28 10:47:47 +00:00
|
|
|
#define DEFAULT_CLK_SPEED 48000000 /* 48Mhz */
|
|
|
|
|
2015-08-11 22:31:55 +00:00
|
|
|
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
2014-10-23 03:37:12 +00:00
|
|
|
static const struct udevice_id omap_serial_ids[] = {
|
2015-09-28 10:47:48 +00:00
|
|
|
{ .compatible = "ti,omap2-uart" },
|
2014-10-23 03:37:12 +00:00
|
|
|
{ .compatible = "ti,omap3-uart" },
|
2015-07-31 23:55:12 +00:00
|
|
|
{ .compatible = "ti,omap4-uart" },
|
2015-09-28 10:47:48 +00:00
|
|
|
{ .compatible = "ti,am3352-uart" },
|
|
|
|
{ .compatible = "ti,am4372-uart" },
|
|
|
|
{ .compatible = "ti,dra742-uart" },
|
2014-10-23 03:37:12 +00:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static int omap_serial_ofdata_to_platdata(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct ns16550_platdata *plat = dev_get_platdata(dev);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = ns16550_serial_ofdata_to_platdata(dev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
|
2015-09-28 10:47:47 +00:00
|
|
|
"clock-frequency", DEFAULT_CLK_SPEED);
|
2014-10-23 03:37:12 +00:00
|
|
|
plat->reg_shift = 2;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(serial_omap_ns16550) = {
|
|
|
|
.name = "serial_omap",
|
|
|
|
.id = UCLASS_SERIAL,
|
|
|
|
.of_match = of_match_ptr(omap_serial_ids),
|
|
|
|
.ofdata_to_platdata = of_match_ptr(omap_serial_ofdata_to_platdata),
|
|
|
|
.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
|
|
|
|
.priv_auto_alloc_size = sizeof(struct NS16550),
|
|
|
|
.probe = ns16550_serial_probe,
|
|
|
|
.ops = &ns16550_serial_ops,
|
|
|
|
.flags = DM_FLAG_PRE_RELOC,
|
|
|
|
};
|