/** * number_of_connections - determine whether an client be on the bus * according number of connections * We support only clients: * 1. with single connection * 2. and fixed clients (max_number_of_connections == 0) * * @cldev: me clients device
*/ staticvoid number_of_connections(struct mei_cl_device *cldev)
{ if (cldev->me_cl->props.max_number_of_connections > 1)
cldev->do_match = 0;
}
/** * blacklist - blacklist a client from the bus * * @cldev: me clients device
*/ staticvoid blacklist(struct mei_cl_device *cldev)
{
cldev->do_match = 0;
}
ret = __mei_cl_send_timeout(cldev->cl, (u8 *)&req, sizeof(req), 0,
MEI_CL_IO_TX_BLOCKING, MKHI_SEND_MAX_TIMEOUT_MSEC); if (ret < 0) {
dev_info(&cldev->dev, "Could not send ReqFWVersion cmd ret = %d\n", ret); return ret;
}
ret = 0;
bytes_recv = __mei_cl_recv(cldev->cl, buf, sizeof(buf), NULL, 0,
cldev->bus->timeouts.mkhi_recv); if (bytes_recv < 0 || (size_t)bytes_recv < MKHI_FWVER_LEN(1)) { /* * Should be at least one version block, * error out if nothing found
*/
dev_info(&cldev->dev, "Could not read FW version ret = %d\n", bytes_recv); return -EIO;
}
rsp = (struct mkhi_msg *)buf;
fwver = (struct mkhi_fw_ver *)rsp->data;
memset(cldev->bus->fw_ver, 0, sizeof(cldev->bus->fw_ver)); for (i = 0; i < MEI_MAX_FW_VER_BLOCKS; i++) { if ((size_t)bytes_recv < MKHI_FWVER_LEN(i + 1)) break;
dev_dbg(&cldev->dev, "FW version%d %d:%d.%d.%d.%d\n",
i, fwver->ver[i].platform,
fwver->ver[i].major, fwver->ver[i].minor,
fwver->ver[i].hotfix, fwver->ver[i].buildno);
staticvoid mei_mkhi_fix(struct mei_cl_device *cldev)
{ int ret;
/* No need to enable the client if nothing is needed from it */ if (!cldev->bus->fw_f_fw_ver_supported &&
!cldev->bus->hbm_f_os_supported) return;
ret = mei_cldev_enable(cldev); if (ret) return;
if (cldev->bus->fw_f_fw_ver_supported) {
ret = mei_fwver(cldev); if (ret < 0)
dev_info(&cldev->dev, "FW version command failed %d\n",
ret);
}
if (cldev->bus->hbm_f_os_supported) {
ret = mei_osver(cldev); if (ret < 0)
dev_info(&cldev->dev, "OS version command failed %d\n",
ret);
}
mei_cldev_disable(cldev);
}
staticvoid mei_gsc_mkhi_ver(struct mei_cl_device *cldev)
{ int ret;
/* * No need to enable the client if nothing is needed from it. * No need to fill in version if it is already filled in by the fix address client.
*/ if (!cldev->bus->fw_f_fw_ver_supported || cldev->bus->fw_ver_received) return;
ret = mei_cldev_enable(cldev); if (ret) return;
ret = mei_fwver(cldev); if (ret < 0)
dev_info(&cldev->dev, "FW version command failed %d\n", ret);
mei_cldev_disable(cldev);
}
staticvoid mei_gsc_mkhi_fix_ver(struct mei_cl_device *cldev)
{ int ret;
/* No need to enable the client if nothing is needed from it */ if (!cldev->bus->fw_f_fw_ver_supported &&
cldev->bus->pxp_mode != MEI_DEV_PXP_INIT) return;
ret = mei_cldev_enable(cldev); if (ret) return;
if (cldev->bus->pxp_mode == MEI_DEV_PXP_INIT) {
ret = mei_gfx_memory_ready(cldev); if (ret < 0) {
dev_err(&cldev->dev, "memory ready command failed %d\n", ret);
} else {
dev_dbg(&cldev->dev, "memory ready command sent\n");
cldev->bus->pxp_mode = MEI_DEV_PXP_SETUP;
} /* we go to reset after that */ goto out;
}
ret = mei_fwver(cldev); if (ret < 0)
dev_info(&cldev->dev, "FW version command failed %d\n",
ret);
out:
mei_cldev_disable(cldev);
}
/** * mei_wd - wd client on the bus, change protocol version * as the API has changed. * * @cldev: me clients device
*/ #if IS_ENABLED(CONFIG_INTEL_MEI_ME) #include <linux/pci.h> #include"hw-me-regs.h" staticvoid mei_wd(struct mei_cl_device *cldev)
{ struct pci_dev *pdev = to_pci_dev(cldev->dev.parent);
/* Radio types */ #define MEI_NFC_VENDOR_INSIDE_UREAD 0x00 #define MEI_NFC_VENDOR_NXP_PN544 0x01
/** * mei_nfc_if_version - get NFC interface version * * @cl: host client (nfc info) * @ver: NFC interface version to be filled in * * Return: 0 on success; < 0 otherwise
*/ staticint mei_nfc_if_version(struct mei_cl *cl, struct mei_nfc_if_version *ver)
{ struct mei_device *bus; struct mei_nfc_cmd cmd = {
.command = MEI_NFC_CMD_MAINTENANCE,
.data_size = 1,
.sub_command = MEI_NFC_SUBCMD_IF_VERSION,
}; struct mei_nfc_reply *reply = NULL;
size_t if_version_length;
u8 vtag; int bytes_recv, ret;
bus = cl->dev;
WARN_ON(mutex_is_locked(&bus->device_lock));
ret = __mei_cl_send(cl, (u8 *)&cmd, sizeof(cmd), 0,
MEI_CL_IO_TX_BLOCKING); if (ret < 0) {
dev_err(bus->dev, "Could not send IF version cmd ret = %d\n", ret); return ret;
}
/* to be sure on the stack we alloc memory */
if_version_length = sizeof(*reply) + sizeof(*ver);
reply = kzalloc(if_version_length, GFP_KERNEL); if (!reply) return -ENOMEM;
ret = 0;
bytes_recv = __mei_cl_recv(cl, (u8 *)reply, if_version_length, &vtag,
0, 0); if (bytes_recv < 0 || (size_t)bytes_recv < if_version_length) {
dev_err(bus->dev, "Could not read IF version ret = %d\n", bytes_recv);
ret = -EIO; goto err;
}
memcpy(ver, reply->data, sizeof(*ver));
dev_info(bus->dev, "NFC MEI VERSION: IVN 0x%x Vendor ID 0x%x Type 0x%x\n",
ver->fw_ivn, ver->vendor_id, ver->radio_type);
err:
kfree(reply); return ret;
}
/** * mei_nfc_radio_name - derive nfc radio name from the interface version * * @ver: NFC radio version * * Return: radio name string
*/ staticconstchar *mei_nfc_radio_name(struct mei_nfc_if_version *ver)
{
if (ver->vendor_id == MEI_NFC_VENDOR_INSIDE) { if (ver->radio_type == MEI_NFC_VENDOR_INSIDE_UREAD) return"microread";
}
if (ver->vendor_id == MEI_NFC_VENDOR_NXP) { if (ver->radio_type == MEI_NFC_VENDOR_NXP_PN544) return"pn544";
}
return NULL;
}
/** * mei_nfc - The nfc fixup function. The function retrieves nfc radio * name and set is as device attribute so we can load * the proper device driver for it * * @cldev: me client device (nfc)
*/ staticvoid mei_nfc(struct mei_cl_device *cldev)
{ struct mei_device *bus; struct mei_cl *cl; struct mei_me_client *me_cl = NULL; struct mei_nfc_if_version ver; constchar *radio_name = NULL; int ret;
bus = cldev->bus;
mutex_lock(&bus->device_lock); /* we need to connect to INFO GUID */
cl = mei_cl_alloc_linked(bus); if (IS_ERR(cl)) {
ret = PTR_ERR(cl);
cl = NULL;
dev_err(&cldev->dev, "nfc hook alloc failed %d\n", ret); goto out;
}
me_cl = mei_me_cl_by_uuid(bus, &mei_nfc_info_guid); if (!me_cl) {
ret = -ENOTTY;
dev_err(&cldev->dev, "Cannot find nfc info %d\n", ret); goto out;
}
ret = mei_cl_connect(cl, me_cl, NULL); if (ret < 0) {
dev_err(&cldev->dev, "Can't connect to the NFC INFO ME ret = %d\n",
ret); goto out;
}
mutex_unlock(&bus->device_lock);
ret = mei_nfc_if_version(cl, &ver); if (ret) goto disconnect;
radio_name = mei_nfc_radio_name(&ver);
if (!radio_name) {
ret = -ENOENT;
dev_err(&cldev->dev, "Can't get the NFC interface version ret = %d\n",
ret); goto disconnect;
}
dev_dbg(&cldev->dev, "nfc radio %s\n", radio_name);
strscpy(cldev->name, radio_name, sizeof(cldev->name));
disconnect:
mutex_lock(&bus->device_lock); if (mei_cl_disconnect(cl) < 0)
dev_err(&cldev->dev, "Can't disconnect the NFC INFO ME\n");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.