| |
| #include <common.h> |
| #include <cpled.h> |
| #include <asm/arch-qcom-common/gpio.h> |
| #include <linux/time.h> |
| |
| static u8 led_pattern_enable; |
| const int speed = 200; |
| static int step = 0; |
| |
| const char* download_pattern[] = { |
| "1110", |
| "1101", |
| "1011", |
| "0111" |
| }; |
| const char* boot_pattern[] = { |
| "1100", // first LED is turned on by led_idlestate() |
| "1000", |
| "0000", |
| "0000" |
| }; |
| const char* write_pattern[] = { |
| "1110", |
| "1011", |
| "1101", |
| "0111" |
| }; |
| const char* count_pattern[] = { |
| "1100", |
| "1110", |
| "0000", |
| "1000", |
| }; |
| |
| const char* usb_pattern[] = { |
| "0011", |
| "1001", |
| "1100", |
| "0110", |
| }; |
| |
| void led_pattern_init(){ |
| tca6424a_setb_reg("xxxx1111 xxxxxxxx xxxxxxxx"); |
| led_pattern_enable = 1; |
| step = 0; |
| } |
| |
| void led_pattern_next(const char* steps[], int slow_factor){ |
| static int wait = 100; |
| char cmd[100]; |
| |
| if (!led_pattern_enable) |
| return; |
| |
| if (slow_factor != 0 && wait > 0) { |
| wait--; |
| return; |
| } |
| |
| wait = speed * slow_factor; |
| |
| sprintf(cmd, "xxxx%s xxxxxxxx xxxxxxxx", steps[step]); |
| tca6424a_setb_reg(cmd); |
| |
| step++; |
| if (step >= 4) |
| step = 0; |
| } |
| |
| void led_pattern_cleanup(){ |
| tca6424a_setb_reg("xxxx1111 xxxxxxxx xxxxxxxx"); |
| led_pattern_enable = 0; |
| step = 0; |
| } |
| |
| void led_ubootstate(){ |
| tca6424a_setb_reg("x1101111 11xxxxxx xxxxxxxx"); |
| } |
| void led_idlestate(){ |
| tca6424a_setb_reg("x1111110 11xxxxxx xxxxxxxx"); |
| } |
| |
| void led_sleepstate(){ |
| tca6424a_setb_reg("xxxxxxxx 01xxxxxx xxxxxxxx"); |
| gpio_set_value(66, 0); |
| gpio_set_value(67, 1); |
| } |
| |
| void led_resetstate(){ |
| printf("reset state\n"); |
| gpio_set_value(66, 0); |
| gpio_set_value(67, 0); |
| tca6424a_setb_reg("xxxxxxxx 00xxxxxx xxxxxxxx"); |
| udelay(500000); |
| gpio_set_value(66, 1); |
| gpio_set_value(67, 1); |
| tca6424a_setb_reg("xxxxxxxx 11xxxxxx xxxxxxxx"); |
| udelay(500000); |
| gpio_set_value(66, 0); |
| gpio_set_value(67, 0); |
| tca6424a_setb_reg("xxxxxxxx 00xxxxxx xxxxxxxx"); |
| udelay(500000); |
| gpio_set_value(66, 1); |
| gpio_set_value(67, 1); |
| tca6424a_setb_reg("xxxxxxxx 11xxxxxx xxxxxxxx"); |
| } |
| |
| |