nfc_i2c_drv.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2019-2021 NXP
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  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, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. ******************************************************************************/
  21. #ifndef _NFC_I2C_DRV_H_
  22. #define _NFC_I2C_DRV_H_
  23. #include <linux/i2c.h>
  24. #define NFC_I2C_DRV_STR "qcom,sn-nci" /*kept same as dts */
  25. #define NFC_I2C_DEV_ID "sn-i2c"
  26. struct nfc_dev;
  27. //Interface specific parameters
  28. struct i2c_dev {
  29. struct i2c_client *client;
  30. /*IRQ parameters */
  31. bool irq_enabled;
  32. spinlock_t irq_enabled_lock;
  33. /* NFC_IRQ wake-up state */
  34. bool irq_wake_up;
  35. };
  36. long nfc_i2c_dev_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg);
  37. int nfc_i2c_dev_probe(struct i2c_client *client,
  38. const struct i2c_device_id *id);
  39. int nfc_i2c_dev_remove(struct i2c_client *client);
  40. int nfc_i2c_dev_suspend(struct device *device);
  41. int nfc_i2c_dev_resume(struct device *device);
  42. #if IS_ENABLED(CONFIG_NFC_QTI_I2C)
  43. int i2c_enable_irq(struct nfc_dev *dev);
  44. int i2c_disable_irq(struct nfc_dev *dev);
  45. int i2c_write(struct nfc_dev *dev, const char *buf, size_t count,
  46. int max_retry_cnt);
  47. int i2c_read(struct nfc_dev *dev, char *buf, size_t count, int timeout);
  48. #else
  49. static inline int i2c_enable_irq(struct nfc_dev *dev)
  50. {
  51. return -ENXIO;
  52. }
  53. static inline int i2c_disable_irq(struct nfc_dev *dev)
  54. {
  55. return -ENXIO;
  56. }
  57. static inline int i2c_write(struct nfc_dev *dev, const char *buf,
  58. size_t count, int max_retry_cnt)
  59. {
  60. return -ENXIO;
  61. }
  62. static inline int i2c_read(struct nfc_dev *dev, char *buf, size_t count, int timeout)
  63. {
  64. return -ENXIO;
  65. }
  66. #endif
  67. #endif //_NFC_I2C_DRV_H_