Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4355910imu; Mon, 28 Jan 2019 23:32:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN5p5jpx81kisX7N1kBYoL9Hx6xExU0jWm/mt/a+N2fiZ9ZSqeO9cNBgYHKKtuajUlYDXXT5 X-Received: by 2002:a62:3006:: with SMTP id w6mr25312688pfw.258.1548747166271; Mon, 28 Jan 2019 23:32:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548747166; cv=none; d=google.com; s=arc-20160816; b=Gyk7QC15MNjq896bkbhrhVAXZRz5h7rsYFeaTdF9lzK7VZmZ6gX2jlMZ+JnKyA2Yoj nAYlNOQZIR5QbXDoZKGvmGteJCeu9L+3Kd/ETI5RZs+9UVIcb1BwR3Eoh/vGJ0+k45iq nTW8aXbpxfeE36vqknKWvl6fAKFjepeeGL8dsrkEGukwbWaA6DluzP5U0dMOVEfNogou E3YMmwUBaO3OySwmsVtt1yJthz1TJKekq8MCe0CskuY5LLvzGjQsDWwQ6wm966SZVOB+ u2xJp7hh61xubHlYLwLCKWz7TKZROjyr2TrjxlWt6IWEb6p/Fu7JflPxuIpp2Xq0T/5/ cGGw== 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=CiRuKo8kxSdzaRwQOxVB75aIo+mus0DHL4bSzxwYQj0=; b=ak01p6zaWvY0kIXAKteT2F1H+4FNEpq5MujlNj2TDymV4YC81HYsXQEGKnPtgLJuqJ jy2Ar+X8dz73Y0z5n8rmnVgTzli/7aTZnHX2ftcZNg+6D0kiY7xrx0yILxrhGuOhwV/e +TcWwvXJzCQh1ZJgNKMC+izG9rFHAXJOFFv7YA2PqxO75Yk85Zx50Z1CwyLoTJOstTQD FjvnW3c29gwmbQ+DSNQcZPdZPVrpWx4RSOYa9TUK7pt/9qg1DslwYmeU8KsdSouTaNnA Gq5SC10PRt3ny1qvnU14iQ1WmjZ9s128XdwtocKgQ/ztc9iwvgiXcqdSiU9SZ0kOcq0n L1UQ== 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 66si16620428plc.125.2019.01.28.23.32.29; Mon, 28 Jan 2019 23:32:46 -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 S1726865AbfA2HcU (ORCPT + 99 others); Tue, 29 Jan 2019 02:32:20 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:8423 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725730AbfA2HcU (ORCPT ); Tue, 29 Jan 2019 02:32:20 -0500 X-UUID: cbdd44d0f7ef4090804e2a5a442cb45c-20190129 X-UUID: cbdd44d0f7ef4090804e2a5a442cb45c-20190129 Received: from mtkmrs01.mediatek.inc [(172.21.131.159)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 2143939328; Tue, 29 Jan 2019 15:32:13 +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 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 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 Content-Type: text/plain X-TM-SNTS-SMTP: 5CABCEE1B16ABE4A2AC62D473E6598E5333E263EFBD4220D2931816D65A199232000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 1.9.1