Skip to content

Commit

Permalink
Merge tag 'nfc-next-4.5-1' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/git/sameo/nfc-next

Samuel Ortiz says:

====================
NFC 4.5 pull request

This is the first NFC pull request for 4.5 and it brings:

- A new driver for the STMicroelectronics ST95HF NFC chipset.
  The ST95HF is an NFC digital transceiver with an embedded analog
  front-end and as such relies on the Linux NFC digital
  implementation. This is the 3rd user of the NFC digital stack.

- ACPI support for the ST st-nci and st21nfca drivers.

- A small improvement for the nfcsim driver, as we can now tune
  the Rx delay through sysfs.

- A bunch of minor cleanups and small fixes from Christophe Ricard,
  for a few drivers and the NFC core code.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jan 5, 2016
2 parents 197c949 + c6dc65d commit 15ab90f
Showing 34 changed files with 1,862 additions and 181 deletions.
50 changes: 50 additions & 0 deletions Documentation/devicetree/bindings/net/nfc/st95hf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
* STMicroelectronics : NFC Transceiver ST95HF

ST NFC Transceiver is required to attach with SPI bus.
ST95HF node should be defined in DT as SPI slave device of SPI
master with which ST95HF transceiver is physically connected.
The properties defined below are required to be the part of DT
to include ST95HF transceiver into the platform.

Required properties:
===================
- reg: Address of SPI slave "ST95HF transceiver" on SPI master bus.

- compatible: should be "st,st95hf" for ST95HF NFC transceiver

- spi-max-frequency: Max. operating SPI frequency for ST95HF
transceiver.

- enable-gpio: GPIO line to enable ST95HF transceiver.

- interrupt-parent : Standard way to specify the controller to which
ST95HF transceiver's interrupt is routed.

- interrupts : Standard way to define ST95HF transceiver's out
interrupt.

Optional property:
=================
- st95hfvin-supply : This is an optional property. It contains a
phandle to ST95HF transceiver's regulator supply node in DT.

Example:
=======
spi@9840000 {
reg = <0x9840000 0x110>;
#address-cells = <1>;
#size-cells = <0>;
cs-gpios = <&pio0 4>;
status = "okay";

st95hf@0{
reg = <0>;
compatible = "st,st95hf";
status = "okay";
spi-max-frequency = <1000000>;
enable-gpio = <&pio4 0>;
interrupt-parent = <&pio0>;
interrupts = <7 IRQ_TYPE_EDGE_FALLING>;
};

};
5 changes: 5 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
@@ -7523,7 +7523,12 @@ F: net/nfc/
F: include/net/nfc/
F: include/uapi/linux/nfc.h
F: drivers/nfc/
F: include/linux/platform_data/microread.h
F: include/linux/platform_data/nfcmrvl.h
F: include/linux/platform_data/nxp-nci.h
F: include/linux/platform_data/pn544.h
F: include/linux/platform_data/st21nfca.h
F: include/linux/platform_data/st-nci.h
F: Documentation/devicetree/bindings/net/nfc/

NFS, SUNRPC, AND LOCKD CLIENTS
1 change: 1 addition & 0 deletions drivers/nfc/Kconfig
Original file line number Diff line number Diff line change
@@ -76,4 +76,5 @@ source "drivers/nfc/st21nfca/Kconfig"
source "drivers/nfc/st-nci/Kconfig"
source "drivers/nfc/nxp-nci/Kconfig"
source "drivers/nfc/s3fwrn5/Kconfig"
source "drivers/nfc/st95hf/Kconfig"
endmenu
1 change: 1 addition & 0 deletions drivers/nfc/Makefile
Original file line number Diff line number Diff line change
@@ -16,3 +16,4 @@ obj-$(CONFIG_NFC_ST21NFCA) += st21nfca/
obj-$(CONFIG_NFC_ST_NCI) += st-nci/
obj-$(CONFIG_NFC_NXP_NCI) += nxp-nci/
obj-$(CONFIG_NFC_S3FWRN5) += s3fwrn5/
obj-$(CONFIG_NFC_ST95HF) += st95hf/
12 changes: 6 additions & 6 deletions drivers/nfc/fdp/i2c.c
Original file line number Diff line number Diff line change
@@ -298,6 +298,12 @@ static int fdp_nci_i2c_probe(struct i2c_client *client,
return -ENODEV;
}

