[PATCH 0/6] [Disco SRU] Use gpiolib for chipselect in DW SPI driver

Ike Panhc ike.pan at canonical.com
Tue May 7 08:58:35 UTC 2019

On 5/6/19 5:39 PM, Stefan Bader wrote:
> On 06.05.19 11:19, Ike Panhc wrote:
>> BugLink: https://bugs.launchpad.net/bugs/1826142
>> Current spi-dw-mmio driver needs hardware description from devicetree
>> or acpitables for chipselect but only support devicetree. Here are
>> patches to enable ACPI support for DW SPI driver so that the TPM
>> module can be supported on ACPI machines.
>> The first patch for spi core provides new method to set gpio pin with
>> gpiolib if use_gpio_descriptors=true and legacy method is still
>> available if use_gpio_descriptors=false.
>> The 2nd patch is to switch DW SPI driver to use gpiolib for
>> chipselect so the duplicate devicetree code can be removed.
>> The rest of patches are minor regression fixes collected from 
>> mainline about unused variable and default polarity of gpio pin.
>> Anders Roxell (1):
>>   spi: dw: fix warning unused variable 'ret'
>> Linus Walleij (5):
>>   spi: Optionally use GPIO descriptors for CS GPIOs
>>   spi: dw: Convert to use CS GPIO descriptors
>>   spi: Support high CS when using descriptors
>>   spi: dw: Fix default polarity of native chipselect
>>   gpio: of: Fix logic inversion
>>  drivers/gpio/gpiolib-of.c |   2 +-
>>  drivers/spi/spi-dw-mmio.c |  22 --------
>>  drivers/spi/spi-dw.c      |  15 ++----
>>  drivers/spi/spi.c         | 109 ++++++++++++++++++++++++++++++++++----
>>  include/linux/spi/spi.h   |  23 ++++++--
>>  5 files changed, 122 insertions(+), 49 deletions(-)
> This must be rather recent code to be needed in Disco. For the SRU I would like
> to see a better argumentation about why this is needed (which functionality is
> currently broken) and which platforms are affected (mentioning device-tree
> points to Arm but this should be less guessing). Also, right now the reason for
> not mentioning Eoan is likely that it is a copy forward kernel there. But
> mentioning that helps to recognize someone has spent thoughts on it. Would also
> be good to mention which upstream kernel version includes all requested patches.
> -Stefan
Ah, sorry I haven't made it clear in description. I will update launchpad bug

We have a TPM module but disco kernel can not initial it. The root cause is
DW SPI driver in disco only support chipselect from device-tree and for 5.1
mainline kernel it can be used with deivce-tree or ACPI. Most of ARM machine
support for ACPI only.

$ dmesg | grep tpm
[    20.820930] tpm tpm0: tpm_try_transmit: send(): error -5
[    21.577912] tpm tpm0: tpm_relinquish_locality: : error -1
[    21.582313] tpm_tis_spi spi_SMO0768:00: 1.2 TPM (device-id 0xFFFF, rev-id 255)
[    21.583438] tpm tpm0: tpm_try_transmit: send(): error -5
[    22.339157] tpm tpm0: tpm_relinquish_locality: : error -1
[    22.343419] tpm tpm0: A TPM error (-5) occurred attempting to determine the timeouts
[    22.348215] tpm_tis_spi: probe of spi-SMO0768:00 failed with error -5

With these patches tpm driver initial successfully.

$ dmesg | grep tpm
[   28.277541] tpm_tis_spi spi-SMO0768:00: 2.0 TPM (device-id 0x1B, rev-id 16)
[   28.288602] tpm tpm0: A TPM error (256) occurred attempting the selftest
[   28.295440] tpm tpm0: starting up the TPM manually
[   28.319036] tpm tpm0: A TPM error (2314) occurred attempting the self test

Reading first 2 patches for determining regression risk and find out only machine
with Designware MMIO SPI and device-tree have risk. Fortunately on mainline kernel
we have Jan Kotas tested and report several regressions e.g. default polarity.

Therefore, another 4 patches is needed to fix the regression on device-tree
machines with DW SPI and that's the only regression risk. Most of all patches in
5.1 kernel for DW SPI are cherry-picked.

Ike Panhc

More information about the kernel-team mailing list