Skip to content

Commit fdd9bac

Browse files
authored
[Mellanox] Add new kernel patches from HW-MGMT package V.7.0020.3005 (sonic-net#287)
* Add kernel patches for SN2201 Signed-off-by: Kebo Liu <[email protected]> * update SN2201 kernel patch with hw-mgmt 2144 Signed-off-by: Kebo Liu <[email protected]> * update SN2201 kernel patch Signed-off-by: Kebo Liu <[email protected]> * Add new patches with hw-mgmt-3000 Signed-off-by: Kebo Liu <[email protected]> * Update kernel patch to V.7.0020.3005 Signed-off-by: Kebo Liu <[email protected]> * fix corrupted patch Signed-off-by: Kebo Liu <[email protected]>
1 parent 50e2bff commit fdd9bac

13 files changed

+2703
-1
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From 7ea34bd6ec1453e21f9f1d9442ea662a92423f32 Mon Sep 17 00:00:00 2001
2+
From: Vadim Pasternak <[email protected]>
3+
Date: Thu, 7 Oct 2021 19:30:05 +0000
4+
Subject: [PATCH backport 5.10/Alligator 1/9] mlxsw: core: Extend external
5+
cooling device whitelist for thermal zone binding
6+
7+
Allow thermal zone binding to an external cooling device of type
8+
"emc2305".
9+
Motivation to support new system SN2021 equipped with ASIC Spectrum-1
10+
supporting 48x Gbps RJ45 + 4x100G QSFP28 ports.
11+
System airflow control is provided by EMC2305 RPM-based PWM Fan Speed
12+
Controller as colling device.
13+
14+
Signed-off-by: Vadim Pasternak <[email protected]>
15+
---
16+
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 1 +
17+
1 file changed, 1 insertion(+)
18+
19+
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
20+
index f9c9ebf68..cc4cddbdb 100644
21+
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
22+
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
23+
@@ -38,6 +38,7 @@
24+
/* External cooling devices, allowed for binding to mlxsw thermal zones. */
25+
static char * const mlxsw_thermal_external_allowed_cdev[] = {
26+
"mlxreg_fan",
27+
+ "emc2305",
28+
};
29+
30+
enum mlxsw_thermal_trips {
31+
--
32+
2.20.1
33+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From abcebcd39fe094b68826cc04f2eca835606697f9 Mon Sep 17 00:00:00 2001
2+
From: Michael Shych <[email protected]>
3+
Date: Sat, 30 Apr 2022 14:58:07 +0300
4+
Subject: [PATCH] platform_data/mlxreg: Add field for notification callback
5+
6+
Add notification callback to inform caller that platform driver probing
7+
has been completed. It allows to caller to perform some initialization
8+
flow steps depending on specific driver probing completion.
9+
10+
Signed-off-by: Michael Shych <[email protected]>
11+
Reviewed-by: Vadim Pasternak <[email protected]>
12+
Link: https://lore.kernel.org/r/[email protected]
13+
Signed-off-by: Hans de Goede <[email protected]>
14+
---
15+
16+
diff --git a/include/linux/platform_data/mlxreg.h b/include/linux/platform_data/mlxreg.h
17+
index 40185f9d7c14..a6bd74e29b6b 100644
18+
--- a/include/linux/platform_data/mlxreg.h
19+
+++ b/include/linux/platform_data/mlxreg.h
20+
@@ -216,6 +216,8 @@
21+
* @mask_low: low aggregation interrupt common mask;
22+
* @deferred_nr: I2C adapter number must be exist prior probing execution;
23+
* @shift_nr: I2C adapter numbers must be incremented by this value;
24+
+ * @handle: handle to be passed by callback;
25+
+ * @completion_notify: callback to notify when platform driver probing is done;
26+
*/
27+
struct mlxreg_core_hotplug_platform_data {
28+
struct mlxreg_core_item *items;
29+
@@ -228,6 +230,8 @@
30+
u32 mask_low;
31+
int deferred_nr;
32+
int shift_nr;
33+
+ void *handle;
34+
+ int (*completion_notify)(void *handle, int id);
35+
};
36+
37+
#endif /* __LINUX_PLATFORM_DATA_MLXREG_H */
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From 81abceea27623640f0d69d1526cb6d11d964025d Mon Sep 17 00:00:00 2001
2+
From: Vadim Pasternak <[email protected]>
3+
Date: Thu, 7 Oct 2021 19:04:25 +0000
4+
Subject: [PATCH backport 5.10/Alligator 3/9] i2c: mlxcpld: Add callback to
5+
notify probing completion
6+
7+
Add notification to inform caller that driver probing has been
8+
completed. It allows to user, invoked platform device registration for
9+
"i2c-mlxcpld" driver, to be notified that bus adapter is available, and
10+
thus some devices could be connected to this bus.
11+
12+
Signed-off-by: Vadim Pasternak <[email protected]>
13+
---
14+
drivers/i2c/busses/i2c-mlxcpld.c | 4 ++++
15+
1 file changed, 4 insertions(+)
16+
17+
diff --git a/drivers/i2c/busses/i2c-mlxcpld.c b/drivers/i2c/busses/i2c-mlxcpld.c
18+
index 56aa424fd..fb451d42a 100644
19+
--- a/drivers/i2c/busses/i2c-mlxcpld.c
20+
+++ b/drivers/i2c/busses/i2c-mlxcpld.c
21+
@@ -560,6 +560,10 @@ static int mlxcpld_i2c_probe(struct platform_device *pdev)
22+
if (err)
23+
goto mlxcpld_i2_probe_failed;
24+
25+
+ /* Notify caller when adapter is added. */
26+
+ if (pdata && pdata->completion_notify)
27+
+ pdata->completion_notify(pdata->handle, mlxcpld_i2c_adapter.nr);
28+
+
29+
return 0;
30+
31+
mlxcpld_i2_probe_failed:
32+
--
33+
2.20.1
34+
Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
From 915d4664b7158d8d0f44da810186742c69300f02 Mon Sep 17 00:00:00 2001
2+
From: Michael Shych <[email protected]>
3+
Date: Tue, 18 Jan 2022 09:56:10 +0200
4+
Subject: [PATCH] hwmon: (powr1220) Upgrade driver to support hwmon info
5+
infrastructure
6+
7+
Reduce code by using devm_hwmon_device_register_with_groups() API by
8+
devm_hwmon_device_register_with_info() API.
9+
The motivation is to reduce code and to allow easy support for similar
10+
devices by the same driver.
11+
12+
Signed-off-by: Michael Shych <[email protected]>
13+
Reviewed-by: Vadim Pasternak <[email protected]>
14+
Link: https://lore.kernel.org/r/[email protected]
15+
Signed-off-by: Guenter Roeck <[email protected]>
16+
---
17+
drivers/hwmon/powr1220.c | 207 +++++++++++++++++++++--------------------------
18+
1 file changed, 92 insertions(+), 115 deletions(-)
19+
20+
diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c
21+
index 542e4a7b0234..0fa1a136eec8 100644
22+
--- a/drivers/hwmon/powr1220.c
23+
+++ b/drivers/hwmon/powr1220.c
24+
@@ -111,7 +111,7 @@
25+
mutex_lock(&data->update_lock);
26+
27+
if (time_after(jiffies, data->adc_last_updated[ch_num] + HZ) ||
28+
- !data->adc_valid[ch_num]) {
29+
+ !data->adc_valid[ch_num]) {
30+
/*
31+
* figure out if we need to use the attenuator for
32+
* high inputs or inputs that we don't yet have a measurement
33+
@@ -119,12 +119,12 @@
34+
* max reading.
35+
*/
36+
if (data->adc_maxes[ch_num] > ADC_MAX_LOW_MEASUREMENT_MV ||
37+
- data->adc_maxes[ch_num] == 0)
38+
+ data->adc_maxes[ch_num] == 0)
39+
adc_range = 1 << 4;
40+
41+
/* set the attenuator and mux */
42+
result = i2c_smbus_write_byte_data(data->client, ADC_MUX,
43+
- adc_range | ch_num);
44+
+ adc_range | ch_num);
45+
if (result)
46+
goto exit;
47+
48+
@@ -167,135 +167,109 @@
49+
return result;
50+
}
51+
52+
-/* Shows the voltage associated with the specified ADC channel */
53+
-static ssize_t powr1220_voltage_show(struct device *dev,
54+
- struct device_attribute *dev_attr,
55+
- char *buf)
56+
+static umode_t
57+
+powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
58+
+ attr, int channel)
59+
{
60+
- struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
61+
- int adc_val = powr1220_read_adc(dev, attr->index);
62+
-
63+
- if (adc_val < 0)
64+
- return adc_val;
65+
+ switch (type) {
66+
+ case hwmon_in:
67+
+ switch (attr) {
68+
+ case hwmon_in_input:
69+
+ case hwmon_in_highest:
70+
+ case hwmon_in_label:
71+
+ return 0444;
72+
+ default:
73+
+ break;
74+
+ }
75+
+ break;
76+
+ default:
77+
+ break;
78+
+ }
79+
80+
- return sprintf(buf, "%d\n", adc_val);
81+
+ return 0;
82+
}
83+
84+
-/* Shows the maximum setting associated with the specified ADC channel */
85+
-static ssize_t powr1220_max_show(struct device *dev,
86+
- struct device_attribute *dev_attr, char *buf)
87+
+static int
88+
+powr1220_read_string(struct device *dev, enum hwmon_sensor_types type, u32 attr,
89+
+ int channel, const char **str)
90+
{
91+
- struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
92+
- struct powr1220_data *data = dev_get_drvdata(dev);
93+
+ switch (type) {
94+
+ case hwmon_in:
95+
+ switch (attr) {
96+
+ case hwmon_in_label:
97+
+ *str = input_names[channel];
98+
+ return 0;
99+
+ default:
100+
+ return -EOPNOTSUPP;
101+
+ }
102+
+ break;
103+
+ default:
104+
+ return -EOPNOTSUPP;
105+
+ }
106+
107+
- return sprintf(buf, "%d\n", data->adc_maxes[attr->index]);
108+
+ return -EOPNOTSUPP;
109+
}
110+
111+
-/* Shows the label associated with the specified ADC channel */
112+
-static ssize_t powr1220_label_show(struct device *dev,
113+
- struct device_attribute *dev_attr,
114+
- char *buf)
115+
+static int
116+
+powr1220_read(struct device *dev, enum hwmon_sensor_types type, u32
117+
+ attr, int channel, long *val)
118+
{
119+
- struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
120+
+ struct powr1220_data *data = dev_get_drvdata(dev);
121+
+ int ret;
122+
123+
- return sprintf(buf, "%s\n", input_names[attr->index]);
124+
+ switch (type) {
125+
+ case hwmon_in:
126+
+ switch (attr) {
127+
+ case hwmon_in_input:
128+
+ ret = powr1220_read_adc(dev, channel);
129+
+ if (ret < 0)
130+
+ return ret;
131+
+ *val = ret;
132+
+ break;
133+
+ case hwmon_in_highest:
134+
+ *val = data->adc_maxes[channel];
135+
+ break;
136+
+ default:
137+
+ return -EOPNOTSUPP;
138+
+ }
139+
+ break;
140+
+ default:
141+
+ return -EOPNOTSUPP;
142+
}
143+
144+
-static SENSOR_DEVICE_ATTR_RO(in0_input, powr1220_voltage, VMON1);
145+
-static SENSOR_DEVICE_ATTR_RO(in1_input, powr1220_voltage, VMON2);
146+
-static SENSOR_DEVICE_ATTR_RO(in2_input, powr1220_voltage, VMON3);
147+
-static SENSOR_DEVICE_ATTR_RO(in3_input, powr1220_voltage, VMON4);
148+
-static SENSOR_DEVICE_ATTR_RO(in4_input, powr1220_voltage, VMON5);
149+
-static SENSOR_DEVICE_ATTR_RO(in5_input, powr1220_voltage, VMON6);
150+
-static SENSOR_DEVICE_ATTR_RO(in6_input, powr1220_voltage, VMON7);
151+
-static SENSOR_DEVICE_ATTR_RO(in7_input, powr1220_voltage, VMON8);
152+
-static SENSOR_DEVICE_ATTR_RO(in8_input, powr1220_voltage, VMON9);
153+
-static SENSOR_DEVICE_ATTR_RO(in9_input, powr1220_voltage, VMON10);
154+
-static SENSOR_DEVICE_ATTR_RO(in10_input, powr1220_voltage, VMON11);
155+
-static SENSOR_DEVICE_ATTR_RO(in11_input, powr1220_voltage, VMON12);
156+
-static SENSOR_DEVICE_ATTR_RO(in12_input, powr1220_voltage, VCCA);
157+
-static SENSOR_DEVICE_ATTR_RO(in13_input, powr1220_voltage, VCCINP);
158+
-
159+
-static SENSOR_DEVICE_ATTR_RO(in0_highest, powr1220_max, VMON1);
160+
-static SENSOR_DEVICE_ATTR_RO(in1_highest, powr1220_max, VMON2);
161+
-static SENSOR_DEVICE_ATTR_RO(in2_highest, powr1220_max, VMON3);
162+
-static SENSOR_DEVICE_ATTR_RO(in3_highest, powr1220_max, VMON4);
163+
-static SENSOR_DEVICE_ATTR_RO(in4_highest, powr1220_max, VMON5);
164+
-static SENSOR_DEVICE_ATTR_RO(in5_highest, powr1220_max, VMON6);
165+
-static SENSOR_DEVICE_ATTR_RO(in6_highest, powr1220_max, VMON7);
166+
-static SENSOR_DEVICE_ATTR_RO(in7_highest, powr1220_max, VMON8);
167+
-static SENSOR_DEVICE_ATTR_RO(in8_highest, powr1220_max, VMON9);
168+
-static SENSOR_DEVICE_ATTR_RO(in9_highest, powr1220_max, VMON10);
169+
-static SENSOR_DEVICE_ATTR_RO(in10_highest, powr1220_max, VMON11);
170+
-static SENSOR_DEVICE_ATTR_RO(in11_highest, powr1220_max, VMON12);
171+
-static SENSOR_DEVICE_ATTR_RO(in12_highest, powr1220_max, VCCA);
172+
-static SENSOR_DEVICE_ATTR_RO(in13_highest, powr1220_max, VCCINP);
173+
-
174+
-static SENSOR_DEVICE_ATTR_RO(in0_label, powr1220_label, VMON1);
175+
-static SENSOR_DEVICE_ATTR_RO(in1_label, powr1220_label, VMON2);
176+
-static SENSOR_DEVICE_ATTR_RO(in2_label, powr1220_label, VMON3);
177+
-static SENSOR_DEVICE_ATTR_RO(in3_label, powr1220_label, VMON4);
178+
-static SENSOR_DEVICE_ATTR_RO(in4_label, powr1220_label, VMON5);
179+
-static SENSOR_DEVICE_ATTR_RO(in5_label, powr1220_label, VMON6);
180+
-static SENSOR_DEVICE_ATTR_RO(in6_label, powr1220_label, VMON7);
181+
-static SENSOR_DEVICE_ATTR_RO(in7_label, powr1220_label, VMON8);
182+
-static SENSOR_DEVICE_ATTR_RO(in8_label, powr1220_label, VMON9);
183+
-static SENSOR_DEVICE_ATTR_RO(in9_label, powr1220_label, VMON10);
184+
-static SENSOR_DEVICE_ATTR_RO(in10_label, powr1220_label, VMON11);
185+
-static SENSOR_DEVICE_ATTR_RO(in11_label, powr1220_label, VMON12);
186+
-static SENSOR_DEVICE_ATTR_RO(in12_label, powr1220_label, VCCA);
187+
-static SENSOR_DEVICE_ATTR_RO(in13_label, powr1220_label, VCCINP);
188+
-
189+
-static struct attribute *powr1220_attrs[] = {
190+
- &sensor_dev_attr_in0_input.dev_attr.attr,
191+
- &sensor_dev_attr_in1_input.dev_attr.attr,
192+
- &sensor_dev_attr_in2_input.dev_attr.attr,
193+
- &sensor_dev_attr_in3_input.dev_attr.attr,
194+
- &sensor_dev_attr_in4_input.dev_attr.attr,
195+
- &sensor_dev_attr_in5_input.dev_attr.attr,
196+
- &sensor_dev_attr_in6_input.dev_attr.attr,
197+
- &sensor_dev_attr_in7_input.dev_attr.attr,
198+
- &sensor_dev_attr_in8_input.dev_attr.attr,
199+
- &sensor_dev_attr_in9_input.dev_attr.attr,
200+
- &sensor_dev_attr_in10_input.dev_attr.attr,
201+
- &sensor_dev_attr_in11_input.dev_attr.attr,
202+
- &sensor_dev_attr_in12_input.dev_attr.attr,
203+
- &sensor_dev_attr_in13_input.dev_attr.attr,
204+
-
205+
- &sensor_dev_attr_in0_highest.dev_attr.attr,
206+
- &sensor_dev_attr_in1_highest.dev_attr.attr,
207+
- &sensor_dev_attr_in2_highest.dev_attr.attr,
208+
- &sensor_dev_attr_in3_highest.dev_attr.attr,
209+
- &sensor_dev_attr_in4_highest.dev_attr.attr,
210+
- &sensor_dev_attr_in5_highest.dev_attr.attr,
211+
- &sensor_dev_attr_in6_highest.dev_attr.attr,
212+
- &sensor_dev_attr_in7_highest.dev_attr.attr,
213+
- &sensor_dev_attr_in8_highest.dev_attr.attr,
214+
- &sensor_dev_attr_in9_highest.dev_attr.attr,
215+
- &sensor_dev_attr_in10_highest.dev_attr.attr,
216+
- &sensor_dev_attr_in11_highest.dev_attr.attr,
217+
- &sensor_dev_attr_in12_highest.dev_attr.attr,
218+
- &sensor_dev_attr_in13_highest.dev_attr.attr,
219+
-
220+
- &sensor_dev_attr_in0_label.dev_attr.attr,
221+
- &sensor_dev_attr_in1_label.dev_attr.attr,
222+
- &sensor_dev_attr_in2_label.dev_attr.attr,
223+
- &sensor_dev_attr_in3_label.dev_attr.attr,
224+
- &sensor_dev_attr_in4_label.dev_attr.attr,
225+
- &sensor_dev_attr_in5_label.dev_attr.attr,
226+
- &sensor_dev_attr_in6_label.dev_attr.attr,
227+
- &sensor_dev_attr_in7_label.dev_attr.attr,
228+
- &sensor_dev_attr_in8_label.dev_attr.attr,
229+
- &sensor_dev_attr_in9_label.dev_attr.attr,
230+
- &sensor_dev_attr_in10_label.dev_attr.attr,
231+
- &sensor_dev_attr_in11_label.dev_attr.attr,
232+
- &sensor_dev_attr_in12_label.dev_attr.attr,
233+
- &sensor_dev_attr_in13_label.dev_attr.attr,
234+
+ return 0;
235+
+}
236+
+
237+
+static const struct hwmon_channel_info *powr1220_info[] = {
238+
+ HWMON_CHANNEL_INFO(in,
239+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL,
240+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL,
241+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL,
242+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL,
243+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL,
244+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL,
245+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL,
246+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL,
247+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL,
248+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL,
249+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL,
250+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL,
251+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL,
252+
+ HWMON_I_INPUT | HWMON_I_HIGHEST | HWMON_I_LABEL),
253+
254+
NULL
255+
};
256+
257+
-ATTRIBUTE_GROUPS(powr1220);
258+
+static const struct hwmon_ops powr1220_hwmon_ops = {
259+
+ .read = powr1220_read,
260+
+ .read_string = powr1220_read_string,
261+
+ .is_visible = powr1220_is_visible,
262+
+};
263+
+
264+
+static const struct hwmon_chip_info powr1220_chip_info = {
265+
+ .ops = &powr1220_hwmon_ops,
266+
+ .info = powr1220_info,
267+
+};
268+
269+
static int powr1220_probe(struct i2c_client *client)
270+
{
271+
@@ -312,8 +286,11 @@
272+
mutex_init(&data->update_lock);
273+
data->client = client;
274+
275+
- hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev,
276+
- client->name, data, powr1220_groups);
277+
+ hwmon_dev = devm_hwmon_device_register_with_info(&client->dev,
278+
+ client->name,
279+
+ data,
280+
+ &powr1220_chip_info,
281+
+ NULL);
282+
283+
return PTR_ERR_OR_ZERO(hwmon_dev);
284+
}

0 commit comments

Comments
 (0)