* [PATCH v2 0/2] synquacer: add TPM support @ 2020-01-14 14:16 Ard Biesheuvel 2020-01-14 14:16 ` [PATCH v2 1/2] dt-bindings: tpm-tis-mmio: add compatible string for SynQuacer TPM Ard Biesheuvel 2020-01-14 14:16 ` [PATCH v2 2/2] tpm: tis: add support for MMIO TPM on SynQuacer Ard Biesheuvel 0 siblings, 2 replies; 9+ messages in thread From: Ard Biesheuvel @ 2020-01-14 14:16 UTC (permalink / raw) To: linux-kernel Cc: Ard Biesheuvel, jarkko.sakkinen, linux-arm-kernel, masahisa.kojima, devicetree, linux-integrity, peterhuewe, jgg This adds support for driving the TPM on Socionext SynQuacer platforms using the existing driver for a memory mapped TIS frame. v2: - don't use read/write_bytes() to implement read/write16/32 since that uses the wrong address Cc: jarkko.sakkinen@linux.intel.com Cc: linux-arm-kernel@lists.infradead.org Cc: masahisa.kojima@linaro.org Cc: devicetree@vger.kernel.org Cc: linux-integrity@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: peterhuewe@gmx.de Cc: jgg@ziepe.ca Ard Biesheuvel (2): dt-bindings: tpm-tis-mmio: add compatible string for SynQuacer TPM tpm: tis: add support for MMIO TPM on SynQuacer Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt | 1 + drivers/char/tpm/tpm_tis.c | 50 +++++++++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) -- 2.20.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/2] dt-bindings: tpm-tis-mmio: add compatible string for SynQuacer TPM 2020-01-14 14:16 [PATCH v2 0/2] synquacer: add TPM support Ard Biesheuvel @ 2020-01-14 14:16 ` Ard Biesheuvel 2020-01-21 22:23 ` Rob Herring 2020-01-23 12:22 ` Jarkko Sakkinen 2020-01-14 14:16 ` [PATCH v2 2/2] tpm: tis: add support for MMIO TPM on SynQuacer Ard Biesheuvel 1 sibling, 2 replies; 9+ messages in thread From: Ard Biesheuvel @ 2020-01-14 14:16 UTC (permalink / raw) To: linux-kernel Cc: Ard Biesheuvel, jarkko.sakkinen, linux-arm-kernel, masahisa.kojima, devicetree, linux-integrity, peterhuewe, jgg, Rob Herring Add a compatible string for the SynQuacer TPM to the binding for a TPM exposed via a memory mapped TIS frame. The MMIO window behaves slightly differently on this hardware, so it requires its own identifier. Cc: Rob Herring <robh+dt@kernel.org> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> --- Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt b/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt index 7c6304426da1..b604c8688dc8 100644 --- a/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt +++ b/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt @@ -12,6 +12,7 @@ Required properties: - compatible: should contain a string below for the chip, followed by "tcg,tpm-tis-mmio". Valid chip strings are: * "atmel,at97sc3204" + * "socionext,synquacer-tpm-mmio" - reg: The location of the MMIO registers, should be at least 0x5000 bytes - interrupts: An optional interrupt indicating command completion. -- 2.20.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: tpm-tis-mmio: add compatible string for SynQuacer TPM 2020-01-14 14:16 ` [PATCH v2 1/2] dt-bindings: tpm-tis-mmio: add compatible string for SynQuacer TPM Ard Biesheuvel @ 2020-01-21 22:23 ` Rob Herring 2020-01-23 12:22 ` Jarkko Sakkinen 1 sibling, 0 replies; 9+ messages in thread From: Rob Herring @ 2020-01-21 22:23 UTC (permalink / raw) To: Ard Biesheuvel Cc: linux-kernel, Ard Biesheuvel, jarkko.sakkinen, linux-arm-kernel, masahisa.kojima, devicetree, linux-integrity, peterhuewe, jgg On Tue, 14 Jan 2020 15:16:46 +0100, Ard Biesheuvel wrote: > Add a compatible string for the SynQuacer TPM to the binding for a > TPM exposed via a memory mapped TIS frame. The MMIO window behaves > slightly differently on this hardware, so it requires its own > identifier. > > Cc: Rob Herring <robh+dt@kernel.org> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org> > --- > Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt | 1 + > 1 file changed, 1 insertion(+) > Acked-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: tpm-tis-mmio: add compatible string for SynQuacer TPM 2020-01-14 14:16 ` [PATCH v2 1/2] dt-bindings: tpm-tis-mmio: add compatible string for SynQuacer TPM Ard Biesheuvel 2020-01-21 22:23 ` Rob Herring @ 2020-01-23 12:22 ` Jarkko Sakkinen 2020-01-23 12:23 ` Ard Biesheuvel 1 sibling, 1 reply; 9+ messages in thread From: Jarkko Sakkinen @ 2020-01-23 12:22 UTC (permalink / raw) To: Ard Biesheuvel, linux-kernel Cc: linux-arm-kernel, masahisa.kojima, devicetree, linux-integrity, peterhuewe, jgg, Rob Herring On Tue, 2020-01-14 at 15:16 +0100, Ard Biesheuvel wrote: > Add a compatible string for the SynQuacer TPM to the binding for a > TPM exposed via a memory mapped TIS frame. The MMIO window behaves > slightly differently on this hardware, so it requires its own > identifier. > > Cc: Rob Herring <robh+dt@kernel.org> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org> > --- > Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt b/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt > index 7c6304426da1..b604c8688dc8 100644 > --- a/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt > +++ b/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt > @@ -12,6 +12,7 @@ Required properties: > - compatible: should contain a string below for the chip, followed by > "tcg,tpm-tis-mmio". Valid chip strings are: > * "atmel,at97sc3204" > + * "socionext,synquacer-tpm-mmio" > - reg: The location of the MMIO registers, should be at least 0x5000 bytes > - interrupts: An optional interrupt indicating command completion. > Acked-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Someone else needs to give reviewed-by as I am not expert on DT bindings. /Jarkko ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: tpm-tis-mmio: add compatible string for SynQuacer TPM 2020-01-23 12:22 ` Jarkko Sakkinen @ 2020-01-23 12:23 ` Ard Biesheuvel 0 siblings, 0 replies; 9+ messages in thread From: Ard Biesheuvel @ 2020-01-23 12:23 UTC (permalink / raw) To: Jarkko Sakkinen Cc: Ard Biesheuvel, Linux Kernel Mailing List, linux-arm-kernel, Masahisa Kojima, Devicetree List, linux-integrity, Peter Hüwe, Jason Gunthorpe, Rob Herring On Thu, 23 Jan 2020 at 13:22, Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> wrote: > > On Tue, 2020-01-14 at 15:16 +0100, Ard Biesheuvel wrote: > > Add a compatible string for the SynQuacer TPM to the binding for a > > TPM exposed via a memory mapped TIS frame. The MMIO window behaves > > slightly differently on this hardware, so it requires its own > > identifier. > > > > Cc: Rob Herring <robh+dt@kernel.org> > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org> > > --- > > Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt b/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt > > index 7c6304426da1..b604c8688dc8 100644 > > --- a/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt > > +++ b/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt > > @@ -12,6 +12,7 @@ Required properties: > > - compatible: should contain a string below for the chip, followed by > > "tcg,tpm-tis-mmio". Valid chip strings are: > > * "atmel,at97sc3204" > > + * "socionext,synquacer-tpm-mmio" > > - reg: The location of the MMIO registers, should be at least 0x5000 bytes > > - interrupts: An optional interrupt indicating command completion. > > > > Acked-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> > > Someone else needs to give reviewed-by as I am not expert on DT bindings. > Cheers Jarko. Rob's ack should be sufficient for this to go via another tree. However, I am still waiting to hear back from Masahisa to confirm that the SPI command sequencer approach works 100% on this hardware, so shall we park these patches for the time being? Thanks, Ard. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 2/2] tpm: tis: add support for MMIO TPM on SynQuacer 2020-01-14 14:16 [PATCH v2 0/2] synquacer: add TPM support Ard Biesheuvel 2020-01-14 14:16 ` [PATCH v2 1/2] dt-bindings: tpm-tis-mmio: add compatible string for SynQuacer TPM Ard Biesheuvel @ 2020-01-14 14:16 ` Ard Biesheuvel 2020-01-23 12:27 ` Jarkko Sakkinen 1 sibling, 1 reply; 9+ messages in thread From: Ard Biesheuvel @ 2020-01-14 14:16 UTC (permalink / raw) To: linux-kernel Cc: Ard Biesheuvel, jarkko.sakkinen, linux-arm-kernel, masahisa.kojima, devicetree, linux-integrity, peterhuewe, jgg When fitted, the SynQuacer platform exposes its SPI TPM via a MMIO window that is backed by the SPI command sequencer in the SPI bus controller. This arrangement has the limitation that only byte size accesses are supported, and so we'll need to provide a separate set of read and write accessors that take this into account. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> --- drivers/char/tpm/tpm_tis.c | 50 +++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index e7df342a317d..2466295fcfe8 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -32,6 +32,7 @@ struct tpm_info { struct resource res; + const struct tpm_tis_phy_ops *ops; /* irq > 0 means: use irq $irq; * irq = 0 means: autoprobe for an irq; * irq = -1 means: no irq support @@ -186,6 +187,48 @@ static const struct tpm_tis_phy_ops tpm_tcg = { .write32 = tpm_tcg_write32, }; +static int tpm_tcg_read16_bw(struct tpm_tis_data *data, u32 addr, u16 *result) +{ + struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data); + + *result = (ioread8(phy->iobase + addr)) | + (ioread8(phy->iobase + addr + 1) << 8); + + return 0; +} + +static int tpm_tcg_read32_bw(struct tpm_tis_data *data, u32 addr, u32 *result) +{ + struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data); + + *result = (ioread8(phy->iobase + addr)) | + (ioread8(phy->iobase + addr + 1) << 8) | + (ioread8(phy->iobase + addr + 2) << 16) | + (ioread8(phy->iobase + addr + 3) << 24); + + return 0; +} + +static int tpm_tcg_write32_bw(struct tpm_tis_data *data, u32 addr, u32 value) +{ + struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data); + + iowrite8(value, phy->iobase + addr); + iowrite8(value >> 8, phy->iobase + addr + 1); + iowrite8(value >> 16, phy->iobase + addr + 2); + iowrite8(value >> 24, phy->iobase + addr + 3); + + return 0; +} + +static const struct tpm_tis_phy_ops tpm_tcg_bw = { + .read_bytes = tpm_tcg_read_bytes, + .write_bytes = tpm_tcg_write_bytes, + .read16 = tpm_tcg_read16_bw, + .read32 = tpm_tcg_read32_bw, + .write32 = tpm_tcg_write32_bw, +}; + static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info) { struct tpm_tis_tcg_phy *phy; @@ -210,7 +253,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info) 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, + return tpm_tis_core_init(dev, &phy->priv, irq, tpm_info->ops, ACPI_HANDLE(dev)); } @@ -219,7 +262,7 @@ static SIMPLE_DEV_PM_OPS(tpm_tis_pm, tpm_pm_suspend, tpm_tis_resume); static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev, const struct pnp_device_id *pnp_id) { - struct tpm_info tpm_info = {}; + struct tpm_info tpm_info = { .ops = &tpm_tcg }; struct resource *res; res = pnp_get_resource(pnp_dev, IORESOURCE_MEM, 0); @@ -295,6 +338,8 @@ static int tpm_tis_plat_probe(struct platform_device *pdev) tpm_info.irq = 0; } + tpm_info.ops = of_device_get_match_data(&pdev->dev) ?: &tpm_tcg; + return tpm_tis_init(&pdev->dev, &tpm_info); } @@ -311,6 +356,7 @@ static int tpm_tis_plat_remove(struct platform_device *pdev) #ifdef CONFIG_OF static const struct of_device_id tis_of_platform_match[] = { {.compatible = "tcg,tpm-tis-mmio"}, + {.compatible = "socionext,synquacer-tpm-mmio", .data = &tpm_tcg_bw}, {}, }; MODULE_DEVICE_TABLE(of, tis_of_platform_match); -- 2.20.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] tpm: tis: add support for MMIO TPM on SynQuacer 2020-01-14 14:16 ` [PATCH v2 2/2] tpm: tis: add support for MMIO TPM on SynQuacer Ard Biesheuvel @ 2020-01-23 12:27 ` Jarkko Sakkinen 2020-01-23 12:29 ` Ard Biesheuvel 0 siblings, 1 reply; 9+ messages in thread From: Jarkko Sakkinen @ 2020-01-23 12:27 UTC (permalink / raw) To: Ard Biesheuvel, linux-kernel Cc: linux-arm-kernel, masahisa.kojima, devicetree, linux-integrity, peterhuewe, jgg On Tue, 2020-01-14 at 15:16 +0100, Ard Biesheuvel wrote: > When fitted, the SynQuacer platform exposes its SPI TPM via a MMIO > window that is backed by the SPI command sequencer in the SPI bus > controller. This arrangement has the limitation that only byte size > accesses are supported, and so we'll need to provide a separate set > of read and write accessors that take this into account. What is SynQuacer platform? I'm also missing a resolution why tpm_tis.c is extended to handle both and not add tpm_tis_something.c instead. It does not follow the pattern we have in place (e.g. look up tpm_tis_spi.c). /Jarkko ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] tpm: tis: add support for MMIO TPM on SynQuacer 2020-01-23 12:27 ` Jarkko Sakkinen @ 2020-01-23 12:29 ` Ard Biesheuvel 2020-01-30 8:37 ` Jarkko Sakkinen 0 siblings, 1 reply; 9+ messages in thread From: Ard Biesheuvel @ 2020-01-23 12:29 UTC (permalink / raw) To: Jarkko Sakkinen Cc: Ard Biesheuvel, Linux Kernel Mailing List, linux-arm-kernel, Masahisa Kojima, Devicetree List, linux-integrity, Peter Hüwe, Jason Gunthorpe On Thu, 23 Jan 2020 at 13:27, Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> wrote: > > On Tue, 2020-01-14 at 15:16 +0100, Ard Biesheuvel wrote: > > When fitted, the SynQuacer platform exposes its SPI TPM via a MMIO > > window that is backed by the SPI command sequencer in the SPI bus > > controller. This arrangement has the limitation that only byte size > > accesses are supported, and so we'll need to provide a separate set > > of read and write accessors that take this into account. > > What is SynQuacer platform? > It is an arm64 SoC manufactured by Socionext. > I'm also missing a resolution why tpm_tis.c is extended to handle both > and not add tpm_tis_something.c instead. It does not follow the pattern > we have in place (e.g. look up tpm_tis_spi.c). > We could easily do that instead, if preferred. It's just that it would duplicate a bit of code. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] tpm: tis: add support for MMIO TPM on SynQuacer 2020-01-23 12:29 ` Ard Biesheuvel @ 2020-01-30 8:37 ` Jarkko Sakkinen 0 siblings, 0 replies; 9+ messages in thread From: Jarkko Sakkinen @ 2020-01-30 8:37 UTC (permalink / raw) To: Ard Biesheuvel Cc: Ard Biesheuvel, Linux Kernel Mailing List, linux-arm-kernel, Masahisa Kojima, Devicetree List, linux-integrity, Peter Hüwe, Jason Gunthorpe On Thu, 2020-01-23 at 13:29 +0100, Ard Biesheuvel wrote: > On Thu, 23 Jan 2020 at 13:27, Jarkko Sakkinen > <jarkko.sakkinen@linux.intel.com> wrote: > > On Tue, 2020-01-14 at 15:16 +0100, Ard Biesheuvel wrote: > > > When fitted, the SynQuacer platform exposes its SPI TPM via a MMIO > > > window that is backed by the SPI command sequencer in the SPI bus > > > controller. This arrangement has the limitation that only byte size > > > accesses are supported, and so we'll need to provide a separate set > > > of read and write accessors that take this into account. > > > > What is SynQuacer platform? > > > > It is an arm64 SoC manufactured by Socionext. > > > I'm also missing a resolution why tpm_tis.c is extended to handle both > > and not add tpm_tis_something.c instead. It does not follow the pattern > > we have in place (e.g. look up tpm_tis_spi.c). > > > > We could easily do that instead, if preferred. It's just that it would > duplicate a bit of code. I'm fine with that. Overally I think it is cleaner flow. /Jarkko ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-01-30 8:37 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-01-14 14:16 [PATCH v2 0/2] synquacer: add TPM support Ard Biesheuvel 2020-01-14 14:16 ` [PATCH v2 1/2] dt-bindings: tpm-tis-mmio: add compatible string for SynQuacer TPM Ard Biesheuvel 2020-01-21 22:23 ` Rob Herring 2020-01-23 12:22 ` Jarkko Sakkinen 2020-01-23 12:23 ` Ard Biesheuvel 2020-01-14 14:16 ` [PATCH v2 2/2] tpm: tis: add support for MMIO TPM on SynQuacer Ard Biesheuvel 2020-01-23 12:27 ` Jarkko Sakkinen 2020-01-23 12:29 ` Ard Biesheuvel 2020-01-30 8:37 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).