diff options
author | Jonas Larsson <jonas.larsson@martinsson.se> | 2009-03-31 05:16:48 -0400 |
---|---|---|
committer | Haavard Skinnemoen <haavard.skinnemoen@atmel.com> | 2009-04-08 14:47:48 -0400 |
commit | 1c1452be2e9ae282a7316c3b23987811bd7acda6 (patch) | |
tree | fe7a8d90f8b38e3e49dcf07ed8fc1ff99730c068 /drivers/mmc/host/atmel-mci.c | |
parent | 577c9c456f0e1371cbade38eaf91ae8e8a308555 (diff) |
atmel-mci: Add support for inverted detect pin
Same patch as before, modified to use bool. Also adds description of
the new field in struct atmel_mci that I missed in the first patch.
This patch adds Atmel MCI support for inverted detect pins.
Signed-off-by: Jonas Larsson <jonas.larsson@martinsson.se>
Acked-by: Pierre Ossman <pierre@ossman.eu>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Diffstat (limited to 'drivers/mmc/host/atmel-mci.c')
-rw-r--r-- | drivers/mmc/host/atmel-mci.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index cf6a100bb38f..7b603e4b41db 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c | |||
@@ -177,6 +177,7 @@ struct atmel_mci { | |||
177 | * available. | 177 | * available. |
178 | * @wp_pin: GPIO pin used for card write protect sending, or negative | 178 | * @wp_pin: GPIO pin used for card write protect sending, or negative |
179 | * if not available. | 179 | * if not available. |
180 | * @detect_is_active_high: The state of the detect pin when it is active. | ||
180 | * @detect_timer: Timer used for debouncing @detect_pin interrupts. | 181 | * @detect_timer: Timer used for debouncing @detect_pin interrupts. |
181 | */ | 182 | */ |
182 | struct atmel_mci_slot { | 183 | struct atmel_mci_slot { |
@@ -196,6 +197,7 @@ struct atmel_mci_slot { | |||
196 | 197 | ||
197 | int detect_pin; | 198 | int detect_pin; |
198 | int wp_pin; | 199 | int wp_pin; |
200 | bool detect_is_active_high; | ||
199 | 201 | ||
200 | struct timer_list detect_timer; | 202 | struct timer_list detect_timer; |
201 | }; | 203 | }; |
@@ -924,7 +926,8 @@ static int atmci_get_cd(struct mmc_host *mmc) | |||
924 | struct atmel_mci_slot *slot = mmc_priv(mmc); | 926 | struct atmel_mci_slot *slot = mmc_priv(mmc); |
925 | 927 | ||
926 | if (gpio_is_valid(slot->detect_pin)) { | 928 | if (gpio_is_valid(slot->detect_pin)) { |
927 | present = !gpio_get_value(slot->detect_pin); | 929 | present = !(gpio_get_value(slot->detect_pin) ^ |
930 | slot->detect_is_active_high); | ||
928 | dev_dbg(&mmc->class_dev, "card is %spresent\n", | 931 | dev_dbg(&mmc->class_dev, "card is %spresent\n", |
929 | present ? "" : "not "); | 932 | present ? "" : "not "); |
930 | } | 933 | } |
@@ -1028,7 +1031,8 @@ static void atmci_detect_change(unsigned long data) | |||
1028 | return; | 1031 | return; |
1029 | 1032 | ||
1030 | enable_irq(gpio_to_irq(slot->detect_pin)); | 1033 | enable_irq(gpio_to_irq(slot->detect_pin)); |
1031 | present = !gpio_get_value(slot->detect_pin); | 1034 | present = !(gpio_get_value(slot->detect_pin) ^ |
1035 | slot->detect_is_active_high); | ||
1032 | present_old = test_bit(ATMCI_CARD_PRESENT, &slot->flags); | 1036 | present_old = test_bit(ATMCI_CARD_PRESENT, &slot->flags); |
1033 | 1037 | ||
1034 | dev_vdbg(&slot->mmc->class_dev, "detect change: %d (was %d)\n", | 1038 | dev_vdbg(&slot->mmc->class_dev, "detect change: %d (was %d)\n", |
@@ -1456,6 +1460,7 @@ static int __init atmci_init_slot(struct atmel_mci *host, | |||
1456 | slot->host = host; | 1460 | slot->host = host; |
1457 | slot->detect_pin = slot_data->detect_pin; | 1461 | slot->detect_pin = slot_data->detect_pin; |
1458 | slot->wp_pin = slot_data->wp_pin; | 1462 | slot->wp_pin = slot_data->wp_pin; |
1463 | slot->detect_is_active_high = slot_data->detect_is_active_high; | ||
1459 | slot->sdc_reg = sdc_reg; | 1464 | slot->sdc_reg = sdc_reg; |
1460 | 1465 | ||
1461 | mmc->ops = &atmci_ops; | 1466 | mmc->ops = &atmci_ops; |
@@ -1477,7 +1482,8 @@ static int __init atmci_init_slot(struct atmel_mci *host, | |||
1477 | if (gpio_request(slot->detect_pin, "mmc_detect")) { | 1482 | if (gpio_request(slot->detect_pin, "mmc_detect")) { |
1478 | dev_dbg(&mmc->class_dev, "no detect pin available\n"); | 1483 | dev_dbg(&mmc->class_dev, "no detect pin available\n"); |
1479 | slot->detect_pin = -EBUSY; | 1484 | slot->detect_pin = -EBUSY; |
1480 | } else if (gpio_get_value(slot->detect_pin)) { | 1485 | } else if (gpio_get_value(slot->detect_pin) ^ |
1486 | slot->detect_is_active_high) { | ||
1481 | clear_bit(ATMCI_CARD_PRESENT, &slot->flags); | 1487 | clear_bit(ATMCI_CARD_PRESENT, &slot->flags); |
1482 | } | 1488 | } |
1483 | } | 1489 | } |