Skip to content

Commit bfffbea

Browse files
committed
Merge tag 'mmc-updates-for-3.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc
Pull MMC updates from Chris Ball: "MMC highlights for 3.11: Core: - Add support for eMMC 5.1 devices - Add MMC_CAP_AGGRESSIVE_PM capability for aggressive power management of eMMC/SD between requests, using runtime PM - Add an ioctl to perform the eMMC 4.5 Sanitize command. Sample code at: git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc-utils.git Drivers: - dw_mmc: Add support for Rockchip's Cortex-A9 SoCs - dw_mmc: Add support for Altera SoCFPGAs - sdhci-esdhc-imx: Add support for 8-bit bus width, non-removable cards - sdhci-bcm-kona: New driver for Broadcom Kona (281xx) SoCs - sdhi/tmio: Add DT DMA support" * tag 'mmc-updates-for-3.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc: (87 commits) mmc: bcm281xx SDHCI driver mmc: sdhci: add card_event callback to sdhci mmc: core: Fixup Oops for SDIO shutdown mmc: sdhci-pci: add another device id mmc: esdhc: Fix bug when writing to SDHCI_HOST_CONTROL register mmc: esdhc: Add support for 8-bit bus width and non-removable card mmc: core: production year for eMMC 4.41 and later mmc: omap: remove unnecessary #if 0's mmc: sdhci: fix ctrl_2 on super-speed selection mmc: dw_mmc-pltfm: add Rockchip variant mmc: dw_mmc-pltfm: move probe and remove below dt match table mmc: dw_mmc-pltfm: remove static from dw_mci_pltfm_remove mmc: sdhci-acpi: add support for eMMC hardware reset for HID 80860F14 mmc: sdhci-pci: add support for eMMC hardware reset for BYT eMMC. mmc: dw_mmc: Add support DW SD/MMC driver on SOCFPGA mmc: sdhci: fix caps2 for HS200 sdhci-pxav3: Fix runtime PM initialization mmc: core: Add DT-bindings for MMC_CAP2_FULL_PWR_CYCLE mmc: core: Invent MMC_CAP2_FULL_PWR_CYCLE mmc: core: Enable power_off_notify for eMMC shutdown sequence ...
2 parents 34ae0a6 + 01ebea1 commit bfffbea

73 files changed

Lines changed: 1807 additions & 790 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/devicetree/bindings/mmc/mmc.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Optional properties:
2828
- cap-mmc-highspeed: MMC high-speed timing is supported
2929
- cap-power-off-card: powering off the card is safe
3030
- cap-sdio-irq: enable SDIO IRQ signalling on this interface
31+
- full-pwr-cycle: full power cycle of the card is supported
3132

3233
*NOTE* on CD and WP polarity. To use common for all SD/MMC host controllers line
3334
polarity properties, we have to fix the meaning of the "normal" and "inverted"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
* Rockchip specific extensions to the Synopsis Designware Mobile
2+
Storage Host Controller
3+
4+
The Synopsis designware mobile storage host controller is used to interface
5+
a SoC with storage medium such as eMMC or SD/MMC cards. This file documents
6+
differences between the core Synopsis dw mshc controller properties described
7+
by synopsis-dw-mshc.txt and the properties used by the Rockchip specific
8+
extensions to the Synopsis Designware Mobile Storage Host Controller.
9+
10+
Required Properties:
11+
12+
* compatible: should be
13+
- "rockchip,rk2928-dw-mshc": for Rockchip RK2928 and following
14+
15+
Example:
16+
17+
rkdwmmc0@12200000 {
18+
compatible = "rockchip,rk2928-dw-mshc";
19+
reg = <0x12200000 0x1000>;
20+
interrupts = <0 75 0>;
21+
#address-cells = <1>;
22+
#size-cells = <0>;
23+
};

‎Documentation/devicetree/bindings/mmc/synopsis-dw-mshc.txt‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ Required Properties:
3939

4040
Optional properties:
4141

42+
* clocks: from common clock binding: handle to biu and ciu clocks for the
43+
bus interface unit clock and the card interface unit clock.
44+
45+
* clock-names: from common clock binding: Shall be "biu" and "ciu".
46+
If the biu clock is missing we'll simply skip enabling it. If the
47+
ciu clock is missing we'll just assume that the clock is running at
48+
clock-frequency. It is an error to omit both the ciu clock and the
49+
clock-frequency.
50+
51+
* clock-frequency: should be the frequency (in Hz) of the ciu clock. If this
52+
is specified and the ciu clock is specified then we'll try to set the ciu
53+
clock to this at probe time.
54+
4255
* num-slots: specifies the number of slots supported by the controller.
4356
The number of physical slots actually used could be equal or less than the
4457
value specified by num-slots. If this property is not specified, the value
@@ -55,6 +68,9 @@ Optional properties:
5568

