spi: tegra quad: Add Tegra Grace features
Subsystems (5)
cover spi: tegra quad: Add Tegra Grace features
Add multiple chip selects and hardware wait state polling supported by Tegra Grace.
Krishna Yarlagadda (3):
spi: tegra210-quad: Multi-cs support
spi: tegra210-quad: Add wait polling support
spi: dt-bindings: Add wait state polling flag
.../bindings/spi/nvidia,tegra210-quad.yaml | 6 ++ drivers/spi/spi-tegra210-quad.c | 64 ++++++++++++++++++- 2 files changed, 68 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/3 spi: tegra210-quad: Multi-cs support
Tegra Grace and later chips can support upto 4 chip select lines for QUAD SPI. Added new compatible for Tegra Grace.
--- drivers/spi/spi-tegra210-quad.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-)
drivers/spi/spi-tegra210-quad.c +31 -2
@@ -37,6 +37,16 @@#define QSPI_RX_EN BIT(12)#define QSPI_CS_SW_VAL BIT(20)#define QSPI_CS_SW_HW BIT(21) + +#define QSPI_CS_POL_INACTIVE (n) (1 << (22 + (n))) +#define QSPI_CS_POL_INACTIVE_MASK (0xF << 22) +#define QSPI_CS_SEL_0 (0 << 26) +#define QSPI_CS_SEL_1 (1 << 26) +#define QSPI_CS_SEL_2 (2 << 26) +#define QSPI_CS_SEL_3 (3 << 26) +#define QSPI_CS_SEL_MASK (3 << 26) +#define QSPI_CS_SEL (x) (((x) & 0x3) << 26) +#define QSPI_CONTROL_MODE_0 (0 << 28)#define QSPI_CONTROL_MODE_3 (3 << 28)#define QSPI_CONTROL_MODE_MASK (3 << 28)
@@ -154,6 +164,7 @@struct tegra_qspi_soc_data {bool has_dma;bool cmb_xfer_capable; +bool cs_count; };struct tegra_qspi_client_data {
@@ -812,6 +823,7 @@ static u32 tegra_qspi_setup_transfer_one(struct spi_device *spi, struct spi_trantegra_qspi_mask_clear_irq (tqspi); command1 = tqspi->def_command1_reg; + command1 |=QSPI_CS_SEL (spi->chip_select); command1 |=QSPI_BIT_LENGTH (bits_per_word -1 ); command1 &= ~QSPI_CONTROL_MODE_MASK ;
@@ -941,10 +953,11 @@ static int tegra_qspi_setup(struct spi_device *spi)/* keep default cs state to inactive */ val = tqspi->def_command1_reg; + val |=QSPI_CS_SEL (spi->chip_select);if (spi->mode &SPI_CS_HIGH ) - val &= ~QSPI_CS_SW_VAL ; + val &= ~QSPI_CS_POL_INACTIVE (spi->chip_select);else - val |=QSPI_CS_SW_VAL ; + val |=QSPI_CS_POL_INACTIVE (spi->chip_select); tqspi->def_command1_reg = val;tegra_qspi_writel (tqspi, tqspi->def_command1_reg,QSPI_COMMAND1 );
@@ -1425,16 +1438,25 @@ static irqreturn_t tegra_qspi_isr_thread(int irq, void *context_data)static struct tegra_qspi_soc_data tegra210_qspi_soc_data = { .has_dma = true, .cmb_xfer_capable = false, + .cs_count =1 , };static struct tegra_qspi_soc_data tegra186_qspi_soc_data = { .has_dma = true, .cmb_xfer_capable = true, + .cs_count =1 , };static struct tegra_qspi_soc_data tegra234_qspi_soc_data = { .has_dma = false, .cmb_xfer_capable = true, + .cs_count =1 , +}; + +static struct tegra_qspi_soc_data tegra_grace_qspi_soc_data = { + .has_dma = false, + .cmb_xfer_capable = true, + .cs_count =4 , };static const struct of_device_id tegra_qspi_of_match[] = {
@@ -1450,6 +1472,9 @@ static const struct of_device_id tegra_qspi_of_match[] = { }, { .compatible = "nvidia,tegra234-qspi", .data = &tegra234_qspi_soc_data, + }, { + .compatible = "nvidia,tegra-grace-qspi", + .data = &tegra_grace_qspi_soc_data, }, {} };
@@ -1467,6 +1492,9 @@ static const struct acpi_device_id tegra_qspi_acpi_match[] = { }, { .id = "NVDA1413", .driver_data = (kernel_ulong_t)&tegra234_qspi_soc_data, + }, { + .id = "NVDA1513", + .driver_data = (kernel_ulong_t)&th500_qspi_soc_data, }, {} };
@@ -1506,6 +1534,7 @@ static int tegra_qspi_probe(struct platform_device *pdev)spin_lock_init (&tqspi->lock); tqspi->soc_data =device_get_match_data (&pdev->dev); + master->num_chipselect = tqspi->soc_data->cs_count; r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); tqspi->base =devm_ioremap_resource (&pdev->dev, r);if (IS_ERR (tqspi->base))
Signature · 1 line
2.17.1
kernel test robot
build botRe: [PATCH 1/3] spi: tegra210-quad: Multi-cs support
Thank you for the patch! Yet something to improve:
Hi Krishna,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on broonie-spi/for-next]
[also build test ERROR on next-20220316]
[cannot apply to v5.17-rc8]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Krishna-Yarlagadda/spi-tegra-quad-Add-Tegra-Grace-features/20220317-092247 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next config: ia64-allmodconfig (https://download.01.org/0day-ci/archive/20220317/[email protected]/config) compiler: ia64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/38ff812651f89adc738066112000ec32eb73d106
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Krishna-Yarlagadda/spi-tegra-quad-Add-Tegra-Grace-features/20220317-092247 git checkout 38ff812651f89adc738066112000ec32eb73d106
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/spi/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/spi/spi-tegra210-quad.c:1497:49: error: 'th500_qspi_soc_data' undeclared here (not in a function); did you mean 'tegra_qspi_soc_data'?
1497 | .driver_data = (kernel_ulong_t)&th500_qspi_soc_data,
| ^~~~~~~~~~~~~~~~~~~
| tegra_qspi_soc_datavim +1497 drivers/spi/spi-tegra210-quad.c
1483
1484 #ifdef CONFIG_ACPI
1485 static const struct acpi_device_id tegra_qspi_acpi_match[] = {
1486 {
1487 .id = "NVDA1213",
1488 .driver_data = (kernel_ulong_t)&tegra210_qspi_soc_data,
1489 }, {
1490 .id = "NVDA1313",
1491 .driver_data = (kernel_ulong_t)&tegra186_qspi_soc_data,
1492 }, {
1493 .id = "NVDA1413",
1494 .driver_data = (kernel_ulong_t)&tegra234_qspi_soc_data,
1495 }, {
1496 .id = "NVDA1513",
> 1497 .driver_data = (kernel_ulong_t)&th500_qspi_soc_data,
1498 },
1499 {}
1500 };
1501
---
0-DAY CI Kernel Test Service
https://lists.01.org/hyperkitty/list/[email protected]
PATCH 2/3 spi: tegra210-quad: Add wait polling support
In reply to Krishna YarlagaddaController can poll for wait state inserted by TPM device and handle it.
--- drivers/spi/spi-tegra210-quad.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/spi/spi-tegra210-quad.c +31 -0
@@ -142,6 +142,7 @@#define QSPI_GLOBAL_CONFIG 0X1a4#define QSPI_CMB_SEQ_EN BIT(0) +#define QSPI_TPM_WAIT_POLL_EN BIT(1)#define QSPI_CMB_SEQ_ADDR 0x1a8#define QSPI_ADDRESS_VALUE_SET (X ) (((x) & 0xFFFF) << 0)
@@ -165,11 +166,13 @@ struct tegra_qspi_soc_data {bool has_dma;bool cmb_xfer_capable;bool cs_count; +bool has_wait_polling; };struct tegra_qspi_client_data {int tx_clk_tap_delay;int rx_clk_tap_delay; +bool wait_polling; };struct tegra_qspi {
@@ -833,6 +836,11 @@ static u32 tegra_qspi_setup_transfer_one(struct spi_device *spi, struct spi_tranelse command1 |=QSPI_CONTROL_MODE_0 ; +if (tqspi->soc_data->cmb_xfer_capable) + command1 &= ~QSPI_CS_SW_HW ; +else + command1 |=QSPI_CS_SW_HW ; +if (spi->mode &SPI_CS_HIGH ) command1 |=QSPI_CS_SW_VAL ;else
@@ -917,6 +925,7 @@ static int tegra_qspi_start_transfer_one(struct spi_device *spi,static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt (struct spi_device *spi) { +struct tegra_qspi *tqspi =spi_master_get_devdata (spi->master);struct tegra_qspi_client_data *cdata; cdata =devm_kzalloc (&spi->dev,sizeof (*cdata),GFP_KERNEL );
@@ -927,6 +936,11 @@ static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt(struct spi_devic &cdata->tx_clk_tap_delay);device_property_read_u32 (&spi->dev,"nvidia,rx-clk-tap-delay" , &cdata->rx_clk_tap_delay); +if (tqspi->soc_data->has_wait_polling) + cdata->wait_polling =device_property_read_bool + (&spi->dev, +"nvidia,wait-polling" ); +return cdata; }
@@ -1049,6 +1063,7 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi,bool is_first_msg = true;struct spi_transfer *xfer;struct spi_device *spi = msg->spi; +struct tegra_qspi_client_data *cdata = spi->controller_data;u8 transfer_phase =0 ;u32 cmd1 =0 , dma_ctl =0 ;int ret =0 ;
@@ -1059,6 +1074,10 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi,/* Enable Combined sequence mode */ val =tegra_qspi_readl (tqspi,QSPI_GLOBAL_CONFIG ); val |=QSPI_CMB_SEQ_EN ; +if (cdata->wait_polling) + val |=QSPI_TPM_WAIT_POLL_EN ; +else + val &= ~QSPI_TPM_WAIT_POLL_EN ;tegra_qspi_writel (tqspi, val,QSPI_GLOBAL_CONFIG );/* Process individual transfer list */ list_for_each_entry (xfer, &msg->transfers, transfer_list) {
@@ -1158,6 +1177,8 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi, transfer_phase++; } + ret =0 ; + exit: msg->status = ret;
@@ -1180,6 +1201,7 @@ static int tegra_qspi_non_combined_seq_xfer(struct tegra_qspi *tqspi,/* Disable Combined sequence mode */ val =tegra_qspi_readl (tqspi,QSPI_GLOBAL_CONFIG ); val &= ~QSPI_CMB_SEQ_EN ; + val &= ~QSPI_TPM_WAIT_POLL_EN ;tegra_qspi_writel (tqspi, val,QSPI_GLOBAL_CONFIG );list_for_each_entry (transfer, &msg->transfers, transfer_list) {struct spi_transfer *xfer = transfer;
@@ -1439,24 +1461,28 @@ static struct tegra_qspi_soc_data tegra210_qspi_soc_data = { .has_dma = true, .cmb_xfer_capable = false, .cs_count = 1, + .has_wait_polling = false, };static struct tegra_qspi_soc_data tegra186_qspi_soc_data = { .has_dma = true, .cmb_xfer_capable = true, .cs_count =1 , + .has_wait_polling = false, };static struct tegra_qspi_soc_data tegra234_qspi_soc_data = { .has_dma = false, .cmb_xfer_capable = true, .cs_count =1 , + .has_wait_polling = true, };static struct tegra_qspi_soc_data tegra_grace_qspi_soc_data = { .has_dma = false, .cmb_xfer_capable = true, .cs_count =4 , + .has_wait_polling = true, };static const struct of_device_id tegra_qspi_of_match[] = {
@@ -1509,6 +1535,7 @@ static int tegra_qspi_probe(struct platform_device *pdev)struct resource *r;int ret, qspi_irq;int bus_num; +u8 val =0 ; master =devm_spi_alloc_master (&pdev->dev,sizeof (*tqspi));if (!master)
@@ -1585,6 +1612,10 @@ static int tegra_qspi_probe(struct platform_device *pdev) tqspi->spi_cs_timing1 =tegra_qspi_readl (tqspi,QSPI_CS_TIMING1 ); tqspi->spi_cs_timing2 =tegra_qspi_readl (tqspi,QSPI_CS_TIMING2 ); tqspi->def_command2_reg =tegra_qspi_readl (tqspi,QSPI_COMMAND2 ); + val =tegra_qspi_readl (tqspi,QSPI_GLOBAL_CONFIG ); + val &= ~QSPI_CMB_SEQ_EN ; + val &= ~QSPI_TPM_WAIT_POLL_EN ; +tegra_qspi_writel (tqspi, val,QSPI_GLOBAL_CONFIG );pm_runtime_put (&pdev->dev);
Signature · 1 line
2.17.1
Jon Hunter
maintainerRe: [PATCH 2/3] spi: tegra210-quad: Add wait polling support
Quoted 55 lines · Krishna Yarlagadda
Controller can poll for wait state inserted by TPM device and handle it.
Signed-off-by Krishna Yarlagadda <[email protected]>--- drivers/spi/spi-tegra210-quad.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/spi/spi-tegra210-quad.c +9
-0@@ -142,6 +142,7 @@#define QSPI_GLOBAL_CONFIG 0X1a4#define QSPI_CMB_SEQ_EN BIT(0) +#define QSPI_TPM_WAIT_POLL_EN BIT(1)#define QSPI_CMB_SEQ_ADDR 0x1a8#define QSPI_ADDRESS_VALUE_SET (X ) (((x) & 0xFFFF) << 0)@@ -165,11 +166,13 @@ struct tegra_qspi_soc_data {bool has_dma;bool cmb_xfer_capable;bool cs_count; +bool has_wait_polling; };struct tegra_qspi_client_data {int tx_clk_tap_delay;int rx_clk_tap_delay; +bool wait_polling; };struct tegra_qspi {@@ -833,6 +836,11 @@ static u32 tegra_qspi_setup_transfer_one(struct spi_device *spi, struct spi_tranelse command1 |=QSPI_CONTROL_MODE_0 ; +if (tqspi->soc_data->cmb_xfer_capable) + command1 &= ~QSPI_CS_SW_HW ; +else + command1 |=QSPI_CS_SW_HW ; +if (spi->mode &SPI_CS_HIGH ) command1 |=QSPI_CS_SW_VAL ;else @@ -917,6 +925,7 @@ static int tegra_qspi_start_transfer_one(struct spi_device *spi,static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt (struct spi_device *spi) { +struct tegra_qspi *tqspi =spi_master_get_devdata (spi->master);struct tegra_qspi_client_data *cdata; cdata =devm_kzalloc (&spi->dev,sizeof (*cdata),GFP_KERNEL );
drivers/spi/spi-tegra210-quad.c static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt(struct spi_devic · line 943
Quoted 8 lines
drivers/spi/spi-tegra210-quad.c +5
-0@@ -927,6 +936,11 @@ static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt(struct spi_devic &cdata->tx_clk_tap_delay);device_property_read_u32 (&spi->dev,"nvidia,rx-clk-tap-delay" , &cdata->rx_clk_tap_delay); +if (tqspi->soc_data->has_wait_polling) + cdata->wait_polling =device_property_read_bool + (&spi->dev, +"nvidia,wait-polling" ); +
This looks odd. Why do we need this device-tree property if it is already specified in the SoC data?
Jon
Signature · 1 line
nvpublic
RE: [PATCH 2/3] spi: tegra210-quad: Add wait polling support
Quoted 64 lines
-----Original Message-----
From: Jonathan Hunter <[email protected]>
Sent: 17 March 2022 14:25
To: Krishna Yarlagadda <[email protected]>; [email protected]; [email protected]; [email protected]; linux- [email protected]; Ashish Singhal <[email protected]>
Cc: Sowjanya Komatineni <[email protected]>; Laxman Dewangan <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] spi: tegra210-quad: Add wait polling supportQuoted 53 lines · Krishna Yarlagadda
Controller can poll for wait state inserted by TPM device and handle it.
Signed-off-by Krishna Yarlagadda <[email protected]>--- drivers/spi/spi-tegra210-quad.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/spi/spi-tegra210-quad.c +9
-0@@ -142,6 +142,7 @@#define QSPI_GLOBAL_CONFIG 0X1a4#define QSPI_CMB_SEQ_EN BIT(0) +#define QSPI_TPM_WAIT_POLL_EN BIT(1)#define QSPI_CMB_SEQ_ADDR 0x1a8#define QSPI_ADDRESS_VALUE_SET (X ) (((x) & 0xFFFF) << 0)@@ -165,11 +166,13 @@ struct tegra_qspi_soc_data {bool has_dma;bool cmb_xfer_capable;bool cs_count; +bool has_wait_polling; };struct tegra_qspi_client_data {int tx_clk_tap_delay;int rx_clk_tap_delay; +bool wait_polling; };struct tegra_qspi {@@ -833,6 +836,11 @@ static u32 tegra_qspi_setup_transfer_one(struct spi_device *spi, struct spi_tranelse command1 |=QSPI_CONTROL_MODE_0 ; +if (tqspi->soc_data->cmb_xfer_capable) + command1 &= ~QSPI_CS_SW_HW ; +else + command1 |=QSPI_CS_SW_HW ; +if (spi->mode &SPI_CS_HIGH ) command1 |=QSPI_CS_SW_VAL ;else @@ -917,6 +925,7 @@ static int tegra_qspi_start_transfer_one(struct spi_device *spi,static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt (struct spi_device *spi) { +struct tegra_qspi *tqspi =spi_master_get_devdata (spi->master);struct tegra_qspi_client_data *cdata;
Quoted 14 lines
drivers/spi/spi-tegra210-quad.c static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt(struct spi_devic · line 943
Quoted 10 lines
drivers/spi/spi-tegra210-quad.c +5
-0cdata =devm_kzalloc (&spi->dev,sizeof (*cdata),GFP_KERNEL );@@ -927,6 +936,11 @@ static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt(struct spi_devic &cdata->tx_clk_tap_delay);device_property_read_u32 (&spi->dev,"nvidia,rx-clk-tap-delay" , &cdata->rx_clk_tap_delay); +if (tqspi->soc_data->has_wait_polling) + cdata->wait_polling =device_property_read_bool + (&spi->dev, +"nvidia,wait-polling" ); +This looks odd. Why do we need this device-tree property if it is already specified in the SoC data?
Soc data specifies chip is capable of wait-polling.
Wait polling still has to be selected on slave devices that can support it. I will add one line description for the properties in next version.
Quoted 5 lines
Jon
--
nvpublic
Jon Hunter
maintainerRe: [PATCH 2/3] spi: tegra210-quad: Add wait polling support
Quoted 78 lines · Krishna Yarlagadda
Quoted 64 lines
-----Original Message-----
From: Jonathan Hunter <[email protected]>
Sent: 17 March 2022 14:25
To: Krishna Yarlagadda <[email protected]>; [email protected]; [email protected]; [email protected]; linux- [email protected]; Ashish Singhal <[email protected]>
Cc: Sowjanya Komatineni <[email protected]>; Laxman Dewangan <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] spi: tegra210-quad: Add wait polling supportQuoted 53 lines · Krishna Yarlagadda
Controller can poll for wait state inserted by TPM device and handle it.
Signed-off-by Krishna Yarlagadda <[email protected]>--- drivers/spi/spi-tegra210-quad.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/spi/spi-tegra210-quad.c +9
-0@@ -142,6 +142,7 @@#define QSPI_GLOBAL_CONFIG 0X1a4#define QSPI_CMB_SEQ_EN BIT(0) +#define QSPI_TPM_WAIT_POLL_EN BIT(1)#define QSPI_CMB_SEQ_ADDR 0x1a8#define QSPI_ADDRESS_VALUE_SET (X ) (((x) & 0xFFFF) << 0)@@ -165,11 +166,13 @@ struct tegra_qspi_soc_data {bool has_dma;bool cmb_xfer_capable;bool cs_count; +bool has_wait_polling; };struct tegra_qspi_client_data {int tx_clk_tap_delay;int rx_clk_tap_delay; +bool wait_polling; };struct tegra_qspi {@@ -833,6 +836,11 @@ static u32 tegra_qspi_setup_transfer_one(struct spi_device *spi, struct spi_tranelse command1 |=QSPI_CONTROL_MODE_0 ; +if (tqspi->soc_data->cmb_xfer_capable) + command1 &= ~QSPI_CS_SW_HW ; +else + command1 |=QSPI_CS_SW_HW ; +if (spi->mode &SPI_CS_HIGH ) command1 |=QSPI_CS_SW_VAL ;else @@ -917,6 +925,7 @@ static int tegra_qspi_start_transfer_one(struct spi_device *spi,static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt (struct spi_device *spi) { +struct tegra_qspi *tqspi =spi_master_get_devdata (spi->master);struct tegra_qspi_client_data *cdata;Quoted 14 lines
drivers/spi/spi-tegra210-quad.c static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt(struct spi_devic · line 943
Quoted 10 lines
drivers/spi/spi-tegra210-quad.c +5
-0cdata =devm_kzalloc (&spi->dev,sizeof (*cdata),GFP_KERNEL );@@ -927,6 +936,11 @@ static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt(struct spi_devic &cdata->tx_clk_tap_delay);device_property_read_u32 (&spi->dev,"nvidia,rx-clk-tap-delay" , &cdata->rx_clk_tap_delay); +if (tqspi->soc_data->has_wait_polling) + cdata->wait_polling =device_property_read_bool + (&spi->dev, +"nvidia,wait-polling" ); +This looks odd. Why do we need this device-tree property if it is already specified in the SoC data?
Quoted 3 lines
Soc data specifies chip is capable of wait-polling.
Wait polling still has to be selected on slave devices that can support it. I will add one line description for the properties in next version.
I can't say I am familiar with this, but it seems that the ideal solution would be able to detect if this needs to be enabled depending on the device connected. Is that not possible?
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerRe: [PATCH 2/3] spi: tegra210-quad: Add wait polling support
Quoted 83 lines · Jon Hunter
Quoted 81 lines · Krishna Yarlagadda
Quoted 81 lines
-----Original Message-----
From: Jonathan Hunter <[email protected]>
Sent: 17 March 2022 14:25
To: Krishna Yarlagadda <[email protected]>; [email protected]; [email protected]; [email protected]; linux- [email protected]; Ashish Singhal <[email protected]>
Cc: Sowjanya Komatineni <[email protected]>; Laxman Dewangan <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] spi: tegra210-quad: Add wait polling supportQuoted 57 lines · Krishna Yarlagadda
Controller can poll for wait state inserted by TPM device and handle it.
Signed-off-by Krishna Yarlagadda <[email protected]>---
drivers/spi/spi-tegra210-quad.c| 31 +++++++++++++++++++++++++++++++1 file changed, 31 insertions(+)drivers/spi/spi-tegra210-quad.c +3
-0@@ -142,6 +142,7 @@ #define QSPI_GLOBAL_CONFIG 0X1a4 #define QSPI_CMB_SEQ_EN BIT(0) +#define QSPI_TPM_WAIT_POLL_EN BIT(1) #define QSPI_CMB_SEQ_ADDR 0x1a8 #define QSPI_ADDRESS_VALUE_SET(X) (((x) & 0xFFFF) << 0)@@ -165,11 +166,13 @@ struct tegra_qspi_soc_data { bool has_dma; bool cmb_xfer_capable; bool cs_count; + bool has_wait_polling; }; struct tegra_qspi_client_data { int tx_clk_tap_delay; int rx_clk_tap_delay; + bool wait_polling; }; struct tegra_qspi {@@ -833,6 +836,11 @@ static u32 tegra_qspi_setup_transfer_one(struct
spi_device*spi, structspi_tran
else
command1 |=QSPI_CONTROL_MODE_0;+ if (
tqspi->soc_data->cmb_xfer_capable)
+ command1 &= ~QSPI_CS_SW_HW;
+ else
+ command1 |=QSPI_CS_SW_HW;
+
if (spi->mode&SPI_CS_HIGH)
command1 |=QSPI_CS_SW_VAL;
elsedrivers/spi/spi-tegra210-quad.c +1
-0@@ -917,6 +925,7 @@ static int tegra_qspi_start_transfer_one(struct spi_device *spi, static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt(struct spi_device *spi) { + struct tegra_qspi *tqspi = spi_master_get_devdata(spi->master); struct tegra_qspi_client_data *cdata;cdata =
devm_kzalloc(&spi->dev, sizeof(*cdata), GFP_KERNEL);drivers/spi/spi-tegra210-quad.c static struct tegra_qspi_client_data · line 944
Quoted 9 lines
drivers/spi/spi-tegra210-quad.c +5
-0@@ -927,6 +936,11 @@ static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt(struct spi_devic &cdata->tx_clk_tap_delay); device_property_read_u32(&spi->dev, "nvidia,rx-clk-tap-delay", &cdata->rx_clk_tap_delay); + if (tqspi->soc_data->has_wait_polling) + cdata->wait_polling = device_property_read_bool + (&spi->dev, + "nvidia,wait-polling"); +This looks odd. Why do we need this device-tree property if it is already specified in the SoC data?
Quoted 6 lines
Quoted 3 lines
Soc data specifies chip is capable of wait-polling.
Wait polling still has to be selected on slave devices that can support it. I will add one line description for the properties in next version.I can't say I am familiar with this, but it seems that the ideal solution would be able to detect if this needs to be enabled depending on the device connected. Is that not possible?
Also, given that Grace supports 4 chip-selects per device, how does this work if there is TPM connected to one chip-select and something else connected to another?
Jon
Signature · 1 line
nvpublic
RE: [PATCH 2/3] spi: tegra210-quad: Add wait polling support
Regards
KY
Quoted 10 lines
-----Original Message-----
From: Jonathan Hunter <[email protected]>
Sent: 17 March 2022 20:56
To: Krishna Yarlagadda <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Ashish Singhal <[email protected]>
Cc: Sowjanya Komatineni <[email protected]>; Laxman Dewangan <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] spi: tegra210-quad: Add wait polling support
Quoted 97 lines
Quoted 96 lines · Jon Hunter
Quoted 85 lines · Krishna Yarlagadda
Quoted 70 lines
-----Original Message-----
From: Jonathan Hunter <[email protected]>
Sent: 17 March 2022 14:25
To: Krishna Yarlagadda <[email protected]>; [email protected]; [email protected]; [email protected]; linux- [email protected]; Ashish Singhal <[email protected]>
Cc: Sowjanya Komatineni <[email protected]>; Laxman Dewangan <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] spi: tegra210-quad: Add wait polling supportQuoted 57 lines · Krishna Yarlagadda
Controller can poll for wait state inserted by TPM device and handle it.
Signed-off-by Krishna Yarlagadda <[email protected]>---
drivers/spi/spi-tegra210-quad.c| 31 +++++++++++++++++++++++++++++++1 file changed, 31 insertions(+)drivers/spi/spi-tegra210-quad.c +3
-0@@ -142,6 +142,7 @@ #define QSPI_GLOBAL_CONFIG 0X1a4 #define QSPI_CMB_SEQ_EN BIT(0) +#define QSPI_TPM_WAIT_POLL_EN BIT(1) #define QSPI_CMB_SEQ_ADDR 0x1a8 #define QSPI_ADDRESS_VALUE_SET(X) (((x) & 0xFFFF) << 0)@@ -165,11 +166,13 @@ struct tegra_qspi_soc_data { bool has_dma; bool cmb_xfer_capable; bool cs_count; + bool has_wait_polling; }; struct tegra_qspi_client_data { int tx_clk_tap_delay; int rx_clk_tap_delay; + bool wait_polling; }; struct tegra_qspi {@@ -833,6 +836,11 @@ static u32 tegra_qspi_setup_transfer_one(struct
spi_device*spi, structspi_tran
else
command1 |=QSPI_CONTROL_MODE_0;+ if (
tqspi->soc_data->cmb_xfer_capable)
+ command1 &= ~QSPI_CS_SW_HW;
+ else
+ command1 |=QSPI_CS_SW_HW;
+
if (spi->mode&SPI_CS_HIGH)
command1 |=QSPI_CS_SW_VAL;
elsedrivers/spi/spi-tegra210-quad.c +0
-0@@ -917,6 +925,7 @@ static int tegra_qspi_start_transfer_one(struct spi_device *spi,static struct
tegra_qspi_client_data*tegra_qspi_parse_cdata_dt(structspi_device*spi)
{
+ structtegra_qspi*tqspi =spi_master_get_devdata(spi->master); structtegra_qspi_client_data*cdata;Quoted 15 lines
drivers/spi/spi-tegra210-quad.c static struct tegra_qspi_client_data · line 944
Quoted 11 lines
cdata =
devm_kzalloc(&spi->dev, sizeof(*cdata), GFP_KERNEL);drivers/spi/spi-tegra210-quad.c +5
-0@@ -927,6 +936,11 @@ static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt(struct spi_devic &cdata->tx_clk_tap_delay); device_property_read_u32(&spi->dev, "nvidia,rx-clk-tap-delay", &cdata->rx_clk_tap_delay); + if (tqspi->soc_data->has_wait_polling) + cdata->wait_polling = device_property_read_bool + (&spi->dev, + "nvidia,wait-polling"); +This looks odd. Why do we need this device-tree property if it is already specified in the SoC data?
Quoted 4 lines
Soc data specifies chip is capable of wait-polling.
Wait polling still has to be selected on slave devices that can support it.
I will add one line description for the properties in next version.I can't say I am familiar with this, but it seems that the ideal solution would be able to detect if this needs to be enabled depending on the device connected. Is that not possible?
We cannot detect at runtime which slave supports wait polling.
Quoted 4 lines
Also, given that Grace supports 4 chip-selects per device, how does this work if there is TPM connected to one chip-select and something else connected to another?
Wait polling is part of client data which is unique for each cs slave. This flag will be enabled on controller register while initiating transfer for TPM slave and disabled for all other transfers.
Quoted 5 lines
Jon
--
nvpublic
Mark Brown
maintainerRe: [PATCH 2/3] spi: tegra210-quad: Add wait polling support
Quoted 9 lines · Krishna Yarlagadda
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Wait polling still has to be selected on slave devices that can support it.
I will add one line description for the properties in next version.I can't say I am familiar with this, but it seems that the ideal solution would be able to detect if this needs to be enabled depending on the device connected. Is that not possible?
We cannot detect at runtime which slave supports wait polling.
How would the client device have any knowledge of how the controller internal implementation works? What even is a "wait state inserted by TPM device"? If this is something the client device is doing then it should be something that is expressed through the generic SPI API by the client device, if some controllers have some way of optimising this then we can add support for that but presumably it's just something that's generically supported by that device so we shouldn't need a DT property for it on the device side either.
Jon Hunter
maintainerRe: [PATCH 2/3] spi: tegra210-quad: Add wait polling support
In reply to Krishna YarlagaddaQuoted 140 lines · Krishna Yarlagadda
Controller can poll for wait state inserted by TPM device and handle it.
Signed-off-by Krishna Yarlagadda <[email protected]>--- drivers/spi/spi-tegra210-quad.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/spi/spi-tegra210-quad.c +27
-0@@ -142,6 +142,7 @@#define QSPI_GLOBAL_CONFIG 0X1a4#define QSPI_CMB_SEQ_EN BIT(0) +#define QSPI_TPM_WAIT_POLL_EN BIT(1)#define QSPI_CMB_SEQ_ADDR 0x1a8#define QSPI_ADDRESS_VALUE_SET (X ) (((x) & 0xFFFF) << 0)@@ -165,11 +166,13 @@ struct tegra_qspi_soc_data {bool has_dma;bool cmb_xfer_capable;bool cs_count; +bool has_wait_polling; };struct tegra_qspi_client_data {int tx_clk_tap_delay;int rx_clk_tap_delay; +bool wait_polling; };struct tegra_qspi {@@ -833,6 +836,11 @@ static u32 tegra_qspi_setup_transfer_one(struct spi_device *spi, struct spi_tranelse command1 |=QSPI_CONTROL_MODE_0 ; +if (tqspi->soc_data->cmb_xfer_capable) + command1 &= ~QSPI_CS_SW_HW ; +else + command1 |=QSPI_CS_SW_HW ; +if (spi->mode &SPI_CS_HIGH ) command1 |=QSPI_CS_SW_VAL ;else @@ -917,6 +925,7 @@ static int tegra_qspi_start_transfer_one(struct spi_device *spi,static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt (struct spi_device *spi) { +struct tegra_qspi *tqspi =spi_master_get_devdata (spi->master);struct tegra_qspi_client_data *cdata; cdata =devm_kzalloc (&spi->dev,sizeof (*cdata),GFP_KERNEL );@@ -927,6 +936,11 @@ static struct tegra_qspi_client_data *tegra_qspi_parse_cdata_dt(struct spi_devic &cdata->tx_clk_tap_delay);device_property_read_u32 (&spi->dev,"nvidia,rx-clk-tap-delay" , &cdata->rx_clk_tap_delay); +if (tqspi->soc_data->has_wait_polling) + cdata->wait_polling =device_property_read_bool + (&spi->dev, +"nvidia,wait-polling" ); +return cdata; }@@ -1049,6 +1063,7 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi,bool is_first_msg = true;struct spi_transfer *xfer;struct spi_device *spi = msg->spi; +struct tegra_qspi_client_data *cdata = spi->controller_data;u8 transfer_phase =0 ;u32 cmd1 =0 , dma_ctl =0 ;int ret =0 ;@@ -1059,6 +1074,10 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi,/* Enable Combined sequence mode */ val =tegra_qspi_readl (tqspi,QSPI_GLOBAL_CONFIG ); val |=QSPI_CMB_SEQ_EN ; +if (cdata->wait_polling) + val |=QSPI_TPM_WAIT_POLL_EN ; +else + val &= ~QSPI_TPM_WAIT_POLL_EN ;tegra_qspi_writel (tqspi, val,QSPI_GLOBAL_CONFIG );/* Process individual transfer list */ list_for_each_entry (xfer, &msg->transfers, transfer_list) {@@ -1158,6 +1177,8 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi, transfer_phase++; } + ret =0 ; + exit: msg->status = ret;@@ -1180,6 +1201,7 @@ static int tegra_qspi_non_combined_seq_xfer(struct tegra_qspi *tqspi,/* Disable Combined sequence mode */ val =tegra_qspi_readl (tqspi,QSPI_GLOBAL_CONFIG ); val &= ~QSPI_CMB_SEQ_EN ; + val &= ~QSPI_TPM_WAIT_POLL_EN ;tegra_qspi_writel (tqspi, val,QSPI_GLOBAL_CONFIG );list_for_each_entry (transfer, &msg->transfers, transfer_list) {struct spi_transfer *xfer = transfer;@@ -1439,24 +1461,28 @@ static struct tegra_qspi_soc_data tegra210_qspi_soc_data = { .has_dma = true, .cmb_xfer_capable = false, .cs_count = 1, + .has_wait_polling = false, };static struct tegra_qspi_soc_data tegra186_qspi_soc_data = { .has_dma = true, .cmb_xfer_capable = true, .cs_count =1 , + .has_wait_polling = false, };static struct tegra_qspi_soc_data tegra234_qspi_soc_data = { .has_dma = false, .cmb_xfer_capable = true, .cs_count =1 , + .has_wait_polling = true, };static struct tegra_qspi_soc_data tegra_grace_qspi_soc_data = { .has_dma = false, .cmb_xfer_capable = true, .cs_count =4 , + .has_wait_polling = true, };static const struct of_device_id tegra_qspi_of_match[] = {@@ -1509,6 +1535,7 @@ static int tegra_qspi_probe(struct platform_device *pdev)struct resource *r;int ret, qspi_irq;int bus_num; +u8 val =0 ; master =devm_spi_alloc_master (&pdev->dev,sizeof (*tqspi));if (!master)
drivers/spi/spi-tegra210-quad.c static int tegra_qspi_probe(struct platform_device *pdev) · line 1617
Quoted 6 lines
drivers/spi/spi-tegra210-quad.c +3
-0@@ -1585,6 +1612,10 @@ static int tegra_qspi_probe(struct platform_device *pdev) tqspi->spi_cs_timing1 =tegra_qspi_readl (tqspi,QSPI_CS_TIMING1 ); tqspi->spi_cs_timing2 =tegra_qspi_readl (tqspi,QSPI_CS_TIMING2 ); tqspi->def_command2_reg =tegra_qspi_readl (tqspi,QSPI_COMMAND2 ); + val =tegra_qspi_readl (tqspi,QSPI_GLOBAL_CONFIG ); + val &= ~QSPI_CMB_SEQ_EN ; + val &= ~QSPI_TPM_WAIT_POLL_EN ;
Don't we need to check here is the device support this TPM_WAIT_POLL?
Jon
Signature · 1 line
nvpublic
PATCH 3/3 spi: dt-bindings: Add wait state polling flag
In reply to Krishna YarlagaddaAdd flag to enable tpm wait state polling and Tegra Grace binding.
--- .../devicetree/bindings/spi/nvidia,tegra210-quad.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml +6 -0
@@ -20,6 +20,7 @@ properties: - nvidia,tegra186-qspi - nvidia,tegra194-qspi - nvidia,tegra234-qspi + - nvidia,tegra-grace-qspi reg: maxItems: 1
@@ -57,6 +58,11 @@ patternProperties: spi-tx-bus-width: enum: [1, 2, 4] + nvidia,wait-polling: + description: + Enable TPM wait state polling on supported chips. + type: boolean + nvidia,tx-clk-tap-delay: description: Delays the clock going out to device with this tap value.
Signature · 1 line
2.17.1
Re: [PATCH 3/3] spi: dt-bindings: Add wait state polling flag
Quoted 12 lines · Krishna Yarlagadda
Add flag to enable tpm wait state polling and Tegra Grace binding.
Signed-off-by Krishna Yarlagadda <[email protected]>--- .../devicetree/bindings/spi/nvidia,tegra210-quad.yaml | 6 ++++++ 1 file changed, 6 insertions(+)Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml +0
-0
Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml properties: · line 23
Quoted 4 lines
Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml +1
-0@@ -20,6 +20,7 @@ properties: - nvidia,tegra186-qspi - nvidia,tegra194-qspi - nvidia,tegra234-qspi + - nvidia,tegra-grace-qspi
nvidia,tegra241-qspi. Similarly in other places that refer to the chip name.
Mikko
Quoted 15 lines
Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml +5
-0reg: maxItems: 1@@ -57,6 +58,11 @@ patternProperties: spi-tx-bus-width: enum: [1, 2, 4] + nvidia,wait-polling: + description: + Enable TPM wait state polling on supported chips. + type: boolean + nvidia,tx-clk-tap-delay: description: Delays the clock going out to device with this tap value.
RE: [PATCH 3/3] spi: dt-bindings: Add wait state polling flag
Quoted 22 lines
-----Original Message-----
From: Mikko Perttunen <[email protected]>
Sent: 17 March 2022 14:13
To: Krishna Yarlagadda <[email protected]>; [email protected]; [email protected]; Jonathan Hunter <[email protected]>; [email protected]; [email protected]; Ashish Singhal <[email protected]>
Cc: Sowjanya Komatineni <[email protected]>; Laxman Dewangan <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 3/3] spi: dt-bindings: Add wait state polling flagExternal email: Use caution opening links or attachments
Review
Quoted 8 lines · Krishna Yarlagadda
Add flag to enable tpm wait state polling and Tegra Grace binding.
Signed-off-by Krishna Yarlagadda <[email protected]>--- .../devicetree/bindings/spi/nvidia,tegra210-quad.yaml | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml
Quoted 10 lines
Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml properties: · line 23
Quoted 8 lines
index
0296edd1de22..88b00fcad210100644Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml +1
-0@@ -20,6 +20,7 @@ properties: - nvidia,tegra186-qspi - nvidia,tegra194-qspi - nvidia,tegra234-qspi + - nvidia,tegra-grace-qspinvidia,tegra241-qspi. Similarly in other places that refer to the chip name.
Agree. Will change it to be consistent with rest of the chip patches.
Quoted 18 lines
Mikko
Quoted 15 lines
Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml +5
-0reg: maxItems: 1@@ -57,6 +58,11 @@ patternProperties: spi-tx-bus-width: enum: [1, 2, 4] + nvidia,wait-polling: + description: + Enable TPM wait state polling on supported chips. + type: boolean + nvidia,tx-clk-tap-delay: description: Delays the clock going out to device with this tap value.
Rob Herring
maintainerRe: [PATCH 3/3] spi: dt-bindings: Add wait state polling flag
In reply to Krishna YarlagaddaQuoted 1 line · Krishna Yarlagadda
Add flag to enable tpm wait state polling and Tegra Grace binding.
TPM
Quoted 19 lines
Signed-off-by Krishna Yarlagadda <[email protected]>--- .../devicetree/bindings/spi/nvidia,tegra210-quad.yaml | 6 ++++++ 1 file changed, 6 insertions(+)Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml +1
-0@@ -20,6 +20,7 @@ properties: - nvidia,tegra186-qspi - nvidia,tegra194-qspi - nvidia,tegra234-qspi + - nvidia,tegra-grace-qspi reg: maxItems: 1
Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml patternProperties: · line 63
Quoted 6 lines
Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml +3
-0@@ -57,6 +58,11 @@ patternProperties: spi-tx-bus-width: enum: [1, 2, 4] + nvidia,wait-polling: + description: + Enable TPM wait state polling on supported chips.
What's TPM?
Why is this not implied by the compatible string?
Also, how child node properties are handled has changed. See Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml. The NVidia specific properties should be refactored first before adding more.
Quoted 9 lines
Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml +2
-0+ type: boolean + nvidia,tx-clk-tap-delay: description: Delays the clock going out to device with this tap value.Signature · 1 line
2.17.1