linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jiri.Pinkava@vscht.cz (Jiří Pinkava)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 6/6] n35: Add LCD backlight regulation
Date: Mon, 4 Oct 2010 02:32:08 +0200	[thread overview]
Message-ID: <4CA92088.4060806@vscht.cz> (raw)
In-Reply-To: <4CA92044.9010902@vscht.cz>


Signed-off-by: Jiri Pinkava <jiri.pinkava@vscht.cz>
---
  arch/arm/mach-s3c2410/mach-n30.c |   71 
++++++++++++++++++++++++++++++++++++++
  1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c2410/mach-n30.c 
b/arch/arm/mach-s3c2410/mach-n30.c
index be5235d..4199143 100644
--- a/arch/arm/mach-s3c2410/mach-n30.c
+++ b/arch/arm/mach-s3c2410/mach-n30.c
@@ -23,6 +23,7 @@
  #include <linux/input.h>
  #include <linux/interrupt.h>
  #include <linux/platform_device.h>
+#include <linux/pwm_backlight.h>
  #include <linux/serial_core.h>
  #include <linux/timer.h>
  #include <linux/io.h>
@@ -369,6 +370,74 @@ static struct s3c2410fb_mach_info n30_fb_info 
__initdata = {
  	.lpcsel		= 0x06,
  };

+static int n35_backlight_init(struct device *dev)
+{
+	int ret;
+
+	ret = gpio_request(S3C2410_GPB(0), "Backlight PWM output");
+	if (ret)
+		goto request_gpb0_fail;
+	ret = gpio_request(S3C2410_GPB(1), "Backlight power");
+	if (ret)
+		goto request_gpb1_fail;
+
+	/* set GPB0 as output of PWM timer */
+	gpio_set_value(S3C2410_GPB(0), 0);
+	s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_DOWN);
+	s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
+
+	/* backlight power */
+	ret = gpio_direction_output(S3C2410_GPB(1), 1);
+	if (ret)
+		goto direction_gpb1_fail;
+	s3c_gpio_setpull(S3C2410_GPB(1), S3C_GPIO_PULL_UP);
+
+	return 0;
+
+direction_gpb1_fail:
+	gpio_free(S3C2410_GPB(1));
+request_gpb1_fail:
+	gpio_free(S3C2410_GPB(0));
+request_gpb0_fail:
+	return ret;
+}
+
+static int n35_backlight_notify(struct device *dev, int brightness)
+{
+	/* power off backlight, values less than 14 are useless */
+	gpio_set_value(S3C2410_GPB(1), brightness > 14 ? 1 : 0);
+	return (brightness > 14 ? brightness : 0);
+}
+
+static void n35_backlight_exit(struct device *dev)
+{
+	gpio_direction_output(S3C2410_GPB(0), 0);
+	gpio_free(S3C2410_GPB(0));
+
+	gpio_set_value(S3C2410_GPB(1), 0);
+	s3c_gpio_setpull(S3C2410_GPB(1), S3C_GPIO_PULL_UP);
+	gpio_free(S3C2410_GPB(1));
+}
+
+static struct platform_pwm_backlight_data backlight_data = {
+	.pwm_id         = 0,
+	.max_brightness = 100,
+	.dft_brightness = 50,
+	.pwm_period_ns  = 3*1000*1000,
+	.init           = n35_backlight_init,
+	.notify         = n35_backlight_notify,
+	.exit           = n35_backlight_exit,
+};
+
+static struct platform_device n35_backlight = {
+	.name = "pwm-backlight",
+	.dev  = {
+		.parent = &s3c_device_timer[0].dev,
+		.platform_data = &backlight_data,
+	},
+	.id   = -1,
+};
+
  static void n30_sdi_set_power(unsigned char power_mode, unsigned short 
vdd)
  {
  	switch (power_mode) {
@@ -416,6 +485,8 @@ static struct platform_device *n35_devices[] 
__initdata = {
  	&s3c_device_sdi,
  	&s3c_device_adc,
  	&s3c_device_ts,
+	&s3c_device_timer[0],
+	&n35_backlight,
  	&n35_button_device,
  	&n35_blue_led,
  	&n35_warning_led,
-- 
1.7.3.1

  reply	other threads:[~2010-10-04  0:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-04  0:23 [PATCH 0/6] - Acer n35 fixes and features Jiří Pinkava
2010-10-04  0:24 ` [PATCH 1/6] n35: fix key codes and types Jiří Pinkava
2010-10-04  0:25   ` [PATCH 2/6] n35: Update GPIO documentation for Acer n35 Jiří Pinkava
2010-10-04  0:26     ` PATCH 3/6] n30: Clean up UARTs configuration Jiří Pinkava
2010-10-04  0:29       ` [PATCH 4/6] n30: Fix MMC power management Jiří Pinkava
2010-10-04  0:31         ` [PATCH 5/6] n30: Add touchscreen support for Ace n35 Jiří Pinkava
2010-10-04  0:32           ` Jiří Pinkava [this message]
2010-10-10 23:38   ` [PATCH 1/6] n35: fix key codes and types Ben Dooks
2010-10-13  7:49     ` Jiří Pinkava
2010-10-06 22:25 ` [PATCH 0/6] - Acer n35 fixes and features Ben Dooks
2010-10-10 23:43 ` Ben Dooks
2010-10-13  7:56 ` [PATCH 1/6] n35: fix key codes Jiri.Pinkava at vscht.cz
2010-10-13  7:56 ` [PATCH 2/6] n35: Update GPIO documentation for Acer n35 Jiri.Pinkava at vscht.cz
2010-10-13  7:56 ` [PATCH 3/6] n30: Clean up UARTs configuration Jiri.Pinkava at vscht.cz
2010-10-13  7:56 ` [PATCH 4/6] n30: Fix MMC power management on Acer n30 / n35 Jiri.Pinkava at vscht.cz
2010-10-13  7:56 ` [PATCH 5/6] n30: Add touchscreen support for " Jiri.Pinkava at vscht.cz
2010-10-13  7:56 ` [PATCH 6/6] n35: Add LCD backlight regulation on Acer n35 Jiri.Pinkava at vscht.cz

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=4CA92088.4060806@vscht.cz \
    --to=jiri.pinkava@vscht.cz \
    --cc=linux-arm-kernel@lists.infradead.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).