Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3769074ybl; Tue, 20 Aug 2019 01:53:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqywWYUN/RVsYKQFCozZTBxlrfrhkM7e2yNLDCRxlisYI1T3Es+1CwHLS2nGjNx2B9ZA/TD1 X-Received: by 2002:aa7:8f2e:: with SMTP id y14mr28972766pfr.113.1566291182582; Tue, 20 Aug 2019 01:53:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566291182; cv=none; d=google.com; s=arc-20160816; b=s70H68CpqzRhs6u2nEp6kvhjvP9h92heaOWgFTUkf5vh8x8Ote2xQR7ovFIj0FNMzl G9fW63sMYoQ/R5Z0FJJ8RiT/XWZ9UJ2OszuAvNA4foYAJbc6RmrCN2d6Bd3Bu0VzzXYu 1CfaKOxC2BY7kRAWWGM1ELNSFoZtPMxVrD3LXghwdsDmEc+e2Ccy/tP+wqnVH2MxcwRR olqafsATrJ4m+ymU2juebPrJz1Txw6PMPDekZvr1kNC/JZr77UTKC37qOFC30n0uiy7r Q6tiwkz+g8wi11GnhpT62R0Y+Qlc2WCMwhMW6GnU4bVw7cWDslRU8hkgcIl3MoZCDs0Z LMVg== 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=kUg6uWEg04fikZYQflcIZEjmHkjyUnrsTdMmut1BUd8=; b=XIY/9+20XTWkm+Rbzm9GTmyCw2OYGKwgteeQKRmDjtuteJ1RvsycF/qOULUxkUFPgN vVoILd7ZlNYTCWZntTOrDije2Cbaq0sZUN7yo3ni//zPgabAd0GvN5WuMaBRM4WtE9Do kaplkGT3Jgjlh+8dsr+UaOwiHQBiSUi03dfT44pcTy4LyAdcG2bdyyv2qDODAezYbQsI JQZI70/v+xGP2ZvTr1sUWWz8W4UxPD06+/aV6F1BY0D4qAntq9cGPI4xYpAIIhBu+hd5 DOiGaiNbY7ji4rcE8z4FZMHo5ajrAg9/A68pLTxiVrn6kX+/xZle/VYvKu6LOuY4CUQn F+DQ== 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 az8si8886773plb.34.2019.08.20.01.52.47; Tue, 20 Aug 2019 01:53:02 -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 S1729614AbfHTItn (ORCPT + 99 others); Tue, 20 Aug 2019 04:49:43 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:24816 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729436AbfHTItl (ORCPT ); Tue, 20 Aug 2019 04:49:41 -0400 X-UUID: ed8fc9b3a424476db56a04145c2f0cb1-20190820 X-UUID: ed8fc9b3a424476db56a04145c2f0cb1-20190820 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 2022715974; Tue, 20 Aug 2019 16:49:34 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 20 Aug 2019 16:49:33 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 20 Aug 2019 16:49:33 +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: [RESEND, PATCH v13 11/12] soc: mediatek: cmdq: add cmdq_dev_get_client_reg function Date: Tue, 20 Aug 2019 16:49:31 +0800 Message-ID: <20190820084932.22282-12-bibby.hsieh@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190820084932.22282-1-bibby.hsieh@mediatek.com> References: <20190820084932.22282-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 Reviewed-by: CK Hu --- 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 c53f8476c68d..80f75a1075b4 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..02ddd60b212f 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 client + * @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 parsing 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