spi.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * ---------------------------------------------------------------------------
  3. * drivers/nfc/st95hf/spi.h functions declarations for SPI communication
  4. * ---------------------------------------------------------------------------
  5. * Copyright (C) 2015 STMicroelectronics – All Rights Reserved
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms and conditions of the GNU General Public License,
  9. * version 2, as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __LINUX_ST95HF_SPI_H
  20. #define __LINUX_ST95HF_SPI_H
  21. #include <linux/spi/spi.h>
  22. /* Basic ST95HF SPI CMDs */
  23. #define ST95HF_COMMAND_SEND 0x0
  24. #define ST95HF_COMMAND_RESET 0x1
  25. #define ST95HF_COMMAND_RECEIVE 0x2
  26. #define ST95HF_RESET_CMD_LEN 0x1
  27. /*
  28. * structure to contain st95hf spi communication specific information.
  29. * @req_issync: true for synchronous calls.
  30. * @spidev: st95hf spi device object.
  31. * @done: completion structure to wait for st95hf response
  32. * for synchronous calls.
  33. * @spi_lock: mutex to allow only one spi transfer at a time.
  34. */
  35. struct st95hf_spi_context {
  36. bool req_issync;
  37. struct spi_device *spidev;
  38. struct completion done;
  39. struct mutex spi_lock;
  40. };
  41. /* flag to differentiate synchronous & asynchronous spi request */
  42. enum req_type {
  43. SYNC,
  44. ASYNC,
  45. };
  46. int st95hf_spi_send(struct st95hf_spi_context *spicontext,
  47. unsigned char *buffertx,
  48. int datalen,
  49. enum req_type reqtype);
  50. int st95hf_spi_recv_response(struct st95hf_spi_context *spicontext,
  51. unsigned char *receivebuff);
  52. int st95hf_spi_recv_echo_res(struct st95hf_spi_context *spicontext,
  53. unsigned char *receivebuff);
  54. #endif