Lines Matching +full:always +full:- +full:wait +full:- +full:for +full:- +full:ack

1 // SPDX-License-Identifier: GPL-2.0
17 * scp_ipi_register() - register an ipi function
22 * @priv: private data for IPI handler
26 * Returns 0 if ipi registers successfully, -error on error.
34 return -EPROBE_DEFER; in scp_ipi_register()
37 return -EINVAL; in scp_ipi_register()
40 scp->ipi_desc[id].handler = handler; in scp_ipi_register()
41 scp->ipi_desc[id].priv = priv; in scp_ipi_register()
49 * scp_ipi_unregister() - unregister an ipi function
65 scp->ipi_desc[id].handler = NULL; in scp_ipi_unregister()
66 scp->ipi_desc[id].priv = NULL; in scp_ipi_unregister()
72 * scp_memcpy_aligned() - Copy src to dst, where dst is in SCP SRAM region.
78 * Since AP access of SCP SRAM don't support byte write, this always write a
90 i = 4 - (dst - ptr); in scp_memcpy_aligned()
92 memcpy((u8 *)&val + (4 - i), src, i); in scp_memcpy_aligned()
96 __iowrite32_copy(dst + i, src + i, (len - i) / 4); in scp_memcpy_aligned()
97 remain = (len - i) % 4; in scp_memcpy_aligned()
100 val = readl_relaxed(dst + len - remain); in scp_memcpy_aligned()
101 memcpy(&val, src + len - remain, remain); in scp_memcpy_aligned()
102 writel_relaxed(val, dst + len - remain); in scp_memcpy_aligned()
108 * scp_ipi_lock() - Lock before operations of an IPI ID
119 mutex_lock(&scp->ipi_desc[id].lock); in scp_ipi_lock()
124 * scp_ipi_lock() - Unlock after operations of an IPI ID
135 mutex_unlock(&scp->ipi_desc[id].lock); in scp_ipi_unlock()
140 * scp_ipi_send() - send data from AP to scp.
146 * @wait: number of msecs to wait for ack. 0 to skip waiting.
148 * This function is thread-safe. When this function returns,
153 * Returns 0 if sending data successfully, -error on error.
156 unsigned int wait) in scp_ipi_send() argument
158 struct mtk_share_obj __iomem *send_obj = scp->send_buf; in scp_ipi_send()
164 WARN_ON(len > sizeof(send_obj->share_buf)) || WARN_ON(!buf)) in scp_ipi_send()
165 return -EINVAL; in scp_ipi_send()
167 mutex_lock(&scp->send_lock); in scp_ipi_send()
169 ret = clk_prepare_enable(scp->clk); in scp_ipi_send()
171 dev_err(scp->dev, "failed to enable clock\n"); in scp_ipi_send()
175 /* Wait until SCP receives the last command */ in scp_ipi_send()
179 dev_err(scp->dev, "%s: IPI timeout!\n", __func__); in scp_ipi_send()
180 ret = -ETIMEDOUT; in scp_ipi_send()
183 } while (readl(scp->reg_base + scp->data->host_to_scp_reg)); in scp_ipi_send()
185 scp_memcpy_aligned(send_obj->share_buf, buf, len); in scp_ipi_send()
187 writel(len, &send_obj->len); in scp_ipi_send()
188 writel(id, &send_obj->id); in scp_ipi_send()
190 scp->ipi_id_ack[id] = false; in scp_ipi_send()
192 writel(scp->data->host_to_scp_int_bit, in scp_ipi_send()
193 scp->reg_base + scp->data->host_to_scp_reg); in scp_ipi_send()
195 if (wait) { in scp_ipi_send()
196 /* wait for SCP's ACK */ in scp_ipi_send()
197 timeout = msecs_to_jiffies(wait); in scp_ipi_send()
198 ret = wait_event_timeout(scp->ack_wq, in scp_ipi_send()
199 scp->ipi_id_ack[id], in scp_ipi_send()
201 scp->ipi_id_ack[id] = false; in scp_ipi_send()
202 if (WARN(!ret, "scp ipi %d ack time out !", id)) in scp_ipi_send()
203 ret = -EIO; in scp_ipi_send()
209 clk_disable_unprepare(scp->clk); in scp_ipi_send()
211 mutex_unlock(&scp->send_lock); in scp_ipi_send()