optee: obtain emmc rpmb info from dt
Subsystems (2)
RFC PATCH 1/2 optee: obtain emmc rpmb info from dt
From: Igor Opaniuk <[email protected]>
Add support for rpmb-dev property in optee node. Prioritize that eMMC info from DT for RPMB operations instead of the one provided by OP-TEE OS core in RPC calls.
Signed-off-by Igor Opaniuk <[email protected]>
---
drivers/tee/optee/core.c | 33 +++++++++++++++++ drivers/tee/optee/optee_private.h | 2 +- drivers/tee/optee/rpmb.c | 60 ++++++++++++++++++------------- 3 files changed, 70 insertions(+), 25 deletions(-)
drivers/tee/optee/core.c +33 -0
@@ -12,6 +12,7 @@#include <linux/arm-smccc.h> #include <linux/err.h> #include <linux/io.h> +#include <mmc.h> #include "optee_smc.h" #include "optee_msg.h"
@@ -607,14 +608,46 @@ static optee_invoke_fn *get_invoke_func(struct udevice *dev)return ERR_PTR (-EINVAL ); } +static struct mmc *get_rpmb_dev (struct udevice *dev) +{ +struct udevice *mmc_dev; +const fdt32_t *phandle_p; +u32 phandle; +int ret =0 ; + +debug ("optee: looking for rpmb device in DT.\n" ); + + phandle_p =ofnode_get_property (dev_ofnode (dev), +"rpmb-dev" ,NULL ); +if (!phandle_p) { +debug ("optee: missing \"rpmb-dev\" property\n" ); +return ERR_PTR (-ENXIO ); + } + + phandle =fdt32_to_cpu (*phandle_p); + + ret =uclass_get_device_by_phandle_id (UCLASS_MMC , phandle, &mmc_dev); +if (ret) { +printf ("optee: invalid phandle value in \"rpmb-dev\".\n" ); +return ERR_PTR (-ENXIO ); + } + +debug ("optee: using phandle %d from \"rpmd-dev\" property.\n" , + phandle); +return mmc_get_mmc_dev (mmc_dev); +} +static int optee_of_to_plat (struct udevice *dev) {struct optee_pdata *pdata =dev_get_plat (dev); +struct optee_private *priv =dev_get_priv (dev); pdata->invoke_fn =get_invoke_func (dev);if (IS_ERR (pdata->invoke_fn))return PTR_ERR (pdata->invoke_fn); + priv->rpmb_mmc =get_rpmb_dev (dev); +return 0 ; }
drivers/tee/optee/optee_private.h +1 -1
@@ -19,8 +19,8 @@*/ struct optee_private {struct mmc *rpmb_mmc; -int rpmb_dev_id;int rpmb_original_part; +bool rpmb_inited; };struct optee_msg_arg ;
drivers/tee/optee/rpmb.c +36 -24
91 lines not on this page · raw message
Signature · 1 line
2.25.1
RFC PATCH 2/2 doc: device-tree-bindings: optee: support rpmb-dev property
From: Igor Opaniuk <[email protected]>
Add support for "rpmb-dev" property which provides eMMC phandle for RPMB-related operations.
This commit is created only to show DT node updates for RFC patch, obviously that node should be updated in device-tree-bindings in Linux first, that pulled here.
Signed-off-by Igor Opaniuk <[email protected]>
---
doc/device-tree-bindings/firmware/linaro,optee-tz.txt | 3 +++ 1 file changed, 3 insertions(+)
doc/device-tree-bindings/firmware/linaro,optee-tz.txt +3 -0
@@ -20,6 +20,8 @@ the reference implementation maintained by Linaro. "hvc" : HVC #0, with the register assignments specified in drivers/tee/optee/optee_smc.h +- rpmb-dev : contains phandle to the eMMC device, whose RPMB partition + is used for secure storage. Example:
@@ -27,5 +29,6 @@ Example: optee { compatible = "linaro,optee-tz"; method = "smc"; + rpmb-dev = <&mmc0> }; };
Signature · 1 line
2.25.1