Merge tpm_tis ACPI and platform drivers
v2 cover Merge tpm_tis ACPI and platform drivers
As suggested by Jarkko.
The two precursor patches might want to go to -stable.
Jerry says it worked on his system, but we still to see results from things like crb systems/etc.
Jason Gunthorpe (3):
tpm_tis: Fix IRQ autoprobing when using platform_device
tpm_tis: Use platform_get_irq
tpm_tis: Consolidate the platform and acpi probe flow
drivers/char/tpm/tpm_tis.c | 175 +++++++++++++++------------------------------ 1 file changed, 57 insertions(+), 118 deletions(-)
Signature · 6 lines
2.7.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
A message that is not in the archive (sent off-list or not yet received): 1493913205-18276-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
PATCH v2 1/3 tpm_tis: Fix IRQ autoprobing when using platform_device
The test was backwards, triggering IRQ autoprobing if the firmware did not specify an IRQ, instead of triggering it only when the module force parameter was specified.
Since autoprobing is not enabled on !x86 and the platform device is currently only used on !x86, or with force, this has gone unnoticed.
--- drivers/char/tpm/tpm_tis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_tis.c +1 -1
@@ -336,7 +336,7 @@ static int tpm_tis_plat_probe(struct platform_device *pdev)if (res) { tpm_info.irq = res->start; }else { -if (pdev == force_pdev) +if (pdev != force_pdev) tpm_info.irq =-1 ;else /* When forcing auto probe the IRQ */
Signature · 6 lines
2.7.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
A message that is not in the archive (sent off-list or not yet received): 1493913205-18276-2-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Jarkko Sakkinen
Reviewed-byRe: [PATCH v2 1/3] tpm_tis: Fix IRQ autoprobing when using platform_device
Quoted 10 lines · Jason Gunthorpe
The test was backwards, triggering IRQ autoprobing if the firmware did not specify an IRQ, instead of triggering it only when the module force parameter was specified.
Since autoprobing is not enabled on !x86 and the platform device is currently only used on !x86, or with force, this has gone unnoticed.
Fixes 00194826e6be ("tpm_tis: Clean up the force=1 module parameter")Tested-by Jerry Snitselaar <[email protected]>
Quoted 20 lines
--- drivers/char/tpm/tpm_tis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/tpm/tpm_tis.c +1
-1@@ -336,7 +336,7 @@ static int tpm_tis_plat_probe(struct platform_device *pdev)if (res) { tpm_info.irq = res->start; }else { -if (pdev == force_pdev) +if (pdev != force_pdev) tpm_info.irq =-1 ;else /* When forcing auto probe the IRQ */ Signature · 1 line
2.7.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
A message that is not in the archive (sent off-list or not yet received): 20170508234502.2fhj5edbcubdalb5-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Jarkko Sakkinen
Tested-byRe: [PATCH v2 1/3] tpm_tis: Fix IRQ autoprobing when using platform_device
Quoted 5 lines · Jarkko Sakkinen
Quoted 4 lines · Jason Gunthorpe
The test was backwards, triggering IRQ autoprobing if the firmware did not specify an IRQ, instead of triggering it only when the module force parameter was specified.
Quoted 8 lines
Quoted 6 lines
Since autoprobing is not enabled on !x86 and the platform device is currently only used on !x86, or with force, this has gone unnoticed.
Fixes 00194826e6be ("tpm_tis: Clean up the force=1 module parameter")Tested-by Jerry Snitselaar <[email protected]>
/Jarkko
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
A message that is not in the archive (sent off-list or not yet received): 20170509140301.bqh3hgpjccdcbj5p-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Jarkko Sakkinen
AppliedRe: [PATCH v2 1/3] tpm_tis: Fix IRQ autoprobing when using platform_device
Quoted 9 lines · Jarkko Sakkinen
Quoted 8 lines · Jarkko Sakkinen
Quoted 7 lines · Jason Gunthorpe
The test was backwards, triggering IRQ autoprobing if the firmware did not specify an IRQ, instead of triggering it only when the module force parameter was specified.
Since autoprobing is not enabled on !x86 and the platform device is currently only used on !x86, or with force, this has gone unnoticed.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Fixes 00194826e6be ("tpm_tis: Clean up the force=1 module parameter")Tested-by Jerry Snitselaar <[email protected]>
Applied.
/Jarkko
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
PATCH v2 2/3 tpm_tis: Use platform_get_irq
In reply to a message not in the archiveReplace the open coded IORESOURCE_IRQ with platform_get_irq, which supports more cases.
--- drivers/char/tpm/tpm_tis.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/char/tpm/tpm_tis.c +2 -4
@@ -332,10 +332,8 @@ static int tpm_tis_plat_probe(struct platform_device *pdev) } tpm_info.res = *res; - res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); -if (res) { - tpm_info.irq = res->start; - }else { + tpm_info.irq =platform_get_irq (pdev,0 ); +if (tpm_info.irq <=0 ) {if (pdev != force_pdev) tpm_info.irq =-1 ;else
Signature · 6 lines
2.7.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
A message that is not in the archive (sent off-list or not yet received): 1493913205-18276-3-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Jarkko Sakkinen
Reviewed-byRe: [PATCH v2 2/3] tpm_tis: Use platform_get_irq
Quoted 6 lines · Jason Gunthorpe
Replace the open coded
IORESOURCE_IRQwithplatform_get_irq, which supports more cases.Fixes 00194826e6be ("tpm_tis: Clean up the force=1 module parameter")Tested-by Jerry Snitselaar <[email protected]>
/Jarkko
Quoted 24 lines
--- drivers/char/tpm/tpm_tis.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/char/tpm/tpm_tis.c +2
-4@@ -332,10 +332,8 @@ static int tpm_tis_plat_probe(struct platform_device *pdev) } tpm_info.res = *res; - res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); -if (res) { - tpm_info.irq = res->start; - }else { + tpm_info.irq =platform_get_irq (pdev,0 ); +if (tpm_info.irq <=0 ) {if (pdev != force_pdev) tpm_info.irq =-1 ;else Signature · 1 line
2.7.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
A message that is not in the archive (sent off-list or not yet received): 20170508234539.qnhf6p7fwxxcb5ul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Jarkko Sakkinen
Tested-byRe: [PATCH v2 2/3] tpm_tis: Use platform_get_irq
Quoted 9 lines · Jarkko Sakkinen
Quoted 6 lines · Jason Gunthorpe
Replace the open coded
IORESOURCE_IRQwithplatform_get_irq, which supports more cases.Fixes 00194826e6be ("tpm_tis: Clean up the force=1 module parameter")Tested-by Jerry Snitselaar <[email protected]>
/Jarkko
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
A message that is not in the archive (sent off-list or not yet received): 20170509140345.tqesdnggeb3s67be-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Jarkko Sakkinen
AppliedRe: [PATCH v2 2/3] tpm_tis: Use platform_get_irq
Quoted 5 lines · Jarkko Sakkinen
Quoted 4 lines · Jarkko Sakkinen
Quoted 3 lines · Jason Gunthorpe
Replace the open coded
IORESOURCE_IRQwithplatform_get_irq, which supports more cases.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Fixes 00194826e6be ("tpm_tis: Clean up the force=1 module parameter")Tested-by Jerry Snitselaar <[email protected]>
Applied.
/Jarkko
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Jarkko Sakkinen
Reviewed-byRe: [PATCH v2 2/3] tpm_tis: Use platform_get_irq
In reply to a message not in the archiveQuoted 6 lines · Jason Gunthorpe
Replace the open coded
IORESOURCE_IRQwithplatform_get_irq, which supports more cases.Fixes 00194826e6be ("tpm_tis: Clean up the force=1 module parameter")Tested-by Jerry Snitselaar <[email protected]>
/Jarkko
Quoted 24 lines
--- drivers/char/tpm/tpm_tis.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/char/tpm/tpm_tis.c +2
-4@@ -332,10 +332,8 @@ static int tpm_tis_plat_probe(struct platform_device *pdev) } tpm_info.res = *res; - res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); -if (res) { - tpm_info.irq = res->start; - }else { + tpm_info.irq =platform_get_irq (pdev,0 ); +if (tpm_info.irq <=0 ) {if (pdev != force_pdev) tpm_info.irq =-1 ;else Signature · 1 line
2.7.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
PATCH v2 3/3 tpm_tis: Consolidate the platform and acpi probe flow
In reply to a message not in the archiveNow that the platform device was merged for OF support we can use the platform device to match ACPI devices as well and run everything through tpm_tis_init.
pnp_acpi_device is replaced with ACPI_COMPANION, and ACPI_HANDLE is pushed further down.
platform_get_resource is used instead of acpi_dev_get_resources.
The itpm global module parameter is no longer changed during itpm detection, instead the phy specific bit is set directly.
--- drivers/char/tpm/tpm_tis.c | 167 +++++++++++++++------------------------------ 1 file changed, 54 insertions(+), 113 deletions(-)
drivers/char/tpm/tpm_tis.c +54 -113
@@ -80,6 +80,8 @@ static int has_hid(struct acpi_device *dev, const char *hid)static inline int is_itpm (struct acpi_device *dev) { +if (!dev) +return 0 ;return has_hid (dev,"INTC0102" ); }#else
@@ -89,6 +91,47 @@ static inline int is_itpm(struct acpi_device *dev) }#endif +#if defined(CONFIG_ACPI ) +#define DEVICE_IS_TPM2 1 + +static const struct acpi_device_id tpm_acpi_tbl[] = { + {"MSFT0101" ,DEVICE_IS_TPM2 }, + {}, +}; +MODULE_DEVICE_TABLE (acpi, tpm_acpi_tbl); + +static int check_acpi_tpm2 (struct device *dev) +{ +const struct acpi_device_id *aid =acpi_match_device (tpm_acpi_tbl, dev); +struct acpi_table_tpm2 *tbl; +acpi_status st; + +if (!aid || aid->driver_data !=DEVICE_IS_TPM2 ) +return 0 ; + +/* If the ACPI TPM2 signature is matched then a global ACPI_SIG_TPM2 +* table is mandatory +*/ + st = +acpi_get_table (ACPI_SIG_TPM2 ,1 , (struct acpi_table_header **)&tbl); +if (ACPI_FAILURE (st) || tbl->header.length <sizeof (*tbl)) { +dev_err (dev,FW_BUG "failed to get TPM2 ACPI table\n" ); +return -EINVAL ; + } + +/* The tpm2_crb driver handles this device */ +if (tbl->start_method !=ACPI_TPM2_MEMORY_MAPPED ) +return -ENODEV ; + +return 0 ; +} +#else +static int check_acpi_tpm2 (struct acpi_device *dev) +{ +return 0 ; +} +#endif +static int tpm_tcg_read_bytes (struct tpm_tis_data *data,u32 addr,u16 len,u8 *result) {
@@ -141,11 +184,15 @@ static const struct tpm_tis_phy_ops tpm_tcg = { .write32 = tpm_tcg_write32, }; -static int tpm_tis_init (struct device *dev,struct tpm_info *tpm_info, -acpi_handle acpi_dev_handle) +static int tpm_tis_init (struct device *dev,struct tpm_info *tpm_info) {struct tpm_tis_tcg_phy *phy;int irq =-1 ; +int rc; + + rc =check_acpi_tpm2 (dev); +if (rc) +return rc; phy =devm_kzalloc (dev,sizeof (struct tpm_tis_tcg_phy ),GFP_KERNEL );if (phy ==NULL )
@@ -158,11 +205,11 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,if (interrupts) irq = tpm_info->irq; -if (itpm) +if (itpm ||is_itpm (ACPI_COMPANION (dev))) phy->priv.flags |=TPM_TIS_ITPM_WORKAROUND ;return tpm_tis_core_init (dev, &phy->priv, irq, &tpm_tcg, - acpi_dev_handle); +ACPI_HANDLE (dev)); } static SIMPLE_DEV_PM_OPS(tpm_tis_pm, tpm_pm_suspend, tpm_tis_resume);
@@ -171,7 +218,6 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev, const struct pnp_device_id *pnp_id) {struct tpm_info tpm_info = {}; -acpi_handle acpi_dev_handle =NULL ;struct resource *res; res =pnp_get_resource (pnp_dev,IORESOURCE_MEM ,0 );
@@ -184,14 +230,7 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,else tpm_info.irq =-1 ; -if (pnp_acpi_device (pnp_dev)) { -if (is_itpm (pnp_acpi_device (pnp_dev))) - itpm = true; - - acpi_dev_handle =ACPI_HANDLE (&pnp_dev->dev); - } - -return tpm_tis_init (&pnp_dev->dev, &tpm_info, acpi_dev_handle); +return tpm_tis_init (&pnp_dev->dev, &tpm_info); }static struct pnp_device_id tpm_pnp_tbl[] = {
@@ -231,93 +270,6 @@ module_param_string(hid, tpm_pnp_tbl[TIS_HID_USR_IDX].id, sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444);MODULE_PARM_DESC (hid,"Set additional specific HID for this driver to probe" ); -#ifdef CONFIG_ACPI -static int tpm_check_resource (struct acpi_resource *ares,void *data) -{ -struct tpm_info *tpm_info = (struct tpm_info *) data; -struct resource res; - -if (acpi_dev_resource_interrupt (ares,0 , &res)) - tpm_info->irq = res.start; -else if (acpi_dev_resource_memory (ares, &res)) { - tpm_info->res = res; - tpm_info->res.name =NULL ; - } - -return 1 ; -} - -static int tpm_tis_acpi_init (struct acpi_device *acpi_dev) -{ -struct acpi_table_tpm2 *tbl; -acpi_status st; -struct list_head resources; -struct tpm_info tpm_info = {}; -int ret; - - st =acpi_get_table (ACPI_SIG_TPM2 ,1 , - (struct acpi_table_header **) &tbl); -if (ACPI_FAILURE (st) || tbl->header.length <sizeof (*tbl)) { -dev_err (&acpi_dev->dev, -FW_BUG "failed to get TPM2 ACPI table\n" ); -return -EINVAL ; - } - -if (tbl->start_method !=ACPI_TPM2_MEMORY_MAPPED ) -return -ENODEV ; - -INIT_LIST_HEAD (&resources); - tpm_info.irq =-1 ; - ret =acpi_dev_get_resources (acpi_dev, &resources, tpm_check_resource, - &tpm_info); -if (ret <0 ) -return ret; - -acpi_dev_free_resource_list (&resources); - -if (resource_type (&tpm_info.res) !=IORESOURCE_MEM ) { -dev_err (&acpi_dev->dev, -FW_BUG "TPM2 ACPI table does not define a memory resource\n" ); -return -EINVAL ; - } - -if (is_itpm (acpi_dev)) - itpm = true; - -return tpm_tis_init (&acpi_dev->dev, &tpm_info, acpi_dev->handle); -} - -static int tpm_tis_acpi_remove (struct acpi_device *dev) -{ -struct tpm_chip *chip =dev_get_drvdata (&dev->dev); - -tpm_chip_unregister (chip); -tpm_tis_remove (chip); - -return 0 ; -} - -static struct acpi_device_id tpm_acpi_tbl[] = { - {"MSFT0101" ,0 },/* TPM 2.0 */ -/* Add new here */ - {"" ,0 },/* User Specified */ - {"" ,0 }/* Terminator */ -}; -MODULE_DEVICE_TABLE (acpi, tpm_acpi_tbl); - -static struct acpi_driver tis_acpi_driver = { - .name ="tpm_tis" , - .ids = tpm_acpi_tbl, - .ops = { - .add = tpm_tis_acpi_init, - .remove = tpm_tis_acpi_remove, - }, - .drv = { - .pm = &tpm_tis_pm, - }, -}; -#endif -static struct platform_device *force_pdev;static int tpm_tis_plat_probe (struct platform_device *pdev)
@@ -341,7 +293,7 @@ static int tpm_tis_plat_probe(struct platform_device *pdev) tpm_info.irq =0 ; } -return tpm_tis_init (&pdev->dev, &tpm_info,NULL ); +return tpm_tis_init (&pdev->dev, &tpm_info); }static int tpm_tis_plat_remove (struct platform_device *pdev)
@@ -369,6 +321,7 @@ static struct platform_driver tis_drv = { .name = "tpm_tis", .pm = &tpm_tis_pm, .of_match_table = of_match_ptr(tis_of_platform_match), + .acpi_match_table = ACPI_PTR(tpm_acpi_tbl), }, };
@@ -411,11 +364,6 @@ static int __init init_tis(void)if (rc) goto err_platform; -#ifdef CONFIG_ACPI - rc =acpi_bus_register_driver (&tis_acpi_driver); -if (rc) - goto err_acpi; -#endif if (IS_ENABLED (CONFIG_PNP )) { rc =pnp_register_driver (&tis_pnp_driver);
@@ -426,10 +374,6 @@ static int __init init_tis(void)return 0 ; err_pnp: -#ifdef CONFIG_ACPI -acpi_bus_unregister_driver (&tis_acpi_driver); -err_acpi: -#endif platform_driver_unregister (&tis_drv); err_platform:if (force_pdev)
@@ -441,9 +385,6 @@ static int __init init_tis(void) static void __exit cleanup_tis(void) {pnp_unregister_driver (&tis_pnp_driver); -#ifdef CONFIG_ACPI -acpi_bus_unregister_driver (&tis_acpi_driver); -#endif platform_driver_unregister (&tis_drv);if (force_pdev)
Signature · 6 lines
2.7.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
A message that is not in the archive (sent off-list or not yet received): 1493913205-18276-4-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Jarkko Sakkinen
Reviewed-byRe: [PATCH v2 3/3] tpm_tis: Consolidate the platform and acpi probe flow
Quoted 7 lines · Jason Gunthorpe
Now that the platform device was merged for OF support we can use the platform device to match ACPI devices as well and run everything through
tpm_tis_init.
pnp_acpi_deviceis replaced withACPI_COMPANION, andACPI_HANDLEis pushed further down.
Quoted 7 lines
platform_get_resourceis used instead ofacpi_dev_get_resources.The itpm global module parameter is no longer changed during itpm detection, instead the phy specific bit is set directly.
/Jarkko
Quoted 268 lines
--- drivers/char/tpm/tpm_tis.c | 167 +++++++++++++++------------------------------ 1 file changed, 54 insertions(+), 113 deletions(-)drivers/char/tpm/tpm_tis.c +54
-113@@ -80,6 +80,8 @@ static int has_hid(struct acpi_device *dev, const char *hid)static inline int is_itpm (struct acpi_device *dev) { +if (!dev) +return 0 ;return has_hid (dev,"INTC0102" ); }#else @@ -89,6 +91,47 @@ static inline int is_itpm(struct acpi_device *dev) }#endif +#if defined(CONFIG_ACPI ) +#define DEVICE_IS_TPM2 1 + +static const struct acpi_device_id tpm_acpi_tbl[] = { + {"MSFT0101" ,DEVICE_IS_TPM2 }, + {}, +}; +MODULE_DEVICE_TABLE (acpi, tpm_acpi_tbl); + +static int check_acpi_tpm2 (struct device *dev) +{ +const struct acpi_device_id *aid =acpi_match_device (tpm_acpi_tbl, dev); +struct acpi_table_tpm2 *tbl; +acpi_status st; + +if (!aid || aid->driver_data !=DEVICE_IS_TPM2 ) +return 0 ; + +/* If the ACPI TPM2 signature is matched then a global ACPI_SIG_TPM2 +* table is mandatory +*/ + st = +acpi_get_table (ACPI_SIG_TPM2 ,1 , (struct acpi_table_header **)&tbl); +if (ACPI_FAILURE (st) || tbl->header.length <sizeof (*tbl)) { +dev_err (dev,FW_BUG "failed to get TPM2 ACPI table\n" ); +return -EINVAL ; + } + +/* The tpm2_crb driver handles this device */ +if (tbl->start_method !=ACPI_TPM2_MEMORY_MAPPED ) +return -ENODEV ; + +return 0 ; +} +#else +static int check_acpi_tpm2 (struct acpi_device *dev) +{ +return 0 ; +} +#endif +static int tpm_tcg_read_bytes (struct tpm_tis_data *data,u32 addr,u16 len,u8 *result) {@@ -141,11 +184,15 @@ static const struct tpm_tis_phy_ops tpm_tcg = { .write32 = tpm_tcg_write32, }; -static int tpm_tis_init (struct device *dev,struct tpm_info *tpm_info, -acpi_handle acpi_dev_handle) +static int tpm_tis_init (struct device *dev,struct tpm_info *tpm_info) {struct tpm_tis_tcg_phy *phy;int irq =-1 ; +int rc; + + rc =check_acpi_tpm2 (dev); +if (rc) +return rc; phy =devm_kzalloc (dev,sizeof (struct tpm_tis_tcg_phy ),GFP_KERNEL );if (phy ==NULL )@@ -158,11 +205,11 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,if (interrupts) irq = tpm_info->irq; -if (itpm) +if (itpm ||is_itpm (ACPI_COMPANION (dev))) phy->priv.flags |=TPM_TIS_ITPM_WORKAROUND ;return tpm_tis_core_init (dev, &phy->priv, irq, &tpm_tcg, - acpi_dev_handle); +ACPI_HANDLE (dev)); } static SIMPLE_DEV_PM_OPS(tpm_tis_pm, tpm_pm_suspend, tpm_tis_resume);@@ -171,7 +218,6 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev, const struct pnp_device_id *pnp_id) {struct tpm_info tpm_info = {}; -acpi_handle acpi_dev_handle =NULL ;struct resource *res; res =pnp_get_resource (pnp_dev,IORESOURCE_MEM ,0 );@@ -184,14 +230,7 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,else tpm_info.irq =-1 ; -if (pnp_acpi_device (pnp_dev)) { -if (is_itpm (pnp_acpi_device (pnp_dev))) - itpm = true; - - acpi_dev_handle =ACPI_HANDLE (&pnp_dev->dev); - } - -return tpm_tis_init (&pnp_dev->dev, &tpm_info, acpi_dev_handle); +return tpm_tis_init (&pnp_dev->dev, &tpm_info); }static struct pnp_device_id tpm_pnp_tbl[] = {@@ -231,93 +270,6 @@ module_param_string(hid, tpm_pnp_tbl[TIS_HID_USR_IDX].id, sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444);MODULE_PARM_DESC (hid,"Set additional specific HID for this driver to probe" ); -#ifdef CONFIG_ACPI -static int tpm_check_resource (struct acpi_resource *ares,void *data) -{ -struct tpm_info *tpm_info = (struct tpm_info *) data; -struct resource res; - -if (acpi_dev_resource_interrupt (ares,0 , &res)) - tpm_info->irq = res.start; -else if (acpi_dev_resource_memory (ares, &res)) { - tpm_info->res = res; - tpm_info->res.name =NULL ; - } - -return 1 ; -} - -static int tpm_tis_acpi_init (struct acpi_device *acpi_dev) -{ -struct acpi_table_tpm2 *tbl; -acpi_status st; -struct list_head resources; -struct tpm_info tpm_info = {}; -int ret; - - st =acpi_get_table (ACPI_SIG_TPM2 ,1 , - (struct acpi_table_header **) &tbl); -if (ACPI_FAILURE (st) || tbl->header.length <sizeof (*tbl)) { -dev_err (&acpi_dev->dev, -FW_BUG "failed to get TPM2 ACPI table\n" ); -return -EINVAL ; - } - -if (tbl->start_method !=ACPI_TPM2_MEMORY_MAPPED ) -return -ENODEV ; - -INIT_LIST_HEAD (&resources); - tpm_info.irq =-1 ; - ret =acpi_dev_get_resources (acpi_dev, &resources, tpm_check_resource, - &tpm_info); -if (ret <0 ) -return ret; - -acpi_dev_free_resource_list (&resources); - -if (resource_type (&tpm_info.res) !=IORESOURCE_MEM ) { -dev_err (&acpi_dev->dev, -FW_BUG "TPM2 ACPI table does not define a memory resource\n" ); -return -EINVAL ; - } - -if (is_itpm (acpi_dev)) - itpm = true; - -return tpm_tis_init (&acpi_dev->dev, &tpm_info, acpi_dev->handle); -} - -static int tpm_tis_acpi_remove (struct acpi_device *dev) -{ -struct tpm_chip *chip =dev_get_drvdata (&dev->dev); - -tpm_chip_unregister (chip); -tpm_tis_remove (chip); - -return 0 ; -} - -static struct acpi_device_id tpm_acpi_tbl[] = { - {"MSFT0101" ,0 },/* TPM 2.0 */ -/* Add new here */ - {"" ,0 },/* User Specified */ - {"" ,0 }/* Terminator */ -}; -MODULE_DEVICE_TABLE (acpi, tpm_acpi_tbl); - -static struct acpi_driver tis_acpi_driver = { - .name ="tpm_tis" , - .ids = tpm_acpi_tbl, - .ops = { - .add = tpm_tis_acpi_init, - .remove = tpm_tis_acpi_remove, - }, - .drv = { - .pm = &tpm_tis_pm, - }, -}; -#endif -static struct platform_device *force_pdev;static int tpm_tis_plat_probe (struct platform_device *pdev)@@ -341,7 +293,7 @@ static int tpm_tis_plat_probe(struct platform_device *pdev) tpm_info.irq =0 ; } -return tpm_tis_init (&pdev->dev, &tpm_info,NULL ); +return tpm_tis_init (&pdev->dev, &tpm_info); }static int tpm_tis_plat_remove (struct platform_device *pdev)@@ -369,6 +321,7 @@ static struct platform_driver tis_drv = { .name = "tpm_tis", .pm = &tpm_tis_pm, .of_match_table = of_match_ptr(tis_of_platform_match), + .acpi_match_table = ACPI_PTR(tpm_acpi_tbl), }, };@@ -411,11 +364,6 @@ static int __init init_tis(void)if (rc) goto err_platform; -#ifdef CONFIG_ACPI - rc =acpi_bus_register_driver (&tis_acpi_driver); -if (rc) - goto err_acpi; -#endif if (IS_ENABLED (CONFIG_PNP )) { rc =pnp_register_driver (&tis_pnp_driver);@@ -426,10 +374,6 @@ static int __init init_tis(void)return 0 ; err_pnp: -#ifdef CONFIG_ACPI -acpi_bus_unregister_driver (&tis_acpi_driver); -err_acpi: -#endif platform_driver_unregister (&tis_drv); err_platform:if (force_pdev)@@ -441,9 +385,6 @@ static int __init init_tis(void) static void __exit cleanup_tis(void) {pnp_unregister_driver (&tis_pnp_driver); -#ifdef CONFIG_ACPI -acpi_bus_unregister_driver (&tis_acpi_driver); -#endif platform_driver_unregister (&tis_drv);if (force_pdev)Signature · 1 line
2.7.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
A message that is not in the archive (sent off-list or not yet received): 20170508235033.qcq6my5dvpyvwrwx-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Jarkko Sakkinen
Tested-byRe: [PATCH v2 3/3] tpm_tis: Consolidate the platform and acpi probe flow
Quoted 10 lines · Jarkko Sakkinen
Quoted 9 lines · Jason Gunthorpe
Now that the platform device was merged for OF support we can use the platform device to match ACPI devices as well and run everything through
tpm_tis_init.
pnp_acpi_deviceis replaced withACPI_COMPANION, andACPI_HANDLEis pushed further down.
platform_get_resourceis used instead ofacpi_dev_get_resources.
Quoted 7 lines
Quoted 5 lines
The itpm global module parameter is no longer changed during itpm detection, instead the phy specific bit is set directly.
/Jarkko
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
A message that is not in the archive (sent off-list or not yet received): 20170509140425.zr5hrxpjiytp6hpd-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Jarkko Sakkinen
AppliedRe: [PATCH v2 3/3] tpm_tis: Consolidate the platform and acpi probe flow
Quoted 14 lines · Jarkko Sakkinen
Quoted 13 lines · Jarkko Sakkinen
Quoted 12 lines · Jason Gunthorpe
Now that the platform device was merged for OF support we can use the platform device to match ACPI devices as well and run everything through
tpm_tis_init.
pnp_acpi_deviceis replaced withACPI_COMPANION, andACPI_HANDLEis pushed further down.
platform_get_resourceis used instead ofacpi_dev_get_resources.The itpm global module parameter is no longer changed during itpm detection, instead the phy specific bit is set directly.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Applied.
/Jarkko
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Jerry Snitselaar
Reviewed-byQuoted 7 lines · Jason Gunthorpe
As suggested by Jarkko.
The two precursor patches might want to go to -stable.
Jerry says it worked on his system, but we still to see results from things like crb systems/etc.
Quoted 11 lines
Jason Gunthorpe (3):
tpm_tis: Fix IRQ autoprobing when usingplatform_device
tpm_tis: Useplatform_get_irq
tpm_tis: Consolidate the platform and acpi probe flow
drivers/char/tpm/tpm_tis.c| 175 +++++++++++++++------------------------------1 file changed, 57 insertions(+), 118 deletions(-)Signature · 1 line
2.7.4
I also tested on a crb device, and verified that check_acpi_tpm2 was detecting it.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 16 lines · Jerry Snitselaar
Quoted 15 lines · Jason Gunthorpe
As suggested by Jarkko.
The two precursor patches might want to go to -stable.
Jerry says it worked on his system, but we still to see results from things like crb systems/etc.
Jason Gunthorpe (3):
tpm_tis: Fix IRQ autoprobing when usingplatform_device
tpm_tis: Useplatform_get_irq
tpm_tis: Consolidate the platform and acpi probe flow
drivers/char/tpm/tpm_tis.c| 175 +++++++++++++++------------------------------1 file changed, 57 insertions(+), 118 deletions(-)
Quoted 7 lines
Quoted 3 lines
Signature · 1 line
2.7.4I also tested on a crb device, and verified that
check_acpi_tpm2was detecting it.Reviewed-by Jerry Snitselaar <[email protected]>
You tested with TPM2 chips only, right? If this is the case, I'll test with TPM 1.2.
/Jarkko
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
A message that is not in the archive (sent off-list or not yet received): 20170508235219.2zczjmnujaenw2sv-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Quoted 21 lines · Jarkko Sakkinen
Quoted 20 lines · Jerry Snitselaar
Quoted 18 lines · Jason Gunthorpe
As suggested by Jarkko.
The two precursor patches might want to go to -stable.
Jerry says it worked on his system, but we still to see results from things like crb systems/etc.
Jason Gunthorpe (3):
tpm_tis: Fix IRQ autoprobing when usingplatform_device
tpm_tis: Useplatform_get_irq
tpm_tis: Consolidate the platform and acpi probe flow
drivers/char/tpm/tpm_tis.c| 175 +++++++++++++++------------------------------1 file changed, 57 insertions(+), 118 deletions(-)--
2.7.4
Quoted 8 lines
Quoted 3 lines
I also tested on a crb device, and verified that
check_acpi_tpm2was detecting it.Reviewed-by Jerry Snitselaar <[email protected]>You tested with TPM2 chips only, right? If this is the case, I'll test with TPM 1.2.
/Jarkko
Yes, I've only tested TPM2 devices so far.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 24 lines · Jerry Snitselaar
Quoted 23 lines · Jarkko Sakkinen
Quoted 22 lines · Jerry Snitselaar
Quoted 12 lines · Jason Gunthorpe
As suggested by Jarkko.
The two precursor patches might want to go to -stable.
Jerry says it worked on his system, but we still to see results from things like crb systems/etc.
Jason Gunthorpe (3):
tpm_tis: Fix IRQ autoprobing when usingplatform_device
tpm_tis: Useplatform_get_irq
tpm_tis: Consolidate the platform and acpi probe flowQuoted 6 lines
drivers/char/tpm/tpm_tis.c| 175 +++++++++++++++------------------------------1 file changed, 57 insertions(+), 118 deletions(-)--
2.7.4I also tested on a crb device, and verified that
check_acpi_tpm2was detecting it.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Reviewed-by Jerry Snitselaar <[email protected]>You tested with TPM2 chips only, right? If this is the case, I'll test with TPM 1.2.
/Jarkko
Yes, I've only tested TPM2 devices so far.
Great, I tested with TPM 1.2 today. I'm ready to apply these patches.
/Jarkko
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot