Skip to content

Commit 70c0b17

Browse files
Larisa Grigorebroonie
authored andcommitted
spi: spi-fsl-dspi: Add config and regmaps for S32G platforms
S32G adds SPI_{T,R}XFR4 and extends SPI_CTAR registers to 5. Add the new regmaps, configs and bits. dspi_volatile_ranges gets SPI_{T,R}XFR4 added which affects all platforms, however they are further limited by dspi_yes_ranges. Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com> Signed-off-by: James Clark <james.clark@linaro.org> Link: https://patch.msgid.link/20250522-james-nxp-spi-v2-6-bea884630cfb@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 1672b06 commit 70c0b17

1 file changed

Lines changed: 36 additions & 3 deletions

File tree

drivers/spi/spi-fsl-dspi.c

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#define SPI_TCR 0x08
3636
#define SPI_TCR_GET_TCNT(x) (((x) & GENMASK(31, 16)) >> 16)
3737

38-
#define SPI_CTAR(x) (0x0c + (((x) & GENMASK(1, 0)) * 4))
38+
#define SPI_CTAR(x) (0x0c + (((x) & GENMASK(2, 0)) * 4))
3939
#define SPI_CTAR_FMSZ(x) (((x) << 27) & GENMASK(30, 27))
4040
#define SPI_CTAR_CPOL BIT(26)
4141
#define SPI_CTAR_CPHA BIT(25)
@@ -93,12 +93,14 @@
9393
#define SPI_TXFR1 0x40
9494
#define SPI_TXFR2 0x44
9595
#define SPI_TXFR3 0x48
96+
#define SPI_TXFR4 0x4C
9697
#define SPI_RXFR0 0x7c
9798
#define SPI_RXFR1 0x80
9899
#define SPI_RXFR2 0x84
99100
#define SPI_RXFR3 0x88
101+
#define SPI_RXFR4 0x8C
100102

101-
#define SPI_CTARE(x) (0x11c + (((x) & GENMASK(1, 0)) * 4))
103+
#define SPI_CTARE(x) (0x11c + (((x) & GENMASK(2, 0)) * 4))
102104
#define SPI_CTARE_FMSZE(x) (((x) & 0x1) << 16)
103105
#define SPI_CTARE_DTCP(x) ((x) & 0x7ff)
104106

@@ -136,6 +138,7 @@ enum {
136138
LX2160A,
137139
MCF5441X,
138140
VF610,
141+
S32G,
139142
};
140143

141144
static const struct regmap_range dspi_yes_ranges[] = {
@@ -147,15 +150,29 @@ static const struct regmap_range dspi_yes_ranges[] = {
147150
regmap_reg_range(SPI_SREX, SPI_SREX),
148151
};
149152

153+
static const struct regmap_range s32g_dspi_yes_ranges[] = {
154+
regmap_reg_range(SPI_MCR, SPI_MCR),
155+
regmap_reg_range(SPI_TCR, SPI_CTAR(5)),
156+
regmap_reg_range(SPI_SR, SPI_TXFR4),
157+
regmap_reg_range(SPI_RXFR0, SPI_RXFR4),
158+
regmap_reg_range(SPI_CTARE(0), SPI_CTARE(5)),
159+
regmap_reg_range(SPI_SREX, SPI_SREX),
160+
};
161+
150162
static const struct regmap_access_table dspi_access_table = {
151163
.yes_ranges = dspi_yes_ranges,
152164
.n_yes_ranges = ARRAY_SIZE(dspi_yes_ranges),
153165
};
154166

167+
static const struct regmap_access_table s32g_dspi_access_table = {
168+
.yes_ranges = s32g_dspi_yes_ranges,
169+
.n_yes_ranges = ARRAY_SIZE(s32g_dspi_yes_ranges),
170+
};
171+
155172
static const struct regmap_range dspi_volatile_ranges[] = {
156173
regmap_reg_range(SPI_MCR, SPI_TCR),
157174
regmap_reg_range(SPI_SR, SPI_SR),
158-
regmap_reg_range(SPI_PUSHR, SPI_RXFR3),
175+
regmap_reg_range(SPI_PUSHR, SPI_RXFR4),
159176
regmap_reg_range(SPI_SREX, SPI_SREX),
160177
};
161178

@@ -167,6 +184,7 @@ static const struct regmap_access_table dspi_volatile_table = {
167184
enum {
168185
DSPI_REGMAP,
169186
DSPI_XSPI_REGMAP,
187+
S32G_DSPI_XSPI_REGMAP,
170188
DSPI_PUSHR,
171189
};
172190

@@ -189,6 +207,15 @@ static const struct regmap_config dspi_regmap_config[] = {
189207
.rd_table = &dspi_access_table,
190208
.wr_table = &dspi_access_table,
191209
},
210+
[S32G_DSPI_XSPI_REGMAP] = {
211+
.reg_bits = 32,
212+
.val_bits = 32,
213+
.reg_stride = 4,
214+
.max_register = SPI_SREX,
215+
.volatile_table = &dspi_volatile_table,
216+
.wr_table = &s32g_dspi_access_table,
217+
.rd_table = &s32g_dspi_access_table,
218+
},
192219
[DSPI_PUSHR] = {
193220
.name = "pushr",
194221
.reg_bits = 16,
@@ -263,6 +290,12 @@ static const struct fsl_dspi_devtype_data devtype_data[] = {
263290
.fifo_size = 16,
264291
.regmap = &dspi_regmap_config[DSPI_REGMAP],
265292
},
293+
[S32G] = {
294+
.trans_mode = DSPI_XSPI_MODE,
295+
.max_clock_factor = 1,
296+
.fifo_size = 5,
297+
.regmap = &dspi_regmap_config[S32G_DSPI_XSPI_REGMAP],
298+
},
266299
};
267300

268301
struct fsl_dspi_dma {

0 commit comments

Comments
 (0)