Skip to content

Commit

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

Samuel Ortiz <sameo@linux.intel.com> says:

"NFC: 3.18 pull request

This is the NFC pull request for 3.18.

We've had major updates for TI and ST Microelectronics drivers:

For TI's trf7970a driver:

- Target mode support for trf7970a
- Suspend/resume support for trf7970a
- DT properties additions to handle different quirks
- A bunch of fixes for smartphone IOP related issues

For ST Microelectronics' ST21NFCA and ST21NFCB drivers:

- ISO15693 support for st21nfcb
- checkpatch and sparse related warning fixes
- Code cleanups and a few minor fixes

Finally, Marvell add ISO15693 support to the NCI stack, together with a
couple of NCI fixes."

Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
John W. Linville committed Sep 26, 2014
2 parents 687b930 + 094e935 commit 330bd4e
Show file tree
Hide file tree
Showing 18 changed files with 1,188 additions and 354 deletions.
2 changes: 1 addition & 1 deletion Documentation/devicetree/bindings/net/nfc/st21nfcb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Example (for ARM-based BeagleBoard xM with ST21NFCB on I2C2):
clock-frequency = <400000>;

interrupt-parent = <&gpio5>;
interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;

reset-gpios = <&gpio5 29 GPIO_ACTIVE_HIGH>;
};
Expand Down
8 changes: 8 additions & 0 deletions Documentation/devicetree/bindings/net/nfc/trf7970a.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Optional SoC Specific Properties:
- pinctrl-names: Contains only one value - "default".
- pintctrl-0: Specifies the pin control groups used for this controller.
- autosuspend-delay: Specify autosuspend delay in milliseconds.
- vin-voltage-override: Specify voltage of VIN pin in microvolts.
- irq-status-read-quirk: Specify that the trf7970a being used has the
"IRQ Status Read" erratum.
- en2-rf-quirk: Specify that the trf7970a being used has the "EN2 RF"
erratum.

Example (for ARM-based BeagleBone with TRF7970A on SPI1):

