2021-05-31 15:35:14 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2021-05-24 05:09:09 +08:00
|
|
|
/*
|
2014-01-07 04:58:19 +08:00
|
|
|
* Marvell NFC driver
|
|
|
|
*
|
2015-10-26 17:27:39 +08:00
|
|
|
* Copyright (C) 2014-2015, Marvell International Ltd.
|
2021-05-31 15:35:14 +08:00
|
|
|
*/
|
2014-01-07 04:58:19 +08:00
|
|
|
|
2015-06-11 20:00:19 +08:00
|
|
|
#ifndef _NFCMRVL_H_
|
|
|
|
#define _NFCMRVL_H_
|
|
|
|
|
|
|
|
#include <linux/platform_data/nfcmrvl.h>
|
|
|
|
|
2015-10-26 17:27:39 +08:00
|
|
|
#include "fw_dnld.h"
|
|
|
|
|
2014-01-07 04:58:19 +08:00
|
|
|
/* Define private flags: */
|
|
|
|
#define NFCMRVL_NCI_RUNNING 1
|
2015-10-26 17:27:41 +08:00
|
|
|
#define NFCMRVL_PHY_ERROR 2
|
2014-01-07 04:58:19 +08:00
|
|
|
|
2014-01-07 04:58:20 +08:00
|
|
|
#define NFCMRVL_EXT_COEX_ID 0xE0
|
|
|
|
#define NFCMRVL_NOT_ALLOWED_ID 0xE1
|
|
|
|
#define NFCMRVL_ACTIVE_ID 0xE2
|
|
|
|
#define NFCMRVL_EXT_COEX_ENABLE 1
|
|
|
|
#define NFCMRVL_GPIO_PIN_NFC_NOT_ALLOWED 0xA
|
|
|
|
#define NFCMRVL_GPIO_PIN_NFC_ACTIVE 0xB
|
2014-01-07 04:58:19 +08:00
|
|
|
#define NFCMRVL_NCI_MAX_EVENT_SIZE 260
|
|
|
|
|
2015-06-12 21:35:54 +08:00
|
|
|
/*
|
2021-05-31 15:35:15 +08:00
|
|
|
* NCI FW Parameters
|
|
|
|
*/
|
2015-06-12 21:35:54 +08:00
|
|
|
|
|
|
|
#define NFCMRVL_PB_BAIL_OUT 0x11
|
2015-10-26 17:27:39 +08:00
|
|
|
#define NFCMRVL_PROP_REF_CLOCK 0xF0
|
|
|
|
#define NFCMRVL_PROP_SET_HI_CONFIG 0xF1
|
2015-06-12 21:35:54 +08:00
|
|
|
|
2015-06-11 17:25:43 +08:00
|
|
|
/*
|
2021-05-31 15:35:15 +08:00
|
|
|
* HCI defines
|
|
|
|
*/
|
2015-06-11 17:25:43 +08:00
|
|
|
|
|
|
|
#define NFCMRVL_HCI_EVENT_HEADER_SIZE 0x04
|
|
|
|
#define NFCMRVL_HCI_EVENT_CODE 0x04
|
|
|
|
#define NFCMRVL_HCI_NFC_EVENT_CODE 0xFF
|
|
|
|
#define NFCMRVL_HCI_COMMAND_CODE 0x01
|
|
|
|
#define NFCMRVL_HCI_OGF 0x81
|
|
|
|
#define NFCMRVL_HCI_OCF 0xFE
|
|
|
|
|
2015-06-11 20:00:20 +08:00
|
|
|
enum nfcmrvl_phy {
|
|
|
|
NFCMRVL_PHY_USB = 0,
|
|
|
|
NFCMRVL_PHY_UART = 1,
|
2015-10-26 17:27:39 +08:00
|
|
|
NFCMRVL_PHY_I2C = 2,
|
|
|
|
NFCMRVL_PHY_SPI = 3,
|
2015-06-11 20:00:20 +08:00
|
|
|
};
|
|
|
|
|
2014-01-07 04:58:19 +08:00
|
|
|
struct nfcmrvl_private {
|
2015-06-11 17:25:43 +08:00
|
|
|
|
2015-06-11 20:00:19 +08:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
/* Platform configuration */
|
|
|
|
struct nfcmrvl_platform_data config;
|
|
|
|
|
2015-10-26 17:27:39 +08:00
|
|
|
/* Parent dev */
|
2014-01-07 04:58:19 +08:00
|
|
|
struct nci_dev *ndev;
|
2015-06-11 17:25:46 +08:00
|
|
|
|
2015-10-26 17:27:39 +08:00
|
|
|
/* FW download context */
|
|
|
|
struct nfcmrvl_fw_dnld fw_dnld;
|
|
|
|
|
|
|
|
/* FW download support */
|
|
|
|
bool support_fw_dnld;
|
|
|
|
|
2015-06-11 20:00:19 +08:00
|
|
|
/*
|
2021-05-31 15:35:15 +08:00
|
|
|
* PHY related information
|
|
|
|
*/
|
2015-06-11 17:25:46 +08:00
|
|
|
|
2015-06-11 20:00:19 +08:00
|
|
|
/* PHY driver context */
|
2014-01-07 04:58:19 +08:00
|
|
|
void *drv_data;
|
2015-06-11 20:00:19 +08:00
|
|
|
/* PHY device */
|
2014-01-07 04:58:19 +08:00
|
|
|
struct device *dev;
|
2015-06-11 20:00:20 +08:00
|
|
|
/* PHY type */
|
|
|
|
enum nfcmrvl_phy phy;
|
2015-06-11 20:00:19 +08:00
|
|
|
/* Low level driver ops */
|
2014-01-07 04:58:19 +08:00
|
|
|
struct nfcmrvl_if_ops *if_ops;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nfcmrvl_if_ops {
|
|
|
|
int (*nci_open) (struct nfcmrvl_private *priv);
|
|
|
|
int (*nci_close) (struct nfcmrvl_private *priv);
|
|
|
|
int (*nci_send) (struct nfcmrvl_private *priv, struct sk_buff *skb);
|
2015-10-26 17:27:39 +08:00
|
|
|
void (*nci_update_config)(struct nfcmrvl_private *priv,
|
|
|
|
const void *param);
|
2014-01-07 04:58:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv);
|
2015-06-11 17:25:44 +08:00
|
|
|
int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, struct sk_buff *skb);
|
2015-10-26 17:27:40 +08:00
|
|
|
struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy,
|
|
|
|
void *drv_data,
|
2015-06-11 20:00:19 +08:00
|
|
|
struct nfcmrvl_if_ops *ops,
|
|
|
|
struct device *dev,
|
|
|
|
struct nfcmrvl_platform_data *pdata);
|
|
|
|
|
2015-06-11 17:25:46 +08:00
|
|
|
|
|
|
|
void nfcmrvl_chip_reset(struct nfcmrvl_private *priv);
|
2015-10-26 17:27:39 +08:00
|
|
|
void nfcmrvl_chip_halt(struct nfcmrvl_private *priv);
|
2015-06-11 20:00:19 +08:00
|
|
|
|
|
|
|
int nfcmrvl_parse_dt(struct device_node *node,
|
|
|
|
struct nfcmrvl_platform_data *pdata);
|
|
|
|
|
|
|
|
#endif
|