• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-cqtcocoa誰得pythonphprubygameguibathyscaphec翻訳計画中(planning stage)omegatframeworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Commit MetaInfo

Revisión19a29ff362d4cc9e7f420021de57e3193812d4c6 (tree)
Tiempo2022-07-27 15:19:09
AutorYing-Chun Liu (PaulLiu) <paul.liu@lina...>
CommiterJaehoon Chung

Log Message

drivers: mmc: write protect single boot area

Add features to write protect single boot area rather than all boot
areas.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>

Cambiar Resumen

Diferencia incremental

--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -863,6 +863,33 @@ int mmc_boot_wp(struct mmc *mmc)
863863 return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP, 1);
864864 }
865865
866+int mmc_boot_wp_single_partition(struct mmc *mmc, int partition)
867+{
868+ u8 value;
869+ int ret;
870+
871+ value = EXT_CSD_BOOT_WP_B_PWR_WP_EN;
872+
873+ if (partition == 0) {
874+ value |= EXT_CSD_BOOT_WP_B_SEC_WP_SEL;
875+ ret = mmc_switch(mmc,
876+ EXT_CSD_CMD_SET_NORMAL,
877+ EXT_CSD_BOOT_WP,
878+ value);
879+ } else if (partition == 1) {
880+ value |= EXT_CSD_BOOT_WP_B_SEC_WP_SEL;
881+ value |= EXT_CSD_BOOT_WP_B_PWR_WP_SEC_SEL;
882+ ret = mmc_switch(mmc,
883+ EXT_CSD_CMD_SET_NORMAL,
884+ EXT_CSD_BOOT_WP,
885+ value);
886+ } else {
887+ ret = mmc_boot_wp(mmc);
888+ }
889+
890+ return ret;
891+}
892+
866893 #if !CONFIG_IS_ENABLED(MMC_TINY)
867894 static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode,
868895 bool hsdowngrade)
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -308,6 +308,10 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx)
308308
309309 #define EXT_CSD_HS_CTRL_REL (1 << 0) /* host controlled WR_REL_SET */
310310
311+#define EXT_CSD_BOOT_WP_B_SEC_WP_SEL (0x80) /* enable partition selector */
312+#define EXT_CSD_BOOT_WP_B_PWR_WP_SEC_SEL (0x02) /* partition selector to protect */
313+#define EXT_CSD_BOOT_WP_B_PWR_WP_EN (0x01) /* power-on write-protect */
314+
311315 #define EXT_CSD_WR_DATA_REL_USR (1 << 0) /* user data area WR_REL */
312316 #define EXT_CSD_WR_DATA_REL_GP(x) (1 << ((x)+1)) /* GP part (x+1) WR_REL */
313317
@@ -991,6 +995,18 @@ int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd);
991995 */
992996 int mmc_boot_wp(struct mmc *mmc);
993997
998+/**
999+ * mmc_boot_wp_single_partition() - set write protection to a boot partition.
1000+ *
1001+ * This function sets a single boot partition to protect and leave the
1002+ * other partition writable.
1003+ *
1004+ * @param mmc the mmc device.
1005+ * @param partition 0 - first boot partition, 1 - second boot partition.
1006+ * @return 0 for success
1007+ */
1008+int mmc_boot_wp_single_partition(struct mmc *mmc, int partition);
1009+
9941010 static inline enum dma_data_direction mmc_get_dma_dir(struct mmc_data *data)
9951011 {
9961012 return data->flags & MMC_DATA_WRITE ? DMA_TO_DEVICE : DMA_FROM_DEVICE;