From patchwork Mon Apr 12 16:03:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12198457 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=-16.8 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,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 DAF17C433B4 for ; Mon, 12 Apr 2021 16:05:20 +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 7D4676121F for ; Mon, 12 Apr 2021 16:05:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D4676121F 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=vqU+At+1IF+QdFaQhA6DXvHM+xO80H1DB1JuxBE4C08=; b=bCu6LzVxrbbwVLjPMK7NB+1E6Y o7STGnJVstLHcJL3yTE3OhW4Zmi31hDnWKEF9qqSCeuVxovnFBulBECJSHuf0vhRU8f2IfRPDJBEZ JllK7sb7UoGHAmCf6XkcnpV3FA15g4gH6rG9rD6Q/DMZjQt+7cNo/ThIGz+b5lASs6YevwSY3igJy rTN0QbTkgwe1hQ1dy+dHvom0xYJfIq9t4ay4hviA3lwBRlyeQrLHdvvoWkcihmJQig0pv2cJGDIAW 1sjjHx95aDWC51fkntsiTFk70NPyxxn6UU7qVvjB7lNeeqRmdi8ugUQWoWtlHIKx+UZ4lyZS6JDBo j6WT8G4w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVz3g-007CJC-Q6; Mon, 12 Apr 2021 16:05:04 +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 1lVz2l-007C45-40 for linux-riscv@desiato.infradead.org; Mon, 12 Apr 2021 16: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:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-ID:Content-Description:In-Reply-To:References; bh=J+q9T9I/lnn/9yhGyShXTCd9b/ryIOKtSnzh412rAic=; b=cqQ8yDl+MsQXXJ8s0dRxMuqN37 aj6SjGhw67HE6vFX0IOnNCJ+yIkRbZZgcchcc4oWWOAf6eHc7GiFCKP/SPbR9dkp3WN3G0PDk6lQG 4lxGWhCROPtjLmMAtv2bHPbHd/+DU/aBt/qp8Vs7Tqwxw3fYWaj1UqawKSkNdCvXJKduAfS03TSZw aTAJpjzridnHZ66G+sxCnihv6ll8QpV+6pXoHPFPaUjls2XTDvtEHK2AHpCZlrH3INdwD3ba2v9a2 YSWMtRe9S/W0ipjW1R/9t97PPIj+syUsAHg7DBCM2XJo5/HaRDueT7CxYoXB5dAsUMrfnTI+EtkeT JSfxWHSw==; Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVz2i-006N6O-11 for linux-riscv@lists.infradead.org; Mon, 12 Apr 2021 16:04:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618243444; x=1649779444; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=OV+0YsG6sI+ZJKXiOdu5QUj/bWtZRv1ZITFCJDfpJnE=; b=a072CcA7OFSYHSTXDyJzA2EqMPDOMZOxre1igDTIE/V/OEVV0pL5X8Hx KfhZxq3p5On/BKn6ypcV3OasLRdK92P/3PzvyjoDb6ra8UAZlvNjS0EN3 MX0CsN9vnSJxAQSsLhTcWWAfOpWjSgDsyexlu+v/hS+Ap0/ijIzc3qcOg Hq89vfmeXCcLZnrvU7sZunBvYy+PDlZha7zkH9x/oadO7tUR1gZXUm3rx j9xwI/bWeX7Qd3/OWUIO8HyaRwlynP2F8SqbWHBpywrx2jBYiMBhHGWrA 379ixWjEnkuO8i9uA5uawJlP2EUxwShXsfKw43PGaqJX5UrWXAOS9iNC1 g==; IronPort-SDR: rpQ/WGyJFW1Z+5TG5wKI69Z0fLRLTYWYgMmYyYoy0twVUn63U++lDAPgxHDR7qluxB+y/r/UzD qKaQ/IgszyiZFpm8GMqdhy7BuVu9dJNGwjwS+EMHPxSYTlBAfZfqhVz8rc707ot3IOLb4S8hDo INWER12GnuOCp/yJZDJHpQRWeTKSg0FXVlPjG975hBhLn85z5MMFZBhHCziJjMwLNh924O3uuo UbDGZYjxJ56dd8Sd+4BsqRtLNTeGTe4WABzQ1zimj3r5Isq891pcMbo9k5Yx2I7Mkju7lfC724 iQc= X-IronPort-AV: E=Sophos;i="5.82,216,1613458800"; d="scan'208";a="122704167" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 12 Apr 2021 09:04:01 -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; Mon, 12 Apr 2021 09:04:01 -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; Mon, 12 Apr 2021 09:03:58 -0700 From: To: , , , , , , , , CC: , , , , , , Conor Dooley Subject: [PATCH v5 1/5] dt-bindings: add bindings for polarfire soc mailbox Date: Mon, 12 Apr 2021 17:03:58 +0100 Message-ID: <20210412160358.19309-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-20210412_090404_140477_1FAB7FC2 X-CRM114-Status: UNSURE ( 9.29 ) 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 Mon Apr 12 16:04:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12198459 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.0 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,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 6E86DC433ED for ; Mon, 12 Apr 2021 16:05:26 +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 D43176121F for ; Mon, 12 Apr 2021 16:05:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D43176121F 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=BvgNk+1/CCvHOyfjNrVZWtcl856voR6E0URqhjhNIq8=; b=QTD53wkE5gJZfJYMtyJHeU77cG N06duceOU/dGRDREmjpRQh8vGlVeFJpLd/4SHPyuvAFAJZafqxzsytqtJqrka+wq6pKPWiopWLy08 ijfmAGI5czlI53hTwt4IOsRsbRWhkxVpwJcOfDlAagVg2tii32gyGIS9H/3KnawJXOnNa3H92tD+Z 2iD4aSjg1sbFlA7aRDzevfQqAomCj7wpp4tY0DloWpZitQCgwyrvYvut/LLqomK52W0xMmZRYtGzV KNTZsoDeTj5R+PahFE2JdntfBmKrAek04F7MPyd8ow/iKRvez2BrInSakWB927KNj06+DWFf8kWmj SfRmKV3w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVz3p-007CKx-K4; Mon, 12 Apr 2021 16:05:13 +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 1lVz2o-007C5V-S3 for linux-riscv@desiato.infradead.org; Mon, 12 Apr 2021 16:04:11 +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=p7BuhwlSDcnzN4djdQE9EFts+gEFz/OaauGP0fzkyBQ=; b=kiWutT28zc50mfBTFgL5BVpo1i 5E38qWk96MntoBYxAilnECH5dp3vWci7ELDTKCxky5BayWi1ICM3Vhi7zFg2qHlHXBa5MKGfYi6g+ uPJl0wYBYxpH4s3vbH23LdXToLCzbCFkgyQp4mHvBISn9AoOdZi35Nk81C6nfGQMShko7kCBkpg9M 0dvcOItIbzCEVzAqRLeYNRsU4NFnhCjBkNNc2lcsMXsuVPCwcapqaZNXYSUw2FYJQdqhM3VYVoe4O H9Cem+1UQrKOO+7jdUH35AZDfj1/J5mIn3oQLWw2rUrl7VmGcqsWFG2M/RFVjnuJDet0hxP9kQqEO 2AmXtWnQ==; Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVz2l-006N64-DA for linux-riscv@lists.infradead.org; Mon, 12 Apr 2021 16:04:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618243447; x=1649779447; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=rLxoEsVz44U7c4EQ6sZY99t/BNBDpYMAcbJhq7gH+e8=; b=UgXdx4AWLHdofk/lzVkgXO4VutjC5MspteLZSKUeAi0mYGnWx9Uum7iV w7DKDKU+no06IA25ak7mfVaJTG1dqtiS8S9kTETxMnwa7EhMjP7LFaYi+ x/7TxBTC1TBXoe/jEGbcy4HpQuZ88/oH/iBActDOlYuYoXlLMZUxiFh/C Aw+Qy9yUiTT9l7s8kO5m0T7yw3HXDLg6COWKceUg6KTwhcaAEMJrOYv+l j+4UEKtV58kSxJ9z1E7+46BN1+QJR2yy3mfWW/yr7ysJPZYTiys3etxyt pKLz6ZmdjY5vdIhtavIlFmEZq4Vl9wMb2L+Et2NcUGG/44KgaL8TEZ+Uy Q==; IronPort-SDR: dAxWhG8BmIrKAb7JKpH27oVweWOrnEJaJzVQi+HLm2G41jU6Ro2hfENuYBogaPYN81VReOXFyw fcCqrvxg4Q+sKpgEQFj4yStLPbd3eIGvlegBbfsJT5yfURqZS2O8oC++yFck4bh6hCZ3REFb1f uiHfO9rCvA3cWeMQ2AbJio2Xq0WFthr2BaBG+rdm68jH/FFHWpD21WkOHq7V1rYIdYVodDixuX 8VY19TAjVdgmDEpzMSAiQtjivsQ3iDh9lFo2Dbm9P3/zk33rmAlSqukO9O+UQVVKG6QHmgdzDs A10= X-IronPort-AV: E=Sophos;i="5.82,216,1613458800"; d="scan'208";a="110516089" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 12 Apr 2021 09:04:06 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 12 Apr 2021 09:04:06 -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; Mon, 12 Apr 2021 09:04:03 -0700 From: To: , , , , , , , , CC: , , , , , , Conor Dooley Subject: [PATCH v5 2/5] mbox: add polarfire soc system controller mailbox Date: Mon, 12 Apr 2021 17:04:02 +0100 Message-ID: <20210412160402.19394-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-20210412_090407_606908_A4F2DE4E X-CRM114-Status: GOOD ( 23.67 ) 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 | 272 +++++++++++++++++++++++++++++++++ include/soc/microchip/mpfs.h | 56 +++++++ 4 files changed, 342 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 f4abe3529acd..b37268bd5004 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..dd51e11d287a --- /dev/null +++ b/drivers/mailbox/mailbox-mpfs.c @@ -0,0 +1,272 @@ +// 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; + 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 struct mpfs_mbox *mbox_chan_to_mpfs_mbox(struct mbox_chan *chan) +{ + if (!chan) + return NULL; + + return (struct mpfs_mbox *)chan->con_priv; +} + +static int mpfs_mbox_send_data(struct mbox_chan *chan, void *data) +{ + u32 val = 0u; + u16 opt_sel; + u32 tx_trigger; + struct mpfs_mss_msg *msg = data; + struct mpfs_mbox *mbox = mbox_chan_to_mpfs_mbox(chan); + + 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 inline bool mpfs_mbox_pending(struct mpfs_mbox *mbox) +{ + u32 status; + + status = readl_relaxed(mbox->mbox_base + SERVICES_SR_OFFSET); + + return !(status & SCB_STATUS_BUSY_MASK); +} + +static void mpfs_mbox_rx_data(struct mbox_chan *chan) +{ + struct mpfs_mbox *mbox = mbox_chan_to_mpfs_mbox(chan); + u32 i; + u16 num_words = ALIGN((mbox->response->resp_size), (4)) / 4U; + struct mpfs_mss_response *response = mbox->response; + + if (!response->resp_msg) { + dev_err(mbox->dev, "failed to assign memory for response %d\n", -ENOMEM); + return; + } + + if (mpfs_mbox_pending(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 = mbox_chan_to_mpfs_mbox(chan); + + 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 = mbox_chan_to_mpfs_mbox(chan); + 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 = mbox_chan_to_mpfs_mbox(chan); + + 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->chans = + devm_kzalloc(&pdev->dev, sizeof(*mbox->chans), GFP_KERNEL); + if (!mbox->chans) + 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 Mon Apr 12 16:04:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12198461 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=-16.8 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,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 B32E8C433B4 for ; Mon, 12 Apr 2021 16:05:34 +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 5202F61026 for ; Mon, 12 Apr 2021 16:05:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5202F61026 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=2G9qPcR+OK+Gpaq1dFT6GhAjjNbcdh0Q7lfPzGOpgbg=; b=X4ZjW2ZN+6dRy6m6WRNqYn+1NQ vy45HwMNzO51kx4Konha91vgRfnEoolnTpSdI4ztQm5zMdfsygCNmz0q/i4MMSM+b7iis89k7glup KHpYLiwngmFHhpYQ2a4T4nC5T7xSvIzFN3zPZ8dL9SK9GllmD3shgizKORYdzopfNUWaV6Af/XVEe zQJSeVmfPqAYg0u2mo2b5CbeClW9nkwQgdTwZ8P471jlE1fa0Q8MMhZZr5VOa9pR/RfUVf+DIzivN eGYW7El396JUyZ2a5bE3JUwN6cQMTXDxANT8k2Vd26UT57LtHUN6j02FMtx701l/w0umnTDSy8tg9 ThlOe1AA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVz3w-007CMb-5j; Mon, 12 Apr 2021 16:05:20 +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 1lVz2s-007C66-T6 for linux-riscv@desiato.infradead.org; Mon, 12 Apr 2021 16:04:14 +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=pkUstEE90JUrN7CzMGeZgqDC4hNLvBVVu0Jijk7IOWY=; b=1x61bZKVFt3XSyr2RQ/v4smnvh 3Xkfx33G5sSEoUZmOKydvkfbx9cTby0KSljOiC2exk6/52AouLBWb1AtlfujyTr3ZWWTzzZE1bgbc n3pqAJL7D4vykZxDUrKpCLlIE2kUEwMdSQEYtpjdm9JBXKXSL7USay4UlZAQ2jrf+1OiKnFh4cXZL MI6FVETEDZlC2501DcRk3HnLEpQutZ8wg9HikbVEc+XvqiD6myDewah12yLJV+UvuhXL/s3i82sHs JqZdaTU3Izb2ivtXSW5oHiLw9HmTN0Nax4yk2dp70YAos06i9S4NNdE7QvSvO4nv1GF4Ta+e3GQQO eyLpevww==; Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVz2q-006N7S-0m for linux-riscv@lists.infradead.org; Mon, 12 Apr 2021 16:04:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618243452; x=1649779452; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=W8vfcucLx9e2rFsTr+G35b4yT9J7bODEo1nq+kavg5Y=; b=pRKFdSpRYIPhSszrRTsWf0mVVhPPNCip5KH1Lpqu4tf8lR0ZHZ9X1aNY 1qMdefo2y+TyqPOJPC1Xm7Kz27lM2zS+e9Tj/GqSutixXcoaE0TP2NXdD 1XVP8tSuQWabmpxaCrj82+dWUY3f7FZCv8Sbhy7AjZQ2DVzpYqKEIl6sG vQT/RB/JxlQVuwd0hZVnZhkDSKT6fUG3wF/gAGop9pi4R1pnf+nABJBal AF9Yn9vDJ8caXuWkur74tKiEyT3ccV8W5uJoZl0/TP7WOje+CMXNJ8qmO wbJqufmCHtUl+NFykBOmiE5SVLA3KufshAcAgRr35hxLyHpmuqnBP3olM w==; IronPort-SDR: eYsqM6ETiRJuLIGKtb08FH7VdfWHIid5fn5A0VnQtDItra/clslD6qBvYj3YiIbjX/iCxTQAP7 v9ILnJfpqRA2wnM7E5qJBqfVy8Fooxe6NsbKtvc+OPJIAwz9ZX4eUif+mLjHe4ZfznaGS2XtiX KWdtzbV9WeIjNTdq1o0XdP7HQfKqiS2rA79rslIaasbPYforAXCyle646ZUEjmACcnES44tV+o Wx/6TiqxsS/CpE+LOTKIVrDua2qRCS8Ebw6utrizNQe7OVrf9f3DKJJCLMSKk4svyQWBbFNTRx ztE= X-IronPort-AV: E=Sophos;i="5.82,216,1613458800"; d="scan'208";a="116142085" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 12 Apr 2021 09:04:11 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Mon, 12 Apr 2021 09:04:10 -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; Mon, 12 Apr 2021 09:04:08 -0700 From: To: , , , , , , , , CC: , , , , , , Conor Dooley Subject: [PATCH v5 3/5] dt-bindings: add bindings for polarfire soc system controller Date: Mon, 12 Apr 2021 17:04:07 +0100 Message-ID: <20210412160407.19462-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-20210412_090412_091113_D638C9F4 X-CRM114-Status: UNSURE ( 9.30 ) 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 Mon Apr 12 16:04:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12198463 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=-16.8 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,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 E5129C43461 for ; Mon, 12 Apr 2021 16:05:40 +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 8B5E96121F for ; Mon, 12 Apr 2021 16:05:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B5E96121F 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=mrgL8eZSByOX1kK8i6z/fMxEZd xXtZLbAK+hLb+HsG+dMDNaHV45lk42vr9BHuuF4a+y9IoQsK+Ddr0pH13lzQpQ2W9aRkxagOcFqNP iOxTrMEB0ORHL4IF4rivh5Tvv/A6BeoppmCZnQS3tGmAKNTnSypS6mKyiMWgixj6s9OHt1MpozRP4 gXdTParjpNkp0LULFKrPK+9GqW8lCHuu8XL8F8Puklyf3dZBcw4VsAEA3HAsZDtZqF8oLMDfCgKrE 1tZU6eoN/q/XTaMkmk7GnszNeOVa9j3M4/SwNSnb53INJ+D89rsN31OvytF2y1lb+ifxrhREGKJq1 CoqygMPg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVz45-007COx-4R; Mon, 12 Apr 2021 16:05:29 +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 1lVz32-007C8r-Ew for linux-riscv@desiato.infradead.org; Mon, 12 Apr 2021 16:04:25 +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=kkCJ/jGHRkT7DkhVDCJr6aWne/ TqjPgu9BJ4tolAZ+dK1MoPQL4VM5hRe7J0bCctlColfs5H6imcjaoeLTIb1CGxaSJmnXELb4DL+Po npKx38+Y0LIxce7lTd3Sd+iQQR+315ugLAvvYmphbuXcWwaBXeNZZq0qJEAO6Hzdf8PyYOgBnxSdR TBfQz63fjWONgfU2ykN6Dmi6CtS86QTFuYap+LVWoB9rijk+fB3cALJWtVASeDZDg91zIVR+icgM3 LimnXyMuxH8jq5OnIuJxMBM3CbBBJ8c+M/7+X15+U61mN1rTy7++XxXGUGoyCdRNyOtyfAHyvv9/i bEEMoIig==; Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVz2w-006N8m-JA for linux-riscv@lists.infradead.org; Mon, 12 Apr 2021 16:04:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618243458; x=1649779458; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=U0hIUeY4b5TuO5xsSS+g8pI9TVKt+grIjGH3oSWbGcQ=; b=c+DqpPAdgiVlIDGW4WncWTu6ea3VE1yztP9ER3m/DX/Q+PEkV6kHUPEF zqDAkFv48MUO66nQaRC6jKn9pnWEPdWddB0gX2d3pl4Q+S9v1x+O7wGwC 34w0WRxJ2R71/CHRiIU5wZbHoIREbNO3fPtC1+dAMRiXqWDYIT26/eyrh 1k9hXv6fxiwsZbDsBd6b1WvCZx6MY86UeMthz78iBnJ36Lgww4gzek6u8 bzBJnhUeGATlvK7DBk6P/cB4Q8v/PRHRvjXT+vHv+K+5XJqI5lIHC4s+k uKmkBdSogytusmUIlXd3CjLheliLVScPK0UktV+vZlUOI47CvV00HVIsv Q==; IronPort-SDR: 4Q7Q/MBuNXgR0tMNK0z3AznwZVT5a2ssoigrVpRyXDvjcg/mwHkJy1qosDtpbJYceUMXANXEH2 5KuTaM2KtpQqGYrjFDziqlkfp3pdyzN9+noyhWLvIJTO2ofdRCyfWTrY+vcqcJQk9WCvHbcOlv r7+Rp4zQ9/sjS5K6ackdJvBEkOtTgDsRMktA/4EZw8m7/REez4E4U4v/3t2+aOWR2I1xpjMYm7 dmbSfwWicDJTetTG7UcVEgKkpNkZQRtuAf1cWteTWuZG/o8UGeL0jILValaXwqLMJS+wTvYzCe ZUM= X-IronPort-AV: E=Sophos;i="5.82,216,1613458800"; d="scan'208";a="113293294" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 12 Apr 2021 09:04:16 -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; Mon, 12 Apr 2021 09:04:16 -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; Mon, 12 Apr 2021 09:04:13 -0700 From: To: , , , , , , , , CC: , , , , , , Conor Dooley Subject: [PATCH v5 4/5] soc: add polarfire soc system controller Date: Mon, 12 Apr 2021 17:04:13 +0100 Message-ID: <20210412160413.19528-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-20210412_090418_781988_0EF58FB2 X-CRM114-Status: GOOD ( 20.02 ) 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 Mon Apr 12 16:04:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12198465 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=-16.8 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,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 84CEFC433B4 for ; Mon, 12 Apr 2021 16:05:51 +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 2F8936121F for ; Mon, 12 Apr 2021 16:05:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F8936121F 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=DLp38KjD+Q7MNCqyCi5dXAdeCH+r8IQ9UcXk/25tIek=; b=XMp5Slch3cJDgD7Lxv9Pj6ACq1 9KujSBGcIV0NCCUIkb05gz1PoaZfBCBLtM09IpjEGH93MMrzwLKYTpTBfeDEuK8B2oIs7aA5VmlGh 2SAdPZxQzhUJpV39S7eut7KcQ9TUBAw7/wv5wjWC58XZ233ngJ7LHUnMnyqJ+mAuqRBof1y72BIcn 5fogAAG/OcjlE050l3Z8U8HEgFhN6WmNCA1uvviUksajJRZNHdvkSN4oeAEucB+PcnaYFoRxY4JBO fn4vQrYUVPHOt1E4U0wV5XDJLkP3NCD07THu2EV28XGoLvZ0O3qUmn5TR8nENDNkjxs4EsiTDt99b 2adHrI4w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVz4B-007CQz-1q; Mon, 12 Apr 2021 16:05:35 +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 1lVz35-007C9Y-Ep for linux-riscv@desiato.infradead.org; Mon, 12 Apr 2021 16:04:28 +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=m/CVxFoJwMOGAhgvs9GWvfDrvprtb5fTOeqBTFn1hig=; b=nmzF3WeO/7ThNFfa/UlYh1dJ/4 jcrRt7L3TZRwByQe96ZdSjTG5xmOFsyHHVQn40cd2DiZiH6E8zPyl/1Nd7Qwsx/s9uYjM9GMWbUSK aeIAWTK8Osj47IP+Z8wBBQwuLWWii+1HESMkeZ9WlVrUa00HhBs6Yf7fOOU8DDvhMyPEMXW/hKcdJ aY6Hs7spKu2a5FAmQqiGV5ErY6BXMplsCsEr+itjjdxE79l3pX6TQpfZ4at9ylsneZbZCk8SG2LI+ 0Zzo1Bb8GLbP9WM5+4qyYCMFKjjSGExes/PNejA1of4hRlQ7xtB7Qj5GNKYQFnRdkjF+ZSfh5Xt+L B/YxpyBA==; Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVz32-006NA3-Qw for linux-riscv@lists.infradead.org; Mon, 12 Apr 2021 16:04:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618243464; x=1649779464; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=NtsbRnX9UZiSvfgBEYfn5sxNum6q9ycjRRfSv7Rnq1w=; b=p4tYjdznt93mgtHJGKSGFXK2ENKNMKXMpSse1Tbr/7u1leb8sOTC05xB ZF4yzLR5Q0zf5tD2MCjBg98KV8pEnRaoT65VF7EPbwZyRUa7ydNzVoIWK N2kV6tghPwchelfWwKkOgk2Kml+K/iNCqRadmljz52Vs5ZfUg6qyUZu1M TvRVsp912kiuPcIML1dEflC82s5s/dQI/cOAzX5ZB35GpIwH+lKTPKo8B qIlqxuP6XCCfaI3KHZPHnX362/RonqaF/H8CidH1DSnzeU5bY3XIzvfaf /RgR7ufCt5cIouHRIIg5GiOMEGuWL54wwHa5nYppV6Mbdou4MV1U4jwYl Q==; IronPort-SDR: WAfHFwTkFGD2sCPhyDiM+VYGK7A0sP3rhyZILvCJYJ3dlxkXJxivG6ioMCuie+3v7GXXfcF3S8 Z6qPEhK1LtEeS1vFS+ST2MDwhS71qeURjBVcTfzKZzRew5IiSOWYPVxEMpt/WmW99OYRzGhh57 KhcSQtVC/P3zyHqCQdDdeVl7RczzX2sK0pgVTymx5cohIZ/36Gstx5IMhPwTN61caSOd/nnZRu ikq65kLeouLDIqVBHlf+tb4nC48/9Dv3lYPmgDRE3UZTyaPynJEqPFI7LlBD/T0FvdP77eFGWz 16M= X-IronPort-AV: E=Sophos;i="5.82,216,1613458800"; d="scan'208";a="116697957" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 12 Apr 2021 09:04:23 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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; Mon, 12 Apr 2021 09:04:22 -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; Mon, 12 Apr 2021 09:04:20 -0700 From: To: , , , , , , , , CC: , , , , , , Conor Dooley Subject: [PATCH v5 5/5] MAINTAINERS: add entry for polarfire soc mailbox driver Date: Mon, 12 Apr 2021 17:04:19 +0100 Message-ID: <20210412160419.19595-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-20210412_090424_901049_82660014 X-CRM114-Status: UNSURE ( 6.92 ) 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 the mailbox driver to the existing MAINTAINERS entry for the polarfire soc Signed-off-by: Conor Dooley --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 8246a19a4fde..996d7d3b7d07 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15357,6 +15357,7 @@ M: Lewis Hanly M: Cyril Jean L: linux-riscv at lists.infradead.org S: Supported +F: drivers/mailbox/mailbox-mpfs.c F: drivers/soc/microchip/ F: include/soc/microchip/mpfs.h