Commit d23d8d7e069c3aca071b7f68d9c15d11f8d4c84d
Committed by
Tom Rini
1 parent
5c1214de8c
Exists in
master
and in
53 other branches
mmc: add support for write protection
Add generic mmc write protection functionality. Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Showing 16 changed files with 39 additions and 0 deletions Side-by-side Diff
- common/cmd_mmc.c
- drivers/mmc/arm_pl180_mmci.c
- drivers/mmc/bfin_sdh.c
- drivers/mmc/davinci_mmc.c
- drivers/mmc/fsl_esdhc.c
- drivers/mmc/ftsdc010_esdhc.c
- drivers/mmc/gen_atmel_mci.c
- drivers/mmc/mmc.c
- drivers/mmc/mmc_spi.c
- drivers/mmc/mxcmmc.c
- drivers/mmc/mxsmmc.c
- drivers/mmc/omap_hsmmc.c
- drivers/mmc/sdhci.c
- drivers/mmc/sh_mmcif.c
- drivers/mmc/tegra_mmc.c
- include/mmc.h
common/cmd_mmc.c
... | ... | @@ -282,6 +282,13 @@ |
282 | 282 | |
283 | 283 | mmc_init(mmc); |
284 | 284 | |
285 | + if ((state == MMC_WRITE || state == MMC_ERASE)) { | |
286 | + if (mmc_getwp(mmc) == 1) { | |
287 | + printf("Error: card is write protected!\n"); | |
288 | + return 1; | |
289 | + } | |
290 | + } | |
291 | + | |
285 | 292 | switch (state) { |
286 | 293 | case MMC_READ: |
287 | 294 | n = mmc->block_dev.block_read(curr_device, blk, |
drivers/mmc/arm_pl180_mmci.c
drivers/mmc/bfin_sdh.c
drivers/mmc/davinci_mmc.c
drivers/mmc/fsl_esdhc.c
drivers/mmc/ftsdc010_esdhc.c
drivers/mmc/gen_atmel_mci.c
drivers/mmc/mmc.c
... | ... | @@ -40,6 +40,23 @@ |
40 | 40 | static struct list_head mmc_devices; |
41 | 41 | static int cur_dev_num = -1; |
42 | 42 | |
43 | +int __weak board_mmc_getwp(struct mmc *mmc) | |
44 | +{ | |
45 | + return -1; | |
46 | +} | |
47 | + | |
48 | +int mmc_getwp(struct mmc *mmc) | |
49 | +{ | |
50 | + int wp; | |
51 | + | |
52 | + wp = board_mmc_getwp(mmc); | |
53 | + | |
54 | + if ((wp < 0) && mmc->getwp) | |
55 | + wp = mmc->getwp(mmc); | |
56 | + | |
57 | + return wp; | |
58 | +} | |
59 | + | |
43 | 60 | int __board_mmc_getcd(struct mmc *mmc) { |
44 | 61 | return -1; |
45 | 62 | } |
drivers/mmc/mmc_spi.c
drivers/mmc/mxcmmc.c
drivers/mmc/mxsmmc.c
drivers/mmc/omap_hsmmc.c
drivers/mmc/sdhci.c
drivers/mmc/sh_mmcif.c
drivers/mmc/tegra_mmc.c
include/mmc.h
... | ... | @@ -259,6 +259,7 @@ |
259 | 259 | void (*set_ios)(struct mmc *mmc); |
260 | 260 | int (*init)(struct mmc *mmc); |
261 | 261 | int (*getcd)(struct mmc *mmc); |
262 | + int (*getwp)(struct mmc *mmc); | |
262 | 263 | uint b_max; |
263 | 264 | }; |
264 | 265 | |
... | ... | @@ -274,6 +275,7 @@ |
274 | 275 | int board_mmc_getcd(struct mmc *mmc); |
275 | 276 | int mmc_switch_part(int dev_num, unsigned int part_num); |
276 | 277 | int mmc_getcd(struct mmc *mmc); |
278 | +int mmc_getwp(struct mmc *mmc); | |
277 | 279 | void spl_mmc_load(void) __noreturn; |
278 | 280 | |
279 | 281 | #ifdef CONFIG_GENERIC_MMC |