Add Amlogic secure monitor driver
Subsystems (2)
v7 cover Add Amlogic secure monitor driver
From: Carlo Caione <[email protected]>
In the Amlogic SoCs the secure monitor calls are used for a lot of reasons:
interact with the NVMEM (efuses), check the reboot reason, set USB boot, ...
This driver defines a generic interface towards the secure monitor that can be used by more specialized drivers to interact with the secure monitor itself without worrying about bounce buffers managing.
Changelog:
v7:
* dropped "simple-bus"
v6:
* Added comments
* Fix checking u32 < 0
* s/-ENODEV/-EINVAL/ in the probe function
* Use WARN_ON()
v5:
* Moved IDs from DT to header file
* Made read/write bounce buffers not mandatory
* Introduced helper meson_sm_map_shmem()
v4:
* Changed patches order
* Removed now useless PATCH 2/4
* Changed compatible to be SoC-specific
* In the DT now we use SoC-agnostic IDs for the SMC functions. These IDs are traslated into SoC specific function IDs inside the driver
* Added error checking on meson_sm_call() to retrieve the base address
* Improved printing on errors
v3:
* Moved driver to drivers/firmware
* Added EXPORT_SYMBOL macros
* Changed '_' in '-'
* Introduced 'struct meson_sm_firmware' and 'meson_sm_get_fw()' to be used by drivers using the secure-monitor to enforce probe ordering
v2:
* All the SMC function identifiers are now in a SoC-specific header file to be included by the DTS files so the SMC commands are now defined in the DT instead to be hardcoded into the driver
* Patchset is no longer an RFC
* Better error management and boundary checking
* s/unsigned int/u32/
* SMC call not only on CPU 0
* Fix memory leaking
* s/amlogic/meson/ in the directory names
Carlo Caione (3):
firmware: Amlogic: Add secure monitor driver
documentation: Add secure monitor binding documentation
ARM64: dts: amlogic: gxbb: Enable secure monitor
.../bindings/firmware/meson/meson_sm.txt | 27 ++ arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 6 + drivers/firmware/Kconfig | 1 + drivers/firmware/Makefile | 1 + drivers/firmware/meson/Kconfig | 8 + drivers/firmware/meson/Makefile | 1 + drivers/firmware/meson/meson_sm.c | 312 +++++++++++++++++++++ include/linux/firmware/meson/meson_sm.h | 32 +++ 8 files changed, 388 insertions(+) create mode 100644 Documentation/devicetree/bindings/firmware/meson/meson_sm.txt create mode 100644 drivers/firmware/meson/Kconfig create mode 100644 drivers/firmware/meson/Makefile create mode 100644 drivers/firmware/meson/meson_sm.c create mode 100644 include/linux/firmware/meson/meson_sm.h
Signature · 1 line
2.7.4
PATCH v7 1/3 firmware: Amlogic: Add secure monitor driver
From: Carlo Caione <[email protected]>
Introduce a driver to provide calls into secure monitor mode.
In the Amlogic SoCs these calls are used for multiple reasons: access to NVMEM, set USB boot, enable JTAG, etc...
--- drivers/firmware/Kconfig | 1 + drivers/firmware/Makefile | 1 + drivers/firmware/meson/Kconfig | 8 + drivers/firmware/meson/Makefile | 1 + drivers/firmware/meson/meson_sm.c | 312 ++++++++++++++++++++++++++++++++ include/linux/firmware/meson/meson_sm.h | 32 ++++ 6 files changed, 355 insertions(+) create mode 100644 drivers/firmware/meson/Kconfig create mode 100644 drivers/firmware/meson/Makefile create mode 100644 drivers/firmware/meson/meson_sm.c create mode 100644 include/linux/firmware/meson/meson_sm.h
drivers/firmware/Kconfig +1 -0
@@ -199,5 +199,6 @@ config HAVE_ARM_SMCCC source "drivers/firmware/broadcom/Kconfig" source "drivers/firmware/google/Kconfig" source "drivers/firmware/efi/Kconfig" +source "drivers/firmware/meson/Kconfig" endmenu
drivers/firmware/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_QCOM_SCM_32) += qcom_scm-32.o CFLAGS_qcom_scm-32.o :=$(call as-instr,.arch armv7-a\n.arch_extension sec,-DREQUIRES_SEC=1) -march=armv7-a obj-y += broadcom/ +obj-y += meson/ obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ obj-$(CONFIG_EFI) += efi/ obj-$(CONFIG_UEFI_CPER) += efi/
drivers/firmware/meson/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +# +# Amlogic Secure Monitor driver +# +config MESON_SM + bool + default ARCH_MESON + help + Say y here to enable the Amlogic secure monitor driver
drivers/firmware/meson/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_MESON_SM) += meson_sm.o
drivers/firmware/meson/meson_sm.c new file +312 -0
312 lines not on this page · raw message
include/linux/firmware/meson/meson_sm.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright (C) 2016 Endless Mobile, Inc. +* Author: Carlo Caione <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* version 2 as published by the Free Software Foundation. +* +* 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 _MESON_SM_FW_H_ +#define _MESON_SM_FW_H_ + +#define SM_EFUSE_READ 0 +#define SM_EFUSE_WRITE 1 +#define SM_EFUSE_USER_MAX 2 + +struct meson_sm_firmware ; + +int meson_sm_call (struct meson_sm_firmware *fw,unsigned int cmd_index, +u32 *ret,u32 arg0,u32 arg1,u32 arg2,u32 arg3,u32 arg4); +int meson_sm_call_write (struct meson_sm_firmware *fw,void *buffer, +unsigned int b_size,unsigned int cmd_index, +u32 arg0,u32 arg1,u32 arg2,u32 arg3,u32 arg4); +int meson_sm_call_read (struct meson_sm_firmware *fw,void *buffer, +unsigned int cmd_index,u32 arg0,u32 arg1, +u32 arg2,u32 arg3,u32 arg4); +struct meson_sm_firmware *meson_sm_get_fw (struct device_node *firmware_node); + +#endif /* _MESON_SM_FW_H_ */
Signature · 1 line
2.7.4
PATCH v7 1/3 firmware: Amlogic: Add secure monitor driver
Quoted 8 lines · Carlo Caione
From: Carlo Caione <[email protected]>
Introduce a driver to provide calls into secure monitor mode.
In the Amlogic SoCs these calls are used for multiple reasons: access to NVMEM, set USB boot, enable JTAG, etc...
Signed-off-by Carlo Caione <[email protected]>
Ping?
Signature · 1 line
Carlo Caione
PATCH v7 2/3 documentation: Add secure monitor binding documentation
In reply to Carlo CaioneFrom: Carlo Caione <[email protected]>
Add the binding documentation for the Amlogic secure monitor driver.
--- .../bindings/firmware/meson/meson_sm.txt | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/firmware/meson/meson_sm.txt
Documentation/devicetree/bindings/firmware/meson/meson_sm.txt new file +27 -0
@@ -0,0 +1,27 @@ +* Amlogic Secure Monitor + +In the Amlogic SoCs the Secure Monitor code is used to provide access to the +NVMEM, enable JTAG, set USB boot, etc... + +Required properties for the secure monitor node: +- compatible: Should be "amlogic,meson-gxbb-sm" + +Example: + + firmware { + sm: secure-monitor { + compatible = "amlogic,meson-gxbb-sm"; + }; + }; + +Example of the node using the secure monitor: + + efuse: efuse { + compatible = "amlogic,meson-gxbb-efuse"; + secure-monitor = <&sm>; + #address-cells = <1>; + #size-cells = <1>; + + ... + }; +
Signature · 1 line
2.7.4
Rob Herring
maintainerPATCH v7 2/3 documentation: Add secure monitor binding documentation
Quoted 9 lines · Carlo Caione
From: Carlo Caione <[email protected]>
Add the binding documentation for the Amlogic secure monitor driver.
Signed-off-by Carlo Caione <[email protected]>--- .../bindings/firmware/meson/meson_sm.txt | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/firmware/meson/meson_sm.txt
PATCH v7 3/3 ARM64: dts: amlogic: gxbb: Enable secure monitor
In reply to Carlo CaioneFrom: Carlo Caione <[email protected]>
Add the secure monitor node in the Amlogic Meson GXBB DTSI file to enable it.
--- arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi +6 -0
@@ -123,6 +123,12 @@ #size-cells = <2>; ranges; + firmware { + sm: secure-monitor { + compatible = "amlogic,meson-gxbb-sm"; + }; + }; + cbus: cbus at c1100000 { compatible = "simple-bus"; reg = <0x0 0xc1100000 0x0 0x100000>;
Signature · 1 line
2.7.4