From patchwork Mon Jul 8 15:47:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168676 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331087ilk; Mon, 8 Jul 2019 08:47:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqynhRdm27FYjedS183AiGgzX+kL5cXGvLnrl/X+Wwu/fYV6iltZsw5UKs/WSb+o8ZlqxU54 X-Received: by 2002:a63:2f44:: with SMTP id v65mr24204626pgv.185.1562600867938; Mon, 08 Jul 2019 08:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600867; cv=none; d=google.com; s=arc-20160816; b=eO1jI+qvx1UqwO6i57eSdl7nyneUFxqU4Iw6WTBwh6Xj4Zx6FJ63wcQGhZ9tra3SyH KmGJu3BSDUQZjthv5W+QZpiT93q1I2ICTzA0h4GeqaYrHail/6JJntqoSqmFpuoXtrc9 Xnm4NTs5UBU7/Wk2CEQX7vn1Uglu1+BxYHdIS/Gy8gdT8V4atbp30al5P1sWA6+sBci1 YW65pxEwu3BkIAyLCVbJzP4jiZtmdYMHLXB3gEeBL7iesTSo3nIE3Cwk21QqVbQrr6+O cABNyT2DMCLkTlxNIOn4gAR8P2SpeKf8E1JkpqlVVXBGe/pOHaCG9vgogdq/KynPfArS fPzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=H9WMx4jYdpUgwq31fAeuJYoGvXH+rA4Gg+NrFLHhsSw=; b=jKVNm58TGgEADaa3gg/IIpQ9CCzPBgn1zMDxBWcO9aoWU3H0IlDOrsmdMHdZ1KftbR yDsq1aDs/3p3Hv4fnAPbX5t5e9OT4IKOxlZwoRc4e8pCDlZtBP6VqmBGPUgLp/6JPQCm HILOazQgCPdC5n5jK7co3Wu/jpE8Lk06xHgDlqriMy2RB3mXeL8MJEmZqEnfdZiXO7Y2 OBgZJZ4wDSxNGsRAN/E5WjRbOBZKRmEmd3A4yxV5dJDxQwN6mdQdZbxsvuZ8kOqC47kR PIxcGdZ17mUbilSt9d1+zpvsEet8/7LleQx731FyhzY4ewPPpg7fAdUAt8awQAgIaSSO maxw== 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 f74si19378230pfa.57.2019.07.08.08.47.47; Mon, 08 Jul 2019 08:47:47 -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 S2391298AbfGHPrq (ORCPT + 30 others); Mon, 8 Jul 2019 11:47:46 -0400 Received: from foss.arm.com ([217.140.110.172]:52340 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391277AbfGHPro (ORCPT ); Mon, 8 Jul 2019 11:47:44 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C62471509; Mon, 8 Jul 2019 08:47:43 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C2DDF3F59C; Mon, 8 Jul 2019 08:47:42 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk Subject: [PATCH 02/11] firmware: arm_scmi: Segregate tx channel handling and prepare to add rx Date: Mon, 8 Jul 2019 16:47:21 +0100 Message-Id: <20190708154730.16643-3-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The transmit(Tx) channels are specified as the first entry and the receive(Rx) channels are the second entry as per the device tree bindings. Since we currently just support Tx, index 0 is hardcoded at all required callsites. In order to prepare for adding Rx support, let's remove those hardcoded index and add boolean parameter to identify Tx/Rx channels when setting them up. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 33 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 0bd2af0a008f..f7fb6d5bfc64 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -112,7 +112,7 @@ struct scmi_chan_info { * @version: SCMI revision information containing protocol version, * implementation version and (sub-)vendor identification. * @minfo: Message info - * @tx_idr: IDR object to map protocol id to channel info pointer + * @tx_idr: IDR object to map protocol id to Tx channel info pointer * @protocols_imp: List of protocols implemented, currently maximum of * MAX_PROTOCOLS_IMP elements allocated by the base protocol * @node: List head @@ -640,22 +640,26 @@ static int scmi_xfer_info_init(struct scmi_info *sinfo) return 0; } -static int scmi_mailbox_check(struct device_node *np) +static int scmi_mailbox_check(struct device_node *np, int idx) { - return of_parse_phandle_with_args(np, "mboxes", "#mbox-cells", 0, NULL); + return of_parse_phandle_with_args(np, "mboxes", "#mbox-cells", + idx, NULL); } -static inline int -scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, int prot_id) +static int scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, + int prot_id, bool tx) { - int ret; + int ret, idx; struct resource res; resource_size_t size; struct device_node *shmem, *np = dev->of_node; struct scmi_chan_info *cinfo; struct mbox_client *cl; - if (scmi_mailbox_check(np)) { + /* Transmit channel is first entry i.e. index 0 */ + idx = tx ? 0 : 1; + + if (scmi_mailbox_check(np, idx)) { cinfo = idr_find(&info->tx_idr, SCMI_PROTOCOL_BASE); goto idr_alloc; } @@ -669,11 +673,11 @@ scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, int prot_id) cl = &cinfo->cl; cl->dev = dev; cl->rx_callback = scmi_rx_callback; - cl->tx_prepare = scmi_tx_prepare; + cl->tx_prepare = tx ? scmi_tx_prepare : NULL; cl->tx_block = false; - cl->knows_txdone = true; + cl->knows_txdone = tx; - shmem = of_parse_phandle(np, "shmem", 0); + shmem = of_parse_phandle(np, "shmem", idx); ret = of_address_to_resource(shmem, 0, &res); of_node_put(shmem); if (ret) { @@ -688,8 +692,7 @@ scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, int prot_id) return -EADDRNOTAVAIL; } - /* Transmit channel is first entry i.e. index 0 */ - cinfo->chan = mbox_request_channel(cl, 0); + cinfo->chan = mbox_request_channel(cl, idx); if (IS_ERR(cinfo->chan)) { ret = PTR_ERR(cinfo->chan); if (ret != -EPROBE_DEFER) @@ -721,7 +724,7 @@ scmi_create_protocol_device(struct device_node *np, struct scmi_info *info, return; } - if (scmi_mbox_chan_setup(info, &sdev->dev, prot_id)) { + if (scmi_mbox_chan_setup(info, &sdev->dev, prot_id, true)) { dev_err(&sdev->dev, "failed to setup transport\n"); scmi_device_destroy(sdev); return; @@ -741,7 +744,7 @@ static int scmi_probe(struct platform_device *pdev) struct device_node *child, *np = dev->of_node; /* Only mailbox method supported, check for the presence of one */ - if (scmi_mailbox_check(np)) { + if (scmi_mailbox_check(np, 0)) { dev_err(dev, "no mailbox found in %pOF\n", np); return -EINVAL; } @@ -769,7 +772,7 @@ static int scmi_probe(struct platform_device *pdev) handle->dev = info->dev; handle->version = &info->version; - ret = scmi_mbox_chan_setup(info, dev, SCMI_PROTOCOL_BASE); + ret = scmi_mbox_chan_setup(info, dev, SCMI_PROTOCOL_BASE, true); if (ret) return ret;