sound/soc/codecs/rt5575-spi.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt5575-spi.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rt5575-spi.c- Extension
.c- Size
- 2672 bytes
- Lines
- 119
- Domain
- Driver Families
- Bucket
- sound/soc
- 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
linux/firmware.hlinux/of.hlinux/spi/spi.hrt5575-spi.h
Detected Declarations
struct rt5575_spi_burst_writefunction rt5575_spi_burst_writefunction rt5575_spi_fw_load
Annotated Snippet
struct rt5575_spi_burst_write {
u8 cmd;
u32 addr;
u8 data[RT5575_SPI_BUF_LEN];
u8 dummy;
} __packed;
struct spi_device *rt5575_spi_get_device(struct device *dev)
{
struct spi_device *spi;
struct spi_controller *ctlr;
struct device_node *spi_np;
u32 cs;
spi_np = of_parse_phandle(dev->of_node, "spi-parent", 0);
if (!spi_np) {
dev_err(dev, "Failed to get spi-parent phandle\n");
return NULL;
}
if (of_property_read_u32_index(dev->of_node, "spi-parent", 1, &cs))
cs = 0;
ctlr = of_find_spi_controller_by_node(spi_np);
of_node_put(spi_np);
if (!ctlr) {
dev_err(dev, "Failed to get spi_controller\n");
return NULL;
}
if (cs >= ctlr->num_chipselect) {
dev_err(dev, "Chip select has wrong number %d\n", cs);
spi_controller_put(ctlr);
return NULL;
}
spi = spi_new_device(ctlr, &(struct spi_board_info){
.modalias = "rt5575",
.chip_select = cs,
.max_speed_hz = 10000000,
});
spi_controller_put(ctlr);
return spi;
}
/**
* rt5575_spi_burst_write - Write data to SPI by rt5575 address.
* @spi: SPI device.
* @addr: Start address.
* @txbuf: Data buffer for writing.
* @len: Data length.
*
*/
static void rt5575_spi_burst_write(struct spi_device *spi, u32 addr, const u8 *txbuf, size_t len)
{
struct rt5575_spi_burst_write buf = {
.cmd = RT5575_SPI_CMD_BURST_WRITE,
};
unsigned int end, offset = 0;
while (offset < len) {
if (offset + RT5575_SPI_BUF_LEN <= len)
end = RT5575_SPI_BUF_LEN;
else
end = len % RT5575_SPI_BUF_LEN;
buf.addr = cpu_to_le32(addr + offset);
memcpy(&buf.data, &txbuf[offset], end);
spi_write(spi, &buf, sizeof(buf));
offset += RT5575_SPI_BUF_LEN;
}
}
int rt5575_spi_fw_load(struct spi_device *spi)
{
struct device *dev = &spi->dev;
const struct firmware *firmware;
int i, ret;
static const char * const fw_path[] = {
"realtek/rt5575/rt5575_fw1.bin",
"realtek/rt5575/rt5575_fw2.bin",
"realtek/rt5575/rt5575_fw3.bin",
"realtek/rt5575/rt5575_fw4.bin",
};
static const u32 fw_addr[] = { 0x5f400000, 0x5f600000, 0x5f7fe000, 0x5f7ff000 };
for (i = 0; i < ARRAY_SIZE(fw_addr); i++) {
ret = request_firmware(&firmware, fw_path[i], dev);
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/of.h`, `linux/spi/spi.h`, `rt5575-spi.h`.
- Detected declarations: `struct rt5575_spi_burst_write`, `function rt5575_spi_burst_write`, `function rt5575_spi_fw_load`.
- Atlas domain: Driver Families / sound/soc.
- 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.