board-uclass.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2017
  4. * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
  5. */
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <board.h>
  9. int board_get(struct udevice **devp)
  10. {
  11. return uclass_first_device_err(UCLASS_BOARD, devp);
  12. }
  13. int board_detect(struct udevice *dev)
  14. {
  15. struct board_ops *ops = board_get_ops(dev);
  16. if (!ops->detect)
  17. return -ENOSYS;
  18. return ops->detect(dev);
  19. }
  20. int board_get_bool(struct udevice *dev, int id, bool *val)
  21. {
  22. struct board_ops *ops = board_get_ops(dev);
  23. if (!ops->get_bool)
  24. return -ENOSYS;
  25. return ops->get_bool(dev, id, val);
  26. }
  27. int board_get_int(struct udevice *dev, int id, int *val)
  28. {
  29. struct board_ops *ops = board_get_ops(dev);
  30. if (!ops->get_int)
  31. return -ENOSYS;
  32. return ops->get_int(dev, id, val);
  33. }
  34. int board_get_str(struct udevice *dev, int id, size_t size, char *val)
  35. {
  36. struct board_ops *ops = board_get_ops(dev);
  37. if (!ops->get_str)
  38. return -ENOSYS;
  39. return ops->get_str(dev, id, size, val);
  40. }
  41. UCLASS_DRIVER(board) = {
  42. .id = UCLASS_BOARD,
  43. .name = "board",
  44. .post_bind = dm_scan_fdt_dev,
  45. };