1be3d162aSKrzysztof Kozlowski /* SPDX-License-Identifier: GPL-2.0-only */ 24dd649d1SAditya Srivastava /* 3f26e30ccSAmitkumar Karwar * Marvell NFC driver 4f26e30ccSAmitkumar Karwar * 53194c687SVincent Cuissard * Copyright (C) 2014-2015, Marvell International Ltd. 6be3d162aSKrzysztof Kozlowski */ 7f26e30ccSAmitkumar Karwar 8dc14bdefSVincent Cuissard #ifndef _NFCMRVL_H_ 9dc14bdefSVincent Cuissard #define _NFCMRVL_H_ 10dc14bdefSVincent Cuissard 113194c687SVincent Cuissard #include "fw_dnld.h" 123194c687SVincent Cuissard 13f26e30ccSAmitkumar Karwar /* Define private flags: */ 14f26e30ccSAmitkumar Karwar #define NFCMRVL_NCI_RUNNING 1 15b5b3e23eSVincent Cuissard #define NFCMRVL_PHY_ERROR 2 16f26e30ccSAmitkumar Karwar 1715203b4cSAmitkumar Karwar #define NFCMRVL_EXT_COEX_ID 0xE0 1815203b4cSAmitkumar Karwar #define NFCMRVL_NOT_ALLOWED_ID 0xE1 1915203b4cSAmitkumar Karwar #define NFCMRVL_ACTIVE_ID 0xE2 2015203b4cSAmitkumar Karwar #define NFCMRVL_EXT_COEX_ENABLE 1 2115203b4cSAmitkumar Karwar #define NFCMRVL_GPIO_PIN_NFC_NOT_ALLOWED 0xA 2215203b4cSAmitkumar Karwar #define NFCMRVL_GPIO_PIN_NFC_ACTIVE 0xB 23f26e30ccSAmitkumar Karwar #define NFCMRVL_NCI_MAX_EVENT_SIZE 260 24f26e30ccSAmitkumar Karwar 25f1f1a7daSVincent Cuissard /* 268f99528eSKrzysztof Kozlowski * NCI FW Parameters 27d0dcad8bSVincent Cuissard */ 28d0dcad8bSVincent Cuissard 29d0dcad8bSVincent Cuissard #define NFCMRVL_PB_BAIL_OUT 0x11 303194c687SVincent Cuissard #define NFCMRVL_PROP_REF_CLOCK 0xF0 313194c687SVincent Cuissard #define NFCMRVL_PROP_SET_HI_CONFIG 0xF1 32d0dcad8bSVincent Cuissard 33d0dcad8bSVincent Cuissard /* 348f99528eSKrzysztof Kozlowski * HCI defines 35f1f1a7daSVincent Cuissard */ 36f1f1a7daSVincent Cuissard 37f1f1a7daSVincent Cuissard #define NFCMRVL_HCI_EVENT_HEADER_SIZE 0x04 38f1f1a7daSVincent Cuissard #define NFCMRVL_HCI_EVENT_CODE 0x04 39f1f1a7daSVincent Cuissard #define NFCMRVL_HCI_NFC_EVENT_CODE 0xFF 40f1f1a7daSVincent Cuissard #define NFCMRVL_HCI_COMMAND_CODE 0x01 41f1f1a7daSVincent Cuissard #define NFCMRVL_HCI_OGF 0x81 42f1f1a7daSVincent Cuissard #define NFCMRVL_HCI_OCF 0xFE 43f1f1a7daSVincent Cuissard 44e097dc62SVincent Cuissard enum nfcmrvl_phy { 45e097dc62SVincent Cuissard NFCMRVL_PHY_USB = 0, 46e097dc62SVincent Cuissard NFCMRVL_PHY_UART = 1, 473194c687SVincent Cuissard NFCMRVL_PHY_I2C = 2, 483194c687SVincent Cuissard NFCMRVL_PHY_SPI = 3, 49e097dc62SVincent Cuissard }; 50e097dc62SVincent Cuissard 51053fdaa8SRob Herring struct nfcmrvl_platform_data { 52053fdaa8SRob Herring /* 53053fdaa8SRob Herring * Generic 54053fdaa8SRob Herring */ 55053fdaa8SRob Herring 56053fdaa8SRob Herring /* GPIO that is wired to RESET_N signal */ 57053fdaa8SRob Herring int reset_n_io; 58053fdaa8SRob Herring /* Tell if transport is muxed in HCI one */ 59*cc6d85c1SRob Herring bool hci_muxed; 60053fdaa8SRob Herring 61053fdaa8SRob Herring /* 62053fdaa8SRob Herring * UART specific 63053fdaa8SRob Herring */ 64053fdaa8SRob Herring 65053fdaa8SRob Herring /* Tell if UART needs flow control at init */ 66*cc6d85c1SRob Herring bool flow_control; 67053fdaa8SRob Herring /* Tell if firmware supports break control for power management */ 68*cc6d85c1SRob Herring bool break_control; 69053fdaa8SRob Herring 70053fdaa8SRob Herring 71053fdaa8SRob Herring /* 72053fdaa8SRob Herring * I2C specific 73053fdaa8SRob Herring */ 74053fdaa8SRob Herring 75053fdaa8SRob Herring unsigned int irq; 76053fdaa8SRob Herring unsigned int irq_polarity; 77053fdaa8SRob Herring }; 78053fdaa8SRob Herring 79f26e30ccSAmitkumar Karwar struct nfcmrvl_private { 80f1f1a7daSVincent Cuissard 81dc14bdefSVincent Cuissard unsigned long flags; 82dc14bdefSVincent Cuissard 83dc14bdefSVincent Cuissard /* Platform configuration */ 84dc14bdefSVincent Cuissard struct nfcmrvl_platform_data config; 85dc14bdefSVincent Cuissard 863194c687SVincent Cuissard /* Parent dev */ 87f26e30ccSAmitkumar Karwar struct nci_dev *ndev; 884a2b947fSVincent Cuissard 893194c687SVincent Cuissard /* FW download context */ 903194c687SVincent Cuissard struct nfcmrvl_fw_dnld fw_dnld; 913194c687SVincent Cuissard 923194c687SVincent Cuissard /* FW download support */ 933194c687SVincent Cuissard bool support_fw_dnld; 943194c687SVincent Cuissard 95dc14bdefSVincent Cuissard /* 968f99528eSKrzysztof Kozlowski * PHY related information 97dc14bdefSVincent Cuissard */ 984a2b947fSVincent Cuissard 99dc14bdefSVincent Cuissard /* PHY driver context */ 100f26e30ccSAmitkumar Karwar void *drv_data; 101dc14bdefSVincent Cuissard /* PHY device */ 102f26e30ccSAmitkumar Karwar struct device *dev; 103e097dc62SVincent Cuissard /* PHY type */ 104e097dc62SVincent Cuissard enum nfcmrvl_phy phy; 105dc14bdefSVincent Cuissard /* Low level driver ops */ 10626955037SKrzysztof Kozlowski const struct nfcmrvl_if_ops *if_ops; 107f26e30ccSAmitkumar Karwar }; 108f26e30ccSAmitkumar Karwar 109f26e30ccSAmitkumar Karwar struct nfcmrvl_if_ops { 110f26e30ccSAmitkumar Karwar int (*nci_open) (struct nfcmrvl_private *priv); 111f26e30ccSAmitkumar Karwar int (*nci_close) (struct nfcmrvl_private *priv); 112f26e30ccSAmitkumar Karwar int (*nci_send) (struct nfcmrvl_private *priv, struct sk_buff *skb); 1133194c687SVincent Cuissard void (*nci_update_config)(struct nfcmrvl_private *priv, 1143194c687SVincent Cuissard const void *param); 115f26e30ccSAmitkumar Karwar }; 116f26e30ccSAmitkumar Karwar 117f26e30ccSAmitkumar Karwar void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv); 118e1bf80c2SVincent Cuissard int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, struct sk_buff *skb); 11958d34aa6SVincent Cuissard struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy, 12058d34aa6SVincent Cuissard void *drv_data, 12126955037SKrzysztof Kozlowski const struct nfcmrvl_if_ops *ops, 122f1f1a7daSVincent Cuissard struct device *dev, 123fe53159fSKrzysztof Kozlowski const struct nfcmrvl_platform_data *pdata); 124dc14bdefSVincent Cuissard 1254a2b947fSVincent Cuissard 1264a2b947fSVincent Cuissard void nfcmrvl_chip_reset(struct nfcmrvl_private *priv); 1273194c687SVincent Cuissard void nfcmrvl_chip_halt(struct nfcmrvl_private *priv); 128dc14bdefSVincent Cuissard 129dc14bdefSVincent Cuissard int nfcmrvl_parse_dt(struct device_node *node, 130dc14bdefSVincent Cuissard struct nfcmrvl_platform_data *pdata); 131dc14bdefSVincent Cuissard 132dc14bdefSVincent Cuissard #endif 133