Lines Matching refs:tc6

20 int oa_tc6_reg_read(struct oa_tc6 *tc6, const uint32_t reg, uint32_t *val)  in oa_tc6_reg_read()  argument
34 if (!tc6->protected) { in oa_tc6_reg_read()
49 ret = spi_transceive_dt(tc6->spi, &tx, &rx); in oa_tc6_reg_read()
64 if (tc6->protected) { in oa_tc6_reg_read()
77 int oa_tc6_reg_write(struct oa_tc6 *tc6, const uint32_t reg, uint32_t val) in oa_tc6_reg_write() argument
92 if (!tc6->protected) { in oa_tc6_reg_write()
108 if (tc6->protected) { in oa_tc6_reg_write()
112 ret = spi_transceive_dt(tc6->spi, &tx, &rx); in oa_tc6_reg_write()
135 if (tc6->protected) { in oa_tc6_reg_write()
146 int oa_tc6_reg_rmw(struct oa_tc6 *tc6, const uint32_t reg, in oa_tc6_reg_rmw() argument
152 ret = oa_tc6_reg_read(tc6, reg, &tmp); in oa_tc6_reg_rmw()
163 return oa_tc6_reg_write(tc6, reg, tmp); in oa_tc6_reg_rmw()
166 int oa_tc6_set_protected_ctrl(struct oa_tc6 *tc6, bool prote) in oa_tc6_set_protected_ctrl() argument
168 int ret = oa_tc6_reg_rmw(tc6, OA_CONFIG0, OA_CONFIG0_PROTE, in oa_tc6_set_protected_ctrl()
174 tc6->protected = prote; in oa_tc6_set_protected_ctrl()
178 int oa_tc6_send_chunks(struct oa_tc6 *tc6, struct net_pkt *pkt) in oa_tc6_send_chunks() argument
181 uint8_t oa_tx[tc6->cps]; in oa_tc6_send_chunks()
190 chunks = len / tc6->cps; in oa_tc6_send_chunks()
191 if (len % tc6->cps) { in oa_tc6_send_chunks()
196 if (chunks > tc6->txc) { in oa_tc6_send_chunks()
218 ret = net_pkt_read(pkt, oa_tx, len > tc6->cps ? tc6->cps : len); in oa_tc6_send_chunks()
223 ret = oa_tc6_chunk_spi_transfer(tc6, NULL, oa_tx, hdr, &ftr); in oa_tc6_send_chunks()
228 len -= tc6->cps; in oa_tc6_send_chunks()
234 int oa_tc6_check_status(struct oa_tc6 *tc6) in oa_tc6_check_status() argument
238 if (!tc6->sync) { in oa_tc6_check_status()
243 if (tc6->exst) { in oa_tc6_check_status()
249 oa_tc6_reg_read(tc6, OA_STATUS0, &sts); in oa_tc6_check_status()
251 oa_tc6_reg_write(tc6, OA_STATUS0, sts); in oa_tc6_check_status()
255 oa_tc6_reg_read(tc6, OA_STATUS1, &sts); in oa_tc6_check_status()
257 oa_tc6_reg_write(tc6, OA_STATUS1, sts); in oa_tc6_check_status()
265 static int oa_tc6_update_status(struct oa_tc6 *tc6, uint32_t ftr) in oa_tc6_update_status() argument
272 tc6->exst = FIELD_GET(OA_DATA_FTR_EXST, ftr); in oa_tc6_update_status()
273 tc6->sync = FIELD_GET(OA_DATA_FTR_SYNC, ftr); in oa_tc6_update_status()
274 tc6->rca = FIELD_GET(OA_DATA_FTR_RCA, ftr); in oa_tc6_update_status()
275 tc6->txc = FIELD_GET(OA_DATA_FTR_TXC, ftr); in oa_tc6_update_status()
280 int oa_tc6_chunk_spi_transfer(struct oa_tc6 *tc6, uint8_t *buf_rx, uint8_t *buf_tx, in oa_tc6_chunk_spi_transfer() argument
294 tx_buf[1].len = tc6->cps; in oa_tc6_chunk_spi_transfer()
300 rx_buf[0].len = tc6->cps; in oa_tc6_chunk_spi_transfer()
308 ret = spi_transceive_dt(tc6->spi, &tx, &rx); in oa_tc6_chunk_spi_transfer()
314 return oa_tc6_update_status(tc6, *ftr); in oa_tc6_chunk_spi_transfer()
317 int oa_tc6_read_status(struct oa_tc6 *tc6, uint32_t *ftr) in oa_tc6_read_status() argument
326 return oa_tc6_chunk_spi_transfer(tc6, NULL, NULL, hdr, ftr); in oa_tc6_read_status()
329 int oa_tc6_read_chunks(struct oa_tc6 *tc6, struct net_pkt *pkt) in oa_tc6_read_chunks() argument
346 if (tc6->concat_buf) { in oa_tc6_read_chunks()
347 net_pkt_append_buffer(pkt, tc6->concat_buf); in oa_tc6_read_chunks()
348 tc6->concat_buf = NULL; in oa_tc6_read_chunks()
363 ret = oa_tc6_chunk_spi_transfer(tc6, buf_rx->data + buf_rx_used, NULL, hdr, &ftr); in oa_tc6_read_chunks()
417 tc6->concat_buf = net_buf_clone(buf_rx, OA_TC6_BUF_ALLOC_TIMEOUT); in oa_tc6_read_chunks()
418 if (!tc6->concat_buf) { in oa_tc6_read_chunks()
423 net_buf_pull(tc6->concat_buf, sbo); in oa_tc6_read_chunks()
436 buf_rx_used += tc6->cps; in oa_tc6_read_chunks()
437 if ((buf_rx_size - buf_rx_used) < tc6->cps) { in oa_tc6_read_chunks()
444 } while (tc6->rca > 0); in oa_tc6_read_chunks()