2010-09-04 09:07:44 +00:00
|
|
|
/* linux/arch/arm/mach-msm/board-htcleo-bkl.c
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010 Cotulla
|
2010-10-05 14:44:15 +00:00
|
|
|
* Copyright (c) 2010 Denis 'GNUtoo' Carikli
|
|
|
|
* Copyright (c) 2010 Lukas-David Gorris
|
2010-09-04 09:07:44 +00:00
|
|
|
*
|
|
|
|
* This software is licensed under the terms of the GNU General Public
|
|
|
|
* License version 2, as published by the Free Software Foundation, and
|
|
|
|
* may be copied, distributed, and modified under those terms.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/clk.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/wakelock.h>
|
2010-10-05 14:44:15 +00:00
|
|
|
#include <linux/backlight.h>
|
2010-09-04 09:07:44 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/mach-types.h>
|
|
|
|
#include <mach/msm_fb.h>
|
|
|
|
#include <linux/gpio.h>
|
|
|
|
#include <mach/msm_iomap.h>
|
2010-09-04 19:14:51 +00:00
|
|
|
#include <mach/atmega_microp.h>
|
2010-09-04 09:07:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
//#define DEBUG_LCM
|
|
|
|
#ifdef DEBUG_LCM
|
|
|
|
#define LCMDBG(fmt, arg...) printk(fmt, ## arg)
|
|
|
|
#else
|
|
|
|
#define LCMDBG(fmt, arg...) {}
|
|
|
|
#endif
|
|
|
|
|
2010-10-05 14:44:15 +00:00
|
|
|
|
|
|
|
#define HTCLEO_MAX_BRIGHTNESS 255
|
2010-09-04 09:07:44 +00:00
|
|
|
|
2010-09-04 19:14:51 +00:00
|
|
|
int htcleo_brightness_onoff_bkl(int enable)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
uint8_t data[1];
|
|
|
|
|
|
|
|
data[0] = enable ? 1 : 0;
|
|
|
|
ret = microp_i2c_write(MICROP_I2C_WCMD_BL_EN, data, 1);
|
|
|
|
if (ret != 0)
|
|
|
|
pr_err("%s: set failed\n", __func__);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int htcleo_brightness_set_bkl(uint8_t value)
|
|
|
|
{
|
|
|
|
int ret;
|
2010-10-16 08:50:05 +00:00
|
|
|
uint8_t cmd[2], data[2];
|
2010-09-04 19:14:51 +00:00
|
|
|
|
2010-10-15 09:14:52 +00:00
|
|
|
LCMDBG("microp_set_bkl(%d)\n", value);
|
2010-09-04 19:14:51 +00:00
|
|
|
|
|
|
|
if (value > 9)
|
|
|
|
{
|
|
|
|
value = 9;
|
|
|
|
}
|
2010-10-16 08:50:05 +00:00
|
|
|
// disable autobrigtness
|
|
|
|
// CotullaTEST: Lsensor test, add 0x100
|
|
|
|
// data[0] = 0;
|
|
|
|
data[0] = 1;
|
|
|
|
data[1] = 0;
|
|
|
|
ret = microp_i2c_write(MICROP_I2C_WCMD_AUTO_BL_CTL, data, 2); // 23
|
|
|
|
if (ret != 0)
|
|
|
|
pr_err("%s: set auto light sensor fail\n", __func__);
|
2010-09-04 19:14:51 +00:00
|
|
|
|
|
|
|
// setvalue
|
|
|
|
cmd[0] = value << 4;
|
2010-10-16 08:50:05 +00:00
|
|
|
// printk("22LEVEL %02X\n", cmd[0]);
|
2010-09-04 19:14:51 +00:00
|
|
|
ret = microp_i2c_write(MICROP_I2C_WCMD_LCM_BL_MANU_CTL, cmd, 1); // 22
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
pr_err("%s: request adc fail\n", __func__);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2010-09-04 09:07:44 +00:00
|
|
|
|
2010-10-05 14:44:15 +00:00
|
|
|
static struct led_trigger *htcleo_lcd_backlight;
|
|
|
|
|
|
|
|
|
|
|
|
int htcleo_brightness_set(struct backlight_device *bd)
|
2010-09-04 09:07:44 +00:00
|
|
|
{
|
2010-10-05 14:44:15 +00:00
|
|
|
int intensity;
|
|
|
|
intensity = bd->props.brightness;
|
|
|
|
|
|
|
|
// set brigtness level via MicroP
|
|
|
|
LCMDBG("htcleo_brightness_set: %d\n", intensity);
|
|
|
|
if (intensity > 255) intensity = 255;
|
|
|
|
if (intensity < 30)
|
|
|
|
{
|
|
|
|
htcleo_brightness_onoff_bkl(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
htcleo_brightness_onoff_bkl(1);
|
|
|
|
htcleo_brightness_set_bkl((intensity - 30) / 23);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2010-09-04 19:14:51 +00:00
|
|
|
|
2010-10-05 14:44:15 +00:00
|
|
|
static int htcleo_brightness_get(struct backlight_device *bd)
|
|
|
|
{
|
|
|
|
return bd->props.brightness;
|
2010-09-04 09:07:44 +00:00
|
|
|
}
|
|
|
|
|
2010-10-05 14:44:15 +00:00
|
|
|
static struct backlight_ops htcleo_backlight_ops =
|
2010-09-04 09:07:44 +00:00
|
|
|
{
|
2010-10-05 14:44:15 +00:00
|
|
|
.options = BL_CORE_SUSPENDRESUME,
|
|
|
|
.update_status = htcleo_brightness_set,
|
|
|
|
.get_brightness = htcleo_brightness_get,
|
2010-09-04 09:07:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-05 14:44:15 +00:00
|
|
|
|
|
|
|
static int htcleo_backlight_probe(struct platform_device *pdev)
|
2010-09-04 09:07:44 +00:00
|
|
|
{
|
2010-10-05 14:44:15 +00:00
|
|
|
struct backlight_device *bd;
|
|
|
|
bd = backlight_device_register("htcleo-backlight", &pdev->dev, NULL, &htcleo_backlight_ops);
|
|
|
|
bd->props.max_brightness = HTCLEO_MAX_BRIGHTNESS;
|
|
|
|
bd->props.brightness = HTCLEO_MAX_BRIGHTNESS;
|
|
|
|
htcleo_brightness_set(bd);
|
|
|
|
return 0;
|
2010-09-04 09:07:44 +00:00
|
|
|
}
|
|
|
|
|
2010-10-05 14:44:15 +00:00
|
|
|
static int htcleo_backlight_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct backlight_device *bl = platform_get_drvdata(pdev);
|
|
|
|
backlight_device_unregister(bl);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-09-04 09:07:44 +00:00
|
|
|
|
2010-10-05 14:44:15 +00:00
|
|
|
|
|
|
|
static struct platform_driver htcleo_backlight_driver =
|
2010-09-04 09:07:44 +00:00
|
|
|
{
|
2010-10-05 14:44:15 +00:00
|
|
|
.probe = htcleo_backlight_probe,
|
|
|
|
.remove = htcleo_backlight_remove,
|
|
|
|
.driver =
|
|
|
|
{
|
|
|
|
.name = "htcleo-backlight",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
};
|
2010-09-04 09:07:44 +00:00
|
|
|
|
|
|
|
|
2010-10-05 14:44:15 +00:00
|
|
|
static int __init htcleo_backlight_init(void)
|
2010-09-04 09:07:44 +00:00
|
|
|
{
|
2010-10-05 14:44:15 +00:00
|
|
|
return platform_driver_register(&htcleo_backlight_driver);
|
2010-09-04 09:07:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(htcleo_backlight_init);
|
|
|
|
|
2010-10-05 14:44:15 +00:00
|
|
|
// END OF FILE
|