drivers/platform/cznic/turris-omnia-mcu-gpio.c
Source file repositories/reference/linux-study-clean/drivers/platform/cznic/turris-omnia-mcu-gpio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/cznic/turris-omnia-mcu-gpio.c- Extension
.c- Size
- 31425 bytes
- Lines
- 1124
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/array_size.hlinux/bitfield.hlinux/bitops.hlinux/bug.hlinux/cleanup.hlinux/device.hlinux/devm-helpers.hlinux/errno.hlinux/gpio/consumer.hlinux/gpio/driver.hlinux/i2c.hlinux/interrupt.hlinux/mutex.hlinux/sysfs.hlinux/types.hlinux/workqueue.hlinux/unaligned.hlinux/turris-omnia-mcu-interface.hturris-omnia-mcu.h
Detected Declarations
struct omnia_gpiofunction __bf_shffunction omnia_ctl_cmd_lockedfunction omnia_ctl_cmdfunction omnia_gpio_requestfunction omnia_gpio_get_directionfunction scoped_guardfunction omnia_gpio_direction_inputfunction omnia_gpio_direction_outputfunction omnia_gpio_getfunction _relevant_field_for_sts_cmdfunction omnia_gpio_get_multiplefunction omnia_gpio_setfunction omnia_gpio_set_multiplefunction for_each_set_bitfunction omnia_gpio_availablefunction omnia_gpio_init_valid_maskfunction omnia_gpio_of_xlatefunction omnia_irq_shutdownfunction omnia_irq_maskfunction omnia_irq_unmaskfunction omnia_irq_set_typefunction omnia_irq_bus_lockfunction bytesfunction omnia_mask_deinterleavefunction omnia_irq_bus_sync_unlockfunction omnia_irq_init_valid_maskfunction omnia_irq_init_hwfunction omnia_irq_compute_pending_lengthfunction omnia_irq_read_pending_newfunction omnia_read_status_word_old_fwfunction button_release_emul_fnfunction fill_int_from_stsfunction omnia_irq_read_pending_oldfunction omnia_irq_read_pendingfunction omnia_irq_thread_handlerfunction for_each_set_bitfunction front_button_mode_showfunction front_button_mode_storefunction omnia_mcu_register_gpiochipfunction omnia_mcu_request_irq
Annotated Snippet
struct omnia_gpio {
u8 cmd;
u8 ctl_cmd;
u8 bit;
u8 ctl_bit;
u8 int_bit;
u16 feat;
u16 feat_mask;
};
#define OMNIA_GPIO_INVALID_INT_BIT 0xff
#define _DEF_GPIO(_cmd, _ctl_cmd, _bit, _ctl_bit, _int_bit, _feat, _feat_mask) \
{ \
.cmd = _cmd, \
.ctl_cmd = _ctl_cmd, \
.bit = _bit, \
.ctl_bit = _ctl_bit, \
.int_bit = (_int_bit) < 0 ? OMNIA_GPIO_INVALID_INT_BIT \
: (_int_bit), \
.feat = _feat, \
.feat_mask = _feat_mask, \
}
#define _DEF_GPIO_STS(_name) \
_DEF_GPIO(OMNIA_CMD_GET_STATUS_WORD, 0, __bf_shf(OMNIA_STS_ ## _name), \
0, __bf_shf(OMNIA_INT_ ## _name), 0, 0)
#define _DEF_GPIO_CTL(_name) \
_DEF_GPIO(OMNIA_CMD_GET_STATUS_WORD, OMNIA_CMD_GENERAL_CONTROL, \
__bf_shf(OMNIA_STS_ ## _name), __bf_shf(OMNIA_CTL_ ## _name), \
-1, 0, 0)
#define _DEF_GPIO_EXT_STS(_name, _feat) \
_DEF_GPIO(OMNIA_CMD_GET_EXT_STATUS_DWORD, 0, \
__bf_shf(OMNIA_EXT_STS_ ## _name), 0, \
__bf_shf(OMNIA_INT_ ## _name), \
OMNIA_FEAT_ ## _feat | OMNIA_FEAT_EXT_CMDS, \
OMNIA_FEAT_ ## _feat | OMNIA_FEAT_EXT_CMDS)
#define _DEF_GPIO_EXT_STS_LED(_name, _ledext) \
_DEF_GPIO(OMNIA_CMD_GET_EXT_STATUS_DWORD, 0, \
__bf_shf(OMNIA_EXT_STS_ ## _name), 0, \
__bf_shf(OMNIA_INT_ ## _name), \
OMNIA_FEAT_LED_STATE_ ## _ledext, \
OMNIA_FEAT_LED_STATE_EXT_MASK)
#define _DEF_GPIO_EXT_STS_LEDALL(_name) \
_DEF_GPIO(OMNIA_CMD_GET_EXT_STATUS_DWORD, 0, \
__bf_shf(OMNIA_EXT_STS_ ## _name), 0, \
__bf_shf(OMNIA_INT_ ## _name), \
OMNIA_FEAT_LED_STATE_EXT_MASK, 0)
#define _DEF_GPIO_EXT_CTL(_name, _feat) \
_DEF_GPIO(OMNIA_CMD_GET_EXT_CONTROL_STATUS, OMNIA_CMD_EXT_CONTROL, \
__bf_shf(OMNIA_EXT_CTL_ ## _name), \
__bf_shf(OMNIA_EXT_CTL_ ## _name), -1, \
OMNIA_FEAT_ ## _feat | OMNIA_FEAT_EXT_CMDS, \
OMNIA_FEAT_ ## _feat | OMNIA_FEAT_EXT_CMDS)
#define _DEF_INT(_name) \
_DEF_GPIO(0, 0, 0, 0, __bf_shf(OMNIA_INT_ ## _name), 0, 0)
static inline bool is_int_bit_valid(const struct omnia_gpio *gpio)
{
return gpio->int_bit != OMNIA_GPIO_INVALID_INT_BIT;
}
static const struct omnia_gpio omnia_gpios[64] = {
/* GPIOs with value read from the 16-bit wide status */
[4] = _DEF_GPIO_STS(CARD_DET),
[5] = _DEF_GPIO_STS(MSATA_IND),
[6] = _DEF_GPIO_STS(USB30_OVC),
[7] = _DEF_GPIO_STS(USB31_OVC),
[8] = _DEF_GPIO_CTL(USB30_PWRON),
[9] = _DEF_GPIO_CTL(USB31_PWRON),
/* brightness changed interrupt, no GPIO */
[11] = _DEF_INT(BRIGHTNESS_CHANGED),
[12] = _DEF_GPIO_STS(BUTTON_PRESSED),
/* TRNG interrupt, no GPIO */
[13] = _DEF_INT(TRNG),
/* MESSAGE_SIGNED interrupt, no GPIO */
[14] = _DEF_INT(MESSAGE_SIGNED),
/* GPIOs with value read from the 32-bit wide extended status */
[16] = _DEF_GPIO_EXT_STS(SFP_nDET, PERIPH_MCU),
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bitfield.h`, `linux/bitops.h`, `linux/bug.h`, `linux/cleanup.h`, `linux/device.h`, `linux/devm-helpers.h`, `linux/errno.h`.
- Detected declarations: `struct omnia_gpio`, `function __bf_shf`, `function omnia_ctl_cmd_locked`, `function omnia_ctl_cmd`, `function omnia_gpio_request`, `function omnia_gpio_get_direction`, `function scoped_guard`, `function omnia_gpio_direction_input`, `function omnia_gpio_direction_output`, `function omnia_gpio_get`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.