Skip to content

Commit a50c1e3

Browse files
iveceradavem330
authored andcommitted
mlxsw: core: Implement thermal zone
Implement thermal zone for mlxsw based HW. It uses temperature sensor provided by ASIC (the same as mlxsw hwmon interface) to report current temp to thermal core. The ASIC's PWM is then used to control speed of system fans registered as cooling devices. Signed-off-by: Ivan Vecera <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 55c63aa commit a50c1e3

File tree

5 files changed

+484
-0
lines changed

5 files changed

+484
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ config MLXSW_CORE_HWMON
1919
---help---
2020
Say Y here if you want to expose HWMON interface on mlxsw devices.
2121

22+
config MLXSW_CORE_THERMAL
23+
bool "Thermal zone support for Mellanox Technologies Switch ASICs"
24+
depends on MLXSW_CORE && THERMAL
25+
depends on !(MLXSW_CORE=y && THERMAL=m)
26+
default y
27+
---help---
28+
Say Y here if you want to automatically control fans speed according
29+
ambient temperature reported by ASIC.
30+
2231
config MLXSW_PCI
2332
tristate "PCI bus implementation for Mellanox Technologies Switch ASICs"
2433
depends on PCI && HAS_DMA && HAS_IOMEM && MLXSW_CORE

drivers/net/ethernet/mellanox/mlxsw/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
obj-$(CONFIG_MLXSW_CORE) += mlxsw_core.o
22
mlxsw_core-objs := core.o
33
mlxsw_core-$(CONFIG_MLXSW_CORE_HWMON) += core_hwmon.o
4+
mlxsw_core-$(CONFIG_MLXSW_CORE_THERMAL) += core_thermal.o
45
obj-$(CONFIG_MLXSW_PCI) += mlxsw_pci.o
56
mlxsw_pci-objs := pci.o
67
obj-$(CONFIG_MLXSW_I2C) += mlxsw_i2c.o

drivers/net/ethernet/mellanox/mlxsw/core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ struct mlxsw_core {
131131
} lag;
132132
struct mlxsw_res res;
133133
struct mlxsw_hwmon *hwmon;
134+
struct mlxsw_thermal *thermal;
134135
struct mlxsw_core_port ports[MLXSW_PORT_MAX_PORTS];
135136
unsigned long driver_priv[0];
136137
/* driver_priv has to be always the last item */
@@ -1162,6 +1163,11 @@ int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
11621163
if (err)
11631164
goto err_hwmon_init;
11641165

1166+
err = mlxsw_thermal_init(mlxsw_core, mlxsw_bus_info,
1167+
&mlxsw_core->thermal);
1168+
if (err)
1169+
goto err_thermal_init;
1170+
11651171
if (mlxsw_driver->init) {
11661172
err = mlxsw_driver->init(mlxsw_core, mlxsw_bus_info);
11671173
if (err)
@@ -1178,6 +1184,7 @@ int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
11781184
if (mlxsw_core->driver->fini)
11791185
mlxsw_core->driver->fini(mlxsw_core);
11801186
err_driver_init:
1187+
err_thermal_init:
11811188
err_hwmon_init:
11821189
devlink_unregister(devlink);
11831190
err_devlink_register:
@@ -1204,6 +1211,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core)
12041211
mlxsw_core_debugfs_fini(mlxsw_core);
12051212
if (mlxsw_core->driver->fini)
12061213
mlxsw_core->driver->fini(mlxsw_core);
1214+
mlxsw_thermal_fini(mlxsw_core->thermal);
12071215
devlink_unregister(devlink);
12081216
mlxsw_emad_fini(mlxsw_core);
12091217
mlxsw_core->bus->fini(mlxsw_core->bus_priv);

drivers/net/ethernet/mellanox/mlxsw/core.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,4 +321,28 @@ static inline int mlxsw_hwmon_init(struct mlxsw_core *mlxsw_core,
321321

322322
#endif
323323

324+
struct mlxsw_thermal;
325+
326+
#ifdef CONFIG_MLXSW_CORE_THERMAL
327+
328+
int mlxsw_thermal_init(struct mlxsw_core *mlxsw_core,
329+
const struct mlxsw_bus_info *mlxsw_bus_info,
330+
struct mlxsw_thermal **p_thermal);
331+
void mlxsw_thermal_fini(struct mlxsw_thermal *thermal);
332+
333+
#else
334+
335+
static inline int mlxsw_thermal_init(struct mlxsw_core *mlxsw_core,
336+
const struct mlxsw_bus_info *mlxsw_bus_info,
337+
struct mlxsw_thermal **p_thermal)
338+
{
339+
return 0;
340+
}
341+
342+
static inline void mlxsw_thermal_fini(struct mlxsw_thermal *thermal)
343+
{
344+
}
345+
346+
#endif
347+
324348
#endif

0 commit comments

Comments
 (0)