i2c_drv.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /******************************************************************************
  2. * Copyright (C) 2015, The Linux Foundation. All rights reserved.
  3. * Copyright (C) 2019-2021 NXP
  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 as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. *
  19. ******************************************************************************/
  20. /*
  21. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  22. *
  23. ******************************************************************************/
  24. #ifndef _I2C_DRV_H_
  25. #define _I2C_DRV_H_
  26. #include <linux/i2c.h>
  27. #include <linux/version.h>
  28. #define NFC_I2C_DRV_STR "qcom,sn-nci" /*kept same as dts */
  29. #define NFC_I2C_DEV_ID "sn-i2c"
  30. struct nfc_dev;
  31. /* Interface specific parameters */
  32. struct i2c_dev {
  33. struct i2c_client *client;
  34. /* IRQ parameters */
  35. bool irq_enabled;
  36. spinlock_t irq_enabled_lock;
  37. /* NFC_IRQ wake-up state */
  38. bool irq_wake_up;
  39. };
  40. long nfc_i2c_dev_ioctl(struct file *pfile, unsigned int cmd, unsigned long arg);
  41. int nfc_i2c_dev_probe(struct i2c_client *client,
  42. const struct i2c_device_id *id);
  43. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
  44. void nfc_i2c_dev_remove(struct i2c_client *client);
  45. #else
  46. int nfc_i2c_dev_remove(struct i2c_client *client);
  47. #endif
  48. int nfc_i2c_dev_suspend(struct device *device);
  49. int nfc_i2c_dev_resume(struct device *device);
  50. #if IS_ENABLED(CONFIG_NXP_NFC_I2C)
  51. int i2c_enable_irq(struct nfc_dev *dev);
  52. int i2c_disable_irq(struct nfc_dev *dev);
  53. int i2c_write(struct nfc_dev *dev, const char *buf, size_t count,
  54. int max_retry_cnt);
  55. int i2c_read(struct nfc_dev *dev, char *buf, size_t count, int timeout);
  56. #endif
  57. #endif //_I2C_DRV_H_