diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-11 13:56:48 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-11 13:56:48 -0500 |
commit | aa7ed01f93ff7e149cad46f13f66b269d59c9bc0 (patch) | |
tree | ab46a44f3c83c75e1c81f211acd0d68ffe60dd7c /drivers/mmc/core/pwrseq_emmc.c | |
parent | 7796c11c728ad40ba4151d559a949c002deffb9a (diff) | |
parent | 017210d1c0dc2e2d3b142985cb31d90b98dc0f0f (diff) |
Merge tag 'mmc-v3.20-1' of git://git.linaro.org/people/ulf.hansson/mmc
Pull MMC updates from Ulf Hansson:
"MMC core:
- Support for MMC power sequences.
- SDIO function devicetree subnode parsing.
- Refactor the hardware reset routines and enable it for SD cards.
- Various code quality improvements, especially for slot-gpio.
MMC host:
- dw_mmc: Various fixes and cleanups.
- dw_mmc: Convert to mmc_send_tuning().
- moxart: Fix probe logic.
- sdhci: Various fixes and cleanups
- sdhci: Asynchronous request handling support.
- sdhci-pxav3: Various fixes and cleanups.
- sdhci-tegra: Fixes for T114, T124 and T132.
- rtsx: Various fixes and cleanups.
- rtsx: Support for SDIO.
- sdhi/tmio: Refactor and cleanup of header files.
- omap_hsmmc: Use slot-gpio and common MMC DT parser.
- Make all hosts to deal with errors from mmc_of_parse().
- sunxi: Various fixes and cleanups.
- sdhci: Support for Fujitsu SDHCI controller f_sdh30"
* tag 'mmc-v3.20-1' of git://git.linaro.org/people/ulf.hansson/mmc: (117 commits)
mmc: sdhci-s3c: solve problem with sleeping in atomic context
mmc: pwrseq: add driver for emmc hardware reset
mmc: moxart: fix probe logic
mmc: core: Invoke mmc_pwrseq_post_power_on() prior MMC_POWER_ON state
mmc: pwrseq_simple: Add optional reference clock support
mmc: pwrseq: Document optional clock for the simple power sequence
mmc: pwrseq_simple: Extend to support more pins
mmc: pwrseq: Document that simple sequence support more than one GPIO
mmc: Add hardware dependencies for sdhci-pxav3 and sdhci-pxav2
mmc: sdhci-pxav3: Modify clock settings for the SDR50 and DDR50 modes
mmc: sdhci-pxav3: Extend binding with SDIO3 conf reg for the Armada 38x
mmc: sdhci-pxav3: Fix Armada 38x controller's caps according to erratum ERR-7878951
mmc: sdhci-pxav3: Fix SDR50 and DDR50 capabilities for the Armada 38x flavor
mmc: sdhci: switch voltage before sdhci_set_ios in runtime resume
mmc: tegra: Write xfer_mode, CMD regs in together
mmc: Resolve BKOPS compatability issue
mmc: sdhci-pxav3: fix setting of pdata->clk_delay_cycles
mmc: dw_mmc: rockchip: remove incorrect __exit_p()
mmc: dw_mmc: exynos: remove incorrect __exit_p()
mmc: Fix menuconfig alignment of MMC_SDHCI_* options
...
Diffstat (limited to 'drivers/mmc/core/pwrseq_emmc.c')
-rw-r--r-- | drivers/mmc/core/pwrseq_emmc.c | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/drivers/mmc/core/pwrseq_emmc.c b/drivers/mmc/core/pwrseq_emmc.c new file mode 100644 index 000000000000..a2d545904fbf --- /dev/null +++ b/drivers/mmc/core/pwrseq_emmc.c | |||
@@ -0,0 +1,101 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015, Samsung Electronics Co., Ltd. | ||
3 | * | ||
4 | * Author: Marek Szyprowski <m.szyprowski@samsung.com> | ||
5 | * | ||
6 | * License terms: GNU General Public License (GPL) version 2 | ||
7 | * | ||
8 | * Simple eMMC hardware reset provider | ||
9 | */ | ||
10 | #include <linux/delay.h> | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/slab.h> | ||
13 | #include <linux/device.h> | ||
14 | #include <linux/err.h> | ||
15 | #include <linux/gpio/consumer.h> | ||
16 | #include <linux/reboot.h> | ||
17 | |||
18 | #include <linux/mmc/host.h> | ||
19 | |||
20 | #include "pwrseq.h" | ||
21 | |||
22 | struct mmc_pwrseq_emmc { | ||
23 | struct mmc_pwrseq pwrseq; | ||
24 | struct notifier_block reset_nb; | ||
25 | struct gpio_desc *reset_gpio; | ||
26 | }; | ||
27 | |||
28 | static void __mmc_pwrseq_emmc_reset(struct mmc_pwrseq_emmc *pwrseq) | ||
29 | { | ||
30 | gpiod_set_value(pwrseq->reset_gpio, 1); | ||
31 | udelay(1); | ||
32 | gpiod_set_value(pwrseq->reset_gpio, 0); | ||
33 | udelay(200); | ||
34 | } | ||
35 | |||
36 | static void mmc_pwrseq_emmc_reset(struct mmc_host *host) | ||
37 | { | ||
38 | struct mmc_pwrseq_emmc *pwrseq = container_of(host->pwrseq, | ||
39 | struct mmc_pwrseq_emmc, pwrseq); | ||
40 | |||
41 | __mmc_pwrseq_emmc_reset(pwrseq); | ||
42 | } | ||
43 | |||
44 | static void mmc_pwrseq_emmc_free(struct mmc_host *host) | ||
45 | { | ||
46 | struct mmc_pwrseq_emmc *pwrseq = container_of(host->pwrseq, | ||
47 | struct mmc_pwrseq_emmc, pwrseq); | ||
48 | |||
49 | unregister_restart_handler(&pwrseq->reset_nb); | ||
50 | gpiod_put(pwrseq->reset_gpio); | ||
51 | kfree(pwrseq); | ||
52 | host->pwrseq = NULL; | ||
53 | } | ||
54 | |||
55 | static struct mmc_pwrseq_ops mmc_pwrseq_emmc_ops = { | ||
56 | .post_power_on = mmc_pwrseq_emmc_reset, | ||
57 | .free = mmc_pwrseq_emmc_free, | ||
58 | }; | ||
59 | |||
60 | static int mmc_pwrseq_emmc_reset_nb(struct notifier_block *this, | ||
61 | unsigned long mode, void *cmd) | ||
62 | { | ||
63 | struct mmc_pwrseq_emmc *pwrseq = container_of(this, | ||
64 | struct mmc_pwrseq_emmc, reset_nb); | ||
65 | |||
66 | __mmc_pwrseq_emmc_reset(pwrseq); | ||
67 | return NOTIFY_DONE; | ||
68 | } | ||
69 | |||
70 | int mmc_pwrseq_emmc_alloc(struct mmc_host *host, struct device *dev) | ||
71 | { | ||
72 | struct mmc_pwrseq_emmc *pwrseq; | ||
73 | int ret = 0; | ||
74 | |||
75 | pwrseq = kzalloc(sizeof(struct mmc_pwrseq_emmc), GFP_KERNEL); | ||
76 | if (!pwrseq) | ||
77 | return -ENOMEM; | ||
78 | |||
79 | pwrseq->reset_gpio = gpiod_get_index(dev, "reset", 0, GPIOD_OUT_LOW); | ||
80 | if (IS_ERR(pwrseq->reset_gpio)) { | ||
81 | ret = PTR_ERR(pwrseq->reset_gpio); | ||
82 | goto free; | ||
83 | } | ||
84 | |||
85 | /* | ||
86 | * register reset handler to ensure emmc reset also from | ||
87 | * emergency_reboot(), priority 129 schedules it just before | ||
88 | * system reboot | ||
89 | */ | ||
90 | pwrseq->reset_nb.notifier_call = mmc_pwrseq_emmc_reset_nb; | ||
91 | pwrseq->reset_nb.priority = 129; | ||
92 | register_restart_handler(&pwrseq->reset_nb); | ||
93 | |||
94 | pwrseq->pwrseq.ops = &mmc_pwrseq_emmc_ops; | ||
95 | host->pwrseq = &pwrseq->pwrseq; | ||
96 | |||
97 | return 0; | ||
98 | free: | ||
99 | kfree(pwrseq); | ||
100 | return ret; | ||
101 | } | ||