From patchwork Fri Nov 3 14:47:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 117918 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp3401739edm; Fri, 3 Nov 2017 07:49:17 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Rrn8gPihDwiUXl3FtAuH7AnSrQXg9tW5DCftyoJqro9Mn47zqYcSn4YvkFfyHT0Ar3tSpT X-Received: by 10.159.204.139 with SMTP id t11mr7115374plo.121.1509720557102; Fri, 03 Nov 2017 07:49:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509720557; cv=none; d=google.com; s=arc-20160816; b=SHU+Ru3Watgn4y54WtyjA0CjkyNLntQaZ4f/cA/7nPcJ6rZh1UL697/tkmYPNXzA97 +Gkdb98aGaUIhxZUm7fkLjOjfovM0mEBO+HFkxIukDysEg/GOqTH2ky5alwKM4ONnSzq XA6z22+1Nsh2efv+knsbvhw4q08s6MJlZx62bUHEcxa55pRZR2js10p2iH6oHb5SffIT MrlOzZJEEadn54VNi3i7+jEyyDy73ohm9Stg6hiapVGnvZpisjoU/yenYlgXL/JSRU1+ xNjp9NIq6Ir7+U6Xyfje0D1CINmtIk0i3FEGO+/csK7hQ8U1mZLe6v9rjTwBh6K6jbA8 dx9A== 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=VZ59DcYJKiNVBmqtkuMi6MaJeIHnjJR36aD0CdRTKPE=; b=eusNy++aJpvqMCDzFHayZ6637ybIL6pOg8JJFKLtSlE+QxD1MTlpE5+3DSiCmuVxZw Q+yE3oT5terVHEgSBskZSqtVIwFhJpUIUXXCtlJZGOJKEvuBMpDHGV+OK+mqsSA885DQ 4vJFBVCXfMNsE8gEUEPhJ/uq53ep6gUpZ6gdlxl8J41lraDpduDZ3mgDTIiTsaZqXlP3 7NRhGCs5vuFbonn7uYFBUad5ac3xHdoeTo1y3C2WYebktaYsxt5S2yMMzeLJ4/EVQvL6 WGxJOWpIVVYKqEv9Hj8FFbWPG0NJ3r3NW9B4Mo9DQGp9d5mVjyL7W1NI4LBbMn/SmRLP v6Eg== 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 c17si6754367pfe.338.2017.11.03.07.49.16; Fri, 03 Nov 2017 07:49:17 -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 S1755717AbdKCOtP (ORCPT + 26 others); Fri, 3 Nov 2017 10:49:15 -0400 Received: from foss.arm.com ([217.140.101.70]:44356 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933559AbdKCOtM (ORCPT ); Fri, 3 Nov 2017 10:49:12 -0400 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 7AFAC199B; Fri, 3 Nov 2017 07:49:12 -0700 (PDT) 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 8BEF93F3DF; Fri, 3 Nov 2017 07:49:10 -0700 (PDT) From: Sudeep Holla To: ALKML , LKML , DTML Cc: Sudeep Holla , Roy Franz , Harb Abdulhamid , Nishanth Menon , Arnd Bergmann , Loc Ho , Ryan Harkin , Jassi Brar Subject: [PATCH v4 10/20] firmware: arm_scmi: probe and initialise all the supported protocols Date: Fri, 3 Nov 2017 14:47:47 +0000 Message-Id: <1509720477-18936-11-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509720477-18936-1-git-send-email-sudeep.holla@arm.com> References: <1509720477-18936-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 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 20d083be474c..11c18ac9816f 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -494,6 +494,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 * @@ -691,6 +706,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; @@ -698,7 +730,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)) { @@ -741,6 +773,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; }