diff options
Diffstat (limited to 'drivers/mmc')
43 files changed, 1647 insertions, 1063 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index c6a383d0244d..dabec556ebb8 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <linux/mmc/mmc.h> | 41 | #include <linux/mmc/mmc.h> |
42 | #include <linux/mmc/sd.h> | 42 | #include <linux/mmc/sd.h> |
43 | 43 | ||
44 | #include <asm/system.h> | ||
45 | #include <asm/uaccess.h> | 44 | #include <asm/uaccess.h> |
46 | 45 | ||
47 | #include "queue.h" | 46 | #include "queue.h" |
@@ -874,7 +873,7 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq, | |||
874 | { | 873 | { |
875 | struct mmc_blk_data *md = mq->data; | 874 | struct mmc_blk_data *md = mq->data; |
876 | struct mmc_card *card = md->queue.card; | 875 | struct mmc_card *card = md->queue.card; |
877 | unsigned int from, nr, arg; | 876 | unsigned int from, nr, arg, trim_arg, erase_arg; |
878 | int err = 0, type = MMC_BLK_SECDISCARD; | 877 | int err = 0, type = MMC_BLK_SECDISCARD; |
879 | 878 | ||
880 | if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) { | 879 | if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) { |
@@ -882,20 +881,26 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq, | |||
882 | goto out; | 881 | goto out; |
883 | } | 882 | } |
884 | 883 | ||
884 | from = blk_rq_pos(req); | ||
885 | nr = blk_rq_sectors(req); | ||
886 | |||
885 | /* The sanitize operation is supported at v4.5 only */ | 887 | /* The sanitize operation is supported at v4.5 only */ |
886 | if (mmc_can_sanitize(card)) { | 888 | if (mmc_can_sanitize(card)) { |
887 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | 889 | erase_arg = MMC_ERASE_ARG; |
888 | EXT_CSD_SANITIZE_START, 1, 0); | 890 | trim_arg = MMC_TRIM_ARG; |
889 | goto out; | 891 | } else { |
892 | erase_arg = MMC_SECURE_ERASE_ARG; | ||
893 | trim_arg = MMC_SECURE_TRIM1_ARG; | ||
890 | } | 894 | } |
891 | 895 | ||
892 | from = blk_rq_pos(req); | 896 | if (mmc_erase_group_aligned(card, from, nr)) |
893 | nr = blk_rq_sectors(req); | 897 | arg = erase_arg; |
894 | 898 | else if (mmc_can_trim(card)) | |
895 | if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr)) | 899 | arg = trim_arg; |
896 | arg = MMC_SECURE_TRIM1_ARG; | 900 | else { |
897 | else | 901 | err = -EINVAL; |
898 | arg = MMC_SECURE_ERASE_ARG; | 902 | goto out; |
903 | } | ||
899 | retry: | 904 | retry: |
900 | if (card->quirks & MMC_QUIRK_INAND_CMD38) { | 905 | if (card->quirks & MMC_QUIRK_INAND_CMD38) { |
901 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | 906 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
@@ -905,25 +910,41 @@ retry: | |||
905 | INAND_CMD38_ARG_SECERASE, | 910 | INAND_CMD38_ARG_SECERASE, |
906 | 0); | 911 | 0); |
907 | if (err) | 912 | if (err) |
908 | goto out; | 913 | goto out_retry; |
909 | } | 914 | } |
915 | |||
910 | err = mmc_erase(card, from, nr, arg); | 916 | err = mmc_erase(card, from, nr, arg); |
911 | if (!err && arg == MMC_SECURE_TRIM1_ARG) { | 917 | if (err == -EIO) |
918 | goto out_retry; | ||
919 | if (err) | ||
920 | goto out; | ||
921 | |||
922 | if (arg == MMC_SECURE_TRIM1_ARG) { | ||
912 | if (card->quirks & MMC_QUIRK_INAND_CMD38) { | 923 | if (card->quirks & MMC_QUIRK_INAND_CMD38) { |
913 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | 924 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
914 | INAND_CMD38_ARG_EXT_CSD, | 925 | INAND_CMD38_ARG_EXT_CSD, |
915 | INAND_CMD38_ARG_SECTRIM2, | 926 | INAND_CMD38_ARG_SECTRIM2, |
916 | 0); | 927 | 0); |
917 | if (err) | 928 | if (err) |
918 | goto out; | 929 | goto out_retry; |
919 | } | 930 | } |
931 | |||
920 | err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG); | 932 | err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG); |
933 | if (err == -EIO) | ||
934 | goto out_retry; | ||
935 | if (err) | ||
936 | goto out; | ||
921 | } | 937 | } |
922 | out: | 938 | |
923 | if (err == -EIO && !mmc_blk_reset(md, card->host, type)) | 939 | if (mmc_can_sanitize(card)) |
940 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | ||
941 | EXT_CSD_SANITIZE_START, 1, 0); | ||
942 | out_retry: | ||
943 | if (err && !mmc_blk_reset(md, card->host, type)) | ||
924 | goto retry; | 944 | goto retry; |
925 | if (!err) | 945 | if (!err) |
926 | mmc_blk_reset_success(md, type); | 946 | mmc_blk_reset_success(md, type); |
947 | out: | ||
927 | spin_lock_irq(&md->lock); | 948 | spin_lock_irq(&md->lock); |
928 | __blk_end_request(req, err, blk_rq_bytes(req)); | 949 | __blk_end_request(req, err, blk_rq_bytes(req)); |
929 | spin_unlock_irq(&md->lock); | 950 | spin_unlock_irq(&md->lock); |
@@ -1080,6 +1101,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, | |||
1080 | struct mmc_blk_request *brq = &mqrq->brq; | 1101 | struct mmc_blk_request *brq = &mqrq->brq; |
1081 | struct request *req = mqrq->req; | 1102 | struct request *req = mqrq->req; |
1082 | struct mmc_blk_data *md = mq->data; | 1103 | struct mmc_blk_data *md = mq->data; |
1104 | bool do_data_tag; | ||
1083 | 1105 | ||
1084 | /* | 1106 | /* |
1085 | * Reliable writes are used to implement Forced Unit Access and | 1107 | * Reliable writes are used to implement Forced Unit Access and |
@@ -1156,6 +1178,16 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, | |||
1156 | mmc_apply_rel_rw(brq, card, req); | 1178 | mmc_apply_rel_rw(brq, card, req); |
1157 | 1179 | ||
1158 | /* | 1180 | /* |
1181 | * Data tag is used only during writing meta data to speed | ||
1182 | * up write and any subsequent read of this meta data | ||
1183 | */ | ||
1184 | do_data_tag = (card->ext_csd.data_tag_unit_size) && | ||
1185 | (req->cmd_flags & REQ_META) && | ||
1186 | (rq_data_dir(req) == WRITE) && | ||
1187 | ((brq->data.blocks * brq->data.blksz) >= | ||
1188 | card->ext_csd.data_tag_unit_size); | ||
1189 | |||
1190 | /* | ||
1159 | * Pre-defined multi-block transfers are preferable to | 1191 | * Pre-defined multi-block transfers are preferable to |
1160 | * open ended-ones (and necessary for reliable writes). | 1192 | * open ended-ones (and necessary for reliable writes). |
1161 | * However, it is not sufficient to just send CMD23, | 1193 | * However, it is not sufficient to just send CMD23, |
@@ -1173,13 +1205,13 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, | |||
1173 | * We'll avoid using CMD23-bounded multiblock writes for | 1205 | * We'll avoid using CMD23-bounded multiblock writes for |
1174 | * these, while retaining features like reliable writes. | 1206 | * these, while retaining features like reliable writes. |
1175 | */ | 1207 | */ |
1176 | 1208 | if ((md->flags & MMC_BLK_CMD23) && mmc_op_multi(brq->cmd.opcode) && | |
1177 | if ((md->flags & MMC_BLK_CMD23) && | 1209 | (do_rel_wr || !(card->quirks & MMC_QUIRK_BLK_NO_CMD23) || |
1178 | mmc_op_multi(brq->cmd.opcode) && | 1210 | do_data_tag)) { |
1179 | (do_rel_wr || !(card->quirks & MMC_QUIRK_BLK_NO_CMD23))) { | ||
1180 | brq->sbc.opcode = MMC_SET_BLOCK_COUNT; | 1211 | brq->sbc.opcode = MMC_SET_BLOCK_COUNT; |
1181 | brq->sbc.arg = brq->data.blocks | | 1212 | brq->sbc.arg = brq->data.blocks | |
1182 | (do_rel_wr ? (1 << 31) : 0); | 1213 | (do_rel_wr ? (1 << 31) : 0) | |
1214 | (do_data_tag ? (1 << 29) : 0); | ||
1183 | brq->sbc.flags = MMC_RSP_R1 | MMC_CMD_AC; | 1215 | brq->sbc.flags = MMC_RSP_R1 | MMC_CMD_AC; |
1184 | brq->mrq.sbc = &brq->sbc; | 1216 | brq->mrq.sbc = &brq->sbc; |
1185 | } | 1217 | } |
@@ -1613,24 +1645,6 @@ static int mmc_blk_alloc_parts(struct mmc_card *card, struct mmc_blk_data *md) | |||
1613 | return ret; | 1645 | return ret; |
1614 | } | 1646 | } |
1615 | 1647 | ||
1616 | static int | ||
1617 | mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card) | ||
1618 | { | ||
1619 | int err; | ||
1620 | |||
1621 | mmc_claim_host(card->host); | ||
1622 | err = mmc_set_blocklen(card, 512); | ||
1623 | mmc_release_host(card->host); | ||
1624 | |||
1625 | if (err) { | ||
1626 | pr_err("%s: unable to set block size to 512: %d\n", | ||
1627 | md->disk->disk_name, err); | ||
1628 | return -EINVAL; | ||
1629 | } | ||
1630 | |||
1631 | return 0; | ||
1632 | } | ||
1633 | |||
1634 | static void mmc_blk_remove_req(struct mmc_blk_data *md) | 1648 | static void mmc_blk_remove_req(struct mmc_blk_data *md) |
1635 | { | 1649 | { |
1636 | struct mmc_card *card; | 1650 | struct mmc_card *card; |
@@ -1685,7 +1699,7 @@ static int mmc_add_disk(struct mmc_blk_data *md) | |||
1685 | 1699 | ||
1686 | if ((md->area_type & MMC_BLK_DATA_AREA_BOOT) && | 1700 | if ((md->area_type & MMC_BLK_DATA_AREA_BOOT) && |
1687 | card->ext_csd.boot_ro_lockable) { | 1701 | card->ext_csd.boot_ro_lockable) { |
1688 | mode_t mode; | 1702 | umode_t mode; |
1689 | 1703 | ||
1690 | if (card->ext_csd.boot_ro_lock & EXT_CSD_BOOT_WP_B_PWR_WP_DIS) | 1704 | if (card->ext_csd.boot_ro_lock & EXT_CSD_BOOT_WP_B_PWR_WP_DIS) |
1691 | mode = S_IRUGO; | 1705 | mode = S_IRUGO; |
@@ -1758,7 +1772,6 @@ static const struct mmc_fixup blk_fixups[] = | |||
1758 | static int mmc_blk_probe(struct mmc_card *card) | 1772 | static int mmc_blk_probe(struct mmc_card *card) |
1759 | { | 1773 | { |
1760 | struct mmc_blk_data *md, *part_md; | 1774 | struct mmc_blk_data *md, *part_md; |
1761 | int err; | ||
1762 | char cap_str[10]; | 1775 | char cap_str[10]; |
1763 | 1776 | ||
1764 | /* | 1777 | /* |
@@ -1771,10 +1784,6 @@ static int mmc_blk_probe(struct mmc_card *card) | |||
1771 | if (IS_ERR(md)) | 1784 | if (IS_ERR(md)) |
1772 | return PTR_ERR(md); | 1785 | return PTR_ERR(md); |
1773 | 1786 | ||
1774 | err = mmc_blk_set_blksize(md, card); | ||
1775 | if (err) | ||
1776 | goto out; | ||
1777 | |||
1778 | string_get_size((u64)get_capacity(md->disk) << 9, STRING_UNITS_2, | 1787 | string_get_size((u64)get_capacity(md->disk) << 9, STRING_UNITS_2, |
1779 | cap_str, sizeof(cap_str)); | 1788 | cap_str, sizeof(cap_str)); |
1780 | pr_info("%s: %s %s %s %s\n", | 1789 | pr_info("%s: %s %s %s %s\n", |
@@ -1799,7 +1808,7 @@ static int mmc_blk_probe(struct mmc_card *card) | |||
1799 | out: | 1808 | out: |
1800 | mmc_blk_remove_parts(card, md); | 1809 | mmc_blk_remove_parts(card, md); |
1801 | mmc_blk_remove_req(md); | 1810 | mmc_blk_remove_req(md); |
1802 | return err; | 1811 | return 0; |
1803 | } | 1812 | } |
1804 | 1813 | ||
1805 | static void mmc_blk_remove(struct mmc_card *card) | 1814 | static void mmc_blk_remove(struct mmc_card *card) |
@@ -1815,7 +1824,7 @@ static void mmc_blk_remove(struct mmc_card *card) | |||
1815 | } | 1824 | } |
1816 | 1825 | ||
1817 | #ifdef CONFIG_PM | 1826 | #ifdef CONFIG_PM |
1818 | static int mmc_blk_suspend(struct mmc_card *card, pm_message_t state) | 1827 | static int mmc_blk_suspend(struct mmc_card *card) |
1819 | { | 1828 | { |
1820 | struct mmc_blk_data *part_md; | 1829 | struct mmc_blk_data *part_md; |
1821 | struct mmc_blk_data *md = mmc_get_drvdata(card); | 1830 | struct mmc_blk_data *md = mmc_get_drvdata(card); |
@@ -1835,8 +1844,6 @@ static int mmc_blk_resume(struct mmc_card *card) | |||
1835 | struct mmc_blk_data *md = mmc_get_drvdata(card); | 1844 | struct mmc_blk_data *md = mmc_get_drvdata(card); |
1836 | 1845 | ||
1837 | if (md) { | 1846 | if (md) { |
1838 | mmc_blk_set_blksize(md, card); | ||
1839 | |||
1840 | /* | 1847 | /* |
1841 | * Resume involves the card going into idle state, | 1848 | * Resume involves the card going into idle state, |
1842 | * so current partition is always the main one. | 1849 | * so current partition is always the main one. |
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index 2517547b4366..996f8e36e23d 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c | |||
@@ -139,7 +139,7 @@ static void mmc_queue_setup_discard(struct request_queue *q, | |||
139 | 139 | ||
140 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); | 140 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); |
141 | q->limits.max_discard_sectors = max_discard; | 141 | q->limits.max_discard_sectors = max_discard; |
142 | if (card->erased_byte == 0) | 142 | if (card->erased_byte == 0 && !mmc_can_discard(card)) |
143 | q->limits.discard_zeroes_data = 1; | 143 | q->limits.discard_zeroes_data = 1; |
144 | q->limits.discard_granularity = card->pref_erase << 9; | 144 | q->limits.discard_granularity = card->pref_erase << 9; |
145 | /* granularity must not be greater than max. discard */ | 145 | /* granularity must not be greater than max. discard */ |
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c index 2c151e18c9e8..5a2cbfac66d2 100644 --- a/drivers/mmc/card/sdio_uart.c +++ b/drivers/mmc/card/sdio_uart.c | |||
@@ -750,15 +750,12 @@ static int sdio_uart_install(struct tty_driver *driver, struct tty_struct *tty) | |||
750 | { | 750 | { |
751 | int idx = tty->index; | 751 | int idx = tty->index; |
752 | struct sdio_uart_port *port = sdio_uart_port_get(idx); | 752 | struct sdio_uart_port *port = sdio_uart_port_get(idx); |
753 | int ret = tty_init_termios(tty); | 753 | int ret = tty_standard_install(driver, tty); |
754 | 754 | ||
755 | if (ret == 0) { | 755 | if (ret == 0) |
756 | tty_driver_kref_get(driver); | ||
757 | tty->count++; | ||
758 | /* This is the ref sdio_uart_port get provided */ | 756 | /* This is the ref sdio_uart_port get provided */ |
759 | tty->driver_data = port; | 757 | tty->driver_data = port; |
760 | driver->ttys[idx] = tty; | 758 | else |
761 | } else | ||
762 | sdio_uart_port_put(port); | 759 | sdio_uart_port_put(port); |
763 | return ret; | 760 | return ret; |
764 | } | 761 | } |
@@ -1178,7 +1175,6 @@ static int __init sdio_uart_init(void) | |||
1178 | if (!tty_drv) | 1175 | if (!tty_drv) |
1179 | return -ENOMEM; | 1176 | return -ENOMEM; |
1180 | 1177 | ||
1181 | tty_drv->owner = THIS_MODULE; | ||
1182 | tty_drv->driver_name = "sdio_uart"; | 1178 | tty_drv->driver_name = "sdio_uart"; |
1183 | tty_drv->name = "ttySDIO"; | 1179 | tty_drv->name = "ttySDIO"; |
1184 | tty_drv->major = 0; /* dynamically allocated */ | 1180 | tty_drv->major = 0; /* dynamically allocated */ |
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index 5d011a39dfff..c60cee92a2b2 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c | |||
@@ -122,14 +122,14 @@ static int mmc_bus_remove(struct device *dev) | |||
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
124 | 124 | ||
125 | static int mmc_bus_suspend(struct device *dev, pm_message_t state) | 125 | static int mmc_bus_suspend(struct device *dev) |
126 | { | 126 | { |
127 | struct mmc_driver *drv = to_mmc_driver(dev->driver); | 127 | struct mmc_driver *drv = to_mmc_driver(dev->driver); |
128 | struct mmc_card *card = mmc_dev_to_card(dev); | 128 | struct mmc_card *card = mmc_dev_to_card(dev); |
129 | int ret = 0; | 129 | int ret = 0; |
130 | 130 | ||
131 | if (dev->driver && drv->suspend) | 131 | if (dev->driver && drv->suspend) |
132 | ret = drv->suspend(card, state); | 132 | ret = drv->suspend(card); |
133 | return ret; | 133 | return ret; |
134 | } | 134 | } |
135 | 135 | ||
@@ -165,20 +165,14 @@ static int mmc_runtime_idle(struct device *dev) | |||
165 | return pm_runtime_suspend(dev); | 165 | return pm_runtime_suspend(dev); |
166 | } | 166 | } |
167 | 167 | ||
168 | #endif /* !CONFIG_PM_RUNTIME */ | ||
169 | |||
168 | static const struct dev_pm_ops mmc_bus_pm_ops = { | 170 | static const struct dev_pm_ops mmc_bus_pm_ops = { |
169 | .runtime_suspend = mmc_runtime_suspend, | 171 | SET_RUNTIME_PM_OPS(mmc_runtime_suspend, mmc_runtime_resume, |
170 | .runtime_resume = mmc_runtime_resume, | 172 | mmc_runtime_idle) |
171 | .runtime_idle = mmc_runtime_idle, | 173 | SET_SYSTEM_SLEEP_PM_OPS(mmc_bus_suspend, mmc_bus_resume) |
172 | }; | 174 | }; |
173 | 175 | ||
174 | #define MMC_PM_OPS_PTR (&mmc_bus_pm_ops) | ||
175 | |||
176 | #else /* !CONFIG_PM_RUNTIME */ | ||
177 | |||
178 | #define MMC_PM_OPS_PTR NULL | ||
179 | |||
180 | #endif /* !CONFIG_PM_RUNTIME */ | ||
181 | |||
182 | static struct bus_type mmc_bus_type = { | 176 | static struct bus_type mmc_bus_type = { |
183 | .name = "mmc", | 177 | .name = "mmc", |
184 | .dev_attrs = mmc_dev_attrs, | 178 | .dev_attrs = mmc_dev_attrs, |
@@ -186,9 +180,7 @@ static struct bus_type mmc_bus_type = { | |||
186 | .uevent = mmc_bus_uevent, | 180 | .uevent = mmc_bus_uevent, |
187 | .probe = mmc_bus_probe, | 181 | .probe = mmc_bus_probe, |
188 | .remove = mmc_bus_remove, | 182 | .remove = mmc_bus_remove, |
189 | .suspend = mmc_bus_suspend, | 183 | .pm = &mmc_bus_pm_ops, |
190 | .resume = mmc_bus_resume, | ||
191 | .pm = MMC_PM_OPS_PTR, | ||
192 | }; | 184 | }; |
193 | 185 | ||
194 | int mmc_register_bus(void) | 186 | int mmc_register_bus(void) |
@@ -267,6 +259,15 @@ int mmc_add_card(struct mmc_card *card) | |||
267 | { | 259 | { |
268 | int ret; | 260 | int ret; |
269 | const char *type; | 261 | const char *type; |
262 | const char *uhs_bus_speed_mode = ""; | ||
263 | static const char *const uhs_speeds[] = { | ||
264 | [UHS_SDR12_BUS_SPEED] = "SDR12 ", | ||
265 | [UHS_SDR25_BUS_SPEED] = "SDR25 ", | ||
266 | [UHS_SDR50_BUS_SPEED] = "SDR50 ", | ||
267 | [UHS_SDR104_BUS_SPEED] = "SDR104 ", | ||
268 | [UHS_DDR50_BUS_SPEED] = "DDR50 ", | ||
269 | }; | ||
270 | |||
270 | 271 | ||
271 | dev_set_name(&card->dev, "%s:%04x", mmc_hostname(card->host), card->rca); | 272 | dev_set_name(&card->dev, "%s:%04x", mmc_hostname(card->host), card->rca); |
272 | 273 | ||
@@ -296,6 +297,10 @@ int mmc_add_card(struct mmc_card *card) | |||
296 | break; | 297 | break; |
297 | } | 298 | } |
298 | 299 | ||
300 | if (mmc_sd_card_uhs(card) && | ||
301 | (card->sd_bus_speed < ARRAY_SIZE(uhs_speeds))) | ||
302 | uhs_bus_speed_mode = uhs_speeds[card->sd_bus_speed]; | ||
303 | |||
299 | if (mmc_host_is_spi(card->host)) { | 304 | if (mmc_host_is_spi(card->host)) { |
300 | pr_info("%s: new %s%s%s card on SPI\n", | 305 | pr_info("%s: new %s%s%s card on SPI\n", |
301 | mmc_hostname(card->host), | 306 | mmc_hostname(card->host), |
@@ -303,13 +308,13 @@ int mmc_add_card(struct mmc_card *card) | |||
303 | mmc_card_ddr_mode(card) ? "DDR " : "", | 308 | mmc_card_ddr_mode(card) ? "DDR " : "", |
304 | type); | 309 | type); |
305 | } else { | 310 | } else { |
306 | pr_info("%s: new %s%s%s%s card at address %04x\n", | 311 | pr_info("%s: new %s%s%s%s%s card at address %04x\n", |
307 | mmc_hostname(card->host), | 312 | mmc_hostname(card->host), |
308 | mmc_card_uhs(card) ? "ultra high speed " : | 313 | mmc_card_uhs(card) ? "ultra high speed " : |
309 | (mmc_card_highspeed(card) ? "high speed " : ""), | 314 | (mmc_card_highspeed(card) ? "high speed " : ""), |
310 | (mmc_card_hs200(card) ? "HS200 " : ""), | 315 | (mmc_card_hs200(card) ? "HS200 " : ""), |
311 | mmc_card_ddr_mode(card) ? "DDR " : "", | 316 | mmc_card_ddr_mode(card) ? "DDR " : "", |
312 | type, card->rca); | 317 | uhs_bus_speed_mode, type, card->rca); |
313 | } | 318 | } |
314 | 319 | ||
315 | #ifdef CONFIG_DEBUG_FS | 320 | #ifdef CONFIG_DEBUG_FS |
diff --git a/drivers/mmc/core/cd-gpio.c b/drivers/mmc/core/cd-gpio.c index 082202ae4a03..2c14be73254c 100644 --- a/drivers/mmc/core/cd-gpio.c +++ b/drivers/mmc/core/cd-gpio.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/gpio.h> | 12 | #include <linux/gpio.h> |
13 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
14 | #include <linux/jiffies.h> | 14 | #include <linux/jiffies.h> |
15 | #include <linux/mmc/cd-gpio.h> | ||
15 | #include <linux/mmc/host.h> | 16 | #include <linux/mmc/host.h> |
16 | #include <linux/module.h> | 17 | #include <linux/module.h> |
17 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
@@ -28,13 +29,17 @@ static irqreturn_t mmc_cd_gpio_irqt(int irq, void *dev_id) | |||
28 | return IRQ_HANDLED; | 29 | return IRQ_HANDLED; |
29 | } | 30 | } |
30 | 31 | ||
31 | int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio, | 32 | int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio) |
32 | unsigned int irq, unsigned long flags) | ||
33 | { | 33 | { |
34 | size_t len = strlen(dev_name(host->parent)) + 4; | 34 | size_t len = strlen(dev_name(host->parent)) + 4; |
35 | struct mmc_cd_gpio *cd = kmalloc(sizeof(*cd) + len, GFP_KERNEL); | 35 | struct mmc_cd_gpio *cd; |
36 | int irq = gpio_to_irq(gpio); | ||
36 | int ret; | 37 | int ret; |
37 | 38 | ||
39 | if (irq < 0) | ||
40 | return irq; | ||
41 | |||
42 | cd = kmalloc(sizeof(*cd) + len, GFP_KERNEL); | ||
38 | if (!cd) | 43 | if (!cd) |
39 | return -ENOMEM; | 44 | return -ENOMEM; |
40 | 45 | ||
@@ -45,7 +50,8 @@ int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio, | |||
45 | goto egpioreq; | 50 | goto egpioreq; |
46 | 51 | ||
47 | ret = request_threaded_irq(irq, NULL, mmc_cd_gpio_irqt, | 52 | ret = request_threaded_irq(irq, NULL, mmc_cd_gpio_irqt, |
48 | flags, cd->label, host); | 53 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
54 | cd->label, host); | ||
49 | if (ret < 0) | 55 | if (ret < 0) |
50 | goto eirqreq; | 56 | goto eirqreq; |
51 | 57 | ||
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 690255c7d4dc..ba821fe70bca 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -188,6 +188,12 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) | |||
188 | struct scatterlist *sg; | 188 | struct scatterlist *sg; |
189 | #endif | 189 | #endif |
190 | 190 | ||
191 | if (mrq->sbc) { | ||
192 | pr_debug("<%s: starting CMD%u arg %08x flags %08x>\n", | ||
193 | mmc_hostname(host), mrq->sbc->opcode, | ||
194 | mrq->sbc->arg, mrq->sbc->flags); | ||
195 | } | ||
196 | |||
191 | pr_debug("%s: starting CMD%u arg %08x flags %08x\n", | 197 | pr_debug("%s: starting CMD%u arg %08x flags %08x\n", |
192 | mmc_hostname(host), mrq->cmd->opcode, | 198 | mmc_hostname(host), mrq->cmd->opcode, |
193 | mrq->cmd->arg, mrq->cmd->flags); | 199 | mrq->cmd->arg, mrq->cmd->flags); |
@@ -243,16 +249,17 @@ static void mmc_wait_done(struct mmc_request *mrq) | |||
243 | complete(&mrq->completion); | 249 | complete(&mrq->completion); |
244 | } | 250 | } |
245 | 251 | ||
246 | static void __mmc_start_req(struct mmc_host *host, struct mmc_request *mrq) | 252 | static int __mmc_start_req(struct mmc_host *host, struct mmc_request *mrq) |
247 | { | 253 | { |
248 | init_completion(&mrq->completion); | 254 | init_completion(&mrq->completion); |
249 | mrq->done = mmc_wait_done; | 255 | mrq->done = mmc_wait_done; |
250 | if (mmc_card_removed(host->card)) { | 256 | if (mmc_card_removed(host->card)) { |
251 | mrq->cmd->error = -ENOMEDIUM; | 257 | mrq->cmd->error = -ENOMEDIUM; |
252 | complete(&mrq->completion); | 258 | complete(&mrq->completion); |
253 | return; | 259 | return -ENOMEDIUM; |
254 | } | 260 | } |
255 | mmc_start_request(host, mrq); | 261 | mmc_start_request(host, mrq); |
262 | return 0; | ||
256 | } | 263 | } |
257 | 264 | ||
258 | static void mmc_wait_for_req_done(struct mmc_host *host, | 265 | static void mmc_wait_for_req_done(struct mmc_host *host, |
@@ -336,6 +343,7 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host, | |||
336 | struct mmc_async_req *areq, int *error) | 343 | struct mmc_async_req *areq, int *error) |
337 | { | 344 | { |
338 | int err = 0; | 345 | int err = 0; |
346 | int start_err = 0; | ||
339 | struct mmc_async_req *data = host->areq; | 347 | struct mmc_async_req *data = host->areq; |
340 | 348 | ||
341 | /* Prepare a new request */ | 349 | /* Prepare a new request */ |
@@ -345,30 +353,23 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host, | |||
345 | if (host->areq) { | 353 | if (host->areq) { |
346 | mmc_wait_for_req_done(host, host->areq->mrq); | 354 | mmc_wait_for_req_done(host, host->areq->mrq); |
347 | err = host->areq->err_check(host->card, host->areq); | 355 | err = host->areq->err_check(host->card, host->areq); |
348 | if (err) { | ||
349 | /* post process the completed failed request */ | ||
350 | mmc_post_req(host, host->areq->mrq, 0); | ||
351 | if (areq) | ||
352 | /* | ||
353 | * Cancel the new prepared request, because | ||
354 | * it can't run until the failed | ||
355 | * request has been properly handled. | ||
356 | */ | ||
357 | mmc_post_req(host, areq->mrq, -EINVAL); | ||
358 | |||
359 | host->areq = NULL; | ||
360 | goto out; | ||
361 | } | ||
362 | } | 356 | } |
363 | 357 | ||
364 | if (areq) | 358 | if (!err && areq) |
365 | __mmc_start_req(host, areq->mrq); | 359 | start_err = __mmc_start_req(host, areq->mrq); |
366 | 360 | ||
367 | if (host->areq) | 361 | if (host->areq) |
368 | mmc_post_req(host, host->areq->mrq, 0); | 362 | mmc_post_req(host, host->areq->mrq, 0); |
369 | 363 | ||
370 | host->areq = areq; | 364 | /* Cancel a prepared request if it was not started. */ |
371 | out: | 365 | if ((err || start_err) && areq) |
366 | mmc_post_req(host, areq->mrq, -EINVAL); | ||
367 | |||
368 | if (err) | ||
369 | host->areq = NULL; | ||
370 | else | ||
371 | host->areq = areq; | ||
372 | |||
372 | if (error) | 373 | if (error) |
373 | *error = err; | 374 | *error = err; |
374 | return data; | 375 | return data; |
@@ -526,10 +527,14 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card) | |||
526 | 527 | ||
527 | if (data->flags & MMC_DATA_WRITE) | 528 | if (data->flags & MMC_DATA_WRITE) |
528 | /* | 529 | /* |
529 | * The limit is really 250 ms, but that is | 530 | * The MMC spec "It is strongly recommended |
530 | * insufficient for some crappy cards. | 531 | * for hosts to implement more than 500ms |
532 | * timeout value even if the card indicates | ||
533 | * the 250ms maximum busy length." Even the | ||
534 | * previous value of 300ms is known to be | ||
535 | * insufficient for some cards. | ||
531 | */ | 536 | */ |
532 | limit_us = 300000; | 537 | limit_us = 3000000; |
533 | else | 538 | else |
534 | limit_us = 100000; | 539 | limit_us = 100000; |
535 | 540 | ||
@@ -599,105 +604,6 @@ unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) | |||
599 | EXPORT_SYMBOL(mmc_align_data_size); | 604 | EXPORT_SYMBOL(mmc_align_data_size); |
600 | 605 | ||
601 | /** | 606 | /** |
602 | * mmc_host_enable - enable a host. | ||
603 | * @host: mmc host to enable | ||
604 | * | ||
605 | * Hosts that support power saving can use the 'enable' and 'disable' | ||
606 | * methods to exit and enter power saving states. For more information | ||
607 | * see comments for struct mmc_host_ops. | ||
608 | */ | ||
609 | int mmc_host_enable(struct mmc_host *host) | ||
610 | { | ||
611 | if (!(host->caps & MMC_CAP_DISABLE)) | ||
612 | return 0; | ||
613 | |||
614 | if (host->en_dis_recurs) | ||
615 | return 0; | ||
616 | |||
617 | if (host->nesting_cnt++) | ||
618 | return 0; | ||
619 | |||
620 | cancel_delayed_work_sync(&host->disable); | ||
621 | |||
622 | if (host->enabled) | ||
623 | return 0; | ||
624 | |||
625 | if (host->ops->enable) { | ||
626 | int err; | ||
627 | |||
628 | host->en_dis_recurs = 1; | ||
629 | mmc_host_clk_hold(host); | ||
630 | err = host->ops->enable(host); | ||
631 | mmc_host_clk_release(host); | ||
632 | host->en_dis_recurs = 0; | ||
633 | |||
634 | if (err) { | ||
635 | pr_debug("%s: enable error %d\n", | ||
636 | mmc_hostname(host), err); | ||
637 | return err; | ||
638 | } | ||
639 | } | ||
640 | host->enabled = 1; | ||
641 | return 0; | ||
642 | } | ||
643 | EXPORT_SYMBOL(mmc_host_enable); | ||
644 | |||
645 | static int mmc_host_do_disable(struct mmc_host *host, int lazy) | ||
646 | { | ||
647 | if (host->ops->disable) { | ||
648 | int err; | ||
649 | |||
650 | host->en_dis_recurs = 1; | ||
651 | mmc_host_clk_hold(host); | ||
652 | err = host->ops->disable(host, lazy); | ||
653 | mmc_host_clk_release(host); | ||
654 | host->en_dis_recurs = 0; | ||
655 | |||
656 | if (err < 0) { | ||
657 | pr_debug("%s: disable error %d\n", | ||
658 | mmc_hostname(host), err); | ||
659 | return err; | ||
660 | } | ||
661 | if (err > 0) { | ||
662 | unsigned long delay = msecs_to_jiffies(err); | ||
663 | |||
664 | mmc_schedule_delayed_work(&host->disable, delay); | ||
665 | } | ||
666 | } | ||
667 | host->enabled = 0; | ||
668 | return 0; | ||
669 | } | ||
670 | |||
671 | /** | ||
672 | * mmc_host_disable - disable a host. | ||
673 | * @host: mmc host to disable | ||
674 | * | ||
675 | * Hosts that support power saving can use the 'enable' and 'disable' | ||
676 | * methods to exit and enter power saving states. For more information | ||
677 | * see comments for struct mmc_host_ops. | ||
678 | */ | ||
679 | int mmc_host_disable(struct mmc_host *host) | ||
680 | { | ||
681 | int err; | ||
682 | |||
683 | if (!(host->caps & MMC_CAP_DISABLE)) | ||
684 | return 0; | ||
685 | |||
686 | if (host->en_dis_recurs) | ||
687 | return 0; | ||
688 | |||
689 | if (--host->nesting_cnt) | ||
690 | return 0; | ||
691 | |||
692 | if (!host->enabled) | ||
693 | return 0; | ||
694 | |||
695 | err = mmc_host_do_disable(host, 0); | ||
696 | return err; | ||
697 | } | ||
698 | EXPORT_SYMBOL(mmc_host_disable); | ||
699 | |||
700 | /** | ||
701 | * __mmc_claim_host - exclusively claim a host | 607 | * __mmc_claim_host - exclusively claim a host |
702 | * @host: mmc host to claim | 608 | * @host: mmc host to claim |
703 | * @abort: whether or not the operation should be aborted | 609 | * @abort: whether or not the operation should be aborted |
@@ -735,8 +641,8 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort) | |||
735 | wake_up(&host->wq); | 641 | wake_up(&host->wq); |
736 | spin_unlock_irqrestore(&host->lock, flags); | 642 | spin_unlock_irqrestore(&host->lock, flags); |
737 | remove_wait_queue(&host->wq, &wait); | 643 | remove_wait_queue(&host->wq, &wait); |
738 | if (!stop) | 644 | if (host->ops->enable && !stop && host->claim_cnt == 1) |
739 | mmc_host_enable(host); | 645 | host->ops->enable(host); |
740 | return stop; | 646 | return stop; |
741 | } | 647 | } |
742 | 648 | ||
@@ -761,21 +667,28 @@ int mmc_try_claim_host(struct mmc_host *host) | |||
761 | claimed_host = 1; | 667 | claimed_host = 1; |
762 | } | 668 | } |
763 | spin_unlock_irqrestore(&host->lock, flags); | 669 | spin_unlock_irqrestore(&host->lock, flags); |
670 | if (host->ops->enable && claimed_host && host->claim_cnt == 1) | ||
671 | host->ops->enable(host); | ||
764 | return claimed_host; | 672 | return claimed_host; |
765 | } | 673 | } |
766 | EXPORT_SYMBOL(mmc_try_claim_host); | 674 | EXPORT_SYMBOL(mmc_try_claim_host); |
767 | 675 | ||
768 | /** | 676 | /** |
769 | * mmc_do_release_host - release a claimed host | 677 | * mmc_release_host - release a host |
770 | * @host: mmc host to release | 678 | * @host: mmc host to release |
771 | * | 679 | * |
772 | * If you successfully claimed a host, this function will | 680 | * Release a MMC host, allowing others to claim the host |
773 | * release it again. | 681 | * for their operations. |
774 | */ | 682 | */ |
775 | void mmc_do_release_host(struct mmc_host *host) | 683 | void mmc_release_host(struct mmc_host *host) |
776 | { | 684 | { |
777 | unsigned long flags; | 685 | unsigned long flags; |
778 | 686 | ||
687 | WARN_ON(!host->claimed); | ||
688 | |||
689 | if (host->ops->disable && host->claim_cnt == 1) | ||
690 | host->ops->disable(host); | ||
691 | |||
779 | spin_lock_irqsave(&host->lock, flags); | 692 | spin_lock_irqsave(&host->lock, flags); |
780 | if (--host->claim_cnt) { | 693 | if (--host->claim_cnt) { |
781 | /* Release for nested claim */ | 694 | /* Release for nested claim */ |
@@ -787,67 +700,6 @@ void mmc_do_release_host(struct mmc_host *host) | |||
787 | wake_up(&host->wq); | 700 | wake_up(&host->wq); |
788 | } | 701 | } |
789 | } | 702 | } |
790 | EXPORT_SYMBOL(mmc_do_release_host); | ||
791 | |||
792 | void mmc_host_deeper_disable(struct work_struct *work) | ||
793 | { | ||
794 | struct mmc_host *host = | ||
795 | container_of(work, struct mmc_host, disable.work); | ||
796 | |||
797 | /* If the host is claimed then we do not want to disable it anymore */ | ||
798 | if (!mmc_try_claim_host(host)) | ||
799 | return; | ||
800 | mmc_host_do_disable(host, 1); | ||
801 | mmc_do_release_host(host); | ||
802 | } | ||
803 | |||
804 | /** | ||
805 | * mmc_host_lazy_disable - lazily disable a host. | ||
806 | * @host: mmc host to disable | ||
807 | * | ||
808 | * Hosts that support power saving can use the 'enable' and 'disable' | ||
809 | * methods to exit and enter power saving states. For more information | ||
810 | * see comments for struct mmc_host_ops. | ||
811 | */ | ||
812 | int mmc_host_lazy_disable(struct mmc_host *host) | ||
813 | { | ||
814 | if (!(host->caps & MMC_CAP_DISABLE)) | ||
815 | return 0; | ||
816 | |||
817 | if (host->en_dis_recurs) | ||
818 | return 0; | ||
819 | |||
820 | if (--host->nesting_cnt) | ||
821 | return 0; | ||
822 | |||
823 | if (!host->enabled) | ||
824 | return 0; | ||
825 | |||
826 | if (host->disable_delay) { | ||
827 | mmc_schedule_delayed_work(&host->disable, | ||
828 | msecs_to_jiffies(host->disable_delay)); | ||
829 | return 0; | ||
830 | } else | ||
831 | return mmc_host_do_disable(host, 1); | ||
832 | } | ||
833 | EXPORT_SYMBOL(mmc_host_lazy_disable); | ||
834 | |||
835 | /** | ||
836 | * mmc_release_host - release a host | ||
837 | * @host: mmc host to release | ||
838 | * | ||
839 | * Release a MMC host, allowing others to claim the host | ||
840 | * for their operations. | ||
841 | */ | ||
842 | void mmc_release_host(struct mmc_host *host) | ||
843 | { | ||
844 | WARN_ON(!host->claimed); | ||
845 | |||
846 | mmc_host_lazy_disable(host); | ||
847 | |||
848 | mmc_do_release_host(host); | ||
849 | } | ||
850 | |||
851 | EXPORT_SYMBOL(mmc_release_host); | 703 | EXPORT_SYMBOL(mmc_release_host); |
852 | 704 | ||
853 | /* | 705 | /* |
@@ -1557,7 +1409,10 @@ static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card, | |||
1557 | { | 1409 | { |
1558 | unsigned int erase_timeout; | 1410 | unsigned int erase_timeout; |
1559 | 1411 | ||
1560 | if (card->ext_csd.erase_group_def & 1) { | 1412 | if (arg == MMC_DISCARD_ARG || |
1413 | (arg == MMC_TRIM_ARG && card->ext_csd.rev >= 6)) { | ||
1414 | erase_timeout = card->ext_csd.trim_timeout; | ||
1415 | } else if (card->ext_csd.erase_group_def & 1) { | ||
1561 | /* High Capacity Erase Group Size uses HC timeouts */ | 1416 | /* High Capacity Erase Group Size uses HC timeouts */ |
1562 | if (arg == MMC_TRIM_ARG) | 1417 | if (arg == MMC_TRIM_ARG) |
1563 | erase_timeout = card->ext_csd.trim_timeout; | 1418 | erase_timeout = card->ext_csd.trim_timeout; |
@@ -1829,8 +1684,6 @@ int mmc_can_trim(struct mmc_card *card) | |||
1829 | { | 1684 | { |
1830 | if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) | 1685 | if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) |
1831 | return 1; | 1686 | return 1; |
1832 | if (mmc_can_discard(card)) | ||
1833 | return 1; | ||
1834 | return 0; | 1687 | return 0; |
1835 | } | 1688 | } |
1836 | EXPORT_SYMBOL(mmc_can_trim); | 1689 | EXPORT_SYMBOL(mmc_can_trim); |
@@ -1849,6 +1702,8 @@ EXPORT_SYMBOL(mmc_can_discard); | |||
1849 | 1702 | ||
1850 | int mmc_can_sanitize(struct mmc_card *card) | 1703 | int mmc_can_sanitize(struct mmc_card *card) |
1851 | { | 1704 | { |
1705 | if (!mmc_can_trim(card) && !mmc_can_erase(card)) | ||
1706 | return 0; | ||
1852 | if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE) | 1707 | if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE) |
1853 | return 1; | 1708 | return 1; |
1854 | return 0; | 1709 | return 0; |
@@ -2068,6 +1923,9 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq) | |||
2068 | */ | 1923 | */ |
2069 | mmc_hw_reset_for_init(host); | 1924 | mmc_hw_reset_for_init(host); |
2070 | 1925 | ||
1926 | /* Initialization should be done at 3.3 V I/O voltage. */ | ||
1927 | mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, 0); | ||
1928 | |||
2071 | /* | 1929 | /* |
2072 | * sdio_reset sends CMD52 to reset card. Since we do not know | 1930 | * sdio_reset sends CMD52 to reset card. Since we do not know |
2073 | * if the card is being re-initialized, just send it. CMD52 | 1931 | * if the card is being re-initialized, just send it. CMD52 |
@@ -2112,18 +1970,36 @@ int _mmc_detect_card_removed(struct mmc_host *host) | |||
2112 | int mmc_detect_card_removed(struct mmc_host *host) | 1970 | int mmc_detect_card_removed(struct mmc_host *host) |
2113 | { | 1971 | { |
2114 | struct mmc_card *card = host->card; | 1972 | struct mmc_card *card = host->card; |
1973 | int ret; | ||
2115 | 1974 | ||
2116 | WARN_ON(!host->claimed); | 1975 | WARN_ON(!host->claimed); |
1976 | |||
1977 | if (!card) | ||
1978 | return 1; | ||
1979 | |||
1980 | ret = mmc_card_removed(card); | ||
2117 | /* | 1981 | /* |
2118 | * The card will be considered unchanged unless we have been asked to | 1982 | * The card will be considered unchanged unless we have been asked to |
2119 | * detect a change or host requires polling to provide card detection. | 1983 | * detect a change or host requires polling to provide card detection. |
2120 | */ | 1984 | */ |
2121 | if (card && !host->detect_change && !(host->caps & MMC_CAP_NEEDS_POLL)) | 1985 | if (!host->detect_change && !(host->caps & MMC_CAP_NEEDS_POLL) && |
2122 | return mmc_card_removed(card); | 1986 | !(host->caps2 & MMC_CAP2_DETECT_ON_ERR)) |
1987 | return ret; | ||
2123 | 1988 | ||
2124 | host->detect_change = 0; | 1989 | host->detect_change = 0; |
1990 | if (!ret) { | ||
1991 | ret = _mmc_detect_card_removed(host); | ||
1992 | if (ret && (host->caps2 & MMC_CAP2_DETECT_ON_ERR)) { | ||
1993 | /* | ||
1994 | * Schedule a detect work as soon as possible to let a | ||
1995 | * rescan handle the card removal. | ||
1996 | */ | ||
1997 | cancel_delayed_work(&host->detect); | ||
1998 | mmc_detect_change(host, 0); | ||
1999 | } | ||
2000 | } | ||
2125 | 2001 | ||
2126 | return _mmc_detect_card_removed(host); | 2002 | return ret; |
2127 | } | 2003 | } |
2128 | EXPORT_SYMBOL(mmc_detect_card_removed); | 2004 | EXPORT_SYMBOL(mmc_detect_card_removed); |
2129 | 2005 | ||
@@ -2200,8 +2076,6 @@ void mmc_stop_host(struct mmc_host *host) | |||
2200 | spin_unlock_irqrestore(&host->lock, flags); | 2076 | spin_unlock_irqrestore(&host->lock, flags); |
2201 | #endif | 2077 | #endif |
2202 | 2078 | ||
2203 | if (host->caps & MMC_CAP_DISABLE) | ||
2204 | cancel_delayed_work(&host->disable); | ||
2205 | cancel_delayed_work_sync(&host->detect); | 2079 | cancel_delayed_work_sync(&host->detect); |
2206 | mmc_flush_scheduled_work(); | 2080 | mmc_flush_scheduled_work(); |
2207 | 2081 | ||
@@ -2364,6 +2238,7 @@ int mmc_cache_ctrl(struct mmc_host *host, u8 enable) | |||
2364 | mmc_card_is_removable(host)) | 2238 | mmc_card_is_removable(host)) |
2365 | return err; | 2239 | return err; |
2366 | 2240 | ||
2241 | mmc_claim_host(host); | ||
2367 | if (card && mmc_card_mmc(card) && | 2242 | if (card && mmc_card_mmc(card) && |
2368 | (card->ext_csd.cache_size > 0)) { | 2243 | (card->ext_csd.cache_size > 0)) { |
2369 | enable = !!enable; | 2244 | enable = !!enable; |
@@ -2381,6 +2256,7 @@ int mmc_cache_ctrl(struct mmc_host *host, u8 enable) | |||
2381 | card->ext_csd.cache_ctrl = enable; | 2256 | card->ext_csd.cache_ctrl = enable; |
2382 | } | 2257 | } |
2383 | } | 2258 | } |
2259 | mmc_release_host(host); | ||
2384 | 2260 | ||
2385 | return err; | 2261 | return err; |
2386 | } | 2262 | } |
@@ -2396,53 +2272,34 @@ int mmc_suspend_host(struct mmc_host *host) | |||
2396 | { | 2272 | { |
2397 | int err = 0; | 2273 | int err = 0; |
2398 | 2274 | ||
2399 | if (host->caps & MMC_CAP_DISABLE) | ||
2400 | cancel_delayed_work(&host->disable); | ||
2401 | cancel_delayed_work(&host->detect); | 2275 | cancel_delayed_work(&host->detect); |
2402 | mmc_flush_scheduled_work(); | 2276 | mmc_flush_scheduled_work(); |
2403 | if (mmc_try_claim_host(host)) { | ||
2404 | err = mmc_cache_ctrl(host, 0); | ||
2405 | mmc_do_release_host(host); | ||
2406 | } else { | ||
2407 | err = -EBUSY; | ||
2408 | } | ||
2409 | 2277 | ||
2278 | err = mmc_cache_ctrl(host, 0); | ||
2410 | if (err) | 2279 | if (err) |
2411 | goto out; | 2280 | goto out; |
2412 | 2281 | ||
2413 | mmc_bus_get(host); | 2282 | mmc_bus_get(host); |
2414 | if (host->bus_ops && !host->bus_dead) { | 2283 | if (host->bus_ops && !host->bus_dead) { |
2415 | 2284 | ||
2416 | /* | 2285 | if (host->bus_ops->suspend) |
2417 | * A long response time is not acceptable for device drivers | 2286 | err = host->bus_ops->suspend(host); |
2418 | * when doing suspend. Prevent mmc_claim_host in the suspend | 2287 | |
2419 | * sequence, to potentially wait "forever" by trying to | 2288 | if (err == -ENOSYS || !host->bus_ops->resume) { |
2420 | * pre-claim the host. | 2289 | /* |
2421 | */ | 2290 | * We simply "remove" the card in this case. |
2422 | if (mmc_try_claim_host(host)) { | 2291 | * It will be redetected on resume. (Calling |
2423 | if (host->bus_ops->suspend) { | 2292 | * bus_ops->remove() with a claimed host can |
2424 | err = host->bus_ops->suspend(host); | 2293 | * deadlock.) |
2425 | } | 2294 | */ |
2426 | mmc_do_release_host(host); | 2295 | if (host->bus_ops->remove) |
2427 | 2296 | host->bus_ops->remove(host); | |
2428 | if (err == -ENOSYS || !host->bus_ops->resume) { | 2297 | mmc_claim_host(host); |
2429 | /* | 2298 | mmc_detach_bus(host); |
2430 | * We simply "remove" the card in this case. | 2299 | mmc_power_off(host); |
2431 | * It will be redetected on resume. (Calling | 2300 | mmc_release_host(host); |
2432 | * bus_ops->remove() with a claimed host can | 2301 | host->pm_flags = 0; |
2433 | * deadlock.) | 2302 | err = 0; |
2434 | */ | ||
2435 | if (host->bus_ops->remove) | ||
2436 | host->bus_ops->remove(host); | ||
2437 | mmc_claim_host(host); | ||
2438 | mmc_detach_bus(host); | ||
2439 | mmc_power_off(host); | ||
2440 | mmc_release_host(host); | ||
2441 | host->pm_flags = 0; | ||
2442 | err = 0; | ||
2443 | } | ||
2444 | } else { | ||
2445 | err = -EBUSY; | ||
2446 | } | 2303 | } |
2447 | } | 2304 | } |
2448 | mmc_bus_put(host); | 2305 | mmc_bus_put(host); |
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 30055f2b0d44..91c84c7a1829 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c | |||
@@ -238,10 +238,10 @@ static inline void mmc_host_clk_init(struct mmc_host *host) | |||
238 | /* Hold MCI clock for 8 cycles by default */ | 238 | /* Hold MCI clock for 8 cycles by default */ |
239 | host->clk_delay = 8; | 239 | host->clk_delay = 8; |
240 | /* | 240 | /* |
241 | * Default clock gating delay is 200ms. | 241 | * Default clock gating delay is 0ms to avoid wasting power. |
242 | * This value can be tuned by writing into sysfs entry. | 242 | * This value can be tuned by writing into sysfs entry. |
243 | */ | 243 | */ |
244 | host->clkgate_delay = 200; | 244 | host->clkgate_delay = 0; |
245 | host->clk_gated = false; | 245 | host->clk_gated = false; |
246 | INIT_DELAYED_WORK(&host->clk_gate_work, mmc_host_clk_gate_work); | 246 | INIT_DELAYED_WORK(&host->clk_gate_work, mmc_host_clk_gate_work); |
247 | spin_lock_init(&host->clk_lock); | 247 | spin_lock_init(&host->clk_lock); |
@@ -330,7 +330,6 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) | |||
330 | spin_lock_init(&host->lock); | 330 | spin_lock_init(&host->lock); |
331 | init_waitqueue_head(&host->wq); | 331 | init_waitqueue_head(&host->wq); |
332 | INIT_DELAYED_WORK(&host->detect, mmc_rescan); | 332 | INIT_DELAYED_WORK(&host->detect, mmc_rescan); |
333 | INIT_DELAYED_WORK_DEFERRABLE(&host->disable, mmc_host_deeper_disable); | ||
334 | #ifdef CONFIG_PM | 333 | #ifdef CONFIG_PM |
335 | host->pm_notify.notifier_call = mmc_pm_notify; | 334 | host->pm_notify.notifier_call = mmc_pm_notify; |
336 | #endif | 335 | #endif |
diff --git a/drivers/mmc/core/host.h b/drivers/mmc/core/host.h index 08a7852ade44..f2ab9e578126 100644 --- a/drivers/mmc/core/host.h +++ b/drivers/mmc/core/host.h | |||
@@ -14,7 +14,6 @@ | |||
14 | 14 | ||
15 | int mmc_register_host_class(void); | 15 | int mmc_register_host_class(void); |
16 | void mmc_unregister_host_class(void); | 16 | void mmc_unregister_host_class(void); |
17 | void mmc_host_deeper_disable(struct work_struct *work); | ||
18 | 17 | ||
19 | #endif | 18 | #endif |
20 | 19 | ||
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index a48066344fa8..54df5adc0413 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -519,6 +519,20 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) | |||
519 | ext_csd[EXT_CSD_CACHE_SIZE + 1] << 8 | | 519 | ext_csd[EXT_CSD_CACHE_SIZE + 1] << 8 | |
520 | ext_csd[EXT_CSD_CACHE_SIZE + 2] << 16 | | 520 | ext_csd[EXT_CSD_CACHE_SIZE + 2] << 16 | |
521 | ext_csd[EXT_CSD_CACHE_SIZE + 3] << 24; | 521 | ext_csd[EXT_CSD_CACHE_SIZE + 3] << 24; |
522 | |||
523 | if (ext_csd[EXT_CSD_DATA_SECTOR_SIZE] == 1) | ||
524 | card->ext_csd.data_sector_size = 4096; | ||
525 | else | ||
526 | card->ext_csd.data_sector_size = 512; | ||
527 | |||
528 | if ((ext_csd[EXT_CSD_DATA_TAG_SUPPORT] & 1) && | ||
529 | (ext_csd[EXT_CSD_TAG_UNIT_SIZE] <= 8)) { | ||
530 | card->ext_csd.data_tag_unit_size = | ||
531 | ((unsigned int) 1 << ext_csd[EXT_CSD_TAG_UNIT_SIZE]) * | ||
532 | (card->ext_csd.data_sector_size); | ||
533 | } else { | ||
534 | card->ext_csd.data_tag_unit_size = 0; | ||
535 | } | ||
522 | } | 536 | } |
523 | 537 | ||
524 | out: | 538 | out: |
@@ -681,6 +695,11 @@ static int mmc_select_powerclass(struct mmc_card *card, | |||
681 | else if (host->ios.clock <= 200000000) | 695 | else if (host->ios.clock <= 200000000) |
682 | index = EXT_CSD_PWR_CL_200_195; | 696 | index = EXT_CSD_PWR_CL_200_195; |
683 | break; | 697 | break; |
698 | case MMC_VDD_27_28: | ||
699 | case MMC_VDD_28_29: | ||
700 | case MMC_VDD_29_30: | ||
701 | case MMC_VDD_30_31: | ||
702 | case MMC_VDD_31_32: | ||
684 | case MMC_VDD_32_33: | 703 | case MMC_VDD_32_33: |
685 | case MMC_VDD_33_34: | 704 | case MMC_VDD_33_34: |
686 | case MMC_VDD_34_35: | 705 | case MMC_VDD_34_35: |
@@ -816,6 +835,9 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
816 | if (!mmc_host_is_spi(host)) | 835 | if (!mmc_host_is_spi(host)) |
817 | mmc_set_bus_mode(host, MMC_BUSMODE_OPENDRAIN); | 836 | mmc_set_bus_mode(host, MMC_BUSMODE_OPENDRAIN); |
818 | 837 | ||
838 | /* Initialization should be done at 3.3 V I/O voltage. */ | ||
839 | mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, 0); | ||
840 | |||
819 | /* | 841 | /* |
820 | * Since we're changing the OCR value, we seem to | 842 | * Since we're changing the OCR value, we seem to |
821 | * need to tell some cards to go back to the idle | 843 | * need to tell some cards to go back to the idle |
@@ -935,7 +957,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
935 | * If enhanced_area_en is TRUE, host needs to enable ERASE_GRP_DEF | 957 | * If enhanced_area_en is TRUE, host needs to enable ERASE_GRP_DEF |
936 | * bit. This bit will be lost every time after a reset or power off. | 958 | * bit. This bit will be lost every time after a reset or power off. |
937 | */ | 959 | */ |
938 | if (card->ext_csd.enhanced_area_en) { | 960 | if (card->ext_csd.enhanced_area_en || |
961 | (card->ext_csd.rev >= 3 && (host->caps2 & MMC_CAP2_HC_ERASE_SZ))) { | ||
939 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | 962 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
940 | EXT_CSD_ERASE_GROUP_DEF, 1, | 963 | EXT_CSD_ERASE_GROUP_DEF, 1, |
941 | card->ext_csd.generic_cmd6_time); | 964 | card->ext_csd.generic_cmd6_time); |
@@ -1030,22 +1053,6 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
1030 | } | 1053 | } |
1031 | 1054 | ||
1032 | /* | 1055 | /* |
1033 | * Enable HPI feature (if supported) | ||
1034 | */ | ||
1035 | if (card->ext_csd.hpi) { | ||
1036 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | ||
1037 | EXT_CSD_HPI_MGMT, 1, 0); | ||
1038 | if (err && err != -EBADMSG) | ||
1039 | goto free_card; | ||
1040 | if (err) { | ||
1041 | pr_warning("%s: Enabling HPI failed\n", | ||
1042 | mmc_hostname(card->host)); | ||
1043 | err = 0; | ||
1044 | } else | ||
1045 | card->ext_csd.hpi_en = 1; | ||
1046 | } | ||
1047 | |||
1048 | /* | ||
1049 | * Compute bus speed. | 1056 | * Compute bus speed. |
1050 | */ | 1057 | */ |
1051 | max_dtr = (unsigned int)-1; | 1058 | max_dtr = (unsigned int)-1; |
@@ -1094,9 +1101,12 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
1094 | * 4. execute tuning for HS200 | 1101 | * 4. execute tuning for HS200 |
1095 | */ | 1102 | */ |
1096 | if ((host->caps2 & MMC_CAP2_HS200) && | 1103 | if ((host->caps2 & MMC_CAP2_HS200) && |
1097 | card->host->ops->execute_tuning) | 1104 | card->host->ops->execute_tuning) { |
1105 | mmc_host_clk_hold(card->host); | ||
1098 | err = card->host->ops->execute_tuning(card->host, | 1106 | err = card->host->ops->execute_tuning(card->host, |
1099 | MMC_SEND_TUNING_BLOCK_HS200); | 1107 | MMC_SEND_TUNING_BLOCK_HS200); |
1108 | mmc_host_clk_release(card->host); | ||
1109 | } | ||
1100 | if (err) { | 1110 | if (err) { |
1101 | pr_warning("%s: tuning execution failed\n", | 1111 | pr_warning("%s: tuning execution failed\n", |
1102 | mmc_hostname(card->host)); | 1112 | mmc_hostname(card->host)); |
@@ -1106,11 +1116,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
1106 | ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ? | 1116 | ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ? |
1107 | EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4; | 1117 | EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4; |
1108 | err = mmc_select_powerclass(card, ext_csd_bits, ext_csd); | 1118 | err = mmc_select_powerclass(card, ext_csd_bits, ext_csd); |
1109 | if (err) { | 1119 | if (err) |
1110 | pr_err("%s: power class selection to bus width %d failed\n", | 1120 | pr_warning("%s: power class selection to bus width %d" |
1111 | mmc_hostname(card->host), 1 << bus_width); | 1121 | " failed\n", mmc_hostname(card->host), |
1112 | goto err; | 1122 | 1 << bus_width); |
1113 | } | ||
1114 | } | 1123 | } |
1115 | 1124 | ||
1116 | /* | 1125 | /* |
@@ -1142,10 +1151,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
1142 | err = mmc_select_powerclass(card, ext_csd_bits[idx][0], | 1151 | err = mmc_select_powerclass(card, ext_csd_bits[idx][0], |
1143 | ext_csd); | 1152 | ext_csd); |
1144 | if (err) | 1153 | if (err) |
1145 | pr_err("%s: power class selection to " | 1154 | pr_warning("%s: power class selection to " |
1146 | "bus width %d failed\n", | 1155 | "bus width %d failed\n", |
1147 | mmc_hostname(card->host), | 1156 | mmc_hostname(card->host), |
1148 | 1 << bus_width); | 1157 | 1 << bus_width); |
1149 | 1158 | ||
1150 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | 1159 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
1151 | EXT_CSD_BUS_WIDTH, | 1160 | EXT_CSD_BUS_WIDTH, |
@@ -1173,10 +1182,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
1173 | err = mmc_select_powerclass(card, ext_csd_bits[idx][1], | 1182 | err = mmc_select_powerclass(card, ext_csd_bits[idx][1], |
1174 | ext_csd); | 1183 | ext_csd); |
1175 | if (err) | 1184 | if (err) |
1176 | pr_err("%s: power class selection to " | 1185 | pr_warning("%s: power class selection to " |
1177 | "bus width %d ddr %d failed\n", | 1186 | "bus width %d ddr %d failed\n", |
1178 | mmc_hostname(card->host), | 1187 | mmc_hostname(card->host), |
1179 | 1 << bus_width, ddr); | 1188 | 1 << bus_width, ddr); |
1180 | 1189 | ||
1181 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | 1190 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
1182 | EXT_CSD_BUS_WIDTH, | 1191 | EXT_CSD_BUS_WIDTH, |
@@ -1216,6 +1225,23 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
1216 | } | 1225 | } |
1217 | 1226 | ||
1218 | /* | 1227 | /* |
1228 | * Enable HPI feature (if supported) | ||
1229 | */ | ||
1230 | if (card->ext_csd.hpi) { | ||
1231 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | ||
1232 | EXT_CSD_HPI_MGMT, 1, | ||
1233 | card->ext_csd.generic_cmd6_time); | ||
1234 | if (err && err != -EBADMSG) | ||
1235 | goto free_card; | ||
1236 | if (err) { | ||
1237 | pr_warning("%s: Enabling HPI failed\n", | ||
1238 | mmc_hostname(card->host)); | ||
1239 | err = 0; | ||
1240 | } else | ||
1241 | card->ext_csd.hpi_en = 1; | ||
1242 | } | ||
1243 | |||
1244 | /* | ||
1219 | * If cache size is higher than 0, this indicates | 1245 | * If cache size is higher than 0, this indicates |
1220 | * the existence of cache and it can be turned on. | 1246 | * the existence of cache and it can be turned on. |
1221 | */ | 1247 | */ |
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 4d41fa984c93..69370f494e05 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c | |||
@@ -553,18 +553,22 @@ int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status) | |||
553 | { | 553 | { |
554 | struct mmc_command cmd = {0}; | 554 | struct mmc_command cmd = {0}; |
555 | unsigned int opcode; | 555 | unsigned int opcode; |
556 | unsigned int flags; | ||
557 | int err; | 556 | int err; |
558 | 557 | ||
558 | if (!card->ext_csd.hpi) { | ||
559 | pr_warning("%s: Card didn't support HPI command\n", | ||
560 | mmc_hostname(card->host)); | ||
561 | return -EINVAL; | ||
562 | } | ||
563 | |||
559 | opcode = card->ext_csd.hpi_cmd; | 564 | opcode = card->ext_csd.hpi_cmd; |
560 | if (opcode == MMC_STOP_TRANSMISSION) | 565 | if (opcode == MMC_STOP_TRANSMISSION) |
561 | flags = MMC_RSP_R1 | MMC_CMD_AC; | 566 | cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; |
562 | else if (opcode == MMC_SEND_STATUS) | 567 | else if (opcode == MMC_SEND_STATUS) |
563 | flags = MMC_RSP_R1 | MMC_CMD_AC; | 568 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; |
564 | 569 | ||
565 | cmd.opcode = opcode; | 570 | cmd.opcode = opcode; |
566 | cmd.arg = card->rca << 16 | 1; | 571 | cmd.arg = card->rca << 16 | 1; |
567 | cmd.flags = flags; | ||
568 | cmd.cmd_timeout_ms = card->ext_csd.out_of_int_time; | 572 | cmd.cmd_timeout_ms = card->ext_csd.out_of_int_time; |
569 | 573 | ||
570 | err = mmc_wait_for_cmd(card->host, &cmd, 0); | 574 | err = mmc_wait_for_cmd(card->host, &cmd, 0); |
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 5017f9354ce2..c272c6868ecf 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c | |||
@@ -911,6 +911,9 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
911 | BUG_ON(!host); | 911 | BUG_ON(!host); |
912 | WARN_ON(!host->claimed); | 912 | WARN_ON(!host->claimed); |
913 | 913 | ||
914 | /* The initialization should be done at 3.3 V I/O voltage. */ | ||
915 | mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, 0); | ||
916 | |||
914 | err = mmc_sd_get_cid(host, ocr, cid, &rocr); | 917 | err = mmc_sd_get_cid(host, ocr, cid, &rocr); |
915 | if (err) | 918 | if (err) |
916 | return err; | 919 | return err; |
@@ -1156,11 +1159,6 @@ int mmc_attach_sd(struct mmc_host *host) | |||
1156 | BUG_ON(!host); | 1159 | BUG_ON(!host); |
1157 | WARN_ON(!host->claimed); | 1160 | WARN_ON(!host->claimed); |
1158 | 1161 | ||
1159 | /* Make sure we are at 3.3V signalling voltage */ | ||
1160 | err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, false); | ||
1161 | if (err) | ||
1162 | return err; | ||
1163 | |||
1164 | /* Disable preset value enable if already set since last time */ | 1162 | /* Disable preset value enable if already set since last time */ |
1165 | if (host->ops->enable_preset_value) { | 1163 | if (host->ops->enable_preset_value) { |
1166 | mmc_host_clk_hold(host); | 1164 | mmc_host_clk_hold(host); |
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 12cde6ee17f5..2c7c83f832d2 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c | |||
@@ -585,6 +585,9 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, | |||
585 | * Inform the card of the voltage | 585 | * Inform the card of the voltage |
586 | */ | 586 | */ |
587 | if (!powered_resume) { | 587 | if (!powered_resume) { |
588 | /* The initialization should be done at 3.3 V I/O voltage. */ | ||
589 | mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, 0); | ||
590 | |||
588 | err = mmc_send_io_op_cond(host, host->ocr, &ocr); | 591 | err = mmc_send_io_op_cond(host, host->ocr, &ocr); |
589 | if (err) | 592 | if (err) |
590 | goto err; | 593 | goto err; |
@@ -996,6 +999,11 @@ static int mmc_sdio_power_restore(struct mmc_host *host) | |||
996 | * With these steps taken, mmc_select_voltage() is also required to | 999 | * With these steps taken, mmc_select_voltage() is also required to |
997 | * restore the correct voltage setting of the card. | 1000 | * restore the correct voltage setting of the card. |
998 | */ | 1001 | */ |
1002 | |||
1003 | /* The initialization should be done at 3.3 V I/O voltage. */ | ||
1004 | if (!mmc_card_keep_power(host)) | ||
1005 | mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, 0); | ||
1006 | |||
999 | sdio_reset(host); | 1007 | sdio_reset(host); |
1000 | mmc_go_idle(host); | 1008 | mmc_go_idle(host); |
1001 | mmc_send_if_cond(host, host->ocr_avail); | 1009 | mmc_send_if_cond(host, host->ocr_avail); |
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c index 40989e6bb53a..236842ec955a 100644 --- a/drivers/mmc/core/sdio_bus.c +++ b/drivers/mmc/core/sdio_bus.c | |||
@@ -192,9 +192,15 @@ static int sdio_bus_remove(struct device *dev) | |||
192 | return ret; | 192 | return ret; |
193 | } | 193 | } |
194 | 194 | ||
195 | #ifdef CONFIG_PM_RUNTIME | 195 | #ifdef CONFIG_PM |
196 | |||
197 | static int pm_no_operation(struct device *dev) | ||
198 | { | ||
199 | return 0; | ||
200 | } | ||
196 | 201 | ||
197 | static const struct dev_pm_ops sdio_bus_pm_ops = { | 202 | static const struct dev_pm_ops sdio_bus_pm_ops = { |
203 | SET_SYSTEM_SLEEP_PM_OPS(pm_no_operation, pm_no_operation) | ||
198 | SET_RUNTIME_PM_OPS( | 204 | SET_RUNTIME_PM_OPS( |
199 | pm_generic_runtime_suspend, | 205 | pm_generic_runtime_suspend, |
200 | pm_generic_runtime_resume, | 206 | pm_generic_runtime_resume, |
@@ -204,11 +210,11 @@ static const struct dev_pm_ops sdio_bus_pm_ops = { | |||
204 | 210 | ||
205 | #define SDIO_PM_OPS_PTR (&sdio_bus_pm_ops) | 211 | #define SDIO_PM_OPS_PTR (&sdio_bus_pm_ops) |
206 | 212 | ||
207 | #else /* !CONFIG_PM_RUNTIME */ | 213 | #else /* !CONFIG_PM */ |
208 | 214 | ||
209 | #define SDIO_PM_OPS_PTR NULL | 215 | #define SDIO_PM_OPS_PTR NULL |
210 | 216 | ||
211 | #endif /* !CONFIG_PM_RUNTIME */ | 217 | #endif /* !CONFIG_PM */ |
212 | 218 | ||
213 | static struct bus_type sdio_bus_type = { | 219 | static struct bus_type sdio_bus_type = { |
214 | .name = "sdio", | 220 | .name = "sdio", |
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 00fcbed1afd2..2bc06e7344db 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig | |||
@@ -395,7 +395,7 @@ config MMC_SPI | |||
395 | 395 | ||
396 | config MMC_S3C | 396 | config MMC_S3C |
397 | tristate "Samsung S3C SD/MMC Card Interface support" | 397 | tristate "Samsung S3C SD/MMC Card Interface support" |
398 | depends on ARCH_S3C2410 | 398 | depends on ARCH_S3C24XX |
399 | help | 399 | help |
400 | This selects a driver for the MCI interface found in | 400 | This selects a driver for the MCI interface found in |
401 | Samsung's S3C2410, S3C2412, S3C2440, S3C2442 CPUs. | 401 | Samsung's S3C2410, S3C2412, S3C2440, S3C2442 CPUs. |
@@ -533,6 +533,31 @@ config MMC_DW_IDMAC | |||
533 | Designware Mobile Storage IP block. This disables the external DMA | 533 | Designware Mobile Storage IP block. This disables the external DMA |
534 | interface. | 534 | interface. |
535 | 535 | ||
536 | config MMC_DW_PLTFM | ||
537 | tristate "Synopsys Designware MCI Support as platform device" | ||
538 | depends on MMC_DW | ||
539 | default y | ||
540 | help | ||
541 | This selects the common helper functions support for Host Controller | ||
542 | Interface based platform driver. Please select this option if the IP | ||
543 | is present as a platform device. This is the common interface for the | ||
544 | Synopsys Designware IP. | ||
545 | |||
546 | If you have a controller with this interface, say Y or M here. | ||
547 | |||
548 | If unsure, say Y. | ||
549 | |||
550 | config MMC_DW_PCI | ||
551 | tristate "Synopsys Designware MCI support on PCI bus" | ||
552 | depends on MMC_DW && PCI | ||
553 | help | ||
554 | This selects the PCI bus for the Synopsys Designware Mobile Storage IP. | ||
555 | Select this option if the IP is present on PCI platform. | ||
556 | |||
557 | If you have a controller with this interface, say Y or M here. | ||
558 | |||
559 | If unsure, say N. | ||
560 | |||
536 | config MMC_SH_MMCIF | 561 | config MMC_SH_MMCIF |
537 | tristate "SuperH Internal MMCIF support" | 562 | tristate "SuperH Internal MMCIF support" |
538 | depends on MMC_BLOCK && (SUPERH || ARCH_SHMOBILE) | 563 | depends on MMC_BLOCK && (SUPERH || ARCH_SHMOBILE) |
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index 745f8fce2519..3e7e26d08073 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile | |||
@@ -39,6 +39,8 @@ obj-$(CONFIG_MMC_CB710) += cb710-mmc.o | |||
39 | obj-$(CONFIG_MMC_VIA_SDMMC) += via-sdmmc.o | 39 | obj-$(CONFIG_MMC_VIA_SDMMC) += via-sdmmc.o |
40 | obj-$(CONFIG_SDH_BFIN) += bfin_sdh.o | 40 | obj-$(CONFIG_SDH_BFIN) += bfin_sdh.o |
41 | obj-$(CONFIG_MMC_DW) += dw_mmc.o | 41 | obj-$(CONFIG_MMC_DW) += dw_mmc.o |
42 | obj-$(CONFIG_MMC_DW_PLTFM) += dw_mmc-pltfm.o | ||
43 | obj-$(CONFIG_MMC_DW_PCI) += dw_mmc-pci.o | ||
42 | obj-$(CONFIG_MMC_SH_MMCIF) += sh_mmcif.o | 44 | obj-$(CONFIG_MMC_SH_MMCIF) += sh_mmcif.o |
43 | obj-$(CONFIG_MMC_JZ4740) += jz4740_mmc.o | 45 | obj-$(CONFIG_MMC_JZ4740) += jz4740_mmc.o |
44 | obj-$(CONFIG_MMC_VUB300) += vub300.o | 46 | obj-$(CONFIG_MMC_VUB300) += vub300.o |
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c index 947faa5d2ce4..efdb81d21c44 100644 --- a/drivers/mmc/host/at91_mci.c +++ b/drivers/mmc/host/at91_mci.c | |||
@@ -86,7 +86,6 @@ static inline int at91mci_is_mci1rev2xx(void) | |||
86 | { | 86 | { |
87 | return ( cpu_is_at91sam9260() | 87 | return ( cpu_is_at91sam9260() |
88 | || cpu_is_at91sam9263() | 88 | || cpu_is_at91sam9263() |
89 | || cpu_is_at91cap9() | ||
90 | || cpu_is_at91sam9rl() | 89 | || cpu_is_at91sam9rl() |
91 | || cpu_is_at91sam9g10() | 90 | || cpu_is_at91sam9g10() |
92 | || cpu_is_at91sam9g20() | 91 | || cpu_is_at91sam9g20() |
diff --git a/drivers/mmc/host/atmel-mci-regs.h b/drivers/mmc/host/atmel-mci-regs.h index 000b3ad0f5ca..787aba1682bb 100644 --- a/drivers/mmc/host/atmel-mci-regs.h +++ b/drivers/mmc/host/atmel-mci-regs.h | |||
@@ -31,6 +31,7 @@ | |||
31 | # define ATMCI_MR_PDCFBYTE ( 1 << 13) /* Force Byte Transfer */ | 31 | # define ATMCI_MR_PDCFBYTE ( 1 << 13) /* Force Byte Transfer */ |
32 | # define ATMCI_MR_PDCPADV ( 1 << 14) /* Padding Value */ | 32 | # define ATMCI_MR_PDCPADV ( 1 << 14) /* Padding Value */ |
33 | # define ATMCI_MR_PDCMODE ( 1 << 15) /* PDC-oriented Mode */ | 33 | # define ATMCI_MR_PDCMODE ( 1 << 15) /* PDC-oriented Mode */ |
34 | # define ATMCI_MR_CLKODD(x) ((x) << 16) /* LSB of Clock Divider */ | ||
34 | #define ATMCI_DTOR 0x0008 /* Data Timeout */ | 35 | #define ATMCI_DTOR 0x0008 /* Data Timeout */ |
35 | # define ATMCI_DTOCYC(x) ((x) << 0) /* Data Timeout Cycles */ | 36 | # define ATMCI_DTOCYC(x) ((x) << 0) /* Data Timeout Cycles */ |
36 | # define ATMCI_DTOMUL(x) ((x) << 4) /* Data Timeout Multiplier */ | 37 | # define ATMCI_DTOMUL(x) ((x) << 4) /* Data Timeout Multiplier */ |
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index 6985cdb0bb26..e94476beca18 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/seq_file.h> | 24 | #include <linux/seq_file.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/stat.h> | 26 | #include <linux/stat.h> |
27 | #include <linux/types.h> | ||
27 | 28 | ||
28 | #include <linux/mmc/host.h> | 29 | #include <linux/mmc/host.h> |
29 | #include <linux/mmc/sdio.h> | 30 | #include <linux/mmc/sdio.h> |
@@ -76,6 +77,7 @@ struct atmel_mci_caps { | |||
76 | bool has_cstor_reg; | 77 | bool has_cstor_reg; |
77 | bool has_highspeed; | 78 | bool has_highspeed; |
78 | bool has_rwproof; | 79 | bool has_rwproof; |
80 | bool has_odd_clk_div; | ||
79 | }; | 81 | }; |
80 | 82 | ||
81 | struct atmel_mci_dma { | 83 | struct atmel_mci_dma { |
@@ -173,6 +175,7 @@ struct atmel_mci { | |||
173 | 175 | ||
174 | struct atmel_mci_dma dma; | 176 | struct atmel_mci_dma dma; |
175 | struct dma_chan *data_chan; | 177 | struct dma_chan *data_chan; |
178 | struct dma_slave_config dma_conf; | ||
176 | 179 | ||
177 | u32 cmd_status; | 180 | u32 cmd_status; |
178 | u32 data_status; | 181 | u32 data_status; |
@@ -480,7 +483,14 @@ err: | |||
480 | static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host, | 483 | static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host, |
481 | unsigned int ns) | 484 | unsigned int ns) |
482 | { | 485 | { |
483 | return (ns * (host->bus_hz / 1000000) + 999) / 1000; | 486 | /* |
487 | * It is easier here to use us instead of ns for the timeout, | ||
488 | * it prevents from overflows during calculation. | ||
489 | */ | ||
490 | unsigned int us = DIV_ROUND_UP(ns, 1000); | ||
491 | |||
492 | /* Maximum clock frequency is host->bus_hz/2 */ | ||
493 | return us * (DIV_ROUND_UP(host->bus_hz, 2000000)); | ||
484 | } | 494 | } |
485 | 495 | ||
486 | static void atmci_set_timeout(struct atmel_mci *host, | 496 | static void atmci_set_timeout(struct atmel_mci *host, |
@@ -863,16 +873,17 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) | |||
863 | 873 | ||
864 | if (data->flags & MMC_DATA_READ) { | 874 | if (data->flags & MMC_DATA_READ) { |
865 | direction = DMA_FROM_DEVICE; | 875 | direction = DMA_FROM_DEVICE; |
866 | slave_dirn = DMA_DEV_TO_MEM; | 876 | host->dma_conf.direction = slave_dirn = DMA_DEV_TO_MEM; |
867 | } else { | 877 | } else { |
868 | direction = DMA_TO_DEVICE; | 878 | direction = DMA_TO_DEVICE; |
869 | slave_dirn = DMA_MEM_TO_DEV; | 879 | host->dma_conf.direction = slave_dirn = DMA_MEM_TO_DEV; |
870 | } | 880 | } |
871 | 881 | ||
872 | sglen = dma_map_sg(chan->device->dev, data->sg, | 882 | sglen = dma_map_sg(chan->device->dev, data->sg, |
873 | data->sg_len, direction); | 883 | data->sg_len, direction); |
874 | 884 | ||
875 | desc = chan->device->device_prep_slave_sg(chan, | 885 | dmaengine_slave_config(chan, &host->dma_conf); |
886 | desc = dmaengine_prep_slave_sg(chan, | ||
876 | data->sg, sglen, slave_dirn, | 887 | data->sg, sglen, slave_dirn, |
877 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | 888 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
878 | if (!desc) | 889 | if (!desc) |
@@ -1124,16 +1135,27 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
1124 | } | 1135 | } |
1125 | 1136 | ||
1126 | /* Calculate clock divider */ | 1137 | /* Calculate clock divider */ |
1127 | clkdiv = DIV_ROUND_UP(host->bus_hz, 2 * clock_min) - 1; | 1138 | if (host->caps.has_odd_clk_div) { |
1128 | if (clkdiv > 255) { | 1139 | clkdiv = DIV_ROUND_UP(host->bus_hz, clock_min) - 2; |
1129 | dev_warn(&mmc->class_dev, | 1140 | if (clkdiv > 511) { |
1130 | "clock %u too slow; using %lu\n", | 1141 | dev_warn(&mmc->class_dev, |
1131 | clock_min, host->bus_hz / (2 * 256)); | 1142 | "clock %u too slow; using %lu\n", |
1132 | clkdiv = 255; | 1143 | clock_min, host->bus_hz / (511 + 2)); |
1144 | clkdiv = 511; | ||
1145 | } | ||
1146 | host->mode_reg = ATMCI_MR_CLKDIV(clkdiv >> 1) | ||
1147 | | ATMCI_MR_CLKODD(clkdiv & 1); | ||
1148 | } else { | ||
1149 | clkdiv = DIV_ROUND_UP(host->bus_hz, 2 * clock_min) - 1; | ||
1150 | if (clkdiv > 255) { | ||
1151 | dev_warn(&mmc->class_dev, | ||
1152 | "clock %u too slow; using %lu\n", | ||
1153 | clock_min, host->bus_hz / (2 * 256)); | ||
1154 | clkdiv = 255; | ||
1155 | } | ||
1156 | host->mode_reg = ATMCI_MR_CLKDIV(clkdiv); | ||
1133 | } | 1157 | } |
1134 | 1158 | ||
1135 | host->mode_reg = ATMCI_MR_CLKDIV(clkdiv); | ||
1136 | |||
1137 | /* | 1159 | /* |
1138 | * WRPROOF and RDPROOF prevent overruns/underruns by | 1160 | * WRPROOF and RDPROOF prevent overruns/underruns by |
1139 | * stopping the clock when the FIFO is full/empty. | 1161 | * stopping the clock when the FIFO is full/empty. |
@@ -1948,34 +1970,41 @@ static bool atmci_filter(struct dma_chan *chan, void *slave) | |||
1948 | } | 1970 | } |
1949 | } | 1971 | } |
1950 | 1972 | ||
1951 | static void atmci_configure_dma(struct atmel_mci *host) | 1973 | static bool atmci_configure_dma(struct atmel_mci *host) |
1952 | { | 1974 | { |
1953 | struct mci_platform_data *pdata; | 1975 | struct mci_platform_data *pdata; |
1954 | 1976 | ||
1955 | if (host == NULL) | 1977 | if (host == NULL) |
1956 | return; | 1978 | return false; |
1957 | 1979 | ||
1958 | pdata = host->pdev->dev.platform_data; | 1980 | pdata = host->pdev->dev.platform_data; |
1959 | 1981 | ||
1960 | if (pdata && find_slave_dev(pdata->dma_slave)) { | 1982 | if (pdata && find_slave_dev(pdata->dma_slave)) { |
1961 | dma_cap_mask_t mask; | 1983 | dma_cap_mask_t mask; |
1962 | 1984 | ||
1963 | setup_dma_addr(pdata->dma_slave, | ||
1964 | host->mapbase + ATMCI_TDR, | ||
1965 | host->mapbase + ATMCI_RDR); | ||
1966 | |||
1967 | /* Try to grab a DMA channel */ | 1985 | /* Try to grab a DMA channel */ |
1968 | dma_cap_zero(mask); | 1986 | dma_cap_zero(mask); |
1969 | dma_cap_set(DMA_SLAVE, mask); | 1987 | dma_cap_set(DMA_SLAVE, mask); |
1970 | host->dma.chan = | 1988 | host->dma.chan = |
1971 | dma_request_channel(mask, atmci_filter, pdata->dma_slave); | 1989 | dma_request_channel(mask, atmci_filter, pdata->dma_slave); |
1972 | } | 1990 | } |
1973 | if (!host->dma.chan) | 1991 | if (!host->dma.chan) { |
1974 | dev_notice(&host->pdev->dev, "DMA not available, using PIO\n"); | 1992 | dev_warn(&host->pdev->dev, "no DMA channel available\n"); |
1975 | else | 1993 | return false; |
1994 | } else { | ||
1976 | dev_info(&host->pdev->dev, | 1995 | dev_info(&host->pdev->dev, |
1977 | "Using %s for DMA transfers\n", | 1996 | "using %s for DMA transfers\n", |
1978 | dma_chan_name(host->dma.chan)); | 1997 | dma_chan_name(host->dma.chan)); |
1998 | |||
1999 | host->dma_conf.src_addr = host->mapbase + ATMCI_RDR; | ||
2000 | host->dma_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
2001 | host->dma_conf.src_maxburst = 1; | ||
2002 | host->dma_conf.dst_addr = host->mapbase + ATMCI_TDR; | ||
2003 | host->dma_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
2004 | host->dma_conf.dst_maxburst = 1; | ||
2005 | host->dma_conf.device_fc = false; | ||
2006 | return true; | ||
2007 | } | ||
1979 | } | 2008 | } |
1980 | 2009 | ||
1981 | static inline unsigned int atmci_get_version(struct atmel_mci *host) | 2010 | static inline unsigned int atmci_get_version(struct atmel_mci *host) |
@@ -1997,35 +2026,35 @@ static void __init atmci_get_cap(struct atmel_mci *host) | |||
1997 | "version: 0x%x\n", version); | 2026 | "version: 0x%x\n", version); |
1998 | 2027 | ||
1999 | host->caps.has_dma = 0; | 2028 | host->caps.has_dma = 0; |
2000 | host->caps.has_pdc = 0; | 2029 | host->caps.has_pdc = 1; |
2001 | host->caps.has_cfg_reg = 0; | 2030 | host->caps.has_cfg_reg = 0; |
2002 | host->caps.has_cstor_reg = 0; | 2031 | host->caps.has_cstor_reg = 0; |
2003 | host->caps.has_highspeed = 0; | 2032 | host->caps.has_highspeed = 0; |
2004 | host->caps.has_rwproof = 0; | 2033 | host->caps.has_rwproof = 0; |
2034 | host->caps.has_odd_clk_div = 0; | ||
2005 | 2035 | ||
2006 | /* keep only major version number */ | 2036 | /* keep only major version number */ |
2007 | switch (version & 0xf00) { | 2037 | switch (version & 0xf00) { |
2008 | case 0x100: | ||
2009 | case 0x200: | ||
2010 | host->caps.has_pdc = 1; | ||
2011 | host->caps.has_rwproof = 1; | ||
2012 | break; | ||
2013 | case 0x300: | ||
2014 | case 0x400: | ||
2015 | case 0x500: | 2038 | case 0x500: |
2039 | host->caps.has_odd_clk_div = 1; | ||
2040 | case 0x400: | ||
2041 | case 0x300: | ||
2016 | #ifdef CONFIG_AT_HDMAC | 2042 | #ifdef CONFIG_AT_HDMAC |
2017 | host->caps.has_dma = 1; | 2043 | host->caps.has_dma = 1; |
2018 | #else | 2044 | #else |
2019 | host->caps.has_dma = 0; | ||
2020 | dev_info(&host->pdev->dev, | 2045 | dev_info(&host->pdev->dev, |
2021 | "has dma capability but dma engine is not selected, then use pio\n"); | 2046 | "has dma capability but dma engine is not selected, then use pio\n"); |
2022 | #endif | 2047 | #endif |
2048 | host->caps.has_pdc = 0; | ||
2023 | host->caps.has_cfg_reg = 1; | 2049 | host->caps.has_cfg_reg = 1; |
2024 | host->caps.has_cstor_reg = 1; | 2050 | host->caps.has_cstor_reg = 1; |
2025 | host->caps.has_highspeed = 1; | 2051 | host->caps.has_highspeed = 1; |
2052 | case 0x200: | ||
2026 | host->caps.has_rwproof = 1; | 2053 | host->caps.has_rwproof = 1; |
2054 | case 0x100: | ||
2027 | break; | 2055 | break; |
2028 | default: | 2056 | default: |
2057 | host->caps.has_pdc = 0; | ||
2029 | dev_warn(&host->pdev->dev, | 2058 | dev_warn(&host->pdev->dev, |
2030 | "Unmanaged mci version, set minimum capabilities\n"); | 2059 | "Unmanaged mci version, set minimum capabilities\n"); |
2031 | break; | 2060 | break; |
@@ -2085,8 +2114,7 @@ static int __init atmci_probe(struct platform_device *pdev) | |||
2085 | 2114 | ||
2086 | /* Get MCI capabilities and set operations according to it */ | 2115 | /* Get MCI capabilities and set operations according to it */ |
2087 | atmci_get_cap(host); | 2116 | atmci_get_cap(host); |
2088 | if (host->caps.has_dma) { | 2117 | if (host->caps.has_dma && atmci_configure_dma(host)) { |
2089 | dev_info(&pdev->dev, "using DMA\n"); | ||
2090 | host->prepare_data = &atmci_prepare_data_dma; | 2118 | host->prepare_data = &atmci_prepare_data_dma; |
2091 | host->submit_data = &atmci_submit_data_dma; | 2119 | host->submit_data = &atmci_submit_data_dma; |
2092 | host->stop_transfer = &atmci_stop_transfer_dma; | 2120 | host->stop_transfer = &atmci_stop_transfer_dma; |
@@ -2096,15 +2124,12 @@ static int __init atmci_probe(struct platform_device *pdev) | |||
2096 | host->submit_data = &atmci_submit_data_pdc; | 2124 | host->submit_data = &atmci_submit_data_pdc; |
2097 | host->stop_transfer = &atmci_stop_transfer_pdc; | 2125 | host->stop_transfer = &atmci_stop_transfer_pdc; |
2098 | } else { | 2126 | } else { |
2099 | dev_info(&pdev->dev, "no DMA, no PDC\n"); | 2127 | dev_info(&pdev->dev, "using PIO\n"); |
2100 | host->prepare_data = &atmci_prepare_data; | 2128 | host->prepare_data = &atmci_prepare_data; |
2101 | host->submit_data = &atmci_submit_data; | 2129 | host->submit_data = &atmci_submit_data; |
2102 | host->stop_transfer = &atmci_stop_transfer; | 2130 | host->stop_transfer = &atmci_stop_transfer; |
2103 | } | 2131 | } |
2104 | 2132 | ||
2105 | if (host->caps.has_dma) | ||
2106 | atmci_configure_dma(host); | ||
2107 | |||
2108 | platform_set_drvdata(pdev, host); | 2133 | platform_set_drvdata(pdev, host); |
2109 | 2134 | ||
2110 | /* We need at least one slot to succeed */ | 2135 | /* We need at least one slot to succeed */ |
diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c index 64a8325a4a8a..c1f3673ae1ef 100644 --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c | |||
@@ -160,6 +160,16 @@ module_param(rw_threshold, uint, S_IRUGO); | |||
160 | MODULE_PARM_DESC(rw_threshold, | 160 | MODULE_PARM_DESC(rw_threshold, |
161 | "Read/Write threshold. Default = 32"); | 161 | "Read/Write threshold. Default = 32"); |
162 | 162 | ||
163 | static unsigned poll_threshold = 128; | ||
164 | module_param(poll_threshold, uint, S_IRUGO); | ||
165 | MODULE_PARM_DESC(poll_threshold, | ||
166 | "Polling transaction size threshold. Default = 128"); | ||
167 | |||
168 | static unsigned poll_loopcount = 32; | ||
169 | module_param(poll_loopcount, uint, S_IRUGO); | ||
170 | MODULE_PARM_DESC(poll_loopcount, | ||
171 | "Maximum polling loop count. Default = 32"); | ||
172 | |||
163 | static unsigned __initdata use_dma = 1; | 173 | static unsigned __initdata use_dma = 1; |
164 | module_param(use_dma, uint, 0); | 174 | module_param(use_dma, uint, 0); |
165 | MODULE_PARM_DESC(use_dma, "Whether to use DMA or not. Default = 1"); | 175 | MODULE_PARM_DESC(use_dma, "Whether to use DMA or not. Default = 1"); |
@@ -193,6 +203,7 @@ struct mmc_davinci_host { | |||
193 | bool use_dma; | 203 | bool use_dma; |
194 | bool do_dma; | 204 | bool do_dma; |
195 | bool sdio_int; | 205 | bool sdio_int; |
206 | bool active_request; | ||
196 | 207 | ||
197 | /* Scatterlist DMA uses one or more parameter RAM entries: | 208 | /* Scatterlist DMA uses one or more parameter RAM entries: |
198 | * the main one (associated with rxdma or txdma) plus zero or | 209 | * the main one (associated with rxdma or txdma) plus zero or |
@@ -219,6 +230,7 @@ struct mmc_davinci_host { | |||
219 | #endif | 230 | #endif |
220 | }; | 231 | }; |
221 | 232 | ||
233 | static irqreturn_t mmc_davinci_irq(int irq, void *dev_id); | ||
222 | 234 | ||
223 | /* PIO only */ | 235 | /* PIO only */ |
224 | static void mmc_davinci_sg_to_buf(struct mmc_davinci_host *host) | 236 | static void mmc_davinci_sg_to_buf(struct mmc_davinci_host *host) |
@@ -376,7 +388,20 @@ static void mmc_davinci_start_command(struct mmc_davinci_host *host, | |||
376 | 388 | ||
377 | writel(cmd->arg, host->base + DAVINCI_MMCARGHL); | 389 | writel(cmd->arg, host->base + DAVINCI_MMCARGHL); |
378 | writel(cmd_reg, host->base + DAVINCI_MMCCMD); | 390 | writel(cmd_reg, host->base + DAVINCI_MMCCMD); |
379 | writel(im_val, host->base + DAVINCI_MMCIM); | 391 | |
392 | host->active_request = true; | ||
393 | |||
394 | if (!host->do_dma && host->bytes_left <= poll_threshold) { | ||
395 | u32 count = poll_loopcount; | ||
396 | |||
397 | while (host->active_request && count--) { | ||
398 | mmc_davinci_irq(0, host); | ||
399 | cpu_relax(); | ||
400 | } | ||
401 | } | ||
402 | |||
403 | if (host->active_request) | ||
404 | writel(im_val, host->base + DAVINCI_MMCIM); | ||
380 | } | 405 | } |
381 | 406 | ||
382 | /*----------------------------------------------------------------------*/ | 407 | /*----------------------------------------------------------------------*/ |
@@ -915,6 +940,7 @@ mmc_davinci_xfer_done(struct mmc_davinci_host *host, struct mmc_data *data) | |||
915 | if (!data->stop || (host->cmd && host->cmd->error)) { | 940 | if (!data->stop || (host->cmd && host->cmd->error)) { |
916 | mmc_request_done(host->mmc, data->mrq); | 941 | mmc_request_done(host->mmc, data->mrq); |
917 | writel(0, host->base + DAVINCI_MMCIM); | 942 | writel(0, host->base + DAVINCI_MMCIM); |
943 | host->active_request = false; | ||
918 | } else | 944 | } else |
919 | mmc_davinci_start_command(host, data->stop); | 945 | mmc_davinci_start_command(host, data->stop); |
920 | } | 946 | } |
@@ -942,6 +968,7 @@ static void mmc_davinci_cmd_done(struct mmc_davinci_host *host, | |||
942 | cmd->mrq->cmd->retries = 0; | 968 | cmd->mrq->cmd->retries = 0; |
943 | mmc_request_done(host->mmc, cmd->mrq); | 969 | mmc_request_done(host->mmc, cmd->mrq); |
944 | writel(0, host->base + DAVINCI_MMCIM); | 970 | writel(0, host->base + DAVINCI_MMCIM); |
971 | host->active_request = false; | ||
945 | } | 972 | } |
946 | } | 973 | } |
947 | 974 | ||
@@ -1009,12 +1036,33 @@ static irqreturn_t mmc_davinci_irq(int irq, void *dev_id) | |||
1009 | * by read. So, it is not unbouned loop even in the case of | 1036 | * by read. So, it is not unbouned loop even in the case of |
1010 | * non-dma. | 1037 | * non-dma. |
1011 | */ | 1038 | */ |
1012 | while (host->bytes_left && (status & (MMCST0_DXRDY | MMCST0_DRRDY))) { | 1039 | if (host->bytes_left && (status & (MMCST0_DXRDY | MMCST0_DRRDY))) { |
1013 | davinci_fifo_data_trans(host, rw_threshold); | 1040 | unsigned long im_val; |
1014 | status = readl(host->base + DAVINCI_MMCST0); | 1041 | |
1015 | if (!status) | 1042 | /* |
1016 | break; | 1043 | * If interrupts fire during the following loop, they will be |
1017 | qstatus |= status; | 1044 | * handled by the handler, but the PIC will still buffer these. |
1045 | * As a result, the handler will be called again to serve these | ||
1046 | * needlessly. In order to avoid these spurious interrupts, | ||
1047 | * keep interrupts masked during the loop. | ||
1048 | */ | ||
1049 | im_val = readl(host->base + DAVINCI_MMCIM); | ||
1050 | writel(0, host->base + DAVINCI_MMCIM); | ||
1051 | |||
1052 | do { | ||
1053 | davinci_fifo_data_trans(host, rw_threshold); | ||
1054 | status = readl(host->base + DAVINCI_MMCST0); | ||
1055 | qstatus |= status; | ||
1056 | } while (host->bytes_left && | ||
1057 | (status & (MMCST0_DXRDY | MMCST0_DRRDY))); | ||
1058 | |||
1059 | /* | ||
1060 | * If an interrupt is pending, it is assumed it will fire when | ||
1061 | * it is unmasked. This assumption is also taken when the MMCIM | ||
1062 | * is first set. Otherwise, writing to MMCIM after reading the | ||
1063 | * status is race-prone. | ||
1064 | */ | ||
1065 | writel(im_val, host->base + DAVINCI_MMCIM); | ||
1018 | } | 1066 | } |
1019 | 1067 | ||
1020 | if (qstatus & MMCST0_DATDNE) { | 1068 | if (qstatus & MMCST0_DATDNE) { |
@@ -1418,17 +1466,14 @@ static int davinci_mmcsd_suspend(struct device *dev) | |||
1418 | struct mmc_davinci_host *host = platform_get_drvdata(pdev); | 1466 | struct mmc_davinci_host *host = platform_get_drvdata(pdev); |
1419 | int ret; | 1467 | int ret; |
1420 | 1468 | ||
1421 | mmc_host_enable(host->mmc); | ||
1422 | ret = mmc_suspend_host(host->mmc); | 1469 | ret = mmc_suspend_host(host->mmc); |
1423 | if (!ret) { | 1470 | if (!ret) { |
1424 | writel(0, host->base + DAVINCI_MMCIM); | 1471 | writel(0, host->base + DAVINCI_MMCIM); |
1425 | mmc_davinci_reset_ctrl(host, 1); | 1472 | mmc_davinci_reset_ctrl(host, 1); |
1426 | mmc_host_disable(host->mmc); | ||
1427 | clk_disable(host->clk); | 1473 | clk_disable(host->clk); |
1428 | host->suspended = 1; | 1474 | host->suspended = 1; |
1429 | } else { | 1475 | } else { |
1430 | host->suspended = 0; | 1476 | host->suspended = 0; |
1431 | mmc_host_disable(host->mmc); | ||
1432 | } | 1477 | } |
1433 | 1478 | ||
1434 | return ret; | 1479 | return ret; |
@@ -1444,7 +1489,6 @@ static int davinci_mmcsd_resume(struct device *dev) | |||
1444 | return 0; | 1489 | return 0; |
1445 | 1490 | ||
1446 | clk_enable(host->clk); | 1491 | clk_enable(host->clk); |
1447 | mmc_host_enable(host->mmc); | ||
1448 | 1492 | ||
1449 | mmc_davinci_reset_ctrl(host, 0); | 1493 | mmc_davinci_reset_ctrl(host, 0); |
1450 | ret = mmc_resume_host(host->mmc); | 1494 | ret = mmc_resume_host(host->mmc); |
diff --git a/drivers/mmc/host/dw_mmc-pci.c b/drivers/mmc/host/dw_mmc-pci.c new file mode 100644 index 000000000000..dc0d25a013e0 --- /dev/null +++ b/drivers/mmc/host/dw_mmc-pci.c | |||
@@ -0,0 +1,158 @@ | |||
1 | /* | ||
2 | * Synopsys DesignWare Multimedia Card PCI Interface driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Vayavya Labs Pvt. Ltd. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/interrupt.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/io.h> | ||
15 | #include <linux/irq.h> | ||
16 | #include <linux/pci.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/mmc/host.h> | ||
19 | #include <linux/mmc/mmc.h> | ||
20 | #include <linux/mmc/dw_mmc.h> | ||
21 | #include "dw_mmc.h" | ||
22 | |||
23 | #define PCI_BAR_NO 2 | ||
24 | #define COMPLETE_BAR 0 | ||
25 | #define SYNOPSYS_DW_MCI_VENDOR_ID 0x700 | ||
26 | #define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107 | ||
27 | /* Defining the Capabilities */ | ||
28 | #define DW_MCI_CAPABILITIES (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED |\ | ||
29 | MMC_CAP_SD_HIGHSPEED | MMC_CAP_8_BIT_DATA |\ | ||
30 | MMC_CAP_SDIO_IRQ) | ||
31 | |||
32 | static struct dw_mci_board pci_board_data = { | ||
33 | .num_slots = 1, | ||
34 | .caps = DW_MCI_CAPABILITIES, | ||
35 | .bus_hz = 33 * 1000 * 1000, | ||
36 | .detect_delay_ms = 200, | ||
37 | .fifo_depth = 32, | ||
38 | }; | ||
39 | |||
40 | static int __devinit dw_mci_pci_probe(struct pci_dev *pdev, | ||
41 | const struct pci_device_id *entries) | ||
42 | { | ||
43 | struct dw_mci *host; | ||
44 | int ret; | ||
45 | |||
46 | ret = pci_enable_device(pdev); | ||
47 | if (ret) | ||
48 | return ret; | ||
49 | if (pci_request_regions(pdev, "dw_mmc_pci")) { | ||
50 | ret = -ENODEV; | ||
51 | goto err_disable_dev; | ||
52 | } | ||
53 | |||
54 | host = kzalloc(sizeof(struct dw_mci), GFP_KERNEL); | ||
55 | if (!host) { | ||
56 | ret = -ENOMEM; | ||
57 | goto err_release; | ||
58 | } | ||
59 | |||
60 | host->irq = pdev->irq; | ||
61 | host->irq_flags = IRQF_SHARED; | ||
62 | host->dev = pdev->dev; | ||
63 | host->pdata = &pci_board_data; | ||
64 | |||
65 | host->regs = pci_iomap(pdev, PCI_BAR_NO, COMPLETE_BAR); | ||
66 | if (!host->regs) { | ||
67 | ret = -EIO; | ||
68 | goto err_unmap; | ||
69 | } | ||
70 | |||
71 | pci_set_drvdata(pdev, host); | ||
72 | ret = dw_mci_probe(host); | ||
73 | if (ret) | ||
74 | goto err_probe_failed; | ||
75 | return ret; | ||
76 | |||
77 | err_probe_failed: | ||
78 | pci_iounmap(pdev, host->regs); | ||
79 | err_unmap: | ||
80 | kfree(host); | ||
81 | err_release: | ||
82 | pci_release_regions(pdev); | ||
83 | err_disable_dev: | ||
84 | pci_disable_device(pdev); | ||
85 | return ret; | ||
86 | } | ||
87 | |||
88 | static void __devexit dw_mci_pci_remove(struct pci_dev *pdev) | ||
89 | { | ||
90 | struct dw_mci *host = pci_get_drvdata(pdev); | ||
91 | |||
92 | dw_mci_remove(host); | ||
93 | pci_set_drvdata(pdev, NULL); | ||
94 | pci_release_regions(pdev); | ||
95 | pci_iounmap(pdev, host->regs); | ||
96 | kfree(host); | ||
97 | pci_disable_device(pdev); | ||
98 | } | ||
99 | |||
100 | #ifdef CONFIG_PM_SLEEP | ||
101 | static int dw_mci_pci_suspend(struct device *dev) | ||
102 | { | ||
103 | int ret; | ||
104 | struct pci_dev *pdev = to_pci_dev(dev); | ||
105 | struct dw_mci *host = pci_get_drvdata(pdev); | ||
106 | |||
107 | ret = dw_mci_suspend(host); | ||
108 | return ret; | ||
109 | } | ||
110 | |||
111 | static int dw_mci_pci_resume(struct device *dev) | ||
112 | { | ||
113 | int ret; | ||
114 | struct pci_dev *pdev = to_pci_dev(dev); | ||
115 | struct dw_mci *host = pci_get_drvdata(pdev); | ||
116 | |||
117 | ret = dw_mci_resume(host); | ||
118 | return ret; | ||
119 | } | ||
120 | #else | ||
121 | #define dw_mci_pci_suspend NULL | ||
122 | #define dw_mci_pci_resume NULL | ||
123 | #endif /* CONFIG_PM_SLEEP */ | ||
124 | |||
125 | static SIMPLE_DEV_PM_OPS(dw_mci_pci_pmops, dw_mci_pci_suspend, dw_mci_pci_resume); | ||
126 | |||
127 | static DEFINE_PCI_DEVICE_TABLE(dw_mci_pci_id) = { | ||
128 | { PCI_DEVICE(SYNOPSYS_DW_MCI_VENDOR_ID, SYNOPSYS_DW_MCI_DEVICE_ID) }, | ||
129 | {} | ||
130 | }; | ||
131 | MODULE_DEVICE_TABLE(pci, dw_mci_pci_id); | ||
132 | |||
133 | static struct pci_driver dw_mci_pci_driver = { | ||
134 | .name = "dw_mmc_pci", | ||
135 | .id_table = dw_mci_pci_id, | ||
136 | .probe = dw_mci_pci_probe, | ||
137 | .remove = dw_mci_pci_remove, | ||
138 | .driver = { | ||
139 | .pm = &dw_mci_pci_pmops | ||
140 | }, | ||
141 | }; | ||
142 | |||
143 | static int __init dw_mci_init(void) | ||
144 | { | ||
145 | return pci_register_driver(&dw_mci_pci_driver); | ||
146 | } | ||
147 | |||
148 | static void __exit dw_mci_exit(void) | ||
149 | { | ||
150 | pci_unregister_driver(&dw_mci_pci_driver); | ||
151 | } | ||
152 | |||
153 | module_init(dw_mci_init); | ||
154 | module_exit(dw_mci_exit); | ||
155 | |||
156 | MODULE_DESCRIPTION("DW Multimedia Card PCI Interface driver"); | ||
157 | MODULE_AUTHOR("Shashidhar Hiremath <shashidharh@vayavyalabs.com>"); | ||
158 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c new file mode 100644 index 000000000000..92ec3eb3aae7 --- /dev/null +++ b/drivers/mmc/host/dw_mmc-pltfm.c | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | * Synopsys DesignWare Multimedia Card Interface driver | ||
3 | * | ||
4 | * Copyright (C) 2009 NXP Semiconductors | ||
5 | * Copyright (C) 2009, 2010 Imagination Technologies Ltd. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/interrupt.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/irq.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <linux/mmc/host.h> | ||
20 | #include <linux/mmc/mmc.h> | ||
21 | #include <linux/mmc/dw_mmc.h> | ||
22 | #include "dw_mmc.h" | ||
23 | |||
24 | static int dw_mci_pltfm_probe(struct platform_device *pdev) | ||
25 | { | ||
26 | struct dw_mci *host; | ||
27 | struct resource *regs; | ||
28 | int ret; | ||
29 | |||
30 | host = kzalloc(sizeof(struct dw_mci), GFP_KERNEL); | ||
31 | if (!host) | ||
32 | return -ENOMEM; | ||
33 | |||
34 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
35 | if (!regs) { | ||
36 | ret = -ENXIO; | ||
37 | goto err_free; | ||
38 | } | ||
39 | |||
40 | host->irq = platform_get_irq(pdev, 0); | ||
41 | if (host->irq < 0) { | ||
42 | ret = host->irq; | ||
43 | goto err_free; | ||
44 | } | ||
45 | |||
46 | host->dev = pdev->dev; | ||
47 | host->irq_flags = 0; | ||
48 | host->pdata = pdev->dev.platform_data; | ||
49 | ret = -ENOMEM; | ||
50 | host->regs = ioremap(regs->start, resource_size(regs)); | ||
51 | if (!host->regs) | ||
52 | goto err_free; | ||
53 | platform_set_drvdata(pdev, host); | ||
54 | ret = dw_mci_probe(host); | ||
55 | if (ret) | ||
56 | goto err_out; | ||
57 | return ret; | ||
58 | err_out: | ||
59 | iounmap(host->regs); | ||
60 | err_free: | ||
61 | kfree(host); | ||
62 | return ret; | ||
63 | } | ||
64 | |||
65 | static int __exit dw_mci_pltfm_remove(struct platform_device *pdev) | ||
66 | { | ||
67 | struct dw_mci *host = platform_get_drvdata(pdev); | ||
68 | |||
69 | platform_set_drvdata(pdev, NULL); | ||
70 | dw_mci_remove(host); | ||
71 | iounmap(host->regs); | ||
72 | kfree(host); | ||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | #ifdef CONFIG_PM_SLEEP | ||
77 | /* | ||
78 | * TODO: we should probably disable the clock to the card in the suspend path. | ||
79 | */ | ||
80 | static int dw_mci_pltfm_suspend(struct device *dev) | ||
81 | { | ||
82 | int ret; | ||
83 | struct dw_mci *host = dev_get_drvdata(dev); | ||
84 | |||
85 | ret = dw_mci_suspend(host); | ||
86 | if (ret) | ||
87 | return ret; | ||
88 | |||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | static int dw_mci_pltfm_resume(struct device *dev) | ||
93 | { | ||
94 | int ret; | ||
95 | struct dw_mci *host = dev_get_drvdata(dev); | ||
96 | |||
97 | ret = dw_mci_resume(host); | ||
98 | if (ret) | ||
99 | return ret; | ||
100 | |||
101 | return 0; | ||
102 | } | ||
103 | #else | ||
104 | #define dw_mci_pltfm_suspend NULL | ||
105 | #define dw_mci_pltfm_resume NULL | ||
106 | #endif /* CONFIG_PM_SLEEP */ | ||
107 | |||
108 | static SIMPLE_DEV_PM_OPS(dw_mci_pltfm_pmops, dw_mci_pltfm_suspend, dw_mci_pltfm_resume); | ||
109 | |||
110 | static struct platform_driver dw_mci_pltfm_driver = { | ||
111 | .remove = __exit_p(dw_mci_pltfm_remove), | ||
112 | .driver = { | ||
113 | .name = "dw_mmc", | ||
114 | .pm = &dw_mci_pltfm_pmops, | ||
115 | }, | ||
116 | }; | ||
117 | |||
118 | static int __init dw_mci_init(void) | ||
119 | { | ||
120 | return platform_driver_probe(&dw_mci_pltfm_driver, dw_mci_pltfm_probe); | ||
121 | } | ||
122 | |||
123 | static void __exit dw_mci_exit(void) | ||
124 | { | ||
125 | platform_driver_unregister(&dw_mci_pltfm_driver); | ||
126 | } | ||
127 | |||
128 | module_init(dw_mci_init); | ||
129 | module_exit(dw_mci_exit); | ||
130 | |||
131 | MODULE_DESCRIPTION("DW Multimedia Card Interface driver"); | ||
132 | MODULE_AUTHOR("NXP Semiconductor VietNam"); | ||
133 | MODULE_AUTHOR("Imagination Technologies Ltd"); | ||
134 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 8bec1c36b159..ab3fc4617107 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c | |||
@@ -268,7 +268,7 @@ static void dw_mci_start_command(struct dw_mci *host, | |||
268 | struct mmc_command *cmd, u32 cmd_flags) | 268 | struct mmc_command *cmd, u32 cmd_flags) |
269 | { | 269 | { |
270 | host->cmd = cmd; | 270 | host->cmd = cmd; |
271 | dev_vdbg(&host->pdev->dev, | 271 | dev_vdbg(&host->dev, |
272 | "start command: ARGR=0x%08x CMDR=0x%08x\n", | 272 | "start command: ARGR=0x%08x CMDR=0x%08x\n", |
273 | cmd->arg, cmd_flags); | 273 | cmd->arg, cmd_flags); |
274 | 274 | ||
@@ -295,15 +295,25 @@ static void dw_mci_stop_dma(struct dw_mci *host) | |||
295 | } | 295 | } |
296 | } | 296 | } |
297 | 297 | ||
298 | static int dw_mci_get_dma_dir(struct mmc_data *data) | ||
299 | { | ||
300 | if (data->flags & MMC_DATA_WRITE) | ||
301 | return DMA_TO_DEVICE; | ||
302 | else | ||
303 | return DMA_FROM_DEVICE; | ||
304 | } | ||
305 | |||
298 | #ifdef CONFIG_MMC_DW_IDMAC | 306 | #ifdef CONFIG_MMC_DW_IDMAC |
299 | static void dw_mci_dma_cleanup(struct dw_mci *host) | 307 | static void dw_mci_dma_cleanup(struct dw_mci *host) |
300 | { | 308 | { |
301 | struct mmc_data *data = host->data; | 309 | struct mmc_data *data = host->data; |
302 | 310 | ||
303 | if (data) | 311 | if (data) |
304 | dma_unmap_sg(&host->pdev->dev, data->sg, data->sg_len, | 312 | if (!data->host_cookie) |
305 | ((data->flags & MMC_DATA_WRITE) | 313 | dma_unmap_sg(&host->dev, |
306 | ? DMA_TO_DEVICE : DMA_FROM_DEVICE)); | 314 | data->sg, |
315 | data->sg_len, | ||
316 | dw_mci_get_dma_dir(data)); | ||
307 | } | 317 | } |
308 | 318 | ||
309 | static void dw_mci_idmac_stop_dma(struct dw_mci *host) | 319 | static void dw_mci_idmac_stop_dma(struct dw_mci *host) |
@@ -326,7 +336,7 @@ static void dw_mci_idmac_complete_dma(struct dw_mci *host) | |||
326 | { | 336 | { |
327 | struct mmc_data *data = host->data; | 337 | struct mmc_data *data = host->data; |
328 | 338 | ||
329 | dev_vdbg(&host->pdev->dev, "DMA complete\n"); | 339 | dev_vdbg(&host->dev, "DMA complete\n"); |
330 | 340 | ||
331 | host->dma_ops->cleanup(host); | 341 | host->dma_ops->cleanup(host); |
332 | 342 | ||
@@ -428,17 +438,15 @@ static struct dw_mci_dma_ops dw_mci_idmac_ops = { | |||
428 | }; | 438 | }; |
429 | #endif /* CONFIG_MMC_DW_IDMAC */ | 439 | #endif /* CONFIG_MMC_DW_IDMAC */ |
430 | 440 | ||
431 | static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) | 441 | static int dw_mci_pre_dma_transfer(struct dw_mci *host, |
442 | struct mmc_data *data, | ||
443 | bool next) | ||
432 | { | 444 | { |
433 | struct scatterlist *sg; | 445 | struct scatterlist *sg; |
434 | unsigned int i, direction, sg_len; | 446 | unsigned int i, sg_len; |
435 | u32 temp; | ||
436 | 447 | ||
437 | host->using_dma = 0; | 448 | if (!next && data->host_cookie) |
438 | 449 | return data->host_cookie; | |
439 | /* If we don't have a channel, we can't do DMA */ | ||
440 | if (!host->use_dma) | ||
441 | return -ENODEV; | ||
442 | 450 | ||
443 | /* | 451 | /* |
444 | * We don't do DMA on "complex" transfers, i.e. with | 452 | * We don't do DMA on "complex" transfers, i.e. with |
@@ -447,6 +455,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) | |||
447 | */ | 455 | */ |
448 | if (data->blocks * data->blksz < DW_MCI_DMA_THRESHOLD) | 456 | if (data->blocks * data->blksz < DW_MCI_DMA_THRESHOLD) |
449 | return -EINVAL; | 457 | return -EINVAL; |
458 | |||
450 | if (data->blksz & 3) | 459 | if (data->blksz & 3) |
451 | return -EINVAL; | 460 | return -EINVAL; |
452 | 461 | ||
@@ -455,17 +464,76 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) | |||
455 | return -EINVAL; | 464 | return -EINVAL; |
456 | } | 465 | } |
457 | 466 | ||
458 | host->using_dma = 1; | 467 | sg_len = dma_map_sg(&host->dev, |
468 | data->sg, | ||
469 | data->sg_len, | ||
470 | dw_mci_get_dma_dir(data)); | ||
471 | if (sg_len == 0) | ||
472 | return -EINVAL; | ||
459 | 473 | ||
460 | if (data->flags & MMC_DATA_READ) | 474 | if (next) |
461 | direction = DMA_FROM_DEVICE; | 475 | data->host_cookie = sg_len; |
462 | else | 476 | |
463 | direction = DMA_TO_DEVICE; | 477 | return sg_len; |
478 | } | ||
479 | |||
480 | static void dw_mci_pre_req(struct mmc_host *mmc, | ||
481 | struct mmc_request *mrq, | ||
482 | bool is_first_req) | ||
483 | { | ||
484 | struct dw_mci_slot *slot = mmc_priv(mmc); | ||
485 | struct mmc_data *data = mrq->data; | ||
464 | 486 | ||
465 | sg_len = dma_map_sg(&host->pdev->dev, data->sg, data->sg_len, | 487 | if (!slot->host->use_dma || !data) |
466 | direction); | 488 | return; |
489 | |||
490 | if (data->host_cookie) { | ||
491 | data->host_cookie = 0; | ||
492 | return; | ||
493 | } | ||
494 | |||
495 | if (dw_mci_pre_dma_transfer(slot->host, mrq->data, 1) < 0) | ||
496 | data->host_cookie = 0; | ||
497 | } | ||
498 | |||
499 | static void dw_mci_post_req(struct mmc_host *mmc, | ||
500 | struct mmc_request *mrq, | ||
501 | int err) | ||
502 | { | ||
503 | struct dw_mci_slot *slot = mmc_priv(mmc); | ||
504 | struct mmc_data *data = mrq->data; | ||
505 | |||
506 | if (!slot->host->use_dma || !data) | ||
507 | return; | ||
467 | 508 | ||
468 | dev_vdbg(&host->pdev->dev, | 509 | if (data->host_cookie) |
510 | dma_unmap_sg(&slot->host->dev, | ||
511 | data->sg, | ||
512 | data->sg_len, | ||
513 | dw_mci_get_dma_dir(data)); | ||
514 | data->host_cookie = 0; | ||
515 | } | ||
516 | |||
517 | static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) | ||
518 | { | ||
519 | int sg_len; | ||
520 | u32 temp; | ||
521 | |||
522 | host->using_dma = 0; | ||
523 | |||
524 | /* If we don't have a channel, we can't do DMA */ | ||
525 | if (!host->use_dma) | ||
526 | return -ENODEV; | ||
527 | |||
528 | sg_len = dw_mci_pre_dma_transfer(host, data, 0); | ||
529 | if (sg_len < 0) { | ||
530 | host->dma_ops->stop(host); | ||
531 | return sg_len; | ||
532 | } | ||
533 | |||
534 | host->using_dma = 1; | ||
535 | |||
536 | dev_vdbg(&host->dev, | ||
469 | "sd sg_cpu: %#lx sg_dma: %#lx sg_len: %d\n", | 537 | "sd sg_cpu: %#lx sg_dma: %#lx sg_len: %d\n", |
470 | (unsigned long)host->sg_cpu, (unsigned long)host->sg_dma, | 538 | (unsigned long)host->sg_cpu, (unsigned long)host->sg_dma, |
471 | sg_len); | 539 | sg_len); |
@@ -579,8 +647,8 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot) | |||
579 | SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); | 647 | SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); |
580 | 648 | ||
581 | /* enable clock */ | 649 | /* enable clock */ |
582 | mci_writel(host, CLKENA, SDMMC_CLKEN_ENABLE | | 650 | mci_writel(host, CLKENA, ((SDMMC_CLKEN_ENABLE | |
583 | SDMMC_CLKEN_LOW_PWR); | 651 | SDMMC_CLKEN_LOW_PWR) << slot->id)); |
584 | 652 | ||
585 | /* inform CIU */ | 653 | /* inform CIU */ |
586 | mci_send_cmd(slot, | 654 | mci_send_cmd(slot, |
@@ -800,6 +868,8 @@ static void dw_mci_enable_sdio_irq(struct mmc_host *mmc, int enb) | |||
800 | 868 | ||
801 | static const struct mmc_host_ops dw_mci_ops = { | 869 | static const struct mmc_host_ops dw_mci_ops = { |
802 | .request = dw_mci_request, | 870 | .request = dw_mci_request, |
871 | .pre_req = dw_mci_pre_req, | ||
872 | .post_req = dw_mci_post_req, | ||
803 | .set_ios = dw_mci_set_ios, | 873 | .set_ios = dw_mci_set_ios, |
804 | .get_ro = dw_mci_get_ro, | 874 | .get_ro = dw_mci_get_ro, |
805 | .get_cd = dw_mci_get_cd, | 875 | .get_cd = dw_mci_get_cd, |
@@ -821,12 +891,12 @@ static void dw_mci_request_end(struct dw_mci *host, struct mmc_request *mrq) | |||
821 | slot = list_entry(host->queue.next, | 891 | slot = list_entry(host->queue.next, |
822 | struct dw_mci_slot, queue_node); | 892 | struct dw_mci_slot, queue_node); |
823 | list_del(&slot->queue_node); | 893 | list_del(&slot->queue_node); |
824 | dev_vdbg(&host->pdev->dev, "list not empty: %s is next\n", | 894 | dev_vdbg(&host->dev, "list not empty: %s is next\n", |
825 | mmc_hostname(slot->mmc)); | 895 | mmc_hostname(slot->mmc)); |
826 | host->state = STATE_SENDING_CMD; | 896 | host->state = STATE_SENDING_CMD; |
827 | dw_mci_start_request(host, slot); | 897 | dw_mci_start_request(host, slot); |
828 | } else { | 898 | } else { |
829 | dev_vdbg(&host->pdev->dev, "list empty\n"); | 899 | dev_vdbg(&host->dev, "list empty\n"); |
830 | host->state = STATE_IDLE; | 900 | host->state = STATE_IDLE; |
831 | } | 901 | } |
832 | 902 | ||
@@ -965,7 +1035,7 @@ static void dw_mci_tasklet_func(unsigned long priv) | |||
965 | data->bytes_xfered = 0; | 1035 | data->bytes_xfered = 0; |
966 | data->error = -ETIMEDOUT; | 1036 | data->error = -ETIMEDOUT; |
967 | } else { | 1037 | } else { |
968 | dev_err(&host->pdev->dev, | 1038 | dev_err(&host->dev, |
969 | "data FIFO error " | 1039 | "data FIFO error " |
970 | "(status=%08x)\n", | 1040 | "(status=%08x)\n", |
971 | status); | 1041 | status); |
@@ -1682,7 +1752,7 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) | |||
1682 | struct mmc_host *mmc; | 1752 | struct mmc_host *mmc; |
1683 | struct dw_mci_slot *slot; | 1753 | struct dw_mci_slot *slot; |
1684 | 1754 | ||
1685 | mmc = mmc_alloc_host(sizeof(struct dw_mci_slot), &host->pdev->dev); | 1755 | mmc = mmc_alloc_host(sizeof(struct dw_mci_slot), &host->dev); |
1686 | if (!mmc) | 1756 | if (!mmc) |
1687 | return -ENOMEM; | 1757 | return -ENOMEM; |
1688 | 1758 | ||
@@ -1720,13 +1790,11 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) | |||
1720 | if (host->pdata->quirks & DW_MCI_QUIRK_HIGHSPEED) | 1790 | if (host->pdata->quirks & DW_MCI_QUIRK_HIGHSPEED) |
1721 | mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED; | 1791 | mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED; |
1722 | 1792 | ||
1723 | #ifdef CONFIG_MMC_DW_IDMAC | 1793 | if (mmc->caps2 & MMC_CAP2_POWEROFF_NOTIFY) |
1724 | mmc->max_segs = host->ring_size; | 1794 | mmc->power_notify_type = MMC_HOST_PW_NOTIFY_SHORT; |
1725 | mmc->max_blk_size = 65536; | 1795 | else |
1726 | mmc->max_blk_count = host->ring_size; | 1796 | mmc->power_notify_type = MMC_HOST_PW_NOTIFY_NONE; |
1727 | mmc->max_seg_size = 0x1000; | 1797 | |
1728 | mmc->max_req_size = mmc->max_seg_size * mmc->max_blk_count; | ||
1729 | #else | ||
1730 | if (host->pdata->blk_settings) { | 1798 | if (host->pdata->blk_settings) { |
1731 | mmc->max_segs = host->pdata->blk_settings->max_segs; | 1799 | mmc->max_segs = host->pdata->blk_settings->max_segs; |
1732 | mmc->max_blk_size = host->pdata->blk_settings->max_blk_size; | 1800 | mmc->max_blk_size = host->pdata->blk_settings->max_blk_size; |
@@ -1735,13 +1803,20 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) | |||
1735 | mmc->max_seg_size = host->pdata->blk_settings->max_seg_size; | 1803 | mmc->max_seg_size = host->pdata->blk_settings->max_seg_size; |
1736 | } else { | 1804 | } else { |
1737 | /* Useful defaults if platform data is unset. */ | 1805 | /* Useful defaults if platform data is unset. */ |
1806 | #ifdef CONFIG_MMC_DW_IDMAC | ||
1807 | mmc->max_segs = host->ring_size; | ||
1808 | mmc->max_blk_size = 65536; | ||
1809 | mmc->max_blk_count = host->ring_size; | ||
1810 | mmc->max_seg_size = 0x1000; | ||
1811 | mmc->max_req_size = mmc->max_seg_size * mmc->max_blk_count; | ||
1812 | #else | ||
1738 | mmc->max_segs = 64; | 1813 | mmc->max_segs = 64; |
1739 | mmc->max_blk_size = 65536; /* BLKSIZ is 16 bits */ | 1814 | mmc->max_blk_size = 65536; /* BLKSIZ is 16 bits */ |
1740 | mmc->max_blk_count = 512; | 1815 | mmc->max_blk_count = 512; |
1741 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; | 1816 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; |
1742 | mmc->max_seg_size = mmc->max_req_size; | 1817 | mmc->max_seg_size = mmc->max_req_size; |
1743 | } | ||
1744 | #endif /* CONFIG_MMC_DW_IDMAC */ | 1818 | #endif /* CONFIG_MMC_DW_IDMAC */ |
1819 | } | ||
1745 | 1820 | ||
1746 | host->vmmc = regulator_get(mmc_dev(mmc), "vmmc"); | 1821 | host->vmmc = regulator_get(mmc_dev(mmc), "vmmc"); |
1747 | if (IS_ERR(host->vmmc)) { | 1822 | if (IS_ERR(host->vmmc)) { |
@@ -1789,10 +1864,10 @@ static void dw_mci_cleanup_slot(struct dw_mci_slot *slot, unsigned int id) | |||
1789 | static void dw_mci_init_dma(struct dw_mci *host) | 1864 | static void dw_mci_init_dma(struct dw_mci *host) |
1790 | { | 1865 | { |
1791 | /* Alloc memory for sg translation */ | 1866 | /* Alloc memory for sg translation */ |
1792 | host->sg_cpu = dma_alloc_coherent(&host->pdev->dev, PAGE_SIZE, | 1867 | host->sg_cpu = dma_alloc_coherent(&host->dev, PAGE_SIZE, |
1793 | &host->sg_dma, GFP_KERNEL); | 1868 | &host->sg_dma, GFP_KERNEL); |
1794 | if (!host->sg_cpu) { | 1869 | if (!host->sg_cpu) { |
1795 | dev_err(&host->pdev->dev, "%s: could not alloc DMA memory\n", | 1870 | dev_err(&host->dev, "%s: could not alloc DMA memory\n", |
1796 | __func__); | 1871 | __func__); |
1797 | goto no_dma; | 1872 | goto no_dma; |
1798 | } | 1873 | } |
@@ -1800,20 +1875,21 @@ static void dw_mci_init_dma(struct dw_mci *host) | |||
1800 | /* Determine which DMA interface to use */ | 1875 | /* Determine which DMA interface to use */ |
1801 | #ifdef CONFIG_MMC_DW_IDMAC | 1876 | #ifdef CONFIG_MMC_DW_IDMAC |
1802 | host->dma_ops = &dw_mci_idmac_ops; | 1877 | host->dma_ops = &dw_mci_idmac_ops; |
1803 | dev_info(&host->pdev->dev, "Using internal DMA controller.\n"); | 1878 | dev_info(&host->dev, "Using internal DMA controller.\n"); |
1804 | #endif | 1879 | #endif |
1805 | 1880 | ||
1806 | if (!host->dma_ops) | 1881 | if (!host->dma_ops) |
1807 | goto no_dma; | 1882 | goto no_dma; |
1808 | 1883 | ||
1809 | if (host->dma_ops->init) { | 1884 | if (host->dma_ops->init && host->dma_ops->start && |
1885 | host->dma_ops->stop && host->dma_ops->cleanup) { | ||
1810 | if (host->dma_ops->init(host)) { | 1886 | if (host->dma_ops->init(host)) { |
1811 | dev_err(&host->pdev->dev, "%s: Unable to initialize " | 1887 | dev_err(&host->dev, "%s: Unable to initialize " |
1812 | "DMA Controller.\n", __func__); | 1888 | "DMA Controller.\n", __func__); |
1813 | goto no_dma; | 1889 | goto no_dma; |
1814 | } | 1890 | } |
1815 | } else { | 1891 | } else { |
1816 | dev_err(&host->pdev->dev, "DMA initialization not found.\n"); | 1892 | dev_err(&host->dev, "DMA initialization not found.\n"); |
1817 | goto no_dma; | 1893 | goto no_dma; |
1818 | } | 1894 | } |
1819 | 1895 | ||
@@ -1821,7 +1897,7 @@ static void dw_mci_init_dma(struct dw_mci *host) | |||
1821 | return; | 1897 | return; |
1822 | 1898 | ||
1823 | no_dma: | 1899 | no_dma: |
1824 | dev_info(&host->pdev->dev, "Using PIO mode.\n"); | 1900 | dev_info(&host->dev, "Using PIO mode.\n"); |
1825 | host->use_dma = 0; | 1901 | host->use_dma = 0; |
1826 | return; | 1902 | return; |
1827 | } | 1903 | } |
@@ -1847,61 +1923,37 @@ static bool mci_wait_reset(struct device *dev, struct dw_mci *host) | |||
1847 | return false; | 1923 | return false; |
1848 | } | 1924 | } |
1849 | 1925 | ||
1850 | static int dw_mci_probe(struct platform_device *pdev) | 1926 | int dw_mci_probe(struct dw_mci *host) |
1851 | { | 1927 | { |
1852 | struct dw_mci *host; | 1928 | int width, i, ret = 0; |
1853 | struct resource *regs; | ||
1854 | struct dw_mci_board *pdata; | ||
1855 | int irq, ret, i, width; | ||
1856 | u32 fifo_size; | 1929 | u32 fifo_size; |
1857 | 1930 | ||
1858 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1931 | if (!host->pdata || !host->pdata->init) { |
1859 | if (!regs) | 1932 | dev_err(&host->dev, |
1860 | return -ENXIO; | ||
1861 | |||
1862 | irq = platform_get_irq(pdev, 0); | ||
1863 | if (irq < 0) | ||
1864 | return irq; | ||
1865 | |||
1866 | host = kzalloc(sizeof(struct dw_mci), GFP_KERNEL); | ||
1867 | if (!host) | ||
1868 | return -ENOMEM; | ||
1869 | |||
1870 | host->pdev = pdev; | ||
1871 | host->pdata = pdata = pdev->dev.platform_data; | ||
1872 | if (!pdata || !pdata->init) { | ||
1873 | dev_err(&pdev->dev, | ||
1874 | "Platform data must supply init function\n"); | 1933 | "Platform data must supply init function\n"); |
1875 | ret = -ENODEV; | 1934 | return -ENODEV; |
1876 | goto err_freehost; | ||
1877 | } | 1935 | } |
1878 | 1936 | ||
1879 | if (!pdata->select_slot && pdata->num_slots > 1) { | 1937 | if (!host->pdata->select_slot && host->pdata->num_slots > 1) { |
1880 | dev_err(&pdev->dev, | 1938 | dev_err(&host->dev, |
1881 | "Platform data must supply select_slot function\n"); | 1939 | "Platform data must supply select_slot function\n"); |
1882 | ret = -ENODEV; | 1940 | return -ENODEV; |
1883 | goto err_freehost; | ||
1884 | } | 1941 | } |
1885 | 1942 | ||
1886 | if (!pdata->bus_hz) { | 1943 | if (!host->pdata->bus_hz) { |
1887 | dev_err(&pdev->dev, | 1944 | dev_err(&host->dev, |
1888 | "Platform data must supply bus speed\n"); | 1945 | "Platform data must supply bus speed\n"); |
1889 | ret = -ENODEV; | 1946 | return -ENODEV; |
1890 | goto err_freehost; | ||
1891 | } | 1947 | } |
1892 | 1948 | ||
1893 | host->bus_hz = pdata->bus_hz; | 1949 | host->bus_hz = host->pdata->bus_hz; |
1894 | host->quirks = pdata->quirks; | 1950 | host->quirks = host->pdata->quirks; |
1895 | 1951 | ||
1896 | spin_lock_init(&host->lock); | 1952 | spin_lock_init(&host->lock); |
1897 | INIT_LIST_HEAD(&host->queue); | 1953 | INIT_LIST_HEAD(&host->queue); |
1898 | 1954 | ||
1899 | ret = -ENOMEM; | ||
1900 | host->regs = ioremap(regs->start, resource_size(regs)); | ||
1901 | if (!host->regs) | ||
1902 | goto err_freehost; | ||
1903 | 1955 | ||
1904 | host->dma_ops = pdata->dma_ops; | 1956 | host->dma_ops = host->pdata->dma_ops; |
1905 | dw_mci_init_dma(host); | 1957 | dw_mci_init_dma(host); |
1906 | 1958 | ||
1907 | /* | 1959 | /* |
@@ -1931,7 +1983,7 @@ static int dw_mci_probe(struct platform_device *pdev) | |||
1931 | } | 1983 | } |
1932 | 1984 | ||
1933 | /* Reset all blocks */ | 1985 | /* Reset all blocks */ |
1934 | if (!mci_wait_reset(&pdev->dev, host)) { | 1986 | if (!mci_wait_reset(&host->dev, host)) { |
1935 | ret = -ENODEV; | 1987 | ret = -ENODEV; |
1936 | goto err_dmaunmap; | 1988 | goto err_dmaunmap; |
1937 | } | 1989 | } |
@@ -1974,13 +2026,10 @@ static int dw_mci_probe(struct platform_device *pdev) | |||
1974 | if (!dw_mci_card_workqueue) | 2026 | if (!dw_mci_card_workqueue) |
1975 | goto err_dmaunmap; | 2027 | goto err_dmaunmap; |
1976 | INIT_WORK(&host->card_work, dw_mci_work_routine_card); | 2028 | INIT_WORK(&host->card_work, dw_mci_work_routine_card); |
1977 | 2029 | ret = request_irq(host->irq, dw_mci_interrupt, host->irq_flags, "dw-mci", host); | |
1978 | ret = request_irq(irq, dw_mci_interrupt, 0, "dw-mci", host); | ||
1979 | if (ret) | 2030 | if (ret) |
1980 | goto err_workqueue; | 2031 | goto err_workqueue; |
1981 | 2032 | ||
1982 | platform_set_drvdata(pdev, host); | ||
1983 | |||
1984 | if (host->pdata->num_slots) | 2033 | if (host->pdata->num_slots) |
1985 | host->num_slots = host->pdata->num_slots; | 2034 | host->num_slots = host->pdata->num_slots; |
1986 | else | 2035 | else |
@@ -2000,7 +2049,7 @@ static int dw_mci_probe(struct platform_device *pdev) | |||
2000 | * Need to check the version-id and set data-offset for DATA register. | 2049 | * Need to check the version-id and set data-offset for DATA register. |
2001 | */ | 2050 | */ |
2002 | host->verid = SDMMC_GET_VERID(mci_readl(host, VERID)); | 2051 | host->verid = SDMMC_GET_VERID(mci_readl(host, VERID)); |
2003 | dev_info(&pdev->dev, "Version ID is %04x\n", host->verid); | 2052 | dev_info(&host->dev, "Version ID is %04x\n", host->verid); |
2004 | 2053 | ||
2005 | if (host->verid < DW_MMC_240A) | 2054 | if (host->verid < DW_MMC_240A) |
2006 | host->data_offset = DATA_OFFSET; | 2055 | host->data_offset = DATA_OFFSET; |
@@ -2017,12 +2066,12 @@ static int dw_mci_probe(struct platform_device *pdev) | |||
2017 | DW_MCI_ERROR_FLAGS | SDMMC_INT_CD); | 2066 | DW_MCI_ERROR_FLAGS | SDMMC_INT_CD); |
2018 | mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /* Enable mci interrupt */ | 2067 | mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /* Enable mci interrupt */ |
2019 | 2068 | ||
2020 | dev_info(&pdev->dev, "DW MMC controller at irq %d, " | 2069 | dev_info(&host->dev, "DW MMC controller at irq %d, " |
2021 | "%d bit host data width, " | 2070 | "%d bit host data width, " |
2022 | "%u deep fifo\n", | 2071 | "%u deep fifo\n", |
2023 | irq, width, fifo_size); | 2072 | host->irq, width, fifo_size); |
2024 | if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO) | 2073 | if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO) |
2025 | dev_info(&pdev->dev, "Internal DMAC interrupt fix enabled.\n"); | 2074 | dev_info(&host->dev, "Internal DMAC interrupt fix enabled.\n"); |
2026 | 2075 | ||
2027 | return 0; | 2076 | return 0; |
2028 | 2077 | ||
@@ -2033,7 +2082,7 @@ err_init_slot: | |||
2033 | dw_mci_cleanup_slot(host->slot[i], i); | 2082 | dw_mci_cleanup_slot(host->slot[i], i); |
2034 | i--; | 2083 | i--; |
2035 | } | 2084 | } |
2036 | free_irq(irq, host); | 2085 | free_irq(host->irq, host); |
2037 | 2086 | ||
2038 | err_workqueue: | 2087 | err_workqueue: |
2039 | destroy_workqueue(dw_mci_card_workqueue); | 2088 | destroy_workqueue(dw_mci_card_workqueue); |
@@ -2041,33 +2090,26 @@ err_workqueue: | |||
2041 | err_dmaunmap: | 2090 | err_dmaunmap: |
2042 | if (host->use_dma && host->dma_ops->exit) | 2091 | if (host->use_dma && host->dma_ops->exit) |
2043 | host->dma_ops->exit(host); | 2092 | host->dma_ops->exit(host); |
2044 | dma_free_coherent(&host->pdev->dev, PAGE_SIZE, | 2093 | dma_free_coherent(&host->dev, PAGE_SIZE, |
2045 | host->sg_cpu, host->sg_dma); | 2094 | host->sg_cpu, host->sg_dma); |
2046 | iounmap(host->regs); | ||
2047 | 2095 | ||
2048 | if (host->vmmc) { | 2096 | if (host->vmmc) { |
2049 | regulator_disable(host->vmmc); | 2097 | regulator_disable(host->vmmc); |
2050 | regulator_put(host->vmmc); | 2098 | regulator_put(host->vmmc); |
2051 | } | 2099 | } |
2052 | |||
2053 | |||
2054 | err_freehost: | ||
2055 | kfree(host); | ||
2056 | return ret; | 2100 | return ret; |
2057 | } | 2101 | } |
2102 | EXPORT_SYMBOL(dw_mci_probe); | ||
2058 | 2103 | ||
2059 | static int __exit dw_mci_remove(struct platform_device *pdev) | 2104 | void dw_mci_remove(struct dw_mci *host) |
2060 | { | 2105 | { |
2061 | struct dw_mci *host = platform_get_drvdata(pdev); | ||
2062 | int i; | 2106 | int i; |
2063 | 2107 | ||
2064 | mci_writel(host, RINTSTS, 0xFFFFFFFF); | 2108 | mci_writel(host, RINTSTS, 0xFFFFFFFF); |
2065 | mci_writel(host, INTMASK, 0); /* disable all mmc interrupt first */ | 2109 | mci_writel(host, INTMASK, 0); /* disable all mmc interrupt first */ |
2066 | 2110 | ||
2067 | platform_set_drvdata(pdev, NULL); | ||
2068 | |||
2069 | for (i = 0; i < host->num_slots; i++) { | 2111 | for (i = 0; i < host->num_slots; i++) { |
2070 | dev_dbg(&pdev->dev, "remove slot %d\n", i); | 2112 | dev_dbg(&host->dev, "remove slot %d\n", i); |
2071 | if (host->slot[i]) | 2113 | if (host->slot[i]) |
2072 | dw_mci_cleanup_slot(host->slot[i], i); | 2114 | dw_mci_cleanup_slot(host->slot[i], i); |
2073 | } | 2115 | } |
@@ -2076,9 +2118,9 @@ static int __exit dw_mci_remove(struct platform_device *pdev) | |||
2076 | mci_writel(host, CLKENA, 0); | 2118 | mci_writel(host, CLKENA, 0); |
2077 | mci_writel(host, CLKSRC, 0); | 2119 | mci_writel(host, CLKSRC, 0); |
2078 | 2120 | ||
2079 | free_irq(platform_get_irq(pdev, 0), host); | 2121 | free_irq(host->irq, host); |
2080 | destroy_workqueue(dw_mci_card_workqueue); | 2122 | destroy_workqueue(dw_mci_card_workqueue); |
2081 | dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma); | 2123 | dma_free_coherent(&host->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma); |
2082 | 2124 | ||
2083 | if (host->use_dma && host->dma_ops->exit) | 2125 | if (host->use_dma && host->dma_ops->exit) |
2084 | host->dma_ops->exit(host); | 2126 | host->dma_ops->exit(host); |
@@ -2088,20 +2130,18 @@ static int __exit dw_mci_remove(struct platform_device *pdev) | |||
2088 | regulator_put(host->vmmc); | 2130 | regulator_put(host->vmmc); |
2089 | } | 2131 | } |
2090 | 2132 | ||
2091 | iounmap(host->regs); | ||
2092 | |||
2093 | kfree(host); | ||
2094 | return 0; | ||
2095 | } | 2133 | } |
2134 | EXPORT_SYMBOL(dw_mci_remove); | ||
2135 | |||
2136 | |||
2096 | 2137 | ||
2097 | #ifdef CONFIG_PM_SLEEP | 2138 | #ifdef CONFIG_PM_SLEEP |
2098 | /* | 2139 | /* |
2099 | * TODO: we should probably disable the clock to the card in the suspend path. | 2140 | * TODO: we should probably disable the clock to the card in the suspend path. |
2100 | */ | 2141 | */ |
2101 | static int dw_mci_suspend(struct device *dev) | 2142 | int dw_mci_suspend(struct dw_mci *host) |
2102 | { | 2143 | { |
2103 | int i, ret; | 2144 | int i, ret = 0; |
2104 | struct dw_mci *host = dev_get_drvdata(dev); | ||
2105 | 2145 | ||
2106 | for (i = 0; i < host->num_slots; i++) { | 2146 | for (i = 0; i < host->num_slots; i++) { |
2107 | struct dw_mci_slot *slot = host->slot[i]; | 2147 | struct dw_mci_slot *slot = host->slot[i]; |
@@ -2123,11 +2163,11 @@ static int dw_mci_suspend(struct device *dev) | |||
2123 | 2163 | ||
2124 | return 0; | 2164 | return 0; |
2125 | } | 2165 | } |
2166 | EXPORT_SYMBOL(dw_mci_suspend); | ||
2126 | 2167 | ||
2127 | static int dw_mci_resume(struct device *dev) | 2168 | int dw_mci_resume(struct dw_mci *host) |
2128 | { | 2169 | { |
2129 | int i, ret; | 2170 | int i, ret; |
2130 | struct dw_mci *host = dev_get_drvdata(dev); | ||
2131 | 2171 | ||
2132 | if (host->vmmc) | 2172 | if (host->vmmc) |
2133 | regulator_enable(host->vmmc); | 2173 | regulator_enable(host->vmmc); |
@@ -2135,7 +2175,7 @@ static int dw_mci_resume(struct device *dev) | |||
2135 | if (host->dma_ops->init) | 2175 | if (host->dma_ops->init) |
2136 | host->dma_ops->init(host); | 2176 | host->dma_ops->init(host); |
2137 | 2177 | ||
2138 | if (!mci_wait_reset(dev, host)) { | 2178 | if (!mci_wait_reset(&host->dev, host)) { |
2139 | ret = -ENODEV; | 2179 | ret = -ENODEV; |
2140 | return ret; | 2180 | return ret; |
2141 | } | 2181 | } |
@@ -2157,32 +2197,19 @@ static int dw_mci_resume(struct device *dev) | |||
2157 | if (ret < 0) | 2197 | if (ret < 0) |
2158 | return ret; | 2198 | return ret; |
2159 | } | 2199 | } |
2160 | |||
2161 | return 0; | 2200 | return 0; |
2162 | } | 2201 | } |
2163 | #else | 2202 | EXPORT_SYMBOL(dw_mci_resume); |
2164 | #define dw_mci_suspend NULL | ||
2165 | #define dw_mci_resume NULL | ||
2166 | #endif /* CONFIG_PM_SLEEP */ | 2203 | #endif /* CONFIG_PM_SLEEP */ |
2167 | 2204 | ||
2168 | static SIMPLE_DEV_PM_OPS(dw_mci_pmops, dw_mci_suspend, dw_mci_resume); | ||
2169 | |||
2170 | static struct platform_driver dw_mci_driver = { | ||
2171 | .remove = __exit_p(dw_mci_remove), | ||
2172 | .driver = { | ||
2173 | .name = "dw_mmc", | ||
2174 | .pm = &dw_mci_pmops, | ||
2175 | }, | ||
2176 | }; | ||
2177 | |||
2178 | static int __init dw_mci_init(void) | 2205 | static int __init dw_mci_init(void) |
2179 | { | 2206 | { |
2180 | return platform_driver_probe(&dw_mci_driver, dw_mci_probe); | 2207 | printk(KERN_INFO "Synopsys Designware Multimedia Card Interface Driver"); |
2208 | return 0; | ||
2181 | } | 2209 | } |
2182 | 2210 | ||
2183 | static void __exit dw_mci_exit(void) | 2211 | static void __exit dw_mci_exit(void) |
2184 | { | 2212 | { |
2185 | platform_driver_unregister(&dw_mci_driver); | ||
2186 | } | 2213 | } |
2187 | 2214 | ||
2188 | module_init(dw_mci_init); | 2215 | module_init(dw_mci_init); |
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h index df392a1143f2..15c27e17c23f 100644 --- a/drivers/mmc/host/dw_mmc.h +++ b/drivers/mmc/host/dw_mmc.h | |||
@@ -175,4 +175,11 @@ | |||
175 | (*(volatile u64 __force *)((dev)->regs + SDMMC_##reg) = (value)) | 175 | (*(volatile u64 __force *)((dev)->regs + SDMMC_##reg) = (value)) |
176 | #endif | 176 | #endif |
177 | 177 | ||
178 | extern int dw_mci_probe(struct dw_mci *host); | ||
179 | extern void dw_mci_remove(struct dw_mci *host); | ||
180 | #ifdef CONFIG_PM | ||
181 | extern int dw_mci_suspend(struct dw_mci *host); | ||
182 | extern int dw_mci_resume(struct dw_mci *host); | ||
183 | #endif | ||
184 | |||
178 | #endif /* _DW_MMC_H_ */ | 185 | #endif /* _DW_MMC_H_ */ |
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 0d955ffaf44e..032b84791a16 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/dma-mapping.h> | 30 | #include <linux/dma-mapping.h> |
31 | #include <linux/amba/mmci.h> | 31 | #include <linux/amba/mmci.h> |
32 | #include <linux/pm_runtime.h> | 32 | #include <linux/pm_runtime.h> |
33 | #include <linux/types.h> | ||
33 | 34 | ||
34 | #include <asm/div64.h> | 35 | #include <asm/div64.h> |
35 | #include <asm/io.h> | 36 | #include <asm/io.h> |
@@ -53,6 +54,8 @@ static unsigned int fmax = 515633; | |||
53 | * @sdio: variant supports SDIO | 54 | * @sdio: variant supports SDIO |
54 | * @st_clkdiv: true if using a ST-specific clock divider algorithm | 55 | * @st_clkdiv: true if using a ST-specific clock divider algorithm |
55 | * @blksz_datactrl16: true if Block size is at b16..b30 position in datactrl register | 56 | * @blksz_datactrl16: true if Block size is at b16..b30 position in datactrl register |
57 | * @pwrreg_powerup: power up value for MMCIPOWER register | ||
58 | * @signal_direction: input/out direction of bus signals can be indicated | ||
56 | */ | 59 | */ |
57 | struct variant_data { | 60 | struct variant_data { |
58 | unsigned int clkreg; | 61 | unsigned int clkreg; |
@@ -63,18 +66,22 @@ struct variant_data { | |||
63 | bool sdio; | 66 | bool sdio; |
64 | bool st_clkdiv; | 67 | bool st_clkdiv; |
65 | bool blksz_datactrl16; | 68 | bool blksz_datactrl16; |
69 | u32 pwrreg_powerup; | ||
70 | bool signal_direction; | ||
66 | }; | 71 | }; |
67 | 72 | ||
68 | static struct variant_data variant_arm = { | 73 | static struct variant_data variant_arm = { |
69 | .fifosize = 16 * 4, | 74 | .fifosize = 16 * 4, |
70 | .fifohalfsize = 8 * 4, | 75 | .fifohalfsize = 8 * 4, |
71 | .datalength_bits = 16, | 76 | .datalength_bits = 16, |
77 | .pwrreg_powerup = MCI_PWR_UP, | ||
72 | }; | 78 | }; |
73 | 79 | ||
74 | static struct variant_data variant_arm_extended_fifo = { | 80 | static struct variant_data variant_arm_extended_fifo = { |
75 | .fifosize = 128 * 4, | 81 | .fifosize = 128 * 4, |
76 | .fifohalfsize = 64 * 4, | 82 | .fifohalfsize = 64 * 4, |
77 | .datalength_bits = 16, | 83 | .datalength_bits = 16, |
84 | .pwrreg_powerup = MCI_PWR_UP, | ||
78 | }; | 85 | }; |
79 | 86 | ||
80 | static struct variant_data variant_u300 = { | 87 | static struct variant_data variant_u300 = { |
@@ -83,6 +90,8 @@ static struct variant_data variant_u300 = { | |||
83 | .clkreg_enable = MCI_ST_U300_HWFCEN, | 90 | .clkreg_enable = MCI_ST_U300_HWFCEN, |
84 | .datalength_bits = 16, | 91 | .datalength_bits = 16, |
85 | .sdio = true, | 92 | .sdio = true, |
93 | .pwrreg_powerup = MCI_PWR_ON, | ||
94 | .signal_direction = true, | ||
86 | }; | 95 | }; |
87 | 96 | ||
88 | static struct variant_data variant_ux500 = { | 97 | static struct variant_data variant_ux500 = { |
@@ -93,6 +102,8 @@ static struct variant_data variant_ux500 = { | |||
93 | .datalength_bits = 24, | 102 | .datalength_bits = 24, |
94 | .sdio = true, | 103 | .sdio = true, |
95 | .st_clkdiv = true, | 104 | .st_clkdiv = true, |
105 | .pwrreg_powerup = MCI_PWR_ON, | ||
106 | .signal_direction = true, | ||
96 | }; | 107 | }; |
97 | 108 | ||
98 | static struct variant_data variant_ux500v2 = { | 109 | static struct variant_data variant_ux500v2 = { |
@@ -104,11 +115,35 @@ static struct variant_data variant_ux500v2 = { | |||
104 | .sdio = true, | 115 | .sdio = true, |
105 | .st_clkdiv = true, | 116 | .st_clkdiv = true, |
106 | .blksz_datactrl16 = true, | 117 | .blksz_datactrl16 = true, |
118 | .pwrreg_powerup = MCI_PWR_ON, | ||
119 | .signal_direction = true, | ||
107 | }; | 120 | }; |
108 | 121 | ||
109 | /* | 122 | /* |
110 | * This must be called with host->lock held | 123 | * This must be called with host->lock held |
111 | */ | 124 | */ |
125 | static void mmci_write_clkreg(struct mmci_host *host, u32 clk) | ||
126 | { | ||
127 | if (host->clk_reg != clk) { | ||
128 | host->clk_reg = clk; | ||
129 | writel(clk, host->base + MMCICLOCK); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | /* | ||
134 | * This must be called with host->lock held | ||
135 | */ | ||
136 | static void mmci_write_pwrreg(struct mmci_host *host, u32 pwr) | ||
137 | { | ||
138 | if (host->pwr_reg != pwr) { | ||
139 | host->pwr_reg = pwr; | ||
140 | writel(pwr, host->base + MMCIPOWER); | ||
141 | } | ||
142 | } | ||
143 | |||
144 | /* | ||
145 | * This must be called with host->lock held | ||
146 | */ | ||
112 | static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired) | 147 | static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired) |
113 | { | 148 | { |
114 | struct variant_data *variant = host->variant; | 149 | struct variant_data *variant = host->variant; |
@@ -153,7 +188,7 @@ static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired) | |||
153 | if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_8) | 188 | if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_8) |
154 | clk |= MCI_ST_8BIT_BUS; | 189 | clk |= MCI_ST_8BIT_BUS; |
155 | 190 | ||
156 | writel(clk, host->base + MMCICLOCK); | 191 | mmci_write_clkreg(host, clk); |
157 | } | 192 | } |
158 | 193 | ||
159 | static void | 194 | static void |
@@ -166,14 +201,10 @@ mmci_request_end(struct mmci_host *host, struct mmc_request *mrq) | |||
166 | host->mrq = NULL; | 201 | host->mrq = NULL; |
167 | host->cmd = NULL; | 202 | host->cmd = NULL; |
168 | 203 | ||
169 | /* | ||
170 | * Need to drop the host lock here; mmc_request_done may call | ||
171 | * back into the driver... | ||
172 | */ | ||
173 | spin_unlock(&host->lock); | ||
174 | pm_runtime_put(mmc_dev(host->mmc)); | ||
175 | mmc_request_done(host->mmc, mrq); | 204 | mmc_request_done(host->mmc, mrq); |
176 | spin_lock(&host->lock); | 205 | |
206 | pm_runtime_mark_last_busy(mmc_dev(host->mmc)); | ||
207 | pm_runtime_put_autosuspend(mmc_dev(host->mmc)); | ||
177 | } | 208 | } |
178 | 209 | ||
179 | static void mmci_set_mask1(struct mmci_host *host, unsigned int mask) | 210 | static void mmci_set_mask1(struct mmci_host *host, unsigned int mask) |
@@ -370,6 +401,7 @@ static int mmci_dma_prep_data(struct mmci_host *host, struct mmc_data *data, | |||
370 | .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, | 401 | .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, |
371 | .src_maxburst = variant->fifohalfsize >> 2, /* # of words */ | 402 | .src_maxburst = variant->fifohalfsize >> 2, /* # of words */ |
372 | .dst_maxburst = variant->fifohalfsize >> 2, /* # of words */ | 403 | .dst_maxburst = variant->fifohalfsize >> 2, /* # of words */ |
404 | .device_fc = false, | ||
373 | }; | 405 | }; |
374 | struct dma_chan *chan; | 406 | struct dma_chan *chan; |
375 | struct dma_device *device; | 407 | struct dma_device *device; |
@@ -411,7 +443,7 @@ static int mmci_dma_prep_data(struct mmci_host *host, struct mmc_data *data, | |||
411 | return -EINVAL; | 443 | return -EINVAL; |
412 | 444 | ||
413 | dmaengine_slave_config(chan, &conf); | 445 | dmaengine_slave_config(chan, &conf); |
414 | desc = device->device_prep_slave_sg(chan, data->sg, nr_sg, | 446 | desc = dmaengine_prep_slave_sg(chan, data->sg, nr_sg, |
415 | conf.direction, DMA_CTRL_ACK); | 447 | conf.direction, DMA_CTRL_ACK); |
416 | if (!desc) | 448 | if (!desc) |
417 | goto unmap_exit; | 449 | goto unmap_exit; |
@@ -607,6 +639,11 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data) | |||
607 | if (data->flags & MMC_DATA_READ) | 639 | if (data->flags & MMC_DATA_READ) |
608 | datactrl |= MCI_DPSM_DIRECTION; | 640 | datactrl |= MCI_DPSM_DIRECTION; |
609 | 641 | ||
642 | /* The ST Micro variants has a special bit to enable SDIO */ | ||
643 | if (variant->sdio && host->mmc->card) | ||
644 | if (mmc_card_sdio(host->mmc->card)) | ||
645 | datactrl |= MCI_ST_DPSM_SDIOEN; | ||
646 | |||
610 | /* | 647 | /* |
611 | * Attempt to use DMA operation mode, if this | 648 | * Attempt to use DMA operation mode, if this |
612 | * should fail, fall back to PIO mode | 649 | * should fail, fall back to PIO mode |
@@ -635,11 +672,6 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data) | |||
635 | irqmask = MCI_TXFIFOHALFEMPTYMASK; | 672 | irqmask = MCI_TXFIFOHALFEMPTYMASK; |
636 | } | 673 | } |
637 | 674 | ||
638 | /* The ST Micro variants has a special bit to enable SDIO */ | ||
639 | if (variant->sdio && host->mmc->card) | ||
640 | if (mmc_card_sdio(host->mmc->card)) | ||
641 | datactrl |= MCI_ST_DPSM_SDIOEN; | ||
642 | |||
643 | writel(datactrl, base + MMCIDATACTRL); | 675 | writel(datactrl, base + MMCIDATACTRL); |
644 | writel(readl(base + MMCIMASK0) & ~MCI_DATAENDMASK, base + MMCIMASK0); | 676 | writel(readl(base + MMCIMASK0) & ~MCI_DATAENDMASK, base + MMCIMASK0); |
645 | mmci_set_mask1(host, irqmask); | 677 | mmci_set_mask1(host, irqmask); |
@@ -786,7 +818,24 @@ static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int rema | |||
786 | if (count <= 0) | 818 | if (count <= 0) |
787 | break; | 819 | break; |
788 | 820 | ||
789 | readsl(base + MMCIFIFO, ptr, count >> 2); | 821 | /* |
822 | * SDIO especially may want to send something that is | ||
823 | * not divisible by 4 (as opposed to card sectors | ||
824 | * etc). Therefore make sure to always read the last bytes | ||
825 | * while only doing full 32-bit reads towards the FIFO. | ||
826 | */ | ||
827 | if (unlikely(count & 0x3)) { | ||
828 | if (count < 4) { | ||
829 | unsigned char buf[4]; | ||
830 | readsl(base + MMCIFIFO, buf, 1); | ||
831 | memcpy(ptr, buf, count); | ||
832 | } else { | ||
833 | readsl(base + MMCIFIFO, ptr, count >> 2); | ||
834 | count &= ~0x3; | ||
835 | } | ||
836 | } else { | ||
837 | readsl(base + MMCIFIFO, ptr, count >> 2); | ||
838 | } | ||
790 | 839 | ||
791 | ptr += count; | 840 | ptr += count; |
792 | remain -= count; | 841 | remain -= count; |
@@ -821,14 +870,13 @@ static int mmci_pio_write(struct mmci_host *host, char *buffer, unsigned int rem | |||
821 | */ | 870 | */ |
822 | if (variant->sdio && | 871 | if (variant->sdio && |
823 | mmc_card_sdio(host->mmc->card)) { | 872 | mmc_card_sdio(host->mmc->card)) { |
873 | u32 clk; | ||
824 | if (count < 8) | 874 | if (count < 8) |
825 | writel(readl(host->base + MMCICLOCK) & | 875 | clk = host->clk_reg & ~variant->clkreg_enable; |
826 | ~variant->clkreg_enable, | ||
827 | host->base + MMCICLOCK); | ||
828 | else | 876 | else |
829 | writel(readl(host->base + MMCICLOCK) | | 877 | clk = host->clk_reg | variant->clkreg_enable; |
830 | variant->clkreg_enable, | 878 | |
831 | host->base + MMCICLOCK); | 879 | mmci_write_clkreg(host, clk); |
832 | } | 880 | } |
833 | 881 | ||
834 | /* | 882 | /* |
@@ -1015,10 +1063,17 @@ static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq) | |||
1015 | static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | 1063 | static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) |
1016 | { | 1064 | { |
1017 | struct mmci_host *host = mmc_priv(mmc); | 1065 | struct mmci_host *host = mmc_priv(mmc); |
1066 | struct variant_data *variant = host->variant; | ||
1018 | u32 pwr = 0; | 1067 | u32 pwr = 0; |
1019 | unsigned long flags; | 1068 | unsigned long flags; |
1020 | int ret; | 1069 | int ret; |
1021 | 1070 | ||
1071 | pm_runtime_get_sync(mmc_dev(mmc)); | ||
1072 | |||
1073 | if (host->plat->ios_handler && | ||
1074 | host->plat->ios_handler(mmc_dev(mmc), ios)) | ||
1075 | dev_err(mmc_dev(mmc), "platform ios_handler failed\n"); | ||
1076 | |||
1022 | switch (ios->power_mode) { | 1077 | switch (ios->power_mode) { |
1023 | case MMC_POWER_OFF: | 1078 | case MMC_POWER_OFF: |
1024 | if (host->vcc) | 1079 | if (host->vcc) |
@@ -1035,22 +1090,38 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
1035 | * power should be rare so we print an error | 1090 | * power should be rare so we print an error |
1036 | * and return here. | 1091 | * and return here. |
1037 | */ | 1092 | */ |
1038 | return; | 1093 | goto out; |
1039 | } | 1094 | } |
1040 | } | 1095 | } |
1041 | if (host->plat->vdd_handler) | 1096 | /* |
1042 | pwr |= host->plat->vdd_handler(mmc_dev(mmc), ios->vdd, | 1097 | * The ST Micro variant doesn't have the PL180s MCI_PWR_UP |
1043 | ios->power_mode); | 1098 | * and instead uses MCI_PWR_ON so apply whatever value is |
1044 | /* The ST version does not have this, fall through to POWER_ON */ | 1099 | * configured in the variant data. |
1045 | if (host->hw_designer != AMBA_VENDOR_ST) { | 1100 | */ |
1046 | pwr |= MCI_PWR_UP; | 1101 | pwr |= variant->pwrreg_powerup; |
1047 | break; | 1102 | |
1048 | } | 1103 | break; |
1049 | case MMC_POWER_ON: | 1104 | case MMC_POWER_ON: |
1050 | pwr |= MCI_PWR_ON; | 1105 | pwr |= MCI_PWR_ON; |
1051 | break; | 1106 | break; |
1052 | } | 1107 | } |
1053 | 1108 | ||
1109 | if (variant->signal_direction && ios->power_mode != MMC_POWER_OFF) { | ||
1110 | /* | ||
1111 | * The ST Micro variant has some additional bits | ||
1112 | * indicating signal direction for the signals in | ||
1113 | * the SD/MMC bus and feedback-clock usage. | ||
1114 | */ | ||
1115 | pwr |= host->plat->sigdir; | ||
1116 | |||
1117 | if (ios->bus_width == MMC_BUS_WIDTH_4) | ||
1118 | pwr &= ~MCI_ST_DATA74DIREN; | ||
1119 | else if (ios->bus_width == MMC_BUS_WIDTH_1) | ||
1120 | pwr &= (~MCI_ST_DATA74DIREN & | ||
1121 | ~MCI_ST_DATA31DIREN & | ||
1122 | ~MCI_ST_DATA2DIREN); | ||
1123 | } | ||
1124 | |||
1054 | if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) { | 1125 | if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) { |
1055 | if (host->hw_designer != AMBA_VENDOR_ST) | 1126 | if (host->hw_designer != AMBA_VENDOR_ST) |
1056 | pwr |= MCI_ROD; | 1127 | pwr |= MCI_ROD; |
@@ -1066,13 +1137,13 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
1066 | spin_lock_irqsave(&host->lock, flags); | 1137 | spin_lock_irqsave(&host->lock, flags); |
1067 | 1138 | ||
1068 | mmci_set_clkreg(host, ios->clock); | 1139 | mmci_set_clkreg(host, ios->clock); |
1069 | 1140 | mmci_write_pwrreg(host, pwr); | |
1070 | if (host->pwr != pwr) { | ||
1071 | host->pwr = pwr; | ||
1072 | writel(pwr, host->base + MMCIPOWER); | ||
1073 | } | ||
1074 | 1141 | ||
1075 | spin_unlock_irqrestore(&host->lock, flags); | 1142 | spin_unlock_irqrestore(&host->lock, flags); |
1143 | |||
1144 | out: | ||
1145 | pm_runtime_mark_last_busy(mmc_dev(mmc)); | ||
1146 | pm_runtime_put_autosuspend(mmc_dev(mmc)); | ||
1076 | } | 1147 | } |
1077 | 1148 | ||
1078 | static int mmci_get_ro(struct mmc_host *mmc) | 1149 | static int mmci_get_ro(struct mmc_host *mmc) |
@@ -1271,12 +1342,13 @@ static int __devinit mmci_probe(struct amba_device *dev, | |||
1271 | /* | 1342 | /* |
1272 | * Block size can be up to 2048 bytes, but must be a power of two. | 1343 | * Block size can be up to 2048 bytes, but must be a power of two. |
1273 | */ | 1344 | */ |
1274 | mmc->max_blk_size = 2048; | 1345 | mmc->max_blk_size = 1 << 11; |
1275 | 1346 | ||
1276 | /* | 1347 | /* |
1277 | * No limit on the number of blocks transferred. | 1348 | * Limit the number of blocks transferred so that we don't overflow |
1349 | * the maximum request size. | ||
1278 | */ | 1350 | */ |
1279 | mmc->max_blk_count = mmc->max_req_size; | 1351 | mmc->max_blk_count = mmc->max_req_size >> 11; |
1280 | 1352 | ||
1281 | spin_lock_init(&host->lock); | 1353 | spin_lock_init(&host->lock); |
1282 | 1354 | ||
@@ -1325,7 +1397,7 @@ static int __devinit mmci_probe(struct amba_device *dev, | |||
1325 | if (ret) | 1397 | if (ret) |
1326 | goto unmap; | 1398 | goto unmap; |
1327 | 1399 | ||
1328 | if (dev->irq[1] == NO_IRQ) | 1400 | if (dev->irq[1] == NO_IRQ || !dev->irq[1]) |
1329 | host->singleirq = true; | 1401 | host->singleirq = true; |
1330 | else { | 1402 | else { |
1331 | ret = request_irq(dev->irq[1], mmci_pio_irq, IRQF_SHARED, | 1403 | ret = request_irq(dev->irq[1], mmci_pio_irq, IRQF_SHARED, |
@@ -1345,6 +1417,8 @@ static int __devinit mmci_probe(struct amba_device *dev, | |||
1345 | 1417 | ||
1346 | mmci_dma_setup(host); | 1418 | mmci_dma_setup(host); |
1347 | 1419 | ||
1420 | pm_runtime_set_autosuspend_delay(&dev->dev, 50); | ||
1421 | pm_runtime_use_autosuspend(&dev->dev); | ||
1348 | pm_runtime_put(&dev->dev); | 1422 | pm_runtime_put(&dev->dev); |
1349 | 1423 | ||
1350 | mmc_add_host(mmc); | 1424 | mmc_add_host(mmc); |
@@ -1429,43 +1503,49 @@ static int __devexit mmci_remove(struct amba_device *dev) | |||
1429 | return 0; | 1503 | return 0; |
1430 | } | 1504 | } |
1431 | 1505 | ||
1432 | #ifdef CONFIG_PM | 1506 | #ifdef CONFIG_SUSPEND |
1433 | static int mmci_suspend(struct amba_device *dev, pm_message_t state) | 1507 | static int mmci_suspend(struct device *dev) |
1434 | { | 1508 | { |
1435 | struct mmc_host *mmc = amba_get_drvdata(dev); | 1509 | struct amba_device *adev = to_amba_device(dev); |
1510 | struct mmc_host *mmc = amba_get_drvdata(adev); | ||
1436 | int ret = 0; | 1511 | int ret = 0; |
1437 | 1512 | ||
1438 | if (mmc) { | 1513 | if (mmc) { |
1439 | struct mmci_host *host = mmc_priv(mmc); | 1514 | struct mmci_host *host = mmc_priv(mmc); |
1440 | 1515 | ||
1441 | ret = mmc_suspend_host(mmc); | 1516 | ret = mmc_suspend_host(mmc); |
1442 | if (ret == 0) | 1517 | if (ret == 0) { |
1518 | pm_runtime_get_sync(dev); | ||
1443 | writel(0, host->base + MMCIMASK0); | 1519 | writel(0, host->base + MMCIMASK0); |
1520 | } | ||
1444 | } | 1521 | } |
1445 | 1522 | ||
1446 | return ret; | 1523 | return ret; |
1447 | } | 1524 | } |
1448 | 1525 | ||
1449 | static int mmci_resume(struct amba_device *dev) | 1526 | static int mmci_resume(struct device *dev) |
1450 | { | 1527 | { |
1451 | struct mmc_host *mmc = amba_get_drvdata(dev); | 1528 | struct amba_device *adev = to_amba_device(dev); |
1529 | struct mmc_host *mmc = amba_get_drvdata(adev); | ||
1452 | int ret = 0; | 1530 | int ret = 0; |
1453 | 1531 | ||
1454 | if (mmc) { | 1532 | if (mmc) { |
1455 | struct mmci_host *host = mmc_priv(mmc); | 1533 | struct mmci_host *host = mmc_priv(mmc); |
1456 | 1534 | ||
1457 | writel(MCI_IRQENABLE, host->base + MMCIMASK0); | 1535 | writel(MCI_IRQENABLE, host->base + MMCIMASK0); |
1536 | pm_runtime_put(dev); | ||
1458 | 1537 | ||
1459 | ret = mmc_resume_host(mmc); | 1538 | ret = mmc_resume_host(mmc); |
1460 | } | 1539 | } |
1461 | 1540 | ||
1462 | return ret; | 1541 | return ret; |
1463 | } | 1542 | } |
1464 | #else | ||
1465 | #define mmci_suspend NULL | ||
1466 | #define mmci_resume NULL | ||
1467 | #endif | 1543 | #endif |
1468 | 1544 | ||
1545 | static const struct dev_pm_ops mmci_dev_pm_ops = { | ||
1546 | SET_SYSTEM_SLEEP_PM_OPS(mmci_suspend, mmci_resume) | ||
1547 | }; | ||
1548 | |||
1469 | static struct amba_id mmci_ids[] = { | 1549 | static struct amba_id mmci_ids[] = { |
1470 | { | 1550 | { |
1471 | .id = 0x00041180, | 1551 | .id = 0x00041180, |
@@ -1511,26 +1591,15 @@ MODULE_DEVICE_TABLE(amba, mmci_ids); | |||
1511 | static struct amba_driver mmci_driver = { | 1591 | static struct amba_driver mmci_driver = { |
1512 | .drv = { | 1592 | .drv = { |
1513 | .name = DRIVER_NAME, | 1593 | .name = DRIVER_NAME, |
1594 | .pm = &mmci_dev_pm_ops, | ||
1514 | }, | 1595 | }, |
1515 | .probe = mmci_probe, | 1596 | .probe = mmci_probe, |
1516 | .remove = __devexit_p(mmci_remove), | 1597 | .remove = __devexit_p(mmci_remove), |
1517 | .suspend = mmci_suspend, | ||
1518 | .resume = mmci_resume, | ||
1519 | .id_table = mmci_ids, | 1598 | .id_table = mmci_ids, |
1520 | }; | 1599 | }; |
1521 | 1600 | ||
1522 | static int __init mmci_init(void) | 1601 | module_amba_driver(mmci_driver); |
1523 | { | ||
1524 | return amba_driver_register(&mmci_driver); | ||
1525 | } | ||
1526 | |||
1527 | static void __exit mmci_exit(void) | ||
1528 | { | ||
1529 | amba_driver_unregister(&mmci_driver); | ||
1530 | } | ||
1531 | 1602 | ||
1532 | module_init(mmci_init); | ||
1533 | module_exit(mmci_exit); | ||
1534 | module_param(fmax, uint, 0444); | 1603 | module_param(fmax, uint, 0444); |
1535 | 1604 | ||
1536 | MODULE_DESCRIPTION("ARM PrimeCell PL180/181 Multimedia Card Interface driver"); | 1605 | MODULE_DESCRIPTION("ARM PrimeCell PL180/181 Multimedia Card Interface driver"); |
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h index 79e4143ab9df..d437ccf62d6b 100644 --- a/drivers/mmc/host/mmci.h +++ b/drivers/mmc/host/mmci.h | |||
@@ -13,16 +13,6 @@ | |||
13 | #define MCI_PWR_ON 0x03 | 13 | #define MCI_PWR_ON 0x03 |
14 | #define MCI_OD (1 << 6) | 14 | #define MCI_OD (1 << 6) |
15 | #define MCI_ROD (1 << 7) | 15 | #define MCI_ROD (1 << 7) |
16 | /* | ||
17 | * The ST Micro version does not have ROD and reuse the voltage registers | ||
18 | * for direction settings | ||
19 | */ | ||
20 | #define MCI_ST_DATA2DIREN (1 << 2) | ||
21 | #define MCI_ST_CMDDIREN (1 << 3) | ||
22 | #define MCI_ST_DATA0DIREN (1 << 4) | ||
23 | #define MCI_ST_DATA31DIREN (1 << 5) | ||
24 | #define MCI_ST_FBCLKEN (1 << 7) | ||
25 | #define MCI_ST_DATA74DIREN (1 << 8) | ||
26 | 16 | ||
27 | #define MMCICLOCK 0x004 | 17 | #define MMCICLOCK 0x004 |
28 | #define MCI_CLK_ENABLE (1 << 8) | 18 | #define MCI_CLK_ENABLE (1 << 8) |
@@ -160,7 +150,7 @@ | |||
160 | (MCI_RXFIFOHALFFULLMASK | MCI_RXDATAAVLBLMASK | \ | 150 | (MCI_RXFIFOHALFFULLMASK | MCI_RXDATAAVLBLMASK | \ |
161 | MCI_TXFIFOHALFEMPTYMASK) | 151 | MCI_TXFIFOHALFEMPTYMASK) |
162 | 152 | ||
163 | #define NR_SG 16 | 153 | #define NR_SG 128 |
164 | 154 | ||
165 | struct clk; | 155 | struct clk; |
166 | struct variant_data; | 156 | struct variant_data; |
@@ -189,7 +179,8 @@ struct mmci_host { | |||
189 | 179 | ||
190 | unsigned int mclk; | 180 | unsigned int mclk; |
191 | unsigned int cclk; | 181 | unsigned int cclk; |
192 | u32 pwr; | 182 | u32 pwr_reg; |
183 | u32 clk_reg; | ||
193 | struct mmci_platform_data *plat; | 184 | struct mmci_platform_data *plat; |
194 | struct variant_data *variant; | 185 | struct variant_data *variant; |
195 | 186 | ||
diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c index 4184b7946bbf..b2058b432320 100644 --- a/drivers/mmc/host/mxcmmc.c +++ b/drivers/mmc/host/mxcmmc.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/gpio.h> | 33 | #include <linux/gpio.h> |
34 | #include <linux/regulator/consumer.h> | 34 | #include <linux/regulator/consumer.h> |
35 | #include <linux/dmaengine.h> | 35 | #include <linux/dmaengine.h> |
36 | #include <linux/types.h> | ||
36 | 37 | ||
37 | #include <asm/dma.h> | 38 | #include <asm/dma.h> |
38 | #include <asm/irq.h> | 39 | #include <asm/irq.h> |
@@ -254,7 +255,7 @@ static int mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data) | |||
254 | if (nents != data->sg_len) | 255 | if (nents != data->sg_len) |
255 | return -EINVAL; | 256 | return -EINVAL; |
256 | 257 | ||
257 | host->desc = host->dma->device->device_prep_slave_sg(host->dma, | 258 | host->desc = dmaengine_prep_slave_sg(host->dma, |
258 | data->sg, data->sg_len, slave_dirn, | 259 | data->sg, data->sg_len, slave_dirn, |
259 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | 260 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
260 | 261 | ||
@@ -267,6 +268,7 @@ static int mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data) | |||
267 | wmb(); | 268 | wmb(); |
268 | 269 | ||
269 | dmaengine_submit(host->desc); | 270 | dmaengine_submit(host->desc); |
271 | dma_async_issue_pending(host->dma); | ||
270 | 272 | ||
271 | return 0; | 273 | return 0; |
272 | } | 274 | } |
@@ -710,6 +712,7 @@ static int mxcmci_setup_dma(struct mmc_host *mmc) | |||
710 | config->src_addr_width = 4; | 712 | config->src_addr_width = 4; |
711 | config->dst_maxburst = host->burstlen; | 713 | config->dst_maxburst = host->burstlen; |
712 | config->src_maxburst = host->burstlen; | 714 | config->src_maxburst = host->burstlen; |
715 | config->device_fc = false; | ||
713 | 716 | ||
714 | return dmaengine_slave_config(host->dma, config); | 717 | return dmaengine_slave_config(host->dma, config); |
715 | } | 718 | } |
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c index 382c835d217c..b0f2ef988188 100644 --- a/drivers/mmc/host/mxs-mmc.c +++ b/drivers/mmc/host/mxs-mmc.c | |||
@@ -38,10 +38,10 @@ | |||
38 | #include <linux/gpio.h> | 38 | #include <linux/gpio.h> |
39 | #include <linux/regulator/consumer.h> | 39 | #include <linux/regulator/consumer.h> |
40 | #include <linux/module.h> | 40 | #include <linux/module.h> |
41 | #include <linux/fsl/mxs-dma.h> | ||
41 | 42 | ||
42 | #include <mach/mxs.h> | 43 | #include <mach/mxs.h> |
43 | #include <mach/common.h> | 44 | #include <mach/common.h> |
44 | #include <mach/dma.h> | ||
45 | #include <mach/mmc.h> | 45 | #include <mach/mmc.h> |
46 | 46 | ||
47 | #define DRIVER_NAME "mxs-mmc" | 47 | #define DRIVER_NAME "mxs-mmc" |
@@ -305,7 +305,7 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void *dev_id) | |||
305 | } | 305 | } |
306 | 306 | ||
307 | static struct dma_async_tx_descriptor *mxs_mmc_prep_dma( | 307 | static struct dma_async_tx_descriptor *mxs_mmc_prep_dma( |
308 | struct mxs_mmc_host *host, unsigned int append) | 308 | struct mxs_mmc_host *host, unsigned long flags) |
309 | { | 309 | { |
310 | struct dma_async_tx_descriptor *desc; | 310 | struct dma_async_tx_descriptor *desc; |
311 | struct mmc_data *data = host->data; | 311 | struct mmc_data *data = host->data; |
@@ -324,8 +324,8 @@ static struct dma_async_tx_descriptor *mxs_mmc_prep_dma( | |||
324 | sg_len = SSP_PIO_NUM; | 324 | sg_len = SSP_PIO_NUM; |
325 | } | 325 | } |
326 | 326 | ||
327 | desc = host->dmach->device->device_prep_slave_sg(host->dmach, | 327 | desc = dmaengine_prep_slave_sg(host->dmach, |
328 | sgl, sg_len, host->slave_dirn, append); | 328 | sgl, sg_len, host->slave_dirn, flags); |
329 | if (desc) { | 329 | if (desc) { |
330 | desc->callback = mxs_mmc_dma_irq_callback; | 330 | desc->callback = mxs_mmc_dma_irq_callback; |
331 | desc->callback_param = host; | 331 | desc->callback_param = host; |
@@ -358,7 +358,7 @@ static void mxs_mmc_bc(struct mxs_mmc_host *host) | |||
358 | host->ssp_pio_words[2] = cmd1; | 358 | host->ssp_pio_words[2] = cmd1; |
359 | host->dma_dir = DMA_NONE; | 359 | host->dma_dir = DMA_NONE; |
360 | host->slave_dirn = DMA_TRANS_NONE; | 360 | host->slave_dirn = DMA_TRANS_NONE; |
361 | desc = mxs_mmc_prep_dma(host, 0); | 361 | desc = mxs_mmc_prep_dma(host, DMA_CTRL_ACK); |
362 | if (!desc) | 362 | if (!desc) |
363 | goto out; | 363 | goto out; |
364 | 364 | ||
@@ -398,7 +398,7 @@ static void mxs_mmc_ac(struct mxs_mmc_host *host) | |||
398 | host->ssp_pio_words[2] = cmd1; | 398 | host->ssp_pio_words[2] = cmd1; |
399 | host->dma_dir = DMA_NONE; | 399 | host->dma_dir = DMA_NONE; |
400 | host->slave_dirn = DMA_TRANS_NONE; | 400 | host->slave_dirn = DMA_TRANS_NONE; |
401 | desc = mxs_mmc_prep_dma(host, 0); | 401 | desc = mxs_mmc_prep_dma(host, DMA_CTRL_ACK); |
402 | if (!desc) | 402 | if (!desc) |
403 | goto out; | 403 | goto out; |
404 | 404 | ||
@@ -526,7 +526,7 @@ static void mxs_mmc_adtc(struct mxs_mmc_host *host) | |||
526 | host->data = data; | 526 | host->data = data; |
527 | host->dma_dir = dma_data_dir; | 527 | host->dma_dir = dma_data_dir; |
528 | host->slave_dirn = slave_dirn; | 528 | host->slave_dirn = slave_dirn; |
529 | desc = mxs_mmc_prep_dma(host, 1); | 529 | desc = mxs_mmc_prep_dma(host, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
530 | if (!desc) | 530 | if (!desc) |
531 | goto out; | 531 | goto out; |
532 | 532 | ||
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index fd0c661bbad3..56d4499d4388 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c | |||
@@ -26,6 +26,9 @@ | |||
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/timer.h> | 27 | #include <linux/timer.h> |
28 | #include <linux/clk.h> | 28 | #include <linux/clk.h> |
29 | #include <linux/of.h> | ||
30 | #include <linux/of_gpio.h> | ||
31 | #include <linux/of_device.h> | ||
29 | #include <linux/mmc/host.h> | 32 | #include <linux/mmc/host.h> |
30 | #include <linux/mmc/core.h> | 33 | #include <linux/mmc/core.h> |
31 | #include <linux/mmc/mmc.h> | 34 | #include <linux/mmc/mmc.h> |
@@ -106,17 +109,6 @@ | |||
106 | #define SOFTRESET (1 << 1) | 109 | #define SOFTRESET (1 << 1) |
107 | #define RESETDONE (1 << 0) | 110 | #define RESETDONE (1 << 0) |
108 | 111 | ||
109 | /* | ||
110 | * FIXME: Most likely all the data using these _DEVID defines should come | ||
111 | * from the platform_data, or implemented in controller and slot specific | ||
112 | * functions. | ||
113 | */ | ||
114 | #define OMAP_MMC1_DEVID 0 | ||
115 | #define OMAP_MMC2_DEVID 1 | ||
116 | #define OMAP_MMC3_DEVID 2 | ||
117 | #define OMAP_MMC4_DEVID 3 | ||
118 | #define OMAP_MMC5_DEVID 4 | ||
119 | |||
120 | #define MMC_AUTOSUSPEND_DELAY 100 | 112 | #define MMC_AUTOSUSPEND_DELAY 100 |
121 | #define MMC_TIMEOUT_MS 20 | 113 | #define MMC_TIMEOUT_MS 20 |
122 | #define OMAP_MMC_MIN_CLOCK 400000 | 114 | #define OMAP_MMC_MIN_CLOCK 400000 |
@@ -164,7 +156,6 @@ struct omap_hsmmc_host { | |||
164 | void __iomem *base; | 156 | void __iomem *base; |
165 | resource_size_t mapbase; | 157 | resource_size_t mapbase; |
166 | spinlock_t irq_lock; /* Prevent races with irq handler */ | 158 | spinlock_t irq_lock; /* Prevent races with irq handler */ |
167 | unsigned int id; | ||
168 | unsigned int dma_len; | 159 | unsigned int dma_len; |
169 | unsigned int dma_sg_idx; | 160 | unsigned int dma_sg_idx; |
170 | unsigned char bus_mode; | 161 | unsigned char bus_mode; |
@@ -179,7 +170,6 @@ struct omap_hsmmc_host { | |||
179 | int got_dbclk; | 170 | int got_dbclk; |
180 | int response_busy; | 171 | int response_busy; |
181 | int context_loss; | 172 | int context_loss; |
182 | int dpm_state; | ||
183 | int vdd; | 173 | int vdd; |
184 | int protect_card; | 174 | int protect_card; |
185 | int reqs_blocked; | 175 | int reqs_blocked; |
@@ -241,28 +231,7 @@ static int omap_hsmmc_resume_cdirq(struct device *dev, int slot) | |||
241 | 231 | ||
242 | #ifdef CONFIG_REGULATOR | 232 | #ifdef CONFIG_REGULATOR |
243 | 233 | ||
244 | static int omap_hsmmc_1_set_power(struct device *dev, int slot, int power_on, | 234 | static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on, |
245 | int vdd) | ||
246 | { | ||
247 | struct omap_hsmmc_host *host = | ||
248 | platform_get_drvdata(to_platform_device(dev)); | ||
249 | int ret; | ||
250 | |||
251 | if (mmc_slot(host).before_set_reg) | ||
252 | mmc_slot(host).before_set_reg(dev, slot, power_on, vdd); | ||
253 | |||
254 | if (power_on) | ||
255 | ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd); | ||
256 | else | ||
257 | ret = mmc_regulator_set_ocr(host->mmc, host->vcc, 0); | ||
258 | |||
259 | if (mmc_slot(host).after_set_reg) | ||
260 | mmc_slot(host).after_set_reg(dev, slot, power_on, vdd); | ||
261 | |||
262 | return ret; | ||
263 | } | ||
264 | |||
265 | static int omap_hsmmc_235_set_power(struct device *dev, int slot, int power_on, | ||
266 | int vdd) | 235 | int vdd) |
267 | { | 236 | { |
268 | struct omap_hsmmc_host *host = | 237 | struct omap_hsmmc_host *host = |
@@ -275,6 +244,13 @@ static int omap_hsmmc_235_set_power(struct device *dev, int slot, int power_on, | |||
275 | */ | 244 | */ |
276 | if (!host->vcc) | 245 | if (!host->vcc) |
277 | return 0; | 246 | return 0; |
247 | /* | ||
248 | * With DT, never turn OFF the regulator. This is because | ||
249 | * the pbias cell programming support is still missing when | ||
250 | * booting with Device tree | ||
251 | */ | ||
252 | if (dev->of_node && !vdd) | ||
253 | return 0; | ||
278 | 254 | ||
279 | if (mmc_slot(host).before_set_reg) | 255 | if (mmc_slot(host).before_set_reg) |
280 | mmc_slot(host).before_set_reg(dev, slot, power_on, vdd); | 256 | mmc_slot(host).before_set_reg(dev, slot, power_on, vdd); |
@@ -318,106 +294,16 @@ static int omap_hsmmc_235_set_power(struct device *dev, int slot, int power_on, | |||
318 | return ret; | 294 | return ret; |
319 | } | 295 | } |
320 | 296 | ||
321 | static int omap_hsmmc_4_set_power(struct device *dev, int slot, int power_on, | ||
322 | int vdd) | ||
323 | { | ||
324 | return 0; | ||
325 | } | ||
326 | |||
327 | static int omap_hsmmc_1_set_sleep(struct device *dev, int slot, int sleep, | ||
328 | int vdd, int cardsleep) | ||
329 | { | ||
330 | struct omap_hsmmc_host *host = | ||
331 | platform_get_drvdata(to_platform_device(dev)); | ||
332 | int mode = sleep ? REGULATOR_MODE_STANDBY : REGULATOR_MODE_NORMAL; | ||
333 | |||
334 | return regulator_set_mode(host->vcc, mode); | ||
335 | } | ||
336 | |||
337 | static int omap_hsmmc_235_set_sleep(struct device *dev, int slot, int sleep, | ||
338 | int vdd, int cardsleep) | ||
339 | { | ||
340 | struct omap_hsmmc_host *host = | ||
341 | platform_get_drvdata(to_platform_device(dev)); | ||
342 | int err, mode; | ||
343 | |||
344 | /* | ||
345 | * If we don't see a Vcc regulator, assume it's a fixed | ||
346 | * voltage always-on regulator. | ||
347 | */ | ||
348 | if (!host->vcc) | ||
349 | return 0; | ||
350 | |||
351 | mode = sleep ? REGULATOR_MODE_STANDBY : REGULATOR_MODE_NORMAL; | ||
352 | |||
353 | if (!host->vcc_aux) | ||
354 | return regulator_set_mode(host->vcc, mode); | ||
355 | |||
356 | if (cardsleep) { | ||
357 | /* VCC can be turned off if card is asleep */ | ||
358 | if (sleep) | ||
359 | err = mmc_regulator_set_ocr(host->mmc, host->vcc, 0); | ||
360 | else | ||
361 | err = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd); | ||
362 | } else | ||
363 | err = regulator_set_mode(host->vcc, mode); | ||
364 | if (err) | ||
365 | return err; | ||
366 | |||
367 | if (!mmc_slot(host).vcc_aux_disable_is_sleep) | ||
368 | return regulator_set_mode(host->vcc_aux, mode); | ||
369 | |||
370 | if (sleep) | ||
371 | return regulator_disable(host->vcc_aux); | ||
372 | else | ||
373 | return regulator_enable(host->vcc_aux); | ||
374 | } | ||
375 | |||
376 | static int omap_hsmmc_4_set_sleep(struct device *dev, int slot, int sleep, | ||
377 | int vdd, int cardsleep) | ||
378 | { | ||
379 | return 0; | ||
380 | } | ||
381 | |||
382 | static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) | 297 | static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) |
383 | { | 298 | { |
384 | struct regulator *reg; | 299 | struct regulator *reg; |
385 | int ret = 0; | ||
386 | int ocr_value = 0; | 300 | int ocr_value = 0; |
387 | 301 | ||
388 | switch (host->id) { | 302 | mmc_slot(host).set_power = omap_hsmmc_set_power; |
389 | case OMAP_MMC1_DEVID: | ||
390 | /* On-chip level shifting via PBIAS0/PBIAS1 */ | ||
391 | mmc_slot(host).set_power = omap_hsmmc_1_set_power; | ||
392 | mmc_slot(host).set_sleep = omap_hsmmc_1_set_sleep; | ||
393 | break; | ||
394 | case OMAP_MMC2_DEVID: | ||
395 | case OMAP_MMC3_DEVID: | ||
396 | case OMAP_MMC5_DEVID: | ||
397 | /* Off-chip level shifting, or none */ | ||
398 | mmc_slot(host).set_power = omap_hsmmc_235_set_power; | ||
399 | mmc_slot(host).set_sleep = omap_hsmmc_235_set_sleep; | ||
400 | break; | ||
401 | case OMAP_MMC4_DEVID: | ||
402 | mmc_slot(host).set_power = omap_hsmmc_4_set_power; | ||
403 | mmc_slot(host).set_sleep = omap_hsmmc_4_set_sleep; | ||
404 | default: | ||
405 | pr_err("MMC%d configuration not supported!\n", host->id); | ||
406 | return -EINVAL; | ||
407 | } | ||
408 | 303 | ||
409 | reg = regulator_get(host->dev, "vmmc"); | 304 | reg = regulator_get(host->dev, "vmmc"); |
410 | if (IS_ERR(reg)) { | 305 | if (IS_ERR(reg)) { |
411 | dev_dbg(host->dev, "vmmc regulator missing\n"); | 306 | dev_dbg(host->dev, "vmmc regulator missing\n"); |
412 | /* | ||
413 | * HACK: until fixed.c regulator is usable, | ||
414 | * we don't require a main regulator | ||
415 | * for MMC2 or MMC3 | ||
416 | */ | ||
417 | if (host->id == OMAP_MMC1_DEVID) { | ||
418 | ret = PTR_ERR(reg); | ||
419 | goto err; | ||
420 | } | ||
421 | } else { | 307 | } else { |
422 | host->vcc = reg; | 308 | host->vcc = reg; |
423 | ocr_value = mmc_regulator_get_ocrmask(reg); | 309 | ocr_value = mmc_regulator_get_ocrmask(reg); |
@@ -425,8 +311,8 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) | |||
425 | mmc_slot(host).ocr_mask = ocr_value; | 311 | mmc_slot(host).ocr_mask = ocr_value; |
426 | } else { | 312 | } else { |
427 | if (!(mmc_slot(host).ocr_mask & ocr_value)) { | 313 | if (!(mmc_slot(host).ocr_mask & ocr_value)) { |
428 | pr_err("MMC%d ocrmask %x is not supported\n", | 314 | dev_err(host->dev, "ocrmask %x is not supported\n", |
429 | host->id, mmc_slot(host).ocr_mask); | 315 | mmc_slot(host).ocr_mask); |
430 | mmc_slot(host).ocr_mask = 0; | 316 | mmc_slot(host).ocr_mask = 0; |
431 | return -EINVAL; | 317 | return -EINVAL; |
432 | } | 318 | } |
@@ -459,11 +345,6 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) | |||
459 | } | 345 | } |
460 | 346 | ||
461 | return 0; | 347 | return 0; |
462 | |||
463 | err: | ||
464 | mmc_slot(host).set_power = NULL; | ||
465 | mmc_slot(host).set_sleep = NULL; | ||
466 | return ret; | ||
467 | } | 348 | } |
468 | 349 | ||
469 | static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host) | 350 | static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host) |
@@ -471,7 +352,6 @@ static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host) | |||
471 | regulator_put(host->vcc); | 352 | regulator_put(host->vcc); |
472 | regulator_put(host->vcc_aux); | 353 | regulator_put(host->vcc_aux); |
473 | mmc_slot(host).set_power = NULL; | 354 | mmc_slot(host).set_power = NULL; |
474 | mmc_slot(host).set_sleep = NULL; | ||
475 | } | 355 | } |
476 | 356 | ||
477 | static inline int omap_hsmmc_have_reg(void) | 357 | static inline int omap_hsmmc_have_reg(void) |
@@ -710,7 +590,7 @@ static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host) | |||
710 | OMAP_HSMMC_WRITE(host->base, SYSCONFIG, | 590 | OMAP_HSMMC_WRITE(host->base, SYSCONFIG, |
711 | OMAP_HSMMC_READ(host->base, SYSCONFIG) | AUTOIDLE); | 591 | OMAP_HSMMC_READ(host->base, SYSCONFIG) | AUTOIDLE); |
712 | 592 | ||
713 | if (host->id == OMAP_MMC1_DEVID) { | 593 | if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { |
714 | if (host->power_mode != MMC_POWER_OFF && | 594 | if (host->power_mode != MMC_POWER_OFF && |
715 | (1 << ios->vdd) <= MMC_VDD_23_24) | 595 | (1 << ios->vdd) <= MMC_VDD_23_24) |
716 | hctl = SDVS18; | 596 | hctl = SDVS18; |
@@ -1261,14 +1141,14 @@ static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host) | |||
1261 | host->reqs_blocked = 0; | 1141 | host->reqs_blocked = 0; |
1262 | if (mmc_slot(host).get_cover_state(host->dev, host->slot_id)) { | 1142 | if (mmc_slot(host).get_cover_state(host->dev, host->slot_id)) { |
1263 | if (host->protect_card) { | 1143 | if (host->protect_card) { |
1264 | pr_info("%s: cover is closed, " | 1144 | dev_info(host->dev, "%s: cover is closed, " |
1265 | "card is now accessible\n", | 1145 | "card is now accessible\n", |
1266 | mmc_hostname(host->mmc)); | 1146 | mmc_hostname(host->mmc)); |
1267 | host->protect_card = 0; | 1147 | host->protect_card = 0; |
1268 | } | 1148 | } |
1269 | } else { | 1149 | } else { |
1270 | if (!host->protect_card) { | 1150 | if (!host->protect_card) { |
1271 | pr_info("%s: cover is open, " | 1151 | dev_info(host->dev, "%s: cover is open, " |
1272 | "card is now inaccessible\n", | 1152 | "card is now inaccessible\n", |
1273 | mmc_hostname(host->mmc)); | 1153 | mmc_hostname(host->mmc)); |
1274 | host->protect_card = 1; | 1154 | host->protect_card = 1; |
@@ -1405,7 +1285,7 @@ static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host, | |||
1405 | 1285 | ||
1406 | if (!next && data->host_cookie && | 1286 | if (!next && data->host_cookie && |
1407 | data->host_cookie != host->next_data.cookie) { | 1287 | data->host_cookie != host->next_data.cookie) { |
1408 | pr_warning("[%s] invalid cookie: data->host_cookie %d" | 1288 | dev_warn(host->dev, "[%s] invalid cookie: data->host_cookie %d" |
1409 | " host->next_data.cookie %d\n", | 1289 | " host->next_data.cookie %d\n", |
1410 | __func__, data->host_cookie, host->next_data.cookie); | 1290 | __func__, data->host_cookie, host->next_data.cookie); |
1411 | data->host_cookie = 0; | 1291 | data->host_cookie = 0; |
@@ -1663,7 +1543,13 @@ static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
1663 | * of external transceiver; but they all handle 1.8V. | 1543 | * of external transceiver; but they all handle 1.8V. |
1664 | */ | 1544 | */ |
1665 | if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) && | 1545 | if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) && |
1666 | (ios->vdd == DUAL_VOLT_OCR_BIT)) { | 1546 | (ios->vdd == DUAL_VOLT_OCR_BIT) && |
1547 | /* | ||
1548 | * With pbias cell programming missing, this | ||
1549 | * can't be allowed when booting with device | ||
1550 | * tree. | ||
1551 | */ | ||
1552 | !host->dev->of_node) { | ||
1667 | /* | 1553 | /* |
1668 | * The mmc_select_voltage fn of the core does | 1554 | * The mmc_select_voltage fn of the core does |
1669 | * not seem to set the power_mode to | 1555 | * not seem to set the power_mode to |
@@ -1748,7 +1634,7 @@ static int omap_hsmmc_enable_fclk(struct mmc_host *mmc) | |||
1748 | return 0; | 1634 | return 0; |
1749 | } | 1635 | } |
1750 | 1636 | ||
1751 | static int omap_hsmmc_disable_fclk(struct mmc_host *mmc, int lazy) | 1637 | static int omap_hsmmc_disable_fclk(struct mmc_host *mmc) |
1752 | { | 1638 | { |
1753 | struct omap_hsmmc_host *host = mmc_priv(mmc); | 1639 | struct omap_hsmmc_host *host = mmc_priv(mmc); |
1754 | 1640 | ||
@@ -1782,15 +1668,8 @@ static int omap_hsmmc_regs_show(struct seq_file *s, void *data) | |||
1782 | if (host->pdata->get_context_loss_count) | 1668 | if (host->pdata->get_context_loss_count) |
1783 | context_loss = host->pdata->get_context_loss_count(host->dev); | 1669 | context_loss = host->pdata->get_context_loss_count(host->dev); |
1784 | 1670 | ||
1785 | seq_printf(s, "mmc%d:\n" | 1671 | seq_printf(s, "mmc%d:\n ctx_loss:\t%d:%d\n\nregs:\n", |
1786 | " enabled:\t%d\n" | 1672 | mmc->index, host->context_loss, context_loss); |
1787 | " dpm_state:\t%d\n" | ||
1788 | " nesting_cnt:\t%d\n" | ||
1789 | " ctx_loss:\t%d:%d\n" | ||
1790 | "\nregs:\n", | ||
1791 | mmc->index, mmc->enabled ? 1 : 0, | ||
1792 | host->dpm_state, mmc->nesting_cnt, | ||
1793 | host->context_loss, context_loss); | ||
1794 | 1673 | ||
1795 | if (host->suspended) { | 1674 | if (host->suspended) { |
1796 | seq_printf(s, "host suspended, can't read registers\n"); | 1675 | seq_printf(s, "host suspended, can't read registers\n"); |
@@ -1847,13 +1726,82 @@ static void omap_hsmmc_debugfs(struct mmc_host *mmc) | |||
1847 | 1726 | ||
1848 | #endif | 1727 | #endif |
1849 | 1728 | ||
1850 | static int __init omap_hsmmc_probe(struct platform_device *pdev) | 1729 | #ifdef CONFIG_OF |
1730 | static u16 omap4_reg_offset = 0x100; | ||
1731 | |||
1732 | static const struct of_device_id omap_mmc_of_match[] = { | ||
1733 | { | ||
1734 | .compatible = "ti,omap2-hsmmc", | ||
1735 | }, | ||
1736 | { | ||
1737 | .compatible = "ti,omap3-hsmmc", | ||
1738 | }, | ||
1739 | { | ||
1740 | .compatible = "ti,omap4-hsmmc", | ||
1741 | .data = &omap4_reg_offset, | ||
1742 | }, | ||
1743 | {}, | ||
1744 | }; | ||
1745 | MODULE_DEVICE_TABLE(of, omap_mmc_of_match); | ||
1746 | |||
1747 | static struct omap_mmc_platform_data *of_get_hsmmc_pdata(struct device *dev) | ||
1748 | { | ||
1749 | struct omap_mmc_platform_data *pdata; | ||
1750 | struct device_node *np = dev->of_node; | ||
1751 | u32 bus_width; | ||
1752 | |||
1753 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | ||
1754 | if (!pdata) | ||
1755 | return NULL; /* out of memory */ | ||
1756 | |||
1757 | if (of_find_property(np, "ti,dual-volt", NULL)) | ||
1758 | pdata->controller_flags |= OMAP_HSMMC_SUPPORTS_DUAL_VOLT; | ||
1759 | |||
1760 | /* This driver only supports 1 slot */ | ||
1761 | pdata->nr_slots = 1; | ||
1762 | pdata->slots[0].switch_pin = of_get_named_gpio(np, "cd-gpios", 0); | ||
1763 | pdata->slots[0].gpio_wp = of_get_named_gpio(np, "wp-gpios", 0); | ||
1764 | |||
1765 | if (of_find_property(np, "ti,non-removable", NULL)) { | ||
1766 | pdata->slots[0].nonremovable = true; | ||
1767 | pdata->slots[0].no_regulator_off_init = true; | ||
1768 | } | ||
1769 | of_property_read_u32(np, "ti,bus-width", &bus_width); | ||
1770 | if (bus_width == 4) | ||
1771 | pdata->slots[0].caps |= MMC_CAP_4_BIT_DATA; | ||
1772 | else if (bus_width == 8) | ||
1773 | pdata->slots[0].caps |= MMC_CAP_8_BIT_DATA; | ||
1774 | |||
1775 | if (of_find_property(np, "ti,needs-special-reset", NULL)) | ||
1776 | pdata->slots[0].features |= HSMMC_HAS_UPDATED_RESET; | ||
1777 | |||
1778 | return pdata; | ||
1779 | } | ||
1780 | #else | ||
1781 | static inline struct omap_mmc_platform_data | ||
1782 | *of_get_hsmmc_pdata(struct device *dev) | ||
1783 | { | ||
1784 | return NULL; | ||
1785 | } | ||
1786 | #endif | ||
1787 | |||
1788 | static int __devinit omap_hsmmc_probe(struct platform_device *pdev) | ||
1851 | { | 1789 | { |
1852 | struct omap_mmc_platform_data *pdata = pdev->dev.platform_data; | 1790 | struct omap_mmc_platform_data *pdata = pdev->dev.platform_data; |
1853 | struct mmc_host *mmc; | 1791 | struct mmc_host *mmc; |
1854 | struct omap_hsmmc_host *host = NULL; | 1792 | struct omap_hsmmc_host *host = NULL; |
1855 | struct resource *res; | 1793 | struct resource *res; |
1856 | int ret, irq; | 1794 | int ret, irq; |
1795 | const struct of_device_id *match; | ||
1796 | |||
1797 | match = of_match_device(of_match_ptr(omap_mmc_of_match), &pdev->dev); | ||
1798 | if (match) { | ||
1799 | pdata = of_get_hsmmc_pdata(&pdev->dev); | ||
1800 | if (match->data) { | ||
1801 | u16 *offsetp = match->data; | ||
1802 | pdata->reg_offset = *offsetp; | ||
1803 | } | ||
1804 | } | ||
1857 | 1805 | ||
1858 | if (pdata == NULL) { | 1806 | if (pdata == NULL) { |
1859 | dev_err(&pdev->dev, "Platform Data is missing\n"); | 1807 | dev_err(&pdev->dev, "Platform Data is missing\n"); |
@@ -1870,8 +1818,6 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1870 | if (res == NULL || irq < 0) | 1818 | if (res == NULL || irq < 0) |
1871 | return -ENXIO; | 1819 | return -ENXIO; |
1872 | 1820 | ||
1873 | res->start += pdata->reg_offset; | ||
1874 | res->end += pdata->reg_offset; | ||
1875 | res = request_mem_region(res->start, resource_size(res), pdev->name); | 1821 | res = request_mem_region(res->start, resource_size(res), pdev->name); |
1876 | if (res == NULL) | 1822 | if (res == NULL) |
1877 | return -EBUSY; | 1823 | return -EBUSY; |
@@ -1894,9 +1840,8 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1894 | host->dev->dma_mask = &pdata->dma_mask; | 1840 | host->dev->dma_mask = &pdata->dma_mask; |
1895 | host->dma_ch = -1; | 1841 | host->dma_ch = -1; |
1896 | host->irq = irq; | 1842 | host->irq = irq; |
1897 | host->id = pdev->id; | ||
1898 | host->slot_id = 0; | 1843 | host->slot_id = 0; |
1899 | host->mapbase = res->start; | 1844 | host->mapbase = res->start + pdata->reg_offset; |
1900 | host->base = ioremap(host->mapbase, SZ_4K); | 1845 | host->base = ioremap(host->mapbase, SZ_4K); |
1901 | host->power_mode = MMC_POWER_OFF; | 1846 | host->power_mode = MMC_POWER_OFF; |
1902 | host->next_data.cookie = 1; | 1847 | host->next_data.cookie = 1; |
@@ -1912,8 +1857,12 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1912 | if (mmc_slot(host).vcc_aux_disable_is_sleep) | 1857 | if (mmc_slot(host).vcc_aux_disable_is_sleep) |
1913 | mmc_slot(host).no_off = 1; | 1858 | mmc_slot(host).no_off = 1; |
1914 | 1859 | ||
1915 | mmc->f_min = OMAP_MMC_MIN_CLOCK; | 1860 | mmc->f_min = OMAP_MMC_MIN_CLOCK; |
1916 | mmc->f_max = OMAP_MMC_MAX_CLOCK; | 1861 | |
1862 | if (pdata->max_freq > 0) | ||
1863 | mmc->f_max = pdata->max_freq; | ||
1864 | else | ||
1865 | mmc->f_max = OMAP_MMC_MAX_CLOCK; | ||
1917 | 1866 | ||
1918 | spin_lock_init(&host->irq_lock); | 1867 | spin_lock_init(&host->irq_lock); |
1919 | 1868 | ||
@@ -1924,9 +1873,6 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1924 | goto err1; | 1873 | goto err1; |
1925 | } | 1874 | } |
1926 | 1875 | ||
1927 | omap_hsmmc_context_save(host); | ||
1928 | |||
1929 | mmc->caps |= MMC_CAP_DISABLE; | ||
1930 | if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) { | 1876 | if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) { |
1931 | dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n"); | 1877 | dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n"); |
1932 | mmc->caps2 |= MMC_CAP2_NO_MULTI_READ; | 1878 | mmc->caps2 |= MMC_CAP2_NO_MULTI_READ; |
@@ -1937,6 +1883,8 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1937 | pm_runtime_set_autosuspend_delay(host->dev, MMC_AUTOSUSPEND_DELAY); | 1883 | pm_runtime_set_autosuspend_delay(host->dev, MMC_AUTOSUSPEND_DELAY); |
1938 | pm_runtime_use_autosuspend(host->dev); | 1884 | pm_runtime_use_autosuspend(host->dev); |
1939 | 1885 | ||
1886 | omap_hsmmc_context_save(host); | ||
1887 | |||
1940 | if (cpu_is_omap2430()) { | 1888 | if (cpu_is_omap2430()) { |
1941 | host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck"); | 1889 | host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck"); |
1942 | /* | 1890 | /* |
@@ -1977,32 +1925,19 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1977 | 1925 | ||
1978 | omap_hsmmc_conf_bus_power(host); | 1926 | omap_hsmmc_conf_bus_power(host); |
1979 | 1927 | ||
1980 | /* Select DMA lines */ | 1928 | res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx"); |
1981 | switch (host->id) { | 1929 | if (!res) { |
1982 | case OMAP_MMC1_DEVID: | 1930 | dev_err(mmc_dev(host->mmc), "cannot get DMA TX channel\n"); |
1983 | host->dma_line_tx = OMAP24XX_DMA_MMC1_TX; | ||
1984 | host->dma_line_rx = OMAP24XX_DMA_MMC1_RX; | ||
1985 | break; | ||
1986 | case OMAP_MMC2_DEVID: | ||
1987 | host->dma_line_tx = OMAP24XX_DMA_MMC2_TX; | ||
1988 | host->dma_line_rx = OMAP24XX_DMA_MMC2_RX; | ||
1989 | break; | ||
1990 | case OMAP_MMC3_DEVID: | ||
1991 | host->dma_line_tx = OMAP34XX_DMA_MMC3_TX; | ||
1992 | host->dma_line_rx = OMAP34XX_DMA_MMC3_RX; | ||
1993 | break; | ||
1994 | case OMAP_MMC4_DEVID: | ||
1995 | host->dma_line_tx = OMAP44XX_DMA_MMC4_TX; | ||
1996 | host->dma_line_rx = OMAP44XX_DMA_MMC4_RX; | ||
1997 | break; | ||
1998 | case OMAP_MMC5_DEVID: | ||
1999 | host->dma_line_tx = OMAP44XX_DMA_MMC5_TX; | ||
2000 | host->dma_line_rx = OMAP44XX_DMA_MMC5_RX; | ||
2001 | break; | ||
2002 | default: | ||
2003 | dev_err(mmc_dev(host->mmc), "Invalid MMC id\n"); | ||
2004 | goto err_irq; | 1931 | goto err_irq; |
2005 | } | 1932 | } |
1933 | host->dma_line_tx = res->start; | ||
1934 | |||
1935 | res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx"); | ||
1936 | if (!res) { | ||
1937 | dev_err(mmc_dev(host->mmc), "cannot get DMA RX channel\n"); | ||
1938 | goto err_irq; | ||
1939 | } | ||
1940 | host->dma_line_rx = res->start; | ||
2006 | 1941 | ||
2007 | /* Request IRQ for MMC operations */ | 1942 | /* Request IRQ for MMC operations */ |
2008 | ret = request_irq(host->irq, omap_hsmmc_irq, 0, | 1943 | ret = request_irq(host->irq, omap_hsmmc_irq, 0, |
@@ -2081,8 +2016,8 @@ err_reg: | |||
2081 | err_irq_cd_init: | 2016 | err_irq_cd_init: |
2082 | free_irq(host->irq, host); | 2017 | free_irq(host->irq, host); |
2083 | err_irq: | 2018 | err_irq: |
2084 | pm_runtime_mark_last_busy(host->dev); | 2019 | pm_runtime_put_sync(host->dev); |
2085 | pm_runtime_put_autosuspend(host->dev); | 2020 | pm_runtime_disable(host->dev); |
2086 | clk_put(host->fclk); | 2021 | clk_put(host->fclk); |
2087 | if (host->got_dbclk) { | 2022 | if (host->got_dbclk) { |
2088 | clk_disable(host->dbclk); | 2023 | clk_disable(host->dbclk); |
@@ -2099,35 +2034,33 @@ err: | |||
2099 | return ret; | 2034 | return ret; |
2100 | } | 2035 | } |
2101 | 2036 | ||
2102 | static int omap_hsmmc_remove(struct platform_device *pdev) | 2037 | static int __devexit omap_hsmmc_remove(struct platform_device *pdev) |
2103 | { | 2038 | { |
2104 | struct omap_hsmmc_host *host = platform_get_drvdata(pdev); | 2039 | struct omap_hsmmc_host *host = platform_get_drvdata(pdev); |
2105 | struct resource *res; | 2040 | struct resource *res; |
2106 | 2041 | ||
2107 | if (host) { | 2042 | pm_runtime_get_sync(host->dev); |
2108 | pm_runtime_get_sync(host->dev); | 2043 | mmc_remove_host(host->mmc); |
2109 | mmc_remove_host(host->mmc); | 2044 | if (host->use_reg) |
2110 | if (host->use_reg) | 2045 | omap_hsmmc_reg_put(host); |
2111 | omap_hsmmc_reg_put(host); | 2046 | if (host->pdata->cleanup) |
2112 | if (host->pdata->cleanup) | 2047 | host->pdata->cleanup(&pdev->dev); |
2113 | host->pdata->cleanup(&pdev->dev); | 2048 | free_irq(host->irq, host); |
2114 | free_irq(host->irq, host); | 2049 | if (mmc_slot(host).card_detect_irq) |
2115 | if (mmc_slot(host).card_detect_irq) | 2050 | free_irq(mmc_slot(host).card_detect_irq, host); |
2116 | free_irq(mmc_slot(host).card_detect_irq, host); | ||
2117 | |||
2118 | pm_runtime_put_sync(host->dev); | ||
2119 | pm_runtime_disable(host->dev); | ||
2120 | clk_put(host->fclk); | ||
2121 | if (host->got_dbclk) { | ||
2122 | clk_disable(host->dbclk); | ||
2123 | clk_put(host->dbclk); | ||
2124 | } | ||
2125 | 2051 | ||
2126 | mmc_free_host(host->mmc); | 2052 | pm_runtime_put_sync(host->dev); |
2127 | iounmap(host->base); | 2053 | pm_runtime_disable(host->dev); |
2128 | omap_hsmmc_gpio_free(pdev->dev.platform_data); | 2054 | clk_put(host->fclk); |
2055 | if (host->got_dbclk) { | ||
2056 | clk_disable(host->dbclk); | ||
2057 | clk_put(host->dbclk); | ||
2129 | } | 2058 | } |
2130 | 2059 | ||
2060 | mmc_free_host(host->mmc); | ||
2061 | iounmap(host->base); | ||
2062 | omap_hsmmc_gpio_free(pdev->dev.platform_data); | ||
2063 | |||
2131 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 2064 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
2132 | if (res) | 2065 | if (res) |
2133 | release_mem_region(res->start, resource_size(res)); | 2066 | release_mem_region(res->start, resource_size(res)); |
@@ -2140,49 +2073,45 @@ static int omap_hsmmc_remove(struct platform_device *pdev) | |||
2140 | static int omap_hsmmc_suspend(struct device *dev) | 2073 | static int omap_hsmmc_suspend(struct device *dev) |
2141 | { | 2074 | { |
2142 | int ret = 0; | 2075 | int ret = 0; |
2143 | struct platform_device *pdev = to_platform_device(dev); | 2076 | struct omap_hsmmc_host *host = dev_get_drvdata(dev); |
2144 | struct omap_hsmmc_host *host = platform_get_drvdata(pdev); | ||
2145 | 2077 | ||
2146 | if (host && host->suspended) | 2078 | if (!host) |
2147 | return 0; | 2079 | return 0; |
2148 | 2080 | ||
2149 | if (host) { | 2081 | if (host && host->suspended) |
2150 | pm_runtime_get_sync(host->dev); | 2082 | return 0; |
2151 | host->suspended = 1; | ||
2152 | if (host->pdata->suspend) { | ||
2153 | ret = host->pdata->suspend(&pdev->dev, | ||
2154 | host->slot_id); | ||
2155 | if (ret) { | ||
2156 | dev_dbg(mmc_dev(host->mmc), | ||
2157 | "Unable to handle MMC board" | ||
2158 | " level suspend\n"); | ||
2159 | host->suspended = 0; | ||
2160 | return ret; | ||
2161 | } | ||
2162 | } | ||
2163 | ret = mmc_suspend_host(host->mmc); | ||
2164 | 2083 | ||
2084 | pm_runtime_get_sync(host->dev); | ||
2085 | host->suspended = 1; | ||
2086 | if (host->pdata->suspend) { | ||
2087 | ret = host->pdata->suspend(dev, host->slot_id); | ||
2165 | if (ret) { | 2088 | if (ret) { |
2089 | dev_dbg(dev, "Unable to handle MMC board" | ||
2090 | " level suspend\n"); | ||
2166 | host->suspended = 0; | 2091 | host->suspended = 0; |
2167 | if (host->pdata->resume) { | 2092 | return ret; |
2168 | ret = host->pdata->resume(&pdev->dev, | ||
2169 | host->slot_id); | ||
2170 | if (ret) | ||
2171 | dev_dbg(mmc_dev(host->mmc), | ||
2172 | "Unmask interrupt failed\n"); | ||
2173 | } | ||
2174 | goto err; | ||
2175 | } | 2093 | } |
2094 | } | ||
2095 | ret = mmc_suspend_host(host->mmc); | ||
2176 | 2096 | ||
2177 | if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) { | 2097 | if (ret) { |
2178 | omap_hsmmc_disable_irq(host); | 2098 | host->suspended = 0; |
2179 | OMAP_HSMMC_WRITE(host->base, HCTL, | 2099 | if (host->pdata->resume) { |
2180 | OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP); | 2100 | ret = host->pdata->resume(dev, host->slot_id); |
2101 | if (ret) | ||
2102 | dev_dbg(dev, "Unmask interrupt failed\n"); | ||
2181 | } | 2103 | } |
2182 | if (host->got_dbclk) | 2104 | goto err; |
2183 | clk_disable(host->dbclk); | 2105 | } |
2184 | 2106 | ||
2107 | if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) { | ||
2108 | omap_hsmmc_disable_irq(host); | ||
2109 | OMAP_HSMMC_WRITE(host->base, HCTL, | ||
2110 | OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP); | ||
2185 | } | 2111 | } |
2112 | |||
2113 | if (host->got_dbclk) | ||
2114 | clk_disable(host->dbclk); | ||
2186 | err: | 2115 | err: |
2187 | pm_runtime_put_sync(host->dev); | 2116 | pm_runtime_put_sync(host->dev); |
2188 | return ret; | 2117 | return ret; |
@@ -2192,38 +2121,37 @@ err: | |||
2192 | static int omap_hsmmc_resume(struct device *dev) | 2121 | static int omap_hsmmc_resume(struct device *dev) |
2193 | { | 2122 | { |
2194 | int ret = 0; | 2123 | int ret = 0; |
2195 | struct platform_device *pdev = to_platform_device(dev); | 2124 | struct omap_hsmmc_host *host = dev_get_drvdata(dev); |
2196 | struct omap_hsmmc_host *host = platform_get_drvdata(pdev); | 2125 | |
2126 | if (!host) | ||
2127 | return 0; | ||
2197 | 2128 | ||
2198 | if (host && !host->suspended) | 2129 | if (host && !host->suspended) |
2199 | return 0; | 2130 | return 0; |
2200 | 2131 | ||
2201 | if (host) { | 2132 | pm_runtime_get_sync(host->dev); |
2202 | pm_runtime_get_sync(host->dev); | ||
2203 | 2133 | ||
2204 | if (host->got_dbclk) | 2134 | if (host->got_dbclk) |
2205 | clk_enable(host->dbclk); | 2135 | clk_enable(host->dbclk); |
2206 | 2136 | ||
2207 | if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) | 2137 | if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) |
2208 | omap_hsmmc_conf_bus_power(host); | 2138 | omap_hsmmc_conf_bus_power(host); |
2209 | 2139 | ||
2210 | if (host->pdata->resume) { | 2140 | if (host->pdata->resume) { |
2211 | ret = host->pdata->resume(&pdev->dev, host->slot_id); | 2141 | ret = host->pdata->resume(dev, host->slot_id); |
2212 | if (ret) | 2142 | if (ret) |
2213 | dev_dbg(mmc_dev(host->mmc), | 2143 | dev_dbg(dev, "Unmask interrupt failed\n"); |
2214 | "Unmask interrupt failed\n"); | 2144 | } |
2215 | } | ||
2216 | 2145 | ||
2217 | omap_hsmmc_protect_card(host); | 2146 | omap_hsmmc_protect_card(host); |
2218 | 2147 | ||
2219 | /* Notify the core to resume the host */ | 2148 | /* Notify the core to resume the host */ |
2220 | ret = mmc_resume_host(host->mmc); | 2149 | ret = mmc_resume_host(host->mmc); |
2221 | if (ret == 0) | 2150 | if (ret == 0) |
2222 | host->suspended = 0; | 2151 | host->suspended = 0; |
2223 | 2152 | ||
2224 | pm_runtime_mark_last_busy(host->dev); | 2153 | pm_runtime_mark_last_busy(host->dev); |
2225 | pm_runtime_put_autosuspend(host->dev); | 2154 | pm_runtime_put_autosuspend(host->dev); |
2226 | } | ||
2227 | 2155 | ||
2228 | return ret; | 2156 | return ret; |
2229 | 2157 | ||
@@ -2240,7 +2168,7 @@ static int omap_hsmmc_runtime_suspend(struct device *dev) | |||
2240 | 2168 | ||
2241 | host = platform_get_drvdata(to_platform_device(dev)); | 2169 | host = platform_get_drvdata(to_platform_device(dev)); |
2242 | omap_hsmmc_context_save(host); | 2170 | omap_hsmmc_context_save(host); |
2243 | dev_dbg(mmc_dev(host->mmc), "disabled\n"); | 2171 | dev_dbg(dev, "disabled\n"); |
2244 | 2172 | ||
2245 | return 0; | 2173 | return 0; |
2246 | } | 2174 | } |
@@ -2251,7 +2179,7 @@ static int omap_hsmmc_runtime_resume(struct device *dev) | |||
2251 | 2179 | ||
2252 | host = platform_get_drvdata(to_platform_device(dev)); | 2180 | host = platform_get_drvdata(to_platform_device(dev)); |
2253 | omap_hsmmc_context_restore(host); | 2181 | omap_hsmmc_context_restore(host); |
2254 | dev_dbg(mmc_dev(host->mmc), "enabled\n"); | 2182 | dev_dbg(dev, "enabled\n"); |
2255 | 2183 | ||
2256 | return 0; | 2184 | return 0; |
2257 | } | 2185 | } |
@@ -2264,29 +2192,17 @@ static struct dev_pm_ops omap_hsmmc_dev_pm_ops = { | |||
2264 | }; | 2192 | }; |
2265 | 2193 | ||
2266 | static struct platform_driver omap_hsmmc_driver = { | 2194 | static struct platform_driver omap_hsmmc_driver = { |
2267 | .remove = omap_hsmmc_remove, | 2195 | .probe = omap_hsmmc_probe, |
2196 | .remove = __devexit_p(omap_hsmmc_remove), | ||
2268 | .driver = { | 2197 | .driver = { |
2269 | .name = DRIVER_NAME, | 2198 | .name = DRIVER_NAME, |
2270 | .owner = THIS_MODULE, | 2199 | .owner = THIS_MODULE, |
2271 | .pm = &omap_hsmmc_dev_pm_ops, | 2200 | .pm = &omap_hsmmc_dev_pm_ops, |
2201 | .of_match_table = of_match_ptr(omap_mmc_of_match), | ||
2272 | }, | 2202 | }, |
2273 | }; | 2203 | }; |
2274 | 2204 | ||
2275 | static int __init omap_hsmmc_init(void) | 2205 | module_platform_driver(omap_hsmmc_driver); |
2276 | { | ||
2277 | /* Register the MMC driver */ | ||
2278 | return platform_driver_probe(&omap_hsmmc_driver, omap_hsmmc_probe); | ||
2279 | } | ||
2280 | |||
2281 | static void __exit omap_hsmmc_cleanup(void) | ||
2282 | { | ||
2283 | /* Unregister MMC driver */ | ||
2284 | platform_driver_unregister(&omap_hsmmc_driver); | ||
2285 | } | ||
2286 | |||
2287 | module_init(omap_hsmmc_init); | ||
2288 | module_exit(omap_hsmmc_cleanup); | ||
2289 | |||
2290 | MODULE_DESCRIPTION("OMAP High Speed Multimedia Card driver"); | 2206 | MODULE_DESCRIPTION("OMAP High Speed Multimedia Card driver"); |
2291 | MODULE_LICENSE("GPL"); | 2207 | MODULE_LICENSE("GPL"); |
2292 | MODULE_ALIAS("platform:" DRIVER_NAME); | 2208 | MODULE_ALIAS("platform:" DRIVER_NAME); |
diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c index 1bcfd6dbb5cc..c3622a69f432 100644 --- a/drivers/mmc/host/s3cmci.c +++ b/drivers/mmc/host/s3cmci.c | |||
@@ -1606,7 +1606,7 @@ static int __devinit s3cmci_probe(struct platform_device *pdev) | |||
1606 | host->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1606 | host->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1607 | if (!host->mem) { | 1607 | if (!host->mem) { |
1608 | dev_err(&pdev->dev, | 1608 | dev_err(&pdev->dev, |
1609 | "failed to get io memory region resouce.\n"); | 1609 | "failed to get io memory region resource.\n"); |
1610 | 1610 | ||
1611 | ret = -ENOENT; | 1611 | ret = -ENOENT; |
1612 | goto probe_free_gpio; | 1612 | goto probe_free_gpio; |
@@ -1630,7 +1630,7 @@ static int __devinit s3cmci_probe(struct platform_device *pdev) | |||
1630 | 1630 | ||
1631 | host->irq = platform_get_irq(pdev, 0); | 1631 | host->irq = platform_get_irq(pdev, 0); |
1632 | if (host->irq == 0) { | 1632 | if (host->irq == 0) { |
1633 | dev_err(&pdev->dev, "failed to get interrupt resouce.\n"); | 1633 | dev_err(&pdev->dev, "failed to get interrupt resource.\n"); |
1634 | ret = -EINVAL; | 1634 | ret = -EINVAL; |
1635 | goto probe_iounmap; | 1635 | goto probe_iounmap; |
1636 | } | 1636 | } |
diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c index 46fd1fd1b605..177f697b5835 100644 --- a/drivers/mmc/host/sdhci-dove.c +++ b/drivers/mmc/host/sdhci-dove.c | |||
@@ -20,6 +20,7 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <linux/module.h> | ||
23 | #include <linux/mmc/host.h> | 24 | #include <linux/mmc/host.h> |
24 | 25 | ||
25 | #include "sdhci-pltfm.h" | 26 | #include "sdhci-pltfm.h" |
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index d601e41af282..8abdaf6697a8 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c | |||
@@ -269,8 +269,9 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg) | |||
269 | imx_data->scratchpad = val; | 269 | imx_data->scratchpad = val; |
270 | return; | 270 | return; |
271 | case SDHCI_COMMAND: | 271 | case SDHCI_COMMAND: |
272 | if ((host->cmd->opcode == MMC_STOP_TRANSMISSION) | 272 | if ((host->cmd->opcode == MMC_STOP_TRANSMISSION || |
273 | && (imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT)) | 273 | host->cmd->opcode == MMC_SET_BLOCK_COUNT) && |
274 | (imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT)) | ||
274 | val |= SDHCI_CMD_ABORTCMD; | 275 | val |= SDHCI_CMD_ABORTCMD; |
275 | 276 | ||
276 | if (is_imx6q_usdhc(imx_data)) { | 277 | if (is_imx6q_usdhc(imx_data)) { |
@@ -463,11 +464,10 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) | |||
463 | err = PTR_ERR(clk); | 464 | err = PTR_ERR(clk); |
464 | goto err_clk_get; | 465 | goto err_clk_get; |
465 | } | 466 | } |
466 | clk_enable(clk); | 467 | clk_prepare_enable(clk); |
467 | pltfm_host->clk = clk; | 468 | pltfm_host->clk = clk; |
468 | 469 | ||
469 | if (!is_imx25_esdhc(imx_data)) | 470 | host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; |
470 | host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; | ||
471 | 471 | ||
472 | if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data)) | 472 | if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data)) |
473 | /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */ | 473 | /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */ |
@@ -558,7 +558,7 @@ no_card_detect_irq: | |||
558 | gpio_free(boarddata->wp_gpio); | 558 | gpio_free(boarddata->wp_gpio); |
559 | no_card_detect_pin: | 559 | no_card_detect_pin: |
560 | no_board_data: | 560 | no_board_data: |
561 | clk_disable(pltfm_host->clk); | 561 | clk_disable_unprepare(pltfm_host->clk); |
562 | clk_put(pltfm_host->clk); | 562 | clk_put(pltfm_host->clk); |
563 | err_clk_get: | 563 | err_clk_get: |
564 | kfree(imx_data); | 564 | kfree(imx_data); |
@@ -585,7 +585,7 @@ static int __devexit sdhci_esdhc_imx_remove(struct platform_device *pdev) | |||
585 | gpio_free(boarddata->cd_gpio); | 585 | gpio_free(boarddata->cd_gpio); |
586 | } | 586 | } |
587 | 587 | ||
588 | clk_disable(pltfm_host->clk); | 588 | clk_disable_unprepare(pltfm_host->clk); |
589 | clk_put(pltfm_host->clk); | 589 | clk_put(pltfm_host->clk); |
590 | kfree(imx_data); | 590 | kfree(imx_data); |
591 | 591 | ||
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c index 5d876ff86f37..f8eb1fb0c921 100644 --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Freescale eSDHC controller driver. | 2 | * Freescale eSDHC controller driver. |
3 | * | 3 | * |
4 | * Copyright (c) 2007, 2010 Freescale Semiconductor, Inc. | 4 | * Copyright (c) 2007, 2010, 2012 Freescale Semiconductor, Inc. |
5 | * Copyright (c) 2009 MontaVista Software, Inc. | 5 | * Copyright (c) 2009 MontaVista Software, Inc. |
6 | * | 6 | * |
7 | * Authors: Xiaobo Xie <X.Xie@freescale.com> | 7 | * Authors: Xiaobo Xie <X.Xie@freescale.com> |
@@ -14,6 +14,7 @@ | |||
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/of.h> | ||
17 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
18 | #include <linux/module.h> | 19 | #include <linux/module.h> |
19 | #include <linux/mmc/host.h> | 20 | #include <linux/mmc/host.h> |
@@ -114,6 +115,34 @@ static unsigned int esdhc_of_get_min_clock(struct sdhci_host *host) | |||
114 | return pltfm_host->clock / 256 / 16; | 115 | return pltfm_host->clock / 256 / 16; |
115 | } | 116 | } |
116 | 117 | ||
118 | static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock) | ||
119 | { | ||
120 | /* Workaround to reduce the clock frequency for p1010 esdhc */ | ||
121 | if (of_find_compatible_node(NULL, NULL, "fsl,p1010-esdhc")) { | ||
122 | if (clock > 20000000) | ||
123 | clock -= 5000000; | ||
124 | if (clock > 40000000) | ||
125 | clock -= 5000000; | ||
126 | } | ||
127 | |||
128 | /* Set the clock */ | ||
129 | esdhc_set_clock(host, clock); | ||
130 | } | ||
131 | |||
132 | #ifdef CONFIG_PM | ||
133 | static u32 esdhc_proctl; | ||
134 | static void esdhc_of_suspend(struct sdhci_host *host) | ||
135 | { | ||
136 | esdhc_proctl = sdhci_be32bs_readl(host, SDHCI_HOST_CONTROL); | ||
137 | } | ||
138 | |||
139 | static void esdhc_of_resume(struct sdhci_host *host) | ||
140 | { | ||
141 | esdhc_of_enable_dma(host); | ||
142 | sdhci_be32bs_writel(host, esdhc_proctl, SDHCI_HOST_CONTROL); | ||
143 | } | ||
144 | #endif | ||
145 | |||
117 | static struct sdhci_ops sdhci_esdhc_ops = { | 146 | static struct sdhci_ops sdhci_esdhc_ops = { |
118 | .read_l = sdhci_be32bs_readl, | 147 | .read_l = sdhci_be32bs_readl, |
119 | .read_w = esdhc_readw, | 148 | .read_w = esdhc_readw, |
@@ -121,10 +150,14 @@ static struct sdhci_ops sdhci_esdhc_ops = { | |||
121 | .write_l = sdhci_be32bs_writel, | 150 | .write_l = sdhci_be32bs_writel, |
122 | .write_w = esdhc_writew, | 151 | .write_w = esdhc_writew, |
123 | .write_b = esdhc_writeb, | 152 | .write_b = esdhc_writeb, |
124 | .set_clock = esdhc_set_clock, | 153 | .set_clock = esdhc_of_set_clock, |
125 | .enable_dma = esdhc_of_enable_dma, | 154 | .enable_dma = esdhc_of_enable_dma, |
126 | .get_max_clock = esdhc_of_get_max_clock, | 155 | .get_max_clock = esdhc_of_get_max_clock, |
127 | .get_min_clock = esdhc_of_get_min_clock, | 156 | .get_min_clock = esdhc_of_get_min_clock, |
157 | #ifdef CONFIG_PM | ||
158 | .platform_suspend = esdhc_of_suspend, | ||
159 | .platform_resume = esdhc_of_resume, | ||
160 | #endif | ||
128 | }; | 161 | }; |
129 | 162 | ||
130 | static struct sdhci_pltfm_data sdhci_esdhc_pdata = { | 163 | static struct sdhci_pltfm_data sdhci_esdhc_pdata = { |
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c index 6ebdc4010e7c..69ef0beae104 100644 --- a/drivers/mmc/host/sdhci-pci.c +++ b/drivers/mmc/host/sdhci-pci.c | |||
@@ -29,6 +29,12 @@ | |||
29 | #include "sdhci.h" | 29 | #include "sdhci.h" |
30 | 30 | ||
31 | /* | 31 | /* |
32 | * PCI device IDs | ||
33 | */ | ||
34 | #define PCI_DEVICE_ID_INTEL_PCH_SDIO0 0x8809 | ||
35 | #define PCI_DEVICE_ID_INTEL_PCH_SDIO1 0x880a | ||
36 | |||
37 | /* | ||
32 | * PCI registers | 38 | * PCI registers |
33 | */ | 39 | */ |
34 | 40 | ||
@@ -47,6 +53,7 @@ struct sdhci_pci_slot; | |||
47 | 53 | ||
48 | struct sdhci_pci_fixes { | 54 | struct sdhci_pci_fixes { |
49 | unsigned int quirks; | 55 | unsigned int quirks; |
56 | unsigned int quirks2; | ||
50 | bool allow_runtime_pm; | 57 | bool allow_runtime_pm; |
51 | 58 | ||
52 | int (*probe) (struct sdhci_pci_chip *); | 59 | int (*probe) (struct sdhci_pci_chip *); |
@@ -73,6 +80,7 @@ struct sdhci_pci_chip { | |||
73 | struct pci_dev *pdev; | 80 | struct pci_dev *pdev; |
74 | 81 | ||
75 | unsigned int quirks; | 82 | unsigned int quirks; |
83 | unsigned int quirks2; | ||
76 | bool allow_runtime_pm; | 84 | bool allow_runtime_pm; |
77 | const struct sdhci_pci_fixes *fixes; | 85 | const struct sdhci_pci_fixes *fixes; |
78 | 86 | ||
@@ -172,6 +180,12 @@ static int mrst_hc_probe(struct sdhci_pci_chip *chip) | |||
172 | return 0; | 180 | return 0; |
173 | } | 181 | } |
174 | 182 | ||
183 | static int pch_hc_probe_slot(struct sdhci_pci_slot *slot) | ||
184 | { | ||
185 | slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA; | ||
186 | return 0; | ||
187 | } | ||
188 | |||
175 | #ifdef CONFIG_PM_RUNTIME | 189 | #ifdef CONFIG_PM_RUNTIME |
176 | 190 | ||
177 | static irqreturn_t sdhci_pci_sd_cd(int irq, void *dev_id) | 191 | static irqreturn_t sdhci_pci_sd_cd(int irq, void *dev_id) |
@@ -244,7 +258,8 @@ static inline void sdhci_pci_remove_own_cd(struct sdhci_pci_slot *slot) | |||
244 | static int mfd_emmc_probe_slot(struct sdhci_pci_slot *slot) | 258 | static int mfd_emmc_probe_slot(struct sdhci_pci_slot *slot) |
245 | { | 259 | { |
246 | slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE; | 260 | slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE; |
247 | slot->host->mmc->caps2 = MMC_CAP2_BOOTPART_NOACC; | 261 | slot->host->mmc->caps2 |= MMC_CAP2_BOOTPART_NOACC | |
262 | MMC_CAP2_HC_ERASE_SZ; | ||
248 | return 0; | 263 | return 0; |
249 | } | 264 | } |
250 | 265 | ||
@@ -271,6 +286,7 @@ static const struct sdhci_pci_fixes sdhci_intel_mfd_sd = { | |||
271 | 286 | ||
272 | static const struct sdhci_pci_fixes sdhci_intel_mfd_sdio = { | 287 | static const struct sdhci_pci_fixes sdhci_intel_mfd_sdio = { |
273 | .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, | 288 | .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, |
289 | .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON, | ||
274 | .allow_runtime_pm = true, | 290 | .allow_runtime_pm = true, |
275 | .probe_slot = mfd_sdio_probe_slot, | 291 | .probe_slot = mfd_sdio_probe_slot, |
276 | }; | 292 | }; |
@@ -281,6 +297,11 @@ static const struct sdhci_pci_fixes sdhci_intel_mfd_emmc = { | |||
281 | .probe_slot = mfd_emmc_probe_slot, | 297 | .probe_slot = mfd_emmc_probe_slot, |
282 | }; | 298 | }; |
283 | 299 | ||
300 | static const struct sdhci_pci_fixes sdhci_intel_pch_sdio = { | ||
301 | .quirks = SDHCI_QUIRK_BROKEN_ADMA, | ||
302 | .probe_slot = pch_hc_probe_slot, | ||
303 | }; | ||
304 | |||
284 | /* O2Micro extra registers */ | 305 | /* O2Micro extra registers */ |
285 | #define O2_SD_LOCK_WP 0xD3 | 306 | #define O2_SD_LOCK_WP 0xD3 |
286 | #define O2_SD_MULTI_VCC3V 0xEE | 307 | #define O2_SD_MULTI_VCC3V 0xEE |
@@ -817,6 +838,22 @@ static const struct pci_device_id pci_ids[] __devinitdata = { | |||
817 | }, | 838 | }, |
818 | 839 | ||
819 | { | 840 | { |
841 | .vendor = PCI_VENDOR_ID_INTEL, | ||
842 | .device = PCI_DEVICE_ID_INTEL_PCH_SDIO0, | ||
843 | .subvendor = PCI_ANY_ID, | ||
844 | .subdevice = PCI_ANY_ID, | ||
845 | .driver_data = (kernel_ulong_t)&sdhci_intel_pch_sdio, | ||
846 | }, | ||
847 | |||
848 | { | ||
849 | .vendor = PCI_VENDOR_ID_INTEL, | ||
850 | .device = PCI_DEVICE_ID_INTEL_PCH_SDIO1, | ||
851 | .subvendor = PCI_ANY_ID, | ||
852 | .subdevice = PCI_ANY_ID, | ||
853 | .driver_data = (kernel_ulong_t)&sdhci_intel_pch_sdio, | ||
854 | }, | ||
855 | |||
856 | { | ||
820 | .vendor = PCI_VENDOR_ID_O2, | 857 | .vendor = PCI_VENDOR_ID_O2, |
821 | .device = PCI_DEVICE_ID_O2_8120, | 858 | .device = PCI_DEVICE_ID_O2_8120, |
822 | .subvendor = PCI_ANY_ID, | 859 | .subvendor = PCI_ANY_ID, |
@@ -1206,6 +1243,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot( | |||
1206 | host->hw_name = "PCI"; | 1243 | host->hw_name = "PCI"; |
1207 | host->ops = &sdhci_pci_ops; | 1244 | host->ops = &sdhci_pci_ops; |
1208 | host->quirks = chip->quirks; | 1245 | host->quirks = chip->quirks; |
1246 | host->quirks2 = chip->quirks2; | ||
1209 | 1247 | ||
1210 | host->irq = pdev->irq; | 1248 | host->irq = pdev->irq; |
1211 | 1249 | ||
@@ -1365,6 +1403,7 @@ static int __devinit sdhci_pci_probe(struct pci_dev *pdev, | |||
1365 | chip->fixes = (const struct sdhci_pci_fixes *)ent->driver_data; | 1403 | chip->fixes = (const struct sdhci_pci_fixes *)ent->driver_data; |
1366 | if (chip->fixes) { | 1404 | if (chip->fixes) { |
1367 | chip->quirks = chip->fixes->quirks; | 1405 | chip->quirks = chip->fixes->quirks; |
1406 | chip->quirks2 = chip->fixes->quirks2; | ||
1368 | chip->allow_runtime_pm = chip->fixes->allow_runtime_pm; | 1407 | chip->allow_runtime_pm = chip->fixes->allow_runtime_pm; |
1369 | } | 1408 | } |
1370 | chip->num_slots = slots; | 1409 | chip->num_slots = slots; |
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index 1af756ee0f9a..55a164fcaa15 100644 --- a/drivers/mmc/host/sdhci-s3c.c +++ b/drivers/mmc/host/sdhci-s3c.c | |||
@@ -20,6 +20,10 @@ | |||
20 | #include <linux/io.h> | 20 | #include <linux/io.h> |
21 | #include <linux/gpio.h> | 21 | #include <linux/gpio.h> |
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/of.h> | ||
24 | #include <linux/of_gpio.h> | ||
25 | #include <linux/pm.h> | ||
26 | #include <linux/pm_runtime.h> | ||
23 | 27 | ||
24 | #include <linux/mmc/host.h> | 28 | #include <linux/mmc/host.h> |
25 | 29 | ||
@@ -53,6 +57,18 @@ struct sdhci_s3c { | |||
53 | struct clk *clk_bus[MAX_BUS_CLK]; | 57 | struct clk *clk_bus[MAX_BUS_CLK]; |
54 | }; | 58 | }; |
55 | 59 | ||
60 | /** | ||
61 | * struct sdhci_s3c_driver_data - S3C SDHCI platform specific driver data | ||
62 | * @sdhci_quirks: sdhci host specific quirks. | ||
63 | * | ||
64 | * Specifies platform specific configuration of sdhci controller. | ||
65 | * Note: A structure for driver specific platform data is used for future | ||
66 | * expansion of its usage. | ||
67 | */ | ||
68 | struct sdhci_s3c_drv_data { | ||
69 | unsigned int sdhci_quirks; | ||
70 | }; | ||
71 | |||
56 | static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host) | 72 | static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host) |
57 | { | 73 | { |
58 | return sdhci_priv(host); | 74 | return sdhci_priv(host); |
@@ -132,10 +148,10 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost, | |||
132 | return UINT_MAX; | 148 | return UINT_MAX; |
133 | 149 | ||
134 | /* | 150 | /* |
135 | * Clock divider's step is different as 1 from that of host controller | 151 | * If controller uses a non-standard clock division, find the best clock |
136 | * when 'clk_type' is S3C_SDHCI_CLK_DIV_EXTERNAL. | 152 | * speed possible with selected clock source and skip the division. |
137 | */ | 153 | */ |
138 | if (ourhost->pdata->clk_type) { | 154 | if (ourhost->host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) { |
139 | rate = clk_round_rate(clksrc, wanted); | 155 | rate = clk_round_rate(clksrc, wanted); |
140 | return wanted - rate; | 156 | return wanted - rate; |
141 | } | 157 | } |
@@ -272,6 +288,8 @@ static unsigned int sdhci_cmu_get_min_clock(struct sdhci_host *host) | |||
272 | static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock) | 288 | static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock) |
273 | { | 289 | { |
274 | struct sdhci_s3c *ourhost = to_s3c(host); | 290 | struct sdhci_s3c *ourhost = to_s3c(host); |
291 | unsigned long timeout; | ||
292 | u16 clk = 0; | ||
275 | 293 | ||
276 | /* don't bother if the clock is going off */ | 294 | /* don't bother if the clock is going off */ |
277 | if (clock == 0) | 295 | if (clock == 0) |
@@ -282,6 +300,25 @@ static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock) | |||
282 | clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock); | 300 | clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock); |
283 | 301 | ||
284 | host->clock = clock; | 302 | host->clock = clock; |
303 | |||
304 | clk = SDHCI_CLOCK_INT_EN; | ||
305 | sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); | ||
306 | |||
307 | /* Wait max 20 ms */ | ||
308 | timeout = 20; | ||
309 | while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL)) | ||
310 | & SDHCI_CLOCK_INT_STABLE)) { | ||
311 | if (timeout == 0) { | ||
312 | printk(KERN_ERR "%s: Internal clock never " | ||
313 | "stabilised.\n", mmc_hostname(host->mmc)); | ||
314 | return; | ||
315 | } | ||
316 | timeout--; | ||
317 | mdelay(1); | ||
318 | } | ||
319 | |||
320 | clk |= SDHCI_CLOCK_CARD_EN; | ||
321 | sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); | ||
285 | } | 322 | } |
286 | 323 | ||
287 | /** | 324 | /** |
@@ -382,16 +419,24 @@ static void sdhci_s3c_setup_card_detect_gpio(struct sdhci_s3c *sc) | |||
382 | } | 419 | } |
383 | } | 420 | } |
384 | 421 | ||
422 | static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data( | ||
423 | struct platform_device *pdev) | ||
424 | { | ||
425 | return (struct sdhci_s3c_drv_data *) | ||
426 | platform_get_device_id(pdev)->driver_data; | ||
427 | } | ||
428 | |||
385 | static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | 429 | static int __devinit sdhci_s3c_probe(struct platform_device *pdev) |
386 | { | 430 | { |
387 | struct s3c_sdhci_platdata *pdata = pdev->dev.platform_data; | 431 | struct s3c_sdhci_platdata *pdata; |
432 | struct sdhci_s3c_drv_data *drv_data; | ||
388 | struct device *dev = &pdev->dev; | 433 | struct device *dev = &pdev->dev; |
389 | struct sdhci_host *host; | 434 | struct sdhci_host *host; |
390 | struct sdhci_s3c *sc; | 435 | struct sdhci_s3c *sc; |
391 | struct resource *res; | 436 | struct resource *res; |
392 | int ret, irq, ptr, clks; | 437 | int ret, irq, ptr, clks; |
393 | 438 | ||
394 | if (!pdata) { | 439 | if (!pdev->dev.platform_data) { |
395 | dev_err(dev, "no device data specified\n"); | 440 | dev_err(dev, "no device data specified\n"); |
396 | return -ENOENT; | 441 | return -ENOENT; |
397 | } | 442 | } |
@@ -402,18 +447,20 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
402 | return irq; | 447 | return irq; |
403 | } | 448 | } |
404 | 449 | ||
405 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
406 | if (!res) { | ||
407 | dev_err(dev, "no memory specified\n"); | ||
408 | return -ENOENT; | ||
409 | } | ||
410 | |||
411 | host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c)); | 450 | host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c)); |
412 | if (IS_ERR(host)) { | 451 | if (IS_ERR(host)) { |
413 | dev_err(dev, "sdhci_alloc_host() failed\n"); | 452 | dev_err(dev, "sdhci_alloc_host() failed\n"); |
414 | return PTR_ERR(host); | 453 | return PTR_ERR(host); |
415 | } | 454 | } |
416 | 455 | ||
456 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
457 | if (!pdata) { | ||
458 | ret = -ENOMEM; | ||
459 | goto err_io_clk; | ||
460 | } | ||
461 | memcpy(pdata, pdev->dev.platform_data, sizeof(*pdata)); | ||
462 | |||
463 | drv_data = sdhci_s3c_get_driver_data(pdev); | ||
417 | sc = sdhci_priv(host); | 464 | sc = sdhci_priv(host); |
418 | 465 | ||
419 | sc->host = host; | 466 | sc->host = host; |
@@ -464,15 +511,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
464 | goto err_no_busclks; | 511 | goto err_no_busclks; |
465 | } | 512 | } |
466 | 513 | ||
467 | sc->ioarea = request_mem_region(res->start, resource_size(res), | 514 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
468 | mmc_hostname(host->mmc)); | 515 | host->ioaddr = devm_request_and_ioremap(&pdev->dev, res); |
469 | if (!sc->ioarea) { | ||
470 | dev_err(dev, "failed to reserve register area\n"); | ||
471 | ret = -ENXIO; | ||
472 | goto err_req_regs; | ||
473 | } | ||
474 | |||
475 | host->ioaddr = ioremap_nocache(res->start, resource_size(res)); | ||
476 | if (!host->ioaddr) { | 516 | if (!host->ioaddr) { |
477 | dev_err(dev, "failed to map registers\n"); | 517 | dev_err(dev, "failed to map registers\n"); |
478 | ret = -ENXIO; | 518 | ret = -ENXIO; |
@@ -491,6 +531,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
491 | /* Setup quirks for the controller */ | 531 | /* Setup quirks for the controller */ |
492 | host->quirks |= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC; | 532 | host->quirks |= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC; |
493 | host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT; | 533 | host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT; |
534 | if (drv_data) | ||
535 | host->quirks |= drv_data->sdhci_quirks; | ||
494 | 536 | ||
495 | #ifndef CONFIG_MMC_SDHCI_S3C_DMA | 537 | #ifndef CONFIG_MMC_SDHCI_S3C_DMA |
496 | 538 | ||
@@ -518,8 +560,13 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
518 | if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT) | 560 | if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT) |
519 | host->mmc->caps = MMC_CAP_NONREMOVABLE; | 561 | host->mmc->caps = MMC_CAP_NONREMOVABLE; |
520 | 562 | ||
521 | if (pdata->host_caps) | 563 | switch (pdata->max_width) { |
522 | host->mmc->caps |= pdata->host_caps; | 564 | case 8: |
565 | host->mmc->caps |= MMC_CAP_8_BIT_DATA; | ||
566 | case 4: | ||
567 | host->mmc->caps |= MMC_CAP_4_BIT_DATA; | ||
568 | break; | ||
569 | } | ||
523 | 570 | ||
524 | if (pdata->pm_caps) | 571 | if (pdata->pm_caps) |
525 | host->mmc->pm_caps |= pdata->pm_caps; | 572 | host->mmc->pm_caps |= pdata->pm_caps; |
@@ -534,7 +581,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
534 | * If controller does not have internal clock divider, | 581 | * If controller does not have internal clock divider, |
535 | * we can use overriding functions instead of default. | 582 | * we can use overriding functions instead of default. |
536 | */ | 583 | */ |
537 | if (pdata->clk_type) { | 584 | if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) { |
538 | sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock; | 585 | sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock; |
539 | sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock; | 586 | sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock; |
540 | sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock; | 587 | sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock; |
@@ -544,10 +591,20 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
544 | if (pdata->host_caps) | 591 | if (pdata->host_caps) |
545 | host->mmc->caps |= pdata->host_caps; | 592 | host->mmc->caps |= pdata->host_caps; |
546 | 593 | ||
594 | if (pdata->host_caps2) | ||
595 | host->mmc->caps2 |= pdata->host_caps2; | ||
596 | |||
597 | pm_runtime_enable(&pdev->dev); | ||
598 | pm_runtime_set_autosuspend_delay(&pdev->dev, 50); | ||
599 | pm_runtime_use_autosuspend(&pdev->dev); | ||
600 | pm_suspend_ignore_children(&pdev->dev, 1); | ||
601 | |||
547 | ret = sdhci_add_host(host); | 602 | ret = sdhci_add_host(host); |
548 | if (ret) { | 603 | if (ret) { |
549 | dev_err(dev, "sdhci_add_host() failed\n"); | 604 | dev_err(dev, "sdhci_add_host() failed\n"); |
550 | goto err_add_host; | 605 | pm_runtime_forbid(&pdev->dev); |
606 | pm_runtime_get_noresume(&pdev->dev); | ||
607 | goto err_req_regs; | ||
551 | } | 608 | } |
552 | 609 | ||
553 | /* The following two methods of card detection might call | 610 | /* The following two methods of card detection might call |
@@ -561,10 +618,6 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
561 | 618 | ||
562 | return 0; | 619 | return 0; |
563 | 620 | ||
564 | err_add_host: | ||
565 | release_resource(sc->ioarea); | ||
566 | kfree(sc->ioarea); | ||
567 | |||
568 | err_req_regs: | 621 | err_req_regs: |
569 | for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) { | 622 | for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) { |
570 | if (sc->clk_bus[ptr]) { | 623 | if (sc->clk_bus[ptr]) { |
@@ -601,6 +654,8 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev) | |||
601 | 654 | ||
602 | sdhci_remove_host(host, 1); | 655 | sdhci_remove_host(host, 1); |
603 | 656 | ||
657 | pm_runtime_disable(&pdev->dev); | ||
658 | |||
604 | for (ptr = 0; ptr < 3; ptr++) { | 659 | for (ptr = 0; ptr < 3; ptr++) { |
605 | if (sc->clk_bus[ptr]) { | 660 | if (sc->clk_bus[ptr]) { |
606 | clk_disable(sc->clk_bus[ptr]); | 661 | clk_disable(sc->clk_bus[ptr]); |
@@ -610,18 +665,13 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev) | |||
610 | clk_disable(sc->clk_io); | 665 | clk_disable(sc->clk_io); |
611 | clk_put(sc->clk_io); | 666 | clk_put(sc->clk_io); |
612 | 667 | ||
613 | iounmap(host->ioaddr); | ||
614 | release_resource(sc->ioarea); | ||
615 | kfree(sc->ioarea); | ||
616 | |||
617 | sdhci_free_host(host); | 668 | sdhci_free_host(host); |
618 | platform_set_drvdata(pdev, NULL); | 669 | platform_set_drvdata(pdev, NULL); |
619 | 670 | ||
620 | return 0; | 671 | return 0; |
621 | } | 672 | } |
622 | 673 | ||
623 | #ifdef CONFIG_PM | 674 | #ifdef CONFIG_PM_SLEEP |
624 | |||
625 | static int sdhci_s3c_suspend(struct device *dev) | 675 | static int sdhci_s3c_suspend(struct device *dev) |
626 | { | 676 | { |
627 | struct sdhci_host *host = dev_get_drvdata(dev); | 677 | struct sdhci_host *host = dev_get_drvdata(dev); |
@@ -635,10 +685,29 @@ static int sdhci_s3c_resume(struct device *dev) | |||
635 | 685 | ||
636 | return sdhci_resume_host(host); | 686 | return sdhci_resume_host(host); |
637 | } | 687 | } |
688 | #endif | ||
689 | |||
690 | #ifdef CONFIG_PM_RUNTIME | ||
691 | static int sdhci_s3c_runtime_suspend(struct device *dev) | ||
692 | { | ||
693 | struct sdhci_host *host = dev_get_drvdata(dev); | ||
694 | |||
695 | return sdhci_runtime_suspend_host(host); | ||
696 | } | ||
697 | |||
698 | static int sdhci_s3c_runtime_resume(struct device *dev) | ||
699 | { | ||
700 | struct sdhci_host *host = dev_get_drvdata(dev); | ||
701 | |||
702 | return sdhci_runtime_resume_host(host); | ||
703 | } | ||
704 | #endif | ||
638 | 705 | ||
706 | #ifdef CONFIG_PM | ||
639 | static const struct dev_pm_ops sdhci_s3c_pmops = { | 707 | static const struct dev_pm_ops sdhci_s3c_pmops = { |
640 | .suspend = sdhci_s3c_suspend, | 708 | SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume) |
641 | .resume = sdhci_s3c_resume, | 709 | SET_RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume, |
710 | NULL) | ||
642 | }; | 711 | }; |
643 | 712 | ||
644 | #define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops) | 713 | #define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops) |
@@ -647,9 +716,31 @@ static const struct dev_pm_ops sdhci_s3c_pmops = { | |||
647 | #define SDHCI_S3C_PMOPS NULL | 716 | #define SDHCI_S3C_PMOPS NULL |
648 | #endif | 717 | #endif |
649 | 718 | ||
719 | #if defined(CONFIG_CPU_EXYNOS4210) || defined(CONFIG_SOC_EXYNOS4212) | ||
720 | static struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = { | ||
721 | .sdhci_quirks = SDHCI_QUIRK_NONSTANDARD_CLOCK, | ||
722 | }; | ||
723 | #define EXYNOS4_SDHCI_DRV_DATA ((kernel_ulong_t)&exynos4_sdhci_drv_data) | ||
724 | #else | ||
725 | #define EXYNOS4_SDHCI_DRV_DATA ((kernel_ulong_t)NULL) | ||
726 | #endif | ||
727 | |||
728 | static struct platform_device_id sdhci_s3c_driver_ids[] = { | ||
729 | { | ||
730 | .name = "s3c-sdhci", | ||
731 | .driver_data = (kernel_ulong_t)NULL, | ||
732 | }, { | ||
733 | .name = "exynos4-sdhci", | ||
734 | .driver_data = EXYNOS4_SDHCI_DRV_DATA, | ||
735 | }, | ||
736 | { } | ||
737 | }; | ||
738 | MODULE_DEVICE_TABLE(platform, sdhci_s3c_driver_ids); | ||
739 | |||
650 | static struct platform_driver sdhci_s3c_driver = { | 740 | static struct platform_driver sdhci_s3c_driver = { |
651 | .probe = sdhci_s3c_probe, | 741 | .probe = sdhci_s3c_probe, |
652 | .remove = __devexit_p(sdhci_s3c_remove), | 742 | .remove = __devexit_p(sdhci_s3c_remove), |
743 | .id_table = sdhci_s3c_driver_ids, | ||
653 | .driver = { | 744 | .driver = { |
654 | .owner = THIS_MODULE, | 745 | .owner = THIS_MODULE, |
655 | .name = "s3c-sdhci", | 746 | .name = "s3c-sdhci", |
diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c index b7f8b33c5f19..6dfa82e03c7e 100644 --- a/drivers/mmc/host/sdhci-spear.c +++ b/drivers/mmc/host/sdhci-spear.c | |||
@@ -300,20 +300,15 @@ static int sdhci_resume(struct device *dev) | |||
300 | 300 | ||
301 | return sdhci_resume_host(host); | 301 | return sdhci_resume_host(host); |
302 | } | 302 | } |
303 | |||
304 | const struct dev_pm_ops sdhci_pm_ops = { | ||
305 | .suspend = sdhci_suspend, | ||
306 | .resume = sdhci_resume, | ||
307 | }; | ||
308 | #endif | 303 | #endif |
309 | 304 | ||
305 | static SIMPLE_DEV_PM_OPS(sdhci_pm_ops, sdhci_suspend, sdhci_resume); | ||
306 | |||
310 | static struct platform_driver sdhci_driver = { | 307 | static struct platform_driver sdhci_driver = { |
311 | .driver = { | 308 | .driver = { |
312 | .name = "sdhci", | 309 | .name = "sdhci", |
313 | .owner = THIS_MODULE, | 310 | .owner = THIS_MODULE, |
314 | #ifdef CONFIG_PM | ||
315 | .pm = &sdhci_pm_ops, | 311 | .pm = &sdhci_pm_ops, |
316 | #endif | ||
317 | }, | 312 | }, |
318 | .probe = sdhci_probe, | 313 | .probe = sdhci_probe, |
319 | .remove = __devexit_p(sdhci_remove), | 314 | .remove = __devexit_p(sdhci_remove), |
diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c index 78a36eba4df0..53b26502f6e2 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c | |||
@@ -19,11 +19,11 @@ | |||
19 | #include <linux/clk.h> | 19 | #include <linux/clk.h> |
20 | #include <linux/io.h> | 20 | #include <linux/io.h> |
21 | #include <linux/of.h> | 21 | #include <linux/of.h> |
22 | #include <linux/of_device.h> | ||
22 | #include <linux/of_gpio.h> | 23 | #include <linux/of_gpio.h> |
23 | #include <linux/gpio.h> | 24 | #include <linux/gpio.h> |
24 | #include <linux/mmc/card.h> | 25 | #include <linux/mmc/card.h> |
25 | #include <linux/mmc/host.h> | 26 | #include <linux/mmc/host.h> |
26 | #include <linux/module.h> | ||
27 | 27 | ||
28 | #include <asm/gpio.h> | 28 | #include <asm/gpio.h> |
29 | 29 | ||
@@ -32,6 +32,19 @@ | |||
32 | 32 | ||
33 | #include "sdhci-pltfm.h" | 33 | #include "sdhci-pltfm.h" |
34 | 34 | ||
35 | #define NVQUIRK_FORCE_SDHCI_SPEC_200 BIT(0) | ||
36 | #define NVQUIRK_ENABLE_BLOCK_GAP_DET BIT(1) | ||
37 | |||
38 | struct sdhci_tegra_soc_data { | ||
39 | struct sdhci_pltfm_data *pdata; | ||
40 | u32 nvquirks; | ||
41 | }; | ||
42 | |||
43 | struct sdhci_tegra { | ||
44 | const struct tegra_sdhci_platform_data *plat; | ||
45 | const struct sdhci_tegra_soc_data *soc_data; | ||
46 | }; | ||
47 | |||
35 | static u32 tegra_sdhci_readl(struct sdhci_host *host, int reg) | 48 | static u32 tegra_sdhci_readl(struct sdhci_host *host, int reg) |
36 | { | 49 | { |
37 | u32 val; | 50 | u32 val; |
@@ -47,7 +60,12 @@ static u32 tegra_sdhci_readl(struct sdhci_host *host, int reg) | |||
47 | 60 | ||
48 | static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg) | 61 | static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg) |
49 | { | 62 | { |
50 | if (unlikely(reg == SDHCI_HOST_VERSION)) { | 63 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
64 | struct sdhci_tegra *tegra_host = pltfm_host->priv; | ||
65 | const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data; | ||
66 | |||
67 | if (unlikely((soc_data->nvquirks & NVQUIRK_FORCE_SDHCI_SPEC_200) && | ||
68 | (reg == SDHCI_HOST_VERSION))) { | ||
51 | /* Erratum: Version register is invalid in HW. */ | 69 | /* Erratum: Version register is invalid in HW. */ |
52 | return SDHCI_SPEC_200; | 70 | return SDHCI_SPEC_200; |
53 | } | 71 | } |
@@ -57,6 +75,10 @@ static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg) | |||
57 | 75 | ||
58 | static void tegra_sdhci_writel(struct sdhci_host *host, u32 val, int reg) | 76 | static void tegra_sdhci_writel(struct sdhci_host *host, u32 val, int reg) |
59 | { | 77 | { |
78 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | ||
79 | struct sdhci_tegra *tegra_host = pltfm_host->priv; | ||
80 | const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data; | ||
81 | |||
60 | /* Seems like we're getting spurious timeout and crc errors, so | 82 | /* Seems like we're getting spurious timeout and crc errors, so |
61 | * disable signalling of them. In case of real errors software | 83 | * disable signalling of them. In case of real errors software |
62 | * timers should take care of eventually detecting them. | 84 | * timers should take care of eventually detecting them. |
@@ -66,7 +88,8 @@ static void tegra_sdhci_writel(struct sdhci_host *host, u32 val, int reg) | |||
66 | 88 | ||
67 | writel(val, host->ioaddr + reg); | 89 | writel(val, host->ioaddr + reg); |
68 | 90 | ||
69 | if (unlikely(reg == SDHCI_INT_ENABLE)) { | 91 | if (unlikely((soc_data->nvquirks & NVQUIRK_ENABLE_BLOCK_GAP_DET) && |
92 | (reg == SDHCI_INT_ENABLE))) { | ||
70 | /* Erratum: Must enable block gap interrupt detection */ | 93 | /* Erratum: Must enable block gap interrupt detection */ |
71 | u8 gap_ctrl = readb(host->ioaddr + SDHCI_BLOCK_GAP_CONTROL); | 94 | u8 gap_ctrl = readb(host->ioaddr + SDHCI_BLOCK_GAP_CONTROL); |
72 | if (val & SDHCI_INT_CARD_INT) | 95 | if (val & SDHCI_INT_CARD_INT) |
@@ -77,10 +100,11 @@ static void tegra_sdhci_writel(struct sdhci_host *host, u32 val, int reg) | |||
77 | } | 100 | } |
78 | } | 101 | } |
79 | 102 | ||
80 | static unsigned int tegra_sdhci_get_ro(struct sdhci_host *sdhci) | 103 | static unsigned int tegra_sdhci_get_ro(struct sdhci_host *host) |
81 | { | 104 | { |
82 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(sdhci); | 105 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
83 | struct tegra_sdhci_platform_data *plat = pltfm_host->priv; | 106 | struct sdhci_tegra *tegra_host = pltfm_host->priv; |
107 | const struct tegra_sdhci_platform_data *plat = tegra_host->plat; | ||
84 | 108 | ||
85 | if (!gpio_is_valid(plat->wp_gpio)) | 109 | if (!gpio_is_valid(plat->wp_gpio)) |
86 | return -1; | 110 | return -1; |
@@ -99,7 +123,8 @@ static irqreturn_t carddetect_irq(int irq, void *data) | |||
99 | static int tegra_sdhci_8bit(struct sdhci_host *host, int bus_width) | 123 | static int tegra_sdhci_8bit(struct sdhci_host *host, int bus_width) |
100 | { | 124 | { |
101 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | 125 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
102 | struct tegra_sdhci_platform_data *plat = pltfm_host->priv; | 126 | struct sdhci_tegra *tegra_host = pltfm_host->priv; |
127 | const struct tegra_sdhci_platform_data *plat = tegra_host->plat; | ||
103 | u32 ctrl; | 128 | u32 ctrl; |
104 | 129 | ||
105 | ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); | 130 | ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); |
@@ -125,7 +150,8 @@ static struct sdhci_ops tegra_sdhci_ops = { | |||
125 | .platform_8bit_width = tegra_sdhci_8bit, | 150 | .platform_8bit_width = tegra_sdhci_8bit, |
126 | }; | 151 | }; |
127 | 152 | ||
128 | static struct sdhci_pltfm_data sdhci_tegra_pdata = { | 153 | #ifdef CONFIG_ARCH_TEGRA_2x_SOC |
154 | static struct sdhci_pltfm_data sdhci_tegra20_pdata = { | ||
129 | .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | | 155 | .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | |
130 | SDHCI_QUIRK_SINGLE_POWER_WRITE | | 156 | SDHCI_QUIRK_SINGLE_POWER_WRITE | |
131 | SDHCI_QUIRK_NO_HISPD_BIT | | 157 | SDHCI_QUIRK_NO_HISPD_BIT | |
@@ -133,8 +159,35 @@ static struct sdhci_pltfm_data sdhci_tegra_pdata = { | |||
133 | .ops = &tegra_sdhci_ops, | 159 | .ops = &tegra_sdhci_ops, |
134 | }; | 160 | }; |
135 | 161 | ||
162 | static struct sdhci_tegra_soc_data soc_data_tegra20 = { | ||
163 | .pdata = &sdhci_tegra20_pdata, | ||
164 | .nvquirks = NVQUIRK_FORCE_SDHCI_SPEC_200 | | ||
165 | NVQUIRK_ENABLE_BLOCK_GAP_DET, | ||
166 | }; | ||
167 | #endif | ||
168 | |||
169 | #ifdef CONFIG_ARCH_TEGRA_3x_SOC | ||
170 | static struct sdhci_pltfm_data sdhci_tegra30_pdata = { | ||
171 | .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | | ||
172 | SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | | ||
173 | SDHCI_QUIRK_SINGLE_POWER_WRITE | | ||
174 | SDHCI_QUIRK_NO_HISPD_BIT | | ||
175 | SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC, | ||
176 | .ops = &tegra_sdhci_ops, | ||
177 | }; | ||
178 | |||
179 | static struct sdhci_tegra_soc_data soc_data_tegra30 = { | ||
180 | .pdata = &sdhci_tegra30_pdata, | ||
181 | }; | ||
182 | #endif | ||
183 | |||
136 | static const struct of_device_id sdhci_tegra_dt_match[] __devinitdata = { | 184 | static const struct of_device_id sdhci_tegra_dt_match[] __devinitdata = { |
137 | { .compatible = "nvidia,tegra20-sdhci", }, | 185 | #ifdef CONFIG_ARCH_TEGRA_3x_SOC |
186 | { .compatible = "nvidia,tegra30-sdhci", .data = &soc_data_tegra30 }, | ||
187 | #endif | ||
188 | #ifdef CONFIG_ARCH_TEGRA_2x_SOC | ||
189 | { .compatible = "nvidia,tegra20-sdhci", .data = &soc_data_tegra20 }, | ||
190 | #endif | ||
138 | {} | 191 | {} |
139 | }; | 192 | }; |
140 | MODULE_DEVICE_TABLE(of, sdhci_dt_ids); | 193 | MODULE_DEVICE_TABLE(of, sdhci_dt_ids); |
@@ -165,13 +218,22 @@ static struct tegra_sdhci_platform_data * __devinit sdhci_tegra_dt_parse_pdata( | |||
165 | 218 | ||
166 | static int __devinit sdhci_tegra_probe(struct platform_device *pdev) | 219 | static int __devinit sdhci_tegra_probe(struct platform_device *pdev) |
167 | { | 220 | { |
221 | const struct of_device_id *match; | ||
222 | const struct sdhci_tegra_soc_data *soc_data; | ||
223 | struct sdhci_host *host; | ||
168 | struct sdhci_pltfm_host *pltfm_host; | 224 | struct sdhci_pltfm_host *pltfm_host; |
169 | struct tegra_sdhci_platform_data *plat; | 225 | struct tegra_sdhci_platform_data *plat; |
170 | struct sdhci_host *host; | 226 | struct sdhci_tegra *tegra_host; |
171 | struct clk *clk; | 227 | struct clk *clk; |
172 | int rc; | 228 | int rc; |
173 | 229 | ||
174 | host = sdhci_pltfm_init(pdev, &sdhci_tegra_pdata); | 230 | match = of_match_device(sdhci_tegra_dt_match, &pdev->dev); |
231 | if (match) | ||
232 | soc_data = match->data; | ||
233 | else | ||
234 | soc_data = &soc_data_tegra20; | ||
235 | |||
236 | host = sdhci_pltfm_init(pdev, soc_data->pdata); | ||
175 | if (IS_ERR(host)) | 237 | if (IS_ERR(host)) |
176 | return PTR_ERR(host); | 238 | return PTR_ERR(host); |
177 | 239 | ||
@@ -188,7 +250,17 @@ static int __devinit sdhci_tegra_probe(struct platform_device *pdev) | |||
188 | goto err_no_plat; | 250 | goto err_no_plat; |
189 | } | 251 | } |
190 | 252 | ||
191 | pltfm_host->priv = plat; | 253 | tegra_host = devm_kzalloc(&pdev->dev, sizeof(*tegra_host), GFP_KERNEL); |
254 | if (!tegra_host) { | ||
255 | dev_err(mmc_dev(host->mmc), "failed to allocate tegra_host\n"); | ||
256 | rc = -ENOMEM; | ||
257 | goto err_no_plat; | ||
258 | } | ||
259 | |||
260 | tegra_host->plat = plat; | ||
261 | tegra_host->soc_data = soc_data; | ||
262 | |||
263 | pltfm_host->priv = tegra_host; | ||
192 | 264 | ||
193 | if (gpio_is_valid(plat->power_gpio)) { | 265 | if (gpio_is_valid(plat->power_gpio)) { |
194 | rc = gpio_request(plat->power_gpio, "sdhci_power"); | 266 | rc = gpio_request(plat->power_gpio, "sdhci_power"); |
@@ -284,7 +356,8 @@ static int __devexit sdhci_tegra_remove(struct platform_device *pdev) | |||
284 | { | 356 | { |
285 | struct sdhci_host *host = platform_get_drvdata(pdev); | 357 | struct sdhci_host *host = platform_get_drvdata(pdev); |
286 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | 358 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
287 | struct tegra_sdhci_platform_data *plat = pltfm_host->priv; | 359 | struct sdhci_tegra *tegra_host = pltfm_host->priv; |
360 | const struct tegra_sdhci_platform_data *plat = tegra_host->plat; | ||
288 | int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); | 361 | int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); |
289 | 362 | ||
290 | sdhci_remove_host(host, dead); | 363 | sdhci_remove_host(host, dead); |
@@ -327,5 +400,5 @@ static struct platform_driver sdhci_tegra_driver = { | |||
327 | module_platform_driver(sdhci_tegra_driver); | 400 | module_platform_driver(sdhci_tegra_driver); |
328 | 401 | ||
329 | MODULE_DESCRIPTION("SDHCI driver for Tegra"); | 402 | MODULE_DESCRIPTION("SDHCI driver for Tegra"); |
330 | MODULE_AUTHOR(" Google, Inc."); | 403 | MODULE_AUTHOR("Google, Inc."); |
331 | MODULE_LICENSE("GPL v2"); | 404 | MODULE_LICENSE("GPL v2"); |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 8d66706824a6..ccefdebeff14 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -147,7 +147,7 @@ static void sdhci_set_card_detection(struct sdhci_host *host, bool enable) | |||
147 | u32 present, irqs; | 147 | u32 present, irqs; |
148 | 148 | ||
149 | if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) || | 149 | if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) || |
150 | !mmc_card_is_removable(host->mmc)) | 150 | (host->mmc->caps & MMC_CAP_NONREMOVABLE)) |
151 | return; | 151 | return; |
152 | 152 | ||
153 | present = sdhci_readl(host, SDHCI_PRESENT_STATE) & | 153 | present = sdhci_readl(host, SDHCI_PRESENT_STATE) & |
@@ -2267,8 +2267,8 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) | |||
2267 | { | 2267 | { |
2268 | irqreturn_t result; | 2268 | irqreturn_t result; |
2269 | struct sdhci_host *host = dev_id; | 2269 | struct sdhci_host *host = dev_id; |
2270 | u32 intmask; | 2270 | u32 intmask, unexpected = 0; |
2271 | int cardint = 0; | 2271 | int cardint = 0, max_loops = 16; |
2272 | 2272 | ||
2273 | spin_lock(&host->lock); | 2273 | spin_lock(&host->lock); |
2274 | 2274 | ||
@@ -2286,6 +2286,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) | |||
2286 | goto out; | 2286 | goto out; |
2287 | } | 2287 | } |
2288 | 2288 | ||
2289 | again: | ||
2289 | DBG("*** %s got interrupt: 0x%08x\n", | 2290 | DBG("*** %s got interrupt: 0x%08x\n", |
2290 | mmc_hostname(host->mmc), intmask); | 2291 | mmc_hostname(host->mmc), intmask); |
2291 | 2292 | ||
@@ -2344,19 +2345,23 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) | |||
2344 | intmask &= ~SDHCI_INT_CARD_INT; | 2345 | intmask &= ~SDHCI_INT_CARD_INT; |
2345 | 2346 | ||
2346 | if (intmask) { | 2347 | if (intmask) { |
2347 | pr_err("%s: Unexpected interrupt 0x%08x.\n", | 2348 | unexpected |= intmask; |
2348 | mmc_hostname(host->mmc), intmask); | ||
2349 | sdhci_dumpregs(host); | ||
2350 | |||
2351 | sdhci_writel(host, intmask, SDHCI_INT_STATUS); | 2349 | sdhci_writel(host, intmask, SDHCI_INT_STATUS); |
2352 | } | 2350 | } |
2353 | 2351 | ||
2354 | result = IRQ_HANDLED; | 2352 | result = IRQ_HANDLED; |
2355 | 2353 | ||
2356 | mmiowb(); | 2354 | intmask = sdhci_readl(host, SDHCI_INT_STATUS); |
2355 | if (intmask && --max_loops) | ||
2356 | goto again; | ||
2357 | out: | 2357 | out: |
2358 | spin_unlock(&host->lock); | 2358 | spin_unlock(&host->lock); |
2359 | 2359 | ||
2360 | if (unexpected) { | ||
2361 | pr_err("%s: Unexpected interrupt 0x%08x.\n", | ||
2362 | mmc_hostname(host->mmc), unexpected); | ||
2363 | sdhci_dumpregs(host); | ||
2364 | } | ||
2360 | /* | 2365 | /* |
2361 | * We have to delay this as it calls back into the driver. | 2366 | * We have to delay this as it calls back into the driver. |
2362 | */ | 2367 | */ |
@@ -2379,6 +2384,9 @@ int sdhci_suspend_host(struct sdhci_host *host) | |||
2379 | int ret; | 2384 | int ret; |
2380 | bool has_tuning_timer; | 2385 | bool has_tuning_timer; |
2381 | 2386 | ||
2387 | if (host->ops->platform_suspend) | ||
2388 | host->ops->platform_suspend(host); | ||
2389 | |||
2382 | sdhci_disable_card_detection(host); | 2390 | sdhci_disable_card_detection(host); |
2383 | 2391 | ||
2384 | /* Disable tuning since we are suspending */ | 2392 | /* Disable tuning since we are suspending */ |
@@ -2423,12 +2431,24 @@ int sdhci_resume_host(struct sdhci_host *host) | |||
2423 | if (ret) | 2431 | if (ret) |
2424 | return ret; | 2432 | return ret; |
2425 | 2433 | ||
2426 | sdhci_init(host, (host->mmc->pm_flags & MMC_PM_KEEP_POWER)); | 2434 | if ((host->mmc->pm_flags & MMC_PM_KEEP_POWER) && |
2427 | mmiowb(); | 2435 | (host->quirks2 & SDHCI_QUIRK2_HOST_OFF_CARD_ON)) { |
2436 | /* Card keeps power but host controller does not */ | ||
2437 | sdhci_init(host, 0); | ||
2438 | host->pwr = 0; | ||
2439 | host->clock = 0; | ||
2440 | sdhci_do_set_ios(host, &host->mmc->ios); | ||
2441 | } else { | ||
2442 | sdhci_init(host, (host->mmc->pm_flags & MMC_PM_KEEP_POWER)); | ||
2443 | mmiowb(); | ||
2444 | } | ||
2428 | 2445 | ||
2429 | ret = mmc_resume_host(host->mmc); | 2446 | ret = mmc_resume_host(host->mmc); |
2430 | sdhci_enable_card_detection(host); | 2447 | sdhci_enable_card_detection(host); |
2431 | 2448 | ||
2449 | if (host->ops->platform_resume) | ||
2450 | host->ops->platform_resume(host); | ||
2451 | |||
2432 | /* Set the re-tuning expiration flag */ | 2452 | /* Set the re-tuning expiration flag */ |
2433 | if ((host->version >= SDHCI_SPEC_300) && host->tuning_count && | 2453 | if ((host->version >= SDHCI_SPEC_300) && host->tuning_count && |
2434 | (host->tuning_mode == SDHCI_TUNING_MODE_1)) | 2454 | (host->tuning_mode == SDHCI_TUNING_MODE_1)) |
@@ -2762,8 +2782,9 @@ int sdhci_add_host(struct sdhci_host *host) | |||
2762 | mmc_card_is_removable(mmc)) | 2782 | mmc_card_is_removable(mmc)) |
2763 | mmc->caps |= MMC_CAP_NEEDS_POLL; | 2783 | mmc->caps |= MMC_CAP_NEEDS_POLL; |
2764 | 2784 | ||
2765 | /* UHS-I mode(s) supported by the host controller. */ | 2785 | /* Any UHS-I mode in caps implies SDR12 and SDR25 support. */ |
2766 | if (host->version >= SDHCI_SPEC_300) | 2786 | if (caps[1] & (SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 | |
2787 | SDHCI_SUPPORT_DDR50)) | ||
2767 | mmc->caps |= MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25; | 2788 | mmc->caps |= MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25; |
2768 | 2789 | ||
2769 | /* SDR104 supports also implies SDR50 support */ | 2790 | /* SDR104 supports also implies SDR50 support */ |
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index ad265b96b75b..f761f23d2a28 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h | |||
@@ -275,6 +275,8 @@ struct sdhci_ops { | |||
275 | void (*platform_reset_exit)(struct sdhci_host *host, u8 mask); | 275 | void (*platform_reset_exit)(struct sdhci_host *host, u8 mask); |
276 | int (*set_uhs_signaling)(struct sdhci_host *host, unsigned int uhs); | 276 | int (*set_uhs_signaling)(struct sdhci_host *host, unsigned int uhs); |
277 | void (*hw_reset)(struct sdhci_host *host); | 277 | void (*hw_reset)(struct sdhci_host *host); |
278 | void (*platform_suspend)(struct sdhci_host *host); | ||
279 | void (*platform_resume)(struct sdhci_host *host); | ||
278 | }; | 280 | }; |
279 | 281 | ||
280 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS | 282 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS |
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index 352d4797865b..724b35e85a26 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include <linux/mmc/sh_mmcif.h> | 56 | #include <linux/mmc/sh_mmcif.h> |
57 | #include <linux/pagemap.h> | 57 | #include <linux/pagemap.h> |
58 | #include <linux/platform_device.h> | 58 | #include <linux/platform_device.h> |
59 | #include <linux/pm_qos.h> | ||
59 | #include <linux/pm_runtime.h> | 60 | #include <linux/pm_runtime.h> |
60 | #include <linux/spinlock.h> | 61 | #include <linux/spinlock.h> |
61 | #include <linux/module.h> | 62 | #include <linux/module.h> |
@@ -285,7 +286,7 @@ static void sh_mmcif_start_dma_rx(struct sh_mmcif_host *host) | |||
285 | DMA_FROM_DEVICE); | 286 | DMA_FROM_DEVICE); |
286 | if (ret > 0) { | 287 | if (ret > 0) { |
287 | host->dma_active = true; | 288 | host->dma_active = true; |
288 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, | 289 | desc = dmaengine_prep_slave_sg(chan, sg, ret, |
289 | DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | 290 | DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
290 | } | 291 | } |
291 | 292 | ||
@@ -334,7 +335,7 @@ static void sh_mmcif_start_dma_tx(struct sh_mmcif_host *host) | |||
334 | DMA_TO_DEVICE); | 335 | DMA_TO_DEVICE); |
335 | if (ret > 0) { | 336 | if (ret > 0) { |
336 | host->dma_active = true; | 337 | host->dma_active = true; |
337 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, | 338 | desc = dmaengine_prep_slave_sg(chan, sg, ret, |
338 | DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | 339 | DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
339 | } | 340 | } |
340 | 341 | ||
@@ -453,7 +454,8 @@ static void sh_mmcif_clock_control(struct sh_mmcif_host *host, unsigned int clk) | |||
453 | sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_SUP_PCLK); | 454 | sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_SUP_PCLK); |
454 | else | 455 | else |
455 | sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_CLEAR & | 456 | sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_CLEAR & |
456 | ((fls(host->clk / clk) - 1) << 16)); | 457 | ((fls(DIV_ROUND_UP(host->clk, |
458 | clk) - 1) - 1) << 16)); | ||
457 | 459 | ||
458 | sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_ENABLE); | 460 | sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_ENABLE); |
459 | } | 461 | } |
@@ -745,7 +747,6 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host, | |||
745 | case MMC_SET_WRITE_PROT: | 747 | case MMC_SET_WRITE_PROT: |
746 | case MMC_CLR_WRITE_PROT: | 748 | case MMC_CLR_WRITE_PROT: |
747 | case MMC_ERASE: | 749 | case MMC_ERASE: |
748 | case MMC_GEN_CMD: | ||
749 | tmp |= CMD_SET_RBSY; | 750 | tmp |= CMD_SET_RBSY; |
750 | break; | 751 | break; |
751 | } | 752 | } |
@@ -828,7 +829,6 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host, | |||
828 | case MMC_SET_WRITE_PROT: | 829 | case MMC_SET_WRITE_PROT: |
829 | case MMC_CLR_WRITE_PROT: | 830 | case MMC_CLR_WRITE_PROT: |
830 | case MMC_ERASE: | 831 | case MMC_ERASE: |
831 | case MMC_GEN_CMD: | ||
832 | mask = MASK_START_CMD | MASK_MRBSYE; | 832 | mask = MASK_START_CMD | MASK_MRBSYE; |
833 | break; | 833 | break; |
834 | default: | 834 | default: |
@@ -1298,14 +1298,8 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev) | |||
1298 | spin_lock_init(&host->lock); | 1298 | spin_lock_init(&host->lock); |
1299 | 1299 | ||
1300 | mmc->ops = &sh_mmcif_ops; | 1300 | mmc->ops = &sh_mmcif_ops; |
1301 | mmc->f_max = host->clk; | 1301 | mmc->f_max = host->clk / 2; |
1302 | /* close to 400KHz */ | 1302 | mmc->f_min = host->clk / 512; |
1303 | if (mmc->f_max < 51200000) | ||
1304 | mmc->f_min = mmc->f_max / 128; | ||
1305 | else if (mmc->f_max < 102400000) | ||
1306 | mmc->f_min = mmc->f_max / 256; | ||
1307 | else | ||
1308 | mmc->f_min = mmc->f_max / 512; | ||
1309 | if (pd->ocr) | 1303 | if (pd->ocr) |
1310 | mmc->ocr_avail = pd->ocr; | 1304 | mmc->ocr_avail = pd->ocr; |
1311 | mmc->caps = MMC_CAP_MMC_HIGHSPEED; | 1305 | mmc->caps = MMC_CAP_MMC_HIGHSPEED; |
@@ -1346,6 +1340,8 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev) | |||
1346 | if (ret < 0) | 1340 | if (ret < 0) |
1347 | goto clean_up5; | 1341 | goto clean_up5; |
1348 | 1342 | ||
1343 | dev_pm_qos_expose_latency_limit(&pdev->dev, 100); | ||
1344 | |||
1349 | dev_info(&pdev->dev, "driver version %s\n", DRIVER_VERSION); | 1345 | dev_info(&pdev->dev, "driver version %s\n", DRIVER_VERSION); |
1350 | dev_dbg(&pdev->dev, "chip ver H'%04x\n", | 1346 | dev_dbg(&pdev->dev, "chip ver H'%04x\n", |
1351 | sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0x0000ffff); | 1347 | sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0x0000ffff); |
@@ -1376,6 +1372,8 @@ static int __devexit sh_mmcif_remove(struct platform_device *pdev) | |||
1376 | host->dying = true; | 1372 | host->dying = true; |
1377 | pm_runtime_get_sync(&pdev->dev); | 1373 | pm_runtime_get_sync(&pdev->dev); |
1378 | 1374 | ||
1375 | dev_pm_qos_hide_latency_limit(&pdev->dev); | ||
1376 | |||
1379 | mmc_remove_host(host->mmc); | 1377 | mmc_remove_host(host->mmc); |
1380 | sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, MASK_ALL); | 1378 | sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, MASK_ALL); |
1381 | 1379 | ||
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 58da3c44acc5..934b68e9efc3 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c | |||
@@ -90,6 +90,15 @@ static int sh_mobile_sdhi_write16_hook(struct tmio_mmc_host *host, int addr) | |||
90 | return 0; | 90 | return 0; |
91 | } | 91 | } |
92 | 92 | ||
93 | static void sh_mobile_sdhi_cd_wakeup(const struct platform_device *pdev) | ||
94 | { | ||
95 | mmc_detect_change(dev_get_drvdata(&pdev->dev), msecs_to_jiffies(100)); | ||
96 | } | ||
97 | |||
98 | static const struct sh_mobile_sdhi_ops sdhi_ops = { | ||
99 | .cd_wakeup = sh_mobile_sdhi_cd_wakeup, | ||
100 | }; | ||
101 | |||
93 | static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | 102 | static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) |
94 | { | 103 | { |
95 | struct sh_mobile_sdhi *priv; | 104 | struct sh_mobile_sdhi *priv; |
@@ -109,6 +118,12 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
109 | mmc_data = &priv->mmc_data; | 118 | mmc_data = &priv->mmc_data; |
110 | p->pdata = mmc_data; | 119 | p->pdata = mmc_data; |
111 | 120 | ||
121 | if (p->init) { | ||
122 | ret = p->init(pdev, &sdhi_ops); | ||
123 | if (ret) | ||
124 | goto einit; | ||
125 | } | ||
126 | |||
112 | snprintf(clk_name, sizeof(clk_name), "sdhi%d", pdev->id); | 127 | snprintf(clk_name, sizeof(clk_name), "sdhi%d", pdev->id); |
113 | priv->clk = clk_get(&pdev->dev, clk_name); | 128 | priv->clk = clk_get(&pdev->dev, clk_name); |
114 | if (IS_ERR(priv->clk)) { | 129 | if (IS_ERR(priv->clk)) { |
@@ -117,8 +132,6 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
117 | goto eclkget; | 132 | goto eclkget; |
118 | } | 133 | } |
119 | 134 | ||
120 | clk_enable(priv->clk); | ||
121 | |||
122 | mmc_data->hclk = clk_get_rate(priv->clk); | 135 | mmc_data->hclk = clk_get_rate(priv->clk); |
123 | mmc_data->set_pwr = sh_mobile_sdhi_set_pwr; | 136 | mmc_data->set_pwr = sh_mobile_sdhi_set_pwr; |
124 | mmc_data->get_cd = sh_mobile_sdhi_get_cd; | 137 | mmc_data->get_cd = sh_mobile_sdhi_get_cd; |
@@ -129,6 +142,7 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
129 | mmc_data->write16_hook = sh_mobile_sdhi_write16_hook; | 142 | mmc_data->write16_hook = sh_mobile_sdhi_write16_hook; |
130 | mmc_data->ocr_mask = p->tmio_ocr_mask; | 143 | mmc_data->ocr_mask = p->tmio_ocr_mask; |
131 | mmc_data->capabilities |= p->tmio_caps; | 144 | mmc_data->capabilities |= p->tmio_caps; |
145 | mmc_data->cd_gpio = p->cd_gpio; | ||
132 | 146 | ||
133 | if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) { | 147 | if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) { |
134 | priv->param_tx.slave_id = p->dma_slave_tx; | 148 | priv->param_tx.slave_id = p->dma_slave_tx; |
@@ -211,7 +225,7 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
211 | 225 | ||
212 | dev_info(&pdev->dev, "%s base at 0x%08lx clock rate %u MHz\n", | 226 | dev_info(&pdev->dev, "%s base at 0x%08lx clock rate %u MHz\n", |
213 | mmc_hostname(host->mmc), (unsigned long) | 227 | mmc_hostname(host->mmc), (unsigned long) |
214 | (platform_get_resource(pdev,IORESOURCE_MEM, 0)->start), | 228 | (platform_get_resource(pdev, IORESOURCE_MEM, 0)->start), |
215 | mmc_data->hclk / 1000000); | 229 | mmc_data->hclk / 1000000); |
216 | 230 | ||
217 | return ret; | 231 | return ret; |
@@ -232,9 +246,11 @@ eirq_sdio: | |||
232 | eirq_card_detect: | 246 | eirq_card_detect: |
233 | tmio_mmc_host_remove(host); | 247 | tmio_mmc_host_remove(host); |
234 | eprobe: | 248 | eprobe: |
235 | clk_disable(priv->clk); | ||
236 | clk_put(priv->clk); | 249 | clk_put(priv->clk); |
237 | eclkget: | 250 | eclkget: |
251 | if (p->cleanup) | ||
252 | p->cleanup(pdev); | ||
253 | einit: | ||
238 | kfree(priv); | 254 | kfree(priv); |
239 | return ret; | 255 | return ret; |
240 | } | 256 | } |
@@ -258,8 +274,11 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev) | |||
258 | free_irq(irq, host); | 274 | free_irq(irq, host); |
259 | } | 275 | } |
260 | 276 | ||
261 | clk_disable(priv->clk); | ||
262 | clk_put(priv->clk); | 277 | clk_put(priv->clk); |
278 | |||
279 | if (p->cleanup) | ||
280 | p->cleanup(pdev); | ||
281 | |||
263 | kfree(priv); | 282 | kfree(priv); |
264 | 283 | ||
265 | return 0; | 284 | return 0; |
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index f96c536d130a..d857f5c6e7d9 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h | |||
@@ -47,16 +47,14 @@ struct tmio_mmc_host { | |||
47 | struct mmc_request *mrq; | 47 | struct mmc_request *mrq; |
48 | struct mmc_data *data; | 48 | struct mmc_data *data; |
49 | struct mmc_host *mmc; | 49 | struct mmc_host *mmc; |
50 | unsigned int sdio_irq_enabled; | 50 | |
51 | /* Controller power state */ | ||
52 | bool power; | ||
51 | 53 | ||
52 | /* Callbacks for clock / power control */ | 54 | /* Callbacks for clock / power control */ |
53 | void (*set_pwr)(struct platform_device *host, int state); | 55 | void (*set_pwr)(struct platform_device *host, int state); |
54 | void (*set_clk_div)(struct platform_device *host, int state); | 56 | void (*set_clk_div)(struct platform_device *host, int state); |
55 | 57 | ||
56 | int pm_error; | ||
57 | /* recognise system-wide suspend in runtime PM methods */ | ||
58 | bool pm_global; | ||
59 | |||
60 | /* pio related stuff */ | 58 | /* pio related stuff */ |
61 | struct scatterlist *sg_ptr; | 59 | struct scatterlist *sg_ptr; |
62 | struct scatterlist *sg_orig; | 60 | struct scatterlist *sg_orig; |
@@ -86,6 +84,7 @@ struct tmio_mmc_host { | |||
86 | spinlock_t lock; /* protect host private data */ | 84 | spinlock_t lock; /* protect host private data */ |
87 | unsigned long last_req_ts; | 85 | unsigned long last_req_ts; |
88 | struct mutex ios_lock; /* protect set_ios() context */ | 86 | struct mutex ios_lock; /* protect set_ios() context */ |
87 | bool native_hotplug; | ||
89 | }; | 88 | }; |
90 | 89 | ||
91 | int tmio_mmc_host_probe(struct tmio_mmc_host **host, | 90 | int tmio_mmc_host_probe(struct tmio_mmc_host **host, |
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c index 8253ec12003e..fff928604859 100644 --- a/drivers/mmc/host/tmio_mmc_dma.c +++ b/drivers/mmc/host/tmio_mmc_dma.c | |||
@@ -88,7 +88,7 @@ static void tmio_mmc_start_dma_rx(struct tmio_mmc_host *host) | |||
88 | 88 | ||
89 | ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_FROM_DEVICE); | 89 | ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_FROM_DEVICE); |
90 | if (ret > 0) | 90 | if (ret > 0) |
91 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, | 91 | desc = dmaengine_prep_slave_sg(chan, sg, ret, |
92 | DMA_DEV_TO_MEM, DMA_CTRL_ACK); | 92 | DMA_DEV_TO_MEM, DMA_CTRL_ACK); |
93 | 93 | ||
94 | if (desc) { | 94 | if (desc) { |
@@ -169,7 +169,7 @@ static void tmio_mmc_start_dma_tx(struct tmio_mmc_host *host) | |||
169 | 169 | ||
170 | ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_TO_DEVICE); | 170 | ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_TO_DEVICE); |
171 | if (ret > 0) | 171 | if (ret > 0) |
172 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, | 172 | desc = dmaengine_prep_slave_sg(chan, sg, ret, |
173 | DMA_MEM_TO_DEV, DMA_CTRL_ACK); | 173 | DMA_MEM_TO_DEV, DMA_CTRL_ACK); |
174 | 174 | ||
175 | if (desc) { | 175 | if (desc) { |
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index 5f9ad74fbf80..9a7996ade58e 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c | |||
@@ -34,11 +34,13 @@ | |||
34 | #include <linux/io.h> | 34 | #include <linux/io.h> |
35 | #include <linux/irq.h> | 35 | #include <linux/irq.h> |
36 | #include <linux/mfd/tmio.h> | 36 | #include <linux/mfd/tmio.h> |
37 | #include <linux/mmc/cd-gpio.h> | ||
37 | #include <linux/mmc/host.h> | 38 | #include <linux/mmc/host.h> |
38 | #include <linux/mmc/tmio.h> | 39 | #include <linux/mmc/tmio.h> |
39 | #include <linux/module.h> | 40 | #include <linux/module.h> |
40 | #include <linux/pagemap.h> | 41 | #include <linux/pagemap.h> |
41 | #include <linux/platform_device.h> | 42 | #include <linux/platform_device.h> |
43 | #include <linux/pm_qos.h> | ||
42 | #include <linux/pm_runtime.h> | 44 | #include <linux/pm_runtime.h> |
43 | #include <linux/scatterlist.h> | 45 | #include <linux/scatterlist.h> |
44 | #include <linux/spinlock.h> | 46 | #include <linux/spinlock.h> |
@@ -126,7 +128,6 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable) | |||
126 | struct tmio_mmc_host *host = mmc_priv(mmc); | 128 | struct tmio_mmc_host *host = mmc_priv(mmc); |
127 | 129 | ||
128 | if (enable) { | 130 | if (enable) { |
129 | host->sdio_irq_enabled = 1; | ||
130 | host->sdio_irq_mask = TMIO_SDIO_MASK_ALL & | 131 | host->sdio_irq_mask = TMIO_SDIO_MASK_ALL & |
131 | ~TMIO_SDIO_STAT_IOIRQ; | 132 | ~TMIO_SDIO_STAT_IOIRQ; |
132 | sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001); | 133 | sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001); |
@@ -135,7 +136,6 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable) | |||
135 | host->sdio_irq_mask = TMIO_SDIO_MASK_ALL; | 136 | host->sdio_irq_mask = TMIO_SDIO_MASK_ALL; |
136 | sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask); | 137 | sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask); |
137 | sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0000); | 138 | sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0000); |
138 | host->sdio_irq_enabled = 0; | ||
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
@@ -303,6 +303,7 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command | |||
303 | { | 303 | { |
304 | struct mmc_data *data = host->data; | 304 | struct mmc_data *data = host->data; |
305 | int c = cmd->opcode; | 305 | int c = cmd->opcode; |
306 | u32 irq_mask = TMIO_MASK_CMD; | ||
306 | 307 | ||
307 | /* Command 12 is handled by hardware */ | 308 | /* Command 12 is handled by hardware */ |
308 | if (cmd->opcode == 12 && !cmd->arg) { | 309 | if (cmd->opcode == 12 && !cmd->arg) { |
@@ -338,7 +339,9 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command | |||
338 | c |= TRANSFER_READ; | 339 | c |= TRANSFER_READ; |
339 | } | 340 | } |
340 | 341 | ||
341 | tmio_mmc_enable_mmc_irqs(host, TMIO_MASK_CMD); | 342 | if (!host->native_hotplug) |
343 | irq_mask &= ~(TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT); | ||
344 | tmio_mmc_enable_mmc_irqs(host, irq_mask); | ||
342 | 345 | ||
343 | /* Fire off the command */ | 346 | /* Fire off the command */ |
344 | sd_ctrl_write32(host, CTL_ARG_REG, cmd->arg); | 347 | sd_ctrl_write32(host, CTL_ARG_REG, cmd->arg); |
@@ -757,7 +760,7 @@ fail: | |||
757 | static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | 760 | static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) |
758 | { | 761 | { |
759 | struct tmio_mmc_host *host = mmc_priv(mmc); | 762 | struct tmio_mmc_host *host = mmc_priv(mmc); |
760 | struct tmio_mmc_data *pdata = host->pdata; | 763 | struct device *dev = &host->pdev->dev; |
761 | unsigned long flags; | 764 | unsigned long flags; |
762 | 765 | ||
763 | mutex_lock(&host->ios_lock); | 766 | mutex_lock(&host->ios_lock); |
@@ -765,13 +768,13 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
765 | spin_lock_irqsave(&host->lock, flags); | 768 | spin_lock_irqsave(&host->lock, flags); |
766 | if (host->mrq) { | 769 | if (host->mrq) { |
767 | if (IS_ERR(host->mrq)) { | 770 | if (IS_ERR(host->mrq)) { |
768 | dev_dbg(&host->pdev->dev, | 771 | dev_dbg(dev, |
769 | "%s.%d: concurrent .set_ios(), clk %u, mode %u\n", | 772 | "%s.%d: concurrent .set_ios(), clk %u, mode %u\n", |
770 | current->comm, task_pid_nr(current), | 773 | current->comm, task_pid_nr(current), |
771 | ios->clock, ios->power_mode); | 774 | ios->clock, ios->power_mode); |
772 | host->mrq = ERR_PTR(-EINTR); | 775 | host->mrq = ERR_PTR(-EINTR); |
773 | } else { | 776 | } else { |
774 | dev_dbg(&host->pdev->dev, | 777 | dev_dbg(dev, |
775 | "%s.%d: CMD%u active since %lu, now %lu!\n", | 778 | "%s.%d: CMD%u active since %lu, now %lu!\n", |
776 | current->comm, task_pid_nr(current), | 779 | current->comm, task_pid_nr(current), |
777 | host->mrq->cmd->opcode, host->last_req_ts, jiffies); | 780 | host->mrq->cmd->opcode, host->last_req_ts, jiffies); |
@@ -787,13 +790,15 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
787 | spin_unlock_irqrestore(&host->lock, flags); | 790 | spin_unlock_irqrestore(&host->lock, flags); |
788 | 791 | ||
789 | /* | 792 | /* |
790 | * pdata->power == false only if COLD_CD is available, otherwise only | 793 | * host->power toggles between false and true in both cases - either |
791 | * in short time intervals during probing or resuming | 794 | * or not the controller can be runtime-suspended during inactivity. |
795 | * But if the controller has to be kept on, the runtime-pm usage_count | ||
796 | * is kept positive, so no suspending actually takes place. | ||
792 | */ | 797 | */ |
793 | if (ios->power_mode == MMC_POWER_ON && ios->clock) { | 798 | if (ios->power_mode == MMC_POWER_ON && ios->clock) { |
794 | if (!pdata->power) { | 799 | if (!host->power) { |
795 | pm_runtime_get_sync(&host->pdev->dev); | 800 | pm_runtime_get_sync(dev); |
796 | pdata->power = true; | 801 | host->power = true; |
797 | } | 802 | } |
798 | tmio_mmc_set_clock(host, ios->clock); | 803 | tmio_mmc_set_clock(host, ios->clock); |
799 | /* power up SD bus */ | 804 | /* power up SD bus */ |
@@ -804,9 +809,9 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
804 | } else if (ios->power_mode != MMC_POWER_UP) { | 809 | } else if (ios->power_mode != MMC_POWER_UP) { |
805 | if (host->set_pwr && ios->power_mode == MMC_POWER_OFF) | 810 | if (host->set_pwr && ios->power_mode == MMC_POWER_OFF) |
806 | host->set_pwr(host->pdev, 0); | 811 | host->set_pwr(host->pdev, 0); |
807 | if (pdata->power) { | 812 | if (host->power) { |
808 | pdata->power = false; | 813 | host->power = false; |
809 | pm_runtime_put(&host->pdev->dev); | 814 | pm_runtime_put(dev); |
810 | } | 815 | } |
811 | tmio_mmc_clk_stop(host); | 816 | tmio_mmc_clk_stop(host); |
812 | } | 817 | } |
@@ -912,7 +917,11 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, | |||
912 | else | 917 | else |
913 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; | 918 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; |
914 | 919 | ||
915 | pdata->power = false; | 920 | _host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD || |
921 | mmc->caps & MMC_CAP_NEEDS_POLL || | ||
922 | mmc->caps & MMC_CAP_NONREMOVABLE); | ||
923 | |||
924 | _host->power = false; | ||
916 | pm_runtime_enable(&pdev->dev); | 925 | pm_runtime_enable(&pdev->dev); |
917 | ret = pm_runtime_resume(&pdev->dev); | 926 | ret = pm_runtime_resume(&pdev->dev); |
918 | if (ret < 0) | 927 | if (ret < 0) |
@@ -925,14 +934,13 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, | |||
925 | * 3) a worker thread polls the sdhi - indicated by MMC_CAP_NEEDS_POLL | 934 | * 3) a worker thread polls the sdhi - indicated by MMC_CAP_NEEDS_POLL |
926 | * 4) the medium is non-removable - indicated by MMC_CAP_NONREMOVABLE | 935 | * 4) the medium is non-removable - indicated by MMC_CAP_NONREMOVABLE |
927 | * | 936 | * |
928 | * While we increment the rtpm counter for all scenarios when the mmc | 937 | * While we increment the runtime PM counter for all scenarios when |
929 | * core activates us by calling an appropriate set_ios(), we must | 938 | * the mmc core activates us by calling an appropriate set_ios(), we |
939 | * must additionally ensure that in case 2) the tmio mmc hardware stays | ||
930 | * additionally ensure that in case 2) the tmio mmc hardware stays | 940 | * additionally ensure that in case 2) the tmio mmc hardware stays |
931 | * powered on during runtime for the card detection to work. | 941 | * powered on during runtime for the card detection to work. |
932 | */ | 942 | */ |
933 | if (!(pdata->flags & TMIO_MMC_HAS_COLD_CD | 943 | if (_host->native_hotplug) |
934 | || mmc->caps & MMC_CAP_NEEDS_POLL | ||
935 | || mmc->caps & MMC_CAP_NONREMOVABLE)) | ||
936 | pm_runtime_get_noresume(&pdev->dev); | 944 | pm_runtime_get_noresume(&pdev->dev); |
937 | 945 | ||
938 | tmio_mmc_clk_stop(_host); | 946 | tmio_mmc_clk_stop(_host); |
@@ -955,14 +963,26 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, | |||
955 | 963 | ||
956 | mmc_add_host(mmc); | 964 | mmc_add_host(mmc); |
957 | 965 | ||
966 | dev_pm_qos_expose_latency_limit(&pdev->dev, 100); | ||
967 | |||
958 | /* Unmask the IRQs we want to know about */ | 968 | /* Unmask the IRQs we want to know about */ |
959 | if (!_host->chan_rx) | 969 | if (!_host->chan_rx) |
960 | irq_mask |= TMIO_MASK_READOP; | 970 | irq_mask |= TMIO_MASK_READOP; |
961 | if (!_host->chan_tx) | 971 | if (!_host->chan_tx) |
962 | irq_mask |= TMIO_MASK_WRITEOP; | 972 | irq_mask |= TMIO_MASK_WRITEOP; |
973 | if (!_host->native_hotplug) | ||
974 | irq_mask &= ~(TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT); | ||
963 | 975 | ||
964 | tmio_mmc_enable_mmc_irqs(_host, irq_mask); | 976 | tmio_mmc_enable_mmc_irqs(_host, irq_mask); |
965 | 977 | ||
978 | if (pdata->flags & TMIO_MMC_USE_GPIO_CD) { | ||
979 | ret = mmc_cd_gpio_request(mmc, pdata->cd_gpio); | ||
980 | if (ret < 0) { | ||
981 | tmio_mmc_host_remove(_host); | ||
982 | return ret; | ||
983 | } | ||
984 | } | ||
985 | |||
966 | *host = _host; | 986 | *host = _host; |
967 | 987 | ||
968 | return 0; | 988 | return 0; |
@@ -980,20 +1000,22 @@ EXPORT_SYMBOL(tmio_mmc_host_probe); | |||
980 | void tmio_mmc_host_remove(struct tmio_mmc_host *host) | 1000 | void tmio_mmc_host_remove(struct tmio_mmc_host *host) |
981 | { | 1001 | { |
982 | struct platform_device *pdev = host->pdev; | 1002 | struct platform_device *pdev = host->pdev; |
1003 | struct tmio_mmc_data *pdata = host->pdata; | ||
1004 | struct mmc_host *mmc = host->mmc; | ||
983 | 1005 | ||
984 | /* | 1006 | if (pdata->flags & TMIO_MMC_USE_GPIO_CD) |
985 | * We don't have to manipulate pdata->power here: if there is a card in | 1007 | /* |
986 | * the slot, the runtime PM is active and our .runtime_resume() will not | 1008 | * This means we can miss a card-eject, but this is anyway |
987 | * be run. If there is no card in the slot and the platform can suspend | 1009 | * possible, because of delayed processing of hotplug events. |
988 | * the controller, the runtime PM is suspended and pdata->power == false, | 1010 | */ |
989 | * so, our .runtime_resume() will not try to detect a card in the slot. | 1011 | mmc_cd_gpio_free(mmc); |
990 | */ | 1012 | |
991 | if (host->pdata->flags & TMIO_MMC_HAS_COLD_CD | 1013 | if (!host->native_hotplug) |
992 | || host->mmc->caps & MMC_CAP_NEEDS_POLL | ||
993 | || host->mmc->caps & MMC_CAP_NONREMOVABLE) | ||
994 | pm_runtime_get_sync(&pdev->dev); | 1014 | pm_runtime_get_sync(&pdev->dev); |
995 | 1015 | ||
996 | mmc_remove_host(host->mmc); | 1016 | dev_pm_qos_hide_latency_limit(&pdev->dev); |
1017 | |||
1018 | mmc_remove_host(mmc); | ||
997 | cancel_work_sync(&host->done); | 1019 | cancel_work_sync(&host->done); |
998 | cancel_delayed_work_sync(&host->delayed_reset_work); | 1020 | cancel_delayed_work_sync(&host->delayed_reset_work); |
999 | tmio_mmc_release_dma(host); | 1021 | tmio_mmc_release_dma(host); |
@@ -1002,7 +1024,7 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host) | |||
1002 | pm_runtime_disable(&pdev->dev); | 1024 | pm_runtime_disable(&pdev->dev); |
1003 | 1025 | ||
1004 | iounmap(host->ctl); | 1026 | iounmap(host->ctl); |
1005 | mmc_free_host(host->mmc); | 1027 | mmc_free_host(mmc); |
1006 | } | 1028 | } |
1007 | EXPORT_SYMBOL(tmio_mmc_host_remove); | 1029 | EXPORT_SYMBOL(tmio_mmc_host_remove); |
1008 | 1030 | ||
@@ -1016,8 +1038,6 @@ int tmio_mmc_host_suspend(struct device *dev) | |||
1016 | if (!ret) | 1038 | if (!ret) |
1017 | tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); | 1039 | tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); |
1018 | 1040 | ||
1019 | host->pm_error = pm_runtime_put_sync(dev); | ||
1020 | |||
1021 | return ret; | 1041 | return ret; |
1022 | } | 1042 | } |
1023 | EXPORT_SYMBOL(tmio_mmc_host_suspend); | 1043 | EXPORT_SYMBOL(tmio_mmc_host_suspend); |
@@ -1027,20 +1047,10 @@ int tmio_mmc_host_resume(struct device *dev) | |||
1027 | struct mmc_host *mmc = dev_get_drvdata(dev); | 1047 | struct mmc_host *mmc = dev_get_drvdata(dev); |
1028 | struct tmio_mmc_host *host = mmc_priv(mmc); | 1048 | struct tmio_mmc_host *host = mmc_priv(mmc); |
1029 | 1049 | ||
1030 | /* The MMC core will perform the complete set up */ | 1050 | tmio_mmc_reset(host); |
1031 | host->pdata->power = false; | 1051 | tmio_mmc_enable_dma(host, true); |
1032 | |||
1033 | host->pm_global = true; | ||
1034 | if (!host->pm_error) | ||
1035 | pm_runtime_get_sync(dev); | ||
1036 | |||
1037 | if (host->pm_global) { | ||
1038 | /* Runtime PM resume callback didn't run */ | ||
1039 | tmio_mmc_reset(host); | ||
1040 | tmio_mmc_enable_dma(host, true); | ||
1041 | host->pm_global = false; | ||
1042 | } | ||
1043 | 1052 | ||
1053 | /* The MMC core will perform the complete set up */ | ||
1044 | return mmc_resume_host(mmc); | 1054 | return mmc_resume_host(mmc); |
1045 | } | 1055 | } |
1046 | EXPORT_SYMBOL(tmio_mmc_host_resume); | 1056 | EXPORT_SYMBOL(tmio_mmc_host_resume); |
@@ -1057,19 +1067,10 @@ int tmio_mmc_host_runtime_resume(struct device *dev) | |||
1057 | { | 1067 | { |
1058 | struct mmc_host *mmc = dev_get_drvdata(dev); | 1068 | struct mmc_host *mmc = dev_get_drvdata(dev); |
1059 | struct tmio_mmc_host *host = mmc_priv(mmc); | 1069 | struct tmio_mmc_host *host = mmc_priv(mmc); |
1060 | struct tmio_mmc_data *pdata = host->pdata; | ||
1061 | 1070 | ||
1062 | tmio_mmc_reset(host); | 1071 | tmio_mmc_reset(host); |
1063 | tmio_mmc_enable_dma(host, true); | 1072 | tmio_mmc_enable_dma(host, true); |
1064 | 1073 | ||
1065 | if (pdata->power) { | ||
1066 | /* Only entered after a card-insert interrupt */ | ||
1067 | if (!mmc->card) | ||
1068 | tmio_mmc_set_ios(mmc, &mmc->ios); | ||
1069 | mmc_detect_change(mmc, msecs_to_jiffies(100)); | ||
1070 | } | ||
1071 | host->pm_global = false; | ||
1072 | |||
1073 | return 0; | 1074 | return 0; |
1074 | } | 1075 | } |
1075 | EXPORT_SYMBOL(tmio_mmc_host_runtime_resume); | 1076 | EXPORT_SYMBOL(tmio_mmc_host_runtime_resume); |