5669
* broken-cd: as documented in mmc core bindings.
5770

71+
* vmmc-supply: The phandle to the regulator to use for vmmc. If this is
72+
specified we'll defer probe until we can find this regulator.
73+
5874
Aliases:
5975

6076
- All the MSHC controller nodes should be represented in the aliases node using
@@ -67,18 +83,22 @@ board specific portions as listed below.
6783

6884
dwmmc0@12200000 {
6985
compatible = "snps,dw-mshc";
86+
clocks = <&clock 351>, <&clock 132>;
87+
clock-names = "biu", "ciu";
7088
reg = <0x12200000 0x1000>;
7189
interrupts = <0 75 0>;
7290
#address-cells = <1>;
7391
#size-cells = <0>;
7492
};
7593

7694
dwmmc0@12200000 {
95+
clock-frequency = <400000000>;
7796
num-slots = <1>;
7897
supports-highspeed;
7998
broken-cd;
8099
fifo-depth = <0x80>;
81100
card-detect-delay = <200>;
101+
vmmc-supply = <&buck8>;
82102

83103
slot@0 {
84104
reg = <0>;

‎arch/arm/configs/bcm_defconfig‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ CONFIG_BACKLIGHT_LCD_SUPPORT=y
7878
CONFIG_LCD_CLASS_DEVICE=y
7979
CONFIG_BACKLIGHT_CLASS_DEVICE=y
8080
# CONFIG_USB_SUPPORT is not set
81+
CONFIG_MMC=y
82+
CONFIG_MMC_UNSAFE_RESUME=y
83+
CONFIG_MMC_BLOCK_MINORS=32
84+
CONFIG_MMC_TEST=y
85+
CONFIG_MMC_SDHCI=y
86+
CONFIG_MMC_SDHCI_PLTFM=y
87+
CONFIG_MMC_SDHCI_BCM_KONA=y
8188
CONFIG_NEW_LEDS=y
8289
CONFIG_LEDS_CLASS=y
8390
CONFIG_LEDS_TRIGGERS=y

‎drivers/mmc/card/block.c‎

Lines changed: 95 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/delay.h>
3535
#include <linux/capability.h>
3636
#include <linux/compat.h>
37+
#include <linux/pm_runtime.h>
3738

3839
#include <linux/mmc/ioctl.h>
3940
#include <linux/mmc/card.h>
@@ -58,6 +59,8 @@ MODULE_ALIAS("mmc:block");
5859
#define INAND_CMD38_ARG_SECTRIM1 0x81
5960
#define INAND_CMD38_ARG_SECTRIM2 0x88
6061
#define MMC_BLK_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */
62+
#define MMC_SANITIZE_REQ_TIMEOUT 240000
63+
#define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF0000) >> 16)
6164

6265
#define mmc_req_rel_wr(req) (((req->cmd_flags & REQ_FUA) || \
6366
(req->cmd_flags & REQ_META)) && \
@@ -222,7 +225,7 @@ static ssize_t power_ro_lock_store(struct device *dev,
222225
md = mmc_blk_get(dev_to_disk(dev));
223226
card = md->queue.card;
224227

225-
mmc_claim_host(card->host);
228+
mmc_get_card(card);
226229

227230
ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP,
228231
card->ext_csd.boot_ro_lock |
@@ -233,7 +236,7 @@ static ssize_t power_ro_lock_store(struct device *dev,
233236
else
234237
card->ext_csd.boot_ro_lock |= EXT_CSD_BOOT_WP_B_PWR_WP_EN;
235238

236-
mmc_release_host(card->host);
239+
mmc_put_card(card);
237240

238241
if (!ret) {
239242
pr_info("%s: Locking boot partition ro until next power on\n",
@@ -408,6 +411,35 @@ static int ioctl_rpmb_card_status_poll(struct mmc_card *card, u32 *status,
408411
return err;
409412
}
410413

414+
static int ioctl_do_sanitize(struct mmc_card *card)
415+
{
416+
int err;
417+
418+
if (!(mmc_can_sanitize(card) &&
419+
(card->host->caps2 & MMC_CAP2_SANITIZE))) {
420+
pr_warn("%s: %s - SANITIZE is not supported\n",
421+
mmc_hostname(card->host), __func__);
422+
err = -EOPNOTSUPP;
423+
goto out;
424+
}
425+
426+
pr_debug("%s: %s - SANITIZE IN PROGRESS...\n",
427+
mmc_hostname(card->host), __func__);
428+
429+
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
430+
EXT_CSD_SANITIZE_START, 1,
431+
MMC_SANITIZE_REQ_TIMEOUT);
432+
433+
if (err)
434+
pr_err("%s: %s - EXT_CSD_SANITIZE_START failed. err=%d\n",
435+
mmc_hostname(card->host), __func__, err);
436+
437+
pr_debug("%s: %s - SANITIZE COMPLETED\n", mmc_hostname(card->host),
438+
__func__);
439+
out:
440+
return err;
441+
}
442+
411443
static int mmc_blk_ioctl_cmd(struct block_device *bdev,
412444
struct mmc_ioc_cmd __user *ic_ptr)
413445
{
@@ -491,7 +523,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
491523

492524
mrq.cmd = &cmd;
493525

494-
mmc_claim_host(card->host);
526+
mmc_get_card(card);
495527

496528
err = mmc_blk_part_switch(card, md);
497529
if (err)
@@ -510,6 +542,17 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
510542
goto cmd_rel_host;
511543
}
512544

545+
if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) &&
546+
(cmd.opcode == MMC_SWITCH)) {
547+
err = ioctl_do_sanitize(card);
548+
549+
if (err)
550+
pr_err("%s: ioctl_do_sanitize() failed. err = %d",
551+
__func__, err);
552+
553+
goto cmd_rel_host;
554+
}
555+
513556
mmc_wait_for_req(card->host, &mrq);
514557

515558
if (cmd.error) {
@@ -558,7 +601,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
558601
}
559602

560603
cmd_rel_host:
561-
mmc_release_host(card->host);
604+
mmc_put_card(card);
562605

563606
cmd_done:
564607
mmc_blk_put(md);
@@ -939,34 +982,22 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
939982
{
940983
struct mmc_blk_data *md = mq->data;
941984
struct mmc_card *card = md->queue.card;
942-
unsigned int from, nr, arg, trim_arg, erase_arg;
985+
unsigned int from, nr, arg;
943986
int err = 0, type = MMC_BLK_SECDISCARD;
944987

945-
if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) {
988+
if (!(mmc_can_secure_erase_trim(card))) {
946989
err = -EOPNOTSUPP;
947990
goto out;
948991
}
949992

950993
from = blk_rq_pos(req);
951994
nr = blk_rq_sectors(req);
952995

953-
/* The sanitize operation is supported at v4.5 only */
954-
if (mmc_can_sanitize(card)) {
955-
erase_arg = MMC_ERASE_ARG;
956-
trim_arg = MMC_TRIM_ARG;
957-
} else {
958-
erase_arg = MMC_SECURE_ERASE_ARG;
959-
trim_arg = MMC_SECURE_TRIM1_ARG;
960-
}
996+
if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr))
997+
arg = MMC_SECURE_TRIM1_ARG;
998+
else
999+
arg = MMC_SECURE_ERASE_ARG;
9611000

962-
if (mmc_erase_group_aligned(card, from, nr))
963-
arg = erase_arg;
964-
else if (mmc_can_trim(card))
965-
arg = trim_arg;
966-
else {
967-
err = -EINVAL;
968-
goto out;
969-
}
9701001
retry:
9711002
if (card->quirks & MMC_QUIRK_INAND_CMD38) {
9721003
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
@@ -1002,9 +1033,6 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
10021033
goto out;
10031034
}
10041035

1005-
if (mmc_can_sanitize(card))
1006-
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1007-
EXT_CSD_SANITIZE_START, 1, 0);
10081036
out_retry:
10091037
if (err && !mmc_blk_reset(md, card->host, type))
10101038
goto retry;
@@ -1895,7 +1923,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
18951923

