spi.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * ---------------------------------------------------------------------------
  4. * drivers/nfc/st95hf/spi.h functions declarations for SPI communication
  5. * ---------------------------------------------------------------------------
  6. * Copyright (C) 2015 STMicroelectronics – All Rights Reserved
  7. */
  8. #ifndef __LINUX_ST95HF_SPI_H
  9. #define __LINUX_ST95HF_SPI_H
  10. #include <linux/spi/spi.h>
  11. /* Basic ST95HF SPI CMDs */
  12. #define ST95HF_COMMAND_SEND 0x0
  13. #define ST95HF_COMMAND_RESET 0x1
  14. #define ST95HF_COMMAND_RECEIVE 0x2
  15. #define ST95HF_RESET_CMD_LEN 0x1
  16. /*
  17. * structure to contain st95hf spi communication specific information.
  18. * @req_issync: true for synchronous calls.
  19. * @spidev: st95hf spi device object.
  20. * @done: completion structure to wait for st95hf response
  21. * for synchronous calls.
  22. * @spi_lock: mutex to allow only one spi transfer at a time.
  23. */
  24. struct st95hf_spi_context {
  25. bool req_issync;
  26. struct spi_device *spidev;
  27. struct completion done;
  28. struct mutex spi_lock;
  29. };
  30. /* flag to differentiate synchronous & asynchronous spi request */
  31. enum req_type {
  32. SYNC,
  33. ASYNC,
  34. };
  35. int st95hf_spi_send(struct st95hf_spi_context *spicontext,
  36. unsigned char *buffertx,
  37. int datalen,
  38. enum req_type reqtype);
  39. int st95hf_spi_recv_response(struct st95hf_spi_context *spicontext,
  40. unsigned char *receivebuff);
  41. int st95hf_spi_recv_echo_res(struct st95hf_spi_context *spicontext,
  42. unsigned char *receivebuff);
  43. #endif