From patchwork Thu Oct 29 19:59:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 11867475 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=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 BBFE4C2D0A3 for ; Thu, 29 Oct 2020 20:00:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 10F3320782 for ; Thu, 29 Oct 2020 20:00:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eDxkEMcn"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Wa4ydWEN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 10F3320782 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=broadcom.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=merlin.20170209; h=Sender:Content-Type:MIME-Version: Cc:List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: References:In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yvS2mxWXwKKMlGArXYqng+9f8ERMe2BdZN0S9/Sa/+8=; b=eDxkEMcnsQxDx+Gr7xgOSO709 1lE99Mz2hPYZ5lm9kCf5UQjVJv0VS5H4Tdp7YeCUAqQ4HRi1cE/IWWasi7BpkuOEqtIPmgfj+Veqg eYzDOmMEYyJpwsRxzIhfE07U/6SNIuRcqxFI+sB8/1te6xCWg7FMrRJbYR27IQOFYl3Vk3ObOiAHs jUun5uH0Ow0clpiI1AIo+aNNtsB1sftlC7QPH/3FuI6hyULNkvY6/AfZEqpHMokLwOia/n48m2VwU 2Ky+VzdVzHyKgzYfqctr8OT9s8/AdajYrpKLX+bx47SAbAJxIEb66sU3qQ0KaAt2eg1OU10ia5C2u lM2pwul8w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYE5D-0002G2-9W; Thu, 29 Oct 2020 19:59:39 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYE59-0002EX-Gc for linux-arm-kernel@lists.infradead.org; Thu, 29 Oct 2020 19:59:36 +0000 Received: by mail-pf1-x442.google.com with SMTP id w65so3273944pfd.3 for ; Thu, 29 Oct 2020 12:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I5nTrt1GKzGlv8XFXKYRnjGD/n0p2mkJFST8zCu2JMo=; b=Wa4ydWENIyXCiciQGZIh+UOYTzg0guIC0zceZePejhOMpsCcEjFoMxz5iAg/dslzhk IXodbj842lekw6CJiPjEZAgOqElI7ZGb768TVUQpGzH13KPkCT10gcheIohB0pufgsE4 uffgVOHYxUb60x6p8JIp+Wc52s1A/VNeIitkQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=I5nTrt1GKzGlv8XFXKYRnjGD/n0p2mkJFST8zCu2JMo=; b=FZcfu1iFHQxqCzxOhvF51bYjT1iBW6AteVDxepTAK5B1C944KaxevZ1ILK30SCCyfK Ppvn5tbZwq2LJriQRr7klfdPRddBoCeZU9nQKZri9P/uaQFt6xnwlgU20YUp6L/U7KhB aTPL/i/O6CO7PrsWJZLAjnNPQ4mdnmXkdBzcYBfqF+mWwSnCg3VptWFVsXx2NZsa6QGi A39f63ojoYpMDBZ5N2ViRP2gckUU2Ks0KLr215SziwKsOC8hdBeseIlZUqV7RlbcSMgA lltJip66PmbgfMO0Wd0qktcBxC8UmUnrQ0SqlmFecbsY5WNqVkLoR+IdSyH0vDRyJKd7 Yl1Q== X-Gm-Message-State: AOAM533500bCj+MTL/dpuaaPbX7FAvEL5bfjrg1t8T6cGKE0UDJ5t+Bl 4Ey8DYP5LvOaCMauPr0lX97fAA== X-Google-Smtp-Source: ABdhPJzxOcdQso/+vEeFph6roiFES0zeDC2LT3HwkPeABO3brHqfSqLNa/2re5jFQCD7MrqBWAwSjg== X-Received: by 2002:a65:680c:: with SMTP id l12mr5443280pgt.118.1604001573566; Thu, 29 Oct 2020 12:59:33 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id z27sm3682662pfr.206.2020.10.29.12.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 12:59:32 -0700 (PDT) From: Jim Quinlan To: sudeep.holla@arm.com, bcm-kernel-feedback-list@broadcom.com, james.quinlan@broadcom.com Subject: [PATCH v4 1/2] dt-bindings: Add bindings for BrcmSTB SCMI mailbox driver Date: Thu, 29 Oct 2020 15:59:06 -0400 Message-Id: <20201029195913.5927-2-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201029195913.5927-1-james.quinlan@broadcom.com> References: <20201029195913.5927-1-james.quinlan@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201029_155935_631981_21D14FAD X-CRM114-Status: GOOD ( 11.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Fainelli , Rob Herring , open list , "moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Bindings are added. Only one interrupt is needed because we do not yet employ the SCMI p2a channel. Signed-off-by: Jim Quinlan --- .../bindings/mailbox/brcm,brcmstb-mbox.yaml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/brcm,brcmstb-mbox.yaml diff --git a/Documentation/devicetree/bindings/mailbox/brcm,brcmstb-mbox.yaml b/Documentation/devicetree/bindings/mailbox/brcm,brcmstb-mbox.yaml new file mode 100644 index 000000000000..797c0cc609a3 --- /dev/null +++ b/Documentation/devicetree/bindings/mailbox/brcm,brcmstb-mbox.yaml @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$schema: "http://devicetree.org/meta-schemas/core.yaml#" +$id: http://devicetree.org/schemas/mailbox/brcm,brcmstb-mbox.yaml# + +title: Broadcom STB mailbox driver bindings + +maintainers: + - Jim Quinlan + +properties: + compatible: + enum: + - brcm,brcmstb-mbox + + interrupts: + items: + - description: a2p return interrupt, indicates SCMI msg completion. + + "#mbox-cells": + const: 1 + +required: + - compatible + - interrupts + - "#mbox-cells" + +additionalProperties: false + +examples: + - | + #include + mailbox { + compatible = "brcm,brcmstb-mailbox"; + #mbox-cells = <1>; + interrupts = ; + }; +... From patchwork Thu Oct 29 19:59:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 11867481 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=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 44FDFC2D0A3 for ; Thu, 29 Oct 2020 20:00:36 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 8F26620782 for ; Thu, 29 Oct 2020 20:00:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="N9a0aCHv"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="KphBE+2b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F26620782 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=broadcom.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=merlin.20170209; h=Sender:Content-Type:MIME-Version: Cc:List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: References:In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2mx4bySAUWkc6Yo1kaFA/2+KGVpWq6EVut/p4CP+ysc=; b=N9a0aCHvkaqRruKWSaaM9snSs j5CJQYPX9/izVcx+cy3M4TodPIk71yEjFu/q56X7EDOmWJ20tE3eTXudYlSWXrL7ir/bur1QSKEsR QH9Z701gCbN1ymOsHBr2zXvlbOyYKk3sexFOP5bV3yvHnvJR4UPgUyiQOAEHRl0yfl4wd0ga0SX8n t4Gxlp/M7GQwQmNrO77qfPPvakYFNGD+xVk/Ij/eTlF6pusvq0+1SXA/i0pMPtkLJLaHP6zKGk43h 1ZU1t+St9W/Bi2QaFrDavXWcRkfU+gKDaF0xhFAwxjpKjQPurwuUhc0Kb5IbvKgHtL3GT/59U7lMO 1EhqRKMvQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYE5X-0002LK-HF; Thu, 29 Oct 2020 19:59:59 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYE5G-0002Gx-TX for linux-arm-kernel@lists.infradead.org; Thu, 29 Oct 2020 19:59:45 +0000 Received: by mail-pf1-x444.google.com with SMTP id b3so3278740pfo.2 for ; Thu, 29 Oct 2020 12:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p7YalbMit9g9h4CS6fSrVCEyqNO8gIUFAxXBhU93QF0=; b=KphBE+2bOQbkdh38Ep9KPkyqtRhhuTl1sa4ujB5uCnuiD4FrO73i1kvEkE8TaV6nZf o1jRaXDMCNlrDp5aqNurDnI50awvYuls8UYDrFpSr7MePlzmXvZGpqotGK5NC+JB4Vds WBUibrCJ2zfKAKCB6BzOz8Xo0c+O83214zGLk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=p7YalbMit9g9h4CS6fSrVCEyqNO8gIUFAxXBhU93QF0=; b=Qqzse9QsQDC4cyt+L0oXtPr2prX7KmQg91JrLo6XohFeRLSmqApUBpwxYu+wDT8wQK w07SMnz85qQTo1VUIch7/VqErZY8yXSp4QEghCgerppATAxuRA1d9YC9h8O5Ne6VHsyj +ytUBVYSURzL9HtKKoBMwcNL3MNNvwHLZhVXHKg0DAuOx2DtDa2/QspvZudNSiQQOSxr 3QoaxwOmAQejbb44MuCZhbM6solgmLlU63LpTXQFlFCan2yD3nvYxdDF2ZkG5Kf3ukuo jBYANQsEkKgyu5zmZ7aJF80EwtYsC0D9kYbm+bayIum5OXV3+Yng+Pl8ifVh/uzwnFxA c24Q== X-Gm-Message-State: AOAM531iDVcwIhnM3Z33llLF4gdIhpCl48ICqc0Qk+it5K/SxSeplOqs qkkYtz8JAhmA58qE64/2UqhSqw== X-Google-Smtp-Source: ABdhPJxw2btUQCiyWuXnf9YWx0cW+IeYiSD6HvXNtuz6KayzYKPDm/QPcGxnTLZfRvEc+ZIdzMc3PQ== X-Received: by 2002:a62:cf06:0:b029:161:90d5:c19f with SMTP id b6-20020a62cf060000b029016190d5c19fmr6004159pfg.37.1604001580308; Thu, 29 Oct 2020 12:59:40 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id z27sm3682662pfr.206.2020.10.29.12.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 12:59:39 -0700 (PDT) From: Jim Quinlan To: sudeep.holla@arm.com, bcm-kernel-feedback-list@broadcom.com, james.quinlan@broadcom.com Subject: [PATCH v4 2/2] mailbox: Add Broadcom STB mailbox driver Date: Thu, 29 Oct 2020 15:59:07 -0400 Message-Id: <20201029195913.5927-3-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201029195913.5927-1-james.quinlan@broadcom.com> References: <20201029195913.5927-1-james.quinlan@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201029_155943_057819_41773367 X-CRM114-Status: GOOD ( 23.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jassi Brar , Florian Fainelli , open list , "moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is a simple mailbox driver to be used by the SCMI protocol stack. It only implements the agent-to-platform channel; we may implement the platform-to-agent channel in the future. An unusual aspect of this driver is how the completion of an SCMI message is indicated. An SCMI message is initiated with an ARM SMC call, but the return of this call does not indicate the execution or completion of the message. Rather, the message's completion is signaled by an interrupt. Signed-off-by: Jim Quinlan Signed-off-by: Florian Fainelli --- drivers/mailbox/Kconfig | 12 +++ drivers/mailbox/Makefile | 2 + drivers/mailbox/brcmstb-mailbox.c | 167 ++++++++++++++++++++++++++++++ 3 files changed, 181 insertions(+) create mode 100644 drivers/mailbox/brcmstb-mailbox.c diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index 05b1009e2820..b1e697e8d5f9 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -254,4 +254,16 @@ config QCOM_IPCC acts as an interrupt controller for receiving interrupts from clients. Say Y here if you want to build this driver. +config BRCMSTB_MBOX + tristate "Broadcom STB Mailbox" + depends on ARM64 || ARM + depends on ARM_SCMI_PROTOCOL && ARCH_BRCMSTB + default ARM_SCMI_PROTOCOL && ARCH_BRCMSTB + help + Mailbox implementation of the Broadcom STB for the sole purposes + of SCMI communication. This is used by the SCMI drivers to + communicate with FW that runs in EL3. This mailbox only implements + the agent-to-platform channgel of SCMI but may be augmented in + the future to add the platform-to-agent channel. + endif diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile index 2e06e02b2e03..95fbcd121f2e 100644 --- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile @@ -54,3 +54,5 @@ obj-$(CONFIG_SUN6I_MSGBOX) += sun6i-msgbox.o obj-$(CONFIG_SPRD_MBOX) += sprd-mailbox.o obj-$(CONFIG_QCOM_IPCC) += qcom-ipcc.o + +obj-$(CONFIG_BRCMSTB_MBOX) += brcmstb-mailbox.o diff --git a/drivers/mailbox/brcmstb-mailbox.c b/drivers/mailbox/brcmstb-mailbox.c new file mode 100644 index 000000000000..d9e953995417 --- /dev/null +++ b/drivers/mailbox/brcmstb-mailbox.c @@ -0,0 +1,167 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2017-2020, Broadcom */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BRCM_SCMI_SMC_OEM_FUNC 0x400 +#define BRCM_SCMI_MBOX_NUM 0 +#define BRCM_FID(ch) ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + IS_ENABLED(CONFIG_ARM64), \ + ARM_SMCCC_OWNER_OEM, \ + BRCM_SCMI_SMC_OEM_FUNC + (ch)) +enum { + A2P_CHAN = 0, + NUM_CHAN +}; + +struct chan_priv { + unsigned int mbox_num; + unsigned int ch; +}; + +struct brcm_mbox { + struct mbox_controller controller; + int irqs[NUM_CHAN]; +}; + +static struct mbox_chan *brcm_mbox_of_xlate(struct mbox_controller *controller, + const struct of_phandle_args *sp) +{ + unsigned int ch = sp->args[0]; + struct brcm_mbox *mbox + = container_of(controller, struct brcm_mbox, controller); + + if (!mbox || ch >= NUM_CHAN) + return ERR_PTR(-ENOENT); + + return &mbox->controller.chans[ch]; +} + +static int announce_msg(unsigned int mbox_num, unsigned int ch) +{ + struct arm_smccc_res res; + + if (ch >= NUM_CHAN) + return -EIO; + arm_smccc_smc(BRCM_FID(ch), mbox_num, 0, 0, 0, 0, 0, 0, &res); + if (res.a0) + return -EIO; + return 0; +} + +static int brcm_mbox_send_data(struct mbox_chan *chan, void *data) +{ + struct chan_priv *priv = chan->con_priv; + + return announce_msg(priv->mbox_num, priv->ch); +} + +static int brcm_mbox_startup(struct mbox_chan *chan) +{ + return 0; +} + +static const struct mbox_chan_ops brcm_mbox_ops = { + .send_data = brcm_mbox_send_data, + .startup = brcm_mbox_startup, +}; + +static irqreturn_t brcm_a2p_isr(int irq, void *data) +{ + struct mbox_chan *chan = data; + + mbox_chan_received_data(chan, NULL); + return IRQ_HANDLED; +} + +static int brcm_mbox_probe(struct platform_device *pdev) +{ + struct brcm_mbox *mbox; + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct chan_priv *chan_priv; + int ret; + + if (!np) + return -EINVAL; + + mbox = devm_kzalloc(&pdev->dev, sizeof(*mbox), GFP_KERNEL); + if (!mbox) + return -ENOMEM; + + /* Allocate channels */ + mbox->controller.chans = devm_kzalloc( + &pdev->dev, NUM_CHAN * sizeof(struct mbox_chan), GFP_KERNEL); + if (!mbox->controller.chans) + return -ENOMEM; + chan_priv = devm_kzalloc( + &pdev->dev, NUM_CHAN * sizeof(struct chan_priv), GFP_KERNEL); + if (!chan_priv) + return -ENOMEM; + + mbox->irqs[A2P_CHAN] = platform_get_irq(pdev, 0); + ret = devm_request_irq(&pdev->dev, mbox->irqs[A2P_CHAN], brcm_a2p_isr, + IRQF_NO_SUSPEND, "brcm: SCMI a2p intr", + &mbox->controller.chans[A2P_CHAN]); + if (ret) { + dev_err(&pdev->dev, "failed to setup SCMI a2p isr\n"); + return ret; + } + chan_priv[A2P_CHAN].mbox_num = BRCM_SCMI_MBOX_NUM; + chan_priv[A2P_CHAN].ch = A2P_CHAN; + mbox->controller.chans[A2P_CHAN].con_priv = &chan_priv[A2P_CHAN]; + mbox->controller.num_chans++; + mbox->controller.dev = &pdev->dev; + mbox->controller.ops = &brcm_mbox_ops; + mbox->controller.of_xlate = brcm_mbox_of_xlate; + ret = mbox_controller_register(&mbox->controller); + if (ret) { + dev_err(dev, "failed to register BrcmSTB mbox\n"); + return ret; + } + + platform_set_drvdata(pdev, mbox); + return 0; +} + +static int brcm_mbox_remove(struct platform_device *pdev) +{ + struct brcm_mbox *mbox = platform_get_drvdata(pdev); + + mbox_controller_unregister(&mbox->controller); + + return 0; +} + +static const struct of_device_id brcm_mbox_of_match[] = { + { .compatible = "brcm,brcmstb-mbox", }, + {} +}; +MODULE_DEVICE_TABLE(of, brcm_mbox_of_match); + +static struct platform_driver brcm_mbox_driver = { + .probe = brcm_mbox_probe, + .remove = brcm_mbox_remove, + .driver = { + .name = "brcm_mbox", + .of_match_table = brcm_mbox_of_match, + }, +}; + +module_platform_driver(brcm_mbox_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Broadcom STB SCMI Mailbox driver"); +MODULE_AUTHOR("Broadcom");