Lines Matching refs:spi_xcomm
32 struct spi_xcomm { struct
43 static int spi_xcomm_sync_config(struct spi_xcomm *spi_xcomm, unsigned int len) in spi_xcomm_sync_config() argument
46 uint8_t *buf = spi_xcomm->buf; in spi_xcomm_sync_config()
48 settings = spi_xcomm->settings; in spi_xcomm_sync_config()
53 put_unaligned_be16(spi_xcomm->chipselect, &buf[3]); in spi_xcomm_sync_config()
55 return i2c_master_send(spi_xcomm->i2c, buf, 5); in spi_xcomm_sync_config()
58 static void spi_xcomm_chipselect(struct spi_xcomm *spi_xcomm, in spi_xcomm_chipselect() argument
62 uint16_t chipselect = spi_xcomm->chipselect; in spi_xcomm_chipselect()
69 spi_xcomm->chipselect = chipselect; in spi_xcomm_chipselect()
72 static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm, in spi_xcomm_setup_transfer() argument
78 if (t->speed_hz != spi_xcomm->current_speed) { in spi_xcomm_setup_transfer()
89 spi_xcomm->current_speed = t->speed_hz; in spi_xcomm_setup_transfer()
110 static int spi_xcomm_txrx_bufs(struct spi_xcomm *spi_xcomm, in spi_xcomm_txrx_bufs() argument
116 spi_xcomm->buf[0] = SPI_XCOMM_CMD_WRITE; in spi_xcomm_txrx_bufs()
117 memcpy(spi_xcomm->buf + 1, t->tx_buf, t->len); in spi_xcomm_txrx_bufs()
119 ret = i2c_master_send(spi_xcomm->i2c, spi_xcomm->buf, t->len + 1); in spi_xcomm_txrx_bufs()
125 ret = i2c_master_recv(spi_xcomm->i2c, t->rx_buf, t->len); in spi_xcomm_txrx_bufs()
138 struct spi_xcomm *spi_xcomm = spi_master_get_devdata(master); in spi_xcomm_transfer_one() local
139 unsigned int settings = spi_xcomm->settings; in spi_xcomm_transfer_one()
147 spi_xcomm_chipselect(spi_xcomm, spi, true); in spi_xcomm_transfer_one()
156 status = spi_xcomm_setup_transfer(spi_xcomm, spi, t, &settings); in spi_xcomm_transfer_one()
169 spi_xcomm->settings = settings; in spi_xcomm_transfer_one()
170 status = spi_xcomm_sync_config(spi_xcomm, t->len); in spi_xcomm_transfer_one()
173 } else if (settings != spi_xcomm->settings || is_first) { in spi_xcomm_transfer_one()
174 spi_xcomm->settings = settings; in spi_xcomm_transfer_one()
175 status = spi_xcomm_sync_config(spi_xcomm, 0); in spi_xcomm_transfer_one()
181 status = spi_xcomm_txrx_bufs(spi_xcomm, spi, t); in spi_xcomm_transfer_one()
197 spi_xcomm_chipselect(spi_xcomm, spi, false); in spi_xcomm_transfer_one()
208 struct spi_xcomm *spi_xcomm; in spi_xcomm_probe() local
212 master = spi_alloc_master(&i2c->dev, sizeof(*spi_xcomm)); in spi_xcomm_probe()
216 spi_xcomm = spi_master_get_devdata(master); in spi_xcomm_probe()
217 spi_xcomm->i2c = i2c; in spi_xcomm_probe()