summaryrefslogtreecommitdiff
path: root/drivers/leds
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2013-01-28 12:29:44 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2013-09-14 12:58:35 -0700
commitef32a3bd284f3b4e6de465c0d787c9007296df67 (patch)
tree722500b199fb30295add807d080f5bf4ec10134d /drivers/leds
parenta36df73d2eb68adfcabbd0218722abd40fd76615 (diff)
led: max77660: add led driver
Add very basic led driver to disable leds for max77660. Change-Id: I658308ad402157cf78728afa78470a9a9e8423d4 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-on: http://git-master/r/194533
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/Kconfig6
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-max77660.c95
3 files changed, 102 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");