drivers/i2c/busses/i2c-bcm-kona.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-bcm-kona.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-bcm-kona.c- Extension
.c- Size
- 22964 bytes
- Lines
- 887
- Domain
- Driver Families
- Bucket
- drivers/i2c
- 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.
- 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/device.hlinux/kernel.hlinux/module.hlinux/sched.hlinux/i2c.hlinux/interrupt.hlinux/platform_device.hlinux/clk.hlinux/io.hlinux/slab.h
Detected Declarations
struct bus_speed_cfgstruct hs_bus_speed_cfgstruct bcm_kona_i2c_devenum bcm_kona_cmd_tenum bus_speed_indexenum hs_bus_speed_indexfunction bcm_kona_i2c_send_cmd_to_ctrlfunction bcm_kona_i2c_enable_clockfunction bcm_kona_i2c_disable_clockfunction bcm_kona_i2c_isrfunction bcm_kona_i2c_wait_if_busyfunction bcm_kona_send_i2c_cmdfunction bcm_kona_i2c_read_fifo_singlefunction bcm_kona_i2c_read_fifofunction bcm_kona_i2c_write_bytefunction bcm_kona_i2c_write_fifo_singlefunction bcm_kona_i2c_write_fifofunction bcm_kona_i2c_do_addrfunction bcm_kona_i2c_enable_autosensefunction bcm_kona_i2c_config_timingfunction bcm_kona_i2c_config_timing_hsfunction bcm_kona_i2c_switch_to_hsfunction bcm_kona_i2c_switch_to_stdfunction bcm_kona_i2c_xferfunction bcm_kona_i2c_functionalityfunction bcm_kona_i2c_assign_bus_speedfunction bcm_kona_i2c_probefunction bcm_kona_i2c_remove
Annotated Snippet
struct bus_speed_cfg {
uint8_t time_m; /* Number of cycles for setup time */
uint8_t time_n; /* Number of cycles for hold time */
uint8_t prescale; /* Prescale divider */
uint8_t time_p; /* Timing coefficient */
uint8_t no_div; /* Disable clock divider */
uint8_t time_div; /* Post-prescale divider */
};
/* Internal divider settings for high-speed mode */
struct hs_bus_speed_cfg {
uint8_t hs_hold; /* Number of clock cycles SCL stays low until
the end of bit period */
uint8_t hs_high_phase; /* Number of clock cycles SCL stays high
before it falls */
uint8_t hs_setup; /* Number of clock cycles SCL stays low
before it rises */
uint8_t prescale; /* Prescale divider */
uint8_t time_p; /* Timing coefficient */
uint8_t no_div; /* Disable clock divider */
uint8_t time_div; /* Post-prescale divider */
};
static const struct bus_speed_cfg std_cfg_table[] = {
[BCM_SPD_100K] = {0x01, 0x01, 0x03, 0x06, 0x00, 0x02},
[BCM_SPD_400K] = {0x05, 0x01, 0x03, 0x05, 0x01, 0x02},
[BCM_SPD_1MHZ] = {0x01, 0x01, 0x03, 0x01, 0x01, 0x03},
};
static const struct hs_bus_speed_cfg hs_cfg_table[] = {
[BCM_SPD_3P4MHZ] = {0x01, 0x08, 0x14, 0x00, 0x06, 0x01, 0x00},
};
struct bcm_kona_i2c_dev {
struct device *device;
void __iomem *base;
int irq;
struct clk *external_clk;
struct i2c_adapter adapter;
struct completion done;
const struct bus_speed_cfg *std_cfg;
const struct hs_bus_speed_cfg *hs_cfg;
};
static void bcm_kona_i2c_send_cmd_to_ctrl(struct bcm_kona_i2c_dev *dev,
enum bcm_kona_cmd_t cmd)
{
dev_dbg(dev->device, "%s, %d\n", __func__, cmd);
switch (cmd) {
case BCM_CMD_NOACTION:
writel((CS_CMD_CMD_NO_ACTION << CS_CMD_SHIFT) |
(CS_EN_CMD_ENABLE_BSC << CS_EN_SHIFT),
dev->base + CS_OFFSET);
break;
case BCM_CMD_START:
writel((CS_ACK_CMD_GEN_START << CS_ACK_SHIFT) |
(CS_CMD_CMD_START_RESTART << CS_CMD_SHIFT) |
(CS_EN_CMD_ENABLE_BSC << CS_EN_SHIFT),
dev->base + CS_OFFSET);
break;
case BCM_CMD_RESTART:
writel((CS_ACK_CMD_GEN_RESTART << CS_ACK_SHIFT) |
(CS_CMD_CMD_START_RESTART << CS_CMD_SHIFT) |
(CS_EN_CMD_ENABLE_BSC << CS_EN_SHIFT),
dev->base + CS_OFFSET);
break;
case BCM_CMD_STOP:
writel((CS_CMD_CMD_STOP << CS_CMD_SHIFT) |
(CS_EN_CMD_ENABLE_BSC << CS_EN_SHIFT),
dev->base + CS_OFFSET);
break;
default:
dev_err(dev->device, "Unknown command %d\n", cmd);
}
}
static void bcm_kona_i2c_enable_clock(struct bcm_kona_i2c_dev *dev)
{
writel(readl(dev->base + CLKEN_OFFSET) | CLKEN_CLKEN_MASK,
dev->base + CLKEN_OFFSET);
}
Annotation
- Immediate include surface: `linux/device.h`, `linux/kernel.h`, `linux/module.h`, `linux/sched.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/platform_device.h`, `linux/clk.h`.
- Detected declarations: `struct bus_speed_cfg`, `struct hs_bus_speed_cfg`, `struct bcm_kona_i2c_dev`, `enum bcm_kona_cmd_t`, `enum bus_speed_index`, `enum hs_bus_speed_index`, `function bcm_kona_i2c_send_cmd_to_ctrl`, `function bcm_kona_i2c_enable_clock`, `function bcm_kona_i2c_disable_clock`, `function bcm_kona_i2c_isr`.
- Atlas domain: Driver Families / drivers/i2c.
- Implementation status: source implementation candidate.
- 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.