0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef __LOCAL_S3FWRN5_H_
0010 #define __LOCAL_S3FWRN5_H_
0011
0012 #include <linux/nfc.h>
0013
0014 #include <net/nfc/nci_core.h>
0015
0016 #include "firmware.h"
0017
0018 enum s3fwrn5_mode {
0019 S3FWRN5_MODE_COLD,
0020 S3FWRN5_MODE_NCI,
0021 S3FWRN5_MODE_FW,
0022 };
0023
0024 struct s3fwrn5_phy_ops {
0025 void (*set_wake)(void *id, bool sleep);
0026 void (*set_mode)(void *id, enum s3fwrn5_mode);
0027 enum s3fwrn5_mode (*get_mode)(void *id);
0028 int (*write)(void *id, struct sk_buff *skb);
0029 };
0030
0031 struct s3fwrn5_info {
0032 struct nci_dev *ndev;
0033 void *phy_id;
0034 struct device *pdev;
0035
0036 const struct s3fwrn5_phy_ops *phy_ops;
0037
0038 struct s3fwrn5_fw_info fw_info;
0039
0040 struct mutex mutex;
0041 };
0042
0043 static inline int s3fwrn5_set_mode(struct s3fwrn5_info *info,
0044 enum s3fwrn5_mode mode)
0045 {
0046 if (!info->phy_ops->set_mode)
0047 return -EOPNOTSUPP;
0048
0049 info->phy_ops->set_mode(info->phy_id, mode);
0050
0051 return 0;
0052 }
0053
0054 static inline enum s3fwrn5_mode s3fwrn5_get_mode(struct s3fwrn5_info *info)
0055 {
0056 if (!info->phy_ops->get_mode)
0057 return -EOPNOTSUPP;
0058
0059 return info->phy_ops->get_mode(info->phy_id);
0060 }
0061
0062 static inline int s3fwrn5_set_wake(struct s3fwrn5_info *info, bool wake)
0063 {
0064 if (!info->phy_ops->set_wake)
0065 return -EOPNOTSUPP;
0066
0067 info->phy_ops->set_wake(info->phy_id, wake);
0068
0069 return 0;
0070 }
0071
0072 static inline int s3fwrn5_write(struct s3fwrn5_info *info, struct sk_buff *skb)
0073 {
0074 if (!info->phy_ops->write)
0075 return -EOPNOTSUPP;
0076
0077 return info->phy_ops->write(info->phy_id, skb);
0078 }
0079
0080 int s3fwrn5_probe(struct nci_dev **ndev, void *phy_id, struct device *pdev,
0081 const struct s3fwrn5_phy_ops *phy_ops);
0082 void s3fwrn5_remove(struct nci_dev *ndev);
0083
0084 int s3fwrn5_recv_frame(struct nci_dev *ndev, struct sk_buff *skb,
0085 enum s3fwrn5_mode mode);
0086
0087 #endif