Lines Matching +full:os +full:- +full:initiated

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (c) 2014-2016, Intel Corporation.
8 #include <linux/devm-helpers.h>
14 #include "hw-ish.h"
22 * ish_reg_read() - Read register
35 return readl(hw->mem_addr + offset); in ish_reg_read()
39 * ish_reg_write() - Write register
52 writel(value, hw->mem_addr + offset); in ish_reg_write()
56 * _ish_read_fw_sts_reg() - Read FW status register
69 * check_generated_interrupt() - Check if ISH interrupt
81 if (dev->pdev->device == PCI_DEVICE_ID_INTEL_ISH_CHV) { in check_generated_interrupt()
88 /* only busy-clear bit is RW, others are RO */ in check_generated_interrupt()
97 * ish_is_input_ready() - Check if FW ready for RX
113 * set_host_ready() - Indicate host ready
120 if (dev->pdev->device == PCI_DEVICE_ID_INTEL_ISH_CHV) { in set_host_ready()
121 if (dev->pdev->revision == REVISION_ID_CHT_A0 || in set_host_ready()
122 (dev->pdev->revision & REVISION_ID_SI_MASK) == in set_host_ready()
125 else if (dev->pdev->revision == REVISION_ID_CHT_B0 || in set_host_ready()
126 (dev->pdev->revision & REVISION_ID_SI_MASK) == in set_host_ready()
128 (dev->pdev->revision & REVISION_ID_SI_MASK) == in set_host_ready()
130 (dev->pdev->revision & REVISION_ID_SI_MASK) == in set_host_ready()
154 * ishtp_fw_is_ready() - Check if FW ready
170 * ish_set_host_rdy() - Indicate host ready
184 * ish_clr_host_rdy() - Indicate host not ready
205 * ish_set_host_ready() - reconfig ipc host registers
225 * _ishtp_read_hdr() - Read message header
238 * _ishtp_read - Read message
262 * write_ipc_from_queue() - try to write ipc msg from Tx queue to device
265 * Check if DRBL is cleared. if it is - write the first IPC msg, then call
283 if (dev->dev_state == ISHTP_DEV_DISABLED) in write_ipc_from_queue()
284 return -EINVAL; in write_ipc_from_queue()
286 spin_lock_irqsave(&dev->wr_processing_spinlock, flags); in write_ipc_from_queue()
288 spin_unlock_irqrestore(&dev->wr_processing_spinlock, flags); in write_ipc_from_queue()
289 return -EBUSY; in write_ipc_from_queue()
293 * if tx send list is empty - return 0; in write_ipc_from_queue()
296 if (list_empty(&dev->wr_processing_list)) { in write_ipc_from_queue()
297 spin_unlock_irqrestore(&dev->wr_processing_spinlock, flags); in write_ipc_from_queue()
301 ipc_link = list_first_entry(&dev->wr_processing_list, in write_ipc_from_queue()
304 length = ipc_link->length - sizeof(uint32_t); in write_ipc_from_queue()
305 doorbell_val = *(uint32_t *)ipc_link->inline_data; in write_ipc_from_queue()
306 r_buf = (uint32_t *)(ipc_link->inline_data + sizeof(uint32_t)); in write_ipc_from_queue()
346 ++dev->ipc_tx_cnt; in write_ipc_from_queue()
347 dev->ipc_tx_bytes_cnt += IPC_HEADER_GET_LENGTH(doorbell_val); in write_ipc_from_queue()
349 ipc_send_compl = ipc_link->ipc_send_compl; in write_ipc_from_queue()
350 ipc_send_compl_prm = ipc_link->ipc_send_compl_prm; in write_ipc_from_queue()
351 list_del_init(&ipc_link->link); in write_ipc_from_queue()
352 list_add(&ipc_link->link, &dev->wr_free_list); in write_ipc_from_queue()
353 spin_unlock_irqrestore(&dev->wr_processing_spinlock, flags); in write_ipc_from_queue()
366 * write_ipc_to_queue() - write ipc msg to Tx queue
374 * Tx-to-write list then try to send the first IPC waiting msg
389 return -EMSGSIZE; in write_ipc_to_queue()
391 spin_lock_irqsave(&dev->wr_processing_spinlock, flags); in write_ipc_to_queue()
392 if (list_empty(&dev->wr_free_list)) { in write_ipc_to_queue()
393 spin_unlock_irqrestore(&dev->wr_processing_spinlock, flags); in write_ipc_to_queue()
394 return -ENOMEM; in write_ipc_to_queue()
396 ipc_link = list_first_entry(&dev->wr_free_list, in write_ipc_to_queue()
398 list_del_init(&ipc_link->link); in write_ipc_to_queue()
400 ipc_link->ipc_send_compl = ipc_send_compl; in write_ipc_to_queue()
401 ipc_link->ipc_send_compl_prm = ipc_send_compl_prm; in write_ipc_to_queue()
402 ipc_link->length = length; in write_ipc_to_queue()
403 memcpy(ipc_link->inline_data, msg, length); in write_ipc_to_queue()
405 list_add_tail(&ipc_link->link, &dev->wr_processing_list); in write_ipc_to_queue()
406 spin_unlock_irqrestore(&dev->wr_processing_spinlock, flags); in write_ipc_to_queue()
414 * ipc_send_mng_msg() - Send management message
440 * timed_wait_for_timeout() - wait special event with timeout
463 ret = -EINVAL; in timed_wait_for_timeout()
471 timeout -= (timeinc - left_time); in timed_wait_for_timeout()
478 ret = -EBUSY; in timed_wait_for_timeout()
490 * ish_fw_reset_handler() - FW reset handler
506 spin_lock_irqsave(&dev->wr_processing_spinlock, flags); in ish_fw_reset_handler()
507 list_splice_init(&dev->wr_processing_list, &dev->wr_free_list); in ish_fw_reset_handler()
508 spin_unlock_irqrestore(&dev->wr_processing_spinlock, flags); in ish_fw_reset_handler()
519 return -EPIPE; in ish_fw_reset_handler()
522 * RESET_NOTIFY_ACK - FW will be checking for it in ish_fw_reset_handler()
537 dev_err(dev->devc, in ish_fw_reset_handler()
538 "[ishtp-ish]: completed reset, ISH is dead (FWSTS = %08X)\n", in ish_fw_reset_handler()
540 return -ENODEV; in ish_fw_reset_handler()
548 * fw_reset_work_fn() - FW reset worker function
559 /* ISH is ILUP & ISHTP-ready. Restart ISHTP */ in fw_reset_work_fn()
561 ishtp_dev->recvd_hw_ready = 1; in fw_reset_work_fn()
562 wake_up_interruptible(&ishtp_dev->wait_hw_ready); in fw_reset_work_fn()
568 dev_err(ishtp_dev->devc, "[ishtp-ish]: FW reset failed (%d)\n", in fw_reset_work_fn()
573 * _ish_sync_fw_clock() -Sync FW clock with the OS clock
576 * Sync FW and OS time
592 * recv_ipc() - Receive and process IPC management messages
611 if (dev->suspend_flag) { in recv_ipc()
612 dev->suspend_flag = 0; in recv_ipc()
613 wake_up_interruptible(&dev->suspend_wait); in recv_ipc()
615 if (dev->resume_flag) { in recv_ipc()
616 dev->resume_flag = 0; in recv_ipc()
617 wake_up_interruptible(&dev->resume_wait); in recv_ipc()
631 dev->recvd_hw_ready = 1; in recv_ipc()
632 wake_up_interruptible(&dev->wait_hw_ready); in recv_ipc()
638 * ish_irq_handler() - ISH IRQ handler
661 if (dev->dev_state == ISHTP_DEV_DISABLED) in ish_irq_handler()
666 dev_err(dev->devc, in ish_irq_handler()
667 "IPC hdr - bad length: %u; dropped\n", in ish_irq_handler()
685 ++dev->ipc_rx_cnt; in ish_irq_handler()
686 dev->ipc_rx_bytes_cnt += IPC_HEADER_GET_LENGTH(doorbell_val); in ish_irq_handler()
696 * ish_disable_dma() - disable dma communication between host and ISHFW
717 dev_err(dev->devc, in ish_disable_dma()
719 return -EBUSY; in ish_disable_dma()
726 * ish_wakeup() - wakeup ishfw from waiting-for-host state
730 * it wil wakeup FW from waiting-for-host state.
748 * _ish_hw_reset() - HW reset
757 struct pci_dev *pdev = dev->pdev; in _ish_hw_reset()
762 return -ENODEV; in _ish_hw_reset()
766 dev->dev_state = ISHTP_DEV_RESETTING; in _ish_hw_reset()
768 if (!pdev->pm_cap) { in _ish_hw_reset()
769 dev_err(&pdev->dev, "Can't reset - no PM caps\n"); in _ish_hw_reset()
770 return -EINVAL; in _ish_hw_reset()
775 dev_err(&pdev->dev, in _ish_hw_reset()
776 "Can't reset - stuck with DMA in-progress\n"); in _ish_hw_reset()
777 return -EBUSY; in _ish_hw_reset()
780 pci_read_config_word(pdev, pdev->pm_cap + PCI_PM_CTRL, &csr); in _ish_hw_reset()
784 pci_write_config_word(pdev, pdev->pm_cap + PCI_PM_CTRL, csr); in _ish_hw_reset()
786 mdelay(pdev->d3hot_delay); in _ish_hw_reset()
790 pci_write_config_word(pdev, pdev->pm_cap + PCI_PM_CTRL, csr); in _ish_hw_reset()
799 * _ish_ipc_reset() - IPC reset
821 dev->recvd_hw_ready = 0; in _ish_ipc_reset()
827 dev_err(dev->devc, "Failed to send IPC MNG_RESET_NOTIFY\n"); in _ish_ipc_reset()
831 wait_event_interruptible_timeout(dev->wait_hw_ready, in _ish_ipc_reset()
832 dev->recvd_hw_ready, 2 * HZ); in _ish_ipc_reset()
833 if (!dev->recvd_hw_ready) { in _ish_ipc_reset()
834 dev_err(dev->devc, "Timed out waiting for HW ready\n"); in _ish_ipc_reset()
835 rv = -ENODEV; in _ish_ipc_reset()
842 * ish_hw_start() -Start ISH HW
858 /* wait for FW-initiated reset flow */ in ish_hw_start()
859 if (!dev->recvd_hw_ready) in ish_hw_start()
860 wait_event_interruptible_timeout(dev->wait_hw_ready, in ish_hw_start()
861 dev->recvd_hw_ready, in ish_hw_start()
864 if (!dev->recvd_hw_ready) { in ish_hw_start()
865 dev_err(dev->devc, in ish_hw_start()
866 "[ishtp-ish]: Timed out waiting for FW-initiated reset\n"); in ish_hw_start()
867 return -ENODEV; in ish_hw_start()
874 * ish_ipc_get_header() -Get doorbell value
908 * Return: false - has cache snooping capability
909 * true - no cache snooping, need manually cache flush
913 return (dev->pdev->device == PCI_DEVICE_ID_INTEL_ISH_EHL_Ax || in _dma_no_cache_snooping()
914 dev->pdev->device == PCI_DEVICE_ID_INTEL_ISH_TGL_LP || in _dma_no_cache_snooping()
915 dev->pdev->device == PCI_DEVICE_ID_INTEL_ISH_TGL_H || in _dma_no_cache_snooping()
916 dev->pdev->device == PCI_DEVICE_ID_INTEL_ISH_ADL_S || in _dma_no_cache_snooping()
917 dev->pdev->device == PCI_DEVICE_ID_INTEL_ISH_ADL_P); in _dma_no_cache_snooping()
933 * ish_dev_init() -Initialize ISH devoce
946 dev = devm_kzalloc(&pdev->dev, in ish_dev_init()
952 dev->devc = &pdev->dev; in ish_dev_init()
955 init_waitqueue_head(&dev->wait_hw_ready); in ish_dev_init()
957 spin_lock_init(&dev->wr_processing_spinlock); in ish_dev_init()
960 INIT_LIST_HEAD(&dev->wr_processing_list); in ish_dev_init()
961 INIT_LIST_HEAD(&dev->wr_free_list); in ish_dev_init()
965 tx_buf = devm_kzalloc(&pdev->dev, in ish_dev_init()
971 * at all - although this shouldn't happen in ish_dev_init()
973 dev_err(dev->devc, in ish_dev_init()
974 "[ishtp-ish]: failure in Tx FIFO allocations (%d)\n", in ish_dev_init()
978 list_add_tail(&tx_buf->link, &dev->wr_free_list); in ish_dev_init()
981 ret = devm_work_autocancel(&pdev->dev, &fw_reset_work, fw_reset_work_fn); in ish_dev_init()
983 dev_err(dev->devc, "Failed to initialise FW reset work\n"); in ish_dev_init()
987 dev->ops = &ish_hw_ops; in ish_dev_init()
988 dev->mtu = IPC_PAYLOAD_SIZE - sizeof(struct ishtp_msg_hdr); in ish_dev_init()
993 * ish_device_disable() - Disable ISH device
1000 struct pci_dev *pdev = dev->pdev; in ish_device_disable()
1007 dev_err(&pdev->dev, in ish_device_disable()
1008 "Can't reset - stuck with DMA in-progress\n"); in ish_device_disable()
1015 dev->dev_state = ISHTP_DEV_DISABLED; in ish_device_disable()