This repository has been archived on 2025-06-06. You can view files and clone it, but cannot push or open issues or pull requests.
Files
android-g900/kernel-2.6.33/arch/arm/mach-pxa/g900/g900_leds.c

199 lines
4.0 KiB
C
Executable File
Raw Blame History

/*
* Led driver for Toshiba G900
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach-types.h>
#include <mach/hardware.h>
#include <mach/mfp-pxa27x.h>
#include <mach/pxa2xx-regs.h>
#include <mach/g900-gpio.h>
#include <linux/platform_device.h>
#include <mach/gpio.h>
#include <asm/gpio.h>
#include <linux/leds.h>
#include "../generic.h"
#ifdef CONFIG_ANDROID_TIMED_GPIO
#include <linux/timed_gpio.h>
#endif
/***********************************************/
/************** Leds and vibrator **************/
/***********************************************/
static struct gpio_led gpio_leds[] = {
#ifndef CONFIG_ANDROID_TIMED_GPIO
{
.gpio = GPIO16_LED_nVibra,
.name = "vibrator",
.active_low = 0,
.default_trigger = "none"
},
{
.gpio = GPIO37_LED_nFlash,
.name = "flash",
.active_low = 0,
.default_trigger = "none"
},
#endif
{
.gpio = GPIO85_LED_nKeyboard,
.name = "keyboard-backlight",
.active_low = 0,
.default_trigger = "none"
},
{
.gpio = GPIO86_LED_nKeypad,
.name = "button-backlight",
.active_low = 0,
.default_trigger = "none"
},
};
#ifdef CONFIG_ANDROID_TIMED_GPIO
static struct timed_gpio timed_gpio_cnf[] = {
{
.gpio = GPIO16_LED_nVibra,
.name = "vibrator",
.active_low = 0,
.max_timeout = 4000,
},
{
.gpio = GPIO37_LED_nFlash,
.name = "flash",
.active_low = 0,
.max_timeout = 4000,
},
};
static struct timed_gpio_platform_data g900_timed_gpio_data = {
.gpios = timed_gpio_cnf,
.num_gpios = ARRAY_SIZE(timed_gpio_cnf),
};
static struct platform_device g900_timed_gpio = {
.name = "timed-gpio",
.id = -1,
.dev = {
.platform_data = &g900_timed_gpio_data,
}
};
#endif
static struct gpio_led_platform_data g900_gpio_leds_data = {
.leds = gpio_leds,
.num_leds = ARRAY_SIZE(gpio_leds),
};
static struct platform_device g900_gpio_leds = {
.name = "leds-gpio",
.id = -1,
.dev = {
.platform_data = &g900_gpio_leds_data,
}
};
/***********************************************/
/**************** Backlight LCD ****************/
/***********************************************/
#if 0
/**
Legacy backlight support
*/
#include <linux/pwm_backlight.h>
static struct platform_pwm_backlight_data g900_backlight_data = {
.pwm_id = 1,
.max_brightness = 100,
.dft_brightness = 75,
.pwm_period_ns = 861280, /* 76.9 ns * 64 * 175 */
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? <20> <20><> <20><><EFBFBD> 30% <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>*/
};
static struct platform_device g900_backlight = {
.name = "pwm-backlight",
.dev = {
.parent = &pxa27x_device_pwm1.dev,
.platform_data = &g900_backlight_data,
},
};
#else
/**
Android backlight support
*/
#include <linux/leds_pwm.h>
static struct led_pwm g900_pwm_leds[] __initdata = {
{
.name = "lcd-backlight",
.pwm_id = 1,
.max_brightness = 255,
.pwm_period_ns = 861280, /* 76.9 ns * 64 * 175 */
.default_trigger= "none",
.active_low = 0,
},
};
static struct led_pwm_platform_data g900_backlight_data = {
.num_leds = 1,
.leds = g900_pwm_leds,
};
static struct platform_device g900_lcd_backlight = {
.name = "leds_pwm",
.dev = {
.platform_data = &g900_backlight_data,
},
};
#endif
static struct platform_device *g900_leds[] __initdata = {
&g900_gpio_leds,
&g900_lcd_backlight,
#ifdef CONFIG_ANDROID_TIMED_GPIO
&g900_timed_gpio, /* BUG !*/
#endif
};
static int __init g900_leds_init (void)
{
if (!machine_is_g900())
return -ENODEV;
return platform_add_devices(ARRAY_AND_SIZE(g900_leds));
}
static void __exit g900_leds_exit (void)
{
}
module_init(g900_leds_init);
module_exit(g900_leds_exit);
MODULE_AUTHOR ("Angell Fear <angell@angellfear.ru>");
MODULE_DESCRIPTION ("Leds support for Toshiba G900");
MODULE_LICENSE ("GPL");