summaryrefslogtreecommitdiff
path: root/target/linux/s3c24xx/patches-2.6.26/1013-gta01-backlight.patch.patch
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/s3c24xx/patches-2.6.26/1013-gta01-backlight.patch.patch')
-rwxr-xr-xtarget/linux/s3c24xx/patches-2.6.26/1013-gta01-backlight.patch.patch308
1 files changed, 308 insertions, 0 deletions
diff --git a/target/linux/s3c24xx/patches-2.6.26/1013-gta01-backlight.patch.patch b/target/linux/s3c24xx/patches-2.6.26/1013-gta01-backlight.patch.patch
new file mode 100755
index 0000000..df13abd
--- /dev/null
+++ b/target/linux/s3c24xx/patches-2.6.26/1013-gta01-backlight.patch.patch
@@ -0,0 +1,308 @@
+From deee418974cd5cc3b1aa9b1329d91b50f8bb7baf Mon Sep 17 00:00:00 2001
+From: mokopatches <mokopatches@openmoko.org>
+Date: Wed, 16 Jul 2008 14:44:49 +0100
+Subject: [PATCH] gta01-backlight.patch
+ This is a backlight driver for the FIC/OpenMoko Neo1973 GTA01 GSM Phone
+
+Signed-off-by: Harald Welte <laforge@openmoko.org>
+---
+ drivers/video/backlight/Kconfig | 7 +
+ drivers/video/backlight/Makefile | 1 +
+ drivers/video/backlight/gta01_bl.c | 255 ++++++++++++++++++++++++++++++++++++
+ 3 files changed, 263 insertions(+), 0 deletions(-)
+ create mode 100644 drivers/video/backlight/gta01_bl.c
+
+diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
+index dcd8073..475db76 100644
+--- a/drivers/video/backlight/Kconfig
++++ b/drivers/video/backlight/Kconfig
+@@ -89,6 +89,13 @@ config BACKLIGHT_OMAP1
+ the PWL module of OMAP1 processors. Say Y if your board
+ uses this hardware.
+
++config BACKLIGHT_GTA01
++ tristate "FIC Neo1973 GTA01 Backlight Driver"
++ depends on BACKLIGHT_CLASS_DEVICE && MACH_NEO1973_GTA01
++ default y
++ help
++ If you have a FIC Neo1973 GTA01, say y to enable the backlight driver.
++
+ config BACKLIGHT_HP680
+ tristate "HP Jornada 680 Backlight Driver"
+ depends on BACKLIGHT_CLASS_DEVICE && SH_HP6XX
+diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
+index 33f6c7c..aee9f46 100644
+--- a/drivers/video/backlight/Makefile
++++ b/drivers/video/backlight/Makefile
+@@ -5,6 +5,7 @@ obj-$(CONFIG_LCD_LTV350QV) += ltv350qv.o
+
+ obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
+ obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o
++obj-$(CONFIG_BACKLIGHT_GTA01) += gta01_bl.o
+ obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
+ obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
+ obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
+diff --git a/drivers/video/backlight/gta01_bl.c b/drivers/video/backlight/gta01_bl.c
+new file mode 100644
+index 0000000..c2bf0c9
+--- /dev/null
++++ b/drivers/video/backlight/gta01_bl.c
+@@ -0,0 +1,255 @@
++/*
++ * Backlight Driver for FIC GTA01 (Neo1973) GSM Phone
++ *
++ * Copyright (C) 2006-2007 by OpenMoko, Inc.
++ * Author: Harald Welte <laforge@openmoko.org>
++ * All rights reserved.
++ *
++ * based on corgi_cl.c, Copyright (c) 2004-2006 Richard Purdie
++ *
++ * 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 in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; 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
++ *
++ * Javi Roman <javiroman@kernel-labs.org>:
++ * implement PWM, instead of simple on/off switching
++ *
++ */
++
++#include <linux/module.h>
++#include <linux/kernel.h>
++#include <linux/init.h>
++#include <linux/platform_device.h>
++#include <linux/mutex.h>
++#include <linux/fb.h>
++#include <linux/backlight.h>
++#include <linux/clk.h>
++
++#include <asm/arch/hardware.h>
++#include <asm/arch/gta01.h>
++#include <asm/arch/pwm.h>
++
++#include <asm/plat-s3c/regs-timer.h>
++
++static struct backlight_properties gta01bl_prop;
++static struct backlight_device *gta01_backlight_device;
++static struct gta01bl_machinfo *bl_machinfo;
++
++static unsigned long gta01bl_flags;
++
++struct gta01bl_data {
++ int intensity;
++ struct mutex mutex;
++ struct clk *clk;
++ struct s3c2410_pwm pwm;
++};
++
++static struct gta01bl_data gta01bl;
++
++#define GTA01BL_SUSPENDED 0x01
++#define GTA01BL_BATTLOW 0x02
++
++/* On the GTA01 / Neo1973, we use a 50 or 66MHz PCLK, which gives
++ * us a 6.25..8.25MHz DIV8 clock, which is further divided by a
++ * prescaler of 4, resulting in a 1.56..2.06MHz tick. This results in a
++ * minimum frequency of 24..31Hz. At 400Hz, we need to set the count
++ * to something like 3906..5156, providing us a way sufficient resolution
++ * for display brightness adjustment. */
++#define GTA01BL_COUNTER 5156
++
++static int gta01bl_send_intensity(struct backlight_device *bd)
++{
++ int intensity = bd->props.brightness;
++
++ if (bd->props.power != FB_BLANK_UNBLANK)
++ intensity = 0;
++ if (bd->props.fb_blank != FB_BLANK_UNBLANK)
++ intensity = 0;
++ if (gta01bl_flags & GTA01BL_SUSPENDED)
++ intensity = 0;
++ if (gta01bl_flags & GTA01BL_BATTLOW)
++ intensity &= bl_machinfo->limit_mask;
++
++ mutex_lock(&gta01bl.mutex);
++#ifdef GTA01_BACKLIGHT_ONOFF_ONLY
++ if (intensity)
++ s3c2410_gpio_setpin(GTA01_GPIO_BACKLIGHT, 1);
++ else
++ s3c2410_gpio_setpin(GTA01_GPIO_BACKLIGHT, 0);
++#else
++ if (intensity == bd->props.max_brightness) {
++ s3c2410_gpio_setpin(GTA01_GPIO_BACKLIGHT, 1);
++ s3c2410_gpio_cfgpin(GTA01_GPIO_BACKLIGHT, S3C2410_GPIO_OUTPUT);
++ } else {
++ s3c2410_pwm_duty_cycle(intensity & 0xffff, &gta01bl.pwm);
++ s3c2410_gpio_cfgpin(GTA01_GPIO_BACKLIGHT, S3C2410_GPB0_TOUT0);
++ }
++#endif
++ mutex_unlock(&gta01bl.mutex);
++
++ gta01bl.intensity = intensity;
++ return 0;
++}
++
++static int gta01bl_init_hw(void)
++{
++ int rc;
++
++ rc = s3c2410_pwm_init(&gta01bl.pwm);
++ if (rc)
++ return rc;
++
++ gta01bl.pwm.timerid = PWM0;
++ gta01bl.pwm.prescaler = (4 - 1);
++ gta01bl.pwm.divider = S3C2410_TCFG1_MUX0_DIV8;
++ gta01bl.pwm.counter = GTA01BL_COUNTER;
++ gta01bl.pwm.comparer = gta01bl.pwm.counter;
++
++ rc = s3c2410_pwm_enable(&gta01bl.pwm);
++ if (rc)
++ return rc;
++
++ s3c2410_pwm_start(&gta01bl.pwm);
++
++ gta01bl_prop.max_brightness = gta01bl.pwm.counter;
++
++ return 0;
++}
++
++#ifdef CONFIG_PM
++static int gta01bl_suspend(struct platform_device *dev, pm_message_t state)
++{
++ gta01bl_flags |= GTA01BL_SUSPENDED;
++ gta01bl_send_intensity(gta01_backlight_device);
++ return 0;
++}
++
++static int gta01bl_resume(struct platform_device *dev)
++{
++ mutex_lock(&gta01bl.mutex);
++ gta01bl_init_hw();
++ mutex_unlock(&gta01bl.mutex);
++
++ gta01bl_flags &= ~GTA01BL_SUSPENDED;
++ gta01bl_send_intensity(gta01_backlight_device);
++ return 0;
++}
++#else
++#define gta01bl_suspend NULL
++#define gta01bl_resume NULL
++#endif
++
++static int gta01bl_get_intensity(struct backlight_device *bd)
++{
++ return gta01bl.intensity;
++}
++
++static int gta01bl_set_intensity(struct backlight_device *bd)
++{
++ gta01bl_send_intensity(gta01_backlight_device);
++ return 0;
++}
++
++/*
++ * Called when the battery is low to limit the backlight intensity.
++ * If limit==0 clear any limit, otherwise limit the intensity
++ */
++void gta01bl_limit_intensity(int limit)
++{
++ if (limit)
++ gta01bl_flags |= GTA01BL_BATTLOW;
++ else
++ gta01bl_flags &= ~GTA01BL_BATTLOW;
++ gta01bl_send_intensity(gta01_backlight_device);
++}
++EXPORT_SYMBOL_GPL(gta01bl_limit_intensity);
++
++
++static struct backlight_ops gta01bl_ops = {
++ .get_brightness = gta01bl_get_intensity,
++ .update_status = gta01bl_set_intensity,
++};
++
++static int __init gta01bl_probe(struct platform_device *pdev)
++{
++ struct gta01bl_machinfo *machinfo = pdev->dev.platform_data;
++ int rc;
++
++#ifdef GTA01_BACKLIGHT_ONOFF_ONLY
++ s3c2410_gpio_cfgpin(GTA01_GPIO_BACKLIGHT, S3C2410_GPIO_OUTPUT);
++ gta01bl_prop.max_brightness = 1;
++#else
++ rc = gta01bl_init_hw();
++ if (rc < 0)
++ return rc;
++#endif
++ mutex_init(&gta01bl.mutex);
++
++ if (!machinfo->limit_mask)
++ machinfo->limit_mask = -1;
++
++ gta01_backlight_device = backlight_device_register("gta01-bl",
++ &pdev->dev, NULL,
++ &gta01bl_ops);
++ if (IS_ERR(gta01_backlight_device))
++ return PTR_ERR(gta01_backlight_device);
++
++ gta01bl_prop.power = FB_BLANK_UNBLANK;
++ gta01bl_prop.brightness = gta01bl_prop.max_brightness;
++ memcpy(&gta01_backlight_device->props,
++ &gta01bl_prop, sizeof(gta01bl_prop));
++ gta01bl_send_intensity(gta01_backlight_device);
++
++ return 0;
++}
++
++static int gta01bl_remove(struct platform_device *dev)
++{
++#ifndef GTA01_BACKLIGHT_ONOFF_ONLY
++ s3c2410_pwm_disable(&gta01bl.pwm);
++#endif
++ backlight_device_unregister(gta01_backlight_device);
++ mutex_destroy(&gta01bl.mutex);
++
++ s3c2410_gpio_cfgpin(GTA01_GPIO_BACKLIGHT, S3C2410_GPIO_OUTPUT);
++ s3c2410_gpio_setpin(GTA01_GPIO_BACKLIGHT, 1);
++
++ return 0;
++}
++
++static struct platform_driver gta01bl_driver = {
++ .probe = gta01bl_probe,
++ .remove = gta01bl_remove,
++ .suspend = gta01bl_suspend,
++ .resume = gta01bl_resume,
++ .driver = {
++ .name = "gta01-bl",
++ },
++};
++
++static int __init gta01bl_init(void)
++{
++ return platform_driver_register(&gta01bl_driver);
++}
++
++static void __exit gta01bl_exit(void)
++{
++ platform_driver_unregister(&gta01bl_driver);
++}
++
++module_init(gta01bl_init);
++module_exit(gta01bl_exit);
++
++MODULE_DESCRIPTION("FIC GTA01 (Neo1973) Backlight Driver");
++MODULE_AUTHOR("Harald Welte <laforge@openmoko.org>");
++MODULE_LICENSE("GPL");
+--
+1.5.6.3
+