Skip to content

Commit 9f1944c

Browse files
muvarovjenswi-linaro
authored andcommitted
tpm_ftpm_tee: register driver on TEE bus
OP-TEE based fTPM Trusted Application depends on tee-supplicant to provide NV RAM implementation based on RPMB secure storage. So this dependency can be resolved via TEE bus where we only invoke fTPM driver probe once fTPM device is registered on the bus which is only true after the tee-supplicant is up and running. Additionally, TEE bus provides auto device enumeration. Signed-off-by: Maxim Uvarov <[email protected]> Suggested-by: Sumit Garg <[email protected]> Suggested-by: Arnd Bergmann <[email protected]> Reviewed-by: Sumit Garg <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Tested-by: Sumit Garg <[email protected]> Signed-off-by: Jens Wiklander <[email protected]>
1 parent 5f178bb commit 9f1944c

File tree

1 file changed

+60
-10
lines changed

1 file changed

+60
-10
lines changed

drivers/char/tpm/tpm_ftpm_tee.c

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,10 @@ static int ftpm_tee_match(struct tee_ioctl_version_data *ver, const void *data)
214214
* Return:
215215
* On success, 0. On failure, -errno.
216216
*/
217-
static int ftpm_tee_probe(struct platform_device *pdev)
217+
static int ftpm_tee_probe(struct device *dev)
218218
{
219219
int rc;
220220
struct tpm_chip *chip;
221-
struct device *dev = &pdev->dev;
222221
struct ftpm_tee_private *pvt_data = NULL;
223222
struct tee_ioctl_open_session_arg sess_arg;
224223

@@ -297,16 +296,23 @@ static int ftpm_tee_probe(struct platform_device *pdev)
297296
return rc;
298297
}
299298

299+
static int ftpm_plat_tee_probe(struct platform_device *pdev)
300+
{
301+
struct device *dev = &pdev->dev;
302+
303+
return ftpm_tee_probe(dev);
304+
}
305+
300306
/**
301307
* ftpm_tee_remove() - remove the TPM device
302308
* @pdev: the platform_device description.
303309
*
304310
* Return:
305311
* 0 always.
306312
*/
307-
static int ftpm_tee_remove(struct platform_device *pdev)
313+
static int ftpm_tee_remove(struct device *dev)
308314
{
309-
struct ftpm_tee_private *pvt_data = dev_get_drvdata(&pdev->dev);
315+
struct ftpm_tee_private *pvt_data = dev_get_drvdata(dev);
310316

311317
/* Release the chip */
312318
tpm_chip_unregister(pvt_data->chip);
@@ -328,11 +334,18 @@ static int ftpm_tee_remove(struct platform_device *pdev)
328334
return 0;
329335
}
330336

337+
static int ftpm_plat_tee_remove(struct platform_device *pdev)
338+
{
339+
struct device *dev = &pdev->dev;
340+
341+
return ftpm_tee_remove(dev);
342+
}
343+
331344
/**
332345
* ftpm_tee_shutdown() - shutdown the TPM device
333346
* @pdev: the platform_device description.
334347
*/
335-
static void ftpm_tee_shutdown(struct platform_device *pdev)
348+
static void ftpm_plat_tee_shutdown(struct platform_device *pdev)
336349
{
337350
struct ftpm_tee_private *pvt_data = dev_get_drvdata(&pdev->dev);
338351

@@ -347,17 +360,54 @@ static const struct of_device_id of_ftpm_tee_ids[] = {
347360
};
348361
MODULE_DEVICE_TABLE(of, of_ftpm_tee_ids);
349362

350-
static struct platform_driver ftpm_tee_driver = {
363+
static struct platform_driver ftpm_tee_plat_driver = {
351364
.driver = {
352365
.name = "ftpm-tee",
353366
.of_match_table = of_match_ptr(of_ftpm_tee_ids),
354367
},
355-
.probe = ftpm_tee_probe,
356-
.remove = ftpm_tee_remove,
357-
.shutdown = ftpm_tee_shutdown,
368+
.shutdown = ftpm_plat_tee_shutdown,
369+
.probe = ftpm_plat_tee_probe,
370+
.remove = ftpm_plat_tee_remove,
371+
};
372+
373+
/* UUID of the fTPM TA */
374+
static const struct tee_client_device_id optee_ftpm_id_table[] = {
375+
{UUID_INIT(0xbc50d971, 0xd4c9, 0x42c4,
376+
0x82, 0xcb, 0x34, 0x3f, 0xb7, 0xf3, 0x78, 0x96)},
377+
{}
358378
};
359379

360-
module_platform_driver(ftpm_tee_driver);
380+
MODULE_DEVICE_TABLE(tee, optee_ftpm_id_table);
381+
382+
static struct tee_client_driver ftpm_tee_driver = {
383+
.id_table = optee_ftpm_id_table,
384+
.driver = {
385+
.name = "optee-ftpm",
386+
.bus = &tee_bus_type,
387+
.probe = ftpm_tee_probe,
388+
.remove = ftpm_tee_remove,
389+
},
390+
};
391+
392+
static int __init ftpm_mod_init(void)
393+
{
394+
int rc;
395+
396+
rc = platform_driver_register(&ftpm_tee_plat_driver);
397+
if (rc)
398+
return rc;
399+
400+
return driver_register(&ftpm_tee_driver.driver);
401+
}
402+
403+
static void __exit ftpm_mod_exit(void)
404+
{
405+
platform_driver_unregister(&ftpm_tee_plat_driver);
406+
driver_unregister(&ftpm_tee_driver.driver);
407+
}
408+
409+
module_init(ftpm_mod_init);
410+
module_exit(ftpm_mod_exit);
361411

362412
MODULE_AUTHOR("Thirupathaiah Annapureddy <[email protected]>");
363413
MODULE_DESCRIPTION("TPM Driver for fTPM TA in TEE");

0 commit comments

Comments
 (0)