Skip to contentSkip to conversation

Add Amlogic secure monitor driver

PATCH Superseded Carlo Caione 3 participants 10 messages May 29, 2016 – Jun 9, 2016

Subsystems (2)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 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:

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           |  33 +++
 arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi        |   8 +
 drivers/firmware/Kconfig                           |   1 +
 drivers/firmware/Makefile                          |   1 +
 drivers/firmware/meson/Kconfig                     |   8 +
 drivers/firmware/meson/Makefile                    |   1 +
 drivers/firmware/meson/meson_sm.c                  | 223 +++++++++++++++++++++
 include/linux/firmware/meson/meson_sm.h            |  32 +++
 8 files changed, 307 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
#1 lore raw

PATCH v5 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       | 223 ++++++++++++++++++++++++++++++++
 include/linux/firmware/meson/meson_sm.h |  32 +++++
 6 files changed, 266 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
index 6664f11..686e395 100644
@@ -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
index 474bada..fc4bb09 100644
@@ -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
new file mode 100644
index 0000000..fff11a3
@@ -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
new file mode 100644
index 0000000..9ab3884
@@ -0,0 +1 @@
+obj-$(CONFIG_MESON_SM) +=	meson_sm.o
drivers/firmware/meson/meson_sm.c new file +223 -0

223 lines not on this page · raw message

include/linux/firmware/meson/meson_sm.h new file +32 -0
new file mode 100644
index 0000000..f653916
@@ -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;
+
+u32 meson_sm_call(struct meson_sm_firmware *fw, unsigned int cmd_index,
+		  u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4);
+u32 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);
+u32 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
#2 lore raw

Re: [PATCH v5 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...

Quoted 7 lines
---
 drivers/firmware/Kconfig                |   1 +
 drivers/firmware/Makefile               |   1 +
 drivers/firmware/meson/Kconfig          |   8 ++
 drivers/firmware/meson/Makefile         |   1 +
 drivers/firmware/meson/meson_sm.c       | 223

++++++++++++++++++++++++++++++++

Quoted 23 lines
 include/linux/firmware/meson/meson_sm.h |  32 +++++
 6 files changed, 266 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
index 6664f11..686e395 100644
@@ -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 +0 -0
index 474bada..fc4bb09 100644

drivers/firmware/Makefile obj-$(CONFIG_QCOM_SCM_32) += qcom_scm-32.o · line 21

Quoted 1 line
drivers/firmware/Makefile +0 -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

Review

Quoted 7 lines
drivers/firmware/Makefile +1 -0
 obj-y                          += broadcom/
+obj-y                          += meson/
 obj-$(CONFIG_GOOGLE_FIRMWARE)  += google/
 obj-$(CONFIG_EFI)              += efi/
 obj-$(CONFIG_UEFI_CPER)                += efi/
(quoted diff) +0 -0

b/drivers/firmware/meson/Kconfig

Review

Quoted 14 lines

new file mode 100644
index 0000000..fff11a3

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
(quoted diff) +0 -0

b/drivers/firmware/meson/Makefile

Review

Quoted 7 lines

new file mode 100644
index 0000000..9ab3884

drivers/firmware/meson/Makefile new file +1 -0
@@ -0,0 +1 @@
+obj-$(CONFIG_MESON_SM) +=      meson_sm.o
(quoted diff) +0 -0

b/drivers/firmware/meson/meson_sm.c

Quoted 55 lines

new file mode 100644
index 0000000..e1ce487

drivers/firmware/meson/meson_sm.c new file +50 -0
@@ -0,0 +1,223 @@
+/*
+ * Amlogic Secure Monitor driver
+ *
+ * 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/>.
+ */
+
+#include <stdarg.h>
+#include <asm/cacheflush.h>
+#include <asm/compiler.h>
+#include <linux/arm-smccc.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/smp.h>
+#include <linux/firmware/meson/meson_sm.h>
+
+struct meson_sm_cmd {
+       unsigned int index;
+       u32 smc_id;
+};
+#define CMD(d, s) { .index = (d), .smc_id = (s), }
+
+struct meson_sm_chip {
+       unsigned int shmem_size;
+       u32 cmd_shmem_in_base;
+       u32 cmd_shmem_out_base;
+       struct meson_sm_cmd cmd[];
+};
+
+struct meson_sm_firmware {
+       struct device *dev;
+       const struct meson_sm_chip *chip;
+       void __iomem *sm_shmem_in_base;
+       void __iomem *sm_shmem_out_base;
+};
+
+struct meson_sm_chip gxbb_chip = {
+       .shmem_size             = 0x1000,
+       .cmd_shmem_in_base      = 0x82000020,

drivers/firmware/meson/meson_sm.c line 60

Quoted 10 lines
drivers/firmware/meson/meson_sm.c new file +10 -0
+       .cmd_shmem_out_base     = 0x82000021,
+       .cmd = {
+               CMD(SM_EFUSE_READ,      0x82000030),
+               CMD(SM_EFUSE_WRITE,     0x82000031),
+               CMD(SM_EFUSE_USER_MAX,  0x82000033),
+               { /* sentinel */ },
+       },
+};
+
+static u32 meson_sm_get_cmd(const struct meson_sm_chip *chip, unsigned

int cmd_index)

drivers/firmware/meson/meson_sm.c

Quoted 11 lines
drivers/firmware/meson/meson_sm.c new file +11 -0
+{
+       unsigned int i;
+
+       for (i = 0; chip->cmd[i].smc_id; i++)
+               if (chip->cmd[i].index == cmd_index)
+                       return chip->cmd[i].smc_id;
+
+       return 0;
+}
+
+static u32 __meson_sm_call(u32 cmd, u32 arg0, u32 arg1, u32 arg2, u32

arg3, u32 arg4)

Quoted 26 lines
drivers/firmware/meson/meson_sm.c new file +26 -0
+{
+       struct arm_smccc_res res;
+
+       arm_smccc_smc(cmd, arg0, arg1, arg2, arg3, arg4, 0, 0, &res);
+       return res.a0;
+}
+
+u32 meson_sm_call(struct meson_sm_firmware *fw, unsigned int cmd_index,
+                 u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4)
+{
+       u32 cmd;
+
+       if (!fw)
+               return -EINVAL;
+
+       cmd = meson_sm_get_cmd(fw->chip, cmd_index);
+       if (!cmd)
+               return -EINVAL;
+
+       return __meson_sm_call(cmd, arg0, arg1, arg2, arg3, arg4);
+}
+EXPORT_SYMBOL(meson_sm_call);
+
+u32 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)

