diff options
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/Kconfig | 12 | ||||
-rw-r--r-- | net/nfc/Makefile | 2 | ||||
-rw-r--r-- | net/nfc/digital.h | 27 | ||||
-rw-r--r-- | net/nfc/digital_core.c | 151 |
4 files changed, 192 insertions, 0 deletions
diff --git a/net/nfc/Kconfig b/net/nfc/Kconfig index 5948b2fc72f6..13e1237e1ea1 100644 --- a/net/nfc/Kconfig +++ b/net/nfc/Kconfig | |||
@@ -14,6 +14,18 @@ menuconfig NFC | |||
14 | To compile this support as a module, choose M here: the module will | 14 | To compile this support as a module, choose M here: the module will |
15 | be called nfc. | 15 | be called nfc. |
16 | 16 | ||
17 | config NFC_DIGITAL | ||
18 | depends on NFC | ||
19 | tristate "NFC Digital Protocol stack support" | ||
20 | default n | ||
21 | help | ||
22 | Say Y if you want to build NFC digital protocol stack support. | ||
23 | This is needed by NFC chipsets whose firmware only implement | ||
24 | the NFC analog layer. | ||
25 | |||
26 | To compile this support as a module, choose M here: the module will | ||
27 | be called nfc_digital. | ||
28 | |||
17 | source "net/nfc/nci/Kconfig" | 29 | source "net/nfc/nci/Kconfig" |
18 | source "net/nfc/hci/Kconfig" | 30 | source "net/nfc/hci/Kconfig" |
19 | 31 | ||
diff --git a/net/nfc/Makefile b/net/nfc/Makefile index a76f4533cb6c..8e0cabd85e99 100644 --- a/net/nfc/Makefile +++ b/net/nfc/Makefile | |||
@@ -5,7 +5,9 @@ | |||
5 | obj-$(CONFIG_NFC) += nfc.o | 5 | obj-$(CONFIG_NFC) += nfc.o |
6 | obj-$(CONFIG_NFC_NCI) += nci/ | 6 | obj-$(CONFIG_NFC_NCI) += nci/ |
7 | obj-$(CONFIG_NFC_HCI) += hci/ | 7 | obj-$(CONFIG_NFC_HCI) += hci/ |
8 | obj-$(CONFIG_NFC_DIGITAL) += nfc_digital.o | ||
8 | 9 | ||
9 | nfc-objs := core.o netlink.o af_nfc.o rawsock.o llcp_core.o llcp_commands.o \ | 10 | nfc-objs := core.o netlink.o af_nfc.o rawsock.o llcp_core.o llcp_commands.o \ |
10 | llcp_sock.o | 11 | llcp_sock.o |
11 | 12 | ||
13 | nfc_digital-objs := digital_core.o | ||
diff --git a/net/nfc/digital.h b/net/nfc/digital.h new file mode 100644 index 000000000000..8d91ed820912 --- /dev/null +++ b/net/nfc/digital.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /* | ||
2 | * NFC Digital Protocol stack | ||
3 | * Copyright (c) 2013, Intel Corporation. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #ifndef __DIGITAL_H | ||
17 | #define __DIGITAL_H | ||
18 | |||
19 | #include <net/nfc/nfc.h> | ||
20 | #include <net/nfc/digital.h> | ||
21 | |||
22 | #define PR_DBG(fmt, ...) pr_debug("%s: " fmt "\n", __func__, ##__VA_ARGS__) | ||
23 | #define PR_ERR(fmt, ...) pr_err("%s: " fmt "\n", __func__, ##__VA_ARGS__) | ||
24 | #define PROTOCOL_ERR(req) pr_err("%s:%d: NFC Digital Protocol error: %s\n", \ | ||
25 | __func__, __LINE__, req) | ||
26 | |||
27 | #endif /* __DIGITAL_H */ | ||
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c new file mode 100644 index 000000000000..471188a0d2e0 --- /dev/null +++ b/net/nfc/digital_core.c | |||
@@ -0,0 +1,151 @@ | |||
1 | /* | ||
2 | * NFC Digital Protocol stack | ||
3 | * Copyright (c) 2013, Intel Corporation. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #include <linux/module.h> | ||
17 | |||
18 | #include "digital.h" | ||
19 | |||
20 | static int digital_start_poll(struct nfc_dev *nfc_dev, __u32 im_protocols, | ||
21 | __u32 tm_protocols) | ||
22 | { | ||
23 | return -EOPNOTSUPP; | ||
24 | } | ||
25 | |||
26 | static void digital_stop_poll(struct nfc_dev *nfc_dev) | ||
27 | { | ||
28 | } | ||
29 | |||
30 | static int digital_dev_up(struct nfc_dev *nfc_dev) | ||
31 | { | ||
32 | return -EOPNOTSUPP; | ||
33 | } | ||
34 | |||
35 | static int digital_dev_down(struct nfc_dev *nfc_dev) | ||
36 | { | ||
37 | return -EOPNOTSUPP; | ||
38 | } | ||
39 | |||
40 | static int digital_dep_link_up(struct nfc_dev *nfc_dev, | ||
41 | struct nfc_target *target, | ||
42 | __u8 comm_mode, __u8 *gb, size_t gb_len) | ||
43 | { | ||
44 | return -EOPNOTSUPP; | ||
45 | } | ||
46 | |||
47 | static int digital_dep_link_down(struct nfc_dev *nfc_dev) | ||
48 | { | ||
49 | return -EOPNOTSUPP; | ||
50 | } | ||
51 | |||
52 | static int digital_activate_target(struct nfc_dev *nfc_dev, | ||
53 | struct nfc_target *target, __u32 protocol) | ||
54 | { | ||
55 | return -EOPNOTSUPP; | ||
56 | } | ||
57 | |||
58 | static void digital_deactivate_target(struct nfc_dev *nfc_dev, | ||
59 | struct nfc_target *target) | ||
60 | { | ||
61 | } | ||
62 | |||
63 | static int digital_tg_send(struct nfc_dev *dev, struct sk_buff *skb) | ||
64 | { | ||
65 | return -EOPNOTSUPP; | ||
66 | } | ||
67 | |||
68 | static int digital_in_send(struct nfc_dev *nfc_dev, struct nfc_target *target, | ||
69 | struct sk_buff *skb, data_exchange_cb_t cb, | ||
70 | void *cb_context) | ||
71 | { | ||
72 | return -EOPNOTSUPP; | ||
73 | } | ||
74 | |||
75 | static struct nfc_ops digital_nfc_ops = { | ||
76 | .dev_up = digital_dev_up, | ||
77 | .dev_down = digital_dev_down, | ||
78 | .start_poll = digital_start_poll, | ||
79 | .stop_poll = digital_stop_poll, | ||
80 | .dep_link_up = digital_dep_link_up, | ||
81 | .dep_link_down = digital_dep_link_down, | ||
82 | .activate_target = digital_activate_target, | ||
83 | .deactivate_target = digital_deactivate_target, | ||
84 | .tm_send = digital_tg_send, | ||
85 | .im_transceive = digital_in_send, | ||
86 | }; | ||
87 | |||
88 | struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops, | ||
89 | __u32 supported_protocols, | ||
90 | __u32 driver_capabilities, | ||
91 | int tx_headroom, int tx_tailroom) | ||
92 | { | ||
93 | struct nfc_digital_dev *ddev; | ||
94 | |||
95 | if (!ops->in_configure_hw || !ops->in_send_cmd || !ops->tg_listen || | ||
96 | !ops->tg_configure_hw || !ops->tg_send_cmd || !ops->abort_cmd || | ||
97 | !ops->switch_rf) | ||
98 | return NULL; | ||
99 | |||
100 | ddev = kzalloc(sizeof(struct nfc_digital_dev), GFP_KERNEL); | ||
101 | if (!ddev) { | ||
102 | PR_ERR("kzalloc failed"); | ||
103 | return NULL; | ||
104 | } | ||
105 | |||
106 | ddev->driver_capabilities = driver_capabilities; | ||
107 | ddev->ops = ops; | ||
108 | |||
109 | ddev->tx_headroom = tx_headroom; | ||
110 | ddev->tx_tailroom = tx_tailroom; | ||
111 | |||
112 | ddev->nfc_dev = nfc_allocate_device(&digital_nfc_ops, ddev->protocols, | ||
113 | ddev->tx_headroom, | ||
114 | ddev->tx_tailroom); | ||
115 | if (!ddev->nfc_dev) { | ||
116 | PR_ERR("nfc_allocate_device failed"); | ||
117 | goto free_dev; | ||
118 | } | ||
119 | |||
120 | nfc_set_drvdata(ddev->nfc_dev, ddev); | ||
121 | |||
122 | return ddev; | ||
123 | |||
124 | free_dev: | ||
125 | kfree(ddev); | ||
126 | |||
127 | return NULL; | ||
128 | } | ||
129 | EXPORT_SYMBOL(nfc_digital_allocate_device); | ||
130 | |||
131 | void nfc_digital_free_device(struct nfc_digital_dev *ddev) | ||
132 | { | ||
133 | nfc_free_device(ddev->nfc_dev); | ||
134 | |||
135 | kfree(ddev); | ||
136 | } | ||
137 | EXPORT_SYMBOL(nfc_digital_free_device); | ||
138 | |||
139 | int nfc_digital_register_device(struct nfc_digital_dev *ddev) | ||
140 | { | ||
141 | return nfc_register_device(ddev->nfc_dev); | ||
142 | } | ||
143 | EXPORT_SYMBOL(nfc_digital_register_device); | ||
144 | |||
145 | void nfc_digital_unregister_device(struct nfc_digital_dev *ddev) | ||
146 | { | ||
147 | nfc_unregister_device(ddev->nfc_dev); | ||
148 | } | ||
149 | EXPORT_SYMBOL(nfc_digital_unregister_device); | ||
150 | |||
151 | MODULE_LICENSE("GPL"); | ||