@@ -605,6 +605,7 @@ static int mmc_cmd_send_ext_csd(struct sd_card *sdcard, char *ext_csd)
605
605
#define MMC_EXT_CSD_ACCESS_CLEAR_BITS 0x02
606
606
#define MMC_EXT_CSD_ACCESS_WRITE_BYTE 0x03
607
607
608
+ #define EXT_CSD_BYTE_BOOT_CONFIG 179
608
609
#define EXT_CSD_BYTE_BUS_WIDTH 183
609
610
#define EXT_CSD_BYTE_HS_TIMING 185
610
611
#define EXT_CSD_BYTE_POWER_CLASS 187
@@ -666,6 +667,9 @@ static int mmc_card_identify(struct sd_card *sdcard)
666
667
if (sdcard -> ddr_support )
667
668
dbg_printf ("MMC: Dual Data Rate supported\n" );
668
669
670
+ sdcard -> boot_partition = (ext_csd [EXT_CSD_BYTE_BOOT_CONFIG ] >> 3 ) & 0x07 ;
671
+ dbg_printf ("MMC: Current boot partition: %d\n" , sdcard -> boot_partition );
672
+
669
673
return 0 ;
670
674
}
671
675
@@ -843,6 +847,30 @@ static int mmc_detect_buswidth(struct sd_card *sdcard)
843
847
844
848
}
845
849
850
+ #if defined(CONFIG_MMC_PART_1 ) || defined(CONFIG_MMC_PART_2 ) || defined(CONFIG_MMC_PART_CUR )
851
+ static int mmc_partition_select (struct sd_card * sdcard , unsigned int partition )
852
+ {
853
+ int ret ;
854
+ ret = mmc_cmd_switch_fun (sdcard ,
855
+ MMC_EXT_CSD_ACCESS_CLEAR_BITS ,
856
+ EXT_CSD_BYTE_BOOT_CONFIG ,
857
+ 0x07 );
858
+ if (ret )
859
+ return ret ;
860
+
861
+ ret = mmc_cmd_switch_fun (sdcard ,
862
+ MMC_EXT_CSD_ACCESS_SET_BITS ,
863
+ EXT_CSD_BYTE_BOOT_CONFIG ,
864
+ partition & 0x07 );
865
+ if (ret )
866
+ return ret ;
867
+
868
+ dbg_info ("MMC: partition %d selected\n" , partition & 0x07 );
869
+
870
+ return 0 ;
871
+ }
872
+ #endif
873
+
846
874
/*-----------------------------------------------------------------*/
847
875
848
876
/*
@@ -1094,6 +1122,25 @@ static int mmc_initialization(struct sd_card *sdcard)
1094
1122
console_printf ("MMC: DDR mode could not be enabled: %d\n" , ret );
1095
1123
}
1096
1124
1125
+ #ifdef CONFIG_MMC_PART_1
1126
+ ret = mmc_partition_select (sdcard , 1 );
1127
+ if (ret ) {
1128
+ console_printf ("MMC: Select boot partition 1 failed !\n" );
1129
+ return ret ;
1130
+ }
1131
+ #elif CONFIG_MMC_PART_2
1132
+ ret = mmc_partition_select (sdcard , 2 );
1133
+ if (ret ) {
1134
+ console_printf ("MMC: Select boot partition 2 failed !\n" );
1135
+ return ret ;
1136
+ }
1137
+ #elif CONFIG_MMC_PART_CUR
1138
+ ret = mmc_partition_select (sdcard , sdcard -> boot_partition );
1139
+ if (ret ) {
1140
+ console_printf ("MMC: Select current boot partition failed !\n" );
1141
+ return ret ;
1142
+ }
1143
+ #endif
1097
1144
return 0 ;
1098
1145
}
1099
1146
0 commit comments