diff options
-rw-r--r-- | Documentation/devicetree/bindings/gpio/gpio-fan.txt | 6 | ||||
-rw-r--r-- | drivers/hwmon/gpio-fan.c | 44 |
2 files changed, 27 insertions, 23 deletions
diff --git a/Documentation/devicetree/bindings/gpio/gpio-fan.txt b/Documentation/devicetree/bindings/gpio/gpio-fan.txt index 2dd457a3469a..f996d428f132 100644 --- a/Documentation/devicetree/bindings/gpio/gpio-fan.txt +++ b/Documentation/devicetree/bindings/gpio/gpio-fan.txt | |||
@@ -2,16 +2,18 @@ Bindings for fan connected to GPIO lines | |||
2 | 2 | ||
3 | Required properties: | 3 | Required properties: |
4 | - compatible : "gpio-fan" | 4 | - compatible : "gpio-fan" |
5 | |||
6 | Optional properties: | ||
5 | - gpios: Specifies the pins that map to bits in the control value, | 7 | - gpios: Specifies the pins that map to bits in the control value, |
6 | ordered MSB-->LSB. | 8 | ordered MSB-->LSB. |
7 | - gpio-fan,speed-map: A mapping of possible fan RPM speeds and the | 9 | - gpio-fan,speed-map: A mapping of possible fan RPM speeds and the |
8 | control value that should be set to achieve them. This array | 10 | control value that should be set to achieve them. This array |
9 | must have the RPM values in ascending order. | 11 | must have the RPM values in ascending order. |
10 | |||
11 | Optional properties: | ||
12 | - alarm-gpios: This pin going active indicates something is wrong with | 12 | - alarm-gpios: This pin going active indicates something is wrong with |
13 | the fan, and a udev event will be fired. | 13 | the fan, and a udev event will be fired. |
14 | 14 | ||
15 | Note: At least one the "gpios" or "alarm-gpios" properties must be set. | ||
16 | |||
15 | Examples: | 17 | Examples: |
16 | 18 | ||
17 | gpio_fan { | 19 | gpio_fan { |
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index 36abf814b8c7..c241f5b0b7cf 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c | |||
@@ -404,10 +404,32 @@ static int gpio_fan_get_of_pdata(struct device *dev, | |||
404 | 404 | ||
405 | node = dev->of_node; | 405 | node = dev->of_node; |
406 | 406 | ||
407 | /* Alarm GPIO if one exists */ | ||
408 | if (of_gpio_named_count(node, "alarm-gpios") > 0) { | ||
409 | struct gpio_fan_alarm *alarm; | ||
410 | int val; | ||
411 | enum of_gpio_flags flags; | ||
412 | |||
413 | alarm = devm_kzalloc(dev, sizeof(struct gpio_fan_alarm), | ||
414 | GFP_KERNEL); | ||
415 | if (!alarm) | ||
416 | return -ENOMEM; | ||
417 | |||
418 | val = of_get_named_gpio_flags(node, "alarm-gpios", 0, &flags); | ||
419 | if (val < 0) | ||
420 | return val; | ||
421 | alarm->gpio = val; | ||
422 | alarm->active_low = flags & OF_GPIO_ACTIVE_LOW; | ||
423 | |||
424 | pdata->alarm = alarm; | ||
425 | } | ||
426 | |||
407 | /* Fill GPIO pin array */ | 427 | /* Fill GPIO pin array */ |
408 | pdata->num_ctrl = of_gpio_count(node); | 428 | pdata->num_ctrl = of_gpio_count(node); |
409 | if (pdata->num_ctrl <= 0) { | 429 | if (pdata->num_ctrl <= 0) { |
410 | dev_err(dev, "gpios DT property empty / missing"); | 430 | if (pdata->alarm) |
431 | return 0; | ||
432 | dev_err(dev, "DT properties empty / missing"); | ||
411 | return -ENODEV; | 433 | return -ENODEV; |
412 | } | 434 | } |
413 | ctrl = devm_kzalloc(dev, pdata->num_ctrl * sizeof(unsigned), | 435 | ctrl = devm_kzalloc(dev, pdata->num_ctrl * sizeof(unsigned), |
@@ -460,26 +482,6 @@ static int gpio_fan_get_of_pdata(struct device *dev, | |||
460 | } | 482 | } |
461 | pdata->speed = speed; | 483 | pdata->speed = speed; |
462 | 484 | ||
463 | /* Alarm GPIO if one exists */ | ||
464 | if (of_gpio_named_count(node, "alarm-gpios") > 0) { | ||
465 | struct gpio_fan_alarm *alarm; | ||
466 | int val; | ||
467 | enum of_gpio_flags flags; | ||
468 | |||
469 | alarm = devm_kzalloc(dev, sizeof(struct gpio_fan_alarm), | ||
470 | GFP_KERNEL); | ||
471 | if (!alarm) | ||
472 | return -ENOMEM; | ||
473 | |||
474 | val = of_get_named_gpio_flags(node, "alarm-gpios", 0, &flags); | ||
475 | if (val < 0) | ||
476 | return val; | ||
477 | alarm->gpio = val; | ||
478 | alarm->active_low = flags & OF_GPIO_ACTIVE_LOW; | ||
479 | |||
480 | pdata->alarm = alarm; | ||
481 | } | ||
482 | |||
483 | return 0; | 485 | return 0; |
484 | } | 486 | } |
485 | 487 | ||