From: Milo Kim <milo.kim@ti.com> To: <devicetree@vger.kernel.org>, <lee.jones@linaro.org>, <linux-kernel@vger.kernel.org> Cc: Milo Kim <milo.kim@ti.com>, Jingoo Han <jingoohan1@gmail.com> Subject: [PATCH RESEND 12/16] backlight: ti-lmu-backlight: add LM3695 driver Date: Mon, 2 Nov 2015 14:24:31 +0900 [thread overview] Message-ID: <1446441875-1256-13-git-send-email-milo.kim@ti.com> (raw) In-Reply-To: <1446441875-1256-1-git-send-email-milo.kim@ti.com> LM3695 has 2 backlight strings and 11 bit dimming is supported. Common backlight driver is controlled by TI LMU backlight driver. Only LM3695 specific code is implemented here. Cc: Jingoo Han <jingoohan1@gmail.com> Cc: Lee Jones <lee.jones@linaro.org> Cc: linux-kernel@vger.kernel.org Signed-off-by: Milo Kim <milo.kim@ti.com> --- drivers/video/backlight/Kconfig | 8 ++++ drivers/video/backlight/Makefile | 1 + drivers/video/backlight/lm3695_bl.c | 91 +++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 drivers/video/backlight/lm3695_bl.c diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index e3c4adb..c1dc908 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -426,6 +426,14 @@ config BACKLIGHT_LM3633 Up to 3 backlight strings and 11 bit dimming is supported. PWM brightness control is also supported. +config BACKLIGHT_LM3695 + tristate "Backlight driver for TI LM3695" + depends on BACKLIGHT_CLASS_DEVICE && MFD_TI_LMU + select TI_LMU_BACKLIGHT + help + Say Y to enable the backlight driver for TI LM3695. + Up to 2 backlight strings and 11 bit dimming is supported. + config TI_LMU_BACKLIGHT tristate "Backlight driver for TI LMU" depends on BACKLIGHT_LM3532 || BACKLIGHT_LM3631 || \ diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 364b854..af20285 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile @@ -43,6 +43,7 @@ obj-$(CONFIG_BACKLIGHT_LM3631) += lm3631_bl.o obj-$(CONFIG_BACKLIGHT_LM3632) += lm3632_bl.o obj-$(CONFIG_BACKLIGHT_LM3633) += lm3633_bl.o obj-$(CONFIG_BACKLIGHT_LM3639) += lm3639_bl.o +obj-$(CONFIG_BACKLIGHT_LM3695) += lm3695_bl.o obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o obj-$(CONFIG_BACKLIGHT_LP8788) += lp8788_bl.o diff --git a/drivers/video/backlight/lm3695_bl.c b/drivers/video/backlight/lm3695_bl.c new file mode 100644 index 0000000..fe47d00 --- /dev/null +++ b/drivers/video/backlight/lm3695_bl.c @@ -0,0 +1,91 @@ +/* + * TI LM3695 Backlight Driver + * + * Copyright 2015 Texas Instruments + * + * Author: Milo Kim <milo.kim@ti.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/delay.h> +#include <linux/kernel.h> +#include <linux/mfd/ti-lmu.h> +#include <linux/mfd/ti-lmu-register.h> +#include <linux/module.h> + +#include "ti-lmu-backlight.h" + +#define LM3695_FULL_STRINGS (LMU_HVLED1 | LMU_HVLED2) +#define LM3695_MAX_BRIGHTNESS 2047 + +static int lm3695_bl_enable(struct ti_lmu_bl *lmu_bl, int enable) +{ + int ret; + + ret = ti_lmu_update_bits(lmu_bl->chip->lmu, LM3695_REG_GP, + LM3695_BL_EN_MASK, enable); + if (ret) + return ret; + + /* Wait time for brightness register wake up */ + usleep_range(600, 700); + + return 0; +} + +static int lm3695_bl_set_brightness(struct ti_lmu_bl *lmu_bl, int brightness) +{ + u8 data; + int ret; + + data = brightness & LM3695_BRT_LSB_MASK; + ret = ti_lmu_update_bits(lmu_bl->chip->lmu, LM3695_REG_BRT_LSB, + LM3695_BRT_LSB_MASK, data); + if (ret) + return ret; + + data = (brightness >> LM3695_BRT_MSB_SHIFT) & 0xFF; + return ti_lmu_write_byte(lmu_bl->chip->lmu, LM3695_REG_BRT_MSB, + data); +} + +static int lm3695_bl_init(struct ti_lmu_bl_chip *chip) +{ + return ti_lmu_update_bits(chip->lmu, LM3695_REG_GP, + LM3695_BRT_RW_MASK, LM3695_BRT_RW_MASK); +} + +static int lm3695_bl_configure(struct ti_lmu_bl *lmu_bl) +{ + u8 val; + + if (lmu_bl->bl_string == LM3695_FULL_STRINGS) + val = LM3695_BL_TWO_STRINGS; + else + val = LM3695_BL_ONE_STRING; + + return ti_lmu_update_bits(lmu_bl->chip->lmu, LM3695_REG_GP, + LM3695_BL_STRING_MASK, val); +} + +static const struct ti_lmu_bl_ops lm3695_lmu_ops = { + .init = lm3695_bl_init, + .configure = lm3695_bl_configure, + .update_brightness = lm3695_bl_set_brightness, + .bl_enable = lm3695_bl_enable, + .max_brightness = LM3695_MAX_BRIGHTNESS, +}; + +/* LM3695 backlight of_device_id */ +TI_LMU_BL_OF_DEVICE(lm3695, "ti,lm3695-backlight"); + +/* LM3695 backlight platform driver */ +TI_LMU_BL_PLATFORM_DRIVER(lm3695, "lm3695-backlight"); + +MODULE_DESCRIPTION("TI LM3695 Backlight Driver"); +MODULE_AUTHOR("Milo Kim"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:lm3695-backlight"); -- 1.9.1
WARNING: multiple messages have this Message-ID (diff)
From: Milo Kim <milo.kim-l0cyMroinI0@public.gmane.org> To: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Milo Kim <milo.kim-l0cyMroinI0@public.gmane.org>, Jingoo Han <jingoohan1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Subject: [PATCH RESEND 12/16] backlight: ti-lmu-backlight: add LM3695 driver Date: Mon, 2 Nov 2015 14:24:31 +0900 [thread overview] Message-ID: <1446441875-1256-13-git-send-email-milo.kim@ti.com> (raw) In-Reply-To: <1446441875-1256-1-git-send-email-milo.kim-l0cyMroinI0@public.gmane.org> LM3695 has 2 backlight strings and 11 bit dimming is supported. Common backlight driver is controlled by TI LMU backlight driver. Only LM3695 specific code is implemented here. Cc: Jingoo Han <jingoohan1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Cc: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Signed-off-by: Milo Kim <milo.kim-l0cyMroinI0@public.gmane.org> --- drivers/video/backlight/Kconfig | 8 ++++ drivers/video/backlight/Makefile | 1 + drivers/video/backlight/lm3695_bl.c | 91 +++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 drivers/video/backlight/lm3695_bl.c diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index e3c4adb..c1dc908 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -426,6 +426,14 @@ config BACKLIGHT_LM3633 Up to 3 backlight strings and 11 bit dimming is supported. PWM brightness control is also supported. +config BACKLIGHT_LM3695 + tristate "Backlight driver for TI LM3695" + depends on BACKLIGHT_CLASS_DEVICE && MFD_TI_LMU + select TI_LMU_BACKLIGHT + help + Say Y to enable the backlight driver for TI LM3695. + Up to 2 backlight strings and 11 bit dimming is supported. + config TI_LMU_BACKLIGHT tristate "Backlight driver for TI LMU" depends on BACKLIGHT_LM3532 || BACKLIGHT_LM3631 || \ diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 364b854..af20285 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile @@ -43,6 +43,7 @@ obj-$(CONFIG_BACKLIGHT_LM3631) += lm3631_bl.o obj-$(CONFIG_BACKLIGHT_LM3632) += lm3632_bl.o obj-$(CONFIG_BACKLIGHT_LM3633) += lm3633_bl.o obj-$(CONFIG_BACKLIGHT_LM3639) += lm3639_bl.o +obj-$(CONFIG_BACKLIGHT_LM3695) += lm3695_bl.o obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o obj-$(CONFIG_BACKLIGHT_LP8788) += lp8788_bl.o diff --git a/drivers/video/backlight/lm3695_bl.c b/drivers/video/backlight/lm3695_bl.c new file mode 100644 index 0000000..fe47d00 --- /dev/null +++ b/drivers/video/backlight/lm3695_bl.c @@ -0,0 +1,91 @@ +/* + * TI LM3695 Backlight Driver + * + * Copyright 2015 Texas Instruments + * + * Author: Milo Kim <milo.kim-l0cyMroinI0@public.gmane.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/delay.h> +#include <linux/kernel.h> +#include <linux/mfd/ti-lmu.h> +#include <linux/mfd/ti-lmu-register.h> +#include <linux/module.h> + +#include "ti-lmu-backlight.h" + +#define LM3695_FULL_STRINGS (LMU_HVLED1 | LMU_HVLED2) +#define LM3695_MAX_BRIGHTNESS 2047 + +static int lm3695_bl_enable(struct ti_lmu_bl *lmu_bl, int enable) +{ + int ret; + + ret = ti_lmu_update_bits(lmu_bl->chip->lmu, LM3695_REG_GP, + LM3695_BL_EN_MASK, enable); + if (ret) + return ret; + + /* Wait time for brightness register wake up */ + usleep_range(600, 700); + + return 0; +} + +static int lm3695_bl_set_brightness(struct ti_lmu_bl *lmu_bl, int brightness) +{ + u8 data; + int ret; + + data = brightness & LM3695_BRT_LSB_MASK; + ret = ti_lmu_update_bits(lmu_bl->chip->lmu, LM3695_REG_BRT_LSB, + LM3695_BRT_LSB_MASK, data); + if (ret) + return ret; + + data = (brightness >> LM3695_BRT_MSB_SHIFT) & 0xFF; + return ti_lmu_write_byte(lmu_bl->chip->lmu, LM3695_REG_BRT_MSB, + data); +} + +static int lm3695_bl_init(struct ti_lmu_bl_chip *chip) +{ + return ti_lmu_update_bits(chip->lmu, LM3695_REG_GP, + LM3695_BRT_RW_MASK, LM3695_BRT_RW_MASK); +} + +static int lm3695_bl_configure(struct ti_lmu_bl *lmu_bl) +{ + u8 val; + + if (lmu_bl->bl_string == LM3695_FULL_STRINGS) + val = LM3695_BL_TWO_STRINGS; + else + val = LM3695_BL_ONE_STRING; + + return ti_lmu_update_bits(lmu_bl->chip->lmu, LM3695_REG_GP, + LM3695_BL_STRING_MASK, val); +} + +static const struct ti_lmu_bl_ops lm3695_lmu_ops = { + .init = lm3695_bl_init, + .configure = lm3695_bl_configure, + .update_brightness = lm3695_bl_set_brightness, + .bl_enable = lm3695_bl_enable, + .max_brightness = LM3695_MAX_BRIGHTNESS, +}; + +/* LM3695 backlight of_device_id */ +TI_LMU_BL_OF_DEVICE(lm3695, "ti,lm3695-backlight"); + +/* LM3695 backlight platform driver */ +TI_LMU_BL_PLATFORM_DRIVER(lm3695, "lm3695-backlight"); + +MODULE_DESCRIPTION("TI LM3695 Backlight Driver"); +MODULE_AUTHOR("Milo Kim"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:lm3695-backlight"); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-11-02 5:26 UTC|newest] Thread overview: 99+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-11-02 5:24 [PATCH RESEND 00/16] Support TI LMU devices Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-02 5:24 ` [PATCH RESEND 01/16] Documentation: dt-bindings: mfd: add TI LMU device binding information Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-06 2:00 ` Rob Herring 2015-11-11 9:49 ` Lee Jones 2015-11-12 0:05 ` Kim, Milo 2015-11-12 0:05 ` Kim, Milo 2015-11-02 5:24 ` [PATCH RESEND 02/16] Documentation: dt-bindings: backlight: add TI LMU backlight " Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-02 15:02 ` Rob Herring 2015-11-03 7:13 ` Kim, Milo 2015-11-03 15:32 ` Rob Herring 2015-11-02 5:24 ` [PATCH RESEND 03/16] Documentation: dt-bindings: hwmon: add TI LMU HWMON " Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-06 1:57 ` Rob Herring 2015-11-06 1:57 ` Rob Herring 2015-11-06 3:48 ` Kim, Milo 2015-11-06 3:48 ` Kim, Milo [not found] ` <1446441875-1256-1-git-send-email-milo.kim-l0cyMroinI0@public.gmane.org> 2015-11-02 5:24 ` [PATCH RESEND 04/16] Documentation: dt-bindings: leds: add LM3633 LED " Milo Kim 2015-11-02 5:24 ` Milo Kim [not found] ` <1446441875-1256-5-git-send-email-milo.kim-l0cyMroinI0@public.gmane.org> 2015-11-03 16:15 ` Jacek Anaszewski 2015-11-03 16:15 ` Jacek Anaszewski 2015-11-10 7:01 ` Kim, Milo 2015-11-10 7:01 ` Kim, Milo 2015-11-02 5:24 ` [PATCH RESEND 05/16] Documentation: dt-bindings: regulator: add LM363x regulator " Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-02 5:24 ` [PATCH RESEND 06/16] mfd: add TI LMU driver Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-23 10:30 ` Lee Jones 2015-11-24 2:35 ` Kim, Milo 2015-11-24 2:35 ` Kim, Milo 2015-11-24 6:39 ` Kim, Milo 2015-11-24 6:39 ` Kim, Milo 2015-11-24 8:18 ` Lee Jones 2015-11-25 8:10 ` Kim, Milo 2015-11-25 8:10 ` Kim, Milo [not found] ` <56556D01.9070804-l0cyMroinI0@public.gmane.org> 2015-11-25 8:15 ` Lee Jones 2015-11-25 8:15 ` Lee Jones 2015-11-02 5:24 ` [PATCH RESEND 07/16] backlight: add TI LMU backlight common driver Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-02 5:24 ` [PATCH RESEND 08/16] backlight: ti-lmu-backlight: add LM3532 driver Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-02 5:37 ` kbuild test robot 2015-11-02 5:37 ` kbuild test robot 2015-11-02 7:33 ` Kim, Milo 2015-11-02 7:33 ` Kim, Milo 2015-11-02 5:24 ` [PATCH RESEND 09/16] backlight: ti-lmu-backlight: add LM3631 driver Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-02 5:24 ` [PATCH RESEND 10/16] backlight: ti-lmu-backlight: add LM3632 driver Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-02 5:24 ` [PATCH RESEND 11/16] backlight: ti-lmu-backlight: add LM3633 driver Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-02 5:24 ` Milo Kim [this message] 2015-11-02 5:24 ` [PATCH RESEND 12/16] backlight: ti-lmu-backlight: add LM3695 driver Milo Kim 2015-11-02 5:24 ` [PATCH RESEND 13/16] backlight: ti-lmu-backlight: add LM3697 driver Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-02 5:24 ` [PATCH RESEND 14/16] hwmon: add TI LMU hardware fault monitoring driver Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-02 14:27 ` Guenter Roeck 2015-11-02 14:27 ` Guenter Roeck 2015-11-03 7:01 ` Kim, Milo 2015-11-03 7:01 ` Kim, Milo 2015-11-02 5:24 ` [PATCH RESEND 15/16] leds: add LM3633 driver Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-03 16:15 ` Jacek Anaszewski [not found] ` <5638DD99.9070502-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 2015-11-10 7:38 ` Kim, Milo 2015-11-10 7:38 ` Kim, Milo 2015-11-10 13:44 ` Jacek Anaszewski [not found] ` <5641F4D3.7000800-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 2015-11-11 2:16 ` Kim, Milo 2015-11-11 2:16 ` Kim, Milo 2015-11-12 9:04 ` Jacek Anaszewski 2015-11-20 9:22 ` Jacek Anaszewski 2015-11-22 23:40 ` Kim, Milo 2015-11-22 23:40 ` Kim, Milo [not found] ` <56525262.60308-l0cyMroinI0@public.gmane.org> 2015-11-23 11:17 ` Jacek Anaszewski 2015-11-23 11:17 ` Jacek Anaszewski 2015-11-02 5:24 ` [PATCH RESEND 16/16] regulator: add LM363X driver Milo Kim 2015-11-02 5:24 ` Milo Kim 2015-11-02 12:26 ` Mark Brown 2015-11-03 6:59 ` Kim, Milo 2015-11-03 6:59 ` Kim, Milo 2015-11-04 13:59 ` Mark Brown 2015-11-10 7:54 ` Kim, Milo 2015-11-10 7:54 ` Kim, Milo 2015-11-02 8:59 ` [PATCH RESEND 00/16] Support TI LMU devices Lee Jones 2015-11-02 8:59 ` Lee Jones 2015-11-03 6:52 ` Kim, Milo 2015-11-03 6:52 ` Kim, Milo 2015-11-03 8:33 ` Lee Jones 2015-11-03 9:08 ` Kim, Milo 2015-11-03 9:08 ` Kim, Milo 2015-11-25 8:51 ` Kim, Milo 2015-11-25 8:51 ` Kim, Milo 2015-11-25 9:05 ` Lee Jones 2015-11-02 9:00 ` Lee Jones 2015-11-03 6:56 ` Kim, Milo 2015-11-03 6:56 ` Kim, Milo 2015-11-03 8:35 ` Lee Jones
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1446441875-1256-13-git-send-email-milo.kim@ti.com \ --to=milo.kim@ti.com \ --cc=devicetree@vger.kernel.org \ --cc=jingoohan1@gmail.com \ --cc=lee.jones@linaro.org \ --cc=linux-kernel@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.