serial_tegra.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 <ns16550.h>
  9. #include <serial.h>
  10. #ifdef CONFIG_OF_CONTROL
  11. static const struct udevice_id tegra_serial_ids[] = {
  12. { .compatible = "nvidia,tegra20-uart" },
  13. { }
  14. };
  15. static int tegra_serial_ofdata_to_platdata(struct udevice *dev)
  16. {
  17. struct ns16550_platdata *plat = dev_get_platdata(dev);
  18. int ret;
  19. ret = ns16550_serial_ofdata_to_platdata(dev);
  20. if (ret)
  21. return ret;
  22. plat->clock = V_NS16550_CLK;
  23. return 0;
  24. }
  25. #else
  26. struct ns16550_platdata tegra_serial = {
  27. .base = CONFIG_SYS_NS16550_COM1,
  28. .reg_shift = 2,
  29. .clock = V_NS16550_CLK,
  30. };
  31. U_BOOT_DEVICE(ns16550_serial) = {
  32. "serial_tegra20", &tegra_serial
  33. };
  34. #endif
  35. U_BOOT_DRIVER(serial_ns16550) = {
  36. .name = "serial_tegra20",
  37. .id = UCLASS_SERIAL,
  38. #ifdef CONFIG_OF_CONTROL
  39. .of_match = tegra_serial_ids,
  40. .ofdata_to_platdata = tegra_serial_ofdata_to_platdata,
  41. .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
  42. #endif
  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. };