serial_omap.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2014 Google, Inc
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <fdtdec.h>
  9. #include <ns16550.h>
  10. #include <serial.h>
  11. DECLARE_GLOBAL_DATA_PTR;
  12. #if CONFIG_IS_ENABLED(OF_CONTROL)
  13. static const struct udevice_id omap_serial_ids[] = {
  14. { .compatible = "ti,omap3-uart" },
  15. { .compatible = "ti,omap4-uart" },
  16. { }
  17. };
  18. static int omap_serial_ofdata_to_platdata(struct udevice *dev)
  19. {
  20. struct ns16550_platdata *plat = dev_get_platdata(dev);
  21. int ret;
  22. ret = ns16550_serial_ofdata_to_platdata(dev);
  23. if (ret)
  24. return ret;
  25. plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
  26. "clock-frequency", -1);
  27. plat->reg_shift = 2;
  28. return 0;
  29. }
  30. #endif
  31. U_BOOT_DRIVER(serial_omap_ns16550) = {
  32. .name = "serial_omap",
  33. .id = UCLASS_SERIAL,
  34. .of_match = of_match_ptr(omap_serial_ids),
  35. .ofdata_to_platdata = of_match_ptr(omap_serial_ofdata_to_platdata),
  36. .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
  37. .priv_auto_alloc_size = sizeof(struct NS16550),
  38. .probe = ns16550_serial_probe,
  39. .ops = &ns16550_serial_ops,
  40. .flags = DM_FLAG_PRE_RELOC,
  41. };