18961924
if (req && !mq->mqrq_prev->req)
18971925
/* claim host only for the first request */
1898-
mmc_claim_host(card->host);
1926+
mmc_get_card(card);
18991927

19001928
ret = mmc_blk_part_switch(card, md);
19011929
if (ret) {
@@ -1939,7 +1967,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
19391967
* In case sepecial request, there is no reentry to
19401968
* the 'mmc_blk_issue_rq' with 'mqrq_prev->req'.
19411969
*/
1942-
mmc_release_host(card->host);
1970+
mmc_put_card(card);
19431971
return ret;
19441972
}
19451973

@@ -2158,6 +2186,14 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md)
21582186
struct mmc_card *card;
21592187

21602188
if (md) {
2189+
/*
2190+
* Flush remaining requests and free queues. It
2191+
* is freeing the queue that stops new requests
2192+
* from being accepted.
2193+
*/
2194+
mmc_cleanup_queue(&md->queue);
2195+
if (md->flags & MMC_BLK_PACKED_CMD)
2196+
mmc_packed_clean(&md->queue);
21612197
card = md->queue.card;
21622198
if (md->disk->flags & GENHD_FL_UP) {
21632199
device_remove_file(disk_to_dev(md->disk), &md->force_ro);
@@ -2166,14 +2202,8 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md)
21662202
device_remove_file(disk_to_dev(md->disk),
21672203
&md->power_ro_lock);
21682204

2169-
/* Stop new requests from getting into the queue */
21702205
del_gendisk(md->disk);
21712206
}
2172-
2173-
/* Then flush out any already in there */
2174-
mmc_cleanup_queue(&md->queue);
2175-
if (md->flags & MMC_BLK_PACKED_CMD)
2176-
mmc_packed_clean(&md->queue);
21772207
mmc_blk_put(md);
21782208
}
21792209
}
@@ -2336,6 +2366,19 @@ static int mmc_blk_probe(struct mmc_card *card)
23362366
if (mmc_add_disk(part_md))
23372367
goto out;
23382368
}
2369+
2370+
pm_runtime_set_autosuspend_delay(&card->dev, 3000);
2371+
pm_runtime_use_autosuspend(&card->dev);
2372+
2373+
/*
2374+
* Don't enable runtime PM for SD-combo cards here. Leave that
2375+
* decision to be taken during the SDIO init sequence instead.
2376+
*/
2377+
if (card->type != MMC_TYPE_SD_COMBO) {
2378+
pm_runtime_set_active(&card->dev);
2379+
pm_runtime_enable(&card->dev);
2380+
}
2381+
23392382
return 0;
23402383

