Skip to content

Commit 35f2b9a

Browse files
committed
spi: tegra quad: Add Tegra Grace features
Merge series from Krishna Yarlagadda <kyarlagadda@nvidia.com>: Add multiple chip select lines supported on Tegra 241
2 parents 41ecad2 + 4f37809 commit 35f2b9a

File tree

4 files changed

+66
-23
lines changed

4 files changed

+66
-23
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/spi/nvidia,tegra210-quad-peripheral-props.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Peripheral properties for Tegra Quad SPI Controller
8+
9+
maintainers:
10+
- Thierry Reding <thierry.reding@gmail.com>
11+
- Jonathan Hunter <jonathanh@nvidia.com>
12+
13+
properties:
14+
nvidia,tx-clk-tap-delay:
15+
description:
16+
Delays the clock going out to device with this tap value.
17+
Tap value varies based on platform design trace lengths from Tegra
18+
QSPI to corresponding slave device.
19+
$ref: /schemas/types.yaml#/definitions/uint32
20+
minimum: 0
21+
maximum: 31
22+
23+
nvidia,rx-clk-tap-delay:
24+
description:
25+
Delays the clock coming in from the device with this tap value.
26+
Tap value varies based on platform design trace lengths from Tegra
27+
QSPI to corresponding slave device.
28+
$ref: /schemas/types.yaml#/definitions/uint32
29+
minimum: 0
30+
maximum: 255
31+
32+
unevaluatedProperties: true
33+

Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ properties:
2020
- nvidia,tegra186-qspi
2121
- nvidia,tegra194-qspi
2222
- nvidia,tegra234-qspi
23+
- nvidia,tegra241-qspi
2324

2425
reg:
2526
maxItems: 1
@@ -57,27 +58,6 @@ patternProperties:
5758
spi-tx-bus-width:
5859
enum: [1, 2, 4]
5960

60-
nvidia,tx-clk-tap-delay:
61-
description:
62-
Delays the clock going out to device with this tap value.
63-
Tap value varies based on platform design trace lengths from Tegra
64-
QSPI to corresponding slave device.
65-
$ref: /schemas/types.yaml#/definitions/uint32
66-
minimum: 0
67-
maximum: 31
68-
69-
nvidia,rx-clk-tap-delay:
70-
description:
71-
Delays the clock coming in from the device with this tap value.
72-
Tap value varies based on platform design trace lengths from Tegra
73-
QSPI to corresponding slave device.
74-
$ref: /schemas/types.yaml#/definitions/uint32
75-
minimum: 0
76-
maximum: 255
77-
78-
required:
79-
- reg
80-
8161
required:
8262
- compatible
8363
- reg

Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,6 @@ properties:
117117
allOf:
118118
- $ref: cdns,qspi-nor-peripheral-props.yaml#
119119
- $ref: samsung,spi-peripheral-props.yaml#
120+
- $ref: nvidia,tegra210-quad-peripheral-props.yaml#
120121

121122
additionalProperties: true

drivers/spi/spi-tegra210-quad.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@
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)
@@ -154,6 +164,7 @@
154164
struct tegra_qspi_soc_data {
155165
bool has_dma;
156166
bool cmb_xfer_capable;
167+
unsigned int cs_count;
157168
};
158169

159170
struct 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)
14251438
static struct tegra_qspi_soc_data tegra210_qspi_soc_data = {
14261439
.has_dma = true,
14271440
.cmb_xfer_capable = false,
1441+
.cs_count = 1,
14281442
};
14291443

14301444
static struct tegra_qspi_soc_data tegra186_qspi_soc_data = {
14311445
.has_dma = true,
14321446
.cmb_xfer_capable = true,
1447+
.cs_count = 1,
14331448
};
14341449

14351450
static 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

14401462
static 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

Comments
 (0)