forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/mmc/host/dw_mmc-rockchip.c
....@@ -1,10 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * 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.
84 */
95
106 #include <linux/module.h>
....@@ -14,6 +10,7 @@
1410 #include <linux/of_address.h>
1511 #include <linux/mmc/slot-gpio.h>
1612 #include <linux/pm_runtime.h>
13
+#include <linux/rockchip/cpu.h>
1714 #include <linux/slab.h>
1815
1916 #include "dw_mmc.h"
....@@ -169,7 +166,7 @@
169166 * It's impossible all 4 fixed phase won't be able to work.
170167 */
171168 for (i = 0; i < ARRAY_SIZE(degrees); i++) {
172
- degree = degrees[i] + priv->last_degree;
169
+ degree = degrees[i] + priv->last_degree + 90;
173170 degree = degree % 360;
174171 clk_set_phase(priv->sample_clk, degree);
175172 if (!mmc_send_tuning(mmc, opcode, NULL))
....@@ -177,12 +174,12 @@
177174 }
178175
179176 if (i == ARRAY_SIZE(degrees)) {
180
- dev_warn(host->dev, "All phases bad!");
177
+ dev_warn(host->dev, "V2 All phases bad!");
181178 return -EIO;
182179 }
183180
184181 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);
186183 priv->last_degree = degree;
187184 return 0;
188185 }
....@@ -211,8 +208,7 @@
211208 }
212209
213210 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))
216212 return 0;
217213 /* Otherwise we continue using fine tuning */
218214 }
....@@ -394,6 +390,19 @@
394390 "rockchip,rk3288-dw-mshc"))
395391 host->bus_hz /= RK3288_CLKGEN_DIV;
396392
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
+
397406 host->need_xfer_timer = true;
398407 return 0;
399408 }
....@@ -438,8 +447,10 @@
438447 if (!pdev->dev.of_node)
439448 return -ENODEV;
440449
441
- if (!device_property_read_bool(&pdev->dev, "non-removable") &&
442
- !device_property_read_bool(&pdev->dev, "cd-gpios"))
450
+ if ((!device_property_read_bool(&pdev->dev, "non-removable") &&
451
+ !device_property_read_bool(&pdev->dev, "cd-gpios")) ||
452
+ (device_property_read_bool(&pdev->dev, "no-sd") &&
453
+ device_property_read_bool(&pdev->dev, "no-mmc")))
443454 use_rpm = false;
444455
445456 match = of_match_node(dw_mci_rockchip_match, pdev->dev.of_node);
....@@ -450,9 +461,9 @@
450461 * pm_runtime_force_resume calls rpm resume callback
451462 */
452463 pm_runtime_get_noresume(&pdev->dev);
464
+ pm_runtime_set_active(&pdev->dev);
453465
454466 if (use_rpm) {
455
- pm_runtime_set_active(&pdev->dev);
456467 pm_runtime_enable(&pdev->dev);
457468 pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
458469 pm_runtime_use_autosuspend(&pdev->dev);
....@@ -496,6 +507,7 @@
496507 .remove = dw_mci_rockchip_remove,
497508 .driver = {
498509 .name = "dwmmc_rockchip",
510
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
499511 .of_match_table = dw_mci_rockchip_match,
500512 .pm = &dw_mci_rockchip_dev_pm_ops,
501513 },