1191b0700STomas Winkler // SPDX-License-Identifier: GPL-2.0 2e0af11faSSamuel Ortiz /* 3e0af11faSSamuel Ortiz * Copyright (C) 2013 Intel Corporation. All rights reserved. 4e0af11faSSamuel Ortiz * 5191b0700STomas Winkler * HCI based Driver for Inside Secure microread NFC Chip 6e0af11faSSamuel Ortiz */ 7e0af11faSSamuel Ortiz 817936b43SJoe Perches #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 917936b43SJoe Perches 10e0af11faSSamuel Ortiz #include <linux/module.h> 114912e2feSEric Lapuyade #include <linux/mod_devicetable.h> 12e0af11faSSamuel Ortiz #include <linux/nfc.h> 13e0af11faSSamuel Ortiz #include <net/nfc/llc.h> 14e0af11faSSamuel Ortiz 154912e2feSEric Lapuyade #include "../mei_phy.h" 16e0af11faSSamuel Ortiz #include "microread.h" 17e0af11faSSamuel Ortiz 18e0af11faSSamuel Ortiz #define MICROREAD_DRIVER_NAME "microread" 19e0af11faSSamuel Ortiz 2089391382STomas Winkler static int microread_mei_probe(struct mei_cl_device *cldev, 219593b0b1SSamuel Ortiz const struct mei_cl_device_id *id) 22e0af11faSSamuel Ortiz { 234912e2feSEric Lapuyade struct nfc_mei_phy *phy; 24e0af11faSSamuel Ortiz int r; 25e0af11faSSamuel Ortiz 26e0af11faSSamuel Ortiz pr_info("Probing NFC microread\n"); 27e0af11faSSamuel Ortiz 2889391382STomas Winkler phy = nfc_mei_phy_alloc(cldev); 29*270be694SKrzysztof Kozlowski if (!phy) 30e0af11faSSamuel Ortiz return -ENOMEM; 31e0af11faSSamuel Ortiz 32e0af11faSSamuel Ortiz r = microread_probe(phy, &mei_phy_ops, LLC_NOP_NAME, 33e0af11faSSamuel Ortiz MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD, 34e0af11faSSamuel Ortiz &phy->hdev); 3573f3adb9SSamuel Ortiz if (r < 0) { 364912e2feSEric Lapuyade nfc_mei_phy_free(phy); 37e0af11faSSamuel Ortiz 38e0af11faSSamuel Ortiz return r; 39e0af11faSSamuel Ortiz } 40e0af11faSSamuel Ortiz 4173f3adb9SSamuel Ortiz return 0; 4273f3adb9SSamuel Ortiz } 4373f3adb9SSamuel Ortiz 44bf5c9cc8SUwe Kleine-König static void microread_mei_remove(struct mei_cl_device *cldev) 45e0af11faSSamuel Ortiz { 46d49dc5e7STomas Winkler struct nfc_mei_phy *phy = mei_cldev_get_drvdata(cldev); 47e0af11faSSamuel Ortiz 48e0af11faSSamuel Ortiz microread_remove(phy->hdev); 49e0af11faSSamuel Ortiz 504912e2feSEric Lapuyade nfc_mei_phy_free(phy); 51e0af11faSSamuel Ortiz } 52e0af11faSSamuel Ortiz 539593b0b1SSamuel Ortiz static struct mei_cl_device_id microread_mei_tbl[] = { 54b26864caSTomas Winkler { MICROREAD_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY}, 55cd48d8baSSamuel Ortiz 56cd48d8baSSamuel Ortiz /* required last entry */ 57cd48d8baSSamuel Ortiz { } 58cd48d8baSSamuel Ortiz }; 59cd48d8baSSamuel Ortiz MODULE_DEVICE_TABLE(mei, microread_mei_tbl); 60cd48d8baSSamuel Ortiz 619593b0b1SSamuel Ortiz static struct mei_cl_driver microread_driver = { 62cd48d8baSSamuel Ortiz .id_table = microread_mei_tbl, 63e0af11faSSamuel Ortiz .name = MICROREAD_DRIVER_NAME, 64e0af11faSSamuel Ortiz 65e0af11faSSamuel Ortiz .probe = microread_mei_probe, 66e0af11faSSamuel Ortiz .remove = microread_mei_remove, 67e0af11faSSamuel Ortiz }; 68e0af11faSSamuel Ortiz 69094dbffeSTomas Winkler module_mei_cl_driver(microread_driver); 70e0af11faSSamuel Ortiz 71e0af11faSSamuel Ortiz MODULE_LICENSE("GPL"); 72e0af11faSSamuel Ortiz MODULE_DESCRIPTION(DRIVER_DESC); 73