drivers/phy/phy-can-transceiver.c
Source file repositories/reference/linux-study-clean/drivers/phy/phy-can-transceiver.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/phy-can-transceiver.c- Extension
.c- Size
- 6804 bytes
- Lines
- 248
- Domain
- Driver Families
- Bucket
- drivers/phy
- 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.
- 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/of.hlinux/phy/phy.hlinux/platform_device.hlinux/module.hlinux/gpio.hlinux/gpio/consumer.hlinux/mux/consumer.h
Detected Declarations
struct can_transceiver_datastruct can_transceiver_phystruct can_transceiver_privfunction can_transceiver_phy_power_onfunction can_transceiver_phy_power_offfunction can_transceiver_phy_probe
Annotated Snippet
struct can_transceiver_data {
u32 flags;
#define CAN_TRANSCEIVER_STB_PRESENT BIT(0)
#define CAN_TRANSCEIVER_EN_PRESENT BIT(1)
#define CAN_TRANSCEIVER_DUAL_CH BIT(2)
#define CAN_TRANSCEIVER_SILENT_PRESENT BIT(3)
};
struct can_transceiver_phy {
struct phy *generic_phy;
struct gpio_desc *silent_gpio;
struct gpio_desc *standby_gpio;
struct gpio_desc *enable_gpio;
struct can_transceiver_priv *priv;
};
struct can_transceiver_priv {
struct mux_state *mux_state;
int num_ch;
struct can_transceiver_phy can_transceiver_phy[] __counted_by(num_ch);
};
/* Power on function */
static int can_transceiver_phy_power_on(struct phy *phy)
{
struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
struct can_transceiver_priv *priv = can_transceiver_phy->priv;
int ret;
if (priv->mux_state) {
ret = mux_state_select(priv->mux_state);
if (ret) {
dev_err(&phy->dev, "Failed to select CAN mux: %d\n", ret);
return ret;
}
}
gpiod_set_value_cansleep(can_transceiver_phy->silent_gpio, 0);
gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0);
gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 1);
return 0;
}
/* Power off function */
static int can_transceiver_phy_power_off(struct phy *phy)
{
struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
struct can_transceiver_priv *priv = can_transceiver_phy->priv;
gpiod_set_value_cansleep(can_transceiver_phy->silent_gpio, 1);
gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1);
gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 0);
if (priv->mux_state)
mux_state_deselect(priv->mux_state);
return 0;
}
static const struct phy_ops can_transceiver_phy_ops = {
.power_on = can_transceiver_phy_power_on,
.power_off = can_transceiver_phy_power_off,
.owner = THIS_MODULE,
};
static const struct can_transceiver_data tcan1042_drvdata = {
.flags = CAN_TRANSCEIVER_STB_PRESENT,
};
static const struct can_transceiver_data tcan1043_drvdata = {
.flags = CAN_TRANSCEIVER_STB_PRESENT | CAN_TRANSCEIVER_EN_PRESENT,
};
static const struct can_transceiver_data tja1048_drvdata = {
.flags = CAN_TRANSCEIVER_STB_PRESENT | CAN_TRANSCEIVER_DUAL_CH,
};
static const struct can_transceiver_data tja1051_drvdata = {
.flags = CAN_TRANSCEIVER_SILENT_PRESENT | CAN_TRANSCEIVER_EN_PRESENT,
};
static const struct can_transceiver_data tja1057_drvdata = {
.flags = CAN_TRANSCEIVER_SILENT_PRESENT,
};
static const struct of_device_id can_transceiver_phy_ids[] = {
{
.compatible = "ti,tcan1042",
.data = &tcan1042_drvdata
},
{
Annotation
- Immediate include surface: `linux/of.h`, `linux/phy/phy.h`, `linux/platform_device.h`, `linux/module.h`, `linux/gpio.h`, `linux/gpio/consumer.h`, `linux/mux/consumer.h`.
- Detected declarations: `struct can_transceiver_data`, `struct can_transceiver_phy`, `struct can_transceiver_priv`, `function can_transceiver_phy_power_on`, `function can_transceiver_phy_power_off`, `function can_transceiver_phy_probe`.
- Atlas domain: Driver Families / drivers/phy.
- 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.