Lines Matching refs:hi

39 	struct cs_hsi_iface	*hi;  member
123 static void cs_hsi_read_on_control(struct cs_hsi_iface *hi);
124 static void cs_hsi_read_on_data(struct cs_hsi_iface *hi);
211 struct cs_hsi_iface *hi = msg->context; in cs_release_cmd() local
213 list_add_tail(&msg->link, &hi->cmdqueue); in cs_release_cmd()
218 struct cs_hsi_iface *hi = msg->context; in cs_cmd_destructor() local
220 spin_lock(&hi->lock); in cs_cmd_destructor()
224 if (hi->iface_state != CS_STATE_CLOSED) in cs_cmd_destructor()
225 dev_err(&hi->cl->device, "Cmd flushed while driver active\n"); in cs_cmd_destructor()
228 hi->control_state &= in cs_cmd_destructor()
231 hi->control_state & SSI_CHANNEL_STATE_WRITING) in cs_cmd_destructor()
232 hi->control_state &= ~SSI_CHANNEL_STATE_WRITING; in cs_cmd_destructor()
236 spin_unlock(&hi->lock); in cs_cmd_destructor()
264 static int cs_alloc_cmds(struct cs_hsi_iface *hi) in cs_alloc_cmds() argument
270 INIT_LIST_HEAD(&hi->cmdqueue); in cs_alloc_cmds()
283 msg->context = hi; in cs_alloc_cmds()
284 list_add_tail(&msg->link, &hi->cmdqueue); in cs_alloc_cmds()
290 cs_free_cmds(hi); in cs_alloc_cmds()
296 struct cs_hsi_iface *hi = msg->context; in cs_hsi_data_destructor() local
301 spin_lock(&hi->lock); in cs_hsi_data_destructor()
302 if (hi->iface_state != CS_STATE_CLOSED) in cs_hsi_data_destructor()
306 hi->data_state &= in cs_hsi_data_destructor()
309 hi->data_state &= ~SSI_CHANNEL_STATE_WRITING; in cs_hsi_data_destructor()
312 if (unlikely(waitqueue_active(&hi->datawait))) in cs_hsi_data_destructor()
313 wake_up_interruptible(&hi->datawait); in cs_hsi_data_destructor()
315 spin_unlock(&hi->lock); in cs_hsi_data_destructor()
318 static int cs_hsi_alloc_data(struct cs_hsi_iface *hi) in cs_hsi_alloc_data() argument
330 rxmsg->context = hi; in cs_hsi_alloc_data()
339 txmsg->context = hi; in cs_hsi_alloc_data()
341 hi->data_rx_msg = rxmsg; in cs_hsi_alloc_data()
342 hi->data_tx_msg = txmsg; in cs_hsi_alloc_data()
359 static void cs_hsi_free_data(struct cs_hsi_iface *hi) in cs_hsi_free_data() argument
361 cs_hsi_free_data_msg(hi->data_rx_msg); in cs_hsi_free_data()
362 cs_hsi_free_data_msg(hi->data_tx_msg); in cs_hsi_free_data()
365 static inline void __cs_hsi_error_pre(struct cs_hsi_iface *hi, in __cs_hsi_error_pre() argument
369 spin_lock(&hi->lock); in __cs_hsi_error_pre()
370 dev_err(&hi->cl->device, "HSI %s error, msg %d, state %u\n", in __cs_hsi_error_pre()
374 static inline void __cs_hsi_error_post(struct cs_hsi_iface *hi) in __cs_hsi_error_post() argument
376 spin_unlock(&hi->lock); in __cs_hsi_error_post()
391 static void cs_hsi_control_read_error(struct cs_hsi_iface *hi, in cs_hsi_control_read_error() argument
394 __cs_hsi_error_pre(hi, msg, "control read", &hi->control_state); in cs_hsi_control_read_error()
396 __cs_hsi_error_read_bits(&hi->control_state); in cs_hsi_control_read_error()
397 __cs_hsi_error_post(hi); in cs_hsi_control_read_error()
400 static void cs_hsi_control_write_error(struct cs_hsi_iface *hi, in cs_hsi_control_write_error() argument
403 __cs_hsi_error_pre(hi, msg, "control write", &hi->control_state); in cs_hsi_control_write_error()
405 __cs_hsi_error_write_bits(&hi->control_state); in cs_hsi_control_write_error()
406 __cs_hsi_error_post(hi); in cs_hsi_control_write_error()
410 static void cs_hsi_data_read_error(struct cs_hsi_iface *hi, struct hsi_msg *msg) in cs_hsi_data_read_error() argument
412 __cs_hsi_error_pre(hi, msg, "data read", &hi->data_state); in cs_hsi_data_read_error()
413 __cs_hsi_error_read_bits(&hi->data_state); in cs_hsi_data_read_error()
414 __cs_hsi_error_post(hi); in cs_hsi_data_read_error()
417 static void cs_hsi_data_write_error(struct cs_hsi_iface *hi, in cs_hsi_data_write_error() argument
420 __cs_hsi_error_pre(hi, msg, "data write", &hi->data_state); in cs_hsi_data_write_error()
421 __cs_hsi_error_write_bits(&hi->data_state); in cs_hsi_data_write_error()
422 __cs_hsi_error_post(hi); in cs_hsi_data_write_error()
428 struct cs_hsi_iface *hi = msg->context; in cs_hsi_read_on_control_complete() local
430 spin_lock(&hi->lock); in cs_hsi_read_on_control_complete()
431 hi->control_state &= ~SSI_CHANNEL_STATE_READING; in cs_hsi_read_on_control_complete()
433 dev_err(&hi->cl->device, "Control RX error detected\n"); in cs_hsi_read_on_control_complete()
434 spin_unlock(&hi->lock); in cs_hsi_read_on_control_complete()
435 cs_hsi_control_read_error(hi, msg); in cs_hsi_read_on_control_complete()
438 dev_dbg(&hi->cl->device, "Read on control: %08X\n", cmd); in cs_hsi_read_on_control_complete()
440 if (hi->flags & CS_FEAT_TSTAMP_RX_CTRL) { in cs_hsi_read_on_control_complete()
443 &hi->mmap_cfg->tstamp_rx_ctrl; in cs_hsi_read_on_control_complete()
450 spin_unlock(&hi->lock); in cs_hsi_read_on_control_complete()
455 cs_hsi_read_on_control(hi); in cs_hsi_read_on_control_complete()
460 struct cs_hsi_iface *hi = msg->context; in cs_hsi_peek_on_control_complete() local
464 dev_err(&hi->cl->device, "Control peek RX error detected\n"); in cs_hsi_peek_on_control_complete()
465 cs_hsi_control_read_error(hi, msg); in cs_hsi_peek_on_control_complete()
469 WARN_ON(!(hi->control_state & SSI_CHANNEL_STATE_READING)); in cs_hsi_peek_on_control_complete()
471 dev_dbg(&hi->cl->device, "Peek on control complete, reading\n"); in cs_hsi_peek_on_control_complete()
474 ret = hsi_async_read(hi->cl, msg); in cs_hsi_peek_on_control_complete()
476 cs_hsi_control_read_error(hi, msg); in cs_hsi_peek_on_control_complete()
479 static void cs_hsi_read_on_control(struct cs_hsi_iface *hi) in cs_hsi_read_on_control() argument
484 spin_lock(&hi->lock); in cs_hsi_read_on_control()
485 if (hi->control_state & SSI_CHANNEL_STATE_READING) { in cs_hsi_read_on_control()
486 dev_err(&hi->cl->device, "Control read already pending (%d)\n", in cs_hsi_read_on_control()
487 hi->control_state); in cs_hsi_read_on_control()
488 spin_unlock(&hi->lock); in cs_hsi_read_on_control()
491 if (hi->control_state & SSI_CHANNEL_STATE_ERROR) { in cs_hsi_read_on_control()
492 dev_err(&hi->cl->device, "Control read error (%d)\n", in cs_hsi_read_on_control()
493 hi->control_state); in cs_hsi_read_on_control()
494 spin_unlock(&hi->lock); in cs_hsi_read_on_control()
497 hi->control_state |= SSI_CHANNEL_STATE_READING; in cs_hsi_read_on_control()
498 dev_dbg(&hi->cl->device, "Issuing RX on control\n"); in cs_hsi_read_on_control()
499 msg = cs_claim_cmd(hi); in cs_hsi_read_on_control()
500 spin_unlock(&hi->lock); in cs_hsi_read_on_control()
504 ret = hsi_async_read(hi->cl, msg); in cs_hsi_read_on_control()
506 cs_hsi_control_read_error(hi, msg); in cs_hsi_read_on_control()
511 struct cs_hsi_iface *hi = msg->context; in cs_hsi_write_on_control_complete() local
513 spin_lock(&hi->lock); in cs_hsi_write_on_control_complete()
514 hi->control_state &= ~SSI_CHANNEL_STATE_WRITING; in cs_hsi_write_on_control_complete()
516 spin_unlock(&hi->lock); in cs_hsi_write_on_control_complete()
518 cs_hsi_control_write_error(hi, msg); in cs_hsi_write_on_control_complete()
520 dev_err(&hi->cl->device, in cs_hsi_write_on_control_complete()
526 static int cs_hsi_write_on_control(struct cs_hsi_iface *hi, u32 message) in cs_hsi_write_on_control() argument
531 spin_lock(&hi->lock); in cs_hsi_write_on_control()
532 if (hi->control_state & SSI_CHANNEL_STATE_ERROR) { in cs_hsi_write_on_control()
533 spin_unlock(&hi->lock); in cs_hsi_write_on_control()
536 if (hi->control_state & SSI_CHANNEL_STATE_WRITING) { in cs_hsi_write_on_control()
537 dev_err(&hi->cl->device, in cs_hsi_write_on_control()
539 spin_unlock(&hi->lock); in cs_hsi_write_on_control()
542 hi->control_state |= SSI_CHANNEL_STATE_WRITING; in cs_hsi_write_on_control()
543 msg = cs_claim_cmd(hi); in cs_hsi_write_on_control()
544 spin_unlock(&hi->lock); in cs_hsi_write_on_control()
549 dev_dbg(&hi->cl->device, in cs_hsi_write_on_control()
551 ret = hsi_async_write(hi->cl, msg); in cs_hsi_write_on_control()
553 dev_err(&hi->cl->device, in cs_hsi_write_on_control()
555 cs_hsi_control_write_error(hi, msg); in cs_hsi_write_on_control()
565 if (!(hi->control_state & SSI_CHANNEL_STATE_READING)) { in cs_hsi_write_on_control()
566 dev_err(&hi->cl->device, "Restarting control reads\n"); in cs_hsi_write_on_control()
567 cs_hsi_read_on_control(hi); in cs_hsi_write_on_control()
575 struct cs_hsi_iface *hi = msg->context; in cs_hsi_read_on_data_complete() local
579 cs_hsi_data_read_error(hi, msg); in cs_hsi_read_on_data_complete()
583 spin_lock(&hi->lock); in cs_hsi_read_on_data_complete()
584 WARN_ON(!(hi->data_state & SSI_CHANNEL_STATE_READING)); in cs_hsi_read_on_data_complete()
585 hi->data_state &= ~SSI_CHANNEL_STATE_READING; in cs_hsi_read_on_data_complete()
587 payload |= hi->rx_slot; in cs_hsi_read_on_data_complete()
588 hi->rx_slot++; in cs_hsi_read_on_data_complete()
589 hi->rx_slot %= hi->rx_ptr_boundary; in cs_hsi_read_on_data_complete()
591 hi->mmap_cfg->rx_ptr = hi->rx_slot; in cs_hsi_read_on_data_complete()
592 if (unlikely(waitqueue_active(&hi->datawait))) in cs_hsi_read_on_data_complete()
593 wake_up_interruptible(&hi->datawait); in cs_hsi_read_on_data_complete()
594 spin_unlock(&hi->lock); in cs_hsi_read_on_data_complete()
596 cs_notify_data(payload, hi->rx_bufs); in cs_hsi_read_on_data_complete()
597 cs_hsi_read_on_data(hi); in cs_hsi_read_on_data_complete()
602 struct cs_hsi_iface *hi = msg->context; in cs_hsi_peek_on_data_complete() local
607 cs_hsi_data_read_error(hi, msg); in cs_hsi_peek_on_data_complete()
610 if (unlikely(hi->iface_state != CS_STATE_CONFIGURED)) { in cs_hsi_peek_on_data_complete()
611 dev_err(&hi->cl->device, "Data received in invalid state\n"); in cs_hsi_peek_on_data_complete()
612 cs_hsi_data_read_error(hi, msg); in cs_hsi_peek_on_data_complete()
616 spin_lock(&hi->lock); in cs_hsi_peek_on_data_complete()
617 WARN_ON(!(hi->data_state & SSI_CHANNEL_STATE_POLL)); in cs_hsi_peek_on_data_complete()
618 hi->data_state &= ~SSI_CHANNEL_STATE_POLL; in cs_hsi_peek_on_data_complete()
619 hi->data_state |= SSI_CHANNEL_STATE_READING; in cs_hsi_peek_on_data_complete()
620 spin_unlock(&hi->lock); in cs_hsi_peek_on_data_complete()
622 address = (u32 *)(hi->mmap_base + in cs_hsi_peek_on_data_complete()
623 hi->rx_offsets[hi->rx_slot % hi->rx_bufs]); in cs_hsi_peek_on_data_complete()
624 sg_init_one(msg->sgt.sgl, address, hi->buf_size); in cs_hsi_peek_on_data_complete()
627 ret = hsi_async_read(hi->cl, msg); in cs_hsi_peek_on_data_complete()
629 cs_hsi_data_read_error(hi, msg); in cs_hsi_peek_on_data_complete()
650 static void cs_hsi_read_on_data(struct cs_hsi_iface *hi) in cs_hsi_read_on_data() argument
655 spin_lock(&hi->lock); in cs_hsi_read_on_data()
656 if (hi->data_state & in cs_hsi_read_on_data()
658 dev_dbg(&hi->cl->device, "Data read already pending (%u)\n", in cs_hsi_read_on_data()
659 hi->data_state); in cs_hsi_read_on_data()
660 spin_unlock(&hi->lock); in cs_hsi_read_on_data()
663 hi->data_state |= SSI_CHANNEL_STATE_POLL; in cs_hsi_read_on_data()
664 spin_unlock(&hi->lock); in cs_hsi_read_on_data()
666 rxmsg = hi->data_rx_msg; in cs_hsi_read_on_data()
667 sg_init_one(rxmsg->sgt.sgl, (void *)hi->mmap_base, 0); in cs_hsi_read_on_data()
671 ret = hsi_async_read(hi->cl, rxmsg); in cs_hsi_read_on_data()
673 cs_hsi_data_read_error(hi, rxmsg); in cs_hsi_read_on_data()
678 struct cs_hsi_iface *hi = msg->context; in cs_hsi_write_on_data_complete() local
681 spin_lock(&hi->lock); in cs_hsi_write_on_data_complete()
682 hi->data_state &= ~SSI_CHANNEL_STATE_WRITING; in cs_hsi_write_on_data_complete()
683 if (unlikely(waitqueue_active(&hi->datawait))) in cs_hsi_write_on_data_complete()
684 wake_up_interruptible(&hi->datawait); in cs_hsi_write_on_data_complete()
685 spin_unlock(&hi->lock); in cs_hsi_write_on_data_complete()
687 cs_hsi_data_write_error(hi, msg); in cs_hsi_write_on_data_complete()
691 static int cs_hsi_write_on_data(struct cs_hsi_iface *hi, unsigned int slot) in cs_hsi_write_on_data() argument
697 spin_lock(&hi->lock); in cs_hsi_write_on_data()
698 if (hi->iface_state != CS_STATE_CONFIGURED) { in cs_hsi_write_on_data()
699 dev_err(&hi->cl->device, "Not configured, aborting\n"); in cs_hsi_write_on_data()
703 if (hi->data_state & SSI_CHANNEL_STATE_ERROR) { in cs_hsi_write_on_data()
704 dev_err(&hi->cl->device, "HSI error, aborting\n"); in cs_hsi_write_on_data()
708 if (hi->data_state & SSI_CHANNEL_STATE_WRITING) { in cs_hsi_write_on_data()
709 dev_err(&hi->cl->device, "Write pending on data channel.\n"); in cs_hsi_write_on_data()
713 hi->data_state |= SSI_CHANNEL_STATE_WRITING; in cs_hsi_write_on_data()
714 spin_unlock(&hi->lock); in cs_hsi_write_on_data()
716 hi->tx_slot = slot; in cs_hsi_write_on_data()
717 address = (u32 *)(hi->mmap_base + hi->tx_offsets[hi->tx_slot]); in cs_hsi_write_on_data()
718 txmsg = hi->data_tx_msg; in cs_hsi_write_on_data()
719 sg_init_one(txmsg->sgt.sgl, address, hi->buf_size); in cs_hsi_write_on_data()
721 ret = hsi_async_write(hi->cl, txmsg); in cs_hsi_write_on_data()
723 cs_hsi_data_write_error(hi, txmsg); in cs_hsi_write_on_data()
728 spin_unlock(&hi->lock); in cs_hsi_write_on_data()
730 cs_hsi_data_write_error(hi, hi->data_tx_msg); in cs_hsi_write_on_data()
735 static unsigned int cs_hsi_get_state(struct cs_hsi_iface *hi) in cs_hsi_get_state() argument
737 return hi->iface_state; in cs_hsi_get_state()
740 static int cs_hsi_command(struct cs_hsi_iface *hi, u32 cmd) in cs_hsi_command() argument
747 ret = cs_hsi_write_on_control(hi, cmd); in cs_hsi_command()
751 ret = cs_hsi_write_on_data(hi, cmd & CS_PARAM_MASK); in cs_hsi_command()
764 static void cs_hsi_set_wakeline(struct cs_hsi_iface *hi, bool new_state) in cs_hsi_set_wakeline() argument
768 spin_lock_bh(&hi->lock); in cs_hsi_set_wakeline()
769 if (hi->wakeline_state != new_state) { in cs_hsi_set_wakeline()
770 hi->wakeline_state = new_state; in cs_hsi_set_wakeline()
772 dev_dbg(&hi->cl->device, "setting wake line to %d (%p)\n", in cs_hsi_set_wakeline()
773 new_state, hi->cl); in cs_hsi_set_wakeline()
775 spin_unlock_bh(&hi->lock); in cs_hsi_set_wakeline()
779 ssip_slave_start_tx(hi->master); in cs_hsi_set_wakeline()
781 ssip_slave_stop_tx(hi->master); in cs_hsi_set_wakeline()
784 dev_dbg(&hi->cl->device, "wake line set to %d (%p)\n", in cs_hsi_set_wakeline()
785 new_state, hi->cl); in cs_hsi_set_wakeline()
788 static void set_buffer_sizes(struct cs_hsi_iface *hi, int rx_bufs, int tx_bufs) in set_buffer_sizes() argument
790 hi->rx_bufs = rx_bufs; in set_buffer_sizes()
791 hi->tx_bufs = tx_bufs; in set_buffer_sizes()
792 hi->mmap_cfg->rx_bufs = rx_bufs; in set_buffer_sizes()
793 hi->mmap_cfg->tx_bufs = tx_bufs; in set_buffer_sizes()
795 if (hi->flags & CS_FEAT_ROLLING_RX_COUNTER) { in set_buffer_sizes()
803 hi->rx_ptr_boundary = (rx_bufs << RX_PTR_BOUNDARY_SHIFT); in set_buffer_sizes()
804 hi->mmap_cfg->rx_ptr_boundary = hi->rx_ptr_boundary; in set_buffer_sizes()
806 hi->rx_ptr_boundary = hi->rx_bufs; in set_buffer_sizes()
810 static int check_buf_params(struct cs_hsi_iface *hi, in check_buf_params() argument
815 size_t ctrl_size_aligned = L1_CACHE_ALIGN(sizeof(*hi->mmap_cfg)); in check_buf_params()
821 } else if ((buf_size_aligned + ctrl_size_aligned) >= hi->mmap_size) { in check_buf_params()
822 dev_err(&hi->cl->device, "No space for the requested buffer " in check_buf_params()
833 static int cs_hsi_data_sync(struct cs_hsi_iface *hi) in cs_hsi_data_sync() argument
837 spin_lock_bh(&hi->lock); in cs_hsi_data_sync()
839 if (!cs_state_xfer_active(hi->data_state)) { in cs_hsi_data_sync()
840 dev_dbg(&hi->cl->device, "hsi_data_sync break, idle\n"); in cs_hsi_data_sync()
847 if (!cs_state_xfer_active(hi->data_state)) in cs_hsi_data_sync()
857 prepare_to_wait(&hi->datawait, &wait, TASK_INTERRUPTIBLE); in cs_hsi_data_sync()
858 spin_unlock_bh(&hi->lock); in cs_hsi_data_sync()
861 spin_lock_bh(&hi->lock); in cs_hsi_data_sync()
862 finish_wait(&hi->datawait, &wait); in cs_hsi_data_sync()
864 dev_dbg(&hi->cl->device, in cs_hsi_data_sync()
873 spin_unlock_bh(&hi->lock); in cs_hsi_data_sync()
874 dev_dbg(&hi->cl->device, "hsi_data_sync done with res %d\n", r); in cs_hsi_data_sync()
879 static void cs_hsi_data_enable(struct cs_hsi_iface *hi, in cs_hsi_data_enable() argument
884 BUG_ON(hi->buf_size == 0); in cs_hsi_data_enable()
886 set_buffer_sizes(hi, buf_cfg->rx_bufs, buf_cfg->tx_bufs); in cs_hsi_data_enable()
888 hi->slot_size = L1_CACHE_ALIGN(hi->buf_size); in cs_hsi_data_enable()
889 dev_dbg(&hi->cl->device, in cs_hsi_data_enable()
891 hi->slot_size, hi->buf_size, L1_CACHE_BYTES); in cs_hsi_data_enable()
893 data_start = L1_CACHE_ALIGN(sizeof(*hi->mmap_cfg)); in cs_hsi_data_enable()
894 dev_dbg(&hi->cl->device, in cs_hsi_data_enable()
896 data_start, sizeof(*hi->mmap_cfg), L1_CACHE_BYTES); in cs_hsi_data_enable()
898 for (i = 0; i < hi->mmap_cfg->rx_bufs; i++) { in cs_hsi_data_enable()
899 hi->rx_offsets[i] = data_start + i * hi->slot_size; in cs_hsi_data_enable()
900 hi->mmap_cfg->rx_offsets[i] = hi->rx_offsets[i]; in cs_hsi_data_enable()
901 dev_dbg(&hi->cl->device, "DL buf #%u at %u\n", in cs_hsi_data_enable()
902 i, hi->rx_offsets[i]); in cs_hsi_data_enable()
904 for (i = 0; i < hi->mmap_cfg->tx_bufs; i++) { in cs_hsi_data_enable()
905 hi->tx_offsets[i] = data_start + in cs_hsi_data_enable()
906 (i + hi->mmap_cfg->rx_bufs) * hi->slot_size; in cs_hsi_data_enable()
907 hi->mmap_cfg->tx_offsets[i] = hi->tx_offsets[i]; in cs_hsi_data_enable()
908 dev_dbg(&hi->cl->device, "UL buf #%u at %u\n", in cs_hsi_data_enable()
909 i, hi->rx_offsets[i]); in cs_hsi_data_enable()
912 hi->iface_state = CS_STATE_CONFIGURED; in cs_hsi_data_enable()
915 static void cs_hsi_data_disable(struct cs_hsi_iface *hi, int old_state) in cs_hsi_data_disable() argument
918 dev_dbg(&hi->cl->device, in cs_hsi_data_disable()
920 hi->iface_state = CS_STATE_OPENED; in cs_hsi_data_disable()
924 static int cs_hsi_buf_config(struct cs_hsi_iface *hi, in cs_hsi_buf_config() argument
928 unsigned int old_state = hi->iface_state; in cs_hsi_buf_config()
930 spin_lock_bh(&hi->lock); in cs_hsi_buf_config()
933 hi->iface_state = CS_STATE_OPENED; in cs_hsi_buf_config()
934 spin_unlock_bh(&hi->lock); in cs_hsi_buf_config()
940 r = cs_hsi_data_sync(hi); in cs_hsi_buf_config()
944 WARN_ON(cs_state_xfer_active(hi->data_state)); in cs_hsi_buf_config()
946 spin_lock_bh(&hi->lock); in cs_hsi_buf_config()
947 r = check_buf_params(hi, buf_cfg); in cs_hsi_buf_config()
951 hi->buf_size = buf_cfg->buf_size; in cs_hsi_buf_config()
952 hi->mmap_cfg->buf_size = hi->buf_size; in cs_hsi_buf_config()
953 hi->flags = buf_cfg->flags; in cs_hsi_buf_config()
955 hi->rx_slot = 0; in cs_hsi_buf_config()
956 hi->tx_slot = 0; in cs_hsi_buf_config()
957 hi->slot_size = 0; in cs_hsi_buf_config()
959 if (hi->buf_size) in cs_hsi_buf_config()
960 cs_hsi_data_enable(hi, buf_cfg); in cs_hsi_buf_config()
962 cs_hsi_data_disable(hi, old_state); in cs_hsi_buf_config()
964 spin_unlock_bh(&hi->lock); in cs_hsi_buf_config()
966 if (old_state != hi->iface_state) { in cs_hsi_buf_config()
967 if (hi->iface_state == CS_STATE_CONFIGURED) { in cs_hsi_buf_config()
968 cpu_latency_qos_add_request(&hi->pm_qos_req, in cs_hsi_buf_config()
971 cs_hsi_read_on_data(hi); in cs_hsi_buf_config()
974 cpu_latency_qos_remove_request(&hi->pm_qos_req); in cs_hsi_buf_config()
980 spin_unlock_bh(&hi->lock); in cs_hsi_buf_config()
984 static int cs_hsi_start(struct cs_hsi_iface **hi, struct hsi_client *cl, in cs_hsi_start() argument
1040 BUG_ON(!hi); in cs_hsi_start()
1041 *hi = hsi_if; in cs_hsi_start()
1059 static void cs_hsi_stop(struct cs_hsi_iface *hi) in cs_hsi_stop() argument
1061 dev_dbg(&hi->cl->device, "cs_hsi_stop\n"); in cs_hsi_stop()
1062 cs_hsi_set_wakeline(hi, 0); in cs_hsi_stop()
1063 ssip_slave_put_master(hi->master); in cs_hsi_stop()
1066 hi->iface_state = CS_STATE_CLOSED; in cs_hsi_stop()
1067 hsi_release_port(hi->cl); in cs_hsi_stop()
1074 WARN_ON(!cs_state_idle(hi->control_state)); in cs_hsi_stop()
1075 WARN_ON(!cs_state_idle(hi->data_state)); in cs_hsi_stop()
1077 if (cpu_latency_qos_request_active(&hi->pm_qos_req)) in cs_hsi_stop()
1078 cpu_latency_qos_remove_request(&hi->pm_qos_req); in cs_hsi_stop()
1080 spin_lock_bh(&hi->lock); in cs_hsi_stop()
1081 cs_hsi_free_data(hi); in cs_hsi_stop()
1082 cs_free_cmds(hi); in cs_hsi_stop()
1083 spin_unlock_bh(&hi->lock); in cs_hsi_stop()
1084 kfree(hi); in cs_hsi_stop()
1192 err = cs_hsi_command(csdata->hi, data); in cs_char_write()
1209 state = cs_hsi_get_state(csdata->hi); in cs_char_ioctl()
1228 cs_hsi_set_wakeline(csdata->hi, !!state); in cs_char_ioctl()
1247 r = cs_hsi_buf_config(csdata->hi, &buf_cfg); in cs_char_ioctl()
1295 ret = cs_hsi_start(&cs_char_data.hi, cs_char_data.cl, p, CS_MMAP_SIZE); in cs_char_open()
1338 cs_hsi_stop(csdata->hi); in cs_char_release()
1340 csdata->hi = NULL; in cs_char_release()
1378 cs_char_data.hi = NULL; in cs_hsi_client_probe()
1407 struct cs_hsi_iface *hi; in cs_hsi_client_remove() local
1412 hi = cs_char_data.hi; in cs_hsi_client_remove()
1413 cs_char_data.hi = NULL; in cs_hsi_client_remove()
1415 if (hi) in cs_hsi_client_remove()
1416 cs_hsi_stop(hi); in cs_hsi_client_remove()