From patchwork Mon Feb 12 18:45:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 128160 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3488082ljc; Mon, 12 Feb 2018 10:50:00 -0800 (PST) X-Google-Smtp-Source: AH8x225fnjza/TB2nJ+tnTl2pIp1bewn4Z+rMb2z3Twau4grfmWQ8ngQRKvtZuZH4IJulc8hzb6P X-Received: by 10.98.152.208 with SMTP id d77mr12512308pfk.108.1518461400835; Mon, 12 Feb 2018 10:50:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518461400; cv=none; d=google.com; s=arc-20160816; b=YuiGMwxRi1VVE7Deug4US8NjQMurKTk+aXK8nvjUdZKuRdekIpOkmUMa/M3G0cXl8y GN28De673au4X3BBzq3Fqsm7HXTPehxHJDPSxoQey4COQahhQf22g1xasRtLTF5rnL/f yheApTSmPxewl1PWFMDoRWK3Wlrlz4og9EbSn6cQOtAaOu7v5eHfA2l1xFNHuw+U2Stz uFJYS+/hU6Jw+zaMoHzWJTpJWzPovOFMpyD+kFzlv6wAgom75IWFYi7dXItCweAL2CUm JMSKo+EwAKd59qeYuDsVjYlouW3MScyDrZHoSE9uWpAemmpjKLLTS5642n7irfB1iJcg Xt5w== 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:arc-authentication-results; bh=hv9xDMcIIbFU52VKTKnFCfEGRvHjw+JAEbCu35224NI=; b=DhpEBoE9+bdY344aqfrE52MjFJ2MTftu7Oh9NI1RH8ib5GkvZHnN8/xNxHRNbKVlM/ yMe6MJPB3VclOuqBhnNhHbgKnJ89xtB3vxAFM58tcyPwTrkA5j7pDh6btos92ucknCfH u8BuwGl11QE3rs6ytamDxjxOUDJcFQomiRVU4G9KhrypEsT7bnIACGc3J1/qF7gOG++3 5SS5BJkG+PyomuoQ+ePjLO604AQeUVrjBsmv2PshlCvCpJkx3SDYLpkxNuU8fJ60PLBw zxaCcj2DBPt9kB5Rt6e4kSBH/4UsurLilSHB0So1DFAIMZnGl9fsL8elAR/xVu9suOq0 HgnQ== 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 t27si1003621pfe.283.2018.02.12.10.50.00; Mon, 12 Feb 2018 10:50:00 -0800 (PST) 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 S1754170AbeBLSt5 (ORCPT + 26 others); Mon, 12 Feb 2018 13:49:57 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47212 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753836AbeBLSp6 (ORCPT ); Mon, 12 Feb 2018 13:45:58 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7EEDF165C; Mon, 12 Feb 2018 10:45:58 -0800 (PST) Received: from e107155-lin.cambridge.arm.com (e107155-lin.cambridge.arm.com [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 298383F24D; Mon, 12 Feb 2018 10:45:57 -0800 (PST) From: Sudeep Holla To: ALKML , LKML , DTML Cc: Sudeep Holla , Greg Kroah-Hartman , Arnd Bergmann , Alexey Klimov Subject: [PATCH v5 10/20] firmware: arm_scmi: probe and initialise all the supported protocols Date: Mon, 12 Feb 2018 18:45:14 +0000 Message-Id: <1518461124-17371-11-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518461124-17371-1-git-send-email-sudeep.holla@arm.com> References: <1518461124-17371-1-git-send-email-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we have basic support for all the protocols in the specification, let's probe them individually and initialise them. Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 51 +++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 0ceff82f6f59..939ef626bfdd 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -477,6 +477,21 @@ void scmi_setup_protocol_implemented(const struct scmi_handle *handle, info->protocols_imp = prot_imp; } +static bool +scmi_is_protocol_implemented(const struct scmi_handle *handle, u8 prot_id) +{ + int i; + struct scmi_info *info = handle_to_scmi_info(handle); + + if (!info->protocols_imp) + return false; + + for (i = 0; i < MAX_PROTOCOLS_IMP; i++) + if (info->protocols_imp[i] == prot_id) + return true; + return false; +} + /** * scmi_handle_get() - Get the SCMI handle for a device * @@ -672,6 +687,23 @@ static inline int scmi_mbox_chan_setup(struct scmi_info *info) return 0; } +static inline void +scmi_create_protocol_device(struct device_node *np, struct scmi_info *info, + int prot_id) +{ + struct scmi_device *sdev; + + sdev = scmi_device_create(np, info->dev, prot_id); + if (!sdev) { + dev_err(info->dev, "failed to create %d protocol device\n", + prot_id); + return; + } + + /* setup handle now as the transport is ready */ + scmi_set_handle(sdev); +} + static int scmi_probe(struct platform_device *pdev) { int ret; @@ -679,7 +711,7 @@ static int scmi_probe(struct platform_device *pdev) const struct scmi_desc *desc; struct scmi_info *info; struct device *dev = &pdev->dev; - struct device_node *np = dev->of_node; + struct device_node *child, *np = dev->of_node; /* Only mailbox method supported, check for the presence of one */ if (scmi_mailbox_check(np)) { @@ -722,6 +754,23 @@ static int scmi_probe(struct platform_device *pdev) list_add_tail(&info->node, &scmi_list); mutex_unlock(&scmi_list_mutex); + for_each_available_child_of_node(np, child) { + u32 prot_id; + + if (of_property_read_u32(child, "reg", &prot_id)) + continue; + + prot_id &= MSG_PROTOCOL_ID_MASK; + + if (!scmi_is_protocol_implemented(handle, prot_id)) { + dev_err(dev, "SCMI protocol %d not implemented\n", + prot_id); + continue; + } + + scmi_create_protocol_device(child, info, prot_id); + } + return 0; }