From patchwork Tue May 11 15:38:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12251413 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=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 86E0EC433B4 for ; Tue, 11 May 2021 15:38:44 +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 DD4DE6162B for ; Tue, 11 May 2021 15:38:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD4DE6162B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=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: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:In-Reply-To:References:List-Owner; bh=MtZDGFrQl5K02XvJoC9R7r1kuxFDTd46gLf4qIGLAzY=; b=WGo4yS6obGjxqYnKaUemsu//yC b3Q3FPVGv/g/TbqxqEk9F7ADuoEwI3HcllHf/dYkCzN5kBrChiiL96lwY8VDHcRMBp9gA+aeqRYeU M5UGjIIDJLdqhc/fbts+rYDLLkGwuF7K0KFirFv0jb+f7MJysBNX/tYpigeV89KB4xicgcx0+OGZ7 ivSlrhvWWoWakm6gr/y/N9r9LZYq36bUMAoAfTiipUwBdykjVR3qak556keDWNjDfthkC2lFthPmr BAZA+jxe875gQPvklmHx9zkoDR0dRo9Bge3JAN2Mxar8dPwJlbUbGRxnAid4PpkwL5Bfy+bmBRh63 gETF1qNQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgUSo-000crR-5P; Tue, 11 May 2021 15:38:26 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgUSk-000cqh-IT for linux-riscv@desiato.infradead.org; Tue, 11 May 2021 15:38:22 +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:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-ID:Content-Description:In-Reply-To:References; bh=CJoHCp8alu4y8O/BxLi8W1qmBphh6ozCYWP8/tJSbs8=; b=oNRkDs6mNSXRm8RNA3D3hNWj67 MGqAT6Z0DiC6UT8mB3SLQxQLFxyZgg6Sw5scy2rgswcyDLcySHUMDxZREAm31lSU4gn+GgHOsI0PF Qy7prf0tt+FbjMjArlomzbly19/AW7Tt7z+Tlo+f8CKAynmFyEhEWMaq40/aNqLxzicBYhvvV7uvJ 2DZqPWrrpo8XQSjjixd6/WaAuLrVt8yhvE4x+eWqAEpkpR4l/OPs5bZT8p8Q5mqAL6xAz8zweDuPp HrDtCDW0HuIueak6PRxG4A1Mr3h+UbXZN/jOZ9zjWctDBUIqUZ0MudvFDGtSZZdCXBAKI53SGASsR BMB344AQ==; Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgUSh-009ivQ-T0 for linux-riscv@lists.infradead.org; Tue, 11 May 2021 15:38:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1620747500; x=1652283500; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=SqNyNIfuwHW0yJuBwaT05X9QMLsai7UvDsw9rjA5dnQ=; b=AqF2CvmRMjMLnHKInnT9tDL5JBpxIDyCC4UCcBlPa6HcUKfuMfDYyB+A jOMG/8IcRNCt9VCbuQQ7lTjOcB3Pp8hUgQWGixuZbV4CyJStH+B9YTYnG Y35CpYoRABBs4tMTb41g+aCfrGo8kh4cFabEM6lw1wf5zd7oWxDcrqS5J 7lZ6w/gG99A9OAcQXUON6B+A+QB686FIS8bBERSDyzb8wOT1mvylXJs0Y 2jZdmuqQ+61kSzWR3m4DvkXSBh0nuRcNg2ETU2bmW/X1ebbfQ5KmhJpfO 4waIuN3qXu4lxXkTrtfzK0k5OxdqGdn0nTJODSnz8+hCe3WBwbI/TqRJH A==; IronPort-SDR: 1Iz84wIrYvtlI1aseHZjzJw0zLjGikuWxtFGv0QZojsnUfRwGihYWGLqJ3gJjUWB2D++ofmbQV /XTCV5rzEaD64T9R+peW6DDTqPQr8QSpwgACWsoQ/XTirG4SvshSONnGNJbl2B9SN4Pp++fY/5 dz8eaaz6Vcm+X7/u+BGPLfGWBoC8Y1RwI/vgHRf1U+jF6WnPX0A/xzswuZ8SrT5ODuueUeoXx/ gLg1ePngPmqL/tcJ0zDljpY8haBmtUXveeDyLDaL/Bzu7xmLM9YzJBzOxKDsVsVtyzANiDynUk gZ0= X-IronPort-AV: E=Sophos;i="5.82,291,1613458800"; d="scan'208";a="120686650" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 May 2021 08:38:19 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 11 May 2021 08:38:18 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Tue, 11 May 2021 08:38:16 -0700 From: To: , , , , , , , , CC: , , , , , , Conor Dooley , Rob Herring Subject: [PATCH v7 1/5] dt-bindings: add bindings for polarfire soc mailbox Date: Tue, 11 May 2021 16:38:15 +0100 Message-ID: <20210511153815.28611-1-conor.dooley@microchip.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_083819_966671_C133D139 X-CRM114-Status: UNSURE ( 9.36 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Conor Dooley Add device tree bindings for the MSS system controller mailbox on the Microchip PolarFire SoC. Signed-off-by: Conor Dooley Reviewed-by: Rob Herring --- .../microchip,polarfire-soc-mailbox.yaml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/microchip,polarfire-soc-mailbox.yaml diff --git a/Documentation/devicetree/bindings/mailbox/microchip,polarfire-soc-mailbox.yaml b/Documentation/devicetree/bindings/mailbox/microchip,polarfire-soc-mailbox.yaml new file mode 100644 index 000000000000..bbb173ea483c --- /dev/null +++ b/Documentation/devicetree/bindings/mailbox/microchip,polarfire-soc-mailbox.yaml @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/mailbox/microchip,polarfire-soc-mailbox.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Microchip PolarFire SoC (MPFS) MSS (microprocessor subsystem) mailbox controller + +maintainers: + - Conor Dooley + +properties: + compatible: + const: microchip,polarfire-soc-mailbox + + reg: + items: + - description: mailbox data registers + - description: mailbox interrupt registers + + interrupts: + maxItems: 1 + + "#mbox-cells": + const: 1 + +required: + - compatible + - reg + - interrupts + - "#mbox-cells" + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + mbox: mailbox@37020000 { + compatible = "microchip,polarfire-soc-mailbox"; + reg = <0x0 0x37020000 0x0 0x1000>, <0x0 0x2000318c 0x0 0x40>; + interrupt-parent = <&L1>; + interrupts = <96>; + #mbox-cells = <1>; + }; + }; From patchwork Tue May 11 15:38:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12251415 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=-14.7 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, UNWANTED_LANGUAGE_BODY,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 64A5BC433B4 for ; Tue, 11 May 2021 15:38:47 +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 B3CD36162B for ; Tue, 11 May 2021 15:38:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3CD36162B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=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: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:In-Reply-To:References:List-Owner; bh=y+6/SCXGAYpqsZYowWfhOHTRQhFo4pr2NAkx4yf+eV0=; b=owZWC38cAL625Yf/iHXpQl1xB8 kg9GI5I67wDvif15UY6dpYeZ8TptoUWNM8mLmhJYBjHP4I7u/CqxrgD7h85vyVluR0t/nHKFOFMdl Bhc5E8SGlv5G+sHuCDAPVl/sFEdP98LcIuvL/eMUROkEohq7op1YL75WEqD4/QnrpBRYl/2H5JwBJ f/bsvYi2JSGM2D2y83JhdYv4Sn8rPGEo4wsOpxQZAIzDe0Ludy7eygtr01s0AGSyCaQ/exIoP4Nzd XI7huAuBWfKpR7TkBPrOcX6v52G7LcIJ6OEveY9dTQz3ggpE0K9TZLdOz3nI5jF8DAGnQSsU6Te1n iWxCQ9LA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgUSt-000csv-OI; Tue, 11 May 2021 15:38:31 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgUSq-000crv-8C for linux-riscv@desiato.infradead.org; Tue, 11 May 2021 15:38:29 +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:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-ID:Content-Description:In-Reply-To:References; bh=AcS0NGH0XkmqvfJ4Is/pl7ue7wT5ORXLY0HmgYJAXN8=; b=GGEbSQfbtg6avC1Wo7xsqRiZ81 LHdYC2/KTP70px9myQAjrMde2F4SCXm1z42aUtUsZg6fU6gJdosiMux5Rd4OPwFjiD8UdwhJxQi8v Qz+m7GLEu3rVthsSat3R1h/1u5SUodCm9J3i+lP5esmUCqAq8Fsb6Qk3kKojWOU7cXE+HCBMsgfFe AH2Iu9Il+p4bDG97ZfnsRN3tMBmngr2Xm9BrsTH0nfub245EMSaG9tgKVdqiZaD0+5D2Ycw9yVpYg ivTssahGVHo28pYEhexWDat7OLogM128KzeXHsomTI7X8sDzuFFwUpsLZ4oiPXgi3my9RChiij6rl timzUHRg==; Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgUSn-009ivQ-4x for linux-riscv@lists.infradead.org; Tue, 11 May 2021 15:38:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1620747505; x=1652283505; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=i3gr7cuZYkTAM0utPdaJkt7kZjMj9LKmaEnrQcXzFfM=; b=WpzwKbFrdUQld7y9BRXYHSyhmhRHc6N3HtBJbAL9WgG/2TJJEe0OgodI F1AEI3AG9Y3bh2ULlzXVq7obLlxa40cEacSjES+cLyRR0n+r+JbsqV826 pw6uLbeUJFglX1n3Evpq0eWgfNjmf1q8tnhfCtO0O+pq8usdkwzsISJHR ThVXEpnpFy2Fwzns6uoKmtN3Gb7/an4KGHFQvcM3YU7gaFRhd2w+o61RZ pgh+N9JQaoKAeKreWc72DprxdvyK/g/QpYkNtqsfciuXqwROZJ4/hzEtJ 7gWh/mu+D+etaAkw/DxQmWETHhIstmMO9i6L5vs0sw63+eqE8EQbgKFIW w==; IronPort-SDR: Or44lqwsX/c5Hi1zRWjilVvEimhFQJuvnR7MS+PhKHaLnK+MfSCLZsMYtk0TB886828iLlyOdA I8Wqqb/jVW06hqyoE+m09nepInyvqN/Lo2Cvm0BXAqPpN2g4ZPtZvjP4IFjt2+xY9FejQz9XW1 Gbw9CVQ66Ai6TWvHb0QcBu1U6Q3yY9hkCsN6mFqTFdD6FvNZr5CIpHIj4cWpUcukEenUDg7v+c ZxbfBo3pXyh+azXjhSjrMvx4wff/Vm/f2okwN+J6qqXuooad+lnGZrYMTWe7UZgDGuktwdIYWh +ic= X-IronPort-AV: E=Sophos;i="5.82,291,1613458800"; d="scan'208";a="120686654" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 May 2021 08:38:24 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 11 May 2021 08:38:24 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Tue, 11 May 2021 08:38:21 -0700 From: To: , , , , , , , , CC: , , , , , , Conor Dooley Subject: [PATCH v7 2/5] mbox: add polarfire soc system controller mailbox Date: Tue, 11 May 2021 16:38:20 +0100 Message-ID: <20210511153820.31359-1-conor.dooley@microchip.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_083825_236320_BCECDA45 X-CRM114-Status: GOOD ( 23.65 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Conor Dooley This driver adds support for the single mailbox channel of the MSS system controller on the Microchip PolarFire SoC. Signed-off-by: Conor Dooley --- drivers/mailbox/Kconfig | 12 ++ drivers/mailbox/Makefile | 2 + drivers/mailbox/mailbox-mpfs.c | 251 +++++++++++++++++++++++++++++++++ include/soc/microchip/mpfs.h | 56 ++++++++ 4 files changed, 321 insertions(+) create mode 100644 drivers/mailbox/mailbox-mpfs.c create mode 100644 include/soc/microchip/mpfs.h diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index 68de2c6af727..b4b780ea2ac8 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -160,6 +160,18 @@ config MAILBOX_TEST Test client to help with testing new Controller driver implementations. +config POLARFIRE_SOC_MAILBOX + tristate "PolarFire SoC (MPFS) Mailbox" + depends on HAS_IOMEM + depends on SOC_MICROCHIP_POLARFIRE || COMPILE_TEST + help + This driver adds support for the PolarFire SoC (MPFS) mailbox controller. + + To compile this driver as a module, choose M here. the + module will be called mailbox-mpfs. + + If unsure, say N. + config QCOM_APCS_IPC tristate "Qualcomm APCS IPC driver" depends on ARCH_QCOM || COMPILE_TEST diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile index 7194fa92c787..c2089f04887e 100644 --- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile @@ -41,6 +41,8 @@ obj-$(CONFIG_BCM_PDC_MBOX) += bcm-pdc-mailbox.o obj-$(CONFIG_BCM_FLEXRM_MBOX) += bcm-flexrm-mailbox.o +obj-$(CONFIG_POLARFIRE_SOC_MAILBOX) += mailbox-mpfs.o + obj-$(CONFIG_QCOM_APCS_IPC) += qcom-apcs-ipc-mailbox.o obj-$(CONFIG_TEGRA_HSP_MBOX) += tegra-hsp.o diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c new file mode 100644 index 000000000000..854338a40e8f --- /dev/null +++ b/drivers/mailbox/mailbox-mpfs.c @@ -0,0 +1,251 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Microchip PolarFire SoC (MPFS) system controller/mailbox controller driver + * + * Copyright (c) 2020 Microchip Corporation. All rights reserved. + * + * Author: Conor Dooley + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SERVICES_CR_OFFSET 0x50u +#define SERVICES_SR_OFFSET 0x54u +#define MAILBOX_REG_OFFSET 0x800u +#define MSS_SYS_MAILBOX_DATA_OFFSET 0u +#define SCB_MASK_WIDTH 16u + +/* SCBCTRL service control register */ + +#define SCB_CTRL_REQ (0) +#define SCB_CTRL_REQ_MASK BIT(SCB_CTRL_REQ) + +#define SCB_CTRL_BUSY (1) +#define SCB_CTRL_BUSY_MASK BIT(SCB_CTRL_BUSY) + +#define SCB_CTRL_ABORT (2) +#define SCB_CTRL_ABORT_MASK BIT(SCB_CTRL_ABORT) + +#define SCB_CTRL_NOTIFY (3) +#define SCB_CTRL_NOTIFY_MASK BIT(SCB_CTRL_NOTIFY) + +#define SCB_CTRL_POS (16) +#define SCB_CTRL_MASK GENMASK(SCB_CTRL_POS + SCB_MASK_WIDTH, SCB_CTRL_POS) + +/* SCBCTRL service status register */ + +#define SCB_STATUS_REQ (0) +#define SCB_STATUS_REQ_MASK BIT(SCB_STATUS_REQ) + +#define SCB_STATUS_BUSY (1) +#define SCB_STATUS_BUSY_MASK BIT(SCB_STATUS_BUSY) + +#define SCB_STATUS_ABORT (2) +#define SCB_STATUS_ABORT_MASK BIT(SCB_STATUS_ABORT) + +#define SCB_STATUS_NOTIFY (3) +#define SCB_STATUS_NOTIFY_MASK BIT(SCB_STATUS_NOTIFY) + +#define SCB_STATUS_POS (16) +#define SCB_STATUS_MASK GENMASK(SCB_STATUS_POS + SCB_MASK_WIDTH, SCB_STATUS_POS) + +struct mpfs_mbox { + struct mbox_controller controller; + struct device *dev; + int irq; + void __iomem *mbox_base; + void __iomem *int_reg; + struct mbox_chan chans[1]; + struct mpfs_mss_response *response; + u16 resp_offset; +}; + +static bool mpfs_mbox_busy(struct mpfs_mbox *mbox) +{ + u32 status; + + status = readl_relaxed(mbox->mbox_base + SERVICES_SR_OFFSET); + + return status & SCB_STATUS_BUSY_MASK; +} + +static int mpfs_mbox_send_data(struct mbox_chan *chan, void *data) +{ + struct mpfs_mbox *mbox = (struct mpfs_mbox *)chan->con_priv; + struct mpfs_mss_msg *msg = data; + u32 tx_trigger; + u16 opt_sel; + u32 val = 0u; + + mbox->response = msg->response; + mbox->resp_offset = msg->resp_offset; + + if (mpfs_mbox_busy(mbox)) + return -EBUSY; + + if (msg->cmd_data_size) { + u32 index; + u8 extra_bits = msg->cmd_data_size & 3; + u32 *word_buf = (u32 *)msg->cmd_data; + + for (index = 0; index < (msg->cmd_data_size / 4); index++) + writel_relaxed(word_buf[index], + mbox->mbox_base + MAILBOX_REG_OFFSET + index * 0x4); + if (extra_bits) { + u8 i; + u8 byte_off = ALIGN_DOWN(msg->cmd_data_size, 4); + u8 *byte_buf = msg->cmd_data + byte_off; + + val = readl_relaxed(mbox->mbox_base + + MAILBOX_REG_OFFSET + index * 0x4); + + for (i = 0u; i < extra_bits; i++) { + val &= ~(0xffu << (i * 8u)); + val |= (byte_buf[i] << (i * 8u)); + } + + writel_relaxed(val, + mbox->mbox_base + MAILBOX_REG_OFFSET + index * 0x4); + } + } + + opt_sel = ((msg->mbox_offset << 7u) | (msg->cmd_opcode & 0x7fu)); + tx_trigger = (opt_sel << SCB_CTRL_POS) & SCB_CTRL_MASK; + tx_trigger |= SCB_CTRL_REQ_MASK | SCB_STATUS_NOTIFY_MASK; + writel_relaxed(tx_trigger, mbox->mbox_base + SERVICES_CR_OFFSET); + + return 0; +} + +static void mpfs_mbox_rx_data(struct mbox_chan *chan) +{ + struct mpfs_mbox *mbox = (struct mpfs_mbox *)chan->con_priv; + struct mpfs_mss_response *response = mbox->response; + u16 num_words = ALIGN((response->resp_size), (4)) / 4U; + u32 i; + + if (!response->resp_msg) { + dev_err(mbox->dev, "failed to assign memory for response %d\n", -ENOMEM); + return; + } + + if (!mpfs_mbox_busy(mbox)) { + for (i = 0; i < num_words; i++) { + response->resp_msg[i] = + readl_relaxed(mbox->mbox_base + MAILBOX_REG_OFFSET + + mbox->resp_offset + i * 0x4); + } + } + + mbox_chan_received_data(chan, response); +} + +static irqreturn_t mpfs_mbox_inbox_isr(int irq, void *data) +{ + struct mbox_chan *chan = data; + struct mpfs_mbox *mbox = (struct mpfs_mbox *)chan->con_priv; + + writel_relaxed(0, mbox->int_reg); + + mpfs_mbox_rx_data(chan); + + mbox_chan_txdone(chan, 0); + return IRQ_HANDLED; +} + +static int mpfs_mbox_startup(struct mbox_chan *chan) +{ + struct mpfs_mbox *mbox = (struct mpfs_mbox *)chan->con_priv; + int ret = 0; + + if (!mbox) + return -EINVAL; + + ret = devm_request_irq(mbox->dev, mbox->irq, mpfs_mbox_inbox_isr, 0, "mpfs-mailbox", chan); + if (ret) + dev_err(mbox->dev, "failed to register mailbox interrupt:%d\n", ret); + + return ret; +} + +static void mpfs_mbox_shutdown(struct mbox_chan *chan) +{ + struct mpfs_mbox *mbox = (struct mpfs_mbox *)chan->con_priv; + + devm_free_irq(mbox->dev, mbox->irq, chan); +} + +static const struct mbox_chan_ops mpfs_mbox_ops = { + .send_data = mpfs_mbox_send_data, + .startup = mpfs_mbox_startup, + .shutdown = mpfs_mbox_shutdown, +}; + +static int mpfs_mbox_probe(struct platform_device *pdev) +{ + struct mpfs_mbox *mbox; + struct resource *regs; + int ret; + + mbox = devm_kzalloc(&pdev->dev, sizeof(*mbox), GFP_KERNEL); + if (!mbox) + return -ENOMEM; + + mbox->mbox_base = devm_platform_get_and_ioremap_resource(pdev, 0, ®s); + if (IS_ERR(mbox->mbox_base)) + return PTR_ERR(mbox->mbox_base); + + mbox->int_reg = devm_platform_get_and_ioremap_resource(pdev, 1, ®s); + if (IS_ERR(mbox->int_reg)) + return PTR_ERR(mbox->int_reg); + + mbox->irq = platform_get_irq(pdev, 0); + if (mbox->irq < 0) + return mbox->irq; + + mbox->dev = &pdev->dev; + + mbox->chans[0].con_priv = mbox; + mbox->controller.dev = mbox->dev; + mbox->controller.num_chans = 1; + mbox->controller.chans = mbox->chans; + mbox->controller.ops = &mpfs_mbox_ops; + mbox->controller.txdone_irq = true; + + ret = devm_mbox_controller_register(&pdev->dev, &mbox->controller); + if (ret) { + dev_err(&pdev->dev, "Registering MPFS mailbox controller failed\n"); + return ret; + } + dev_info(&pdev->dev, "Registered MPFS mailbox controller driver\n"); + + return 0; +} + +static const struct of_device_id mpfs_mbox_of_match[] = { + {.compatible = "microchip,polarfire-soc-mailbox", }, + {}, +}; +MODULE_DEVICE_TABLE(of, mpfs_mbox_of_match); + +static struct platform_driver mpfs_mbox_driver = { + .driver = { + .name = "mpfs-mailbox", + .of_match_table = mpfs_mbox_of_match, + }, + .probe = mpfs_mbox_probe, +}; +module_platform_driver(mpfs_mbox_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Conor Dooley "); +MODULE_DESCRIPTION("MPFS mailbox controller driver"); diff --git a/include/soc/microchip/mpfs.h b/include/soc/microchip/mpfs.h new file mode 100644 index 000000000000..16309c5852fb --- /dev/null +++ b/include/soc/microchip/mpfs.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * + * Microchip PolarFire SoC (MPFS) + * + * Copyright (c) 2020 Microchip Corporation. All rights reserved. + * + * Author: Conor Dooley + * + */ + +#ifndef __SOC_MPFS_H__ +#define __SOC_MPFS_H__ + +#include +#include + +struct mpfs_sys_controller; + +struct mpfs_mss_msg { + u8 cmd_opcode; + u16 cmd_data_size; + struct mpfs_mss_response *response; + u8 *cmd_data; + u16 mbox_offset; + u16 resp_offset; +}; + +struct mpfs_mss_response { + u32 resp_status; + u32 *resp_msg; + u16 resp_size; +}; + +#if IS_ENABLED(CONFIG_POLARFIRE_SOC_SYS_CTRL) + +int mpfs_blocking_transaction(struct mpfs_sys_controller *mpfs_client, void *msg); + +struct mpfs_sys_controller *mpfs_sys_controller_get(struct device_node *mailbox_node); + +#else + +static int mpfs_blocking_transaction(struct mpfs_sys_controller *mpfs_client, void *msg, + struct mpfs_mss_response *response) +{ + return -ENOSYS; +} + +struct mpfs_sys_controller *mpfs_sys_controller_get(struct device_node *mailbox_node) +{ + return NULL; +} + +#endif /* if IS_ENABLED(CONFIG_POLARFIRE_SOC_SYS_CTRL) */ + +#endif /* __SOC_MPFS_H__ */ From patchwork Tue May 11 15:38:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12251417 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=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 B22F1C433B4 for ; Tue, 11 May 2021 15:38:57 +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 0ABD66162B for ; Tue, 11 May 2021 15:38:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0ABD66162B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=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: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:In-Reply-To:References:List-Owner; bh=WCZ69B+zs+0ZAXGtauUDapqgkckqPF/xNj9ZXrXzYK8=; b=At4rwcrlD8WnXLIcvUEfm0DOKj Mm7NHELYpUnqp3hXVldUeON2FBaHFFGWJzKO3793Rdnp9LZ4xcB2QIF2kCCUoZ+1p3BkuM8DIg67C c1R9xUAYnJX6U1aM3dnigv+RZVVHBS5BOMo78fzA/KQkd60LdjH2yflEJM5yNjiFtiXtzKGGezckS RId49BUQwg0bHcWMu7l4gzd1gvTAh6neyPP59b4frp32JAulhw+cOKjmR3+cgPfQKDT1XsHccLA+E F7N8V0RdkBvOKUUd5YeUkZKd+wK0sf/qt016sYnbMc1EMxIVrLuEtEcwrADYViXrZ1ekYu4A75GEA ptaX4M3g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgUSz-000cw9-Uv; Tue, 11 May 2021 15:38:38 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgUSx-000cvR-Hg for linux-riscv@desiato.infradead.org; Tue, 11 May 2021 15:38:35 +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:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-ID:Content-Description:In-Reply-To:References; bh=es0wDremQNWOktdkE3WCmmcjyWmeF7qaGKysftxpXq0=; b=V7rWGtr05eRnCPwjptsh/4IvLA ktWVvj+9/mh1wD9hWOVGuJMNc/EGV+HrSdMOQ+pqq62aoKF0MaYSucPca9VkEoPcuETZD1xfUrUOb NSUxA0LXJckTNBCZVg2Gsmsg94gYEtctosjcXkrSdMhXTNwhR2LJjJOroRzx5CP52K55IlgMhJVHW p8zY60J7bEXdzvKpHaYYL8MSxZ00+/SLK6ExEO7oYNW4qR2JYyQ0lcRPgW1ITaTQlq8ujz3jlwvK4 gc2CM+GGGbQqvxx64XVRm7REjxfQ56NSZNhLmaKo1cW7fprYeM/w5pFqtlabpO9y8ZWV+gVPLMsLB zuwZpsUA==; Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgUSu-009ixJ-RB for linux-riscv@lists.infradead.org; Tue, 11 May 2021 15:38:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1620747512; x=1652283512; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=4p3t+4D2U+AKPg4n/O+ArrbzKLVo+0girpiXU0sKiVo=; b=JwBIguSfwz8fQL+6CemHHiJkPGCpilC3Vcd2TCld+Mf7szRA/YLPX9cO 4LOEysaSiOjwjIb0jOLzfjul5rnnBfeIonlN4cf3XeU/jHLC8M66DMAJU 38pia+2FaCGdWLGg0PQbYzC1N8lO6CzwXRFbLyXo1pw/gJEYzBr51bqrE LfAEQ6zoH5e0Wlo+D1HSa5C7uqaqNGaOf1I/BUhsVGR73JW5Y4TV2MN0W XBlUT4vT1JCrrtpGeNbRdJCITkgr64eZwWpE1Bri7yMpDK6E0GGTVcNYa w8iXETd2F4uEeVMhUqz9EQKX4CbTXXWNk1JEIFFl6pqegWvBmpqamGHED w==; IronPort-SDR: 4xe8/nHLh0ufC9t1GOMwyzfFKW1sZqa+2ZwWJoJOAXMkjDy98dC4WmShbyT+bJ4niN7LQRZSh4 S38I2Q8ielnimohsimFXDuGWFLlnD9FEHwuOnRFRTF43Bx2uzD+jhhmL5USOZpGOuqeT+9hQsr 7ChDuiO1bC9OCCU7BI8oZObjybkb7JHUX/DSv4DexepxONMTuH3GOl3Y7OvU4le36c/Me/T91c vhVX8Ygm6H6xrjDH8HYG7WxohzDp8m7aMp77n3SQJq65mIuIkdc3BCTdIR8EdytzBh+eHpP0Cd zjs= X-IronPort-AV: E=Sophos;i="5.82,291,1613458800"; d="scan'208";a="121227821" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 May 2021 08:38:31 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 11 May 2021 08:38:31 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Tue, 11 May 2021 08:38:28 -0700 From: To: , , , , , , , , CC: , , , , , , Conor Dooley , Rob Herring Subject: [PATCH v7 3/5] dt-bindings: add bindings for polarfire soc system controller Date: Tue, 11 May 2021 16:38:28 +0100 Message-ID: <20210511153828.6579-1-conor.dooley@microchip.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_083832_913478_A0D7BD82 X-CRM114-Status: UNSURE ( 9.06 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Conor Dooley Add device tree bindings for the MSS system controller on the Microchip PolarFire SoC. Signed-off-by: Conor Dooley Reviewed-by: Rob Herring --- ...icrochip,polarfire-soc-sys-controller.yaml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/microchip/microchip,polarfire-soc-sys-controller.yaml diff --git a/Documentation/devicetree/bindings/soc/microchip/microchip,polarfire-soc-sys-controller.yaml b/Documentation/devicetree/bindings/soc/microchip/microchip,polarfire-soc-sys-controller.yaml new file mode 100644 index 000000000000..2cd3bc6bd8d6 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/microchip/microchip,polarfire-soc-sys-controller.yaml @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/soc/microchip/microchip,polarfire-soc-sys-controller.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Microchip PolarFire SoC (MPFS) MSS (microprocessor subsystem) system controller + +maintainers: + - Conor Dooley + +description: | + The PolarFire SoC system controller is communicated with via a mailbox. + This document describes the bindings for the client portion of that mailbox. + + +properties: + mboxes: + maxItems: 1 + + compatible: + const: microchip,polarfire-soc-sys-controller + +required: + - compatible + - mboxes + +additionalProperties: false + +examples: + - | + syscontroller: syscontroller { + compatible = "microchip,polarfire-soc-sys-controller"; + mboxes = <&mbox 0>; + }; From patchwork Tue May 11 15:38:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12251419 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 B1042C43461 for ; Tue, 11 May 2021 15:39: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 0F75E616EB for ; Tue, 11 May 2021 15:39:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F75E616EB Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=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: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:In-Reply-To:References:List-Owner; bh=8sBzXkycwZhnnIbSjWzNLju9jpKPPP8THll4enuejF4=; b=Ac9ANu/7SDEA9w/y+7YLmyFquI HBkGGWIAHm/Ld1CTmtku2lHPthl/6EwEhs7XntxbX1ZqF7C+A+C+65Vb794koV4vBO7ISUesVMWLD G/PZOT/VIKIkO+MBSMrmbXzAVQHjTXD1+9yz0Ug141TwLLl/6AOClU0oCW3jVxxBoztpCEb74gf/4 nrU/lDZj0qbvM1kN6XOkg27ccQIDjAUAwCxqdXr86W4kO8FY8jn8Vt0iqnOkHWs1UYzkTT2J8p+B5 aIHjZn/DPF80F0UQp+PaSg7MP5MDT5idUPI0sXfH8o7luLT7rDr7zOYqHkUOgOuDzW05y0d14FlbV Z/KhO4qQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgUT5-000cyW-4K; Tue, 11 May 2021 15:38:43 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgUT2-000cwv-7S for linux-riscv@desiato.infradead.org; Tue, 11 May 2021 15:38:40 +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:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-ID:Content-Description:In-Reply-To:References; bh=qUYvSQCp7Rlyak/PIFvaKHnz+NLkkhXRKHQPfs34Pbc=; b=LNb12anrFwI55wH2XLhb/EJFax gnccd/bpl3yZr3V3Oszo1E4dcBYwGhgky7woSKU9HJEA/yts2Gar0ASkq1/CezXo5eVnK3orxR6Iu WtZEpj7IvEvfyOS40fJyx56hEfrhNOkITrb1g2p2Z95iXWBNYdoU1fbvTKbPP0MMjq2zMQBsAC23n AJauZGDm38FAP6VnpeO4BchwxRWO5KT9DYclAnaqKw2oSHFnvb7TLAmbIen5bdry5j6mm3VBczMnN o8D0wITe41XsFx35xtploG5NpBFWHmMOuhhsGYUszI6A2tX20KWxXbv1BpubyUeFUx4O+lkUIFt4c uLCX/2gg==; Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgUSz-009ixJ-Ef for linux-riscv@lists.infradead.org; Tue, 11 May 2021 15:38:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1620747517; x=1652283517; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=U0hIUeY4b5TuO5xsSS+g8pI9TVKt+grIjGH3oSWbGcQ=; b=r94EWg9fYsF86Ub3g8njy5cvjGVCEXLx7pVUAf6K3QmzKaZssJytDVAR 0jVK6iMdMPKrnk/UUviAbzfHfoAJml4rGv+rfe6jJTbIMgMibUidwdKhM T3vqEdm3cqjqO8uc6selMWsCqSGzHUkc1J7mRaJ5tc91pc/2JUQF3cxVl DHKUBYVrscalyoWA9zBV/zuTr1mdoEM292uYgIZdqUH0APTjM2ebm2/QI 3+fXc79rj1Im196LCdsMZEfVuhDNJQQ7cbr1+20WFj8lmKzACEfYjEl05 G0GNKi5yZTQJv/8V6zi+kWYXs2IsaHScBt5XG8zMbKJbKaG2UxS3Jow8g g==; IronPort-SDR: RrGsJABCWv9kSBFpvrzWkxGn75HdsuCcOB9qEdx0Pfbjql7Ax4H9sItDFyTmu9Wa/h2ZG4iBmd ATn8n5eo5oNp3xrt1d/5ga3P1lS2kXdho+geXaYKaRDVYTzveoQMG9n39Ohw10kle48f1XpcHU F3lzbIxHu5/DULCKvxPxYrHrdQEcHf8oje6UM32AqvL8kleklTVHTV2Hv+gGIRFgW1rIL8w7ce sUX7dODtHLbbGfoMRBKgk6eMPIhP6vemPWahUESYMw48fXXYg3PPmb7uASQWtYvsF6PRHjYjKu FEI= X-IronPort-AV: E=Sophos;i="5.82,291,1613458800"; d="scan'208";a="121227846" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 May 2021 08:38:36 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 11 May 2021 08:38:36 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Tue, 11 May 2021 08:38:33 -0700 From: To: , , , , , , , , CC: , , , , , , Conor Dooley Subject: [PATCH v7 4/5] soc: add polarfire soc system controller Date: Tue, 11 May 2021 16:38:33 +0100 Message-ID: <20210511153833.8120-1-conor.dooley@microchip.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_083837_531136_7E275F73 X-CRM114-Status: GOOD ( 19.88 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Conor Dooley This driver provides an interface for other drivers to access the functions of the system controller on the Microchip PolarFire SoC. Signed-off-by: Conor Dooley --- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/microchip/Kconfig | 10 ++ drivers/soc/microchip/Makefile | 1 + drivers/soc/microchip/mpfs-sys-controller.c | 119 ++++++++++++++++++++ 5 files changed, 132 insertions(+) create mode 100644 drivers/soc/microchip/Kconfig create mode 100644 drivers/soc/microchip/Makefile create mode 100644 drivers/soc/microchip/mpfs-sys-controller.c diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index e8a30c4c5aec..b33142e020e0 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -12,6 +12,7 @@ source "drivers/soc/imx/Kconfig" source "drivers/soc/ixp4xx/Kconfig" source "drivers/soc/litex/Kconfig" source "drivers/soc/mediatek/Kconfig" +source "drivers/soc/microchip/Kconfig" source "drivers/soc/qcom/Kconfig" source "drivers/soc/renesas/Kconfig" source "drivers/soc/rockchip/Kconfig" diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index f678e4d9e585..10cfdcd972c7 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_ARCH_IXP4XX) += ixp4xx/ obj-$(CONFIG_SOC_XWAY) += lantiq/ obj-$(CONFIG_LITEX_SOC_CONTROLLER) += litex/ obj-y += mediatek/ +obj-y += microchip/ obj-y += amlogic/ obj-y += qcom/ obj-y += renesas/ diff --git a/drivers/soc/microchip/Kconfig b/drivers/soc/microchip/Kconfig new file mode 100644 index 000000000000..eb656b33156b --- /dev/null +++ b/drivers/soc/microchip/Kconfig @@ -0,0 +1,10 @@ +config POLARFIRE_SOC_SYS_CTRL + tristate "POLARFIRE_SOC_SYS_CTRL" + depends on POLARFIRE_SOC_MAILBOX + help + This driver adds support for the PolarFire SoC (MPFS) system controller. + + To compile this driver as a module, choose M here. the + module will be called mpfs_system_controller. + + If unsure, say N. diff --git a/drivers/soc/microchip/Makefile b/drivers/soc/microchip/Makefile new file mode 100644 index 000000000000..14489919fe4b --- /dev/null +++ b/drivers/soc/microchip/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_POLARFIRE_SOC_SYS_CTRL) += mpfs-sys-controller.o diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c new file mode 100644 index 000000000000..3cfee997fa59 --- /dev/null +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Microchip PolarFire SoC (MPFS) system controller driver + * + * Copyright (c) 2020 Microchip Corporation. All rights reserved. + * + * Author: Conor Dooley + * + */ + +#include +#include +#include +#include +#include +#include +#include + +static DEFINE_MUTEX(transaction_lock); + +struct mpfs_sys_controller { + struct mbox_client client; + struct mbox_chan *chan; + struct completion c; + u32 enabled; +}; + +int mpfs_blocking_transaction(struct mpfs_sys_controller *mpfs_client, void *msg) +{ + int ret; + + mutex_lock_interruptible(&transaction_lock); + + reinit_completion(&mpfs_client->c); + + ret = mbox_send_message(mpfs_client->chan, msg); + if (ret >= 0) { + if (wait_for_completion_timeout(&mpfs_client->c, HZ)) { + ret = 0; + } else { + ret = -ETIMEDOUT; + dev_warn(mpfs_client->client.dev, "MPFS sys controller transaction timeout\n"); + } + } else { + dev_err(mpfs_client->client.dev, + "mpfs sys controller transaction returned %d\n", ret); + } + + mutex_unlock(&transaction_lock); + + return ret; +} +EXPORT_SYMBOL(mpfs_blocking_transaction); + +static void rx_callback(struct mbox_client *client, void *msg) +{ + struct mpfs_sys_controller *mpfs_client = + container_of(client, struct mpfs_sys_controller, client); + + complete(&mpfs_client->c); +} + +static int mpfs_sys_controller_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct mpfs_sys_controller *mpfs_client; + + mpfs_client = devm_kzalloc(dev, sizeof(*mpfs_client), GFP_KERNEL); + if (!mpfs_client) + return -ENOMEM; + + mpfs_client->client.dev = dev; + mpfs_client->client.rx_callback = rx_callback; + mpfs_client->client.tx_block = 1U; + + mpfs_client->chan = mbox_request_channel(&mpfs_client->client, 0); + if (IS_ERR(mpfs_client->chan)) + return dev_err_probe(dev, PTR_ERR(mpfs_client->chan), + "Failed to get mbox channel\n"); + + init_completion(&mpfs_client->c); + + platform_set_drvdata(pdev, mpfs_client); + + dev_info(&pdev->dev, "Registered MPFS system controller driver\n"); + + return 0; +} + +struct mpfs_sys_controller * +mpfs_sys_controller_get(struct device_node *mss_node) +{ + struct platform_device *pdev = of_find_device_by_node(mss_node); + + if (!pdev) + return NULL; + + return platform_get_drvdata(pdev); +} +EXPORT_SYMBOL(mpfs_sys_controller_get); + +static const struct of_device_id mpfs_sys_controller_of_match[] = { + {.compatible = "microchip,polarfire-soc-sys-controller", }, + {}, +}; +MODULE_DEVICE_TABLE(of, mpfs_sys_controller_of_match); + +static struct platform_driver mpfs_sys_controller_driver = { + .driver = { + .name = "mpfs-sys-controller", + .of_match_table = mpfs_sys_controller_of_match, + }, + .probe = mpfs_sys_controller_probe, +}; +module_platform_driver(mpfs_sys_controller_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Conor Dooley "); +MODULE_DESCRIPTION("MPFS system controller driver"); From patchwork Tue May 11 15:46:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12251423 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=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 3198BC433B4 for ; Tue, 11 May 2021 15:47:05 +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 88B4061260 for ; Tue, 11 May 2021 15:47:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 88B4061260 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=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: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:In-Reply-To:References:List-Owner; bh=6e6ZYvKhjvRAMSr/98Y4l8t93PDjmf46rBZrC/L1hNk=; b=VU2cTKMqQFQlGn7046E+mIfGVW Stp5EfWV4jh6tC8LG3cvz+xEO/VN1l60657Emr579eiN+fuNlgwU4GXk6yb3K3M9ASd3/CiQTygwq OX+3Mb2Oo7tA1taMpCIKwd6CprN0h+qFMzH0J2/V+4326gDhOZS2+eNlsIRJYhoznMCQQYgPrp+Qv +Jb8mEDZSsAbGP4lcAKxJvPYxh9fm0JaeBmsceMbdG72jlrjo3s43yn/+QDOdZkUXqAXdG/1R0VLi fq93AzTt3PSJPNGkM3o6QUzIYKISabkvWYF5whDhHVRmJJxvufoGfbeJ3D9GSUzjHfSRWab0EtJsD 6NZFX6sw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgUav-000dwL-NW; Tue, 11 May 2021 15:46:49 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgUat-000dw4-B6 for linux-riscv@desiato.infradead.org; Tue, 11 May 2021 15:46:47 +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:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-ID:Content-Description:In-Reply-To:References; bh=J5J64PHzL2oDapIhvjuJs5+Ku143FJlS733gtsYTsps=; b=zVyZ33bCBvelvDIeRxOw9Ka9oB TY75r/Vpqakq5PKQTBS3n3vh9MpT6wTTFOzTOOi6FcF0DpVa9uCcMzn1++R7IauDCbb12MTmam028 gTYToR7ztaeJRplb3o4ofZyhBTy2rl3xyEilROyQmB20VwgnaSQtlAdRNMfydnJjvbPIkGChJ2fBa /mMdQznABFInhpEC32CszEHWnp770tiMUZSOhfOstD3hJGj5v6C4CfT0s6iK3psnNZt9C/ws5x+b0 YTnsAPOwOsebc3f2dWs9354ICWFVgJoIrf779UPfKYiWuqLnAFmibI8LZb41oEMK0gbhd25UKZqqm CG6u+8Bg==; Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgUaq-009jGD-UB for linux-riscv@lists.infradead.org; Tue, 11 May 2021 15:46:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1620748005; x=1652284005; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=2wFNoG8f366htGhQt8VAHF5ZyPpaUVl2/KxdsBD2KTY=; b=fAX2fUftE0e3WSJwlVg2mSsaDYRTdarhgPLbvh8uNDy026wJeR1H9KT1 YA0wPqq8j8ViIN3Qq0jIC8hKUmf66lhn/qPt0vvh+f0R9yhF0A1H0peWM WMwF3r82JYbm0P1AANmEhN0HYB7bSLZwfPjuvGZN9TzgsRiPNFL1lz6qC h7ZP+7tKScBCfqW9Deqh2wUPQciHhzv9Vw/ZaFrJmIpwEaKVGxr7LA7ip QTiI7DSnX+rCkOyaWvIfDEMz+ChZE0hp9agK0zLViKq9FB08fBf7k4N0W 6l5SH/gAfMO0mv4Cs7RybZDvTox9UeOR5TOOiPwFDX8WrN29UdYX4zab3 g==; IronPort-SDR: 7VPdf6u1uldYlANmAUTf8Cs9wmc1Ja/pJAmKHvFRoVADALlJPQFQHYVm6ULh7yL5tyNfznn7OA Cr87ifwt3TW08bknBl+fs8kxmuTlRsfq2WocO9faRGtn6o+iJsZb+gahRcf7RpwqEte0UBg1CI aPj1pUJngeVg4aT00lvdl5UqIxz/i/qmZTmKPJc5GXyZLv/EmHJkJt7QMijpzxBQ1HS5w2yQy2 8U7JzMFBVKzUajznsvtkpfdFSduXnOWJhZe4zT6MEeawYe8NCDcE8ZOo3XbTFGdPP4/j6Ca0Pf MKs= X-IronPort-AV: E=Sophos;i="5.82,291,1613458800"; d="scan'208";a="120688921" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 May 2021 08:46:44 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 11 May 2021 08:46:43 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Tue, 11 May 2021 08:46:41 -0700 From: To: , , , , , , , , CC: , , , , , , Conor Dooley Subject: [PATCH v7 5/5] MAINTAINERS: add entry for polarfire soc mailbox Date: Tue, 11 May 2021 16:46:40 +0100 Message-ID: <20210511154640.6831-1-conor.dooley@microchip.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_084644_998192_FDF93C98 X-CRM114-Status: UNSURE ( 5.33 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Conor Dooley Add Lewis Hanly as a maintainer for the Microchip SoC directory and the system services mailbox driver Signed-off-by: Conor Dooley --- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index bd7aff0c120f..c3ec9407ce2c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15693,6 +15693,14 @@ F: arch/riscv/ N: riscv K: riscv +RISC-V/MICROCHIP POLARFIRE SOC SUPPORT +M: Lewis Hanly +L: linux-riscv@lists.infradead.org +S: Supported +F: drivers/mailbox/mailbox-mpfs.c +F: drivers/soc/microchip/ +F: include/soc/microchip/mpfs.h + RNBD BLOCK DRIVERS M: Md. Haris Iqbal M: Jack Wang