Lines Matching +full:spi +full:- +full:3 +full:wire

1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt5677-spi.c -- RT5677 ALSA SoC audio codec driver
11 #include <linux/spi/spi.h>
27 #include "rt5677-spi.h"
35 /* The AddressPhase and DataPhase of SPI commands are MSB first on the wire.
36 * DataPhase word size of 16-bit commands is 2 bytes.
37 * DataPhase word size of 32-bit commands is 4 bytes.
39 * The DSP CPU is little-endian.
55 * 3 transfer commands are available:
88 *len = (((remain - 1) >> 3) + 1) << 3; in rt5677_spi_select_cmd()
104 si = w + word_size - i - 1; in rt5677_spi_reverse()
110 /* Read DSP address space using SPI. addr and len have to be 4-byte aligned. */
124 return -ENODEV; in rt5677_spi_read()
126 if ((addr & 3) || (len & 3)) { in rt5677_spi_read()
127 dev_err(&g_spi->dev, "Bad read align 0x%x(%zu)\n", addr, len); in rt5677_spi_read()
128 return -EACCES; in rt5677_spi_read()
141 len - offset, &t[1].len); in rt5677_spi_read()
143 /* Construct SPI message header */ in rt5677_spi_read()
147 header[3] = ((addr + offset) & 0x0000ff00) >> 8; in rt5677_spi_read()
156 rt5677_spi_reverse(cb + offset, len - offset, body, t[1].len); in rt5677_spi_read()
162 /* Write DSP address space using SPI. addr has to be 4-byte aligned.
163 * If len is not 4-byte aligned, then extra zeros are written at the end
179 return -ENODEV; in rt5677_spi_write()
181 if (addr & 3) { in rt5677_spi_write()
182 dev_err(&g_spi->dev, "Bad write align 0x%x(%zu)\n", addr, len); in rt5677_spi_write()
183 return -EACCES; in rt5677_spi_write()
193 len - offset, &t.len); in rt5677_spi_write()
195 /* Construct SPI message header */ in rt5677_spi_write()
199 buf[3] = ((addr + offset) & 0x0000ff00) >> 8; in rt5677_spi_write()
203 rt5677_spi_reverse(body, t.len, cb + offset, len - offset); in rt5677_spi_write()
217 return rt5677_spi_write(addr, fw->data, fw->size); in rt5677_spi_write_firmware()
221 static int rt5677_spi_probe(struct spi_device *spi) in rt5677_spi_probe() argument
223 g_spi = spi; in rt5677_spi_probe()
242 MODULE_DESCRIPTION("ASoC RT5677 SPI driver");