1*191b0700STomas Winkler // SPDX-License-Identifier: GPL-2.0 2e0af11faSSamuel Ortiz /* 3e0af11faSSamuel Ortiz * Copyright (C) 2013 Intel Corporation. All rights reserved. 4e0af11faSSamuel Ortiz * 5*191b0700STomas 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/hci.h> 14e0af11faSSamuel Ortiz #include <net/nfc/llc.h> 15e0af11faSSamuel Ortiz 164912e2feSEric Lapuyade #include "../mei_phy.h" 17e0af11faSSamuel Ortiz #include "microread.h" 18e0af11faSSamuel Ortiz 19e0af11faSSamuel Ortiz #define MICROREAD_DRIVER_NAME "microread" 20e0af11faSSamuel Ortiz 2189391382STomas Winkler static int microread_mei_probe(struct mei_cl_device *cldev, 229593b0b1SSamuel Ortiz const struct mei_cl_device_id *id) 23e0af11faSSamuel Ortiz { 244912e2feSEric Lapuyade struct nfc_mei_phy *phy; 25e0af11faSSamuel Ortiz int r; 26e0af11faSSamuel Ortiz 27e0af11faSSamuel Ortiz pr_info("Probing NFC microread\n"); 28e0af11faSSamuel Ortiz 2989391382STomas Winkler phy = nfc_mei_phy_alloc(cldev); 30e0af11faSSamuel Ortiz if (!phy) { 31e0af11faSSamuel Ortiz pr_err("Cannot allocate memory for microread mei phy.\n"); 32e0af11faSSamuel Ortiz return -ENOMEM; 33e0af11faSSamuel Ortiz } 34e0af11faSSamuel Ortiz 35e0af11faSSamuel Ortiz r = microread_probe(phy, &mei_phy_ops, LLC_NOP_NAME, 36e0af11faSSamuel Ortiz MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD, 37e0af11faSSamuel Ortiz &phy->hdev); 3873f3adb9SSamuel Ortiz if (r < 0) { 394912e2feSEric Lapuyade nfc_mei_phy_free(phy); 40e0af11faSSamuel Ortiz 41e0af11faSSamuel Ortiz return r; 42e0af11faSSamuel Ortiz } 43e0af11faSSamuel Ortiz 4473f3adb9SSamuel Ortiz return 0; 4573f3adb9SSamuel Ortiz } 4673f3adb9SSamuel Ortiz 4789391382STomas Winkler static int microread_mei_remove(struct mei_cl_device *cldev) 48e0af11faSSamuel Ortiz { 49d49dc5e7STomas Winkler struct nfc_mei_phy *phy = mei_cldev_get_drvdata(cldev); 50e0af11faSSamuel Ortiz 51e0af11faSSamuel Ortiz microread_remove(phy->hdev); 52e0af11faSSamuel Ortiz 534912e2feSEric Lapuyade nfc_mei_phy_free(phy); 54e0af11faSSamuel Ortiz 55e0af11faSSamuel Ortiz return 0; 56e0af11faSSamuel Ortiz } 57e0af11faSSamuel Ortiz 589593b0b1SSamuel Ortiz static struct mei_cl_device_id microread_mei_tbl[] = { 59b26864caSTomas Winkler { MICROREAD_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY}, 60cd48d8baSSamuel Ortiz 61cd48d8baSSamuel Ortiz /* required last entry */ 62cd48d8baSSamuel Ortiz { } 63cd48d8baSSamuel Ortiz }; 64cd48d8baSSamuel Ortiz MODULE_DEVICE_TABLE(mei, microread_mei_tbl); 65cd48d8baSSamuel Ortiz 669593b0b1SSamuel Ortiz static struct mei_cl_driver microread_driver = { 67cd48d8baSSamuel Ortiz .id_table = microread_mei_tbl, 68e0af11faSSamuel Ortiz .name = MICROREAD_DRIVER_NAME, 69e0af11faSSamuel Ortiz 70e0af11faSSamuel Ortiz .probe = microread_mei_probe, 71e0af11faSSamuel Ortiz .remove = microread_mei_remove, 72e0af11faSSamuel Ortiz }; 73e0af11faSSamuel Ortiz 74094dbffeSTomas Winkler module_mei_cl_driver(microread_driver); 75e0af11faSSamuel Ortiz 76e0af11faSSamuel Ortiz MODULE_LICENSE("GPL"); 77e0af11faSSamuel Ortiz MODULE_DESCRIPTION(DRIVER_DESC); 78