163 lines
4.7 KiB
Diff
163 lines
4.7 KiB
Diff
|
From b557fc4afe1563d26aab58bec05ee84dcd6f9be8 Mon Sep 17 00:00:00 2001
|
||
|
From: Myy Miouyouyou <myy@miouyouyou.fr>
|
||
|
Date: Sun, 11 Mar 2018 22:15:36 +0100
|
||
|
Subject: [PATCH] dw_mmc: The stupid ASUS Reboot patch
|
||
|
|
||
|
The patch didn't apply in the 4.16-rc4 so it had to be "rewritten".
|
||
|
By "rewritten", I mean, move the code blocks accordingly, based on
|
||
|
the new dw_mmc.c file layout.
|
||
|
|
||
|
No major changes were done.
|
||
|
|
||
|
It's still fucking ugly but I have no time to concentrate on this
|
||
|
issue and deal with it accordingly.
|
||
|
|
||
|
Signed-off-by: Myy Miouyouyou <myy@miouyouyou.fr>
|
||
|
---
|
||
|
drivers/mmc/host/dw_mmc-rockchip.c | 25 +++++++++++++++++++++++++
|
||
|
drivers/mmc/host/dw_mmc.c | 31 +++++++++++++++++++++++++++++++
|
||
|
include/linux/reboot.h | 2 ++
|
||
|
kernel/reboot.c | 1 +
|
||
|
4 files changed, 59 insertions(+)
|
||
|
|
||
|
diff --git a/drivers/mmc/host/dw_mmc-rockchip.c b/drivers/mmc/host/dw_mmc-rockchip.c
|
||
|
index 339295212..a8fe79b14 100644
|
||
|
--- a/drivers/mmc/host/dw_mmc-rockchip.c
|
||
|
+++ b/drivers/mmc/host/dw_mmc-rockchip.c
|
||
|
@@ -14,10 +14,13 @@
|
||
|
#include <linux/of_address.h>
|
||
|
#include <linux/mmc/slot-gpio.h>
|
||
|
#include <linux/pm_runtime.h>
|
||
|
+#include <linux/regulator/consumer.h> // Stupid Tinkerboard Hack
|
||
|
#include <linux/slab.h>
|
||
|
|
||
|
#include "dw_mmc.h"
|
||
|
#include "dw_mmc-pltfm.h"
|
||
|
+#include "../core/core.h" // Stupid Tinkerboard Hack
|
||
|
+
|
||
|
|
||
|
#define RK3288_CLKGEN_DIV 2
|
||
|
|
||
|
@@ -366,6 +369,27 @@ static int dw_mci_rockchip_probe(struct platform_device *pdev)
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
+/* Stupid Tinkerboard Hack */
|
||
|
+static void dw_mci_rockchip_platfm_shutdown(struct platform_device *pdev)
|
||
|
+{
|
||
|
+ struct dw_mci *host = platform_get_drvdata(pdev);
|
||
|
+ struct mmc_host *mmc = host->slot->mmc;
|
||
|
+ int ret;
|
||
|
+
|
||
|
+ if(of_machine_is_compatible("asus,rk3288-tinker")){
|
||
|
+
|
||
|
+ mmc_power_off(mmc);
|
||
|
+
|
||
|
+ mdelay(20);
|
||
|
+
|
||
|
+ if (!IS_ERR(mmc->supply.vmmc))
|
||
|
+ ret = regulator_enable(mmc->supply.vmmc);
|
||
|
+
|
||
|
+ if (!IS_ERR(mmc->supply.vqmmc))
|
||
|
+ regulator_set_voltage(mmc->supply.vqmmc, 3000000, 3300000);
|
||
|
+ }
|
||
|
+}
|
||
|
+
|
||
|
static int dw_mci_rockchip_remove(struct platform_device *pdev)
|
||
|
{
|
||
|
pm_runtime_get_sync(&pdev->dev);
|
||
|
@@ -386,6 +410,7 @@ static const struct dev_pm_ops dw_mci_rockchip_dev_pm_ops = {
|
||
|
static struct platform_driver dw_mci_rockchip_pltfm_driver = {
|
||
|
.probe = dw_mci_rockchip_probe,
|
||
|
.remove = dw_mci_rockchip_remove,
|
||
|
+ .shutdown = dw_mci_rockchip_platfm_shutdown, // Stupid Tinkerboard Hack
|
||
|
.driver = {
|
||
|
.name = "dwmmc_rockchip",
|
||
|
.of_match_table = dw_mci_rockchip_match,
|
||
|
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
|
||
|
index d9b4acefe..5627c9da6 100644
|
||
|
--- a/drivers/mmc/host/dw_mmc.c
|
||
|
+++ b/drivers/mmc/host/dw_mmc.c
|
||
|
@@ -39,8 +39,10 @@
|
||
|
#include <linux/of.h>
|
||
|
#include <linux/of_gpio.h>
|
||
|
#include <linux/mmc/slot-gpio.h>
|
||
|
+#include <linux/reboot.h> // Stupid Tinkerboard Hack
|
||
|
|
||
|
#include "dw_mmc.h"
|
||
|
+#include "../core/core.h" // Stupid Tinkerboard hack
|
||
|
|
||
|
/* Common flag combinations */
|
||
|
#define DW_MCI_DATA_ERROR_FLAGS (SDMMC_INT_DRTO | SDMMC_INT_DCRC | \
|
||
|
@@ -2782,6 +2784,31 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
|
||
|
return IRQ_HANDLED;
|
||
|
}
|
||
|
|
||
|
+/* Stupid Tinkerboard Hack */
|
||
|
+struct dw_mci *mSdhost;
|
||
|
+void setmmcEmergency() {
|
||
|
+ struct mmc_host *mmc;
|
||
|
+ int ret;
|
||
|
+
|
||
|
+ printk(KERN_ERR "Emergency route taken.\n");
|
||
|
+ if (of_machine_is_compatible("asus,rk3288-tinker")) {
|
||
|
+ mmc = mSdhost->slot->mmc;
|
||
|
+
|
||
|
+ mmc_power_off(mmc);
|
||
|
+
|
||
|
+ mdelay(20);
|
||
|
+
|
||
|
+ if (!IS_ERR(mmc->supply.vmmc))
|
||
|
+ ret = regulator_enable(mmc->supply.vmmc);
|
||
|
+
|
||
|
+ if (!IS_ERR(mmc->supply.vqmmc))
|
||
|
+ regulator_set_voltage(mmc->supply.vqmmc, 3000000, 3300000);
|
||
|
+ }
|
||
|
+}
|
||
|
+EXPORT_SYMBOL(setmmcEmergency);
|
||
|
+
|
||
|
+
|
||
|
+
|
||
|
static int dw_mci_init_slot_caps(struct dw_mci_slot *slot)
|
||
|
{
|
||
|
struct dw_mci *host = slot->host;
|
||
|
@@ -2858,6 +2885,10 @@ static int dw_mci_init_slot(struct dw_mci *host)
|
||
|
mmc->f_max = freq[1];
|
||
|
}
|
||
|
|
||
|
+ /* Stupid Tinkerboard Hack */
|
||
|
+ if (of_find_property(host->dev->of_node, "supports-sd", NULL))
|
||
|
+ mSdhost = host;
|
||
|
+
|
||
|
/*if there are external regulators, get them*/
|
||
|
ret = mmc_regulator_get_supply(mmc);
|
||
|
if (ret)
|
||
|
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
|
||
|
index e63799a6e..057d3ce0c 100644
|
||
|
--- a/include/linux/reboot.h
|
||
|
+++ b/include/linux/reboot.h
|
||
|
@@ -77,6 +77,8 @@ extern char poweroff_cmd[POWEROFF_CMD_PATH_LEN];
|
||
|
|
||
|
extern void orderly_poweroff(bool force);
|
||
|
extern void orderly_reboot(void);
|
||
|
+/* Stupid Tinkerboard Hack */
|
||
|
+extern void setmmcEmergency(void);
|
||
|
|
||
|
/*
|
||
|
* Emergency restart, callable from an interrupt handler.
|
||
|
diff --git a/kernel/reboot.c b/kernel/reboot.c
|
||
|
index e4ced883d..c8e678ce6 100644
|
||
|
--- a/kernel/reboot.c
|
||
|
+++ b/kernel/reboot.c
|
||
|
@@ -61,6 +61,7 @@ void (*pm_power_off_prepare)(void);
|
||
|
void emergency_restart(void)
|
||
|
{
|
||
|
kmsg_dump(KMSG_DUMP_EMERG);
|
||
|
+ setmmcEmergency(); // Stupid Tinkerboard Hack
|
||
|
machine_emergency_restart();
|
||
|
}
|
||
|
EXPORT_SYMBOL_GPL(emergency_restart);
|
||
|
--
|
||
|
2.14.1
|
||
|
|