Lines Matching defs:phy
93 static int st21nfca_hci_platform_init(struct st21nfca_i2c_phy *phy)
101 r = i2c_master_send(phy->i2c_dev, reboot_cmd,
113 r = i2c_master_recv(phy->i2c_dev, tmp,
134 struct st21nfca_i2c_phy *phy = phy_id;
136 gpiod_set_value(phy->gpiod_ena, 1);
137 phy->powered = 1;
138 phy->run_mode = ST21NFCA_HCI_MODE;
147 struct st21nfca_i2c_phy *phy = phy_id;
149 gpiod_set_value(phy->gpiod_ena, 0);
151 phy->powered = 0;
185 struct st21nfca_i2c_phy *phy = phy_id;
186 struct i2c_client *client = phy->i2c_dev;
191 if (phy->hard_fault != 0)
192 return phy->hard_fault;
230 mutex_lock(&phy->phy_lock);
236 mutex_unlock(&phy->phy_lock);
345 static int st21nfca_hci_i2c_read(struct st21nfca_i2c_phy *phy,
351 struct i2c_client *client = phy->i2c_dev;
353 if (phy->current_read_len < ARRAY_SIZE(len_seq)) {
354 len = len_seq[phy->current_read_len];
362 mutex_lock(&phy->phy_lock);
368 mutex_unlock(&phy->phy_lock);
371 phy->current_read_len = 0;
379 if (!phy->current_read_len && !IS_START_OF_FRAME(buf)) {
381 phy->current_read_len = 0;
383 } else if (phy->current_read_len && IS_START_OF_FRAME(buf)) {
390 phy->current_read_len = 0;
396 phy->current_read_len = 0;
399 phy->current_read_len++;
421 struct st21nfca_i2c_phy *phy = phy_id;
425 if (!phy || irq != phy->i2c_dev->irq) {
430 if (phy->hard_fault != 0)
433 r = st21nfca_hci_i2c_read(phy, phy->pending_skb);
435 phy->hard_fault = r;
437 nfc_hci_recv_frame(phy->hdev, NULL);
442 } else if (r == -EBADMSG && phy->crc_trials < ARRAY_SIZE(wait_tab)) {
452 msleep(wait_tab[phy->crc_trials]);
453 phy->crc_trials++;
454 phy->current_read_len = 0;
455 kfree_skb(phy->pending_skb);
462 nfc_hci_recv_frame(phy->hdev, phy->pending_skb);
463 phy->crc_trials = 0;
465 kfree_skb(phy->pending_skb);
468 phy->pending_skb = alloc_skb(ST21NFCA_HCI_LLC_MAX_SIZE * 2, GFP_KERNEL);
469 if (phy->pending_skb == NULL) {
470 phy->hard_fault = -ENOMEM;
471 nfc_hci_recv_frame(phy->hdev, NULL);
493 struct st21nfca_i2c_phy *phy;
501 phy = devm_kzalloc(&client->dev, sizeof(struct st21nfca_i2c_phy),
503 if (!phy)
506 phy->i2c_dev = client;
507 phy->pending_skb = alloc_skb(ST21NFCA_HCI_LLC_MAX_SIZE * 2, GFP_KERNEL);
508 if (phy->pending_skb == NULL)
511 phy->current_read_len = 0;
512 phy->crc_trials = 0;
513 mutex_init(&phy->phy_lock);
514 i2c_set_clientdata(client, phy);
521 phy->gpiod_ena = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
522 if (IS_ERR(phy->gpiod_ena)) {
524 r = PTR_ERR(phy->gpiod_ena);
528 phy->se_status.is_ese_present =
530 phy->se_status.is_uicc_present =
533 r = st21nfca_hci_platform_init(phy);
542 ST21NFCA_HCI_DRIVER_NAME, phy);
548 r = st21nfca_hci_probe(phy, &i2c_phy_ops, LLC_SHDLC_NAME,
552 &phy->hdev,
553 &phy->se_status);
560 kfree_skb(phy->pending_skb);
566 struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client);
568 st21nfca_hci_remove(phy->hdev);
570 if (phy->powered)
571 st21nfca_hci_i2c_disable(phy);
572 kfree_skb(phy->pending_skb);