Expand All @@ -30,7 +35,10 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1):
ti,enable-gpios = <&gpio2 2 GPIO_ACTIVE_LOW>,
<&gpio2 5 GPIO_ACTIVE_LOW>;
vin-supply = <&ldo3_reg>;
vin-voltage-override = <5000000>;
autosuspend-delay = <30000>;
irq-status-read-quirk;
en2-rf-quirk;
status = "okay";
};
};
34 changes: 9 additions & 25 deletions drivers/nfc/st21nfca/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ static int st21nfca_hci_i2c_write(void *phy_id, struct sk_buff *skb)
static int get_frame_size(u8 *buf, int buflen)
{
int len = 0;

if (buf[len + 1] == ST21NFCA_SOF_EOF)
return 0;

Expand Down Expand Up @@ -311,6 +312,7 @@ static int check_crc(u8 *buf, int buflen)
static int st21nfca_hci_i2c_repack(struct sk_buff *skb)
{
int i, j, r, size;

if (skb->len < 1 || (skb->len > 1 && skb->data[1] != 0))
return -EBADMSG;

Expand Down Expand Up @@ -525,24 +527,19 @@ static int st21nfca_hci_i2c_of_request_resources(struct i2c_client *client)
}

/* GPIO request and configuration */
r = devm_gpio_request(&client->dev, gpio, "clf_enable");
r = devm_gpio_request_one(&client->dev, gpio, GPIOF_OUT_INIT_HIGH,
"clf_enable");
if (r) {
nfc_err(&client->dev, "Failed to request enable pin\n");
return -ENODEV;
}

r = gpio_direction_output(gpio, 1);
if (r) {
nfc_err(&client->dev, "Failed to set enable pin direction as output\n");
return -ENODEV;
}
phy->gpio_ena = gpio;

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

Expand Down Expand Up @@ -576,32 +573,20 @@ static int st21nfca_hci_i2c_request_resources(struct i2c_client *client)
phy->gpio_ena = pdata->gpio_ena;
phy->irq_polarity = pdata->irq_polarity;

r = devm_gpio_request(&client->dev, phy->gpio_irq, "wake_up");
r = devm_gpio_request_one(&client->dev, phy->gpio_irq, GPIOF_IN,
"wake_up");
if (r) {
pr_err("%s : gpio_request failed\n", __FILE__);
return -ENODEV;
}

r = gpio_direction_input(phy->gpio_irq);
if (r) {
pr_err("%s : gpio_direction_input failed\n", __FILE__);
return -ENODEV;
}

if (phy->gpio_ena > 0) {
r = devm_gpio_request(&client->dev,
phy->gpio_ena, "clf_enable");
r = devm_gpio_request_one(&client->dev, phy->gpio_ena,
GPIOF_OUT_INIT_HIGH, "clf_enable");
if (r) {
pr_err("%s : ena gpio_request failed\n", __FILE__);
return -ENODEV;
}
r = gpio_direction_output(phy->gpio_ena, 1);

if (r) {
pr_err("%s : ena gpio_direction_output failed\n",
__FILE__);
return -ENODEV;
}
}

/* IRQ */
Expand Down Expand Up @@ -711,7 +696,6 @@ static struct i2c_driver st21nfca_hci_i2c_driver = {
.driver = {
.owner = THIS_MODULE,
.name = ST21NFCA_HCI_I2C_DRIVER_NAME,
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(of_st21nfca_i2c_match),
},
.probe = st21nfca_hci_i2c_probe,
Expand Down
59 changes: 40 additions & 19 deletions drivers/nfc/st21nfca/st21nfca.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#define ST21NFCA_RF_READER_CMD_PRESENCE_CHECK 0x30

#define ST21NFCA_RF_READER_ISO15693_GATE 0x12
#define ST21NFCA_RF_READER_ISO15693_INVENTORY 0x01
#define ST21NFCA_RF_READER_ISO15693_INVENTORY 0x01

/*
* Reader gate for communication with contact-less cards using Type A
Expand All @@ -45,21 +45,42 @@
#define ST21NFCA_RF_READER_14443_3_A_ATQA 0x03
#define ST21NFCA_RF_READER_14443_3_A_SAK 0x04

#define ST21NFCA_RF_READER_F_DATARATE 0x01
#define ST21NFCA_RF_READER_F_DATARATE_106 0x01
#define ST21NFCA_RF_READER_F_DATARATE_212 0x02
#define ST21NFCA_RF_READER_F_DATARATE_424 0x04
#define ST21NFCA_RF_READER_F_POL_REQ 0x02
#define ST21NFCA_RF_READER_F_POL_REQ_DEFAULT 0xffff0000
#define ST21NFCA_RF_READER_F_NFCID2 0x03
#define ST21NFCA_RF_READER_F_NFCID1 0x04

#define ST21NFCA_RF_CARD_F_MODE 0x01
#define ST21NFCA_RF_CARD_F_NFCID2_LIST 0x04
#define ST21NFCA_RF_CARD_F_NFCID1 0x05
#define ST21NFCA_RF_CARD_F_SENS_RES 0x06
#define ST21NFCA_RF_CARD_F_SEL_RES 0x07
#define ST21NFCA_RF_CARD_F_DATARATE 0x08
#define ST21NFCA_RF_CARD_F_DATARATE_212_424 0x01

#define ST21NFCA_DEVICE_MGNT_GATE 0x01
#define ST21NFCA_DEVICE_MGNT_PIPE 0x02

#define ST21NFCA_DM_GETINFO 0x13
#define ST21NFCA_DM_GETINFO_PIPE_LIST 0x02
#define ST21NFCA_DM_GETINFO_PIPE_INFO 0x01
#define ST21NFCA_DM_PIPE_CREATED 0x02
#define ST21NFCA_DM_PIPE_OPEN 0x04
#define ST21NFCA_DM_RF_ACTIVE 0x80
#define ST21NFCA_DM_DISCONNECT 0x30
#define ST21NFCA_DM_GETINFO 0x13
#define ST21NFCA_DM_GETINFO_PIPE_LIST 0x02
#define ST21NFCA_DM_GETINFO_PIPE_INFO 0x01
#define ST21NFCA_DM_PIPE_CREATED 0x02
#define ST21NFCA_DM_PIPE_OPEN 0x04
#define ST21NFCA_DM_RF_ACTIVE 0x80
#define ST21NFCA_DM_DISCONNECT 0x30

#define ST21NFCA_DM_IS_PIPE_OPEN(p) \
((p & 0x0f) == (ST21NFCA_DM_PIPE_CREATED | ST21NFCA_DM_PIPE_OPEN))

#define ST21NFCA_NFC_MODE 0x03 /* NFC_MODE parameter*/
#define ST21NFCA_NFC_MODE 0x03 /* NFC_MODE parameter*/
#define ST21NFCA_EVT_FIELD_ON 0x11
#define ST21NFCA_EVT_CARD_DEACTIVATED 0x12
#define ST21NFCA_EVT_CARD_ACTIVATED 0x13
#define ST21NFCA_EVT_FIELD_OFF 0x14

static DECLARE_BITMAP(dev_mask, ST21NFCA_NUM_DEVICES);

Expand Down Expand Up @@ -355,8 +376,8 @@ static int st21nfca_hci_start_poll(struct nfc_hci_dev *hdev,
if (r < 0)
return r;

pol_req =
be32_to_cpu(ST21NFCA_RF_READER_F_POL_REQ_DEFAULT);
pol_req = be32_to_cpu((__force __be32)
ST21NFCA_RF_READER_F_POL_REQ_DEFAULT);
r = nfc_hci_set_param(hdev, ST21NFCA_RF_READER_F_GATE,
ST21NFCA_RF_READER_F_POL_REQ,
(u8 *) &pol_req, 4);
Expand Down Expand Up @@ -790,6 +811,7 @@ static int st21nfca_hci_check_presence(struct nfc_hci_dev *hdev,
struct nfc_target *target)
{
u8 fwi = 0x11;

switch (target->hci_reader_gate) {
case NFC_HCI_RF_READER_A_GATE:
case NFC_HCI_RF_READER_B_GATE:
Expand Down Expand Up @@ -839,20 +861,16 @@ static int st21nfca_hci_event_received(struct nfc_hci_dev *hdev, u8 gate,
if (gate == ST21NFCA_RF_CARD_F_GATE) {
r = st21nfca_tm_event_send_data(hdev, skb, gate);
if (r < 0)
goto exit;
return r;
return 0;
} else {
info->dep_info.curr_nfc_dep_pni = 0;
return 1;
}
break;
info->dep_info.curr_nfc_dep_pni = 0;
return 1;
default:
return 1;
}
kfree_skb(skb);
return 0;
exit:
return r;
}

static struct nfc_hci_ops st21nfca_hci_ops = {
Expand Down Expand Up @@ -904,8 +922,11 @@ int st21nfca_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops,
* persistent info to discriminate 2 identical chips
*/
dev_num = find_first_zero_bit(dev_mask, ST21NFCA_NUM_DEVICES);

if (dev_num >= ST21NFCA_NUM_DEVICES)
goto err_alloc_hdev;
return -ENODEV;

set_bit(dev_num, dev_mask);

scnprintf(init_data.session_id, sizeof(init_data.session_id), "%s%2x",
"ST21AH", dev_num);
Expand Down
21 changes: 0 additions & 21 deletions drivers/nfc/st21nfca/st21nfca.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,9 @@ struct st21nfca_hci_info {
#define ST21NFCA_WR_XCHG_DATA 0x10

#define ST21NFCA_RF_READER_F_GATE 0x14
#define ST21NFCA_RF_READER_F_DATARATE 0x01
#define ST21NFCA_RF_READER_F_DATARATE_106 0x01
#define ST21NFCA_RF_READER_F_DATARATE_212 0x02
#define ST21NFCA_RF_READER_F_DATARATE_424 0x04
#define ST21NFCA_RF_READER_F_POL_REQ 0x02
#define ST21NFCA_RF_READER_F_POL_REQ_DEFAULT 0xffff0000
#define ST21NFCA_RF_READER_F_NFCID2 0x03
#define ST21NFCA_RF_READER_F_NFCID1 0x04
#define ST21NFCA_RF_READER_F_SENS_RES 0x05

#define ST21NFCA_RF_CARD_F_GATE 0x24
#define ST21NFCA_RF_CARD_F_MODE 0x01
#define ST21NFCA_RF_CARD_F_NFCID2_LIST 0x04
#define ST21NFCA_RF_CARD_F_NFCID1 0x05
#define ST21NFCA_RF_CARD_F_SENS_RES 0x06
#define ST21NFCA_RF_CARD_F_SEL_RES 0x07
#define ST21NFCA_RF_CARD_F_DATARATE 0x08
#define ST21NFCA_RF_CARD_F_DATARATE_106 0x00
#define ST21NFCA_RF_CARD_F_DATARATE_212_424 0x01

#define ST21NFCA_EVT_SEND_DATA 0x10
#define ST21NFCA_EVT_FIELD_ON 0x11
#define ST21NFCA_EVT_CARD_DEACTIVATED 0x12
#define ST21NFCA_EVT_CARD_ACTIVATED 0x13
#define ST21NFCA_EVT_FIELD_OFF 0x14

#endif /* __LOCAL_ST21NFCA_H_ */
Loading

0 comments on commit 330bd4e

Please sign in to comment.