drivers/platform/mellanox/mlxreg-lc.c
Source file repositories/reference/linux-study-clean/drivers/platform/mellanox/mlxreg-lc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/mellanox/mlxreg-lc.c- Extension
.c- Size
- 26789 bytes
- Lines
- 959
- 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.
- 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/device.hlinux/i2c.hlinux/module.hlinux/platform_data/mlxcpld.hlinux/platform_data/mlxreg.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
struct mlxreg_lcenum mlxreg_lc_typeenum mlxreg_lc_statefunction mlxreg_lc_writeable_regfunction mlxreg_lc_readable_regfunction mlxreg_lc_volatile_regfunction mlxreg_lc_create_static_devicesfunction mlxreg_lc_destroy_static_devicesfunction mlxreg_lc_power_on_offfunction mlxreg_lc_enable_disablefunction mlxreg_lc_sn4800_c16_config_initfunction mlxreg_lc_state_updatefunction mlxreg_lc_state_update_lockedfunction mlxreg_lc_event_handlerfunction mlxreg_lc_completion_notifyfunction mlxreg_lc_config_initfunction mlxreg_lc_config_exitfunction mlxreg_lc_probefunction mlxreg_lc_remove
Annotated Snippet
struct mlxreg_lc {
struct device *dev;
struct mutex lock; /* line card access lock */
void *par_regmap;
struct mlxreg_core_data *data;
struct mlxreg_core_platform_data *io_data;
struct mlxreg_core_platform_data *led_data;
struct mlxcpld_mux_plat_data *mux_data;
struct platform_device *led;
struct platform_device *io_regs;
struct i2c_board_info *mux_brdinfo;
struct platform_device *mux;
struct mlxreg_hotplug_device *aux_devs;
int aux_devs_num;
struct mlxreg_hotplug_device *main_devs;
int main_devs_num;
enum mlxreg_lc_state state;
};
static bool mlxreg_lc_writeable_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
case MLXREG_LC_REG_LED1_OFFSET:
case MLXREG_LC_REG_GP0_OFFSET:
case MLXREG_LC_REG_FIELD_UPGRADE:
case MLXREG_LC_CHANNEL_I2C_REG:
return true;
}
return false;
}
static bool mlxreg_lc_readable_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
case MLXREG_LC_REG_CPLD1_VER_OFFSET:
case MLXREG_LC_REG_FPGA1_VER_OFFSET:
case MLXREG_LC_REG_CPLD1_PN_OFFSET:
case MLXREG_LC_REG_FPGA1_PN_OFFSET:
case MLXREG_LC_REG_RESET_CAUSE_OFFSET:
case MLXREG_LC_REG_LED1_OFFSET:
case MLXREG_LC_REG_GP0_OFFSET:
case MLXREG_LC_REG_FIELD_UPGRADE:
case MLXREG_LC_CHANNEL_I2C_REG:
case MLXREG_LC_REG_CPLD1_MVER_OFFSET:
case MLXREG_LC_REG_FPGA1_MVER_OFFSET:
case MLXREG_LC_REG_MAX_POWER_OFFSET:
case MLXREG_LC_REG_CONFIG_OFFSET:
return true;
}
return false;
}
static bool mlxreg_lc_volatile_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
case MLXREG_LC_REG_CPLD1_VER_OFFSET:
case MLXREG_LC_REG_FPGA1_VER_OFFSET:
case MLXREG_LC_REG_CPLD1_PN_OFFSET:
case MLXREG_LC_REG_FPGA1_PN_OFFSET:
case MLXREG_LC_REG_RESET_CAUSE_OFFSET:
case MLXREG_LC_REG_LED1_OFFSET:
case MLXREG_LC_REG_GP0_OFFSET:
case MLXREG_LC_REG_FIELD_UPGRADE:
case MLXREG_LC_CHANNEL_I2C_REG:
case MLXREG_LC_REG_CPLD1_MVER_OFFSET:
case MLXREG_LC_REG_FPGA1_MVER_OFFSET:
case MLXREG_LC_REG_MAX_POWER_OFFSET:
case MLXREG_LC_REG_CONFIG_OFFSET:
return true;
}
return false;
}
static const struct reg_default mlxreg_lc_regmap_default[] = {
{ MLXREG_LC_CHANNEL_I2C_REG, 0x00 },
};
/* Configuration for the register map of a device with 2 bytes address space. */
static const struct regmap_config mlxreg_lc_regmap_conf = {
.reg_bits = 16,
.val_bits = 8,
.max_register = MLXREG_LC_REG_MAX,
.cache_type = REGCACHE_FLAT,
.writeable_reg = mlxreg_lc_writeable_reg,
.readable_reg = mlxreg_lc_readable_reg,
.volatile_reg = mlxreg_lc_volatile_reg,
.reg_defaults = mlxreg_lc_regmap_default,
.num_reg_defaults = ARRAY_SIZE(mlxreg_lc_regmap_default),
};
Annotation
- Immediate include surface: `linux/device.h`, `linux/i2c.h`, `linux/module.h`, `linux/platform_data/mlxcpld.h`, `linux/platform_data/mlxreg.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct mlxreg_lc`, `enum mlxreg_lc_type`, `enum mlxreg_lc_state`, `function mlxreg_lc_writeable_reg`, `function mlxreg_lc_readable_reg`, `function mlxreg_lc_volatile_reg`, `function mlxreg_lc_create_static_devices`, `function mlxreg_lc_destroy_static_devices`, `function mlxreg_lc_power_on_off`, `function mlxreg_lc_enable_disable`.
- 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.
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.