Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3967206imb; Wed, 6 Mar 2019 01:52:30 -0800 (PST) X-Google-Smtp-Source: APXvYqyGR17I3pt8lnTX1A0ijjpLGWPC7qkmzLNi4xdZI94EMI0RlLKI2CjO37OafeR0woEHXHHL X-Received: by 2002:a63:d112:: with SMTP id k18mr5586414pgg.426.1551865950147; Wed, 06 Mar 2019 01:52:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551865950; cv=none; d=google.com; s=arc-20160816; b=P5S1XePGhgbskw3R1qL85Nfh/NXHt83+i00AaB28OM+e/b2vLTfesu2iPDrrcFLV6l SouCGgYSlUjGew20rtPSo9xOxPTmr9qOwtz56ox7BIcTTr0GbAyWztIs1VZdjt6wi+AE DupfUc5ud8sBKNpy8AtUyE762a1e1hl3wHR955tpSrdMwhnAotSkfQQTwv86GBf7LWGH GIFpoiUpBXckufL4IRrFsvVIjHLOF5bnMkAK6bkNfeoK+mU0pNa1GNvuav4Lf+GImOsq +A8vSyr10uFK1eXwAHuSIDSOnFJw8BLZoeuhNqr0b4or+QByfu185ACwRAYhPy34C4iS RlmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=7PeflrVtaBiIOpWiJbYIQZz+wXJJLj3K1U46QOuP6fg=; b=nSyZO7KfUarlSr8vo3gesBa/rJZu+QN7oeE0CSuTB6+1E/juX/nxKPXwMcMiDf6INh LrAz1bSCEZtBE1OXDf985+pw2tdJf2AXuTljdoEfTloX3f8QVMABJ+uJewdNWJd8p2HP uch+bB0UNc0HVY1yZ+sQc6/5K3Wu6zo5ZVRpk3WJTNgSqM1x4C5/6A2I8uwmZ6drafW/ WD4Cacf5JChMlqibbfXTbC0zfkbSL5CRrVzKECgi+Xpv2nggQ7BLQ58L4vmqtnDzW5We v39V6/jyF1LC2qGU4bbw5Y5g/UmNSdIK1YBemOFhaEWLr5KiaLVFx4UXnPCq6F/jIXRh alrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w15si1119247pgt.332.2019.03.06.01.52.15; Wed, 06 Mar 2019 01:52:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729982AbfCFJvR (ORCPT + 99 others); Wed, 6 Mar 2019 04:51:17 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:21977 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729907AbfCFJu4 (ORCPT ); Wed, 6 Mar 2019 04:50:56 -0500 X-UUID: 4b5a623bde3041d6a25c4a55648a83d2-20190306 X-UUID: 4b5a623bde3041d6a25c4a55648a83d2-20190306 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1261378590; Wed, 06 Mar 2019 17:50:38 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 6 Mar 2019 17:50:38 +0800 Received: from mtkslt302.mediatek.inc (10.21.14.115) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 6 Mar 2019 17:50:38 +0800 From: Bibby Hsieh To: Jassi Brar , Matthias Brugger , Rob Herring , CK HU CC: Daniel Kurtz , Sascha Hauer , , , , , , Sascha Hauer , Philipp Zabel , Nicolas Boichat , Bibby Hsieh , YT Shen , Daoyuan Huang , Jiaguang Zhang , Dennis-YC Hsieh , Houlong Wei , , , Frederic Chen Subject: [PATCH v2 08/10] soc: mediatek: cmdq: add polling function Date: Wed, 6 Mar 2019 17:50:33 +0800 Message-ID: <1551865835-50974-9-git-send-email-bibby.hsieh@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1551865835-50974-1-git-send-email-bibby.hsieh@mediatek.com> References: <1551865835-50974-1-git-send-email-bibby.hsieh@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org add polling function in cmdq helper functions Signed-off-by: Bibby Hsieh --- drivers/soc/mediatek/mtk-cmdq-helper.c | 21 +++++++++++++++++++++ include/linux/mailbox/mtk-cmdq-mailbox.h | 1 + include/linux/soc/mediatek/mtk-cmdq.h | 15 +++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c index d3873ab..71c167c 100644 --- a/drivers/soc/mediatek/mtk-cmdq-helper.c +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c @@ -231,6 +231,27 @@ int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 event) } EXPORT_SYMBOL(cmdq_pkt_clear_event); +int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys, + u16 offset, u32 value, u32 mask) +{ + int err; + + if (mask != 0xffffffff) { + err = cmdq_pkt_append_command(pkt, CMDQ_GET_ARG_C(~mask), + CMDQ_GET_ARG_B(~mask), + 0, 0, 0, 0, 0, CMDQ_CODE_MASK); + + if (err != 0) + return err; + } + offset = offset | 0x1; + + return cmdq_pkt_append_command(pkt, CMDQ_GET_ARG_C(value), + CMDQ_GET_ARG_B(value), + offset, subsys, 0, 0, 0, CMDQ_CODE_POLL); +} +EXPORT_SYMBOL(cmdq_pkt_poll); + static int cmdq_pkt_finalize(struct cmdq_pkt *pkt) { int err; diff --git a/include/linux/mailbox/mtk-cmdq-mailbox.h b/include/linux/mailbox/mtk-cmdq-mailbox.h index f21801d..1dfd5ed 100644 --- a/include/linux/mailbox/mtk-cmdq-mailbox.h +++ b/include/linux/mailbox/mtk-cmdq-mailbox.h @@ -46,6 +46,7 @@ enum cmdq_code { CMDQ_CODE_MASK = 0x02, CMDQ_CODE_WRITE = 0x04, + CMDQ_CODE_POLL = 0x08, CMDQ_CODE_JUMP = 0x10, CMDQ_CODE_WFE = 0x20, CMDQ_CODE_EOC = 0x40, diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h index 52f69c8..0651a0b 100644 --- a/include/linux/soc/mediatek/mtk-cmdq.h +++ b/include/linux/soc/mediatek/mtk-cmdq.h @@ -100,6 +100,21 @@ int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys, u16 offset, int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 event); /** + * cmdq_pkt_poll() - Append polling command to the CMDQ packet, ask GCE to + * execute an instruction that wait for a specified hardware + * register to check for the value. All GCE hardware + * threads will be blocked by this instruction. + * @pkt: the CMDQ packet + * @subsys: the CMDQ sub system code + * @offset: register offset from CMDQ sub system + * @value: the specified target register value + * @mask: the specified target register mask + * + * Return: 0 for success; else the error code is returned + */ +int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys, + u16 offset, u32 value, u32 mask); +/** * cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ * packet and call back at the end of done packet * @pkt: the CMDQ packet -- 1.9.1