spmi-uclass.c 976 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * SPMI bus uclass driver
  3. *
  4. * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <dm.h>
  10. #include <errno.h>
  11. #include <dm/root.h>
  12. #include <spmi/spmi.h>
  13. #include <linux/ctype.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. int spmi_reg_read(struct udevice *dev, int usid, int pid, int reg)
  16. {
  17. const struct dm_spmi_ops *ops = dev_get_driver_ops(dev);
  18. if (!ops || !ops->read)
  19. return -ENOSYS;
  20. return ops->read(dev, usid, pid, reg);
  21. }
  22. int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg,
  23. uint8_t value)
  24. {
  25. const struct dm_spmi_ops *ops = dev_get_driver_ops(dev);
  26. if (!ops || !ops->write)
  27. return -ENOSYS;
  28. return ops->write(dev, usid, pid, reg, value);
  29. }
  30. static int spmi_post_bind(struct udevice *dev)
  31. {
  32. return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
  33. }
  34. UCLASS_DRIVER(spmi) = {
  35. .id = UCLASS_SPMI,
  36. .name = "spmi",
  37. .post_bind = spmi_post_bind,
  38. };