drivers/iio/common/ssp_sensors/ssp_dev.c
Source file repositories/reference/linux-study-clean/drivers/iio/common/ssp_sensors/ssp_dev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/common/ssp_sensors/ssp_dev.c- Extension
.c- Size
- 16300 bytes
- Lines
- 670
- Domain
- Driver Families
- Bucket
- drivers/iio
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/iio/iio.hlinux/interrupt.hlinux/io.hlinux/mfd/core.hlinux/mod_devicetable.hlinux/module.hlinux/property.hssp.h
Detected Declarations
struct ssp_instructionfunction ssp_toggle_mcu_reset_gpiofunction ssp_sync_available_sensorsfunction ssp_enable_mcufunction ssp_check_fwblfunction ssp_reset_mcufunction ssp_wdt_work_funcfunction ssp_wdt_timer_funcfunction ssp_enable_wdt_timerfunction ssp_disable_wdt_timerfunction ssp_get_sensor_delayfunction ssp_enable_sensorfunction ssp_change_delayfunction ssp_disable_sensorfunction ssp_irq_thread_fnfunction ssp_initialize_mcufunction ssp_refresh_taskfunction ssp_queue_ssp_refresh_taskfunction ssp_register_consumerfunction ssp_probefunction ssp_removefunction ssp_suspendfunction ssp_resume
Annotated Snippet
struct ssp_instruction {
__le32 a;
__le32 b;
u8 c;
} __attribute__((__packed__));
static const u8 ssp_magnitude_table[] = {110, 85, 171, 71, 203, 195, 0, 67,
208, 56, 175, 244, 206, 213, 0, 92, 250, 0, 55, 48, 189, 252, 171,
243, 13, 45, 250};
static const struct ssp_sensorhub_info ssp_rinato_info = {
.fw_name = "ssp_B2.fw",
.fw_crashed_name = "ssp_crashed.fw",
.fw_rev = 14052300,
.mag_table = ssp_magnitude_table,
.mag_length = ARRAY_SIZE(ssp_magnitude_table),
};
static const struct ssp_sensorhub_info ssp_thermostat_info = {
.fw_name = "thermostat_B2.fw",
.fw_crashed_name = "ssp_crashed.fw",
.fw_rev = 14080600,
.mag_table = ssp_magnitude_table,
.mag_length = ARRAY_SIZE(ssp_magnitude_table),
};
static const struct mfd_cell sensorhub_sensor_devs[] = {
{
.name = "ssp-accelerometer",
},
{
.name = "ssp-gyroscope",
},
};
static void ssp_toggle_mcu_reset_gpio(struct ssp_data *data)
{
gpiod_set_value(data->mcu_reset_gpiod, 0);
usleep_range(1000, 1200);
gpiod_set_value(data->mcu_reset_gpiod, 1);
msleep(50);
}
static void ssp_sync_available_sensors(struct ssp_data *data)
{
int i, ret;
for (i = 0; i < SSP_SENSOR_MAX; ++i) {
if (data->available_sensors & BIT(i)) {
ret = ssp_enable_sensor(data, i, data->delay_buf[i]);
if (ret < 0) {
dev_err(&data->spi->dev,
"Sync sensor nr: %d fail\n", i);
continue;
}
}
}
ret = ssp_command(data, SSP_MSG2SSP_AP_MCU_SET_DUMPMODE,
data->mcu_dump_mode);
if (ret < 0)
dev_err(&data->spi->dev,
"SSP_MSG2SSP_AP_MCU_SET_DUMPMODE failed\n");
}
static void ssp_enable_mcu(struct ssp_data *data, bool enable)
{
dev_info(&data->spi->dev, "current shutdown = %d, old = %d\n", enable,
data->shut_down);
if (enable && data->shut_down) {
data->shut_down = false;
enable_irq(data->spi->irq);
enable_irq_wake(data->spi->irq);
} else if (!enable && !data->shut_down) {
data->shut_down = true;
disable_irq(data->spi->irq);
disable_irq_wake(data->spi->irq);
} else {
dev_warn(&data->spi->dev, "current shutdown = %d, old = %d\n",
enable, data->shut_down);
}
}
/*
* This function is the first one which communicates with the mcu so it is
* possible that the first attempt will fail
*/
static int ssp_check_fwbl(struct ssp_data *data)
{
Annotation
- Immediate include surface: `linux/iio/iio.h`, `linux/interrupt.h`, `linux/io.h`, `linux/mfd/core.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/property.h`, `ssp.h`.
- Detected declarations: `struct ssp_instruction`, `function ssp_toggle_mcu_reset_gpio`, `function ssp_sync_available_sensors`, `function ssp_enable_mcu`, `function ssp_check_fwbl`, `function ssp_reset_mcu`, `function ssp_wdt_work_func`, `function ssp_wdt_timer_func`, `function ssp_enable_wdt_timer`, `function ssp_disable_wdt_timer`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration 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.