From patchwork Tue Jan 29 07:32:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bibby Hsieh X-Patchwork-Id: 10785607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 91A9F1390 for ; Tue, 29 Jan 2019 07:34:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C9442A6AF for ; Tue, 29 Jan 2019 07:34:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 709F62A738; Tue, 29 Jan 2019 07:34:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 01D382A6AF for ; Tue, 29 Jan 2019 07:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W5AMpaemhLtKwYAFCDReS2dHeEXEzsiTA6Uyew5BDJc=; b=EgQTIzSRME15O+ P6GD4DVH+t9TTaGH9YLqw7VfESVOZf8fnhHxggewwpIAOQEKXWU54W4bFe8XXjFZFm71VCBQ6+31f NcbbIK3pmi6KpUcg4JkgmTDVjwmUCuZ4W0L6GE66b938u1d3vyilFRykAOdkvO70FkAuLwZZQqcSb ny879CrpqGG7aMG0VdsctNKWC8VvnAbMW2KTQ8u2W3yTOFuP2biN/2rOidofiL7/ZEdJN9O1cI2Az acBeiIr+l0yzD7oulwInIkbuN4vbKQ/0S/2ximFVT0+OBtG+q7ebgb/XFRPCaSvhcRJhxZzCMnrxP sDxIoi68yLjir9ar4mAg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1goNuo-0006iN-Sg; Tue, 29 Jan 2019 07:34:38 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1goNtO-00050M-ET; Tue, 29 Jan 2019 07:33:21 +0000 X-UUID: 2f1138a1d0644f9b95c073215585d24b-20190128 X-UUID: 2f1138a1d0644f9b95c073215585d24b-20190128 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 1945524770; Mon, 28 Jan 2019 23:32:21 -0800 Received: from MTKMBS02N2.mediatek.inc (172.21.101.101) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 28 Jan 2019 23:32:21 -0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 29 Jan 2019 15:32:12 +0800 Received: from mtkslt302.mediatek.inc (10.21.14.115) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 29 Jan 2019 15:32:12 +0800 From: Bibby Hsieh To: Jassi Brar , Matthias Brugger , Rob Herring , CK HU Subject: [PATCH 09/10] soc: mediatek: change the argument of write and write_mask API Date: Tue, 29 Jan 2019 15:32:06 +0800 Message-ID: <1548747128-60136-10-git-send-email-bibby.hsieh@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1548747128-60136-1-git-send-email-bibby.hsieh@mediatek.com> References: <1548747128-60136-1-git-send-email-bibby.hsieh@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 5CABCEE1B16ABE4A2AC62D473E6598E5333E263EFBD4220D2931816D65A199232000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190128_233310_770327_696FB15D X-CRM114-Status: GOOD ( 13.11 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Nicolas Boichat , Philipp Zabel , srv_heupstream@mediatek.com, Daoyuan Huang , Sascha Hauer , linux-kernel@vger.kernel.org, Dennis-YC Hsieh , kendrick.hsu@mediatek.com, linux-mediatek@lists.infradead.org, Houlong Wei , Sascha Hauer , Frederic Chen , Jiaguang Zhang , Bibby Hsieh , linux-arm-kernel@lists.infradead.org, ginny.chen@mediatek.com Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In order to enhance the convienience of client usage, we change the input argument from subsys and offset to struct cmdq_base and dma_addr_t. Signed-off-by: Bibby Hsieh --- drivers/soc/mediatek/mtk-cmdq-helper.c | 24 +++++++++++++++++------- include/linux/soc/mediatek/mtk-cmdq.h | 16 ++++++++-------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c index 923a815..34ae712 100644 --- a/drivers/soc/mediatek/mtk-cmdq-helper.c +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c @@ -238,8 +238,13 @@ static int cmdq_pkt_append_command(struct cmdq_pkt *pkt, s16 arg_c, s16 arg_b, return 0; } -int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value) +int cmdq_pkt_write(struct cmdq_pkt *pkt, struct cmdq_base *clt_base, + dma_addr_t addr, u32 value) { + const u32 base = (addr >> 32) ? 0 : addr & 0xFFFF0000; + u8 subsys = cmdq_subsys_base_to_id(clt_base, base); + s16 offset = addr & 0x0000FFFF; + return cmdq_pkt_append_command(pkt, CMDQ_GET_ARG_C(value), CMDQ_GET_ARG_B(value), offset, subsys, CMDQ_IMMEDIATE_VALUE, @@ -248,21 +253,26 @@ int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value) } EXPORT_SYMBOL(cmdq_pkt_write); -int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys, u16 offset, - u32 value, u32 mask) +int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, struct cmdq_base *clt_base, + dma_addr_t addr, u32 value, u32 mask) { - u32 offset_mask = offset; + const u32 base = (addr >> 32) ? 0 : addr & 0xFFFF0000; + u8 subsys = cmdq_subsys_base_to_id(clt_base, base); + s16 offset = addr & 0x0000FFFF; int err = 0; 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); - offset_mask |= CMDQ_WRITE_ENABLE_MASK; + offset |= CMDQ_WRITE_ENABLE_MASK; } - err |= cmdq_pkt_write(pkt, subsys, offset_mask, value); - return err; + return cmdq_pkt_append_command(pkt, CMDQ_GET_ARG_C(value), + CMDQ_GET_ARG_B(value), offset, subsys, + CMDQ_IMMEDIATE_VALUE, + CMDQ_IMMEDIATE_VALUE, + CMDQ_IMMEDIATE_VALUE, CMDQ_CODE_WRITE); } EXPORT_SYMBOL(cmdq_pkt_write_mask); diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h index e4d1876..230bc2b 100644 --- a/include/linux/soc/mediatek/mtk-cmdq.h +++ b/include/linux/soc/mediatek/mtk-cmdq.h @@ -70,26 +70,26 @@ struct cmdq_client *cmdq_mbox_create(struct device *dev, int index, /** * cmdq_pkt_write() - append write command to the CMDQ packet * @pkt: the CMDQ packet - * @subsys: the CMDQ sub system code - * @offset: register offset from CMDQ sub system + * @cmdq_base: the CMDQ sub system code and base address + * @addr: register address * @value: the specified target register value * * Return: 0 for success; else the error code is returned */ -int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value); - +int cmdq_pkt_write(struct cmdq_pkt *pkt, struct cmdq_base *clt_base, + dma_addr_t addr, u32 value); /** * cmdq_pkt_write_mask() - append write command with mask to the CMDQ packet * @pkt: the CMDQ packet - * @subsys: the CMDQ sub system code - * @offset: register offset from CMDQ sub system + * @cmdq_base: the CMDQ sub system code and base address + * @addr: register address * @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_write_mask(struct cmdq_pkt *pkt, u8 subsys, u16 offset, - u32 value, u32 mask); +int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, struct cmdq_base *clt_base, + dma_addr_t addr, u32 value, u32 mask); /** * cmdq_pkt_wfe() - append wait for event command to the CMDQ packet