| .. | .. |
|---|
| 22 | 22 | #define MLXREG_LED_AMBER_SOLID 0x09 /* Solid amber */ |
|---|
| 23 | 23 | #define MLXREG_LED_BLINK_3HZ 167 /* ~167 msec off/on - HW support */ |
|---|
| 24 | 24 | #define MLXREG_LED_BLINK_6HZ 83 /* ~83 msec off/on - HW support */ |
|---|
| 25 | +#define MLXREG_LED_CAPABILITY_CLEAR GENMASK(31, 8) /* Clear mask */ |
|---|
| 25 | 26 | |
|---|
| 26 | 27 | /** |
|---|
| 27 | 28 | * struct mlxreg_led_data - led control data: |
|---|
| .. | .. |
|---|
| 187 | 188 | struct mlxreg_led_data *led_data; |
|---|
| 188 | 189 | struct led_classdev *led_cdev; |
|---|
| 189 | 190 | enum led_brightness brightness; |
|---|
| 191 | + u32 regval; |
|---|
| 190 | 192 | int i; |
|---|
| 191 | 193 | int err; |
|---|
| 192 | 194 | |
|---|
| .. | .. |
|---|
| 196 | 198 | if (!led_data) |
|---|
| 197 | 199 | return -ENOMEM; |
|---|
| 198 | 200 | |
|---|
| 201 | + if (data->capability) { |
|---|
| 202 | + err = regmap_read(led_pdata->regmap, data->capability, |
|---|
| 203 | + ®val); |
|---|
| 204 | + if (err) { |
|---|
| 205 | + dev_err(&priv->pdev->dev, "Failed to query capability register\n"); |
|---|
| 206 | + return err; |
|---|
| 207 | + } |
|---|
| 208 | + if (!(regval & data->bit)) |
|---|
| 209 | + continue; |
|---|
| 210 | + /* |
|---|
| 211 | + * Field "bit" can contain one capability bit in 0 byte |
|---|
| 212 | + * and offset bit in 1-3 bytes. Clear capability bit and |
|---|
| 213 | + * keep only offset bit. |
|---|
| 214 | + */ |
|---|
| 215 | + data->bit &= MLXREG_LED_CAPABILITY_CLEAR; |
|---|
| 216 | + } |
|---|
| 217 | + |
|---|
| 199 | 218 | led_cdev = &led_data->led_cdev; |
|---|
| 200 | 219 | led_data->data_parent = priv; |
|---|
| 201 | 220 | if (strstr(data->label, "red") || |
|---|