* [PATCH v2 00/12] tpm/st33zp24: Few code style and sanity fixes + acpi device probing support
@ 2016-02-13 15:15 Christophe Ricard
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
0 siblings, 1 reply; 17+ messages in thread
From: Christophe Ricard @ 2016-02-13 15:15 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA, peterhuewe-Mmb7MZpHnFY
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Hi Peter, Jarko,
Please find in the following serie:
- a set of code style or sanity cleanup
- acpi device probing support for i2c and spi phys.
In v2, i have:
- Added Jarkko review
- Fixed a warning on patch 12
This serie applies on top of jarkko tree:
b64f343cb02b2a2a009b3805a8331425dd4a8611 tpm: fix rollback/cleanup before tpm_chip_register()
Best Regards
Christophe
Christophe Ricard (12):
tpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage
tpm/st33zp24/spi: Use functions name with st33zp24_spi_ prefix
tpm/st33zp24/spi: Remove useless use of memcpy.
tpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy
structure
tpm/st33zp24: Remove unneeded CONFIG_OF switches
tpm/st33zp24: Auto-select core module
tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency
tpm/st33zp24: Extend Copyright headers
tpm/st33zp24: Add support for acpi probing for i2c device.
tpm: st33zp24: Add support for acpi probing for spi device.
tpm/st33zp24/i2c: Change xxx_request_resources header
tpm/st33zp24/spi: Change xxx_request_resources header
drivers/char/tpm/st33zp24/Kconfig | 11 +-
drivers/char/tpm/st33zp24/i2c.c | 76 ++++++++++---
drivers/char/tpm/st33zp24/spi.c | 190 ++++++++++++++++++++-------------
drivers/char/tpm/st33zp24/st33zp24.c | 2 +-
drivers/char/tpm/st33zp24/st33zp24.h | 2 +-
include/linux/platform_data/st33zp24.h | 2 +-
6 files changed, 182 insertions(+), 101 deletions(-)
--
2.5.0
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 01/12] tpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
@ 2016-02-13 15:15 ` Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 02/12] tpm/st33zp24/spi: Use functions name with st33zp24_spi_ prefix Christophe Ricard
` (11 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Christophe Ricard @ 2016-02-13 15:15 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA, peterhuewe-Mmb7MZpHnFY
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
nbr_dummy_bytes variable could be easily replaced by phy->latency in
st33zp24_spi_send and st33zp24_spi_recv.
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/char/tpm/st33zp24/spi.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
index f974c94..74c5fcc 100644
--- a/drivers/char/tpm/st33zp24/spi.c
+++ b/drivers/char/tpm/st33zp24/spi.c
@@ -111,7 +111,7 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data,
int tpm_size)
{
u8 data = 0;
- int total_length = 0, nbr_dummy_bytes = 0, ret = 0;
+ int total_length = 0, ret = 0;
struct st33zp24_spi_phy *phy = phy_id;
struct spi_device *dev = phy->spi_device;
u8 *tx_buf = (u8 *)phy->spi_xfer.tx_buf;
@@ -133,14 +133,13 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data,
memcpy(&tx_buf[total_length], tpm_data, tpm_size);
total_length += tpm_size;
- nbr_dummy_bytes = phy->latency;
- memset(&tx_buf[total_length], TPM_DUMMY_BYTE, nbr_dummy_bytes);
+ memset(&tx_buf[total_length], TPM_DUMMY_BYTE, phy->latency);
- phy->spi_xfer.len = total_length + nbr_dummy_bytes;
+ phy->spi_xfer.len = total_length + phy->latency;
ret = spi_sync_transfer(dev, &phy->spi_xfer, 1);
if (ret == 0)
- ret = rx_buf[total_length + nbr_dummy_bytes - 1];
+ ret = rx_buf[total_length + phy->latency - 1];
return st33zp24_status_to_errno(ret);
} /* st33zp24_spi_send() */
@@ -157,7 +156,7 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data,
static int read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size)
{
u8 data = 0;
- int total_length = 0, nbr_dummy_bytes, ret;
+ int total_length = 0, ret;
struct st33zp24_spi_phy *phy = phy_id;
struct spi_device *dev = phy->spi_device;
u8 *tx_buf = (u8 *)phy->spi_xfer.tx_buf;
@@ -171,18 +170,17 @@ static int read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size)
memcpy(tx_buf + total_length, &data, sizeof(data));
total_length++;
- nbr_dummy_bytes = phy->latency;
memset(&tx_buf[total_length], TPM_DUMMY_BYTE,
- nbr_dummy_bytes + tpm_size);
+ phy->latency + tpm_size);
- phy->spi_xfer.len = total_length + nbr_dummy_bytes + tpm_size;
+ phy->spi_xfer.len = total_length + phy->latency + tpm_size;
/* header + status byte + size of the data + status byte */
ret = spi_sync_transfer(dev, &phy->spi_xfer, 1);
if (tpm_size > 0 && ret == 0) {
- ret = rx_buf[total_length + nbr_dummy_bytes - 1];
+ ret = rx_buf[total_length + phy->latency - 1];
- memcpy(tpm_data, rx_buf + total_length + nbr_dummy_bytes,
+ memcpy(tpm_data, rx_buf + total_length + phy->latency,
tpm_size);
}
--
2.5.0
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 02/12] tpm/st33zp24/spi: Use functions name with st33zp24_spi_ prefix
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-02-13 15:15 ` [PATCH v2 01/12] tpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage Christophe Ricard
@ 2016-02-13 15:15 ` Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 03/12] tpm/st33zp24/spi: Remove useless use of memcpy Christophe Ricard
` (10 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Christophe Ricard @ 2016-02-13 15:15 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA, peterhuewe-Mmb7MZpHnFY
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Make sure every function name use st33zp24_spi_ prefix.
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/char/tpm/st33zp24/spi.c | 45 +++++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
index 74c5fcc..f42c443 100644
--- a/drivers/char/tpm/st33zp24/spi.c
+++ b/drivers/char/tpm/st33zp24/spi.c
@@ -145,7 +145,7 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data,
} /* st33zp24_spi_send() */
/*
- * read8_recv
+ * st33zp24_spi_read8_recv
* Recv byte from the TIS register according to the ST33ZP24 SPI protocol.
* @param: phy_id, the phy description
* @param: tpm_register, the tpm tis register where the data should be read
@@ -153,7 +153,8 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data,
* @param: tpm_size, tpm TPM response size to read.
* @return: should be zero if success else a negative error code.
*/
-static int read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size)
+static int st33zp24_spi_read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data,
+ int tpm_size)
{
u8 data = 0;
int total_length = 0, ret;
@@ -185,7 +186,7 @@ static int read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size)
}
return ret;
-} /* read8_reg() */
+} /* st33zp24_spi_read8_reg() */
/*
* st33zp24_spi_recv
@@ -201,13 +202,13 @@ static int st33zp24_spi_recv(void *phy_id, u8 tpm_register, u8 *tpm_data,
{
int ret;
- ret = read8_reg(phy_id, tpm_register, tpm_data, tpm_size);
+ ret = st33zp24_spi_read8_reg(phy_id, tpm_register, tpm_data, tpm_size);
if (!st33zp24_status_to_errno(ret))
return tpm_size;
return ret;
} /* st33zp24_spi_recv() */
-static int evaluate_latency(void *phy_id)
+static int st33zp24_spi_evaluate_latency(void *phy_id)
{
struct st33zp24_spi_phy *phy = phy_id;
int latency = 1, status = 0;
@@ -215,7 +216,8 @@ static int evaluate_latency(void *phy_id)
while (!status && latency < MAX_SPI_LATENCY) {
phy->latency = latency;
- status = read8_reg(phy_id, TPM_INTF_CAPABILITY, &data, 1);
+ status = st33zp24_spi_read8_reg(phy_id, TPM_INTF_CAPABILITY,
+ &data, 1);
latency++;
}
return latency - 1;
@@ -227,7 +229,7 @@ static const struct st33zp24_phy_ops spi_phy_ops = {
};
#ifdef CONFIG_OF
-static int tpm_stm_spi_of_request_resources(struct st33zp24_spi_phy *phy)
+static int st33zp24_spi_of_request_resources(struct st33zp24_spi_phy *phy)
{
struct device_node *pp;
struct spi_device *dev = phy->spi_device;
@@ -265,14 +267,14 @@ static int tpm_stm_spi_of_request_resources(struct st33zp24_spi_phy *phy)
return 0;
}
#else
-static int tpm_stm_spi_of_request_resources(struct st33zp24_spi_phy *phy)
+static int st33zp24_spi_of_request_resources(struct st33zp24_spi_phy *phy)
{
return -ENODEV;
}
#endif
-static int tpm_stm_spi_request_resources(struct spi_device *dev,
- struct st33zp24_spi_phy *phy)
+static int st33zp24_spi_request_resources(struct spi_device *dev,
+ struct st33zp24_spi_phy *phy)
{
struct st33zp24_platform_data *pdata;
int ret;
@@ -301,13 +303,12 @@ static int tpm_stm_spi_request_resources(struct spi_device *dev,
}
/*
- * tpm_st33_spi_probe initialize the TPM device
+ * st33zp24_spi_probe initialize the TPM device
* @param: dev, the spi_device drescription (TPM SPI description).
* @return: 0 in case of success.
* or a negative value describing the error.
*/
-static int
-tpm_st33_spi_probe(struct spi_device *dev)
+static int st33zp24_spi_probe(struct spi_device *dev)
{
int ret;
struct st33zp24_platform_data *pdata;
@@ -328,11 +329,11 @@ tpm_st33_spi_probe(struct spi_device *dev)
phy->spi_device = dev;
pdata = dev->dev.platform_data;
if (!pdata && dev->dev.of_node) {
- ret = tpm_stm_spi_of_request_resources(phy);
+ ret = st33zp24_spi_of_request_resources(phy);
if (ret)
return ret;
} else if (pdata) {
- ret = tpm_stm_spi_request_resources(dev, phy);
+ ret = st33zp24_spi_request_resources(dev, phy);
if (ret)
return ret;
}
@@ -340,7 +341,7 @@ tpm_st33_spi_probe(struct spi_device *dev)
phy->spi_xfer.tx_buf = phy->tx_buf;
phy->spi_xfer.rx_buf = phy->rx_buf;
- phy->latency = evaluate_latency(phy);
+ phy->latency = st33zp24_spi_evaluate_latency(phy);
if (phy->latency <= 0)
return -ENODEV;
@@ -349,11 +350,11 @@ tpm_st33_spi_probe(struct spi_device *dev)
}
/*
- * tpm_st33_spi_remove remove the TPM device
+ * st33zp24_spi_remove remove the TPM device
* @param: client, the spi_device drescription (TPM SPI description).
* @return: 0 in case of success.
*/
-static int tpm_st33_spi_remove(struct spi_device *dev)
+static int st33zp24_spi_remove(struct spi_device *dev)
{
struct tpm_chip *chip = spi_get_drvdata(dev);
@@ -377,18 +378,18 @@ MODULE_DEVICE_TABLE(of, of_st33zp24_spi_match);
static SIMPLE_DEV_PM_OPS(st33zp24_spi_ops, st33zp24_pm_suspend,
st33zp24_pm_resume);
-static struct spi_driver tpm_st33_spi_driver = {
+static struct spi_driver st33zp24_spi_driver = {
.driver = {
.name = TPM_ST33_SPI,
.pm = &st33zp24_spi_ops,
.of_match_table = of_match_ptr(of_st33zp24_spi_match),
},
- .probe = tpm_st33_spi_probe,
- .remove = tpm_st33_spi_remove,
+ .probe = st33zp24_spi_probe,
+ .remove = st33zp24_spi_remove,
.id_table = st33zp24_spi_id,
};
-module_spi_driver(tpm_st33_spi_driver);
+module_spi_driver(st33zp24_spi_driver);
MODULE_AUTHOR("TPM support (TPMsupport-nkJGhpqTU55BDgjK7y7TUQ@public.gmane.org)");
MODULE_DESCRIPTION("STM TPM 1.2 SPI ST33 Driver");
--
2.5.0
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 03/12] tpm/st33zp24/spi: Remove useless use of memcpy.
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-02-13 15:15 ` [PATCH v2 01/12] tpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 02/12] tpm/st33zp24/spi: Use functions name with st33zp24_spi_ prefix Christophe Ricard
@ 2016-02-13 15:15 ` Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 04/12] tpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy structure Christophe Ricard
` (9 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Christophe Ricard @ 2016-02-13 15:15 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA, peterhuewe-Mmb7MZpHnFY
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
An affectation is enough when copying 1 byte. Remove memcpy usage where
possible.
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/char/tpm/st33zp24/spi.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
index f42c443..08ffbfe 100644
--- a/drivers/char/tpm/st33zp24/spi.c
+++ b/drivers/char/tpm/st33zp24/spi.c
@@ -110,7 +110,6 @@ static int st33zp24_status_to_errno(u8 code)
static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data,
int tpm_size)
{
- u8 data = 0;
int total_length = 0, ret = 0;
struct st33zp24_spi_phy *phy = phy_id;
struct spi_device *dev = phy->spi_device;
@@ -118,12 +117,8 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data,
u8 *rx_buf = phy->spi_xfer.rx_buf;
/* Pre-Header */
- data = TPM_WRITE_DIRECTION | LOCALITY0;
- memcpy(tx_buf + total_length, &data, sizeof(data));
- total_length++;
- data = tpm_register;
- memcpy(tx_buf + total_length, &data, sizeof(data));
- total_length++;
+ tx_buf[total_length++] = TPM_WRITE_DIRECTION | LOCALITY0;
+ tx_buf[total_length++] = tpm_register;
if (tpm_size > 0 && tpm_register == TPM_DATA_FIFO) {
tx_buf[total_length++] = tpm_size >> 8;
@@ -156,7 +151,6 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data,
static int st33zp24_spi_read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data,
int tpm_size)
{
- u8 data = 0;
int total_length = 0, ret;
struct st33zp24_spi_phy *phy = phy_id;
struct spi_device *dev = phy->spi_device;
@@ -164,12 +158,8 @@ static int st33zp24_spi_read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data,
u8 *rx_buf = phy->spi_xfer.rx_buf;
/* Pre-Header */
- data = LOCALITY0;
- memcpy(tx_buf + total_length, &data, sizeof(data));
- total_length++;
- data = tpm_register;
- memcpy(tx_buf + total_length, &data, sizeof(data));
- total_length++;
+ tx_buf[total_length++] = LOCALITY0;
+ tx_buf[total_length++] = tpm_register;
memset(&tx_buf[total_length], TPM_DUMMY_BYTE,
phy->latency + tpm_size);
--
2.5.0
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 04/12] tpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy structure
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (2 preceding siblings ...)
2016-02-13 15:15 ` [PATCH v2 03/12] tpm/st33zp24/spi: Remove useless use of memcpy Christophe Ricard
@ 2016-02-13 15:15 ` Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 05/12] tpm/st33zp24: Remove unneeded CONFIG_OF switches Christophe Ricard
` (8 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Christophe Ricard @ 2016-02-13 15:15 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA, peterhuewe-Mmb7MZpHnFY
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Remove spi_xfer from st33zp24_spi_phy structure and declare local spi_xfer
when needed instead.
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/char/tpm/st33zp24/spi.c | 50 ++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
index 08ffbfe..41c11c9 100644
--- a/drivers/char/tpm/st33zp24/spi.c
+++ b/drivers/char/tpm/st33zp24/spi.c
@@ -66,7 +66,7 @@
struct st33zp24_spi_phy {
struct spi_device *spi_device;
- struct spi_transfer spi_xfer;
+
u8 tx_buf[ST33ZP24_SPI_BUFFER_SIZE];
u8 rx_buf[ST33ZP24_SPI_BUFFER_SIZE];
@@ -113,28 +113,30 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data,
int total_length = 0, ret = 0;
struct st33zp24_spi_phy *phy = phy_id;
struct spi_device *dev = phy->spi_device;
- u8 *tx_buf = (u8 *)phy->spi_xfer.tx_buf;
- u8 *rx_buf = phy->spi_xfer.rx_buf;
+ struct spi_transfer spi_xfer = {
+ .tx_buf = phy->tx_buf,
+ .rx_buf = phy->rx_buf,
+ };
/* Pre-Header */
- tx_buf[total_length++] = TPM_WRITE_DIRECTION | LOCALITY0;
- tx_buf[total_length++] = tpm_register;
+ phy->tx_buf[total_length++] = TPM_WRITE_DIRECTION | LOCALITY0;
+ phy->tx_buf[total_length++] = tpm_register;
if (tpm_size > 0 && tpm_register == TPM_DATA_FIFO) {
- tx_buf[total_length++] = tpm_size >> 8;
- tx_buf[total_length++] = tpm_size;
+ phy->tx_buf[total_length++] = tpm_size >> 8;
+ phy->tx_buf[total_length++] = tpm_size;
}
- memcpy(&tx_buf[total_length], tpm_data, tpm_size);
+ memcpy(&phy->tx_buf[total_length], tpm_data, tpm_size);
total_length += tpm_size;
- memset(&tx_buf[total_length], TPM_DUMMY_BYTE, phy->latency);
+ memset(&phy->tx_buf[total_length], TPM_DUMMY_BYTE, phy->latency);
- phy->spi_xfer.len = total_length + phy->latency;
+ spi_xfer.len = total_length + phy->latency;
- ret = spi_sync_transfer(dev, &phy->spi_xfer, 1);
+ ret = spi_sync_transfer(dev, &spi_xfer, 1);
if (ret == 0)
- ret = rx_buf[total_length + phy->latency - 1];
+ ret = phy->rx_buf[total_length + phy->latency - 1];
return st33zp24_status_to_errno(ret);
} /* st33zp24_spi_send() */
@@ -154,24 +156,25 @@ static int st33zp24_spi_read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data,
int total_length = 0, ret;
struct st33zp24_spi_phy *phy = phy_id;
struct spi_device *dev = phy->spi_device;
- u8 *tx_buf = (u8 *)phy->spi_xfer.tx_buf;
- u8 *rx_buf = phy->spi_xfer.rx_buf;
+ struct spi_transfer spi_xfer = {
+ .tx_buf = phy->tx_buf,
+ .rx_buf = phy->rx_buf,
+ };
/* Pre-Header */
- tx_buf[total_length++] = LOCALITY0;
- tx_buf[total_length++] = tpm_register;
+ phy->tx_buf[total_length++] = LOCALITY0;
+ phy->tx_buf[total_length++] = tpm_register;
- memset(&tx_buf[total_length], TPM_DUMMY_BYTE,
- phy->latency + tpm_size);
+ memset(&phy->tx_buf[total_length], TPM_DUMMY_BYTE, phy->latency + tpm_size);
- phy->spi_xfer.len = total_length + phy->latency + tpm_size;
+ spi_xfer.len = total_length + phy->latency + tpm_size;
/* header + status byte + size of the data + status byte */
- ret = spi_sync_transfer(dev, &phy->spi_xfer, 1);
+ ret = spi_sync_transfer(dev, &spi_xfer, 1);
if (tpm_size > 0 && ret == 0) {
- ret = rx_buf[total_length + phy->latency - 1];
+ ret = phy->rx_buf[total_length + phy->latency - 1];
- memcpy(tpm_data, rx_buf + total_length + phy->latency,
+ memcpy(tpm_data, phy->rx_buf + total_length + phy->latency,
tpm_size);
}
@@ -328,9 +331,6 @@ static int st33zp24_spi_probe(struct spi_device *dev)
return ret;
}
- phy->spi_xfer.tx_buf = phy->tx_buf;
- phy->spi_xfer.rx_buf = phy->rx_buf;
-
phy->latency = st33zp24_spi_evaluate_latency(phy);
if (phy->latency <= 0)
return -ENODEV;
--
2.5.0
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 05/12] tpm/st33zp24: Remove unneeded CONFIG_OF switches
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (3 preceding siblings ...)
2016-02-13 15:15 ` [PATCH v2 04/12] tpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy structure Christophe Ricard
@ 2016-02-13 15:15 ` Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 06/12] tpm/st33zp24: Auto-select core module Christophe Ricard
` (7 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Christophe Ricard @ 2016-02-13 15:15 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA, peterhuewe-Mmb7MZpHnFY
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
DT headers already define NOOP routines when CONFIG_OF is not defined.
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/char/tpm/st33zp24/i2c.c | 9 ---------
drivers/char/tpm/st33zp24/spi.c | 9 ---------
2 files changed, 18 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/i2c.c b/drivers/char/tpm/st33zp24/i2c.c
index 309d276..a05fbd8 100644
--- a/drivers/char/tpm/st33zp24/i2c.c
+++ b/drivers/char/tpm/st33zp24/i2c.c
@@ -108,7 +108,6 @@ static const struct st33zp24_phy_ops i2c_phy_ops = {
.recv = st33zp24_i2c_recv,
};
-#ifdef CONFIG_OF
static int st33zp24_i2c_of_request_resources(struct st33zp24_i2c_phy *phy)
{
struct device_node *pp;
@@ -146,12 +145,6 @@ static int st33zp24_i2c_of_request_resources(struct st33zp24_i2c_phy *phy)
return 0;
}
-#else
-static int st33zp24_i2c_of_request_resources(struct st33zp24_i2c_phy *phy)
-{
- return -ENODEV;
-}
-#endif
static int st33zp24_i2c_request_resources(struct i2c_client *client,
struct st33zp24_i2c_phy *phy)
@@ -245,13 +238,11 @@ static const struct i2c_device_id st33zp24_i2c_id[] = {
};
MODULE_DEVICE_TABLE(i2c, st33zp24_i2c_id);
-#ifdef CONFIG_OF
static const struct of_device_id of_st33zp24_i2c_match[] = {
{ .compatible = "st,st33zp24-i2c", },
{}
};
MODULE_DEVICE_TABLE(of, of_st33zp24_i2c_match);
-#endif
static SIMPLE_DEV_PM_OPS(st33zp24_i2c_ops, st33zp24_pm_suspend,
st33zp24_pm_resume);
diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
index 41c11c9..0af836a 100644
--- a/drivers/char/tpm/st33zp24/spi.c
+++ b/drivers/char/tpm/st33zp24/spi.c
@@ -221,7 +221,6 @@ static const struct st33zp24_phy_ops spi_phy_ops = {
.recv = st33zp24_spi_recv,
};
-#ifdef CONFIG_OF
static int st33zp24_spi_of_request_resources(struct st33zp24_spi_phy *phy)
{
struct device_node *pp;
@@ -259,12 +258,6 @@ static int st33zp24_spi_of_request_resources(struct st33zp24_spi_phy *phy)
return 0;
}
-#else
-static int st33zp24_spi_of_request_resources(struct st33zp24_spi_phy *phy)
-{
- return -ENODEV;
-}
-#endif
static int st33zp24_spi_request_resources(struct spi_device *dev,
struct st33zp24_spi_phy *phy)
@@ -357,13 +350,11 @@ static const struct spi_device_id st33zp24_spi_id[] = {
};
MODULE_DEVICE_TABLE(spi, st33zp24_spi_id);
-#ifdef CONFIG_OF
static const struct of_device_id of_st33zp24_spi_match[] = {
{ .compatible = "st,st33zp24-spi", },
{}
};
MODULE_DEVICE_TABLE(of, of_st33zp24_spi_match);
-#endif
static SIMPLE_DEV_PM_OPS(st33zp24_spi_ops, st33zp24_pm_suspend,
st33zp24_pm_resume);
--
2.5.0
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 06/12] tpm/st33zp24: Auto-select core module
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (4 preceding siblings ...)
2016-02-13 15:15 ` [PATCH v2 05/12] tpm/st33zp24: Remove unneeded CONFIG_OF switches Christophe Ricard
@ 2016-02-13 15:15 ` Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 07/12] tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency Christophe Ricard
` (6 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Christophe Ricard @ 2016-02-13 15:15 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA, peterhuewe-Mmb7MZpHnFY
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
The core st33zp24 module is useless without either the I2C or the
SPI access module. So hide NFC_ST_NCI and select it automatically
if either TCG_TIS_ST33ZP24_I2C or TCG_TIS_ST33ZP24_SPI is selected.
This avoids presenting TCG_TIS_ST33ZP24 when neither TCG_TIS_ST33ZP24_I2C
nor TCG_TIS_ST33ZP24_SPI can be selected.
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/char/tpm/st33zp24/Kconfig | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/Kconfig b/drivers/char/tpm/st33zp24/Kconfig
index 19c0074..e74c6f2 100644
--- a/drivers/char/tpm/st33zp24/Kconfig
+++ b/drivers/char/tpm/st33zp24/Kconfig
@@ -1,6 +1,5 @@
config TCG_TIS_ST33ZP24
- tristate "STMicroelectronics TPM Interface Specification 1.2 Interface"
- depends on GPIOLIB || COMPILE_TEST
+ tristate
---help---
STMicroelectronics ST33ZP24 core driver. It implements the core
TPM1.2 logic and hooks into the TPM kernel APIs. Physical layers will
@@ -10,9 +9,9 @@ config TCG_TIS_ST33ZP24
tpm_st33zp24.
config TCG_TIS_ST33ZP24_I2C
- tristate "TPM 1.2 ST33ZP24 I2C support"
- depends on TCG_TIS_ST33ZP24
+ tristate "STMicroelectronics TPM Interface Specification 1.2 Interface (I2C)"
depends on I2C
+ select TCG_TIS_ST33ZP24
---help---
This module adds support for the STMicroelectronics TPM security chip
ST33ZP24 with i2c interface.
@@ -20,9 +19,9 @@ config TCG_TIS_ST33ZP24_I2C
called tpm_st33zp24_i2c.
config TCG_TIS_ST33ZP24_SPI
- tristate "TPM 1.2 ST33ZP24 SPI support"
- depends on TCG_TIS_ST33ZP24
+ tristate "STMicroelectronics TPM Interface Specification 1.2 Interface (SPI)"
depends on SPI
+ select TCG_TIS_ST33ZP24
---help---
This module adds support for the STMicroelectronics TPM security chip
ST33ZP24 with spi interface.
--
2.5.0
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 07/12] tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (5 preceding siblings ...)
2016-02-13 15:15 ` [PATCH v2 06/12] tpm/st33zp24: Auto-select core module Christophe Ricard
@ 2016-02-13 15:15 ` Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 08/12] tpm/st33zp24: Extend Copyright headers Christophe Ricard
` (5 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Christophe Ricard @ 2016-02-13 15:15 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA, peterhuewe-Mmb7MZpHnFY
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Add check in st33zp24_spi_evaluate_latency helping to diagnose if the chip
is present or in a bad state.
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/char/tpm/st33zp24/spi.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
index 0af836a..7cabf1d 100644
--- a/drivers/char/tpm/st33zp24/spi.c
+++ b/drivers/char/tpm/st33zp24/spi.c
@@ -213,6 +213,11 @@ static int st33zp24_spi_evaluate_latency(void *phy_id)
&data, 1);
latency++;
}
+ if (status < 0)
+ return status;
+ if (latency == MAX_SPI_LATENCY)
+ return -ENODEV;
+
return latency - 1;
} /* evaluate_latency() */
--
2.5.0
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 08/12] tpm/st33zp24: Extend Copyright headers
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (6 preceding siblings ...)
2016-02-13 15:15 ` [PATCH v2 07/12] tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency Christophe Ricard
@ 2016-02-13 15:15 ` Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 09/12] tpm/st33zp24: Add support for acpi probing for i2c device Christophe Ricard
` (4 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Christophe Ricard @ 2016-02-13 15:15 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA, peterhuewe-Mmb7MZpHnFY
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Extend copyright header to 2016
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/char/tpm/st33zp24/i2c.c | 2 +-
drivers/char/tpm/st33zp24/spi.c | 2 +-
drivers/char/tpm/st33zp24/st33zp24.c | 2 +-
drivers/char/tpm/st33zp24/st33zp24.h | 2 +-
include/linux/platform_data/st33zp24.h | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/i2c.c b/drivers/char/tpm/st33zp24/i2c.c
index a05fbd8..a49b6f1 100644
--- a/drivers/char/tpm/st33zp24/i2c.c
+++ b/drivers/char/tpm/st33zp24/i2c.c
@@ -1,6 +1,6 @@
/*
* STMicroelectronics TPM I2C Linux driver for TPM ST33ZP24
- * Copyright (C) 2009 - 2015 STMicroelectronics
+ * Copyright (C) 2009 - 2016 STMicroelectronics
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
index 7cabf1d..34cdee1 100644
--- a/drivers/char/tpm/st33zp24/spi.c
+++ b/drivers/char/tpm/st33zp24/spi.c
@@ -1,6 +1,6 @@
/*
* STMicroelectronics TPM SPI Linux driver for TPM ST33ZP24
- * Copyright (C) 2009 - 2015 STMicroelectronics
+ * Copyright (C) 2009 - 2016 STMicroelectronics
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c
index 8d62678..944d279 100644
--- a/drivers/char/tpm/st33zp24/st33zp24.c
+++ b/drivers/char/tpm/st33zp24/st33zp24.c
@@ -1,6 +1,6 @@
/*
* STMicroelectronics TPM Linux driver for TPM ST33ZP24
- * Copyright (C) 2009 - 2015 STMicroelectronics
+ * Copyright (C) 2009 - 2016 STMicroelectronics
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/drivers/char/tpm/st33zp24/st33zp24.h b/drivers/char/tpm/st33zp24/st33zp24.h
index c207ceb..bcbd5ff 100644
--- a/drivers/char/tpm/st33zp24/st33zp24.h
+++ b/drivers/char/tpm/st33zp24/st33zp24.h
@@ -1,6 +1,6 @@
/*
* STMicroelectronics TPM Linux driver for TPM ST33ZP24
- * Copyright (C) 2009 - 2015 STMicroelectronics
+ * Copyright (C) 2009 - 2016 STMicroelectronics
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
diff --git a/include/linux/platform_data/st33zp24.h b/include/linux/platform_data/st33zp24.h
index 817dfdb..6f0fb6e 100644
--- a/include/linux/platform_data/st33zp24.h
+++ b/include/linux/platform_data/st33zp24.h
@@ -1,6 +1,6 @@
/*
* STMicroelectronics TPM Linux driver for TPM 1.2 ST33ZP24
- * Copyright (C) 2009 - 2015 STMicroelectronics
+ * Copyright (C) 2009 - 2016 STMicroelectronics
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
--
2.5.0
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 09/12] tpm/st33zp24: Add support for acpi probing for i2c device.
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (7 preceding siblings ...)
2016-02-13 15:15 ` [PATCH v2 08/12] tpm/st33zp24: Extend Copyright headers Christophe Ricard
@ 2016-02-13 15:15 ` Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 10/12] tpm: st33zp24: Add support for acpi probing for spi device Christophe Ricard
` (3 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Christophe Ricard @ 2016-02-13 15:15 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA, peterhuewe-Mmb7MZpHnFY
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Add support for acpi probing. SMO3324 is used for st33zp24.
It has been tested with the following acpi node on Minnowboard:
Device (TPM1)
{
Name (_ADR, Zero) // _ADR: Address
Name (_HID, "SMO3324") // _HID: Hardware ID
Name (_CID, "SMO3324") // _CID: Compatible ID
Name (_DDN, "SMO TPM") // _DDN: DOS Device Name
Name (_UID, One) // _UID: Unique ID
Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings
{
Name (SBUF, ResourceTemplate ()
{
I2cSerialBus (0x0013, ControllerInitiated, 400000,
AddressingMode7Bit, "\\_SB.I2C7",
0x00, ResourceConsumer, ,)
GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
"\\_SB.GPO2", 0x00, ResourceConsumer, ,)
{ // Pin list
0x0001
}
GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
"\\_SB.GPO2", 0x00, ResourceConsumer, ,)
{ // Pin list
0x0002,
}
})
Return (SBUF) /* \_SB_.I2C7.TPM1._CRS.SBUF */
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
Return (0x0F)
}
}
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/char/tpm/st33zp24/i2c.c | 50 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/drivers/char/tpm/st33zp24/i2c.c b/drivers/char/tpm/st33zp24/i2c.c
index a49b6f1..b20cc2b 100644
--- a/drivers/char/tpm/st33zp24/i2c.c
+++ b/drivers/char/tpm/st33zp24/i2c.c
@@ -19,8 +19,10 @@
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/of_irq.h>
#include <linux/of_gpio.h>
+#include <linux/acpi.h>
#include <linux/tpm.h>
#include <linux/platform_data/st33zp24.h>
@@ -108,6 +110,43 @@ static const struct st33zp24_phy_ops i2c_phy_ops = {
.recv = st33zp24_i2c_recv,
};
+static int st33zp24_i2c_acpi_request_resources(struct st33zp24_i2c_phy *phy)
+{
+ struct i2c_client *client = phy->client;
+ const struct acpi_device_id *id;
+ struct gpio_desc *gpiod_lpcpd;
+ struct device *dev;
+
+ if (!client)
+ return -EINVAL;
+
+ dev = &client->dev;
+
+ /* Match the struct device against a given list of ACPI IDs */
+ id = acpi_match_device(dev->driver->acpi_match_table, dev);
+ if (!id)
+ return -ENODEV;
+
+ /* Get LPCPD GPIO from ACPI */
+ gpiod_lpcpd = devm_gpiod_get_index(dev, "TPM IO LPCPD", 1,
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(gpiod_lpcpd)) {
+ dev_err(&client->dev,
+ "Failed to retrieve lpcpd-gpios from acpi.\n");
+ phy->io_lpcpd = -1;
+ /*
+ * lpcpd pin is not specified. This is not an issue as
+ * power management can be also managed by TPM specific
+ * commands. So leave with a success status code.
+ */
+ return 0;
+ }
+
+ phy->io_lpcpd = desc_to_gpio(gpiod_lpcpd);
+
+ return 0;
+}
+
static int st33zp24_i2c_of_request_resources(struct st33zp24_i2c_phy *phy)
{
struct device_node *pp;
@@ -214,6 +253,10 @@ static int st33zp24_i2c_probe(struct i2c_client *client,
ret = st33zp24_i2c_request_resources(client, phy);
if (ret)
return ret;
+ } else if (ACPI_HANDLE(&client->dev)) {
+ ret = st33zp24_i2c_acpi_request_resources(phy);
+ if (ret)
+ return ret;
}
return st33zp24_probe(phy, &i2c_phy_ops, &client->dev, client->irq,
@@ -244,6 +287,12 @@ static const struct of_device_id of_st33zp24_i2c_match[] = {
};
MODULE_DEVICE_TABLE(of, of_st33zp24_i2c_match);
+static const struct acpi_device_id st33zp24_i2c_acpi_match[] = {
+ {"SMO3324"},
+ {}
+};
+MODULE_DEVICE_TABLE(acpi, st33zp24_i2c_acpi_match);
+
static SIMPLE_DEV_PM_OPS(st33zp24_i2c_ops, st33zp24_pm_suspend,
st33zp24_pm_resume);
@@ -252,6 +301,7 @@ static struct i2c_driver st33zp24_i2c_driver = {
.name = TPM_ST33_I2C,
.pm = &st33zp24_i2c_ops,
.of_match_table = of_match_ptr(of_st33zp24_i2c_match),
+ .acpi_match_table = ACPI_PTR(st33zp24_i2c_acpi_match),
},
.probe = st33zp24_i2c_probe,
.remove = st33zp24_i2c_remove,
--
2.5.0
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 10/12] tpm: st33zp24: Add support for acpi probing for spi device.
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (8 preceding siblings ...)
2016-02-13 15:15 ` [PATCH v2 09/12] tpm/st33zp24: Add support for acpi probing for i2c device Christophe Ricard
@ 2016-02-13 15:15 ` Christophe Ricard
[not found] ` <1455376535-9549-11-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-02-13 15:15 ` [PATCH v2 11/12] tpm/st33zp24/i2c: Change xxx_request_resources header Christophe Ricard
` (2 subsequent siblings)
12 siblings, 1 reply; 17+ messages in thread
From: Christophe Ricard @ 2016-02-13 15:15 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA, peterhuewe-Mmb7MZpHnFY
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Add support for acpi probing. SMO3324 is used for st33zp24.
It has been tested with the following acpi node on Minnowboard:
Device (TPM1)
{
Name (_ADR, Zero) // _ADR: Address
Name (_HID, "SMO3324") // _HID: Hardware ID
Name (_CID, "SMO3324") // _CID: Compatible ID
Name (_DDN, "SMO TPM") // _DDN: DOS Device Name
Name (_UID, One) // _UID: Unique ID
Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings
{
Name (SBUF, ResourceTemplate ()
{
SpiSerialBus (0, PolarityLow, FourWireMode, 8,
ControllerInitiated, 10000000, ClockPolarityLow,
ClockPhaseFirst, "\\_SB.SPI1",
0x00, ResourceConsumer, ,)
GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
"\\_SB.GPO2", 0x00, ResourceConsumer, ,)
{ // Pin list
0x0001
}
GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
"\\_SB.GPO2", 0x00, ResourceConsumer, ,)
{ // Pin list
0x0002,
}
})
Return (SBUF) /* \_SB_.SPI1.TPM1._CRS.SBUF */
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
Return (0x0F)
}
}
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/char/tpm/st33zp24/spi.c | 50 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
index 34cdee1..b9b74ae 100644
--- a/drivers/char/tpm/st33zp24/spi.c
+++ b/drivers/char/tpm/st33zp24/spi.c
@@ -19,8 +19,10 @@
#include <linux/module.h>
#include <linux/spi/spi.h>
#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/of_irq.h>
#include <linux/of_gpio.h>
+#include <linux/acpi.h>
#include <linux/tpm.h>
#include <linux/platform_data/st33zp24.h>
@@ -226,6 +228,43 @@ static const struct st33zp24_phy_ops spi_phy_ops = {
.recv = st33zp24_spi_recv,
};
+static int st33zp24_spi_acpi_request_resources(struct st33zp24_i2c_phy *phy)
+{
+ struct spi_device *spi_dev = phy->spi_device;
+ const struct acpi_device_id *id;
+ struct gpio_desc *gpiod_lpcpd;
+ struct device *dev;
+
+ if (!spi_dev)
+ return -EINVAL;
+
+ dev = &spi_dev->dev;
+
+ /* Match the struct device against a given list of ACPI IDs */
+ id = acpi_match_device(dev->driver->acpi_match_table, dev);
+ if (!id)
+ return -ENODEV;
+
+ /* Get LPCPD GPIO from ACPI */
+ gpiod_lpcpd = devm_gpiod_get_index(dev, "TPM IO LPCPD", 1,
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(gpiod_lpcpd)) {
+ dev_err(&client->dev,
+ "Failed to retrieve lpcpd-gpios from acpi.\n");
+ phy->io_lpcpd = -1;
+ /*
+ * lpcpd pin is not specified. This is not an issue as
+ * power management can be also managed by TPM specific
+ * commands. So leave with a success status code.
+ */
+ return 0;
+ }
+
+ phy->io_lpcpd = desc_to_gpio(gpiod_lpcpd);
+
+ return 0;
+}
+
static int st33zp24_spi_of_request_resources(struct st33zp24_spi_phy *phy)
{
struct device_node *pp;
@@ -327,6 +366,10 @@ static int st33zp24_spi_probe(struct spi_device *dev)
ret = st33zp24_spi_request_resources(dev, phy);
if (ret)
return ret;
+ } else if (ACPI_HANDLE(&dev->dev)) {
+ ret = st33zp24_spi_acpi_request_resources(phy);
+ if (ret)
+ return ret;
}
phy->latency = st33zp24_spi_evaluate_latency(phy);
@@ -361,6 +404,12 @@ static const struct of_device_id of_st33zp24_spi_match[] = {
};
MODULE_DEVICE_TABLE(of, of_st33zp24_spi_match);
+static const struct acpi_device_id st33zp24_spi_acpi_match[] = {
+ {"SMO3324"},
+ {}
+};
+MODULE_DEVICE_TABLE(acpi, st33zp24_spi_acpi_match);
+
static SIMPLE_DEV_PM_OPS(st33zp24_spi_ops, st33zp24_pm_suspend,
st33zp24_pm_resume);
@@ -369,6 +418,7 @@ static struct spi_driver st33zp24_spi_driver = {
.name = TPM_ST33_SPI,
.pm = &st33zp24_spi_ops,
.of_match_table = of_match_ptr(of_st33zp24_spi_match),
+ .acpi_match_table = ACPI_PTR(st33zp24_spi_acpi_match),
},
.probe = st33zp24_spi_probe,
.remove = st33zp24_spi_remove,
--
2.5.0
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 11/12] tpm/st33zp24/i2c: Change xxx_request_resources header
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (9 preceding siblings ...)
2016-02-13 15:15 ` [PATCH v2 10/12] tpm: st33zp24: Add support for acpi probing for spi device Christophe Ricard
@ 2016-02-13 15:15 ` Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 12/12] tpm/st33zp24/spi: " Christophe Ricard
2016-02-22 23:56 ` [PATCH v2 00/12] tpm/st33zp24: Few code style and sanity fixes + acpi device probing support Jarkko Sakkinen
12 siblings, 0 replies; 17+ messages in thread
From: Christophe Ricard @ 2016-02-13 15:15 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA, peterhuewe-Mmb7MZpHnFY
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Simplify st33zp24_i2c_acpi_request_resources, st33zp24_i2c_of_request_resources
and st33zp24_i2c_request_resources to have the same prototype and using
i2c_get_clientdata.
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/char/tpm/st33zp24/i2c.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/i2c.c b/drivers/char/tpm/st33zp24/i2c.c
index b20cc2b..f179aad 100644
--- a/drivers/char/tpm/st33zp24/i2c.c
+++ b/drivers/char/tpm/st33zp24/i2c.c
@@ -110,9 +110,9 @@ static const struct st33zp24_phy_ops i2c_phy_ops = {
.recv = st33zp24_i2c_recv,
};
-static int st33zp24_i2c_acpi_request_resources(struct st33zp24_i2c_phy *phy)
+static int st33zp24_i2c_acpi_request_resources(struct i2c_client *client)
{
- struct i2c_client *client = phy->client;
+ struct st33zp24_i2c_phy *phy = i2c_get_clientdata(client);
const struct acpi_device_id *id;
struct gpio_desc *gpiod_lpcpd;
struct device *dev;
@@ -147,10 +147,10 @@ static int st33zp24_i2c_acpi_request_resources(struct st33zp24_i2c_phy *phy)
return 0;
}
-static int st33zp24_i2c_of_request_resources(struct st33zp24_i2c_phy *phy)
+static int st33zp24_i2c_of_request_resources(struct i2c_client *client)
{
+ struct st33zp24_i2c_phy *phy = i2c_get_clientdata(client);
struct device_node *pp;
- struct i2c_client *client = phy->client;
int gpio;
int ret;
@@ -185,10 +185,10 @@ static int st33zp24_i2c_of_request_resources(struct st33zp24_i2c_phy *phy)
return 0;
}
-static int st33zp24_i2c_request_resources(struct i2c_client *client,
- struct st33zp24_i2c_phy *phy)
+static int st33zp24_i2c_request_resources(struct i2c_client *client)
{
struct st33zp24_platform_data *pdata;
+ struct st33zp24_i2c_phy *phy = i2c_get_clientdata(client);
int ret;
pdata = client->dev.platform_data;
@@ -244,17 +244,20 @@ static int st33zp24_i2c_probe(struct i2c_client *client,
return -ENOMEM;
phy->client = client;
+
+ i2c_set_clientdata(client, phy);
+
pdata = client->dev.platform_data;
if (!pdata && client->dev.of_node) {
- ret = st33zp24_i2c_of_request_resources(phy);
+ ret = st33zp24_i2c_of_request_resources(client);
if (ret)
return ret;
} else if (pdata) {
- ret = st33zp24_i2c_request_resources(client, phy);
+ ret = st33zp24_i2c_request_resources(client);
if (ret)
return ret;
} else if (ACPI_HANDLE(&client->dev)) {
- ret = st33zp24_i2c_acpi_request_resources(phy);
+ ret = st33zp24_i2c_acpi_request_resources(client);
if (ret)
return ret;
}
--
2.5.0
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 12/12] tpm/st33zp24/spi: Change xxx_request_resources header
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (10 preceding siblings ...)
2016-02-13 15:15 ` [PATCH v2 11/12] tpm/st33zp24/i2c: Change xxx_request_resources header Christophe Ricard
@ 2016-02-13 15:15 ` Christophe Ricard
2016-02-22 23:56 ` [PATCH v2 00/12] tpm/st33zp24: Few code style and sanity fixes + acpi device probing support Jarkko Sakkinen
12 siblings, 0 replies; 17+ messages in thread
From: Christophe Ricard @ 2016-02-13 15:15 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA, peterhuewe-Mmb7MZpHnFY
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Simplify st33zp24_spi_acpi_request_resources, st33zp24_spi_of_request_resources
and st33zp24_spi_request_resources to have the same prototype and using
spi_get_drvdata.
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/char/tpm/st33zp24/spi.c | 33 ++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
index b9b74ae..ded0859 100644
--- a/drivers/char/tpm/st33zp24/spi.c
+++ b/drivers/char/tpm/st33zp24/spi.c
@@ -228,9 +228,9 @@ static const struct st33zp24_phy_ops spi_phy_ops = {
.recv = st33zp24_spi_recv,
};
-static int st33zp24_spi_acpi_request_resources(struct st33zp24_i2c_phy *phy)
+static int st33zp24_spi_acpi_request_resources(struct spi_device *spi_dev)
{
- struct spi_device *spi_dev = phy->spi_device;
+ struct st33zp24_spi_phy *phy = spi_get_drvdata(spi_dev);
const struct acpi_device_id *id;
struct gpio_desc *gpiod_lpcpd;
struct device *dev;
@@ -249,7 +249,7 @@ static int st33zp24_spi_acpi_request_resources(struct st33zp24_i2c_phy *phy)
gpiod_lpcpd = devm_gpiod_get_index(dev, "TPM IO LPCPD", 1,
GPIOD_OUT_HIGH);
if (IS_ERR(gpiod_lpcpd)) {
- dev_err(&client->dev,
+ dev_err(dev,
"Failed to retrieve lpcpd-gpios from acpi.\n");
phy->io_lpcpd = -1;
/*
@@ -265,23 +265,23 @@ static int st33zp24_spi_acpi_request_resources(struct st33zp24_i2c_phy *phy)
return 0;
}
-static int st33zp24_spi_of_request_resources(struct st33zp24_spi_phy *phy)
+static int st33zp24_spi_of_request_resources(struct spi_device *spi_dev)
{
+ struct st33zp24_spi_phy *phy = spi_get_drvdata(spi_dev);
struct device_node *pp;
- struct spi_device *dev = phy->spi_device;
int gpio;
int ret;
- pp = dev->dev.of_node;
+ pp = spi_dev->dev.of_node;
if (!pp) {
- dev_err(&dev->dev, "No platform data\n");
+ dev_err(&spi_dev->dev, "No platform data\n");
return -ENODEV;
}
/* Get GPIO from device tree */
gpio = of_get_named_gpio(pp, "lpcpd-gpios", 0);
if (gpio < 0) {
- dev_err(&dev->dev,
+ dev_err(&spi_dev->dev,
"Failed to retrieve lpcpd-gpios from dts.\n");
phy->io_lpcpd = -1;
/*
@@ -292,10 +292,10 @@ static int st33zp24_spi_of_request_resources(struct st33zp24_spi_phy *phy)
return 0;
}
/* GPIO request and configuration */
- ret = devm_gpio_request_one(&dev->dev, gpio,
+ ret = devm_gpio_request_one(&spi_dev->dev, gpio,
GPIOF_OUT_INIT_HIGH, "TPM IO LPCPD");
if (ret) {
- dev_err(&dev->dev, "Failed to request lpcpd pin\n");
+ dev_err(&spi_dev->dev, "Failed to request lpcpd pin\n");
return -ENODEV;
}
phy->io_lpcpd = gpio;
@@ -303,9 +303,9 @@ static int st33zp24_spi_of_request_resources(struct st33zp24_spi_phy *phy)
return 0;
}
-static int st33zp24_spi_request_resources(struct spi_device *dev,
- struct st33zp24_spi_phy *phy)
+static int st33zp24_spi_request_resources(struct spi_device *dev)
{
+ struct st33zp24_spi_phy *phy = spi_get_drvdata(dev);
struct st33zp24_platform_data *pdata;
int ret;
@@ -357,17 +357,20 @@ static int st33zp24_spi_probe(struct spi_device *dev)
return -ENOMEM;
phy->spi_device = dev;
+
+ spi_set_drvdata(dev, phy);
+
pdata = dev->dev.platform_data;
if (!pdata && dev->dev.of_node) {
- ret = st33zp24_spi_of_request_resources(phy);
+ ret = st33zp24_spi_of_request_resources(dev);
if (ret)
return ret;
} else if (pdata) {
- ret = st33zp24_spi_request_resources(dev, phy);
+ ret = st33zp24_spi_request_resources(dev);
if (ret)
return ret;
} else if (ACPI_HANDLE(&dev->dev)) {
- ret = st33zp24_spi_acpi_request_resources(phy);
+ ret = st33zp24_spi_acpi_request_resources(dev);
if (ret)
return ret;
}
--
2.5.0
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v2 10/12] tpm: st33zp24: Add support for acpi probing for spi device.
[not found] ` <1455376535-9549-11-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
@ 2016-02-22 15:57 ` Jarkko Sakkinen
0 siblings, 0 replies; 17+ messages in thread
From: Jarkko Sakkinen @ 2016-02-22 15:57 UTC (permalink / raw)
To: Christophe Ricard
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
On Sat, Feb 13, 2016 at 04:15:33PM +0100, Christophe Ricard wrote:
> Add support for acpi probing. SMO3324 is used for st33zp24.
> It has been tested with the following acpi node on Minnowboard:
>
> Device (TPM1)
> {
> Name (_ADR, Zero) // _ADR: Address
> Name (_HID, "SMO3324") // _HID: Hardware ID
> Name (_CID, "SMO3324") // _CID: Compatible ID
> Name (_DDN, "SMO TPM") // _DDN: DOS Device Name
> Name (_UID, One) // _UID: Unique ID
> Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings
> {
> Name (SBUF, ResourceTemplate ()
> {
> SpiSerialBus (0, PolarityLow, FourWireMode, 8,
> ControllerInitiated, 10000000, ClockPolarityLow,
> ClockPhaseFirst, "\\_SB.SPI1",
> 0x00, ResourceConsumer, ,)
> GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
> "\\_SB.GPO2", 0x00, ResourceConsumer, ,)
> { // Pin list
> 0x0001
> }
> GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
> "\\_SB.GPO2", 0x00, ResourceConsumer, ,)
> { // Pin list
> 0x0002,
> }
> })
> Return (SBUF) /* \_SB_.SPI1.TPM1._CRS.SBUF */
> }
> Method (_STA, 0, NotSerialized) // _STA: Status
> {
> Return (0x0F)
> }
> }
>
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
Not applied this patch yet because I'm still trying to get my hands on
the regular Minnowboard (not MAX). Tested-by's are greatly appreciated
for this patch.
I hope I get one this week so I can add my Tested-by.
/Jarkko
> ---
> drivers/char/tpm/st33zp24/spi.c | 50 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
>
> diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
> index 34cdee1..b9b74ae 100644
> --- a/drivers/char/tpm/st33zp24/spi.c
> +++ b/drivers/char/tpm/st33zp24/spi.c
> @@ -19,8 +19,10 @@
> #include <linux/module.h>
> #include <linux/spi/spi.h>
> #include <linux/gpio.h>
> +#include <linux/gpio/consumer.h>
> #include <linux/of_irq.h>
> #include <linux/of_gpio.h>
> +#include <linux/acpi.h>
> #include <linux/tpm.h>
> #include <linux/platform_data/st33zp24.h>
>
> @@ -226,6 +228,43 @@ static const struct st33zp24_phy_ops spi_phy_ops = {
> .recv = st33zp24_spi_recv,
> };
>
> +static int st33zp24_spi_acpi_request_resources(struct st33zp24_i2c_phy *phy)
> +{
> + struct spi_device *spi_dev = phy->spi_device;
> + const struct acpi_device_id *id;
> + struct gpio_desc *gpiod_lpcpd;
> + struct device *dev;
> +
> + if (!spi_dev)
> + return -EINVAL;
> +
> + dev = &spi_dev->dev;
> +
> + /* Match the struct device against a given list of ACPI IDs */
> + id = acpi_match_device(dev->driver->acpi_match_table, dev);
> + if (!id)
> + return -ENODEV;
> +
> + /* Get LPCPD GPIO from ACPI */
> + gpiod_lpcpd = devm_gpiod_get_index(dev, "TPM IO LPCPD", 1,
> + GPIOD_OUT_HIGH);
> + if (IS_ERR(gpiod_lpcpd)) {
> + dev_err(&client->dev,
> + "Failed to retrieve lpcpd-gpios from acpi.\n");
> + phy->io_lpcpd = -1;
> + /*
> + * lpcpd pin is not specified. This is not an issue as
> + * power management can be also managed by TPM specific
> + * commands. So leave with a success status code.
> + */
> + return 0;
> + }
> +
> + phy->io_lpcpd = desc_to_gpio(gpiod_lpcpd);
> +
> + return 0;
> +}
> +
> static int st33zp24_spi_of_request_resources(struct st33zp24_spi_phy *phy)
> {
> struct device_node *pp;
> @@ -327,6 +366,10 @@ static int st33zp24_spi_probe(struct spi_device *dev)
> ret = st33zp24_spi_request_resources(dev, phy);
> if (ret)
> return ret;
> + } else if (ACPI_HANDLE(&dev->dev)) {
> + ret = st33zp24_spi_acpi_request_resources(phy);
> + if (ret)
> + return ret;
> }
>
> phy->latency = st33zp24_spi_evaluate_latency(phy);
> @@ -361,6 +404,12 @@ static const struct of_device_id of_st33zp24_spi_match[] = {
> };
> MODULE_DEVICE_TABLE(of, of_st33zp24_spi_match);
>
> +static const struct acpi_device_id st33zp24_spi_acpi_match[] = {
> + {"SMO3324"},
> + {}
> +};
> +MODULE_DEVICE_TABLE(acpi, st33zp24_spi_acpi_match);
> +
> static SIMPLE_DEV_PM_OPS(st33zp24_spi_ops, st33zp24_pm_suspend,
> st33zp24_pm_resume);
>
> @@ -369,6 +418,7 @@ static struct spi_driver st33zp24_spi_driver = {
> .name = TPM_ST33_SPI,
> .pm = &st33zp24_spi_ops,
> .of_match_table = of_match_ptr(of_st33zp24_spi_match),
> + .acpi_match_table = ACPI_PTR(st33zp24_spi_acpi_match),
> },
> .probe = st33zp24_spi_probe,
> .remove = st33zp24_spi_remove,
> --
> 2.5.0
>
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 00/12] tpm/st33zp24: Few code style and sanity fixes + acpi device probing support
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (11 preceding siblings ...)
2016-02-13 15:15 ` [PATCH v2 12/12] tpm/st33zp24/spi: " Christophe Ricard
@ 2016-02-22 23:56 ` Jarkko Sakkinen
[not found] ` <20160222235639.GA7721-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
12 siblings, 1 reply; 17+ messages in thread
From: Jarkko Sakkinen @ 2016-02-22 23:56 UTC (permalink / raw)
To: Christophe Ricard
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
On Sat, Feb 13, 2016 at 04:15:23PM +0100, Christophe Ricard wrote:
> Hi Peter, Jarko,
>
> Please find in the following serie:
> - a set of code style or sanity cleanup
> - acpi device probing support for i2c and spi phys.
>
> In v2, i have:
> - Added Jarkko review
> - Fixed a warning on patch 12
>
> This serie applies on top of jarkko tree:
> b64f343cb02b2a2a009b3805a8331425dd4a8611 tpm: fix rollback/cleanup before tpm_chip_register()
I've now applied the patches to my master branch:
* All of them have my Reviewed-by. For one patch I had to fix one style
error (one line was of over 80 characters).
* Two of the patches have my Tested-by.
Now I'm trying to get a Minnowboard so that I could test ACPI probing
for I2C/SPI device. If that would work, then this seres would be ready
for a pull request.
Can you check quickly check the applied patches to make sure that I
didn't mess anything up? And perhaps compile my master and see if
things work at run-time as well?
> Best Regards
> Christophe
/Jarkko
>
> Christophe Ricard (12):
> tpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage
> tpm/st33zp24/spi: Use functions name with st33zp24_spi_ prefix
> tpm/st33zp24/spi: Remove useless use of memcpy.
> tpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy
> structure
> tpm/st33zp24: Remove unneeded CONFIG_OF switches
> tpm/st33zp24: Auto-select core module
> tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency
> tpm/st33zp24: Extend Copyright headers
> tpm/st33zp24: Add support for acpi probing for i2c device.
> tpm: st33zp24: Add support for acpi probing for spi device.
> tpm/st33zp24/i2c: Change xxx_request_resources header
> tpm/st33zp24/spi: Change xxx_request_resources header
>
> drivers/char/tpm/st33zp24/Kconfig | 11 +-
> drivers/char/tpm/st33zp24/i2c.c | 76 ++++++++++---
> drivers/char/tpm/st33zp24/spi.c | 190 ++++++++++++++++++++-------------
> drivers/char/tpm/st33zp24/st33zp24.c | 2 +-
> drivers/char/tpm/st33zp24/st33zp24.h | 2 +-
> include/linux/platform_data/st33zp24.h | 2 +-
> 6 files changed, 182 insertions(+), 101 deletions(-)
>
> --
> 2.5.0
>
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 00/12] tpm/st33zp24: Few code style and sanity fixes + acpi device probing support
[not found] ` <20160222235639.GA7721-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2016-02-25 7:48 ` Christophe Ricard
[not found] ` <56CEB1DA.4020709-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 17+ messages in thread
From: Christophe Ricard @ 2016-02-25 7:48 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Hi Jarkko,
I have checked your tree and sent a v3 fixing patch 10 and 12.
Best Regards
Christophe
On 23/02/2016 00:56, Jarkko Sakkinen wrote:
> On Sat, Feb 13, 2016 at 04:15:23PM +0100, Christophe Ricard wrote:
>> Hi Peter, Jarko,
>>
>> Please find in the following serie:
>> - a set of code style or sanity cleanup
>> - acpi device probing support for i2c and spi phys.
>>
>> In v2, i have:
>> - Added Jarkko review
>> - Fixed a warning on patch 12
>>
>> This serie applies on top of jarkko tree:
>> b64f343cb02b2a2a009b3805a8331425dd4a8611 tpm: fix rollback/cleanup before tpm_chip_register()
> I've now applied the patches to my master branch:
>
> * All of them have my Reviewed-by. For one patch I had to fix one style
> error (one line was of over 80 characters).
> * Two of the patches have my Tested-by.
>
> Now I'm trying to get a Minnowboard so that I could test ACPI probing
> for I2C/SPI device. If that would work, then this seres would be ready
> for a pull request.
>
> Can you check quickly check the applied patches to make sure that I
> didn't mess anything up? And perhaps compile my master and see if
> things work at run-time as well?
>
>> Best Regards
>> Christophe
> /Jarkko
>
>> Christophe Ricard (12):
>> tpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage
>> tpm/st33zp24/spi: Use functions name with st33zp24_spi_ prefix
>> tpm/st33zp24/spi: Remove useless use of memcpy.
>> tpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy
>> structure
>> tpm/st33zp24: Remove unneeded CONFIG_OF switches
>> tpm/st33zp24: Auto-select core module
>> tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency
>> tpm/st33zp24: Extend Copyright headers
>> tpm/st33zp24: Add support for acpi probing for i2c device.
>> tpm: st33zp24: Add support for acpi probing for spi device.
>> tpm/st33zp24/i2c: Change xxx_request_resources header
>> tpm/st33zp24/spi: Change xxx_request_resources header
>>
>> drivers/char/tpm/st33zp24/Kconfig | 11 +-
>> drivers/char/tpm/st33zp24/i2c.c | 76 ++++++++++---
>> drivers/char/tpm/st33zp24/spi.c | 190 ++++++++++++++++++++-------------
>> drivers/char/tpm/st33zp24/st33zp24.c | 2 +-
>> drivers/char/tpm/st33zp24/st33zp24.h | 2 +-
>> include/linux/platform_data/st33zp24.h | 2 +-
>> 6 files changed, 182 insertions(+), 101 deletions(-)
>>
>> --
>> 2.5.0
>>
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 00/12] tpm/st33zp24: Few code style and sanity fixes + acpi device probing support
[not found] ` <56CEB1DA.4020709-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-02-25 13:18 ` Jarkko Sakkinen
0 siblings, 0 replies; 17+ messages in thread
From: Jarkko Sakkinen @ 2016-02-25 13:18 UTC (permalink / raw)
To: Christophe Ricard
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
On Thu, Feb 25, 2016 at 08:48:42AM +0100, Christophe Ricard wrote:
> Hi Jarkko,
>
> I have checked your tree and sent a v3 fixing patch 10 and 12.
They are applied.
/Jarkko
>
> Best Regards
> Christophe
>
> On 23/02/2016 00:56, Jarkko Sakkinen wrote:
> >On Sat, Feb 13, 2016 at 04:15:23PM +0100, Christophe Ricard wrote:
> >>Hi Peter, Jarko,
> >>
> >>Please find in the following serie:
> >>- a set of code style or sanity cleanup
> >>- acpi device probing support for i2c and spi phys.
> >>
> >>In v2, i have:
> >>- Added Jarkko review
> >>- Fixed a warning on patch 12
> >>
> >>This serie applies on top of jarkko tree:
> >>b64f343cb02b2a2a009b3805a8331425dd4a8611 tpm: fix rollback/cleanup before tpm_chip_register()
> >I've now applied the patches to my master branch:
> >
> >* All of them have my Reviewed-by. For one patch I had to fix one style
> > error (one line was of over 80 characters).
> >* Two of the patches have my Tested-by.
> >
> >Now I'm trying to get a Minnowboard so that I could test ACPI probing
> >for I2C/SPI device. If that would work, then this seres would be ready
> >for a pull request.
> >
> >Can you check quickly check the applied patches to make sure that I
> >didn't mess anything up? And perhaps compile my master and see if
> >things work at run-time as well?
> >
> >>Best Regards
> >>Christophe
> >/Jarkko
> >
> >>Christophe Ricard (12):
> >> tpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage
> >> tpm/st33zp24/spi: Use functions name with st33zp24_spi_ prefix
> >> tpm/st33zp24/spi: Remove useless use of memcpy.
> >> tpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy
> >> structure
> >> tpm/st33zp24: Remove unneeded CONFIG_OF switches
> >> tpm/st33zp24: Auto-select core module
> >> tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency
> >> tpm/st33zp24: Extend Copyright headers
> >> tpm/st33zp24: Add support for acpi probing for i2c device.
> >> tpm: st33zp24: Add support for acpi probing for spi device.
> >> tpm/st33zp24/i2c: Change xxx_request_resources header
> >> tpm/st33zp24/spi: Change xxx_request_resources header
> >>
> >> drivers/char/tpm/st33zp24/Kconfig | 11 +-
> >> drivers/char/tpm/st33zp24/i2c.c | 76 ++++++++++---
> >> drivers/char/tpm/st33zp24/spi.c | 190 ++++++++++++++++++++-------------
> >> drivers/char/tpm/st33zp24/st33zp24.c | 2 +-
> >> drivers/char/tpm/st33zp24/st33zp24.h | 2 +-
> >> include/linux/platform_data/st33zp24.h | 2 +-
> >> 6 files changed, 182 insertions(+), 101 deletions(-)
> >>
> >>--
> >>2.5.0
> >>
>
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2016-02-25 13:18 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-13 15:15 [PATCH v2 00/12] tpm/st33zp24: Few code style and sanity fixes + acpi device probing support Christophe Ricard
[not found] ` <1455376535-9549-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-02-13 15:15 ` [PATCH v2 01/12] tpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 02/12] tpm/st33zp24/spi: Use functions name with st33zp24_spi_ prefix Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 03/12] tpm/st33zp24/spi: Remove useless use of memcpy Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 04/12] tpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy structure Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 05/12] tpm/st33zp24: Remove unneeded CONFIG_OF switches Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 06/12] tpm/st33zp24: Auto-select core module Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 07/12] tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 08/12] tpm/st33zp24: Extend Copyright headers Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 09/12] tpm/st33zp24: Add support for acpi probing for i2c device Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 10/12] tpm: st33zp24: Add support for acpi probing for spi device Christophe Ricard
[not found] ` <1455376535-9549-11-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-02-22 15:57 ` Jarkko Sakkinen
2016-02-13 15:15 ` [PATCH v2 11/12] tpm/st33zp24/i2c: Change xxx_request_resources header Christophe Ricard
2016-02-13 15:15 ` [PATCH v2 12/12] tpm/st33zp24/spi: " Christophe Ricard
2016-02-22 23:56 ` [PATCH v2 00/12] tpm/st33zp24: Few code style and sanity fixes + acpi device probing support Jarkko Sakkinen
[not found] ` <20160222235639.GA7721-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-02-25 7:48 ` Christophe Ricard
[not found] ` <56CEB1DA.4020709-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-02-25 13:18 ` Jarkko Sakkinen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.