fsi.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* FSI device & driver interfaces
  2. *
  3. * Copyright (C) IBM Corporation 2016
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef LINUX_FSI_H
  15. #define LINUX_FSI_H
  16. #include <linux/device.h>
  17. struct fsi_device {
  18. struct device dev;
  19. u8 engine_type;
  20. u8 version;
  21. u8 unit;
  22. struct fsi_slave *slave;
  23. uint32_t addr;
  24. uint32_t size;
  25. };
  26. extern int fsi_device_read(struct fsi_device *dev, uint32_t addr,
  27. void *val, size_t size);
  28. extern int fsi_device_write(struct fsi_device *dev, uint32_t addr,
  29. const void *val, size_t size);
  30. extern int fsi_device_peek(struct fsi_device *dev, void *val);
  31. struct fsi_device_id {
  32. u8 engine_type;
  33. u8 version;
  34. };
  35. #define FSI_VERSION_ANY 0
  36. #define FSI_DEVICE(t) \
  37. .engine_type = (t), .version = FSI_VERSION_ANY,
  38. #define FSI_DEVICE_VERSIONED(t, v) \
  39. .engine_type = (t), .version = (v),
  40. struct fsi_driver {
  41. struct device_driver drv;
  42. const struct fsi_device_id *id_table;
  43. };
  44. #define to_fsi_dev(devp) container_of(devp, struct fsi_device, dev)
  45. #define to_fsi_drv(drvp) container_of(drvp, struct fsi_driver, drv)
  46. extern int fsi_driver_register(struct fsi_driver *fsi_drv);
  47. extern void fsi_driver_unregister(struct fsi_driver *fsi_drv);
  48. /* module_fsi_driver() - Helper macro for drivers that don't do
  49. * anything special in module init/exit. This eliminates a lot of
  50. * boilerplate. Each module may only use this macro once, and
  51. * calling it replaces module_init() and module_exit()
  52. */
  53. #define module_fsi_driver(__fsi_driver) \
  54. module_driver(__fsi_driver, fsi_driver_register, \
  55. fsi_driver_unregister)
  56. /* direct slave API */
  57. extern int fsi_slave_claim_range(struct fsi_slave *slave,
  58. uint32_t addr, uint32_t size);
  59. extern void fsi_slave_release_range(struct fsi_slave *slave,
  60. uint32_t addr, uint32_t size);
  61. extern int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
  62. void *val, size_t size);
  63. extern int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
  64. const void *val, size_t size);
  65. extern struct bus_type fsi_bus_type;
  66. extern const struct device_type fsi_cdev_type;
  67. enum fsi_dev_type {
  68. fsi_dev_cfam,
  69. fsi_dev_sbefifo,
  70. fsi_dev_scom,
  71. fsi_dev_occ
  72. };
  73. extern int fsi_get_new_minor(struct fsi_device *fdev, enum fsi_dev_type type,
  74. dev_t *out_dev, int *out_index);
  75. extern void fsi_free_minor(dev_t dev);
  76. #endif /* LINUX_FSI_H */