# # Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher # --- linux-2.6.16/arch/arm/mach-pxa/ezx.c~e680-leds-r0.patch 2006-06-06 17:14:06.000000000 +0200 +++ linux-2.6.16/arch/arm/mach-pxa/ezx.c 2006-06-06 17:23:14.000000000 +0200 @@ -357,6 +357,17 @@ .num_resources = ARRAY_SIZE(ezx_backlight_resources), }; +#ifdef CONFIG_PXA_EZX_E680 +/* + * E680 LEDs + */ +static struct platform_device e680led_device = { + .name = "e680-led", + .id = -1, +}; +#endif + + /* keyboard */ #if defined(CONFIG_PXA_EZX_V700) @@ -766,6 +777,9 @@ static struct platform_device *devices[] __initdata = { &ezx_bp_device, +#ifdef CONFIG_PXA_EZX_E680 + &e680led_device, +#endif }; static void __init --- linux-2.6.16/drivers/leds/Kconfig~e680-leds-r0.patch 2006-06-06 17:14:05.000000000 +0200 +++ linux-2.6.16/drivers/leds/Kconfig 2006-06-06 17:23:14.000000000 +0200 @@ -59,6 +59,13 @@ This option enables support for the LEDs on Sharp Zaurus SL-6000 series. +config LEDS_E680 + tristate "LED Support for the Motorola E680(i) GSM Phone" + depends LEDS_CLASS && PXA_EZX_E680 + help + This options enables support for the LEDs on the + Motorola E680(i) GSM Phone. + config LEDS_TRIGGER_TIMER tristate "LED Timer Trigger" depends LEDS_TRIGGERS --- linux-2.6.16/drivers/leds/Makefile~e680-leds-r0.patch 2006-06-06 17:14:05.000000000 +0200 +++ linux-2.6.16/drivers/leds/Makefile 2006-06-06 17:23:14.000000000 +0200 @@ -10,7 +10,8 @@ obj-$(CONFIG_LEDS_SPITZ) += leds-spitz.o obj-$(CONFIG_LEDS_IXP4XX) += leds-ixp4xx-gpio.o obj-$(CONFIG_LEDS_TOSA) += leds-tosa.o +obj-$(CONFIG_LEDS_E680) += leds-e680.o # LED Triggers obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o -obj-$(CONFIG_LEDS_TRIGGER_IDE_DISK) += ledtrig-ide-disk.o \ Kein Zeilenumbruch am Dateiende. +obj-$(CONFIG_LEDS_TRIGGER_IDE_DISK) += ledtrig-ide-disk.o --- /dev/null 2006-06-06 16:58:36.577045136 +0200 +++ linux-2.6.16/drivers/leds/leds-e680.c 2006-06-06 17:55:46.000000000 +0200 @@ -0,0 +1,307 @@ +/* + * EZX Platform LED Driver for the Motorola E680(i) GSM Phone + * + * Copyright 2006 Vanille-Media + * + * Author: Michael Lauer + * + * Based on the Motorola 2.4 leds-e680.c and leds-corgi.c by Richard Purdie + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//FIXME move defines to a common header file +#define IND_CNTL_R_BUL 46 +#define IND_CNTL_G_BUL 47 +#define SSP_PCAP_LED_MASK 0x000fffe0 +#define SSP_PCAP_LED_SHIFT 5 +#define GPIO_TC_MM_EN 99 + +static enum led_brightness old_red; +static enum led_brightness old_green; +static enum led_brightness old_blue; + +typedef struct { + unsigned char ind_GPIO_red; /*Indicator Red control GPIO 46: 0 active, 1 disactive*/ + unsigned char ind_GPIO_green; /*Indicator Green control GPIO 47: 0 active, 1 disactive*/ + unsigned char pcap_LEDR_en; /*pcap LEDR_EN bit value: 1 =Red LED(&Green) sink circuit enabled*/ + unsigned char pcap_LEDG_en; /*pcap LEDG_EN bit value:1 =Green(->Blue)LED sink circuit enabled*/ + unsigned char pcap_LEDR_CTRL; /* 4bits Sets the timing for the red(&Green) LED sink circuit*/ + unsigned char pcap_LEDG_CTRL; /* 4bits Sets the timing for the GREEN (->Blue) LED sink circuit*/ + unsigned char pcap_LEDR_I; /* 2 bits 00 3mA,01 4mA, 10 5mA, 11 9mA, sets the pulsed current level for LEDR*/ + unsigned char pcap_LEDG_I; /* 2 bits 00 3mA,01 4mA, 10 5mA, 11 9mA, sets the pulsed current level for LEDG*/ + unsigned char pcap_SKIP_on; /*1=The ON timing sequence defined by LEDx_CTRL is executed on every other cycle*/ +} PCAP2_LED_REGISTER_VALUE; + +const PCAP2_LED_REGISTER_VALUE led_register_value[]= +{ + /* on/off pulsepower timing intensity */ + {0x1,0x1, 0x0,0x0, 0x0,0x0, 0x0,0x0,0x0}, /* OFF */ + {0x0,0x1, 0x1,0x0, 0xc,0x0, 0x1,0x0,0x0}, /* RED */ + {0x1,0x0, 0x1,0x0, 0xc,0x0, 0x1,0x0,0x0}, /* GREEN */ + {0x0,0x0, 0x1,0x0, 0xc,0x0, 0x1,0x0,0x0}, /* ORANGE = RED + GREEN */ + {0x1,0x1, 0x0,0x1, 0x0,0xc, 0x0,0x0,0x0}, /* BLUE */ + {0x0,0x1, 0x1,0x1, 0xc,0xc, 0x1,0x0,0x0}, /* LIGHT_RED = RED + BLUE */ + {0x1,0x0, 0x1,0x1, 0xc,0xc, 0x1,0x0,0x0}, /* LIGHT_GREEN = GREEN + BLUE */ + {0x0,0x0, 0x1,0x1, 0xc,0xc, 0x1,0x0,0x0}, /* WHITE = RED + GREEN + BLUE */ +}; + +static void e680led_led_set( enum led_brightness red, enum led_brightness green, enum led_brightness blue ) +{ + printk( KERN_DEBUG "e680led_led_set: red=%d, green=%d, blue=%d", red, green, blue ); + unsigned int tempValue = 0; + unsigned int value = 0; + unsigned int stateIndex = 0; + unsigned char gpio_red, gpio_green, ledr_en, ledg_en, ledr_ctrl, ledg_ctrl, ledr_i, ledg_i,skip; + + stateIndex = ( ( blue << 2 ) | ( green << 1 ) | ( red ) ) & 0x7; + printk( KERN_DEBUG "LED stateIndex is %d", stateIndex ); + gpio_red = led_register_value[stateIndex].ind_GPIO_red & 0x1; + gpio_green = led_register_value[stateIndex].ind_GPIO_green & 0x1; + ledr_en = led_register_value[stateIndex].pcap_LEDR_en & 0x1; + ledg_en = led_register_value[stateIndex].pcap_LEDG_en & 0x1; + ledr_ctrl = led_register_value[stateIndex].pcap_LEDR_CTRL & 0xf; + ledg_ctrl = led_register_value[stateIndex].pcap_LEDG_CTRL & 0xf; + ledr_i = led_register_value[stateIndex].pcap_LEDR_I & 0x3; + ledg_i = led_register_value[stateIndex].pcap_LEDG_I & 0x3; + skip = led_register_value[stateIndex].pcap_SKIP_on & 0x1; + + /* disable LEDs */ + if( ezx_pcap_read(SSP_PCAP_ADJ_PERIPH_REGISTER,&tempValue) != SSP_PCAP_SUCCESS ) + { + printk( KERN_WARNING "LED PCAP Read Failed\n" ); + return; + } + tempValue &= (~SSP_PCAP_LED_MASK); + if( ezx_pcap_write(SSP_PCAP_ADJ_PERIPH_REGISTER,tempValue) != SSP_PCAP_SUCCESS ) + { + printk( KERN_WARNING "LED PCAP Write Failed (Clear Data)\n" ); + return; + } + + /* configure GPIOs as output */ + pxa_gpio_mode(IND_CNTL_R_BUL | GPIO_OUT); + pxa_gpio_mode(IND_CNTL_G_BUL | GPIO_OUT); + + //FIXME: Simplify this logic + if ( (gpio_green && gpio_red) ) + { + /*Disable Red & Green signal*/ + set_GPIO(IND_CNTL_R_BUL); /*IND_CNTL_R_BUL Low active*/ + PGSR(IND_CNTL_R_BUL) = PGSR(IND_CNTL_R_BUL) | GPIO_bit(IND_CNTL_R_BUL); + + clr_GPIO(IND_CNTL_G_BUL); /*IND_CNTL_G_BUL High active*/ + PGSR(IND_CNTL_G_BUL) = PGSR(IND_CNTL_G_BUL) & (~GPIO_bit(IND_CNTL_G_BUL)); + + printk( KERN_DEBUG "LED GPIO Green & Red Disable\n"); + } else if ( gpio_green && !gpio_red ) + { + /*Green Disable, Red Enable*/ + clr_GPIO(IND_CNTL_R_BUL); + PGSR(IND_CNTL_R_BUL) = PGSR(IND_CNTL_R_BUL) & (~GPIO_bit(IND_CNTL_R_BUL)); + + clr_GPIO(IND_CNTL_G_BUL); + PGSR(IND_CNTL_G_BUL) = PGSR(IND_CNTL_G_BUL) & (~GPIO_bit(IND_CNTL_G_BUL)); + + printk( KERN_DEBUG "LED GPIO Green Disable, Red Enable\n"); + } else if (gpio_red && !gpio_green ) + { + /*Red Disable, Green Enable*/ + set_GPIO(IND_CNTL_R_BUL); + PGSR(IND_CNTL_R_BUL) = PGSR(IND_CNTL_R_BUL) | GPIO_bit(IND_CNTL_R_BUL); + + set_GPIO(IND_CNTL_G_BUL); + PGSR(IND_CNTL_G_BUL) = PGSR(IND_CNTL_G_BUL) | GPIO_bit(IND_CNTL_G_BUL); + printk( KERN_DEBUG "LED GPIO Red Disable, Green Enable"); + }else + { + /*Red & Green enable*/ + clr_GPIO(IND_CNTL_R_BUL); + PGSR(IND_CNTL_R_BUL) = PGSR(IND_CNTL_R_BUL) & (~GPIO_bit(IND_CNTL_R_BUL)); + + set_GPIO(IND_CNTL_G_BUL); + PGSR(IND_CNTL_G_BUL) = PGSR(IND_CNTL_G_BUL) | GPIO_bit(IND_CNTL_G_BUL); + printk( KERN_DEBUG "LED GPIO Red & Green Enable\n"); + } + + /* Write PCAP LED Peripheral Control Register*/ + value = ( ledr_en | (ledg_en <<1) | (ledr_ctrl <<2) | (ledg_ctrl <<6) | + (ledr_i << 10) | (ledg_i <<12) | (skip <<14) ) & 0x7fff; + tempValue |= (value <dev, &e680_red_led); + if (ret < 0) + return ret; + + ret = led_classdev_register(&pdev->dev, &e680_green_led); + if (ret < 0) + led_classdev_unregister(&e680_red_led); + + ret = led_classdev_register(&pdev->dev, &e680_blue_led); + if (ret < 0) { + led_classdev_unregister(&e680_red_led); + led_classdev_unregister(&e680_green_led); + } + + ret = led_classdev_register(&pdev->dev, &e680_keypad_led); + if (ret < 0) { + led_classdev_unregister(&e680_red_led); + led_classdev_unregister(&e680_green_led); + led_classdev_unregister(&e680_blue_led); + } + return ret; +} + +static int e680led_remove(struct platform_device *pdev) +{ + led_classdev_unregister(&e680_red_led); + led_classdev_unregister(&e680_green_led); + led_classdev_unregister(&e680_blue_led); + led_classdev_unregister(&e680_keypad_led); + return 0; +} + +static struct platform_driver e680led_driver = { + .probe = e680led_probe, + .remove = e680led_remove, +#ifdef CONFIG_PM + .suspend = e680led_suspend, + .resume = e680led_resume, +#endif + .driver = { + .name = "e680-led", + }, +}; + +static int __init e680led_init(void) +{ + return platform_driver_register(&e680led_driver); +} + +static void __exit e680led_exit(void) +{ + e680led_led_set( 0, 0, 0 ); + platform_driver_unregister(&e680led_driver); +} + +module_init(e680led_init); +module_exit(e680led_exit); + +MODULE_AUTHOR("Michael Lauer "); +MODULE_DESCRIPTION("Motorola E680 LED driver"); +MODULE_LICENSE("GPL");