drivers/net/can/m_can/tcan4x5x-core.c
Source file repositories/reference/linux-study-clean/drivers/net/can/m_can/tcan4x5x-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/m_can/tcan4x5x-core.c- Extension
.c- Size
- 15532 bytes
- Lines
- 611
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
tcan4x5x.h
Detected Declarations
struct tcan4x5x_version_infofunction tcan4x5x_check_wakefunction tcan4x5x_resetfunction tcan4x5x_read_regfunction tcan4x5x_read_fifofunction tcan4x5x_write_regfunction tcan4x5x_write_fifofunction tcan4x5x_power_enablefunction tcan4x5x_write_tcan_regfunction tcan4x5x_clear_interruptsfunction tcan4x5x_initfunction tcan4x5x_deinitfunction tcan4x5x_disable_wakefunction tcan4x5x_disable_statefunction tcan4x5x_get_dt_datafunction tcan4x5x_get_gpiosfunction tcan4x5x_check_gpiosfunction tcan4x5x_can_probefunction tcan4x5x_can_removefunction tcan4x5x_suspendfunction tcan4x5x_resume
Annotated Snippet
struct tcan4x5x_version_info {
const char *name;
u32 id2_register;
bool has_wake_pin;
bool has_state_pin;
};
enum {
TCAN4552 = 0,
TCAN4553,
TCAN4X5X,
};
static const struct tcan4x5x_version_info tcan4x5x_versions[] = {
[TCAN4552] = {
.name = "4552",
.id2_register = 0x32353534,
},
[TCAN4553] = {
.name = "4553",
.id2_register = 0x33353534,
},
/* generic version with no id2_register at the end */
[TCAN4X5X] = {
.name = "generic",
.has_wake_pin = true,
.has_state_pin = true,
},
};
static inline struct tcan4x5x_priv *cdev_to_priv(struct m_can_classdev *cdev)
{
return container_of(cdev, struct tcan4x5x_priv, cdev);
}
static void tcan4x5x_check_wake(struct tcan4x5x_priv *priv)
{
int wake_state = 0;
if (priv->device_state_gpio)
wake_state = gpiod_get_value(priv->device_state_gpio);
if (priv->device_wake_gpio && wake_state) {
gpiod_set_value(priv->device_wake_gpio, 0);
usleep_range(5, 50);
gpiod_set_value(priv->device_wake_gpio, 1);
}
}
static int tcan4x5x_reset(struct tcan4x5x_priv *priv)
{
int ret = 0;
if (priv->reset_gpio) {
gpiod_set_value(priv->reset_gpio, 1);
/* tpulse_width minimum 30us */
usleep_range(30, 100);
gpiod_set_value(priv->reset_gpio, 0);
} else {
ret = regmap_write(priv->regmap, TCAN4X5X_CONFIG,
TCAN4X5X_SW_RESET);
if (ret)
return ret;
}
usleep_range(700, 1000);
return ret;
}
static u32 tcan4x5x_read_reg(struct m_can_classdev *cdev, int reg)
{
struct tcan4x5x_priv *priv = cdev_to_priv(cdev);
u32 val;
regmap_read(priv->regmap, TCAN4X5X_MCAN_OFFSET + reg, &val);
return val;
}
static int tcan4x5x_read_fifo(struct m_can_classdev *cdev, int addr_offset,
void *val, size_t val_count)
{
struct tcan4x5x_priv *priv = cdev_to_priv(cdev);
return regmap_bulk_read(priv->regmap, TCAN4X5X_MRAM_START + addr_offset, val, val_count);
}
Annotation
- Immediate include surface: `tcan4x5x.h`.
- Detected declarations: `struct tcan4x5x_version_info`, `function tcan4x5x_check_wake`, `function tcan4x5x_reset`, `function tcan4x5x_read_reg`, `function tcan4x5x_read_fifo`, `function tcan4x5x_write_reg`, `function tcan4x5x_write_fifo`, `function tcan4x5x_power_enable`, `function tcan4x5x_write_tcan_reg`, `function tcan4x5x_clear_interrupts`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.