drivers/firmware/meson/meson_sm.c line 107

Quoted 10 lines
drivers/firmware/meson/meson_sm.c new file +10 -0
+{
+       u32 size;
+
+       if (!fw->chip->cmd_shmem_out_base)
+               return -EINVAL;
+
+       size = meson_sm_call(fw, cmd_index, arg0, arg1, arg2, arg3, arg4);
+       if (size <= 0 || size > fw->chip->shmem_size)
+               return -EINVAL;
+

u32 cannot be less than 0

Quoted 45 lines
drivers/firmware/meson/meson_sm.c new file +45 -0
+       memcpy(buffer, fw->sm_shmem_out_base, size);
+
+       return size;
+}
+EXPORT_SYMBOL(meson_sm_call_read);
+
+u32 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)
+{
+       u32 size;
+
+       if (b_size > fw->chip->shmem_size)
+               return -EINVAL;
+
+       if (!fw->chip->cmd_shmem_in_base)
+               return -EINVAL;
+
+       memcpy(fw->sm_shmem_in_base, buffer, b_size);
+
+       size = meson_sm_call(fw, cmd_index, arg0, arg1, arg2, arg3, arg4);
+       if (size <= 0)
+               return -EINVAL;
+
+       return size;
+}
+EXPORT_SYMBOL(meson_sm_call_write);
+
+static void __iomem *meson_sm_map_shmem(u32 cmd_shmem, unsigned int size)
+{
+       u32 sm_phy_base;
+
+       sm_phy_base = __meson_sm_call(cmd_shmem, 0, 0, 0, 0, 0);
+       if (!sm_phy_base)
+               return 0;
+
+       return ioremap_cache(sm_phy_base, size);
+}
+
+static int meson_sm_probe(struct platform_device *pdev)
+{
+       const struct meson_sm_chip *chip;
+       struct meson_sm_firmware *fw;
+
+       fw = devm_kzalloc(&pdev->dev, sizeof(*fw), GFP_KERNEL);

drivers/firmware/meson/meson_sm.c line 162

Quoted 10 lines
drivers/firmware/meson/meson_sm.c new file +10 -0
+       if (!fw)
+               return -ENOMEM;
+
+       fw->dev = &pdev->dev;
+
+       chip = of_device_get_match_data(fw->dev);
+       if (!chip) {
+               dev_err(fw->dev, "Unable to setup secure-monitor data\n");
+               return -ENODEV;
+       }

-ENODEV not best return here. Return -EINVAL better. -ENODEV won't get reported by device layer

drivers/firmware/meson/meson_sm.c line 164

Quoted 2 lines
drivers/firmware/meson/meson_sm.c new file +2 -0
+       if (chip->cmd_shmem_in_base) {
+               fw->sm_shmem_in_base =

meson_sm_map_shmem(chip->cmd_shmem_in_base,

drivers/firmware/meson/meson_sm.c line 165

Quoted 1 line
drivers/firmware/meson/meson_sm.c new file +1 -0
+

chip->shmem_size);

drivers/firmware/meson/meson_sm.c line 169

Quoted 3 lines
drivers/firmware/meson/meson_sm.c new file +3 -0
+               if (!fw->sm_shmem_in_base)
+                       goto out;
+       }

Maybe use WarnOn here

drivers/firmware/meson/meson_sm.c line 170

Quoted 2 lines
drivers/firmware/meson/meson_sm.c new file +2 -0
+       if (chip->cmd_shmem_out_base) {
+               fw->sm_shmem_out_base =

meson_sm_map_shmem(chip->cmd_shmem_out_base,

drivers/firmware/meson/meson_sm.c line 171

Quoted 1 line
drivers/firmware/meson/meson_sm.c new file +1 -0
+

chip->shmem_size);

Quoted 9 lines
drivers/firmware/meson/meson_sm.c new file +9 -0
+               if (!fw->sm_shmem_out_base)
+                       goto out;
+       }
+
+       fw->chip = chip;
+       platform_set_drvdata(pdev, fw);
+
+       dev_info(fw->dev, "secure-monitor enabled\n");
+

drivers/firmware/meson/meson_sm.c

Quoted 10 lines
drivers/firmware/meson/meson_sm.c new file +10 -0
+       return 0;
+
+out:
+       if (fw->sm_shmem_in_base)
+               iounmap(fw->sm_shmem_in_base);
+
+       return -EINVAL;
+}
+
+struct meson_sm_firmware *meson_sm_get_fw(struct device_node

*firmware_node)

