Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2011 Instituto Nokia de Tecnologia
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *    Lauro Ramos Venancio <lauro.venancio@openbossa.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *    Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #ifndef __LOCAL_NFC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define __LOCAL_NFC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <net/nfc/nfc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define NFC_TARGET_MODE_IDLE 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define NFC_TARGET_MODE_SLEEP 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) struct nfc_protocol {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	struct proto *proto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	struct module *owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	int (*create)(struct net *net, struct socket *sock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 		      const struct nfc_protocol *nfc_proto, int kern);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) struct nfc_rawsock {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	struct sock sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	struct nfc_dev *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	u32 target_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct work_struct tx_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	bool tx_work_scheduled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) struct nfc_sock_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	struct hlist_head head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	rwlock_t          lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define nfc_rawsock(sk) ((struct nfc_rawsock *) sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define to_rawsock_sk(_tx_work) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	((struct sock *) container_of(_tx_work, struct nfc_rawsock, tx_work))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) struct nfc_llcp_sdp_tlv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) void nfc_llcp_mac_is_down(struct nfc_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 			u8 comm_mode, u8 rf_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) int nfc_llcp_register_device(struct nfc_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) void nfc_llcp_unregister_device(struct nfc_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) int nfc_llcp_data_received(struct nfc_dev *dev, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) int __init nfc_llcp_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) void nfc_llcp_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) void nfc_llcp_free_sdp_tlv(struct nfc_llcp_sdp_tlv *sdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) void nfc_llcp_free_sdp_tlv_list(struct hlist_head *head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) int __init rawsock_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) void rawsock_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) int __init af_nfc_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) void af_nfc_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) int nfc_proto_register(const struct nfc_protocol *nfc_proto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) void nfc_proto_unregister(const struct nfc_protocol *nfc_proto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) extern int nfc_devlist_generation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) extern struct mutex nfc_devlist_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) int __init nfc_genl_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) void nfc_genl_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) void nfc_genl_data_init(struct nfc_genl_data *genl_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) void nfc_genl_data_exit(struct nfc_genl_data *genl_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) int nfc_genl_targets_found(struct nfc_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) int nfc_genl_device_added(struct nfc_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) int nfc_genl_device_removed(struct nfc_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			       u8 comm_mode, u8 rf_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) int nfc_genl_dep_link_down_event(struct nfc_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) int nfc_genl_tm_activated(struct nfc_dev *dev, u32 protocol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) int nfc_genl_tm_deactivated(struct nfc_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) int nfc_genl_llc_send_sdres(struct nfc_dev *dev, struct hlist_head *sdres_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) int nfc_genl_se_added(struct nfc_dev *dev, u32 se_idx, u16 type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) int nfc_genl_se_removed(struct nfc_dev *dev, u32 se_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) int nfc_genl_se_transaction(struct nfc_dev *dev, u8 se_idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			    struct nfc_evt_transaction *evt_transaction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) int nfc_genl_se_connectivity(struct nfc_dev *dev, u8 se_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) struct nfc_dev *nfc_get_device(unsigned int idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static inline void nfc_put_device(struct nfc_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	put_device(&dev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static inline void nfc_device_iter_init(struct class_dev_iter *iter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	class_dev_iter_init(iter, &nfc_class, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static inline struct nfc_dev *nfc_device_iter_next(struct class_dev_iter *iter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	struct device *d = class_dev_iter_next(iter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	if (!d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	return to_nfc_dev(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static inline void nfc_device_iter_exit(struct class_dev_iter *iter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	class_dev_iter_exit(iter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) int nfc_fw_download(struct nfc_dev *dev, const char *firmware_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) int nfc_genl_fw_download_done(struct nfc_dev *dev, const char *firmware_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			      u32 result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int nfc_dev_up(struct nfc_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) int nfc_dev_down(struct nfc_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int nfc_start_poll(struct nfc_dev *dev, u32 im_protocols, u32 tm_protocols);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) int nfc_stop_poll(struct nfc_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) int nfc_dep_link_up(struct nfc_dev *dev, int target_idx, u8 comm_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) int nfc_dep_link_down(struct nfc_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx, u8 mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		      data_exchange_cb_t cb, void *cb_context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) int nfc_enable_se(struct nfc_dev *dev, u32 se_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) int nfc_disable_se(struct nfc_dev *dev, u32 se_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) #endif /* __LOCAL_NFC_H */