Linux Audio

Check our new training course

Loading...
v4.6
 
 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
20#ifndef __LOCAL_S3FWRN5_H_
21#define __LOCAL_S3FWRN5_H_
22
23#include <linux/nfc.h>
24
25#include <net/nfc/nci_core.h>
26
27#include "firmware.h"
28
29enum s3fwrn5_mode {
30	S3FWRN5_MODE_COLD,
31	S3FWRN5_MODE_NCI,
32	S3FWRN5_MODE_FW,
33};
34
35struct s3fwrn5_phy_ops {
36	void (*set_wake)(void *id, bool sleep);
37	void (*set_mode)(void *id, enum s3fwrn5_mode);
38	enum s3fwrn5_mode (*get_mode)(void *id);
39	int (*write)(void *id, struct sk_buff *skb);
40};
41
42struct s3fwrn5_info {
43	struct nci_dev *ndev;
44	void *phy_id;
45	struct device *pdev;
46
47	const struct s3fwrn5_phy_ops *phy_ops;
48	unsigned int max_payload;
49
50	struct s3fwrn5_fw_info fw_info;
51
52	struct mutex mutex;
53};
54
55static inline int s3fwrn5_set_mode(struct s3fwrn5_info *info,
56	enum s3fwrn5_mode mode)
57{
58	if (!info->phy_ops->set_mode)
59		return -ENOTSUPP;
60
61	info->phy_ops->set_mode(info->phy_id, mode);
62
63	return 0;
64}
65
66static inline enum s3fwrn5_mode s3fwrn5_get_mode(struct s3fwrn5_info *info)
67{
68	if (!info->phy_ops->get_mode)
69		return -ENOTSUPP;
70
71	return info->phy_ops->get_mode(info->phy_id);
72}
73
74static inline int s3fwrn5_set_wake(struct s3fwrn5_info *info, bool wake)
75{
76	if (!info->phy_ops->set_wake)
77		return -ENOTSUPP;
78
79	info->phy_ops->set_wake(info->phy_id, wake);
80
81	return 0;
82}
83
84static inline int s3fwrn5_write(struct s3fwrn5_info *info, struct sk_buff *skb)
85{
86	if (!info->phy_ops->write)
87		return -ENOTSUPP;
88
89	return info->phy_ops->write(info->phy_id, skb);
90}
91
92int s3fwrn5_probe(struct nci_dev **ndev, void *phy_id, struct device *pdev,
93	const struct s3fwrn5_phy_ops *phy_ops, unsigned int max_payload);
94void s3fwrn5_remove(struct nci_dev *ndev);
95
96int s3fwrn5_recv_frame(struct nci_dev *ndev, struct sk_buff *skb,
97	enum s3fwrn5_mode mode);
98
99#endif /* __LOCAL_S3FWRN5_H_ */
v6.13.7
 1/* SPDX-License-Identifier: GPL-2.0-or-later */
 2/*
 3 * NCI based driver for Samsung S3FWRN5 NFC chip
 4 *
 5 * Copyright (C) 2015 Samsung Electrnoics
 6 * Robert Baldyga <r.baldyga@samsung.com>
 
 
 
 
 
 
 
 
 
 
 
 
 7 */
 8
 9#ifndef __LOCAL_S3FWRN5_H_
10#define __LOCAL_S3FWRN5_H_
11
12#include <linux/nfc.h>
13
14#include <net/nfc/nci_core.h>
15
16#include "firmware.h"
17
18enum s3fwrn5_mode {
19	S3FWRN5_MODE_COLD,
20	S3FWRN5_MODE_NCI,
21	S3FWRN5_MODE_FW,
22};
23
24struct s3fwrn5_phy_ops {
25	void (*set_wake)(void *id, bool sleep);
26	void (*set_mode)(void *id, enum s3fwrn5_mode);
27	enum s3fwrn5_mode (*get_mode)(void *id);
28	int (*write)(void *id, struct sk_buff *skb);
29};
30
31struct s3fwrn5_info {
32	struct nci_dev *ndev;
33	void *phy_id;
34	struct device *pdev;
35
36	const struct s3fwrn5_phy_ops *phy_ops;
 
37
38	struct s3fwrn5_fw_info fw_info;
39
40	struct mutex mutex;
41};
42
43static inline int s3fwrn5_set_mode(struct s3fwrn5_info *info,
44	enum s3fwrn5_mode mode)
45{
46	if (!info->phy_ops->set_mode)
47		return -EOPNOTSUPP;
48
49	info->phy_ops->set_mode(info->phy_id, mode);
50
51	return 0;
52}
53
54static inline enum s3fwrn5_mode s3fwrn5_get_mode(struct s3fwrn5_info *info)
55{
56	if (!info->phy_ops->get_mode)
57		return -EOPNOTSUPP;
58
59	return info->phy_ops->get_mode(info->phy_id);
60}
61
62static inline int s3fwrn5_set_wake(struct s3fwrn5_info *info, bool wake)
63{
64	if (!info->phy_ops->set_wake)
65		return -EOPNOTSUPP;
66
67	info->phy_ops->set_wake(info->phy_id, wake);
68
69	return 0;
70}
71
72static inline int s3fwrn5_write(struct s3fwrn5_info *info, struct sk_buff *skb)
73{
74	if (!info->phy_ops->write)
75		return -EOPNOTSUPP;
76
77	return info->phy_ops->write(info->phy_id, skb);
78}
79
80int s3fwrn5_probe(struct nci_dev **ndev, void *phy_id, struct device *pdev,
81	const struct s3fwrn5_phy_ops *phy_ops);
82void s3fwrn5_remove(struct nci_dev *ndev);
83
84int s3fwrn5_recv_frame(struct nci_dev *ndev, struct sk_buff *skb,
85	enum s3fwrn5_mode mode);
86
87#endif /* __LOCAL_S3FWRN5_H_ */