23412384
out:
@@ -2349,20 +2392,24 @@ static void mmc_blk_remove(struct mmc_card *card)
23492392
struct mmc_blk_data *md = mmc_get_drvdata(card);
23502393

23512394
mmc_blk_remove_parts(card, md);
2395+
pm_runtime_get_sync(&card->dev);
23522396
mmc_claim_host(card->host);
23532397
mmc_blk_part_switch(card, md);
23542398
mmc_release_host(card->host);
2399+
if (card->type != MMC_TYPE_SD_COMBO)
2400+
pm_runtime_disable(&card->dev);
2401+
pm_runtime_put_noidle(&card->dev);
23552402
mmc_blk_remove_req(md);
23562403
mmc_set_drvdata(card, NULL);
23572404
}
23582405

2359-
#ifdef CONFIG_PM
2360-
static int mmc_blk_suspend(struct mmc_card *card)
2406+
static int _mmc_blk_suspend(struct mmc_card *card)
23612407
{
23622408
struct mmc_blk_data *part_md;
23632409
struct mmc_blk_data *md = mmc_get_drvdata(card);
23642410

23652411
if (md) {
2412+
pm_runtime_get_sync(&card->dev);
23662413
mmc_queue_suspend(&md->queue);
23672414
list_for_each_entry(part_md, &md->part, part) {
23682415
mmc_queue_suspend(&part_md->queue);
@@ -2371,6 +2418,17 @@ static int mmc_blk_suspend(struct mmc_card *card)
23712418
return 0;
23722419
}
23732420

2421+
static void mmc_blk_shutdown(struct mmc_card *card)
2422+
{
2423+
_mmc_blk_suspend(card);
2424+
}
2425+
2426+
#ifdef CONFIG_PM
2427+
static int mmc_blk_suspend(struct mmc_card *card)
2428+
{
2429+
return _mmc_blk_suspend(card);
2430+
}
2431+
23742432
static int mmc_blk_resume(struct mmc_card *card)
23752433
{
23762434
struct mmc_blk_data *part_md;
@@ -2386,6 +2444,7 @@ static int mmc_blk_resume(struct mmc_card *card)
23862444
list_for_each_entry(part_md, &md->part, part) {
23872445
mmc_queue_resume(&part_md->queue);
23882446
}
2447+
pm_runtime_put(&card->dev);
23892448
}
23902449
return 0;
23912450
}
@@ -2402,6 +2461,7 @@ static struct mmc_driver mmc_driver = {
24022461
.remove = mmc_blk_remove,
24032462
.suspend = mmc_blk_suspend,
24042463
.resume = mmc_blk_resume,
2464+
.shutdown = mmc_blk_shutdown,
24052465
};
24062466

24072467
static int __init mmc_blk_init(void)

0 commit comments

Comments
 (0)