| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 6 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 | | - * (at your option) any later version. |
|---|
| 8 | 4 | */ |
|---|
| 9 | 5 | |
|---|
| 10 | 6 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 14 | 10 | #include <linux/of_address.h> |
|---|
| 15 | 11 | #include <linux/mmc/slot-gpio.h> |
|---|
| 16 | 12 | #include <linux/pm_runtime.h> |
|---|
| 13 | +#include <linux/rockchip/cpu.h> |
|---|
| 17 | 14 | #include <linux/slab.h> |
|---|
| 18 | 15 | |
|---|
| 19 | 16 | #include "dw_mmc.h" |
|---|
| .. | .. |
|---|
| 169 | 166 | * It's impossible all 4 fixed phase won't be able to work. |
|---|
| 170 | 167 | */ |
|---|
| 171 | 168 | for (i = 0; i < ARRAY_SIZE(degrees); i++) { |
|---|
| 172 | | - degree = degrees[i] + priv->last_degree; |
|---|
| 169 | + degree = degrees[i] + priv->last_degree + 90; |
|---|
| 173 | 170 | degree = degree % 360; |
|---|
| 174 | 171 | clk_set_phase(priv->sample_clk, degree); |
|---|
| 175 | 172 | if (!mmc_send_tuning(mmc, opcode, NULL)) |
|---|
| .. | .. |
|---|
| 177 | 174 | } |
|---|
| 178 | 175 | |
|---|
| 179 | 176 | if (i == ARRAY_SIZE(degrees)) { |
|---|
| 180 | | - dev_warn(host->dev, "All phases bad!"); |
|---|
| 177 | + dev_warn(host->dev, "V2 All phases bad!"); |
|---|
| 181 | 178 | return -EIO; |
|---|
| 182 | 179 | } |
|---|
| 183 | 180 | |
|---|
| 184 | 181 | done: |
|---|
| 185 | | - dev_info(host->dev, "Successfully tuned phase to %d\n", degrees[i]); |
|---|
| 182 | + dev_info(host->dev, "Successfully tuned phase to %d\n", degree); |
|---|
| 186 | 183 | priv->last_degree = degree; |
|---|
| 187 | 184 | return 0; |
|---|
| 188 | 185 | } |
|---|
| .. | .. |
|---|
| 211 | 208 | } |
|---|
| 212 | 209 | |
|---|
| 213 | 210 | if (priv->use_v2_tuning) { |
|---|
| 214 | | - ret = dw_mci_v2_execute_tuning(slot, opcode); |
|---|
| 215 | | - if (!ret) |
|---|
| 211 | + if (!dw_mci_v2_execute_tuning(slot, opcode)) |
|---|
| 216 | 212 | return 0; |
|---|
| 217 | 213 | /* Otherwise we continue using fine tuning */ |
|---|
| 218 | 214 | } |
|---|
| .. | .. |
|---|
| 394 | 390 | "rockchip,rk3288-dw-mshc")) |
|---|
| 395 | 391 | host->bus_hz /= RK3288_CLKGEN_DIV; |
|---|
| 396 | 392 | |
|---|
| 393 | + if (of_device_is_compatible(host->dev->of_node, |
|---|
| 394 | + "rockchip,rv1106-dw-mshc") && |
|---|
| 395 | + rockchip_get_cpu_version() == 0 && |
|---|
| 396 | + !strcmp(dev_name(host->dev), "ffaa0000.mmc")) { |
|---|
| 397 | + if (device_property_read_bool(host->dev, "no-sd")) { |
|---|
| 398 | + dev_err(host->dev, "Invalid usage, should be SD card only\n"); |
|---|
| 399 | + return -EINVAL; |
|---|
| 400 | + } |
|---|
| 401 | + |
|---|
| 402 | + host->is_rv1106_sd = true; |
|---|
| 403 | + dev_info(host->dev, "is rv1106 sd\n"); |
|---|
| 404 | + } |
|---|
| 405 | + |
|---|
| 397 | 406 | host->need_xfer_timer = true; |
|---|
| 398 | 407 | return 0; |
|---|
| 399 | 408 | } |
|---|
| .. | .. |
|---|
| 452 | 461 | * pm_runtime_force_resume calls rpm resume callback |
|---|
| 453 | 462 | */ |
|---|
| 454 | 463 | pm_runtime_get_noresume(&pdev->dev); |
|---|
| 464 | + pm_runtime_set_active(&pdev->dev); |
|---|
| 455 | 465 | |
|---|
| 456 | 466 | if (use_rpm) { |
|---|
| 457 | | - pm_runtime_set_active(&pdev->dev); |
|---|
| 458 | 467 | pm_runtime_enable(&pdev->dev); |
|---|
| 459 | 468 | pm_runtime_set_autosuspend_delay(&pdev->dev, 50); |
|---|
| 460 | 469 | pm_runtime_use_autosuspend(&pdev->dev); |
|---|