drivers/platform/cznic/turris-omnia-mcu-base.c
Source file repositories/reference/linux-study-clean/drivers/platform/cznic/turris-omnia-mcu-base.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/cznic/turris-omnia-mcu-base.c- Extension
.c- Size
- 10340 bytes
- Lines
- 420
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/array_size.hlinux/bits.hlinux/device.hlinux/errno.hlinux/hex.hlinux/i2c.hlinux/module.hlinux/string.hlinux/sysfs.hlinux/types.hlinux/turris-omnia-mcu-interface.hturris-omnia-mcu.h
Detected Declarations
function omnia_cmd_write_readfunction omnia_get_version_hashfunction fw_version_hash_showfunction fw_version_hash_application_showfunction fw_version_hash_bootloader_showfunction fw_features_showfunction mcu_type_showfunction reset_selector_showfunction serial_number_showfunction first_mac_address_showfunction board_revision_showfunction omnia_mcu_base_attrs_visiblefunction omnia_mcu_print_version_hashfunction omnia_info_missing_featurefunction omnia_mcu_read_featuresfunction omnia_mcu_read_board_infofunction omnia_mcu_probeexport omnia_cmd_write_read
Annotated Snippet
if (err) {
/* try read 16-bit features */
u16 features16;
err = omnia_cmd_read_u16(client, OMNIA_CMD_GET_FEATURES,
&features16);
if (err)
return err;
mcu->features = features16;
} else {
if (mcu->features & OMNIA_FEAT_FROM_BIT_16_INVALID)
mcu->features &= GENMASK(15, 0);
}
} else {
dev_info(dev,
"Your board's MCU firmware does not support feature reading.\n");
suggest_fw_upgrade = true;
}
mcu->type = omnia_status_to_mcu_type(status);
dev_info(dev, "MCU type %s%s\n", mcu->type,
(mcu->features & OMNIA_FEAT_PERIPH_MCU) ?
", with peripheral resets wired" : "");
omnia_mcu_print_version_hash(mcu, true);
if (mcu->features & OMNIA_FEAT_BOOTLOADER)
dev_warn(dev,
"MCU is running bootloader firmware. Was firmware upgrade interrupted?\n");
else
omnia_mcu_print_version_hash(mcu, false);
for (unsigned int i = 0; i < ARRAY_SIZE(features); i++) {
if (mcu->features & features[i].mask)
continue;
omnia_info_missing_feature(dev, features[i].name);
suggest_fw_upgrade = true;
}
if (suggest_fw_upgrade)
dev_info(dev,
"Consider upgrading MCU firmware with the omnia-mcutool utility.\n");
return 0;
}
static int omnia_mcu_read_board_info(struct omnia_mcu *mcu)
{
u8 reply[1 + OMNIA_BOARD_INFO_LEN];
int err;
err = omnia_cmd_read(mcu->client, OMNIA_CMD_BOARD_INFO_GET, reply,
sizeof(reply));
if (err)
return err;
if (reply[0] != OMNIA_BOARD_INFO_LEN)
return -EIO;
mcu->board_serial_number = get_unaligned_le64(&reply[1]);
/* we can't use ether_addr_copy() because reply is not u16-aligned */
memcpy(mcu->board_first_mac, &reply[9], sizeof(mcu->board_first_mac));
mcu->board_revision = reply[15];
return 0;
}
static int omnia_mcu_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct omnia_mcu *mcu;
int err;
if (!client->irq)
return dev_err_probe(dev, -EINVAL, "IRQ resource not found\n");
mcu = devm_kzalloc(dev, sizeof(*mcu), GFP_KERNEL);
if (!mcu)
return -ENOMEM;
mcu->client = client;
i2c_set_clientdata(client, mcu);
err = omnia_mcu_read_features(mcu);
if (err)
return dev_err_probe(dev, err,
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bits.h`, `linux/device.h`, `linux/errno.h`, `linux/hex.h`, `linux/i2c.h`, `linux/module.h`, `linux/string.h`.
- Detected declarations: `function omnia_cmd_write_read`, `function omnia_get_version_hash`, `function fw_version_hash_show`, `function fw_version_hash_application_show`, `function fw_version_hash_bootloader_show`, `function fw_features_show`, `function mcu_type_show`, `function reset_selector_show`, `function serial_number_show`, `function first_mac_address_show`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: integration implementation candidate.
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.