drivers/firmware/meson/meson_sm.c line 192

Quoted 2 lines
drivers/firmware/meson/meson_sm.c new file +2 -0
+{
+       struct platform_device *pdev =

of_find_device_by_node(firmware_node);

Review

Quoted 30 lines
drivers/firmware/meson/meson_sm.c new file +29 -0
+
+       /*
+        * Returns NULL is the firmware device is not ready.
+        */
+       if (!pdev)
+               return NULL;
+
+       return platform_get_drvdata(pdev);
+}
+EXPORT_SYMBOL(meson_sm_get_fw);
+
+static const struct of_device_id meson_sm_ids[] = {
+       { .compatible = "amlogic,meson-gxbb-sm", .data = &gxbb_chip },
+       { /* sentinel */},
+};
+MODULE_DEVICE_TABLE(of, meson_sm_ids);
+
+static struct platform_driver meson_sm_platform_driver = {
+       .probe  = meson_sm_probe,
+       .driver = {
+               .name           = "secure-monitor",
+               .of_match_table = meson_sm_ids,
+       },
+};
+module_platform_driver(meson_sm_platform_driver);
+
+MODULE_AUTHOR("Carlo Caione <[email protected]>");
+MODULE_DESCRIPTION("Amlogic secure monitor driver");
+MODULE_LICENSE("GPL");
(quoted diff) +0 -0

b/include/linux/firmware/meson/meson_sm.h

Quoted 25 lines

new file mode 100644
index 0000000..f653916

include/linux/firmware/meson/meson_sm.h new file +20 -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;

include/linux/firmware/meson/meson_sm.h line 30

Quoted 10 lines
include/linux/firmware/meson/meson_sm.h new file +10 -0
+
+u32 meson_sm_call(struct meson_sm_firmware *fw, unsigned int cmd_index,
+                 u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4);
+u32 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);
+u32 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);

Quoted 10 lines
include/linux/firmware/meson/meson_sm.h new file +2 -1
+
+#endif /* _MESON_SM_FW_H_ */
--

2.7.4

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

#3 lore raw

PATCH v5 1/3 firmware: Amlogic: Add secure monitor driver

On 29/05/16 12:27, Ben Dooks wrote:

[...]

