rio-uclass.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (c) 2017 Texas Instruments, Inc
  3. * Authors: Aurelien Jacquiot <a-jacquiot@ti.com>
  4. * WingMan Kwok <w-kwok2@ti.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <dm.h>
  10. #include <dm/device-internal.h>
  11. #include <errno.h>
  12. #include <fdtdec.h>
  13. #include <malloc.h>
  14. #include <asm/io.h>
  15. #include <linux/list.h>
  16. #include <rio.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. UCLASS_DRIVER(rapidio) = {
  19. .name = "rapidio",
  20. .id = UCLASS_RIO,
  21. };
  22. int rio_config_read(struct udevice *dev, int portid, u16 destid,
  23. u8 hopcount, u32 offset, int len, u32 *val)
  24. {
  25. const struct rio_ops *ops = device_get_ops(dev);
  26. if (!ops->config_read)
  27. return -ENOSYS;
  28. return ops->config_read(dev, portid, destid, hopcount,
  29. offset, len, val);
  30. }
  31. int rio_config_write(struct udevice *dev, int portid, u16 destid,
  32. u8 hopcount, u32 offset, int len, u32 val)
  33. {
  34. const struct rio_ops *ops = device_get_ops(dev);
  35. if (!ops->config_write)
  36. return -ENOSYS;
  37. return ops->config_write(dev, portid, destid, hopcount,
  38. offset, len, val);
  39. }
  40. int rio_local_config_read(struct udevice *dev, u32 offset, int len, u32 *data)
  41. {
  42. const struct rio_ops *ops = device_get_ops(dev);
  43. if (!ops->local_config_read)
  44. return -ENOSYS;
  45. return ops->local_config_read(dev, offset, len, data);
  46. }
  47. int rio_local_config_write(struct udevice *dev, u32 offset, int len, u32 data)
  48. {
  49. const struct rio_ops *ops = device_get_ops(dev);
  50. if (!ops->local_config_write)
  51. return -ENOSYS;
  52. return ops->local_config_write(dev, offset, len, data);
  53. }
  54. int rio_doorbell_rx(struct udevice *dev, u16 info)
  55. {
  56. const struct rio_ops *ops = device_get_ops(dev);
  57. if (!ops->doorbell_rx)
  58. return -ENOSYS;
  59. return ops->doorbell_rx(dev, info);
  60. }
  61. int rio_remove(struct udevice *dev)
  62. {
  63. return device_remove(dev);
  64. }