1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 2 /* 3 * Mellanox platform driver 4 * 5 * Copyright (C) 2016-2018 Mellanox Technologies 6 * Copyright (C) 2016-2018 Vadim Pasternak <vadimp@mellanox.com> 7 */ 8 9 #include <linux/device.h> 10 #include <linux/dmi.h> 11 #include <linux/i2c.h> 12 #include <linux/i2c-mux.h> 13 #include <linux/io.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> 19 20 #define MLX_PLAT_DEVICE_NAME "mlxplat" 21 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 108 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) 119 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) 145 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 151 152 /* Default I2C parent bus number */ 153 #define MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR 1 154 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 158 159 /* Number of channels in group */ 160 #define MLXPLAT_CPLD_GRP_CHNL_NUM 8 161 162 /* Start channel numbers */ 163 #define MLXPLAT_CPLD_CH1 2 164 #define MLXPLAT_CPLD_CH2 10 165 #define MLXPLAT_CPLD_CH3 18 166 167 /* Number of LPC attached MUX platform devices */ 168 #define MLXPLAT_CPLD_LPC_MUX_DEVS 3 169 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_PSU_MSNXXXX_NR2 3 175 #define MLXPLAT_CPLD_FAN1_DEFAULT_NR 11 176 #define MLXPLAT_CPLD_FAN2_DEFAULT_NR 12 177 #define MLXPLAT_CPLD_FAN3_DEFAULT_NR 13 178 #define MLXPLAT_CPLD_FAN4_DEFAULT_NR 14 179 180 /* Masks and default values for watchdogs */ 181 #define MLXPLAT_CPLD_WD1_CLEAR_MASK GENMASK(7, 1) 182 #define MLXPLAT_CPLD_WD2_CLEAR_MASK (GENMASK(7, 0) & ~BIT(1)) 183 184 #define MLXPLAT_CPLD_WD_TYPE1_TO_MASK GENMASK(7, 4) 185 #define MLXPLAT_CPLD_WD_TYPE2_TO_MASK 0 186 #define MLXPLAT_CPLD_WD_RESET_ACT_MASK GENMASK(7, 1) 187 #define MLXPLAT_CPLD_WD_FAN_ACT_MASK (GENMASK(7, 0) & ~BIT(4)) 188 #define MLXPLAT_CPLD_WD_COUNT_ACT_MASK (GENMASK(7, 0) & ~BIT(7)) 189 #define MLXPLAT_CPLD_WD_CPBLTY_MASK (GENMASK(7, 0) & ~BIT(6)) 190 #define MLXPLAT_CPLD_WD_DFLT_TIMEOUT 30 191 #define MLXPLAT_CPLD_WD3_DFLT_TIMEOUT 600 192 #define MLXPLAT_CPLD_WD_MAX_DEVS 2 193 194 /* mlxplat_priv - platform private data 195 * @pdev_i2c - i2c controller platform device 196 * @pdev_mux - array of mux platform devices 197 * @pdev_hotplug - hotplug platform devices 198 * @pdev_led - led platform devices 199 * @pdev_io_regs - register access platform devices 200 * @pdev_fan - FAN platform devices 201 * @pdev_wd - array of watchdog platform devices 202 * @regmap: device register map 203 */ 204 struct mlxplat_priv { 205 struct platform_device *pdev_i2c; 206 struct platform_device *pdev_mux[MLXPLAT_CPLD_LPC_MUX_DEVS]; 207 struct platform_device *pdev_hotplug; 208 struct platform_device *pdev_led; 209 struct platform_device *pdev_io_regs; 210 struct platform_device *pdev_fan; 211 struct platform_device *pdev_wd[MLXPLAT_CPLD_WD_MAX_DEVS]; 212 void *regmap; 213 }; 214 215 /* Regions for LPC I2C controller and LPC base register space */ 216 static const struct resource mlxplat_lpc_resources[] = { 217 [0] = DEFINE_RES_NAMED(MLXPLAT_CPLD_LPC_I2C_BASE_ADRR, 218 MLXPLAT_CPLD_LPC_IO_RANGE, 219 "mlxplat_cpld_lpc_i2c_ctrl", IORESOURCE_IO), 220 [1] = DEFINE_RES_NAMED(MLXPLAT_CPLD_LPC_REG_BASE_ADRR, 221 MLXPLAT_CPLD_LPC_IO_RANGE, 222 "mlxplat_cpld_lpc_regs", 223 IORESOURCE_IO), 224 }; 225 226 /* Platform i2c next generation systems data */ 227 static struct mlxreg_core_data mlxplat_mlxcpld_i2c_ng_items_data[] = { 228 { 229 .reg = MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET, 230 .mask = MLXPLAT_CPLD_I2C_CAP_MASK, 231 .bit = MLXPLAT_CPLD_I2C_CAP_BIT, 232 }, 233 }; 234 235 static struct mlxreg_core_item mlxplat_mlxcpld_i2c_ng_items[] = { 236 { 237 .data = mlxplat_mlxcpld_i2c_ng_items_data, 238 }, 239 }; 240 241 /* Platform next generation systems i2c data */ 242 static struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_i2c_ng_data = { 243 .items = mlxplat_mlxcpld_i2c_ng_items, 244 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, 245 .mask = MLXPLAT_CPLD_AGGR_MASK_COMEX, 246 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRCO_OFFSET, 247 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_I2C, 248 }; 249 250 /* Platform default channels */ 251 static const int mlxplat_default_channels[][MLXPLAT_CPLD_GRP_CHNL_NUM] = { 252 { 253 MLXPLAT_CPLD_CH1, MLXPLAT_CPLD_CH1 + 1, MLXPLAT_CPLD_CH1 + 2, 254 MLXPLAT_CPLD_CH1 + 3, MLXPLAT_CPLD_CH1 + 4, MLXPLAT_CPLD_CH1 + 255 5, MLXPLAT_CPLD_CH1 + 6, MLXPLAT_CPLD_CH1 + 7 256 }, 257 { 258 MLXPLAT_CPLD_CH2, MLXPLAT_CPLD_CH2 + 1, MLXPLAT_CPLD_CH2 + 2, 259 MLXPLAT_CPLD_CH2 + 3, MLXPLAT_CPLD_CH2 + 4, MLXPLAT_CPLD_CH2 + 260 5, MLXPLAT_CPLD_CH2 + 6, MLXPLAT_CPLD_CH2 + 7 261 }, 262 }; 263 264 /* Platform channels for MSN21xx system family */ 265 static const int mlxplat_msn21xx_channels[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; 266 267 /* Platform mux data */ 268 static struct i2c_mux_reg_platform_data mlxplat_default_mux_data[] = { 269 { 270 .parent = 1, 271 .base_nr = MLXPLAT_CPLD_CH1, 272 .write_only = 1, 273 .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG1, 274 .reg_size = 1, 275 .idle_in_use = 1, 276 }, 277 { 278 .parent = 1, 279 .base_nr = MLXPLAT_CPLD_CH2, 280 .write_only = 1, 281 .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG2, 282 .reg_size = 1, 283 .idle_in_use = 1, 284 }, 285 286 }; 287 288 /* Platform mux configuration variables */ 289 static int mlxplat_max_adap_num; 290 static int mlxplat_mux_num; 291 static struct i2c_mux_reg_platform_data *mlxplat_mux_data; 292 293 /* Platform extended mux data */ 294 static struct i2c_mux_reg_platform_data mlxplat_extended_mux_data[] = { 295 { 296 .parent = 1, 297 .base_nr = MLXPLAT_CPLD_CH1, 298 .write_only = 1, 299 .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG1, 300 .reg_size = 1, 301 .idle_in_use = 1, 302 }, 303 { 304 .parent = 1, 305 .base_nr = MLXPLAT_CPLD_CH2, 306 .write_only = 1, 307 .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG3, 308 .reg_size = 1, 309 .idle_in_use = 1, 310 }, 311 { 312 .parent = 1, 313 .base_nr = MLXPLAT_CPLD_CH3, 314 .write_only = 1, 315 .reg = (void __iomem *)MLXPLAT_CPLD_LPC_REG2, 316 .reg_size = 1, 317 .idle_in_use = 1, 318 }, 319 320 }; 321 322 /* Platform hotplug devices */ 323 static struct i2c_board_info mlxplat_mlxcpld_psu[] = { 324 { 325 I2C_BOARD_INFO("24c02", 0x51), 326 }, 327 { 328 I2C_BOARD_INFO("24c02", 0x50), 329 }, 330 }; 331 332 static struct i2c_board_info mlxplat_mlxcpld_ng_psu[] = { 333 { 334 I2C_BOARD_INFO("24c32", 0x51), 335 }, 336 { 337 I2C_BOARD_INFO("24c32", 0x50), 338 }, 339 }; 340 341 static struct i2c_board_info mlxplat_mlxcpld_pwr[] = { 342 { 343 I2C_BOARD_INFO("dps460", 0x59), 344 }, 345 { 346 I2C_BOARD_INFO("dps460", 0x58), 347 }, 348 }; 349 350 static struct i2c_board_info mlxplat_mlxcpld_fan[] = { 351 { 352 I2C_BOARD_INFO("24c32", 0x50), 353 }, 354 { 355 I2C_BOARD_INFO("24c32", 0x50), 356 }, 357 { 358 I2C_BOARD_INFO("24c32", 0x50), 359 }, 360 { 361 I2C_BOARD_INFO("24c32", 0x50), 362 }, 363 }; 364 365 /* Platform hotplug comex carrier system family data */ 366 static struct mlxreg_core_data mlxplat_mlxcpld_comex_psu_items_data[] = { 367 { 368 .label = "psu1", 369 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 370 .mask = BIT(0), 371 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 372 }, 373 { 374 .label = "psu2", 375 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 376 .mask = BIT(1), 377 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 378 }, 379 }; 380 381 /* Platform hotplug default data */ 382 static struct mlxreg_core_data mlxplat_mlxcpld_default_psu_items_data[] = { 383 { 384 .label = "psu1", 385 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 386 .mask = BIT(0), 387 .hpdev.brdinfo = &mlxplat_mlxcpld_psu[0], 388 .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, 389 }, 390 { 391 .label = "psu2", 392 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 393 .mask = BIT(1), 394 .hpdev.brdinfo = &mlxplat_mlxcpld_psu[1], 395 .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, 396 }, 397 }; 398 399 static struct mlxreg_core_data mlxplat_mlxcpld_default_pwr_items_data[] = { 400 { 401 .label = "pwr1", 402 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 403 .mask = BIT(0), 404 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[0], 405 .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, 406 }, 407 { 408 .label = "pwr2", 409 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 410 .mask = BIT(1), 411 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[1], 412 .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, 413 }, 414 }; 415 416 static struct mlxreg_core_data mlxplat_mlxcpld_default_fan_items_data[] = { 417 { 418 .label = "fan1", 419 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 420 .mask = BIT(0), 421 .hpdev.brdinfo = &mlxplat_mlxcpld_fan[0], 422 .hpdev.nr = MLXPLAT_CPLD_FAN1_DEFAULT_NR, 423 }, 424 { 425 .label = "fan2", 426 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 427 .mask = BIT(1), 428 .hpdev.brdinfo = &mlxplat_mlxcpld_fan[1], 429 .hpdev.nr = MLXPLAT_CPLD_FAN2_DEFAULT_NR, 430 }, 431 { 432 .label = "fan3", 433 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 434 .mask = BIT(2), 435 .hpdev.brdinfo = &mlxplat_mlxcpld_fan[2], 436 .hpdev.nr = MLXPLAT_CPLD_FAN3_DEFAULT_NR, 437 }, 438 { 439 .label = "fan4", 440 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 441 .mask = BIT(3), 442 .hpdev.brdinfo = &mlxplat_mlxcpld_fan[3], 443 .hpdev.nr = MLXPLAT_CPLD_FAN4_DEFAULT_NR, 444 }, 445 }; 446 447 static struct mlxreg_core_data mlxplat_mlxcpld_default_asic_items_data[] = { 448 { 449 .label = "asic1", 450 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, 451 .mask = MLXPLAT_CPLD_ASIC_MASK, 452 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 453 }, 454 }; 455 456 static struct mlxreg_core_item mlxplat_mlxcpld_default_items[] = { 457 { 458 .data = mlxplat_mlxcpld_default_psu_items_data, 459 .aggr_mask = MLXPLAT_CPLD_AGGR_PSU_MASK_DEF, 460 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 461 .mask = MLXPLAT_CPLD_PSU_MASK, 462 .count = ARRAY_SIZE(mlxplat_mlxcpld_psu), 463 .inversed = 1, 464 .health = false, 465 }, 466 { 467 .data = mlxplat_mlxcpld_default_pwr_items_data, 468 .aggr_mask = MLXPLAT_CPLD_AGGR_PWR_MASK_DEF, 469 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 470 .mask = MLXPLAT_CPLD_PWR_MASK, 471 .count = ARRAY_SIZE(mlxplat_mlxcpld_pwr), 472 .inversed = 0, 473 .health = false, 474 }, 475 { 476 .data = mlxplat_mlxcpld_default_fan_items_data, 477 .aggr_mask = MLXPLAT_CPLD_AGGR_FAN_MASK_DEF, 478 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 479 .mask = MLXPLAT_CPLD_FAN_MASK, 480 .count = ARRAY_SIZE(mlxplat_mlxcpld_fan), 481 .inversed = 1, 482 .health = false, 483 }, 484 { 485 .data = mlxplat_mlxcpld_default_asic_items_data, 486 .aggr_mask = MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF, 487 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, 488 .mask = MLXPLAT_CPLD_ASIC_MASK, 489 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data), 490 .inversed = 0, 491 .health = true, 492 }, 493 }; 494 495 static struct mlxreg_core_item mlxplat_mlxcpld_comex_items[] = { 496 { 497 .data = mlxplat_mlxcpld_comex_psu_items_data, 498 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_CARRIER, 499 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 500 .mask = MLXPLAT_CPLD_PSU_MASK, 501 .count = ARRAY_SIZE(mlxplat_mlxcpld_psu), 502 .inversed = 1, 503 .health = false, 504 }, 505 { 506 .data = mlxplat_mlxcpld_default_pwr_items_data, 507 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_CARRIER, 508 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 509 .mask = MLXPLAT_CPLD_PWR_MASK, 510 .count = ARRAY_SIZE(mlxplat_mlxcpld_pwr), 511 .inversed = 0, 512 .health = false, 513 }, 514 { 515 .data = mlxplat_mlxcpld_default_fan_items_data, 516 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_CARRIER, 517 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 518 .mask = MLXPLAT_CPLD_FAN_MASK, 519 .count = ARRAY_SIZE(mlxplat_mlxcpld_fan), 520 .inversed = 1, 521 .health = false, 522 }, 523 { 524 .data = mlxplat_mlxcpld_default_asic_items_data, 525 .aggr_mask = MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF, 526 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, 527 .mask = MLXPLAT_CPLD_ASIC_MASK, 528 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data), 529 .inversed = 0, 530 .health = true, 531 }, 532 }; 533 534 static 535 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_default_data = { 536 .items = mlxplat_mlxcpld_default_items, 537 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_items), 538 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, 539 .mask = MLXPLAT_CPLD_AGGR_MASK_DEF, 540 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET, 541 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, 542 }; 543 544 static 545 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_comex_data = { 546 .items = mlxplat_mlxcpld_comex_items, 547 .counter = ARRAY_SIZE(mlxplat_mlxcpld_comex_items), 548 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, 549 .mask = MLXPLAT_CPLD_AGGR_MASK_CARR_DEF, 550 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRCX_OFFSET, 551 .mask_low = MLXPLAT_CPLD_LOW_AGGRCX_MASK, 552 }; 553 554 static struct mlxreg_core_data mlxplat_mlxcpld_msn21xx_pwr_items_data[] = { 555 { 556 .label = "pwr1", 557 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 558 .mask = BIT(0), 559 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 560 }, 561 { 562 .label = "pwr2", 563 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 564 .mask = BIT(1), 565 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 566 }, 567 }; 568 569 /* Platform hotplug MSN21xx system family data */ 570 static struct mlxreg_core_item mlxplat_mlxcpld_msn21xx_items[] = { 571 { 572 .data = mlxplat_mlxcpld_msn21xx_pwr_items_data, 573 .aggr_mask = MLXPLAT_CPLD_AGGR_PWR_MASK_DEF, 574 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 575 .mask = MLXPLAT_CPLD_PWR_MASK, 576 .count = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_pwr_items_data), 577 .inversed = 0, 578 .health = false, 579 }, 580 { 581 .data = mlxplat_mlxcpld_default_asic_items_data, 582 .aggr_mask = MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF, 583 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, 584 .mask = MLXPLAT_CPLD_ASIC_MASK, 585 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data), 586 .inversed = 0, 587 .health = true, 588 }, 589 }; 590 591 static 592 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn21xx_data = { 593 .items = mlxplat_mlxcpld_msn21xx_items, 594 .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_items), 595 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, 596 .mask = MLXPLAT_CPLD_AGGR_MASK_DEF, 597 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET, 598 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, 599 }; 600 601 /* Platform hotplug msn274x system family data */ 602 static struct mlxreg_core_data mlxplat_mlxcpld_msn274x_psu_items_data[] = { 603 { 604 .label = "psu1", 605 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 606 .mask = BIT(0), 607 .hpdev.brdinfo = &mlxplat_mlxcpld_psu[0], 608 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, 609 }, 610 { 611 .label = "psu2", 612 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 613 .mask = BIT(1), 614 .hpdev.brdinfo = &mlxplat_mlxcpld_psu[1], 615 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, 616 }, 617 }; 618 619 static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_pwr_items_data[] = { 620 { 621 .label = "pwr1", 622 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 623 .mask = BIT(0), 624 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[0], 625 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, 626 }, 627 { 628 .label = "pwr2", 629 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 630 .mask = BIT(1), 631 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[1], 632 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, 633 }, 634 }; 635 636 static struct mlxreg_core_data mlxplat_mlxcpld_msn274x_fan_items_data[] = { 637 { 638 .label = "fan1", 639 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 640 .mask = BIT(0), 641 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 642 }, 643 { 644 .label = "fan2", 645 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 646 .mask = BIT(1), 647 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 648 }, 649 { 650 .label = "fan3", 651 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 652 .mask = BIT(2), 653 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 654 }, 655 { 656 .label = "fan4", 657 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 658 .mask = BIT(3), 659 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 660 }, 661 }; 662 663 static struct mlxreg_core_item mlxplat_mlxcpld_msn274x_items[] = { 664 { 665 .data = mlxplat_mlxcpld_msn274x_psu_items_data, 666 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, 667 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 668 .mask = MLXPLAT_CPLD_PSU_MASK, 669 .count = ARRAY_SIZE(mlxplat_mlxcpld_msn274x_psu_items_data), 670 .inversed = 1, 671 .health = false, 672 }, 673 { 674 .data = mlxplat_mlxcpld_default_ng_pwr_items_data, 675 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, 676 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 677 .mask = MLXPLAT_CPLD_PWR_MASK, 678 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_pwr_items_data), 679 .inversed = 0, 680 .health = false, 681 }, 682 { 683 .data = mlxplat_mlxcpld_msn274x_fan_items_data, 684 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, 685 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 686 .mask = MLXPLAT_CPLD_FAN_MASK, 687 .count = ARRAY_SIZE(mlxplat_mlxcpld_msn274x_fan_items_data), 688 .inversed = 1, 689 .health = false, 690 }, 691 { 692 .data = mlxplat_mlxcpld_default_asic_items_data, 693 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, 694 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, 695 .mask = MLXPLAT_CPLD_ASIC_MASK, 696 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data), 697 .inversed = 0, 698 .health = true, 699 }, 700 }; 701 702 static 703 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn274x_data = { 704 .items = mlxplat_mlxcpld_msn274x_items, 705 .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn274x_items), 706 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, 707 .mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, 708 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET, 709 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, 710 }; 711 712 /* Platform hotplug MSN201x system family data */ 713 static struct mlxreg_core_data mlxplat_mlxcpld_msn201x_pwr_items_data[] = { 714 { 715 .label = "pwr1", 716 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 717 .mask = BIT(0), 718 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 719 }, 720 { 721 .label = "pwr2", 722 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 723 .mask = BIT(1), 724 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 725 }, 726 }; 727 728 static struct mlxreg_core_item mlxplat_mlxcpld_msn201x_items[] = { 729 { 730 .data = mlxplat_mlxcpld_msn201x_pwr_items_data, 731 .aggr_mask = MLXPLAT_CPLD_AGGR_PWR_MASK_DEF, 732 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 733 .mask = MLXPLAT_CPLD_PWR_MASK, 734 .count = ARRAY_SIZE(mlxplat_mlxcpld_msn201x_pwr_items_data), 735 .inversed = 0, 736 .health = false, 737 }, 738 { 739 .data = mlxplat_mlxcpld_default_asic_items_data, 740 .aggr_mask = MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF, 741 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, 742 .mask = MLXPLAT_CPLD_ASIC_MASK, 743 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data), 744 .inversed = 0, 745 .health = true, 746 }, 747 }; 748 749 static 750 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn201x_data = { 751 .items = mlxplat_mlxcpld_msn201x_items, 752 .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn201x_items), 753 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, 754 .mask = MLXPLAT_CPLD_AGGR_MASK_DEF, 755 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET, 756 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, 757 }; 758 759 /* Platform hotplug next generation system family data */ 760 static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_psu_items_data[] = { 761 { 762 .label = "psu1", 763 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 764 .mask = BIT(0), 765 .hpdev.brdinfo = &mlxplat_mlxcpld_ng_psu[0], 766 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, 767 }, 768 { 769 .label = "psu2", 770 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 771 .mask = BIT(1), 772 .hpdev.brdinfo = &mlxplat_mlxcpld_ng_psu[1], 773 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, 774 }, 775 }; 776 777 static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_fan_items_data[] = { 778 { 779 .label = "fan1", 780 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 781 .mask = BIT(0), 782 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 783 .bit = BIT(0), 784 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 785 }, 786 { 787 .label = "fan2", 788 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 789 .mask = BIT(1), 790 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 791 .bit = BIT(1), 792 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 793 }, 794 { 795 .label = "fan3", 796 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 797 .mask = BIT(2), 798 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 799 .bit = BIT(2), 800 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 801 }, 802 { 803 .label = "fan4", 804 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 805 .mask = BIT(3), 806 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 807 .bit = BIT(3), 808 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 809 }, 810 { 811 .label = "fan5", 812 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 813 .mask = BIT(4), 814 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 815 .bit = BIT(4), 816 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 817 }, 818 { 819 .label = "fan6", 820 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 821 .mask = BIT(5), 822 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 823 .bit = BIT(5), 824 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 825 }, 826 }; 827 828 static struct mlxreg_core_item mlxplat_mlxcpld_default_ng_items[] = { 829 { 830 .data = mlxplat_mlxcpld_default_ng_psu_items_data, 831 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, 832 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 833 .mask = MLXPLAT_CPLD_PSU_MASK, 834 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_psu_items_data), 835 .inversed = 1, 836 .health = false, 837 }, 838 { 839 .data = mlxplat_mlxcpld_default_ng_pwr_items_data, 840 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, 841 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 842 .mask = MLXPLAT_CPLD_PWR_MASK, 843 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_pwr_items_data), 844 .inversed = 0, 845 .health = false, 846 }, 847 { 848 .data = mlxplat_mlxcpld_default_ng_fan_items_data, 849 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, 850 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 851 .mask = MLXPLAT_CPLD_FAN_NG_MASK, 852 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_fan_items_data), 853 .inversed = 1, 854 .health = false, 855 }, 856 { 857 .data = mlxplat_mlxcpld_default_asic_items_data, 858 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, 859 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, 860 .mask = MLXPLAT_CPLD_ASIC_MASK, 861 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data), 862 .inversed = 0, 863 .health = true, 864 }, 865 }; 866 867 static 868 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_default_ng_data = { 869 .items = mlxplat_mlxcpld_default_ng_items, 870 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_items), 871 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, 872 .mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF | MLXPLAT_CPLD_AGGR_MASK_COMEX, 873 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET, 874 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, 875 }; 876 877 /* Platform hotplug extended system family data */ 878 static struct mlxreg_core_data mlxplat_mlxcpld_ext_psu_items_data[] = { 879 { 880 .label = "psu1", 881 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 882 .mask = BIT(0), 883 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 884 }, 885 { 886 .label = "psu2", 887 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 888 .mask = BIT(1), 889 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 890 }, 891 { 892 .label = "psu3", 893 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 894 .mask = BIT(2), 895 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 896 }, 897 { 898 .label = "psu4", 899 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 900 .mask = BIT(3), 901 .hpdev.nr = MLXPLAT_CPLD_NR_NONE, 902 }, 903 }; 904 905 static struct mlxreg_core_data mlxplat_mlxcpld_ext_pwr_items_data[] = { 906 { 907 .label = "pwr1", 908 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 909 .mask = BIT(0), 910 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[0], 911 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, 912 }, 913 { 914 .label = "pwr2", 915 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 916 .mask = BIT(1), 917 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[1], 918 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, 919 }, 920 { 921 .label = "pwr3", 922 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 923 .mask = BIT(2), 924 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[0], 925 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR2, 926 }, 927 { 928 .label = "pwr4", 929 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 930 .mask = BIT(3), 931 .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[1], 932 .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR2, 933 }, 934 }; 935 936 static struct mlxreg_core_item mlxplat_mlxcpld_ext_items[] = { 937 { 938 .data = mlxplat_mlxcpld_ext_psu_items_data, 939 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, 940 .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, 941 .mask = MLXPLAT_CPLD_PSU_EXT_MASK, 942 .capability = MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET, 943 .count = ARRAY_SIZE(mlxplat_mlxcpld_ext_psu_items_data), 944 .inversed = 1, 945 .health = false, 946 }, 947 { 948 .data = mlxplat_mlxcpld_ext_pwr_items_data, 949 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, 950 .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, 951 .mask = MLXPLAT_CPLD_PWR_EXT_MASK, 952 .capability = MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET, 953 .count = ARRAY_SIZE(mlxplat_mlxcpld_ext_pwr_items_data), 954 .inversed = 0, 955 .health = false, 956 }, 957 { 958 .data = mlxplat_mlxcpld_default_ng_fan_items_data, 959 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, 960 .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 961 .mask = MLXPLAT_CPLD_FAN_NG_MASK, 962 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_fan_items_data), 963 .inversed = 1, 964 .health = false, 965 }, 966 { 967 .data = mlxplat_mlxcpld_default_asic_items_data, 968 .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, 969 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, 970 .mask = MLXPLAT_CPLD_ASIC_MASK, 971 .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data), 972 .inversed = 0, 973 .health = true, 974 }, 975 }; 976 977 static 978 struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_ext_data = { 979 .items = mlxplat_mlxcpld_ext_items, 980 .counter = ARRAY_SIZE(mlxplat_mlxcpld_ext_items), 981 .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, 982 .mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF | MLXPLAT_CPLD_AGGR_MASK_COMEX, 983 .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET, 984 .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, 985 }; 986 987 /* Platform led default data */ 988 static struct mlxreg_core_data mlxplat_mlxcpld_default_led_data[] = { 989 { 990 .label = "status:green", 991 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 992 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 993 }, 994 { 995 .label = "status:red", 996 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 997 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK 998 }, 999 { 1000 .label = "psu:green", 1001 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 1002 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1003 }, 1004 { 1005 .label = "psu:red", 1006 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 1007 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1008 }, 1009 { 1010 .label = "fan1:green", 1011 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1012 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1013 }, 1014 { 1015 .label = "fan1:red", 1016 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1017 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1018 }, 1019 { 1020 .label = "fan2:green", 1021 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1022 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1023 }, 1024 { 1025 .label = "fan2:red", 1026 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1027 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1028 }, 1029 { 1030 .label = "fan3:green", 1031 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, 1032 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1033 }, 1034 { 1035 .label = "fan3:red", 1036 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, 1037 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1038 }, 1039 { 1040 .label = "fan4:green", 1041 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, 1042 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1043 }, 1044 { 1045 .label = "fan4:red", 1046 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, 1047 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1048 }, 1049 }; 1050 1051 static struct mlxreg_core_platform_data mlxplat_default_led_data = { 1052 .data = mlxplat_mlxcpld_default_led_data, 1053 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_led_data), 1054 }; 1055 1056 /* Platform led MSN21xx system family data */ 1057 static struct mlxreg_core_data mlxplat_mlxcpld_msn21xx_led_data[] = { 1058 { 1059 .label = "status:green", 1060 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 1061 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1062 }, 1063 { 1064 .label = "status:red", 1065 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 1066 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK 1067 }, 1068 { 1069 .label = "fan:green", 1070 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1071 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1072 }, 1073 { 1074 .label = "fan:red", 1075 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1076 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1077 }, 1078 { 1079 .label = "psu1:green", 1080 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, 1081 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1082 }, 1083 { 1084 .label = "psu1:red", 1085 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, 1086 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1087 }, 1088 { 1089 .label = "psu2:green", 1090 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, 1091 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1092 }, 1093 { 1094 .label = "psu2:red", 1095 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, 1096 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1097 }, 1098 { 1099 .label = "uid:blue", 1100 .reg = MLXPLAT_CPLD_LPC_REG_LED5_OFFSET, 1101 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1102 }, 1103 }; 1104 1105 static struct mlxreg_core_platform_data mlxplat_msn21xx_led_data = { 1106 .data = mlxplat_mlxcpld_msn21xx_led_data, 1107 .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_led_data), 1108 }; 1109 1110 /* Platform led for default data for 200GbE systems */ 1111 static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_led_data[] = { 1112 { 1113 .label = "status:green", 1114 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 1115 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1116 }, 1117 { 1118 .label = "status:orange", 1119 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 1120 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK 1121 }, 1122 { 1123 .label = "psu:green", 1124 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 1125 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1126 }, 1127 { 1128 .label = "psu:orange", 1129 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 1130 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1131 }, 1132 { 1133 .label = "fan1:green", 1134 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1135 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1136 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 1137 .bit = BIT(0), 1138 }, 1139 { 1140 .label = "fan1:orange", 1141 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1142 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1143 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 1144 .bit = BIT(0), 1145 }, 1146 { 1147 .label = "fan2:green", 1148 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1149 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1150 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 1151 .bit = BIT(1), 1152 }, 1153 { 1154 .label = "fan2:orange", 1155 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1156 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1157 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 1158 .bit = BIT(1), 1159 }, 1160 { 1161 .label = "fan3:green", 1162 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, 1163 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1164 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 1165 .bit = BIT(2), 1166 }, 1167 { 1168 .label = "fan3:orange", 1169 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, 1170 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1171 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 1172 .bit = BIT(2), 1173 }, 1174 { 1175 .label = "fan4:green", 1176 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, 1177 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1178 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 1179 .bit = BIT(3), 1180 }, 1181 { 1182 .label = "fan4:orange", 1183 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, 1184 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1185 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 1186 .bit = BIT(3), 1187 }, 1188 { 1189 .label = "fan5:green", 1190 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, 1191 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1192 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 1193 .bit = BIT(4), 1194 }, 1195 { 1196 .label = "fan5:orange", 1197 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, 1198 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1199 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 1200 .bit = BIT(4), 1201 }, 1202 { 1203 .label = "fan6:green", 1204 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, 1205 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1206 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 1207 .bit = BIT(5), 1208 }, 1209 { 1210 .label = "fan6:orange", 1211 .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, 1212 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1213 .capability = MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET, 1214 .bit = BIT(5), 1215 }, 1216 { 1217 .label = "uid:blue", 1218 .reg = MLXPLAT_CPLD_LPC_REG_LED5_OFFSET, 1219 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1220 }, 1221 }; 1222 1223 static struct mlxreg_core_platform_data mlxplat_default_ng_led_data = { 1224 .data = mlxplat_mlxcpld_default_ng_led_data, 1225 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_led_data), 1226 }; 1227 1228 /* Platform led for Comex based 100GbE systems */ 1229 static struct mlxreg_core_data mlxplat_mlxcpld_comex_100G_led_data[] = { 1230 { 1231 .label = "status:green", 1232 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 1233 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1234 }, 1235 { 1236 .label = "status:red", 1237 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 1238 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK 1239 }, 1240 { 1241 .label = "psu:green", 1242 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 1243 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1244 }, 1245 { 1246 .label = "psu:red", 1247 .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, 1248 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1249 }, 1250 { 1251 .label = "fan1:green", 1252 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1253 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1254 }, 1255 { 1256 .label = "fan1:red", 1257 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1258 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1259 }, 1260 { 1261 .label = "fan2:green", 1262 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1263 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1264 }, 1265 { 1266 .label = "fan2:red", 1267 .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, 1268 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1269 }, 1270 { 1271 .label = "fan3:green", 1272 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, 1273 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1274 }, 1275 { 1276 .label = "fan3:red", 1277 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, 1278 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1279 }, 1280 { 1281 .label = "fan4:green", 1282 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, 1283 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1284 }, 1285 { 1286 .label = "fan4:red", 1287 .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, 1288 .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, 1289 }, 1290 { 1291 .label = "uid:blue", 1292 .reg = MLXPLAT_CPLD_LPC_REG_LED5_OFFSET, 1293 .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, 1294 }, 1295 }; 1296 1297 static struct mlxreg_core_platform_data mlxplat_comex_100G_led_data = { 1298 .data = mlxplat_mlxcpld_comex_100G_led_data, 1299 .counter = ARRAY_SIZE(mlxplat_mlxcpld_comex_100G_led_data), 1300 }; 1301 1302 /* Platform register access default */ 1303 static struct mlxreg_core_data mlxplat_mlxcpld_default_regs_io_data[] = { 1304 { 1305 .label = "cpld1_version", 1306 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET, 1307 .bit = GENMASK(7, 0), 1308 .mode = 0444, 1309 }, 1310 { 1311 .label = "cpld2_version", 1312 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET, 1313 .bit = GENMASK(7, 0), 1314 .mode = 0444, 1315 }, 1316 { 1317 .label = "cpld1_pn", 1318 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_PN_OFFSET, 1319 .bit = GENMASK(15, 0), 1320 .mode = 0444, 1321 .regnum = 2, 1322 }, 1323 { 1324 .label = "cpld2_pn", 1325 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_PN_OFFSET, 1326 .bit = GENMASK(15, 0), 1327 .mode = 0444, 1328 .regnum = 2, 1329 }, 1330 { 1331 .label = "cpld1_version_min", 1332 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_MVER_OFFSET, 1333 .bit = GENMASK(7, 0), 1334 .mode = 0444, 1335 }, 1336 { 1337 .label = "cpld2_version_min", 1338 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_MVER_OFFSET, 1339 .bit = GENMASK(7, 0), 1340 .mode = 0444, 1341 }, 1342 { 1343 .label = "reset_long_pb", 1344 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1345 .mask = GENMASK(7, 0) & ~BIT(0), 1346 .mode = 0444, 1347 }, 1348 { 1349 .label = "reset_short_pb", 1350 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1351 .mask = GENMASK(7, 0) & ~BIT(1), 1352 .mode = 0444, 1353 }, 1354 { 1355 .label = "reset_aux_pwr_or_ref", 1356 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1357 .mask = GENMASK(7, 0) & ~BIT(2), 1358 .mode = 0444, 1359 }, 1360 { 1361 .label = "reset_main_pwr_fail", 1362 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1363 .mask = GENMASK(7, 0) & ~BIT(3), 1364 .mode = 0444, 1365 }, 1366 { 1367 .label = "reset_sw_reset", 1368 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1369 .mask = GENMASK(7, 0) & ~BIT(4), 1370 .mode = 0444, 1371 }, 1372 { 1373 .label = "reset_fw_reset", 1374 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1375 .mask = GENMASK(7, 0) & ~BIT(5), 1376 .mode = 0444, 1377 }, 1378 { 1379 .label = "reset_hotswap_or_wd", 1380 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1381 .mask = GENMASK(7, 0) & ~BIT(6), 1382 .mode = 0444, 1383 }, 1384 { 1385 .label = "reset_asic_thermal", 1386 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1387 .mask = GENMASK(7, 0) & ~BIT(7), 1388 .mode = 0444, 1389 }, 1390 { 1391 .label = "psu1_on", 1392 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, 1393 .mask = GENMASK(7, 0) & ~BIT(0), 1394 .mode = 0200, 1395 }, 1396 { 1397 .label = "psu2_on", 1398 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, 1399 .mask = GENMASK(7, 0) & ~BIT(1), 1400 .mode = 0200, 1401 }, 1402 { 1403 .label = "pwr_cycle", 1404 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, 1405 .mask = GENMASK(7, 0) & ~BIT(2), 1406 .mode = 0200, 1407 }, 1408 { 1409 .label = "pwr_down", 1410 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, 1411 .mask = GENMASK(7, 0) & ~BIT(3), 1412 .mode = 0200, 1413 }, 1414 { 1415 .label = "select_iio", 1416 .reg = MLXPLAT_CPLD_LPC_REG_GP2_OFFSET, 1417 .mask = GENMASK(7, 0) & ~BIT(6), 1418 .mode = 0644, 1419 }, 1420 { 1421 .label = "asic_health", 1422 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, 1423 .mask = MLXPLAT_CPLD_ASIC_MASK, 1424 .bit = 1, 1425 .mode = 0444, 1426 }, 1427 }; 1428 1429 static struct mlxreg_core_platform_data mlxplat_default_regs_io_data = { 1430 .data = mlxplat_mlxcpld_default_regs_io_data, 1431 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_regs_io_data), 1432 }; 1433 1434 /* Platform register access MSN21xx, MSN201x, MSN274x systems families data */ 1435 static struct mlxreg_core_data mlxplat_mlxcpld_msn21xx_regs_io_data[] = { 1436 { 1437 .label = "cpld1_version", 1438 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET, 1439 .bit = GENMASK(7, 0), 1440 .mode = 0444, 1441 }, 1442 { 1443 .label = "cpld2_version", 1444 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET, 1445 .bit = GENMASK(7, 0), 1446 .mode = 0444, 1447 }, 1448 { 1449 .label = "cpld1_pn", 1450 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_PN_OFFSET, 1451 .bit = GENMASK(15, 0), 1452 .mode = 0444, 1453 .regnum = 2, 1454 }, 1455 { 1456 .label = "cpld2_pn", 1457 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_PN_OFFSET, 1458 .bit = GENMASK(15, 0), 1459 .mode = 0444, 1460 .regnum = 2, 1461 }, 1462 { 1463 .label = "cpld1_version_min", 1464 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_MVER_OFFSET, 1465 .bit = GENMASK(7, 0), 1466 .mode = 0444, 1467 }, 1468 { 1469 .label = "cpld2_version_min", 1470 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_MVER_OFFSET, 1471 .bit = GENMASK(7, 0), 1472 .mode = 0444, 1473 }, 1474 { 1475 .label = "reset_long_pb", 1476 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1477 .mask = GENMASK(7, 0) & ~BIT(0), 1478 .mode = 0444, 1479 }, 1480 { 1481 .label = "reset_short_pb", 1482 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1483 .mask = GENMASK(7, 0) & ~BIT(1), 1484 .mode = 0444, 1485 }, 1486 { 1487 .label = "reset_aux_pwr_or_ref", 1488 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1489 .mask = GENMASK(7, 0) & ~BIT(2), 1490 .mode = 0444, 1491 }, 1492 { 1493 .label = "reset_sw_reset", 1494 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1495 .mask = GENMASK(7, 0) & ~BIT(3), 1496 .mode = 0444, 1497 }, 1498 { 1499 .label = "reset_main_pwr_fail", 1500 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1501 .mask = GENMASK(7, 0) & ~BIT(4), 1502 .mode = 0444, 1503 }, 1504 { 1505 .label = "reset_asic_thermal", 1506 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1507 .mask = GENMASK(7, 0) & ~BIT(5), 1508 .mode = 0444, 1509 }, 1510 { 1511 .label = "reset_hotswap_or_halt", 1512 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1513 .mask = GENMASK(7, 0) & ~BIT(6), 1514 .mode = 0444, 1515 }, 1516 { 1517 .label = "reset_sff_wd", 1518 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET, 1519 .mask = GENMASK(7, 0) & ~BIT(6), 1520 .mode = 0444, 1521 }, 1522 { 1523 .label = "psu1_on", 1524 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, 1525 .mask = GENMASK(7, 0) & ~BIT(0), 1526 .mode = 0200, 1527 }, 1528 { 1529 .label = "psu2_on", 1530 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, 1531 .mask = GENMASK(7, 0) & ~BIT(1), 1532 .mode = 0200, 1533 }, 1534 { 1535 .label = "pwr_cycle", 1536 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, 1537 .mask = GENMASK(7, 0) & ~BIT(2), 1538 .mode = 0200, 1539 }, 1540 { 1541 .label = "pwr_down", 1542 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, 1543 .mask = GENMASK(7, 0) & ~BIT(3), 1544 .mode = 0200, 1545 }, 1546 { 1547 .label = "select_iio", 1548 .reg = MLXPLAT_CPLD_LPC_REG_GP2_OFFSET, 1549 .mask = GENMASK(7, 0) & ~BIT(6), 1550 .mode = 0644, 1551 }, 1552 { 1553 .label = "asic_health", 1554 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, 1555 .mask = MLXPLAT_CPLD_ASIC_MASK, 1556 .bit = 1, 1557 .mode = 0444, 1558 }, 1559 }; 1560 1561 static struct mlxreg_core_platform_data mlxplat_msn21xx_regs_io_data = { 1562 .data = mlxplat_mlxcpld_msn21xx_regs_io_data, 1563 .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_regs_io_data), 1564 }; 1565 1566 /* Platform register access for next generation systems families data */ 1567 static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_regs_io_data[] = { 1568 { 1569 .label = "cpld1_version", 1570 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET, 1571 .bit = GENMASK(7, 0), 1572 .mode = 0444, 1573 }, 1574 { 1575 .label = "cpld2_version", 1576 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET, 1577 .bit = GENMASK(7, 0), 1578 .mode = 0444, 1579 }, 1580 { 1581 .label = "cpld3_version", 1582 .reg = MLXPLAT_CPLD_LPC_REG_CPLD3_VER_OFFSET, 1583 .bit = GENMASK(7, 0), 1584 .mode = 0444, 1585 }, 1586 { 1587 .label = "cpld4_version", 1588 .reg = MLXPLAT_CPLD_LPC_REG_CPLD4_VER_OFFSET, 1589 .bit = GENMASK(7, 0), 1590 .mode = 0444, 1591 }, 1592 { 1593 .label = "cpld1_pn", 1594 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_PN_OFFSET, 1595 .bit = GENMASK(15, 0), 1596 .mode = 0444, 1597 .regnum = 2, 1598 }, 1599 { 1600 .label = "cpld2_pn", 1601 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_PN_OFFSET, 1602 .bit = GENMASK(15, 0), 1603 .mode = 0444, 1604 .regnum = 2, 1605 }, 1606 { 1607 .label = "cpld3_pn", 1608 .reg = MLXPLAT_CPLD_LPC_REG_CPLD3_PN_OFFSET, 1609 .bit = GENMASK(15, 0), 1610 .mode = 0444, 1611 .regnum = 2, 1612 }, 1613 { 1614 .label = "cpld4_pn", 1615 .reg = MLXPLAT_CPLD_LPC_REG_CPLD4_PN_OFFSET, 1616 .bit = GENMASK(15, 0), 1617 .mode = 0444, 1618 .regnum = 2, 1619 }, 1620 { 1621 .label = "cpld1_version_min", 1622 .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_MVER_OFFSET, 1623 .bit = GENMASK(7, 0), 1624 .mode = 0444, 1625 }, 1626 { 1627 .label = "cpld2_version_min", 1628 .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_MVER_OFFSET, 1629 .bit = GENMASK(7, 0), 1630 .mode = 0444, 1631 }, 1632 { 1633 .label = "cpld3_version_min", 1634 .reg = MLXPLAT_CPLD_LPC_REG_CPLD3_MVER_OFFSET, 1635 .bit = GENMASK(7, 0), 1636 .mode = 0444, 1637 }, 1638 { 1639 .label = "cpld4_version_min", 1640 .reg = MLXPLAT_CPLD_LPC_REG_CPLD4_MVER_OFFSET, 1641 .bit = GENMASK(7, 0), 1642 .mode = 0444, 1643 }, 1644 { 1645 .label = "reset_long_pb", 1646 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1647 .mask = GENMASK(7, 0) & ~BIT(0), 1648 .mode = 0444, 1649 }, 1650 { 1651 .label = "reset_short_pb", 1652 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1653 .mask = GENMASK(7, 0) & ~BIT(1), 1654 .mode = 0444, 1655 }, 1656 { 1657 .label = "reset_aux_pwr_or_ref", 1658 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1659 .mask = GENMASK(7, 0) & ~BIT(2), 1660 .mode = 0444, 1661 }, 1662 { 1663 .label = "reset_from_comex", 1664 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1665 .mask = GENMASK(7, 0) & ~BIT(4), 1666 .mode = 0444, 1667 }, 1668 { 1669 .label = "reset_from_asic", 1670 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1671 .mask = GENMASK(7, 0) & ~BIT(5), 1672 .mode = 0444, 1673 }, 1674 { 1675 .label = "reset_swb_wd", 1676 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1677 .mask = GENMASK(7, 0) & ~BIT(6), 1678 .mode = 0444, 1679 }, 1680 { 1681 .label = "reset_asic_thermal", 1682 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1683 .mask = GENMASK(7, 0) & ~BIT(7), 1684 .mode = 0444, 1685 }, 1686 { 1687 .label = "reset_comex_pwr_fail", 1688 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET, 1689 .mask = GENMASK(7, 0) & ~BIT(3), 1690 .mode = 0444, 1691 }, 1692 { 1693 .label = "reset_platform", 1694 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET, 1695 .mask = GENMASK(7, 0) & ~BIT(4), 1696 .mode = 0444, 1697 }, 1698 { 1699 .label = "reset_soc", 1700 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET, 1701 .mask = GENMASK(7, 0) & ~BIT(5), 1702 .mode = 0444, 1703 }, 1704 { 1705 .label = "reset_comex_wd", 1706 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET, 1707 .mask = GENMASK(7, 0) & ~BIT(6), 1708 .mode = 0444, 1709 }, 1710 { 1711 .label = "reset_voltmon_upgrade_fail", 1712 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET, 1713 .mask = GENMASK(7, 0) & ~BIT(0), 1714 .mode = 0444, 1715 }, 1716 { 1717 .label = "reset_system", 1718 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET, 1719 .mask = GENMASK(7, 0) & ~BIT(1), 1720 .mode = 0444, 1721 }, 1722 { 1723 .label = "reset_sw_pwr_off", 1724 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET, 1725 .mask = GENMASK(7, 0) & ~BIT(2), 1726 .mode = 0444, 1727 }, 1728 { 1729 .label = "reset_comex_thermal", 1730 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET, 1731 .mask = GENMASK(7, 0) & ~BIT(3), 1732 .mode = 0444, 1733 }, 1734 { 1735 .label = "reset_reload_bios", 1736 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET, 1737 .mask = GENMASK(7, 0) & ~BIT(5), 1738 .mode = 0444, 1739 }, 1740 { 1741 .label = "reset_ac_pwr_fail", 1742 .reg = MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET, 1743 .mask = GENMASK(7, 0) & ~BIT(6), 1744 .mode = 0444, 1745 }, 1746 { 1747 .label = "psu1_on", 1748 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, 1749 .mask = GENMASK(7, 0) & ~BIT(0), 1750 .mode = 0200, 1751 }, 1752 { 1753 .label = "psu2_on", 1754 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, 1755 .mask = GENMASK(7, 0) & ~BIT(1), 1756 .mode = 0200, 1757 }, 1758 { 1759 .label = "pwr_cycle", 1760 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, 1761 .mask = GENMASK(7, 0) & ~BIT(2), 1762 .mode = 0200, 1763 }, 1764 { 1765 .label = "pwr_down", 1766 .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, 1767 .mask = GENMASK(7, 0) & ~BIT(3), 1768 .mode = 0200, 1769 }, 1770 { 1771 .label = "jtag_enable", 1772 .reg = MLXPLAT_CPLD_LPC_REG_GP2_OFFSET, 1773 .mask = GENMASK(7, 0) & ~BIT(4), 1774 .mode = 0644, 1775 }, 1776 { 1777 .label = "asic_health", 1778 .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, 1779 .mask = MLXPLAT_CPLD_ASIC_MASK, 1780 .bit = 1, 1781 .mode = 0444, 1782 }, 1783 { 1784 .label = "fan_dir", 1785 .reg = MLXPLAT_CPLD_LPC_REG_FAN_DIRECTION, 1786 .bit = GENMASK(7, 0), 1787 .mode = 0444, 1788 }, 1789 { 1790 .label = "voltreg_update_status", 1791 .reg = MLXPLAT_CPLD_LPC_REG_GP0_RO_OFFSET, 1792 .mask = MLXPLAT_CPLD_VOLTREG_UPD_MASK, 1793 .bit = 5, 1794 .mode = 0444, 1795 }, 1796 { 1797 .label = "vpd_wp", 1798 .reg = MLXPLAT_CPLD_LPC_REG_GP0_OFFSET, 1799 .mask = GENMASK(7, 0) & ~BIT(3), 1800 .mode = 0644, 1801 }, 1802 { 1803 .label = "pcie_asic_reset_dis", 1804 .reg = MLXPLAT_CPLD_LPC_REG_GP0_OFFSET, 1805 .mask = GENMASK(7, 0) & ~BIT(4), 1806 .mode = 0644, 1807 }, 1808 { 1809 .label = "config1", 1810 .reg = MLXPLAT_CPLD_LPC_REG_CONFIG1_OFFSET, 1811 .bit = GENMASK(7, 0), 1812 .mode = 0444, 1813 }, 1814 { 1815 .label = "config2", 1816 .reg = MLXPLAT_CPLD_LPC_REG_CONFIG2_OFFSET, 1817 .bit = GENMASK(7, 0), 1818 .mode = 0444, 1819 }, 1820 { 1821 .label = "ufm_version", 1822 .reg = MLXPLAT_CPLD_LPC_REG_UFM_VERSION_OFFSET, 1823 .bit = GENMASK(7, 0), 1824 .mode = 0444, 1825 }, 1826 }; 1827 1828 static struct mlxreg_core_platform_data mlxplat_default_ng_regs_io_data = { 1829 .data = mlxplat_mlxcpld_default_ng_regs_io_data, 1830 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_regs_io_data), 1831 }; 1832 1833 /* Platform FAN default */ 1834 static struct mlxreg_core_data mlxplat_mlxcpld_default_fan_data[] = { 1835 { 1836 .label = "pwm1", 1837 .reg = MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET, 1838 }, 1839 { 1840 .label = "tacho1", 1841 .reg = MLXPLAT_CPLD_LPC_REG_TACHO1_OFFSET, 1842 .mask = GENMASK(7, 0), 1843 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET, 1844 .bit = BIT(0), 1845 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 1846 1847 }, 1848 { 1849 .label = "tacho2", 1850 .reg = MLXPLAT_CPLD_LPC_REG_TACHO2_OFFSET, 1851 .mask = GENMASK(7, 0), 1852 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET, 1853 .bit = BIT(1), 1854 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 1855 }, 1856 { 1857 .label = "tacho3", 1858 .reg = MLXPLAT_CPLD_LPC_REG_TACHO3_OFFSET, 1859 .mask = GENMASK(7, 0), 1860 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET, 1861 .bit = BIT(2), 1862 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 1863 }, 1864 { 1865 .label = "tacho4", 1866 .reg = MLXPLAT_CPLD_LPC_REG_TACHO4_OFFSET, 1867 .mask = GENMASK(7, 0), 1868 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET, 1869 .bit = BIT(3), 1870 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 1871 }, 1872 { 1873 .label = "tacho5", 1874 .reg = MLXPLAT_CPLD_LPC_REG_TACHO5_OFFSET, 1875 .mask = GENMASK(7, 0), 1876 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET, 1877 .bit = BIT(4), 1878 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 1879 }, 1880 { 1881 .label = "tacho6", 1882 .reg = MLXPLAT_CPLD_LPC_REG_TACHO6_OFFSET, 1883 .mask = GENMASK(7, 0), 1884 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET, 1885 .bit = BIT(5), 1886 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 1887 }, 1888 { 1889 .label = "tacho7", 1890 .reg = MLXPLAT_CPLD_LPC_REG_TACHO7_OFFSET, 1891 .mask = GENMASK(7, 0), 1892 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET, 1893 .bit = BIT(6), 1894 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 1895 }, 1896 { 1897 .label = "tacho8", 1898 .reg = MLXPLAT_CPLD_LPC_REG_TACHO8_OFFSET, 1899 .mask = GENMASK(7, 0), 1900 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET, 1901 .bit = BIT(7), 1902 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 1903 }, 1904 { 1905 .label = "tacho9", 1906 .reg = MLXPLAT_CPLD_LPC_REG_TACHO9_OFFSET, 1907 .mask = GENMASK(7, 0), 1908 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP2_OFFSET, 1909 .bit = BIT(0), 1910 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 1911 }, 1912 { 1913 .label = "tacho10", 1914 .reg = MLXPLAT_CPLD_LPC_REG_TACHO10_OFFSET, 1915 .mask = GENMASK(7, 0), 1916 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP2_OFFSET, 1917 .bit = BIT(1), 1918 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 1919 }, 1920 { 1921 .label = "tacho11", 1922 .reg = MLXPLAT_CPLD_LPC_REG_TACHO11_OFFSET, 1923 .mask = GENMASK(7, 0), 1924 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP2_OFFSET, 1925 .bit = BIT(2), 1926 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 1927 }, 1928 { 1929 .label = "tacho12", 1930 .reg = MLXPLAT_CPLD_LPC_REG_TACHO12_OFFSET, 1931 .mask = GENMASK(7, 0), 1932 .capability = MLXPLAT_CPLD_LPC_REG_FAN_CAP2_OFFSET, 1933 .bit = BIT(3), 1934 .reg_prsnt = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, 1935 }, 1936 { 1937 .label = "conf", 1938 .capability = MLXPLAT_CPLD_LPC_REG_TACHO_SPEED_OFFSET, 1939 }, 1940 }; 1941 1942 static struct mlxreg_core_platform_data mlxplat_default_fan_data = { 1943 .data = mlxplat_mlxcpld_default_fan_data, 1944 .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_fan_data), 1945 }; 1946 1947 /* Watchdog type1: hardware implementation version1 1948 * (MSN2700, MSN2410, MSN2740, MSN2100 and MSN2140 systems). 1949 */ 1950 static struct mlxreg_core_data mlxplat_mlxcpld_wd_main_regs_type1[] = { 1951 { 1952 .label = "action", 1953 .reg = MLXPLAT_CPLD_LPC_REG_WD1_ACT_OFFSET, 1954 .mask = MLXPLAT_CPLD_WD_RESET_ACT_MASK, 1955 .bit = 0, 1956 }, 1957 { 1958 .label = "timeout", 1959 .reg = MLXPLAT_CPLD_LPC_REG_WD1_TMR_OFFSET, 1960 .mask = MLXPLAT_CPLD_WD_TYPE1_TO_MASK, 1961 .health_cntr = MLXPLAT_CPLD_WD_DFLT_TIMEOUT, 1962 }, 1963 { 1964 .label = "ping", 1965 .reg = MLXPLAT_CPLD_LPC_REG_WD_CLEAR_OFFSET, 1966 .mask = MLXPLAT_CPLD_WD1_CLEAR_MASK, 1967 .bit = 0, 1968 }, 1969 { 1970 .label = "reset", 1971 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 1972 .mask = GENMASK(7, 0) & ~BIT(6), 1973 .bit = 6, 1974 }, 1975 }; 1976 1977 static struct mlxreg_core_data mlxplat_mlxcpld_wd_aux_regs_type1[] = { 1978 { 1979 .label = "action", 1980 .reg = MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET, 1981 .mask = MLXPLAT_CPLD_WD_FAN_ACT_MASK, 1982 .bit = 4, 1983 }, 1984 { 1985 .label = "timeout", 1986 .reg = MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET, 1987 .mask = MLXPLAT_CPLD_WD_TYPE1_TO_MASK, 1988 .health_cntr = MLXPLAT_CPLD_WD_DFLT_TIMEOUT, 1989 }, 1990 { 1991 .label = "ping", 1992 .reg = MLXPLAT_CPLD_LPC_REG_WD_CLEAR_OFFSET, 1993 .mask = MLXPLAT_CPLD_WD1_CLEAR_MASK, 1994 .bit = 1, 1995 }, 1996 }; 1997 1998 static struct mlxreg_core_platform_data mlxplat_mlxcpld_wd_set_type1[] = { 1999 { 2000 .data = mlxplat_mlxcpld_wd_main_regs_type1, 2001 .counter = ARRAY_SIZE(mlxplat_mlxcpld_wd_main_regs_type1), 2002 .version = MLX_WDT_TYPE1, 2003 .identity = "mlx-wdt-main", 2004 }, 2005 { 2006 .data = mlxplat_mlxcpld_wd_aux_regs_type1, 2007 .counter = ARRAY_SIZE(mlxplat_mlxcpld_wd_aux_regs_type1), 2008 .version = MLX_WDT_TYPE1, 2009 .identity = "mlx-wdt-aux", 2010 }, 2011 }; 2012 2013 /* Watchdog type2: hardware implementation version 2 2014 * (all systems except (MSN2700, MSN2410, MSN2740, MSN2100 and MSN2140). 2015 */ 2016 static struct mlxreg_core_data mlxplat_mlxcpld_wd_main_regs_type2[] = { 2017 { 2018 .label = "action", 2019 .reg = MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET, 2020 .mask = MLXPLAT_CPLD_WD_RESET_ACT_MASK, 2021 .bit = 0, 2022 }, 2023 { 2024 .label = "timeout", 2025 .reg = MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET, 2026 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK, 2027 .health_cntr = MLXPLAT_CPLD_WD_DFLT_TIMEOUT, 2028 }, 2029 { 2030 .label = "timeleft", 2031 .reg = MLXPLAT_CPLD_LPC_REG_WD2_TLEFT_OFFSET, 2032 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK, 2033 }, 2034 { 2035 .label = "ping", 2036 .reg = MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET, 2037 .mask = MLXPLAT_CPLD_WD_RESET_ACT_MASK, 2038 .bit = 0, 2039 }, 2040 { 2041 .label = "reset", 2042 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 2043 .mask = GENMASK(7, 0) & ~BIT(6), 2044 .bit = 6, 2045 }, 2046 }; 2047 2048 static struct mlxreg_core_data mlxplat_mlxcpld_wd_aux_regs_type2[] = { 2049 { 2050 .label = "action", 2051 .reg = MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET, 2052 .mask = MLXPLAT_CPLD_WD_FAN_ACT_MASK, 2053 .bit = 4, 2054 }, 2055 { 2056 .label = "timeout", 2057 .reg = MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET, 2058 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK, 2059 .health_cntr = MLXPLAT_CPLD_WD_DFLT_TIMEOUT, 2060 }, 2061 { 2062 .label = "timeleft", 2063 .reg = MLXPLAT_CPLD_LPC_REG_WD3_TLEFT_OFFSET, 2064 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK, 2065 }, 2066 { 2067 .label = "ping", 2068 .reg = MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET, 2069 .mask = MLXPLAT_CPLD_WD_FAN_ACT_MASK, 2070 .bit = 4, 2071 }, 2072 }; 2073 2074 static struct mlxreg_core_platform_data mlxplat_mlxcpld_wd_set_type2[] = { 2075 { 2076 .data = mlxplat_mlxcpld_wd_main_regs_type2, 2077 .counter = ARRAY_SIZE(mlxplat_mlxcpld_wd_main_regs_type2), 2078 .version = MLX_WDT_TYPE2, 2079 .identity = "mlx-wdt-main", 2080 }, 2081 { 2082 .data = mlxplat_mlxcpld_wd_aux_regs_type2, 2083 .counter = ARRAY_SIZE(mlxplat_mlxcpld_wd_aux_regs_type2), 2084 .version = MLX_WDT_TYPE2, 2085 .identity = "mlx-wdt-aux", 2086 }, 2087 }; 2088 2089 /* Watchdog type3: hardware implementation version 3 2090 * Can be on all systems. It's differentiated by WD capability bit. 2091 * Old systems (MSN2700, MSN2410, MSN2740, MSN2100 and MSN2140) 2092 * still have only one main watchdog. 2093 */ 2094 static struct mlxreg_core_data mlxplat_mlxcpld_wd_main_regs_type3[] = { 2095 { 2096 .label = "action", 2097 .reg = MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET, 2098 .mask = MLXPLAT_CPLD_WD_RESET_ACT_MASK, 2099 .bit = 0, 2100 }, 2101 { 2102 .label = "timeout", 2103 .reg = MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET, 2104 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK, 2105 .health_cntr = MLXPLAT_CPLD_WD3_DFLT_TIMEOUT, 2106 }, 2107 { 2108 .label = "timeleft", 2109 .reg = MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET, 2110 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK, 2111 }, 2112 { 2113 .label = "ping", 2114 .reg = MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET, 2115 .mask = MLXPLAT_CPLD_WD_RESET_ACT_MASK, 2116 .bit = 0, 2117 }, 2118 { 2119 .label = "reset", 2120 .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, 2121 .mask = GENMASK(7, 0) & ~BIT(6), 2122 .bit = 6, 2123 }, 2124 }; 2125 2126 static struct mlxreg_core_data mlxplat_mlxcpld_wd_aux_regs_type3[] = { 2127 { 2128 .label = "action", 2129 .reg = MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET, 2130 .mask = MLXPLAT_CPLD_WD_FAN_ACT_MASK, 2131 .bit = 4, 2132 }, 2133 { 2134 .label = "timeout", 2135 .reg = MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET, 2136 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK, 2137 .health_cntr = MLXPLAT_CPLD_WD3_DFLT_TIMEOUT, 2138 }, 2139 { 2140 .label = "timeleft", 2141 .reg = MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET, 2142 .mask = MLXPLAT_CPLD_WD_TYPE2_TO_MASK, 2143 }, 2144 { 2145 .label = "ping", 2146 .reg = MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET, 2147 .mask = MLXPLAT_CPLD_WD_FAN_ACT_MASK, 2148 .bit = 4, 2149 }, 2150 }; 2151 2152 static struct mlxreg_core_platform_data mlxplat_mlxcpld_wd_set_type3[] = { 2153 { 2154 .data = mlxplat_mlxcpld_wd_main_regs_type3, 2155 .counter = ARRAY_SIZE(mlxplat_mlxcpld_wd_main_regs_type3), 2156 .version = MLX_WDT_TYPE3, 2157 .identity = "mlx-wdt-main", 2158 }, 2159 { 2160 .data = mlxplat_mlxcpld_wd_aux_regs_type3, 2161 .counter = ARRAY_SIZE(mlxplat_mlxcpld_wd_aux_regs_type3), 2162 .version = MLX_WDT_TYPE3, 2163 .identity = "mlx-wdt-aux", 2164 }, 2165 }; 2166 2167 static bool mlxplat_mlxcpld_writeable_reg(struct device *dev, unsigned int reg) 2168 { 2169 switch (reg) { 2170 case MLXPLAT_CPLD_LPC_REG_LED1_OFFSET: 2171 case MLXPLAT_CPLD_LPC_REG_LED2_OFFSET: 2172 case MLXPLAT_CPLD_LPC_REG_LED3_OFFSET: 2173 case MLXPLAT_CPLD_LPC_REG_LED4_OFFSET: 2174 case MLXPLAT_CPLD_LPC_REG_LED5_OFFSET: 2175 case MLXPLAT_CPLD_LPC_REG_GP0_OFFSET: 2176 case MLXPLAT_CPLD_LPC_REG_GP1_OFFSET: 2177 case MLXPLAT_CPLD_LPC_REG_WP1_OFFSET: 2178 case MLXPLAT_CPLD_LPC_REG_GP2_OFFSET: 2179 case MLXPLAT_CPLD_LPC_REG_WP2_OFFSET: 2180 case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET: 2181 case MLXPLAT_CPLD_LPC_REG_AGGRLO_MASK_OFFSET: 2182 case MLXPLAT_CPLD_LPC_REG_AGGRCO_MASK_OFFSET: 2183 case MLXPLAT_CPLD_LPC_REG_AGGRCX_MASK_OFFSET: 2184 case MLXPLAT_CPLD_LPC_REG_ASIC_EVENT_OFFSET: 2185 case MLXPLAT_CPLD_LPC_REG_ASIC_MASK_OFFSET: 2186 case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFFSET: 2187 case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFFSET: 2188 case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFFSET: 2189 case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFFSET: 2190 case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET: 2191 case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET: 2192 case MLXPLAT_CPLD_LPC_REG_WD_CLEAR_OFFSET: 2193 case MLXPLAT_CPLD_LPC_REG_WD_CLEAR_WP_OFFSET: 2194 case MLXPLAT_CPLD_LPC_REG_WD1_TMR_OFFSET: 2195 case MLXPLAT_CPLD_LPC_REG_WD1_ACT_OFFSET: 2196 case MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET: 2197 case MLXPLAT_CPLD_LPC_REG_WD2_TLEFT_OFFSET: 2198 case MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET: 2199 case MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET: 2200 case MLXPLAT_CPLD_LPC_REG_WD3_TLEFT_OFFSET: 2201 case MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET: 2202 case MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET: 2203 case MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET: 2204 return true; 2205 } 2206 return false; 2207 } 2208 2209 static bool mlxplat_mlxcpld_readable_reg(struct device *dev, unsigned int reg) 2210 { 2211 switch (reg) { 2212 case MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET: 2213 case MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET: 2214 case MLXPLAT_CPLD_LPC_REG_CPLD3_VER_OFFSET: 2215 case MLXPLAT_CPLD_LPC_REG_CPLD4_VER_OFFSET: 2216 case MLXPLAT_CPLD_LPC_REG_CPLD1_PN_OFFSET: 2217 case MLXPLAT_CPLD_LPC_REG_CPLD2_PN_OFFSET: 2218 case MLXPLAT_CPLD_LPC_REG_CPLD3_PN_OFFSET: 2219 case MLXPLAT_CPLD_LPC_REG_CPLD4_PN_OFFSET: 2220 case MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET: 2221 case MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET: 2222 case MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET: 2223 case MLXPLAT_CPLD_LPC_REG_LED1_OFFSET: 2224 case MLXPLAT_CPLD_LPC_REG_LED2_OFFSET: 2225 case MLXPLAT_CPLD_LPC_REG_LED3_OFFSET: 2226 case MLXPLAT_CPLD_LPC_REG_LED4_OFFSET: 2227 case MLXPLAT_CPLD_LPC_REG_LED5_OFFSET: 2228 case MLXPLAT_CPLD_LPC_REG_FAN_DIRECTION: 2229 case MLXPLAT_CPLD_LPC_REG_GP0_RO_OFFSET: 2230 case MLXPLAT_CPLD_LPC_REG_GP0_OFFSET: 2231 case MLXPLAT_CPLD_LPC_REG_GP1_OFFSET: 2232 case MLXPLAT_CPLD_LPC_REG_WP1_OFFSET: 2233 case MLXPLAT_CPLD_LPC_REG_GP2_OFFSET: 2234 case MLXPLAT_CPLD_LPC_REG_WP2_OFFSET: 2235 case MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET: 2236 case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET: 2237 case MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET: 2238 case MLXPLAT_CPLD_LPC_REG_AGGRLO_MASK_OFFSET: 2239 case MLXPLAT_CPLD_LPC_REG_AGGRCO_OFFSET: 2240 case MLXPLAT_CPLD_LPC_REG_AGGRCO_MASK_OFFSET: 2241 case MLXPLAT_CPLD_LPC_REG_AGGRCX_OFFSET: 2242 case MLXPLAT_CPLD_LPC_REG_AGGRCX_MASK_OFFSET: 2243 case MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET: 2244 case MLXPLAT_CPLD_LPC_REG_ASIC_EVENT_OFFSET: 2245 case MLXPLAT_CPLD_LPC_REG_ASIC_MASK_OFFSET: 2246 case MLXPLAT_CPLD_LPC_REG_PSU_OFFSET: 2247 case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFFSET: 2248 case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFFSET: 2249 case MLXPLAT_CPLD_LPC_REG_PWR_OFFSET: 2250 case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFFSET: 2251 case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFFSET: 2252 case MLXPLAT_CPLD_LPC_REG_FAN_OFFSET: 2253 case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET: 2254 case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET: 2255 case MLXPLAT_CPLD_LPC_REG_WD_CLEAR_OFFSET: 2256 case MLXPLAT_CPLD_LPC_REG_WD_CLEAR_WP_OFFSET: 2257 case MLXPLAT_CPLD_LPC_REG_WD1_TMR_OFFSET: 2258 case MLXPLAT_CPLD_LPC_REG_WD1_ACT_OFFSET: 2259 case MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET: 2260 case MLXPLAT_CPLD_LPC_REG_WD2_TLEFT_OFFSET: 2261 case MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET: 2262 case MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET: 2263 case MLXPLAT_CPLD_LPC_REG_WD3_TLEFT_OFFSET: 2264 case MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET: 2265 case MLXPLAT_CPLD_LPC_REG_CPLD1_MVER_OFFSET: 2266 case MLXPLAT_CPLD_LPC_REG_CPLD2_MVER_OFFSET: 2267 case MLXPLAT_CPLD_LPC_REG_CPLD3_MVER_OFFSET: 2268 case MLXPLAT_CPLD_LPC_REG_CPLD4_MVER_OFFSET: 2269 case MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET: 2270 case MLXPLAT_CPLD_LPC_REG_TACHO1_OFFSET: 2271 case MLXPLAT_CPLD_LPC_REG_TACHO2_OFFSET: 2272 case MLXPLAT_CPLD_LPC_REG_TACHO3_OFFSET: 2273 case MLXPLAT_CPLD_LPC_REG_TACHO4_OFFSET: 2274 case MLXPLAT_CPLD_LPC_REG_TACHO5_OFFSET: 2275 case MLXPLAT_CPLD_LPC_REG_TACHO6_OFFSET: 2276 case MLXPLAT_CPLD_LPC_REG_TACHO7_OFFSET: 2277 case MLXPLAT_CPLD_LPC_REG_TACHO8_OFFSET: 2278 case MLXPLAT_CPLD_LPC_REG_TACHO9_OFFSET: 2279 case MLXPLAT_CPLD_LPC_REG_TACHO10_OFFSET: 2280 case MLXPLAT_CPLD_LPC_REG_TACHO11_OFFSET: 2281 case MLXPLAT_CPLD_LPC_REG_TACHO12_OFFSET: 2282 case MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET: 2283 case MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET: 2284 case MLXPLAT_CPLD_LPC_REG_FAN_CAP2_OFFSET: 2285 case MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET: 2286 case MLXPLAT_CPLD_LPC_REG_TACHO_SPEED_OFFSET: 2287 case MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET: 2288 case MLXPLAT_CPLD_LPC_REG_CONFIG1_OFFSET: 2289 case MLXPLAT_CPLD_LPC_REG_CONFIG2_OFFSET: 2290 case MLXPLAT_CPLD_LPC_REG_UFM_VERSION_OFFSET: 2291 return true; 2292 } 2293 return false; 2294 } 2295 2296 static bool mlxplat_mlxcpld_volatile_reg(struct device *dev, unsigned int reg) 2297 { 2298 switch (reg) { 2299 case MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET: 2300 case MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET: 2301 case MLXPLAT_CPLD_LPC_REG_CPLD3_VER_OFFSET: 2302 case MLXPLAT_CPLD_LPC_REG_CPLD4_VER_OFFSET: 2303 case MLXPLAT_CPLD_LPC_REG_CPLD1_PN_OFFSET: 2304 case MLXPLAT_CPLD_LPC_REG_CPLD2_PN_OFFSET: 2305 case MLXPLAT_CPLD_LPC_REG_CPLD3_PN_OFFSET: 2306 case MLXPLAT_CPLD_LPC_REG_CPLD4_PN_OFFSET: 2307 case MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET: 2308 case MLXPLAT_CPLD_LPC_REG_RST_CAUSE1_OFFSET: 2309 case MLXPLAT_CPLD_LPC_REG_RST_CAUSE2_OFFSET: 2310 case MLXPLAT_CPLD_LPC_REG_LED1_OFFSET: 2311 case MLXPLAT_CPLD_LPC_REG_LED2_OFFSET: 2312 case MLXPLAT_CPLD_LPC_REG_LED3_OFFSET: 2313 case MLXPLAT_CPLD_LPC_REG_LED4_OFFSET: 2314 case MLXPLAT_CPLD_LPC_REG_LED5_OFFSET: 2315 case MLXPLAT_CPLD_LPC_REG_FAN_DIRECTION: 2316 case MLXPLAT_CPLD_LPC_REG_GP0_RO_OFFSET: 2317 case MLXPLAT_CPLD_LPC_REG_GP0_OFFSET: 2318 case MLXPLAT_CPLD_LPC_REG_GP1_OFFSET: 2319 case MLXPLAT_CPLD_LPC_REG_GP2_OFFSET: 2320 case MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET: 2321 case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET: 2322 case MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET: 2323 case MLXPLAT_CPLD_LPC_REG_AGGRLO_MASK_OFFSET: 2324 case MLXPLAT_CPLD_LPC_REG_AGGRCO_OFFSET: 2325 case MLXPLAT_CPLD_LPC_REG_AGGRCO_MASK_OFFSET: 2326 case MLXPLAT_CPLD_LPC_REG_AGGRCX_OFFSET: 2327 case MLXPLAT_CPLD_LPC_REG_AGGRCX_MASK_OFFSET: 2328 case MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET: 2329 case MLXPLAT_CPLD_LPC_REG_ASIC_EVENT_OFFSET: 2330 case MLXPLAT_CPLD_LPC_REG_ASIC_MASK_OFFSET: 2331 case MLXPLAT_CPLD_LPC_REG_PSU_OFFSET: 2332 case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFFSET: 2333 case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFFSET: 2334 case MLXPLAT_CPLD_LPC_REG_PWR_OFFSET: 2335 case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFFSET: 2336 case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFFSET: 2337 case MLXPLAT_CPLD_LPC_REG_FAN_OFFSET: 2338 case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET: 2339 case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET: 2340 case MLXPLAT_CPLD_LPC_REG_WD2_TMR_OFFSET: 2341 case MLXPLAT_CPLD_LPC_REG_WD2_TLEFT_OFFSET: 2342 case MLXPLAT_CPLD_LPC_REG_WD3_TMR_OFFSET: 2343 case MLXPLAT_CPLD_LPC_REG_WD3_TLEFT_OFFSET: 2344 case MLXPLAT_CPLD_LPC_REG_CPLD1_MVER_OFFSET: 2345 case MLXPLAT_CPLD_LPC_REG_CPLD2_MVER_OFFSET: 2346 case MLXPLAT_CPLD_LPC_REG_CPLD3_MVER_OFFSET: 2347 case MLXPLAT_CPLD_LPC_REG_CPLD4_MVER_OFFSET: 2348 case MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET: 2349 case MLXPLAT_CPLD_LPC_REG_TACHO1_OFFSET: 2350 case MLXPLAT_CPLD_LPC_REG_TACHO2_OFFSET: 2351 case MLXPLAT_CPLD_LPC_REG_TACHO3_OFFSET: 2352 case MLXPLAT_CPLD_LPC_REG_TACHO4_OFFSET: 2353 case MLXPLAT_CPLD_LPC_REG_TACHO5_OFFSET: 2354 case MLXPLAT_CPLD_LPC_REG_TACHO6_OFFSET: 2355 case MLXPLAT_CPLD_LPC_REG_TACHO7_OFFSET: 2356 case MLXPLAT_CPLD_LPC_REG_TACHO8_OFFSET: 2357 case MLXPLAT_CPLD_LPC_REG_TACHO9_OFFSET: 2358 case MLXPLAT_CPLD_LPC_REG_TACHO10_OFFSET: 2359 case MLXPLAT_CPLD_LPC_REG_TACHO11_OFFSET: 2360 case MLXPLAT_CPLD_LPC_REG_TACHO12_OFFSET: 2361 case MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET: 2362 case MLXPLAT_CPLD_LPC_REG_FAN_CAP1_OFFSET: 2363 case MLXPLAT_CPLD_LPC_REG_FAN_CAP2_OFFSET: 2364 case MLXPLAT_CPLD_LPC_REG_FAN_DRW_CAP_OFFSET: 2365 case MLXPLAT_CPLD_LPC_REG_TACHO_SPEED_OFFSET: 2366 case MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET: 2367 case MLXPLAT_CPLD_LPC_REG_CONFIG1_OFFSET: 2368 case MLXPLAT_CPLD_LPC_REG_CONFIG2_OFFSET: 2369 case MLXPLAT_CPLD_LPC_REG_UFM_VERSION_OFFSET: 2370 return true; 2371 } 2372 return false; 2373 } 2374 2375 static const struct reg_default mlxplat_mlxcpld_regmap_default[] = { 2376 { MLXPLAT_CPLD_LPC_REG_WP1_OFFSET, 0x00 }, 2377 { MLXPLAT_CPLD_LPC_REG_WP2_OFFSET, 0x00 }, 2378 { MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, 0x00 }, 2379 { MLXPLAT_CPLD_LPC_REG_WD_CLEAR_WP_OFFSET, 0x00 }, 2380 }; 2381 2382 static const struct reg_default mlxplat_mlxcpld_regmap_ng[] = { 2383 { MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, 0x00 }, 2384 { MLXPLAT_CPLD_LPC_REG_WD_CLEAR_WP_OFFSET, 0x00 }, 2385 }; 2386 2387 static const struct reg_default mlxplat_mlxcpld_regmap_comex_default[] = { 2388 { MLXPLAT_CPLD_LPC_REG_AGGRCX_MASK_OFFSET, 2389 MLXPLAT_CPLD_LOW_AGGRCX_MASK }, 2390 { MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, 0x00 }, 2391 }; 2392 2393 static const struct reg_default mlxplat_mlxcpld_regmap_ng400[] = { 2394 { MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, 0x00 }, 2395 { MLXPLAT_CPLD_LPC_REG_WD1_ACT_OFFSET, 0x00 }, 2396 { MLXPLAT_CPLD_LPC_REG_WD2_ACT_OFFSET, 0x00 }, 2397 { MLXPLAT_CPLD_LPC_REG_WD3_ACT_OFFSET, 0x00 }, 2398 }; 2399 2400 struct mlxplat_mlxcpld_regmap_context { 2401 void __iomem *base; 2402 }; 2403 2404 static struct mlxplat_mlxcpld_regmap_context mlxplat_mlxcpld_regmap_ctx; 2405 2406 static int 2407 mlxplat_mlxcpld_reg_read(void *context, unsigned int reg, unsigned int *val) 2408 { 2409 struct mlxplat_mlxcpld_regmap_context *ctx = context; 2410 2411 *val = ioread8(ctx->base + reg); 2412 return 0; 2413 } 2414 2415 static int 2416 mlxplat_mlxcpld_reg_write(void *context, unsigned int reg, unsigned int val) 2417 { 2418 struct mlxplat_mlxcpld_regmap_context *ctx = context; 2419 2420 iowrite8(val, ctx->base + reg); 2421 return 0; 2422 } 2423 2424 static const struct regmap_config mlxplat_mlxcpld_regmap_config = { 2425 .reg_bits = 8, 2426 .val_bits = 8, 2427 .max_register = 255, 2428 .cache_type = REGCACHE_FLAT, 2429 .writeable_reg = mlxplat_mlxcpld_writeable_reg, 2430 .readable_reg = mlxplat_mlxcpld_readable_reg, 2431 .volatile_reg = mlxplat_mlxcpld_volatile_reg, 2432 .reg_defaults = mlxplat_mlxcpld_regmap_default, 2433 .num_reg_defaults = ARRAY_SIZE(mlxplat_mlxcpld_regmap_default), 2434 .reg_read = mlxplat_mlxcpld_reg_read, 2435 .reg_write = mlxplat_mlxcpld_reg_write, 2436 }; 2437 2438 static const struct regmap_config mlxplat_mlxcpld_regmap_config_ng = { 2439 .reg_bits = 8, 2440 .val_bits = 8, 2441 .max_register = 255, 2442 .cache_type = REGCACHE_FLAT, 2443 .writeable_reg = mlxplat_mlxcpld_writeable_reg, 2444 .readable_reg = mlxplat_mlxcpld_readable_reg, 2445 .volatile_reg = mlxplat_mlxcpld_volatile_reg, 2446 .reg_defaults = mlxplat_mlxcpld_regmap_ng, 2447 .num_reg_defaults = ARRAY_SIZE(mlxplat_mlxcpld_regmap_ng), 2448 .reg_read = mlxplat_mlxcpld_reg_read, 2449 .reg_write = mlxplat_mlxcpld_reg_write, 2450 }; 2451 2452 static const struct regmap_config mlxplat_mlxcpld_regmap_config_comex = { 2453 .reg_bits = 8, 2454 .val_bits = 8, 2455 .max_register = 255, 2456 .cache_type = REGCACHE_FLAT, 2457 .writeable_reg = mlxplat_mlxcpld_writeable_reg, 2458 .readable_reg = mlxplat_mlxcpld_readable_reg, 2459 .volatile_reg = mlxplat_mlxcpld_volatile_reg, 2460 .reg_defaults = mlxplat_mlxcpld_regmap_comex_default, 2461 .num_reg_defaults = ARRAY_SIZE(mlxplat_mlxcpld_regmap_comex_default), 2462 .reg_read = mlxplat_mlxcpld_reg_read, 2463 .reg_write = mlxplat_mlxcpld_reg_write, 2464 }; 2465 2466 static const struct regmap_config mlxplat_mlxcpld_regmap_config_ng400 = { 2467 .reg_bits = 8, 2468 .val_bits = 8, 2469 .max_register = 255, 2470 .cache_type = REGCACHE_FLAT, 2471 .writeable_reg = mlxplat_mlxcpld_writeable_reg, 2472 .readable_reg = mlxplat_mlxcpld_readable_reg, 2473 .volatile_reg = mlxplat_mlxcpld_volatile_reg, 2474 .reg_defaults = mlxplat_mlxcpld_regmap_ng400, 2475 .num_reg_defaults = ARRAY_SIZE(mlxplat_mlxcpld_regmap_ng400), 2476 .reg_read = mlxplat_mlxcpld_reg_read, 2477 .reg_write = mlxplat_mlxcpld_reg_write, 2478 }; 2479 2480 static struct resource mlxplat_mlxcpld_resources[] = { 2481 [0] = DEFINE_RES_IRQ_NAMED(17, "mlxreg-hotplug"), 2482 }; 2483 2484 static struct platform_device *mlxplat_dev; 2485 static struct mlxreg_core_hotplug_platform_data *mlxplat_i2c; 2486 static struct mlxreg_core_hotplug_platform_data *mlxplat_hotplug; 2487 static struct mlxreg_core_platform_data *mlxplat_led; 2488 static struct mlxreg_core_platform_data *mlxplat_regs_io; 2489 static struct mlxreg_core_platform_data *mlxplat_fan; 2490 static struct mlxreg_core_platform_data 2491 *mlxplat_wd_data[MLXPLAT_CPLD_WD_MAX_DEVS]; 2492 static const struct regmap_config *mlxplat_regmap_config; 2493 2494 static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi) 2495 { 2496 int i; 2497 2498 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; 2499 mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data); 2500 mlxplat_mux_data = mlxplat_default_mux_data; 2501 for (i = 0; i < mlxplat_mux_num; i++) { 2502 mlxplat_mux_data[i].values = mlxplat_default_channels[i]; 2503 mlxplat_mux_data[i].n_values = 2504 ARRAY_SIZE(mlxplat_default_channels[i]); 2505 } 2506 mlxplat_hotplug = &mlxplat_mlxcpld_default_data; 2507 mlxplat_hotplug->deferred_nr = 2508 mlxplat_default_channels[i - 1][MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; 2509 mlxplat_led = &mlxplat_default_led_data; 2510 mlxplat_regs_io = &mlxplat_default_regs_io_data; 2511 mlxplat_wd_data[0] = &mlxplat_mlxcpld_wd_set_type1[0]; 2512 2513 return 1; 2514 } 2515 2516 static int __init mlxplat_dmi_msn21xx_matched(const struct dmi_system_id *dmi) 2517 { 2518 int i; 2519 2520 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; 2521 mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data); 2522 mlxplat_mux_data = mlxplat_default_mux_data; 2523 for (i = 0; i < mlxplat_mux_num; i++) { 2524 mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; 2525 mlxplat_mux_data[i].n_values = 2526 ARRAY_SIZE(mlxplat_msn21xx_channels); 2527 } 2528 mlxplat_hotplug = &mlxplat_mlxcpld_msn21xx_data; 2529 mlxplat_hotplug->deferred_nr = 2530 mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; 2531 mlxplat_led = &mlxplat_msn21xx_led_data; 2532 mlxplat_regs_io = &mlxplat_msn21xx_regs_io_data; 2533 mlxplat_wd_data[0] = &mlxplat_mlxcpld_wd_set_type1[0]; 2534 2535 return 1; 2536 } 2537 2538 static int __init mlxplat_dmi_msn274x_matched(const struct dmi_system_id *dmi) 2539 { 2540 int i; 2541 2542 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; 2543 mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data); 2544 mlxplat_mux_data = mlxplat_default_mux_data; 2545 for (i = 0; i < mlxplat_mux_num; i++) { 2546 mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; 2547 mlxplat_mux_data[i].n_values = 2548 ARRAY_SIZE(mlxplat_msn21xx_channels); 2549 } 2550 mlxplat_hotplug = &mlxplat_mlxcpld_msn274x_data; 2551 mlxplat_hotplug->deferred_nr = 2552 mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; 2553 mlxplat_led = &mlxplat_default_led_data; 2554 mlxplat_regs_io = &mlxplat_msn21xx_regs_io_data; 2555 mlxplat_wd_data[0] = &mlxplat_mlxcpld_wd_set_type1[0]; 2556 2557 return 1; 2558 } 2559 2560 static int __init mlxplat_dmi_msn201x_matched(const struct dmi_system_id *dmi) 2561 { 2562 int i; 2563 2564 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; 2565 mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data); 2566 mlxplat_mux_data = mlxplat_default_mux_data; 2567 for (i = 0; i < mlxplat_mux_num; i++) { 2568 mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; 2569 mlxplat_mux_data[i].n_values = 2570 ARRAY_SIZE(mlxplat_msn21xx_channels); 2571 } 2572 mlxplat_hotplug = &mlxplat_mlxcpld_msn201x_data; 2573 mlxplat_hotplug->deferred_nr = 2574 mlxplat_default_channels[i - 1][MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; 2575 mlxplat_led = &mlxplat_msn21xx_led_data; 2576 mlxplat_regs_io = &mlxplat_msn21xx_regs_io_data; 2577 mlxplat_wd_data[0] = &mlxplat_mlxcpld_wd_set_type1[0]; 2578 2579 return 1; 2580 } 2581 2582 static int __init mlxplat_dmi_qmb7xx_matched(const struct dmi_system_id *dmi) 2583 { 2584 int i; 2585 2586 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; 2587 mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data); 2588 mlxplat_mux_data = mlxplat_default_mux_data; 2589 for (i = 0; i < mlxplat_mux_num; i++) { 2590 mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; 2591 mlxplat_mux_data[i].n_values = 2592 ARRAY_SIZE(mlxplat_msn21xx_channels); 2593 } 2594 mlxplat_hotplug = &mlxplat_mlxcpld_default_ng_data; 2595 mlxplat_hotplug->deferred_nr = 2596 mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; 2597 mlxplat_led = &mlxplat_default_ng_led_data; 2598 mlxplat_regs_io = &mlxplat_default_ng_regs_io_data; 2599 mlxplat_fan = &mlxplat_default_fan_data; 2600 for (i = 0; i < ARRAY_SIZE(mlxplat_mlxcpld_wd_set_type2); i++) 2601 mlxplat_wd_data[i] = &mlxplat_mlxcpld_wd_set_type2[i]; 2602 mlxplat_i2c = &mlxplat_mlxcpld_i2c_ng_data; 2603 mlxplat_regmap_config = &mlxplat_mlxcpld_regmap_config_ng; 2604 2605 return 1; 2606 } 2607 2608 static int __init mlxplat_dmi_comex_matched(const struct dmi_system_id *dmi) 2609 { 2610 int i; 2611 2612 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_EXT_ADAPTER_NUM; 2613 mlxplat_mux_num = ARRAY_SIZE(mlxplat_extended_mux_data); 2614 mlxplat_mux_data = mlxplat_extended_mux_data; 2615 for (i = 0; i < mlxplat_mux_num; i++) { 2616 mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; 2617 mlxplat_mux_data[i].n_values = 2618 ARRAY_SIZE(mlxplat_msn21xx_channels); 2619 } 2620 mlxplat_hotplug = &mlxplat_mlxcpld_comex_data; 2621 mlxplat_hotplug->deferred_nr = MLXPLAT_CPLD_MAX_PHYS_EXT_ADAPTER_NUM; 2622 mlxplat_led = &mlxplat_comex_100G_led_data; 2623 mlxplat_regs_io = &mlxplat_default_ng_regs_io_data; 2624 mlxplat_fan = &mlxplat_default_fan_data; 2625 for (i = 0; i < ARRAY_SIZE(mlxplat_mlxcpld_wd_set_type2); i++) 2626 mlxplat_wd_data[i] = &mlxplat_mlxcpld_wd_set_type2[i]; 2627 mlxplat_regmap_config = &mlxplat_mlxcpld_regmap_config_comex; 2628 2629 return 1; 2630 } 2631 2632 static int __init mlxplat_dmi_ng400_matched(const struct dmi_system_id *dmi) 2633 { 2634 int i; 2635 2636 mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; 2637 mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data); 2638 mlxplat_mux_data = mlxplat_default_mux_data; 2639 for (i = 0; i < mlxplat_mux_num; i++) { 2640 mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; 2641 mlxplat_mux_data[i].n_values = 2642 ARRAY_SIZE(mlxplat_msn21xx_channels); 2643 } 2644 mlxplat_hotplug = &mlxplat_mlxcpld_ext_data; 2645 mlxplat_hotplug->deferred_nr = 2646 mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; 2647 mlxplat_led = &mlxplat_default_ng_led_data; 2648 mlxplat_regs_io = &mlxplat_default_ng_regs_io_data; 2649 mlxplat_fan = &mlxplat_default_fan_data; 2650 for (i = 0; i < ARRAY_SIZE(mlxplat_mlxcpld_wd_set_type2); i++) 2651 mlxplat_wd_data[i] = &mlxplat_mlxcpld_wd_set_type2[i]; 2652 mlxplat_i2c = &mlxplat_mlxcpld_i2c_ng_data; 2653 mlxplat_regmap_config = &mlxplat_mlxcpld_regmap_config_ng400; 2654 2655 return 1; 2656 } 2657 2658 static const struct dmi_system_id mlxplat_dmi_table[] __initconst = { 2659 { 2660 .callback = mlxplat_dmi_default_matched, 2661 .matches = { 2662 DMI_MATCH(DMI_BOARD_NAME, "VMOD0001"), 2663 }, 2664 }, 2665 { 2666 .callback = mlxplat_dmi_msn21xx_matched, 2667 .matches = { 2668 DMI_MATCH(DMI_BOARD_NAME, "VMOD0002"), 2669 }, 2670 }, 2671 { 2672 .callback = mlxplat_dmi_msn274x_matched, 2673 .matches = { 2674 DMI_MATCH(DMI_BOARD_NAME, "VMOD0003"), 2675 }, 2676 }, 2677 { 2678 .callback = mlxplat_dmi_msn201x_matched, 2679 .matches = { 2680 DMI_MATCH(DMI_BOARD_NAME, "VMOD0004"), 2681 }, 2682 }, 2683 { 2684 .callback = mlxplat_dmi_qmb7xx_matched, 2685 .matches = { 2686 DMI_MATCH(DMI_BOARD_NAME, "VMOD0005"), 2687 }, 2688 }, 2689 { 2690 .callback = mlxplat_dmi_qmb7xx_matched, 2691 .matches = { 2692 DMI_MATCH(DMI_BOARD_NAME, "VMOD0007"), 2693 }, 2694 }, 2695 { 2696 .callback = mlxplat_dmi_comex_matched, 2697 .matches = { 2698 DMI_MATCH(DMI_BOARD_NAME, "VMOD0009"), 2699 }, 2700 }, 2701 { 2702 .callback = mlxplat_dmi_ng400_matched, 2703 .matches = { 2704 DMI_MATCH(DMI_BOARD_NAME, "VMOD0010"), 2705 }, 2706 }, 2707 { 2708 .callback = mlxplat_dmi_msn274x_matched, 2709 .matches = { 2710 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), 2711 DMI_MATCH(DMI_PRODUCT_NAME, "MSN274"), 2712 }, 2713 }, 2714 { 2715 .callback = mlxplat_dmi_default_matched, 2716 .matches = { 2717 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), 2718 DMI_MATCH(DMI_PRODUCT_NAME, "MSN24"), 2719 }, 2720 }, 2721 { 2722 .callback = mlxplat_dmi_default_matched, 2723 .matches = { 2724 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), 2725 DMI_MATCH(DMI_PRODUCT_NAME, "MSN27"), 2726 }, 2727 }, 2728 { 2729 .callback = mlxplat_dmi_default_matched, 2730 .matches = { 2731 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), 2732 DMI_MATCH(DMI_PRODUCT_NAME, "MSB"), 2733 }, 2734 }, 2735 { 2736 .callback = mlxplat_dmi_default_matched, 2737 .matches = { 2738 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), 2739 DMI_MATCH(DMI_PRODUCT_NAME, "MSX"), 2740 }, 2741 }, 2742 { 2743 .callback = mlxplat_dmi_msn21xx_matched, 2744 .matches = { 2745 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), 2746 DMI_MATCH(DMI_PRODUCT_NAME, "MSN21"), 2747 }, 2748 }, 2749 { 2750 .callback = mlxplat_dmi_msn201x_matched, 2751 .matches = { 2752 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), 2753 DMI_MATCH(DMI_PRODUCT_NAME, "MSN201"), 2754 }, 2755 }, 2756 { 2757 .callback = mlxplat_dmi_qmb7xx_matched, 2758 .matches = { 2759 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), 2760 DMI_MATCH(DMI_PRODUCT_NAME, "MQM87"), 2761 }, 2762 }, 2763 { 2764 .callback = mlxplat_dmi_qmb7xx_matched, 2765 .matches = { 2766 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), 2767 DMI_MATCH(DMI_PRODUCT_NAME, "MSN37"), 2768 }, 2769 }, 2770 { 2771 .callback = mlxplat_dmi_qmb7xx_matched, 2772 .matches = { 2773 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), 2774 DMI_MATCH(DMI_PRODUCT_NAME, "MSN34"), 2775 }, 2776 }, 2777 { 2778 .callback = mlxplat_dmi_qmb7xx_matched, 2779 .matches = { 2780 DMI_MATCH(DMI_BOARD_VENDOR, "Mellanox Technologies"), 2781 DMI_MATCH(DMI_PRODUCT_NAME, "MSN38"), 2782 }, 2783 }, 2784 { } 2785 }; 2786 2787 MODULE_DEVICE_TABLE(dmi, mlxplat_dmi_table); 2788 2789 static int mlxplat_mlxcpld_verify_bus_topology(int *nr) 2790 { 2791 struct i2c_adapter *search_adap; 2792 int shift, i; 2793 2794 /* Scan adapters from expected id to verify it is free. */ 2795 *nr = MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR; 2796 for (i = MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR; i < 2797 mlxplat_max_adap_num; i++) { 2798 search_adap = i2c_get_adapter(i); 2799 if (search_adap) { 2800 i2c_put_adapter(search_adap); 2801 continue; 2802 } 2803 2804 /* Return if expected parent adapter is free. */ 2805 if (i == MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR) 2806 return 0; 2807 break; 2808 } 2809 2810 /* Return with error if free id for adapter is not found. */ 2811 if (i == mlxplat_max_adap_num) 2812 return -ENODEV; 2813 2814 /* Shift adapter ids, since expected parent adapter is not free. */ 2815 *nr = i; 2816 for (i = 0; i < mlxplat_mux_num; i++) { 2817 shift = *nr - mlxplat_mux_data[i].parent; 2818 mlxplat_mux_data[i].parent = *nr; 2819 mlxplat_mux_data[i].base_nr += shift; 2820 if (shift > 0) 2821 mlxplat_hotplug->shift_nr = shift; 2822 } 2823 2824 return 0; 2825 } 2826 2827 static int mlxplat_mlxcpld_check_wd_capability(void *regmap) 2828 { 2829 u32 regval; 2830 int i, rc; 2831 2832 rc = regmap_read(regmap, MLXPLAT_CPLD_LPC_REG_PSU_I2C_CAP_OFFSET, 2833 ®val); 2834 if (rc) 2835 return rc; 2836 2837 if (!(regval & ~MLXPLAT_CPLD_WD_CPBLTY_MASK)) { 2838 for (i = 0; i < ARRAY_SIZE(mlxplat_mlxcpld_wd_set_type3); i++) { 2839 if (mlxplat_wd_data[i]) 2840 mlxplat_wd_data[i] = 2841 &mlxplat_mlxcpld_wd_set_type3[i]; 2842 } 2843 } 2844 2845 return 0; 2846 } 2847 2848 static int __init mlxplat_init(void) 2849 { 2850 struct mlxplat_priv *priv; 2851 int i, j, nr, err; 2852 2853 if (!dmi_check_system(mlxplat_dmi_table)) 2854 return -ENODEV; 2855 2856 mlxplat_dev = platform_device_register_simple(MLX_PLAT_DEVICE_NAME, -1, 2857 mlxplat_lpc_resources, 2858 ARRAY_SIZE(mlxplat_lpc_resources)); 2859 2860 if (IS_ERR(mlxplat_dev)) 2861 return PTR_ERR(mlxplat_dev); 2862 2863 priv = devm_kzalloc(&mlxplat_dev->dev, sizeof(struct mlxplat_priv), 2864 GFP_KERNEL); 2865 if (!priv) { 2866 err = -ENOMEM; 2867 goto fail_alloc; 2868 } 2869 platform_set_drvdata(mlxplat_dev, priv); 2870 2871 mlxplat_mlxcpld_regmap_ctx.base = devm_ioport_map(&mlxplat_dev->dev, 2872 mlxplat_lpc_resources[1].start, 1); 2873 if (!mlxplat_mlxcpld_regmap_ctx.base) { 2874 err = -ENOMEM; 2875 goto fail_alloc; 2876 } 2877 2878 if (!mlxplat_regmap_config) 2879 mlxplat_regmap_config = &mlxplat_mlxcpld_regmap_config; 2880 2881 priv->regmap = devm_regmap_init(&mlxplat_dev->dev, NULL, 2882 &mlxplat_mlxcpld_regmap_ctx, 2883 mlxplat_regmap_config); 2884 if (IS_ERR(priv->regmap)) { 2885 err = PTR_ERR(priv->regmap); 2886 goto fail_alloc; 2887 } 2888 2889 err = mlxplat_mlxcpld_verify_bus_topology(&nr); 2890 if (nr < 0) 2891 goto fail_alloc; 2892 2893 nr = (nr == mlxplat_max_adap_num) ? -1 : nr; 2894 if (mlxplat_i2c) 2895 mlxplat_i2c->regmap = priv->regmap; 2896 priv->pdev_i2c = platform_device_register_resndata( 2897 &mlxplat_dev->dev, "i2c_mlxcpld", 2898 nr, mlxplat_mlxcpld_resources, 2899 ARRAY_SIZE(mlxplat_mlxcpld_resources), 2900 mlxplat_i2c, sizeof(*mlxplat_i2c)); 2901 if (IS_ERR(priv->pdev_i2c)) { 2902 err = PTR_ERR(priv->pdev_i2c); 2903 goto fail_alloc; 2904 } 2905 2906 for (i = 0; i < mlxplat_mux_num; i++) { 2907 priv->pdev_mux[i] = platform_device_register_resndata( 2908 &priv->pdev_i2c->dev, 2909 "i2c-mux-reg", i, NULL, 2910 0, &mlxplat_mux_data[i], 2911 sizeof(mlxplat_mux_data[i])); 2912 if (IS_ERR(priv->pdev_mux[i])) { 2913 err = PTR_ERR(priv->pdev_mux[i]); 2914 goto fail_platform_mux_register; 2915 } 2916 } 2917 2918 /* Add hotplug driver */ 2919 mlxplat_hotplug->regmap = priv->regmap; 2920 priv->pdev_hotplug = platform_device_register_resndata( 2921 &mlxplat_dev->dev, "mlxreg-hotplug", 2922 PLATFORM_DEVID_NONE, 2923 mlxplat_mlxcpld_resources, 2924 ARRAY_SIZE(mlxplat_mlxcpld_resources), 2925 mlxplat_hotplug, sizeof(*mlxplat_hotplug)); 2926 if (IS_ERR(priv->pdev_hotplug)) { 2927 err = PTR_ERR(priv->pdev_hotplug); 2928 goto fail_platform_mux_register; 2929 } 2930 2931 /* Set default registers. */ 2932 for (j = 0; j < mlxplat_regmap_config->num_reg_defaults; j++) { 2933 err = regmap_write(priv->regmap, 2934 mlxplat_regmap_config->reg_defaults[j].reg, 2935 mlxplat_regmap_config->reg_defaults[j].def); 2936 if (err) 2937 goto fail_platform_mux_register; 2938 } 2939 2940 /* Add LED driver. */ 2941 mlxplat_led->regmap = priv->regmap; 2942 priv->pdev_led = platform_device_register_resndata( 2943 &mlxplat_dev->dev, "leds-mlxreg", 2944 PLATFORM_DEVID_NONE, NULL, 0, 2945 mlxplat_led, sizeof(*mlxplat_led)); 2946 if (IS_ERR(priv->pdev_led)) { 2947 err = PTR_ERR(priv->pdev_led); 2948 goto fail_platform_hotplug_register; 2949 } 2950 2951 /* Add registers io access driver. */ 2952 if (mlxplat_regs_io) { 2953 mlxplat_regs_io->regmap = priv->regmap; 2954 priv->pdev_io_regs = platform_device_register_resndata( 2955 &mlxplat_dev->dev, "mlxreg-io", 2956 PLATFORM_DEVID_NONE, NULL, 0, 2957 mlxplat_regs_io, 2958 sizeof(*mlxplat_regs_io)); 2959 if (IS_ERR(priv->pdev_io_regs)) { 2960 err = PTR_ERR(priv->pdev_io_regs); 2961 goto fail_platform_led_register; 2962 } 2963 } 2964 2965 /* Add FAN driver. */ 2966 if (mlxplat_fan) { 2967 mlxplat_fan->regmap = priv->regmap; 2968 priv->pdev_fan = platform_device_register_resndata( 2969 &mlxplat_dev->dev, "mlxreg-fan", 2970 PLATFORM_DEVID_NONE, NULL, 0, 2971 mlxplat_fan, 2972 sizeof(*mlxplat_fan)); 2973 if (IS_ERR(priv->pdev_fan)) { 2974 err = PTR_ERR(priv->pdev_fan); 2975 goto fail_platform_io_regs_register; 2976 } 2977 } 2978 2979 /* Add WD drivers. */ 2980 err = mlxplat_mlxcpld_check_wd_capability(priv->regmap); 2981 if (err) 2982 goto fail_platform_wd_register; 2983 for (j = 0; j < MLXPLAT_CPLD_WD_MAX_DEVS; j++) { 2984 if (mlxplat_wd_data[j]) { 2985 mlxplat_wd_data[j]->regmap = priv->regmap; 2986 priv->pdev_wd[j] = platform_device_register_resndata( 2987 &mlxplat_dev->dev, "mlx-wdt", 2988 j, NULL, 0, 2989 mlxplat_wd_data[j], 2990 sizeof(*mlxplat_wd_data[j])); 2991 if (IS_ERR(priv->pdev_wd[j])) { 2992 err = PTR_ERR(priv->pdev_wd[j]); 2993 goto fail_platform_wd_register; 2994 } 2995 } 2996 } 2997 2998 /* Sync registers with hardware. */ 2999 regcache_mark_dirty(priv->regmap); 3000 err = regcache_sync(priv->regmap); 3001 if (err) 3002 goto fail_platform_wd_register; 3003 3004 return 0; 3005 3006 fail_platform_wd_register: 3007 while (--j >= 0) 3008 platform_device_unregister(priv->pdev_wd[j]); 3009 if (mlxplat_fan) 3010 platform_device_unregister(priv->pdev_fan); 3011 fail_platform_io_regs_register: 3012 if (mlxplat_regs_io) 3013 platform_device_unregister(priv->pdev_io_regs); 3014 fail_platform_led_register: 3015 platform_device_unregister(priv->pdev_led); 3016 fail_platform_hotplug_register: 3017 platform_device_unregister(priv->pdev_hotplug); 3018 fail_platform_mux_register: 3019 while (--i >= 0) 3020 platform_device_unregister(priv->pdev_mux[i]); 3021 platform_device_unregister(priv->pdev_i2c); 3022 fail_alloc: 3023 platform_device_unregister(mlxplat_dev); 3024 3025 return err; 3026 } 3027 module_init(mlxplat_init); 3028 3029 static void __exit mlxplat_exit(void) 3030 { 3031 struct mlxplat_priv *priv = platform_get_drvdata(mlxplat_dev); 3032 int i; 3033 3034 for (i = MLXPLAT_CPLD_WD_MAX_DEVS - 1; i >= 0 ; i--) 3035 platform_device_unregister(priv->pdev_wd[i]); 3036 if (priv->pdev_fan) 3037 platform_device_unregister(priv->pdev_fan); 3038 if (priv->pdev_io_regs) 3039 platform_device_unregister(priv->pdev_io_regs); 3040 platform_device_unregister(priv->pdev_led); 3041 platform_device_unregister(priv->pdev_hotplug); 3042 3043 for (i = mlxplat_mux_num - 1; i >= 0 ; i--) 3044 platform_device_unregister(priv->pdev_mux[i]); 3045 3046 platform_device_unregister(priv->pdev_i2c); 3047 platform_device_unregister(mlxplat_dev); 3048 } 3049 module_exit(mlxplat_exit); 3050 3051 MODULE_AUTHOR("Vadim Pasternak (vadimp@mellanox.com)"); 3052 MODULE_DESCRIPTION("Mellanox platform driver"); 3053 MODULE_LICENSE("Dual BSD/GPL"); 3054