add the function of write-protect for sdmmc after you select the option

This commit is contained in:
xbw
2011-09-22 13:18:17 +08:00
parent 60f96d5bc0
commit 2149515b96
4 changed files with 77 additions and 4 deletions

View File

@@ -1823,6 +1823,15 @@ static struct platform_device rk29_device_pwm_regulator = {
#endif
#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
#define SDMMC0_WRITE_PROTECT_PIN RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin.
#endif
#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
#define SDMMC1_WRITE_PROTECT_PIN RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin.
#endif
/*****************************************************************************************
* SDMMC devices
*****************************************************************************************/
@@ -1851,6 +1860,12 @@ static int rk29_sdmmc0_cfg_gpio(void)
#else
gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
#endif
#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
gpio_request(SDMMC0_WRITE_PROTECT_PIN,"sdmmc-wp");
gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
#endif
return 0;
}
@@ -1869,6 +1884,12 @@ struct rk29_sdmmc_platform_data default_sdmmc0_data = {
#endif
.detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
.enable_sd_wakeup = 0,
#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
.write_prt = SDMMC0_WRITE_PROTECT_PIN,
#else
.write_prt = INVALID_GPIO,
#endif
};
#endif
#ifdef CONFIG_SDMMC1_RK29
@@ -1882,6 +1903,11 @@ static int rk29_sdmmc1_cfg_gpio(void)
rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
//rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
gpio_request(SDMMC1_WRITE_PROTECT_PIN,"sdio-wp");
gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
#endif
return 0;
}
@@ -1912,6 +1938,13 @@ struct rk29_sdmmc_platform_data default_sdmmc1_data = {
#if 0
.detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
#endif
#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
.write_prt = SDMMC1_WRITE_PROTECT_PIN,
#else
.write_prt = INVALID_GPIO,
#endif
};
#endif

1
arch/arm/mach-rk29/include/mach/board.h Normal file → Executable file
View File

@@ -143,6 +143,7 @@ struct rk29_sdmmc_platform_data {
int (*register_status_notify)(void (*callback)(int card_present, void *dev_id), void *dev_id);
int detect_irq;
int enable_sd_wakeup;
int write_prt;
};
struct rk29_i2c_platform_data {
int bus_num;

13
drivers/mmc/host/Kconfig Normal file → Executable file
View File

@@ -24,6 +24,13 @@ if SDMMC_RK29
depends on ARCH_RK29
help
This supports the use of the SDMMC0 controller on Rk29 processors.
config SDMMC0_RK29_WRITE_PROTECT
bool "Write-protect for SDMMC0"
depends on SDMMC0_RK29
help
You will add the feature of write-protect for sdmmc-card if you say Yes.
Please note that this feature requires hardware support.
# config EMMC_RK29
# tristate "RK29 EMMC controller support(sdmmc)"
# default y
@@ -36,6 +43,12 @@ if SDMMC_RK29
depends on ARCH_RK29
help
This supports the use of the SDMMC1 controller on Rk29 processors.
config SDMMC1_RK29_WRITE_PROTECT
bool "Write-protect for SDMMC1"
depends on SDMMC1_RK29
help
You will add the feature of write-protect for sdio-card if you say Yes.
Please note that this feature requires hardware support.
endif
config MMC_ARMMMCI

View File

@@ -61,7 +61,7 @@ int debug_level = 7;
#define xbwprintk(n, arg...)
#endif
#define RK29_SDMMC_ERROR_FLAGS (SDMMC_INT_FRUN /*| SDMMC_INT_RTO*/ | SDMMC_INT_HLE )
#define RK29_SDMMC_ERROR_FLAGS (SDMMC_INT_FRUN | SDMMC_INT_HLE )
#define RK29_SDMMC_INTMASK_USEDMA (SDMMC_INT_CMD_DONE | SDMMC_INT_DTO | RK29_SDMMC_ERROR_FLAGS | SDMMC_INT_CD)
#define RK29_SDMMC_INTMASK_USEIO (SDMMC_INT_CMD_DONE | SDMMC_INT_DTO | RK29_SDMMC_ERROR_FLAGS | SDMMC_INT_CD| SDMMC_INT_TXDR | SDMMC_INT_RXDR )
@@ -72,7 +72,7 @@ int debug_level = 7;
#define RK29_SDMMC_WAIT_DTO_INTERNVAL 1500 //The time interval from the CMD_DONE_INT to DTO_INT
#define RK29_SDMMC_REMOVAL_DELAY 2000 //The time interval from the CD_INT to detect_timer react.
#define RK29_SDMMC_VERSION "Ver.2.07 The last modify date is 2011-09-09,modifyed by XBW."
#define RK29_SDMMC_VERSION "Ver.2.08 The last modify date is 2011-09-21,modifyed by XBW."
#define RK29_CTRL_SDMMC_ID 0 //mainly used by SDMMC
#define RK29_CTRL_SDIO1_ID 1 //mainly used by sdio-wifi
@@ -197,10 +197,16 @@ struct rk29_sdmmc {
unsigned int oldstatus;
unsigned int complete_done;
unsigned int retryfunc;
#ifdef CONFIG_PM
int gpio_irq;
int gpio_det;
#endif
#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) || defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
int write_protect;
#endif
};
@@ -2074,10 +2080,26 @@ out:
static int rk29_sdmmc_get_ro(struct mmc_host *mmc)
{
struct rk29_sdmmc *host = mmc_priv(mmc);
struct rk29_sdmmc *host = mmc_priv(mmc);
#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) || defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
int ret;
if(INVALID_GPIO == host->write_protect)
ret = 0;//no write-protect
else
ret = gpio_get_value(host->write_protect)?1:0;
xbwprintk(7,"%s..%d.. write_prt_pin=%d, get_ro=%d ===xbw[%s]===\n",\
__FUNCTION__, __LINE__,host->write_protect, ret, host->dma_name);
return ret;
#else
u32 wrtprt = rk29_sdmmc_read(host->regs, SDMMC_WRTPRT);
return (wrtprt & SDMMC_WRITE_PROTECT)?1:0;
#endif
}
@@ -3027,6 +3049,10 @@ static int rk29_sdmmc_probe(struct platform_device *pdev)
host->dma_addr = regs->start + SDMMC_DATA;
}
#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) || defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
host->write_protect = pdata->write_prt;
#endif
rk29_sdmmc_hw_init(host);
ret = request_irq(irq, rk29_sdmmc_interrupt, 0, dev_name(&pdev->dev), host);