diff options
-rw-r--r-- | drivers/leds/Kconfig | 6 | ||||
-rw-r--r-- | drivers/leds/Makefile | 1 | ||||
-rw-r--r-- | drivers/leds/leds-max77660.c | 95 | ||||
-rw-r--r-- | include/linux/mfd/max77660/max77660-core.h | 10 |
4 files changed, 112 insertions, 0 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index f6c6a5875d67..ae9296696316 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -24,6 +24,12 @@ config LEDS_CLASS comment "LED drivers" +config LEDS_MAX77660 + tristate "LED Support for Maxim MAX77660" + depends on LEDS_CLASS || MFD_MAX77660 + help + This option enables the led support for Maxim PMIC MAX77660. + config LEDS_MAX8831 tristate "LED Support for Maxim MAX8831" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 22fc59fa8b2a..7472b7521ec9 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -53,6 +53,7 @@ obj-$(CONFIG_LEDS_NS2) += leds-ns2.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o +obj-$(CONFIG_LEDS_MAX77660) += leds-max77660.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_LM355x) += leds-lm355x.o obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o diff --git a/drivers/leds/leds-max77660.c b/drivers/leds/leds-max77660.c new file mode 100644 index 000000000000..3680436c95b4 --- /dev/null +++ b/drivers/leds/leds-max77660.c @@ -0,0 +1,95 @@ +/* + * leds-max77660.c -- MAXIM MAX77660 led driver. + * + * Copyright (c) 2013, NVIDIA Corporation. + * + * Author: Laxman Dewangan <ldewangan@nvidia.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, + * whether express or implied; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA + */ +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/delay.h> +#include <linux/pm.h> +#include <linux/mfd/max77660/max77660-core.h> + +struct max77660_leds { + struct device *dev; + struct device *parent; +}; + +static int max77660_disable_leds(struct max77660_leds *leds) +{ + int ret; + + /* Disable LED driver by default */ + ret = max77660_reg_write(leds->parent, MAX77660_PWR_SLAVE, + MAX77660_REG_LEDEN, 0x80); + if (ret < 0) { + dev_err(leds->dev, "LED write failed: %d\n", ret); + return ret; + } + + ret = max77660_reg_write(leds->parent, MAX77660_PWR_SLAVE, + MAX77660_REG_LEDBLNK, 0x0); + if (ret < 0) { + dev_err(leds->dev, "LEDBLNK write failed: %d\n", ret); + return ret; + } + return 0; +} + +static int max77660_leds_probe(struct platform_device *pdev) +{ + struct max77660_leds *leds; + struct max77660_platform_data *pdata; + int ret = 0; + + pdata = dev_get_platdata(pdev->dev.parent); + if (!pdata) { + dev_err(&pdev->dev, "No Platform data\n"); + return -EINVAL; + } + + leds = devm_kzalloc(&pdev->dev, sizeof(*leds), GFP_KERNEL); + if (!leds) { + dev_err(&pdev->dev, "Memory allocation failed for leds\n"); + return -ENOMEM; + } + + leds->dev = &pdev->dev; + leds->parent = pdev->dev.parent; + dev_set_drvdata(&pdev->dev, leds); + + if (pdata->led_disable) + ret = max77660_disable_leds(leds); + return ret; +} + +static struct platform_driver max77660_leds_driver = { + .probe = max77660_leds_probe, + .driver = { + .name = "max77660-leds", + .owner = THIS_MODULE, + }, +}; + +module_platform_driver(max77660_leds_driver); + +MODULE_DESCRIPTION("max77660 LEDs driver"); +MODULE_AUTHOR("Laxman Dewangan<ldewangan@nvidia.com>"); +MODULE_ALIAS("platform:max77660-leds"); +MODULE_LICENSE("GPL v2"); diff --git a/include/linux/mfd/max77660/max77660-core.h b/include/linux/mfd/max77660/max77660-core.h index 2df7b04f5ba6..346b035e02c1 100644 --- a/include/linux/mfd/max77660/max77660-core.h +++ b/include/linux/mfd/max77660/max77660-core.h @@ -119,6 +119,14 @@ #define MAX77660_REG_AME1_GPIO 0x78 #define MAX77660_REG_AME2_GPIO 0x78 +/* LED controls */ +#define MAX77660_REG_LEDEN 0x94 +#define MAX77660_REG_LED0BRT 0x95 +#define MAX77660_REG_LED1BRT 0x96 +#define MAX77660_REG_LED2BRT 0x97 +#define MAX77660_REG_LED3BRT 0x98 +#define MAX77660_REG_LEDBLNK 0x99 + #if 0 #define MAX77660_REG_GPIO_PU 0x3E #define MAX77660_REG_GPIO_PD 0x3F @@ -565,6 +573,7 @@ struct max77660_gpio_config { * @num_pinctrl: Number of pin control data. * @system_watchdog_timeout: System wathdog timeout in seconds. If this value * is -ve then timer will not start during initialisation. + * led_disable: Disable LEDs. */ struct max77660_platform_data { @@ -595,6 +604,7 @@ struct max77660_platform_data { bool use_power_off; int system_watchdog_timeout; + bool led_disable; }; enum max77660_i2c_slave { |