Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2158824ybl; Sun, 18 Aug 2019 19:56:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOVx7HakKUhchXif+OBBTYYW+h4L7OgKw6xZUDJmD/YSpMqdp4zEtPO4TEhjRfhthbkhr+ X-Received: by 2002:a65:6546:: with SMTP id a6mr18574623pgw.220.1566183375781; Sun, 18 Aug 2019 19:56:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566183375; cv=none; d=google.com; s=arc-20160816; b=jilYM0UfojjMUcRQMZH4ROnc5Iir+kx2p0UCoRmp3pD22OKB4A9PnkgWfBytyahJh5 21SpoU604Yb6w6+RBSV6gHj4FSySCsIVKyPW+btEzkoP6mfaSMgjJDtLW+XR+fLaLHDI SlYt9YDCaw8dSlOjFp8N8hZu0fH3Pp7bCff9g6nvHsBDLsz8O2NsuEWQ31q/TUu6Pnuq YnaihEJlqsY773W/kRG6lDYrV6gTluKk9XkeyUE14VQdiq8Li6nfhpemRX6m4pteJKif x14fe7+3ex/CvT1Yx3YYDsD2nM391cPKO8rMe1STFfpILcfgLKS2hT1NL8sp+fU//hpD c7vQ== 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=s3dLn2QzJPBI+6CLHt7TnYKh70CU5XhGvpilWepaPRk=; b=T1tZK+swwqSwfjz796Bose28uqP49VAo0hRRkKE23fSEU7Ku9DzYiCICZM8tzN2a9R Z1wJ315y0qRXELMK1bsjIjjWEr3R+fz98F69x8IdkiyTDLAXoJ7TLyMxrPfR5eCFIIAS fKnQ0DwIhnp8hhoxoJL2LLeHM1jRrnautjP7oR69x/m2iY3vQRPcrTZKX2a7GtU/0KoK EAEdlgQ9O8Zz61TNezWXB3hXDhRnNUSMzJPjFdHrH9e4JGkOLmaBcm1ZhqVHE5JFWZqm y+1pPOWseHnSLLN47R2PsC/WARfFNABavfZgIJOPAPlNOQNBnT1DcLTHaf6ZI8B3vPK4 1KXg== 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 o61si9197354pld.21.2019.08.18.19.56.01; Sun, 18 Aug 2019 19:56:15 -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 S1726741AbfHSCyp (ORCPT + 99 others); Sun, 18 Aug 2019 22:54:45 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:65072 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726491AbfHSCyN (ORCPT ); Sun, 18 Aug 2019 22:54:13 -0400 X-UUID: 8c53a125a8544c4781630822894ae460-20190819 X-UUID: 8c53a125a8544c4781630822894ae460-20190819 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 1063635644; Mon, 19 Aug 2019 10:54:03 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 19 Aug 2019 10:54:03 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 19 Aug 2019 10:54:03 +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 v12 11/12] soc: mediatek: cmdq: add cmdq_dev_get_client_reg function Date: Mon, 19 Aug 2019 10:53:58 +0800 Message-ID: <20190819025359.11381-12-bibby.hsieh@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190819025359.11381-1-bibby.hsieh@mediatek.com> References: <20190819025359.11381-1-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 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 340a92a254e5..1bed07362b7a 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 = (u8)spec.args[0]; + client_reg->offset = (u16)spec.args[1]; + client_reg->size = (u16)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..6215d4fc4ba3 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; @@ -24,6 +30,21 @@ struct cmdq_client { u32 timeout_ms; /* in unit of microsecond */ }; +/** + * 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); + /** * cmdq_mbox_create() - create CMDQ mailbox client and channel * @dev: device of CMDQ mailbox client -- 2.18.0