summaryrefslogtreecommitdiff
path: root/packages/nonworking/atmelwlandriver/atmelwlandriver-3.4.1.0/power-on-and-leds.patch
blob: 0ac06f1482f434d714061d1fe6c191752ec660a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
diff -Nurd atmelwlandriver-3.4.1.0/src/usb/vnetusba.c atmelwlandriver-3.4.1.0-hh/src/usb/vnetusba.c
--- atmelwlandriver-3.4.1.0/src/usb/vnetusba.c	2005-12-02 10:25:21.946561154 -0800
+++ atmelwlandriver-3.4.1.0-hh/src/usb/vnetusba.c	2005-12-02 10:22:42.877486580 -0800
@@ -31,6 +31,12 @@
 #include "vnetioctl.h"
 #include "config.h"
 
+#ifdef CONFIG_ARCH_H5400
+#include <asm/mach-types.h>
+#include <asm/arch/ipaq.h>
+#include <asm/arch-pxa/h5400-asic.h>
+#endif
+
 struct usb_device_id __devinitdata vnet_usb_id[] =
 #if defined(RFMD)
     RFMD_DEVICES
@@ -151,6 +157,16 @@
 		dbgcond(DBG_STATE, "state change %d -> %d\n",
 			Adapter->StationState, State);
 	Adapter->StationState = State;
+
+#ifdef CONFIG_ARCH_H5400
+	if (machine_is_h5400()) {
+		if (State == STATION_STATE_READY) {
+			ipaq_led_off (RED_LED);
+		} else {
+			ipaq_led_blink (RED_LED, 1, 2);
+		}
+	}
+#endif
 }
 
 static int usb_vnet_open(struct net_device *dev)
@@ -221,6 +237,13 @@
 #endif
 #endif	// Linux v. < 2.5+
 
+#ifdef CONFIG_ARCH_H5400
+	if (machine_is_h5400()) {
+		ipaq_led_off (RED_LED);
+		ipaq_led_off (RED_LED_2);
+	}
+#endif
+
 	printk("Device %s closed\n", dev->name);
 	return 0;
 }
@@ -1926,6 +1949,32 @@
 	return 0;
 }
 
+#ifdef CONFIG_ARCH_H5400
+static struct timer_list led_timer;
+
+static void
+ipaq_clear_led (unsigned long time)
+{
+	ipaq_led_off (RED_LED_2);
+}
+
+static void
+ipaq_blink_led (void)
+{
+	ipaq_led_on (RED_LED_2);
+
+	mod_timer (&led_timer, jiffies + (HZ / 25));
+}
+
+static void
+ipaq_init_led (void)
+{
+	led_timer.function = ipaq_clear_led;
+
+	init_timer (&led_timer);
+}
+#endif /* CONFIG_ARCH_H5400*/
+
 static int usb_vnet_tx(struct sk_buff *skb, struct net_device *dev)
 {
 	PVNet_ADAPTER Adapter = (PVNet_ADAPTER) dev->priv;
@@ -1954,6 +2003,11 @@
 	if (Adapter->StationState != STATION_STATE_READY)
 		return -EAGAIN;
 
+#ifdef CONFIG_ARCH_H5400
+	if (machine_is_h5400())
+		ipaq_blink_led();
+#endif
+
 	len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
 
   Adapter->lock = SPIN_LOCK_UNLOCKED;
@@ -2080,6 +2134,10 @@
 		kfree(Adapter);
 		return RETERR;
 	}
+#ifdef CONFIG_ARCH_H5400
+	if (machine_is_h5400 ())
+		ipaq_init_led ();
+#endif
 #if (LINUX_VERSION_CODE > 0x020500)
         usb_set_intfdata(interface, Adapter);
 
@@ -2244,6 +2302,11 @@
 	Adapter->flags &= ~VNET_RUNNING;
 	Adapter->StationState = STATION_STATE_EXITING;
 
+#ifdef CONFIG_ARCH_H5400
+	if (machine_is_h5400())
+		del_timer(&led_timer);
+#endif
+
 	if (waitqueue_active(Adapter->ctrl_wait)) {
 		Adapter->flags |= WAKE_UP_WITH_ERROR;
 		wake_up_interruptible(Adapter->ctrl_wait);
@@ -2316,6 +2379,13 @@
 
 static int __init usb_vnet_init(void)
 {
+#ifdef CONFIG_ARCH_H5400
+	if (machine_is_h5400()) {
+		/* turn WLAN power on */
+		SET_H5400_ASIC_GPIO (GPB, RF_POWER_ON, 1);
+		SET_H5400_ASIC_GPIO (GPB, WLAN_POWER_ON, 1);
+	}
+#endif
 	return usb_register(&vnet_driver);
 }
 
@@ -2326,6 +2396,13 @@
 #endif
 	//printk("AtmelWlanDriver Is deregistered!\n");
 	usb_deregister(&vnet_driver);
+#ifdef CONFIG_ARCH_H5400
+	if (machine_is_h5400()) {
+		/* turn WLAN power off */
+		SET_H5400_ASIC_GPIO (GPB, RF_POWER_ON, 0);
+		SET_H5400_ASIC_GPIO (GPB, WLAN_POWER_ON, 0);
+	}
+#endif
 }
 
 /**************************************************************/