Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5427401ybi; Wed, 12 Jun 2019 02:16:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIlC9vYWwwmmVAFaOX99aR0KM5QRf7S1mbV6hOiaGyiuMlQRf5Fqd4Gztdo0iUU7SpNAxg X-Received: by 2002:a17:90a:1c17:: with SMTP id s23mr23262637pjs.108.1560331004790; Wed, 12 Jun 2019 02:16:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560331004; cv=none; d=google.com; s=arc-20160816; b=avkpDd+e1VAzFV3WfFs7kjIQsrjNOTBRJVWr2WoicMjxng7giczazJjcRN09iOFSEE Pqn2WX008qT14lRpbLQ5nGA4zLgvCFX/I5ohdYUvbIAYqntwI7BBVnEWyTuWR6hUtKxK M0skNbi2LfUfxVKSWn85o7Ig3t7phuj+1A1YmOh1+31b04BD/lbvCf6RtZjTut67NvqX KZwOITa4CDSsphsvTvHHBkPTlao+Y1HmD2a7qFwyADNoJ9D8VBCxRuj8so8Y0MWrTq5y uBEDzeTfwmVN/vi4XNa/tK7XESeaCBnfxniAuMq8QK21qaAT1wde3E5C9rVCxarQdcaq lIGA== 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=v0vH+d2x/Ycu5Tkkp1XbNLPJ+R3ZUgjSMb7qEgAQ+WE=; b=BLF11Mc2Td0oWgop4DWoByE6+3UCwQOjqdQSBAiOtsMZuFOpAx65QLrZ4DZ0RQ8mGM SKkPeorv6ng5YKZa/CXlTDuPUQUozSW4fY4Cu/biOuaophI1k6N1ns7AaH+SWqQi4kY2 cgtfht3kLawA1MR87FP5cDncFfNkF5K/Yr3j54mRcZAxzeNCqr5E9JqQfkRO/4q3bEBR FtSQ29ipXsB31D5qJygZiqsgMKwBE1RnokI/qEn2ALlBuG/5lsA6ldGXxDJll76d0U5w DtoitKuvO/UhUq2e3uaNxM6lxz5twbgaKsgRqYBufytTfizG0NhLTXT4LfvJU4l83SRc //bg== 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 h1si14640033pgv.67.2019.06.12.02.16.28; Wed, 12 Jun 2019 02:16:44 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731894AbfFLIys (ORCPT + 99 others); Wed, 12 Jun 2019 04:54:48 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:43578 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1731714AbfFLIyA (ORCPT ); Wed, 12 Jun 2019 04:54:00 -0400 X-UUID: c499d211544b4df8b145707515ae4e0a-20190612 X-UUID: c499d211544b4df8b145707515ae4e0a-20190612 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1024068181; Wed, 12 Jun 2019 16:53:54 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 12 Jun 2019 16:53:53 +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; Wed, 12 Jun 2019 16:53:53 +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 v8 11/12] soc: mediatek: cmdq: add cmdq_dev_get_client_reg function Date: Wed, 12 Jun 2019 16:53:48 +0800 Message-ID: <20190612085349.21243-12-bibby.hsieh@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190612085349.21243-1-bibby.hsieh@mediatek.com> References: <20190612085349.21243-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 | 24 ++++++++++++++++++++++++ include/linux/soc/mediatek/mtk-cmdq.h | 20 ++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c index 70ad4d806fac..fac4d33fd520 100644 --- a/drivers/soc/mediatek/mtk-cmdq-helper.c +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c @@ -27,6 +27,30 @@ 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; + + if (!client_reg) + return -EINVAL; + + if (of_parse_phandle_with_args(dev->of_node, "mediatek,gce-client-reg", + "#subsys-cells", idx, &spec)) { + dev_err(dev, "can't parse gce-client-reg property (%d)", idx); + + return -EINVAL; + } + + 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..2e2a2274c231 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,18 @@ 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