drivers/platform/chrome/cros_ec_lpc_mec.c
Source file repositories/reference/linux-study-clean/drivers/platform/chrome/cros_ec_lpc_mec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/chrome/cros_ec_lpc_mec.c- Extension
.c- Size
- 5189 bytes
- Lines
- 222
- Domain
- Driver Families
- Bucket
- drivers/platform
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/io.hlinux/mutex.hlinux/types.hcros_ec_lpc_mec.h
Detected Declarations
function cros_ec_lpc_mec_lockfunction cros_ec_lpc_mec_unlockfunction cros_ec_lpc_mec_emi_write_addressfunction cros_ec_lpc_mec_in_rangefunction cros_ec_lpc_io_bytes_mecfunction cros_ec_lpc_mec_initfunction cros_ec_lpc_mec_acpi_mutexexport cros_ec_lpc_io_bytes_mecexport cros_ec_lpc_mec_initexport cros_ec_lpc_mec_acpi_mutex
Annotated Snippet
while (io_addr <= MEC_EMI_EC_DATA_B3(mec_emi_base)) {
if (io_type == MEC_IO_READ)
buf[i] = inb(io_addr++);
else
outb(buf[i], io_addr++);
sum += buf[i++];
offset++;
/* Extra bounds check in case of misaligned length */
if (i == length)
goto done;
}
/*
* Use long auto-increment access except for misaligned write,
* since writing B3 triggers the flush.
*/
if (length - i < 4 && io_type == MEC_IO_WRITE)
new_access = ACCESS_TYPE_BYTE;
else
new_access = ACCESS_TYPE_LONG_AUTO_INCREMENT;
if (new_access != access ||
access != ACCESS_TYPE_LONG_AUTO_INCREMENT) {
access = new_access;
cros_ec_lpc_mec_emi_write_address(offset, access);
}
/* Access [B0, B3] on each loop pass */
io_addr = MEC_EMI_EC_DATA_B0(mec_emi_base);
}
done:
ret = cros_ec_lpc_mec_unlock();
if (ret)
return ret;
return sum;
}
EXPORT_SYMBOL(cros_ec_lpc_io_bytes_mec);
void cros_ec_lpc_mec_init(unsigned int base, unsigned int end)
{
mec_emi_base = base;
mec_emi_end = end;
}
EXPORT_SYMBOL(cros_ec_lpc_mec_init);
int cros_ec_lpc_mec_acpi_mutex(struct acpi_device *adev, const char *pathname)
{
int status;
if (!adev)
return -ENOENT;
status = acpi_get_handle(adev->handle, pathname, &aml_mutex);
if (ACPI_FAILURE(status))
return -ENOENT;
return 0;
}
EXPORT_SYMBOL(cros_ec_lpc_mec_acpi_mutex);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/io.h`, `linux/mutex.h`, `linux/types.h`, `cros_ec_lpc_mec.h`.
- Detected declarations: `function cros_ec_lpc_mec_lock`, `function cros_ec_lpc_mec_unlock`, `function cros_ec_lpc_mec_emi_write_address`, `function cros_ec_lpc_mec_in_range`, `function cros_ec_lpc_io_bytes_mec`, `function cros_ec_lpc_mec_init`, `function cros_ec_lpc_mec_acpi_mutex`, `export cros_ec_lpc_io_bytes_mec`, `export cros_ec_lpc_mec_init`, `export cros_ec_lpc_mec_acpi_mutex`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.