drivers/firmware/turris-mox-rwtm.c
Source file repositories/reference/linux-study-clean/drivers/firmware/turris-mox-rwtm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/turris-mox-rwtm.c- Extension
.c- Size
- 13244 bytes
- Lines
- 517
- Domain
- Driver Families
- Bucket
- drivers/firmware
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
crypto/sha2.hlinux/align.hlinux/armada-37xx-rwtm-mailbox.hlinux/cleanup.hlinux/completion.hlinux/container_of.hlinux/device.hlinux/dma-mapping.hlinux/err.hlinux/hw_random.hlinux/if_ether.hlinux/key.hlinux/kobject.hlinux/mailbox_client.hlinux/math.hlinux/minmax.hlinux/module.hlinux/mutex.hlinux/platform_device.hlinux/sizes.hlinux/sysfs.hlinux/turris-signing-key.hlinux/types.h
Detected Declarations
struct mox_rwtmenum mbox_cmdfunction mox_get_statusfunction mox_rwtm_rx_callbackfunction mox_rwtm_execfunction reply_to_mac_addrfunction mox_get_board_infofunction check_get_random_supportfunction mox_hwrng_readfunction mox_ecc_number_to_binfunction mox_ecc_public_key_to_binfunction mox_rwtm_signfunction mox_register_signing_keyfunction mox_register_signing_keyfunction rwtm_devm_mbox_releasefunction rwtm_firmware_symlink_dropfunction turris_mox_rwtm_probe
Annotated Snippet
struct mox_rwtm {
struct mbox_client mbox_client;
struct mbox_chan *mbox;
struct hwrng hwrng;
struct armada_37xx_rwtm_rx_msg reply;
void *buf;
dma_addr_t buf_phys;
struct mutex busy;
struct completion cmd_done;
bool has_board_info;
u64 serial_number;
int board_version, ram_size;
u8 mac_address1[ETH_ALEN], mac_address2[ETH_ALEN];
#ifdef CONFIG_TURRIS_MOX_RWTM_KEYCTL
u8 pubkey[MOX_ECC_PUBKEY_LEN];
#endif
};
static inline struct device *rwtm_dev(struct mox_rwtm *rwtm)
{
return rwtm->mbox_client.dev;
}
#define MOX_ATTR_RO(name, format) \
static ssize_t \
name##_show(struct device *dev, struct device_attribute *a, \
char *buf) \
{ \
struct mox_rwtm *rwtm = dev_get_drvdata(dev); \
if (!rwtm->has_board_info) \
return -ENODATA; \
return sysfs_emit(buf, format, rwtm->name); \
} \
static DEVICE_ATTR_RO(name)
MOX_ATTR_RO(serial_number, "%016llX\n");
MOX_ATTR_RO(board_version, "%i\n");
MOX_ATTR_RO(ram_size, "%i\n");
MOX_ATTR_RO(mac_address1, "%pM\n");
MOX_ATTR_RO(mac_address2, "%pM\n");
static struct attribute *turris_mox_rwtm_attrs[] = {
&dev_attr_serial_number.attr,
&dev_attr_board_version.attr,
&dev_attr_ram_size.attr,
&dev_attr_mac_address1.attr,
&dev_attr_mac_address2.attr,
NULL
};
ATTRIBUTE_GROUPS(turris_mox_rwtm);
static int mox_get_status(enum mbox_cmd cmd, u32 retval)
{
if (MBOX_STS_CMD(retval) != cmd)
return -EIO;
else if (MBOX_STS_ERROR(retval) == MBOX_STS_FAIL)
return -(int)MBOX_STS_VALUE(retval);
else if (MBOX_STS_ERROR(retval) == MBOX_STS_BADCMD)
return -EOPNOTSUPP;
else if (MBOX_STS_ERROR(retval) != MBOX_STS_SUCCESS)
return -EIO;
else
return MBOX_STS_VALUE(retval);
}
static void mox_rwtm_rx_callback(struct mbox_client *cl, void *data)
{
struct mox_rwtm *rwtm = dev_get_drvdata(cl->dev);
struct armada_37xx_rwtm_rx_msg *msg = data;
if (completion_done(&rwtm->cmd_done))
return;
rwtm->reply = *msg;
complete(&rwtm->cmd_done);
}
static int mox_rwtm_exec(struct mox_rwtm *rwtm, enum mbox_cmd cmd,
struct armada_37xx_rwtm_tx_msg *msg,
bool interruptible)
{
struct armada_37xx_rwtm_tx_msg _msg = {};
int ret;
if (!msg)
Annotation
- Immediate include surface: `crypto/sha2.h`, `linux/align.h`, `linux/armada-37xx-rwtm-mailbox.h`, `linux/cleanup.h`, `linux/completion.h`, `linux/container_of.h`, `linux/device.h`, `linux/dma-mapping.h`.
- Detected declarations: `struct mox_rwtm`, `enum mbox_cmd`, `function mox_get_status`, `function mox_rwtm_rx_callback`, `function mox_rwtm_exec`, `function reply_to_mac_addr`, `function mox_get_board_info`, `function check_get_random_support`, `function mox_hwrng_read`, `function mox_ecc_number_to_bin`.
- Atlas domain: Driver Families / drivers/firmware.
- Implementation status: source 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.