mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 07:31:15 +00:00
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>
This commit is contained in:
parent
5c1214de8c
commit
d23d8d7e06
16 changed files with 39 additions and 0 deletions
|
@ -282,6 +282,13 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
|
||||
mmc_init(mmc);
|
||||
|
||||
if ((state == MMC_WRITE || state == MMC_ERASE)) {
|
||||
if (mmc_getwp(mmc) == 1) {
|
||||
printf("Error: card is write protected!\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case MMC_READ:
|
||||
n = mmc->block_dev.block_read(curr_device, blk,
|
||||
|
|
|
@ -377,6 +377,7 @@ int arm_pl180_mmci_init(struct pl180_mmc_host *host)
|
|||
dev->set_ios = host_set_ios;
|
||||
dev->init = mmc_host_reset;
|
||||
dev->getcd = NULL;
|
||||
dev->getwp = NULL;
|
||||
dev->host_caps = host->caps;
|
||||
dev->voltages = host->voltages;
|
||||
dev->f_min = host->clock_min;
|
||||
|
|
|
@ -251,6 +251,7 @@ int bfin_mmc_init(bd_t *bis)
|
|||
mmc->set_ios = bfin_sdh_set_ios;
|
||||
mmc->init = bfin_sdh_init;
|
||||
mmc->getcd = NULL;
|
||||
mmc->getwp = NULL;
|
||||
mmc->host_caps = MMC_MODE_4BIT;
|
||||
|
||||
mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
|
||||
|
|
|
@ -388,6 +388,7 @@ int davinci_mmc_init(bd_t *bis, struct davinci_mmc *host)
|
|||
mmc->set_ios = dmmc_set_ios;
|
||||
mmc->init = dmmc_init;
|
||||
mmc->getcd = NULL;
|
||||
mmc->getwp = NULL;
|
||||
|
||||
mmc->f_min = 200000;
|
||||
mmc->f_max = 25000000;
|
||||
|
|
|
@ -552,6 +552,7 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
|
|||
mmc->set_ios = esdhc_set_ios;
|
||||
mmc->init = esdhc_init;
|
||||
mmc->getcd = esdhc_getcd;
|
||||
mmc->getwp = NULL;
|
||||
|
||||
voltage_caps = 0;
|
||||
caps = regs->hostcapblt;
|
||||
|
|
|
@ -666,6 +666,7 @@ int ftsdc010_mmc_init(int dev_index)
|
|||
mmc->set_ios = ftsdc010_set_ios;
|
||||
mmc->init = ftsdc010_core_init;
|
||||
mmc->getcd = NULL;
|
||||
mmc->getwp = NULL;
|
||||
|
||||
mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
|
||||
|
||||
|
|
|
@ -349,6 +349,7 @@ int atmel_mci_init(void *regs)
|
|||
mmc->set_ios = mci_set_ios;
|
||||
mmc->init = mci_init;
|
||||
mmc->getcd = NULL;
|
||||
mmc->getwp = NULL;
|
||||
|
||||
/* need to be able to pass these in on a board by board basis */
|
||||
mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
|
||||
|
|
|
@ -40,6 +40,23 @@
|
|||
static struct list_head mmc_devices;
|
||||
static int cur_dev_num = -1;
|
||||
|
||||
int __weak board_mmc_getwp(struct mmc *mmc)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mmc_getwp(struct mmc *mmc)
|
||||
{
|
||||
int wp;
|
||||
|
||||
wp = board_mmc_getwp(mmc);
|
||||
|
||||
if ((wp < 0) && mmc->getwp)
|
||||
wp = mmc->getwp(mmc);
|
||||
|
||||
return wp;
|
||||
}
|
||||
|
||||
int __board_mmc_getcd(struct mmc *mmc) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -273,6 +273,7 @@ struct mmc *mmc_spi_init(uint bus, uint cs, uint speed, uint mode)
|
|||
mmc->set_ios = mmc_spi_set_ios;
|
||||
mmc->init = mmc_spi_init_p;
|
||||
mmc->getcd = NULL;
|
||||
mmc->getwp = NULL;
|
||||
mmc->host_caps = MMC_MODE_SPI;
|
||||
|
||||
mmc->voltages = MMC_SPI_VOLTAGE;
|
||||
|
|
|
@ -499,6 +499,7 @@ static int mxcmci_initialize(bd_t *bis)
|
|||
mmc->set_ios = mxcmci_set_ios;
|
||||
mmc->init = mxcmci_init;
|
||||
mmc->getcd = NULL;
|
||||
mmc->getwp = NULL;
|
||||
mmc->host_caps = MMC_MODE_4BIT;
|
||||
|
||||
host->base = (struct mxcmci_regs *)CONFIG_MXC_MCI_REGS_BASE;
|
||||
|
|
|
@ -432,6 +432,7 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int))
|
|||
mmc->set_ios = mxsmmc_set_ios;
|
||||
mmc->init = mxsmmc_init;
|
||||
mmc->getcd = NULL;
|
||||
mmc->getwp = NULL;
|
||||
mmc->priv = priv;
|
||||
|
||||
mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
|
||||
|
|
|
@ -590,6 +590,7 @@ int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio)
|
|||
mmc->set_ios = mmc_set_ios;
|
||||
mmc->init = mmc_init_setup;
|
||||
mmc->getcd = omap_mmc_getcd;
|
||||
mmc->getwp = NULL;
|
||||
mmc->priv = priv_data;
|
||||
|
||||
switch (dev_index) {
|
||||
|
|
|
@ -438,6 +438,7 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk)
|
|||
mmc->set_ios = sdhci_set_ios;
|
||||
mmc->init = sdhci_init;
|
||||
mmc->getcd = NULL;
|
||||
mmc->getwp = NULL;
|
||||
|
||||
caps = sdhci_readl(host, SDHCI_CAPABILITIES);
|
||||
#ifdef CONFIG_MMC_SDMA
|
||||
|
|
|
@ -599,6 +599,7 @@ int mmcif_mmc_init(void)
|
|||
mmc->set_ios = sh_mmcif_set_ios;
|
||||
mmc->init = sh_mmcif_init;
|
||||
mmc->getcd = NULL;
|
||||
mmc->getwp = NULL;
|
||||
host->regs = (struct sh_mmcif_regs *)CONFIG_SH_MMCIF_ADDR;
|
||||
host->clk = CONFIG_SH_MMCIF_CLK;
|
||||
mmc->priv = host;
|
||||
|
|
|
@ -563,6 +563,7 @@ int tegra_mmc_init(int dev_index, int bus_width, int pwr_gpio, int cd_gpio)
|
|||
mmc->set_ios = mmc_set_ios;
|
||||
mmc->init = mmc_core_init;
|
||||
mmc->getcd = tegra_mmc_getcd;
|
||||
mmc->getwp = NULL;
|
||||
|
||||
mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
|
||||
mmc->host_caps = 0;
|
||||
|
|
|
@ -259,6 +259,7 @@ struct mmc {
|
|||
void (*set_ios)(struct mmc *mmc);
|
||||
int (*init)(struct mmc *mmc);
|
||||
int (*getcd)(struct mmc *mmc);
|
||||
int (*getwp)(struct mmc *mmc);
|
||||
uint b_max;
|
||||
};
|
||||
|
||||
|
@ -274,6 +275,7 @@ int get_mmc_num(void);
|
|||
int board_mmc_getcd(struct mmc *mmc);
|
||||
int mmc_switch_part(int dev_num, unsigned int part_num);
|
||||
int mmc_getcd(struct mmc *mmc);
|
||||
int mmc_getwp(struct mmc *mmc);
|
||||
void spl_mmc_load(void) __noreturn;
|
||||
|
||||
#ifdef CONFIG_GENERIC_MMC
|
||||
|
|
Loading…
Reference in a new issue