soc: imx: add scu firmware api support
Subsystems (2)
v9 cover soc: imx: add scu firmware api support
Unlike the former i.MX Architectures, the new generation i.MX8 SoCs (e.g. MX8QXP and MX8QM) contain a system controller which runs on a dedicated Cortex-M core to provide power, clock, Pad, and resource management. Communication between the host processor running an OS and the system controller happens through a SCU protocol. This patchset adds the SCU APIs which is implemented based on MU and will be used by different system components.
It mainly consists of below parts:
1) SCU IPC
Basic IPC mechanism implemention based on mailbox which is used for communication between AP and SCU firmware.
2) SCU IPC Service API
v8->v9:
* only scu headfile path update from include/soc/imx to include/linux/firmware/imx
Dong Aisheng (3):
dt-bindings: arm: fsl: add scu binding doc
firmware: imx: add SCU firmware driver support
firmware: imx: add misc svc support
.../devicetree/bindings/arm/freescale/fsl,scu.txt | 183 ++++++ drivers/firmware/Kconfig | 1 + drivers/firmware/Makefile | 1 + drivers/firmware/imx/Kconfig | 11 + drivers/firmware/imx/Makefile | 2 + drivers/firmware/imx/imx-scu.c | 269 +++++++++ drivers/firmware/imx/misc.c | 99 ++++ include/linux/firmware/imx/ipc.h | 59 ++ include/linux/firmware/imx/sci.h | 17 + include/linux/firmware/imx/svc/misc.h | 55 ++ include/linux/firmware/imx/types.h | 617 +++++++++++++++++++++ 11 files changed, 1314 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt create mode 100644 drivers/firmware/imx/Kconfig create mode 100644 drivers/firmware/imx/Makefile create mode 100644 drivers/firmware/imx/imx-scu.c create mode 100644 drivers/firmware/imx/misc.c create mode 100644 include/linux/firmware/imx/ipc.h create mode 100644 include/linux/firmware/imx/sci.h create mode 100644 include/linux/firmware/imx/svc/misc.h create mode 100644 include/linux/firmware/imx/types.h
Signature · 1 line
2.7.4
PATCH v9 1/3 dt-bindings: arm: fsl: add scu binding doc
The System Controller Firmware (SCFW) is a low-level system function which runs on a dedicated Cortex-M core to provide power, clock, and resource management. It exists on some i.MX8 processors. e.g. i.MX8QM (QM, QP), and i.MX8QX (QXP, DX).
---v6->v9:
* no changesv5->v6:
* add input clocks to clock bindings according to Rob's suggestion
* typo clean upv4->v5:
* scu node should be under firmware node
* add pd/clk/pinctrl binding as well according to Rob's suggestion
* switch to new generic MU binding
Use 8 separate mu channels in one MU instance for SCU communicationv3->v4:
* fully change to mailbox binding
* add child node descriptionv2->v3:
* update a bit to mailbox bindingv1->v2:
* remove status
* changed to mu1
--- .../devicetree/bindings/arm/freescale/fsl,scu.txt | 183 +++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +183 -0
@@ -0,0 +1,183 @@ +NXP i.MX System Controller Firmware (SCFW) +-------------------------------------------------------------------- + +The System Controller Firmware (SCFW) is a low-level system function +which runs on a dedicated Cortex-M core to provide power, clock, and +resource management. It exists on some i.MX8 processors. e.g. i.MX8QM +(QM, QP), and i.MX8QX (QXP, DX). + +The AP communicates with the SC using a multi-ported MU module found +in the LSIO subsystem. The current definition of this MU module provides +5 remote AP connections to the SC to support up to 5 execution environments +(TZ, HV, standard Linux, etc.). The SC side of this MU module interfaces +with the LSIO DSC IP bus. The SC firmware will communicate with this MU +using the MSI bus. + +System Controller Device Node: +============================================================ + +The scu node with the following properties shall be under the /firmware/ node. + +Required properties: +------------------- +- compatible: should be "fsl,imx-scu". +- mbox-names: should include "tx0", "tx1", "tx2", "tx3", + "rx0", "rx1", "rx2", "rx3". +- mboxes: List of phandle of 4 MU channels for tx and 4 MU channels + for rx. All 8 MU channels must be in the same MU instance. + Cross instances are not allowed. The MU instance can only + be one of LSIO MU0~M4 for imx8qxp and imx8qm. Users need + to make sure use the one which is not conflict with other + execution environments. e.g. ATF. + Note: + Channel 0 must be "tx0" or "rx0". + Channel 1 must be "tx1" or "rx1". + Channel 2 must be "tx2" or "rx2". + Channel 3 must be "tx3" or "rx3". + e.g. + mboxes = <&lsio_mu1 0 0 + &lsio_mu1 0 1 + &lsio_mu1 0 2 + &lsio_mu1 0 3 + &lsio_mu1 1 0 + &lsio_mu1 1 1 + &lsio_mu1 1 2 + &lsio_mu1 1 3>; + See Documentation/devicetree/bindings/mailbox/fsl,mu.txt + for detailed mailbox binding. + +i.MX SCU Client Device Node: +============================================================ + +Client nodes are maintained as children of the relevant IMX-SCU device node. + +Power domain bindings based on SCU Message Protocol +------------------------------------------------------------ + +This binding for the SCU power domain providers uses the generic power +domain binding[2]. + +Required properties: +- compatible: Should be "fsl,scu-pd". +- #address-cells: Should be 1. +- #size-cells: Should be 0. + +Required properties for power domain sub nodes: +- #power-domain-cells: Must be 0. + +Optional Properties: +- reg: Resource ID of this power domain. + No exist means uncontrollable by user. + See detailed Resource ID list from: + include/dt-bindings/power/imx-rsrc.h +- power-domains: phandle pointing to the parent power domain. + +Clock bindings based on SCU Message Protocol +------------------------------------------------------------ + +This binding uses the common clock binding[1]. + +Required properties: +- compatible: Should be "fsl,imx8qxp-clock". +- #clock-cells: Should be 1. Contains the Clock ID value. +- clocks: List of clock specifiers, must contain an entry for + each required entry in clock-names +- clock-names: Should include entries "xtal_32KHz", "xtal_24MHz" + +The clock consumer should specify the desired clock by having the clock +ID in its "clocks" phandle cell. + +See the full list of clock IDs from: +include/dt-bindings/clock/imx8qxp-clock.h + +Pinctrl bindings based on SCU Message Protocol +------------------------------------------------------------ + +This binding uses the i.MX common pinctrl binding[3]. + +Required properties: +- compatible: Should be "fsl,imx8qxp-iomuxc". + +Required properties for Pinctrl sub nodes: +- fsl,pins: Each entry consists of 3 integers which represents + the mux and config setting for one pin. The first 2 + integers <pin_id mux_mode> are specified using a + PIN_FUNC_ID macro, which can be found in + <dt-bindings/pinctrl/pads-imx8qxp.h>. + The last integer CONFIG is the pad setting value like + pull-up on this pin. + + Please refer to i.MX8QXP Reference Manual for detailed + CONFIG settings. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt +[2] Documentation/devicetree/bindings/power/power_domain.txt +[3] Documentation/devicetree/bindings/pinctrl/fsl,imx-pinctrl.txt + +Example (imx8qxp): +------------- +lsio_mu1: mailbox at 5d1c0000 { + ... + #mbox-cells = <2>; +}; + +firmware { + scu { + compatible = "fsl,imx-scu"; + mbox-names = "tx0", "tx1", "tx2", "tx3", + "rx0", "rx1", "rx2", "rx3"; + mboxes = <&lsio_mu1 0 0 + &lsio_mu1 0 1 + &lsio_mu1 0 2 + &lsio_mu1 0 3 + &lsio_mu1 1 0 + &lsio_mu1 1 1 + &lsio_mu1 1 2 + &lsio_mu1 1 3>; + + clk: clk { + compatible = "fsl,imx8qxp-clk"; + #clock-cells = <1>; + }; + + iomuxc { + compatible = "fsl,imx8qxp-iomuxc"; + + pinctrl_lpuart0: lpuart0grp { + fsl,pins = < + SC_P_UART0_RX_ADMA_UART0_RX 0x06000020 + SC_P_UART0_TX_ADMA_UART0_TX 0x06000020 + >; + }; + ... + }; + + imx8qx-pm { + compatible = "fsl,scu-pd"; + #address-cells = <1>; + #size-cells = <0>; + + pd_dma: dma-power-domain { + #power-domain-cells = <0>; + + pd_dma_lpuart0: dma-lpuart0 at 57 { + reg = <SC_R_UART_0>; + #power-domain-cells = <0>; + power-domains = <&pd_dma>; + }; + ... + }; + ... + }; + }; +}; + +serial at 5a060000 { + ... + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_lpuart0>; + clocks = <&clk IMX8QXP_UART0_CLK>, + <&clk IMX8QXP_UART0_IPG_CLK>; + clock-names = "per", "ipg"; + power-domains = <&pd_dma_lpuart0>; +};
Signature · 1 line
2.7.4
PATCH v9 2/3 firmware: imx: add SCU firmware driver support
In reply to Dong AishengThe System Controller Firmware (SCFW) is a low-level system function which runs on a dedicated Cortex-M core to provide power, clock, and resource management. It exists on some i.MX8 processors. e.g. i.MX8QM (QM, QP), and i.MX8QX (QXP, DX).
This patch implements the SCU firmware IPC function and the common message sending API sc_call_rpc.
---v8->v9:
* update firmware headfile patch from include/soc/imx to include/linux/firmware/imxv7->v8:
* only name change
add imx_sc prefix for exported functions/enums/structures like sc_ipc/sc_chan/sc_rpc_msg/sc_rsrc_t/sc_ctrl_t/sc_err_t
* add imx_sc_to_linux_errno, then sc_err_t won't be used by clients. Instead, clients use standard error codes.v6->v7:
* better namespace for exported functions
* no_resp->have_resp to avoid double negationv5->v6:
* remove resource management (sc_ipc_open/close)
* make sc_call_rpc and related structure visible by client drivers, so remove internal headfile drivers/soc/imx/sc/main/rpc.h accordingly
* move scu firmware driver under drivers/firmware/imx
* patch title changedv4->v5:
* switch to new generic MU binding.
Use 8 separate mu channels in one MU instance for SCU communication
* create struct sc_rpc_msg to separate the msg header and service, accordingly the old sc_rpc_msg_s with raw data union is removed. This can gain better readability.
* remove defines like RPC_XXX(MSG)
* remove unused types
* headfiles cleanup
* NOTE:
With the new approach that uses 8 separate irq driven changes, i still did not find a clean way to better support receiving msg over 4 words. So the current driver does not support it.
As in current SCU protocol, there's only a minor of commands need receiving msg over 4 words which is still not used by Linux, so it does not affect the normal function.
* Know issue:
The performance drops a lot after using 8 separate interrupt driven MUs to send/receive msgs.
e.g. Sending a scu message with tx size 2 words and rx size 2 words:
Former (polling) : < 10us to handle a SCU msg
Now (irq) : 20~30 us to handle a SCU msg (Caused by interrupt latency)v3->v4:
* change to use mailbox
* separate the IPC part and RPC API for easy review
* headfiles cleanupv2->v3:
* add the ipc read/write error checkv1->v2:
* change the type of sc_ipc_t from uint32_t to unsigned long. This can make it be capable of storing 64 bit pointer in ARMv8 system.
* Update to use the new MU library implemenation (handle iomem privately)
* remove unused delcarations e.g. sc_rpc_dispatch and sc_rpc_xlate.
* remove unneeded pad ctl functions
--- drivers/firmware/Kconfig | 1 + drivers/firmware/Makefile | 1 + drivers/firmware/imx/Kconfig | 11 + drivers/firmware/imx/Makefile | 2 + drivers/firmware/imx/imx-scu.c | 269 ++++++++++++++++ include/linux/firmware/imx/ipc.h | 59 ++++ include/linux/firmware/imx/sci.h | 16 + include/linux/firmware/imx/types.h | 617 +++++++++++++++++++++++++++++++++++++ 8 files changed, 976 insertions(+) create mode 100644 drivers/firmware/imx/Kconfig create mode 100644 drivers/firmware/imx/Makefile create mode 100644 drivers/firmware/imx/imx-scu.c create mode 100644 include/linux/firmware/imx/ipc.h create mode 100644 include/linux/firmware/imx/sci.h create mode 100644 include/linux/firmware/imx/types.h
drivers/firmware/Kconfig +1 -0
@@ -289,6 +289,7 @@ config HAVE_ARM_SMCCC source "drivers/firmware/broadcom/Kconfig" source "drivers/firmware/google/Kconfig" source "drivers/firmware/efi/Kconfig" +source "drivers/firmware/imx/Kconfig" source "drivers/firmware/meson/Kconfig" source "drivers/firmware/tegra/Kconfig"
drivers/firmware/Makefile +1 -0
@@ -31,4 +31,5 @@ obj-y += meson/ obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ obj-$(CONFIG_EFI) += efi/ obj-$(CONFIG_UEFI_CPER) += efi/ +obj-y += imx/ obj-y += tegra/
drivers/firmware/imx/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +config IMX_SCU + bool "IMX SCU Protocol driver" + depends on IMX_MBOX + help + The System Controller Firmware (SCFW) is a low-level system function + which runs on a dedicated Cortex-M core to provide power, clock, and + resource management. It exists on some i.MX8 processors. e.g. i.MX8QM + (QM, QP), and i.MX8QX (QXP, DX). + + This driver manages the IPC interface between host CPU and the + SCU firmware running on M4.
drivers/firmware/imx/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_IMX_SCU) += imx-scu.o
drivers/firmware/imx/imx-scu.c new file +269 -0
269 lines not on this page · raw message
include/linux/firmware/imx/ipc.h new file +59 -0
59 lines not on this page · raw message
include/linux/firmware/imx/sci.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2016 Freescale Semiconductor, Inc. +* Copyright 2017~2018 NXP +* +* Header file containing the public System Controller Interface (SCI) +* definitions. +*/ + +#ifndef _SC_SCI_H +#define _SC_SCI_H + +#include <linux/firmware/imx/ipc.h> +#include <linux/firmware/imx/types.h> + +#endif /* _SC_SCI_H */
include/linux/firmware/imx/types.h new file +617 -0
617 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v9 3/3 firmware: imx: add misc svc support
In reply to Dong AishengAdd SCU MISC SVC support which provides misc control get/set functions.
---v8->v9:
* update firmware headfile patch from include/soc/imx to include/linux/firmware/imxv7->v8:
* updating function/enums names with imx_sc prefixv6->v7:
* move MISC_FUNC enums into headfile
* delete void * cast
* move function description over the function definitionv5->v6:
* move into drivers/firmware/imx
* using structure sc_ipc as handle instread of sc_ipc_t
* patch title changedv4->v5:
* new patch
--- drivers/firmware/imx/Makefile | 2 +- drivers/firmware/imx/misc.c | 99 +++++++++++++++++++++++++++++++++++ include/linux/firmware/imx/sci.h | 1 + include/linux/firmware/imx/svc/misc.h | 55 +++++++++++++++++++ 4 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/imx/misc.c create mode 100644 include/linux/firmware/imx/svc/misc.h
drivers/firmware/imx/Makefile +1 -1
@@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_IMX_SCU) += imx-scu.o +obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o
drivers/firmware/imx/misc.c new file +99 -0
99 lines not on this page · raw message
include/linux/firmware/imx/sci.h +1 -0
@@ -13,4 +13,5 @@#include <linux/firmware/imx/ipc.h> #include <linux/firmware/imx/types.h> +#include <linux/firmware/imx/svc/misc.h> #endif /* _SC_SCI_H */
include/linux/firmware/imx/svc/misc.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.7.4
Shawn Guo
Appliedv9 cover soc: imx: add scu firmware api support
In reply to Dong AishengQuoted 14 lines · Dong Aisheng
Unlike the former i.MX Architectures, the new generation i.MX8 SoCs (e.g. MX8QXP and MX8QM) contain a system controller which runs on a dedicated Cortex-M core to provide power, clock, Pad, and resource management. Communication between the host processor running an OS and the system controller happens through a SCU protocol. This patchset adds the SCU APIs which is implemented based on MU and will be used by different system components.
It mainly consists of below parts:
1) SCU IPC
Basic IPC mechanism implemention based on mailbox which is used for communication between AP and SCU firmware.
2) SCU IPC Service API
Quoted 8 lines
v8->v9:
* only scu headfile path update frominclude/soc/imxtoinclude/linux/firmware/imxDong Aisheng (3):
dt-bindings: arm: fsl: add scu binding doc
firmware: imx: add SCU firmware driver support
firmware: imx: add misc svc support
Applied all, thanks.
I'm waiting for the MAINTAINERS update to send another pull request to arm-soc folks.
Shawn