From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x2272ly56BMA0qfbp0P8syUgAQ/LTntts7tPmvOAh04Uu6McWifx38V2CRk6dxhX0+wYHeBZD ARC-Seal: i=1; a=rsa-sha256; t=1518461158; cv=none; d=google.com; s=arc-20160816; b=Ph2ElT1fIVA7gqspe0t00kiCYkm5lqJdNpKMdQj99MEveR5ffxearZeZrDreD7pJex B0Ok5wHVgDRuW+Iizp7U8CQDy1Oi+ULMCu33pgUgavT6Agv0+SQCBpV0I+y9GKKDrFGf Y8dwpNi+hAxj20/lEYjhyDp5hvo/CphZiOFy+5hONFvR8MHlXawxH/PdqvL02VeIf0HP xamyRtBIMz+EXcYTgNhf3gXyVMTlKOV2oXLco/+WOwYgmhbW0jlq1yFJ+583o1ngerI2 OGEN7NwswzsHn1Jckwk7Oz6bSk9YpegK/QSNWTK4k3n0vZI9HrKdaHpe1FaofAFCXrd+ NLTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hv9xDMcIIbFU52VKTKnFCfEGRvHjw+JAEbCu35224NI=; b=kXECKbKL5m5sRD6m3rj8rc0c9PtES8GTRc7rxE5N69Zt0a2kUTeFcAgz0xtMhoyrQ0 D/Ppa+/yZCHvq2QxImvs4YUVQlrD17BCRdfttDO5hGniaBsSOCpKJhAiCg6OzSbLAy8w sc/47XdsDajRaff6J16b/bE5WxGQN1uGiS93+ABg0Rb/ZuFWKKvkqoXchzTv0KLaNPRL IJw3uJBeP7TpSKhNpz+M96fze3SC6gT5KTP/npa8eHj29ELtOdJ/Q8BG/zX5PmCCEHY5 tI+5FhMUmJyPGKdDFblMDtMSCaZqN//9ALEvrCaIaQ+TOzT35UBwS1zZ8rmOX694JQao x01A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of sudeep.holla@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=sudeep.holla@arm.com Authentication-Results: mx.google.com; spf=pass (google.com: domain of sudeep.holla@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=sudeep.holla@arm.com 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> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1592221928132277765?= X-GMAIL-MSGID: =?utf-8?q?1592221928132277765?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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(-) 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; } -- 2.7.4