Lines Matching refs:stcontext
343 static int secondary_configuration_type4a(struct st95hf_context *stcontext) in secondary_configuration_type4a() argument
346 struct device *dev = &stcontext->nfcdev->dev; in secondary_configuration_type4a()
349 result = st95hf_send_recv_cmd(stcontext, in secondary_configuration_type4a()
360 result = st95hf_send_recv_cmd(stcontext, in secondary_configuration_type4a()
371 static int secondary_configuration_type4b(struct st95hf_context *stcontext) in secondary_configuration_type4b() argument
374 struct device *dev = &stcontext->nfcdev->dev; in secondary_configuration_type4b()
376 result = st95hf_send_recv_cmd(stcontext, in secondary_configuration_type4b()
387 static int st95hf_select_protocol(struct st95hf_context *stcontext, int type) in st95hf_select_protocol() argument
392 dev = &stcontext->nfcdev->dev; in st95hf_select_protocol()
396 stcontext->current_rf_tech = NFC_DIGITAL_RF_TECH_106A; in st95hf_select_protocol()
397 result = st95hf_send_recv_cmd(stcontext, in st95hf_select_protocol()
409 result = secondary_configuration_type4a(stcontext); in st95hf_select_protocol()
417 stcontext->current_rf_tech = NFC_DIGITAL_RF_TECH_106B; in st95hf_select_protocol()
418 result = st95hf_send_recv_cmd(stcontext, in st95hf_select_protocol()
436 result = secondary_configuration_type4b(stcontext); in st95hf_select_protocol()
444 stcontext->current_rf_tech = NFC_DIGITAL_RF_TECH_ISO15693; in st95hf_select_protocol()
445 result = st95hf_send_recv_cmd(stcontext, in st95hf_select_protocol()
615 static int st95hf_handle_wtx(struct st95hf_context *stcontext, in st95hf_handle_wtx() argument
622 struct nfc_digital_dev *nfcddev = stcontext->ddev; in st95hf_handle_wtx()
623 struct device *dev = &stcontext->nfcdev->dev; in st95hf_handle_wtx()
626 result = iso14443_config_fdt(stcontext, wtx_val & 0x3f); in st95hf_handle_wtx()
637 result = st95hf_send_recv_cmd(stcontext, in st95hf_handle_wtx()
653 result = iso14443_config_fdt(stcontext, val_mm); in st95hf_handle_wtx()
661 static int st95hf_error_handling(struct st95hf_context *stcontext, in st95hf_error_handling() argument
667 struct device *dev = &stcontext->nfcdev->dev; in st95hf_error_handling()
679 switch (stcontext->current_rf_tech) { in st95hf_error_handling()
681 if (stcontext->sendrcv_trflag == TRFLAG_NFCA_STD_FRAME_CRC) { in st95hf_error_handling()
706 static int st95hf_response_handler(struct st95hf_context *stcontext, in st95hf_response_handler() argument
713 struct nfc_digital_dev *nfcddev = stcontext->ddev; in st95hf_response_handler()
714 struct device *dev = &stcontext->nfcdev->dev; in st95hf_response_handler()
717 cb_arg = &stcontext->complete_cb_arg; in st95hf_response_handler()
731 stcontext->fwi = in st95hf_response_handler()
734 stcontext->fwi = in st95hf_response_handler()
739 result = iso14443_config_fdt(stcontext, val_mm); in st95hf_response_handler()
749 switch (stcontext->current_rf_tech) { in st95hf_response_handler()
751 if (stcontext->sendrcv_trflag == TRFLAG_NFCA_STD_FRAME_CRC) in st95hf_response_handler()
767 struct st95hf_context *stcontext = in st95hf_irq_handler() local
770 if (stcontext->spicontext.req_issync) { in st95hf_irq_handler()
771 complete(&stcontext->spicontext.done); in st95hf_irq_handler()
772 stcontext->spicontext.req_issync = false; in st95hf_irq_handler()
788 struct st95hf_context *stcontext = in st95hf_irq_thread_handler() local
792 spidevice = &stcontext->spicontext.spidev->dev; in st95hf_irq_thread_handler()
807 if (!down_trylock(&stcontext->exchange_lock)) { in st95hf_irq_thread_handler()
808 up(&stcontext->exchange_lock); in st95hf_irq_thread_handler()
813 cb_arg = &stcontext->complete_cb_arg; in st95hf_irq_thread_handler()
816 mutex_lock(&stcontext->rm_lock); in st95hf_irq_thread_handler()
817 res_len = st95hf_spi_recv_response(&stcontext->spicontext, in st95hf_irq_thread_handler()
826 if (stcontext->nfcdev_free) { in st95hf_irq_thread_handler()
831 dev = &stcontext->nfcdev->dev; in st95hf_irq_thread_handler()
832 nfcddev = stcontext->ddev; in st95hf_irq_thread_handler()
835 result = st95hf_handle_wtx(stcontext, true, skb_resp->data[3]); in st95hf_irq_thread_handler()
840 mutex_unlock(&stcontext->rm_lock); in st95hf_irq_thread_handler()
844 result = st95hf_error_handling(stcontext, skb_resp, res_len); in st95hf_irq_thread_handler()
848 result = st95hf_response_handler(stcontext, skb_resp, res_len); in st95hf_irq_thread_handler()
858 result = st95hf_handle_wtx(stcontext, false, 0); in st95hf_irq_thread_handler()
864 cb_arg->complete_cb(stcontext->ddev, cb_arg->cb_usrarg, skb_resp); in st95hf_irq_thread_handler()
867 up(&stcontext->exchange_lock); in st95hf_irq_thread_handler()
868 mutex_unlock(&stcontext->rm_lock); in st95hf_irq_thread_handler()
878 cb_arg->complete_cb(stcontext->ddev, cb_arg->cb_usrarg, skb_resp); in st95hf_irq_thread_handler()
880 up(&stcontext->exchange_lock); in st95hf_irq_thread_handler()
881 mutex_unlock(&stcontext->rm_lock); in st95hf_irq_thread_handler()
890 struct st95hf_context *stcontext = nfc_digital_get_drvdata(ddev); in st95hf_in_configure_hw() local
893 return st95hf_select_protocol(stcontext, param); in st95hf_in_configure_hw()
898 stcontext->sendrcv_trflag = TRFLAG_NFCA_SHORT_FRAME; in st95hf_in_configure_hw()
901 stcontext->sendrcv_trflag = TRFLAG_NFCA_STD_FRAME; in st95hf_in_configure_hw()
906 stcontext->sendrcv_trflag = TRFLAG_NFCA_STD_FRAME_CRC; in st95hf_in_configure_hw()
918 static int rf_off(struct st95hf_context *stcontext) in rf_off() argument
923 dev = &stcontext->nfcdev->dev; in rf_off()
925 rc = st95hf_send_recv_cmd(stcontext, CMD_FIELD_OFF, 0, NULL, true); in rf_off()
938 struct st95hf_context *stcontext = nfc_digital_get_drvdata(ddev); in st95hf_in_send_cmd() local
949 switch (stcontext->current_rf_tech) { in st95hf_in_send_cmd()
952 skb_put_u8(skb, stcontext->sendrcv_trflag); in st95hf_in_send_cmd()
968 stcontext->complete_cb_arg.skb_resp = skb_resp; in st95hf_in_send_cmd()
969 stcontext->complete_cb_arg.cb_usrarg = arg; in st95hf_in_send_cmd()
970 stcontext->complete_cb_arg.complete_cb = cb; in st95hf_in_send_cmd()
974 stcontext->complete_cb_arg.rats = true; in st95hf_in_send_cmd()
981 rc = down_killable(&stcontext->exchange_lock); in st95hf_in_send_cmd()
987 rc = st95hf_spi_send(&stcontext->spicontext, skb->data, in st95hf_in_send_cmd()
991 dev_err(&stcontext->nfcdev->dev, in st95hf_in_send_cmd()
994 up(&stcontext->exchange_lock); in st95hf_in_send_cmd()
1041 struct st95hf_context *stcontext = nfc_digital_get_drvdata(ddev); in st95hf_switch_rf() local
1047 return st95hf_select_protocol(stcontext, rf_tech); in st95hf_switch_rf()
1050 return rf_off(stcontext); in st95hf_switch_rf()
1220 struct st95hf_context *stcontext = container_of(spictx, in st95hf_remove() local
1224 mutex_lock(&stcontext->rm_lock); in st95hf_remove()
1226 nfc_digital_unregister_device(stcontext->ddev); in st95hf_remove()
1227 nfc_digital_free_device(stcontext->ddev); in st95hf_remove()
1228 stcontext->nfcdev_free = true; in st95hf_remove()
1230 mutex_unlock(&stcontext->rm_lock); in st95hf_remove()
1233 result = down_killable(&stcontext->exchange_lock); in st95hf_remove()
1238 result = st95hf_spi_send(&stcontext->spicontext, in st95hf_remove()
1252 if (stcontext->st95hf_supply) in st95hf_remove()
1253 regulator_disable(stcontext->st95hf_supply); in st95hf_remove()