/* Checking if we have an irq */
if (client->irq <= 0) {
nfc_err(dev, "IRQ not present\n");
return -ENODEV;
}

phy = devm_kzalloc(dev, sizeof(struct fdp_i2c_phy),
GFP_KERNEL);
if (!phy)
@@ -307,12 +313,6 @@ static int fdp_nci_i2c_probe(struct i2c_client *client,
phy->next_read_size = FDP_NCI_I2C_MIN_PAYLOAD;
i2c_set_clientdata(client, phy);

/* Checking if we have an irq */
if (client->irq <= 0) {
dev_err(dev, "IRQ not present\n");
return -ENODEV;
}

r = request_threaded_irq(client->irq, NULL, fdp_nci_i2c_irq_thread_fn,
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
FDP_I2C_DRIVER_NAME, phy);
2 changes: 0 additions & 2 deletions drivers/nfc/microread/i2c.c
Original file line number Diff line number Diff line change
@@ -50,8 +50,6 @@ struct microread_i2c_phy {
struct i2c_client *i2c_dev;
struct nfc_hci_dev *hdev;

int irq;

int hard_fault; /*
* < 0 if hardware error occured (e.g. i2c err)
* and prevents normal operation.
10 changes: 7 additions & 3 deletions drivers/nfc/nfcsim.c
Original file line number Diff line number Diff line change
@@ -32,6 +32,8 @@
#define NFCSIM_POLL_TARGET 2
#define NFCSIM_POLL_DUAL (NFCSIM_POLL_INITIATOR | NFCSIM_POLL_TARGET)

#define RX_DEFAULT_DELAY 5

struct nfcsim {
struct nfc_dev *nfc_dev;

@@ -51,6 +53,8 @@ struct nfcsim {

u8 initiator;

u32 rx_delay;

data_exchange_cb_t cb;
void *cb_context;

@@ -320,10 +324,9 @@ static int nfcsim_tx(struct nfc_dev *nfc_dev, struct nfc_target *target,
* If packet transmission occurs immediately between them, we have a
* non-stop flow of several tens of thousands SYMM packets per second
* and a burning cpu.
*
* TODO: Add support for a sysfs entry to control this delay.
*/
queue_delayed_work(wq, &peer->recv_work, msecs_to_jiffies(5));
queue_delayed_work(wq, &peer->recv_work,
msecs_to_jiffies(dev->rx_delay));

mutex_unlock(&peer->lock);

@@ -461,6 +464,7 @@ static struct nfcsim *nfcsim_init_dev(void)
if (rc)
goto free_nfc_dev;

dev->rx_delay = RX_DEFAULT_DELAY;
return dev;

free_nfc_dev:
34 changes: 3 additions & 31 deletions drivers/nfc/nxp-nci/i2c.c
Original file line number Diff line number Diff line change
@@ -52,7 +52,6 @@ struct nxp_nci_i2c_phy {

unsigned int gpio_en;
unsigned int gpio_fw;
unsigned int gpio_irq;

int hard_fault; /*
* < 0 if hardware error occurred (e.g. i2c err)
@@ -85,7 +84,7 @@ static int nxp_nci_i2c_write(void *phy_id, struct sk_buff *skb)
return phy->hard_fault;

r = i2c_master_send(client, skb->data, skb->len);
if (r == -EREMOTEIO) {
if (r < 0) {
/* Retry, chip was in standby */
usleep_range(110000, 120000);
r = i2c_master_send(client, skb->data, skb->len);
@@ -264,8 +263,6 @@ static irqreturn_t nxp_nci_i2c_irq_thread_fn(int irq, void *phy_id)
return IRQ_NONE;
}

#ifdef CONFIG_OF

static int nxp_nci_i2c_parse_devtree(struct i2c_client *client)
{
struct nxp_nci_i2c_phy *phy = i2c_get_clientdata(client);
@@ -294,48 +291,24 @@ static int nxp_nci_i2c_parse_devtree(struct i2c_client *client)
}
phy->gpio_fw = r;

r = irq_of_parse_and_map(pp, 0);
if (r < 0) {
nfc_err(&client->dev, "Unable to get irq, error: %d\n", r);
return r;
}
client->irq = r;

return 0;
}

#else

static int nxp_nci_i2c_parse_devtree(struct i2c_client *client)
{
return -ENODEV;
}

#endif

static int nxp_nci_i2c_acpi_config(struct nxp_nci_i2c_phy *phy)
{
struct i2c_client *client = phy->i2c_dev;
struct gpio_desc *gpiod_en, *gpiod_fw, *gpiod_irq;
struct gpio_desc *gpiod_en, *gpiod_fw;

gpiod_en = devm_gpiod_get_index(&client->dev, NULL, 2, GPIOD_OUT_LOW);
gpiod_fw = devm_gpiod_get_index(&client->dev, NULL, 1, GPIOD_OUT_LOW);
gpiod_irq = devm_gpiod_get_index(&client->dev, NULL, 0, GPIOD_IN);

if (IS_ERR(gpiod_en) || IS_ERR(gpiod_fw) || IS_ERR(gpiod_irq)) {
if (IS_ERR(gpiod_en) || IS_ERR(gpiod_fw)) {
nfc_err(&client->dev, "No GPIOs\n");
return -EINVAL;
}

client->irq = gpiod_to_irq(gpiod_irq);
if (client->irq < 0) {
nfc_err(&client->dev, "No IRQ\n");
return -EINVAL;
}

phy->gpio_en = desc_to_gpio(gpiod_en);
phy->gpio_fw = desc_to_gpio(gpiod_fw);
phy->gpio_irq = desc_to_gpio(gpiod_irq);

return 0;
}
@@ -374,7 +347,6 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
} else if (pdata) {
phy->gpio_en = pdata->gpio_en;
phy->gpio_fw = pdata->gpio_fw;
client->irq = pdata->irq;
} else if (ACPI_HANDLE(&client->dev)) {
r = nxp_nci_i2c_acpi_config(phy);
if (r < 0)
46 changes: 1 addition & 45 deletions drivers/nfc/pn544/i2c.c
Original file line number Diff line number Diff line change
@@ -166,7 +166,6 @@ struct pn544_i2c_phy {
struct nfc_hci_dev *hdev;

unsigned int gpio_en;
unsigned int gpio_irq;
unsigned int gpio_fw;
unsigned int en_polarity;

@@ -879,9 +878,8 @@ static int pn544_hci_i2c_acpi_request_resources(struct i2c_client *client)
{
struct pn544_i2c_phy *phy = i2c_get_clientdata(client);
const struct acpi_device_id *id;
struct gpio_desc *gpiod_en, *gpiod_irq, *gpiod_fw;
struct gpio_desc *gpiod_en, *gpiod_fw;
struct device *dev;
int ret;

if (!client)
return -EINVAL;
@@ -914,32 +912,9 @@ static int pn544_hci_i2c_acpi_request_resources(struct i2c_client *client)

phy->gpio_fw = desc_to_gpio(gpiod_fw);

/* Get IRQ GPIO */
gpiod_irq = devm_gpiod_get_index(dev, PN544_GPIO_NAME_IRQ, 0,
GPIOD_IN);
if (IS_ERR(gpiod_irq)) {
nfc_err(dev, "Unable to get IRQ GPIO\n");
return -ENODEV;
}

phy->gpio_irq = desc_to_gpio(gpiod_irq);

/* Map the pin to an IRQ */
ret = gpiod_to_irq(gpiod_irq);
if (ret < 0) {
nfc_err(dev, "Fail pin IRQ mapping\n");
return ret;
}

nfc_info(dev, "GPIO resource, no:%d irq:%d\n",
desc_to_gpio(gpiod_irq), ret);
client->irq = ret;

return 0;
}

#ifdef CONFIG_OF

static int pn544_hci_i2c_of_request_resources(struct i2c_client *client)
{
struct pn544_i2c_phy *phy = i2c_get_clientdata(client);
@@ -996,15 +971,6 @@ static int pn544_hci_i2c_of_request_resources(struct i2c_client *client)
goto err_gpio_fw;
}

/* IRQ */
ret = irq_of_parse_and_map(pp, 0);
if (ret < 0) {
nfc_err(&client->dev,
"Unable to get irq, error: %d\n", ret);
goto err_gpio_fw;
}
client->irq = ret;

return 0;

err_gpio_fw:
@@ -1015,15 +981,6 @@ static int pn544_hci_i2c_of_request_resources(struct i2c_client *client)
return ret;
}

#else

static int pn544_hci_i2c_of_request_resources(struct i2c_client *client)
{
return -ENODEV;
}

#endif

static int pn544_hci_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -1076,7 +1033,6 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,

phy->gpio_en = pdata->get_gpio(NFC_GPIO_ENABLE);
phy->gpio_fw = pdata->get_gpio(NFC_GPIO_FW_RESET);
phy->gpio_irq = pdata->get_gpio(NFC_GPIO_IRQ);
/* Using ACPI */
} else if (ACPI_HANDLE(&client->dev)) {
r = pn544_hci_i2c_acpi_request_resources(client);
2 changes: 1 addition & 1 deletion drivers/nfc/s3fwrn5/core.c
Original file line number Diff line number Diff line change
@@ -147,7 +147,7 @@ static struct nci_ops s3fwrn5_nci_ops = {
};

int s3fwrn5_probe(struct nci_dev **ndev, void *phy_id, struct device *pdev,
struct s3fwrn5_phy_ops *phy_ops, unsigned int max_payload)
const struct s3fwrn5_phy_ops *phy_ops, unsigned int max_payload)
{
struct s3fwrn5_info *info;
int ret;
2 changes: 1 addition & 1 deletion drivers/nfc/s3fwrn5/i2c.c
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ static int s3fwrn5_i2c_write(void *phy_id, struct sk_buff *skb)
return 0;
}

static struct s3fwrn5_phy_ops i2c_phy_ops = {
static const struct s3fwrn5_phy_ops i2c_phy_ops = {
.set_wake = s3fwrn5_i2c_set_wake,
.set_mode = s3fwrn5_i2c_set_mode,
.get_mode = s3fwrn5_i2c_get_mode,
4 changes: 2 additions & 2 deletions drivers/nfc/s3fwrn5/s3fwrn5.h
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ struct s3fwrn5_info {
void *phy_id;
struct device *pdev;

struct s3fwrn5_phy_ops *phy_ops;
const struct s3fwrn5_phy_ops *phy_ops;
unsigned int max_payload;

struct s3fwrn5_fw_info fw_info;
@@ -90,7 +90,7 @@ static inline int s3fwrn5_write(struct s3fwrn5_info *info, struct sk_buff *skb)
}

int s3fwrn5_probe(struct nci_dev **ndev, void *phy_id, struct device *pdev,
struct s3fwrn5_phy_ops *phy_ops, unsigned int max_payload);
const struct s3fwrn5_phy_ops *phy_ops, unsigned int max_payload);
void s3fwrn5_remove(struct nci_dev *ndev);

int s3fwrn5_recv_frame(struct nci_dev *ndev, struct sk_buff *skb,
18 changes: 7 additions & 11 deletions drivers/nfc/st-nci/Kconfig
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
config NFC_ST_NCI
tristate "STMicroelectronics ST NCI NFC driver"
depends on NFC_NCI
default n
tristate
---help---
STMicroelectronics NFC NCI chips core driver. It implements the chipset
NCI logic and hooks into the NFC kernel APIs. Physical layers will
register against it.

To compile this driver as a module, choose m here. The module will
be called st-nci.
Say N if unsure.

config NFC_ST_NCI_I2C
tristate "NFC ST NCI i2c support"
depends on NFC_ST_NCI && I2C
tristate "STMicroelectronics ST NCI NFC driver (I2C)"
depends on NFC_NCI && I2C
select NFC_ST_NCI
---help---
This module adds support for an I2C interface to the
STMicroelectronics NFC NCI chips familly.
@@ -23,8 +18,9 @@ config NFC_ST_NCI_I2C
Say N if unsure.

config NFC_ST_NCI_SPI
tristate "NFC ST NCI spi support"
depends on NFC_ST_NCI && SPI
tristate "STMicroelectronics ST NCI NFC driver (SPI)"
depends on NFC_NCI && SPI
select NFC_ST_NCI
---help---
This module adds support for an SPI interface to the
STMicroelectronics NFC NCI chips familly.
Loading

0 comments on commit 15ab90f

Please sign in to comment.