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: 13916797 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C77BB2156FD for ; Fri, 20 Dec 2024 13:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734702603; cv=none; b=s3GsYXBcKDghy9m+jEcFNiSyYkI4vMbtidP9KRbArTAutGk2ju89h1HvWbd+nRfrOiyESJ/BC/aQopxuCIS7ITUVg4X9FepRgInKb2AsXuy3rQi0+SADI7QGTpdGbWn0vdT/LVjtb06qaJS++a3GRVZEfdV5QZnI0jqActpy6do= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734702603; c=relaxed/simple; bh=98UdmgNXZR4Odm8WAK3DNauL946xSKIV8vPYFoFzXtc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EoBDcyhFFXjE/4m3MIVbWAkYaW9Ad76TCt6Kub1tI5KdIQ/t0l3EbHJt4E6MrQUrf9eAOatz+p7g9G3A2WTQltWWKGra9XF+z+QbYSz7nCSM762QnTMSavxMITDZ17F268i2LMKy3HDaU9eZyIDKhjNQLLmldqvOILiFm8QGmn0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=SI13F7aW; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SI13F7aW" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-385dece873cso850628f8f.0 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=vger.kernel.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=SI13F7aWZl3ze+TueJuL9j8JTC/efTOY+yljHQaEfuee6GFFAHPCCBkXwhCWOhJtIL W3SIv5QC2jH1CybtmnJxWj7it9TImIY3uY4eq5HhN30B91LcASl0uoKXsSbdA7bGOGSq yICR7nrilO3WtqeSG1X8dUY952nM7ZGCJK2Ny2bZqyBQPhP6iBHFf7TxAVFL+kut66zQ AXtdse/24bgOBzCyEHWXVktyeRRBbHuso6F5tP+iqZBuWtwXVuDcxVDAkCX3XwV4u9BD azOvY1EChZeol55huPOgRYE0jI+pLc3xhS/6S3ThsUfpan4Z6wtxRGo9EcGLqIvyWIIY vTSQ== 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=khronuaJOYGz0KrT+ogVsLWCBpjJqKynsEQSl8LiFKLgVm219tP9LKlS/M+2vTlQ6m ZlsZkgtbE5t3RCsahoIA4OtmE63L+qojPn6+2lsoEY9V2OIjIq8m5u/vWVxn/aWM6W/c AvmwugosgghR3cg3kPWywyNj08UmY4K53+uq+az8IN7ygONWnVDAHmFPjujt+D7Lmdj7 VtP9HLVZ8CY9qj1OaYd+84Yu2GU1lMRDtYNTls5on5HwzDOGrozyweQ4a2hBexU4bG1g Znh2SKmiJAeV4CfYlBiuVaY4N4IOLF6WDHYwTecZgOjiNSfEWi2qrDBRS3e0HL1upsYF 6ykQ== X-Forwarded-Encrypted: i=1; AJvYcCWz+lrwYMgxzUgsPKZmWynWRcV4ZZRwjSQIXYttUfO9Fd5SZxVIz3KfdDd0sjPcHDMXArousQo1KUcDc7g9ejY3hg==@vger.kernel.org X-Gm-Message-State: AOJu0Yye/hMRk+YZT1KfKHTl97LAnuWUwCtI3OvMck4KPJOx/k6nqXLv zKvpYjRygJdU0aZtSkMRnaGFAaYKfEENdedl/tMDPpy7WeUUO5p+YQT46+z3r54= X-Gm-Gg: ASbGncsooNzh4Cj8SZA/+GRA1NEEJF1DCVCXCBICuKRNQJToJo9f702a27uE4d4erXV xbelzuWyYAVC9uxH7A1bsrYTYq0nLcq5DQYCO4RHuUY6eUF1dm8htplFRwD0j05lP1PsgO3cIK3 E+TLDFX5R2dTzJAInDUnenSMPi05RC5NK/R7pu83qkF7L4o8+jfej0prjMFOTse1Qf71fgfob2A DRvHAqqumYk39VBfhqlF1sZA8nZF4sM0UTjcO1Uqp7iVkl+EUFgYE3pURmE6cVhcpyQw4WboGBd u6kMIQeG9UBibDRQyvKOcgICfEGLsgPIoSXW 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>; Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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= 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 Acked-by: Krzysztof Kozlowski --- 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: 13916799 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2DF3216392 for ; Fri, 20 Dec 2024 13:50:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734702604; cv=none; b=YDbg88RM/HaxOz8yf1TeBrGPtl+Y6QumUlZ8rPwaP/Ms8nKKCfky4JBB7Yzg+JHvUXJtzDMGTkPRqzHKJ3ZYvPr9cY5Pu6Bc5UCwBjM2oPXICGj3Evpohh+E1SOJ6I65Meh8XgKCxU/jnMoYsW6XLpiA8j8G9ePn7tftTibm6xU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734702604; c=relaxed/simple; bh=gc/x/vd/iTT6DgRuhTHKKXPn1qQVX3+uctKpzIwRy8k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Sr8ARu9Jqur7cfhzEBJbsqloc/tlvEbQZQFSyK3ieM6TsF5/jZ3h/wFm7ucUE79Q03qOuEXG0EvQSRew9f+ONceNl32BtFc4bhELcPb9Q2HCgmLCE+Kn0pqm+WBd4o5/J9Ge8XEuFABGTALdDygF5OrYJxluwvkKuRWqk0kBrNs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Qvwji8Gq; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Qvwji8Gq" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-436637e8c8dso14898515e9.1 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=vger.kernel.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=Qvwji8GqF3WohjUIVxGklkmlYPawplJY/2wP9EsiOkTpwaijr+//ZVU8ltlF7B3wU9 fUaUEGQfY788vSWOm3yoXV4QNtwm9uMbvUifQ/k95+8DHlXbBrXgmGyN5ICfqorGszKp SK/bQdXqpj8bD46WRLPDmnGoRaBhuN70RPGengu9xLcgdlDYPBbV9ze9EnobNT1WWtBn R0hWJiZZe98PCuldv1qS0mdES8zR136wQZ3k3S0cd2pxCC/oDr1uZmhCPsd/hj5BVIW8 69eDMHTcjEydsoytHP+3YBBAOPPRkDv8/l39ZV/dGWHPPdad1WXZwNlVBZt8uIRFPGy0 nEag== 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=Ho3yGCJoRar24mjKWJUaMIonLFQIwZ3r8gy6u+fGjaOtvHp1DplNQtH4oFU3zPpuQW v++kne5AuZro1QfVBDmea0tSrSg6/Ve3O3CfdBeIkWwVOW7KooXVpdB37wIvS3zBRbmc oEeCwubF80Sb2rn1hUBpt1GzRd2MTKhhfq7anKOqKj+pmE4SLTSJ4WTvJ0b9VPJCW0XY AYto9MQ81o5sJf7EU/5eO5h24i0d69KpjliKfa6zD2bHvRLEoNtDea4K8Sz5qlchGTCF HDqWWnUO3CsgExAJ6eAXZbWB+nP6TY36hIwu/Jna/j+YT1amuEZdiEoMtucd8l/egFK3 kxPA== X-Forwarded-Encrypted: i=1; AJvYcCXQopcJg9hSfE6hhwoUq+3mHd9khrhiZYdwu18CS4X/hOyvogKsD/TitegnVkMaWG51d/IzDEC2LP+IV/+O2ml1eQ==@vger.kernel.org X-Gm-Message-State: AOJu0YwDnqulnLd7HJKgOzjqTnaByApZqQMQs2Nc+uclZijk8cU3yg9K mkOWBEb6tW6P8d5KGH1miQu2BDexx+vHZ7qhSFy2OF/Ax4mUVatZdt9551E8A6vOeG5Qax8Y/Ph hUL4= X-Gm-Gg: ASbGncuEynv00dg+mlS7qT/5nrm/dyVBOIzZaHDiIl5BE0W/jdvDvlPbnpb+IDmOqBc ztqedubuTEF8TtgZE3Ilrrt7GPeY1N5LvPDD13K7toHoDWe1/73fZ8uhE6cJTsVUPmQHerXcwNK s190bBW0aybklmIHpnwvhnANEWbNRIcgWXhpOs98CK+AF2WzvY9yMkU0yYna8W8ucs7C5y6FHkn xX2iXsLFUjR0+N3nDA1pqVBRIZUXSodAsWffjDC6PFzdoDiBNsLxntgI5tzCNDWsdY4KDN6+kEW kNc4WgmwKNrb+EImbUPwPYMIcu74l2h0xzKQ 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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= 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: 13916800 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C736A21A420 for ; Fri, 20 Dec 2024 13:50:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734702606; cv=none; b=VM4nZmbazWCUbfHgW6X3CKymN5xuywKHSwRPfiPy7JSPT9hcAwEft2XHBw0S3LOdYOR3TW9XF0XIDxF3n9scW/kZO9uTDPAoquNT7iWXG5u4YbBR3BmW8FIcTWW9Z87DA8bFCrbbf9dvie79WtDOWFj7RXM9GM13n4D/+JkV7wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734702606; c=relaxed/simple; bh=yyB5CQGhVmNL0L7BcpLJ32JRUO4zLOTRcjHSgygE7Ik=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c+IP1mDCY5cLEw+8mmieDBecJjbzZzKpvr8xPL/FatHI6HML5dWK5yUiwv8ourxKV2o/V4PZsaLdyuo5KT89QFnO7189cQDpGwZZCyiLCeMWlYgRBV+622ORpUkGnjv5b+7wOgBrarNYUl+2X+FWH+oqPXep2PLEaCvk2Y4IJ+0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=oEfqu0+F; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oEfqu0+F" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3862b364538so1113404f8f.1 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=vger.kernel.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=oEfqu0+FX7OUC3BONqiSMd4vX106N8KVi8M/rK6DSfeDKux8vVWbfwAGzd08aScr2+ Csw0+r5vrWx+8O7X2HDgBVYvhcjs1eADZsLV74sV7oQDq6XhXsS24HEsOKjo2nBItcSI pMk82REltjeVSvqNQ8tdLpJf0xIBXXHxVnapz/M1F+e7UjfYMHauW1s61OyT7D5/VDmR xc24KdLey4RvHqLrbZf2/6a3CZBQwXkOlZaXtUgw5smrTQwcxetU5qD1u30BawMxS1XV G1ssanl3noXmDAFJzQ945hIcPmRhveaeta7gj8JImMpzGrFRJfc4tq055Ak8NfCJWmpe vtYg== 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=UKCg9YNqSa6LimtwAB/wyBrIIjFvmt4pFf0OQIVsyhrKFSBcBmIpzocrYz0GKKu9O1 1N5liGeGvZfmO9kAasXsVVaPyxD/OAtiJyMaWB5TWFFCaiFHJPnyjN9maRlUB2pQc5Cs BiKizCd6pl8tYY/OLr2YbkLilyHUOUa0fw+2z+BkAkHUFN0wKDD6QZ+h8CSmBu7CFeXa 350/sthLgXQf7jaGJ9K6EynjlOMrqqkGEw492wFV7RLxeUDOwOdlLg3lM4CPHqcEN1Uu 8s+FkEUBgHj28mbGwHF7K2+jJ58hLwM96HYJxkJvDC4HwKro1s9FTc+F7M5IliB7TsOK SzAA== X-Forwarded-Encrypted: i=1; AJvYcCXoXZVYcoNb5a61+ho7FZUmCESIVTK98Gbm8164Yn5NME+h3RxEp2LkhzDALJEbPguZrZWngctb5qTDV+IKYoQqGw==@vger.kernel.org X-Gm-Message-State: AOJu0Yx8ONrINsd1x12DVgNoc0RO+wCQM9qW2xfk3i0yN4IcMpAeok0I ew8hVlh9XS+TOK47fsNJ7JhRwFhEfTqSu1FoupCnBeRHlv1heid4+CcOAxbWDZs= X-Gm-Gg: ASbGncueR1PkPnMaO3lHJ1AomhMLOsUK/Pe68JU6I595Uw9nZ56oIivKotwXy0cy29r sSjHZ3pplXCfYarNQoy2uOhKz9A+dHaqmkgbUjqXm/ConPxs/hBbY2KoFaUSQBOafmzuK3jd9U3 MfDWI8EPs2MsNbZRhjW7dd3srBkfALz9oxPPAccQWCAuttLtu7Pq4nEIDCICcfCkN9H6QZtKqJ/ TMD00kUYeDY1I578grv8mQWgqRAbpn/6uk6KrOtnfEe6bm+ipeSoK6cLXDxhFI9EuutRaXi1OgM S0wgdmn6eqmjP3ZfqCN5oo3QZDUkQPQcVnuY 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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= 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: 13916801 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CAAD21A435 for ; Fri, 20 Dec 2024 13:50:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734702607; cv=none; b=RA5+TTfALomwtkfVTsIUPPc6f11fHg7Wwv7Ox1AaVdoVmjYxRLeUq95K72LQm0MuHbRWhLLr9DsLQYfRmIcTggRph9ipVE90XZFLu6tSkxImnEce1kSxCxf4rLBTSP8200NqyGC//robn47YBrg/X0+LItve18o2mrHeVOBlngg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734702607; c=relaxed/simple; bh=8V4hRjvTjS/OPHho+b5gFECG0twWFwovkcgrCiubsOw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YzDr2hyobBQVF3fV4euCfSUE0+e/kxtdgdXO7jruxs55UjdrD5LaqELFfd6etxu3zuVdvgHk3zE884wpAQDyCzYkfie+ilPjzpo33j2aL4S/WczJJd3LSFCqUKBr6IDkZIknNy9xkBnO4/Ybz+KY+BPH/ydEG1MbVonqaCzSFpk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Yq8/mABM; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Yq8/mABM" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-385e87b25f0so1998567f8f.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=vger.kernel.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=Yq8/mABM8ooWWfsYifETiI6KwVyj1jfnKNHU+K8PEUjgBr4dq+KkEmVxjaukZ+s0qK eiyULWMQLYmSH3vZ3bNqRCSQ72E0S8t9W75vcTk78qUzU3x/ZcfYQtqQT0kTXB90KEN1 LByxtODLM/09CrhlhMCjiw/X6+GqKD7J252EC75U5AWl+g2wG/btuf0A9B7fVVQn1puk J9ZShUlU4zmdTEwntTBE9FM5PVsmGRgXNRhzY8n1U/kh5XTHSdSXCTZO7hOw4AX1sFZM 1lD2CL2b9bPA/Lff05abUvCAo/zLoAfj6DVZ0gxbd/DipQQyLNQ7haoZQ8Jb7zbJOAkI h24g== 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=AXhjhViXi99Ko0gJWzJ2n0M6jeWWBxI3padMS3/lUv74FZntPS9MfNhb4cSsZgMItc f6iwL8ia5EGiy/Wwn+T4OcdXICGugtECdxkyzzmrxKUhFf+mQe6xMhvNW8I70Cu9eRWt wc201vp0Y6IvdL5xdgd29H0fOijP1XvKYt+ZpAik8WPA0PCRBaFeCYqQ8e27mDP1DBYV g5Dhh+S2VLGvyRuo4jjsq0I2/Q2RVspb6zlDGTSRdSyUui0IQ0B/8U4nsta8pZBG6LvV bF7qA9gQug5iIz72+Y5Z0ayReB3ixk+v0kTiT4+HevJZnzlQ4sI5a8slW6tynWpSFNkH YLWg== X-Forwarded-Encrypted: i=1; AJvYcCX1E5hVoY0evWXpOKaZAaQ4z83i/dLx5z7mgL2RplmdlHCLin8ihapuWEtDr/zFU2XpTqpeuZifp8m9poFfBO6h+g==@vger.kernel.org X-Gm-Message-State: AOJu0YwwSxdtz4eUvKbqpSsjRLl72gnQnMl87VP4LumcBl3nBTs9lp6h BVVvE2zG72Wub1b9VNuBTzsXOjnDJI2fpR7tlmFK3lssVQka4NiBipP/EHy9tEU= X-Gm-Gg: ASbGnctT62yzF/09GP9YloKaIZvZmBcYnGwF/oLyIta/bcwvXmRE+Sl8tREAaDb//Y6 fb+N/aHICL2PBoseY1h+f78vnlMyR/2+MVKoVM3HR2H6rLrLzJ6otC2wL6kcs4fIEvQyb2nyY4i SEE0lMkRF0takr8+L7TLYfDwmhhkDtWvWOG5sNR5jrxhpTJGIRhavGyTvIvAMXMZSKucqv4koRS a6nMOdRGef5vUc7A7l9YmCYKkYkVa8nIN2wIzuLMXW2hjizD62kzO3B3sGvk89vVXY8eVBk8onH wKnaqfHqdr6ssNqA8eX07SNxE8T1zIQh4vQs 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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= 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: 13916802 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F14E21A422 for ; Fri, 20 Dec 2024 13:50:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734702608; cv=none; b=BV0laG3xJSUhGzz/v4RC8ClRCNq4Fs8tP5Bi+AmmgppKvq0xT2K03lB12vcOK6rO89GwLhGdAZzDzzfLK5e2H9Rm7hobSlM0l5N3iWge9uhVpSa9bTrX9He3KEwBtYjTQEJ11ljwCOldQtf2Q0kWvomtWH99AuA6HRL9X28cjn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734702608; c=relaxed/simple; bh=FADFf9WfzjcMmisKrO8yY+HCWLXOPKs8H/SA2SqLMyQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j9PtxGsnhogqew7ItxXhq1NAux9il2rKULbcsfayde501gExz+5jMxwujMCM0po3cr3wQQwaurH0UVtqjCmCfTxo878FWfbRYvEzOU2avJQuuk2IUmQ3WvM/gDUn6ImKft3XMa1zxHtlIWtdsDL60RLXu2E9uSbBdHm+FfuFaCo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=OGKP9bCI; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OGKP9bCI" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-43622354a3eso13362255e9.1 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=vger.kernel.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=OGKP9bCIfBgldblNmXgampEHN0kkPbvM7oZvzQpX83YC+QlbREAa6SnxIinB5kNtZZ 7UGRjlHpHJyvWj9eU0CrBAcib28Sq54cZKihAG4I8d83daDpYMvVvskdnnDEHtx1tZnG nSZrGvY1e1455hsUSwd1sJQlm1T9Yx1dg2Oan1YhLRhGbXh87ggynItHxSl6oVxeKec/ gb7TuwhAwL4IdiZk4lyVsvPfbVxlvNm3gvIltASm+XeF8iWP9FDYSTlPdmGqKhHwC7b2 owneHQT0jz0ei/Va65oVNp2MYm4KncyXDoDwVqMOPXMdLi106SHasDB0uOg8J8BZb0gv ksQQ== 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=hTO3usUMarStX06LBANyacKyqX6dVFc+QHDPi7Yerq3BlCtTArhUWjPGFHd2naaaZo X582aTqOFmLsYDwLk6iLyauuM4Kc7d/14ov4w0lchcoxWbUXfzIQm0IKJFVeKH8VbbF1 1G9Vej5p32ZzuQoxV9N/Ih9OIJUSDWuoqd1+cm+AS97YK5c/LyqFkqUzi2womhcOUbrn RCpJ3qzOH1bKcGUeTz5ONPVdg91IizAVBL+aKjTbbEgqrIo/Sthgx6AnewqEulGg6rr0 uTBRHb+Gaa6eCInAaN1m7/BzF0V8qamditeHU4YE3Sbx7D48/wMcd7TVw4VCp1OB1H1Y ruAg== X-Forwarded-Encrypted: i=1; AJvYcCVF2wXrU5WWYtjen7Q/7icz5RtRMx/ozp7TpMuN0D6U4lkb9LafzryIJdZW7PMavku73Cw40qs7va+HAq4iO+A8Hg==@vger.kernel.org X-Gm-Message-State: AOJu0Yy47C1yztmN5NhD7jLDI2hMc2evDgHkqGvoyUQOq9QbHx5Vtcjx dnRwI+NaUfeww/5/1D3L25feeLdp1cC1iEyntvMrtBpVrpTMRDvEW2ucRxZyInU= X-Gm-Gg: ASbGncva/sVvv7K3Tu0dOvf5BNYMTUSi8AkmINaz29BMFJr0pp43Sa2ps1ClkCYp8YV Jegalc01Qmp/bqDDc5tvX54y/ebA1pHCxfVEn40a/8j9xqU7SLoeh3olpywtntlYeJ/aDtAuDJo UO/vwumlUAqrAgLPsyquPI3jZlYfKSP8JmMss+pfReevWtjlgAkCrZwKww8HwNamLf/L69D83ve 1xxMBvVRI1WXUNkLPB7AuFf5TbID0WMpB+2aLXGevk+hZm/ewcwp4/y8zOKh1CTitC6nf9mRzWm ZZGTNQy/sjQMSWle0CmWEDpxeNElh1LVIMmi 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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= 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