summaryrefslogtreecommitdiff
path: root/drivers/leds
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/Kconfig21
-rw-r--r--drivers/leds/Makefile3
-rw-r--r--drivers/leds/leds-da9052.c307
-rw-r--r--drivers/leds/leds-mc13892.c153
-rw-r--r--drivers/leds/leds-mxs-pwm.c217
5 files changed, 701 insertions, 0 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 81bf25e67ce1..196270d08960 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -33,6 +33,17 @@ config LEDS_ATMEL_PWM
This option enables support for LEDs driven using outputs
of the dedicated PWM controller found on newer Atmel SOCs.
+config LEDS_MXS
+ tristate "Support for PWM LEDs on MXS"
+ depends on LEDS_CLASS && ARCH_MXS
+ help
+ This option enables support for the LEDs connected to PWM
+ outputs on the Freescale MXS SOC.
+
+config LEDS_MC13892
+ tristate "LED Support for mc13892 pmic"
+ depends on LEDS_CLASS && MXC_MC13892_LIGHT
+
config LEDS_LOCOMO
tristate "LED Support for Locomo device"
depends on SHARP_LOCOMO
@@ -235,6 +246,16 @@ config LEDS_DA903X
This option enables support for on-chip LED drivers found
on Dialog Semiconductor DA9030/DA9034 PMICs.
+config LEDS_DA9052
+ tristate "Dialog DA9052 LEDS"
+ depends on PMIC_DA9052
+ help
+ This option enables support for on-chip LED drivers found
+ on Dialog Semiconductor DA9052 PMICs.
+
+ To compile this driver as a module, choose M here: the
+ module will be called leds-da9052.
+
config LEDS_DAC124S085
tristate "LED Support for DAC124S085 SPI DAC"
depends on SPI
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 2493de499374..8285efc54a03 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o
obj-$(CONFIG_LEDS_88PM860X) += leds-88pm860x.o
obj-$(CONFIG_LEDS_ATMEL_PWM) += leds-atmel-pwm.o
obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o
+obj-$(CONFIG_LEDS_MC13892) += leds-mc13892.o
obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o
obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o
obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
@@ -28,6 +29,7 @@ obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o
obj-$(CONFIG_LEDS_FSG) += leds-fsg.o
obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o
obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o
+obj-$(CONFIG_LEDS_DA9052) += leds-da9052.o
obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o
obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o
obj-$(CONFIG_LEDS_PWM) += leds-pwm.o
@@ -37,6 +39,7 @@ obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o
obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o
obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o
obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o
+obj-$(CONFIG_LEDS_MXS) += leds-mxs-pwm.o
# LED SPI Drivers
obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
diff --git a/drivers/leds/leds-da9052.c b/drivers/leds/leds-da9052.c
new file mode 100644
index 000000000000..187d4d2372e0
--- /dev/null
+++ b/drivers/leds/leds-da9052.c
@@ -0,0 +1,307 @@
+/*
+ * leds-da9052.c -- LED Driver for Dialog DA9052
+ *
+ * Copyright(c) 2009 Dialog Semiconductor Ltd.
+ *
+ * Author: Dialog Semiconductor Ltd <dchen@diasemi.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; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/leds.h>
+#include <linux/workqueue.h>
+#include <linux/slab.h>
+
+#include <linux/mfd/da9052/reg.h>
+#include <linux/mfd/da9052/da9052.h>
+#include <linux/mfd/da9052/led.h>
+
+#define DRIVER_NAME "da9052-leds"
+
+#define DA9052_LED4_PRESENT 1
+#define DA9052_LED5_PRESENT 1
+
+
+struct da9052_led_data {
+ struct led_classdev cdev;
+ struct work_struct work;
+ struct da9052 *da9052;
+ int id;
+ int new_brightness;
+ int is_led4_present;
+ int is_led5_present;
+};
+
+#define GPIO14_PIN 2 /* GPO Open Drain */
+#define GPIO14_TYPE 0 /* VDD_IO1 */
+#define GPIO14_MODE 1 /* Output High */
+
+#define GPIO15_PIN 2 /* GPO Open Drain */
+#define GPIO15_TYPE 0 /* VDD_IO1 */
+#define GPIO15_MODE 1 /* Output High */
+
+#define MAXIMUM_PWM 95
+#define MASK_GPIO14 0x0F
+#define MASK_GPIO15 0xF0
+#define GPIO15_PIN_BIT_POSITION 4
+
+static void da9052_led_work(struct work_struct *work)
+{
+ struct da9052_led_data *led = container_of(work,
+ struct da9052_led_data, work);
+ int reg = 0;
+ int led_dim_bit = 0;
+ struct da9052_ssc_msg msg;
+ int ret = 0;
+
+ switch (led->id) {
+ case DA9052_LED_4:
+ reg = DA9052_LED4CONT_REG;
+ led_dim_bit = DA9052_LED4CONT_LED4DIM;
+ break;
+ case DA9052_LED_5:
+ reg = DA9052_LED5CONT_REG;
+ led_dim_bit = DA9052_LED5CONT_LED5DIM;
+ break;
+ }
+
+ if (led->new_brightness > MAXIMUM_PWM)
+ led->new_brightness = MAXIMUM_PWM;
+
+ /* Always enable DIM feature
+ * This feature can be disabled if required
+ */
+ msg.addr = reg;
+ msg.data = led->new_brightness | led_dim_bit;
+ da9052_lock(led->da9052);
+ ret = led->da9052->write(led->da9052, &msg);
+ if (ret) {
+ da9052_unlock(led->da9052);
+ return;
+ }
+ da9052_unlock(led->da9052);
+}
+
+static void da9052_led_set(struct led_classdev *led_cdev,
+ enum led_brightness value)
+{
+ struct da9052_led_data *led;
+
+ led = container_of(led_cdev, struct da9052_led_data, cdev);
+ led->new_brightness = value;
+ schedule_work(&led->work);
+}
+
+static int __devinit da9052_led_setup(struct da9052_led_data *led)
+{
+ int reg = 0;
+ int ret = 0;
+
+ struct da9052_ssc_msg msg;
+
+ switch (led->id) {
+ case DA9052_LED_4:
+ reg = DA9052_LED4CONT_REG;
+ break;
+ case DA9052_LED_5:
+ reg = DA9052_LED5CONT_REG;
+ break;
+ }
+
+ msg.addr = reg;
+ msg.data = 0;
+
+ da9052_lock(led->da9052);
+ ret = led->da9052->write(led->da9052, &msg);
+ if (ret) {
+ da9052_unlock(led->da9052);
+ return ret;
+ }
+ da9052_unlock(led->da9052);
+ return ret;
+}
+
+static int da9052_leds_prepare(struct da9052_led_data *led)
+{
+ int ret = 0;
+ struct da9052_ssc_msg msg;
+
+ da9052_lock(led->da9052);
+
+ if (1 == led->is_led4_present) {
+ msg.addr = DA9052_GPIO1415_REG;
+ msg.data = 0;
+
+ ret = led->da9052->read(led->da9052, &msg);
+ if (ret)
+ goto out;
+ msg.data = msg.data & ~(MASK_GPIO14);
+ msg.data = msg.data | (
+ GPIO14_PIN |
+ (GPIO14_TYPE ? DA9052_GPIO1415_GPIO14TYPE : 0) |
+ (GPIO14_MODE ? DA9052_GPIO1415_GPIO14MODE : 0));
+
+ ret = led->da9052->write(led->da9052, &msg);
+ if (ret)
+ goto out;
+ }
+
+ if (1 == led->is_led5_present) {
+ msg.addr = DA9052_GPIO1415_REG;
+ msg.data = 0;
+
+ ret = led->da9052->read(led->da9052, &msg);
+ if (ret)
+ goto out;
+ msg.data = msg.data & ~(MASK_GPIO15);
+ msg.data = msg.data |
+ (((GPIO15_PIN << GPIO15_PIN_BIT_POSITION) |
+ (GPIO15_TYPE ? DA9052_GPIO1415_GPIO15TYPE : 0) |
+ (GPIO15_MODE ? DA9052_GPIO1415_GPIO15MODE : 0))
+ );
+ ret = led->da9052->write(led->da9052, &msg);
+ if (ret)
+ goto out;
+ }
+
+ da9052_unlock(led->da9052);
+ return ret;
+out:
+ da9052_unlock(led->da9052);
+ return ret;
+}
+
+static int __devinit da9052_led_probe(struct platform_device *pdev)
+{
+ struct da9052_leds_platform_data *pdata = (pdev->dev.platform_data);
+ struct da9052_led_platform_data *led_cur;
+ struct da9052_led_data *led, *led_dat;
+ int ret, i;
+ int init_led = 0;
+
+ if (pdata->num_leds < 1 || pdata->num_leds > DA9052_LED_MAX) {
+ dev_err(&pdev->dev, "Invalid led count %d\n", pdata->num_leds);
+ return -EINVAL;
+ }
+
+ led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL);
+ if (led == NULL) {
+ dev_err(&pdev->dev, "failed to alloc memory\n");
+ return -ENOMEM;
+ }
+
+ led->is_led4_present = DA9052_LED4_PRESENT;
+ led->is_led5_present = DA9052_LED5_PRESENT;
+
+ for (i = 0; i < pdata->num_leds; i++) {
+ led_dat = &led[i];
+ led_cur = &pdata->led[i];
+ if (led_cur->id < 0) {
+ dev_err(&pdev->dev, "invalid id %d\n", led_cur->id);
+ ret = -EINVAL;
+ goto err_register;
+ }
+
+ if (init_led & (1 << led_cur->id)) {
+ dev_err(&pdev->dev, "led %d already initialized\n",
+ led_cur->id);
+ ret = -EINVAL;
+ goto err_register;
+ }
+
+ init_led |= 1 << led_cur->id;
+
+ led_dat->cdev.name = led_cur->name;
+ // led_dat->cdev.default_trigger = led_cur[i]->default_trigger;
+ led_dat->cdev.brightness_set = da9052_led_set;
+ led_dat->cdev.brightness = LED_OFF;
+ led_dat->id = led_cur->id;
+ led_dat->da9052 = dev_get_drvdata(pdev->dev.parent);
+
+ INIT_WORK(&led_dat->work, da9052_led_work);
+
+ ret = led_classdev_register(pdev->dev.parent, &led_dat->cdev);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to register led %d\n",
+ led_dat->id);
+ goto err_register;
+
+ }
+ ret = da9052_led_setup(led_dat);
+ if (ret) {
+ dev_err(&pdev->dev, "unable to init led %d\n",
+ led_dat->id);
+ i++;
+ goto err_register;
+ }
+ }
+ ret = da9052_leds_prepare(led);
+ if (ret) {
+ dev_err(&pdev->dev, "unable to init led driver\n");
+ goto err_free;
+ }
+
+ platform_set_drvdata(pdev, led);
+ return 0;
+
+err_register:
+ for (i = i - 1; i >= 0; i--) {
+ led_classdev_unregister(&led[i].cdev);
+ cancel_work_sync(&led[i].work);
+ }
+
+err_free:
+ kfree(led);
+ return ret;
+}
+
+static int __devexit da9052_led_remove(struct platform_device *pdev)
+{
+ struct da9052_leds_platform_data *pdata =
+ (struct da9052_leds_platform_data *)pdev->dev.platform_data;
+ struct da9052_led_data *led = platform_get_drvdata(pdev);
+ int i;
+
+ for (i = 0; i < pdata->num_leds; i++) {
+ da9052_led_setup(&led[i]);
+ led_classdev_unregister(&led[i].cdev);
+ cancel_work_sync(&led[i].work);
+ }
+
+ kfree(led);
+ return 0;
+}
+
+static struct platform_driver da9052_led_driver = {
+ .driver = {
+ .name = DRIVER_NAME,
+ .owner = THIS_MODULE,
+ },
+ .probe = da9052_led_probe,
+ .remove = __devexit_p(da9052_led_remove),
+};
+
+static int __init da9052_led_init(void)
+{
+ return platform_driver_register(&da9052_led_driver);
+}
+module_init(da9052_led_init);
+
+static void __exit da9052_led_exit(void)
+{
+ platform_driver_unregister(&da9052_led_driver);
+}
+module_exit(da9052_led_exit);
+
+MODULE_AUTHOR("Dialog Semiconductor Ltd <dchen@diasemi.com> ");
+MODULE_DESCRIPTION("LED driver for Dialog DA9052 PMIC");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:" DRIVER_NAME);
diff --git a/drivers/leds/leds-mc13892.c b/drivers/leds/leds-mc13892.c
new file mode 100644
index 000000000000..ec7ae4316b4d
--- /dev/null
+++ b/drivers/leds/leds-mc13892.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ */
+
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/slab.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/leds.h>
+#include <linux/pmic_light.h>
+
+static void mc13892_led_set(struct led_classdev *led_cdev,
+ enum led_brightness value)
+{
+ struct platform_device *dev = to_platform_device(led_cdev->dev->parent);
+ int led_ch;
+
+ switch (dev->id) {
+ case 'r':
+ led_ch = LIT_RED;
+ break;
+ case 'g':
+ led_ch = LIT_GREEN;
+ break;
+ case 'b':
+ led_ch = LIT_BLUE;
+ break;
+ default:
+ return;
+ }
+
+ /* set current with medium value, in case current is too large */
+ mc13892_bklit_set_current(led_ch, LIT_CURR_12);
+ /* max duty cycle is 63, brightness needs to be divided by 4 */
+ mc13892_bklit_set_dutycycle(led_ch, value / 4);
+
+}
+
+static int mc13892_led_remove(struct platform_device *dev)
+{
+ struct led_classdev *led_cdev = platform_get_drvdata(dev);
+
+ led_classdev_unregister(led_cdev);
+ kfree(led_cdev->name);
+ kfree(led_cdev);
+
+ return 0;
+}
+
+#define LED_NAME_LEN 16
+
+static int mc13892_led_probe(struct platform_device *dev)
+{
+ int ret;
+ struct led_classdev *led_cdev;
+ char *name;
+
+ led_cdev = kzalloc(sizeof(struct led_classdev), GFP_KERNEL);
+ if (led_cdev == NULL) {
+ dev_err(&dev->dev, "No memory for device\n");
+ return -ENOMEM;
+ }
+ name = kzalloc(LED_NAME_LEN, GFP_KERNEL);
+ if (name == NULL) {
+ dev_err(&dev->dev, "No memory for device\n");
+ ret = -ENOMEM;
+ goto exit_err;
+ }
+
+ strcpy(name, dev->name);
+ ret = strlen(dev->name);
+ if (ret > LED_NAME_LEN - 2) {
+ dev_err(&dev->dev, "led name is too long\n");
+ goto exit_err1;
+ }
+ name[ret] = dev->id;
+ name[ret + 1] = '\0';
+ led_cdev->name = name;
+ led_cdev->brightness_set = mc13892_led_set;
+
+ ret = led_classdev_register(&dev->dev, led_cdev);
+ if (ret < 0) {
+ dev_err(&dev->dev, "led_classdev_register failed\n");
+ goto exit_err1;
+ }
+
+ platform_set_drvdata(dev, led_cdev);
+
+ return 0;
+ exit_err1:
+ kfree(led_cdev->name);
+ exit_err:
+ kfree(led_cdev);
+ return ret;
+}
+
+#ifdef CONFIG_PM
+static int mc13892_led_suspend(struct platform_device *dev, pm_message_t state)
+{
+ struct led_classdev *led_cdev = platform_get_drvdata(dev);
+
+ led_classdev_suspend(led_cdev);
+ return 0;
+}
+
+static int mc13892_led_resume(struct platform_device *dev)
+{
+ struct led_classdev *led_cdev = platform_get_drvdata(dev);
+
+ led_classdev_resume(led_cdev);
+ return 0;
+}
+#else
+#define mc13892_led_suspend NULL
+#define mc13892_led_resume NULL
+#endif
+
+static struct platform_driver mc13892_led_driver = {
+ .probe = mc13892_led_probe,
+ .remove = mc13892_led_remove,
+ .suspend = mc13892_led_suspend,
+ .resume = mc13892_led_resume,
+ .driver = {
+ .name = "pmic_leds",
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init mc13892_led_init(void)
+{
+ return platform_driver_register(&mc13892_led_driver);
+}
+
+static void __exit mc13892_led_exit(void)
+{
+ platform_driver_unregister(&mc13892_led_driver);
+}
+
+module_init(mc13892_led_init);
+module_exit(mc13892_led_exit);
+
+MODULE_DESCRIPTION("Led driver for PMIC mc13892");
+MODULE_AUTHOR("Freescale Semiconductor, Inc.");
+MODULE_LICENSE("GPL");
diff --git a/drivers/leds/leds-mxs-pwm.c b/drivers/leds/leds-mxs-pwm.c
new file mode 100644
index 000000000000..a546900a44d0
--- /dev/null
+++ b/drivers/leds/leds-mxs-pwm.c
@@ -0,0 +1,217 @@
+/*
+ * Freescale MXS PWM LED driver
+ *
+ * Author: Drew Benedetti <drewb@embeddedalley.com>
+ *
+ * Copyright 2008-2010 Freescale Semiconductor, Inc.
+ * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
+ */
+
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/leds.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/clk.h>
+
+#include <mach/hardware.h>
+#include <mach/system.h>
+#include <mach/device.h>
+#include <mach/regs-pwm.h>
+
+
+/*
+ * PWM enables are the lowest bits of HW_PWM_CTRL register
+ */
+#define BM_PWM_CTRL_PWM_ENABLE ((1<<(CONFIG_MXS_PWM_CHANNELS)) - 1)
+#define BF_PWM_CTRL_PWM_ENABLE(n) ((1<<(n)) & BM_PWM_CTRL_PWM_ENABLE)
+
+#define BF_PWM_PERIODn_SETTINGS \
+ (BF_PWM_PERIODn_CDIV(5) | /* divide by 64 */ \
+ BF_PWM_PERIODn_INACTIVE_STATE(3) | /* low */ \
+ BF_PWM_PERIODn_ACTIVE_STATE(2) | /* high */ \
+ BF_PWM_PERIODn_PERIOD(LED_FULL)) /* 255 cycles */
+
+struct mxs_pwm_leds {
+ struct clk *pwm_clk;
+ unsigned int base;
+ unsigned int led_num;
+ struct mxs_pwm_led *leds;
+};
+
+static struct mxs_pwm_leds leds;
+
+static void mxs_pwm_led_brightness_set(struct led_classdev *pled,
+ enum led_brightness value)
+{
+ struct mxs_pwm_led *pwm_led;
+
+ pwm_led = container_of(pled, struct mxs_pwm_led, dev);
+
+ if (pwm_led->pwm < CONFIG_MXS_PWM_CHANNELS) {
+ __raw_writel(BF_PWM_CTRL_PWM_ENABLE(pwm_led->pwm),
+ leds.base + HW_PWM_CTRL_CLR);
+ __raw_writel(BF_PWM_ACTIVEn_INACTIVE(LED_FULL) |
+ BF_PWM_ACTIVEn_ACTIVE(value),
+ leds.base + HW_PWM_ACTIVEn(pwm_led->pwm));
+ __raw_writel(BF_PWM_PERIODn_SETTINGS,
+ leds.base + HW_PWM_PERIODn(pwm_led->pwm));
+ __raw_writel(BF_PWM_CTRL_PWM_ENABLE(pwm_led->pwm),
+ leds.base + HW_PWM_CTRL_SET);
+ }
+}
+
+static int __devinit mxs_pwm_led_probe(struct platform_device *pdev)
+{
+ struct mxs_pwm_leds_plat_data *plat_data;
+ struct resource *res;
+ struct led_classdev *led;
+ unsigned int pwmn;
+ int leds_in_use = 0, rc = 0;
+ int i;
+
+ plat_data = (struct mxs_pwm_leds_plat_data *)pdev->dev.platform_data;
+ if (plat_data == NULL)
+ return -ENODEV;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (res == NULL)
+ return -ENODEV;
+ leds.base = (unsigned int)IO_ADDRESS(res->start);
+
+ mxs_reset_block((void __iomem *)leds.base, 1);
+
+ leds.led_num = plat_data->num;
+ if (leds.led_num <= 0 || leds.led_num > CONFIG_MXS_PWM_CHANNELS)
+ return -EFAULT;
+ leds.leds = plat_data->leds;
+ if (leds.leds == NULL)
+ return -EFAULT;
+
+ leds.pwm_clk = clk_get(&pdev->dev, "pwm");
+ if (IS_ERR(leds.pwm_clk)) {
+ rc = PTR_ERR(leds.pwm_clk);
+ return rc;
+ }
+
+ clk_enable(leds.pwm_clk);
+
+ for (i = 0; i < leds.led_num; i++) {
+ pwmn = leds.leds[i].pwm;
+ if (pwmn >= CONFIG_MXS_PWM_CHANNELS) {
+ dev_err(&pdev->dev,
+ "[led-pwm%d]:PWM %d doesn't exist\n",
+ i, pwmn);
+ continue;
+ }
+ led = &(leds.leds[i].dev);
+ led->name = leds.leds[i].name;
+ led->brightness = LED_HALF;
+ led->flags = 0;
+ led->brightness_set = mxs_pwm_led_brightness_set;
+ led->default_trigger = 0;
+
+ rc = led_classdev_register(&pdev->dev, led);
+ if (rc < 0) {
+ dev_err(&pdev->dev,
+ "Unable to register LED device %d (err=%d)\n",
+ i, rc);
+ continue;
+ }
+
+ leds_in_use++;
+
+ /* Set default brightness */
+ mxs_pwm_led_brightness_set(led, LED_HALF);
+ }
+
+ if (leds_in_use == 0) {
+ dev_info(&pdev->dev, "No PWM LEDs available\n");
+ clk_disable(leds.pwm_clk);
+ clk_put(leds.pwm_clk);
+ return -ENODEV;
+ }
+ return 0;
+}
+
+static int __devexit mxs_pwm_led_remove(struct platform_device *pdev)
+{
+ int i;
+ unsigned int pwm;
+ for (i = 0; i < leds.led_num; i++) {
+ pwm = leds.leds[i].pwm;
+ __raw_writel(BF_PWM_CTRL_PWM_ENABLE(pwm),
+ leds.base + HW_PWM_CTRL_CLR);
+ __raw_writel(BF_PWM_ACTIVEn_INACTIVE(0) |
+ BF_PWM_ACTIVEn_ACTIVE(0),
+ leds.base + HW_PWM_ACTIVEn(pwm));
+ __raw_writel(BF_PWM_PERIODn_SETTINGS,
+ leds.base + HW_PWM_PERIODn(pwm));
+ led_classdev_unregister(&leds.leds[i].dev);
+ }
+
+ clk_disable(leds.pwm_clk);
+ clk_put(leds.pwm_clk);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static int mxs_led_suspend(struct platform_device *dev, pm_message_t state)
+{
+ int i;
+
+ for (i = 0; i < leds.led_num; i++)
+ led_classdev_suspend(&leds.leds[i].dev);
+ return 0;
+}
+
+static int mxs_led_resume(struct platform_device *dev)
+{
+ int i;
+
+ for (i = 0; i < leds.led_num; i++)
+ led_classdev_resume(&leds.leds[i].dev);
+ return 0;
+}
+#else
+#define mxs_led_suspend NULL
+#define mxs_led_resume NULL
+#endif
+
+
+static struct platform_driver mxs_pwm_led_driver = {
+ .probe = mxs_pwm_led_probe,
+ .remove = __devexit_p(mxs_pwm_led_remove),
+ .suspend = mxs_led_suspend,
+ .resume = mxs_led_resume,
+ .driver = {
+ .name = "mxs-leds",
+ },
+};
+
+static int __init mxs_pwm_led_init(void)
+{
+ return platform_driver_register(&mxs_pwm_led_driver);
+}
+
+static void __exit mxs_pwm_led_exit(void)
+{
+ platform_driver_unregister(&mxs_pwm_led_driver);
+}
+
+module_init(mxs_pwm_led_init);
+module_exit(mxs_pwm_led_exit);
+
+MODULE_AUTHOR("Drew Benedetti <drewb@embeddedalley.com>");
+MODULE_DESCRIPTION("mxs PWM LED driver");
+MODULE_LICENSE("GPL");