]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/bcm/led_control.h
50a6d7defd745a59ec7eb46445350458e112a925
[karo-tx-linux.git] / drivers / staging / bcm / led_control.h
1 #ifndef _LED_CONTROL_H
2 #define _LED_CONTROL_H
3
4 #define NUM_OF_LEDS                             4
5 #define DSD_START_OFFSET                        0x0200
6 #define EEPROM_VERSION_OFFSET                   0x020E
7 #define EEPROM_HW_PARAM_POINTER_ADDRESS         0x0218
8 #define EEPROM_HW_PARAM_POINTER_ADDRRES_MAP5    0x0220
9 #define GPIO_SECTION_START_OFFSET               0x03
10 #define COMPATIBILITY_SECTION_LENGTH            42
11 #define COMPATIBILITY_SECTION_LENGTH_MAP5       84
12 #define EEPROM_MAP5_MAJORVERSION                5
13 #define EEPROM_MAP5_MINORVERSION                0
14 #define MAX_NUM_OF_BLINKS                       10
15 #define NUM_OF_GPIO_PINS                        16
16 #define DISABLE_GPIO_NUM                        0xFF
17 #define EVENT_SIGNALED                          1
18 #define MAX_FILE_NAME_BUFFER_SIZE               100
19
20 #define TURN_ON_LED(GPIO, index) do {                                   \
21                 UINT gpio_val = GPIO;                                   \
22                 (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ?   \
23                         wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)) : \
24                         wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)); \
25         } while (0)
26
27 #define TURN_OFF_LED(GPIO, index)  do {                                 \
28                 UINT gpio_val = GPIO;                                   \
29                 (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ?   \
30                         wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)) : \
31                         wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)); \
32         } while (0)
33
34 #define B_ULONG32 unsigned long
35
36 typedef enum _LEDColors {
37         RED_LED         = 1,
38         BLUE_LED        = 2,
39         YELLOW_LED      = 3,
40         GREEN_LED       = 4
41 } LEDColors; /* Enumerated values of different LED types */
42
43 typedef enum LedEvents {
44         SHUTDOWN_EXIT           = 0x00,
45         DRIVER_INIT             = 0x1,
46         FW_DOWNLOAD             = 0x2,
47         FW_DOWNLOAD_DONE        = 0x4,
48         NO_NETWORK_ENTRY        = 0x8,
49         NORMAL_OPERATION        = 0x10,
50         LOWPOWER_MODE_ENTER     = 0x20,
51         IDLEMODE_CONTINUE       = 0x40,
52         IDLEMODE_EXIT           = 0x80,
53         LED_THREAD_INACTIVE     = 0x100,  /* Makes the LED thread Inactivce. It wil be equivallent to putting the thread on hold. */
54         LED_THREAD_ACTIVE       = 0x200,  /* Makes the LED Thread Active back. */
55         DRIVER_HALT             = 0xff
56 } LedEventInfo_t; /* Enumerated values of different driver states */
57
58 /*
59  * Structure which stores the information of different LED types
60  * and corresponding LED state information of driver states
61  */
62 typedef struct LedStateInfo_t {
63         unsigned char LED_Type; /* specify GPIO number - use 0xFF if not used */
64         unsigned char LED_On_State; /* Bits set or reset for different states */
65         unsigned char LED_Blink_State; /* Bits set or reset for blinking LEDs for different states */
66         unsigned char GPIO_Num;
67         unsigned char BitPolarity; /* To represent whether H/W is normal polarity or reverse polarity */
68 } LEDStateInfo, *pLEDStateInfo;
69
70 typedef struct _LED_INFO_STRUCT {
71         LEDStateInfo    LEDState[NUM_OF_LEDS];
72         bool            bIdleMode_tx_from_host; /* Variable to notify whether driver came out from idlemode due to Host or target */
73         bool            bIdle_led_off;
74         wait_queue_head_t       notify_led_event;
75         wait_queue_head_t       idleModeSyncEvent;
76         struct task_struct      *led_cntrl_threadid;
77         int             led_thread_running;
78         bool            bLedInitDone;
79
80 } LED_INFO_STRUCT, *PLED_INFO_STRUCT;
81
82 /* LED Thread state. */
83 #define BCM_LED_THREAD_DISABLED         0   /* LED Thread is not running. */
84 #define BCM_LED_THREAD_RUNNING_ACTIVELY 1   /* LED thread is running. */
85 #define BCM_LED_THREAD_RUNNING_INACTIVELY 2 /* LED thread has been put on hold */
86
87 #endif