Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp3803454pxb; Tue, 7 Sep 2021 07:56:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPA2yg57mrUhISBgwR7i/zGfNMlrY4eqtQPBC9llxG1/IWmpFtjyiX8mHVFeIZdTd0x53q X-Received: by 2002:a05:6e02:1aa8:: with SMTP id l8mr12606911ilv.226.1631026583020; Tue, 07 Sep 2021 07:56:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631026583; cv=none; d=google.com; s=arc-20160816; b=QraSYilAiWKb7JI8AUiQCwhSB1XtQXsE8IfgqMuOqBjgmr2Ut2KKLECjl1JIBoAmv2 8t2nPlYWnh140IQhISYtmwM4s7o7kzm4KYC3bm2qKg0kbQWfn/34v+UsyK5mre+InEW1 F/Bkjq2zR5wsA4CM4vS1o4rj04Oh9+ycc9mMmZOSi9XmQ0wqkPMxwcMkiQFMsXUxBLqC 5Ctc+Cs93QormGpBXw0ZLY8pVhjge9/YcvKtkUxQXD/wiCNVLoFtTQmVEtoCOl3yJh6f T1UzPEuWJHh4OC+RB4sGyLy8lCPAhDgdnrTE9HXCCjQd7p4FTAYb6uwH/Gc8QtfxoF7J Y/Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=tr3rAne2mxvJdDMSmiNoM/kTe53cOj7AacnE9RSwub8=; b=jCHlELRRow+NSAjkvU8AA42ovHCEDDg3srJFjsedC6cNQRYEVx0uTsq7iMcVUYr3+c x6NID+OpGaDx/PFm+JosIXrTxqTbCGyR8tLg5q/QT8F+7M+rGbSSgT0EFA6g425+7wcf 2L1K2GgjFmGOpXWtrlOXOPW7hwVaKCQnogMS8A+XHE0Kg7y8KmTGlzEWy1B/W2iBuKmM Ko4DhmemXfMm4ZY1CwYaLBTKtjiNR7kBzzZWOu56BGqWuShjjqtKC9QYrZeUuI06/zMi 6uYytfCekb0L0aKQo9rVstOUwTYgpz3oqN6q0jM8tAwUThwWxKdQ+DmXbED2OL0cd+7v 7EpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm2 header.b=NPisbDDC; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=AI796OQo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=svenpeter.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u2si10628426ioc.87.2021.09.07.07.56.10; Tue, 07 Sep 2021 07:56:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm2 header.b=NPisbDDC; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=AI796OQo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=svenpeter.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343987AbhIGO42 (ORCPT + 99 others); Tue, 7 Sep 2021 10:56:28 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:36779 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235265AbhIGO41 (ORCPT ); Tue, 7 Sep 2021 10:56:27 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id D65D3580E7F; Tue, 7 Sep 2021 10:55:20 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 07 Sep 2021 10:55:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm2; bh=tr3rAne2mxvJdDMSmiNoM/kTe5 3cOj7AacnE9RSwub8=; b=NPisbDDCJyXec9+Izt2ILl+GYv6oGQHVoQotbxN2In LWjrapdigidirvIzigOfPkh1VxpqCSWHsT87JGaYQNrMHw7EF0aIKwEkXOkdRcuA DTGHUW7kdSSXmsjl6W2AAmH8wcJr1KmUV//6d+t4VMVcYpy+QPwczMGvh8e25UkK +OLHZB1Wm6IqP61FRKXuosk7DKjVylNJzcrfgql1ek7H/iVKLHHxfnx3iLAjEIen opqizuIF8cjBJ7tM+5LhpWfdBkFSyCOsrIpsRm69vZI3wXvZAGZVI/YE610zLNhT 4/CPFzd/nSIYPNXgafMgH9ang8dqBGSWJZ+BQjcubLSw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=tr3rAne2mxvJdDMSm iNoM/kTe53cOj7AacnE9RSwub8=; b=AI796OQoTbjMCduu4/84/NMmjtBQStayZ Ex8jcBwhAf8nsjQywECUodWsynTtc+5DFvLOs/Tif3ExMGgr+LIgaRtWxs9lr+pb vsApvy1n50pPFHiR3gWeEsM9UiMoit3ONH6GXicUEXQmLJrv2xw0JMXcPPc8upCa 9bTO5RXsUcDnDT2V9znBhmeYM12LSxlheGVVJamdW4Y+zyTeNw2fTGL2CawcVYkk vZ8y1wRQBzqCEkeXWUJudp/fxAdnpI2289Lf0dPUYf12fi0NbC28RZtLc+EADDCZ Ky3DEykVfT3RVQ04MQC1z/U8cEbpmRitkLrx7OIpV0p+AcAmQAVAg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudefhedgkeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcurfgv thgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvghrnh epuefgleekvddtjefffeejheevleefveekgfduudfhgefhfeegtdehveejfefffffgnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvghnse hsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 7 Sep 2021 10:55:17 -0400 (EDT) From: Sven Peter To: Jassi Brar Cc: Sven Peter , Rob Herring , Mark Kettenis , Hector Martin , Alyssa Rosenzweig , Mohamed Mediouni , Stan Skowronek , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/3] Apple Mailbox Controller support Date: Tue, 7 Sep 2021 16:54:58 +0200 Message-Id: <20210907145501.69161-1-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, This series adds support for the mailbox HW found in the Apple M1. These SoCs have various co-processors controlling different peripherals (NVMe, display controller, SMC (required for WiFi), Thunderbolt, and probably more we don't know about yet). All these co-processors communicate with the main CPU using these mailboxes. These mailboxes transmit 64+32 bit messages, are backed by a hardware FIFO and have four interrupts (FIFO empty and FIFO not empty for the transmit and receive FIFO each). The hardware itself allows to send 64+32 bit message using two hardware registers. A write to or read from the second register transmits or receives a message. Usually, the first 64 bit register is used for the message itself and 8 bits of the second register are used as an endpoint. I originally considered to have the endpoint exposed as a mailbox-channel, but finally decided against it: The hardware itself only provides a single channel to the co-processor and the endpoint bits are only an implementation detail of the firmware. There's even one co-processor (SEP) which uses 8 bits of the first register as its endpoint number instead. There was a similar discussion about the BCM2835 / Raspberry Pi mailboxes which came to the same conclusion [1]. These mailboxes also have a hardware FIFO which make implementing them with the current mailbox a bit tricky: There is no "transmission done" interrupt because most transmissions are "done" immediately. There is only a "transmission fifo empty" level interrupt. I have instead implemented this by adding a fast-path to the core mailbox code as a new txready_fifo mode. The other possibilities (which would not require any changes to the core mailbox code) are to either use the polling mode or to enable the "tx fifo empty" interrupt in send_message and then call txready from the irq handler before disabling it again. I'd like to avoid those though since so far I've never seen the TX FIFO run full which allows to almost always avoid the context switch when sending a message. I can easily switch to one of these modes if you prefer to keep the core code untouched though. Best, Sven Sven Peter (3): mailbox: Add txdone_fifo dt-bindings: mailbox: Add Apple mailbox bindings mailbox: apple: Add driver for Apple mailboxes .../bindings/mailbox/apple,mailbox.yaml | 81 ++++ MAINTAINERS | 3 + drivers/mailbox/Kconfig | 12 + drivers/mailbox/Makefile | 2 + drivers/mailbox/apple-mailbox.c | 432 ++++++++++++++++++ drivers/mailbox/mailbox.c | 66 ++- drivers/mailbox/mailbox.h | 1 + include/linux/apple-mailbox.h | 18 + include/linux/mailbox_controller.h | 15 + 9 files changed, 621 insertions(+), 9 deletions(-) create mode 100644 Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml create mode 100644 drivers/mailbox/apple-mailbox.c create mode 100644 include/linux/apple-mailbox.h -- 2.25.1