• Home
  • Raw
  • Download

Lines Matching refs:dev

41 static int send_shm(struct spi_dev* dev,  in send_shm()  argument
62 rc = send_msg(dev->h, &msg); in send_shm()
93 static int shm_map(struct spi_dev* dev, void* shm_base, size_t shm_size) { in shm_map() argument
110 rc = send_shm(dev, &req, &shm_req, memref); in shm_map()
117 rc = handle_shm_resp(dev->h); in shm_map()
145 int spi_dev_open(struct spi_dev* dev, in spi_dev_open() argument
153 if (!dev || !name || max_num_cmds == 0) { in spi_dev_open()
158 rc = tipc_connect(&dev->h, name); in spi_dev_open()
175 rc = shm_map(dev, shm_base, shm_size); in spi_dev_open()
181 mb_init(&dev->shm, shm_base, shm_size, SPI_CMD_SHM_ALIGN); in spi_dev_open()
182 mb_resize(&dev->shm, shm_size); in spi_dev_open()
183 dev->max_num_cmds = max_num_cmds; in spi_dev_open()
184 dev->max_total_payload = max_total_payload; in spi_dev_open()
185 spi_clear_cmds(dev); in spi_dev_open()
198 close(dev->h); in spi_dev_open()
199 dev->h = INVALID_IPC_HANDLE; in spi_dev_open()
204 static inline bool is_initialized(struct spi_dev* dev) { in is_initialized() argument
205 return dev && dev->h != INVALID_IPC_HANDLE; in is_initialized()
208 void spi_clear_cmds(struct spi_dev* dev) { in spi_clear_cmds() argument
209 assert(is_initialized(dev)); in spi_clear_cmds()
210 mb_rewind_pos(&dev->shm); in spi_clear_cmds()
211 dev->num_cmds = 0; in spi_clear_cmds()
212 dev->total_payload = 0; in spi_clear_cmds()
213 dev->config_err = false; in spi_clear_cmds()
216 static int send_batch_req(struct spi_dev* dev) { in send_batch_req() argument
221 .len = mb_curr_pos(&dev->shm), in send_batch_req()
222 .num_cmds = dev->num_cmds, in send_batch_req()
224 int rc = tipc_send2(dev->h, &req, sizeof(req), &batch_req, in send_batch_req()
298 static int handle_batch_resp(struct spi_dev* dev, size_t* failed) { in handle_batch_resp() argument
304 rc = wait(dev->h, &evt, INFINITE_TIME); in handle_batch_resp()
310 rc = tipc_recv2(dev->h, sizeof(resp) + sizeof(batch_resp), &resp, in handle_batch_resp()
327 return validate_batch_resp(&batch_resp, &dev->shm, failed); in handle_batch_resp()
330 int spi_exec_cmds(struct spi_dev* dev, size_t* failed) { in spi_exec_cmds() argument
334 if (!is_initialized(dev)) { in spi_exec_cmds()
343 if (dev->config_err) { in spi_exec_cmds()
345 *failed = dev->num_cmds; in spi_exec_cmds()
349 rc = send_batch_req(dev); in spi_exec_cmds()
354 rc = handle_batch_resp(dev, failed); in spi_exec_cmds()
358 spi_clear_cmds(dev); in spi_exec_cmds()
362 static int spi_add_cmd(struct spi_dev* dev, in spi_add_cmd() argument
375 if (!is_initialized(dev)) { in spi_add_cmd()
379 if (dev->config_err) { in spi_add_cmd()
383 if (dev->num_cmds >= dev->max_num_cmds) { in spi_add_cmd()
388 shm_hdr = mb_advance_pos(&dev->shm, sizeof(*shm_hdr)); in spi_add_cmd()
397 *args = mb_advance_pos(&dev->shm, args_len); in spi_add_cmd()
404 assert(dev->total_payload <= dev->max_total_payload); in spi_add_cmd()
405 if (payload_len > dev->max_total_payload - dev->total_payload) { in spi_add_cmd()
409 dev->total_payload += payload_len; in spi_add_cmd()
411 *payload = mb_advance_pos(&dev->shm, payload_len); in spi_add_cmd()
415 dev->num_cmds++; in spi_add_cmd()
423 dev->config_err = true; in spi_add_cmd()
429 int spi_add_data_xfer_cmd(struct spi_dev* dev, in spi_add_data_xfer_cmd() argument
438 rc = spi_add_cmd(dev, SPI_CMD_SHM_OP_XFER, (void**)&args, sizeof(*args), in spi_add_data_xfer_cmd()
458 int spi_add_cs_assert_cmd(struct spi_dev* dev) { in spi_add_cs_assert_cmd() argument
459 return spi_add_cmd(dev, SPI_CMD_SHM_OP_CS_ASSERT, NULL, 0, NULL, 0); in spi_add_cs_assert_cmd()
462 int spi_add_cs_deassert_cmd(struct spi_dev* dev) { in spi_add_cs_deassert_cmd() argument
463 return spi_add_cmd(dev, SPI_CMD_SHM_OP_CS_DEASSERT, NULL, 0, NULL, 0); in spi_add_cs_deassert_cmd()
466 int spi_add_set_clk_cmd(struct spi_dev* dev, in spi_add_set_clk_cmd() argument
472 rc = spi_add_cmd(dev, SPI_CMD_SHM_OP_SET_CLK, (void**)&args, sizeof(*args), in spi_add_set_clk_cmd()
487 int spi_add_delay_cmd(struct spi_dev* dev, uint64_t delay_ns) { in spi_add_delay_cmd() argument
491 rc = spi_add_cmd(dev, SPI_CMD_SHM_OP_DELAY, (void**)&args, sizeof(*args), in spi_add_delay_cmd()