firmware: Add Tegra IVC and BPMP support
v4 cover firmware: Add Tegra IVC and BPMP support
From: Thierry Reding <[email protected]>
Hi everyone,
This is the fourth revision of the Tegra IVC and BPMP support patches. It incorporates all of the comments from earlier postings with some fixes on top, primarily to make the driver use the mmio-sram bindings via the misc/sram driver and genalloc rather than duplicate moste of that code. This has the side-effect of removing many sparse warnings about incompatible address modifiers.
Another small change is that IVC now always maps buffers to the peer device if any. This avoids potential confusion when a peer device is given along with physical addresses.
The interdependencies of IVC/BPMP and other low-level drivers such as clocks, resets and power domains are fairly complicated and the dead- line for v4.10 submissions is coming up fast, so my plan is to take this into linux-next tonight and submit for v4.10 by the end of the week, barring any serious objections.
For completeness I've also included some patches from Stephen that amend the BPMP DT bindings.
Thierry
Joseph Lo (1):
dt-bindings: firmware: Add bindings for Tegra BPMP
Stephen Warren (2):
dt-bindings: Add power domains to Tegra BPMP firmware
dt-bindings: firmware: Allow child nodes inside the Tegra BPMP
Thierry Reding (2):
firmware: tegra: Add IVC library
firmware: tegra: Add BPMP support
.../bindings/firmware/nvidia,tegra186-bpmp.txt | 108 ++ drivers/firmware/Kconfig | 1 + drivers/firmware/Makefile | 1 + drivers/firmware/tegra/Kconfig | 25 + drivers/firmware/tegra/Makefile | 2 + drivers/firmware/tegra/bpmp.c | 868 +++++++++++ drivers/firmware/tegra/ivc.c | 695 +++++++++ include/dt-bindings/clock/tegra186-clock.h | 940 ++++++++++++ include/dt-bindings/power/tegra186-powergate.h | 39 + include/dt-bindings/reset/tegra186-reset.h | 217 +++ include/soc/tegra/bpmp-abi.h | 1601 ++++++++++++++++++++ include/soc/tegra/bpmp.h | 139 ++ include/soc/tegra/ivc.h | 109 ++ 13 files changed, 4745 insertions(+) create mode 100644 Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.txt create mode 100644 drivers/firmware/tegra/Kconfig create mode 100644 drivers/firmware/tegra/Makefile create mode 100644 drivers/firmware/tegra/bpmp.c create mode 100644 drivers/firmware/tegra/ivc.c create mode 100644 include/dt-bindings/clock/tegra186-clock.h create mode 100644 include/dt-bindings/power/tegra186-powergate.h create mode 100644 include/dt-bindings/reset/tegra186-reset.h create mode 100644 include/soc/tegra/bpmp-abi.h create mode 100644 include/soc/tegra/bpmp.h create mode 100644 include/soc/tegra/ivc.h
Signature · 1 line
2.10.2
PATCH v4 1/5 dt-bindings: firmware: Add bindings for Tegra BPMP
From: Joseph Lo <[email protected]>
The Boot and Power Management Processor (BPMP) is a co-processor found in Tegra SoCs. It is designed to handle the early stages of the boot process as well as to offload power management tasks (such as clocks, resets, powergates, ...).
The binding document defines the resources that are used by the BPMP firmware, which implements the interprocessor communication (IPC) between the CPU and the BPMP.
--- .../bindings/firmware/nvidia,tegra186-bpmp.txt | 81 ++ include/dt-bindings/clock/tegra186-clock.h | 940 +++++++++++++++++++++ include/dt-bindings/reset/tegra186-reset.h | 217 +++++ 3 files changed, 1238 insertions(+) create mode 100644 Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.txt create mode 100644 include/dt-bindings/clock/tegra186-clock.h create mode 100644 include/dt-bindings/reset/tegra186-reset.h
Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.txt new file +81 -0
@@ -0,0 +1,81 @@ +NVIDIA Tegra Boot and Power Management Processor (BPMP) + +The BPMP is a specific processor in Tegra chip, which is designed for +booting process handling and offloading the power management, clock +management, and reset control tasks from the CPU. The binding document +defines the resources that would be used by the BPMP firmware driver, +which can create the interprocessor communication (IPC) between the CPU +and BPMP. + +Required properties: +- name : Should be bpmp +- compatible + Array of strings + One of: + - "nvidia,tegra186-bpmp" +- mboxes : The phandle of mailbox controller and the mailbox specifier. +- shmem : List of the phandle of the TX and RX shared memory area that + the IPC between CPU and BPMP is based on. +- #clock-cells : Should be 1. +- #reset-cells : Should be 1. + +This node is a mailbox consumer. See the following files for details of +the mailbox subsystem, and the specifiers implemented by the relevant +provider(s): + +- .../mailbox/mailbox.txt +- .../mailbox/nvidia,tegra186-hsp.txt + +This node is a clock and reset provider. See the following files for +general documentation of those features, and the specifiers implemented +by this node: + +- .../clock/clock-bindings.txt +- <dt-bindings/clock/tegra186-clock.h> +- .../reset/reset.txt +- <dt-bindings/reset/tegra186-reset.h> + +The shared memory bindings for BPMP +----------------------------------- + +The shared memory area for the IPC TX and RX between CPU and BPMP are +predefined and work on top of sysram, which is an SRAM inside the chip. + +See ".../sram/sram.txt" for the bindings. + +Example: + +hsp_top0: hsp at 03c00000 { + ... + #mbox-cells = <2>; +}; + +sysram at 30000000 { + compatible = "nvidia,tegra186-sysram", "mmio-sram"; + reg = <0x0 0x30000000 0x0 0x50000>; + #address-cells = <2>; + #size-cells = <2>; + ranges = <0 0x0 0x0 0x30000000 0x0 0x50000>; + + cpu_bpmp_tx: shmem at 4e000 { + compatible = "nvidia,tegra186-bpmp-shmem"; + reg = <0x0 0x4e000 0x0 0x1000>; + label = "cpu-bpmp-tx"; + pool; + }; + + cpu_bpmp_rx: shmem at 4f000 { + compatible = "nvidia,tegra186-bpmp-shmem"; + reg = <0x0 0x4f000 0x0 0x1000>; + label = "cpu-bpmp-rx"; + pool; + }; +}; + +bpmp { + compatible = "nvidia,tegra186-bpmp"; + mboxes = <&hsp_top0 TEGRA_HSP_MBOX_TYPE_DB TEGRA_HSP_DB_MASTER_BPMP>; + shmem = <&cpu_bpmp_tx &cpu_bpmp_rx>; + #clock-cells = <1>; + #reset-cells = <1>; +};
include/dt-bindings/clock/tegra186-clock.h new file +940 -0
940 lines not on this page · raw message
include/dt-bindings/reset/tegra186-reset.h new file +217 -0
217 lines not on this page · raw message
Signature · 1 line
2.10.2
PATCH v4 2/5 firmware: tegra: Add IVC library
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
The Inter-VM communication (IVC) is a communication protocol which is designed for interprocessor communication (IPC) or the communication between the hypervisor and the virtual machine with a guest OS.
Message channels are used to communicate between processors. They are backed by DRAM or SRAM, so care must be taken to maintain coherence of data.
The IVC library maintains memory-based descriptors for the transmission and reception channels as well as the data coherence of the counter and payload. Clients, such as the driver for the BPMP firmware, can use the library to exchange messages with remote processors.
Based on work by Peter Newman <[email protected]> and Joseph Lo <[email protected]>.
---
Changes in v4:
- eliminate all BUG_ON(), none of the conditions are fatal
- prevent potential NULL pointer dereference
- use BUILD_BUG_ON() where appropriate
- use more consistent error handling
- rework DMA mapping of buffers
- fix sparse warning
Changes in v3:
- use a more object oriented design
drivers/firmware/Kconfig | 1 + drivers/firmware/Makefile | 1 + drivers/firmware/tegra/Kconfig | 13 + drivers/firmware/tegra/Makefile | 1 + drivers/firmware/tegra/ivc.c | 695 ++++++++++++++++++++++++++++++++++++++++ include/soc/tegra/ivc.h | 109 +++++++ 6 files changed, 820 insertions(+) create mode 100644 drivers/firmware/tegra/Kconfig create mode 100644 drivers/firmware/tegra/Makefile create mode 100644 drivers/firmware/tegra/ivc.c create mode 100644 include/soc/tegra/ivc.h
drivers/firmware/Kconfig +1 -0
@@ -210,5 +210,6 @@ source "drivers/firmware/broadcom/Kconfig" source "drivers/firmware/google/Kconfig" source "drivers/firmware/efi/Kconfig" source "drivers/firmware/meson/Kconfig" +source "drivers/firmware/tegra/Kconfig" endmenu
drivers/firmware/Makefile +1 -0
@@ -26,3 +26,4 @@ obj-y += meson/ obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ obj-$(CONFIG_EFI) += efi/ obj-$(CONFIG_UEFI_CPER) += efi/ +obj-y += tegra/
drivers/firmware/tegra/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +menu "Tegra firmware driver" + +config TEGRA_IVC + bool "Tegra IVC protocol" + depends on ARCH_TEGRA + help + IVC (Inter-VM Communication) protocol is part of the IPC + (Inter Processor Communication) framework on Tegra. It maintains the + data and the different commuication channels in SysRAM or RAM and + keeps the content is synchronization between host CPU and remote + processors. + +endmenu
drivers/firmware/tegra/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_TEGRA_IVC) += ivc.o
drivers/firmware/tegra/ivc.c new file +695 -0
695 lines not on this page · raw message
include/soc/tegra/ivc.h new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
2.10.2
PATCH v4 3/5 firmware: tegra: Add BPMP support
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
The Boot and Power Management Processor (BPMP) is a co-processor found on Tegra SoCs. It is designed to handle the early stages of the boot process and offload power management tasks (such as clocks, resets, powergates, ...) as well as system control services.
Compared to the ARM SCPI, the services provided by BPMP are message- based rather than method-based. The BPMP firmware driver provides the services to transmit data to and receive data from the BPMP. Users can also register a Message ReQuest (MRQ), for which a service routine will be run when a corresponding event is received from the firmware.
A set of messages, called the BPMP ABI, are specified for a number of different services provided by the BPMP (such as clocks or resets).
Based on work by Sivaram Nair <[email protected]> and Joseph Lo <[email protected]>.
---
Changes in v4:
- fix race condition between channel setup and interrupt service routine
- correctly check for return value of wait_for_completion_timeout()
- use _size suffix for variables denoting size to avoid confusion
- use genalloc to obtain shmem via misc/sram driver
- use correct reply to BPMP ping challenge
- avoid potential NULL pointer dereference
- use more consistent error handling
- properly clean up on failure
- use defines from bpmp-abi.h
- implement correct timeout
Changes in v3:
- use a message structure for transfers to avoid long function prototypes
- restructure driver for easier maintainability
- rename bpmp_abi.h to bpmp-abi.h for consistency
drivers/firmware/tegra/Kconfig | 12 + drivers/firmware/tegra/Makefile | 1 + drivers/firmware/tegra/bpmp.c | 868 +++++++++++++++++++++ include/soc/tegra/bpmp-abi.h | 1601 +++++++++++++++++++++++++++++++++++++++ include/soc/tegra/bpmp.h | 139 ++++ 5 files changed, 2621 insertions(+) create mode 100644 drivers/firmware/tegra/bpmp.c create mode 100644 include/soc/tegra/bpmp-abi.h create mode 100644 include/soc/tegra/bpmp.h
drivers/firmware/tegra/Kconfig +12 -0
@@ -10,4 +10,16 @@ config TEGRA_IVC keeps the content is synchronization between host CPU and remote processors. +config TEGRA_BPMP + bool "Tegra BPMP driver" + depends on ARCH_TEGRA && TEGRA_HSP_MBOX && TEGRA_IVC + help + BPMP (Boot and Power Management Processor) is designed to off-loading + the PM functions which include clock/DVFS/thermal/power from the CPU. + It needs HSP as the HW synchronization and notification module and + IVC module as the message communication protocol. + + This driver manages the IPC interface between host CPU and the + firmware running on BPMP. + endmenu
drivers/firmware/tegra/Makefile +1 -0
@@ -1 +1,2 @@ +obj-$(CONFIG_TEGRA_BPMP) += bpmp.o obj-$(CONFIG_TEGRA_IVC) += ivc.o
drivers/firmware/tegra/bpmp.c new file +868 -0
868 lines not on this page · raw message
include/soc/tegra/bpmp-abi.h new file +1601 -0
1,601 lines not on this page · raw message
include/soc/tegra/bpmp.h new file +139 -0
139 lines not on this page · raw message
Signature · 1 line
2.10.2
PATCH v4 4/5 dt-bindings: Add power domains to Tegra BPMP firmware
In reply to Thierry RedingFrom: Stephen Warren <[email protected]>
The Tegra186 BPMP is also a provider of power domains. Enhance the device tree binding to describe this.
--- .../bindings/firmware/nvidia,tegra186-bpmp.txt | 10 ++++-- include/dt-bindings/power/tegra186-powergate.h | 39 ++++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 include/dt-bindings/power/tegra186-powergate.h
Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.txt +7 -3
@@ -17,6 +17,7 @@ Required properties: - shmem : List of the phandle of the TX and RX shared memory area that the IPC between CPU and BPMP is based on. - #clock-cells : Should be 1. +- #power-domain-cells : Should be 1. - #reset-cells : Should be 1. This node is a mailbox consumer. See the following files for details of
@@ -26,12 +27,14 @@ provider(s): - .../mailbox/mailbox.txt - .../mailbox/nvidia,tegra186-hsp.txt -This node is a clock and reset provider. See the following files for -general documentation of those features, and the specifiers implemented -by this node: +This node is a clock, power domain, and reset provider. See the following +files for general documentation of those features, and the specifiers +implemented by this node: - .../clock/clock-bindings.txt - <dt-bindings/clock/tegra186-clock.h> +- ../power/power_domain.txt +- <dt-bindings/power/tegra186-powergate.h> - .../reset/reset.txt - <dt-bindings/reset/tegra186-reset.h>
@@ -77,5 +80,6 @@ bpmp { mboxes = <&hsp_top0 TEGRA_HSP_MBOX_TYPE_DB TEGRA_HSP_DB_MASTER_BPMP>; shmem = <&cpu_bpmp_tx &cpu_bpmp_rx>; #clock-cells = <1>; + #power-domain-cells = <1>; #reset-cells = <1>; };
include/dt-bindings/power/tegra186-powergate.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _DT_BINDINGS_POWER_TEGRA186_POWERGATE_H +#define _DT_BINDINGS_POWER_TEGRA186_POWERGATE_H + +#define TEGRA186_POWER_DOMAIN_AUD 0 +#define TEGRA186_POWER_DOMAIN_DFD 1 +#define TEGRA186_POWER_DOMAIN_DISP 2 +#define TEGRA186_POWER_DOMAIN_DISPB 3 +#define TEGRA186_POWER_DOMAIN_DISPC 4 +#define TEGRA186_POWER_DOMAIN_ISPA 5 +#define TEGRA186_POWER_DOMAIN_NVDEC 6 +#define TEGRA186_POWER_DOMAIN_NVJPG 7 +#define TEGRA186_POWER_DOMAIN_MPE 8 +#define TEGRA186_POWER_DOMAIN_PCX 9 +#define TEGRA186_POWER_DOMAIN_SAX 10 +#define TEGRA186_POWER_DOMAIN_VE 11 +#define TEGRA186_POWER_DOMAIN_VIC 12 +#define TEGRA186_POWER_DOMAIN_XUSBA 13 +#define TEGRA186_POWER_DOMAIN_XUSBB 14 +#define TEGRA186_POWER_DOMAIN_XUSBC 15 +#define TEGRA186_POWER_DOMAIN_GPU 43 +#define TEGRA186_POWER_DOMAIN_MAX 44 + +#endif
Signature · 1 line
2.10.2
PATCH v4 5/5 dt-bindings: firmware: Allow child nodes inside the Tegra BPMP
In reply to Thierry RedingFrom: Stephen Warren <[email protected]>
The BPMP implements some services which must be represented by separate nodes. For example, it can provide access to certain I2C controllers, and the I2C bindings represent each I2C controller as a device tree node. Update the binding to describe how the BPMP supports this.
--- .../bindings/firmware/nvidia,tegra186-bpmp.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+)
Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.txt +23 -0
@@ -38,6 +38,24 @@ implemented by this node: - .../reset/reset.txt - <dt-bindings/reset/tegra186-reset.h> +The BPMP implements some services which must be represented by separate nodes. +For example, it can provide access to certain I2C controllers, and the I2C +bindings represent each I2C controller as a device tree node. Such nodes should +be nested directly inside the main BPMP node. + +Software can determine whether a child node of the BPMP node represents a device +by checking for a compatible property. Any node with a compatible property +represents a device that can be instantiated. Nodes without a compatible +property may be used to provide configuration information regarding the BPMP +itself, although no such configuration nodes are currently defined by this +binding. + +The BPMP firmware defines no single global name-/numbering-space for such +services. Put another way, the numbering scheme for I2C buses is distinct from +the numbering scheme for any other service the BPMP may provide (e.g. a future +hypothetical SPI bus service). As such, child device nodes will have no reg +property, and the BPMP node will have no #address-cells or #size-cells property. + The shared memory bindings for BPMP -----------------------------------
@@ -82,4 +100,9 @@ bpmp { #clock-cells = <1>; #power-domain-cells = <1>; #reset-cells = <1>; + + i2c { + compatible = "..."; + ... + }; };
Signature · 1 line
2.10.2