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.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.c')
-rw-r--r-- | drivers/mmc/core/pwrseq.c | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/drivers/mmc/core/pwrseq.c b/drivers/mmc/core/pwrseq.c new file mode 100644 index 000000000000..862356123d78 --- /dev/null +++ b/drivers/mmc/core/pwrseq.c | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Linaro Ltd | ||
3 | * | ||
4 | * Author: Ulf Hansson <ulf.hansson@linaro.org> | ||
5 | * | ||
6 | * License terms: GNU General Public License (GPL) version 2 | ||
7 | * | ||
8 | * MMC power sequence management | ||
9 | */ | ||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/platform_device.h> | ||
12 | #include <linux/err.h> | ||
13 | #include <linux/of.h> | ||
14 | #include <linux/of_platform.h> | ||
15 | |||
16 | #include <linux/mmc/host.h> | ||
17 | |||
18 | #include "pwrseq.h" | ||
19 | |||
20 | struct mmc_pwrseq_match { | ||
21 | const char *compatible; | ||
22 | int (*alloc)(struct mmc_host *host, struct device *dev); | ||
23 | }; | ||
24 | |||
25 | static struct mmc_pwrseq_match pwrseq_match[] = { | ||
26 | { | ||
27 | .compatible = "mmc-pwrseq-simple", | ||
28 | .alloc = mmc_pwrseq_simple_alloc, | ||
29 | }, { | ||
30 | .compatible = "mmc-pwrseq-emmc", | ||
31 | .alloc = mmc_pwrseq_emmc_alloc, | ||
32 | }, | ||
33 | }; | ||
34 | |||
35 | static struct mmc_pwrseq_match *mmc_pwrseq_find(struct device_node *np) | ||
36 | { | ||
37 | struct mmc_pwrseq_match *match = ERR_PTR(-ENODEV); | ||
38 | int i; | ||
39 | |||
40 | for (i = 0; i < ARRAY_SIZE(pwrseq_match); i++) { | ||
41 | if (of_device_is_compatible(np, pwrseq_match[i].compatible)) { | ||
42 | match = &pwrseq_match[i]; | ||
43 | break; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | return match; | ||
48 | } | ||
49 | |||
50 | int mmc_pwrseq_alloc(struct mmc_host *host) | ||
51 | { | ||
52 | struct platform_device *pdev; | ||
53 | struct device_node *np; | ||
54 | struct mmc_pwrseq_match *match; | ||
55 | int ret = 0; | ||
56 | |||
57 | np = of_parse_phandle(host->parent->of_node, "mmc-pwrseq", 0); | ||
58 | if (!np) | ||
59 | return 0; | ||
60 | |||
61 | pdev = of_find_device_by_node(np); | ||
62 | if (!pdev) { | ||
63 | ret = -ENODEV; | ||
64 | goto err; | ||
65 | } | ||
66 | |||
67 | match = mmc_pwrseq_find(np); | ||
68 | if (IS_ERR(match)) { | ||
69 | ret = PTR_ERR(match); | ||
70 | goto err; | ||
71 | } | ||
72 | |||
73 | ret = match->alloc(host, &pdev->dev); | ||
74 | if (!ret) | ||
75 | dev_info(host->parent, "allocated mmc-pwrseq\n"); | ||
76 | |||
77 | err: | ||
78 | of_node_put(np); | ||
79 | return ret; | ||
80 | } | ||
81 | |||
82 | void mmc_pwrseq_pre_power_on(struct mmc_host *host) | ||
83 | { | ||
84 | struct mmc_pwrseq *pwrseq = host->pwrseq; | ||
85 | |||
86 | if (pwrseq && pwrseq->ops && pwrseq->ops->pre_power_on) | ||
87 | pwrseq->ops->pre_power_on(host); | ||
88 | } | ||
89 | |||
90 | void mmc_pwrseq_post_power_on(struct mmc_host *host) | ||
91 | { | ||
92 | struct mmc_pwrseq *pwrseq = host->pwrseq; | ||
93 | |||
94 | if (pwrseq && pwrseq->ops && pwrseq->ops->post_power_on) | ||
95 | pwrseq->ops->post_power_on(host); | ||
96 | } | ||
97 | |||
98 | void mmc_pwrseq_power_off(struct mmc_host *host) | ||
99 | { | ||
100 | struct mmc_pwrseq *pwrseq = host->pwrseq; | ||
101 | |||
102 | if (pwrseq && pwrseq->ops && pwrseq->ops->power_off) | ||
103 | pwrseq->ops->power_off(host); | ||
104 | } | ||
105 | |||
106 | void mmc_pwrseq_free(struct mmc_host *host) | ||
107 | { | ||
108 | struct mmc_pwrseq *pwrseq = host->pwrseq; | ||
109 | |||
110 | if (pwrseq && pwrseq->ops && pwrseq->ops->free) | ||
111 | pwrseq->ops->free(host); | ||
112 | } | ||