|
| 1 | +From 693ea1c72c6f1b83232c043fdb1b175a450bc172 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Vadim Pasternak < [email protected]> |
| 3 | +Date: Wed, 7 Aug 2024 00:09:11 +0000 |
| 4 | +Subject: [PATCH backport 6.1 1/1] platform: mellanox: nvsw-sn2200: Add support |
| 5 | + for new system flavour |
| 6 | + |
| 7 | +Add support for SN2201 system flavour, which is fitting OCP rack |
| 8 | +form-factor and feeded from external power source through the rack |
| 9 | +standard busbar interface. |
| 10 | + |
| 11 | +Validate system type through DMI decode. |
| 12 | +For new system flavour: |
| 13 | +- Skip internal power supply configuration. |
| 14 | +- Attach power hotswap device. |
| 15 | + |
| 16 | +Signed-off-by: Vadim Pasternak < [email protected]> |
| 17 | +--- |
| 18 | + drivers/platform/mellanox/nvsw-sn2201.c | 111 +++++++++++++++++++++++- |
| 19 | + 1 file changed, 108 insertions(+), 3 deletions(-) |
| 20 | + |
| 21 | +diff --git a/drivers/platform/mellanox/nvsw-sn2201.c b/drivers/platform/mellanox/nvsw-sn2201.c |
| 22 | +index 2612bb5f82a3..d604069e3313 100644 |
| 23 | +--- a/drivers/platform/mellanox/nvsw-sn2201.c |
| 24 | ++++ b/drivers/platform/mellanox/nvsw-sn2201.c |
| 25 | +@@ -6,6 +6,7 @@ |
| 26 | + */ |
| 27 | + |
| 28 | + #include <linux/device.h> |
| 29 | ++#include <linux/dmi.h> |
| 30 | + #include <linux/i2c.h> |
| 31 | + #include <linux/interrupt.h> |
| 32 | + #include <linux/irq.h> |
| 33 | +@@ -104,6 +105,9 @@ |
| 34 | + | NVSW_SN2201_CPLD_AGGR_PSU_MASK_DEF \ |
| 35 | + | NVSW_SN2201_CPLD_AGGR_PWR_MASK_DEF \ |
| 36 | + | NVSW_SN2201_CPLD_AGGR_FAN_MASK_DEF) |
| 37 | ++#define NVSW_SN2201_CPLD_AGGR_BUSBAR_MASK_DEF \ |
| 38 | ++ (NVSW_SN2201_CPLD_AGGR_ASIC_MASK_DEF \ |
| 39 | ++ | NVSW_SN2201_CPLD_AGGR_FAN_MASK_DEF) |
| 40 | + |
| 41 | + #define NVSW_SN2201_CPLD_ASIC_MASK GENMASK(3, 1) |
| 42 | + #define NVSW_SN2201_CPLD_PSU_MASK GENMASK(1, 0) |
| 43 | +@@ -132,6 +136,7 @@ |
| 44 | + * @cpld_devs: I2C devices for cpld; |
| 45 | + * @cpld_devs_num: number of I2C devices for cpld; |
| 46 | + * @main_mux_deferred_nr: I2C adapter number must be exist prior creating devices execution; |
| 47 | ++ * @ext_pwr_source: 1 if system powered by external power supply; 0 - by internal; |
| 48 | + */ |
| 49 | + struct nvsw_sn2201 { |
| 50 | + struct device *dev; |
| 51 | +@@ -152,6 +157,7 @@ struct nvsw_sn2201 { |
| 52 | + struct mlxreg_hotplug_device *cpld_devs; |
| 53 | + int cpld_devs_num; |
| 54 | + int main_mux_deferred_nr; |
| 55 | ++ u8 ext_pwr_source; |
| 56 | + }; |
| 57 | + |
| 58 | + static bool nvsw_sn2201_writeable_reg(struct device *dev, unsigned int reg) |
| 59 | +@@ -523,6 +529,36 @@ struct mlxreg_core_hotplug_platform_data nvsw_sn2201_hotplug = { |
| 60 | + .deferred_nr = NVSW_SN2201_2ND_MUX_CH3_NR, |
| 61 | + }; |
| 62 | + |
| 63 | ++static struct mlxreg_core_item nvsw_sn2201_busbar_items[] = { |
| 64 | ++ { |
| 65 | ++ .data = nvsw_sn2201_fan_items_data, |
| 66 | ++ .aggr_mask = NVSW_SN2201_CPLD_AGGR_FAN_MASK_DEF, |
| 67 | ++ .reg = NVSW_SN2201_FAN_PRSNT_STATUS_OFFSET, |
| 68 | ++ .mask = NVSW_SN2201_CPLD_FAN_MASK, |
| 69 | ++ .count = ARRAY_SIZE(nvsw_sn2201_fan_items_data), |
| 70 | ++ .inversed = 1, |
| 71 | ++ .health = false, |
| 72 | ++ }, |
| 73 | ++ { |
| 74 | ++ .data = nvsw_sn2201_sys_items_data, |
| 75 | ++ .aggr_mask = NVSW_SN2201_CPLD_AGGR_ASIC_MASK_DEF, |
| 76 | ++ .reg = NVSW_SN2201_ASIC_STATUS_OFFSET, |
| 77 | ++ .mask = NVSW_SN2201_CPLD_ASIC_MASK, |
| 78 | ++ .count = ARRAY_SIZE(nvsw_sn2201_sys_items_data), |
| 79 | ++ .inversed = 1, |
| 80 | ++ .health = false, |
| 81 | ++ }, |
| 82 | ++}; |
| 83 | ++ |
| 84 | ++static |
| 85 | ++struct mlxreg_core_hotplug_platform_data nvsw_sn2201_busbar_hotplug = { |
| 86 | ++ .items = nvsw_sn2201_busbar_items, |
| 87 | ++ .counter = ARRAY_SIZE(nvsw_sn2201_busbar_items), |
| 88 | ++ .cell = NVSW_SN2201_SYS_INT_STATUS_OFFSET, |
| 89 | ++ .mask = NVSW_SN2201_CPLD_AGGR_BUSBAR_MASK_DEF, |
| 90 | ++ .deferred_nr = NVSW_SN2201_2ND_MUX_CH3_NR, |
| 91 | ++}; |
| 92 | ++ |
| 93 | + /* SN2201 static devices. */ |
| 94 | + static struct i2c_board_info nvsw_sn2201_static_devices[] = { |
| 95 | + { |
| 96 | +@@ -558,6 +594,9 @@ static struct i2c_board_info nvsw_sn2201_static_devices[] = { |
| 97 | + { |
| 98 | + I2C_BOARD_INFO("pmbus", 0x40), |
| 99 | + }, |
| 100 | ++ { |
| 101 | ++ I2C_BOARD_INFO("lm5066i", 0x15), |
| 102 | ++ }, |
| 103 | + }; |
| 104 | + |
| 105 | + /* SN2201 default static board info. */ |
| 106 | +@@ -608,6 +647,58 @@ static struct mlxreg_hotplug_device nvsw_sn2201_static_brdinfo[] = { |
| 107 | + }, |
| 108 | + }; |
| 109 | + |
| 110 | ++/* SN2201 default busbar static board info. */ |
| 111 | ++static struct mlxreg_hotplug_device nvsw_sn2201_busbar_static_brdinfo[] = { |
| 112 | ++ { |
| 113 | ++ .brdinfo = &nvsw_sn2201_static_devices[0], |
| 114 | ++ .nr = NVSW_SN2201_MAIN_NR, |
| 115 | ++ }, |
| 116 | ++ { |
| 117 | ++ .brdinfo = &nvsw_sn2201_static_devices[1], |
| 118 | ++ .nr = NVSW_SN2201_MAIN_MUX_CH0_NR, |
| 119 | ++ }, |
| 120 | ++ { |
| 121 | ++ .brdinfo = &nvsw_sn2201_static_devices[2], |
| 122 | ++ .nr = NVSW_SN2201_MAIN_MUX_CH0_NR, |
| 123 | ++ }, |
| 124 | ++ { |
| 125 | ++ .brdinfo = &nvsw_sn2201_static_devices[3], |
| 126 | ++ .nr = NVSW_SN2201_MAIN_MUX_CH0_NR, |
| 127 | ++ }, |
| 128 | ++ { |
| 129 | ++ .brdinfo = &nvsw_sn2201_static_devices[4], |
| 130 | ++ .nr = NVSW_SN2201_MAIN_MUX_CH3_NR, |
| 131 | ++ }, |
| 132 | ++ { |
| 133 | ++ .brdinfo = &nvsw_sn2201_static_devices[5], |
| 134 | ++ .nr = NVSW_SN2201_MAIN_MUX_CH5_NR, |
| 135 | ++ }, |
| 136 | ++ { |
| 137 | ++ .brdinfo = &nvsw_sn2201_static_devices[6], |
| 138 | ++ .nr = NVSW_SN2201_MAIN_MUX_CH5_NR, |
| 139 | ++ }, |
| 140 | ++ { |
| 141 | ++ .brdinfo = &nvsw_sn2201_static_devices[7], |
| 142 | ++ .nr = NVSW_SN2201_MAIN_MUX_CH5_NR, |
| 143 | ++ }, |
| 144 | ++ { |
| 145 | ++ .brdinfo = &nvsw_sn2201_static_devices[8], |
| 146 | ++ .nr = NVSW_SN2201_MAIN_MUX_CH6_NR, |
| 147 | ++ }, |
| 148 | ++ { |
| 149 | ++ .brdinfo = &nvsw_sn2201_static_devices[9], |
| 150 | ++ .nr = NVSW_SN2201_MAIN_MUX_CH6_NR, |
| 151 | ++ }, |
| 152 | ++ { |
| 153 | ++ .brdinfo = &nvsw_sn2201_static_devices[10], |
| 154 | ++ .nr = NVSW_SN2201_MAIN_MUX_CH7_NR, |
| 155 | ++ }, |
| 156 | ++ { |
| 157 | ++ .brdinfo = &nvsw_sn2201_static_devices[11], |
| 158 | ++ .nr = NVSW_SN2201_MAIN_MUX_CH1_NR, |
| 159 | ++ }, |
| 160 | ++}; |
| 161 | ++ |
| 162 | + /* LED default data. */ |
| 163 | + static struct mlxreg_core_data nvsw_sn2201_led_data[] = { |
| 164 | + { |
| 165 | +@@ -982,7 +1073,10 @@ static int nvsw_sn2201_config_init(struct nvsw_sn2201 *nvsw_sn2201, void *regmap |
| 166 | + nvsw_sn2201->io_data = &nvsw_sn2201_regs_io; |
| 167 | + nvsw_sn2201->led_data = &nvsw_sn2201_led; |
| 168 | + nvsw_sn2201->wd_data = &nvsw_sn2201_wd; |
| 169 | +- nvsw_sn2201->hotplug_data = &nvsw_sn2201_hotplug; |
| 170 | ++ if (nvsw_sn2201->ext_pwr_source) |
| 171 | ++ nvsw_sn2201->hotplug_data = &nvsw_sn2201_busbar_hotplug; |
| 172 | ++ else |
| 173 | ++ nvsw_sn2201->hotplug_data = &nvsw_sn2201_hotplug; |
| 174 | + |
| 175 | + /* Register IO access driver. */ |
| 176 | + if (nvsw_sn2201->io_data) { |
| 177 | +@@ -1199,11 +1293,17 @@ static int nvsw_sn2201_config_pre_init(struct nvsw_sn2201 *nvsw_sn2201) |
| 178 | + static int nvsw_sn2201_probe(struct platform_device *pdev) |
| 179 | + { |
| 180 | + struct nvsw_sn2201 *nvsw_sn2201; |
| 181 | ++ const char *sku; |
| 182 | + |
| 183 | + nvsw_sn2201 = devm_kzalloc(&pdev->dev, sizeof(*nvsw_sn2201), GFP_KERNEL); |
| 184 | + if (!nvsw_sn2201) |
| 185 | + return -ENOMEM; |
| 186 | + |
| 187 | ++ /* Validate system powering type. */ |
| 188 | ++ sku = dmi_get_system_info(DMI_PRODUCT_SKU); |
| 189 | ++ if (!strcmp(sku, "HI168")) |
| 190 | ++ nvsw_sn2201->ext_pwr_source = 1; |
| 191 | ++ |
| 192 | + nvsw_sn2201->dev = &pdev->dev; |
| 193 | + platform_set_drvdata(pdev, nvsw_sn2201); |
| 194 | + platform_device_add_resources(pdev, nvsw_sn2201_lpc_io_resources, |
| 195 | +@@ -1212,8 +1312,13 @@ static int nvsw_sn2201_probe(struct platform_device *pdev) |
| 196 | + nvsw_sn2201->main_mux_deferred_nr = NVSW_SN2201_MAIN_MUX_DEFER_NR; |
| 197 | + nvsw_sn2201->main_mux_devs = nvsw_sn2201_main_mux_brdinfo; |
| 198 | + nvsw_sn2201->cpld_devs = nvsw_sn2201_cpld_brdinfo; |
| 199 | +- nvsw_sn2201->sn2201_devs = nvsw_sn2201_static_brdinfo; |
| 200 | +- nvsw_sn2201->sn2201_devs_num = ARRAY_SIZE(nvsw_sn2201_static_brdinfo); |
| 201 | ++ if (nvsw_sn2201->ext_pwr_source) { |
| 202 | ++ nvsw_sn2201->sn2201_devs = nvsw_sn2201_busbar_static_brdinfo; |
| 203 | ++ nvsw_sn2201->sn2201_devs_num = ARRAY_SIZE(nvsw_sn2201_busbar_static_brdinfo); |
| 204 | ++ } else { |
| 205 | ++ nvsw_sn2201->sn2201_devs = nvsw_sn2201_static_brdinfo; |
| 206 | ++ nvsw_sn2201->sn2201_devs_num = ARRAY_SIZE(nvsw_sn2201_static_brdinfo); |
| 207 | ++ } |
| 208 | + |
| 209 | + return nvsw_sn2201_config_pre_init(nvsw_sn2201); |
| 210 | + } |
| 211 | +-- |
| 212 | +2.44.0 |
| 213 | + |
0 commit comments