|
17 | 17 | #include <linux/regulator/consumer.h> |
18 | 18 | #include <linux/interconnect.h> |
19 | 19 | #include <linux/pinctrl/consumer.h> |
| 20 | +#include <linux/reset.h> |
20 | 21 |
|
21 | 22 | #include "sdhci-pltfm.h" |
22 | 23 | #include "cqhci.h" |
@@ -2507,6 +2508,43 @@ static inline void sdhci_msm_get_of_property(struct platform_device *pdev, |
2507 | 2508 | of_property_read_u32(node, "qcom,dll-config", &msm_host->dll_config); |
2508 | 2509 | } |
2509 | 2510 |
|
| 2511 | +static int sdhci_msm_gcc_reset(struct device *dev, struct sdhci_host *host) |
| 2512 | +{ |
| 2513 | + struct reset_control *reset; |
| 2514 | + int ret = 0; |
| 2515 | + |
| 2516 | + reset = reset_control_get_optional_exclusive(dev, NULL); |
| 2517 | + if (IS_ERR(reset)) |
| 2518 | + return dev_err_probe(dev, PTR_ERR(reset), |
| 2519 | + "unable to acquire core_reset\n"); |
| 2520 | + |
| 2521 | + if (!reset) |
| 2522 | + return ret; |
| 2523 | + |
| 2524 | + ret = reset_control_assert(reset); |
| 2525 | + if (ret) { |
| 2526 | + reset_control_put(reset); |
| 2527 | + return dev_err_probe(dev, ret, "core_reset assert failed\n"); |
| 2528 | + } |
| 2529 | + |
| 2530 | + /* |
| 2531 | + * The hardware requirement for delay between assert/deassert |
| 2532 | + * is at least 3-4 sleep clock (32.7KHz) cycles, which comes to |
| 2533 | + * ~125us (4/32768). To be on the safe side add 200us delay. |
| 2534 | + */ |
| 2535 | + usleep_range(200, 210); |
| 2536 | + |
| 2537 | + ret = reset_control_deassert(reset); |
| 2538 | + if (ret) { |
| 2539 | + reset_control_put(reset); |
| 2540 | + return dev_err_probe(dev, ret, "core_reset deassert failed\n"); |
| 2541 | + } |
| 2542 | + |
| 2543 | + usleep_range(200, 210); |
| 2544 | + reset_control_put(reset); |
| 2545 | + |
| 2546 | + return ret; |
| 2547 | +} |
2510 | 2548 |
|
2511 | 2549 | static int sdhci_msm_probe(struct platform_device *pdev) |
2512 | 2550 | { |
@@ -2554,6 +2592,10 @@ static int sdhci_msm_probe(struct platform_device *pdev) |
2554 | 2592 |
|
2555 | 2593 | msm_host->saved_tuning_phase = INVALID_TUNING_PHASE; |
2556 | 2594 |
|
| 2595 | + ret = sdhci_msm_gcc_reset(&pdev->dev, host); |
| 2596 | + if (ret) |
| 2597 | + goto pltfm_free; |
| 2598 | + |
2557 | 2599 | /* Setup SDCC bus voter clock. */ |
2558 | 2600 | msm_host->bus_clk = devm_clk_get(&pdev->dev, "bus"); |
2559 | 2601 | if (!IS_ERR(msm_host->bus_clk)) { |
|
0 commit comments