1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
3 * Mellanox platform driver
5 * Copyright (C) 2016-2018 Mellanox Technologies
6 * Copyright (C) 2016-2018 Vadim Pasternak <vadimp@mellanox.com>
9 #include <linux/device.h>
10 #include <linux/dmi.h>
11 #include <linux/i2c.h>
12 #include <linux/i2c-mux.h>
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
16 #include <linux/platform_data/i2c-mux-reg.h>
17 #include <linux/platform_data/mlxreg.h>
18 #include <linux/regmap.h>
20 #define MLX_PLAT_DEVICE_NAME "mlxplat"
22 /* LPC bus IO offsets */
23 #define MLXPLAT_CPLD_LPC_I2C_BASE_ADRR 0x2000
24 #define MLXPLAT_CPLD_LPC_REG_BASE_ADRR 0x2500
25 #define MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET 0x00
26 #define MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET 0x01
27 #define MLXPLAT_CPLD_LPC_REG_CPLD3_VER_OFFSET 0x02
28 #define MLXPLAT_CPLD_LPC_REG_CPLD4_VER_OFFSET 0x03
29 #define MLXPLAT_CPLD_LPC_REG_CPLD1_PN_OFFSET 0x04
30 #define MLXPLAT_CPLD_LPC_REG_CPLD2_PN_OFFSET 0x06
31 #define MLXPLAT_CPLD_LPC_REG_CPLD3_PN_OFFSET 0x08
32 #define MLXPLAT_CPLD_LPC_REG_CPLD4_PN_OFFSET 0x0a
33 #define MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET 0x1d
34 #define MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET 0x1e
35 #define MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET 0x1f
36 #define MLXPLAT_CPLD_LPC_REG_LED1_OFFSET 0x20
37 #define MLXPLAT_CPLD_LPC_REG_LED2_OFFSET 0x21
38 #define MLXPLAT_CPLD_LPC_REG_LED3_OFFSET 0x22
39 #define MLXPLAT_CPLD_LPC_REG_LED4_OFFSET 0x23
40 #define MLXPLAT_CPLD_LPC_REG_LED5_OFFSET 0x24
41 #define MLXPLAT_CPLD_LPC_REG_FAN_DIRECTION 0x2a
42 #define MLXPLAT_CPLD_LPC_REG_GP0_RO_OFFSET 0x2b
43 #define MLXPLAT_CPLD_LPC_REG_GP0_OFFSET 0x2e
44 #define MLXPLAT_CPLD_LPC_REG_GP1_OFFSET 0x30
45 #define MLXPLAT_CPLD_LPC_REG_WP1_OFFSET 0x31
46 #define MLXPLAT_CPLD_LPC_REG_GP2_OFFSET 0x32
47 #define MLXPLAT_CPLD_LPC_REG_WP2_OFFSET 0x33
48 #define MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET 0x37
49 #define MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET 0x3a
50 #define MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET 0x3b
51 #define MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET 0x40
52 #define MLXPLAT_CPLD_LPC_REG_AGGRLO_MASK_OFFSET 0x41
53 #define MLXPLAT_CPLD_LPC_REG_AGGRCO_OFFSET 0x42
54 #define MLXPLAT_CPLD_LPC_REG_AGGRCO_MASK_OFFSET 0x43
55 #define MLXPLAT_CPLD_LPC_REG_AGGRCX_OFFSET 0x44
56 #define MLXPLAT_CPLD_LPC_REG_AGGRCX_MASK_OFFSET 0x45
57 #define MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET 0x50
58 #define MLXPLAT_CPLD_LPC_REG_ASIC_EVENT_OFFSET 0x51
59 #define MLXPLAT_CPLD_LPC_REG_ASIC_MASK_OFFSET 0x52
60 #define MLXPLAT_CPLD_LPC_REG_PSU_OFFSET 0x58
61 #define MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFFSET 0x59
62 #define MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFFSET 0x5a
63 #define MLXPLAT_CPLD_LPC_REG_PWR_OFFSET 0x64
64 #define MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFFSET 0x65
65 #define MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFFSET 0x66
66 #define MLXPLAT_CPLD_LPC_REG_FAN_OFFSET 0x88
67 #define MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET 0x89
68 #define MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET 0x8a
69 #define MLXPLAT_CPLD_LPC_REG_WD_CLEAR_OFFSET 0xc7
70 #define MLXPLAT_CPLD_LPC_REG_WD_CLEAR_WP_OFFSET 0xc8
71 #define MLXPLAT_CPLD_LPC_REG_WD1_TMR_OFFSET 0xc9
72 #define MLXPLAT_CPLD_LPC_REG_WD1_ACT_OFFSET 0xcb
73 #define MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET 0xcd
74 #define MLXPLAT_CPLD_LPC_REG_WD2_TLEFT_OFFSET 0xce
75 #define MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET 0xcf
76 #define MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET 0xd1
77 #define MLXPLAT_CPLD_LPC_REG_WD3_TLEFT_OFFSET 0xd2
78 #define MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET 0xd3
79 #define MLXPLAT_CPLD_LPC_REG_CPLD1_MVER_OFFSET 0xde
80 #define MLXPLAT_CPLD_LPC_REG_CPLD2_MVER_OFFSET 0xdf
81 #define MLXPLAT_CPLD_LPC_REG_CPLD3_MVER_OFFSET 0xe0
82 #define MLXPLAT_CPLD_LPC_REG_CPLD4_MVER_OFFSET 0xe1
83 #define MLXPLAT_CPLD_LPC_REG_UFM_VERSION_OFFSET 0xe2
84 #define MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET 0xe3
85 #define MLXPLAT_CPLD_LPC_REG_TACHO1_OFFSET 0xe4
86 #define MLXPLAT_CPLD_LPC_REG_TACHO2_OFFSET 0xe5
87 #define MLXPLAT_CPLD_LPC_REG_TACHO3_OFFSET 0xe6
88 #define MLXPLAT_CPLD_LPC_REG_TACHO4_OFFSET 0xe7
89 #define MLXPLAT_CPLD_LPC_REG_TACHO5_OFFSET 0xe8
90 #define MLXPLAT_CPLD_LPC_REG_TACHO6_OFFSET 0xe9
91 #define MLXPLAT_CPLD_LPC_REG_TACHO7_OFFSET 0xeb
92 #define MLXPLAT_CPLD_LPC_REG_TACHO8_OFFSET 0xec
93 #define MLXPLAT_CPLD_LPC_REG_TACHO9_OFFSET 0xed
94 #define MLXPLAT_CPLD_LPC_REG_TACHO10_OFFSET 0xee
95 #define MLXPLAT_CPLD_LPC_REG_TACHO11_OFFSET 0xef
96 #define MLXPLAT_CPLD_LPC_REG_TACHO12_OFFSET 0xf0
97 #define MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET 0xf5
98 #define MLXPLAT_CPLD_LPC_REG_FAN_CAP2_OFFSET 0xf6
99 #define MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET 0xf7
100 #define MLXPLAT_CPLD_LPC_REG_TACHO_SPEED_OFFSET 0xf8
101 #define MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET 0xf9
102 #define MLXPLAT_CPLD_LPC_REG_CONFIG1_OFFSET 0xfb
103 #define MLXPLAT_CPLD_LPC_REG_CONFIG2_OFFSET 0xfc
104 #define MLXPLAT_CPLD_LPC_IO_RANGE 0x100
105 #define MLXPLAT_CPLD_LPC_I2C_CH1_OFF 0xdb
106 #define MLXPLAT_CPLD_LPC_I2C_CH2_OFF 0xda
107 #define MLXPLAT_CPLD_LPC_I2C_CH3_OFF 0xdc
109 #define MLXPLAT_CPLD_LPC_PIO_OFFSET 0x10000UL
110 #define MLXPLAT_CPLD_LPC_REG1 ((MLXPLAT_CPLD_LPC_REG_BASE_ADRR + \
111 MLXPLAT_CPLD_LPC_I2C_CH1_OFF) | \
112 MLXPLAT_CPLD_LPC_PIO_OFFSET)
113 #define MLXPLAT_CPLD_LPC_REG2 ((MLXPLAT_CPLD_LPC_REG_BASE_ADRR + \
114 MLXPLAT_CPLD_LPC_I2C_CH2_OFF) | \
115 MLXPLAT_CPLD_LPC_PIO_OFFSET)
116 #define MLXPLAT_CPLD_LPC_REG3 ((MLXPLAT_CPLD_LPC_REG_BASE_ADRR + \
117 MLXPLAT_CPLD_LPC_I2C_CH3_OFF) | \
118 MLXPLAT_CPLD_LPC_PIO_OFFSET)
120 /* Masks for aggregation, psu, pwr and fan event in CPLD related registers. */
121 #define MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF 0x04
122 #define MLXPLAT_CPLD_AGGR_PSU_MASK_DEF 0x08
123 #define MLXPLAT_CPLD_AGGR_PWR_MASK_DEF 0x08
124 #define MLXPLAT_CPLD_AGGR_FAN_MASK_DEF 0x40
125 #define MLXPLAT_CPLD_AGGR_MASK_DEF (MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF | \
126 MLXPLAT_CPLD_AGGR_PSU_MASK_DEF | \
127 MLXPLAT_CPLD_AGGR_FAN_MASK_DEF)
128 #define MLXPLAT_CPLD_AGGR_ASIC_MASK_NG 0x01
129 #define MLXPLAT_CPLD_AGGR_MASK_NG_DEF 0x04
130 #define MLXPLAT_CPLD_AGGR_MASK_COMEX BIT(0)
131 #define MLXPLAT_CPLD_LOW_AGGR_MASK_LOW 0xc1
132 #define MLXPLAT_CPLD_LOW_AGGR_MASK_I2C BIT(6)
133 #define MLXPLAT_CPLD_PSU_MASK GENMASK(1, 0)
134 #define MLXPLAT_CPLD_PWR_MASK GENMASK(1, 0)
135 #define MLXPLAT_CPLD_PSU_EXT_MASK GENMASK(3, 0)
136 #define MLXPLAT_CPLD_PWR_EXT_MASK GENMASK(3, 0)
137 #define MLXPLAT_CPLD_FAN_MASK GENMASK(3, 0)
138 #define MLXPLAT_CPLD_ASIC_MASK GENMASK(1, 0)
139 #define MLXPLAT_CPLD_FAN_NG_MASK GENMASK(5, 0)
140 #define MLXPLAT_CPLD_LED_LO_NIBBLE_MASK GENMASK(7, 4)
141 #define MLXPLAT_CPLD_LED_HI_NIBBLE_MASK GENMASK(3, 0)
142 #define MLXPLAT_CPLD_VOLTREG_UPD_MASK GENMASK(5, 4)
143 #define MLXPLAT_CPLD_I2C_CAP_BIT 0x04
144 #define MLXPLAT_CPLD_I2C_CAP_MASK GENMASK(5, MLXPLAT_CPLD_I2C_CAP_BIT)
146 /* Masks for aggregation for comex carriers */
147 #define MLXPLAT_CPLD_AGGR_MASK_CARRIER BIT(1)
148 #define MLXPLAT_CPLD_AGGR_MASK_CARR_DEF (MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF | \
149 MLXPLAT_CPLD_AGGR_MASK_CARRIER)
150 #define MLXPLAT_CPLD_LOW_AGGRCX_MASK 0xc1
152 /* Default I2C parent bus number */
153 #define MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR 1
155 /* Maximum number of possible physical buses equipped on system */
156 #define MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM 16
157 #define MLXPLAT_CPLD_MAX_PHYS_EXT_ADAPTER_NUM 24
159 /* Number of channels in group */
160 #define MLXPLAT_CPLD_GRP_CHNL_NUM 8
162 /* Start channel numbers */
163 #define MLXPLAT_CPLD_CH1 2
164 #define MLXPLAT_CPLD_CH2 10
165 #define MLXPLAT_CPLD_CH3 18
167 /* Number of LPC attached MUX platform devices */
168 #define MLXPLAT_CPLD_LPC_MUX_DEVS 3
170 /* Hotplug devices adapter numbers */
171 #define MLXPLAT_CPLD_NR_NONE -1
172 #define MLXPLAT_CPLD_PSU_DEFAULT_NR 10
173 #define MLXPLAT_CPLD_PSU_MSNXXXX_NR 4
174 #define MLXPLAT_CPLD_FAN1_DEFAULT_NR 11
175 #define MLXPLAT_CPLD_FAN2_DEFAULT_NR 12
176 #define MLXPLAT_CPLD_FAN3_DEFAULT_NR 13
177 #define MLXPLAT_CPLD_FAN4_DEFAULT_NR 14
179 /* Masks and default values for watchdogs */
180 #define MLXPLAT_CPLD_WD1_CLEAR_MASK GENMASK(7, 1)
181 #define MLXPLAT_CPLD_WD2_CLEAR_MASK (GENMASK(7, 0) & ~BIT(1))
183 #define MLXPLAT_CPLD_WD_TYPE1_TO_MASK GENMASK(7, 4)
184 #define MLXPLAT_CPLD_WD_TYPE2_TO_MASK 0
185 #define MLXPLAT_CPLD_WD_RESET_ACT_MASK GENMASK(7, 1)
186 #define MLXPLAT_CPLD_WD_FAN_ACT_MASK (GENMASK(7, 0) & ~BIT(4))
187 #define MLXPLAT_CPLD_WD_COUNT_ACT_MASK (GENMASK(7, 0) & ~BIT(7))
188 #define MLXPLAT_CPLD_WD_CPBLTY_MASK (GENMASK(7, 0) & ~BIT(6))
189 #define MLXPLAT_CPLD_WD_DFLT_TIMEOUT 30
190 #define MLXPLAT_CPLD_WD3_DFLT_TIMEOUT 600
191 #define MLXPLAT_CPLD_WD_MAX_DEVS 2
193 /* mlxplat_priv - platform private data
194 * @pdev_i2c - i2c controller platform device
195 * @pdev_mux - array of mux platform devices
196 * @pdev_hotplug - hotplug platform devices
197 * @pdev_led - led platform devices
198 * @pdev_io_regs - register access platform devices
199 * @pdev_fan - FAN platform devices
200 * @pdev_wd - array of watchdog platform devices
201 * @regmap: device register map
203 struct mlxplat_priv {
204 struct platform_device *pdev_i2c;
205 struct platform_device *pdev_mux[MLXPLAT_CPLD_LPC_MUX_DEVS];
206 struct platform_device *pdev_hotplug;
207 struct platform_device *pdev_led;
208 struct platform_device *pdev_io_regs;
209 struct platform_device *pdev_fan;
210 struct platform_device *pdev_wd[MLXPLAT_CPLD_WD_MAX_DEVS];
214 /* Regions for LPC I2C controller and LPC base register space */
215 static const struct resource mlxplat_lpc_resources[] = {
216 [0] = DEFINE_RES_NAMED(MLXPLAT_CPLD_LPC_I2C_BASE_ADRR,
217 MLXPLAT_CPLD_LPC_IO_RANGE,
218 "mlxplat_cpld_lpc_i2c_ctrl", IORESOURCE_IO),
219 [1] = DEFINE_RES_NAMED(MLXPLAT_CPLD_LPC_REG_BASE_ADRR,
220 MLXPLAT_CPLD_LPC_IO_RANGE,
221 "mlxplat_cpld_lpc_regs",
225 /* Platform i2c next generation systems data */
226 static struct mlxreg_core_data mlxplat_mlxcpld_i2c_ng_items_data[] = {
228 .reg = MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET,
229 .mask = MLXPLAT_CPLD_I2C_CAP_MASK,
230 .bit = MLXPLAT_CPLD_I2C_CAP_BIT,
234 static struct mlxreg_core_item mlxplat_mlxcpld_i2c_ng_items[] = {
236 .data = mlxplat_mlxcpld_i2c_ng_items_data,
240 /* Platform next generation systems i2c data */
241 static struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_i2c_ng_data = {
242 .items = mlxplat_mlxcpld_i2c_ng_items,
243 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET,
244 .mask = MLXPLAT_CPLD_AGGR_MASK_COMEX,
245 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRCO_OFFSET,
246 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_I2C,
249 /* Platform default channels */
250 static const int mlxplat_default_channels[][MLXPLAT_CPLD_GRP_CHNL_NUM] = {
252 MLXPLAT_CPLD_CH1, MLXPLAT_CPLD_CH1 + 1, MLXPLAT_CPLD_CH1 + 2,
253 MLXPLAT_CPLD_CH1 + 3, MLXPLAT_CPLD_CH1 + 4, MLXPLAT_CPLD_CH1 +
254 5, MLXPLAT_CPLD_CH1 + 6, MLXPLAT_CPLD_CH1 + 7
257 MLXPLAT_CPLD_CH2, MLXPLAT_CPLD_CH2 + 1, MLXPLAT_CPLD_CH2 + 2,
258 MLXPLAT_CPLD_CH2 + 3, MLXPLAT_CPLD_CH2 + 4, MLXPLAT_CPLD_CH2 +
259 5, MLXPLAT_CPLD_CH2 + 6, MLXPLAT_CPLD_CH2 + 7
263 /* Platform channels for MSN21xx system family */
264 static const int mlxplat_msn21xx_channels[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
266 /* Platform mux data */
267 static struct i2c_mux_reg_platform_data mlxplat_default_mux_data[] = {
270 .base_nr = MLXPLAT_CPLD_CH1,
272 .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG1,
278 .base_nr = MLXPLAT_CPLD_CH2,
280 .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG2,
287 /* Platform mux configuration variables */
288 static int mlxplat_max_adap_num;
289 static int mlxplat_mux_num;
290 static struct i2c_mux_reg_platform_data *mlxplat_mux_data;
292 /* Platform extended mux data */
293 static struct i2c_mux_reg_platform_data mlxplat_extended_mux_data[] = {
296 .base_nr = MLXPLAT_CPLD_CH1,
298 .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG1,
304 .base_nr = MLXPLAT_CPLD_CH2,
306 .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG3,
312 .base_nr = MLXPLAT_CPLD_CH3,
314 .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG2,
321 /* Platform hotplug devices */
322 static struct i2c_board_info mlxplat_mlxcpld_psu[] = {
324 I2C_BOARD_INFO("24c02", 0x51),
327 I2C_BOARD_INFO("24c02", 0x50),
331 static struct i2c_board_info mlxplat_mlxcpld_pwr[] = {
333 I2C_BOARD_INFO("dps460", 0x59),
336 I2C_BOARD_INFO("dps460", 0x58),
340 static struct i2c_board_info mlxplat_mlxcpld_ext_pwr[] = {
342 I2C_BOARD_INFO("dps460", 0x5b),
345 I2C_BOARD_INFO("dps460", 0x5a),
349 static struct i2c_board_info mlxplat_mlxcpld_fan[] = {
351 I2C_BOARD_INFO("24c32", 0x50),
354 I2C_BOARD_INFO("24c32", 0x50),
357 I2C_BOARD_INFO("24c32", 0x50),
360 I2C_BOARD_INFO("24c32", 0x50),
364 /* Platform hotplug comex carrier system family data */
365 static struct mlxreg_core_data mlxplat_mlxcpld_comex_psu_items_data[] = {
368 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
370 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
374 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
376 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
380 /* Platform hotplug default data */
381 static struct mlxreg_core_data mlxplat_mlxcpld_default_psu_items_data[] = {
384 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
386 .hpdev.brdinfo = &mlxplat_mlxcpld_psu[0],
387 .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR,
391 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
393 .hpdev.brdinfo = &mlxplat_mlxcpld_psu[1],
394 .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR,
398 static struct mlxreg_core_data mlxplat_mlxcpld_default_pwr_items_data[] = {
401 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
403 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[0],
404 .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR,
408 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
410 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[1],
411 .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR,
415 static struct mlxreg_core_data mlxplat_mlxcpld_default_fan_items_data[] = {
418 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
420 .hpdev.brdinfo = &mlxplat_mlxcpld_fan[0],
421 .hpdev.nr = MLXPLAT_CPLD_FAN1_DEFAULT_NR,
425 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
427 .hpdev.brdinfo = &mlxplat_mlxcpld_fan[1],
428 .hpdev.nr = MLXPLAT_CPLD_FAN2_DEFAULT_NR,
432 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
434 .hpdev.brdinfo = &mlxplat_mlxcpld_fan[2],
435 .hpdev.nr = MLXPLAT_CPLD_FAN3_DEFAULT_NR,
439 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
441 .hpdev.brdinfo = &mlxplat_mlxcpld_fan[3],
442 .hpdev.nr = MLXPLAT_CPLD_FAN4_DEFAULT_NR,
446 static struct mlxreg_core_data mlxplat_mlxcpld_default_asic_items_data[] = {
449 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET,
450 .mask = MLXPLAT_CPLD_ASIC_MASK,
451 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
455 static struct mlxreg_core_item mlxplat_mlxcpld_default_items[] = {
457 .data = mlxplat_mlxcpld_default_psu_items_data,
458 .aggr_mask = MLXPLAT_CPLD_AGGR_PSU_MASK_DEF,
459 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
460 .mask = MLXPLAT_CPLD_PSU_MASK,
461 .count = ARRAY_SIZE(mlxplat_mlxcpld_psu),
466 .data = mlxplat_mlxcpld_default_pwr_items_data,
467 .aggr_mask = MLXPLAT_CPLD_AGGR_PWR_MASK_DEF,
468 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
469 .mask = MLXPLAT_CPLD_PWR_MASK,
470 .count = ARRAY_SIZE(mlxplat_mlxcpld_pwr),
475 .data = mlxplat_mlxcpld_default_fan_items_data,
476 .aggr_mask = MLXPLAT_CPLD_AGGR_FAN_MASK_DEF,
477 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
478 .mask = MLXPLAT_CPLD_FAN_MASK,
479 .count = ARRAY_SIZE(mlxplat_mlxcpld_fan),
484 .data = mlxplat_mlxcpld_default_asic_items_data,
485 .aggr_mask = MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF,
486 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET,
487 .mask = MLXPLAT_CPLD_ASIC_MASK,
488 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data),
494 static struct mlxreg_core_item mlxplat_mlxcpld_comex_items[] = {
496 .data = mlxplat_mlxcpld_comex_psu_items_data,
497 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_CARRIER,
498 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
499 .mask = MLXPLAT_CPLD_PSU_MASK,
500 .count = ARRAY_SIZE(mlxplat_mlxcpld_psu),
505 .data = mlxplat_mlxcpld_default_pwr_items_data,
506 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_CARRIER,
507 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
508 .mask = MLXPLAT_CPLD_PWR_MASK,
509 .count = ARRAY_SIZE(mlxplat_mlxcpld_pwr),
514 .data = mlxplat_mlxcpld_default_fan_items_data,
515 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_CARRIER,
516 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
517 .mask = MLXPLAT_CPLD_FAN_MASK,
518 .count = ARRAY_SIZE(mlxplat_mlxcpld_fan),
523 .data = mlxplat_mlxcpld_default_asic_items_data,
524 .aggr_mask = MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF,
525 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET,
526 .mask = MLXPLAT_CPLD_ASIC_MASK,
527 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data),
534 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_default_data = {
535 .items = mlxplat_mlxcpld_default_items,
536 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_items),
537 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET,
538 .mask = MLXPLAT_CPLD_AGGR_MASK_DEF,
539 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET,
540 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW,
544 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_comex_data = {
545 .items = mlxplat_mlxcpld_comex_items,
546 .counter = ARRAY_SIZE(mlxplat_mlxcpld_comex_items),
547 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET,
548 .mask = MLXPLAT_CPLD_AGGR_MASK_CARR_DEF,
549 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRCX_OFFSET,
550 .mask_low = MLXPLAT_CPLD_LOW_AGGRCX_MASK,
553 static struct mlxreg_core_data mlxplat_mlxcpld_msn21xx_pwr_items_data[] = {
556 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
558 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
562 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
564 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
568 /* Platform hotplug MSN21xx system family data */
569 static struct mlxreg_core_item mlxplat_mlxcpld_msn21xx_items[] = {
571 .data = mlxplat_mlxcpld_msn21xx_pwr_items_data,
572 .aggr_mask = MLXPLAT_CPLD_AGGR_PWR_MASK_DEF,
573 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
574 .mask = MLXPLAT_CPLD_PWR_MASK,
575 .count = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_pwr_items_data),
580 .data = mlxplat_mlxcpld_default_asic_items_data,
581 .aggr_mask = MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF,
582 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET,
583 .mask = MLXPLAT_CPLD_ASIC_MASK,
584 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data),
591 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn21xx_data = {
592 .items = mlxplat_mlxcpld_msn21xx_items,
593 .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_items),
594 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET,
595 .mask = MLXPLAT_CPLD_AGGR_MASK_DEF,
596 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET,
597 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW,
600 /* Platform hotplug msn274x system family data */
601 static struct mlxreg_core_data mlxplat_mlxcpld_msn274x_psu_items_data[] = {
604 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
606 .hpdev.brdinfo = &mlxplat_mlxcpld_psu[0],
607 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR,
611 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
613 .hpdev.brdinfo = &mlxplat_mlxcpld_psu[1],
614 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR,
618 static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_pwr_items_data[] = {
621 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
623 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[0],
624 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR,
628 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
630 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[1],
631 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR,
635 static struct mlxreg_core_data mlxplat_mlxcpld_msn274x_fan_items_data[] = {
638 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
640 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
644 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
646 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
650 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
652 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
656 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
658 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
662 static struct mlxreg_core_item mlxplat_mlxcpld_msn274x_items[] = {
664 .data = mlxplat_mlxcpld_msn274x_psu_items_data,
665 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF,
666 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
667 .mask = MLXPLAT_CPLD_PSU_MASK,
668 .count = ARRAY_SIZE(mlxplat_mlxcpld_msn274x_psu_items_data),
673 .data = mlxplat_mlxcpld_default_ng_pwr_items_data,
674 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF,
675 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
676 .mask = MLXPLAT_CPLD_PWR_MASK,
677 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_pwr_items_data),
682 .data = mlxplat_mlxcpld_msn274x_fan_items_data,
683 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF,
684 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
685 .mask = MLXPLAT_CPLD_FAN_MASK,
686 .count = ARRAY_SIZE(mlxplat_mlxcpld_msn274x_fan_items_data),
691 .data = mlxplat_mlxcpld_default_asic_items_data,
692 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF,
693 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET,
694 .mask = MLXPLAT_CPLD_ASIC_MASK,
695 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data),
702 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn274x_data = {
703 .items = mlxplat_mlxcpld_msn274x_items,
704 .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn274x_items),
705 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET,
706 .mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF,
707 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET,
708 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW,
711 /* Platform hotplug MSN201x system family data */
712 static struct mlxreg_core_data mlxplat_mlxcpld_msn201x_pwr_items_data[] = {
715 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
717 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
721 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
723 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
727 static struct mlxreg_core_item mlxplat_mlxcpld_msn201x_items[] = {
729 .data = mlxplat_mlxcpld_msn201x_pwr_items_data,
730 .aggr_mask = MLXPLAT_CPLD_AGGR_PWR_MASK_DEF,
731 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
732 .mask = MLXPLAT_CPLD_PWR_MASK,
733 .count = ARRAY_SIZE(mlxplat_mlxcpld_msn201x_pwr_items_data),
738 .data = mlxplat_mlxcpld_default_asic_items_data,
739 .aggr_mask = MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF,
740 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET,
741 .mask = MLXPLAT_CPLD_ASIC_MASK,
742 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data),
749 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn201x_data = {
750 .items = mlxplat_mlxcpld_msn201x_items,
751 .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn201x_items),
752 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET,
753 .mask = MLXPLAT_CPLD_AGGR_MASK_DEF,
754 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET,
755 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW,
758 /* Platform hotplug next generation system family data */
759 static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_psu_items_data[] = {
762 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
764 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
768 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
770 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
774 static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_fan_items_data[] = {
777 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
779 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
781 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
785 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
787 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
789 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
793 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
795 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
797 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
801 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
803 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
805 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
809 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
811 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
813 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
817 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
819 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
821 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
825 static struct mlxreg_core_item mlxplat_mlxcpld_default_ng_items[] = {
827 .data = mlxplat_mlxcpld_default_ng_psu_items_data,
828 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF,
829 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
830 .mask = MLXPLAT_CPLD_PSU_MASK,
831 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_psu_items_data),
836 .data = mlxplat_mlxcpld_default_ng_pwr_items_data,
837 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF,
838 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
839 .mask = MLXPLAT_CPLD_PWR_MASK,
840 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_pwr_items_data),
845 .data = mlxplat_mlxcpld_default_ng_fan_items_data,
846 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF,
847 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
848 .mask = MLXPLAT_CPLD_FAN_NG_MASK,
849 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_fan_items_data),
854 .data = mlxplat_mlxcpld_default_asic_items_data,
855 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF,
856 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET,
857 .mask = MLXPLAT_CPLD_ASIC_MASK,
858 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data),
865 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_default_ng_data = {
866 .items = mlxplat_mlxcpld_default_ng_items,
867 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_items),
868 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET,
869 .mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF | MLXPLAT_CPLD_AGGR_MASK_COMEX,
870 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET,
871 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW,
874 /* Platform hotplug extended system family data */
875 static struct mlxreg_core_data mlxplat_mlxcpld_ext_psu_items_data[] = {
878 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
880 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
884 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
886 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
890 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
892 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
896 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
898 .hpdev.nr = MLXPLAT_CPLD_NR_NONE,
902 static struct mlxreg_core_data mlxplat_mlxcpld_ext_pwr_items_data[] = {
905 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
907 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[0],
908 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR,
912 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
914 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[1],
915 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR,
919 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
921 .hpdev.brdinfo = &mlxplat_mlxcpld_ext_pwr[0],
922 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR,
926 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
928 .hpdev.brdinfo = &mlxplat_mlxcpld_ext_pwr[1],
929 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR,
933 static struct mlxreg_core_item mlxplat_mlxcpld_ext_items[] = {
935 .data = mlxplat_mlxcpld_ext_psu_items_data,
936 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF,
937 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET,
938 .mask = MLXPLAT_CPLD_PSU_EXT_MASK,
939 .capability = MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET,
940 .count = ARRAY_SIZE(mlxplat_mlxcpld_ext_psu_items_data),
945 .data = mlxplat_mlxcpld_ext_pwr_items_data,
946 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF,
947 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET,
948 .mask = MLXPLAT_CPLD_PWR_EXT_MASK,
949 .capability = MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET,
950 .count = ARRAY_SIZE(mlxplat_mlxcpld_ext_pwr_items_data),
955 .data = mlxplat_mlxcpld_default_ng_fan_items_data,
956 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF,
957 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
958 .mask = MLXPLAT_CPLD_FAN_NG_MASK,
959 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_fan_items_data),
964 .data = mlxplat_mlxcpld_default_asic_items_data,
965 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF,
966 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET,
967 .mask = MLXPLAT_CPLD_ASIC_MASK,
968 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data),
975 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_ext_data = {
976 .items = mlxplat_mlxcpld_ext_items,
977 .counter = ARRAY_SIZE(mlxplat_mlxcpld_ext_items),
978 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET,
979 .mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF | MLXPLAT_CPLD_AGGR_MASK_COMEX,
980 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET,
981 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW,
984 /* Platform led default data */
985 static struct mlxreg_core_data mlxplat_mlxcpld_default_led_data[] = {
987 .label = "status:green",
988 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
989 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
992 .label = "status:red",
993 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
994 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK
997 .label = "psu:green",
998 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
999 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1003 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
1004 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1007 .label = "fan1:green",
1008 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1009 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1012 .label = "fan1:red",
1013 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1014 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1017 .label = "fan2:green",
1018 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1019 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1022 .label = "fan2:red",
1023 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1024 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1027 .label = "fan3:green",
1028 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
1029 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1032 .label = "fan3:red",
1033 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
1034 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1037 .label = "fan4:green",
1038 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
1039 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1042 .label = "fan4:red",
1043 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
1044 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1048 static struct mlxreg_core_platform_data mlxplat_default_led_data = {
1049 .data = mlxplat_mlxcpld_default_led_data,
1050 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_led_data),
1053 /* Platform led MSN21xx system family data */
1054 static struct mlxreg_core_data mlxplat_mlxcpld_msn21xx_led_data[] = {
1056 .label = "status:green",
1057 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
1058 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1061 .label = "status:red",
1062 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
1063 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK
1066 .label = "fan:green",
1067 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1068 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1072 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1073 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1076 .label = "psu1:green",
1077 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
1078 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1081 .label = "psu1:red",
1082 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
1083 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1086 .label = "psu2:green",
1087 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
1088 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1091 .label = "psu2:red",
1092 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
1093 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1096 .label = "uid:blue",
1097 .reg = MLXPLAT_CPLD_LPC_REG_LED5_OFFSET,
1098 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1102 static struct mlxreg_core_platform_data mlxplat_msn21xx_led_data = {
1103 .data = mlxplat_mlxcpld_msn21xx_led_data,
1104 .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_led_data),
1107 /* Platform led for default data for 200GbE systems */
1108 static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_led_data[] = {
1110 .label = "status:green",
1111 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
1112 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1115 .label = "status:orange",
1116 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
1117 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK
1120 .label = "psu:green",
1121 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
1122 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1125 .label = "psu:orange",
1126 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
1127 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1130 .label = "fan1:green",
1131 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1132 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1133 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
1137 .label = "fan1:orange",
1138 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1139 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1140 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
1144 .label = "fan2:green",
1145 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1146 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1147 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
1151 .label = "fan2:orange",
1152 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1153 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1154 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
1158 .label = "fan3:green",
1159 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
1160 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1161 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
1165 .label = "fan3:orange",
1166 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
1167 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1168 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
1172 .label = "fan4:green",
1173 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
1174 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1175 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
1179 .label = "fan4:orange",
1180 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
1181 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1182 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
1186 .label = "fan5:green",
1187 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
1188 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1189 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
1193 .label = "fan5:orange",
1194 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
1195 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1196 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
1200 .label = "fan6:green",
1201 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
1202 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1203 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
1207 .label = "fan6:orange",
1208 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
1209 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1210 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET,
1214 .label = "uid:blue",
1215 .reg = MLXPLAT_CPLD_LPC_REG_LED5_OFFSET,
1216 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1220 static struct mlxreg_core_platform_data mlxplat_default_ng_led_data = {
1221 .data = mlxplat_mlxcpld_default_ng_led_data,
1222 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_led_data),
1225 /* Platform led for Comex based 100GbE systems */
1226 static struct mlxreg_core_data mlxplat_mlxcpld_comex_100G_led_data[] = {
1228 .label = "status:green",
1229 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
1230 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1233 .label = "status:red",
1234 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
1235 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK
1238 .label = "psu:green",
1239 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
1240 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1244 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
1245 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1248 .label = "fan1:green",
1249 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1250 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1253 .label = "fan1:red",
1254 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1255 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1258 .label = "fan2:green",
1259 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1260 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1263 .label = "fan2:red",
1264 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
1265 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1268 .label = "fan3:green",
1269 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
1270 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1273 .label = "fan3:red",
1274 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
1275 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1278 .label = "fan4:green",
1279 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
1280 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1283 .label = "fan4:red",
1284 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
1285 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
1288 .label = "uid:blue",
1289 .reg = MLXPLAT_CPLD_LPC_REG_LED5_OFFSET,
1290 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
1294 static struct mlxreg_core_platform_data mlxplat_comex_100G_led_data = {
1295 .data = mlxplat_mlxcpld_comex_100G_led_data,
1296 .counter = ARRAY_SIZE(mlxplat_mlxcpld_comex_100G_led_data),
1299 /* Platform register access default */
1300 static struct mlxreg_core_data mlxplat_mlxcpld_default_regs_io_data[] = {
1302 .label = "cpld1_version",
1303 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET,
1304 .bit = GENMASK(7, 0),
1308 .label = "cpld2_version",
1309 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET,
1310 .bit = GENMASK(7, 0),
1314 .label = "cpld1_pn",
1315 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_PN_OFFSET,
1316 .bit = GENMASK(15, 0),
1321 .label = "cpld2_pn",
1322 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_PN_OFFSET,
1323 .bit = GENMASK(15, 0),
1328 .label = "cpld1_version_min",
1329 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_MVER_OFFSET,
1330 .bit = GENMASK(7, 0),
1334 .label = "cpld2_version_min",
1335 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_MVER_OFFSET,
1336 .bit = GENMASK(7, 0),
1340 .label = "reset_long_pb",
1341 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1342 .mask = GENMASK(7, 0) & ~BIT(0),
1346 .label = "reset_short_pb",
1347 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1348 .mask = GENMASK(7, 0) & ~BIT(1),
1352 .label = "reset_aux_pwr_or_ref",
1353 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1354 .mask = GENMASK(7, 0) & ~BIT(2),
1358 .label = "reset_main_pwr_fail",
1359 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1360 .mask = GENMASK(7, 0) & ~BIT(3),
1364 .label = "reset_sw_reset",
1365 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1366 .mask = GENMASK(7, 0) & ~BIT(4),
1370 .label = "reset_fw_reset",
1371 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1372 .mask = GENMASK(7, 0) & ~BIT(5),
1376 .label = "reset_hotswap_or_wd",
1377 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1378 .mask = GENMASK(7, 0) & ~BIT(6),
1382 .label = "reset_asic_thermal",
1383 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1384 .mask = GENMASK(7, 0) & ~BIT(7),
1389 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET,
1390 .mask = GENMASK(7, 0) & ~BIT(0),
1395 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET,
1396 .mask = GENMASK(7, 0) & ~BIT(1),
1400 .label = "pwr_cycle",
1401 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET,
1402 .mask = GENMASK(7, 0) & ~BIT(2),
1406 .label = "pwr_down",
1407 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET,
1408 .mask = GENMASK(7, 0) & ~BIT(3),
1412 .label = "select_iio",
1413 .reg = MLXPLAT_CPLD_LPC_REG_GP2_OFFSET,
1414 .mask = GENMASK(7, 0) & ~BIT(6),
1418 .label = "asic_health",
1419 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET,
1420 .mask = MLXPLAT_CPLD_ASIC_MASK,
1426 static struct mlxreg_core_platform_data mlxplat_default_regs_io_data = {
1427 .data = mlxplat_mlxcpld_default_regs_io_data,
1428 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_regs_io_data),
1431 /* Platform register access MSN21xx, MSN201x, MSN274x systems families data */
1432 static struct mlxreg_core_data mlxplat_mlxcpld_msn21xx_regs_io_data[] = {
1434 .label = "cpld1_version",
1435 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET,
1436 .bit = GENMASK(7, 0),
1440 .label = "cpld2_version",
1441 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET,
1442 .bit = GENMASK(7, 0),
1446 .label = "cpld1_pn",
1447 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_PN_OFFSET,
1448 .bit = GENMASK(15, 0),
1453 .label = "cpld2_pn",
1454 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_PN_OFFSET,
1455 .bit = GENMASK(15, 0),
1460 .label = "cpld1_version_min",
1461 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_MVER_OFFSET,
1462 .bit = GENMASK(7, 0),
1466 .label = "cpld2_version_min",
1467 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_MVER_OFFSET,
1468 .bit = GENMASK(7, 0),
1472 .label = "reset_long_pb",
1473 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1474 .mask = GENMASK(7, 0) & ~BIT(0),
1478 .label = "reset_short_pb",
1479 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1480 .mask = GENMASK(7, 0) & ~BIT(1),
1484 .label = "reset_aux_pwr_or_ref",
1485 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1486 .mask = GENMASK(7, 0) & ~BIT(2),
1490 .label = "reset_sw_reset",
1491 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1492 .mask = GENMASK(7, 0) & ~BIT(3),
1496 .label = "reset_main_pwr_fail",
1497 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1498 .mask = GENMASK(7, 0) & ~BIT(4),
1502 .label = "reset_asic_thermal",
1503 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1504 .mask = GENMASK(7, 0) & ~BIT(5),
1508 .label = "reset_hotswap_or_halt",
1509 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1510 .mask = GENMASK(7, 0) & ~BIT(6),
1514 .label = "reset_sff_wd",
1515 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET,
1516 .mask = GENMASK(7, 0) & ~BIT(6),
1521 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET,
1522 .mask = GENMASK(7, 0) & ~BIT(0),
1527 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET,
1528 .mask = GENMASK(7, 0) & ~BIT(1),
1532 .label = "pwr_cycle",
1533 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET,
1534 .mask = GENMASK(7, 0) & ~BIT(2),
1538 .label = "pwr_down",
1539 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET,
1540 .mask = GENMASK(7, 0) & ~BIT(3),
1544 .label = "select_iio",
1545 .reg = MLXPLAT_CPLD_LPC_REG_GP2_OFFSET,
1546 .mask = GENMASK(7, 0) & ~BIT(6),
1550 .label = "asic_health",
1551 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET,
1552 .mask = MLXPLAT_CPLD_ASIC_MASK,
1558 static struct mlxreg_core_platform_data mlxplat_msn21xx_regs_io_data = {
1559 .data = mlxplat_mlxcpld_msn21xx_regs_io_data,
1560 .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_regs_io_data),
1563 /* Platform register access for next generation systems families data */
1564 static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_regs_io_data[] = {
1566 .label = "cpld1_version",
1567 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET,
1568 .bit = GENMASK(7, 0),
1572 .label = "cpld2_version",
1573 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET,
1574 .bit = GENMASK(7, 0),
1578 .label = "cpld3_version",
1579 .reg = MLXPLAT_CPLD_LPC_REG_CPLD3_VER_OFFSET,
1580 .bit = GENMASK(7, 0),
1584 .label = "cpld4_version",
1585 .reg = MLXPLAT_CPLD_LPC_REG_CPLD4_VER_OFFSET,
1586 .bit = GENMASK(7, 0),
1590 .label = "cpld1_pn",
1591 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_PN_OFFSET,
1592 .bit = GENMASK(15, 0),
1597 .label = "cpld2_pn",
1598 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_PN_OFFSET,
1599 .bit = GENMASK(15, 0),
1604 .label = "cpld3_pn",
1605 .reg = MLXPLAT_CPLD_LPC_REG_CPLD3_PN_OFFSET,
1606 .bit = GENMASK(15, 0),
1611 .label = "cpld4_pn",
1612 .reg = MLXPLAT_CPLD_LPC_REG_CPLD4_PN_OFFSET,
1613 .bit = GENMASK(15, 0),
1618 .label = "cpld1_version_min",
1619 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_MVER_OFFSET,
1620 .bit = GENMASK(7, 0),
1624 .label = "cpld2_version_min",
1625 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_MVER_OFFSET,
1626 .bit = GENMASK(7, 0),
1630 .label = "cpld3_version_min",
1631 .reg = MLXPLAT_CPLD_LPC_REG_CPLD3_MVER_OFFSET,
1632 .bit = GENMASK(7, 0),
1636 .label = "cpld4_version_min",
1637 .reg = MLXPLAT_CPLD_LPC_REG_CPLD4_MVER_OFFSET,
1638 .bit = GENMASK(7, 0),
1642 .label = "reset_long_pb",
1643 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1644 .mask = GENMASK(7, 0) & ~BIT(0),
1648 .label = "reset_short_pb",
1649 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1650 .mask = GENMASK(7, 0) & ~BIT(1),
1654 .label = "reset_aux_pwr_or_ref",
1655 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1656 .mask = GENMASK(7, 0) & ~BIT(2),
1660 .label = "reset_from_comex",
1661 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1662 .mask = GENMASK(7, 0) & ~BIT(4),
1666 .label = "reset_from_asic",
1667 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1668 .mask = GENMASK(7, 0) & ~BIT(5),
1672 .label = "reset_swb_wd",
1673 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1674 .mask = GENMASK(7, 0) & ~BIT(6),
1678 .label = "reset_asic_thermal",
1679 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1680 .mask = GENMASK(7, 0) & ~BIT(7),
1684 .label = "reset_comex_pwr_fail",
1685 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET,
1686 .mask = GENMASK(7, 0) & ~BIT(3),
1690 .label = "reset_platform",
1691 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET,
1692 .mask = GENMASK(7, 0) & ~BIT(4),
1696 .label = "reset_soc",
1697 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET,
1698 .mask = GENMASK(7, 0) & ~BIT(5),
1702 .label = "reset_comex_wd",
1703 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET,
1704 .mask = GENMASK(7, 0) & ~BIT(6),
1708 .label = "reset_voltmon_upgrade_fail",
1709 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET,
1710 .mask = GENMASK(7, 0) & ~BIT(0),
1714 .label = "reset_system",
1715 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET,
1716 .mask = GENMASK(7, 0) & ~BIT(1),
1720 .label = "reset_sw_pwr_off",
1721 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET,
1722 .mask = GENMASK(7, 0) & ~BIT(2),
1726 .label = "reset_comex_thermal",
1727 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET,
1728 .mask = GENMASK(7, 0) & ~BIT(3),
1732 .label = "reset_reload_bios",
1733 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET,
1734 .mask = GENMASK(7, 0) & ~BIT(5),
1738 .label = "reset_ac_pwr_fail",
1739 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET,
1740 .mask = GENMASK(7, 0) & ~BIT(6),
1745 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET,
1746 .mask = GENMASK(7, 0) & ~BIT(0),
1751 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET,
1752 .mask = GENMASK(7, 0) & ~BIT(1),
1756 .label = "pwr_cycle",
1757 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET,
1758 .mask = GENMASK(7, 0) & ~BIT(2),
1762 .label = "pwr_down",
1763 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET,
1764 .mask = GENMASK(7, 0) & ~BIT(3),
1768 .label = "jtag_enable",
1769 .reg = MLXPLAT_CPLD_LPC_REG_GP2_OFFSET,
1770 .mask = GENMASK(7, 0) & ~BIT(4),
1774 .label = "asic_health",
1775 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET,
1776 .mask = MLXPLAT_CPLD_ASIC_MASK,
1782 .reg = MLXPLAT_CPLD_LPC_REG_FAN_DIRECTION,
1783 .bit = GENMASK(7, 0),
1787 .label = "voltreg_update_status",
1788 .reg = MLXPLAT_CPLD_LPC_REG_GP0_RO_OFFSET,
1789 .mask = MLXPLAT_CPLD_VOLTREG_UPD_MASK,
1795 .reg = MLXPLAT_CPLD_LPC_REG_GP0_OFFSET,
1796 .mask = GENMASK(7, 0) & ~BIT(3),
1800 .label = "pcie_asic_reset_dis",
1801 .reg = MLXPLAT_CPLD_LPC_REG_GP0_OFFSET,
1802 .mask = GENMASK(7, 0) & ~BIT(4),
1807 .reg = MLXPLAT_CPLD_LPC_REG_CONFIG1_OFFSET,
1808 .bit = GENMASK(7, 0),
1813 .reg = MLXPLAT_CPLD_LPC_REG_CONFIG2_OFFSET,
1814 .bit = GENMASK(7, 0),
1818 .label = "ufm_version",
1819 .reg = MLXPLAT_CPLD_LPC_REG_UFM_VERSION_OFFSET,
1820 .bit = GENMASK(7, 0),
1825 static struct mlxreg_core_platform_data mlxplat_default_ng_regs_io_data = {
1826 .data = mlxplat_mlxcpld_default_ng_regs_io_data,
1827 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_regs_io_data),
1830 /* Platform FAN default */
1831 static struct mlxreg_core_data mlxplat_mlxcpld_default_fan_data[] = {
1834 .reg = MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET,
1838 .reg = MLXPLAT_CPLD_LPC_REG_TACHO1_OFFSET,
1839 .mask = GENMASK(7, 0),
1840 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET,
1842 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
1847 .reg = MLXPLAT_CPLD_LPC_REG_TACHO2_OFFSET,
1848 .mask = GENMASK(7, 0),
1849 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET,
1851 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
1855 .reg = MLXPLAT_CPLD_LPC_REG_TACHO3_OFFSET,
1856 .mask = GENMASK(7, 0),
1857 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET,
1859 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
1863 .reg = MLXPLAT_CPLD_LPC_REG_TACHO4_OFFSET,
1864 .mask = GENMASK(7, 0),
1865 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET,
1867 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
1871 .reg = MLXPLAT_CPLD_LPC_REG_TACHO5_OFFSET,
1872 .mask = GENMASK(7, 0),
1873 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET,
1875 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
1879 .reg = MLXPLAT_CPLD_LPC_REG_TACHO6_OFFSET,
1880 .mask = GENMASK(7, 0),
1881 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET,
1883 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
1887 .reg = MLXPLAT_CPLD_LPC_REG_TACHO7_OFFSET,
1888 .mask = GENMASK(7, 0),
1889 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET,
1891 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
1895 .reg = MLXPLAT_CPLD_LPC_REG_TACHO8_OFFSET,
1896 .mask = GENMASK(7, 0),
1897 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET,
1899 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
1903 .reg = MLXPLAT_CPLD_LPC_REG_TACHO9_OFFSET,
1904 .mask = GENMASK(7, 0),
1905 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP2_OFFSET,
1907 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
1911 .reg = MLXPLAT_CPLD_LPC_REG_TACHO10_OFFSET,
1912 .mask = GENMASK(7, 0),
1913 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP2_OFFSET,
1915 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
1919 .reg = MLXPLAT_CPLD_LPC_REG_TACHO11_OFFSET,
1920 .mask = GENMASK(7, 0),
1921 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP2_OFFSET,
1923 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
1927 .reg = MLXPLAT_CPLD_LPC_REG_TACHO12_OFFSET,
1928 .mask = GENMASK(7, 0),
1929 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP2_OFFSET,
1931 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET,
1935 .capability = MLXPLAT_CPLD_LPC_REG_TACHO_SPEED_OFFSET,
1939 static struct mlxreg_core_platform_data mlxplat_default_fan_data = {
1940 .data = mlxplat_mlxcpld_default_fan_data,
1941 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_fan_data),
1944 /* Watchdog type1: hardware implementation version1
1945 * (MSN2700, MSN2410, MSN2740, MSN2100 and MSN2140 systems).
1947 static struct mlxreg_core_data mlxplat_mlxcpld_wd_main_regs_type1[] = {
1950 .reg = MLXPLAT_CPLD_LPC_REG_WD1_ACT_OFFSET,
1951 .mask = MLXPLAT_CPLD_WD_RESET_ACT_MASK,
1956 .reg = MLXPLAT_CPLD_LPC_REG_WD1_TMR_OFFSET,
1957 .mask = MLXPLAT_CPLD_WD_TYPE1_TO_MASK,
1958 .health_cntr = MLXPLAT_CPLD_WD_DFLT_TIMEOUT,
1962 .reg = MLXPLAT_CPLD_LPC_REG_WD_CLEAR_OFFSET,
1963 .mask = MLXPLAT_CPLD_WD1_CLEAR_MASK,
1968 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
1969 .mask = GENMASK(7, 0) & ~BIT(6),
1974 static struct mlxreg_core_data mlxplat_mlxcpld_wd_aux_regs_type1[] = {
1977 .reg = MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET,
1978 .mask = MLXPLAT_CPLD_WD_FAN_ACT_MASK,
1983 .reg = MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET,
1984 .mask = MLXPLAT_CPLD_WD_TYPE1_TO_MASK,
1985 .health_cntr = MLXPLAT_CPLD_WD_DFLT_TIMEOUT,
1989 .reg = MLXPLAT_CPLD_LPC_REG_WD_CLEAR_OFFSET,
1990 .mask = MLXPLAT_CPLD_WD1_CLEAR_MASK,
1995 static struct mlxreg_core_platform_data mlxplat_mlxcpld_wd_set_type1[] = {
1997 .data = mlxplat_mlxcpld_wd_main_regs_type1,
1998 .counter = ARRAY_SIZE(mlxplat_mlxcpld_wd_main_regs_type1),
1999 .version = MLX_WDT_TYPE1,
2000 .identity = "mlx-wdt-main",
2003 .data = mlxplat_mlxcpld_wd_aux_regs_type1,
2004 .counter = ARRAY_SIZE(mlxplat_mlxcpld_wd_aux_regs_type1),
2005 .version = MLX_WDT_TYPE1,
2006 .identity = "mlx-wdt-aux",
2010 /* Watchdog type2: hardware implementation version 2
2011 * (all systems except (MSN2700, MSN2410, MSN2740, MSN2100 and MSN2140).
2013 static struct mlxreg_core_data mlxplat_mlxcpld_wd_main_regs_type2[] = {
2016 .reg = MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET,
2017 .mask = MLXPLAT_CPLD_WD_RESET_ACT_MASK,
2022 .reg = MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET,
2023 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK,
2024 .health_cntr = MLXPLAT_CPLD_WD_DFLT_TIMEOUT,
2027 .label = "timeleft",
2028 .reg = MLXPLAT_CPLD_LPC_REG_WD2_TLEFT_OFFSET,
2029 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK,
2033 .reg = MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET,
2034 .mask = MLXPLAT_CPLD_WD_RESET_ACT_MASK,
2039 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
2040 .mask = GENMASK(7, 0) & ~BIT(6),
2045 static struct mlxreg_core_data mlxplat_mlxcpld_wd_aux_regs_type2[] = {
2048 .reg = MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET,
2049 .mask = MLXPLAT_CPLD_WD_FAN_ACT_MASK,
2054 .reg = MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET,
2055 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK,
2056 .health_cntr = MLXPLAT_CPLD_WD_DFLT_TIMEOUT,
2059 .label = "timeleft",
2060 .reg = MLXPLAT_CPLD_LPC_REG_WD3_TLEFT_OFFSET,
2061 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK,
2065 .reg = MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET,
2066 .mask = MLXPLAT_CPLD_WD_FAN_ACT_MASK,
2071 static struct mlxreg_core_platform_data mlxplat_mlxcpld_wd_set_type2[] = {
2073 .data = mlxplat_mlxcpld_wd_main_regs_type2,
2074 .counter = ARRAY_SIZE(mlxplat_mlxcpld_wd_main_regs_type2),
2075 .version = MLX_WDT_TYPE2,
2076 .identity = "mlx-wdt-main",
2079 .data = mlxplat_mlxcpld_wd_aux_regs_type2,
2080 .counter = ARRAY_SIZE(mlxplat_mlxcpld_wd_aux_regs_type2),
2081 .version = MLX_WDT_TYPE2,
2082 .identity = "mlx-wdt-aux",
2086 /* Watchdog type3: hardware implementation version 3
2087 * Can be on all systems. It's differentiated by WD capability bit.
2088 * Old systems (MSN2700, MSN2410, MSN2740, MSN2100 and MSN2140)
2089 * still have only one main watchdog.
2091 static struct mlxreg_core_data mlxplat_mlxcpld_wd_main_regs_type3[] = {
2094 .reg = MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET,
2095 .mask = MLXPLAT_CPLD_WD_RESET_ACT_MASK,
2100 .reg = MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET,
2101 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK,
2102 .health_cntr = MLXPLAT_CPLD_WD3_DFLT_TIMEOUT,
2105 .label = "timeleft",
2106 .reg = MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET,
2107 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK,
2111 .reg = MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET,
2112 .mask = MLXPLAT_CPLD_WD_RESET_ACT_MASK,
2117 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET,
2118 .mask = GENMASK(7, 0) & ~BIT(6),
2123 static struct mlxreg_core_data mlxplat_mlxcpld_wd_aux_regs_type3[] = {
2126 .reg = MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET,
2127 .mask = MLXPLAT_CPLD_WD_FAN_ACT_MASK,
2132 .reg = MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET,
2133 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK,
2134 .health_cntr = MLXPLAT_CPLD_WD3_DFLT_TIMEOUT,
2137 .label = "timeleft",
2138 .reg = MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET,
2139 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK,
2143 .reg = MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET,
2144 .mask = MLXPLAT_CPLD_WD_FAN_ACT_MASK,
2149 static struct mlxreg_core_platform_data mlxplat_mlxcpld_wd_set_type3[] = {
2151 .data = mlxplat_mlxcpld_wd_main_regs_type3,
2152 .counter = ARRAY_SIZE(mlxplat_mlxcpld_wd_main_regs_type3),
2153 .version = MLX_WDT_TYPE3,
2154 .identity = "mlx-wdt-main",
2157 .data = mlxplat_mlxcpld_wd_aux_regs_type3,
2158 .counter = ARRAY_SIZE(mlxplat_mlxcpld_wd_aux_regs_type3),
2159 .version = MLX_WDT_TYPE3,
2160 .identity = "mlx-wdt-aux",
2164 static bool mlxplat_mlxcpld_writeable_reg(struct device *dev, unsigned int reg)
2167 case MLXPLAT_CPLD_LPC_REG_LED1_OFFSET:
2168 case MLXPLAT_CPLD_LPC_REG_LED2_OFFSET:
2169 case MLXPLAT_CPLD_LPC_REG_LED3_OFFSET:
2170 case MLXPLAT_CPLD_LPC_REG_LED4_OFFSET:
2171 case MLXPLAT_CPLD_LPC_REG_LED5_OFFSET:
2172 case MLXPLAT_CPLD_LPC_REG_GP0_OFFSET:
2173 case MLXPLAT_CPLD_LPC_REG_GP1_OFFSET:
2174 case MLXPLAT_CPLD_LPC_REG_WP1_OFFSET:
2175 case MLXPLAT_CPLD_LPC_REG_GP2_OFFSET:
2176 case MLXPLAT_CPLD_LPC_REG_WP2_OFFSET:
2177 case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET:
2178 case MLXPLAT_CPLD_LPC_REG_AGGRLO_MASK_OFFSET:
2179 case MLXPLAT_CPLD_LPC_REG_AGGRCO_MASK_OFFSET:
2180 case MLXPLAT_CPLD_LPC_REG_AGGRCX_MASK_OFFSET:
2181 case MLXPLAT_CPLD_LPC_REG_ASIC_EVENT_OFFSET:
2182 case MLXPLAT_CPLD_LPC_REG_ASIC_MASK_OFFSET:
2183 case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFFSET:
2184 case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFFSET:
2185 case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFFSET:
2186 case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFFSET:
2187 case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET:
2188 case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET:
2189 case MLXPLAT_CPLD_LPC_REG_WD_CLEAR_OFFSET:
2190 case MLXPLAT_CPLD_LPC_REG_WD_CLEAR_WP_OFFSET:
2191 case MLXPLAT_CPLD_LPC_REG_WD1_TMR_OFFSET:
2192 case MLXPLAT_CPLD_LPC_REG_WD1_ACT_OFFSET:
2193 case MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET:
2194 case MLXPLAT_CPLD_LPC_REG_WD2_TLEFT_OFFSET:
2195 case MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET:
2196 case MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET:
2197 case MLXPLAT_CPLD_LPC_REG_WD3_TLEFT_OFFSET:
2198 case MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET:
2199 case MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET:
2200 case MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET:
2206 static bool mlxplat_mlxcpld_readable_reg(struct device *dev, unsigned int reg)
2209 case MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET:
2210 case MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET:
2211 case MLXPLAT_CPLD_LPC_REG_CPLD3_VER_OFFSET:
2212 case MLXPLAT_CPLD_LPC_REG_CPLD4_VER_OFFSET:
2213 case MLXPLAT_CPLD_LPC_REG_CPLD1_PN_OFFSET:
2214 case MLXPLAT_CPLD_LPC_REG_CPLD2_PN_OFFSET:
2215 case MLXPLAT_CPLD_LPC_REG_CPLD3_PN_OFFSET:
2216 case MLXPLAT_CPLD_LPC_REG_CPLD4_PN_OFFSET:
2217 case MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET:
2218 case MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET:
2219 case MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET:
2220 case MLXPLAT_CPLD_LPC_REG_LED1_OFFSET:
2221 case MLXPLAT_CPLD_LPC_REG_LED2_OFFSET:
2222 case MLXPLAT_CPLD_LPC_REG_LED3_OFFSET:
2223 case MLXPLAT_CPLD_LPC_REG_LED4_OFFSET:
2224 case MLXPLAT_CPLD_LPC_REG_LED5_OFFSET:
2225 case MLXPLAT_CPLD_LPC_REG_FAN_DIRECTION:
2226 case MLXPLAT_CPLD_LPC_REG_GP0_RO_OFFSET:
2227 case MLXPLAT_CPLD_LPC_REG_GP0_OFFSET:
2228 case MLXPLAT_CPLD_LPC_REG_GP1_OFFSET:
2229 case MLXPLAT_CPLD_LPC_REG_WP1_OFFSET:
2230 case MLXPLAT_CPLD_LPC_REG_GP2_OFFSET:
2231 case MLXPLAT_CPLD_LPC_REG_WP2_OFFSET:
2232 case MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET:
2233 case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET:
2234 case MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET:
2235 case MLXPLAT_CPLD_LPC_REG_AGGRLO_MASK_OFFSET:
2236 case MLXPLAT_CPLD_LPC_REG_AGGRCO_OFFSET:
2237 case MLXPLAT_CPLD_LPC_REG_AGGRCO_MASK_OFFSET:
2238 case MLXPLAT_CPLD_LPC_REG_AGGRCX_OFFSET:
2239 case MLXPLAT_CPLD_LPC_REG_AGGRCX_MASK_OFFSET:
2240 case MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET:
2241 case MLXPLAT_CPLD_LPC_REG_ASIC_EVENT_OFFSET:
2242 case MLXPLAT_CPLD_LPC_REG_ASIC_MASK_OFFSET:
2243 case MLXPLAT_CPLD_LPC_REG_PSU_OFFSET:
2244 case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFFSET:
2245 case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFFSET:
2246 case MLXPLAT_CPLD_LPC_REG_PWR_OFFSET:
2247 case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFFSET:
2248 case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFFSET:
2249 case MLXPLAT_CPLD_LPC_REG_FAN_OFFSET:
2250 case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET:
2251 case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET:
2252 case MLXPLAT_CPLD_LPC_REG_WD_CLEAR_OFFSET:
2253 case MLXPLAT_CPLD_LPC_REG_WD_CLEAR_WP_OFFSET:
2254 case MLXPLAT_CPLD_LPC_REG_WD1_TMR_OFFSET:
2255 case MLXPLAT_CPLD_LPC_REG_WD1_ACT_OFFSET:
2256 case MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET:
2257 case MLXPLAT_CPLD_LPC_REG_WD2_TLEFT_OFFSET:
2258 case MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET:
2259 case MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET:
2260 case MLXPLAT_CPLD_LPC_REG_WD3_TLEFT_OFFSET:
2261 case MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET:
2262 case MLXPLAT_CPLD_LPC_REG_CPLD1_MVER_OFFSET:
2263 case MLXPLAT_CPLD_LPC_REG_CPLD2_MVER_OFFSET:
2264 case MLXPLAT_CPLD_LPC_REG_CPLD3_MVER_OFFSET:
2265 case MLXPLAT_CPLD_LPC_REG_CPLD4_MVER_OFFSET:
2266 case MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET:
2267 case MLXPLAT_CPLD_LPC_REG_TACHO1_OFFSET:
2268 case MLXPLAT_CPLD_LPC_REG_TACHO2_OFFSET:
2269 case MLXPLAT_CPLD_LPC_REG_TACHO3_OFFSET:
2270 case MLXPLAT_CPLD_LPC_REG_TACHO4_OFFSET:
2271 case MLXPLAT_CPLD_LPC_REG_TACHO5_OFFSET:
2272 case MLXPLAT_CPLD_LPC_REG_TACHO6_OFFSET:
2273 case MLXPLAT_CPLD_LPC_REG_TACHO7_OFFSET:
2274 case MLXPLAT_CPLD_LPC_REG_TACHO8_OFFSET:
2275 case MLXPLAT_CPLD_LPC_REG_TACHO9_OFFSET:
2276 case MLXPLAT_CPLD_LPC_REG_TACHO10_OFFSET:
2277 case MLXPLAT_CPLD_LPC_REG_TACHO11_OFFSET:
2278 case MLXPLAT_CPLD_LPC_REG_TACHO12_OFFSET:
2279 case MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET:
2280 case MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET:
2281 case MLXPLAT_CPLD_LPC_REG_FAN_CAP2_OFFSET:
2282 case MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET:
2283 case MLXPLAT_CPLD_LPC_REG_TACHO_SPEED_OFFSET:
2284 case MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET:
2285 case MLXPLAT_CPLD_LPC_REG_CONFIG1_OFFSET:
2286 case MLXPLAT_CPLD_LPC_REG_CONFIG2_OFFSET:
2287 case MLXPLAT_CPLD_LPC_REG_UFM_VERSION_OFFSET:
2293 static bool mlxplat_mlxcpld_volatile_reg(struct device *dev, unsigned int reg)
2296 case MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET:
2297 case MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET:
2298 case MLXPLAT_CPLD_LPC_REG_CPLD3_VER_OFFSET:
2299 case MLXPLAT_CPLD_LPC_REG_CPLD4_VER_OFFSET:
2300 case MLXPLAT_CPLD_LPC_REG_CPLD1_PN_OFFSET:
2301 case MLXPLAT_CPLD_LPC_REG_CPLD2_PN_OFFSET:
2302 case MLXPLAT_CPLD_LPC_REG_CPLD3_PN_OFFSET:
2303 case MLXPLAT_CPLD_LPC_REG_CPLD4_PN_OFFSET:
2304 case MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET:
2305 case MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET:
2306 case MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET:
2307 case MLXPLAT_CPLD_LPC_REG_LED1_OFFSET:
2308 case MLXPLAT_CPLD_LPC_REG_LED2_OFFSET:
2309 case MLXPLAT_CPLD_LPC_REG_LED3_OFFSET:
2310 case MLXPLAT_CPLD_LPC_REG_LED4_OFFSET:
2311 case MLXPLAT_CPLD_LPC_REG_LED5_OFFSET:
2312 case MLXPLAT_CPLD_LPC_REG_FAN_DIRECTION:
2313 case MLXPLAT_CPLD_LPC_REG_GP0_RO_OFFSET:
2314 case MLXPLAT_CPLD_LPC_REG_GP0_OFFSET:
2315 case MLXPLAT_CPLD_LPC_REG_GP1_OFFSET:
2316 case MLXPLAT_CPLD_LPC_REG_GP2_OFFSET:
2317 case MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET:
2318 case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET:
2319 case MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET:
2320 case MLXPLAT_CPLD_LPC_REG_AGGRLO_MASK_OFFSET:
2321 case MLXPLAT_CPLD_LPC_REG_AGGRCO_OFFSET:
2322 case MLXPLAT_CPLD_LPC_REG_AGGRCO_MASK_OFFSET:
2323 case MLXPLAT_CPLD_LPC_REG_AGGRCX_OFFSET:
2324 case MLXPLAT_CPLD_LPC_REG_AGGRCX_MASK_OFFSET:
2325 case MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET:
2326 case MLXPLAT_CPLD_LPC_REG_ASIC_EVENT_OFFSET:
2327 case MLXPLAT_CPLD_LPC_REG_ASIC_MASK_OFFSET:
2328 case MLXPLAT_CPLD_LPC_REG_PSU_OFFSET:
2329 case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFFSET:
2330 case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFFSET:
2331 case MLXPLAT_CPLD_LPC_REG_PWR_OFFSET:
2332 case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFFSET:
2333 case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFFSET:
2334 case MLXPLAT_CPLD_LPC_REG_FAN_OFFSET:
2335 case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET:
2336 case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET:
2337 case MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET:
2338 case MLXPLAT_CPLD_LPC_REG_WD2_TLEFT_OFFSET:
2339 case MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET:
2340 case MLXPLAT_CPLD_LPC_REG_WD3_TLEFT_OFFSET:
2341 case MLXPLAT_CPLD_LPC_REG_CPLD1_MVER_OFFSET:
2342 case MLXPLAT_CPLD_LPC_REG_CPLD2_MVER_OFFSET:
2343 case MLXPLAT_CPLD_LPC_REG_CPLD3_MVER_OFFSET:
2344 case MLXPLAT_CPLD_LPC_REG_CPLD4_MVER_OFFSET:
2345 case MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET:
2346 case MLXPLAT_CPLD_LPC_REG_TACHO1_OFFSET:
2347 case MLXPLAT_CPLD_LPC_REG_TACHO2_OFFSET:
2348 case MLXPLAT_CPLD_LPC_REG_TACHO3_OFFSET:
2349 case MLXPLAT_CPLD_LPC_REG_TACHO4_OFFSET:
2350 case MLXPLAT_CPLD_LPC_REG_TACHO5_OFFSET:
2351 case MLXPLAT_CPLD_LPC_REG_TACHO6_OFFSET:
2352 case MLXPLAT_CPLD_LPC_REG_TACHO7_OFFSET:
2353 case MLXPLAT_CPLD_LPC_REG_TACHO8_OFFSET:
2354 case MLXPLAT_CPLD_LPC_REG_TACHO9_OFFSET:
2355 case MLXPLAT_CPLD_LPC_REG_TACHO10_OFFSET:
2356 case MLXPLAT_CPLD_LPC_REG_TACHO11_OFFSET:
2357 case MLXPLAT_CPLD_LPC_REG_TACHO12_OFFSET:
2358 case MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET:
2359 case MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET:
2360 case MLXPLAT_CPLD_LPC_REG_FAN_CAP2_OFFSET:
2361 case MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET:
2362 case MLXPLAT_CPLD_LPC_REG_TACHO_SPEED_OFFSET:
2363 case MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET:
2364 case MLXPLAT_CPLD_LPC_REG_CONFIG1_OFFSET:
2365 case MLXPLAT_CPLD_LPC_REG_CONFIG2_OFFSET:
2366 case MLXPLAT_CPLD_LPC_REG_UFM_VERSION_OFFSET:
2372 static const struct reg_default mlxplat_mlxcpld_regmap_default[] = {
2373 { MLXPLAT_CPLD_LPC_REG_WP1_OFFSET, 0x00 },
2374 { MLXPLAT_CPLD_LPC_REG_WP2_OFFSET, 0x00 },
2375 { MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, 0x00 },
2376 { MLXPLAT_CPLD_LPC_REG_WD_CLEAR_WP_OFFSET, 0x00 },
2379 static const struct reg_default mlxplat_mlxcpld_regmap_ng[] = {
2380 { MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, 0x00 },
2381 { MLXPLAT_CPLD_LPC_REG_WD_CLEAR_WP_OFFSET, 0x00 },
2384 static const struct reg_default mlxplat_mlxcpld_regmap_comex_default[] = {
2385 { MLXPLAT_CPLD_LPC_REG_AGGRCX_MASK_OFFSET,
2386 MLXPLAT_CPLD_LOW_AGGRCX_MASK },
2387 { MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, 0x00 },
2390 static const struct reg_default mlxplat_mlxcpld_regmap_ng400[] = {
2391 { MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, 0x00 },
2392 { MLXPLAT_CPLD_LPC_REG_WD1_ACT_OFFSET, 0x00 },
2393 { MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET, 0x00 },
2394 { MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET, 0x00 },
2397 struct mlxplat_mlxcpld_regmap_context {
2401 static struct mlxplat_mlxcpld_regmap_context mlxplat_mlxcpld_regmap_ctx;
2404 mlxplat_mlxcpld_reg_read(void *context, unsigned int reg, unsigned int *val)
2406 struct mlxplat_mlxcpld_regmap_context *ctx = context;
2408 *val = ioread8(ctx->base + reg);
2413 mlxplat_mlxcpld_reg_write(void *context, unsigned int reg, unsigned int val)
2415 struct mlxplat_mlxcpld_regmap_context *ctx = context;
2417 iowrite8(val, ctx->base + reg);
2421 static const struct regmap_config mlxplat_mlxcpld_regmap_config = {
2424 .max_register = 255,
2425 .cache_type = REGCACHE_FLAT,
2426 .writeable_reg = mlxplat_mlxcpld_writeable_reg,
2427 .readable_reg = mlxplat_mlxcpld_readable_reg,
2428 .volatile_reg = mlxplat_mlxcpld_volatile_reg,
2429 .reg_defaults = mlxplat_mlxcpld_regmap_default,
2430 .num_reg_defaults = ARRAY_SIZE(mlxplat_mlxcpld_regmap_default),
2431 .reg_read = mlxplat_mlxcpld_reg_read,
2432 .reg_write = mlxplat_mlxcpld_reg_write,
2435 static const struct regmap_config mlxplat_mlxcpld_regmap_config_ng = {
2438 .max_register = 255,
2439 .cache_type = REGCACHE_FLAT,
2440 .writeable_reg = mlxplat_mlxcpld_writeable_reg,
2441 .readable_reg = mlxplat_mlxcpld_readable_reg,
2442 .volatile_reg = mlxplat_mlxcpld_volatile_reg,
2443 .reg_defaults = mlxplat_mlxcpld_regmap_ng,
2444 .num_reg_defaults = ARRAY_SIZE(mlxplat_mlxcpld_regmap_ng),
2445 .reg_read = mlxplat_mlxcpld_reg_read,
2446 .reg_write = mlxplat_mlxcpld_reg_write,
2449 static const struct regmap_config mlxplat_mlxcpld_regmap_config_comex = {
2452 .max_register = 255,
2453 .cache_type = REGCACHE_FLAT,
2454 .writeable_reg = mlxplat_mlxcpld_writeable_reg,
2455 .readable_reg = mlxplat_mlxcpld_readable_reg,
2456 .volatile_reg = mlxplat_mlxcpld_volatile_reg,
2457 .reg_defaults = mlxplat_mlxcpld_regmap_comex_default,
2458 .num_reg_defaults = ARRAY_SIZE(mlxplat_mlxcpld_regmap_comex_default),
2459 .reg_read = mlxplat_mlxcpld_reg_read,
2460 .reg_write = mlxplat_mlxcpld_reg_write,
2463 static const struct regmap_config mlxplat_mlxcpld_regmap_config_ng400 = {
2466 .max_register = 255,
2467 .cache_type = REGCACHE_FLAT,
2468 .writeable_reg = mlxplat_mlxcpld_writeable_reg,
2469 .readable_reg = mlxplat_mlxcpld_readable_reg,
2470 .volatile_reg = mlxplat_mlxcpld_volatile_reg,
2471 .reg_defaults = mlxplat_mlxcpld_regmap_ng400,
2472 .num_reg_defaults = ARRAY_SIZE(mlxplat_mlxcpld_regmap_ng400),
2473 .reg_read = mlxplat_mlxcpld_reg_read,
2474 .reg_write = mlxplat_mlxcpld_reg_write,
2477 static struct resource mlxplat_mlxcpld_resources[] = {
2478 [0] = DEFINE_RES_IRQ_NAMED(17, "mlxreg-hotplug"),
2481 static struct platform_device *mlxplat_dev;
2482 static struct mlxreg_core_hotplug_platform_data *mlxplat_i2c;
2483 static struct mlxreg_core_hotplug_platform_data *mlxplat_hotplug;
2484 static struct mlxreg_core_platform_data *mlxplat_led;
2485 static struct mlxreg_core_platform_data *mlxplat_regs_io;
2486 static struct mlxreg_core_platform_data *mlxplat_fan;
2487 static struct mlxreg_core_platform_data
2488 *mlxplat_wd_data[MLXPLAT_CPLD_WD_MAX_DEVS];
2489 static const struct regmap_config *mlxplat_regmap_config;
2491 static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi)
2495 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM;
2496 mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data);
2497 mlxplat_mux_data = mlxplat_default_mux_data;
2498 for (i = 0; i < mlxplat_mux_num; i++) {
2499 mlxplat_mux_data[i].values = mlxplat_default_channels[i];
2500 mlxplat_mux_data[i].n_values =
2501 ARRAY_SIZE(mlxplat_default_channels[i]);
2503 mlxplat_hotplug = &mlxplat_mlxcpld_default_data;
2504 mlxplat_hotplug->deferred_nr =
2505 mlxplat_default_channels[i - 1][MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
2506 mlxplat_led = &mlxplat_default_led_data;
2507 mlxplat_regs_io = &mlxplat_default_regs_io_data;
2508 mlxplat_wd_data[0] = &mlxplat_mlxcpld_wd_set_type1[0];
2513 static int __init mlxplat_dmi_msn21xx_matched(const struct dmi_system_id *dmi)
2517 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM;
2518 mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data);
2519 mlxplat_mux_data = mlxplat_default_mux_data;
2520 for (i = 0; i < mlxplat_mux_num; i++) {
2521 mlxplat_mux_data[i].values = mlxplat_msn21xx_channels;
2522 mlxplat_mux_data[i].n_values =
2523 ARRAY_SIZE(mlxplat_msn21xx_channels);
2525 mlxplat_hotplug = &mlxplat_mlxcpld_msn21xx_data;
2526 mlxplat_hotplug->deferred_nr =
2527 mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
2528 mlxplat_led = &mlxplat_msn21xx_led_data;
2529 mlxplat_regs_io = &mlxplat_msn21xx_regs_io_data;
2530 mlxplat_wd_data[0] = &mlxplat_mlxcpld_wd_set_type1[0];
2535 static int __init mlxplat_dmi_msn274x_matched(const struct dmi_system_id *dmi)
2539 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM;
2540 mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data);
2541 mlxplat_mux_data = mlxplat_default_mux_data;
2542 for (i = 0; i < mlxplat_mux_num; i++) {
2543 mlxplat_mux_data[i].values = mlxplat_msn21xx_channels;
2544 mlxplat_mux_data[i].n_values =
2545 ARRAY_SIZE(mlxplat_msn21xx_channels);
2547 mlxplat_hotplug = &mlxplat_mlxcpld_msn274x_data;
2548 mlxplat_hotplug->deferred_nr =
2549 mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
2550 mlxplat_led = &mlxplat_default_led_data;
2551 mlxplat_regs_io = &mlxplat_msn21xx_regs_io_data;
2552 mlxplat_wd_data[0] = &mlxplat_mlxcpld_wd_set_type1[0];
2557 static int __init mlxplat_dmi_msn201x_matched(const struct dmi_system_id *dmi)
2561 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM;
2562 mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data);
2563 mlxplat_mux_data = mlxplat_default_mux_data;
2564 for (i = 0; i < mlxplat_mux_num; i++) {
2565 mlxplat_mux_data[i].values = mlxplat_msn21xx_channels;
2566 mlxplat_mux_data[i].n_values =
2567 ARRAY_SIZE(mlxplat_msn21xx_channels);
2569 mlxplat_hotplug = &mlxplat_mlxcpld_msn201x_data;
2570 mlxplat_hotplug->deferred_nr =
2571 mlxplat_default_channels[i - 1][MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
2572 mlxplat_led = &mlxplat_msn21xx_led_data;
2573 mlxplat_regs_io = &mlxplat_msn21xx_regs_io_data;
2574 mlxplat_wd_data[0] = &mlxplat_mlxcpld_wd_set_type1[0];
2579 static int __init mlxplat_dmi_qmb7xx_matched(const struct dmi_system_id *dmi)
2583 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM;
2584 mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data);
2585 mlxplat_mux_data = mlxplat_default_mux_data;
2586 for (i = 0; i < mlxplat_mux_num; i++) {
2587 mlxplat_mux_data[i].values = mlxplat_msn21xx_channels;
2588 mlxplat_mux_data[i].n_values =
2589 ARRAY_SIZE(mlxplat_msn21xx_channels);
2591 mlxplat_hotplug = &mlxplat_mlxcpld_default_ng_data;
2592 mlxplat_hotplug->deferred_nr =
2593 mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
2594 mlxplat_led = &mlxplat_default_ng_led_data;
2595 mlxplat_regs_io = &mlxplat_default_ng_regs_io_data;
2596 mlxplat_fan = &mlxplat_default_fan_data;
2597 for (i = 0; i < ARRAY_SIZE(mlxplat_mlxcpld_wd_set_type2); i++)
2598 mlxplat_wd_data[i] = &mlxplat_mlxcpld_wd_set_type2[i];
2599 mlxplat_i2c = &mlxplat_mlxcpld_i2c_ng_data;
2600 mlxplat_regmap_config = &mlxplat_mlxcpld_regmap_config_ng;
2605 static int __init mlxplat_dmi_comex_matched(const struct dmi_system_id *dmi)
2609 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_EXT_ADAPTER_NUM;
2610 mlxplat_mux_num = ARRAY_SIZE(mlxplat_extended_mux_data);
2611 mlxplat_mux_data = mlxplat_extended_mux_data;
2612 for (i = 0; i < mlxplat_mux_num; i++) {
2613 mlxplat_mux_data[i].values = mlxplat_msn21xx_channels;
2614 mlxplat_mux_data[i].n_values =
2615 ARRAY_SIZE(mlxplat_msn21xx_channels);
2617 mlxplat_hotplug = &mlxplat_mlxcpld_comex_data;
2618 mlxplat_hotplug->deferred_nr = MLXPLAT_CPLD_MAX_PHYS_EXT_ADAPTER_NUM;
2619 mlxplat_led = &mlxplat_comex_100G_led_data;
2620 mlxplat_regs_io = &mlxplat_default_ng_regs_io_data;
2621 mlxplat_fan = &mlxplat_default_fan_data;
2622 for (i = 0; i < ARRAY_SIZE(mlxplat_mlxcpld_wd_set_type2); i++)
2623 mlxplat_wd_data[i] = &mlxplat_mlxcpld_wd_set_type2[i];
2624 mlxplat_regmap_config = &mlxplat_mlxcpld_regmap_config_comex;
2629 static int __init mlxplat_dmi_ng400_matched(const struct dmi_system_id *dmi)
2633 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM;
2634 mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data);
2635 mlxplat_mux_data = mlxplat_default_mux_data;
2636 for (i = 0; i < mlxplat_mux_num; i++) {
2637 mlxplat_mux_data[i].values = mlxplat_msn21xx_channels;
2638 mlxplat_mux_data[i].n_values =
2639 ARRAY_SIZE(mlxplat_msn21xx_channels);
2641 mlxplat_hotplug = &mlxplat_mlxcpld_ext_data;
2642 mlxplat_hotplug->deferred_nr =
2643 mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
2644 mlxplat_led = &mlxplat_default_ng_led_data;
2645 mlxplat_regs_io = &mlxplat_default_ng_regs_io_data;
2646 mlxplat_fan = &mlxplat_default_fan_data;
2647 for (i = 0; i < ARRAY_SIZE(mlxplat_mlxcpld_wd_set_type2); i++)
2648 mlxplat_wd_data[i] = &mlxplat_mlxcpld_wd_set_type2[i];
2649 mlxplat_i2c = &mlxplat_mlxcpld_i2c_ng_data;
2650 mlxplat_regmap_config = &mlxplat_mlxcpld_regmap_config_ng400;
2655 static const struct dmi_system_id mlxplat_dmi_table[] __initconst = {
2657 .callback = mlxplat_dmi_default_matched,
2659 DMI_MATCH(DMI_BOARD_NAME, "VMOD0001"),
2663 .callback = mlxplat_dmi_msn21xx_matched,
2665 DMI_MATCH(DMI_BOARD_NAME, "VMOD0002"),
2669 .callback = mlxplat_dmi_msn274x_matched,
2671 DMI_MATCH(DMI_BOARD_NAME, "VMOD0003"),
2675 .callback = mlxplat_dmi_msn201x_matched,
2677 DMI_MATCH(DMI_BOARD_NAME, "VMOD0004"),
2681 .callback = mlxplat_dmi_qmb7xx_matched,
2683 DMI_MATCH(DMI_BOARD_NAME, "VMOD0005"),
2687 .callback = mlxplat_dmi_qmb7xx_matched,
2689 DMI_MATCH(DMI_BOARD_NAME, "VMOD0007"),
2693 .callback = mlxplat_dmi_comex_matched,
2695 DMI_MATCH(DMI_BOARD_NAME, "VMOD0009"),
2699 .callback = mlxplat_dmi_ng400_matched,
2701 DMI_MATCH(DMI_BOARD_NAME, "VMOD0010"),
2705 .callback = mlxplat_dmi_msn274x_matched,
2707 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"),
2708 DMI_MATCH(DMI_PRODUCT_NAME, "MSN274"),
2712 .callback = mlxplat_dmi_default_matched,
2714 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"),
2715 DMI_MATCH(DMI_PRODUCT_NAME, "MSN24"),
2719 .callback = mlxplat_dmi_default_matched,
2721 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"),
2722 DMI_MATCH(DMI_PRODUCT_NAME, "MSN27"),
2726 .callback = mlxplat_dmi_default_matched,
2728 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"),
2729 DMI_MATCH(DMI_PRODUCT_NAME, "MSB"),
2733 .callback = mlxplat_dmi_default_matched,
2735 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"),
2736 DMI_MATCH(DMI_PRODUCT_NAME, "MSX"),
2740 .callback = mlxplat_dmi_msn21xx_matched,
2742 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"),
2743 DMI_MATCH(DMI_PRODUCT_NAME, "MSN21"),
2747 .callback = mlxplat_dmi_msn201x_matched,
2749 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"),
2750 DMI_MATCH(DMI_PRODUCT_NAME, "MSN201"),
2754 .callback = mlxplat_dmi_qmb7xx_matched,
2756 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"),
2757 DMI_MATCH(DMI_PRODUCT_NAME, "MQM87"),
2761 .callback = mlxplat_dmi_qmb7xx_matched,
2763 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"),
2764 DMI_MATCH(DMI_PRODUCT_NAME, "MSN37"),
2768 .callback = mlxplat_dmi_qmb7xx_matched,
2770 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"),
2771 DMI_MATCH(DMI_PRODUCT_NAME, "MSN34"),
2775 .callback = mlxplat_dmi_qmb7xx_matched,
2777 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"),
2778 DMI_MATCH(DMI_PRODUCT_NAME, "MSN38"),
2784 MODULE_DEVICE_TABLE(dmi, mlxplat_dmi_table);
2786 static int mlxplat_mlxcpld_verify_bus_topology(int *nr)
2788 struct i2c_adapter *search_adap;
2791 /* Scan adapters from expected id to verify it is free. */
2792 *nr = MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR;
2793 for (i = MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR; i <
2794 mlxplat_max_adap_num; i++) {
2795 search_adap = i2c_get_adapter(i);
2797 i2c_put_adapter(search_adap);
2801 /* Return if expected parent adapter is free. */
2802 if (i == MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR)
2807 /* Return with error if free id for adapter is not found. */
2808 if (i == mlxplat_max_adap_num)
2811 /* Shift adapter ids, since expected parent adapter is not free. */
2813 for (i = 0; i < mlxplat_mux_num; i++) {
2814 shift = *nr - mlxplat_mux_data[i].parent;
2815 mlxplat_mux_data[i].parent = *nr;
2816 mlxplat_mux_data[i].base_nr += shift;
2818 mlxplat_hotplug->shift_nr = shift;
2824 static int mlxplat_mlxcpld_check_wd_capability(void *regmap)
2829 rc = regmap_read(regmap, MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET,
2834 if (!(regval & ~MLXPLAT_CPLD_WD_CPBLTY_MASK)) {
2835 for (i = 0; i < ARRAY_SIZE(mlxplat_mlxcpld_wd_set_type3); i++) {
2836 if (mlxplat_wd_data[i])
2837 mlxplat_wd_data[i] =
2838 &mlxplat_mlxcpld_wd_set_type3[i];
2845 static int __init mlxplat_init(void)
2847 struct mlxplat_priv *priv;
2850 if (!dmi_check_system(mlxplat_dmi_table))
2853 mlxplat_dev = platform_device_register_simple(MLX_PLAT_DEVICE_NAME, -1,
2854 mlxplat_lpc_resources,
2855 ARRAY_SIZE(mlxplat_lpc_resources));
2857 if (IS_ERR(mlxplat_dev))
2858 return PTR_ERR(mlxplat_dev);
2860 priv = devm_kzalloc(&mlxplat_dev->dev, sizeof(struct mlxplat_priv),
2866 platform_set_drvdata(mlxplat_dev, priv);
2868 mlxplat_mlxcpld_regmap_ctx.base = devm_ioport_map(&mlxplat_dev->dev,
2869 mlxplat_lpc_resources[1].start, 1);
2870 if (!mlxplat_mlxcpld_regmap_ctx.base) {
2875 if (!mlxplat_regmap_config)
2876 mlxplat_regmap_config = &mlxplat_mlxcpld_regmap_config;
2878 priv->regmap = devm_regmap_init(&mlxplat_dev->dev, NULL,
2879 &mlxplat_mlxcpld_regmap_ctx,
2880 mlxplat_regmap_config);
2881 if (IS_ERR(priv->regmap)) {
2882 err = PTR_ERR(priv->regmap);
2886 err = mlxplat_mlxcpld_verify_bus_topology(&nr);
2890 nr = (nr == mlxplat_max_adap_num) ? -1 : nr;
2892 mlxplat_i2c->regmap = priv->regmap;
2893 priv->pdev_i2c = platform_device_register_resndata(
2894 &mlxplat_dev->dev, "i2c_mlxcpld",
2895 nr, mlxplat_mlxcpld_resources,
2896 ARRAY_SIZE(mlxplat_mlxcpld_resources),
2897 mlxplat_i2c, sizeof(*mlxplat_i2c));
2898 if (IS_ERR(priv->pdev_i2c)) {
2899 err = PTR_ERR(priv->pdev_i2c);
2903 for (i = 0; i < mlxplat_mux_num; i++) {
2904 priv->pdev_mux[i] = platform_device_register_resndata(
2905 &priv->pdev_i2c->dev,
2906 "i2c-mux-reg", i, NULL,
2907 0, &mlxplat_mux_data[i],
2908 sizeof(mlxplat_mux_data[i]));
2909 if (IS_ERR(priv->pdev_mux[i])) {
2910 err = PTR_ERR(priv->pdev_mux[i]);
2911 goto fail_platform_mux_register;
2915 /* Add hotplug driver */
2916 mlxplat_hotplug->regmap = priv->regmap;
2917 priv->pdev_hotplug = platform_device_register_resndata(
2918 &mlxplat_dev->dev, "mlxreg-hotplug",
2919 PLATFORM_DEVID_NONE,
2920 mlxplat_mlxcpld_resources,
2921 ARRAY_SIZE(mlxplat_mlxcpld_resources),
2922 mlxplat_hotplug, sizeof(*mlxplat_hotplug));
2923 if (IS_ERR(priv->pdev_hotplug)) {
2924 err = PTR_ERR(priv->pdev_hotplug);
2925 goto fail_platform_mux_register;
2928 /* Set default registers. */
2929 for (j = 0; j < mlxplat_regmap_config->num_reg_defaults; j++) {
2930 err = regmap_write(priv->regmap,
2931 mlxplat_regmap_config->reg_defaults[j].reg,
2932 mlxplat_regmap_config->reg_defaults[j].def);
2934 goto fail_platform_mux_register;
2937 /* Add LED driver. */
2938 mlxplat_led->regmap = priv->regmap;
2939 priv->pdev_led = platform_device_register_resndata(
2940 &mlxplat_dev->dev, "leds-mlxreg",
2941 PLATFORM_DEVID_NONE, NULL, 0,
2942 mlxplat_led, sizeof(*mlxplat_led));
2943 if (IS_ERR(priv->pdev_led)) {
2944 err = PTR_ERR(priv->pdev_led);
2945 goto fail_platform_hotplug_register;
2948 /* Add registers io access driver. */
2949 if (mlxplat_regs_io) {
2950 mlxplat_regs_io->regmap = priv->regmap;
2951 priv->pdev_io_regs = platform_device_register_resndata(
2952 &mlxplat_dev->dev, "mlxreg-io",
2953 PLATFORM_DEVID_NONE, NULL, 0,
2955 sizeof(*mlxplat_regs_io));
2956 if (IS_ERR(priv->pdev_io_regs)) {
2957 err = PTR_ERR(priv->pdev_io_regs);
2958 goto fail_platform_led_register;
2962 /* Add FAN driver. */
2964 mlxplat_fan->regmap = priv->regmap;
2965 priv->pdev_fan = platform_device_register_resndata(
2966 &mlxplat_dev->dev, "mlxreg-fan",
2967 PLATFORM_DEVID_NONE, NULL, 0,
2969 sizeof(*mlxplat_fan));
2970 if (IS_ERR(priv->pdev_fan)) {
2971 err = PTR_ERR(priv->pdev_fan);
2972 goto fail_platform_io_regs_register;
2976 /* Add WD drivers. */
2977 err = mlxplat_mlxcpld_check_wd_capability(priv->regmap);
2979 goto fail_platform_wd_register;
2980 for (j = 0; j < MLXPLAT_CPLD_WD_MAX_DEVS; j++) {
2981 if (mlxplat_wd_data[j]) {
2982 mlxplat_wd_data[j]->regmap = priv->regmap;
2983 priv->pdev_wd[j] = platform_device_register_resndata(
2984 &mlxplat_dev->dev, "mlx-wdt",
2987 sizeof(*mlxplat_wd_data[j]));
2988 if (IS_ERR(priv->pdev_wd[j])) {
2989 err = PTR_ERR(priv->pdev_wd[j]);
2990 goto fail_platform_wd_register;
2995 /* Sync registers with hardware. */
2996 regcache_mark_dirty(priv->regmap);
2997 err = regcache_sync(priv->regmap);
2999 goto fail_platform_wd_register;
3003 fail_platform_wd_register:
3005 platform_device_unregister(priv->pdev_wd[j]);
3007 platform_device_unregister(priv->pdev_fan);
3008 fail_platform_io_regs_register:
3009 if (mlxplat_regs_io)
3010 platform_device_unregister(priv->pdev_io_regs);
3011 fail_platform_led_register:
3012 platform_device_unregister(priv->pdev_led);
3013 fail_platform_hotplug_register:
3014 platform_device_unregister(priv->pdev_hotplug);
3015 fail_platform_mux_register:
3017 platform_device_unregister(priv->pdev_mux[i]);
3018 platform_device_unregister(priv->pdev_i2c);
3020 platform_device_unregister(mlxplat_dev);
3024 module_init(mlxplat_init);
3026 static void __exit mlxplat_exit(void)
3028 struct mlxplat_priv *priv = platform_get_drvdata(mlxplat_dev);
3031 for (i = MLXPLAT_CPLD_WD_MAX_DEVS - 1; i >= 0 ; i--)
3032 platform_device_unregister(priv->pdev_wd[i]);
3034 platform_device_unregister(priv->pdev_fan);
3035 if (priv->pdev_io_regs)
3036 platform_device_unregister(priv->pdev_io_regs);
3037 platform_device_unregister(priv->pdev_led);
3038 platform_device_unregister(priv->pdev_hotplug);
3040 for (i = mlxplat_mux_num - 1; i >= 0 ; i--)
3041 platform_device_unregister(priv->pdev_mux[i]);
3043 platform_device_unregister(priv->pdev_i2c);
3044 platform_device_unregister(mlxplat_dev);
3046 module_exit(mlxplat_exit);
3048 MODULE_AUTHOR("Vadim Pasternak (vadimp@mellanox.com)");
3049 MODULE_DESCRIPTION("Mellanox platform driver");
3050 MODULE_LICENSE("Dual BSD/GPL");