From patchwork Thu Jan 20 07:43:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongqiang Niu X-Patchwork-Id: 12718416 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7B92C433F5 for ; Thu, 20 Jan 2022 08:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=O1f6oGIbxILt0VdT4fydoMWag2cOQl3mmNJ+HeRIohQ=; b=hnqEnE4STdy3i5 8wTz3gd3FTgZGSC8/TIZiJs3Kb728dABV7tFGkyDMnZoDDvzXtKvhcEYoTDBObi5Bg13CiUfjL0+z VZrtENMg6X1CLPlC2pLHhXcMeEq2pnYKhhHqlU3YAB/oDV2r8baOIRaYG22xLBOZCtNj9ZDUma5PZ jeIEI6Sfct8gXGC5hE2ajIyl0XelLStUyONyDo6+7wip2tJY+cTxYu4xCd3YNtOb7cq9s6b9Fh/79 Svjjo+ZAz0fOCuJ8e5wb1r34s4SWOXypzKIpUpXXq8JrufOwp2/1HGt0ZlcnZnMHPIzO3iXAUvLqp S6wQMFj833M1nnq0+/dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nASO1-009Xbg-1G; Thu, 20 Jan 2022 08:01:37 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAS6L-009Pds-CH; Thu, 20 Jan 2022 07:43:22 +0000 X-UUID: 7f6296824e764ec2a2f65e2c6586d0d2-20220120 X-UUID: 7f6296824e764ec2a2f65e2c6586d0d2-20220120 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1460628571; Thu, 20 Jan 2022 00:43:17 -0700 Received: from MTKMBS07N2.mediatek.inc (172.21.101.141) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 19 Jan 2022 23:43:16 -0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 20 Jan 2022 15:43:15 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 20 Jan 2022 15:43:14 +0800 From: Yongqiang Niu To: Chun-Kuang Hu CC: Rob Herring , Matthias Brugger , Philipp Zabel , "David Airlie" , Daniel Vetter , Jassi Brar , Yongqiang Niu , Fabien Parent , Dennis YC Hsieh , , , , , , , Hsin-Yi Wang , mtk18742 Subject: [PATCH v1, 1/1] soc: mediatek: cmdq: add cmdq_pkt_poll_addr function Date: Thu, 20 Jan 2022 15:43:11 +0800 Message-ID: <20220120074311.2243-2-yongqiang.niu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220120074311.2243-1-yongqiang.niu@mediatek.com> References: <20220120074311.2243-1-yongqiang.niu@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220119_234321_464369_8724B336 X-CRM114-Status: GOOD ( 12.70 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: mtk18742 add cmdq_pkt_poll_addr function in cmdq helper functions Signed-off-by: Yongqiang Niu --- drivers/soc/mediatek/mtk-cmdq-helper.c | 39 ++++++++++++++++++++++++ include/linux/mailbox/mtk-cmdq-mailbox.h | 1 + include/linux/soc/mediatek/mtk-cmdq.h | 2 ++ 3 files changed, 42 insertions(+) diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c index 3c8e4212d941..6c5cfb284140 100644 --- a/drivers/soc/mediatek/mtk-cmdq-helper.c +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c @@ -344,6 +344,45 @@ int cmdq_pkt_set_event(struct cmdq_pkt *pkt, u16 event) } EXPORT_SYMBOL(cmdq_pkt_set_event); +s32 cmdq_pkt_poll_addr(struct cmdq_pkt *pkt, u32 value, u32 addr, u32 mask, u8 reg_gpr) +{ + struct cmdq_instruction inst = { {0} }; + + s32 err; + + if (mask != 0xffffffff) { + inst.op = CMDQ_CODE_MASK; + inst.mask = ~mask; + err = cmdq_pkt_append_command(pkt, inst); + if (err != 0) + return err; + + addr = addr | 0x1; + } + + /* Move extra handle APB address to GPR */ + inst.op = CMDQ_CODE_MOVE; + inst.value = addr; + inst.sop = reg_gpr; + inst.dst_t = 1; + err = cmdq_pkt_append_command(pkt, inst); + if (err != 0) + pr_err("%s fail append command move addr to reg err:%d", + __func__, err); + + inst.op = CMDQ_CODE_POLL; + inst.value = value; + inst.sop = reg_gpr; + inst.dst_t = 1; + err = cmdq_pkt_append_command(pkt, inst); + if (err != 0) + pr_err("%s fail append command poll err:%d", + __func__, err); + + return err; +} +EXPORT_SYMBOL(cmdq_pkt_poll_addr); + int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value) { diff --git a/include/linux/mailbox/mtk-cmdq-mailbox.h b/include/linux/mailbox/mtk-cmdq-mailbox.h index 44365aab043c..a27329fd7c7f 100644 --- a/include/linux/mailbox/mtk-cmdq-mailbox.h +++ b/include/linux/mailbox/mtk-cmdq-mailbox.h @@ -54,6 +54,7 @@ */ enum cmdq_code { CMDQ_CODE_MASK = 0x02, + CMDQ_CODE_MOVE = 0x02, CMDQ_CODE_WRITE = 0x04, CMDQ_CODE_POLL = 0x08, CMDQ_CODE_JUMP = 0x10, diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h index ac6b5f3cba95..28dc5ce0ff03 100644 --- a/include/linux/soc/mediatek/mtk-cmdq.h +++ b/include/linux/soc/mediatek/mtk-cmdq.h @@ -280,4 +280,6 @@ int cmdq_pkt_finalize(struct cmdq_pkt *pkt); int cmdq_pkt_flush_async(struct cmdq_pkt *pkt, cmdq_async_flush_cb cb, void *data); +s32 cmdq_pkt_poll_addr(struct cmdq_pkt *pkt, u32 value, u32 addr, u32 mask, u8 reg_gpr); + #endif /* __MTK_CMDQ_H__ */