aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-10 16:40:14 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-10 16:40:14 -0400
commit40c43269cf8e88a0bdc306c717d1dd5446a6f3b8 (patch)
tree5db4e262ed088f82e5b84757f238a1a11e5062dd /drivers/leds
parent93834c6419bccf102a17971c6b114826597a61c5 (diff)
parent3afb57fa721f94206e642f8fda51f5a89dda3dfb (diff)
Merge tag 'hwmon-for-linus-v3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon updates from Guenter Roeck: - new driver for menf21bmc. - convert k10temp, smsc47b397, da9052, da9055 to new hwmon API. - register ntc_thermistor driver with thermal subsystem. - add support for F15h M60h to k10temp driver. - add driver for MEN14F021P00 BMC HWMON driver; this required a merge with tag mfd-hwmon-leds-watchdog-v3.18 * tag 'hwmon-for-linus-v3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (ab8500) Call kernel_power_off instead of pm_power_off hwmon: (menf21bmc) Introduce MEN14F021P00 BMC HWMON driver leds: leds-menf21bmc: Introduce MEN 14F021P00 BMC LED driver watchdog: menf21bmc_wdt: Introduce MEN 14F021P00 BMC Watchdog driver mfd: menf21bmc: Introduce MEN 14F021P00 BMC MFD Core driver hwmon: (ntc_thermistor) Add ntc thermistor to thermal subsystem as a sensor. hwmon: (smsc47b397) Convert to devm_hwmon_device_register_with_groups MAINTAINERS: add entry for the PWM fan driver hwmon: (k10temp) Convert to devm_hwmon_device_register_with_groups hwmon: (k10temp) Add support for F15h M60h hwmon: (da9052) Convert to devm_hwmon_device_register_with_groups hwmon: (da9055) Convert to devm_hwmon_device_register_with_groups hwmon: (ads1015) Use of_property_read_u32 at appropriate places
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/Kconfig9
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-menf21bmc.c131
3 files changed, 141 insertions, 0 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 90e108f9e22e..a210338cfeb1 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -468,6 +468,15 @@ config LEDS_OT200
468 This option enables support for the LEDs on the Bachmann OT200. 468 This option enables support for the LEDs on the Bachmann OT200.
469 Say Y to enable LEDs on the Bachmann OT200. 469 Say Y to enable LEDs on the Bachmann OT200.
470 470
471config LEDS_MENF21BMC
472 tristate "LED support for the MEN 14F021P00 BMC"
473 depends on LEDS_CLASS && MFD_MENF21BMC
474 help
475 Say Y here to include support for the MEN 14F021P00 BMC LEDs.
476
477 This driver can also be built as a module. If so the module
478 will be called leds-menf21bmc.
479
471comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)" 480comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)"
472 481
473config LEDS_BLINKM 482config LEDS_BLINKM
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 822dd83ef97a..a2b164741465 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_LEDS_LM355x) += leds-lm355x.o
55obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o 55obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o
56obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o 56obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o
57obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o 57obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o
58obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o
58 59
59# LED SPI Drivers 60# LED SPI Drivers
60obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o 61obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
diff --git a/drivers/leds/leds-menf21bmc.c b/drivers/leds/leds-menf21bmc.c
new file mode 100644
index 000000000000..89dd57769e3b
--- /dev/null
+++ b/drivers/leds/leds-menf21bmc.c
@@ -0,0 +1,131 @@
1/*
2 * MEN 14F021P00 Board Management Controller (BMC) LEDs Driver.
3 *
4 * This is the core LED driver of the MEN 14F021P00 BMC.
5 * There are four LEDs available which can be switched on and off.
6 * STATUS LED, HOT SWAP LED, USER LED 1, USER LED 2
7 *
8 * Copyright (C) 2014 MEN Mikro Elektronik Nuernberg GmbH
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
16#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/platform_device.h>
19#include <linux/leds.h>
20#include <linux/i2c.h>
21
22#define BMC_CMD_LED_GET_SET 0xA0
23#define BMC_BIT_LED_STATUS BIT(0)
24#define BMC_BIT_LED_HOTSWAP BIT(1)
25#define BMC_BIT_LED_USER1 BIT(2)
26#define BMC_BIT_LED_USER2 BIT(3)
27
28struct menf21bmc_led {
29 struct led_classdev cdev;
30 u8 led_bit;
31 const char *name;
32 struct i2c_client *i2c_client;
33};
34
35static struct menf21bmc_led leds[] = {
36 {
37 .name = "menf21bmc:led_status",
38 .led_bit = BMC_BIT_LED_STATUS,
39 },
40 {
41 .name = "menf21bmc:led_hotswap",
42 .led_bit = BMC_BIT_LED_HOTSWAP,
43 },
44 {
45 .name = "menf21bmc:led_user1",
46 .led_bit = BMC_BIT_LED_USER1,
47 },
48 {
49 .name = "menf21bmc:led_user2",
50 .led_bit = BMC_BIT_LED_USER2,
51 }
52};
53
54static DEFINE_MUTEX(led_lock);
55
56static void
57menf21bmc_led_set(struct led_classdev *led_cdev, enum led_brightness value)
58{
59 int led_val;
60 struct menf21bmc_led *led = container_of(led_cdev,
61 struct menf21bmc_led, cdev);
62
63 mutex_lock(&led_lock);
64 led_val = i2c_smbus_read_byte_data(led->i2c_client,
65 BMC_CMD_LED_GET_SET);
66 if (led_val < 0)
67 goto err_out;
68
69 if (value == LED_OFF)
70 led_val &= ~led->led_bit;
71 else
72 led_val |= led->led_bit;
73
74 i2c_smbus_write_byte_data(led->i2c_client,
75 BMC_CMD_LED_GET_SET, led_val);
76err_out:
77 mutex_unlock(&led_lock);
78}
79
80static int menf21bmc_led_probe(struct platform_device *pdev)
81{
82 int i;
83 int ret;
84 struct i2c_client *i2c_client = to_i2c_client(pdev->dev.parent);
85
86 for (i = 0; i < ARRAY_SIZE(leds); i++) {
87 leds[i].cdev.name = leds[i].name;
88 leds[i].cdev.brightness_set = menf21bmc_led_set;
89 leds[i].i2c_client = i2c_client;
90 ret = led_classdev_register(&pdev->dev, &leds[i].cdev);
91 if (ret < 0)
92 goto err_free_leds;
93 }
94 dev_info(&pdev->dev, "MEN 140F21P00 BMC LED device enabled\n");
95
96 return 0;
97
98err_free_leds:
99 dev_err(&pdev->dev, "failed to register LED device\n");
100
101 for (i = i - 1; i >= 0; i--)
102 led_classdev_unregister(&leds[i].cdev);
103
104 return ret;
105}
106
107static int menf21bmc_led_remove(struct platform_device *pdev)
108{
109 int i;
110
111 for (i = 0; i < ARRAY_SIZE(leds); i++)
112 led_classdev_unregister(&leds[i].cdev);
113
114 return 0;
115}
116
117static struct platform_driver menf21bmc_led = {
118 .probe = menf21bmc_led_probe,
119 .remove = menf21bmc_led_remove,
120 .driver = {
121 .name = "menf21bmc_led",
122 .owner = THIS_MODULE,
123 },
124};
125
126module_platform_driver(menf21bmc_led);
127
128MODULE_AUTHOR("Andreas Werner <andreas.werner@men.de>");
129MODULE_DESCRIPTION("MEN 14F021P00 BMC led driver");
130MODULE_LICENSE("GPL v2");
131MODULE_ALIAS("platform:menf21bmc_led");