Lines Matching +full:dout +full:- +full:ports

1 // SPDX-License-Identifier: GPL-2.0
4 // Copyright (C) 2012-2015 Google, Inc
6 // This driver uses the ChromeOS EC byte-level message-based protocol for
54 * struct lpc_driver_data - driver data attached to a DMI device ID to indicate
71 * struct cros_ec_lpc - LPC device-specific data
79 * struct lpc_driver_ops - LPC driver operations
81 * Returns a negative error code on error, or the 8-bit checksum
84 * Returns a negative error code on error, or the 8-bit checksum
146 offset - EC_HOST_CMD_REGION0, in cros_ec_lpc_mec_read_bytes()
165 offset - EC_HOST_CMD_REGION0, in cros_ec_lpc_mec_write_bytes()
195 u8 *dout; in cros_ec_pkt_xfer_lpc() local
202 ret = cros_ec_lpc_ops.write(EC_LPC_ADDR_HOST_PACKET, ret, ec->dout); in cros_ec_pkt_xfer_lpc()
216 dev_warn(ec->dev, "EC response timed out\n"); in cros_ec_pkt_xfer_lpc()
217 ret = -EIO; in cros_ec_pkt_xfer_lpc()
225 msg->result = ret; in cros_ec_pkt_xfer_lpc()
231 dout = (u8 *)&response; in cros_ec_pkt_xfer_lpc()
233 dout); in cros_ec_pkt_xfer_lpc()
238 msg->result = response.result; in cros_ec_pkt_xfer_lpc()
240 if (response.data_len > msg->insize) { in cros_ec_pkt_xfer_lpc()
241 dev_err(ec->dev, in cros_ec_pkt_xfer_lpc()
243 response.data_len, msg->insize); in cros_ec_pkt_xfer_lpc()
244 ret = -EMSGSIZE; in cros_ec_pkt_xfer_lpc()
251 msg->data); in cros_ec_pkt_xfer_lpc()
257 dev_err(ec->dev, in cros_ec_pkt_xfer_lpc()
260 ret = -EBADMSG; in cros_ec_pkt_xfer_lpc()
277 if (msg->outsize > EC_PROTO2_MAX_PARAM_SIZE || in cros_ec_cmd_xfer_lpc()
278 msg->insize > EC_PROTO2_MAX_PARAM_SIZE) { in cros_ec_cmd_xfer_lpc()
279 dev_err(ec->dev, in cros_ec_cmd_xfer_lpc()
281 msg->outsize, msg->insize); in cros_ec_cmd_xfer_lpc()
282 return -EINVAL; in cros_ec_cmd_xfer_lpc()
287 args.command_version = msg->version; in cros_ec_cmd_xfer_lpc()
288 args.data_size = msg->outsize; in cros_ec_cmd_xfer_lpc()
291 sum = msg->command + args.flags + args.command_version + args.data_size; in cros_ec_cmd_xfer_lpc()
294 ret = cros_ec_lpc_ops.write(EC_LPC_ADDR_HOST_PARAM, msg->outsize, in cros_ec_cmd_xfer_lpc()
295 msg->data); in cros_ec_cmd_xfer_lpc()
308 sum = msg->command; in cros_ec_cmd_xfer_lpc()
317 dev_warn(ec->dev, "EC response timed out\n"); in cros_ec_cmd_xfer_lpc()
318 ret = -EIO; in cros_ec_cmd_xfer_lpc()
326 msg->result = ret; in cros_ec_cmd_xfer_lpc()
336 if (args.data_size > msg->insize) { in cros_ec_cmd_xfer_lpc()
337 dev_err(ec->dev, in cros_ec_cmd_xfer_lpc()
339 args.data_size, msg->insize); in cros_ec_cmd_xfer_lpc()
340 ret = -ENOSPC; in cros_ec_cmd_xfer_lpc()
345 sum = msg->command + args.flags + args.command_version + args.data_size; in cros_ec_cmd_xfer_lpc()
349 msg->data); in cros_ec_cmd_xfer_lpc()
356 dev_err(ec->dev, in cros_ec_cmd_xfer_lpc()
359 ret = -EBADMSG; in cros_ec_cmd_xfer_lpc()
373 struct cros_ec_lpc *ec_lpc = ec->priv; in cros_ec_lpc_readmem()
379 if (offset >= EC_MEMMAP_SIZE - bytes) in cros_ec_lpc_readmem()
380 return -EINVAL; in cros_ec_lpc_readmem()
384 ret = cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + offset, bytes, s); in cros_ec_lpc_readmem()
392 ret = cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + i, 1, s); in cros_ec_lpc_readmem()
410 ec_dev->last_event_time = cros_ec_get_time_ns(); in cros_ec_lpc_acpi_notify()
413 dev_emerg(ec_dev->dev, "CrOS EC Panic Reported. Shutdown is imminent!"); in cros_ec_lpc_acpi_notify()
414 blocking_notifier_call_chain(&ec_dev->panic_notifier, 0, ec_dev); in cros_ec_lpc_acpi_notify()
415 kobject_uevent_env(&ec_dev->dev->kobj, KOBJ_CHANGE, (char **)env); in cros_ec_lpc_acpi_notify()
417 hw_protection_shutdown("CrOS EC Panic", -1); in cros_ec_lpc_acpi_notify()
422 if (ec_dev->mkbp_event_supported) in cros_ec_lpc_acpi_notify()
428 &ec_dev->event_notifier, 0, in cros_ec_lpc_acpi_notify()
458 struct device *dev = &pdev->dev; in cros_ec_lpc_probe()
470 return -ENOMEM; in cros_ec_lpc_probe()
472 ec_lpc->mmio_memory_base = EC_LPC_ADDR_MEMMAP; in cros_ec_lpc_probe()
476 quirks = driver_data->quirks; in cros_ec_lpc_probe()
482 ec_lpc->mmio_memory_base = driver_data->quirk_mmio_memory_base; in cros_ec_lpc_probe()
485 adev = cros_ec_lpc_get_device(driver_data->quirk_acpi_id); in cros_ec_lpc_probe()
488 driver_data->quirk_acpi_id); in cros_ec_lpc_probe()
489 return -ENODEV; in cros_ec_lpc_probe()
496 = driver_data->quirk_aml_mutex_name; in cros_ec_lpc_probe()
507 * The Framework Laptop (and possibly other non-ChromeOS devices) in cros_ec_lpc_probe()
508 * only exposes the eight I/O ports that are required for the Microchip EC. in cros_ec_lpc_probe()
514 return -EBUSY; in cros_ec_lpc_probe()
532 if (!devm_request_region(dev, ec_lpc->mmio_memory_base, EC_MEMMAP_SIZE, in cros_ec_lpc_probe()
535 return -EBUSY; in cros_ec_lpc_probe()
538 /* Re-assign read/write operations for the non MEC variant */ in cros_ec_lpc_probe()
541 ret = cros_ec_lpc_ops.read(ec_lpc->mmio_memory_base + EC_MEMMAP_ID, 2, in cros_ec_lpc_probe()
547 return -ENODEV; in cros_ec_lpc_probe()
550 /* Reserve the remaining I/O ports required by the non-MEC protocol. */ in cros_ec_lpc_probe()
552 EC_HOST_CMD_REGION_SIZE - EC_HOST_CMD_MEC_REGION_SIZE, in cros_ec_lpc_probe()
555 return -EBUSY; in cros_ec_lpc_probe()
560 return -EBUSY; in cros_ec_lpc_probe()
566 return -ENOMEM; in cros_ec_lpc_probe()
569 ec_dev->dev = dev; in cros_ec_lpc_probe()
570 ec_dev->phys_name = dev_name(dev); in cros_ec_lpc_probe()
571 ec_dev->cmd_xfer = cros_ec_cmd_xfer_lpc; in cros_ec_lpc_probe()
572 ec_dev->pkt_xfer = cros_ec_pkt_xfer_lpc; in cros_ec_lpc_probe()
573 ec_dev->cmd_readmem = cros_ec_lpc_readmem; in cros_ec_lpc_probe()
574 ec_dev->din_size = sizeof(struct ec_host_response) + in cros_ec_lpc_probe()
576 ec_dev->dout_size = sizeof(struct ec_host_request); in cros_ec_lpc_probe()
577 ec_dev->priv = ec_lpc; in cros_ec_lpc_probe()
585 ec_dev->irq = irq; in cros_ec_lpc_probe()
586 else if (irq != -ENXIO) { in cros_ec_lpc_probe()
603 status = acpi_install_notify_handler(adev->handle, in cros_ec_lpc_probe()
620 adev = ACPI_COMPANION(&pdev->dev); in cros_ec_lpc_remove()
622 acpi_remove_notify_handler(adev->handle, ACPI_ALL_NOTIFY, in cros_ec_lpc_remove()
670 /* x86-link, the Chromebook Pixel. */
677 /* x86-samus, the Chromebook Pixel 2. */
684 /* x86-peppy, the Acer C720 Chromebook. */
691 /* x86-glimmer, the Lenovo Thinkpad Yoga 11e. */
697 /* A small number of non-Chromebook/box machines also use the ChromeOS EC */
804 return -ENODEV; in cros_ec_lpc_init()
816 platform_set_drvdata(&cros_ec_lpc_device, dmi_match->driver_data); in cros_ec_lpc_init()