diff options
author | John Crispin <john@openwrt.org> | 2007-12-13 21:00:03 +0000 |
---|---|---|
committer | John Crispin <john@openwrt.org> | 2007-12-13 21:00:03 +0000 |
commit | 4545e6f507249f6145e8d62e0d6a505c8bbf5f23 (patch) | |
tree | 9d219614f4a0cf90fa683d714e86d415fb5feea7 | |
parent | 31857f702b90c92c0b374e2ff05850657544c17d (diff) | |
download | upstream-4545e6f507249f6145e8d62e0d6a505c8bbf5f23.tar.gz upstream-4545e6f507249f6145e8d62e0d6a505c8bbf5f23.tar.bz2 upstream-4545e6f507249f6145e8d62e0d6a505c8bbf5f23.zip |
danube led cleanup
SVN-Revision: 9734
-rw-r--r-- | target/linux/danube/files/drivers/char/danube_led.c | 71 |
1 files changed, 56 insertions, 15 deletions
diff --git a/target/linux/danube/files/drivers/char/danube_led.c b/target/linux/danube/files/drivers/char/danube_led.c index 1f7dda9a69..ba53abfbf9 100644 --- a/target/linux/danube/files/drivers/char/danube_led.c +++ b/target/linux/danube/files/drivers/char/danube_led.c @@ -33,6 +33,48 @@ #include <asm/danube/danube_led.h> #include <asm/danube/danube_gptu.h> +#define LED_CONFIG 0x01 + +#define CONFIG_OPERATION_UPDATE_SOURCE 0x0001 +#define CONFIG_OPERATION_BLINK 0x0002 +#define CONFIG_OPERATION_UPDATE_CLOCK 0x0004 +#define CONFIG_OPERATION_STORE_MODE 0x0008 +#define CONFIG_OPERATION_SHIFT_CLOCK 0x0010 +#define CONFIG_OPERATION_DATA_OFFSET 0x0020 +#define CONFIG_OPERATION_NUMBER_OF_LED 0x0040 +#define CONFIG_OPERATION_DATA 0x0080 +#define CONFIG_OPERATION_MIPS0_ACCESS 0x0100 +#define CONFIG_DATA_CLOCK_EDGE 0x0200 + + +/* +* Data Type Used to Call ioctl +*/ +struct led_config_param { + unsigned long operation_mask; // Select operations to be performed + unsigned long led; // LED to change update source (LED or ADSL) + unsigned long source; // Corresponding update source (LED or ADSL) + unsigned long blink_mask; // LEDs to set blink mode + unsigned long blink; // Set to blink mode or normal mode + unsigned long update_clock; // Select the source of update clock + unsigned long fpid; // If FPI is the source of update clock, set the divider + // else if GPT is the source, set the frequency + unsigned long store_mode; // Set clock mode or single pulse mode for store signal + unsigned long fpis; // FPI is the source of shift clock, set the divider + unsigned long data_offset; // Set cycles to be inserted before data is transmitted + unsigned long number_of_enabled_led; // Total number of LED to be enabled + unsigned long data_mask; // LEDs to set value + unsigned long data; // Corresponding value + unsigned long mips0_access_mask; // LEDs to set access right + unsigned long mips0_access; // 1: the corresponding data is output from MIPS0, 0: MIPS1 + unsigned long f_data_clock_on_rising; // 1: data clock on rising edge, 0: data clock on falling edge +}; + + +extern int danube_led_set_blink(unsigned int, unsigned int); +extern int danube_led_set_data(unsigned int, unsigned int); +extern int danube_led_config(struct led_config_param *); + #define DATA_CLOCKING_EDGE FALLING_EDGE #define RISING_EDGE 0 #define FALLING_EDGE 1 @@ -808,37 +850,35 @@ static struct miscdevice led_miscdev = { int __init danube_led_init (void) { - int ret; + int ret = 0; struct led_config_param param = {0}; enable_led(); - /* - * Set default value to registers to turn off all LED light. - */ - *DANUBE_LED_AR = 0x0; - *DANUBE_LED_CPU0 = 0x0; - *DANUBE_LED_CPU1 = 0x0; - *DANUBE_LED_CON1 = 0x0; - *DANUBE_LED_CON0 = (0x80000000 | (DATA_CLOCKING_EDGE << 26)); + writel(0, DANUBE_LED_AR); + writel(0, DANUBE_LED_CPU0); + writel(0, DANUBE_LED_CPU1); + writel(0, DANUBE_LED_CON1); + writel((0x80000000 | (DATA_CLOCKING_EDGE << 26)), DANUBE_LED_CON0); disable_led(); sema_init(&led_sem, 0); ret = misc_register(&led_miscdev); - if ( ret == -EBUSY ) + if (ret == -EBUSY) { led_miscdev.minor = MISC_DYNAMIC_MINOR; ret = misc_register(&led_miscdev); } - if ( ret ) + + if (ret) { printk(KERN_ERR "led: can't misc_register\n"); - return ret; - } - else + goto out; + } else { printk(KERN_INFO "led: misc_register on minor = %d\n", led_miscdev.minor); + } module_id = THIS_MODULE ? (int)THIS_MODULE : ((MISC_MAJOR << 8) | led_miscdev.minor); @@ -886,7 +926,8 @@ danube_led_init (void) param.data = 1 << 5; danube_led_config(¶m); - return 0; +out: + return ret; } void __exit |