From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lee Jones Subject: Re: [PATCH v6 3/4] drivers/leds/leds-menf21bmc: introduce MEN 14F021P00 BMC LED driver Date: Fri, 29 Aug 2014 11:59:13 +0100 Message-ID: <20140829105913.GI24579@lee--X1> References: <20140829065915.GZ24579@lee--X1> <20140829113815.GA30736@awelinux> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Received: from mail-ig0-f171.google.com ([209.85.213.171]:50903 "EHLO mail-ig0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751944AbaH2K7U (ORCPT ); Fri, 29 Aug 2014 06:59:20 -0400 Received: by mail-ig0-f171.google.com with SMTP id l13so9455108iga.16 for ; Fri, 29 Aug 2014 03:59:19 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20140829113815.GA30736@awelinux> Sender: linux-leds-owner@vger.kernel.org List-Id: linux-leds@vger.kernel.org To: Andreas Werner Cc: Bryan Wu , lkml , Samuel Ortiz , linux@roeck-us.net, lm-sensors@lm-sensors.org, wim@iguana.be, linux-watchdog@vger.kernel.org, "rpurdie@rpsys.net" , Linux LED Subsystem On Fri, 29 Aug 2014, Andreas Werner wrote: > On Fri, Aug 29, 2014 at 07:59:15AM +0100, Lee Jones wrote: > > On Thu, 28 Aug 2014, Bryan Wu wrote: > >=20 > > > On Wed, Aug 27, 2014 at 10:52 AM, Andreas Werner wrote: > > > > Added driver to support the 14F021P00 BMC LEDs. > > > > The BMC is a Board Management Controller including four LEDs wh= ich > > > > can be switched on and off. > > > > > > >=20 > > > Please go ahead with my Ack > > > Acked-by: Bryan Wu > > >=20 > > > Lee, will you merge this through your tree? I think we do that in= one > > > shot is better. > >=20 > > Yes, that's fine. Pull-request to follow. > >=20 >=20 > Thanks to all for review. >=20 > Who of you does the Watchdog part? Is it the part of Wim to Ack the p= atch > if everythings is right or Guenther? Wim looks like the guy: WATCHDOG DEVICE DRIVERS M: Wim Van Sebroeck L: linux-watchdog@vger.kernel.org W: http://www.linux-watchdog.org/ T: git git://www.linux-watchdog.org/linux-watchdog.git S: Maintained =46: Documentation/watchdog/ =46: drivers/watchdog/ =46: include/linux/watchdog.h =46: include/uapi/linux/watchdog.h > I ask because if everything is ok all the patches can go in completly= that would > be nice. That is the plan. > > > > Signed-off-by: Andreas Werner > > > > --- > > > > drivers/leds/Kconfig | 9 +++ > > > > drivers/leds/Makefile | 1 + > > > > drivers/leds/leds-menf21bmc.c | 131 ++++++++++++++++++++++++++= ++++++++++++++++ > > > > 3 files changed, 141 insertions(+) > > > > create mode 100644 drivers/leds/leds-menf21bmc.c > > > > > > > > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig > > > > index 27cf0cd..ec03457 100644 > > > > --- a/drivers/leds/Kconfig > > > > +++ b/drivers/leds/Kconfig > > > > @@ -458,6 +458,15 @@ config LEDS_OT200 > > > > This option enables support for the LEDs on the Bachm= ann OT200. > > > > Say Y to enable LEDs on the Bachmann OT200. > > > > > > > > +config LEDS_MENF21BMC > > > > + tristate "LED support for the MEN 14F021P00 BMC" > > > > + depends on LEDS_CLASS && MFD_MENF21BMC > > > > + help > > > > + Say Y here to include support for the MEN 14F021P00 B= MC LEDs. > > > > + > > > > + This driver can also be built as a module. If so the = module > > > > + will be called leds-menf21bmc. > > > > + > > > > comment "LED driver for blink(1) USB RGB LED is under Special = HID drivers (HID_THINGM)" > > > > > > > > config LEDS_BLINKM > > > > diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile > > > > index 3c03666..cadc433 100644 > > > > --- a/drivers/leds/Makefile > > > > +++ b/drivers/leds/Makefile > > > > @@ -53,6 +53,7 @@ obj-$(CONFIG_LEDS_MAX8997) +=3D le= ds-max8997.o > > > > obj-$(CONFIG_LEDS_LM355x) +=3D leds-lm355x.o > > > > obj-$(CONFIG_LEDS_BLINKM) +=3D leds-blinkm.o > > > > obj-$(CONFIG_LEDS_VERSATILE) +=3D leds-versatile.o > > > > +obj-$(CONFIG_LEDS_MENF21BMC) +=3D leds-menf21bmc.o > > > > > > > > # LED SPI Drivers > > > > obj-$(CONFIG_LEDS_DAC124S085) +=3D leds-dac124s085.o > > > > diff --git a/drivers/leds/leds-menf21bmc.c b/drivers/leds/leds-= menf21bmc.c > > > > new file mode 100644 > > > > index 0000000..89dd577 > > > > --- /dev/null > > > > +++ b/drivers/leds/leds-menf21bmc.c > > > > @@ -0,0 +1,131 @@ > > > > +/* > > > > + * MEN 14F021P00 Board Management Controller (BMC) LEDs Drive= r. > > > > + * > > > > + * This is the core LED driver of the MEN 14F021P00 BMC. > > > > + * There are four LEDs available which can be switched on and= off. > > > > + * STATUS LED, HOT SWAP LED, USER LED 1, USER LED 2 > > > > + * > > > > + * Copyright (C) 2014 MEN Mikro Elektronik Nuernberg GmbH > > > > + * > > > > + * This program is free software; you can redistribute it an= d/or modify it > > > > + * under the terms of the GNU General Public License as pu= blished by the > > > > + * Free Software Foundation; either version 2 of the Licens= e, or (at your > > > > + * option) any later version. > > > > + */ > > > > + > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > + > > > > +#define BMC_CMD_LED_GET_SET 0xA0 > > > > +#define BMC_BIT_LED_STATUS BIT(0) > > > > +#define BMC_BIT_LED_HOTSWAP BIT(1) > > > > +#define BMC_BIT_LED_USER1 BIT(2) > > > > +#define BMC_BIT_LED_USER2 BIT(3) > > > > + > > > > +struct menf21bmc_led { > > > > + struct led_classdev cdev; > > > > + u8 led_bit; > > > > + const char *name; > > > > + struct i2c_client *i2c_client; > > > > +}; > > > > + > > > > +static struct menf21bmc_led leds[] =3D { > > > > + { > > > > + .name =3D "menf21bmc:led_status", > > > > + .led_bit =3D BMC_BIT_LED_STATUS, > > > > + }, > > > > + { > > > > + .name =3D "menf21bmc:led_hotswap", > > > > + .led_bit =3D BMC_BIT_LED_HOTSWAP, > > > > + }, > > > > + { > > > > + .name =3D "menf21bmc:led_user1", > > > > + .led_bit =3D BMC_BIT_LED_USER1, > > > > + }, > > > > + { > > > > + .name =3D "menf21bmc:led_user2", > > > > + .led_bit =3D BMC_BIT_LED_USER2, > > > > + } > > > > +}; > > > > + > > > > +static DEFINE_MUTEX(led_lock); > > > > + > > > > +static void > > > > +menf21bmc_led_set(struct led_classdev *led_cdev, enum led_brig= htness value) > > > > +{ > > > > + int led_val; > > > > + struct menf21bmc_led *led =3D container_of(led_cdev, > > > > + struct menf21bmc_led, c= dev); > > > > + > > > > + mutex_lock(&led_lock); > > > > + led_val =3D i2c_smbus_read_byte_data(led->i2c_client, > > > > + BMC_CMD_LED_GET_SET)= ; > > > > + if (led_val < 0) > > > > + goto err_out; > > > > + > > > > + if (value =3D=3D LED_OFF) > > > > + led_val &=3D ~led->led_bit; > > > > + else > > > > + led_val |=3D led->led_bit; > > > > + > > > > + i2c_smbus_write_byte_data(led->i2c_client, > > > > + BMC_CMD_LED_GET_SET, led_val)= ; > > > > +err_out: > > > > + mutex_unlock(&led_lock); > > > > +} > > > > + > > > > +static int menf21bmc_led_probe(struct platform_device *pdev) > > > > +{ > > > > + int i; > > > > + int ret; > > > > + struct i2c_client *i2c_client =3D to_i2c_client(pdev->d= ev.parent); > > > > + > > > > + for (i =3D 0; i < ARRAY_SIZE(leds); i++) { > > > > + leds[i].cdev.name =3D leds[i].name; > > > > + leds[i].cdev.brightness_set =3D menf21bmc_led_s= et; > > > > + leds[i].i2c_client =3D i2c_client; > > > > + ret =3D led_classdev_register(&pdev->dev, &leds= [i].cdev); > > > > + if (ret < 0) > > > > + goto err_free_leds; > > > > + } > > > > + dev_info(&pdev->dev, "MEN 140F21P00 BMC LED device enab= led\n"); > > > > + > > > > + return 0; > > > > + > > > > +err_free_leds: > > > > + dev_err(&pdev->dev, "failed to register LED device\n"); > > > > + > > > > + for (i =3D i - 1; i >=3D 0; i--) > > > > + led_classdev_unregister(&leds[i].cdev); > > > > + > > > > + return ret; > > > > +} > > > > + > > > > +static int menf21bmc_led_remove(struct platform_device *pdev) > > > > +{ > > > > + int i; > > > > + > > > > + for (i =3D 0; i < ARRAY_SIZE(leds); i++) > > > > + led_classdev_unregister(&leds[i].cdev); > > > > + > > > > + return 0; > > > > +} > > > > + > > > > +static struct platform_driver menf21bmc_led =3D { > > > > + .probe =3D menf21bmc_led_probe, > > > > + .remove =3D menf21bmc_led_remove, > > > > + .driver =3D { > > > > + .name =3D "menf21bmc_led", > > > > + .owner =3D THIS_MODULE, > > > > + }, > > > > +}; > > > > + > > > > +module_platform_driver(menf21bmc_led); > > > > + > > > > +MODULE_AUTHOR("Andreas Werner "); > > > > +MODULE_DESCRIPTION("MEN 14F021P00 BMC led driver"); > > > > +MODULE_LICENSE("GPL v2"); > > > > +MODULE_ALIAS("platform:menf21bmc_led"); > > > > > >=20 --=20 Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org =E2=94=82 Open source software for ARM SoCs =46ollow Linaro: Facebook | Twitter | Blog