From: Stephen Boyd <swboyd@chromium.org>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Peter Huewe <peterhuewe@gmx.de>,
linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org,
Andrey Pronin <apronin@chromium.org>,
Duncan Laurie <dlaurie@chromium.org>,
Jason Gunthorpe <jgg@ziepe.ca>, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Guenter Roeck <groeck@chromium.org>,
Alexander Steffen <Alexander.Steffen@infineon.com>
Subject: Re: [PATCH v4 2/6] tpm: tpm_tis_spi: Introduce a flow control callback
Date: Mon, 19 Aug 2019 10:06:40 -0700 [thread overview]
Message-ID: <5d5ad721.1c69fb81.6a514.e649@mx.google.com> (raw)
In-Reply-To: <20190819163240.vsgylmctemzgqd34@linux.intel.com>
Quoting Jarkko Sakkinen (2019-08-19 09:32:40)
> On Mon, Aug 12, 2019 at 03:36:18PM -0700, Stephen Boyd wrote:
> > Cr50 firmware has a different flow control protocol than the one used by
> > this TPM PTP SPI driver. Introduce a flow control callback so we can
> > override the standard sequence with the custom one that Cr50 uses.
> >
> > Cc: Andrey Pronin <apronin@chromium.org>
> > Cc: Duncan Laurie <dlaurie@chromium.org>
> > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: Guenter Roeck <groeck@chromium.org>
> > Cc: Alexander Steffen <Alexander.Steffen@infineon.com>
> > Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> > ---
> > drivers/char/tpm/tpm_tis_spi.c | 55 +++++++++++++++++++++-------------
> > 1 file changed, 34 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c
> > index 19513e622053..819602e85b34 100644
> > --- a/drivers/char/tpm/tpm_tis_spi.c
> > +++ b/drivers/char/tpm/tpm_tis_spi.c
> > @@ -42,6 +42,8 @@
> > struct tpm_tis_spi_phy {
> > struct tpm_tis_data priv;
> > struct spi_device *spi_device;
> > + int (*flow_control)(struct tpm_tis_spi_phy *phy,
> > + struct spi_transfer *xfer);
> > u8 *iobuf;
> > };
> >
> > @@ -50,12 +52,39 @@ static inline struct tpm_tis_spi_phy *to_tpm_tis_spi_phy(struct tpm_tis_data *da
> > return container_of(data, struct tpm_tis_spi_phy, priv);
> > }
> >
> > +static int tpm_tis_spi_flow_control(struct tpm_tis_spi_phy *phy,
> > + struct spi_transfer *spi_xfer)
> > +{
> > + struct spi_message m;
> > + int ret, i;
> > +
> > + if ((phy->iobuf[3] & 0x01) == 0) {
> > + // handle SPI wait states
> > + phy->iobuf[0] = 0;
> > +
> > + for (i = 0; i < TPM_RETRY; i++) {
> > + spi_xfer->len = 1;
> > + spi_message_init(&m);
> > + spi_message_add_tail(spi_xfer, &m);
> > + ret = spi_sync_locked(phy->spi_device, &m);
> > + if (ret < 0)
> > + return ret;
> > + if (phy->iobuf[0] & 0x01)
> > + break;
> > + }
> > +
> > + if (i == TPM_RETRY)
> > + return -ETIMEDOUT;
> > + }
> > +
> > + return 0;
> > +}
>
> AFAIK the flow control is not part of the SPI standard itself but is
> proprietary for each slave device. Thus, the flow control should be
> documented to the source code. I do not want flow control mechanisms to
> be multiplied before this is done.
Can you clarify this please? I don't understand what "the flow control
should be documented to the source code" means.
>
> The magic number 0x01 would be also good to get rid off.
>
Ok. What name should the #define be? I can make that another patch.
next prev parent reply other threads:[~2019-08-19 17:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-12 22:36 [PATCH v4 0/6] tpm: Add driver for cr50 Stephen Boyd
2019-08-12 22:36 ` [PATCH v4 1/6] tpm: Add a flag to indicate TPM power is managed by firmware Stephen Boyd
2019-08-15 20:34 ` Jarkko Sakkinen
2019-08-12 22:36 ` [PATCH v4 2/6] tpm: tpm_tis_spi: Introduce a flow control callback Stephen Boyd
2019-08-19 16:32 ` Jarkko Sakkinen
2019-08-19 17:06 ` Stephen Boyd [this message]
2019-08-21 18:13 ` Jarkko Sakkinen
2019-08-12 22:36 ` [PATCH v4 3/6] tpm: tpm_tis_spi: Add a pre-transfer callback Stephen Boyd
2019-08-19 16:35 ` Jarkko Sakkinen
2019-08-19 17:07 ` Stephen Boyd
2019-08-21 19:11 ` Jarkko Sakkinen
2019-08-21 21:44 ` Stephen Boyd
2019-08-12 22:36 ` [PATCH v4 4/6] tpm: tpm_tis_spi: Export functionality to other drivers Stephen Boyd
2019-08-19 16:40 ` Jarkko Sakkinen
2019-08-19 17:10 ` Stephen Boyd
2019-08-21 17:58 ` Jarkko Sakkinen
2019-08-22 17:29 ` Stephen Boyd
2019-08-12 22:36 ` [PATCH v4 5/6] dt-bindings: tpm: document properties for cr50 Stephen Boyd
2019-08-12 22:36 ` [PATCH v4 6/6] tpm: add driver for cr50 on SPI Stephen Boyd
2019-08-27 0:58 ` [PATCH v4 0/6] tpm: Add driver for cr50 Heiko Stuebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5d5ad721.1c69fb81.6a514.e649@mx.google.com \
--to=swboyd@chromium.org \
--cc=Alexander.Steffen@infineon.com \
--cc=apronin@chromium.org \
--cc=arnd@arndb.de \
--cc=dlaurie@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=groeck@chromium.org \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=jgg@ziepe.ca \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterhuewe@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).