sysinfo-uclass.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 <sysinfo.h>
  9. int sysinfo_get(struct udevice **devp)
  10. {
  11. return uclass_first_device_err(UCLASS_SYSINFO, devp);
  12. }
  13. int sysinfo_detect(struct udevice *dev)
  14. {
  15. struct sysinfo_ops *ops = sysinfo_get_ops(dev);
  16. if (!ops->detect)
  17. return -ENOSYS;
  18. return ops->detect(dev);
  19. }
  20. int sysinfo_get_fit_loadable(struct udevice *dev, int index, const char *type,
  21. const char **strp)
  22. {
  23. struct sysinfo_ops *ops = sysinfo_get_ops(dev);
  24. if (!ops->get_fit_loadable)
  25. return -ENOSYS;
  26. return ops->get_fit_loadable(dev, index, type, strp);
  27. }
  28. int sysinfo_get_bool(struct udevice *dev, int id, bool *val)
  29. {
  30. struct sysinfo_ops *ops = sysinfo_get_ops(dev);
  31. if (!ops->get_bool)
  32. return -ENOSYS;
  33. return ops->get_bool(dev, id, val);
  34. }
  35. int sysinfo_get_int(struct udevice *dev, int id, int *val)
  36. {
  37. struct sysinfo_ops *ops = sysinfo_get_ops(dev);
  38. if (!ops->get_int)
  39. return -ENOSYS;
  40. return ops->get_int(dev, id, val);
  41. }
  42. int sysinfo_get_str(struct udevice *dev, int id, size_t size, char *val)
  43. {
  44. struct sysinfo_ops *ops = sysinfo_get_ops(dev);
  45. if (!ops->get_str)
  46. return -ENOSYS;
  47. return ops->get_str(dev, id, size, val);
  48. }
  49. UCLASS_DRIVER(sysinfo) = {
  50. .id = UCLASS_SYSINFO,
  51. .name = "sysinfo",
  52. .post_bind = dm_scan_fdt_dev,
  53. };