84
84
85
85
#define SPIFMC_MAX_READ_SIZE 0x10000
86
86
87
+ struct sg204x_spifmc_chip_info {
88
+ bool has_opt_reg ;
89
+ u32 rd_fifo_int_trigger_level ;
90
+ };
91
+
87
92
struct sg2044_spifmc {
88
93
struct spi_controller * ctrl ;
89
94
void __iomem * io_base ;
90
95
struct device * dev ;
91
96
struct mutex lock ;
92
97
struct clk * clk ;
98
+ const struct sg204x_spifmc_chip_info * chip_info ;
93
99
};
94
100
95
101
static int sg2044_spifmc_wait_int (struct sg2044_spifmc * spifmc , u8 int_type )
@@ -139,7 +145,7 @@ static ssize_t sg2044_spifmc_read_64k(struct sg2044_spifmc *spifmc,
139
145
140
146
reg = sg2044_spifmc_init_reg (spifmc );
141
147
reg |= (op -> addr .nbytes + op -> dummy .nbytes ) << SPIFMC_TRAN_CSR_ADDR_BYTES_SHIFT ;
142
- reg |= SPIFMC_TRAN_CSR_FIFO_TRG_LVL_8_BYTE ;
148
+ reg |= spifmc -> chip_info -> rd_fifo_int_trigger_level ;
143
149
reg |= SPIFMC_TRAN_CSR_WITH_CMD ;
144
150
reg |= SPIFMC_TRAN_CSR_TRAN_MODE_RX ;
145
151
@@ -335,7 +341,8 @@ static ssize_t sg2044_spifmc_trans_reg(struct sg2044_spifmc *spifmc,
335
341
reg |= SPIFMC_TRAN_CSR_TRAN_MODE_RX ;
336
342
reg |= SPIFMC_TRAN_CSR_TRAN_MODE_TX ;
337
343
338
- writel (SPIFMC_OPT_DISABLE_FIFO_FLUSH , spifmc -> io_base + SPIFMC_OPT );
344
+ if (spifmc -> chip_info -> has_opt_reg )
345
+ writel (SPIFMC_OPT_DISABLE_FIFO_FLUSH , spifmc -> io_base + SPIFMC_OPT );
339
346
} else {
340
347
/*
341
348
* If write values to the Status Register,
@@ -457,6 +464,11 @@ static int sg2044_spifmc_probe(struct platform_device *pdev)
457
464
ret = devm_mutex_init (dev , & spifmc -> lock );
458
465
if (ret )
459
466
return ret ;
467
+ spifmc -> chip_info = device_get_match_data (& pdev -> dev );
468
+ if (!spifmc -> chip_info ) {
469
+ dev_err (& pdev -> dev , "Failed to get specific chip info\n" );
470
+ return - EINVAL ;
471
+ }
460
472
461
473
sg2044_spifmc_init (spifmc );
462
474
sg2044_spifmc_init_reg (spifmc );
@@ -468,8 +480,19 @@ static int sg2044_spifmc_probe(struct platform_device *pdev)
468
480
return 0 ;
469
481
}
470
482
483
+ static const struct sg204x_spifmc_chip_info sg2044_chip_info = {
484
+ .has_opt_reg = true,
485
+ .rd_fifo_int_trigger_level = SPIFMC_TRAN_CSR_FIFO_TRG_LVL_8_BYTE ,
486
+ };
487
+
488
+ static const struct sg204x_spifmc_chip_info sg2042_chip_info = {
489
+ .has_opt_reg = false,
490
+ .rd_fifo_int_trigger_level = SPIFMC_TRAN_CSR_FIFO_TRG_LVL_1_BYTE ,
491
+ };
492
+
471
493
static const struct of_device_id sg2044_spifmc_match [] = {
472
- { .compatible = "sophgo,sg2044-spifmc-nor" },
494
+ { .compatible = "sophgo,sg2044-spifmc-nor" , .data = & sg2044_chip_info },
495
+ { .compatible = "sophgo,sg2042-spifmc-nor" , .data = & sg2042_chip_info },
473
496
{ /* sentinel */ }
474
497
};
475
498
MODULE_DEVICE_TABLE (of , sg2044_spifmc_match );
0 commit comments