mac80211: update to wireless-testing 2011-04-06
[openwrt.git] / package / mac80211 / patches / 620-rt2x00_soc_led_support.patch
1 --- a/drivers/net/wireless/rt2x00/rt2800lib.c
2 +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
3 @@ -938,6 +938,7 @@ EXPORT_SYMBOL_GPL(rt2800_rfkill_poll);
4 static void rt2800_brightness_set(struct led_classdev *led_cdev,
5 enum led_brightness brightness)
6 {
7 + u32 reg;
8 struct rt2x00_led *led =
9 container_of(led_cdev, struct rt2x00_led, led_dev);
10 unsigned int enabled = brightness != LED_OFF;
11 @@ -950,24 +951,46 @@ static void rt2800_brightness_set(struct
12 rt2x00_get_field16(led->rt2x00dev->led_mcu_reg,
13 EEPROM_FREQ_LED_MODE);
14
15 - if (led->type == LED_TYPE_RADIO) {
16 - rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
17 - enabled ? 0x20 : 0);
18 - } else if (led->type == LED_TYPE_ASSOC) {
19 - rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
20 - enabled ? (bg_mode ? 0x60 : 0xa0) : 0x20);
21 - } else if (led->type == LED_TYPE_QUALITY) {
22 - /*
23 - * The brightness is divided into 6 levels (0 - 5),
24 - * The specs tell us the following levels:
25 - * 0, 1 ,3, 7, 15, 31
26 - * to determine the level in a simple way we can simply
27 - * work with bitshifting:
28 - * (1 << level) - 1
29 - */
30 - rt2800_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff,
31 - (1 << brightness / (LED_FULL / 6)) - 1,
32 - polarity);
33 + /* Check for SoC (SOC devices don't support MCU requests) */
34 + if (rt2x00_is_soc(led->rt2x00dev)) {
35 + rt2800_register_read(led->rt2x00dev, LED_CFG, &reg);
36 +
37 + /* Set LED Polarity */
38 + rt2x00_set_field32(&reg, LED_CFG_LED_POLAR, polarity);
39 +
40 + /* Set LED Mode */
41 + if (led->type == LED_TYPE_RADIO) {
42 + rt2x00_set_field32(&reg, LED_CFG_G_LED_MODE,
43 + enabled ? 3 : 0);
44 + } else if (led->type == LED_TYPE_ASSOC) {
45 + rt2x00_set_field32(&reg, LED_CFG_Y_LED_MODE,
46 + enabled ? 3 : 0);
47 + } else if (led->type == LED_TYPE_QUALITY) {
48 + rt2x00_set_field32(&reg, LED_CFG_R_LED_MODE,
49 + enabled ? 3 : 0);
50 + }
51 + rt2800_register_write(led->rt2x00dev, LED_CFG, reg);
52 + }
53 + else {
54 + if (led->type == LED_TYPE_RADIO) {
55 + rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
56 + enabled ? 0x20 : 0);
57 + } else if (led->type == LED_TYPE_ASSOC) {
58 + rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
59 + enabled ? (bg_mode ? 0x60 : 0xa0) : 0x20);
60 + } else if (led->type == LED_TYPE_QUALITY) {
61 + /*
62 + * The brightness is divided into 6 levels (0 - 5),
63 + * The specs tell us the following levels:
64 + * 0, 1 ,3, 7, 15, 31
65 + * to determine the level in a simple way we can simply
66 + * work with bitshifting:
67 + * (1 << level) - 1
68 + */
69 + rt2800_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff,
70 + (1 << brightness / (LED_FULL / 6)) - 1,
71 + polarity);
72 + }
73 }
74 }
75
This page took 0.045894 seconds and 5 git commands to generate.