summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-kernel/linux/linux-aspeed/0071-peci-add-a-temporary-workaround.patch
blob: e32ec54ac6309759078cd20db89cccfcc3fcb457 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
From 3394fabbd17ad7263feeb0f4ae593056237f0647 Mon Sep 17 00:00:00 2001
From: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
Date: Tue, 30 Jul 2019 13:01:58 -0700
Subject: [PATCH] peci: add a temporary workaround

To cover a PECI issue, this commit makes PECI driver block all PECI
commands when PLTRST_N signal is 0.

Also, it adds 'use_wa' module parameter for platforms that don't have
the PLTRST_N gpio input so that the WA can be disabled through the
module parameter.

This is a temporary workaround.

Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
---
 drivers/peci/busses/peci-aspeed.c | 11 +++++++++++
 drivers/peci/peci-core.c          | 11 +++++++++++
 include/linux/peci.h              |  1 +
 3 files changed, 23 insertions(+)

diff --git a/drivers/peci/busses/peci-aspeed.c b/drivers/peci/busses/peci-aspeed.c
index 8a0dd40730cc..76394ab32854 100644
--- a/drivers/peci/busses/peci-aspeed.c
+++ b/drivers/peci/busses/peci-aspeed.c
@@ -10,6 +10,7 @@
 #include <linux/jiffies.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_gpio.h>
 #include <linux/peci.h>
 #include <linux/platform_device.h>
 #include <linux/reset.h>
@@ -445,6 +446,16 @@ static int aspeed_peci_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_put_adapter_dev;
 
+	priv->adapter->pltrst_pin = of_get_gpio(pdev->dev.of_node, 0);
+	if (gpio_is_valid(priv->adapter->pltrst_pin)) {
+		ret = devm_gpio_request(&pdev->dev, priv->adapter->pltrst_pin,
+					"peci-aspeed");
+		if (ret < 0) {
+			priv->adapter->pltrst_pin = -1;
+			dev_err(&pdev->dev, "error requesting pltrst gpio\n");
+		}
+	}
+
 	ret = peci_add_adapter(priv->adapter);
 	if (ret)
 		goto err_put_adapter_dev;
diff --git a/drivers/peci/peci-core.c b/drivers/peci/peci-core.c
index b99ba788a032..2e3b9a0c83e9 100644
--- a/drivers/peci/peci-core.c
+++ b/drivers/peci/peci-core.c
@@ -5,6 +5,7 @@
 #include <linux/crc8.h>
 #include <linux/delay.h>
 #include <linux/mm.h>
+#include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
 #include <linux/peci.h>
@@ -190,6 +191,11 @@ static int peci_aw_fcs(struct peci_xfer_msg *msg, int len, u8 *aw_fcs)
 	return 0;
 }
 
+/* Temporary WA */
+static bool use_wa __read_mostly = true;
+module_param_named(use_wa, use_wa, bool, 0644);
+MODULE_PARM_DESC(use_wa, "flag for enabling of WA");
+
 static int __peci_xfer(struct peci_adapter *adapter, struct peci_xfer_msg *msg,
 		       bool do_retry, bool has_aw_fcs)
 {
@@ -197,6 +203,11 @@ static int __peci_xfer(struct peci_adapter *adapter, struct peci_xfer_msg *msg,
 	u8 aw_fcs;
 	int ret;
 
+	/* Temporary WA */
+	if (use_wa && gpio_is_valid(adapter->pltrst_pin) &&
+	    gpio_get_value(adapter->pltrst_pin) == 0)
+		return -EAGAIN;
+
 	/*
 	 * In case if adapter uses DMA, check at here whether tx and rx buffers
 	 * are DMA capable or not.
diff --git a/include/linux/peci.h b/include/linux/peci.h
index 6fc424dc2a73..e589cb258a2a 100644
--- a/include/linux/peci.h
+++ b/include/linux/peci.h
@@ -44,6 +44,7 @@ struct peci_adapter {
 					struct peci_xfer_msg *msg);
 	u32			cmd_mask;
 	bool			use_dma;
+	int			pltrst_pin;
 };
 
 static inline struct peci_adapter *to_peci_adapter(void *d)
-- 
2.7.4