Skip to contentSkip to conversation

Add a mailbox driver framework/uclass

PATCH Superseded Stephen Warren 2 participants 5 messages May 13, 2016 – May 27, 2016 Mailbox API

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Add a mailbox driver framework/uclass

From: Stephen Warren <[email protected]>

A mailbox is a hardware mechanism for transferring small message and/or notifications between the CPU on which U-Boot runs and some other device such as an auxilliary CPU running firmware or a hardware module.

This patch defines a standard API that connects mailbox clients to mailbox providers (drivers). Initially, DT is the only supported method for connecting the two.

The DT binding specification (mailbox.txt) was taken from Linux kernel v4.5's Documentation/devicetree/bindings/mailbox/mailbox.txt.

---
v2:
* Use timer_get_us() rather than get_ticks() and conversion code.
* Explicitly mention that mailbox messages are fixed size.
* Spell out IPC.
* Fix typos.

I'll send a sandbox test for this as a separate patch.

 doc/device-tree-bindings/mailbox/mailbox.txt |  32 ++++++
 drivers/Kconfig                              |   2 +
 drivers/Makefile                             |   1 +
 drivers/mailbox/Kconfig                      |  13 +++
 drivers/mailbox/Makefile                     |   5 +
 drivers/mailbox/mailbox-uclass.c             | 145 ++++++++++++++++++++++++++
 include/dm/uclass-id.h                       |   1 +
 include/mailbox_client.h                     | 149 +++++++++++++++++++++++++++
 include/mailbox_uclass.h                     |  83 +++++++++++++++
 9 files changed, 431 insertions(+)
 create mode 100644 doc/device-tree-bindings/mailbox/mailbox.txt
 create mode 100644 drivers/mailbox/Kconfig
 create mode 100644 drivers/mailbox/Makefile
 create mode 100644 drivers/mailbox/mailbox-uclass.c
 create mode 100644 include/mailbox_client.h
 create mode 100644 include/mailbox_uclass.h
doc/device-tree-bindings/mailbox/mailbox.txt new file +32 -0
new file mode 100644
index 000000000000..be05b9746c69
@@ -0,0 +1,32 @@
+* Generic Mailbox Controller and client driver bindings
+
+Generic binding to provide a way for Mailbox controller drivers to
+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.
+
+Example:
+	mailbox: mailbox {
+		...
+		#mbox-cells = <1>;
+	};
+
+
+* Mailbox Client
+
+Required property:
+- mboxes: List of phandle and mailbox channel specifiers.
+
+Optional property:
+- mbox-names: List of identifier strings for each mailbox channel.
+
+Example:
+	pwr_cntrl: power {
+		...
+		mbox-names = "pwr-ctrl", "rpc";
+		mboxes = <&mailbox 0 &mailbox 1>;
+	};
drivers/Kconfig +2 -0
index 118b66ed0e14..f2a137ad87fc 100644
@@ -30,6 +30,8 @@ source "drivers/input/Kconfig"
 
 source "drivers/led/Kconfig"
 
+source "drivers/mailbox/Kconfig"
+
 source "drivers/memory/Kconfig"
 
 source "drivers/misc/Kconfig"
drivers/Makefile +1 -0
index 6900097e7998..47fddff084b5 100644
@@ -62,6 +62,7 @@ obj-y += video/
 obj-y += watchdog/
 obj-$(CONFIG_QE) += qe/
 obj-$(CONFIG_U_QE) += qe/
+obj-y += mailbox/
 obj-y += memory/
 obj-y += pwm/
 obj-y += input/
drivers/mailbox/Kconfig new file +13 -0
new file mode 100644
index 000000000000..295e6db0f28c
@@ -0,0 +1,13 @@
+menu "Mailbox Controller Support"
+
+config DM_MAILBOX
+	bool "Enable mailbox controllers using Driver Model"
+	depends on DM && OF_CONTROL
+	help
+	  Enable support for the mailbox driver class. Mailboxes provide the
+	  ability to transfer small messages and/or notifications from one
+	  CPU to another CPU, or sometimes to dedicated HW modules. They form
+	  the basis of a variety of inter-process/inter-CPU communication
+	  protocols.
+
+endmenu
drivers/mailbox/Makefile new file +5 -0
new file mode 100644
index 000000000000..a2d96a4e3b98
@@ -0,0 +1,5 @@
+# Copyright (c) 2016, NVIDIA CORPORATION.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_DM_MAILBOX) += mailbox-uclass.o
drivers/mailbox/mailbox-uclass.c new file +145 -0

145 lines not on this page · raw message

