s3fwrn5.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * NCI based driver for Samsung S3FWRN5 NFC chip
  3. *
  4. * Copyright (C) 2015 Samsung Electrnoics
  5. * Robert Baldyga <r.baldyga@samsung.com>
  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 or later, 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 __LOCAL_S3FWRN5_H_
  20. #define __LOCAL_S3FWRN5_H_
  21. #include <linux/nfc.h>
  22. #include <net/nfc/nci_core.h>
  23. #include "firmware.h"
  24. enum s3fwrn5_mode {
  25. S3FWRN5_MODE_COLD,
  26. S3FWRN5_MODE_NCI,
  27. S3FWRN5_MODE_FW,
  28. };
  29. struct s3fwrn5_phy_ops {
  30. void (*set_wake)(void *id, bool sleep);
  31. void (*set_mode)(void *id, enum s3fwrn5_mode);
  32. enum s3fwrn5_mode (*get_mode)(void *id);
  33. int (*write)(void *id, struct sk_buff *skb);
  34. };
  35. struct s3fwrn5_info {
  36. struct nci_dev *ndev;
  37. void *phy_id;
  38. struct device *pdev;
  39. struct s3fwrn5_phy_ops *phy_ops;
  40. unsigned int max_payload;
  41. struct s3fwrn5_fw_info fw_info;
  42. struct mutex mutex;
  43. };
  44. static inline int s3fwrn5_set_mode(struct s3fwrn5_info *info,
  45. enum s3fwrn5_mode mode)
  46. {
  47. if (!info->phy_ops->set_mode)
  48. return -ENOTSUPP;
  49. info->phy_ops->set_mode(info->phy_id, mode);
  50. return 0;
  51. }
  52. static inline enum s3fwrn5_mode s3fwrn5_get_mode(struct s3fwrn5_info *info)
  53. {
  54. if (!info->phy_ops->get_mode)
  55. return -ENOTSUPP;
  56. return info->phy_ops->get_mode(info->phy_id);
  57. }
  58. static inline int s3fwrn5_set_wake(struct s3fwrn5_info *info, bool wake)
  59. {
  60. if (!info->phy_ops->set_wake)
  61. return -ENOTSUPP;
  62. info->phy_ops->set_wake(info->phy_id, wake);
  63. return 0;
  64. }
  65. static inline int s3fwrn5_write(struct s3fwrn5_info *info, struct sk_buff *skb)
  66. {
  67. if (!info->phy_ops->write)
  68. return -ENOTSUPP;
  69. return info->phy_ops->write(info->phy_id, skb);
  70. }
  71. int s3fwrn5_probe(struct nci_dev **ndev, void *phy_id, struct device *pdev,
  72. struct s3fwrn5_phy_ops *phy_ops, unsigned int max_payload);
  73. void s3fwrn5_remove(struct nci_dev *ndev);
  74. int s3fwrn5_recv_frame(struct nci_dev *ndev, struct sk_buff *skb,
  75. enum s3fwrn5_mode mode);
  76. #endif /* __LOCAL_S3FWRN5_H_ */