13e256b8fSLauro Ramos Venancio /* 23e256b8fSLauro Ramos Venancio * Copyright (C) 2011 Instituto Nokia de Tecnologia 33e256b8fSLauro Ramos Venancio * 43e256b8fSLauro Ramos Venancio * Authors: 53e256b8fSLauro Ramos Venancio * Lauro Ramos Venancio <lauro.venancio@openbossa.org> 63e256b8fSLauro Ramos Venancio * Aloisio Almeida Jr <aloisio.almeida@openbossa.org> 73e256b8fSLauro Ramos Venancio * 83e256b8fSLauro Ramos Venancio * This program is free software; you can redistribute it and/or modify 93e256b8fSLauro Ramos Venancio * it under the terms of the GNU General Public License as published by 103e256b8fSLauro Ramos Venancio * the Free Software Foundation; either version 2 of the License, or 113e256b8fSLauro Ramos Venancio * (at your option) any later version. 123e256b8fSLauro Ramos Venancio * 133e256b8fSLauro Ramos Venancio * This program is distributed in the hope that it will be useful, 143e256b8fSLauro Ramos Venancio * but WITHOUT ANY WARRANTY; without even the implied warranty of 153e256b8fSLauro Ramos Venancio * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 163e256b8fSLauro Ramos Venancio * GNU General Public License for more details. 173e256b8fSLauro Ramos Venancio * 183e256b8fSLauro Ramos Venancio * You should have received a copy of the GNU General Public License 193e256b8fSLauro Ramos Venancio * along with this program; if not, write to the 203e256b8fSLauro Ramos Venancio * Free Software Foundation, Inc., 213e256b8fSLauro Ramos Venancio * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 223e256b8fSLauro Ramos Venancio */ 233e256b8fSLauro Ramos Venancio 243e256b8fSLauro Ramos Venancio #ifndef __LOCAL_NFC_H 253e256b8fSLauro Ramos Venancio #define __LOCAL_NFC_H 263e256b8fSLauro Ramos Venancio 2755eb94f9SIlan Elias #include <net/nfc/nfc.h> 28c7fe3b52SAloisio Almeida Jr #include <net/sock.h> 293e256b8fSLauro Ramos Venancio 30c7fe3b52SAloisio Almeida Jr struct nfc_protocol { 31c7fe3b52SAloisio Almeida Jr int id; 32c7fe3b52SAloisio Almeida Jr struct proto *proto; 33c7fe3b52SAloisio Almeida Jr struct module *owner; 34c7fe3b52SAloisio Almeida Jr int (*create)(struct net *net, struct socket *sock, 35c7fe3b52SAloisio Almeida Jr const struct nfc_protocol *nfc_proto); 36c7fe3b52SAloisio Almeida Jr }; 37c7fe3b52SAloisio Almeida Jr 3823b7869cSLauro Ramos Venancio struct nfc_rawsock { 3923b7869cSLauro Ramos Venancio struct sock sk; 4023b7869cSLauro Ramos Venancio struct nfc_dev *dev; 4123b7869cSLauro Ramos Venancio u32 target_idx; 4223b7869cSLauro Ramos Venancio struct work_struct tx_work; 4323b7869cSLauro Ramos Venancio bool tx_work_scheduled; 4423b7869cSLauro Ramos Venancio }; 4523b7869cSLauro Ramos Venancio #define nfc_rawsock(sk) ((struct nfc_rawsock *) sk) 4623b7869cSLauro Ramos Venancio #define to_rawsock_sk(_tx_work) \ 4723b7869cSLauro Ramos Venancio ((struct sock *) container_of(_tx_work, struct nfc_rawsock, tx_work)) 4823b7869cSLauro Ramos Venancio 49d9b8d8e1SThierry Escande struct nfc_llcp_sdp_tlv; 50d9b8d8e1SThierry Escande 51d646960fSSamuel Ortiz void nfc_llcp_mac_is_down(struct nfc_dev *dev); 52d646960fSSamuel Ortiz void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx, 53d646960fSSamuel Ortiz u8 comm_mode, u8 rf_mode); 54d646960fSSamuel Ortiz int nfc_llcp_register_device(struct nfc_dev *dev); 55d646960fSSamuel Ortiz void nfc_llcp_unregister_device(struct nfc_dev *dev); 56d646960fSSamuel Ortiz int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len); 5747807d3dSSamuel Ortiz u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len); 5873167cedSSamuel Ortiz int nfc_llcp_data_received(struct nfc_dev *dev, struct sk_buff *skb); 5952feb444SThierry Escande struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev); 60d646960fSSamuel Ortiz int __init nfc_llcp_init(void); 61d646960fSSamuel Ortiz void nfc_llcp_exit(void); 62d9b8d8e1SThierry Escande void nfc_llcp_free_sdp_tlv(struct nfc_llcp_sdp_tlv *sdp); 63d9b8d8e1SThierry Escande void nfc_llcp_free_sdp_tlv_list(struct hlist_head *head); 64d646960fSSamuel Ortiz 6523b7869cSLauro Ramos Venancio int __init rawsock_init(void); 6623b7869cSLauro Ramos Venancio void rawsock_exit(void); 6723b7869cSLauro Ramos Venancio 68c7fe3b52SAloisio Almeida Jr int __init af_nfc_init(void); 69c7fe3b52SAloisio Almeida Jr void af_nfc_exit(void); 70c7fe3b52SAloisio Almeida Jr int nfc_proto_register(const struct nfc_protocol *nfc_proto); 71c7fe3b52SAloisio Almeida Jr void nfc_proto_unregister(const struct nfc_protocol *nfc_proto); 72c7fe3b52SAloisio Almeida Jr 733e256b8fSLauro Ramos Venancio extern int nfc_devlist_generation; 743e256b8fSLauro Ramos Venancio extern struct mutex nfc_devlist_mutex; 753e256b8fSLauro Ramos Venancio 764d12b8b1SLauro Ramos Venancio int __init nfc_genl_init(void); 774d12b8b1SLauro Ramos Venancio void nfc_genl_exit(void); 784d12b8b1SLauro Ramos Venancio 794d12b8b1SLauro Ramos Venancio void nfc_genl_data_init(struct nfc_genl_data *genl_data); 804d12b8b1SLauro Ramos Venancio void nfc_genl_data_exit(struct nfc_genl_data *genl_data); 814d12b8b1SLauro Ramos Venancio 824d12b8b1SLauro Ramos Venancio int nfc_genl_targets_found(struct nfc_dev *dev); 838112a5c9SSamuel Ortiz int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx); 844d12b8b1SLauro Ramos Venancio 854d12b8b1SLauro Ramos Venancio int nfc_genl_device_added(struct nfc_dev *dev); 864d12b8b1SLauro Ramos Venancio int nfc_genl_device_removed(struct nfc_dev *dev); 874d12b8b1SLauro Ramos Venancio 881ed28f61SSamuel Ortiz int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx, 891ed28f61SSamuel Ortiz u8 comm_mode, u8 rf_mode); 901ed28f61SSamuel Ortiz int nfc_genl_dep_link_down_event(struct nfc_dev *dev); 911ed28f61SSamuel Ortiz 92fc40a8c1SSamuel Ortiz int nfc_genl_tm_activated(struct nfc_dev *dev, u32 protocol); 93fc40a8c1SSamuel Ortiz int nfc_genl_tm_deactivated(struct nfc_dev *dev); 94fc40a8c1SSamuel Ortiz 95d9b8d8e1SThierry Escande int nfc_genl_llc_send_sdres(struct nfc_dev *dev, struct hlist_head *sdres_list); 96d9b8d8e1SThierry Escande 972757c372SSamuel Ortiz int nfc_genl_se_added(struct nfc_dev *dev, u32 se_idx, u16 type); 982757c372SSamuel Ortiz int nfc_genl_se_removed(struct nfc_dev *dev, u32 se_idx); 992757c372SSamuel Ortiz 10095c96174SEric Dumazet struct nfc_dev *nfc_get_device(unsigned int idx); 1013e256b8fSLauro Ramos Venancio 1023e256b8fSLauro Ramos Venancio static inline void nfc_put_device(struct nfc_dev *dev) 1033e256b8fSLauro Ramos Venancio { 1043e256b8fSLauro Ramos Venancio put_device(&dev->dev); 1053e256b8fSLauro Ramos Venancio } 1063e256b8fSLauro Ramos Venancio 1073e256b8fSLauro Ramos Venancio static inline void nfc_device_iter_init(struct class_dev_iter *iter) 1083e256b8fSLauro Ramos Venancio { 1093e256b8fSLauro Ramos Venancio class_dev_iter_init(iter, &nfc_class, NULL, NULL); 1103e256b8fSLauro Ramos Venancio } 1113e256b8fSLauro Ramos Venancio 1123e256b8fSLauro Ramos Venancio static inline struct nfc_dev *nfc_device_iter_next(struct class_dev_iter *iter) 1133e256b8fSLauro Ramos Venancio { 1143e256b8fSLauro Ramos Venancio struct device *d = class_dev_iter_next(iter); 1153e256b8fSLauro Ramos Venancio if (!d) 1163e256b8fSLauro Ramos Venancio return NULL; 1173e256b8fSLauro Ramos Venancio 1183e256b8fSLauro Ramos Venancio return to_nfc_dev(d); 1193e256b8fSLauro Ramos Venancio } 1203e256b8fSLauro Ramos Venancio 1213e256b8fSLauro Ramos Venancio static inline void nfc_device_iter_exit(struct class_dev_iter *iter) 1223e256b8fSLauro Ramos Venancio { 1233e256b8fSLauro Ramos Venancio class_dev_iter_exit(iter); 1243e256b8fSLauro Ramos Venancio } 1253e256b8fSLauro Ramos Venancio 1269674da87SEric Lapuyade int nfc_fw_upload(struct nfc_dev *dev, const char *firmware_name); 1279674da87SEric Lapuyade int nfc_genl_fw_upload_done(struct nfc_dev *dev, const char *firmware_name); 1289674da87SEric Lapuyade 1299674da87SEric Lapuyade int nfc_fw_upload_done(struct nfc_dev *dev, const char *firmware_name); 1309674da87SEric Lapuyade 1318b3fe7b5SIlan Elias int nfc_dev_up(struct nfc_dev *dev); 1328b3fe7b5SIlan Elias 1338b3fe7b5SIlan Elias int nfc_dev_down(struct nfc_dev *dev); 1348b3fe7b5SIlan Elias 135fe7c5800SSamuel Ortiz int nfc_start_poll(struct nfc_dev *dev, u32 im_protocols, u32 tm_protocols); 1363e256b8fSLauro Ramos Venancio 1373e256b8fSLauro Ramos Venancio int nfc_stop_poll(struct nfc_dev *dev); 1383e256b8fSLauro Ramos Venancio 13947807d3dSSamuel Ortiz int nfc_dep_link_up(struct nfc_dev *dev, int target_idx, u8 comm_mode); 1401ed28f61SSamuel Ortiz 1411ed28f61SSamuel Ortiz int nfc_dep_link_down(struct nfc_dev *dev); 1421ed28f61SSamuel Ortiz 1433e256b8fSLauro Ramos Venancio int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol); 1443e256b8fSLauro Ramos Venancio 1453e256b8fSLauro Ramos Venancio int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx); 1463e256b8fSLauro Ramos Venancio 1470a40acb2SSamuel Ortiz int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb, 1480a40acb2SSamuel Ortiz data_exchange_cb_t cb, void *cb_context); 1493e256b8fSLauro Ramos Venancio 150*c531c9ecSSamuel Ortiz int nfc_enable_se(struct nfc_dev *dev, u32 se_idx); 151*c531c9ecSSamuel Ortiz int nfc_disable_se(struct nfc_dev *dev, u32 se_idx); 152*c531c9ecSSamuel Ortiz 1533e256b8fSLauro Ramos Venancio #endif /* __LOCAL_NFC_H */ 154