include/dm/uclass-id.h +1 -0
index 45ae9650e3dd..4e252ae210f7 100644
@@ -44,6 +44,7 @@ enum uclass_id {
 	UCLASS_KEYBOARD,	/* Keyboard input device */
 	UCLASS_LED,		/* Light-emitting diode (LED) */
 	UCLASS_LPC,		/* x86 'low pin count' interface */
+	UCLASS_MAILBOX,		/* Mailbox controller */
 	UCLASS_MASS_STORAGE,	/* Mass storage device */
 	UCLASS_MISC,		/* Miscellaneous device */
 	UCLASS_MMC,		/* SD / MMC card or chip */
include/mailbox_client.h new file +149 -0

149 lines not on this page · raw message

include/mailbox_uclass.h new file +83 -0

83 lines not on this page · raw message

Signature · 1 line
2.8.2
#1 lore raw

PATCH v2 1/1 Add a mailbox driver framework/uclass

Quoted 23 lines · Stephen Warren

From: Stephen Warren <[email protected]>

A mailbox is a hardware mechanism for transferring small message and/or notifications between the CPU on which U-Boot runs and some other device such as an auxilliary CPU running firmware or a hardware module.

This patch defines a standard API that connects mailbox clients to mailbox providers (drivers). Initially, DT is the only supported method for connecting the two.

The DT binding specification (mailbox.txt) was taken from Linux kernel v4.5's Documentation/devicetree/bindings/mailbox/mailbox.txt.

---
v2:
* Use timer_get_us() rather than get_ticks() and conversion code.
* Explicitly mention that mailbox messages are fixed size.
* Spell out IPC.
* Fix typos.

I'll send a sandbox test for this as a separate patch.

Quoted 16 lines
 doc/device-tree-bindings/mailbox/mailbox.txt |  32 ++++++
 drivers/Kconfig                              |   2 +
 drivers/Makefile                             |   1 +
 drivers/mailbox/Kconfig                      |  13 +++
 drivers/mailbox/Makefile                     |   5 +
 drivers/mailbox/mailbox-uclass.c             | 145 ++++++++++++++++++++++++++
 include/dm/uclass-id.h                       |   1 +
 include/mailbox_client.h                     | 149 +++++++++++++++++++++++++++
 include/mailbox_uclass.h                     |  83 +++++++++++++++
 9 files changed, 431 insertions(+)
 create mode 100644 doc/device-tree-bindings/mailbox/mailbox.txt
 create mode 100644 drivers/mailbox/Kconfig
 create mode 100644 drivers/mailbox/Makefile
 create mode 100644 drivers/mailbox/mailbox-uclass.c
 create mode 100644 include/mailbox_client.h
 create mode 100644 include/mailbox_uclass.h
#2 lore raw

PATCH v2 1/1 Add a mailbox driver framework/uclass

Quoted 41 lines · Simon Glass
Quoted 23 lines · Stephen Warren

From: Stephen Warren <[email protected]>

A mailbox is a hardware mechanism for transferring small message and/or notifications between the CPU on which U-Boot runs and some other device such as an auxilliary CPU running firmware or a hardware module.

This patch defines a standard API that connects mailbox clients to mailbox providers (drivers). Initially, DT is the only supported method for connecting the two.

The DT binding specification (mailbox.txt) was taken from Linux kernel v4.5's Documentation/devicetree/bindings/mailbox/mailbox.txt.

---
v2:
* Use timer_get_us() rather than get_ticks() and conversion code.
* Explicitly mention that mailbox messages are fixed size.
* Spell out IPC.
* Fix typos.

I'll send a sandbox test for this as a separate patch.

Quoted 16 lines
 doc/device-tree-bindings/mailbox/mailbox.txt |  32 ++++++
 drivers/Kconfig                              |   2 +
 drivers/Makefile                             |   1 +
 drivers/mailbox/Kconfig                      |  13 +++
 drivers/mailbox/Makefile                     |   5 +
 drivers/mailbox/mailbox-uclass.c             | 145 ++++++++++++++++++++++++++
 include/dm/uclass-id.h                       |   1 +
 include/mailbox_client.h                     | 149 +++++++++++++++++++++++++++
 include/mailbox_uclass.h                     |  83 +++++++++++++++
 9 files changed, 431 insertions(+)
 create mode 100644 doc/device-tree-bindings/mailbox/mailbox.txt
 create mode 100644 drivers/mailbox/Kconfig
 create mode 100644 drivers/mailbox/Makefile
 create mode 100644 drivers/mailbox/mailbox-uclass.c
 create mode 100644 include/mailbox_client.h
 create mode 100644 include/mailbox_uclass.h
Quoted 1 line

Applied to u-boot-dm, thanks!

#3 lore raw

PATCH v2 1/1 Add a mailbox driver framework/uclass

Quoted 8 lines · Simon Glass
Quoted 7 lines · Simon Glass
Quoted 6 lines · Stephen Warren

From: Stephen Warren <[email protected]>

A mailbox is a hardware mechanism for transferring small message and/or notifications between the CPU on which U-Boot runs and some other device such as an auxilliary CPU running firmware or a hardware module.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

This patch defines a standard API that connects mailbox clients to mailbox providers (drivers). Initially, DT is the only supported method for connecting the two.

The DT binding specification (mailbox.txt) was taken from Linux kernel v4.5's Documentation/devicetree/bindings/mailbox/mailbox.txt.

Applied to u-boot-dm, thanks!

Great, thanks! Are you planning a DM pull request soon? There are some patches there which are a dependency for the T186 support I sent out, and I believe that all the dependencies are applied there, so a pull request (once applied by TomR) would be enough for TomW to apply all the Tegra patches.

#4 lore raw

PATCH v2 1/1 Add a mailbox driver framework/uclass

Hi Stephen,

Quoted 17 lines · Stephen Warren
Quoted 15 lines · Simon Glass
Quoted 13 lines · Simon Glass
Quoted 11 lines · Stephen Warren

From: Stephen Warren <[email protected]>

A mailbox is a hardware mechanism for transferring small message and/or notifications between the CPU on which U-Boot runs and some other device such as an auxilliary CPU running firmware or a hardware module.

This patch defines a standard API that connects mailbox clients to mailbox providers (drivers). Initially, DT is the only supported method for connecting the two.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

The DT binding specification (mailbox.txt) was taken from Linux kernel v4.5's Documentation/devicetree/bindings/mailbox/mailbox.txt.

Applied to u-boot-dm, thanks!

Great, thanks! Are you planning a DM pull request soon? There are some patches there which are a dependency for the T186 support I sent out, and I believe that all the dependencies are applied there, so a pull request (once applied by TomR) would be enough for TomW to apply all the Tegra patches.

Yes I expect to do one by Monday.

Regards,
Simon