From patchwork Tue May 11 00:20:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Hilber X-Patchwork-Id: 12250381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E856C433ED for ; Tue, 11 May 2021 10:02:00 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E308761352 for ; Tue, 11 May 2021 10:01:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E308761352 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=opensynergy.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YJt/SWQqIRwuFXG5qPy8ZHwtf4V4OLKsHeoJYfXYGuo=; b=qzH8y2WnCGFHeHr5oEAI78eVS T/Anm64CtH/bG9m72nFU+ybhxk2QSZ4/jUpCmTFCzERP6uiC6w7huL7CcFfudNozD8omSLeR3NR83 Jsvqy7RW3oYtvMqibKAcj7zujnxH9fUK/iIHxtW3zPBk20RbmePhygz00AjT/O5hHUFMOkuQqFKLP 71h4FM92tHG0QecZPvHZh4BKOGSSvX6mcQ9Hs/Sv5VPGNjzYHYCKQLikeQASWsLodv9YT1dSHNBYq sMQIUzqFUHm1OWMm4JMze/1wIv4Gfl7E0ZONFkxQYHoGc7tt73nn3yMuc0Nd6rdPu3H5cS7GWfZfV XdyRxGspg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgPBk-00Gnzg-RO; Tue, 11 May 2021 10:00:30 +0000 Received: from [2607:7c80:54:e::133] (helo=bombadil.infradead.org) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgGof-00G0q2-Iq for linux-arm-kernel@desiato.infradead.org; Tue, 11 May 2021 01:04:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Sender:Reply-To:Content-ID:Content-Description; bh=OU+HtaTs8FvoJVnDadVJ79nNHdyp+spOITIiOi6q/EY=; b=usW0A9SUfFwj43BWyX/d/kPlmU cRmJwQC04uRpxZM3/4I7ustj2q9NSZyo8hHKtKmDKyknS4V8MOIzdUiA6RE1bZVEn0a4NIsBhYWzm 142niFnLrvZWJONSY6QC5kxq38pg9/s05uc54OqDmeBaQumnRxqewDIOtSQNhonAhMF4NJ8CbSeXU dmW1weAc1UOF9rmGl9PIR8QwWcL0rdF7thI1HQcuMGIrgqxQ3RS+zHxpj/iM5taGvVjskaf8/gx2W WbIkbrQhQ0L4rikgUowNxYQimrxLVdV4Qqq39Rw7mLNCfEGedW/ebLaLItGIE1giqZBwdAzgzPgm6 3fWEVcEw==; Received: from mx1.opensynergy.com ([217.66.60.4]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgGGO-009DOz-LJ for linux-arm-kernel@lists.infradead.org; Tue, 11 May 2021 00:28:42 +0000 Received: from SR-MAILGATE-02.opensynergy.com (localhost.localdomain [127.0.0.1]) by mx1.opensynergy.com (Proxmox) with ESMTP id 4B3C3A1A12; Tue, 11 May 2021 02:22:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=opensynergy.com; h=cc:cc:content-transfer-encoding:content-type:content-type :date:from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=srmailgate02; bh=OU+HtaTs8Fvo JVnDadVJ79nNHdyp+spOITIiOi6q/EY=; b=Q6e3d650yUpUKNqe1tItVEO+y1Of mkEptEEXBi3JmUTqq0hYd9Wl/L8iwt4cWn09CUoEQhd9oo//HYwNbmw8wDZFEP+F PST0J/epi8V0j545ALWeXD4UMPHnErPKW4cgYxlER8yYLbR1ZVaX+O75va+OWujO HvdNHIkHezDdZ7cFH8xzpJdbbcHclCVZPXvC1R79MKd7B31huAGQ2hMCQHFGOk7f 3vEGl260cGGfZnKFMgNdQw3YcPLnmZ66VgpHESL7Am/MgLPaiwFIJhvAL7BY2EKc SKchiSGSYuMTzfrDbeBJIJoE1CkZkjxbpl9+gW6M0yp6ypxKDh1iMvHJ2A== From: Peter Hilber To: , CC: Cristian Marussi , Peter Hilber , Rob Herring , , , , , , , , , Vasyl Vavrychuk , Andriy Tryshnivskyy Subject: [RFC PATCH v3 02/12] firmware: arm_scmi: Add transport init/deinit Date: Tue, 11 May 2021 02:20:30 +0200 Message-ID: <20210511002040.802226-3-peter.hilber@opensynergy.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210511002040.802226-1-peter.hilber@opensynergy.com> References: <20210511002040.802226-1-peter.hilber@opensynergy.com> MIME-Version: 1.0 X-ClientProxiedBy: SR-MAIL-01.open-synergy.com (10.26.10.21) To SR-MAIL-02.open-synergy.com (10.26.10.22) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210510_172840_901724_E2E21B74 X-CRM114-Status: GOOD ( 12.80 ) /bin/ln: failed to access 'reaver_cache/texts/20210510_172840_901724_E2E21B74': No such file or directory X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210510_172840_901724_E2E21B74 X-CRM114-Status: GOOD ( 10.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Cristian Marussi Signed-off-by: Cristian Marussi [ Peter: Adapted RFC patch by Cristian for submission to upstream. ] Signed-off-by: Peter Hilber --- drivers/firmware/arm_scmi/common.h | 2 ++ drivers/firmware/arm_scmi/driver.c | 45 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index 94dcfb8c0176..961a3c63cc42 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -324,6 +324,8 @@ struct scmi_device *scmi_child_dev_find(struct device *parent, * @max_msg_size: Maximum size of data per message that can be handled. */ struct scmi_desc { + int (*init)(void); + void (*exit)(void); const struct scmi_transport_ops *ops; int max_rx_timeout_ms; int max_msg; diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 41d80bbaa9a2..471c5de827c1 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -1588,10 +1588,53 @@ static struct platform_driver scmi_driver = { .remove = scmi_remove, }; +static inline int __scmi_transports_setup(bool init) +{ + int ret = 0; + const struct of_device_id *trans; + + for (trans = scmi_of_match; trans->data; trans++) { + const struct scmi_desc *tdesc = trans->data; + + if ((init && !tdesc->init) || !tdesc->exit) + continue; + pr_info("SCMI %sInitializing %s transport\n", init ? "" : "De-", + trans->compatible); + if (init) + ret = tdesc->init(); + else + tdesc->exit(); + + if (ret) { + pr_err("SCMI transport %s FAILED initialization!\n", + trans->compatible); + break; + } + } + + return ret; +} + +static int __init scmi_transports_init(void) +{ + return __scmi_transports_setup(true); +} + +static void __exit scmi_transports_exit(void) +{ + __scmi_transports_setup(false); +} + static int __init scmi_driver_init(void) { + int ret; + scmi_bus_init(); + ret = scmi_transports_init(); + if (ret) + return ret; + scmi_base_register(); scmi_clock_register(); @@ -1618,6 +1661,8 @@ static void __exit scmi_driver_exit(void) scmi_voltage_unregister(); scmi_system_unregister(); + scmi_transports_exit(); + scmi_bus_exit(); platform_driver_unregister(&scmi_driver);