From patchwork Fri Dec 20 13:49:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 13916809 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 06EB1E77188 for ; Fri, 20 Dec 2024 14:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vYqkobOK+CGs+TgrhYtB4J6Yl7NbzklVF+5ziOlA9ss=; b=Nct/0jRcTzUyXLKZERq3uHPV2D RvNdQwmreItuGKwIa+A+ygEYIfRalvHNrTrLN3L3Q+EnsXVtKIg7/3mGfNpGWVkvXGzXFp1yLV86E B1oznqZpXPtbKxXOviym3GQQrSuvdXytK25apAVhUHpqyA8JRo/XJZl7crqlb4dNoPKPqX0gUn+iA moZQ0ceMkGwei90R6MeuEs1CE/uyLKuAz4BEuXmqtkmOm0JVGaMlsJHLPTcrIo/9bupVQFLVryib9 /Pe/reNRe1gUck9EzvyzH0UZ5RLxHSDME8/Qxz1v/tloW0AGj7TkbtFsI2t4EQQfZ5gDPvE8pYV0D D/3zky9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOdZc-000000055Fq-3Ub1; Fri, 20 Dec 2024 14:01:48 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOdOE-0000000534z-3Uel for linux-arm-kernel@lists.infradead.org; Fri, 20 Dec 2024 13:50:04 +0000 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-385e1fcb0e1so1126791f8f.2 for ; Fri, 20 Dec 2024 05:50:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734702600; x=1735307400; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=vYqkobOK+CGs+TgrhYtB4J6Yl7NbzklVF+5ziOlA9ss=; b=gwD5dfMtaAaKrx+d9rTqMw6AZ45AbC5KhBrKpXVS/zZs5etZ1QTNhM/hTNdmjQtEt1 ItlKmqy8VXaNv14poMRFF5GhiTNnD+4KuRqKsQiFwjXz6+68hdvRT5cmOgwQCiK6yNfz 5YA+K/BZVQFUZgs7BRO/L5gMfh5vNTZASgyfe9kxokrfHEEba61IK8xgd/Qa4H9UgcDZ mE1DwgsV+Ljv92kYfkznFoK3qsG5spgT/BhpPFjH54zkH5Rx8QBKeeDb0W1RLuhksfNG 0UrdlakL6cJW8rcjGLbWO03gscNWmNryJ00Q/pmD02tKMi2QFUoa7+tsRfeDjUUs/RVs o2BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734702600; x=1735307400; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vYqkobOK+CGs+TgrhYtB4J6Yl7NbzklVF+5ziOlA9ss=; b=N0kGqjQQavZBcb7VnDU4O4I/KflhJC4mZokHFzJFvWpGL6LQfR4RC1Mw00wvDNfq0L h6zi4RzqYrGXTIaoEK813+A0xCv8+mzn9FBaMZEXXPpoc/ZjRQNRATlt1E6p0NksBltz kt4hEMABXDs3/idHKS9+F6zta53oRePF8/I6niIt7QP9uuizFy4GGxznMtl+Ul+Xi8jz 2Oewf4Y2f6ioJv4gz+u1//bOlEEQQqUonUxz2K76HUY7Efyx1oJqTgBq8vnyVpWfirjV zBRZnComOSOuT/grVrLz4Gt+jeSZIq87sJdj7Z7SidkyaTAmfXl0aWT6xWTIOMQGDOGK 2SoQ== X-Forwarded-Encrypted: i=1; AJvYcCXfmVC35I46hppPSplj/MM/3gpG1oDuKP2WM8mNYiis1IocPfVTJovkwsiKSDpApR30N8xMD9TxSSWQfJPqN3aC@lists.infradead.org X-Gm-Message-State: AOJu0YykX4gQAA2LP+RByPv9K+7144FN2OUJF2/ALA6SlWakv3QF/8WR aD8dCUrWQOAhYuepRi6mNJKwEtP37OF77U2/VHbVDD40/2rdKZZEWfpTywROajs= X-Gm-Gg: ASbGncvIWbc5+/kMY7RcoHmghODqQo93vVOsoxU0VKkqPL/N8KiZYPleJClRFlCH/P/ l8lo12DmNlKz3WsEcBW4tUfIcACMeQPVGDGEH7CAewt/toA1RWhQdJtJod0O476OHvmYk/jQqsr 94dA7WGEMTaY33oFUQfbR7N+NO9gGk4cIrDNpaSjt85x6I3ZAodB9S9ItEo7Dz8xtEPTEGqpwAa 7SQA7e6sjCIKoCFjrYHS3jYfSlDEFJ+7FT3wHLPQGDu2Kaa1RLsLNlXRG5rqxnIkxA/cDUVY2vl bVqgKVRJYbhBl0ALxMBFehDV4SO2bWGy+NM8 X-Google-Smtp-Source: AGHT+IHmrkvtNC0bpXN3WfagnYqTmX3f/cgHqADtcvMIQyUNWR5Q5Jsopz545p5OgeVnpUJdIYXklg== X-Received: by 2002:a05:6000:178c:b0:385:dfab:1643 with SMTP id ffacd0b85a97d-38a221ff705mr2979256f8f.27.1734702600234; Fri, 20 Dec 2024 05:50:00 -0800 (PST) Received: from ta2.c.googlers.com (130.173.34.34.bc.googleusercontent.com. [34.34.173.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c832e74sm4044313f8f.30.2024.12.20.05.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 05:49:59 -0800 (PST) From: Tudor Ambarus Date: Fri, 20 Dec 2024 13:49:56 +0000 Subject: [PATCH v6 1/5] dt-bindings: mailbox: allow #mbox-cells = <0>; MIME-Version: 1.0 Message-Id: <20241220-acpm-v4-upstream-mbox-v6-1-a6942806e52a@linaro.org> References: <20241220-acpm-v4-upstream-mbox-v6-0-a6942806e52a@linaro.org> In-Reply-To: <20241220-acpm-v4-upstream-mbox-v6-0-a6942806e52a@linaro.org> To: Jassi Brar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Krzysztof Kozlowski , Alim Akhtar Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, andre.draszik@linaro.org, peter.griffin@linaro.org, kernel-team@android.com, willmcvicker@google.com, daniel.lezcano@linaro.org, vincent.guittot@linaro.org, ulf.hansson@linaro.org, arnd@arndb.de, Tudor Ambarus X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734702598; l=1213; i=tudor.ambarus@linaro.org; s=20241212; h=from:subject:message-id; bh=98UdmgNXZR4Odm8WAK3DNauL946xSKIV8vPYFoFzXtc=; b=L27tekKbbbVcK6U5BoYlAcu5YGoP7VilFJa2kRv2a4piHaSjgl6c8pZq3lyr2xXRNPu1TQkQh AuzOHGFoQW1DsplvHHW5KhfrQXyL0uUAXa/BQ4Qcems105t6N1TPsWA X-Developer-Key: i=tudor.ambarus@linaro.org; a=ed25519; pk=uQzE0NXo3dIjeowMTOPCpIiPHEz12IA/MbyzrZVh9WI= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_055002_892167_8B87CCCD X-CRM114-Status: GOOD ( 10.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are mailbox clients that can discover the mailbox channel identifiers at runtime. For such cases passing the channel identifiers via DT is redundant. The framework API will be supplied with mbox_request_channel_by_args(). It will allow clients to request a mailbox channel using the runtime discovered channel identifiers. Add support for referencing controllers solely by phandle. Signed-off-by: Tudor Ambarus --- Documentation/devicetree/bindings/mailbox/mailbox.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/mailbox/mailbox.txt b/Documentation/devicetree/bindings/mailbox/mailbox.txt index af8ecee2ac68..fc31a4a3b637 100644 --- a/Documentation/devicetree/bindings/mailbox/mailbox.txt +++ b/Documentation/devicetree/bindings/mailbox/mailbox.txt @@ -6,8 +6,7 @@ assign appropriate mailbox channel to client drivers. * Mailbox Controller Required property: -- #mbox-cells: Must be at least 1. Number of cells in a mailbox - specifier. +- #mbox-cells: Must be at least 0. Number of cells in a mailbox specifier. Example: mailbox: mailbox { From patchwork Fri Dec 20 13:49:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 13916811 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B37EAE77188 for ; Fri, 20 Dec 2024 14:04:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Drrp/bM071Dp74jG1eEsU28h5Inku9vU1l6IcVuKHXY=; b=A/heA5GITizmqCS8sXYd1W5VF6 fq94/yju/A4Uk6avQc96fO4A9XTBD9Drt12syNxFlK3UnGbirerRxO8Gu0tnTyafp/1ZCvOSUCbH4 65Hj+qQXK1gnE5XtvEzUrMjhJOFYRvyq6CJZTRBGVZlCfXToAN3AgjSaljwV9Vawl6Xqww8eqWqnA x8H8DCydh4EE9Eeh7hMb4tPgZmhzeYQxUw4mDkZ3cYhjMpT7LOLVtq6Ze8kAnRDm5CINiK1K4pHxT BSm0sHcTZ03XdB4nClQyPlQ8NvjXW4lOuRYCafcUsg+pLI9rpLR+Z5DkZd64JkNxaXVbCyOvj4WMB 0q217Ewg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOdbs-000000055WT-1fsR; Fri, 20 Dec 2024 14:04:08 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOdOF-0000000535A-0PnG for linux-arm-kernel@lists.infradead.org; Fri, 20 Dec 2024 13:50:05 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-43622267b2eso19611495e9.0 for ; Fri, 20 Dec 2024 05:50:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734702601; x=1735307401; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Drrp/bM071Dp74jG1eEsU28h5Inku9vU1l6IcVuKHXY=; b=MgbVSgklg8+jgIxRkDmi+XJBQsWg92HE2ziwBSBwxYpbBpibLaEkxOgdSiMJ1cIQVt G96tyH7AJ50C9v9mKvEV1pTmbxVYH974/ivX+1jfVilPkSFiVRl2TDauiMeMB5FBr031 OmyMoZ/P8INFK0ubRITb0bdBEzyU6ioo8PtDoN0DEl7po9JUm8e/PLSBswcJSyQaoyp7 RDwVCpwVKQasRQhxYk8y+KjvaKVGS0kUAi0jbPch+b7H1nrh3yMGngL+878ItotupaHs 5/VzttQl+A0bbTwqRtIG06YQ1PSIHCDEUardAylUHJWN/wM3Rli3bh/EpVC27uX94LDL uPFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734702601; x=1735307401; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Drrp/bM071Dp74jG1eEsU28h5Inku9vU1l6IcVuKHXY=; b=Z1K7JvWa5XY17toxV9Zd6jTWYigqqNTvXojtOUTIhiN4MmmSngpbft4XC39iCAc3Nr xTVBB9kAjyQuPN/WLv8NX5B5nron6JHnF9cFf7tT8V0TL4AOsTCq3mCUYJaXkSh4ifdB AvVy/OXq2GDuyNZB7iPbUWpoHyFL8IuHrzIxNTgka+uFToK+AFBRsU6K9jupkt9j6lvf 7x26sZWVBCy4S/hqOJ0YHFnJc0rzFN9XNJIBdfPKviZITqnQH3Fy86+Buts18l6wgXLf 9p71KxNkFPswx4Zn4BsG1VuSfMt8bmk4m2c/l8LxHQGPsu8xfcsxgxCSoi6zjPOOPCsn YsQw== X-Forwarded-Encrypted: i=1; AJvYcCXTWqMtrHqB4dXIURjiUQRWxvOtV60/821AzrP+zyTbgoRLIiui8NyksbnAnZzCD10km4yvkCCnexk7VwnN7ocH@lists.infradead.org X-Gm-Message-State: AOJu0Yyfa1hMC7XywCgAe9N5MbpvODRLN9v1/e8w1Hv8YmAXJXJHCy1I n9oQXoUG7A0r5nsiK1W6ZOJayiRdhFx6Gagl1NaLptnXDCqxJDSsodkX2/tYIZg= X-Gm-Gg: ASbGncvE+AxAfUQIaHTbnDQNCTwB00h9ScxtcUq1f4fh2qnCrVSey28/pqKpy17002T JKeqruV0BGBr+v6+pk9dY5C1bRQCiPV5jRMYEwBG/fG2xliPafxJB904ZZAAK8IkkmL1MNm5viI Xf7ahJ11JHcj8gUngt/9MV4fKAMIPLAIKYBR/4SXJTBmfUi2PCjjYEHHJ3XsaFVFm3PeqIl/hNv EVUoceXA+Rp1qEqVybgwAzDfRwmlaojmGljB9gfvFUONY8Hzt4VFjS1rSYI0/bhYsnTVjQ5dMlr Uy0c0ZWYdS/+sbzXkkz5wZuYEdAiHgdIfYYA X-Google-Smtp-Source: AGHT+IGmLqoezR1dy/0yCfVQQLVCWAofOQ6KwjPi9F1bHXgcS8BNdXaZNl7LSVDsp8VtWoa4v/CqjA== X-Received: by 2002:a05:600c:1c91:b0:434:e9ee:c2d with SMTP id 5b1f17b1804b1-43668b5e085mr23276095e9.26.1734702601113; Fri, 20 Dec 2024 05:50:01 -0800 (PST) Received: from ta2.c.googlers.com (130.173.34.34.bc.googleusercontent.com. [34.34.173.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c832e74sm4044313f8f.30.2024.12.20.05.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 05:50:00 -0800 (PST) From: Tudor Ambarus Date: Fri, 20 Dec 2024 13:49:57 +0000 Subject: [PATCH v6 2/5] dt-bindings: mailbox: add google,gs101-mbox MIME-Version: 1.0 Message-Id: <20241220-acpm-v4-upstream-mbox-v6-2-a6942806e52a@linaro.org> References: <20241220-acpm-v4-upstream-mbox-v6-0-a6942806e52a@linaro.org> In-Reply-To: <20241220-acpm-v4-upstream-mbox-v6-0-a6942806e52a@linaro.org> To: Jassi Brar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Krzysztof Kozlowski , Alim Akhtar Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, andre.draszik@linaro.org, peter.griffin@linaro.org, kernel-team@android.com, willmcvicker@google.com, daniel.lezcano@linaro.org, vincent.guittot@linaro.org, ulf.hansson@linaro.org, arnd@arndb.de, Tudor Ambarus X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734702598; l=3101; i=tudor.ambarus@linaro.org; s=20241212; h=from:subject:message-id; bh=gc/x/vd/iTT6DgRuhTHKKXPn1qQVX3+uctKpzIwRy8k=; b=1yqD4Mr6+HTppBrswLA85XgGW1DxBWk3OZasij4CNC75DdzHxr/YW9Uc8Rmqtjk0KoCQpB3uz qEW29wjIKGVDt2tWSzFxK7GDD7pOdikK2I0UV7O+C4Hcq7ipm9gl7Eb X-Developer-Key: i=tudor.ambarus@linaro.org; a=ed25519; pk=uQzE0NXo3dIjeowMTOPCpIiPHEz12IA/MbyzrZVh9WI= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_055003_146667_6EFB2C3B X-CRM114-Status: GOOD ( 16.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add bindings for the Samsung Exynos Mailbox Controller. Signed-off-by: Tudor Ambarus --- .../bindings/mailbox/google,gs101-mbox.yaml | 70 ++++++++++++++++++++++ include/dt-bindings/mailbox/google,gs101.h | 14 +++++ 2 files changed, 84 insertions(+) diff --git a/Documentation/devicetree/bindings/mailbox/google,gs101-mbox.yaml b/Documentation/devicetree/bindings/mailbox/google,gs101-mbox.yaml new file mode 100644 index 000000000000..a1fbc3b2b9de --- /dev/null +++ b/Documentation/devicetree/bindings/mailbox/google,gs101-mbox.yaml @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright 2024 Linaro Ltd. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mailbox/google,gs101-mbox.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung Exynos Mailbox Controller + +maintainers: + - Tudor Ambarus + +description: | + The Samsung Exynos mailbox controller, used on Google GS101 SoC, has 16 flag + bits for hardware interrupt generation and a shared register for passing + mailbox messages. When the controller is used by the ACPM protocol the shared + register is ignored and the mailbox controller acts as a doorbell. + The controller just raises the interrupt to the firmware after the + ACPM protocol has written the message to SRAM. + +properties: + compatible: + const: google,gs101-mbox + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: pclk + + interrupts: + description: IRQ line for the RX mailbox. + maxItems: 1 + + '#mbox-cells': + const: 0 + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - '#mbox-cells' + +additionalProperties: false + +examples: + # Doorbell mode. + - | + #include + #include + + soc { + #address-cells = <1>; + #size-cells = <1>; + + ap2apm_mailbox: mailbox@17610000 { + compatible = "google,gs101-mbox"; + reg = <0x17610000 0x1000>; + clocks = <&cmu_apm CLK_GOUT_APM_MAILBOX_APM_AP_PCLK>; + clock-names = "pclk"; + interrupts = ; + #mbox-cells = <0>; + }; + }; diff --git a/include/dt-bindings/mailbox/google,gs101.h b/include/dt-bindings/mailbox/google,gs101.h new file mode 100644 index 000000000000..7ff4fe669f9e --- /dev/null +++ b/include/dt-bindings/mailbox/google,gs101.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* + * Copyright 2024 Linaro Ltd. + * + * This header provides constants for the defined mailbox channel types. + */ + +#ifndef _DT_BINDINGS_MAILBOX_GOOGLE_GS101_H +#define _DT_BINDINGS_MAILBOX_GOOGLE_GS101_H + +#define DOORBELL 0 +#define DATA 1 + +#endif /* _DT_BINDINGS_MAILBOX_GOOGLE_GS101_H */ From patchwork Fri Dec 20 13:49:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 13916812 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9AA5E77188 for ; Fri, 20 Dec 2024 14:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Y3R4Jhe3KgMdcHWwBtGAqNwkL06pjGhdfYrGLYcX0qU=; b=0kaG6bhd8pl92rYj/2Q/ec9DKs oxF9OQkzgaAhplsY+5XdQcxFIeDS9UL7T2I2lNvSrOI4WW6fBgU0NPZ9RUnMu4ZjQLSXgrjrnqN1r M0IIno102GEHzwps9SvGv+qs++ShOyo4Ck16MHsjZ1SagkddtyjxmvcGIi6C9Hb40Vh1NZWtaqplo rLy3K9b0PUJz3yAfYp1DdPJS+MWPbUaQ3pJDLeqcJOqv0Ysurzbyxf7FAjwO+t5XWAz4LK2Eq6jxJ TWdnk5pxEEYDiiCeM6l2ec+MMwHSRmLEzvtrCse8LOr3h5qtqunB3FsxCOLmetar0cxmB6d8EADVU ABM4Et3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOdd0-000000055gT-0Rvk; Fri, 20 Dec 2024 14:05:18 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOdOG-0000000535B-0Olt for linux-arm-kernel@lists.infradead.org; Fri, 20 Dec 2024 13:50:05 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3862d16b4f5so1333275f8f.0 for ; Fri, 20 Dec 2024 05:50:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734702602; x=1735307402; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Y3R4Jhe3KgMdcHWwBtGAqNwkL06pjGhdfYrGLYcX0qU=; b=lT0ASPbtGa8hpRb0qZ9PkwCWG1TaMHfAy7O14pUSydjew5TMtVyqrdYvmlVaL0/Myl LgnnL9ENgc5LDZcPjKt7+3tAnKe5jAq7UOn0K3BOT3RhP51zGio7hO1QJzHO36XiP5GS eWvRbDaDB7TyKipPC2tcVP98y6S1c3e+6EcHgStwgQLstx4JgmracLXiGXhpZMBk+BAz b1wzv9Z+N7rcVkzNF8M/2tRiVSBqbyD6KgyD4DUYXoZQDEP6j2tMGlOT103GXvYyt6rk wWWSBstl9oJpxyHi1hEAzzNx2zjOqq4NGK7dvDSIHWY2zOB5zI1xou7G6Ax2by/GFvqp ibNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734702602; x=1735307402; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y3R4Jhe3KgMdcHWwBtGAqNwkL06pjGhdfYrGLYcX0qU=; b=lIZjaHjbsLQP3n08K3x+Jjhxljr4dYX0LcwvxAwaSdwS8KopAv5UTTlIDtHjT9JBBS KRCvSaPXWu4uUBHY02Zyrg+tBebUsFhCfBbl2Q/e6cxOVV5wy0GsRJFpIMvNHCwGP618 sqioUGQzij1Q0Cl8NECii5E4uHxmDOUSbVmJ5Mwy2dqFU2HpoPBkAI9ekqD5pTd/S5Hq w9dikK3SiN9ls0N12SGFahmp/Eg6WoOqlapIv/oyg7LFqTTMw7btb+dru83ADbxLJ6zb WQ7IRVh8NinI55c+HPAGxpuNkG1CkNzHDTtl8FWnTfiq9emoUMfVbErCTs2QrmNt3jh6 eMjA== X-Forwarded-Encrypted: i=1; AJvYcCWRxRrOTu3ZTJa9UjB/PejLtJT4IyeRxyCoMCOFK78QtPadfpIOaQQtY1487+wyV2lXrzd37QEogtIzx1YL7ASK@lists.infradead.org X-Gm-Message-State: AOJu0YyQB5pTGC6oKV4EyfbpcZljsAU/vWdk/bkzBCplZtfTQl87muo5 NnoxeGRsghVMjTJvKmJE14V4GAuCCrkJrtjiO/RwwotGM2iPoxhr2OXzzF1ytvc= X-Gm-Gg: ASbGncsjda5okdl5/+jJ2zb6LH4tmQlt8xJBHyrPIJslFyEKBElxZy4gbqD7+YK5zY+ yKvAOcKuYikIpBUkUhdzMuAEzIWvH9PDtNnouC/bV0gsbutML6ML37cq4y1ALSrAiuyErb5xaR6 GeFxw8w2yHn7k3G2NRTV7LS0p6pbBa6SytznYwvtd7b8BFAYZceVxMyKSgmAe8RoZJqdM1VrS7B Yu1HxV5aHCL37KSIIyF4Y/SKC9bFI/SM3KtC3bykcuhKv/UgOi2XTXtlhcX55DZg0NehKGTPtNl WY2PQHM9YqSsSfDRZlm27sCV95RDP4Dt7ayP X-Google-Smtp-Source: AGHT+IFO4m1UMUWH98xI6WEcrXsCmyinFas11MjCCiL6zLrmfdc5i7QkqHRJkTCA4ukd1H0E1zdRFw== X-Received: by 2002:a05:6000:1785:b0:386:3c93:70ff with SMTP id ffacd0b85a97d-38a1a1fdd35mr6675772f8f.8.1734702602133; Fri, 20 Dec 2024 05:50:02 -0800 (PST) Received: from ta2.c.googlers.com (130.173.34.34.bc.googleusercontent.com. [34.34.173.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c832e74sm4044313f8f.30.2024.12.20.05.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 05:50:01 -0800 (PST) From: Tudor Ambarus Date: Fri, 20 Dec 2024 13:49:58 +0000 Subject: [PATCH v6 3/5] mailbox: add support for clients to request channels by args MIME-Version: 1.0 Message-Id: <20241220-acpm-v4-upstream-mbox-v6-3-a6942806e52a@linaro.org> References: <20241220-acpm-v4-upstream-mbox-v6-0-a6942806e52a@linaro.org> In-Reply-To: <20241220-acpm-v4-upstream-mbox-v6-0-a6942806e52a@linaro.org> To: Jassi Brar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Krzysztof Kozlowski , Alim Akhtar Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, andre.draszik@linaro.org, peter.griffin@linaro.org, kernel-team@android.com, willmcvicker@google.com, daniel.lezcano@linaro.org, vincent.guittot@linaro.org, ulf.hansson@linaro.org, arnd@arndb.de, Tudor Ambarus X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734702598; l=5904; i=tudor.ambarus@linaro.org; s=20241212; h=from:subject:message-id; bh=yyB5CQGhVmNL0L7BcpLJ32JRUO4zLOTRcjHSgygE7Ik=; b=vsmN1tUctzs2mQxUDHpQYFZZw2uQY7/lH7aU0MJkG/FL5nc9qKT2nTT5HYlqjC6BnhqU8Jipu zaGST/SqFPyALdMnBZnXEks6QaRLLJw/KxnPYpoXUa0ql5fqZ+5W8/P X-Developer-Key: i=tudor.ambarus@linaro.org; a=ed25519; pk=uQzE0NXo3dIjeowMTOPCpIiPHEz12IA/MbyzrZVh9WI= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_055004_158845_12BB581D X-CRM114-Status: GOOD ( 21.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are clients that can discover channel identifiers at runtime by parsing a shared memory for example, as in the ACPM interface's case. Supply a new framework API: mbox_request_channel_by_args(). It works by supplying the usual client pointer as the first argument, the usual index of the mailbox specifier in the 'mboxes' property as a second argument, and a pointer to a 'const struct mbox_xlate_args' as a third. The newly introduced struct is modeled after 'struct of_phandle_args'. The API identifies the controller's device node, and then calls that controller's xlate() method that will return a pointer to a mbox_chan or a ERR_PTR. The binding between the channel and the client is done in the typical way. Signed-off-by: Tudor Ambarus --- drivers/mailbox/mailbox.c | 60 ++++++++++++++++++++++++++++++++++++++ include/linux/mailbox.h | 17 +++++++++++ include/linux/mailbox_client.h | 3 ++ include/linux/mailbox_controller.h | 4 +++ 4 files changed, 84 insertions(+) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index d3d26a2c9895..0eecffd5a2ad 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -467,6 +467,66 @@ struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl, } EXPORT_SYMBOL_GPL(mbox_request_channel_byname); +/** + * mbox_request_channel_by_args - request a mailbox channel using client's + * channel identifiers. + * @cl: identity of the client requesting the channel. + * @index: index of mailbox specifier in 'mboxes' property. + * @spec: arguments that describe the channel. + * + * Used by clients that can discover the channel identifiers at runtime (by + * parsing a shared memory for example). The description of + * mbox_request_channel() applies here as well. + * + * Return: Pointer to the channel assigned to the client if successful. + * ERR_PTR for request failure. + */ +struct mbox_chan *mbox_request_channel_by_args(struct mbox_client *cl, + int index, const struct mbox_xlate_args *mbox_spec) +{ + struct of_phandle_args of_args; + struct device *dev = cl->dev; + struct mbox_controller *mbox; + struct mbox_chan *chan; + int ret; + + if (!dev || !dev->of_node) { + pr_debug("%s: No owner device node\n", __func__); + return ERR_PTR(-ENODEV); + } + + if (of_parse_phandle_with_args(dev->of_node, "mboxes", + "#mbox-cells", index, &of_args)) { + dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", __func__); + return ERR_PTR(-ENODEV); + } + + mutex_lock(&con_mutex); + + chan = ERR_PTR(-EPROBE_DEFER); + list_for_each_entry(mbox, &mbox_cons, node) + if (mbox->dev->of_node == of_args.np && mbox->xlate) { + chan = mbox->xlate(mbox, mbox_spec); + if (!IS_ERR(chan)) + break; + } + + of_node_put(of_args.np); + + if (IS_ERR(chan)) { + mutex_unlock(&con_mutex); + return chan; + } + + ret = __mbox_bind_client(chan, cl); + if (ret) + chan = ERR_PTR(ret); + + mutex_unlock(&con_mutex); + return chan; +} +EXPORT_SYMBOL_GPL(mbox_request_channel_by_args); + /** * mbox_free_channel - The client relinquishes control of a mailbox * channel by this call. diff --git a/include/linux/mailbox.h b/include/linux/mailbox.h new file mode 100644 index 000000000000..cef88c5ae49d --- /dev/null +++ b/include/linux/mailbox.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright 2024 Linaro Ltd. + */ + +#ifndef __LINUX_MAILBOX_H +#define __LINUX_MAILBOX_H + +#include + +#define MBOX_XLATE_MAX_ARGS 16 +struct mbox_xlate_args { + int args_count; + u32 args[MBOX_XLATE_MAX_ARGS]; +}; + +#endif /* __LINUX_MAILBOX_H */ diff --git a/include/linux/mailbox_client.h b/include/linux/mailbox_client.h index 734694912ef7..06e2721313ca 100644 --- a/include/linux/mailbox_client.h +++ b/include/linux/mailbox_client.h @@ -9,6 +9,7 @@ #include #include +#include struct mbox_chan; @@ -41,6 +42,8 @@ int mbox_bind_client(struct mbox_chan *chan, struct mbox_client *cl); struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl, const char *name); struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index); +struct mbox_chan *mbox_request_channel_by_args(struct mbox_client *cl, + int index, const struct mbox_xlate_args *mbox_spec); int mbox_send_message(struct mbox_chan *chan, void *mssg); int mbox_flush(struct mbox_chan *chan, unsigned long timeout); void mbox_client_txdone(struct mbox_chan *chan, int r); /* atomic */ diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h index 6fee33cb52f5..dfddcf966f9f 100644 --- a/include/linux/mailbox_controller.h +++ b/include/linux/mailbox_controller.h @@ -8,6 +8,7 @@ #include #include #include +#include struct mbox_chan; @@ -67,6 +68,7 @@ struct mbox_chan_ops { * @txpoll_period: If 'txdone_poll' is in effect, the API polls for * last TX's status after these many millisecs * @of_xlate: Controller driver specific mapping of channel via DT + * @xlate: Controller driver specific mapping of channel * @poll_hrt: API private. hrtimer used to poll for TXDONE on all * channels. * @node: API private. To hook into list of controllers. @@ -81,6 +83,8 @@ struct mbox_controller { unsigned txpoll_period; struct mbox_chan *(*of_xlate)(struct mbox_controller *mbox, const struct of_phandle_args *sp); + struct mbox_chan *(*xlate)(struct mbox_controller *mbox, + const struct mbox_xlate_args *sp); /* Internal to API */ struct hrtimer poll_hrt; spinlock_t poll_hrt_lock; From patchwork Fri Dec 20 13:49:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 13916813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78620E77188 for ; Fri, 20 Dec 2024 14:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=QmwzVQdSamTI4Mm25hbiGBJIk1Q/esKMsBlmHYpUYHM=; b=Iv2BCDC8MQ2DMs0TrxOIHDA5Jo AYm/6oBnuJ4kDOP+lk7IOM6yrRC8pzMAm4iRB3uUO4YoLReKVDJfQZ6B6CuQwIaEOELZc1RG2Uq6X DDM+jfQQ7SJWctSfVnTy5K0lTUGygQKa0DfgtIaaeI1fTSBoKfBNTzRbrEPaHwju3izimwC5AKJsM gFkKEUPvbhP5nV75/N+8K1oWE7HqHT7rG8g9GHxmpkkmaZmL7ek9xTN7Ce8+Ei5gcrJ5J4oBj1yTf I4iQi1E4N7b+0zK7DmAn4C0H73Ukwv5ZCD1flt9h7cGkyy/QdyuSqZcE2J9v5KBXnx0eoheY4pJm7 x+hf8OFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOde7-000000055pT-38Zt; Fri, 20 Dec 2024 14:06:27 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOdOH-0000000536L-1o7g for linux-arm-kernel@lists.infradead.org; Fri, 20 Dec 2024 13:50:06 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3862d16b4f5so1333297f8f.0 for ; Fri, 20 Dec 2024 05:50:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734702603; x=1735307403; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=QmwzVQdSamTI4Mm25hbiGBJIk1Q/esKMsBlmHYpUYHM=; b=Vk2oAGMF1tFiCTRCjdA8aalFq4InKqdMz8pNA8i2FwEFRy+QWQzDTpl0hH6P4Kc/N+ 1+AEip1d+Sh2uhx/+YGhZY3FjHoIKG4h7hA9WPcrk0mUrmRFpUmbCCSdfdz3JfjnRuG1 aguflxDunTffdGchgAbeiPywDSJBmOvefGWBdTfyVgoUjj/uBhh/FMfnuReAkGuXzt7F oCeUKMLRFevGS87/kGPhcnQ3B6fGDz61o11DwWYZzIPU6JW/j5GnGLWgSF1t4p2cqOT7 cCmKFrJXv9/8bmdR6GhnurAA3vXtvrlch3aJszkEDOdNme8V/lnnsmCxM+6083wOGeTw LzOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734702603; x=1735307403; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QmwzVQdSamTI4Mm25hbiGBJIk1Q/esKMsBlmHYpUYHM=; b=UtB/55CIjtiLQuA7J2z+BZGde5a6AUlJfenieGqfRIgbQC4q/aZKqFC4ssfSlN9dJM nREh83d9xcl5R7Rb1m8w+Jwrl2JsleDbNkPZr/s9Rall8w0ngx0/z1oGibMPPuW/vkJ9 31fot54PKIgqi3CZqoazHAfC73FhkHVkxEU+m18Z1Q0YiZCgZEWxVnXtshUWP0+Norz1 rcfjEHWaqNJDzcubw32uLKzj1LcNe2Q8iIr/UTI9+mqb0K0hNkdz/2O2mmRgR6msKFn2 RI/pS6ClVp/vGZhN/tAq4s61l5UQF4lx27wrgpfl/2CIC7YztkPGuZiZ5IOSAb+wjxHc 3BXQ== X-Forwarded-Encrypted: i=1; AJvYcCXJWs7ZxVydqZlZw3EVwZ3Kga1lJZs6+W/6oLadYLOQuJuUAHKe/y2yhv+t2mlc+fZ1/kReT2zO0F8vv00UXG+P@lists.infradead.org X-Gm-Message-State: AOJu0YxVWdmOM+3n1MFcTfwwaMCGZ9WLeMtl09H2ITb4p35MbRxf/Fy8 Isw7gUccNLF1BVJ8CMVUBpxnGz9XLf56RrE9t1gXeRjZNq2mupahDQ64WemyQUAq+i5WCMzaQII dg4k= X-Gm-Gg: ASbGncsonfhCfQAkKTbmctgQbxqxW/E/xEO5qf/wvXgnYHAGs6JU/Ool36en6b1lKL5 efmo7fT6uy9q+YcOcrgPTvmTXI9iv2P5AVG+gjRUohpCWnjmS0XdwqGnoQ+4svvd9lEMj8LZMO6 ezAtORbFD4C0ew7NiMMVtB7pxIN8ZNYisdVTIFSDVL0sEAfTAylOYiEd4oPODCQ0Ljl8xCWclJY f3T0BfGu5omqiC4dBb+H+y/se+Za4Fiv4bZm65eLKC6t9uhtvl7PgE4MJoJ27mUQKky3lIqP5o9 BlxrMgJbPX+Zuay+EiNNyDnau82yFG67mOu/ X-Google-Smtp-Source: AGHT+IG4yktd0Nvj4jp85019vCB0iMT9S1j+gDh88vOL8Wge+kTTESou7askbSNFyaZ7Gt6ZtnOLAg== X-Received: by 2002:a05:6000:1acd:b0:386:3c2f:a3e7 with SMTP id ffacd0b85a97d-38a1a1f7298mr6356413f8f.3.1734702603348; Fri, 20 Dec 2024 05:50:03 -0800 (PST) Received: from ta2.c.googlers.com (130.173.34.34.bc.googleusercontent.com. [34.34.173.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c832e74sm4044313f8f.30.2024.12.20.05.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 05:50:02 -0800 (PST) From: Tudor Ambarus Date: Fri, 20 Dec 2024 13:49:59 +0000 Subject: [PATCH v6 4/5] mailbox: add Samsung Exynos driver MIME-Version: 1.0 Message-Id: <20241220-acpm-v4-upstream-mbox-v6-4-a6942806e52a@linaro.org> References: <20241220-acpm-v4-upstream-mbox-v6-0-a6942806e52a@linaro.org> In-Reply-To: <20241220-acpm-v4-upstream-mbox-v6-0-a6942806e52a@linaro.org> To: Jassi Brar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Krzysztof Kozlowski , Alim Akhtar Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, andre.draszik@linaro.org, peter.griffin@linaro.org, kernel-team@android.com, willmcvicker@google.com, daniel.lezcano@linaro.org, vincent.guittot@linaro.org, ulf.hansson@linaro.org, arnd@arndb.de, Tudor Ambarus X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734702598; l=7455; i=tudor.ambarus@linaro.org; s=20241212; h=from:subject:message-id; bh=8V4hRjvTjS/OPHho+b5gFECG0twWFwovkcgrCiubsOw=; b=aFSKkY8CH0jktsAVfeCjhnjjDoAFx4ULnLvakRK6H6Z+77IEJyqtRBaxSWah93ELQ7I8E4wWw nM/5nv7SeA+A0J15n+UpbuzK9zJ4psVXCTpXcGxYoVWX9ALZbNSHk2w X-Developer-Key: i=tudor.ambarus@linaro.org; a=ed25519; pk=uQzE0NXo3dIjeowMTOPCpIiPHEz12IA/MbyzrZVh9WI= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_055005_475394_5DCCB4CA X-CRM114-Status: GOOD ( 24.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Samsung Exynos mailbox controller, used on Google GS101 SoC, has 16 flag bits for hardware interrupt generation and a shared register for passing mailbox messages. When the controller is used by the ACPM protocol the shared register is ignored and the mailbox controller acts as a doorbell. The controller just raises the interrupt to APM after the ACPM protocol has written the message to SRAM. Add support for the Samsung Exynos mailbox controller. Signed-off-by: Tudor Ambarus --- drivers/mailbox/Kconfig | 11 +++ drivers/mailbox/Makefile | 2 + drivers/mailbox/exynos-mailbox.c | 174 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+) diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index 8ecba7fb999e..44b808c4d97f 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -36,6 +36,17 @@ config ARM_MHU_V3 that provides different means of transports: supported extensions will be discovered and possibly managed at probe-time. +config EXYNOS_MBOX + tristate "Exynos Mailbox" + depends on ARCH_EXYNOS || COMPILE_TEST + help + Say Y here if you want to build the Samsung Exynos Mailbox controller + driver. The controller has 16 flag bits for hardware interrupt + generation and a shared register for passing mailbox messages. + When the controller is used by the ACPM protocol the shared register + is ignored and the mailbox controller acts as a doorbell that raises + the interrupt to the ACPM firmware. + config IMX_MBOX tristate "i.MX Mailbox" depends on ARCH_MXC || COMPILE_TEST diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile index 5f4f5b0ce2cc..86192b5c7c32 100644 --- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile @@ -11,6 +11,8 @@ obj-$(CONFIG_ARM_MHU_V2) += arm_mhuv2.o obj-$(CONFIG_ARM_MHU_V3) += arm_mhuv3.o +obj-$(CONFIG_EXYNOS_MBOX) += exynos-mailbox.o + obj-$(CONFIG_IMX_MBOX) += imx-mailbox.o obj-$(CONFIG_ARMADA_37XX_RWTM_MBOX) += armada-37xx-rwtm-mailbox.o diff --git a/drivers/mailbox/exynos-mailbox.c b/drivers/mailbox/exynos-mailbox.c new file mode 100644 index 000000000000..07bbc6b442ef --- /dev/null +++ b/drivers/mailbox/exynos-mailbox.c @@ -0,0 +1,174 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright 2020 Samsung Electronics Co., Ltd. + * Copyright 2020 Google LLC. + * Copyright 2024 Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define EXYNOS_MBOX_MCUCTRL 0x0 /* Mailbox Control Register */ +#define EXYNOS_MBOX_INTCR0 0x24 /* Interrupt Clear Register 0 */ +#define EXYNOS_MBOX_INTMR0 0x28 /* Interrupt Mask Register 0 */ +#define EXYNOS_MBOX_INTSR0 0x2c /* Interrupt Status Register 0 */ +#define EXYNOS_MBOX_INTMSR0 0x30 /* Interrupt Mask Status Register 0 */ +#define EXYNOS_MBOX_INTGR1 0x40 /* Interrupt Generation Register 1 */ +#define EXYNOS_MBOX_INTMR1 0x48 /* Interrupt Mask Register 1 */ +#define EXYNOS_MBOX_INTSR1 0x4c /* Interrupt Status Register 1 */ +#define EXYNOS_MBOX_INTMSR1 0x50 /* Interrupt Mask Status Register 1 */ + +#define EXYNOS_MBOX_INTMR0_MASK GENMASK(15, 0) +#define EXYNOS_MBOX_INTGR1_MASK GENMASK(15, 0) + +#define EXYNOS_MBOX_CHAN_COUNT HWEIGHT32(EXYNOS_MBOX_INTGR1_MASK) + +enum { + EXYNOS_MBOX_CELL_ID, + EXYNOS_MBOX_CELL_TYPE, + EXYNOS_MBOX_CELLS +}; + +#define EXYNOS_MBOX_CELL_TYPE_COUNT 2 + +/** + * struct exynos_mbox - driver's private data. + * @regs: mailbox registers base address. + * @mbox: pointer to the mailbox controller. + * @dev: pointer to the mailbox device. + * @pclk: pointer to the mailbox peripheral clock. + */ +struct exynos_mbox { + void __iomem *regs; + struct mbox_controller *mbox; + struct device *dev; + struct clk *pclk; +}; + +static inline int exynos_mbox_chan_index(struct mbox_chan *chan) +{ + return chan - chan->mbox->chans; +} + +static int exynos_mbox_send_data(struct mbox_chan *chan, void *data) +{ + struct exynos_mbox *exynos_mbox = dev_get_drvdata(chan->mbox->dev); + int index = exynos_mbox_chan_index(chan); + + writel(BIT(index), exynos_mbox->regs + EXYNOS_MBOX_INTGR1); + + return 0; +} + +static const struct mbox_chan_ops exynos_mbox_chan_ops = { + .send_data = exynos_mbox_send_data, +}; + +static struct mbox_chan *exynos_mbox_xlate(struct mbox_controller *mbox, + const struct mbox_xlate_args *sp) +{ + u32 id, type; + + if (sp->args_count != EXYNOS_MBOX_CELLS) { + dev_err(mbox->dev, "Invalid argument count %d\n", + sp->args_count); + return ERR_PTR(-EINVAL); + } + + id = sp->args[EXYNOS_MBOX_CELL_ID]; + if (id >= mbox->num_chans) { + dev_err(mbox->dev, "Invalid channel ID %d\n", id); + return ERR_PTR(-EINVAL); + } + + type = sp->args[EXYNOS_MBOX_CELL_TYPE]; + if (type >= EXYNOS_MBOX_CELL_TYPE_COUNT) { + dev_err(mbox->dev, "Invalid channel type %d\n", type); + return ERR_PTR(-EINVAL); + } + + if (type == DATA) { + dev_err(mbox->dev, "DATA channel type [%d] not supported\n", + type); + return ERR_PTR(-EINVAL); + }; + + return &mbox->chans[id]; +} + +static const struct of_device_id exynos_mbox_match[] = { + { .compatible = "google,gs101-mbox" }, + {}, +}; +MODULE_DEVICE_TABLE(of, exynos_mbox_match); + +static int exynos_mbox_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct exynos_mbox *exynos_mbox; + struct mbox_controller *mbox; + struct mbox_chan *chans; + int i; + + exynos_mbox = devm_kzalloc(dev, sizeof(*exynos_mbox), GFP_KERNEL); + if (!exynos_mbox) + return -ENOMEM; + + mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); + if (!mbox) + return -ENOMEM; + + chans = devm_kcalloc(dev, EXYNOS_MBOX_CHAN_COUNT, sizeof(*chans), + GFP_KERNEL); + if (!chans) + return -ENOMEM; + + exynos_mbox->regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(exynos_mbox->regs)) + return PTR_ERR(exynos_mbox->regs); + + exynos_mbox->pclk = devm_clk_get_enabled(dev, "pclk"); + if (IS_ERR(exynos_mbox->pclk)) + return dev_err_probe(dev, PTR_ERR(exynos_mbox->pclk), + "Failed to enable clock.\n"); + + mbox->num_chans = EXYNOS_MBOX_CHAN_COUNT; + mbox->chans = chans; + mbox->dev = dev; + mbox->ops = &exynos_mbox_chan_ops; + mbox->xlate = exynos_mbox_xlate; + + for (i = 0; i < EXYNOS_MBOX_CHAN_COUNT; i++) + chans[i].mbox = mbox; + + exynos_mbox->dev = dev; + exynos_mbox->mbox = mbox; + + platform_set_drvdata(pdev, exynos_mbox); + + /* Mask out all interrupts. We support just polling channels for now. */ + writel(EXYNOS_MBOX_INTMR0_MASK, exynos_mbox->regs + EXYNOS_MBOX_INTMR0); + + return devm_mbox_controller_register(dev, mbox); +} + +static struct platform_driver exynos_mbox_driver = { + .probe = exynos_mbox_probe, + .driver = { + .name = "exynos-acpm-mbox", + .of_match_table = exynos_mbox_match, + }, +}; +module_platform_driver(exynos_mbox_driver); + +MODULE_AUTHOR("Tudor Ambarus "); +MODULE_DESCRIPTION("Samsung Exynos mailbox driver"); +MODULE_LICENSE("GPL"); From patchwork Fri Dec 20 13:50:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 13916814 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E974FE77188 for ; Fri, 20 Dec 2024 14:07:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2h6pKpWNyOGCaw3yTYwiqZcJCt91K/pLDCAKswGUtgU=; b=Em/F4jQA/sdyu6Vk4mQOXKdAYv Xlgf9VFTsOl/Ax3626vwaoumXApZBtkJgsMKVyiTtniUyKN2G8aYzORAjmJcbznhHatfrSHnX4kVl tCx4vj1bye4yMJ0rnmu1jFlV204SmUZ9gbVl6uN9J0TtMAnt5vau2nFm1jVThz0CSa6P+GQ0soDya Q/+lysECqedAH8NQNEcBXEZGdp6fTjgIyTxmmvcuWI8cB6/uVRYgmr4ZPoF34641ZG1W0+hI+BhyY 7F8WcMpbZrgq691l50Zwi2CCCle2JPFIJJSrvDuFs7ohi7t7zcrDgAdVfEnNs11x2Rf6FFqWmJEWQ slFovwqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOdfF-000000055xZ-1y24; Fri, 20 Dec 2024 14:07:37 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOdOI-0000000536h-30iq for linux-arm-kernel@lists.infradead.org; Fri, 20 Dec 2024 13:50:07 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-388cae9eb9fso1145429f8f.3 for ; Fri, 20 Dec 2024 05:50:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734702605; x=1735307405; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=2h6pKpWNyOGCaw3yTYwiqZcJCt91K/pLDCAKswGUtgU=; b=LMtIcx3DiNcc+tiZ1or3z3bsVHxk9USjplOZW6fPipxPljn/NQisldmrHOddP/aHdD QnBJ4VLGCjA1Sp8MXC3+mK5FIIja+vaeeBXjhdSDZYGHev4q0MuzzXV7XGJ9CmCJ5sUN VeOJMedH60v85BTQYJyRAZO/GWUHS1vF0xpxPrrz2VL8Xkun6EqWz9l5UqIAfLAXhn4m yMNCH39hZ2xdNfgPKytVyW2ZeWypoDpQ6jkBS8JK5BmnMP2c01UK4duQEu9RBrO0S5Ml wIeYs9Zv9REZwATtb/pLYC0ePjKlxU70PePbzlS7QZwRyE6Xkq20czAzFsRFYnCjWYEg MhaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734702605; x=1735307405; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2h6pKpWNyOGCaw3yTYwiqZcJCt91K/pLDCAKswGUtgU=; b=l4MnHGee6vlpRya63d/ZGU/fP0KwtYSGQHmBU8auyq8kwpCj93lWiNkrJ25JgdFYf7 hXEmxfbHq/W07aMSNyYqoSAHC40xIiDcFr+tjBwh/lv68xnS4B9WqMpnwTlIxq4s/FsW TMWVlYCK/N8hBcu4BYndQr7FqzqznerDpIBSXhxAEzFjRRGm5gqs6Zi8seSbwkcmgutC 1oUqLUPCQvt7Ny0UKgishiTadjs7EbNskTyYsdqctecpeFIMtgj3Ur7Tn4WMKvEMBvNs t2cEfoNvSd6xyMKZhoIPPmZVzzhTqwdiwDqv3pflADXDU640MIAY7be0tGzUtlmwZpTq SElw== X-Forwarded-Encrypted: i=1; AJvYcCUp5EmdKMc2NqMWW238+sjHbzlrFwbKWEFM8HyJBV22oFdbeOt6XWzAy8B6iSQhZrmY8XmK+vzGY8xHseauVwxb@lists.infradead.org X-Gm-Message-State: AOJu0YxnGLhPwLDq5TwzSdi59bPU7Mu7W3JdGttgw6inY9LlBxF6Yk7p QCBwagUUvzd6TDx9cSa5Zxm71J5GxItTwxuTw8dQQXiMRK+hXzMKbHktFeoS/yU= X-Gm-Gg: ASbGnctzocHU1gBa/2EVsTKZ5QXTBpdKyACMyxVx+4sTUCZX+tbqHKLO8w49Xb6OgJU JvwVjzZv14BzBEKTzoF79eFIz/EwHn2OjVJh0ErAzawvuIySbG+NDcHWav/6+NomLInnOYkvFvS ar7SBWvjU/jqPPnpeGp+3hz0/AmI5/BllUUIgD4c88gJ7/wX/J1nTXUP7gnEpatW4MgmJxE7pKU //Z2L8LoQxB3ZIfgwV5M2Jo5n/fkMpsBncI9HExN9zDg1uMTW+qyz3ZuI9c6+kHRjXI86aSPfC7 wavSW9a7vsqev62j2B9wK/BJtk/bpvwh8KW+ X-Google-Smtp-Source: AGHT+IEzk3FDr4mxRi9pcg64L4EH36p/AQ921KSU720SqVRUCT5e6SMqARYYJAMs7JhmbOKgemYFdQ== X-Received: by 2002:a5d:648a:0:b0:386:36e7:f44f with SMTP id ffacd0b85a97d-38a221fb038mr2515751f8f.18.1734702604753; Fri, 20 Dec 2024 05:50:04 -0800 (PST) Received: from ta2.c.googlers.com (130.173.34.34.bc.googleusercontent.com. [34.34.173.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c832e74sm4044313f8f.30.2024.12.20.05.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 05:50:03 -0800 (PST) From: Tudor Ambarus Date: Fri, 20 Dec 2024 13:50:00 +0000 Subject: [PATCH v6 5/5] MAINTAINERS: add entry for Samsung Exynos mailbox driver MIME-Version: 1.0 Message-Id: <20241220-acpm-v4-upstream-mbox-v6-5-a6942806e52a@linaro.org> References: <20241220-acpm-v4-upstream-mbox-v6-0-a6942806e52a@linaro.org> In-Reply-To: <20241220-acpm-v4-upstream-mbox-v6-0-a6942806e52a@linaro.org> To: Jassi Brar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Krzysztof Kozlowski , Alim Akhtar Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, andre.draszik@linaro.org, peter.griffin@linaro.org, kernel-team@android.com, willmcvicker@google.com, daniel.lezcano@linaro.org, vincent.guittot@linaro.org, ulf.hansson@linaro.org, arnd@arndb.de, Tudor Ambarus , Krzysztof Kozlowski X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734702598; l=1338; i=tudor.ambarus@linaro.org; s=20241212; h=from:subject:message-id; bh=FADFf9WfzjcMmisKrO8yY+HCWLXOPKs8H/SA2SqLMyQ=; b=R/NhwDpi95hfet9uVWKydOIL9KS/J5QAVtPKjGibId5k5o46YPFi74GbUfbFSSKG+goXQpBoD DO8znrl5OuxCXJUd1qUWRkIqdil5rImUGzsy1AcnYVz0s/L8+wAW5B7 X-Developer-Key: i=tudor.ambarus@linaro.org; a=ed25519; pk=uQzE0NXo3dIjeowMTOPCpIiPHEz12IA/MbyzrZVh9WI= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241220_055006_756525_237B017E X-CRM114-Status: UNSURE ( 8.80 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add entry for the Samsung Exynos mailbox driver. Signed-off-by: Tudor Ambarus Reviewed-by: Krzysztof Kozlowski Reviewed-by: Peter Griffin --- MAINTAINERS | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index baf0eeb9a355..6bef5fc5e4ee 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3023,6 +3023,7 @@ F: drivers/*/*s3c24* F: drivers/*/*s3c64xx* F: drivers/*/*s5pv210* F: drivers/clocksource/samsung_pwm_timer.c +F: drivers/mailbox/exynos-mailbox.c F: drivers/memory/samsung/ F: drivers/pwm/pwm-samsung.c F: drivers/soc/samsung/ @@ -20717,6 +20718,15 @@ F: arch/arm64/boot/dts/exynos/exynos850* F: drivers/clk/samsung/clk-exynos850.c F: include/dt-bindings/clock/exynos850.h +SAMSUNG EXYNOS MAILBOX DRIVER +M: Tudor Ambarus +L: linux-kernel@vger.kernel.org +L: linux-samsung-soc@vger.kernel.org +S: Supported +F: Documentation/devicetree/bindings/mailbox/google,gs101-mbox.yaml +F: drivers/mailbox/exynos-mailbox.c +F: include/dt-bindings/mailbox/google,gs101.h + SAMSUNG EXYNOS PSEUDO RANDOM NUMBER GENERATOR (RNG) DRIVER M: Krzysztof Kozlowski L: linux-crypto@vger.kernel.org