tpm: Add support for new Infineon I2C TPM (SLB 9645 TT 1.2 I2C)
Subsystems (3)
PATCH v2 1/1 tpm: Add support for new Infineon I2C TPM (SLB 9645 TT 1.2 I2C)
This driver adds support for Infineon's new SLB 9645 TT 1.2 I2C TPMs, which supports clockstretching, combined reads and a bus speed of up to 400khz. The device also has a new device id.
The driver works now also fine with device trees, so you can instantiate your device by adding:
+ tpm {
+ compatible = "infineon,slb9645tt";
+ reg = <0x20>;
+ };
for SLB 9645 devices or
+ tpm {
+ compatible = "infineon,slb9635tt";
+ reg = <0x20>;
+ };
for SLB 9635 devices
to your device tree.tpm_i2c_infineon is also retained as a compatible id as a fallback to slb9635 protocol.
The driver was tested on Beaglebone.
---
Please apply on top of "char/tpm: Convert struct i2c_msg initialization to C99 format" by Shubhrajyoti Datta
.../devicetree/bindings/i2c/trivial-devices.txt | 2 + drivers/char/tpm/tpm_i2c_infineon.c | 137 +++++++++++++++------ 2 files changed, 99 insertions(+), 40 deletions(-)
Documentation/devicetree/bindings/i2c/trivial-devices.txt +2 -0
@@ -35,6 +35,8 @@ fsl,mc13892 MC13892: Power Management Integrated Circuit (PMIC) for i.MX35/51 fsl,mma8450 MMA8450Q: Xtrinsic Low-power, 3-axis Xtrinsic Accelerometer fsl,mpr121 MPR121: Proximity Capacitive Touch Sensor Controller fsl,sgtl5000 SGTL5000: Ultra Low-Power Audio Codec +infineon,slb9635tt Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz) +infineon,slb9645tt Infineon SLB9645 I2C TPM (new protocol, max 400khz) maxim,ds1050 5 Bit Programmable, Pulse-Width Modulator maxim,max1237 Low-Power, 4-/12-Channel, 2-Wire Serial, 12-Bit ADCs maxim,max6625 9-Bit/12-Bit Temperature Sensors with I²C-Compatible Serial Interface
drivers/char/tpm/tpm_i2c_infineon.c +97 -40
267 lines not on this page · raw message
Signature · 1 line
1.8.1.msysgit.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Kent Yoder
drivers/char/tpm/tpm_i2c_infineon.c static struct i2c_driver tpm_tis_i2c_driver = { · line 762
Quoted 8 lines
drivers/char/tpm/tpm_i2c_infineon.c +1
-0.id_table = tpm_tis_i2c_table, .probe = tpm_tis_i2c_probe, .remove = tpm_tis_i2c_remove,@@ -703,11 +759,12 @@ static struct i2c_driver tpm_tis_i2c_driver = { .name = "tpm_i2c_infineon", .owner = THIS_MODULE, .pm = &tpm_tis_i2c_ops, + .of_match_table = of_match_ptr(tpm_tis_i2c_of_match),Please put this line inside an ifdef
CONFIG_OF, sinceof_match_ptr
lives in there.
The OF stuff is designed to hide the CONFIG_OF from using code, of_match_ptr(x) expends to NULL when CONFIG_OF is not set.
It is optional to include the MATCH_TABLE bit in a CONFI_OF #ifdef, lots of places don't.
Jason
Hi Kent,
short reply from my private account - so only talking on behalf of myself.
Am Montag, 4. März 2013, 18:41:04 schrieb Kent Yoder:
Quoted 3 lines
Hi Peter,
Sorry for the long delay in getting this reviewed...
No problem.
Quoted 15 lines
drivers/char/tpm/tpm_i2c_infineon.c static int iic_tpm_read(u8 addr, u8 *buffer, size_t len) · line 128
Quoted 13 lines
drivers/char/tpm/tpm_i2c_infineon.c +7
-5-for (count =0 ; count <MAX_COUNT ; count++) { -usleep_range (SLEEP_DURATION_LOW ,SLEEP_DURATION_HI ); - rc =__i2c_transfer (tpm_dev.client->adapter, &msg2,1 ); -if (rc >0 ) -break ; +if (tpm_dev.chip_type ==SLB9645 ) { +/* use a combined read for newer chips +* unfortunately the smbus functions are not suitable due to +* the 32 byte limit of the smbus. +* retries should usually not be needed, but are kept just to +* be on the safe side. +*/ Bump out that last line of comment by a column.
You mean I should add 1 space - okay, no problem.
(and I'm nitty picky.... ;) *g*
Quoted 7 lines
drivers/char/tpm/tpm_i2c_infineon.c static int iic_tpm_read(u8 addr, u8 *buffer, size_t len)
Quoted 4 lines
drivers/char/tpm/tpm_i2c_infineon.c +0
-0if (rc <=0 )return -EIO ;This confused me for a second, but I see
__i2c_transferreturns the number
of messages transferred. Maybe worth adding a comment.
Maybe I can add one - I'll think about it.
Quoted 11 lines
drivers/char/tpm/tpm_i2c_infineon.c out_err: · line 699
Quoted 7 lines
drivers/char/tpm/tpm_i2c_infineon.c +6
-0+ +#ifdef CONFIG_OF +static const struct of_device_id tpm_tis_i2c_of_match[] = { + { .compatible ="infineon,tpm_i2c_infineon" , .data = (void *)0 }, + { .compatible ="infineon,slb9635tt" , .data = (void *)0 }, + { .compatible = "infineon,slb9645tt", .data = (void *)1 },Here "name" and "type" are left empty in
of_device_id. Will there be
times when those are needed? Like informational messages from the OF subsystem?
Hmm, what do you propose?
name = chip type ? or name = tpm_i2c_infineon?
type = tpm ?
Quoted 5 lines
drivers/char/tpm/tpm_i2c_infineon.c static struct i2c_driver tpm_tis_i2c_driver = { · line 762
Quoted 2 lines
drivers/char/tpm/tpm_i2c_infineon.c +1
-0+ .of_match_table = of_match_ptr(tpm_tis_i2c_of_match),Please put this line inside an ifdef
CONFIG_OF, sinceof_match_ptr
lives in there.
NACK.of.h has already the ifdef CONFIG_OF for of_match_ptr and defines it either as
#define of_match_ptr(_ptr) (_ptr)
or
#define of_match_ptr(_ptr) NULL
depending on CONFIG_OF is set.
Quoted 1 line
Won't you also need to add OF to
Kconfig?
Not really, as the only stuff we're using is the compatible id - the driver can live without it and can be probed from userspace or plain old platform data. I probably have compile tested it with and without CONFIG_OF.
Is it worth a v3?
or a small update patch which adds the of name/type and the space? (I can
create this patch immediately)
Thanks,
Peter
Quoted 12 lines
Quoted 11 lines
drivers/char/tpm/tpm_i2c_infineon.c out_err: · line 699
Quoted 7 lines
drivers/char/tpm/tpm_i2c_infineon.c +6
-0+ +#ifdef CONFIG_OF +static const struct of_device_id tpm_tis_i2c_of_match[] = { + { .compatible ="infineon,tpm_i2c_infineon" , .data = (void *)0 }, + { .compatible ="infineon,slb9635tt" , .data = (void *)0 }, + { .compatible = "infineon,slb9645tt", .data = (void *)1 },Here "name" and "type" are left empty in
of_device_id. Will there be
times when those are needed? Like informational messages from the OF subsystem?
Quoted 3 lines
Hmm, what do you propose?
name = chip type ? or name =tpm_i2c_infineon?
type = tpm ?
Doesn't matter to me, I just wanted to be sure you hadn't missed anything.
Quoted 11 lines
Quoted 4 lines
Quoted 1 line
+ .of_match_table =
of_match_ptr(tpm_tis_i2c_of_match),Please put this line inside an ifdef
CONFIG_OF, sinceof_match_ptr
lives in there.NACK.
of.hhas already the ifdefCONFIG_OFforof_match_ptrand defines it either as#define
of_match_ptr(_ptr)(_ptr)
or
#defineof_match_ptr(_ptr)NULL
depending onCONFIG_OFis set.
Thanks.
Quoted 4 lines
Quoted 1 line
Won't you also need to add OF to
Kconfig?Not really, as the only stuff we're using is the compatible id - the driver can live without it and can be probed from userspace or plain old platform data. I probably have compile tested it with and without
CONFIG_OF.
Ok.
Quoted 3 lines
Is it worth a v3?
or a small update patch which adds the of name/type and the space? (I can
create this patch immediately)
Not a problem, I can apply as-is with the fixup.
Kent
Quoted 6 lines
Thanks,
Peter
Quoted 37 lines · Kent Yoder
Quoted 12 lines
Quoted 11 lines
drivers/char/tpm/tpm_i2c_infineon.c out_err: · line 699
Quoted 7 lines
drivers/char/tpm/tpm_i2c_infineon.c +6
-0+ +#ifdef CONFIG_OF +static const struct of_device_id tpm_tis_i2c_of_match[] = { + { .compatible ="infineon,tpm_i2c_infineon" , .data = (void *)0 }, + { .compatible ="infineon,slb9635tt" , .data = (void *)0 }, + { .compatible = "infineon,slb9645tt", .data = (void *)1 },Here "name" and "type" are left empty in
of_device_id. Will there be
times when those are needed? Like informational messages from the OF subsystem?Quoted 3 lines
Hmm, what do you propose?
name = chip type ? or name =tpm_i2c_infineon?
type = tpm ?Doesn't matter to me, I just wanted to be sure you hadn't missed anything.
Quoted 11 lines
Quoted 4 lines
Quoted 1 line
+ .of_match_table =
of_match_ptr(tpm_tis_i2c_of_match),Please put this line inside an ifdef
CONFIG_OF, sinceof_match_ptr
lives in there.NACK.
of.hhas already the ifdefCONFIG_OFforof_match_ptrand defines it either as#define
of_match_ptr(_ptr)(_ptr)
or
#defineof_match_ptr(_ptr)NULL
depending onCONFIG_OFis set.Thanks.
Quoted 4 lines
Quoted 1 line
Won't you also need to add OF to
Kconfig?Not really, as the only stuff we're using is the compatible id - the driver can live without it and can be probed from userspace or plain old platform data. I probably have compile tested it with and without
CONFIG_OF.
Quoted 7 lines
Ok.
Quoted 3 lines
Is it worth a v3?
or a small update patch which adds the of name/type and the space? (I can
create this patch immediately)Not a problem, I can apply as-is with the fixup.
Staged here:
https://github.com/shpedoikal/linux.git tpmdd-03-04-13
Thanks,
Kent
Quoted 8 lines
Kent
Quoted 6 lines
Thanks,
Peter