diff options
author | Vincent Cuissard <cuissard@marvell.com> | 2015-06-11 11:25:46 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2015-06-11 23:25:21 +0200 |
commit | 4a2b947f56b33cde68d6e0543160ea09ce651fd9 (patch) | |
tree | 5bd042492e6be12b7d9d8320012bb414b0d339fb /drivers/nfc/nfcmrvl/main.c | |
parent | 8a81a96bd116ef5c505f37e035ce141f6b35a6a7 (diff) | |
download | linux-4a2b947f56b33cde68d6e0543160ea09ce651fd9.tar.bz2 |
NFC: nfcmrvl: add chip reset management
Low level driver can specify a GPIO that will be used to reset
the chip. Thanks to this the driver can ensure the state of the
device at init.
Signed-off-by: Vincent Cuissard <cuissard@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc/nfcmrvl/main.c')
-rw-r--r-- | drivers/nfc/nfcmrvl/main.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/nfc/nfcmrvl/main.c b/drivers/nfc/nfcmrvl/main.c index e7f579b2d987..708aad28c567 100644 --- a/drivers/nfc/nfcmrvl/main.c +++ b/drivers/nfc/nfcmrvl/main.c @@ -17,6 +17,8 @@ */ #include <linux/module.h> +#include <linux/gpio.h> +#include <linux/delay.h> #include <linux/nfc.h> #include <net/nfc/nci.h> #include <net/nfc/nci_core.h> @@ -107,6 +109,16 @@ struct nfcmrvl_private *nfcmrvl_nci_register_dev(void *drv_data, priv->if_ops = ops; priv->dev = dev; priv->hci_muxed = (flags & NFCMRVL_DEV_FLAG_HCI_MUXED) ? 1 : 0; + priv->reset_n_io = NFCMRVL_DEV_FLAG_GET_RESET_N_IO(flags); + + if (priv->reset_n_io) { + rc = devm_gpio_request_one(dev, + priv->reset_n_io, + GPIOF_OUT_INIT_LOW, + "nfcmrvl_reset_n"); + if (rc < 0) + nfc_err(dev, "failed to request reset_n io\n"); + } if (priv->hci_muxed) headroom = NFCMRVL_HCI_EVENT_HEADER_SIZE; @@ -127,6 +139,8 @@ struct nfcmrvl_private *nfcmrvl_nci_register_dev(void *drv_data, nci_set_drvdata(priv->ndev, priv); + nfcmrvl_chip_reset(priv); + rc = nci_register_device(priv->ndev); if (rc) { nfc_err(dev, "nci_register_device failed %d\n", rc); @@ -179,6 +193,22 @@ int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, struct sk_buff *skb) } EXPORT_SYMBOL_GPL(nfcmrvl_nci_recv_frame); +void nfcmrvl_chip_reset(struct nfcmrvl_private *priv) +{ + /* + * This function does not take care if someone is using the device. + * To be improved. + */ + + if (priv->reset_n_io) { + nfc_info(priv->dev, "reset the chip\n"); + gpio_set_value(priv->reset_n_io, 0); + usleep_range(5000, 10000); + gpio_set_value(priv->reset_n_io, 1); + } else + nfc_info(priv->dev, "no reset available on this interface\n"); +} + MODULE_AUTHOR("Marvell International Ltd."); MODULE_DESCRIPTION("Marvell NFC driver ver " VERSION); MODULE_VERSION(VERSION); |