57
57
#include <linux/spi/spi.h>
58
58
#include <linux/spi/spi-mem.h>
59
59
60
- /*
61
- * The driver only uses one single LUT entry, that is updated on
62
- * each call of exec_op(). Index 0 is preset at boot with a basic
63
- * read operation, so let's use the last entry (31).
64
- */
65
- #define SEQID_LUT 31
66
-
67
60
/* Registers used by the driver */
68
61
#define FSPI_MCR0 0x00
69
62
#define FSPI_MCR0_AHB_TIMEOUT (x ) ((x) << 24)
263
256
#define FSPI_TFDR 0x180
264
257
265
258
#define FSPI_LUT_BASE 0x200
266
- #define FSPI_LUT_OFFSET (SEQID_LUT * 4 * 4)
267
- #define FSPI_LUT_REG (idx ) \
268
- (FSPI_LUT_BASE + FSPI_LUT_OFFSET + (idx) * 4)
269
259
270
260
/* register map end */
271
261
@@ -341,6 +331,7 @@ struct nxp_fspi_devtype_data {
341
331
unsigned int txfifo ;
342
332
unsigned int ahb_buf_size ;
343
333
unsigned int quirks ;
334
+ unsigned int lut_num ;
344
335
bool little_endian ;
345
336
};
346
337
@@ -349,6 +340,7 @@ static struct nxp_fspi_devtype_data lx2160a_data = {
349
340
.txfifo = SZ_1K , /* (128 * 64 bits) */
350
341
.ahb_buf_size = SZ_2K , /* (256 * 64 bits) */
351
342
.quirks = 0 ,
343
+ .lut_num = 32 ,
352
344
.little_endian = true, /* little-endian */
353
345
};
354
346
@@ -357,6 +349,7 @@ static struct nxp_fspi_devtype_data imx8mm_data = {
357
349
.txfifo = SZ_1K , /* (128 * 64 bits) */
358
350
.ahb_buf_size = SZ_2K , /* (256 * 64 bits) */
359
351
.quirks = 0 ,
352
+ .lut_num = 32 ,
360
353
.little_endian = true, /* little-endian */
361
354
};
362
355
@@ -365,6 +358,7 @@ static struct nxp_fspi_devtype_data imx8qxp_data = {
365
358
.txfifo = SZ_1K , /* (128 * 64 bits) */
366
359
.ahb_buf_size = SZ_2K , /* (256 * 64 bits) */
367
360
.quirks = 0 ,
361
+ .lut_num = 32 ,
368
362
.little_endian = true, /* little-endian */
369
363
};
370
364
@@ -373,6 +367,7 @@ static struct nxp_fspi_devtype_data imx8dxl_data = {
373
367
.txfifo = SZ_1K , /* (128 * 64 bits) */
374
368
.ahb_buf_size = SZ_2K , /* (256 * 64 bits) */
375
369
.quirks = FSPI_QUIRK_USE_IP_ONLY ,
370
+ .lut_num = 32 ,
376
371
.little_endian = true, /* little-endian */
377
372
};
378
373
@@ -544,6 +539,8 @@ static void nxp_fspi_prepare_lut(struct nxp_fspi *f,
544
539
void __iomem * base = f -> iobase ;
545
540
u32 lutval [4 ] = {};
546
541
int lutidx = 1 , i ;
542
+ u32 lut_offset = (f -> devtype_data -> lut_num - 1 ) * 4 * 4 ;
543
+ u32 target_lut_reg ;
547
544
548
545
/* cmd */
549
546
lutval [0 ] |= LUT_DEF (0 , LUT_CMD , LUT_PAD (op -> cmd .buswidth ),
@@ -588,8 +585,10 @@ static void nxp_fspi_prepare_lut(struct nxp_fspi *f,
588
585
fspi_writel (f , FSPI_LCKER_UNLOCK , f -> iobase + FSPI_LCKCR );
589
586
590
587
/* fill LUT */
591
- for (i = 0 ; i < ARRAY_SIZE (lutval ); i ++ )
592
- fspi_writel (f , lutval [i ], base + FSPI_LUT_REG (i ));
588
+ for (i = 0 ; i < ARRAY_SIZE (lutval ); i ++ ) {
589
+ target_lut_reg = FSPI_LUT_BASE + lut_offset + i * 4 ;
590
+ fspi_writel (f , lutval [i ], base + target_lut_reg );
591
+ }
593
592
594
593
dev_dbg (f -> dev , "CMD[%02x] lutval[0:%08x 1:%08x 2:%08x 3:%08x], size: 0x%08x\n" ,
595
594
op -> cmd .opcode , lutval [0 ], lutval [1 ], lutval [2 ], lutval [3 ], op -> data .nbytes );
@@ -874,7 +873,7 @@ static int nxp_fspi_do_op(struct nxp_fspi *f, const struct spi_mem_op *op)
874
873
void __iomem * base = f -> iobase ;
875
874
int seqnum = 0 ;
876
875
int err = 0 ;
877
- u32 reg ;
876
+ u32 reg , seqid_lut ;
878
877
879
878
reg = fspi_readl (f , base + FSPI_IPRXFCR );
880
879
/* invalid RXFIFO first */
@@ -890,8 +889,9 @@ static int nxp_fspi_do_op(struct nxp_fspi *f, const struct spi_mem_op *op)
890
889
* the LUT at each exec_op() call. And also specify the DATA
891
890
* length, since it's has not been specified in the LUT.
892
891
*/
892
+ seqid_lut = f -> devtype_data -> lut_num - 1 ;
893
893
fspi_writel (f , op -> data .nbytes |
894
- (SEQID_LUT << FSPI_IPCR1_SEQID_SHIFT ) |
894
+ (seqid_lut << FSPI_IPCR1_SEQID_SHIFT ) |
895
895
(seqnum << FSPI_IPCR1_SEQNUM_SHIFT ),
896
896
base + FSPI_IPCR1 );
897
897
@@ -1015,7 +1015,7 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)
1015
1015
{
1016
1016
void __iomem * base = f -> iobase ;
1017
1017
int ret , i ;
1018
- u32 reg ;
1018
+ u32 reg , seqid_lut ;
1019
1019
1020
1020
/* disable and unprepare clock to avoid glitch pass to controller */
1021
1021
nxp_fspi_clk_disable_unprep (f );
@@ -1090,11 +1090,17 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)
1090
1090
fspi_writel (f , reg , base + FSPI_FLSHB1CR1 );
1091
1091
fspi_writel (f , reg , base + FSPI_FLSHB2CR1 );
1092
1092
1093
+ /*
1094
+ * The driver only uses one single LUT entry, that is updated on
1095
+ * each call of exec_op(). Index 0 is preset at boot with a basic
1096
+ * read operation, so let's use the last entry.
1097
+ */
1098
+ seqid_lut = f -> devtype_data -> lut_num - 1 ;
1093
1099
/* AHB Read - Set lut sequence ID for all CS. */
1094
- fspi_writel (f , SEQID_LUT , base + FSPI_FLSHA1CR2 );
1095
- fspi_writel (f , SEQID_LUT , base + FSPI_FLSHA2CR2 );
1096
- fspi_writel (f , SEQID_LUT , base + FSPI_FLSHB1CR2 );
1097
- fspi_writel (f , SEQID_LUT , base + FSPI_FLSHB2CR2 );
1100
+ fspi_writel (f , seqid_lut , base + FSPI_FLSHA1CR2 );
1101
+ fspi_writel (f , seqid_lut , base + FSPI_FLSHA2CR2 );
1102
+ fspi_writel (f , seqid_lut , base + FSPI_FLSHB1CR2 );
1103
+ fspi_writel (f , seqid_lut , base + FSPI_FLSHB2CR2 );
1098
1104
1099
1105
f -> selected = -1 ;
1100
1106
0 commit comments