diff options
author | Ulf Hansson <ulf.hansson@linaro.org> | 2013-09-13 05:31:33 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2013-10-30 20:26:29 -0400 |
commit | 6904115095ad60ced638eb1e36e0e4e5e7de00b0 (patch) | |
tree | 7bf979ff85dbf5a97c0aef99624293b67a54b094 /drivers/mmc | |
parent | db4a0d0512253c23a052ae650395c07d956118b3 (diff) |
mmc: core: Move cached value of the negotiated ocr mask to card struct
The negotiated ocr mask is directly related to the card. Once a card
gets removed, the mask shall be dropped. By moving the cache of the ocr
mask from the host struct to the card struct we have accomplished this.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/core/core.c | 7 | ||||
-rw-r--r-- | drivers/mmc/core/mmc.c | 19 | ||||
-rw-r--r-- | drivers/mmc/core/sd.c | 22 | ||||
-rw-r--r-- | drivers/mmc/core/sdio.c | 26 |
4 files changed, 40 insertions, 34 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 5909ba46b8f2..529d2eff6095 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -1574,9 +1574,10 @@ void mmc_power_off(struct mmc_host *host) | |||
1574 | 1574 | ||
1575 | /* | 1575 | /* |
1576 | * Reset ocr mask to be the highest possible voltage supported for | 1576 | * Reset ocr mask to be the highest possible voltage supported for |
1577 | * this mmc host. This value will be used at next power up. | 1577 | * this card. This value will be used at next power up. |
1578 | */ | 1578 | */ |
1579 | host->ocr = 1 << (fls(host->ocr_avail) - 1); | 1579 | if (host->card) |
1580 | host->card->ocr = 1 << (fls(host->ocr_avail) - 1); | ||
1580 | 1581 | ||
1581 | if (!mmc_host_is_spi(host)) { | 1582 | if (!mmc_host_is_spi(host)) { |
1582 | host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; | 1583 | host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; |
@@ -2550,7 +2551,7 @@ int mmc_power_restore_host(struct mmc_host *host) | |||
2550 | return -EINVAL; | 2551 | return -EINVAL; |
2551 | } | 2552 | } |
2552 | 2553 | ||
2553 | mmc_power_up(host, host->ocr); | 2554 | mmc_power_up(host, host->card->ocr); |
2554 | ret = host->bus_ops->power_restore(host); | 2555 | ret = host->bus_ops->power_restore(host); |
2555 | 2556 | ||
2556 | mmc_bus_put(host); | 2557 | mmc_bus_put(host); |
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 75c66f975e24..eb7161c11587 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -934,6 +934,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
934 | goto err; | 934 | goto err; |
935 | } | 935 | } |
936 | 936 | ||
937 | card->ocr = ocr; | ||
937 | card->type = MMC_TYPE_MMC; | 938 | card->type = MMC_TYPE_MMC; |
938 | card->rca = 1; | 939 | card->rca = 1; |
939 | memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); | 940 | memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); |
@@ -1533,9 +1534,9 @@ static int mmc_resume(struct mmc_host *host) | |||
1533 | BUG_ON(!host->card); | 1534 | BUG_ON(!host->card); |
1534 | 1535 | ||
1535 | mmc_claim_host(host); | 1536 | mmc_claim_host(host); |
1536 | mmc_power_up(host, host->ocr); | 1537 | mmc_power_up(host, host->card->ocr); |
1537 | mmc_select_voltage(host, host->ocr); | 1538 | mmc_select_voltage(host, host->card->ocr); |
1538 | err = mmc_init_card(host, host->ocr, host->card); | 1539 | err = mmc_init_card(host, host->card->ocr, host->card); |
1539 | mmc_release_host(host); | 1540 | mmc_release_host(host); |
1540 | 1541 | ||
1541 | return err; | 1542 | return err; |
@@ -1579,7 +1580,7 @@ static int mmc_runtime_resume(struct mmc_host *host) | |||
1579 | 1580 | ||
1580 | mmc_claim_host(host); | 1581 | mmc_claim_host(host); |
1581 | 1582 | ||
1582 | mmc_power_up(host, host->ocr); | 1583 | mmc_power_up(host, host->card->ocr); |
1583 | err = mmc_resume(host); | 1584 | err = mmc_resume(host); |
1584 | if (err) | 1585 | if (err) |
1585 | pr_err("%s: error %d doing aggessive resume\n", | 1586 | pr_err("%s: error %d doing aggessive resume\n", |
@@ -1595,7 +1596,7 @@ static int mmc_power_restore(struct mmc_host *host) | |||
1595 | 1596 | ||
1596 | host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200); | 1597 | host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200); |
1597 | mmc_claim_host(host); | 1598 | mmc_claim_host(host); |
1598 | ret = mmc_init_card(host, host->ocr, host->card); | 1599 | ret = mmc_init_card(host, host->card->ocr, host->card); |
1599 | mmc_release_host(host); | 1600 | mmc_release_host(host); |
1600 | 1601 | ||
1601 | return ret; | 1602 | return ret; |
@@ -1640,7 +1641,7 @@ static void mmc_attach_bus_ops(struct mmc_host *host) | |||
1640 | int mmc_attach_mmc(struct mmc_host *host) | 1641 | int mmc_attach_mmc(struct mmc_host *host) |
1641 | { | 1642 | { |
1642 | int err; | 1643 | int err; |
1643 | u32 ocr; | 1644 | u32 ocr, rocr; |
1644 | 1645 | ||
1645 | BUG_ON(!host); | 1646 | BUG_ON(!host); |
1646 | WARN_ON(!host->claimed); | 1647 | WARN_ON(!host->claimed); |
@@ -1677,12 +1678,12 @@ int mmc_attach_mmc(struct mmc_host *host) | |||
1677 | ocr &= ~0x7F; | 1678 | ocr &= ~0x7F; |
1678 | } | 1679 | } |
1679 | 1680 | ||
1680 | host->ocr = mmc_select_voltage(host, ocr); | 1681 | rocr = mmc_select_voltage(host, ocr); |
1681 | 1682 | ||
1682 | /* | 1683 | /* |
1683 | * Can we support the voltage of the card? | 1684 | * Can we support the voltage of the card? |
1684 | */ | 1685 | */ |
1685 | if (!host->ocr) { | 1686 | if (!rocr) { |
1686 | err = -EINVAL; | 1687 | err = -EINVAL; |
1687 | goto err; | 1688 | goto err; |
1688 | } | 1689 | } |
@@ -1690,7 +1691,7 @@ int mmc_attach_mmc(struct mmc_host *host) | |||
1690 | /* | 1691 | /* |
1691 | * Detect and init the card. | 1692 | * Detect and init the card. |
1692 | */ | 1693 | */ |
1693 | err = mmc_init_card(host, host->ocr, NULL); | 1694 | err = mmc_init_card(host, rocr, NULL); |
1694 | if (err) | 1695 | if (err) |
1695 | goto err; | 1696 | goto err; |
1696 | 1697 | ||
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 5818887fffb3..398065c57edf 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c | |||
@@ -721,6 +721,7 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr) | |||
721 | int err; | 721 | int err; |
722 | u32 max_current; | 722 | u32 max_current; |
723 | int retries = 10; | 723 | int retries = 10; |
724 | u32 pocr = ocr; | ||
724 | 725 | ||
725 | try_again: | 726 | try_again: |
726 | if (!retries) { | 727 | if (!retries) { |
@@ -774,7 +775,7 @@ try_again: | |||
774 | if (!mmc_host_is_spi(host) && rocr && | 775 | if (!mmc_host_is_spi(host) && rocr && |
775 | ((*rocr & 0x41000000) == 0x41000000)) { | 776 | ((*rocr & 0x41000000) == 0x41000000)) { |
776 | err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, | 777 | err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, |
777 | host->ocr); | 778 | pocr); |
778 | if (err == -EAGAIN) { | 779 | if (err == -EAGAIN) { |
779 | retries--; | 780 | retries--; |
780 | goto try_again; | 781 | goto try_again; |
@@ -936,6 +937,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
936 | if (IS_ERR(card)) | 937 | if (IS_ERR(card)) |
937 | return PTR_ERR(card); | 938 | return PTR_ERR(card); |
938 | 939 | ||
940 | card->ocr = ocr; | ||
939 | card->type = MMC_TYPE_SD; | 941 | card->type = MMC_TYPE_SD; |
940 | memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); | 942 | memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); |
941 | } | 943 | } |
@@ -1100,9 +1102,9 @@ static int mmc_sd_resume(struct mmc_host *host) | |||
1100 | BUG_ON(!host->card); | 1102 | BUG_ON(!host->card); |
1101 | 1103 | ||
1102 | mmc_claim_host(host); | 1104 | mmc_claim_host(host); |
1103 | mmc_power_up(host, host->ocr); | 1105 | mmc_power_up(host, host->card->ocr); |
1104 | mmc_select_voltage(host, host->ocr); | 1106 | mmc_select_voltage(host, host->card->ocr); |
1105 | err = mmc_sd_init_card(host, host->ocr, host->card); | 1107 | err = mmc_sd_init_card(host, host->card->ocr, host->card); |
1106 | mmc_release_host(host); | 1108 | mmc_release_host(host); |
1107 | 1109 | ||
1108 | return err; | 1110 | return err; |
@@ -1145,7 +1147,7 @@ static int mmc_sd_runtime_resume(struct mmc_host *host) | |||
1145 | 1147 | ||
1146 | mmc_claim_host(host); | 1148 | mmc_claim_host(host); |
1147 | 1149 | ||
1148 | mmc_power_up(host, host->ocr); | 1150 | mmc_power_up(host, host->card->ocr); |
1149 | err = mmc_sd_resume(host); | 1151 | err = mmc_sd_resume(host); |
1150 | if (err) | 1152 | if (err) |
1151 | pr_err("%s: error %d doing aggessive resume\n", | 1153 | pr_err("%s: error %d doing aggessive resume\n", |
@@ -1161,7 +1163,7 @@ static int mmc_sd_power_restore(struct mmc_host *host) | |||
1161 | 1163 | ||
1162 | host->card->state &= ~MMC_STATE_HIGHSPEED; | 1164 | host->card->state &= ~MMC_STATE_HIGHSPEED; |
1163 | mmc_claim_host(host); | 1165 | mmc_claim_host(host); |
1164 | ret = mmc_sd_init_card(host, host->ocr, host->card); | 1166 | ret = mmc_sd_init_card(host, host->card->ocr, host->card); |
1165 | mmc_release_host(host); | 1167 | mmc_release_host(host); |
1166 | 1168 | ||
1167 | return ret; | 1169 | return ret; |
@@ -1206,7 +1208,7 @@ static void mmc_sd_attach_bus_ops(struct mmc_host *host) | |||
1206 | int mmc_attach_sd(struct mmc_host *host) | 1208 | int mmc_attach_sd(struct mmc_host *host) |
1207 | { | 1209 | { |
1208 | int err; | 1210 | int err; |
1209 | u32 ocr; | 1211 | u32 ocr, rocr; |
1210 | 1212 | ||
1211 | BUG_ON(!host); | 1213 | BUG_ON(!host); |
1212 | WARN_ON(!host->claimed); | 1214 | WARN_ON(!host->claimed); |
@@ -1249,12 +1251,12 @@ int mmc_attach_sd(struct mmc_host *host) | |||
1249 | ocr &= ~MMC_VDD_165_195; | 1251 | ocr &= ~MMC_VDD_165_195; |
1250 | } | 1252 | } |
1251 | 1253 | ||
1252 | host->ocr = mmc_select_voltage(host, ocr); | 1254 | rocr = mmc_select_voltage(host, ocr); |
1253 | 1255 | ||
1254 | /* | 1256 | /* |
1255 | * Can we support the voltage(s) of the card(s)? | 1257 | * Can we support the voltage(s) of the card(s)? |
1256 | */ | 1258 | */ |
1257 | if (!host->ocr) { | 1259 | if (!rocr) { |
1258 | err = -EINVAL; | 1260 | err = -EINVAL; |
1259 | goto err; | 1261 | goto err; |
1260 | } | 1262 | } |
@@ -1262,7 +1264,7 @@ int mmc_attach_sd(struct mmc_host *host) | |||
1262 | /* | 1264 | /* |
1263 | * Detect and init the card. | 1265 | * Detect and init the card. |
1264 | */ | 1266 | */ |
1265 | err = mmc_sd_init_card(host, host->ocr, NULL); | 1267 | err = mmc_sd_init_card(host, rocr, NULL); |
1266 | if (err) | 1268 | if (err) |
1267 | goto err; | 1269 | goto err; |
1268 | 1270 | ||
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 9587d9f8cf1c..e0a135a635f5 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c | |||
@@ -594,6 +594,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, | |||
594 | int err; | 594 | int err; |
595 | int retries = 10; | 595 | int retries = 10; |
596 | u32 rocr = 0; | 596 | u32 rocr = 0; |
597 | u32 ocr_card = ocr; | ||
597 | 598 | ||
598 | BUG_ON(!host); | 599 | BUG_ON(!host); |
599 | WARN_ON(!host->claimed); | 600 | WARN_ON(!host->claimed); |
@@ -762,6 +763,7 @@ try_again: | |||
762 | 763 | ||
763 | card = oldcard; | 764 | card = oldcard; |
764 | } | 765 | } |
766 | card->ocr = ocr_card; | ||
765 | mmc_fixup_device(card, NULL); | 767 | mmc_fixup_device(card, NULL); |
766 | 768 | ||
767 | if (card->type == MMC_TYPE_SD_COMBO) { | 769 | if (card->type == MMC_TYPE_SD_COMBO) { |
@@ -984,8 +986,8 @@ static int mmc_sdio_resume(struct mmc_host *host) | |||
984 | 986 | ||
985 | /* Restore power if needed */ | 987 | /* Restore power if needed */ |
986 | if (!mmc_card_keep_power(host)) { | 988 | if (!mmc_card_keep_power(host)) { |
987 | mmc_power_up(host, host->ocr); | 989 | mmc_power_up(host, host->card->ocr); |
988 | mmc_select_voltage(host, host->ocr); | 990 | mmc_select_voltage(host, host->card->ocr); |
989 | /* | 991 | /* |
990 | * Tell runtime PM core we just powered up the card, | 992 | * Tell runtime PM core we just powered up the card, |
991 | * since it still believes the card is powered off. | 993 | * since it still believes the card is powered off. |
@@ -1003,7 +1005,7 @@ static int mmc_sdio_resume(struct mmc_host *host) | |||
1003 | if (mmc_card_is_removable(host) || !mmc_card_keep_power(host)) { | 1005 | if (mmc_card_is_removable(host) || !mmc_card_keep_power(host)) { |
1004 | sdio_reset(host); | 1006 | sdio_reset(host); |
1005 | mmc_go_idle(host); | 1007 | mmc_go_idle(host); |
1006 | err = mmc_sdio_init_card(host, host->ocr, host->card, | 1008 | err = mmc_sdio_init_card(host, host->card->ocr, host->card, |
1007 | mmc_card_keep_power(host)); | 1009 | mmc_card_keep_power(host)); |
1008 | } else if (mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host)) { | 1010 | } else if (mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host)) { |
1009 | /* We may have switched to 1-bit mode during suspend */ | 1011 | /* We may have switched to 1-bit mode during suspend */ |
@@ -1043,7 +1045,7 @@ static int mmc_sdio_resume(struct mmc_host *host) | |||
1043 | static int mmc_sdio_power_restore(struct mmc_host *host) | 1045 | static int mmc_sdio_power_restore(struct mmc_host *host) |
1044 | { | 1046 | { |
1045 | int ret; | 1047 | int ret; |
1046 | u32 ocr; | 1048 | u32 ocr, rocr; |
1047 | 1049 | ||
1048 | BUG_ON(!host); | 1050 | BUG_ON(!host); |
1049 | BUG_ON(!host->card); | 1051 | BUG_ON(!host->card); |
@@ -1080,13 +1082,13 @@ static int mmc_sdio_power_restore(struct mmc_host *host) | |||
1080 | if (host->ocr_avail_sdio) | 1082 | if (host->ocr_avail_sdio) |
1081 | host->ocr_avail = host->ocr_avail_sdio; | 1083 | host->ocr_avail = host->ocr_avail_sdio; |
1082 | 1084 | ||
1083 | host->ocr = mmc_select_voltage(host, ocr & ~0x7F); | 1085 | rocr = mmc_select_voltage(host, ocr & ~0x7F); |
1084 | if (!host->ocr) { | 1086 | if (!rocr) { |
1085 | ret = -EINVAL; | 1087 | ret = -EINVAL; |
1086 | goto out; | 1088 | goto out; |
1087 | } | 1089 | } |
1088 | 1090 | ||
1089 | ret = mmc_sdio_init_card(host, host->ocr, host->card, | 1091 | ret = mmc_sdio_init_card(host, rocr, host->card, |
1090 | mmc_card_keep_power(host)); | 1092 | mmc_card_keep_power(host)); |
1091 | if (!ret && host->sdio_irqs) | 1093 | if (!ret && host->sdio_irqs) |
1092 | mmc_signal_sdio_irq(host); | 1094 | mmc_signal_sdio_irq(host); |
@@ -1107,7 +1109,7 @@ static int mmc_sdio_runtime_suspend(struct mmc_host *host) | |||
1107 | static int mmc_sdio_runtime_resume(struct mmc_host *host) | 1109 | static int mmc_sdio_runtime_resume(struct mmc_host *host) |
1108 | { | 1110 | { |
1109 | /* Restore power and re-initialize. */ | 1111 | /* Restore power and re-initialize. */ |
1110 | mmc_power_up(host, host->ocr); | 1112 | mmc_power_up(host, host->card->ocr); |
1111 | return mmc_sdio_power_restore(host); | 1113 | return mmc_sdio_power_restore(host); |
1112 | } | 1114 | } |
1113 | 1115 | ||
@@ -1130,7 +1132,7 @@ static const struct mmc_bus_ops mmc_sdio_ops = { | |||
1130 | int mmc_attach_sdio(struct mmc_host *host) | 1132 | int mmc_attach_sdio(struct mmc_host *host) |
1131 | { | 1133 | { |
1132 | int err, i, funcs; | 1134 | int err, i, funcs; |
1133 | u32 ocr; | 1135 | u32 ocr, rocr; |
1134 | struct mmc_card *card; | 1136 | struct mmc_card *card; |
1135 | 1137 | ||
1136 | BUG_ON(!host); | 1138 | BUG_ON(!host); |
@@ -1155,12 +1157,12 @@ int mmc_attach_sdio(struct mmc_host *host) | |||
1155 | ocr &= ~0x7F; | 1157 | ocr &= ~0x7F; |
1156 | } | 1158 | } |
1157 | 1159 | ||
1158 | host->ocr = mmc_select_voltage(host, ocr); | 1160 | rocr = mmc_select_voltage(host, ocr); |
1159 | 1161 | ||
1160 | /* | 1162 | /* |
1161 | * Can we support the voltage(s) of the card(s)? | 1163 | * Can we support the voltage(s) of the card(s)? |
1162 | */ | 1164 | */ |
1163 | if (!host->ocr) { | 1165 | if (!rocr) { |
1164 | err = -EINVAL; | 1166 | err = -EINVAL; |
1165 | goto err; | 1167 | goto err; |
1166 | } | 1168 | } |
@@ -1168,7 +1170,7 @@ int mmc_attach_sdio(struct mmc_host *host) | |||
1168 | /* | 1170 | /* |
1169 | * Detect and init the card. | 1171 | * Detect and init the card. |
1170 | */ | 1172 | */ |
1171 | err = mmc_sdio_init_card(host, host->ocr, NULL, 0); | 1173 | err = mmc_sdio_init_card(host, rocr, NULL, 0); |
1172 | if (err) | 1174 | if (err) |
1173 | goto err; | 1175 | goto err; |
1174 | 1176 | ||