Quoted 6 lines
Quoted 6 lines
drivers/firmware/meson/meson_sm.c new file +6 -0
+u32 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)
+{
+       u32 size;
+
Quoted 8 lines

drivers/firmware/meson/meson_sm.c line 107

Quoted 7 lines
drivers/firmware/meson/meson_sm.c new file +7 -0
+       if (!fw->chip->cmd_shmem_out_base)
+               return -EINVAL;
+
+       size = meson_sm_call(fw, cmd_index, arg0, arg1, arg2, arg3, arg4);
+       if (size <= 0 || size > fw->chip->shmem_size)
+               return -EINVAL;
+

u32 cannot be less than 0

Ouch. Definitely overlooked that. Fix coming.

[...]

Quoted 10 lines
Quoted 10 lines
drivers/firmware/meson/meson_sm.c new file +10 -0
+static int meson_sm_probe(struct platform_device *pdev)
+{
+       const struct meson_sm_chip *chip;
+       struct meson_sm_firmware *fw;
+
+       fw = devm_kzalloc(&pdev->dev, sizeof(*fw), GFP_KERNEL);
+       if (!fw)
+               return -ENOMEM;
+
+       fw->dev = &pdev->dev;
Quoted 8 lines

drivers/firmware/meson/meson_sm.c line 162

Quoted 6 lines
drivers/firmware/meson/meson_sm.c new file +6 -0
+
+       chip = of_device_get_match_data(fw->dev);
+       if (!chip) {
+               dev_err(fw->dev, "Unable to setup secure-monitor data\n");
+               return -ENODEV;
+       }

-ENODEV not best return here. Return -EINVAL better. -ENODEV won't get reported by device layer

Ok

[...]

Quoted 4 lines

drivers/firmware/meson/meson_sm.c line 169

Quoted 3 lines
drivers/firmware/meson/meson_sm.c new file +3 -0
+               if (!fw->sm_shmem_in_base)
+                       goto out;
+       }

Maybe use WarnOn here

Alright.

Cheers,

Signature · 1 line
Carlo Caione
#4 lore raw

PATCH v5 2/3 documentation: Add secure monitor binding documentation

In reply to Carlo Caione

From: Carlo Caione <[email protected]>

Add the binding documentation for the Amlogic secure monitor driver.

---
 .../bindings/firmware/meson/meson_sm.txt           | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/meson/meson_sm.txt
Documentation/devicetree/bindings/firmware/meson/meson_sm.txt new file +33 -0
new file mode 100644
index 0000000..6f0b5bc
@@ -0,0 +1,33 @@
+* 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 {
+		compatible = "simple-bus";
+
+		sm: secure-monitor {
+			compatible = "amlogic,meson-gxbb-sm";
+		};
+	};
+
+Example of the node using the secure monitor:
+
+	#include <dt-bindings/firmware/meson-sm.h>
+
+	...
+
+	efuse: efuse {
+		compatible = "amlogic,meson-gxbb-efuse";
+		secure-monitor = <&sm>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		...
+	};
+
Signature · 1 line
2.7.4
maintainer
#5 lore raw

PATCH v5 2/3 documentation: Add secure monitor binding documentation

Quoted 18 lines · Carlo Caione

From: Carlo Caione <[email protected]>

Add the binding documentation for the Amlogic secure monitor driver.

---
 .../bindings/firmware/meson/meson_sm.txt           | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/meson/meson_sm.txt
Documentation/devicetree/bindings/firmware/meson/meson_sm.txt new file +2 -0
new file mode 100644
index 0000000..6f0b5bc
@@ -0,0 +1,33 @@
+* Amlogic Secure Monitor
+

Documentation/devicetree/bindings/firmware/meson/meson_sm.txt line 12

Quoted 10 lines
Documentation/devicetree/bindings/firmware/meson/meson_sm.txt new file +10 -0
+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 {
+		compatible = "simple-bus";

Drop this. Sorry, but no abusing simple-bus to get automagic creation of your platform device.

Quoted 5 lines
Documentation/devicetree/bindings/firmware/meson/meson_sm.txt new file +5 -0
+
+		sm: secure-monitor {
+			compatible = "amlogic,meson-gxbb-sm";
+		};
+	};

Documentation/devicetree/bindings/firmware/meson/meson_sm.txt line 27

Quoted 10 lines
Documentation/devicetree/bindings/firmware/meson/meson_sm.txt new file +10 -0
+
+Example of the node using the secure monitor:
+
+	#include <dt-bindings/firmware/meson-sm.h>
+
+	...
+
+	efuse: efuse {
+		compatible = "amlogic,meson-gxbb-efuse";
+		secure-monitor = <&sm>;

Why do you need this? Given there can only be one node, just use of_find_compatible_node();

Quoted 9 lines
Documentation/devicetree/bindings/firmware/meson/meson_sm.txt new file +6 -0
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		...
+	};
+
Signature · 1 line
2.7.4
#6 lore raw

PATCH v5 2/3 documentation: Add secure monitor binding documentation

Quoted 24 lines · Rob Herring
Quoted 23 lines · Carlo Caione

From: Carlo Caione <[email protected]>

Add the binding documentation for the Amlogic secure monitor driver.

---
 .../bindings/firmware/meson/meson_sm.txt           | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/meson/meson_sm.txt
Documentation/devicetree/bindings/firmware/meson/meson_sm.txt new file +7 -0
new file mode 100644
index 0000000..6f0b5bc
@@ -0,0 +1,33 @@
+* 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"
Quoted 8 lines

Documentation/devicetree/bindings/firmware/meson/meson_sm.txt line 12

Quoted 5 lines
Documentation/devicetree/bindings/firmware/meson/meson_sm.txt new file +5 -0
+
+Example:
+
+	firmware {
+		compatible = "simple-bus";

Drop this. Sorry, but no abusing simple-bus to get automagic creation of your platform device.

Sounds reasonable. I can hook this up to some *_initcall. What about introducing a new FIRMWARE_OF_DECLARE() ?

Cheers,

Signature · 1 line
Carlo Caione
maintainer
#7 lore raw

PATCH v5 2/3 documentation: Add secure monitor binding documentation

Quoted 34 lines · Carlo Caione
Quoted 24 lines · Rob Herring
Quoted 23 lines · Carlo Caione

From: Carlo Caione <[email protected]>

Add the binding documentation for the Amlogic secure monitor driver.

---
 .../bindings/firmware/meson/meson_sm.txt           | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/meson/meson_sm.txt
Documentation/devicetree/bindings/firmware/meson/meson_sm.txt new file +7 -0
new file mode 100644
index 0000000..6f0b5bc
@@ -0,0 +1,33 @@
+* 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"
Quoted 8 lines

Documentation/devicetree/bindings/firmware/meson/meson_sm.txt line 12

Quoted 5 lines
Documentation/devicetree/bindings/firmware/meson/meson_sm.txt new file +5 -0
+
+Example:
+
+   firmware {
+           compatible = "simple-bus";

Drop this. Sorry, but no abusing simple-bus to get automagic creation of your platform device.

Quoted 2 lines

Sounds reasonable. I can hook this up to some *_initcall. What about introducing a new FIRMWARE_OF_DECLARE() ?

Please don't add FIRMWARE_OF_DECLARE unless it needs to be early.

Rob

#8 lore raw

PATCH v5 2/3 documentation: Add secure monitor binding documentation

In reply to Rob Herring
Quoted 1 line · Rob Herring

On Sun, May 29, 2016 at 01:12:02PM +0200, Carlo Caione wrote:

[...]

Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/firmware/meson/meson_sm.txt new file +4 -0
+Example of the node using the secure monitor:
+
+	#include <dt-bindings/firmware/meson-sm.h>
+
Quoted 8 lines

Documentation/devicetree/bindings/firmware/meson/meson_sm.txt line 27

Quoted 5 lines
Documentation/devicetree/bindings/firmware/meson/meson_sm.txt new file +5 -0
+	...
+
+	efuse: efuse {
+		compatible = "amlogic,meson-gxbb-efuse";
+		secure-monitor = <&sm>;

Why do you need this? Given there can only be one node, just use of_find_compatible_node();

of_find_compatible_node() in the driver works fine if we have only one possible compatible property for the secure-monitor node. In this case we have a different compatible property for each SoC (GXBB in this case) so I think having the phandle in the DT is still the best thing to do.

Any thought on this Rob?

Signature · 1 line
Carlo Caione
#9 lore raw

PATCH v5 3/3 ARM64: dts: amlogic: gxbb: Enable secure monitor

In reply to Carlo Caione

From: 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 | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi +8 -0
index 76b3b6d..a453bbf 100644
@@ -98,6 +98,14 @@
 		method = "smc";
 	};
 
+	firmware {
+		compatible = "simple-bus";
+
+		sm: secure-monitor {
+			compatible = "amlogic,meson-gxbb-sm";
+		};
+	};
+
 	timer {
 		compatible = "arm,armv8-timer";
 		interrupts = <GIC_PPI 13
Signature · 1 line
2.7.4