Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3059326ybi; Mon, 29 Jul 2019 00:03:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwnWuDgAty+6ym+7w5COG+1aBhpkMJw1tHapMr/FPiHoMnKRhbhG0U6JQpv053SQn9IhAc X-Received: by 2002:a65:4044:: with SMTP id h4mr102916111pgp.164.1564383819367; Mon, 29 Jul 2019 00:03:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564383819; cv=none; d=google.com; s=arc-20160816; b=s2NtKaBNjZjtZFi9U14803TI0HnJcucnShvdpJasuMxQrR5vGHBmlDJA4EYGH3c0VG GodA+Zv2w+jTh/uGdT8Q5qOwiBGX1dvv6GDJ7IKquLj16hXOLMlnpikmcSMLv7tHgcaj cMysSSuoqQbRj02gx1GR3gpyyZDcaFg23rd3k+gyEey94Iyb3ovaSgtxERERXFeemG4T D/FNlRXJL/51rLb8qhfDeIc+NmeNfC9+KfDKXVSk3AO83GxbASQdBRhzTeem8QIFRFoa nQOhU3CzN9t7n8IYEcGiOsNSvnNu9IyqDs12ZMvQZx4mbGNPdcAAFXPeoFUGdj4xHxUO Zk3A== 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=lBAwzh+NoXdH0QFRJ9NHSgWAjXMLlyxjY+TzqADiLzk=; b=P2VPGLQC9hpToVPmyOg49U3q+P+jSm8L231m4nyvGnanh6WOCHwScNpXTkK4vz275W bnjTEjZM9EDVK1E6LCjtLxBAaxhq/MarKp/VF0qMDGQZ7a1aT81kxpfbzcb7GCLGBic0 hV2wWLcKD75LQum5TcXVqLqstOgoSliblQAdF+D0p0txpqFRFbJG2yWrvUB9WGyNhwh2 W9eTE7b/ZRwetkV/Q0sZkMefomb6MFXNKn42yUQE7jrtkxIc+Ka52nCOGXs77ojgi5Y2 LyzHaIh7qjn0LiziC7XOcFqwdoPRn3Y5Lz0qle0DFEX+7q7dTr9f1NSZFYM2Bjk6THwv RP7A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c8si27714994pfo.42.2019.07.29.00.03.24; Mon, 29 Jul 2019 00:03:39 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727263AbfG2HB1 (ORCPT + 99 others); Mon, 29 Jul 2019 03:01:27 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:16223 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726715AbfG2HBV (ORCPT ); Mon, 29 Jul 2019 03:01:21 -0400 X-UUID: 6df50625263c4eea9f69bdd702ec6db5-20190729 X-UUID: 6df50625263c4eea9f69bdd702ec6db5-20190729 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 79567011; Mon, 29 Jul 2019 15:01:10 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 29 Jul 2019 15:01:10 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 29 Jul 2019 15:01:10 +0800 From: Bibby Hsieh To: Jassi Brar , Matthias Brugger , Rob Herring , CK HU CC: Daniel Kurtz , Sascha Hauer , , , , , , Sascha Hauer , Philipp Zabel , Nicolas Boichat , YT Shen , Daoyuan Huang , Jiaguang Zhang , Dennis-YC Hsieh , Houlong Wei , , Bibby Hsieh Subject: [PATCH v11 11/12] soc: mediatek: cmdq: add cmdq_dev_get_client_reg function Date: Mon, 29 Jul 2019 15:01:05 +0800 Message-ID: <20190729070106.9332-12-bibby.hsieh@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190729070106.9332-1-bibby.hsieh@mediatek.com> References: <20190729070106.9332-1-bibby.hsieh@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: CB56927D4CC28A63525F028F4DC4F07DFE94C5F00B93375D6BEF3C19DE4AB2A22000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org GCE cannot know the register base address, this function can help cmdq client to get the cmdq_client_reg structure. Signed-off-by: Bibby Hsieh --- drivers/soc/mediatek/mtk-cmdq-helper.c | 29 ++++++++++++++++++++++++++ include/linux/soc/mediatek/mtk-cmdq.h | 21 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c index 70ad4d806fac..9695b75cfc89 100644 --- a/drivers/soc/mediatek/mtk-cmdq-helper.c +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c @@ -27,6 +27,35 @@ struct cmdq_instruction { u8 op; }; +int cmdq_dev_get_client_reg(struct device *dev, + struct cmdq_client_reg *client_reg, int idx) +{ + struct of_phandle_args spec; + int err; + + if (!client_reg) + return -ENOENT; + + err = of_parse_phandle_with_fixed_args(dev->of_node, + "mediatek,gce-client-reg", + 3, idx, &spec); + if (err < 0) { + dev_err(dev, + "error %d can't parse gce-client-reg property (%d)", + err, idx); + + return err; + } + + client_reg->subsys = spec.args[0]; + client_reg->offset = spec.args[1]; + client_reg->size = spec.args[2]; + of_node_put(spec.np); + + return 0; +} +EXPORT_SYMBOL(cmdq_dev_get_client_reg); + static void cmdq_client_timeout(struct timer_list *t) { struct cmdq_client *client = from_timer(client, t, timer); diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h index a345870a6d10..be402c4c740e 100644 --- a/include/linux/soc/mediatek/mtk-cmdq.h +++ b/include/linux/soc/mediatek/mtk-cmdq.h @@ -15,6 +15,12 @@ struct cmdq_pkt; +struct cmdq_client_reg { + u8 subsys; + u16 offset; + u16 size; +}; + struct cmdq_client { spinlock_t lock; u32 pkt_cnt; @@ -142,4 +148,19 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt, cmdq_async_flush_cb cb, */ int cmdq_pkt_flush(struct cmdq_pkt *pkt); +/** + * cmdq_dev_get_client_reg() - parse cmdq client reg from the device + * node of CMDQ client + * @dev: device of CMDQ mailbox clienti + * @client_reg: CMDQ client reg pointer + * @idx: the index of desired reg + * + * Return: 0 for success; else the error code is returned + * + * Help CMDQ client pasing the cmdq client reg + * from the device node of CMDQ client. + */ +int cmdq_dev_get_client_reg(struct device *dev, + struct cmdq_client_reg *client_reg, int idx); + #endif /* __MTK_CMDQ_H__ */ -- 2.18.0