196
196
* controller. These can be changed when board is initialized with the
197
197
* Segment Address Registers.
198
198
*/
199
- static const AspeedSegments aspeed_2400_spi1_segments [];
200
199
static const AspeedSegments aspeed_2500_spi1_segments [];
201
200
static const AspeedSegments aspeed_2500_spi2_segments [];
202
201
@@ -382,15 +381,15 @@ static inline int aspeed_smc_flash_cmd(const AspeedSMCFlash *fl)
382
381
return cmd ;
383
382
}
384
383
385
- static inline int aspeed_smc_flash_is_4byte (const AspeedSMCFlash * fl )
384
+ static inline int aspeed_smc_flash_addr_width (const AspeedSMCFlash * fl )
386
385
{
387
386
const AspeedSMCState * s = fl -> controller ;
388
387
AspeedSMCClass * asc = ASPEED_SMC_GET_CLASS (s );
389
388
390
- if (asc -> segments == aspeed_2400_spi1_segments ) {
391
- return s -> regs [ s -> r_ctrl0 ] & CTRL_AST2400_SPI_4BYTE ;
389
+ if (asc -> addr_width ) {
390
+ return asc -> addr_width ( s ) ;
392
391
} else {
393
- return s -> regs [s -> r_ce_ctrl ] & (1 << (CTRL_EXTENDED0 + fl -> cs ));
392
+ return s -> regs [s -> r_ce_ctrl ] & (1 << (CTRL_EXTENDED0 + fl -> cs )) ? 4 : 3 ;
394
393
}
395
394
}
396
395
@@ -450,7 +449,7 @@ static void aspeed_smc_flash_setup(AspeedSMCFlash *fl, uint32_t addr)
450
449
{
451
450
const AspeedSMCState * s = fl -> controller ;
452
451
uint8_t cmd = aspeed_smc_flash_cmd (fl );
453
- int i = aspeed_smc_flash_is_4byte (fl ) ? 4 : 3 ;
452
+ int i = aspeed_smc_flash_addr_width (fl );
454
453
455
454
/* Flash access can not exceed CS segment */
456
455
addr = aspeed_smc_check_segment_addr (fl , addr );
@@ -558,7 +557,7 @@ static bool aspeed_smc_do_snoop(AspeedSMCFlash *fl, uint64_t data,
558
557
unsigned size )
559
558
{
560
559
AspeedSMCState * s = fl -> controller ;
561
- uint8_t addr_width = aspeed_smc_flash_is_4byte (fl ) ? 4 : 3 ;
560
+ uint8_t addr_width = aspeed_smc_flash_addr_width (fl );
562
561
563
562
trace_aspeed_smc_do_snoop (fl -> cs , s -> snoop_index , s -> snoop_dummies ,
564
563
(uint8_t ) data & 0xff );
@@ -1384,6 +1383,11 @@ static const AspeedSegments aspeed_2400_spi1_segments[] = {
1384
1383
{ 0x30000000 , 64 * MiB },
1385
1384
};
1386
1385
1386
+ static int aspeed_2400_spi1_addr_width (const AspeedSMCState * s )
1387
+ {
1388
+ return s -> regs [R_SPI_CTRL0 ] & CTRL_AST2400_SPI_4BYTE ? 4 : 3 ;
1389
+ }
1390
+
1387
1391
static void aspeed_2400_spi1_class_init (ObjectClass * klass , void * data )
1388
1392
{
1389
1393
DeviceClass * dc = DEVICE_CLASS (klass );
@@ -1405,6 +1409,7 @@ static void aspeed_2400_spi1_class_init(ObjectClass *klass, void *data)
1405
1409
asc -> segment_to_reg = aspeed_smc_segment_to_reg ;
1406
1410
asc -> reg_to_segment = aspeed_smc_reg_to_segment ;
1407
1411
asc -> dma_ctrl = aspeed_smc_dma_ctrl ;
1412
+ asc -> addr_width = aspeed_2400_spi1_addr_width ;
1408
1413
}
1409
1414
1410
1415
static const TypeInfo aspeed_2400_spi1_info = {
0 commit comments