3737#define QSPI_RX_EN BIT(12)
3838#define QSPI_CS_SW_VAL BIT(20)
3939#define QSPI_CS_SW_HW BIT(21)
40+
41+ #define QSPI_CS_POL_INACTIVE (n ) (1 << (22 + (n)))
42+ #define QSPI_CS_POL_INACTIVE_MASK (0xF << 22)
43+ #define QSPI_CS_SEL_0 (0 << 26)
44+ #define QSPI_CS_SEL_1 (1 << 26)
45+ #define QSPI_CS_SEL_2 (2 << 26)
46+ #define QSPI_CS_SEL_3 (3 << 26)
47+ #define QSPI_CS_SEL_MASK (3 << 26)
48+ #define QSPI_CS_SEL (x ) (((x) & 0x3) << 26)
49+
4050#define QSPI_CONTROL_MODE_0 (0 << 28)
4151#define QSPI_CONTROL_MODE_3 (3 << 28)
4252#define QSPI_CONTROL_MODE_MASK (3 << 28)
154164struct tegra_qspi_soc_data {
155165 bool has_dma ;
156166 bool cmb_xfer_capable ;
167+ unsigned int cs_count ;
157168};
158169
159170struct tegra_qspi_client_data {
@@ -812,6 +823,7 @@ static u32 tegra_qspi_setup_transfer_one(struct spi_device *spi, struct spi_tran
812823 tegra_qspi_mask_clear_irq (tqspi );
813824
814825 command1 = tqspi -> def_command1_reg ;
826+ command1 |= QSPI_CS_SEL (spi -> chip_select );
815827 command1 |= QSPI_BIT_LENGTH (bits_per_word - 1 );
816828
817829 command1 &= ~QSPI_CONTROL_MODE_MASK ;
@@ -941,10 +953,11 @@ static int tegra_qspi_setup(struct spi_device *spi)
941953
942954 /* keep default cs state to inactive */
943955 val = tqspi -> def_command1_reg ;
956+ val |= QSPI_CS_SEL (spi -> chip_select );
944957 if (spi -> mode & SPI_CS_HIGH )
945- val &= ~QSPI_CS_SW_VAL ;
958+ val &= ~QSPI_CS_POL_INACTIVE ( spi -> chip_select ) ;
946959 else
947- val |= QSPI_CS_SW_VAL ;
960+ val |= QSPI_CS_POL_INACTIVE ( spi -> chip_select ) ;
948961
949962 tqspi -> def_command1_reg = val ;
950963 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)
14251438static struct tegra_qspi_soc_data tegra210_qspi_soc_data = {
14261439 .has_dma = true,
14271440 .cmb_xfer_capable = false,
1441+ .cs_count = 1 ,
14281442};
14291443
14301444static struct tegra_qspi_soc_data tegra186_qspi_soc_data = {
14311445 .has_dma = true,
14321446 .cmb_xfer_capable = true,
1447+ .cs_count = 1 ,
14331448};
14341449
14351450static struct tegra_qspi_soc_data tegra234_qspi_soc_data = {
14361451 .has_dma = false,
14371452 .cmb_xfer_capable = true,
1453+ .cs_count = 1 ,
1454+ };
1455+
1456+ static struct tegra_qspi_soc_data tegra241_qspi_soc_data = {
1457+ .has_dma = false,
1458+ .cmb_xfer_capable = true,
1459+ .cs_count = 4 ,
14381460};
14391461
14401462static const struct of_device_id tegra_qspi_of_match [] = {
@@ -1450,6 +1472,9 @@ static const struct of_device_id tegra_qspi_of_match[] = {
14501472 }, {
14511473 .compatible = "nvidia,tegra234-qspi" ,
14521474 .data = & tegra234_qspi_soc_data ,
1475+ }, {
1476+ .compatible = "nvidia,tegra241-qspi" ,
1477+ .data = & tegra241_qspi_soc_data ,
14531478 },
14541479 {}
14551480};
@@ -1467,6 +1492,9 @@ static const struct acpi_device_id tegra_qspi_acpi_match[] = {
14671492 }, {
14681493 .id = "NVDA1413" ,
14691494 .driver_data = (kernel_ulong_t )& tegra234_qspi_soc_data ,
1495+ }, {
1496+ .id = "NVDA1513" ,
1497+ .driver_data = (kernel_ulong_t )& tegra241_qspi_soc_data ,
14701498 },
14711499 {}
14721500};
@@ -1506,6 +1534,7 @@ static int tegra_qspi_probe(struct platform_device *pdev)
15061534 spin_lock_init (& tqspi -> lock );
15071535
15081536 tqspi -> soc_data = device_get_match_data (& pdev -> dev );
1537+ master -> num_chipselect = tqspi -> soc_data -> cs_count ;
15091538 r = platform_get_resource (pdev , IORESOURCE_MEM , 0 );
15101539 tqspi -> base = devm_ioremap_resource (& pdev -> dev , r );
15111540 if (IS_ERR (tqspi -> base ))
0 commit comments