32
32
#define SPINOR_REG_CYPRESS_CFR2_MEMLAT_11_24 0xb
33
33
#define SPINOR_REG_CYPRESS_CFR2_ADRBYT BIT(7)
34
34
#define SPINOR_REG_CYPRESS_CFR3 0x4
35
- #define SPINOR_REG_CYPRESS_CFR3V \
36
- (SPINOR_REG_CYPRESS_VREG + SPINOR_REG_CYPRESS_CFR3)
37
35
#define SPINOR_REG_CYPRESS_CFR3_PGSZ BIT(4) /* Page size. */
38
36
#define SPINOR_REG_CYPRESS_CFR5 0x6
39
37
#define SPINOR_REG_CYPRESS_CFR5_BIT6 BIT(6)
@@ -467,28 +465,17 @@ static int cypress_nor_set_addr_mode_nbytes(struct spi_nor *nor)
467
465
return 0 ;
468
466
}
469
467
470
- static int cypress_nor_get_page_size_single_chip (struct spi_nor * nor )
471
- {
472
- struct spi_mem_op op =
473
- CYPRESS_NOR_RD_ANY_REG_OP (nor -> params -> addr_mode_nbytes ,
474
- SPINOR_REG_CYPRESS_CFR3V , 0 ,
475
- nor -> bouncebuf );
476
- int ret ;
477
-
478
- ret = spi_nor_read_any_reg (nor , & op , nor -> reg_proto );
479
- if (ret )
480
- return ret ;
481
-
482
- if (nor -> bouncebuf [0 ] & SPINOR_REG_CYPRESS_CFR3_PGSZ )
483
- nor -> params -> page_size = 512 ;
484
- else
485
- nor -> params -> page_size = 256 ;
486
-
487
- return 0 ;
488
- }
489
-
490
-
491
- static int cypress_nor_get_page_size_mcp (struct spi_nor * nor )
468
+ /**
469
+ * cypress_nor_get_page_size() - Get flash page size configuration.
470
+ * @nor: pointer to a 'struct spi_nor'
471
+ *
472
+ * The BFPT table advertises a 512B or 256B page size depending on part but the
473
+ * page size is actually configurable (with the default being 256B). Read from
474
+ * CFR3V[4] and set the correct size.
475
+ *
476
+ * Return: 0 on success, -errno otherwise.
477
+ */
478
+ static int cypress_nor_get_page_size (struct spi_nor * nor )
492
479
{
493
480
struct spi_mem_op op =
494
481
CYPRESS_NOR_RD_ANY_REG_OP (nor -> params -> addr_mode_nbytes ,
@@ -518,23 +505,6 @@ static int cypress_nor_get_page_size_mcp(struct spi_nor *nor)
518
505
return 0 ;
519
506
}
520
507
521
- /**
522
- * cypress_nor_get_page_size() - Get flash page size configuration.
523
- * @nor: pointer to a 'struct spi_nor'
524
- *
525
- * The BFPT table advertises a 512B or 256B page size depending on part but the
526
- * page size is actually configurable (with the default being 256B). Read from
527
- * CFR3V[4] and set the correct size.
528
- *
529
- * Return: 0 on success, -errno otherwise.
530
- */
531
- static int cypress_nor_get_page_size (struct spi_nor * nor )
532
- {
533
- if (nor -> params -> n_dice )
534
- return cypress_nor_get_page_size_mcp (nor );
535
- return cypress_nor_get_page_size_single_chip (nor );
536
- }
537
-
538
508
static void cypress_nor_ecc_init (struct spi_nor * nor )
539
509
{
540
510
/*
@@ -571,20 +541,32 @@ s25fs256t_post_bfpt_fixup(struct spi_nor *nor,
571
541
if (nor -> bouncebuf [0 ])
572
542
return - ENODEV ;
573
543
574
- return cypress_nor_get_page_size ( nor ) ;
544
+ return 0 ;
575
545
}
576
546
577
547
static int s25fs256t_post_sfdp_fixup (struct spi_nor * nor )
578
548
{
579
549
struct spi_nor_flash_parameter * params = nor -> params ;
580
550
551
+ /*
552
+ * S25FS256T does not define the SCCR map, but we would like to use the
553
+ * same code base for both single and multi chip package devices, thus
554
+ * set the vreg_offset and n_dice to be able to do so.
555
+ */
556
+ params -> vreg_offset = devm_kmalloc (nor -> dev , sizeof (u32 ), GFP_KERNEL );
557
+ if (!params -> vreg_offset )
558
+ return - ENOMEM ;
559
+
560
+ params -> vreg_offset [0 ] = SPINOR_REG_CYPRESS_VREG ;
561
+ params -> n_dice = 1 ;
562
+
581
563
/* PP_1_1_4_4B is supported but missing in 4BAIT. */
582
564
params -> hwcaps .mask |= SNOR_HWCAPS_PP_1_1_4 ;
583
565
spi_nor_set_pp_settings (& params -> page_programs [SNOR_CMD_PP_1_1_4 ],
584
566
SPINOR_OP_PP_1_1_4_4B ,
585
567
SNOR_PROTO_1_1_4 );
586
568
587
- return 0 ;
569
+ return cypress_nor_get_page_size ( nor ) ;
588
570
}
589
571
590
572
static int s25fs256t_late_init (struct spi_nor * nor )
@@ -619,10 +601,20 @@ s25hx_t_post_bfpt_fixup(struct spi_nor *nor,
619
601
620
602
static int s25hx_t_post_sfdp_fixup (struct spi_nor * nor )
621
603
{
622
- struct spi_nor_erase_type * erase_type =
623
- nor -> params -> erase_map .erase_type ;
604
+ struct spi_nor_flash_parameter * params = nor -> params ;
605
+ struct spi_nor_erase_type * erase_type = params -> erase_map .erase_type ;
624
606
unsigned int i ;
625
607
608
+ if (!params -> n_dice || !params -> vreg_offset ) {
609
+ dev_err (nor -> dev , "%s failed. The volatile register offset could not be retrieved from SFDP.\n" ,
610
+ __func__ );
611
+ return - EOPNOTSUPP ;
612
+ }
613
+
614
+ /* The 2 Gb parts duplicate info and advertise 4 dice instead of 2. */
615
+ if (params -> size == SZ_256M )
616
+ params -> n_dice = 2 ;
617
+
626
618
/*
627
619
* In some parts, 3byte erase opcodes are advertised by 4BAIT.
628
620
* Convert them to 4byte erase opcodes.
@@ -640,23 +632,13 @@ static int s25hx_t_post_sfdp_fixup(struct spi_nor *nor)
640
632
}
641
633
}
642
634
643
- /* The 2 Gb parts duplicate info and advertise 4 dice instead of 2. */
644
- if (nor -> params -> size == SZ_256M )
645
- nor -> params -> n_dice = 2 ;
646
-
647
635
return cypress_nor_get_page_size (nor );
648
636
}
649
637
650
638
static int s25hx_t_late_init (struct spi_nor * nor )
651
639
{
652
640
struct spi_nor_flash_parameter * params = nor -> params ;
653
641
654
- if (!params -> n_dice || !params -> vreg_offset ) {
655
- dev_err (nor -> dev , "%s failed. The volatile register offset could not be retrieved from SFDP.\n" ,
656
- __func__ );
657
- return - EOPNOTSUPP ;
658
- }
659
-
660
642
/* Fast Read 4B requires mode cycles */
661
643
params -> reads [SNOR_CMD_READ_FAST ].num_mode_clocks = 8 ;
662
644
params -> ready = cypress_nor_sr_ready_and_clear ;
@@ -690,6 +672,17 @@ static int cypress_nor_set_octal_dtr(struct spi_nor *nor, bool enable)
690
672
static int s28hx_t_post_sfdp_fixup (struct spi_nor * nor )
691
673
{
692
674
struct spi_nor_flash_parameter * params = nor -> params ;
675
+
676
+ if (!params -> n_dice || !params -> vreg_offset ) {
677
+ dev_err (nor -> dev , "%s failed. The volatile register offset could not be retrieved from SFDP.\n" ,
678
+ __func__ );
679
+ return - EOPNOTSUPP ;
680
+ }
681
+
682
+ /* The 2 Gb parts duplicate info and advertise 4 dice instead of 2. */
683
+ if (params -> size == SZ_256M )
684
+ params -> n_dice = 2 ;
685
+
693
686
/*
694
687
* On older versions of the flash the xSPI Profile 1.0 table has the
695
688
* 8D-8D-8D Fast Read opcode as 0x00. But it actually should be 0xEE.
@@ -715,10 +708,6 @@ static int s28hx_t_post_sfdp_fixup(struct spi_nor *nor)
715
708
*/
716
709
params -> rdsr_addr_nbytes = 4 ;
717
710
718
- /* The 2 Gb parts duplicate info and advertise 4 dice instead of 2. */
719
- if (params -> size == SZ_256M )
720
- params -> n_dice = 2 ;
721
-
722
711
return cypress_nor_get_page_size (nor );
723
712
}
724
713
@@ -733,12 +722,6 @@ static int s28hx_t_late_init(struct spi_nor *nor)
733
722
{
734
723
struct spi_nor_flash_parameter * params = nor -> params ;
735
724
736
- if (!params -> n_dice || !params -> vreg_offset ) {
737
- dev_err (nor -> dev , "%s failed. The volatile register offset could not be retrieved from SFDP.\n" ,
738
- __func__ );
739
- return - EOPNOTSUPP ;
740
- }
741
-
742
725
params -> set_octal_dtr = cypress_nor_set_octal_dtr ;
743
726
params -> ready = cypress_nor_sr_ready_and_clear ;
744
727
cypress_nor_ecc_init (nor );
0 commit comments