mmc: msm_sdcc: Add support for card detect, write protect gpios
Add support for SD card insertion/removal detection and write protect switch detection using gpio numbers passed through device tree. Change-Id: I63aed72f38f912b33de4b8eaedf72e52bbaeb4a0 Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
This commit is contained in:
committed by
Stephen Boyd
parent
1951c7d62a
commit
3d40dec379
@@ -16,10 +16,8 @@ Required properties:
|
||||
Optional Properties:
|
||||
- cell-index - defines slot ID.
|
||||
- qcom,sdcc-bus-width - defines the bus I/O width that controller supports.
|
||||
- qcom,sdcc-wp-gpio - defines write protect switch gpio.
|
||||
- qcom,sdcc-wp-polarity - specifies the polarity of wp switch.
|
||||
- qcom,sdcc-cd-gpio - defines card detect gpio number.
|
||||
- qcom,sdcc-cd-polarity - specifies the polarity of cd gpio.
|
||||
- wp-gpios - specify GPIO for write protect switch detection.
|
||||
- cd-gpios - specify GPIO for card detection.
|
||||
- qcom,sdcc-nonremovable - specifies whether the card in slot is
|
||||
hot pluggable or hard wired.
|
||||
- qcom,sdcc-disable_cmd23 - disable sending CMD23 to card when controller can't support it.
|
||||
|
||||
@@ -146,7 +146,7 @@ struct mmc_platform_data {
|
||||
unsigned int uhs_caps2;
|
||||
void (*sdio_lpm_gpio_setup)(struct device *, unsigned int);
|
||||
unsigned int status_irq;
|
||||
unsigned int status_gpio;
|
||||
int status_gpio;
|
||||
/* Indicates the polarity of the GPIO line when card is inserted */
|
||||
bool is_status_gpio_active_low;
|
||||
unsigned int sdiowakeup_irq;
|
||||
@@ -158,7 +158,7 @@ struct mmc_platform_data {
|
||||
unsigned int msmsdcc_fmax;
|
||||
bool nonremovable;
|
||||
unsigned int mpm_sdiowakeup_int;
|
||||
unsigned int wpswitch_gpio;
|
||||
int wpswitch_gpio;
|
||||
bool is_wpswitch_active_low;
|
||||
struct msm_mmc_slot_reg_data *vreg_data;
|
||||
int is_sdio_al_client;
|
||||
|
||||
@@ -3165,7 +3165,7 @@ static int msmsdcc_get_ro(struct mmc_host *mmc)
|
||||
|
||||
if (host->plat->wpswitch) {
|
||||
status = host->plat->wpswitch(mmc_dev(mmc));
|
||||
} else if (host->plat->wpswitch_gpio) {
|
||||
} else if (gpio_is_valid(host->plat->wpswitch_gpio)) {
|
||||
status = gpio_request(host->plat->wpswitch_gpio,
|
||||
"SD_WP_Switch");
|
||||
if (status) {
|
||||
@@ -3971,7 +3971,7 @@ msmsdcc_check_status(unsigned long data)
|
||||
struct msmsdcc_host *host = (struct msmsdcc_host *)data;
|
||||
unsigned int status;
|
||||
|
||||
if (host->plat->status || host->plat->status_gpio) {
|
||||
if (host->plat->status || gpio_is_valid(host->plat->status_gpio)) {
|
||||
if (host->plat->status)
|
||||
status = host->plat->status(mmc_dev(host->mmc));
|
||||
else
|
||||
@@ -5008,6 +5008,25 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void msmsdcc_dt_get_cd_wp_gpio(struct device *dev,
|
||||
struct mmc_platform_data *pdata)
|
||||
{
|
||||
enum of_gpio_flags flags = OF_GPIO_ACTIVE_LOW;
|
||||
struct device_node *np = dev->of_node;
|
||||
|
||||
pdata->status_gpio = of_get_named_gpio_flags(np,
|
||||
"cd-gpios", 0, &flags);
|
||||
if (gpio_is_valid(pdata->status_gpio)) {
|
||||
pdata->status_irq = gpio_to_irq(pdata->status_gpio);
|
||||
pdata->is_status_gpio_active_low = flags & OF_GPIO_ACTIVE_LOW;
|
||||
}
|
||||
|
||||
pdata->wpswitch_gpio = of_get_named_gpio_flags(np,
|
||||
"wp-gpios", 0, &flags);
|
||||
if (gpio_is_valid(pdata->wpswitch_gpio))
|
||||
pdata->is_wpswitch_active_low = flags & OF_GPIO_ACTIVE_LOW;
|
||||
}
|
||||
|
||||
static int msmsdcc_dt_parse_gpio_info(struct device *dev,
|
||||
struct mmc_platform_data *pdata)
|
||||
{
|
||||
@@ -5015,6 +5034,8 @@ static int msmsdcc_dt_parse_gpio_info(struct device *dev,
|
||||
struct msm_mmc_pin_data *pin_data;
|
||||
struct device_node *np = dev->of_node;
|
||||
|
||||
msmsdcc_dt_get_cd_wp_gpio(dev, pdata);
|
||||
|
||||
pin_data = devm_kzalloc(dev, sizeof(*pin_data), GFP_KERNEL);
|
||||
if (!pin_data) {
|
||||
dev_err(dev, "No memory for pin_data\n");
|
||||
@@ -5656,7 +5677,12 @@ msmsdcc_probe(struct platform_device *pdev)
|
||||
* Setup card detect change
|
||||
*/
|
||||
|
||||
if (plat->status || plat->status_gpio) {
|
||||
if (!plat->status_gpio)
|
||||
plat->status_gpio = -ENOENT;
|
||||
if (!plat->wpswitch_gpio)
|
||||
plat->wpswitch_gpio = -ENOENT;
|
||||
|
||||
if (plat->status || gpio_is_valid(plat->status_gpio)) {
|
||||
if (plat->status)
|
||||
host->oldstat = plat->status(mmc_dev(host->mmc));
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user