Skip to content

Commit

Permalink
Merge branch 'nfc-pn533-add-uart-phy-driver'
Browse files Browse the repository at this point in the history
Lars Poeschel says:

====================
nfc: pn533: add uart phy driver

The purpose of this patch series is to add a uart phy driver to the
pn533 nfc driver.
It first changes the dt strings and docs. The dt compatible strings
need to change, because I would add "pn532-uart" to the already
existing "pn533-i2c" one. These two are now unified into just
"pn532". Then the neccessary changes to the pn533 core driver are
made. Then the uart phy is added.
As the pn532 chip supports a autopoll, I wanted to use this instead
of the software poll loop in the pn533 core driver. It is added and
activated by the last to patches.
The way to add the autopoll later in seperate patches is chosen, to
show, that the uart phy driver can also work with the software poll
loop, if someone needs that for some reason.
In v11 of this patchseries I address a byte ordering issue reported
by kbuild test robot in patch 5/7.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Oct 30, 2019
2 parents 9014fc3 + e4a5dc1 commit 7492344
Show file tree
Hide file tree
Showing 9 changed files with 692 additions and 88 deletions.
46 changes: 46 additions & 0 deletions Documentation/devicetree/bindings/net/nfc/pn532.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
* NXP Semiconductors PN532 NFC Controller

Required properties:
- compatible: Should be
- "nxp,pn532" Place a node with this inside the devicetree node of the bus
where the NFC chip is connected to.
Currently the kernel has phy bindings for uart and i2c.
- "nxp,pn532-i2c" (DEPRECATED) only works for the i2c binding.
- "nxp,pn533-i2c" (DEPRECATED) only works for the i2c binding.

Required properties if connected on i2c:
- clock-frequency: I²C work frequency.
- reg: for the I²C bus address. This is fixed at 0x24 for the PN532.
- interrupts: GPIO interrupt to which the chip is connected

Optional SoC Specific Properties:
- pinctrl-names: Contains only one value - "default".
- pintctrl-0: Specifies the pin control groups used for this controller.

Example (for ARM-based BeagleBone with PN532 on I2C2):

&i2c2 {


pn532: nfc@24 {

compatible = "nxp,pn532";

reg = <0x24>;
clock-frequency = <400000>;

interrupt-parent = <&gpio1>;
interrupts = <17 IRQ_TYPE_EDGE_FALLING>;

};
};

Example (for PN532 connected via uart):

uart4: serial@49042000 {
compatible = "ti,omap3-uart";

pn532: nfc {
compatible = "nxp,pn532";
};
};
29 changes: 0 additions & 29 deletions Documentation/devicetree/bindings/net/nfc/pn533-i2c.txt

This file was deleted.

11 changes: 11 additions & 0 deletions drivers/nfc/pn533/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@ config NFC_PN533_I2C

If you choose to build a module, it'll be called pn533_i2c.
Say N if unsure.

config NFC_PN532_UART
tristate "NFC PN532 device support (UART)"
depends on SERIAL_DEV_BUS
select NFC_PN533
---help---
This module adds support for the NXP pn532 UART interface.
Select this if your platform is using the UART bus.

If you choose to build a module, it'll be called pn532_uart.
Say N if unsure.
2 changes: 2 additions & 0 deletions drivers/nfc/pn533/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#
pn533_usb-objs = usb.o
pn533_i2c-objs = i2c.o
pn532_uart-objs = uart.o

obj-$(CONFIG_NFC_PN533) += pn533.o
obj-$(CONFIG_NFC_PN533_USB) += pn533_usb.o
obj-$(CONFIG_NFC_PN533_I2C) += pn533_i2c.o
obj-$(CONFIG_NFC_PN532_UART) += pn532_uart.o
32 changes: 23 additions & 9 deletions drivers/nfc/pn533/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,20 @@ static int pn533_i2c_probe(struct i2c_client *client,
phy->i2c_dev = client;
i2c_set_clientdata(client, phy);

priv = pn533_register_device(PN533_DEVICE_PN532,
PN533_NO_TYPE_B_PROTOCOLS,
PN533_PROTO_REQ_ACK_RESP,
phy, &i2c_phy_ops, NULL,
&phy->i2c_dev->dev,
&client->dev);
priv = pn53x_common_init(PN533_DEVICE_PN532,
PN533_PROTO_REQ_ACK_RESP,
phy, &i2c_phy_ops, NULL,
&phy->i2c_dev->dev);

if (IS_ERR(priv)) {
r = PTR_ERR(priv);
return r;
}

phy->priv = priv;
r = pn532_i2c_nfc_alloc(priv, PN533_NO_TYPE_B_PROTOCOLS, &client->dev);
if (r)
goto nfc_alloc_err;

r = request_threaded_irq(client->irq, NULL, pn533_i2c_irq_thread_fn,
IRQF_TRIGGER_FALLING |
Expand All @@ -220,13 +221,20 @@ static int pn533_i2c_probe(struct i2c_client *client,
if (r)
goto fn_setup_err;

return 0;
r = nfc_register_device(priv->nfc_dev);
if (r)
goto fn_setup_err;

return r;

fn_setup_err:
free_irq(client->irq, phy);

irq_rqst_err:
pn533_unregister_device(phy->priv);
nfc_free_device(priv->nfc_dev);

nfc_alloc_err:
pn53x_common_clean(phy->priv);

return r;
}
Expand All @@ -239,12 +247,18 @@ static int pn533_i2c_remove(struct i2c_client *client)

free_irq(client->irq, phy);

pn533_unregister_device(phy->priv);
pn53x_unregister_nfc(phy->priv);
pn53x_common_clean(phy->priv);

return 0;
}

static const struct of_device_id of_pn533_i2c_match[] = {
{ .compatible = "nxp,pn532", },
/*
* NOTE: The use of the compatibles with the trailing "...-i2c" is
* deprecated and will be removed.
*/
{ .compatible = "nxp,pn533-i2c", },
{ .compatible = "nxp,pn532-i2c", },
{},
Expand Down
Loading

0 comments on commit 7492344

Please sign in to comment.